关闭

【以太坊】Definitions of Data Structure

标签: ethereumblockheadersmartcontract
412人阅读 评论(0) 收藏 举报
分类:

BlockChain

SourceCode: BlockChain

Type Field Description
SharedMutex x_blocks
BlocksHash m_blocks
SharedMutex x_details
BlockDetailsHash m_details
SharedMutex x_logBlooms
BlockLogBloomsHash m_logBlooms
SharedMutex x_receipts
BlockReceiptsHash m_receipts
SharedMutex x_transactionAddresses
TransactionAddressHash m_transactionAddresses
SharedMutex x_blockHashes
BlockHashHash m_blockHashes
SharedMutex x_blocksBlooms
BlocksBloomsHash m_blocksBlooms
Mutex x_cacheUsage
std::deque< std::unordered_set > m_cacheUsage
std::unordered_set< CacheID > m_inUse
std::chrono::system_clock::time_point m_lastCollection
Mutex x_lastLastHashes
LastHashes m_lastLastHashes
Statistics m_lastStats
ldb::DB* m_blocksDB The disk DBs. Thread-safe, so no need for locks.
ldb::DB* m_extrasDB
boost::shared_mutex x_lastBlockHash Hash of the last (valid) block on the longest chain.
h256 m_lastBlockHash
unsigned m_lastBlockNumber = 0
ldb::ReadOptions m_readOptions
ldb::WriteOptions m_writeOptions
ChainParams m_params
std::shared_ptr < SealEngineFace > m_sealEngine consider shared_ptr.
SharedMutex x_genesis
BlockHeader m_genesis because they’re effectively memos.
bytes m_genesisHeaderBytes because they’re effectively memos.
h256 m_genesisHash because they’re effectively memos.
std::function< void(Exception&) > m_onBad Called if we have a block that doesn’t verify.
std::string m_dbPath

Block

Type Filed Description
State m_state Our state tree, as an OverlayDB DB.
Transactions m_transactions The current list of transactions that we’ve included in the state.
TransactionReceipts m_receipts The corresponding list of transaction receipts.
h256Hash m_transactionSet The set of transaction hashes that we’ve included in the state.
State m_precommit State at the point immediately prior to rewards.
BlockHeader m_previousBlock The previous block’s information.
BlockHeader m_currentBlock The current block’s information.
bytes m_currentBytes The current block’s bytes.
bool m_committedToSeal Default: false, Have we committed to mine on the present m_currentBlock?
bytes m_currentTxs The RLP-encoded block of transactions.
bytes m_currentUncles The RLP-encoded block of uncles.
Address m_author Our address (i.e. the address to which fees go).
SealEngineFace* m_sealEngine Default: nullptr , The chain’s seal engine.

Block Header

h256 m_parentHash;
h256 m_sha3Uncles;
h256 m_stateRoot;
h256 m_transactionsRoot;
h256 m_receiptsRoot;
LogBloom m_logBloom;
u256 m_number;
u256 m_gasLimit;
u256 m_gasUsed;
bytes m_extraData;
u256 m_timestamp = Invalid256;
Address m_author;
u256 m_difficulty;
std::vector<bytes> m_seal;      ///< Additional (RLP-encoded) header fields.
mutable h256 m_hash;            ///< (Memoised) SHA3 hash of the block header with seal.
mutable h256 m_hashWithout;     ///< (Memoised) SHA3 hash of the block header without seal.
Filed Type Description
m_parentHash h256
m_sha3Uncles h256
m_stateRoot h256 MPT Hash Root of States
m_transactionsRoot h256 MPT Hash Root of Transactions
m_receiptsRoot h256 ?
m_logBloom LogBloom
m_number u256
m_gasLimit u256
m_gasUsed u256
m_extraData bytes
m_timestamp u256
m_author Address
m_difficulty u256
m_seal vector < bytes >
m_hash h256
m_hashWithout h256

State

SourceCode: State

Type Filed Description
OverlayDB m_db Our overlay for the state tree.
SecureTrieDB< Address,OverlayDB > m_state Our state tree, as an OverlayDB DB.
map< Address,Account > m_cache Our address cache. This stores the states of each address that has (or at least might have) been changed.
AddressHash m_touched Tracks all addresses touched so far.
u256 m_accountStartNonce
string c_defaultPath

Transaction Type

Type Description
NullTransaction Null transaction.
ContractCreation Transaction to create contracts - receiveAddress() is ignored.
MessageCall Transaction to invoke a message call - receiveAddress() is used.

TransactionSkeleton

struct TransactionSkeleton
{
    bool creation = false;
    Address from;
    Address to;
    u256 value;
    bytes data;
    u256 nonce = Invalid256;
    u256 gas = Invalid256;
    u256 gasPrice = Invalid256;
};

TransactionBase

Type Field Description
Type m_type Default: NullTransaction Is this a contract-creation transaction or a message-call transaction?
u256 m_nonce The transaction-count of the sender.
u256 m_value The amount of ETH to be transferred by this transaction. Called ‘endowment’ for contract-creation transactions.
Address m_receiveAddress The receiving address of the transaction.
u256 m_gasPrice The base fee and thus the implied exchange rate of ETH to GAS.
u256 m_gas The total gas to convert, paid for from sender’s account. Any unused gas gets refunded once the contract is ended.
bytes m_data The data associated with the transaction, or the initialiser if it’s a creation transaction.
SignatureStruct m_vrs The signature of the transaction. Encodes the sender.
h256 m_hashWith Cached hash of transaction with signature.
Address m_sender Cached sender, determined from signature.
bigint m_gasRequired = 0 Memoised amount required for the transaction to run.

Receipts

LogBloom

Instructions

OpCode Description
STOP = 0x00 halts execution
ADD addition operation
MUL mulitplication operation
SUB subtraction operation
DIV integer division operation
SDIV signed integer division operation
MOD modulo remainder operation
SMOD signed modulo remainder operation
ADDMOD unsigned modular addition
MULMOD unsigned modular multiplication
EXP exponential operation
SIGNEXTEND extend length of signed integer
LT = 0x10 less-than comparision
GT greater-than comparision
SLT signed less-than comparision
SGT signed greater-than comparision
EQ equality comparision
ISZERO simple not operator
AND bitwise AND operation
OR bitwise OR operation
XOR bitwise XOR operation
NOT bitwise NOT opertation
BYTE retrieve single byte from word
SHA3 = 0x20 compute SHA3-256 hash
ADDRESS = 0x30 get address of currently executing account
BALANCE get balance of the given account
ORIGIN get execution origination address
CALLER get caller address
CALLVALUE get deposited value by the instruction/transaction responsible for this execution
CALLDATALOAD get input data of current environment
CALLDATASIZE get size of input data in current environment
CALLDATACOPY copy input data in current environment to memory
CODESIZE get size of code running in current environment
CODECOPY copy code running in current environment to memory
GASPRICE get price of gas in current environment
EXTCODESIZE get external code size (from another contract)
EXTCODECOPY copy external code (from another contract)
BLOCKHASH = 0x40 get hash of most recent complete block
COINBASE get the block’s coinbase address
TIMESTAMP get the block’s timestamp
NUMBER get the block’s number
DIFFICULTY get the block’s difficulty
GASLIMIT get the block’s gas limit
POP = 0x50 remove item from stack
MLOAD load word from memory
MSTORE save word to memory
MSTORE8 save byte to memory
SLOAD load word from storage
SSTORE save word to storage
JUMP alter the program counter
JUMPI conditionally alter the program counter
PC get the program counter
MSIZE get the size of active memory
GAS get the amount of available gas
JUMPDEST set a potential jump destination
PUSH1 = 0x60 place 1 byte item on stack
PUSH2 place 2 byte item on stack
PUSH3 place 3 byte item on stack
PUSH4 place 4 byte item on stack
PUSH5 place 5 byte item on stack
PUSH6 place 6 byte item on stack
PUSH7 place 7 byte item on stack
PUSH8 place 8 byte item on stack
PUSH9 place 9 byte item on stack
PUSH10 place 10 byte item on stack
PUSH11 place 11 byte item on stack
PUSH12 place 12 byte item on stack
PUSH13 place 13 byte item on stack
PUSH14 place 14 byte item on stack
PUSH15 place 15 byte item on stack
PUSH16 place 16 byte item on stack
PUSH17 place 17 byte item on stack
PUSH18 place 18 byte item on stack
PUSH19 place 19 byte item on stack
PUSH20 place 20 byte item on stack
PUSH21 place 21 byte item on stack
PUSH22 place 22 byte item on stack
PUSH23 place 23 byte item on stack
PUSH24 place 24 byte item on stack
PUSH25 place 25 byte item on stack
PUSH26 place 26 byte item on stack
PUSH27 place 27 byte item on stack
PUSH28 place 28 byte item on stack
PUSH29 place 29 byte item on stack
PUSH30 place 30 byte item on stack
PUSH31 place 31 byte item on stack
PUSH32 place 32 byte item on stack
DUP1 = 0x80 copies the highest item in the stack to the top of the stack
DUP2 copies the second highest item in the stack to the top of the stack
DUP3 copies the third highest item in the stack to the top of the stack
DUP4 copies the 4th highest item in the stack to the top of the stack
DUP5 copies the 5th highest item in the stack to the top of the stack
DUP6 copies the 6th highest item in the stack to the top of the stack
DUP7 copies the 7th highest item in the stack to the top of the stack
DUP8 copies the 8th highest item in the stack to the top of the stack
DUP9 copies the 9th highest item in the stack to the top of the stack
DUP10 copies the 10th highest item in the stack to the top of the stack
DUP11 copies the 11th highest item in the stack to the top of the stack
DUP12 copies the 12th highest item in the stack to the top of the stack
DUP13 copies the 13th highest item in the stack to the top of the stack
DUP14 copies the 14th highest item in the stack to the top of the stack
DUP15 copies the 15th highest item in the stack to the top of the stack
DUP16 copies the 16th highest item in the stack to the top of the stack
SWAP1 = 0x90 swaps the highest and second highest value on the stack
SWAP2 swaps the highest and third highest value on the stack
SWAP3 swaps the highest and 4th highest value on the stack
SWAP4 swaps the highest and 5th highest value on the stack
SWAP5 swaps the highest and 6th highest value on the stack
SWAP6 swaps the highest and 7th highest value on the stack
SWAP7 swaps the highest and 8th highest value on the stack
SWAP8 swaps the highest and 9th highest value on the stack
SWAP9 swaps the highest and 10th highest value on the stack
SWAP10 swaps the highest and 11th highest value on the stack
SWAP11 swaps the highest and 12th highest value on the stack
SWAP12 swaps the highest and 13th highest value on the stack
SWAP13 swaps the highest and 14th highest value on the stack
SWAP14 swaps the highest and 15th highest value on the stack
SWAP15 swaps the highest and 16th highest value on the stack
SWAP16 swaps the highest and 17th highest value on the stack
LOG0 = 0xa0 Makes a log entry; no topics.
LOG1 Makes a log entry; 1 topic.
LOG2 Makes a log entry; 2 topics.
LOG3 Makes a log entry; 3 topics.
LOG4 Makes a log entry; 4 topics.
CREATE = 0xf0 create a new account with associated code
CALL message-call into an account
CALLCODE message-call with another account’s code only
RETURN halt execution returning output data
DELEGATECALL like CALLCODE but keeps caller’s value and sender
SUICIDE = 0xff halt execution and register account for later deletion
0
0

查看评论
* 以上用户言论只代表其个人观点,不代表CSDN网站的观点或立场
    个人资料
    • 访问:386295次
    • 积分:5741
    • 等级:
    • 排名:第4511名
    • 原创:190篇
    • 转载:9篇
    • 译文:4篇
    • 评论:193条
    博客专栏
    文章分类