Fabcoin Core  0.16.2
P2P Digital Currency
vm.cpp
Go to the documentation of this file.
1 /*
2  This file is part of cpp-ethereum.
3 
4  cpp-ethereum is free software: you can redistribute it and/or modify
5  it under the terms of the GNU General Public License as published by
6  the Free Software Foundation, either version 3 of the License, or
7  (at your option) any later version.
8 
9  cpp-ethereum is distributed in the hope that it will be useful,
10  but WITHOUT ANY WARRANTY; without even the implied warranty of
11  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12  GNU General Public License for more details.
13 
14  You should have received a copy of the GNU General Public License
15  along with cpp-ethereum. If not, see <http://www.gnu.org/licenses/>.
16 */
23 #include <boost/filesystem.hpp>
24 
25 #include <libethereum/Executive.h>
26 #include <libevm/VMFactory.h>
27 #include <libevm/ExtVMFace.h>
28 #include "vm.h"
29 
30 using namespace std;
31 using namespace json_spirit;
32 using namespace dev;
33 using namespace dev::eth;
34 using namespace dev::test;
35 
36 FakeExtVM::FakeExtVM(EnvInfo const& _envInfo, unsigned _depth):
37  ExtVMFace(_envInfo, Address(), Address(), Address(), 0, 1, bytesConstRef(), bytes(), EmptySHA3, _depth)
38 {}
39 
40 h160 FakeExtVM::create(u256 _endowment, u256& io_gas, bytesConstRef _init, OnOpFunc const&)
41 {
43 
44  Transaction t(_endowment, gasPrice, io_gas, _init.toBytes());
45  callcreates.push_back(t);
46  return na;
47 }
48 
49 boost::optional<eth::owning_bytes_ref> FakeExtVM::call(CallParameters& _p)
50 {
52  callcreates.push_back(t);
53  return eth::owning_bytes_ref{}; // Return empty output.
54 }
55 
56 void FakeExtVM::set(Address _a, u256 _myBalance, u256 _myNonce, map<u256, u256> const& _storage, bytes const& _code)
57 {
58  get<0>(addresses[_a]) = _myBalance;
59  get<1>(addresses[_a]) = _myNonce;
60  get<2>(addresses[_a]) = _storage;
61  get<3>(addresses[_a]) = _code;
62 }
63 
64 void FakeExtVM::reset(u256 _myBalance, u256 _myNonce, map<u256, u256> const& _storage)
65 {
66  callcreates.clear();
67  addresses.clear();
68  set(myAddress, _myBalance, _myNonce, _storage, get<3>(addresses[myAddress]));
69 }
70 
72 {
73  mObject ret;
74  ret["currentDifficulty"] = toCompactHex(envInfo().difficulty(), HexPrefix::Add, 1);
75  ret["currentTimestamp"] = toCompactHex(envInfo().timestamp(), HexPrefix::Add, 1);
76  ret["currentCoinbase"] = toString(envInfo().author());
77  ret["currentNumber"] = toCompactHex(envInfo().number(), HexPrefix::Add, 1);
78  ret["currentGasLimit"] = toCompactHex(envInfo().gasLimit(), HexPrefix::Add, 1);
79  return ret;
80 }
81 
83 {
84  // cant use BOOST_REQUIRE, because this function is used outside boost test (createRandomTest)
85  assert(_o.count("currentGasLimit") > 0);
86  assert(_o.count("currentDifficulty") > 0);
87  assert(_o.count("currentTimestamp") > 0);
88  assert(_o.count("currentCoinbase") > 0);
89  assert(_o.count("currentNumber") > 0);
90  auto gasLimit = toInt(_o["currentGasLimit"]);
92 
93  EnvInfo info;
94  info.setGasLimit(gasLimit.convert_to<int64_t>());
95  info.setDifficulty(toInt(_o["currentDifficulty"]));
96  info.setTimestamp(toInt(_o["currentTimestamp"]));
97  info.setAuthor(Address(_o["currentCoinbase"].get_str()));
98  info.setNumber(toInt(_o["currentNumber"]));
99  info.setLastHashes( lastHashes( info.number() ) );
100  return info;
101 }
102 
104 {
105  mObject ret;
106  for (auto const& a: addresses)
107  {
108  mObject o;
109  o["balance"] = toCompactHex(get<0>(a.second), HexPrefix::Add, 1);
110  o["nonce"] = toCompactHex(get<1>(a.second), HexPrefix::Add, 1);
111  {
112  mObject store;
113  for (auto const& s: get<2>(a.second))
114  store[toCompactHex(s.first, HexPrefix::Add, 1)] = toCompactHex(s.second, HexPrefix::Add, 1);
115  o["storage"] = store;
116  }
117  o["code"] = toHex(get<3>(a.second), 2, HexPrefix::Add);
118  ret[toString(a.first)] = o;
119  }
120  return ret;
121 }
122 
124 {
125  for (auto const& i: _object)
126  {
127  mObject o = i.second.get_obj();
128  // cant use BOOST_REQUIRE, because this function is used outside boost test (createRandomTest)
129  assert(o.count("balance") > 0);
130  assert(o.count("nonce") > 0);
131  assert(o.count("storage") > 0);
132  assert(o.count("code") > 0);
133 
134  auto& a = addresses[Address(i.first)];
135  get<0>(a) = toInt(o["balance"]);
136  get<1>(a) = toInt(o["nonce"]);
137  for (auto const& j: o["storage"].get_obj())
138  get<2>(a)[toInt(j.first)] = toInt(j.second);
139 
140  get<3>(a) = importCode(o);
141  }
142 }
143 
145 {
146  mObject ret;
147  ret["address"] = toString(myAddress);
148  ret["caller"] = toString(caller);
149  ret["origin"] = toString(origin);
150  ret["value"] = toCompactHex(value, HexPrefix::Add, 1);
151  ret["gasPrice"] = toCompactHex(gasPrice, HexPrefix::Add, 1);
152  ret["gas"] = toCompactHex(execGas, HexPrefix::Add, 1);
153  ret["data"] = toHex(data, 2, HexPrefix::Add);
154  ret["code"] = toHex(code, 2, HexPrefix::Add);
155  return ret;
156 }
157 
159 {
160  // cant use BOOST_REQUIRE, because this function is used outside boost test (createRandomTest)
161  assert(_o.count("address")> 0);
162  assert(_o.count("caller") > 0);
163  assert(_o.count("origin") > 0);
164  assert(_o.count("value") > 0);
165  assert(_o.count("data") > 0);
166  assert(_o.count("gasPrice") > 0);
167  assert(_o.count("gas") > 0);
168 
169  myAddress = Address(_o["address"].get_str());
170  caller = Address(_o["caller"].get_str());
171  origin = Address(_o["origin"].get_str());
172  value = toInt(_o["value"]);
173  gasPrice = toInt(_o["gasPrice"]);
174  gas = toInt(_o["gas"]);
175  execGas = gas;
176 
177  thisTxCode.clear();
178  code = thisTxCode;
179 
180  thisTxCode = importCode(_o);
181  if (_o["code"].type() != str_type && _o["code"].type() != array_type)
182  code.clear();
183 
184  thisTxData.clear();
185  thisTxData = importData(_o);
186 
187  data = &thisTxData;
188 }
189 
191 {
192  mArray ret;
193  for (Transaction const& tx: callcreates)
194  {
195  mObject o;
196  o["destination"] = tx.isCreation() ? "" : toString(tx.receiveAddress());
197  o["gasLimit"] = toCompactHex(tx.gas(), HexPrefix::Add, 1);
198  o["value"] = toCompactHex(tx.value(), HexPrefix::Add, 1);
199  o["data"] = toHex(tx.data(), 2, HexPrefix::Add);
200  ret.push_back(o);
201  }
202  return ret;
203 }
204 
206 {
207  for (mValue& v: _callcreates)
208  {
209  auto tx = v.get_obj();
210  assert(tx.count("data") > 0);
211  assert(tx.count("value") > 0);
212  assert(tx.count("destination") > 0);
213  assert(tx.count("gasLimit") > 0);
214  Transaction t = tx["destination"].get_str().empty() ?
215  Transaction(toInt(tx["value"]), 0, toInt(tx["gasLimit"]), fromHex(tx["data"].get_str())) :
216  Transaction(toInt(tx["value"]), 0, toInt(tx["gasLimit"]), Address(tx["destination"].get_str()), fromHex(tx["data"].get_str()));
217  callcreates.push_back(t);
218  }
219 }
220 
222 {
223 
224  return [](uint64_t steps, uint64_t pc, eth::Instruction inst, bigint newMemSize, bigint gasCost, bigint gas, dev::eth::VM* voidVM, dev::eth::ExtVMFace const* voidExt)
225  {
226  FakeExtVM const& ext = *static_cast<FakeExtVM const*>(voidExt);
227  eth::VM& vm = *voidVM;
228 
229  std::ostringstream o;
230  o << std::endl << " STACK" << std::endl;
231  for (auto i: vm.stack())
232  o << (h256)i << std::endl;
233  o << " MEMORY" << std::endl << memDump(vm.memory());
234  o << " STORAGE" << std::endl;
235 
236  for (auto const& i: std::get<2>(ext.addresses.find(ext.myAddress)->second))
237  o << std::showbase << std::hex << i.first << ": " << i.second << std::endl;
238 
240  dev::LogOutputStream<eth::VMTraceChannel, false>() << " | " << std::dec << ext.depth << " | " << ext.myAddress << " | #" << steps << " | " << std::hex << std::setw(4) << std::setfill('0') << pc << " : " << instructionInfo(inst).name << " | " << std::dec << gas << " | -" << std::dec << gasCost << " | " << newMemSize << "x32" << " ]";
241 
242  /*creates json stack trace*/
244  {
245  Object o_step;
246 
247  /*add the stack*/
248  Array a_stack;
249  for (auto i: vm.stack())
250  a_stack.push_back((string)i);
251 
252  o_step.push_back(Pair( "stack", a_stack ));
253 
254  /*add the memory*/
255  Array a_mem;
256  for(auto i: vm.memory())
257  a_mem.push_back(i);
258 
259  o_step.push_back(Pair("memory", a_mem));
260 
261  /*add the storage*/
262  Object storage;
263  for (auto const& i: std::get<2>(ext.addresses.find(ext.myAddress)->second))
264  storage.push_back(Pair( (string)i.first , (string)i.second));
265 
266  /*add all the other details*/
267  o_step.push_back(Pair("storage", storage));
268  o_step.push_back(Pair("depth", to_string(ext.depth)));
269  o_step.push_back(Pair("gas", (string)gas));
270  o_step.push_back(Pair("address", toString(ext.myAddress )));
271  o_step.push_back(Pair("step", steps ));
272  o_step.push_back(Pair("pc", pc));
273  o_step.push_back(Pair("opcode", instructionInfo(inst).name ));
274 
275  /*append the JSON object to the log file*/
276  Value v(o_step);
277  ofstream os( "./stackTrace.json", ofstream::app);
278  os << write_string(v, true) << ",";
279  os.close();
280  }
281  };
282 }
283 
284 namespace dev { namespace test {
285 
286 void doVMTests(json_spirit::mValue& _v, bool _fillin)
287 {
288  if (string(boost::unit_test::framework::current_test_case().p_name) != "vmRandom")
290 
291  for (auto& i: _v.get_obj())
292  {
293  string testname = i.first;
294  json_spirit::mObject& o = i.second.get_obj();
295 
296  if (!TestOutputHelper::passTest(o, testname))
297  continue;
298 
299  BOOST_REQUIRE_MESSAGE(o.count("env") > 0, testname + "env not set!");
300  BOOST_REQUIRE_MESSAGE(o.count("pre") > 0, testname + "pre not set!");
301  BOOST_REQUIRE_MESSAGE(o.count("exec") > 0, testname + "exec not set!");
302 
303  eth::EnvInfo env = FakeExtVM::importEnv(o["env"].get_obj());
304  FakeExtVM fev(env);
305  fev.importState(o["pre"].get_obj());
306 
307  if (_fillin)
308  o["pre"] = mValue(fev.exportState());
309 
310  fev.importExec(o["exec"].get_obj());
311  if (fev.code.empty())
312  {
313  fev.thisTxCode = get<3>(fev.addresses.at(fev.myAddress));
314  fev.code = fev.thisTxCode;
315  }
316  fev.codeHash = sha3(fev.code);
317 
318  owning_bytes_ref output;
319  bool vmExceptionOccured = false;
320  try
321  {
322  auto vm = eth::VMFactory::create();
323  auto vmtrace = Options::get().vmtrace ? fev.simpleTrace() : OnOpFunc{};
324  {
325  Listener::ExecTimeGuard guard{i.first};
326  auto gas = static_cast<int64_t>(fev.gas);
327  output = vm->exec(fev.gas, fev, vmtrace);
328  gas -= static_cast<int64_t>(fev.gas);
329  guard.setGasUsed(gas);
330  }
331  }
332  catch (VMException const&)
333  {
334  cnote << " Safe VM Exception\n";
335  vmExceptionOccured = true;
336  }
337  catch (Exception const& _e)
338  {
339  cnote << "VM did throw an exception: " << diagnostic_information(_e);
340  BOOST_ERROR("Failed VM Test with Exception: " << _e.what());
341  }
342  catch (std::exception const& _e)
343  {
344  cnote << "VM did throw an exception: " << _e.what();
345  BOOST_ERROR("Failed VM Test with Exception: " << _e.what());
346  }
347 
348  // delete null entries in storage for the sake of comparison
349 
350  for (auto &a: fev.addresses)
351  {
352  vector<u256> keystoDelete;
353  for (auto &s: get<2>(a.second))
354  {
355  if (s.second == 0)
356  keystoDelete.push_back(s.first);
357  }
358  for (auto const key: keystoDelete )
359  {
360  get<2>(a.second).erase(key);
361  }
362  }
363 
364  if (_fillin)
365  {
366  o["env"] = mValue(fev.exportEnv());
367  o["exec"] = mValue(fev.exportExec());
368  if (!vmExceptionOccured)
369  {
370  o["post"] = mValue(fev.exportState());
371 
372  if (o.count("expect") > 0)
373  {
374  State postState(State::Null);
375  State expectState(State::Null);
376  AccountMaskMap expectStateMap;
377  ImportTest::importState(o["post"].get_obj(), postState);
378  ImportTest::importState(o["expect"].get_obj(), expectState, expectStateMap);
379  ImportTest::compareStates(expectState, postState, expectStateMap, Options::get().checkstate ? WhenError::Throw : WhenError::DontThrow);
380  o.erase(o.find("expect"));
381  }
382 
383  o["callcreates"] = fev.exportCallCreates();
384  o["out"] = output.size() > 4096 ? "#" + toString(output.size()) : toHex(output, 2, HexPrefix::Add);
385 
386  // compare expected output with post output
387  if (o.count("expectOut") > 0)
388  {
389  std::string warning = "Check State: Error! Unexpected output: " + o["out"].get_str() + " Expected: " + o["expectOut"].get_str();
390  if (Options::get().checkstate)
391  BOOST_CHECK_MESSAGE(o["out"].get_str() == o["expectOut"].get_str(), warning);
392  else
393  BOOST_WARN_MESSAGE(o["out"].get_str() == o["expectOut"].get_str(), warning);
394 
395  o.erase(o.find("expectOut"));
396  }
397 
398  o["gas"] = toCompactHex(fev.gas, HexPrefix::Add, 1);
399  o["logs"] = exportLog(fev.sub.logs);
400  }
401  }
402  else
403  {
404  if (o.count("post") > 0) // No exceptions expected
405  {
406  BOOST_CHECK(!vmExceptionOccured);
407 
408  BOOST_REQUIRE(o.count("post") > 0);
409  BOOST_REQUIRE(o.count("callcreates") > 0);
410  BOOST_REQUIRE(o.count("out") > 0);
411  BOOST_REQUIRE(o.count("gas") > 0);
412  BOOST_REQUIRE(o.count("logs") > 0);
413 
415  test.importState(o["post"].get_obj());
416  test.importCallCreates(o["callcreates"].get_array());
417  test.sub.logs = importLog(o["logs"].get_array());
418 
419 
420  checkOutput(output, o);
421 
422  BOOST_CHECK_EQUAL(toInt(o["gas"]), fev.gas);
423 
424  State postState(State::Null);
425  State expectState(State::Null);
426  mObject mPostState = fev.exportState();
427  ImportTest::importState(mPostState, postState);
428  ImportTest::importState(o["post"].get_obj(), expectState);
429  ImportTest::compareStates(expectState, postState);
430 
431  //checkAddresses<std::map<Address, std::tuple<u256, u256, std::map<u256, u256>, bytes> > >(test.addresses, fev.addresses);
432 
433  checkCallCreates(fev.callcreates, test.callcreates);
434 
435  checkLog(fev.sub.logs, test.sub.logs);
436  }
437  else // Exception expected
438  BOOST_CHECK(vmExceptionOccured);
439  }
440  }
441 
443 }
444 
445 } } // namespace close
446 
447 BOOST_AUTO_TEST_SUITE(VMTests)
448 
450 {
451  dev::test::executeTests("vmtests", "/VMTests", "/VMTestsFiller", dev::test::doVMTests);
452 }
453 
454 BOOST_AUTO_TEST_CASE(vmArithmeticTest)
455 {
456  dev::test::executeTests("vmArithmeticTest", "/VMTests", "/VMTestsFiller", dev::test::doVMTests);
457 }
458 
459 BOOST_AUTO_TEST_CASE(vmBitwiseLogicOperationTest)
460 {
461  dev::test::executeTests("vmBitwiseLogicOperationTest", "/VMTests", "/VMTestsFiller", dev::test::doVMTests);
462 }
463 
465 {
466  dev::test::executeTests("vmSha3Test", "/VMTests", "/VMTestsFiller", dev::test::doVMTests);
467 }
468 
469 BOOST_AUTO_TEST_CASE(vmEnvironmentalInfoTest)
470 {
471  dev::test::executeTests("vmEnvironmentalInfoTest", "/VMTests", "/VMTestsFiller", dev::test::doVMTests);
472 }
473 
474 BOOST_AUTO_TEST_CASE(vmBlockInfoTest)
475 {
476  dev::test::executeTests("vmBlockInfoTest", "/VMTests", "/VMTestsFiller", dev::test::doVMTests);
477 }
478 
479 BOOST_AUTO_TEST_CASE(vmIOandFlowOperationsTest)
480 {
481  dev::test::executeTests("vmIOandFlowOperationsTest", "/VMTests", "/VMTestsFiller", dev::test::doVMTests);
482 }
483 
484 BOOST_AUTO_TEST_CASE(vmPushDupSwapTest)
485 {
486  dev::test::executeTests("vmPushDupSwapTest", "/VMTests", "/VMTestsFiller", dev::test::doVMTests);
487 }
488 
490 {
491  dev::test::executeTests("vmLogTest", "/VMTests", "/VMTestsFiller", dev::test::doVMTests);
492 }
493 
494 BOOST_AUTO_TEST_CASE(vmSystemOperationsTest)
495 {
496  dev::test::executeTests("vmSystemOperationsTest", "/VMTests", "/VMTestsFiller", dev::test::doVMTests);
497 }
498 
499 BOOST_AUTO_TEST_CASE(vmPerformanceTest)
500 {
501  if (test::Options::get().performance)
502  dev::test::executeTests("vmPerformanceTest", "/VMTests", "/VMTestsFiller", dev::test::doVMTests);
503 }
504 
505 BOOST_AUTO_TEST_CASE(vmInputLimitsTest)
506 {
507  if (test::Options::get().inputLimits)
508  dev::test::executeTests("vmInputLimits", "/VMTests", "/VMTestsFiller", dev::test::doVMTests);
509 }
510 
511 BOOST_AUTO_TEST_CASE(vmInputLimitsLightTest)
512 {
513  if (test::Options::get().inputLimits)
514  dev::test::executeTests("vmInputLimitsLight", "/VMTests", "/VMTestsFiller", dev::test::doVMTests);
515 }
516 
518 {
519  test::Options::get(); // parse command line options, e.g. to enable JIT
520 
521  string testPath = getTestPath();
522  testPath += "/VMTests/RandomTests";
523 
524  vector<boost::filesystem::path> testFiles;
525  boost::filesystem::directory_iterator iterator(testPath);
526  for(; iterator != boost::filesystem::directory_iterator(); ++iterator)
527  if (boost::filesystem::is_regular_file(iterator->path()) && iterator->path().extension() == ".json")
528  testFiles.push_back(iterator->path());
529 
531  test::TestOutputHelper::setMaxTests(testFiles.size());
532 
533  for (auto& path: testFiles)
534  {
535  try
536  {
537  cnote << "TEST " << path.filename();
539  string s = asString(dev::contents(path.string()));
540  BOOST_REQUIRE_MESSAGE(s.length() > 0, "Content of " + path.string() + " is empty. Have you cloned the 'tests' repo branch develop and set ETHEREUM_TEST_PATH to its path?");
542  test::Listener::notifySuiteStarted(path.filename().string());
543  doVMTests(v, false);
544  }
545  catch (Exception const& _e)
546  {
547  BOOST_ERROR("Failed test with Exception: " << diagnostic_information(_e));
548  }
549  catch (std::exception const& _e)
550  {
551  BOOST_ERROR("Failed test with Exception: " << _e.what());
552  }
553  }
554 }
555 
556 BOOST_AUTO_TEST_CASE(userDefinedFile)
557 {
559 }
560 
const Object & get_obj() const
std::string toCompactHex(u256 val, HexPrefix prefix=HexPrefix::DontAdd, unsigned _min=0)
Definition: CommonData.h:175
h256 EmptySHA3
Definition: SHA3.cpp:35
Adapted from code found on http://stackoverflow.com/questions/180947/base64-decode-snippet-in-c Origi...
Definition: Arith256.cpp:15
std::string toHex(T const &_data, int _w=2, HexPrefix _prefix=HexPrefix::DontAdd)
Definition: CommonData.h:54
u256s stack() const
Definition: VM.h:72
bytes importData(json_spirit::mObject const &_o)
Definition: TestHelper.cpp:226
static Options const & get(int argc=0, char **argv=0)
Get reference to options The first time used, options are parsed with argc, argv. ...
Definition: Options.cpp:203
static dev::eth::EnvInfo importEnv(json_spirit::mObject &_o)
Definition: vm.cpp:82
virtual u256 store(u256 _n) override
Read storage location.
Definition: vm.h:50
h160 right160(h256 const &_t)
Convert the given value into h160 (160-bit unsigned integer) using the right 20 bytes.
Definition: FixedHash.h:353
void checkOutput(bytesConstRef _output, json_spirit::mObject &_o)
Definition: TestHelper.cpp:318
static const int verbosity
Definition: Executive.h:51
LogEntries logs
Any logs.
Definition: ExtVMFace.h:169
boost::multiprecision::number< boost::multiprecision::cpp_int_backend<>> bigint
Definition: Common.h:121
u256 value
Value (in Wei) that was passed to this address.
Definition: ExtVMFace.h:326
const char * what() const noexceptoverride
Definition: Exceptions.h:42
h160 Address
An Ethereum address: 20 bytes.
Definition: Common.h:62
EnvInfo const & envInfo() const
Get the execution environment information.
Definition: ExtVMFace.h:313
std::hash for asio::adress
Definition: Common.h:323
json_spirit::mObject exportExec()
Definition: vm.cpp:144
assert(len-trim+(2 *lenIndices)<=WIDTH)
void importState(json_spirit::mObject &_object)
Definition: vm.cpp:123
void setGasLimit(int64_t _v)
Definition: ExtVMFace.h:249
static std::unique_ptr< VMFace > create()
Creates a VM instance of global kind (controlled by setKind() function).
Definition: VMFactory.cpp:41
std::string toString(string32 const &_s)
Make normal string from fixed-length string.
Definition: CommonData.cpp:141
h256 codeHash
SHA3 hash of the executing code.
Definition: ExtVMFace.h:330
u256 const & number() const
Definition: ExtVMFace.h:237
Model of an Ethereum state, essentially a facade for the trie.
Definition: State.h:161
Config::Object_type Object
bytes thisTxCode
Definition: vm.h:78
mConfig::Value_type mValue
std::vector< mutable_value_type > toVector() const
Definition: vector_ref.h:44
InstructionInfo instructionInfo(Instruction _inst)
Information on all the instructions.
void checkLog(LogEntries _resultLogs, LogEntries _expectedLogs)
Definition: TestHelper.cpp:361
static int compareStates(eth::State const &_stateExpect, eth::State const &_statePost, eth::AccountMaskMap const _expectedStateOptions=eth::AccountMaskMap(), WhenError _throw=WhenError::Throw)
Definition: ImportTest.cpp:356
bool vmtrace
Create EVM execution tracer.
Definition: Options.h:40
#define a(i)
bytes fromHex(std::string const &_s, WhenError _throw=WhenError::DontThrow)
Definition: CommonData.cpp:99
bool read_string(const String_type &s, Value_type &value)
void importCallCreates(json_spirit::mArray &_callcreates)
Definition: vm.cpp:205
json_spirit::mObject exportEnv()
Definition: vm.cpp:71
static void importState(json_spirit::mObject const &_o, eth::State &_state)
Base class for all exceptions.
Definition: Exceptions.h:39
Address caller
Address which sent the message (either equal to origin or a contract).
Definition: ExtVMFace.h:324
void userDefinedTest(std::function< void(json_spirit::mValue &, bool)> doTests)
Definition: TestHelper.cpp:386
mConfig::Array_type mArray
std::string name
The name of the instruction.
Definition: Instruction.h:260
static void setMaxTests(int _count)
json_spirit::mObject exportState()
Definition: vm.cpp:103
std::map< Address, std::tuple< u256, u256, std::map< u256, u256 >, bytes > > addresses
Definition: vm.h:75
const char * name
Definition: rest.cpp:36
ExecStats::duration max
Definition: ExecStats.cpp:36
virtual boost::optional< eth::owning_bytes_ref > call(eth::CallParameters &) override
Make a new message call.
Definition: vm.cpp:49
Test started/finished notification RAII helper.
Definition: TestHelper.h:189
json_spirit::mArray exportLog(eth::LogEntries _logs)
Definition: TestHelper.cpp:176
void setLastHashes(LastHashes &&_lh)
Definition: ExtVMFace.h:250
bytes thisTxData
Definition: vm.h:77
void setTimestamp(u256 const &_v)
Definition: ExtVMFace.h:247
std::vector< byte > bytes
Definition: Common.h:75
std::string getTestPath()
Definition: Common.cpp:35
std::vector< unsigned char > toBytes() const
Definition: vector_ref.h:45
bytes const & memory() const
Definition: VM.h:71
Fixed-size raw-byte array container type, with an API optimised for storing hashes.
Definition: FixedHash.h:47
std::function< void(uint64_t, uint64_t, Instruction, bigint, bigint, bigint, VM *, ExtVMFace const *)> OnOpFunc
Definition: ExtVMFace.h:193
unsigned depth
Depth of the present call.
Definition: ExtVMFace.h:332
static void notifySuiteStarted(std::string const &_name)
Definition: TestHelper.cpp:592
void setNumber(u256 const &_v)
Definition: ExtVMFace.h:245
Config::Array_type Array
const String_type & get_str() const
eth::Transactions callcreates
Definition: vm.h:76
boost::multiprecision::number< boost::multiprecision::cpp_int_backend< 256, 256, boost::multiprecision::unsigned_magnitude, boost::multiprecision::unchecked, void >> u256
Definition: Common.h:125
bytes importCode(json_spirit::mObject &_o)
Definition: TestHelper.cpp:281
Encodes a transaction, ready to be exported to or freshly imported from RLP.
Definition: Transaction.h:84
eth::OnOpFunc simpleTrace() const
Definition: vm.cpp:221
std::unordered_map< Address, AccountMask > AccountMaskMap
Definition: Account.h:240
Instruction
Virtual machine bytecode instruction.
Definition: Instruction.h:39
size_t size() const
Definition: vector_ref.h:55
mConfig::Object_type mObject
bytes rlpList()
Export a list of items in RLP format, returning a byte array.
Definition: RLP.h:470
int g_logVerbosity
The logging system&#39;s current verbosity.
Definition: Log.cpp:37
u256 gasPrice
Price of gas (that we already paid).
Definition: ExtVMFace.h:327
void doVMTests(json_spirit::mValue &_v, bool _fillin)
Definition: vm.cpp:286
Interface and null implementation of the class for specifying VM externalities.
Definition: ExtVMFace.h:265
BOOST_AUTO_TEST_CASE(rndCode)
Definition: fuzzHelper.cpp:409
Value_type::String_type write_string(const Value_type &value, bool pretty)
bytes code
Current code that is executing.
Definition: ExtVMFace.h:329
Address myAddress
Address associated with executing code (a contract, or contract-to-be).
Definition: ExtVMFace.h:323
#define cnote
Definition: Log.h:303
Address origin
Original transactor.
Definition: ExtVMFace.h:325
PlatformStyle::TableColorType type
Definition: rpcconsole.cpp:61
Reference to a slice of buffer that also owns the buffer.
Definition: ExtVMFace.h:56
#define BOOST_CHECK_EQUAL(v1, v2)
Definition: object.cpp:18
LastHashes lastHashes(u256 _currentBlockNumber)
Definition: TestHelper.cpp:544
bool sha3(bytesConstRef _input, bytesRef o_output)
Calculate SHA3-256 hash of the given input and load it into the given output.
Definition: SHA3.cpp:214
#define BOOST_AUTO_TEST_SUITE_END()
Definition: object.cpp:16
void importExec(json_spirit::mObject &_o)
Definition: vm.cpp:158
void setAuthor(Address const &_v)
Definition: ExtVMFace.h:246
SubState sub
Sub-band VM state (suicides, refund counter, logs).
Definition: ExtVMFace.h:331
bytesConstRef data
Definition: ExtVMFace.h:203
std::string memDump(bytes const &_bytes, unsigned _width=8, bool _html=false)
Nicely renders the given bytes to a string, optionally as HTML.
Definition: CommonIO.cpp:37
void executeTests(const string &_name, const string &_testPathAppendix, const string &_fillerPathAppendix, std::function< void(json_spirit::mValue &, bool)> doTests, bool _addFillerSuffix)
Definition: TestHelper.cpp:434
u256 execGas
Definition: vm.h:80
json_spirit::mArray exportCallCreates()
Definition: vm.cpp:190
bytesConstRef data
Current input data.
Definition: ExtVMFace.h:328
void setDifficulty(u256 const &_v)
Definition: ExtVMFace.h:248
void checkCallCreates(eth::Transactions _resultCallCreates, eth::Transactions _expectedCallCreates)
Definition: TestHelper.cpp:373
void reset(u256 _myBalance, u256 _myNonce, std::map< u256, u256 > const &_storage)
Definition: vm.cpp:64
std::string get_str(std::string::const_iterator begin, std::string::const_iterator end)
void set(Address _a, u256 _myBalance, u256 _myNonce, std::map< u256, u256 > const &_storage, bytes const &_code)
Definition: vm.cpp:56
bytes contents(std::string const &_file)
Retrieve and returns the contents of the given file.
Config::Pair_type Pair
LogEntries importLog(json_spirit::mArray &_a)
Definition: TestHelper.cpp:298
std::string asString(bytes const &_b)
Converts byte array to a string containing the same (binary) data.
Definition: CommonData.h:79
u256 toInt(json_spirit::mValue const &_v)
Definition: TestHelper.cpp:195
virtual h160 create(u256 _endowment, u256 &io_gas, bytesConstRef _init, eth::OnOpFunc const &) override
Create a new (contract) account.
Definition: vm.cpp:40
Logging class, iostream-like, that can be shifted to.
Definition: Log.h:260
#define BOOST_CHECK(expr)
Definition: object.cpp:17
static void initTest(int _maxTests=1)
static bool passTest(json_spirit::mObject &_o, std::string &_testName)