Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

GlobalAllowList returns Panic error 0x11: when deauthorizing a not authorized address #292

Open
manumonti opened this issue Jul 15, 2024 · 1 comment
Assignees

Comments

@manumonti
Copy link
Member

If I try to deauthorize an address that either has never been authorized or has been authorized in the past but deauthorized later, the transaction returns

Panic error 0x11: Arithmetic operation results in underflow or overflow.

I used this code (web3.py):

tx = global_allow_list_contract.functions.deauthorize(
        ritual_id,
        encryptors_addresses,
    ).build_transaction(
        {
            "from": account.address,
            "nonce": nonce, # TODO: update nonce consequently
        }
    )

    signed_tx = w3.eth.account.sign_transaction(tx, private_key=PRIVATE_KEY)
    tx_hash = w3.eth.send_raw_transaction(signed_tx.rawTransaction)
    tx_receipt = w3.eth.wait_for_transaction_receipt(tx_hash)

Error log:

Traceback (most recent call last):
  File "/Users/manumonti/Projects/nucypher/nucypher-contracts/scripts/bqeth_subscription.py", line 222, in <module>
    remove_encryptors(global_allow_list_contract, account, nonce, encryptors, ritual_id)
  File "/Users/manumonti/Projects/nucypher/nucypher-contracts/scripts/bqeth_subscription.py", line 166, in remove_encryptors
    ).build_transaction(
      ^^^^^^^^^^^^^^^^^^
  File "/Users/manumonti/.pyenv/versions/3.11.6/envs/nucypher-contracts/lib/python3.11/site-packages/web3/contract/contract.py", line 356, in build_transaction
    return build_transaction_for_function(
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/Users/manumonti/.pyenv/versions/3.11.6/envs/nucypher-contracts/lib/python3.11/site-packages/web3/contract/utils.py", line 233, in build_transaction_for_function
    prepared_transaction = fill_transaction_defaults(w3, prepared_transaction)
                           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "cytoolz/functoolz.pyx", line 263, in cytoolz.functoolz.curry.__call__
  File "/Users/manumonti/.pyenv/versions/3.11.6/envs/nucypher-contracts/lib/python3.11/site-packages/web3/_utils/transactions.py", line 136, in fill_transaction_defaults
    default_val = default_getter(w3, transaction)
                  ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/Users/manumonti/.pyenv/versions/3.11.6/envs/nucypher-contracts/lib/python3.11/site-packages/web3/_utils/transactions.py", line 76, in <lambda>
    "gas": lambda w3, tx: w3.eth.estimate_gas(tx),
                          ^^^^^^^^^^^^^^^^^^^^^^^
  File "/Users/manumonti/.pyenv/versions/3.11.6/envs/nucypher-contracts/lib/python3.11/site-packages/web3/eth/eth.py", line 316, in estimate_gas
    return self._estimate_gas(transaction, block_identifier, state_override)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/Users/manumonti/.pyenv/versions/3.11.6/envs/nucypher-contracts/lib/python3.11/site-packages/web3/module.py", line 75, in caller
    result = w3.manager.request_blocking(
             ^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/Users/manumonti/.pyenv/versions/3.11.6/envs/nucypher-contracts/lib/python3.11/site-packages/web3/manager.py", line 330, in request_blocking
    return self.formatted_response(
           ^^^^^^^^^^^^^^^^^^^^^^^^
  File "/Users/manumonti/.pyenv/versions/3.11.6/envs/nucypher-contracts/lib/python3.11/site-packages/web3/manager.py", line 291, in formatted_response
    apply_error_formatters(error_formatters, response)
  File "/Users/manumonti/.pyenv/versions/3.11.6/envs/nucypher-contracts/lib/python3.11/site-packages/web3/manager.py", line 104, in apply_error_formatters
    formatted_resp = pipe(response, error_formatters)
                     ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "cytoolz/functoolz.pyx", line 680, in cytoolz.functoolz.pipe
  File "cytoolz/functoolz.pyx", line 655, in cytoolz.functoolz.c_pipe
  File "/Users/manumonti/.pyenv/versions/3.11.6/envs/nucypher-contracts/lib/python3.11/site-packages/web3/_utils/error_formatters_utils.py", line 157, in raise_contract_logic_error_on_revert
    _raise_contract_error(data)
  File "/Users/manumonti/.pyenv/versions/3.11.6/envs/nucypher-contracts/lib/python3.11/site-packages/web3/_utils/error_formatters_utils.py", line 115, in _raise_contract_error
    raise ContractPanicError(
web3.exceptions.ContractPanicError: ('Panic error 0x11: Arithmetic operation results in underflow or overflow.', '0x4e487b710000000000000000000000000000000000000000000000000000000000000011')
@cygnusv
Copy link
Member

cygnusv commented Jul 15, 2024

oh this is a great find! There's not enough checks in EncryptorSlotsSubscription.beforeSetAuthorization().

vzotova added a commit to vzotova/nucypher-contracts that referenced this issue Jul 15, 2024
@vzotova vzotova mentioned this issue Jul 15, 2024
7 tasks
cygnusv added a commit that referenced this issue Jul 16, 2024
derekpierre pushed a commit that referenced this issue Aug 9, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants