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

fix: cast overflow in 32-bits OS #978

Merged
merged 8 commits into from
Jan 16, 2024
Merged

Conversation

dyxushuai
Copy link
Contributor

Close #971

+r @rakita

@Wollac
Copy link
Contributor

Wollac commented Jan 15, 2024

I haven't run the zeth tests with it yet, but it seems that the eth tests still fail for me on i686-unknown-linux-gnu. Of course, this could be unrelated.

Running tests in tests/GeneralStateTests/...

Traces:

Execution result: Ok(
    Halt {
        reason: OutOfGas(
            InvalidOperand,
        ),
        gas_used: 4000000,
    },
)

Expected exception: None

State before: CacheState {
    accounts: {
        0xa94f5374fce5edbc8e2a8697c15331677e6ebf0b: CacheAccount {
            account: Some(
                PlainAccount {
                    info: AccountInfo {
                        balance: 0x0000000000000000000000000000000000000000000000000de0b6b3a7640000_U256,
                        nonce: 0,
                        code_hash: 0xc5d2460186f7233c927e7db2dcc703c0e500b653ca82273b7bfad8045d85a470,
                        code: Some(
                            Bytecode {
                                bytecode: 0x,
                                state: Raw,
                            },
                        ),
                    },
                    storage: {},
                },
            ),
            status: Loaded,
        },
        0x095e7baea6a6c7c4c2dfeb977efac326af552d87: CacheAccount {
            account: Some(
                PlainAccount {
                    info: AccountInfo {
                        balance: 0x0000000000000000000000000000000000000000000000000de0b6b3a7640000_U256,
                        nonce: 0,
                        code_hash: 0x003dee9cac09c55c8fd75f8345bd106bb755d5c2a2f3f57d544a02723cfa8934,
                        code: Some(
                            Bytecode {
                                bytecode: 0x600049600055600a4960015563ffffffff4960025567ffffffffffffffff496003556fffffffffffffffffffffffffffffffff496004557fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff4960055500,
                                state: Raw,
                            },
                        ),
                    },
                    storage: {
                        0x0000000000000000000000000000000000000000000000000000000000000001_U256: 0x0000000000000000000000000000000000000000000000000000000000000001_U256,
                        0x0000000000000000000000000000000000000000000000000000000000000004_U256: 0x0000000000000000000000000000000000000000000000000000000000000001_U256,
                        0x0_U256: 0x0000000000000000000000000000000000000000000000000000000000000001_U256,
                        0x0000000000000000000000000000000000000000000000000000000000000005_U256: 0x0000000000000000000000000000000000000000000000000000000000000001_U256,
                        0x0000000000000000000000000000000000000000000000000000000000000003_U256: 0x0000000000000000000000000000000000000000000000000000000000000001_U256,
                        0x0000000000000000000000000000000000000000000000000000000000000002_U256: 0x0000000000000000000000000000000000000000000000000000000000000001_U256,
                    },
                },
            ),
            status: Loaded,
        },
    },
    contracts: {},
    has_state_clear: false,
}

State after: CacheState {
    accounts: {
        0x0000000000000000000000000000000000000000: CacheAccount {
            account: Some(
                PlainAccount {
                    info: AccountInfo {
                        balance: 0x0_U256,
                        nonce: 1,
                        code_hash: 0xc5d2460186f7233c927e7db2dcc703c0e500b653ca82273b7bfad8045d85a470,
                        code: Some(
                            Bytecode {
                                bytecode: 0x00,
                                state: Analysed {
                                    len: 0,
                                    jump_map: JumpMap {
                                        map: "00",
                                    },
                                },
                            },
                        ),
                    },
                    storage: {},
                },
            ),
            status: InMemoryChange,
        },
        0xa94f5374fce5edbc8e2a8697c15331677e6ebf0b: CacheAccount {
            account: Some(
                PlainAccount {
                    info: AccountInfo {
                        balance: 0x0000000000000000000000000000000000000000000000000de0b6b3a7640000_U256,
                        nonce: 0,
                        code_hash: 0xc5d2460186f7233c927e7db2dcc703c0e500b653ca82273b7bfad8045d85a470,
                        code: Some(
                            Bytecode {
                                bytecode: 0x,
                                state: Raw,
                            },
                        ),
                    },
                    storage: {},
                },
            ),
            status: Loaded,
        },
        0x095e7baea6a6c7c4c2dfeb977efac326af552d87: CacheAccount {
            account: Some(
                PlainAccount {
                    info: AccountInfo {
                        balance: 0x0000000000000000000000000000000000000000000000000de0b6b3a7640000_U256,
                        nonce: 0,
                        code_hash: 0x003dee9cac09c55c8fd75f8345bd106bb755d5c2a2f3f57d544a02723cfa8934,
                        code: Some(
                            Bytecode {
                                bytecode: 0x600049600055600a4960015563ffffffff4960025567ffffffffffffffff496003556fffffffffffffffffffffffffffffffff496004557fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff4960055500,
                                state: Raw,
                            },
                        ),
                    },
                    storage: {
                        0x0000000000000000000000000000000000000000000000000000000000000001_U256: 0x0000000000000000000000000000000000000000000000000000000000000001_U256,
                        0x0000000000000000000000000000000000000000000000000000000000000004_U256: 0x0000000000000000000000000000000000000000000000000000000000000001_U256,
                        0x0_U256: 0x0000000000000000000000000000000000000000000000000000000000000001_U256,
                        0x0000000000000000000000000000000000000000000000000000000000000005_U256: 0x0000000000000000000000000000000000000000000000000000000000000001_U256,
                        0x0000000000000000000000000000000000000000000000000000000000000003_U256: 0x0000000000000000000000000000000000000000000000000000000000000001_U256,
                        0x0000000000000000000000000000000000000000000000000000000000000002_U256: 0x0000000000000000000000000000000000000000000000000000000000000001_U256,
                    },
                },
            ),
            status: Loaded,
        },
    },
    contracts: {},
    has_state_clear: true,
}

Specification: CANCUN

Environment: Env {
    cfg: CfgEnv {
        chain_id: 1,
        kzg_settings: Default,
        perf_analyse_created_bytecodes: Analyse,
        limit_contract_code_size: None,
    },
    block: BlockEnv {
        number: 0x0000000000000000000000000000000000000000000000000000000000000001_U256,
        coinbase: 0x2adc25665018aa1fe0e6bc666dac8fc2697ff9ba,
        timestamp: 0x00000000000000000000000000000000000000000000000000000000000003e8_U256,
        gas_limit: 0x0000000000000000000000000000000000000000000000000000001000000000_U256,
        basefee: 0x0000000000000000000000000000000000000000000000000000000000000001_U256,
        difficulty: 0x0000000000000000000000000000000000000000000000000000000000020000_U256,
        prevrandao: Some(
            0x0000000000000000000000000000000000000000000000000000000000020000,
        ),
        blob_excess_gas_and_price: Some(
            BlobExcessGasAndPrice {
                excess_blob_gas: 0,
                blob_gasprice: 1,
            },
        ),
    },
    tx: TxEnv {
        caller: 0xa94f5374fce5edbc8e2a8697c15331677e6ebf0b,
        gas_limit: 4000000,
        gas_price: 0x000000000000000000000000000000000000000000000000000000012a05f200_U256,
        transact_to: Call(
            0x095e7baea6a6c7c4c2dfeb977efac326af552d87,
        ),
        value: 0x00000000000000000000000000000000000000000000000000000000000186a0_U256,
        data: 0x00,
        nonce: None,
        chain_id: None,
        access_list: [
            (
                0x095e7baea6a6c7c4c2dfeb977efac326af552d87,
                [
                    0x0_U256,
                    0x0000000000000000000000000000000000000000000000000000000000000001_U256,
                ],
            ),
        ],
        gas_priority_fee: Some(
            0x0000000000000000000000000000000000000000000000000000000000000002_U256,
        ),
        blob_hashes: [
            0x01a915e4d060149eb4365960e6a7a45f334393093061116b197e3240065ff2d8,
            0x01a915e4d060149eb4365960e6a7a45f334393093061116b197e3240065ff2d8,
        ],
        max_fee_per_blob_gas: Some(
            0x000000000000000000000000000000000000000000000000000000000000000a_U256,
        ),
    },
}

Test name: "opcodeBlobhBounds" (index: 0, path: tests/GeneralStateTests/Cancun/stEIP4844-blobtransactions/opcodeBlobhBounds.json) failed:
Test opcodeBlobhBounds failed: state root mismatch: expected 0x426146b44c5917613224a944ceff7c3672f26f7a9bee97f7c8b9b097d67cb3a9, got 0x2c526db07cff1c6794440d3258ae3890c2e1faa3ba619540b94b4316230c73fe

@dyxushuai
Copy link
Contributor Author

I haven't run the zeth tests with it yet, but it seems that the eth tests still fail for me on i686-unknown-linux-gnu. Of course, this could be unrelated.

Running tests in tests/GeneralStateTests/...

Traces:

Execution result: Ok(
    Halt {
        reason: OutOfGas(
            InvalidOperand,
        ),
        gas_used: 4000000,
    },
)

Expected exception: None

State before: CacheState {
    accounts: {
        0xa94f5374fce5edbc8e2a8697c15331677e6ebf0b: CacheAccount {
            account: Some(
                PlainAccount {
                    info: AccountInfo {
                        balance: 0x0000000000000000000000000000000000000000000000000de0b6b3a7640000_U256,
                        nonce: 0,
                        code_hash: 0xc5d2460186f7233c927e7db2dcc703c0e500b653ca82273b7bfad8045d85a470,
                        code: Some(
                            Bytecode {
                                bytecode: 0x,
                                state: Raw,
                            },
                        ),
                    },
                    storage: {},
                },
            ),
            status: Loaded,
        },
        0x095e7baea6a6c7c4c2dfeb977efac326af552d87: CacheAccount {
            account: Some(
                PlainAccount {
                    info: AccountInfo {
                        balance: 0x0000000000000000000000000000000000000000000000000de0b6b3a7640000_U256,
                        nonce: 0,
                        code_hash: 0x003dee9cac09c55c8fd75f8345bd106bb755d5c2a2f3f57d544a02723cfa8934,
                        code: Some(
                            Bytecode {
                                bytecode: 0x600049600055600a4960015563ffffffff4960025567ffffffffffffffff496003556fffffffffffffffffffffffffffffffff496004557fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff4960055500,
                                state: Raw,
                            },
                        ),
                    },
                    storage: {
                        0x0000000000000000000000000000000000000000000000000000000000000001_U256: 0x0000000000000000000000000000000000000000000000000000000000000001_U256,
                        0x0000000000000000000000000000000000000000000000000000000000000004_U256: 0x0000000000000000000000000000000000000000000000000000000000000001_U256,
                        0x0_U256: 0x0000000000000000000000000000000000000000000000000000000000000001_U256,
                        0x0000000000000000000000000000000000000000000000000000000000000005_U256: 0x0000000000000000000000000000000000000000000000000000000000000001_U256,
                        0x0000000000000000000000000000000000000000000000000000000000000003_U256: 0x0000000000000000000000000000000000000000000000000000000000000001_U256,
                        0x0000000000000000000000000000000000000000000000000000000000000002_U256: 0x0000000000000000000000000000000000000000000000000000000000000001_U256,
                    },
                },
            ),
            status: Loaded,
        },
    },
    contracts: {},
    has_state_clear: false,
}

State after: CacheState {
    accounts: {
        0x0000000000000000000000000000000000000000: CacheAccount {
            account: Some(
                PlainAccount {
                    info: AccountInfo {
                        balance: 0x0_U256,
                        nonce: 1,
                        code_hash: 0xc5d2460186f7233c927e7db2dcc703c0e500b653ca82273b7bfad8045d85a470,
                        code: Some(
                            Bytecode {
                                bytecode: 0x00,
                                state: Analysed {
                                    len: 0,
                                    jump_map: JumpMap {
                                        map: "00",
                                    },
                                },
                            },
                        ),
                    },
                    storage: {},
                },
            ),
            status: InMemoryChange,
        },
        0xa94f5374fce5edbc8e2a8697c15331677e6ebf0b: CacheAccount {
            account: Some(
                PlainAccount {
                    info: AccountInfo {
                        balance: 0x0000000000000000000000000000000000000000000000000de0b6b3a7640000_U256,
                        nonce: 0,
                        code_hash: 0xc5d2460186f7233c927e7db2dcc703c0e500b653ca82273b7bfad8045d85a470,
                        code: Some(
                            Bytecode {
                                bytecode: 0x,
                                state: Raw,
                            },
                        ),
                    },
                    storage: {},
                },
            ),
            status: Loaded,
        },
        0x095e7baea6a6c7c4c2dfeb977efac326af552d87: CacheAccount {
            account: Some(
                PlainAccount {
                    info: AccountInfo {
                        balance: 0x0000000000000000000000000000000000000000000000000de0b6b3a7640000_U256,
                        nonce: 0,
                        code_hash: 0x003dee9cac09c55c8fd75f8345bd106bb755d5c2a2f3f57d544a02723cfa8934,
                        code: Some(
                            Bytecode {
                                bytecode: 0x600049600055600a4960015563ffffffff4960025567ffffffffffffffff496003556fffffffffffffffffffffffffffffffff496004557fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff4960055500,
                                state: Raw,
                            },
                        ),
                    },
                    storage: {
                        0x0000000000000000000000000000000000000000000000000000000000000001_U256: 0x0000000000000000000000000000000000000000000000000000000000000001_U256,
                        0x0000000000000000000000000000000000000000000000000000000000000004_U256: 0x0000000000000000000000000000000000000000000000000000000000000001_U256,
                        0x0_U256: 0x0000000000000000000000000000000000000000000000000000000000000001_U256,
                        0x0000000000000000000000000000000000000000000000000000000000000005_U256: 0x0000000000000000000000000000000000000000000000000000000000000001_U256,
                        0x0000000000000000000000000000000000000000000000000000000000000003_U256: 0x0000000000000000000000000000000000000000000000000000000000000001_U256,
                        0x0000000000000000000000000000000000000000000000000000000000000002_U256: 0x0000000000000000000000000000000000000000000000000000000000000001_U256,
                    },
                },
            ),
            status: Loaded,
        },
    },
    contracts: {},
    has_state_clear: true,
}

Specification: CANCUN

Environment: Env {
    cfg: CfgEnv {
        chain_id: 1,
        kzg_settings: Default,
        perf_analyse_created_bytecodes: Analyse,
        limit_contract_code_size: None,
    },
    block: BlockEnv {
        number: 0x0000000000000000000000000000000000000000000000000000000000000001_U256,
        coinbase: 0x2adc25665018aa1fe0e6bc666dac8fc2697ff9ba,
        timestamp: 0x00000000000000000000000000000000000000000000000000000000000003e8_U256,
        gas_limit: 0x0000000000000000000000000000000000000000000000000000001000000000_U256,
        basefee: 0x0000000000000000000000000000000000000000000000000000000000000001_U256,
        difficulty: 0x0000000000000000000000000000000000000000000000000000000000020000_U256,
        prevrandao: Some(
            0x0000000000000000000000000000000000000000000000000000000000020000,
        ),
        blob_excess_gas_and_price: Some(
            BlobExcessGasAndPrice {
                excess_blob_gas: 0,
                blob_gasprice: 1,
            },
        ),
    },
    tx: TxEnv {
        caller: 0xa94f5374fce5edbc8e2a8697c15331677e6ebf0b,
        gas_limit: 4000000,
        gas_price: 0x000000000000000000000000000000000000000000000000000000012a05f200_U256,
        transact_to: Call(
            0x095e7baea6a6c7c4c2dfeb977efac326af552d87,
        ),
        value: 0x00000000000000000000000000000000000000000000000000000000000186a0_U256,
        data: 0x00,
        nonce: None,
        chain_id: None,
        access_list: [
            (
                0x095e7baea6a6c7c4c2dfeb977efac326af552d87,
                [
                    0x0_U256,
                    0x0000000000000000000000000000000000000000000000000000000000000001_U256,
                ],
            ),
        ],
        gas_priority_fee: Some(
            0x0000000000000000000000000000000000000000000000000000000000000002_U256,
        ),
        blob_hashes: [
            0x01a915e4d060149eb4365960e6a7a45f334393093061116b197e3240065ff2d8,
            0x01a915e4d060149eb4365960e6a7a45f334393093061116b197e3240065ff2d8,
        ],
        max_fee_per_blob_gas: Some(
            0x000000000000000000000000000000000000000000000000000000000000000a_U256,
        ),
    },
}

Test name: "opcodeBlobhBounds" (index: 0, path: tests/GeneralStateTests/Cancun/stEIP4844-blobtransactions/opcodeBlobhBounds.json) failed:
Test opcodeBlobhBounds failed: state root mismatch: expected 0x426146b44c5917613224a944ceff7c3672f26f7a9bee97f7c8b9b097d67cb3a9, got 0x2c526db07cff1c6794440d3258ae3890c2e1faa3ba619540b94b4316230c73fe

Sorry, I didn't test the failed issues. I will test it and make sure it works.

@Wollac
Copy link
Contributor

Wollac commented Jan 15, 2024

I can now confirm that i686-unknown-linux-gnu as well as the zeth issue seems to be fixed for me.
However, shouldn't it also be possible to run the (eth) tests on the CI on i686-unknown-linux-gnu? I think that might be something worth adding to prevent problems like this in the future.

Co-authored-by: rakita <rakita@users.noreply.github.com>
@dyxushuai
Copy link
Contributor Author

I can now confirm that i686-unknown-linux-gnu as well as the zeth issue seems to be fixed for me. However, shouldn't it also be possible to run the (eth) tests on the CI on i686-unknown-linux-gnu? I think that might be something worth adding to prevent problems like this in the future.

@Wollac @rakita Sounds good, I can try to add it

Copy link
Member

@rakita rakita left a comment

Choose a reason for hiding this comment

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

This lgtm!

Will wait for CI before merging, let me know if you need help

@dyxushuai
Copy link
Contributor Author

dyxushuai commented Jan 16, 2024

This lgtm!

Will wait for CI before merging, let me know if you need help

I just try to use the cross to do the cross platforms running. And it works well.

@dyxushuai
Copy link
Contributor Author

@rakita It's ready for review and merging.

Copy link
Member

@rakita rakita left a comment

Choose a reason for hiding this comment

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

TIL about cross

@rakita rakita merged commit 5e6546e into bluealloy:main Jan 16, 2024
25 checks passed
@github-actions github-actions bot mentioned this pull request Jan 16, 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
3 participants