cairo-lang
                                
                                 cairo-lang copied to clipboard
                                
                                    cairo-lang copied to clipboard
                            
                            
                            
                        invoke CLI command does not work with OpenZeppelin's 0.10.0 Account contract
Setup:
- Have an Open Zeppelin v0.10 account contract with some goerli-ETH in it deployed on alpha-goerli network
- Install latest cairo-lang(==0.10.0)
- Setup the account from (1) for CLI usage (add it to~/.starknet_accounts/starknet_open_zeppelin_accounts.json)
BUG 🐞:
Calls to starknet invoke asserts on Error message: Account: invalid tx version. For example, here's an ERC20 transfer failure:
starknet --account oz_010_test invoke --address 0x049d36570d4e46f48e99674bd3fcc84644ddd6b96f7c741b1562b82f9e004dc7 --abi artifacts/abis/ERC20.json --function transfer --inputs <recipient> 5000000 0
File "cairo-contracts/venv/lib/python3.9/site-packages/services/external_api/client.py", line 117, in _send_request raise BadRequest(status_code=response.status, text=text) services.external_api.client.BadRequest: HTTP error ocurred. Status: 500. Text: {"code": "StarknetErrorCode.TRANSACTION_FAILED", "message": "Error message: Account: invalid tx versionError at pc=0:185: An ASSERT_EQ instruction failed: 1 != 340282366920938463463374607431768211457.Cairo traceback (most recent call last): Unknown location (pc=0:608) Unknown location (pc=0:554)"} Error: BadRequest: HTTP error ocurred. Status: 500. Text: {"code": "StarknetErrorCode.TRANSACTION_FAILED", "message": "Error message: Account: invalid tx version Error at pc=0:185: An ASSERT_EQ instruction failed: 1 != 340282366920938463463374607431768211457. Cairo traceback (most recent call last): Unknown location (pc=0:608) Unknown location (pc=0:554)"}
Root cause analysis:
- invoke()at src/starkware/starknet/cli/starknet_cli.py is triggered from- starknet invokeCLI command
- compute_max_feeis called with- invoke_tx_for_simulate
- invoke_tx_for_simulateis created with- create_invoke_txwith- query=True
- create_invoke_txwith- query=Truesets the- versionfield as follows:- version = constants.QUERY_VERSION if query else constants.TRANSACTION_VERSIONwhere:- QUERY_VERSION = QUERY_VERSION_BASE + TRANSACTION_VERSION== 340282366920938463463374607431768211457
- OZ account asserts on tx_info.version=1causing the assertion above
- NOTE: The Account contract bundled in cairo-lang asserts on the version differently as follows:
assert_not_equal(tx_info.version, 0);
Which version of OZ did you use to get this? Isn't this an OpenZeppelin issue (already reported here and soon to be resolved: https://github.com/OpenZeppelin/cairo-contracts/issues/471)
Which version of OZ did you use to get this? Isn't this an OpenZeppelin issue (already reported here and soon to be resolved: OpenZeppelin/cairo-contracts#471)
@FabijanC actually @martriay asked me to open this as a cairo-lang issue a while ago. In any case a fix on either side is great 👍