-
Notifications
You must be signed in to change notification settings - Fork 2.2k
Conversation
bbe1350
to
555050f
Compare
@@ -1,5 +1,7 @@ | |||
#pragma once | |||
|
|||
#include "db.h" |
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 vector_ref.h file uses DEV_LDB
macro defined in db.h
This came up after reordering of #include's in another file
@@ -45,7 +45,7 @@ class Ethash: public SealEngineBase | |||
|
|||
StringHashMap jsInfo(BlockHeader const& _bi) const override; | |||
void verify(Strictness _s, BlockHeader const& _bi, BlockHeader const& _parent, bytesConstRef _block) const override; | |||
void verifyTransaction(ImportRequirements::value _ir, TransactionBase const& _t, EnvInfo const& _env) const override; | |||
void verifyTransaction(ImportRequirements::value _ir, TransactionBase const& _t, BlockHeader const& _header, u256 const& _startGasUsed) const override; |
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.
The reason for this change is that I find it weird that transaction validation depends on EnvInfo
which describes an enviroment for VM execution.
Also EnvInfo
now contains a pointer to LastBlockHashesFace
, which shouldn't have to do with transation validation.
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 am happy to see these dependencies go.
555050f
to
6951d6d
Compare
Codecov Report
@@ Coverage Diff @@
## develop #4126 +/- ##
===========================================
+ Coverage 66.94% 67.16% +0.21%
===========================================
Files 299 301 +2
Lines 23138 23126 -12
===========================================
+ Hits 15490 15532 +42
+ Misses 7648 7594 -54
|
@@ -100,10 +100,6 @@ class Client: public ClientBase, protected Worker | |||
/// Queues a block for import. | |||
ImportResult queueBlock(bytes const& _block, bool _isSafe = false); | |||
|
|||
using Interface::call; // to remove warning about hiding virtual function | |||
/// Makes the given call. Nothing is recorded into the state. This cheats by creating a null address and endowing it with a lot of ETH. | |||
ExecutionResult call(Address _dest, bytes const& _data = bytes(), u256 _gas = 125000, u256 _value = 0, u256 _gasPrice = 1 * ether, Address const& _from = Address()); |
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 not used
@@ -95,13 +95,6 @@ class Interface | |||
ExecutionResult call(Secret const& _secret, u256 _value, Address _dest, bytes const& _data, u256 _gas, u256 _gasPrice, BlockNumber _blockNumber, FudgeFactor _ff = FudgeFactor::Strict) { return call(toAddress(_secret), _value, _dest, _data, _gas, _gasPrice, _blockNumber, _ff); } | |||
ExecutionResult call(Secret const& _secret, u256 _value, Address _dest, bytes const& _data, u256 _gas, u256 _gasPrice, FudgeFactor _ff = FudgeFactor::Strict) { return call(toAddress(_secret), _value, _dest, _data, _gas, _gasPrice, _ff); } | |||
|
|||
/// Does the given creation. Nothing is recorded into the 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.
These were not used
6951d6d
to
ac33ed8
Compare
@@ -313,7 +313,7 @@ int main(int argc, char** argv) | |||
|
|||
if (mode == Mode::Statistics) | |||
{ | |||
cout << "Gas used: " << res.gasUsed << " (+" << t.baseGasRequired(se->evmSchedule(envInfo)) << " for transaction, -" << res.gasRefunded << " refunded)" << endl; | |||
cout << "Gas used: " << res.gasUsed << " (+" << t.baseGasRequired(se->evmSchedule(envInfo.number())) << " for transaction, -" << res.gasRefunded << " refunded)" << endl; |
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.
will this affect VMTests ?
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.
Definitely not, this change is just giving evmSchedule
the only thing it needs - block number instead of the whole EnvInfo
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.
tests work fine
libethcore/SealEngine.h
Outdated
@@ -75,7 +75,7 @@ class SealEngineFace | |||
ChainOperationParams const& chainParams() const { return m_params; } | |||
void setChainParams(ChainOperationParams const& _params) { m_params = _params; } | |||
SealEngineFace* withChainParams(ChainOperationParams const& _params) { setChainParams(_params); return this; } | |||
virtual EVMSchedule const& evmSchedule(EnvInfo const&) const = 0; | |||
virtual EVMSchedule const& evmSchedule(u256 const&) const = 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.
Name the parameter?
libethcore/SealEngine.h
Outdated
@@ -105,7 +105,7 @@ class SealEngineBase: public SealEngineFace | |||
m_onSealGenerated(ret.out()); | |||
} | |||
void onSealGenerated(std::function<void(bytes const&)> const& _f) override { m_onSealGenerated = _f; } | |||
EVMSchedule const& evmSchedule(EnvInfo const&) const override; | |||
EVMSchedule const& evmSchedule(u256 const&) const override; |
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.
Name the parameter?
libevm/ExtVMFace.h
Outdated
@@ -228,30 +227,32 @@ class EnvInfo | |||
{ | |||
public: | |||
EnvInfo() {} | |||
EnvInfo(BlockHeader const& _current, LastHashes const& _lh = LastHashes(), u256 const& _gasUsed = u256()): | |||
EnvInfo(BlockHeader const& _current, std::shared_ptr<LastBlockHashesFace const> _lh, u256 const& _gasUsed): |
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 can't to figure out the reason this is the shared_ptr.
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 tried to get rid of it and pass LastBlockHashesFace const&
around, but I gave up because some test code need setting & resetting this interface into EnvInfo
(calling EnvInfo::setLastHashes()
)
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 code to be exact: https:/ethereum/cpp-ethereum/pull/4126/files#diff-e01cd53eebd917cc35354ffc7719d8adR295
Probably there's a way to change this test code somehow... modifying EnvInfo
is a weird thing to do in general
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 like the shared_ptr here either, but can't tell you how to fix it.
libevm/ExtVMFace.h
Outdated
void setLastHashes(LastHashes&& _lh) { m_lastHashes = _lh; } | ||
|
||
void setLastHashes(std::shared_ptr<LastBlockHashesFace const> _lh) { m_lastHashes = _lh; } | ||
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.
Spurious space.
I like the direction it is going. And I also want less dependencies on test framework. Just can we use unique PTR instead? |
@chfast Hm, making it |
I'm trying to replace If it does work out, it probably better should go into separate PR |
0a4d215
to
778418e
Compare
@@ -274,6 +283,8 @@ int main(int argc, char** argv) | |||
state.addBalance(sender, value); | |||
|
|||
unique_ptr<SealEngineFace> se(ChainParams(genesisInfo(networkName)).createSealEngine()); | |||
LastBlockHashes lastBlockHashes; | |||
EnvInfo const envInfo(blockHeader, lastBlockHashes, 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.
Looks like previously ethvm
tool didn't work for the code containing BLOCKHASH. Now any BLOCKHASH will return 0
778418e
to
14997eb
Compare
6e75183
to
f3e90f5
Compare
I've replaced Tests are green now, please review the changes @chfast @gcolvin @pirapira @winsvega |
libethereum/BlockChain.cpp
Outdated
h256s precedingHashes(h256 const& _mostRecentHash) const override | ||
{ | ||
Guard l(m_lastHashesMutex); | ||
if (m_lastHashes.empty() || m_lastHashes.back() != _mostRecentHash) |
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 mean front
instead of back
?
In a following line I see m_lastHashes[0] = _mostRecentHash
.
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.
Yeah, looks like it was incorrect in the original code, nice catch!
LastHashes BlockChain::lastHashes(h256 const& _parent) const | ||
{ | ||
Guard l(x_lastLastHashes); | ||
if (m_lastLastHashes.empty() || m_lastLastHashes.back() != _parent) |
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 see the back
is inherited from here.
f3e90f5
to
b45e406
Compare
Follow-up to #4066
Resolves #4084
Refactoring basically replaces
LastHashes
vector constructed byBlockchain
class and passed toExecutive
when we need to execute some VM code withLastBlockHashesFace
interface provided byBlockChain
class.The new interface constructs exactly the same vector, and the behavior before Metropolis is not changed.
After Metropolis BLOCKHASH doesn't access this interface (performs a call to contract instead) and this way we avoid constructing unnecessary hash vector.