-
Notifications
You must be signed in to change notification settings - Fork 2.2k
Conversation
Codecov Report
@@ Coverage Diff @@
## develop #4275 +/- ##
===========================================
+ Coverage 67.48% 67.49% +<.01%
===========================================
Files 306 306
Lines 23450 23472 +22
===========================================
+ Hits 15826 15843 +17
- Misses 7624 7629 +5
|
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 need also to modify Block::stateRootBeforeTx
, so that it returns 0 when receipt doesn't have state root - this is what RPC methods that need intermediate state rely on.
libethereum/TransactionReceipt.h
Outdated
@@ -52,7 +58,12 @@ class TransactionReceipt | |||
bytes rlp() const { RLPStream s; streamRLP(s); return s.out(); } | |||
|
|||
private: | |||
h256 m_stateRoot; | |||
bool m_hasStatusCode = false; | |||
union |
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'd suggest trying to use boost::variant
for this, it kind of encapsulates union + type variable
Also |
More exactly, |
183ce75
to
0ddd07a
Compare
I started using |
libethereum/TransactionReceipt.cpp
Outdated
_s.appendList(3); | ||
|
||
_s << m_gasUsed << m_bloom; | ||
struct appenderVisitor : boost::static_visitor<void> |
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.
Wow, couldn't we just do something like
if (m_statusCodeOrStateRoot.which() == 0)
_s << boost::get<uint8_t>(m_statusCodeOrStateRoot);
else
_s << boost::get<h256>(m_statusCodeOrStateRoot);
libethereum/TransactionReceipt.cpp
Outdated
{ | ||
try | ||
{ | ||
return boost::get<h256>(m_statusCodeOrStateRoot); |
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.
In stateRoot
you use different approach than in hasStatusCode
& stateRoot
, choose one for consistency (the one without visitor is easier).
I would actually prefer just
if (m_statusCodeOrStateRoot.which() == 1)
return boost::get<h256>(m_statusCodeOrStateRoot);
else
BOOST_THROW_EXCEPTION(TransactionReceiptVersionError());
I made everything into |
libethereum/TransactionReceipt.cpp
Outdated
@@ -22,54 +22,88 @@ | |||
#include "TransactionReceipt.h" | |||
#include <libethcore/Exceptions.h> | |||
|
|||
#include <boost/variant/static_visitor.hpp> |
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 one is not needed now
libethereum/Block.cpp
Outdated
{ | ||
return (_i > 0 ? receipt(_i - 1).stateRoot() : m_previousBlock.stateRoot()); | ||
} | ||
catch(TransactionReceiptVersionError const&) |
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.
space after catch
libethereum/TransactionReceipt.cpp
Outdated
if (r[0].size() == 32) | ||
m_statusCodeOrStateRoot = (h256)r[0]; | ||
else if (r[0].size() == 1) | ||
m_statusCodeOrStateRoot = (uint8_t)r[0]; |
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.
Probable add else BOOST_THROW_EXCEPTION(InvalidTransactionReceiptFormat());
libweb3jsonrpc/JsonHelper.cpp
Outdated
@@ -185,7 +185,14 @@ Json::Value toJson(dev::eth::TransactionSkeleton const& _t) | |||
Json::Value toJson(dev::eth::TransactionReceipt const& _t) | |||
{ | |||
Json::Value res; | |||
res["stateRoot"] = toJS(_t.stateRoot()); | |||
try |
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.
Maybe somewhat simpler would be to use hasStatusCode()
instead of try/catch
libethereum/TransactionReceipt.h
Outdated
/// @returns true if the receipt has a status code. Otherwise the receipt has a state root (pre-EIP658). | ||
bool hasStatusCode() const; | ||
/// @returns the state root. | ||
/// @throw TransactionReceiptVersionError when m_hasStatusCode is true. |
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.
Fix comment, there's no m_hasStatusCode
anymore
ee46ab2
to
eca4fbf
Compare
eca4fbf
to
c9d14fc
Compare
Spec: ethereum/EIPs#658