nucypher / nucypher-contracts

Ethereum contracts supporting TACo applications on the Threshold Network.
16 stars 11 forks source link

Add duration calculation for subscription based rituals #306

Closed theref closed 3 weeks ago

theref commented 3 weeks ago

If anyone wants to test it here is the command:

ape run initiate_ritual --network polygon:amoy:infura -d lynx -c GlobalAllowList -f BqETHSubscription -a 0x3B42d26E19FF860bC4dEbB920DD8caA53F93c600 --num-nodes 3

derekpierre commented 3 weeks ago

I can run it locally but get the following error:

  File "/Users/derek/Documents/Github/repos/forks/derek/nucypher-contracts/deployment/utils.py", line 198, in sample_nodes
    result = sorted(data["result"]["ursulas"], key=lambda x: x.lower())
                    ~~~~^^^^^^^^^^
KeyError: 'result'

Porter is returning a 400 because the duration calculated is negative:

{'error': 'duration must be a non-negative integer.', 'version': '3.7.0'}

The duration value used as a parameter is:

'duration': -2804636

Therefore, no results are returned.

As a side note, the sample_nodes(...) utility function could probably handle any errors from porter sampling better i.e. check the response status code before assuming that the call was successful.

theref commented 3 weeks ago

@derekpierre thank you! Ape seems happier today (i think there's something odd with ape-etherscan api urls for polygon testnets, I'm looking into it...) and I got the same error - it's happening because the subscription has already ended. I've added a check for this in https://github.com/nucypher/nucypher-contracts/pull/306/commits/2619079d5ec0b8916d856c9b70ee5babbb19ec51