1 #include <jsonrpccpp/common/exception.h> 21 if (!_json.isObject() || _json.empty())
23 if (!_json[
"disableStorage"].empty())
25 if (!_json[
"disableMemory"].empty())
27 if (!_json[
"disableStack"].empty())
29 if (!_json[
"fullStorage"].empty())
36 if (isHash<h256>(_blockNumberOrHash))
37 return h256(_blockNumberOrHash.substr(_blockNumberOrHash.size() - 64, 64));
44 throw jsonrpc::JsonRpcException(
"Invalid argument");
58 Json::Reader().parse(st.
json(), trace);
65 for (
unsigned k = 0; k < _block.
pending().size(); k++)
71 e.setResultRecipient(er);
87 e.setResultRecipient(er);
91 ret[
"structLogs"] = trace;
95 cwarn << diagnostic_information(_e);
126 ret[
"complete"] =
true;
130 throw jsonrpc::JsonRpcException(
"Negative index");
131 if (_maxResults <= 0)
132 throw jsonrpc::JsonRpcException(
"Nonpositive maxResults");
138 unsigned const i = ((unsigned)_txIndex < block.
pending().size()) ? (
unsigned)_txIndex : block.
pending().size();
141 map<h256, pair<u256, u256>>
const storage(state.
storage(
Address(_address)));
144 auto itBegin = storage.lower_bound(
h256fromHex(_begin));
146 for (
auto it = itBegin; it != storage.end(); ++it)
148 if (ret[
"storage"].
size() ==
static_cast<unsigned>(_maxResults))
150 ret[
"complete"] =
false;
159 ret[
"storage"].append(keyValue);
164 cwarn << diagnostic_information(_e);
165 throw jsonrpc::JsonRpcException(jsonrpc::Errors::ERROR_RPC_INVALID_PARAMS);
201 ret[
"structLogs"] = trace;
205 cwarn << diagnostic_information(_e);
unsigned transactionIndex() const
std::string toCompactHex(u256 val, HexPrefix prefix=HexPrefix::DontAdd, unsigned _min=0)
Adapted from code found on http://stackoverflow.com/questions/180947/base64-decode-snippet-in-c Origi...
std::string toHex(T const &_data, int _w=2, HexPrefix _prefix=HexPrefix::DontAdd)
virtual Json::Value debug_traceCall(Json::Value const &_call, std::string const &_blockNumber, Json::Value const &_options) override
State fromPending(unsigned _i) const
Get the State immediately after the given number of pending transactions have been applied...
dev::eth::Block block(h256 const &_blockHash, PopulationStatistics *o_stats) const
Get the block.
Json::Value traceTransaction(dev::eth::Executive &_e, dev::eth::Transaction const &_t, Json::Value const &_json)
virtual Json::Value debug_traceBlockByNumber(int _blockNumber, Json::Value const &_json) override
h160 Address
An Ethereum address: 20 bytes.
virtual u256 gasLimitRemaining() const override
Get the remaining gas limit in this block.
OverlayDB const & stateDB() const
Get the block queue.
std::hash for asio::adress
u256 transactionsFrom(Address const &_address) const
Get the number of transactions a particular address has sent (used for the transaction nonce)...
Description of the result of executing a transaction.
virtual Json::Value debug_traceTransaction(std::string const &_txHash, Json::Value const &_json) override
Model of an Ethereum state, essentially a facade for the trie.
bool go(OnOpFunc const &_onOp=OnOpFunc())
Executes (or continues execution of) the VM.
TransactionSkeleton toTransactionSkeleton(Json::Value const &_json)
virtual std::string debug_preimage(std::string const &_hashedKey) override
BlockNumber jsToBlockNumber(std::string const &_js)
Convert to a block number, a bit like jsToInt, except that it correctly recognises "pending" and "lat...
Active model of a block within the block chain.
bytes fromHex(std::string const &_s, WhenError _throw=WhenError::DontThrow)
std::string json(bool _styled=false) const
Base class for all exceptions.
BlockChain const & blockChain() const
Get the object representing the current canonical blockchain.
h256 numberHash(unsigned _i) const
Get the hash for a given block's number.
void finalize()
Finalise a transaction previously set up with initialize().
std::vector< byte > bytes
u256 storage(Address const &_contract, u256 const &_memory) const
Get the value of a storage position of an account.
bytes lookupAux(h256 const &_h) const
Main API hub for interfacing with Ethereum.
Message-call/contract-creation executor; useful for executing transactions.
boost::multiprecision::number< boost::multiprecision::cpp_int_backend< 256, 256, boost::multiprecision::unsigned_magnitude, boost::multiprecision::unchecked, void >> u256
virtual Json::Value debug_traceBlock(std::string const &_blockRlp, Json::Value const &_json)
Transactions const & pending() const
Get the list of pending transactions.
Encodes a transaction, ready to be exported to or freshly imported from RLP.
virtual Json::Value debug_traceBlockByHash(std::string const &_blockHash, Json::Value const &_json) override
h256 blockHash(std::string const &_blockHashOrNumber) const
void initialize(bytesConstRef _transaction)
Initializes the executive for evaluating a transaction. You must call finalize() at some point follow...
eth::Client const & m_eth
h256 const & blockHash() const
State & mutableState()
Get a mutable State object which is backing this block.
uint8_t const size_t const size
bool execute()
Begins execution of a transaction.
void forceSender(Address const &_a)
Force the sender to a particular value. This will result in an invalid transaction RLP...
virtual void addBalance(Address const &_id, u256 const &_amount)
Add some amount to balance.
virtual Json::Value debug_storageRangeAt(std::string const &_blockHashOrNumber, int _txIndex, std::string const &_address, std::string const &_begin, int _maxResults) override
virtual LocalisedTransaction localisedTransaction(h256 const &_transactionHash) const override
h256 h256fromHex(string const &_s)
StandardTrace::DebugOptions debugOptions(Json::Value const &_json)
virtual u256 gasBidPrice() const override
Get the gas bid price.
void setOptions(DebugOptions _options)
void setResultRecipient(ExecutionResult &_res)
Collect execution results in the result storage provided.
Json::Value traceBlock(dev::eth::Block const &_block, Json::Value const &_json)