Fabcoin Core  0.16.2
P2P Digital Currency
Executive.cpp
Go to the documentation of this file.
1 /*
2  This file is part of cpp-ethereum.
3  cpp-ethereum is free software: you can redistribute it and/or modify
4  it under the terms of the GNU General Public License as published by
5  the Free Software Foundation, either version 3 of the License, or
6  (at your option) any later version.
7  cpp-ethereum is distributed in the hope that it will be useful,
8  but WITHOUT ANY WARRANTY; without even the implied warranty of
9  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
10  GNU General Public License for more details.
11  You should have received a copy of the GNU General Public License
12  along with cpp-ethereum. If not, see <http://www.gnu.org/licenses/>.
13 */
19 #include "Executive.h"
20 
21 #include <boost/timer.hpp>
22 #ifndef FASC_BUILD
23 #include <json/json.h>
24 #endif
25 #include <libdevcore/CommonIO.h>
26 #include <libevm/VMFactory.h>
27 #include <libevm/VM.h>
28 #include <libethcore/CommonJS.h>
29 #include "Interface.h"
30 #include "State.h"
31 #include "ExtVM.h"
32 #include "BlockChain.h"
33 #include "Block.h"
34 using namespace std;
35 using namespace dev;
36 using namespace dev::eth;
37 
38 const char* VMTraceChannel::name() { return "EVM"; }
39 const char* ExecutiveWarnChannel::name() { return WarnChannel::name(); }
40 
41 #ifdef FASC_BUILD
42 StandardTrace::StandardTrace()
43 {}
44 #else
45 StandardTrace::StandardTrace():
46  m_trace(Json::arrayValue)
47 {}
48 #endif
49 
51 {
52  return
53  _inst == Instruction::MSTORE ||
54  _inst == Instruction::MSTORE8 ||
55  _inst == Instruction::MLOAD ||
56  _inst == Instruction::CREATE ||
57  _inst == Instruction::CALL ||
58  _inst == Instruction::CALLCODE ||
59  _inst == Instruction::SHA3 ||
60  _inst == Instruction::CALLDATACOPY ||
61  _inst == Instruction::CODECOPY ||
62  _inst == Instruction::EXTCODECOPY ||
64 }
65 
67 {
68  return _inst == Instruction::SSTORE;
69 }
70 
71 void StandardTrace::operator()(uint64_t _steps, uint64_t PC, Instruction inst, bigint newMemSize, bigint gasCost, bigint gas, VM* voidVM, ExtVMFace const* voidExt)
72 {
73 #ifdef FASC_BUILD
74  return;
75 #else
76  (void)_steps;
77 
78  ExtVM const& ext = dynamic_cast<ExtVM const&>(*voidExt);
79  VM& vm = *voidVM;
80 
81  Json::Value r(Json::objectValue);
82 
83  Json::Value stack(Json::arrayValue);
85  {
86  for (auto const& i: vm.stack())
87  stack.append("0x" + toHex(toCompactBigEndian(i, 1)));
88  r["stack"] = stack;
89  }
90 
91  bool newContext = false;
92  Instruction lastInst = Instruction::STOP;
93 
94  if (m_lastInst.size() == ext.depth)
95  {
96  // starting a new context
97  assert(m_lastInst.size() == ext.depth);
98  m_lastInst.push_back(inst);
99  newContext = true;
100  }
101  else if (m_lastInst.size() == ext.depth + 2)
102  {
103  m_lastInst.pop_back();
104  lastInst = m_lastInst.back();
105  }
106  else if (m_lastInst.size() == ext.depth + 1)
107  {
108  // continuing in previous context
109  lastInst = m_lastInst.back();
110  m_lastInst.back() = inst;
111  }
112  else
113  {
114  cwarn << "GAA!!! Tracing VM and more than one new/deleted stack frame between steps!";
115  cwarn << "Attmepting naive recovery...";
116  m_lastInst.resize(ext.depth + 1);
117  }
118 
119  Json::Value memJson(Json::arrayValue);
120  if (!m_options.disableMemory && (changesMemory(lastInst) || newContext))
121  {
122  for (unsigned i = 0; i < vm.memory().size(); i += 32)
123  {
124  bytesConstRef memRef(vm.memory().data() + i, 32);
125  memJson.append(toHex(memRef, 2, HexPrefix::DontAdd));
126  }
127  r["memory"] = memJson;
128  }
129 
130  if (!m_options.disableStorage && (m_options.fullStorage || changesStorage(lastInst) || newContext))
131  {
132  Json::Value storage(Json::objectValue);
133  for (auto const& i: ext.state().storage(ext.myAddress))
134  storage["0x" + toHex(toCompactBigEndian(i.second.first, 1))] = "0x" + toHex(toCompactBigEndian(i.second.second, 1));
135  r["storage"] = storage;
136  }
137 
138  if (m_showMnemonics)
139  r["op"] = instructionInfo(inst).name;
140  r["pc"] = toString(PC);
141  r["gas"] = toString(gas);
142  r["gasCost"] = toString(gasCost);
143  if (!!newMemSize)
144  r["memexpand"] = toString(newMemSize);
145 
146  m_trace.append(r);
147 #endif
148 }
149 
150 string StandardTrace::json(bool _styled) const
151 {
152 #ifdef FASC_BUILD
153  return "";
154 #else
155  return _styled ? Json::StyledWriter().write(m_trace) : Json::FastWriter().write(m_trace);
156 #endif
157 }
158 
159 Executive::Executive(Block& _s, BlockChain const& _bc, unsigned _level):
160  m_s(_s.mutableState()),
161  m_envInfo(_s.info(), _bc.lastHashes(_s.info().parentHash())),
162  m_depth(_level),
163  m_sealEngine(*_bc.sealEngine())
164 {
165 }
166 
167 Executive::Executive(Block& _s, LastHashes const& _lh, unsigned _level):
168  m_s(_s.mutableState()),
169  m_envInfo(_s.info(), _lh),
170  m_depth(_level),
171  m_sealEngine(*_s.sealEngine())
172 {
173 }
174 
175 Executive::Executive(State& _s, Block const& _block, unsigned _txIndex, BlockChain const& _bc, unsigned _level):
176  m_s(_s = _block.fromPending(_txIndex)),
177  m_envInfo(_block.info(), _bc.lastHashes(_block.info().parentHash()), _txIndex ? _block.receipt(_txIndex - 1).gasUsed() : 0),
178  m_depth(_level),
179  m_sealEngine(*_bc.sealEngine())
180 {
181 }
182 
184 {
185  return m_t.gas() - m_gas;
186 }
187 
188 void Executive::accrueSubState(SubState& _parentContext)
189 {
190  if (m_ext)
191  _parentContext += m_ext->sub;
192 }
193 
194 void Executive::initialize(Transaction const& _transaction)
195 {
196  m_t = _transaction;
197 
198  // Avoid transactions that would take us beyond the block gas limit.
199  u256 startGasUsed = m_envInfo.gasUsed();
200  if (startGasUsed + (bigint)m_t.gas() > m_envInfo.gasLimit())
201  {
202  clog(ExecutiveWarnChannel) << "Cannot fit tx in block" << m_envInfo.number() << ": Require <" << (m_envInfo.gasLimit() - startGasUsed) << " Got" << m_t.gas();
204  BOOST_THROW_EXCEPTION(BlockGasLimitReached() << RequirementError((bigint)(m_envInfo.gasLimit() - startGasUsed), (bigint)m_t.gas()));
205  }
206 
207  // Check gas cost is enough.
209  if (m_baseGasRequired > m_t.gas())
210  {
211  clog(ExecutiveWarnChannel) << "Not enough gas to pay for the transaction: Require >" << m_baseGasRequired << " Got" << m_t.gas();
213  BOOST_THROW_EXCEPTION(OutOfGasBase() << RequirementError((bigint)m_baseGasRequired, (bigint)m_t.gas()));
214  }
215 
216  // Avoid invalid transactions.
217  u256 nonceReq;
218  try
219  {
220  nonceReq = m_s.getNonce(m_t.sender());
221  }
222  catch (...)
223  {
224  clog(ExecutiveWarnChannel) << "Invalid Signature";
226  throw;
227  }
228  if (m_t.nonce() != nonceReq)
229  {
230  clog(ExecutiveWarnChannel) << "Invalid Nonce: Require" << nonceReq << " Got" << m_t.nonce();
232  BOOST_THROW_EXCEPTION(InvalidNonce() << RequirementError((bigint)nonceReq, (bigint)m_t.nonce()));
233  }
234 
235  // Avoid unaffordable transactions.
236  bigint gasCost = (bigint)m_t.gas() * m_t.gasPrice();
237  bigint totalCost = m_t.value() + gasCost;
238  if (m_s.balance(m_t.sender()) < totalCost)
239  {
240  clog(ExecutiveWarnChannel) << "Not enough cash: Require >" << totalCost << "=" << m_t.gas() << "*" << m_t.gasPrice() << "+" << m_t.value() << " Got" << m_s.balance(m_t.sender()) << "for sender: " << m_t.sender();
242  BOOST_THROW_EXCEPTION(NotEnoughCash() << RequirementError(totalCost, (bigint)m_s.balance(m_t.sender())) << errinfo_comment(m_t.sender().abridged()));
243  }
244  m_gasCost = (u256)gasCost; // Convert back to 256-bit, safe now.
245 }
246 
248 {
249  // Entry point for a user-executed transaction.
250 
251  // Pay...
252  clog(StateDetail) << "Paying" << formatBalance(m_gasCost) << "from sender for gas (" << m_t.gas() << "gas at" << formatBalance(m_t.gasPrice()) << ")";
254 
255  if (m_t.isCreation())
257  else
259 }
260 
261 bool Executive::call(Address _receiveAddress, Address _senderAddress, u256 _value, u256 _gasPrice, bytesConstRef _data, u256 _gas)
262 {
263  CallParameters params{_senderAddress, _receiveAddress, _receiveAddress, _value, _value, _gas, _data, {}};
264  return call(params, _gasPrice, _senderAddress);
265 }
266 
267 bool Executive::call(CallParameters const& _p, u256 const& _gasPrice, Address const& _origin)
268 {
269  // If external transaction.
270  if (m_t)
271  {
272  // FIXME: changelog contains unrevertable balance change that paid
273  // for the transaction.
274  // Increment associated nonce for sender.
276  }
277 
279 
281  {
283  if (_p.gas < g)
284  {
286  // Bail from exception.
287 
288  // Empty precompiled contracts need to be deleted even in case of OOG
289  // because the bug in both Geth and Parity led to deleting RIPEMD precompiled in this case
290  // see https://github.com/ethereum/go-ethereum/pull/3341/files#diff-2433aa143ee4772026454b8abd76b9dd
291  // We mark the account as touched here, so that is can be removed among other touched empty accounts (after tx finalization)
292  if (m_envInfo.number() >= m_sealEngine.chainParams().u256Param("EIP158ForkBlock"))
293  m_s.addBalance(_p.codeAddress, 0);
294 
295  return true; // true actually means "all finished - nothing more to be done regarding go().
296  }
297  else
298  {
299  m_gas = (u256)(_p.gas - g);
300  bytes output;
301  bool success;
302  tie(success, output) = m_sealEngine.executePrecompiled(_p.codeAddress, _p.data, m_envInfo.number());
303  if (!success)
304  {
305  m_gas = 0;
307  }
308  size_t outputSize = output.size();
309  m_output = owning_bytes_ref{std::move(output), 0, outputSize};
310  }
311  }
312  else
313  {
314  m_gas = _p.gas;
316  {
317  bytes const& c = m_s.code(_p.codeAddress);
319  m_ext = make_shared<ExtVM>(m_s, m_envInfo, m_sealEngine, _p.receiveAddress, _p.senderAddress, _origin, _p.apparentValue, _gasPrice, _p.data, &c, codeHash, m_depth);
320  }
321  }
322 
327 
328  // Transfer ether.
330  return !m_ext;
331 }
332 
333 bool Executive::create(Address _sender, u256 _endowment, u256 _gasPrice, u256 _gas, bytesConstRef _init, Address _origin)
334 {
335  u256 nonce = m_s.getNonce(_sender);
336  m_s.incNonce(_sender);
337 
339 
340  m_isCreation = true;
341 
342  // We can allow for the reverted state (i.e. that with which m_ext is constructed) to contain the m_orig.address, since
343  // we delete it explicitly if we decide we need to revert.
344  m_newAddress = right160(sha3(rlpList(_sender, nonce)));
345  m_gas = _gas;
346 
347  // Transfer ether before deploying the code. This will also create new
348  // account if it does not exist yet.
349  m_s.transferBalance(_sender, m_newAddress, _endowment);
350 
351  if (m_envInfo.number() >= m_sealEngine.chainParams().u256Param("EIP158ForkBlock"))
353 
354  // Schedule _init execution if not empty.
355  if (!_init.empty())
356  m_ext = make_shared<ExtVM>(m_s, m_envInfo, m_sealEngine, m_newAddress, _sender, _origin, _endowment, _gasPrice, bytesConstRef(), _init, sha3(_init), m_depth);
357  else if (m_s.addressHasCode(m_newAddress))
358  // Overwrite with empty code in case the account already has a code
359  // (address collision -- not real life case but we can check it with
360  // synthetic tests).
362 
363  return !m_ext;
364 }
365 
367 {
368  return [](uint64_t steps, uint64_t PC, Instruction inst, bigint newMemSize, bigint gasCost, bigint gas, VM* voidVM, ExtVMFace const* voidExt)
369  {
370  ExtVM const& ext = *static_cast<ExtVM const*>(voidExt);
371  VM& vm = *voidVM;
372 
373  ostringstream o;
374  o << endl << " STACK" << endl;
375  for (auto i: vm.stack())
376  o << (h256)i << endl;
377  o << " MEMORY" << endl << ((vm.memory().size() > 1000) ? " mem size greater than 1000 bytes " : memDump(vm.memory()));
378  o << " STORAGE" << endl;
379  for (auto const& i: ext.state().storage(ext.myAddress))
380  o << showbase << hex << i.second.first << ": " << i.second.second << endl;
382  dev::LogOutputStream<VMTraceChannel, false>() << " < " << dec << ext.depth << " : " << ext.myAddress << " : #" << steps << " : " << hex << setw(4) << setfill('0') << PC << " : " << instructionInfo(inst).name << " : " << dec << gas << " : -" << dec << gasCost << " : " << newMemSize << "x32" << " >";
383  };
384 }
385 
386 bool Executive::go(OnOpFunc const& _onOp)
387 {
388  if (m_ext)
389  {
390 #if ETH_TIMED_EXECUTIONS
391  Timer t;
392 #endif
393  try
394  {
395  // Create VM instance. Force Interpreter if tracing requested.
397  if (m_isCreation)
398  {
399  auto out = vm->exec(m_gas, *m_ext, _onOp);
400  if (m_res)
401  {
403  m_res->depositSize = out.size();
404  }
405  if (out.size() > m_ext->evmSchedule().maxCodeSize)
406  BOOST_THROW_EXCEPTION(OutOfGas());
407  else if (out.size() * m_ext->evmSchedule().createDataGas <= m_gas)
408  {
409  if (m_res)
411  m_gas -= out.size() * m_ext->evmSchedule().createDataGas;
412  }
413  else
414  {
415  if (m_ext->evmSchedule().exceptionalFailedCodeDeposit)
416  BOOST_THROW_EXCEPTION(OutOfGas());
417  else
418  {
419  if (m_res)
421  out = {};
422  }
423  }
424  if (m_res)
425  m_res->output = out.toVector(); // copy output to execution result
426  m_s.setNewCode(m_ext->myAddress, out.toVector());
427  }
428  else
429  {
430  m_output = vm->exec(m_gas, *m_ext, _onOp);
431  if (m_res)
432  // Copy full output:
434  }
435  }
436  catch (VMException const& _e)
437  {
438  clog(StateSafeExceptions) << "Safe VM Exception. " << diagnostic_information(_e);
439  m_gas = 0;
441  revert();
442  }
443  catch (Exception const& _e)
444  {
445  // TODO: AUDIT: check that this can never reasonably happen. Consider what to do if it does.
446  cwarn << "Unexpected exception in VM. There may be a bug in this implementation. " << diagnostic_information(_e);
447  exit(1);
448  // Another solution would be to reject this transaction, but that also
449  // has drawbacks. Essentially, the amount of ram has to be increased here.
450  }
451  catch (std::exception const& _e)
452  {
453  // TODO: AUDIT: check that this can never reasonably happen. Consider what to do if it does.
454  cwarn << "Unexpected std::exception in VM. Not enough RAM? " << _e.what();
455  exit(1);
456  // Another solution would be to reject this transaction, but that also
457  // has drawbacks. Essentially, the amount of ram has to be increased here.
458  }
459 #if ETH_TIMED_EXECUTIONS
460  cnote << "VM took:" << t.elapsed() << "; gas used: " << (sgas - m_endGas);
461 #endif
462  }
463  return true;
464 }
465 
467 {
468  // Accumulate refunds for suicides.
469  if (m_ext)
470  m_ext->sub.refunds += m_ext->evmSchedule().suicideRefundGas * m_ext->sub.suicides.size();
471 
472  // SSTORE refunds...
473  // must be done before the miner gets the fees.
474  m_refunded = m_ext ? min((m_t.gas() - m_gas) / 2, m_ext->sub.refunds) : 0;
475  m_gas += m_refunded;
476 
477  if (m_t)
478  {
480 
481  u256 feesEarned = (m_t.gas() - m_gas) * m_t.gasPrice();
482  m_s.addBalance(m_envInfo.author(), feesEarned);
483  }
484 
485  // Suicides...
486  if (m_ext)
487  for (auto a: m_ext->sub.suicides)
488  m_s.kill(a);
489 
490  // Logs..
491  if (m_ext)
492  m_logs = m_ext->sub.logs;
493 
494  if (m_res) // Collect results
495  {
496  m_res->gasUsed = gasUsed();
497  m_res->excepted = m_excepted; // TODO: m_except is used only in ExtVM::call
499  m_res->gasRefunded = m_ext ? m_ext->sub.refunds : 0;
500  }
501 }
502 
504 {
505  if (m_ext)
506  m_ext->sub.clear();
507 
508  // Set result address to the null one.
509  m_newAddress = {};
511 }
bool addressInUse(Address const &_address) const
Check if the address is in use.
Definition: State.cpp:245
u256 balance(Address const &_id) const
Get an account&#39;s balance.
Definition: State.cpp:266
CodeDeposit codeDeposit
Failed if an attempted deposit failed due to lack of gas.
Definition: Transaction.h:75
Adapted from code found on http://stackoverflow.com/questions/180947/base64-decode-snippet-in-c Origi...
Definition: Arith256.cpp:15
bool call(Address _receiveAddress, Address _txSender, u256 _txValue, u256 _gasPrice, bytesConstRef _txData, u256 _gas)
Set up the executive for evaluating a bare CALL (message call) operation.
Definition: Executive.cpp:261
bool create(Address _txSender, u256 _endowment, u256 _gasPrice, u256 _gas, bytesConstRef _code, Address _originAddress)
Set up the executive for evaluating a bare CREATE (contract-creation) operation.
Definition: Executive.cpp:333
std::string toHex(T const &_data, int _w=2, HexPrefix _prefix=HexPrefix::DontAdd)
Definition: CommonData.h:54
u256s stack() const
Definition: VM.h:72
ChainOperationParams const & chainParams() const
Definition: SealEngine.h:75
Implements the blockchain database.
Definition: BlockChain.h:105
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 setNewCode(Address const &_address, bytes &&_code)
Sets the code of the account. Must only be called during / after contract creation.
Definition: State.cpp:440
copy input data in current environment to memory
u256 gasUsed() const
Definition: Executive.cpp:183
boost::multiprecision::number< boost::multiprecision::cpp_int_backend<>> bigint
Definition: Common.h:121
void rollback(size_t _savepoint)
Revert all recent changes up to the given _savepoint savepoint.
Definition: State.cpp:480
int64_t gasLimit() const
Definition: ExtVMFace.h:241
u256 m_refunded
The amount of gas refunded.
Definition: Executive.h:201
#define g(i)
Definition: sha.cpp:735
Address const & author() const
Definition: ExtVMFace.h:238
Address const & sender() const
#define c(i)
std::hash for asio::adress
Definition: Common.h:323
assert(len-trim+(2 *lenIndices)<=WIDTH)
virtual std::pair< bool, bytes > executePrecompiled(Address const &_a, bytesConstRef _in, u256 const &) const
Definition: SealEngine.h:85
u256 const & gasUsed() const
Definition: ExtVMFace.h:243
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
owning_bytes_ref m_output
Execution output.
Definition: Executive.h:194
int64_t baseGasRequired(EVMSchedule const &_es) const
Definition: Transaction.h:148
std::shared_ptr< ExtVM > m_ext
The VM externality object for the VM execution or null if no VM is required. shared_ptr used only to ...
Definition: Executive.h:193
ExecStats::duration min
Definition: ExecStats.cpp:35
u256 const & number() const
Definition: ExtVMFace.h:237
std::vector< Instruction > m_lastInst
Definition: Executive.h:77
void accrueSubState(SubState &_parentContext)
Finalise an operation through accruing the substate into the parent context.
Definition: Executive.cpp:188
Model of an Ethereum state, essentially a facade for the trie.
Definition: State.h:161
bool go(OnOpFunc const &_onOp=OnOpFunc())
Executes (or continues execution of) the VM.
Definition: Executive.cpp:386
save byte to memory
void revert()
Revert all changes made to the state by this execution.
Definition: Executive.cpp:503
Executive(State &_s, EnvInfo const &_envInfo, SealEngineFace const &_sealEngine, unsigned _level=0)
Simple constructor; executive will operate on given state, with the given environment info...
Definition: Executive.h:110
TransactionException m_excepted
Details if the VM&#39;s execution resulted in an exception.
Definition: Executive.h:198
u256 m_gas
The gas for EVM code execution. Initial amount before go() execution, final amount after go() executi...
Definition: Executive.h:200
int64_t m_baseGasRequired
The base amount of gas requried for executing this transaction.
Definition: Executive.h:199
std::vector< mutable_value_type > toVector() const
Definition: vector_ref.h:44
InstructionInfo instructionInfo(Instruction _inst)
Information on all the instructions.
Transaction const & t() const
Definition: Executive.h:145
bool empty() const
Definition: vector_ref.h:56
#define a(i)
Active model of a block within the block chain.
Definition: Block.h:73
bool isCreation() const
Definition: Transaction.h:101
Ran out of gas executing code of the transaction.
LogEntries m_logs
The log entries created by this transaction. Set by finalize().
Definition: Executive.h:204
std::vector< h256 > LastHashes
Definition: ExtVMFace.h:191
double elapsed() const
Definition: Common.h:280
get the program counter
virtual void kill(Address _a)
Delete an account (used for processing suicides).
Definition: State.cpp:338
u256 gas() const
Definition: Executive.h:176
std::string json(bool _styled=false) const
Definition: Executive.cpp:150
Base class for all exceptions.
Definition: Exceptions.h:39
Config::Value_type Value
std::string name
The name of the instruction.
Definition: Instruction.h:260
DebugOptions m_options
Definition: Executive.h:82
const char * name
Definition: rest.cpp:36
EnvInfo m_envInfo
Information on the runtime environment.
Definition: Executive.h:192
void finalize()
Finalise a transaction previously set up with initialize().
Definition: Executive.cpp:466
save word to storage
message-call with another account&#39;s code only
std::vector< byte > bytes
Definition: Common.h:75
compute SHA3-256 hash
vector_ref< byte const > bytesConstRef
Definition: Common.h:77
bytes toCompactBigEndian(T _val, unsigned _min=0)
Convenience function for toBigEndian.
Definition: CommonData.h:141
bytes const & memory() const
Definition: VM.h:71
Definition: Executive.h:31
u256 storage(Address const &_contract, u256 const &_memory) const
Get the value of a storage position of an account.
Definition: State.cpp:353
u256 getNonce(Address const &_addr) const
Get the account nonce – the number of transactions it has sent.
Definition: State.cpp:345
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
bytes const & data() const
Definition: Transaction.h:131
bytes const & code(Address const &_addr) const
Get the code of an account.
Definition: State.cpp:423
#define cwarn
Definition: Log.h:304
copy code running in current environment to memory
boost::multiprecision::number< boost::multiprecision::cpp_int_backend< 256, 256, boost::multiprecision::unsigned_magnitude, boost::multiprecision::unchecked, void >> u256
Definition: Common.h:125
std::string formatBalance(bigint const &_b)
User-friendly string representation of the amount _b in wei.
Definition: Common.cpp:102
like CALLCODE but keeps caller&#39;s value and sender
Address m_newAddress
Definition: Executive.h:210
Encodes a transaction, ready to be exported to or freshly imported from RLP.
Definition: Transaction.h:84
TransactionException excepted
Definition: Transaction.h:72
Instruction
Virtual machine bytecode instruction.
Definition: Instruction.h:39
bytes rlpList()
Export a list of items in RLP format, returning a byte array.
Definition: RLP.h:470
copy external code (from another contract)
bool changesStorage(Instruction _inst)
Definition: Executive.cpp:66
void initialize(bytesConstRef _transaction)
Initializes the executive for evaluating a transaction. You must call finalize() at some point follow...
Definition: Executive.h:135
Interface and null implementation of the class for specifying VM externalities.
Definition: ExtVMFace.h:265
h256 codeHash
Definition: SmartVM.cpp:46
virtual EVMSchedule const & evmSchedule(EnvInfo const &) const =0
u256 u256Param(std::string const &_name) const
Convenience method to get an otherParam as a u256 int.
u256 gasForDeposit
Amount of gas remaining for the code deposit phase.
Definition: Transaction.h:78
Address myAddress
Address associated with executing code (a contract, or contract-to-be).
Definition: ExtVMFace.h:323
#define cnote
Definition: Log.h:303
Reference to a slice of buffer that also owns the buffer.
Definition: ExtVMFace.h:56
std::set< Address > deleteAddresses
Definition: SealEngine.h:96
bool execute()
Begins execution of a transaction.
Definition: Executive.cpp:247
bool changesMemory(Instruction _inst)
Definition: Executive.cpp:50
virtual void transferBalance(Address const &_from, Address const &_to, u256 const &_value)
Transfers "the balance _value between two accounts.
Definition: State.h:240
State & m_s
The state to which this operation/transaction is applied.
Definition: Executive.h:190
LastHashes lastHashes(u256 _currentBlockNumber)
Definition: TestHelper.cpp:544
virtual bigint costOfPrecompiled(Address const &_a, bytesConstRef _in, u256 const &) const
Definition: SealEngine.h:84
boost::error_info< struct tag_comment, std::string > errinfo_comment
Definition: Assertions.h:78
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
virtual void addBalance(Address const &_id, u256 const &_amount)
Add some amount to balance.
Definition: State.cpp:286
unsigned depositSize
Amount of code of the creation&#39;s attempted deposit.
Definition: Transaction.h:77
message-call into an account
ExecutionResult * m_res
Optional storage for execution results.
Definition: Executive.h:195
Externality interface for the Virtual Machine providing access to world state.
Definition: ExtVM.h:42
std::string abridged() const
Definition: FixedHash.h:124
save word to memory
virtual bool isPrecompiled(Address const &_a, u256 const &_blockNumber) const
Definition: SealEngine.h:80
#define clog(X)
Definition: Log.h:295
unsigned m_depth
The context&#39;s call-depth.
Definition: Executive.h:197
bytesConstRef data
Definition: ExtVMFace.h:203
Transaction m_t
The original transaction. Set by setup().
Definition: Executive.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
State const & state() const
Definition: ExtVM.h:91
boost::tuple< errinfo_required, errinfo_got > RequirementError
Definition: Exceptions.h:80
static OnOpFunc simpleTrace()
Operation function for providing a simple trace of the VM execution.
Definition: Executive.cpp:366
size_t savepoint() const
Create a savepoint in the state changelog.
Definition: State.cpp:475
SealEngineFace const & m_sealEngine
Definition: Executive.h:207
Json::Value m_trace
Definition: Executive.h:80
load word from memory
Too little gas to pay for the base transaction cost.
void subBalance(Address const &_addr, u256 const &_value)
Subtract the _value amount from the balance of _addr account.
Definition: State.cpp:311
bool addressHasCode(Address const &_address) const
Check if the address contains executable code.
Definition: State.cpp:258
void operator()(uint64_t _steps, uint64_t _PC, Instruction _inst, bigint _newMemSize, bigint _gasCost, bigint _gas, VM *_vm, ExtVMFace const *_extVM)
Definition: Executive.cpp:71
create a new account with associated code
Logging class, iostream-like, that can be shifted to.
Definition: Log.h:260
Address receiveAddress() const
Definition: Transaction.h:122
TransactionException toTransactionException(Exception const &_e)
Definition: Transaction.cpp:42
void incNonce(Address const &_id)
Increament the account nonce.
Definition: State.cpp:274
h256 codeHash(Address const &_contract) const
Get the code hash of an account.
Definition: State.cpp:446