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

EIP-7702 devnet-3 readiness #3581

Merged
merged 41 commits into from
Sep 11, 2024
Merged

EIP-7702 devnet-3 readiness #3581

merged 41 commits into from
Sep 11, 2024

Conversation

jochem-brouwer
Copy link
Member

@jochem-brouwer jochem-brouwer commented Aug 12, 2024

Updates the EIP-7702 implementation to this spec: https://github.com/ethereum/EIPs/blob/52de6be37bfb7c134d0a2280f3d5b3d2433dc572/EIPS/eip-7702.md (devnet-3 spec (?))

NOTE for t8ntool to work for state tests, I have disabled throwing on requests.ts if code does not exist, we should carefully review this as a side-effect of this PR. (Will add a blocked label for this one since we should discuss)

This makes EthereumJS devnet-3 ready, see: https://notes.ethereum.org/@ethpandaops/pectra-devnet-3

@jochem-brouwer
Copy link
Member Author

Note to self: have to take care of the edge case when a precompile is the delegation address

@jochem-brouwer
Copy link
Member Author

jochem-brouwer commented Aug 19, 2024

Failing execution-spec-tests

These tests are likely wrong on the side of execution-spec-tests:

FAILED tests/prague/eip7702_set_code_tx/test_gas.py::test_account_warming[fork_Prague-blockchain_test-single_invalid_nonce_authorization_single_signer] - ethereum_test_base_types.composite_types.Storage.KeyValueMismatch: incorrect value in address 0x0000000000000000000000000000000000001000 (callee_address) for key 0x000000000000000000000000000000000000...
FAILED tests/prague/eip7702_set_code_tx/test_gas.py::test_account_warming[fork_Prague-blockchain_test-multiple_invalid_nonce_authorizations_single_signer] - ethereum_test_base_types.composite_types.Storage.KeyValueMismatch: incorrect value in address 0x0000000000000000000000000000000000001000 (callee_address) for key 0x000000000000000000000000000000000000...
FAILED tests/prague/eip7702_set_code_tx/test_gas.py::test_account_warming[fork_Prague-blockchain_test-multiple_invalid_nonce_authorizations_multiple_signers] - ethereum_test_base_types.composite_types.Storage.KeyValueMismatch: incorrect value in address 0x0000000000000000000000000000000000001000 (callee_address) for key 0x000000000000000000000000000000000000...
FAILED tests/prague/eip7702_set_code_tx/test_gas.py::test_account_warming[fork_Prague-blockchain_test-single_valid_authorization_invalid_contract_authority] - ethereum_test_base_types.composite_types.Storage.KeyValueMismatch: incorrect value in address 0x0000000000000000000000000000000000001000 (callee_address) for key 0x000000000000000000000000000000000000...
FAILED tests/prague/eip7702_set_code_tx/test_gas.py::test_account_warming[fork_Prague-blockchain_test-multiple_authorizations_empty_account_then_contract_authority] - ethereum_test_base_types.composite_types.Storage.KeyValueMismatch: incorrect value in address 0x0000000000000000000000000000000000001000 (callee_address) for key 0x000000000000000000000000000000000000...
FAILED tests/prague/eip7702_set_code_tx/test_gas.py::test_account_warming[fork_Prague-blockchain_test-multiple_authorizations_eoa_then_contract_authority] - ethereum_test_base_types.composite_types.Storage.KeyValueMismatch: incorrect value in address 0x0000000000000000000000000000000000001000 (callee_address) for key 0x000000000000000000000000000000000000...
FAILED tests/prague/eip7702_set_code_tx/test_gas.py::test_account_warming[fork_Prague-blockchain_test-multiple_authorizations_eoa_self_sponsored_then_contract_authority] - ethereum_test_base_types.composite_types.Storage.KeyValueMismatch: incorrect value in address 0x0000000000000000000000000000000000001000 (callee_address) for key 0x000000000000000000000000000000000000...
FAILED tests/prague/eip7702_set_code_tx/test_gas.py::test_account_warming[fork_Prague-blockchain_test_engine-single_invalid_nonce_authorization_single_signer] - ethereum_test_base_types.composite_types.Storage.KeyValueMismatch: incorrect value in address 0x0000000000000000000000000000000000001000 (callee_address) for key 0x000000000000000000000000000000000000...
FAILED tests/prague/eip7702_set_code_tx/test_gas.py::test_account_warming[fork_Prague-blockchain_test_engine-multiple_invalid_nonce_authorizations_single_signer] - ethereum_test_base_types.composite_types.Storage.KeyValueMismatch: incorrect value in address 0x0000000000000000000000000000000000001000 (callee_address) for key 0x000000000000000000000000000000000000...
FAILED tests/prague/eip7702_set_code_tx/test_gas.py::test_account_warming[fork_Prague-blockchain_test_engine-multiple_invalid_nonce_authorizations_multiple_signers] - ethereum_test_base_types.composite_types.Storage.KeyValueMismatch: incorrect value in address 0x0000000000000000000000000000000000001000 (callee_address) for key 0x000000000000000000000000000000000000...
FAILED tests/prague/eip7702_set_code_tx/test_gas.py::test_account_warming[fork_Prague-blockchain_test_engine-single_valid_authorization_invalid_contract_authority] - ethereum_test_base_types.composite_types.Storage.KeyValueMismatch: incorrect value in address 0x0000000000000000000000000000000000001000 (callee_address) for key 0x000000000000000000000000000000000000...
FAILED tests/prague/eip7702_set_code_tx/test_gas.py::test_account_warming[fork_Prague-blockchain_test_engine-multiple_authorizations_empty_account_then_contract_authority] - ethereum_test_base_types.composite_types.Storage.KeyValueMismatch: incorrect value in address 0x0000000000000000000000000000000000001000 (callee_address) for key 0x000000000000000000000000000000000000...
FAILED tests/prague/eip7702_set_code_tx/test_gas.py::test_account_warming[fork_Prague-blockchain_test_engine-multiple_authorizations_eoa_then_contract_authority] - ethereum_test_base_types.composite_types.Storage.KeyValueMismatch: incorrect value in address 0x0000000000000000000000000000000000001000 (callee_address) for key 0x000000000000000000000000000000000000...
FAILED tests/prague/eip7702_set_code_tx/test_gas.py::test_account_warming[fork_Prague-blockchain_test_engine-multiple_authorizations_eoa_self_sponsored_then_contract_authority] - ethereum_test_base_types.composite_types.Storage.KeyValueMismatch: incorrect value in address 0x0000000000000000000000000000000000001000 (callee_address) for key 0x000000000000000000000000000000000000...
FAILED tests/prague/eip7702_set_code_tx/test_gas.py::test_account_warming[fork_Prague-state_test-single_invalid_nonce_authorization_single_signer] - ethereum_test_base_types.composite_types.Storage.KeyValueMismatch: incorrect value in address 0x0000000000000000000000000000000000001000 (callee_address) for key 0x000000000000000000000000000000000000...
FAILED tests/prague/eip7702_set_code_tx/test_gas.py::test_account_warming[fork_Prague-state_test-multiple_invalid_nonce_authorizations_single_signer] - ethereum_test_base_types.composite_types.Storage.KeyValueMismatch: incorrect value in address 0x0000000000000000000000000000000000001000 (callee_address) for key 0x000000000000000000000000000000000000...
FAILED tests/prague/eip7702_set_code_tx/test_gas.py::test_account_warming[fork_Prague-state_test-multiple_invalid_nonce_authorizations_multiple_signers] - ethereum_test_base_types.composite_types.Storage.KeyValueMismatch: incorrect value in address 0x0000000000000000000000000000000000001000 (callee_address) for key 0x000000000000000000000000000000000000...
FAILED tests/prague/eip7702_set_code_tx/test_gas.py::test_account_warming[fork_Prague-state_test-single_valid_authorization_invalid_contract_authority] - ethereum_test_base_types.composite_types.Storage.KeyValueMismatch: incorrect value in address 0x0000000000000000000000000000000000001000 (callee_address) for key 0x000000000000000000000000000000000000...
FAILED tests/prague/eip7702_set_code_tx/test_gas.py::test_account_warming[fork_Prague-state_test-multiple_authorizations_empty_account_then_contract_authority] - ethereum_test_base_types.composite_types.Storage.KeyValueMismatch: incorrect value in address 0x0000000000000000000000000000000000001000 (callee_address) for key 0x000000000000000000000000000000000000...
FAILED tests/prague/eip7702_set_code_tx/test_gas.py::test_account_warming[fork_Prague-state_test-multiple_authorizations_eoa_then_contract_authority] - ethereum_test_base_types.composite_types.Storage.KeyValueMismatch: incorrect value in address 0x0000000000000000000000000000000000001000 (callee_address) for key 0x000000000000000000000000000000000000...
FAILED tests/prague/eip7702_set_code_tx/test_gas.py::test_account_warming[fork_Prague-state_test-multiple_authorizations_eoa_self_sponsored_then_contract_authority] - ethereum_test_base_types.composite_types.Storage.KeyValueMismatch: incorrect value in address 0x0000000000000000000000000000000000001000 (callee_address) for key 0x000000000000000000000000000000000000...
FAILED tests/prague/eip7702_set_code_tx/test_set_code_txs.py::test_set_code_to_sstore_then_sload[fork_Prague-blockchain_test] - ethereum_test_base_types.composite_types.Storage.KeyValueMismatch: incorrect value in address 0xa94f5374fce5edbc8e2a8697c15331677e6ebf0b for key 0x00000000000000000000000000000000000000000000000000000...
FAILED tests/prague/eip7702_set_code_tx/test_set_code_txs.py::test_set_code_to_sstore_then_sload[fork_Prague-blockchain_test_engine] - ethereum_test_base_types.composite_types.Storage.KeyValueMismatch: incorrect value in address 0xa94f5374fce5edbc8e2a8697c15331677e6ebf0b for key 0x00000000000000000000000000000000000000000000000000000...
FAILED tests/prague/eip7702_set_code_tx/test_set_code_txs.py::test_ext_code_on_chain_delegating_set_code[fork_Prague-blockchain_test-balance_0] - ethereum_test_base_types.composite_types.Storage.KeyValueMismatch: incorrect value in address 0x0000000000000000000000000000000000001000 (callee_address) for key 0x000000000000000000000000000000000000...
FAILED tests/prague/eip7702_set_code_tx/test_set_code_txs.py::test_ext_code_on_chain_delegating_set_code[fork_Prague-blockchain_test-balance_1] - ethereum_test_base_types.composite_types.Storage.KeyValueMismatch: incorrect value in address 0x0000000000000000000000000000000000001000 (callee_address) for key 0x000000000000000000000000000000000000...
FAILED tests/prague/eip7702_set_code_tx/test_set_code_txs.py::test_ext_code_on_chain_delegating_set_code[fork_Prague-blockchain_test_engine-balance_0] - ethereum_test_base_types.composite_types.Storage.KeyValueMismatch: incorrect value in address 0x0000000000000000000000000000000000001000 (callee_address) for key 0x000000000000000000000000000000000000...
FAILED tests/prague/eip7702_set_code_tx/test_set_code_txs.py::test_ext_code_on_chain_delegating_set_code[fork_Prague-blockchain_test_engine-balance_1] - ethereum_test_base_types.composite_types.Storage.KeyValueMismatch: incorrect value in address 0x0000000000000000000000000000000000001000 (callee_address) for key 0x000000000000000000000000000000000000...
FAILED tests/prague/eip7702_set_code_tx/test_set_code_txs.py::test_ext_code_on_chain_delegating_set_code[fork_Prague-state_test-balance_0] - ethereum_test_base_types.composite_types.Storage.KeyValueMismatch: incorrect value in address 0x0000000000000000000000000000000000001000 (callee_address) for key 0x000000000000000000000000000000000000...
FAILED tests/prague/eip7702_set_code_tx/test_set_code_txs.py::test_ext_code_on_chain_delegating_set_code[fork_Prague-state_test-balance_1] - ethereum_test_base_types.composite_types.Storage.KeyValueMismatch: incorrect value in address 0x0000000000000000000000000000000000001000 (callee_address) for key 0x000000000000000000000000000000000000...
FAILED tests/prague/eip7702_set_code_tx/test_set_code_txs.py::test_set_code_all_invalid_authorization_tuples[fork_Prague-blockchain_test] - ethereum_test_types.types.Alloc.MissingAccount: Account missing from allocation 0xa94f5374fce5edbc8e2a8697c15331677e6ebf0b
FAILED tests/prague/eip7702_set_code_tx/test_set_code_txs.py::test_set_code_all_invalid_authorization_tuples[fork_Prague-blockchain_test_engine] - ethereum_test_types.types.Alloc.MissingAccount: Account missing from allocation 0xa94f5374fce5edbc8e2a8697c15331677e6ebf0b
FAILED tests/prague/eip7702_set_code_tx/test_set_code_txs.py::test_set_code_all_invalid_authorization_tuples[fork_Prague-state_test] - ethereum_test_types.types.Alloc.MissingAccount: Account missing from allocation 0xa94f5374fce5edbc8e2a8697c15331677e6ebf0b
FAILED tests/prague/eip7702_set_code_tx/test_set_code_txs.py::test_set_code_invalid_authorization_tuple[fork_Prague-blockchain_test-invalidity_reason_InvalidityReason.CHAIN_ID-transaction_exception_TransactionException.TYPE_4_EMPTY_AUTHORIZATION_LIST] - Exception: tx expected to fail succeeded: pos=0, nonce=0x0
FAILED tests/prague/eip7702_set_code_tx/test_set_code_txs.py::test_set_code_invalid_authorization_tuple[fork_Prague-blockchain_test_engine-invalidity_reason_InvalidityReason.CHAIN_ID-transaction_exception_TransactionException.TYPE_4_EMPTY_AUTHORIZATION_LIST] - Exception: tx expected to fail succeeded: pos=0, nonce=0x0
FAILED tests/prague/eip7702_set_code_tx/test_set_code_txs.py::test_set_code_to_system_contract[fork_Prague-call_opcode_CALL-evm_code_type_LEGACY-system_contract_0x00000000219ab540356cbb839cbe05303d7705fa-blockchain_test] - ethereum_test_base_types.composite_types.Storage.KeyValueMismatch: incorrect value in address 0x0000000000000000000000000000000000001000 (caller_code_address) for key 0x0000000000000000000000000000000...
FAILED tests/prague/eip7702_set_code_tx/test_set_code_txs.py::test_set_code_to_system_contract[fork_Prague-call_opcode_CALL-evm_code_type_LEGACY-system_contract_0x00000000219ab540356cbb839cbe05303d7705fa-blockchain_test_engine] - ethereum_test_base_types.composite_types.Storage.KeyValueMismatch: incorrect value in address 0x0000000000000000000000000000000000001000 (caller_code_address) for key 0x0000000000000000000000000000000...
FAILED tests/prague/eip7702_set_code_tx/test_set_code_txs.py::test_set_code_to_system_contract[fork_Prague-call_opcode_CALL-evm_code_type_LEGACY-system_contract_0x00a3ca265ebcb825b45f985a16cefb49958ce017-blockchain_test] - ethereum_test_base_types.composite_types.Storage.KeyValueMismatch: incorrect value in address 0x0000000000000000000000000000000000001000 (caller_code_address) for key 0x0000000000000000000000000000000...
FAILED tests/prague/eip7702_set_code_tx/test_set_code_txs.py::test_set_code_to_system_contract[fork_Prague-call_opcode_CALL-evm_code_type_LEGACY-system_contract_0x00a3ca265ebcb825b45f985a16cefb49958ce017-blockchain_test_engine] - ethereum_test_base_types.composite_types.Storage.KeyValueMismatch: incorrect value in address 0x0000000000000000000000000000000000001000 (caller_code_address) for key 0x0000000000000000000000000000000...
FAILED tests/prague/eip7702_set_code_tx/test_set_code_txs.py::test_set_code_to_system_contract[fork_Prague-call_opcode_CALL-evm_code_type_LEGACY-system_contract_0x00b42dbf2194e931e80326d950320f7d9dbeac02-blockchain_test] - ethereum_test_base_types.composite_types.Storage.KeyValueMismatch: incorrect value in address 0x0000000000000000000000000000000000001000 (caller_code_address) for key 0x0000000000000000000000000000000...
FAILED tests/prague/eip7702_set_code_tx/test_set_code_txs.py::test_set_code_to_system_contract[fork_Prague-call_opcode_CALL-evm_code_type_LEGACY-system_contract_0x00b42dbf2194e931e80326d950320f7d9dbeac02-blockchain_test_engine] - ethereum_test_base_types.composite_types.Storage.KeyValueMismatch: incorrect value in address 0x0000000000000000000000000000000000001000 (caller_code_address) for key 0x0000000000000000000000000000000...
FAILED tests/prague/eip7702_set_code_tx/test_set_code_txs.py::test_set_code_to_system_contract[fork_Prague-call_opcode_CALL-evm_code_type_LEGACY-system_contract_0x0aae40965e6800cd9b1f4b05ff21581047e3f91e-blockchain_test] - ethereum_test_base_types.composite_types.Storage.KeyValueMismatch: incorrect value in address 0x0000000000000000000000000000000000001000 (caller_code_address) for key 0x0000000000000000000000000000000...
FAILED tests/prague/eip7702_set_code_tx/test_set_code_txs.py::test_set_code_to_system_contract[fork_Prague-call_opcode_CALL-evm_code_type_LEGACY-system_contract_0x0aae40965e6800cd9b1f4b05ff21581047e3f91e-blockchain_test_engine] - ethereum_test_base_types.composite_types.Storage.KeyValueMismatch: incorrect value in address 0x0000000000000000000000000000000000001000 (caller_code_address) for key 0x0000000000000000000000000000000...
FAILED tests/prague/eip7702_set_code_tx/test_set_code_txs.py::test_set_code_to_system_contract[fork_Prague-call_opcode_CALL-evm_code_type_LEGACY-system_contract_0x000f3df6d732807ef1319fb7b8bb8522d0beac02-blockchain_test] - ethereum_test_base_types.composite_types.Storage.KeyValueMismatch: incorrect value in address 0x0000000000000000000000000000000000001000 (caller_code_address) for key 0x0000000000000000000000000000000...
FAILED tests/prague/eip7702_set_code_tx/test_set_code_txs.py::test_set_code_to_system_contract[fork_Prague-call_opcode_CALL-evm_code_type_LEGACY-system_contract_0x000f3df6d732807ef1319fb7b8bb8522d0beac02-blockchain_test_engine] - ethereum_test_base_types.composite_types.Storage.KeyValueMismatch: incorrect value in address 0x0000000000000000000000000000000000001000 (caller_code_address) for key 0x0000000000000000000000000000000...

@jochem-brouwer
Copy link
Member Author

Ok, have cross-checked all tests! Bugs found are fixed here.

@holgerd77
Copy link
Member

Could you like the tests which are tested here?

@jochem-brouwer jochem-brouwer marked this pull request as ready for review August 30, 2024 11:46
Copy link
Contributor

@acolytec3 acolytec3 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good overall though a couple of things we should clean up before merging

// EIP-7702 delegation check
if (
this.common.isActivatedEIP(7702) &&
equalsBytes(message.code.slice(0, 3), new Uint8Array([0xef, 0x01, 0x00]))
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Could we make a constant out of 0xef0100 and call it DELEGATION_DESIGNATOR or whatever is the best way to refer to this instead of a magic number?

packages/tx/src/7702/tx.ts Show resolved Hide resolved
throw new Error(msg)
if (vm.common.isActivatedEIP(7702)) {
const code = await state.getCode(caller)
if (!equalsBytes(code.slice(0, 3), new Uint8Array([0xef, 0x01, 0x00]))) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Again, let's make 0xef0100 a constant and not a magic number.

packages/vm/src/runTx.ts Outdated Show resolved Hide resolved
@holgerd77
Copy link
Member

Does devnet-3 have a URL (yet)? If so, can it be added to the PR description? Thanks! 🙂

@jochem-brouwer
Copy link
Member Author

jochem-brouwer commented Sep 2, 2024

I thought there was a devnet-3 spec somewhere, but I can't find it 🤔

NVM, found it https://notes.ethereum.org/@ethpandaops/pectra-devnet-3. Added to description.

@@ -64,6 +64,9 @@ const journalCacheCleanUpLabel = 'Journal/cache cleanup'
const receiptsLabel = 'Receipts'
const entireTxLabel = 'Entire tx'

// EIP-7702 flag: if contract code starts with these 3 bytes, it is a 7702-delegated EOA
const DELEGATION_7702_FLAG = new Uint8Array([0xef, 0x01, 0x00])
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Shouldn't this be in common or else a constants section? Feels out of place to declare a constant like this in runTx.

acolytec3
acolytec3 previously approved these changes Sep 11, 2024
@acolytec3 acolytec3 merged commit 674a8a3 into master Sep 11, 2024
38 checks passed
@acolytec3 acolytec3 deleted the 7702-update branch September 11, 2024 19:14
@jochem-brouwer jochem-brouwer restored the 7702-update branch September 12, 2024 18:36
@jochem-brouwer jochem-brouwer deleted the 7702-update branch September 12, 2024 18:39
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants