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

I doubt that whether the calculation of state root is incorrect. #1439

Closed
yangby-cryptape opened this issue Sep 19, 2023 · 2 comments
Closed
Assignees
Labels
agenda t:bug Something isn't working

Comments

@yangby-cryptape
Copy link
Collaborator

yangby-cryptape commented Sep 19, 2023

Current Behavior

I'm not an Ethereum expert.
In following explain, if I was wrong, please point that.

With my limited knowledge, I think the global state has no relation with the sender of a contract when the contract doesn't save any information about the sender into storage.

Let's check the Metadata contract:

function construct() public {
highest_epoch = U64_MAX;
}

Before 10 minutes, I have been told the solc contract is not used.
Check the following contract:

impl<Adapter: ExecutorAdapter + ApplyBackend> SystemContract<Adapter>
for MetadataContract<Adapter>
{
const ADDRESS: H160 = METADATA_CONTRACT_ADDRESS;
fn exec_(&self, adapter: &mut Adapter, tx: &SignedTransaction) -> TxResp {

It doesn't save the sender.

But, in the following unit test, the different senders will lead to different state root (CI checks is passed).

TestCase {
chain_name: "single_node",
config_file: "config.toml",
chain_spec_file: "specs/single_node/chain-spec.toml",
key_file: "debug-v1.key",
input_genesis_hash: "0x5a4918d8cf9440b11f40047e184e4e2e0231cc449bd473d7dca1275b2ef938e1",
genesis_state_root: "0x956e0bff5a59189447ae1bc8727ae18f7d01d0841fb9f6302c7b8675a6089763",
genesis_receipts_root: "0x7e747618f612d08dfe54bcb67f58f13a49e8b1bafee9a8f19a3a0f7122f44d02",
},
TestCase {
chain_name: "single_node",
config_file: "config.toml",
chain_spec_file: "specs/single_node/chain-spec.toml",
key_file: "debug-v2.key",
input_genesis_hash: "0x5a4918d8cf9440b11f40047e184e4e2e0231cc449bd473d7dca1275b2ef938e1",
genesis_state_root: "0x9d7fa055987ed34353ec84465d98b9e1bd6f3af871c36bd2d0d3f44e45170d27",
genesis_receipts_root: "0x7e747618f612d08dfe54bcb67f58f13a49e8b1bafee9a8f19a3a0f7122f44d02",
},

So, I doubt that whether the calculation of state root is incorrect.

p.s. The accounts of both two senders used in the unit test are empty, so no state for their balance should be existed.

Expected Behavior

The state root should be the same if only the sender is different but the sander is not saved into state.

@yangby-cryptape
Copy link
Collaborator Author

The nonce for the sender will be increased, that why the state roots are different.

@yangby-cryptape
Copy link
Collaborator Author

There are still some strange logs that need to be investigated, but they are not part of this issue.
If I found any further results, I will create another issue.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
agenda t:bug Something isn't working
Projects
None yet
Development

No branches or pull requests

3 participants