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