aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorPaweł Bylica <pawel.bylica@imapp.pl>2014-10-30 19:37:21 +0800
committerPaweł Bylica <pawel.bylica@imapp.pl>2014-10-30 19:37:21 +0800
commitfdca7c8eede82e25843bf9190ffc8ece72f64060 (patch)
tree3d6c920ef3ae107e90f53dc4d8657d9b6c2c44f8
parentec9330609fa965b8928a99fd8e9b1e10a7c45fa0 (diff)
parent5110ffe3044a6c362ef29b33bc67c6d08c783451 (diff)
downloaddexon-solidity-fdca7c8eede82e25843bf9190ffc8ece72f64060.tar.gz
dexon-solidity-fdca7c8eede82e25843bf9190ffc8ece72f64060.tar.zst
dexon-solidity-fdca7c8eede82e25843bf9190ffc8ece72f64060.zip
Merge branch 'develop' into develop-evmcc
Conflicts: libevm/VM.h test/vm.cpp
-rw-r--r--solidityParser.cpp2
-rw-r--r--vm.cpp39
-rw-r--r--vm.h29
3 files changed, 37 insertions, 33 deletions
diff --git a/solidityParser.cpp b/solidityParser.cpp
index 025cd74d..701a6e76 100644
--- a/solidityParser.cpp
+++ b/solidityParser.cpp
@@ -185,7 +185,7 @@ BOOST_AUTO_TEST_CASE(while_loop)
{
char const* text = "contract test {\n"
" function fun(uint256 a) {\n"
- " uint256 x = (1 + 4).member(++67) || true;\n"
+ " while (true) { uint256 x = 1; break; continue; } x = 9;\n"
" }\n"
"}\n";
BOOST_CHECK_NO_THROW(parseText(text));
diff --git a/vm.cpp b/vm.cpp
index 56fe104e..102de7c4 100644
--- a/vm.cpp
+++ b/vm.cpp
@@ -130,7 +130,7 @@ bool FakeExtVM::call(Address _receiveAddress, u256 _value, bytesConstRef _data,
m_ms.internal.resize(m_ms.internal.size() + 1);
- auto ret = m_s.call(_receiveAddress,_codeAddressOverride ? _codeAddressOverride : _receiveAddress, _myAddressOverride ? _myAddressOverride : myAddress, _value, gasPrice, _data, _gas, _out, origin, &sub, &(m_ms.internal.back()), simpleTrace<ExtVM>(), 1);
+ auto ret = m_s.call(_receiveAddress,_codeAddressOverride ? _codeAddressOverride : _receiveAddress, _myAddressOverride ? _myAddressOverride : myAddress, _value, gasPrice, _data, _gas, _out, origin, &sub, &(m_ms.internal.back()), Executive::simpleTrace(), 1);
if (!m_ms.internal.back().from)
m_ms.internal.pop_back();
@@ -421,6 +421,39 @@ void FakeExtVM::importCallCreates(mArray& _callcreates)
}
}
+eth::OnOpFunc FakeExtVM::simpleTrace()
+{
+ return [](uint64_t steps, eth::Instruction inst, bigint newMemSize, bigint gasCost, void* voidVM, void const* voidExt)
+ {
+ FakeExtVM const& ext = *(FakeExtVM const*)voidExt;
+ eth::VM& vm = *(eth::VM*)voidVM;
+
+ std::ostringstream o;
+ o << std::endl << " STACK" << std::endl;
+ for (auto i: vm.stack())
+ o << (h256)i << std::endl;
+ o << " MEMORY" << std::endl << memDump(vm.memory());
+ o << " STORAGE" << std::endl;
+
+ for (auto const& i: ext.state().storage(ext.myAddress))
+ o << std::showbase << std::hex << i.first << ": " << i.second << std::endl;
+
+ for (auto const& i: std::get<2>(ext.addresses.find(ext.myAddress)->second))
+ o << std::showbase << std::hex << i.first << ": " << i.second << std::endl;
+
+ dev::LogOutputStream<eth::VMTraceChannel, false>(true) << o.str();
+ dev::LogOutputStream<eth::VMTraceChannel, false>(false) << " | " << std::dec << ext.depth << " | " << ext.myAddress << " | #" << steps << " | " << std::hex << std::setw(4) << std::setfill('0') << vm.curPC() << " : " << instructionInfo(inst).name << " | " << std::dec << vm.gas() << " | -" << std::dec << gasCost << " | " << newMemSize << "x32" << " ]";
+
+ if (eth::VMTraceChannel::verbosity <= g_logVerbosity)
+ {
+ std::ofstream f;
+ f.open("./vmtrace.log", std::ofstream::app);
+ f << o.str();
+ f << " | " << std::dec << ext.depth << " | " << ext.myAddress << " | #" << steps << " | " << std::hex << std::setw(4) << std::setfill('0') << vm.curPC() << " : " << instructionInfo(inst).name << " | " << std::dec << vm.gas() << " | -" << std::dec << gasCost << " | " << newMemSize << "x32";
+ }
+ };
+}
+
// THIS IS BROKEN AND NEEDS TO BE REMOVED.
h160 FakeState::createNewAddress(Address _newAddress, Address _sender, u256 _endowment, u256 _gasPrice, u256* _gas, bytesConstRef _code, Address _origin, SubState* o_sub, Manifest* o_ms, OnOpFunc const& _onOp, unsigned _level)
{
@@ -520,7 +553,7 @@ void doTests(json_spirit::mValue& v, bool _fillin)
fev.thisTxCode = get<3>(fev.addresses.at(fev.myAddress));
fev.code = &fev.thisTxCode;
}
-
+
auto vm = VMFace::create(fev.getVMKind(), fev.gas);
bytes output;
auto outOfGas = false;
@@ -528,7 +561,7 @@ void doTests(json_spirit::mValue& v, bool _fillin)
auto startTime = std::chrono::high_resolution_clock::now();
try
{
- output = vm->go(fev, fev.simpleTrace<FakeExtVM>()).toVector();
+ output = vm->go(fev, fev.simpleTrace()).toVector();
}
catch (OutOfGas const&)
{
diff --git a/vm.h b/vm.h
index e51fe3f8..b3397b2c 100644
--- a/vm.h
+++ b/vm.h
@@ -83,9 +83,7 @@ public:
void setVMKind(eth::VMFace::Kind _kind) { m_s.setVMKind(_kind); }
eth::VMFace::Kind getVMKind() const { return m_s.getVMKind(); }
- template<typename ExtVMType>
eth::OnOpFunc simpleTrace();
-
FakeState state() const { return m_s; }
std::map<Address, std::tuple<u256, u256, std::map<u256, u256>, bytes>> addresses;
@@ -99,32 +97,5 @@ private:
eth::Manifest m_ms;
};
-template<typename ExtVMType>
-eth::OnOpFunc FakeExtVM::simpleTrace()
-{
- return [](uint64_t steps, eth::Instruction inst, bigint newMemSize, bigint gasCost, void* voidVM, void const* voidExt)
- {
- ExtVMType const& ext = *(ExtVMType const*)voidExt;
- eth::VM& vm = *(eth::VM*)voidVM;
-
- std::ostringstream o;
- o << std::endl << " STACK" << std::endl;
- for (auto i: vm.stack())
- o << (h256)i << std::endl;
- o << " MEMORY" << std::endl << memDump(vm.memory());
- o << " STORAGE" << std::endl;
- for (auto const& i: ext.state().storage(ext.myAddress))
- o << std::showbase << std::hex << i.first << ": " << i.second << std::endl;
- dev::LogOutputStream<eth::VMTraceChannel, false>(true) << o.str();
- dev::LogOutputStream<eth::VMTraceChannel, false>(false) << " | " << std::dec << ext.depth << " | " << ext.myAddress << " | #" << steps << " | " << std::hex << std::setw(4) << std::setfill('0') << vm.curPC() << " : " << instructionInfo(inst).name << " | " << std::dec << vm.gas() << " | -" << std::dec << gasCost << " | " << newMemSize << "x32" << " ]";
- if (eth::VMTraceChannel::verbosity <= g_logVerbosity)
- {
- std::ofstream f;
- f.open("./vmtrace.log", std::ofstream::app);
- f << o.str();
- f << " | " << std::dec << ext.depth << " | " << ext.myAddress << " | #" << steps << " | " << std::hex << std::setw(4) << std::setfill('0') << vm.curPC() << " : " << instructionInfo(inst).name << " | " << std::dec << vm.gas() << " | -" << std::dec << gasCost << " | " << newMemSize << "x32";
- }
- };
-}
} } // Namespace Close