 |
Ethereum
PoC-8
The C++ Implementation of Ethereum
|
Go to the documentation of this file.
33 #include <unordered_map>
38 namespace test {
class ImportTest;
class StateLoader; }
49 using errinfo_now = boost::error_info<struct tag_now, unsigned>;
125 assert(_kind !=
Code);
204 std::unordered_map<Address, u256>
addresses()
const;
208 std::pair<AddressMap, h256>
addresses(
h256 const& _begin,
size_t _maxResults)
const;
283 std::map<h256, std::pair<u256, u256>>
storage(
Address const& _contract)
const;
335 void removeEmptyAccounts();
346 void clearCacheIfTooLarge()
const;
348 void createAccount(
Address const& _address,
Account const&& _account);
360 mutable std::unordered_map<Address, Account> m_cache;
362 mutable std::vector<Address> m_unchangedCacheEntries;
364 mutable std::set<Address> m_nonExistingAccountsCache;
368 u256 m_accountStartNonce;
bytes oldCode
Code overwritten by CREATE, empty except in case of address collision.
boost::error_info< struct tag_block, bytes > errinfo_block
std::function< void(uint64_t, uint64_t, Instruction, bigint, bigint, bigint, VMFace const *, ExtVMFace const *)> OnOpFunc
Address address
Changed account address.
bool addressInUse(Address const &_address) const
Check if the address is in use.
h256 rootHash() const
The hash of the root of our state tree.
u256 const & accountStartNonce() const
Get the account start nonce. May be required.
Encodes a transaction, ready to be exported to or freshly imported from RLP.
void subBalance(Address const &_addr, u256 const &_value)
Change(Address const &_addr, u256 const &_value)
Helper constructor for nonce change log.
void setNonce(Address const &_addr, u256 const &_newNonce)
Set the account nonce.
static OverlayDB openDB(boost::filesystem::path const &_path, h256 const &_genesisHash, WithExisting _we=WithExisting::Trust)
Open a DB - useful for passing into the constructor & keeping for other states that are necessary.
void kill(Address _a)
Delete an account (used for processing suicides).
friend std::ostream & operator<<(std::ostream &_out, State const &_s)
bytes const & code(Address const &_addr) const
State & createIntermediateState(State &o_s, Block const &_block, unsigned _txIndex, BlockChain const &_bc)
std::vector< Change > ChangeLog
void noteAccountStartNonce(u256 const &_actual)
std::unordered_map< Address, Account > AccountMap
u256 getNonce(Address const &_addr) const
u256 value
Change value, e.g. balance, storage and nonce.
AddressHash commit(AccountMap const &_cache, SecureTrieDB< Address, DB > &_state)
void commit(CommitBehaviour _commitBehaviour)
void incNonce(Address const &_id)
Increament the account nonce.
size_t codeSize(Address const &_contract) const
@ Touch
Account was touched for the first time.
friend class dev::test::ImportTest
void setBalance(Address const &_addr, u256 const &_value)
Change(Address const &_addr, bytes const &_oldCode)
Helper constructor especially for new code change log.
bool accountNonemptyAndExisting(Address const &_address) const
ChangeLog const & changeLog() const
void addBalance(Address const &_id, u256 const &_amount)
void clearStorage(Address const &_contract)
Clear the storage root hash of an account to the hash of the empty trie.
std::unordered_set< h160 > AddressHash
A hash set of Ethereum addresses.
@ Create
Account was created (it was not existing before).
State & operator=(State const &_s)
Copy state object.
boost::error_info< struct tag_phase, unsigned > errinfo_phase
@ Uncommitted
Uncommitted state for change log readings in tests.
void executeBlockTransactions(Block const &_block, unsigned _txCount, LastBlockHashesFace const &_lastHashes, SealEngineFace const &_sealEngine)
@ Code
New code was added to an account (by "create" message execution).
void populateFrom(AccountMap const &_map)
Populate the state from the given AccountMap. Just uses dev::eth::commit().
Kind kind
The kind of the change.
boost::error_info< struct tag_vmtrace, std::string > errinfo_vmtrace
boost::error_info< struct tag_get_LogBloom, LogBloom > errinfo_got_LogBloom
boost::error_info< struct tag_transactionIndex, unsigned > errinfo_transactionIndex
std::vector< byte > bytes
boost::error_info< struct tag_uncleNumber, u256 > errinfo_uncleNumber
Change(Address const &_addr, u256 const &_key, u256 const &_value)
Helper constructor especially for storage change log.
Message-call/contract-creation executor; useful for executing transactions.
Implements the blockchain database. All data this gives is disk-backed. @threadsafe.
Externality interface for the Virtual Machine providing access to world state.
State(u256 const &_accountStartNonce)
Default constructor; creates with a blank database prepopulated with the genesis block.
bool addressHasCode(Address const &_address) const
Check if the address contains executable code.
constexpr u256 Invalid256
boost::error_info< struct tag_uncleIndex, unsigned > errinfo_uncleIndex
A queue of Transactions, each stored as RLP. Maintains a transaction queue sorted by nonce diff and g...
@ Nonce
Account nonce was changed.
Change(Kind _kind, Address const &_addr, u256 const &_value=0)
Helper constructor to make change log update more readable.
An atomic state changelog entry.
OverlayDB const & db() const
std::map< h256, Address > AddressMap
void transferBalance(Address const &_from, Address const &_to, u256 const &_value)
Transfers "the balance _value between two accounts.
u256 const & requireAccountStartNonce() const
boost::error_info< struct tag_unclesExcluded, h256Hash > errinfo_unclesExcluded
void setStorage(Address const &_contract, u256 const &_location, u256 const &_value)
Set the value of a storage position of an account.
boost::multiprecision::number< boost::multiprecision::cpp_int_backend< 256, 256, boost::multiprecision::unsigned_magnitude, boost::multiprecision::unchecked, void > > u256
boost::error_info< struct tag_transaction, bytes > errinfo_transaction
h256 storageRoot(Address const &_contract) const
Get the root of the storage of an account.
boost::error_info< struct tag_receipts, std::vector< bytes > > errinfo_receipts
std::ostream & operator<<(std::ostream &_out, BlockHeader const &_bi)
u256 originalStorageValue(Address const &_contract, u256 const &_key) const
boost::error_info< struct tag_currentNumber, u256 > errinfo_currentNumber
Verified block info, does not hold block data, but a reference instead.
u256 key
Storage key. Last because used only in one case.
void setRoot(h256 const &_root)
Resets any uncommitted changes to the cache.
DEV_SIMPLE_EXCEPTION(NoHashRecorded)
std::unordered_map< Address, u256 > addresses() const
void setCode(Address const &_address, bytes &&_code)
Sets the code of the account. Must only be called during / after contract creation.
friend class dev::test::StateLoader
u256 balance(Address const &_id) const
h256 codeHash(Address const &_contract) const
void rollback(size_t _savepoint)
Revert all recent changes up to the given _savepoint savepoint.
boost::error_info< struct tag_now, unsigned > errinfo_now
std::pair< ExecutionResult, TransactionReceipt > execute(EnvInfo const &_envInfo, SealEngineFace const &_sealEngine, Transaction const &_t, Permanence _p=Permanence::Committed, OnOpFunc const &_onOp=OnOpFunc())
u256 storage(Address const &_contract, u256 const &_memory) const
void createContract(Address const &_address)
Create a contract at the given address (with unset code and unchanged balance).
Interface for getting a list of recent block hashes @threadsafe.
boost::error_info< struct tag_required_LogBloom, LogBloom > errinfo_required_LogBloom
Active model of a block within the block chain. Keeps track of all transactions, receipts and state f...
boost::tuple< errinfo_required_LogBloom, errinfo_got_LogBloom > LogBloomRequirementError