-
Notifications
You must be signed in to change notification settings - Fork 2.2k
test_getPostState #4972
test_getPostState #4972
Conversation
libweb3jsonrpc/Test.cpp
Outdated
continue; | ||
|
||
Json::Value o; | ||
if (mapEmpty || _map.at(a.first).hasBalance()) |
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.
Why is this empty case treated in a special way?
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.
this is actually a copy of the same method from tests. but that one works with json_spirit.
I guess the account map here could be removed. because it is needed for expect sections with incomplete post states.
Codecov Report
@@ Coverage Diff @@
## develop #4972 +/- ##
===========================================
- Coverage 61.08% 60.95% -0.14%
===========================================
Files 350 350
Lines 28303 28379 +76
Branches 2889 2893 +4
===========================================
+ Hits 17290 17299 +9
- Misses 10049 10118 +69
+ Partials 964 962 -2 |
libweb3jsonrpc/Test.cpp
Outdated
if (_state.code(a.first).size() > 0) | ||
o["code"] = toHexPrefixed(_state.code(a.first)); | ||
else | ||
o["code"] = ""; |
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 you really need to separate these two cases? What's wrong if o["code"]
becomes 0x
?
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 right. changed this now
libweb3jsonrpc/Test.cpp
Outdated
else | ||
return toJS(EmptyListSHA3); | ||
} | ||
return ""; |
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.
I think this case should be an error, rather than just an empty reply.
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.
how do we report an error via RPC reply ?
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.
I don't know, look at other methods.
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.
well there is BOOST_THROW_EXCEPTION(JsonRpcException(Errors::ERROR_RPC_INVALID_PARAMS));
but it stops the client. which is not a good thing. you dont want a client to stop on malicious rpc
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.
It shouldn't stop the client, all RPC methods report errors kind of like that and the last time I tried it I saw correct error message on the caller side.
Could you investigate whether it crashes because of unhandled exception or for other reason?
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.
Also related issue is #4726
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.
no. it does not crash the client. I was wrong. the rpc error is returned.
libweb3jsonrpc/Test.cpp
Outdated
{ | ||
Json::Value out; | ||
Json::FastWriter fastWriter; | ||
if (u256(param1["version"].asString()) == c_postStateJustHashVersion) |
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.
Does the RPC method take 1
, 2
, or 3
, indicating different versions? In other parts of the RPC, "latest" means "latest", and so on. I guess strings like "jushash" "fullstate" or "loghash" are easier.
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.
no problem here. it could be anything.
the discussion is here
ethereum/retesteth#7
23615c2
to
d37e20c
Compare
@pirapira do you have any more proposals? |
Actually should this method be a test method only ? |
API-design-wise it should better be three different API methods instead of one method doing completely different things based on "version" param |
else if (param1["version"].asString() == c_postStateLogHashVersion) | ||
{ | ||
if (m_eth.blockChain().receipts().receipts.size() != 0) | ||
return exportLog(m_eth.blockChain().receipts().receipts[0].log()); |
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.
This gets the receipt of only the first transaction of the block, is this your intention?
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.
Couldn't you just use receipts root which is in the block header?
Json::Value out; | ||
Json::FastWriter fastWriter; | ||
if (param1["version"].asString() == c_postStateJustHashVersion) | ||
return toJS(m_eth.postState().state().rootHash()); |
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.
Is this any different from getting eth.getBlock("latest").stateRoot
?
@@ -33,6 +34,60 @@ using namespace jsonrpc; | |||
|
|||
Test::Test(eth::Client& _eth): m_eth(_eth) {} | |||
|
|||
Json::Value fillJsonWithState(eth::State const& _state) |
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.
Put free functions into the unnamed namespace
Casey said there are debug methods specified for mainnet.
this getPost state method should probably be implemented with those debug methods. |
I'm also for it. It's better to have many simple RPC methods than not many but complex RPC methods. Having simple ones you can who is using what and why. And also able to deprecate individual methods in future. |
This method will be replaced by
which could work on mainnet. with the first one you could select accounts in state at specific block after specific transaction. with the second you could select post state values of a specific account in a specific block after specific transaction. |
return current actual post state of the blockchain.