Skip to content

[ETCM-846] make ETS stBadOpcode tests pass #992

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

Merged
merged 7 commits into from
May 27, 2021

Conversation

AurelienRichez
Copy link
Contributor

@AurelienRichez AurelienRichez commented May 20, 2021

Description

This PR is part of the ogoing effort to make ETS pass all tests. The stBadOpcode suite did not pass because the accounts were not imported with the root hash for their storage.

Proposed Solution

The getGenesisStateRoot now create an in memory trie in order to compte the resulting hash.

As this change is not specific to stBadOpcode, it also makes most the previously failing tests pass (9 failing test for GeneralStateTests while we had around 400 before).

@AurelienRichez AurelienRichez changed the title [ETCM-846] make stBadOpcode pass [ETCM-846] make ETS stBadOpcode tests pass May 20, 2021
@AurelienRichez AurelienRichez force-pushed the fix/ETCM-846-make-stBadOpcode-pass branch from d4d5e5a to d91d37b Compare May 20, 2021 10:06
@AurelienRichez AurelienRichez force-pushed the fix/ETCM-846-make-stBadOpcode-pass branch 3 times, most recently from a5d804a to 239f5e7 Compare May 21, 2021 07:36
@AurelienRichez AurelienRichez changed the title [ETCM-846] make ETS stBadOpcode tests pass [WIP] [ETCM-846] make ETS stBadOpcode tests pass May 21, 2021
@AurelienRichez AurelienRichez force-pushed the fix/ETCM-846-make-stBadOpcode-pass branch 3 times, most recently from 6d9e0b3 to 868b21d Compare May 21, 2021 09:58
@AurelienRichez AurelienRichez changed the title [WIP] [ETCM-846] make ETS stBadOpcode tests pass [ETCM-846] make ETS stBadOpcode tests pass May 21, 2021
@dzajkowski
Copy link
Contributor

please also use the ticket tag in commit messages ([ECTM-846]) this enables integration with jira

@AurelienRichez AurelienRichez force-pushed the fix/ETCM-846-make-stBadOpcode-pass branch 3 times, most recently from 75f5ae4 to 56e61b6 Compare May 25, 2021 07:52
Copy link
Contributor

@jvdp jvdp left a comment

Choose a reason for hiding this comment

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

So it looks a lot simpler than the previous implementation and less dependent on InMemoryWorldStateProxy which sounds scary. (What's the impact of not using this anymore btw? Is it only for tests & test mode or also part of production code?)

Can you explain the main change a bit more? It's now more directly committing the genesis account to the blockchain instead of keeping it in the in-memory state?

@AurelienRichez AurelienRichez force-pushed the fix/ETCM-846-make-stBadOpcode-pass branch 3 times, most recently from ada8944 to a7bcf3a Compare May 26, 2021 10:58
@AurelienRichez AurelienRichez force-pushed the fix/ETCM-846-make-stBadOpcode-pass branch from a7bcf3a to f88e4f4 Compare May 26, 2021 12:46
@AurelienRichez
Copy link
Contributor Author

@jvdp

The change is only for testmode so it should not affect normal production. We should probably at some point refactor the code so that the test specific parts are in a dedicated module though (there is a ticket for that)

The main problem here was that the rootHash for account storage was not set properly in getGenesisStateRoot.

Regarding the ditching of InMemoryWorldStateProxy :

From what I see InMemoryWorldStateProxy is more focused on building a transient state when running transactions, i.e, taking an initial state, modifying it and then commit the new resulting state.

But when we load the genesis state we do not have an initial state to start with so we have a kind of a chicken and egg problem (no initial to set the storage, and the initial state needs a storage).

My first working solution was to create the genesis state with empty contract storage, call the function with InMemoryWorldStateProxy, get the root hashes from there and then reload the genesis this time with the real contract storage.

I found it weird to have this logic (there was no reason to initialize the state in two passes), and with some guidance from Konrad I found how to directly store arbitrary MPTs. Calling directly the storage layer allows to create the desired state in the database directly without the double genesis initialization trick.

@AurelienRichez AurelienRichez force-pushed the fix/ETCM-846-make-stBadOpcode-pass branch from f88e4f4 to 93a7084 Compare May 26, 2021 13:36
@AurelienRichez AurelienRichez force-pushed the fix/ETCM-846-make-stBadOpcode-pass branch from 93a7084 to 6a24a53 Compare May 27, 2021 14:58
@AurelienRichez AurelienRichez merged commit f144be7 into develop May 27, 2021
@AurelienRichez AurelienRichez deleted the fix/ETCM-846-make-stBadOpcode-pass branch May 27, 2021 15:58
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

Successfully merging this pull request may close these issues.

4 participants