-
Notifications
You must be signed in to change notification settings - Fork 75
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
[ETCM-878] blockchain tests : BlockchainTests/vmArithmeticTest #1002
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
While this PR improves the implementation of
storageRangeAt
andgetAccountsInRange
, they are still not completely functional. They only work in test mode.
With the knowledge you've gained fixing these tests so far: with so much of this stuff being test-mode specific, do you think there's a missed opportunity for covering more of the production code by ETS?
Also, is there an issue that the testservice now has very different operation compared to the other RPC services? (eg. the regular eth_
methods listed here: https://github.com/ethereum/retesteth/wiki/RPC-Methods) Or am I misunderstanding how this works?
Finally, run retesteth in Nix in Docker: | ||
|
||
nix-in-docker/run --command "ets/retesteth -t GeneralStateTests" | ||
nix-in-docker/run --command "ets/retesteth -t GeneralStateTests -- --nodes <ip>:8546" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Cool! 👍
if (bigIntValue != 0) | ||
ByteString(byteArrayValue.dropWhile(_ == 0)) | ||
else | ||
ByteString(byteArrayValue) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks like a job for regexes to me!
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You mean we should change the output when transforming to a String in test service ? Here we are using BigInt and byte arrays. As It seems not really correct that getAccountStorageAt
might return 33 bytes I fixed it here.
* nexKey field is the next key hash if any key left in the state, or 0x00 otherwise. | ||
* | ||
* Normally, this RPC method is supposed to also be able to look up the state after after transaction | ||
* _txIndex is executed. This is currently not supported in mantis. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Do we have a ticket to track this lack of support? And are tests failing because of it?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We have ETCM-784 and ETCM-758 which are related to this. I'll add a comment there.
I did not find any test specifically failing because of this but I did not really look why other suites are failing. So I went with an iterative approach by implementing the minimum to make vmArithmeticTest
pass.
src/main/scala/io/iohk/ethereum/testmode/TestModeWorldStateProxy.scala
Outdated
Show resolved
Hide resolved
ca19c1d
to
f3ea767
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
a couple non-blocking comments, otherwise looks good 👍🏻
7401e36
to
4c418b0
Compare
4c418b0
to
6e518f2
Compare
Description
This PR is part of the ogoing effort to make ETS pass all tests. The vmArithmeticTest suite did not pass because of several problems :
sealEngine
parameter and were always running withNoReward
when mantis was running in test modegetAccountStorage
sometime wrongly had leading zeros due to a sign bit added by BigInt.toByteAray.storageRangeAt
did not return a range of value and took a key instead of a hash as input. This kind of worked because most test used0x00
as storage keygetAccountsInRange
did not included the coinbase account. It also depended on some state instead of taking the hash given as a parameter to find the start of its range.Fixing those problem also fixes lots of other tests
Important Changes Introduced
Most of the changes are external to the production code. The most impactful change is probably in
BlockchainImpl
where we now remove the leading zeros. I don't think this impact other parts of the application.Regarding
TestService.scala
, I removed the variableaccountRangeOffset
. I also added some state in testmode with a mappreimageCache
. This map is used to keep track of what storage address were used during one test run and be able to implementstorageRangeAt
. This is not really elegant so I will be happy for suggestion on how to make it better.Important note
While this PR improves the implementation of
storageRangeAt
andgetAccountsInRange
, they are still not completely functional. They only work in test mode. There are also some edge case not handled :getAccountsInRange
is only able to return account known in the genesis state and the account used for coinbase (So it won't return account created in a transaction)storageRangeAt
should be able to get the state not only on a given block but also after an arbitrary transaction inside the block. We currently only handle the first case. I'm not sure the tests actually need the second part so it might be alright for ETS.Also the
storageRangeAt
implementation is not really smart. It just iterate over known keys instead of actually reading the Merkle Patricia Trie. For tests with few values in storage It's good enough though.