Forks

Frontier

FrontierVM

class eth.vm.forks.frontier.FrontierVM(header: eth.abc.BlockHeaderAPI, chaindb: eth.abc.ChainDatabaseAPI, chain_context: eth.abc.ChainContextAPI, consensus_context: eth.abc.ConsensusContextAPI)
block_class

alias of eth.vm.forks.frontier.blocks.FrontierBlock

add_receipt_to_header(old_header: eth.abc.BlockHeaderAPI, receipt: eth.abc.ReceiptAPI) → eth.abc.BlockHeaderAPI

Apply the receipt to the old header, and return the resulting header. This may have storage-related side-effects. For example, pre-Byzantium, the state root hash is included in the receipt, and so must be stored into the database.

static compute_difficulty(parent_header: eth.abc.BlockHeaderAPI, timestamp: int) → int

Computes the difficulty for a frontier block based on the parent block.

static get_block_reward() → int

Return the amount in wei that should be given to a miner as a reward for this block.

Note

This is an abstract method that must be implemented in subclasses

classmethod get_nephew_reward() → int

Return the reward which should be given to the miner of the given nephew.

Note

This is an abstract method that must be implemented in subclasses

static get_uncle_reward(block_number: int, uncle: eth.abc.BlockHeaderAPI) → int

Return the reward which should be given to the miner of the given uncle.

Note

This is an abstract method that must be implemented in subclasses

classmethod make_receipt(base_header: eth.abc.BlockHeaderAPI, transaction: eth.abc.SignedTransactionAPI, computation: eth.abc.ComputationAPI, state: eth.abc.StateAPI) → eth.abc.ReceiptAPI

Generate the receipt resulting from applying the transaction.

Parameters:
  • base_header – the header of the block before the transaction was applied.
  • transaction – the transaction used to generate the receipt
  • computation – the result of running the transaction computation
  • state – the resulting state, after executing the computation
Returns:

receipt

FrontierState

class eth.vm.forks.frontier.state.FrontierState(db: eth.abc.AtomicDatabaseAPI, execution_context: eth.abc.ExecutionContextAPI, state_root: NewType.<locals>.new_type)
account_db_class

alias of eth.db.account.AccountDB

computation_class

alias of eth.vm.forks.frontier.computation.FrontierComputation

transaction_context_class

alias of eth.vm.forks.frontier.transaction_context.FrontierTransactionContext

transaction_executor_class

alias of FrontierTransactionExecutor

apply_transaction(transaction: eth.abc.SignedTransactionAPI) → eth.abc.ComputationAPI

Apply transaction to the vm state

Parameters:transaction – the transaction to apply
Returns:the computation
validate_transaction(transaction: eth.abc.SignedTransactionAPI) → None

Validate the given transaction.

FrontierComputation

class eth.vm.forks.frontier.computation.FrontierComputation(state: eth.abc.StateAPI, message: eth.abc.MessageAPI, transaction_context: eth.abc.TransactionContextAPI)

A class for all execution computations in the Frontier fork. Inherits from BaseComputation

classmethod apply_create_message(state: eth.abc.StateAPI, message: eth.abc.MessageAPI, transaction_context: eth.abc.TransactionContextAPI) → eth.abc.ComputationAPI

Execute a VM message to create a new contract. This is where the VM-specific create logic exists.

classmethod apply_message(state: eth.abc.StateAPI, message: eth.abc.MessageAPI, transaction_context: eth.abc.TransactionContextAPI) → eth.abc.ComputationAPI

Execute a VM message. This is where the VM-specific call logic exists.

Homestead

HomesteadVM

class eth.vm.forks.homestead.HomesteadVM(header: eth.abc.BlockHeaderAPI, chaindb: eth.abc.ChainDatabaseAPI, chain_context: eth.abc.ChainContextAPI, consensus_context: eth.abc.ConsensusContextAPI)
block_class

alias of eth.vm.forks.homestead.blocks.HomesteadBlock

static compute_difficulty(parent_header: eth.abc.BlockHeaderAPI, timestamp: int) → int

Computes the difficulty for a homestead block based on the parent block.

HomesteadState

class eth.vm.forks.homestead.state.HomesteadState(db: eth.abc.AtomicDatabaseAPI, execution_context: eth.abc.ExecutionContextAPI, state_root: NewType.<locals>.new_type)
computation_class

alias of eth.vm.forks.homestead.computation.HomesteadComputation

validate_transaction(transaction: eth.abc.SignedTransactionAPI) → None

Validate the given transaction.

HomesteadComputation

class eth.vm.forks.homestead.computation.HomesteadComputation(state: eth.abc.StateAPI, message: eth.abc.MessageAPI, transaction_context: eth.abc.TransactionContextAPI)

A class for all execution computations in the Frontier fork. Inherits from FrontierComputation

classmethod apply_create_message(state: eth.abc.StateAPI, message: eth.abc.MessageAPI, transaction_context: eth.abc.TransactionContextAPI) → eth.abc.ComputationAPI

Execute a VM message to create a new contract. This is where the VM-specific create logic exists.

TangerineWhistle

TangerineWhistleVM

class eth.vm.forks.tangerine_whistle.TangerineWhistleVM(header: eth.abc.BlockHeaderAPI, chaindb: eth.abc.ChainDatabaseAPI, chain_context: eth.abc.ChainContextAPI, consensus_context: eth.abc.ConsensusContextAPI)

TangerineWhistleState

class eth.vm.forks.tangerine_whistle.state.TangerineWhistleState(db: eth.abc.AtomicDatabaseAPI, execution_context: eth.abc.ExecutionContextAPI, state_root: NewType.<locals>.new_type)
computation_class

alias of eth.vm.forks.tangerine_whistle.computation.TangerineWhistleComputation

TangerineWhistleComputation

class eth.vm.forks.tangerine_whistle.computation.TangerineWhistleComputation(state: eth.abc.StateAPI, message: eth.abc.MessageAPI, transaction_context: eth.abc.TransactionContextAPI)

A class for all execution computations in the TangerineWhistle fork. Inherits from HomesteadComputation

SpuriousDragon

SpuriousDragonVM

class eth.vm.forks.spurious_dragon.SpuriousDragonVM(header: eth.abc.BlockHeaderAPI, chaindb: eth.abc.ChainDatabaseAPI, chain_context: eth.abc.ChainContextAPI, consensus_context: eth.abc.ConsensusContextAPI)
block_class

alias of eth.vm.forks.spurious_dragon.blocks.SpuriousDragonBlock

SpuriousDragonState

class eth.vm.forks.spurious_dragon.state.SpuriousDragonState(db: eth.abc.AtomicDatabaseAPI, execution_context: eth.abc.ExecutionContextAPI, state_root: NewType.<locals>.new_type)
computation_class

alias of eth.vm.forks.spurious_dragon.computation.SpuriousDragonComputation

transaction_executor_class

alias of SpuriousDragonTransactionExecutor

SpuriousDragonComputation

class eth.vm.forks.spurious_dragon.computation.SpuriousDragonComputation(state: eth.abc.StateAPI, message: eth.abc.MessageAPI, transaction_context: eth.abc.TransactionContextAPI)

A class for all execution computations in the SpuriousDragon fork. Inherits from HomesteadComputation

classmethod apply_create_message(state: eth.abc.StateAPI, message: eth.abc.MessageAPI, transaction_context: eth.abc.TransactionContextAPI) → eth.abc.ComputationAPI

Execute a VM message to create a new contract. This is where the VM-specific create logic exists.

Byzantium

ByzantiumVM

class eth.vm.forks.byzantium.ByzantiumVM(header: eth.abc.BlockHeaderAPI, chaindb: eth.abc.ChainDatabaseAPI, chain_context: eth.abc.ChainContextAPI, consensus_context: eth.abc.ConsensusContextAPI)
block_class

alias of eth.vm.forks.byzantium.blocks.ByzantiumBlock

add_receipt_to_header(old_header: eth.abc.BlockHeaderAPI, receipt: eth.abc.ReceiptAPI) → eth.abc.BlockHeaderAPI

Apply the receipt to the old header, and return the resulting header. This may have storage-related side-effects. For example, pre-Byzantium, the state root hash is included in the receipt, and so must be stored into the database.

static get_block_reward() → int

Return the amount in wei that should be given to a miner as a reward for this block.

Note

This is an abstract method that must be implemented in subclasses

classmethod make_receipt(base_header: eth.abc.BlockHeaderAPI, transaction: eth.abc.SignedTransactionAPI, computation: eth.abc.ComputationAPI, state: eth.abc.StateAPI) → eth.abc.ReceiptAPI

Generate the receipt resulting from applying the transaction.

Parameters:
  • base_header – the header of the block before the transaction was applied.
  • transaction – the transaction used to generate the receipt
  • computation – the result of running the transaction computation
  • state – the resulting state, after executing the computation
Returns:

receipt

classmethod validate_receipt(receipt: eth.abc.ReceiptAPI) → None

Validate the given receipt.

compute_difficulty

https://github.com/ethereum/EIPs/issues/100

ByzantiumState

class eth.vm.forks.byzantium.state.ByzantiumState(db: eth.abc.AtomicDatabaseAPI, execution_context: eth.abc.ExecutionContextAPI, state_root: NewType.<locals>.new_type)
computation_class

alias of eth.vm.forks.byzantium.computation.ByzantiumComputation

ByzantiumComputation

class eth.vm.forks.byzantium.computation.ByzantiumComputation(state: eth.abc.StateAPI, message: eth.abc.MessageAPI, transaction_context: eth.abc.TransactionContextAPI)

A class for all execution computations in the Byzantium fork. Inherits from SpuriousDragonComputation

Constantinople

ConstantinopleVM

class eth.vm.forks.constantinople.ConstantinopleVM(header: eth.abc.BlockHeaderAPI, chaindb: eth.abc.ChainDatabaseAPI, chain_context: eth.abc.ChainContextAPI, consensus_context: eth.abc.ConsensusContextAPI)
block_class

alias of eth.vm.forks.constantinople.blocks.ConstantinopleBlock

static get_block_reward() → int

Return the amount in wei that should be given to a miner as a reward for this block.

Note

This is an abstract method that must be implemented in subclasses

compute_difficulty

https://github.com/ethereum/EIPs/issues/100

ConstantinopleState

class eth.vm.forks.constantinople.state.ConstantinopleState(db: eth.abc.AtomicDatabaseAPI, execution_context: eth.abc.ExecutionContextAPI, state_root: NewType.<locals>.new_type)
computation_class

alias of eth.vm.forks.constantinople.computation.ConstantinopleComputation

ConstantinopleComputation

class eth.vm.forks.constantinople.computation.ConstantinopleComputation(state: eth.abc.StateAPI, message: eth.abc.MessageAPI, transaction_context: eth.abc.TransactionContextAPI)

A class for all execution computations in the Constantinople fork. Inherits from ByzantiumComputation

get_gas_meter() → eth.vm.gas_meter.GasMeter

Return the GasMeterAPI of the computation.

Petersburg

PetersburgVM

class eth.vm.forks.petersburg.PetersburgVM(header: eth.abc.BlockHeaderAPI, chaindb: eth.abc.ChainDatabaseAPI, chain_context: eth.abc.ChainContextAPI, consensus_context: eth.abc.ConsensusContextAPI)
block_class

alias of eth.vm.forks.petersburg.blocks.PetersburgBlock

static get_block_reward() → int

Return the amount in wei that should be given to a miner as a reward for this block.

Note

This is an abstract method that must be implemented in subclasses

compute_difficulty

https://github.com/ethereum/EIPs/issues/100

PetersburgState

class eth.vm.forks.petersburg.state.PetersburgState(db: eth.abc.AtomicDatabaseAPI, execution_context: eth.abc.ExecutionContextAPI, state_root: NewType.<locals>.new_type)
computation_class

alias of eth.vm.forks.petersburg.computation.PetersburgComputation

PetersburgComputation

class eth.vm.forks.petersburg.computation.PetersburgComputation(state: eth.abc.StateAPI, message: eth.abc.MessageAPI, transaction_context: eth.abc.TransactionContextAPI)

A class for all execution computations in the Petersburg fork. Inherits from ByzantiumComputation

Istanbul

IstanbulVM

class eth.vm.forks.istanbul.IstanbulVM(header: eth.abc.BlockHeaderAPI, chaindb: eth.abc.ChainDatabaseAPI, chain_context: eth.abc.ChainContextAPI, consensus_context: eth.abc.ConsensusContextAPI)
block_class

alias of eth.vm.forks.istanbul.blocks.IstanbulBlock

compute_difficulty

https://github.com/ethereum/EIPs/issues/100

IstanbulState

class eth.vm.forks.istanbul.state.IstanbulState(db: eth.abc.AtomicDatabaseAPI, execution_context: eth.abc.ExecutionContextAPI, state_root: NewType.<locals>.new_type)
computation_class

alias of eth.vm.forks.istanbul.computation.IstanbulComputation

IstanbulComputation

class eth.vm.forks.istanbul.computation.IstanbulComputation(state: eth.abc.StateAPI, message: eth.abc.MessageAPI, transaction_context: eth.abc.TransactionContextAPI)

A class for all execution computations in the Istanbul fork. Inherits from PetersburgComputation

get_gas_meter() → eth.vm.gas_meter.GasMeter

Return the GasMeterAPI of the computation.

Muir Glacier

Submodules

eth.vm.forks.muir_glacier.blocks module

class eth.vm.forks.muir_glacier.blocks.MuirGlacierBlock(header: eth.abc.BlockHeaderAPI, transactions: Sequence[eth.abc.SignedTransactionAPI] = None, uncles: Sequence[eth.abc.BlockHeaderAPI] = None)

Bases: eth.vm.forks.istanbul.blocks.IstanbulBlock

transaction_builder

alias of eth.vm.forks.muir_glacier.transactions.MuirGlacierTransaction

header
transactions
uncles

eth.vm.forks.muir_glacier.computation module

class eth.vm.forks.muir_glacier.computation.MuirGlacierComputation(state: eth.abc.StateAPI, message: eth.abc.MessageAPI, transaction_context: eth.abc.TransactionContextAPI)

Bases: eth.vm.forks.istanbul.computation.IstanbulComputation

A class for all execution computations in the MuirGlacier fork. Inherits from IstanbulComputation

opcodes = {0: <abc.opcode:STOP object at 0x7fc93d14e748>, 1: <abc.opcode:ADD object at 0x7fc93d14e6a0>, 2: <abc.opcode:MUL object at 0x7fc93d14e780>, 3: <abc.opcode:SUB object at 0x7fc93d14e7f0>, 4: <abc.opcode:DIV object at 0x7fc93d14e898>, 5: <abc.opcode:SDIV object at 0x7fc93d14e8d0>, 6: <abc.opcode:MOD object at 0x7fc93d14e908>, 7: <abc.opcode:SMOD object at 0x7fc93d14e940>, 8: <abc.opcode:ADDMOD object at 0x7fc93d14e978>, 9: <abc.opcode:MULMOD object at 0x7fc93d14e9b0>, 10: <abc.opcode:EXP object at 0x7fc93d14e9e8>, 11: <abc.opcode:SIGNEXTEND object at 0x7fc93d14ea20>, 16: <abc.opcode:LT object at 0x7fc93d14ea58>, 17: <abc.opcode:GT object at 0x7fc93d14ea90>, 18: <abc.opcode:SLT object at 0x7fc93d14eac8>, 19: <abc.opcode:SGT object at 0x7fc93d14eb00>, 20: <abc.opcode:EQ object at 0x7fc93d14eb38>, 21: <abc.opcode:ISZERO object at 0x7fc93d14eb70>, 22: <abc.opcode:AND object at 0x7fc93d14eba8>, 23: <abc.opcode:OR object at 0x7fc93d14ebe0>, 24: <abc.opcode:XOR object at 0x7fc93d14ec18>, 25: <abc.opcode:NOT object at 0x7fc93d14ec50>, 26: <abc.opcode:BYTE object at 0x7fc93d14ec88>, 27: <abc.opcode:SHL object at 0x7fc93d153588>, 28: <abc.opcode:SHR object at 0x7fc93d1535c0>, 29: <abc.opcode:SAR object at 0x7fc93d1535f8>, 32: <abc.opcode:SHA3 object at 0x7fc93d14ecc0>, 48: <abc.opcode:ADDRESS object at 0x7fc93d14ecf8>, 49: <abc.opcode:BALANCE object at 0x7fc93d14ed30>, 50: <abc.opcode:ORIGIN object at 0x7fc93d14ed68>, 51: <abc.opcode:CALLER object at 0x7fc93d14eda0>, 52: <abc.opcode:CALLVALUE object at 0x7fc93d14edd8>, 53: <abc.opcode:CALLDATALOAD object at 0x7fc93d14ee10>, 54: <abc.opcode:CALLDATASIZE object at 0x7fc93d14ee48>, 55: <abc.opcode:CALLDATACOPY object at 0x7fc93d14ee80>, 56: <abc.opcode:CODESIZE object at 0x7fc93d14eeb8>, 57: <abc.opcode:CODECOPY object at 0x7fc93d14eef0>, 58: <abc.opcode:GASPRICE object at 0x7fc93d14ef28>, 59: <abc.opcode:EXTCODESIZE object at 0x7fc93d14ef60>, 60: <abc.opcode:EXTCODECOPY object at 0x7fc93d14ef98>, 61: <abc.opcode:RETURNDATASIZE object at 0x7fc93d1534e0>, 62: <abc.opcode:RETURNDATACOPY object at 0x7fc93d153518>, 63: <abc.opcode:EXTCODEHASH object at 0x7fc93d153630>, 64: <abc.opcode:BLOCKHASH object at 0x7fc93d14efd0>, 65: <abc.opcode:COINBASE object at 0x7fc93d152048>, 66: <abc.opcode:TIMESTAMP object at 0x7fc93d152080>, 67: <abc.opcode:NUMBER object at 0x7fc93d1520b8>, 68: <abc.opcode:DIFFICULTY object at 0x7fc93d1520f0>, 69: <abc.opcode:GASLIMIT object at 0x7fc93d152128>, 70: <abc.opcode:CHAINID object at 0x7fc93d1536a0>, 71: <abc.opcode:SELFBALANCE object at 0x7fc93d1536d8>, 80: <abc.opcode:POP object at 0x7fc93d152160>, 81: <abc.opcode:MLOAD object at 0x7fc93d152198>, 82: <abc.opcode:MSTORE object at 0x7fc93d1521d0>, 83: <abc.opcode:MSTORE8 object at 0x7fc93d152208>, 84: <abc.opcode:SLOAD object at 0x7fc93d152240>, 85: <abc.opcode:SSTORE object at 0x7fc93d152278>, 86: <abc.opcode:JUMP object at 0x7fc93d1522b0>, 87: <abc.opcode:JUMPI object at 0x7fc93d1522e8>, 88: <abc.opcode:PC object at 0x7fc93d152320>, 89: <abc.opcode:MSIZE object at 0x7fc93d152358>, 90: <abc.opcode:GAS object at 0x7fc93d152390>, 91: <abc.opcode:JUMPDEST object at 0x7fc93d1523c8>, 96: <abc.opcode:PUSH1 object at 0x7fc93d152400>, 97: <abc.opcode:PUSH2 object at 0x7fc93d152438>, 98: <abc.opcode:PUSH3 object at 0x7fc93d152470>, 99: <abc.opcode:PUSH4 object at 0x7fc93d1524a8>, 100: <abc.opcode:PUSH5 object at 0x7fc93d1524e0>, 101: <abc.opcode:PUSH6 object at 0x7fc93d152518>, 102: <abc.opcode:PUSH7 object at 0x7fc93d152550>, 103: <abc.opcode:PUSH8 object at 0x7fc93d152588>, 104: <abc.opcode:PUSH9 object at 0x7fc93d1525c0>, 105: <abc.opcode:PUSH10 object at 0x7fc93d1525f8>, 106: <abc.opcode:PUSH11 object at 0x7fc93d152630>, 107: <abc.opcode:PUSH12 object at 0x7fc93d152668>, 108: <abc.opcode:PUSH13 object at 0x7fc93d1526a0>, 109: <abc.opcode:PUSH14 object at 0x7fc93d1526d8>, 110: <abc.opcode:PUSH15 object at 0x7fc93d152710>, 111: <abc.opcode:PUSH16 object at 0x7fc93d152748>, 112: <abc.opcode:PUSH17 object at 0x7fc93d152780>, 113: <abc.opcode:PUSH18 object at 0x7fc93d1527b8>, 114: <abc.opcode:PUSH19 object at 0x7fc93d1527f0>, 115: <abc.opcode:PUSH20 object at 0x7fc93d152828>, 116: <abc.opcode:PUSH21 object at 0x7fc93d152860>, 117: <abc.opcode:PUSH22 object at 0x7fc93d152898>, 118: <abc.opcode:PUSH23 object at 0x7fc93d1528d0>, 119: <abc.opcode:PUSH24 object at 0x7fc93d152908>, 120: <abc.opcode:PUSH25 object at 0x7fc93d152940>, 121: <abc.opcode:PUSH26 object at 0x7fc93d152978>, 122: <abc.opcode:PUSH27 object at 0x7fc93d1529b0>, 123: <abc.opcode:PUSH28 object at 0x7fc93d1529e8>, 124: <abc.opcode:PUSH29 object at 0x7fc93d152a20>, 125: <abc.opcode:PUSH30 object at 0x7fc93d152a58>, 126: <abc.opcode:PUSH31 object at 0x7fc93d152a90>, 127: <abc.opcode:PUSH32 object at 0x7fc93d152ac8>, 128: <abc.opcode:DUP1 object at 0x7fc93d152b00>, 129: <abc.opcode:DUP2 object at 0x7fc93d152b38>, 130: <abc.opcode:DUP3 object at 0x7fc93d152b70>, 131: <abc.opcode:DUP4 object at 0x7fc93d152ba8>, 132: <abc.opcode:DUP5 object at 0x7fc93d152be0>, 133: <abc.opcode:DUP6 object at 0x7fc93d152c18>, 134: <abc.opcode:DUP7 object at 0x7fc93d152c50>, 135: <abc.opcode:DUP8 object at 0x7fc93d152c88>, 136: <abc.opcode:DUP9 object at 0x7fc93d152cc0>, 137: <abc.opcode:DUP10 object at 0x7fc93d152cf8>, 138: <abc.opcode:DUP11 object at 0x7fc93d152d30>, 139: <abc.opcode:DUP12 object at 0x7fc93d152d68>, 140: <abc.opcode:DUP13 object at 0x7fc93d152da0>, 141: <abc.opcode:DUP14 object at 0x7fc93d152dd8>, 142: <abc.opcode:DUP15 object at 0x7fc93d152e10>, 143: <abc.opcode:DUP16 object at 0x7fc93d152e48>, 144: <abc.opcode:SWAP1 object at 0x7fc93d152e80>, 145: <abc.opcode:SWAP2 object at 0x7fc93d152eb8>, 146: <abc.opcode:SWAP3 object at 0x7fc93d152ef0>, 147: <abc.opcode:SWAP4 object at 0x7fc93d152f28>, 148: <abc.opcode:SWAP5 object at 0x7fc93d152f60>, 149: <abc.opcode:SWAP6 object at 0x7fc93d152f98>, 150: <abc.opcode:SWAP7 object at 0x7fc93d152fd0>, 151: <abc.opcode:SWAP8 object at 0x7fc93d153048>, 152: <abc.opcode:SWAP9 object at 0x7fc93d153080>, 153: <abc.opcode:SWAP10 object at 0x7fc93d1530b8>, 154: <abc.opcode:SWAP11 object at 0x7fc93d1530f0>, 155: <abc.opcode:SWAP12 object at 0x7fc93d153128>, 156: <abc.opcode:SWAP13 object at 0x7fc93d153160>, 157: <abc.opcode:SWAP14 object at 0x7fc93d153198>, 158: <abc.opcode:SWAP15 object at 0x7fc93d1531d0>, 159: <abc.opcode:SWAP16 object at 0x7fc93d153208>, 160: <abc.opcode:LOG0 object at 0x7fc93d153240>, 161: <abc.opcode:LOG1 object at 0x7fc93d153278>, 162: <abc.opcode:LOG2 object at 0x7fc93d1532b0>, 163: <abc.opcode:LOG3 object at 0x7fc93d1532e8>, 164: <abc.opcode:LOG4 object at 0x7fc93d153320>, 240: <abc.opcode:CREATE object at 0x7fc93d153358>, 241: <abc.opcode:CALL object at 0x7fc93d153390>, 242: <abc.opcode:CALLCODE object at 0x7fc93d1533c8>, 243: <abc.opcode:RETURN object at 0x7fc93d153400>, 244: <abc.opcode:DELEGATECALL object at 0x7fc93d153470>, 245: <abc.opcode:CREATE2 object at 0x7fc93d153668>, 250: <abc.opcode:STATICCALL object at 0x7fc93d153550>, 253: <abc.opcode:REVERT object at 0x7fc93d1534a8>, 255: <abc.opcode:SELFDESTRUCT object at 0x7fc93d153438>}

eth.vm.forks.muir_glacier.headers module

eth.vm.forks.muir_glacier.opcodes module

eth.vm.forks.muir_glacier.state module

class eth.vm.forks.muir_glacier.state.MuirGlacierState(db: eth.abc.AtomicDatabaseAPI, execution_context: eth.abc.ExecutionContextAPI, state_root: NewType.<locals>.new_type)

Bases: eth.vm.forks.istanbul.state.IstanbulState

computation_class

alias of eth.vm.forks.muir_glacier.computation.MuirGlacierComputation

eth.vm.forks.muir_glacier.transactions module

class eth.vm.forks.muir_glacier.transactions.MuirGlacierTransaction(*args, **kwargs)

Bases: eth.vm.forks.istanbul.transactions.IstanbulTransaction

classmethod create_unsigned_transaction(*, nonce: int, gas_price: int, gas: int, to: NewType.<locals>.new_type, value: int, data: bytes) → eth.vm.forks.muir_glacier.transactions.MuirGlacierUnsignedTransaction

Create an unsigned transaction.

data
gas
gas_price
nonce
r
s
to
v
value
class eth.vm.forks.muir_glacier.transactions.MuirGlacierUnsignedTransaction(*args, **kwargs)

Bases: eth.vm.forks.istanbul.transactions.IstanbulUnsignedTransaction

as_signed_transaction(private_key: eth_keys.datatypes.PrivateKey, chain_id: int = None) → eth.vm.forks.muir_glacier.transactions.MuirGlacierTransaction

Return a version of this transaction which has been signed using the provided private_key

data
gas
gas_price
nonce
to
value

Module contents

class eth.vm.forks.muir_glacier.MuirGlacierVM(header: eth.abc.BlockHeaderAPI, chaindb: eth.abc.ChainDatabaseAPI, chain_context: eth.abc.ChainContextAPI, consensus_context: eth.abc.ConsensusContextAPI)

Bases: eth.vm.forks.istanbul.IstanbulVM

block_class

alias of eth.vm.forks.muir_glacier.blocks.MuirGlacierBlock

compute_difficulty

https://github.com/ethereum/EIPs/issues/100

configure_header
create_header_from_parent
fork = 'muir-glacier'

Berlin

Submodules

eth.vm.forks.berlin.blocks module

class eth.vm.forks.berlin.blocks.BerlinBlock(header: eth.abc.BlockHeaderAPI, transactions: Sequence[eth.abc.SignedTransactionAPI] = None, uncles: Sequence[eth.abc.BlockHeaderAPI] = None)

Bases: eth.vm.forks.muir_glacier.blocks.MuirGlacierBlock

receipt_builder

alias of eth.vm.forks.berlin.receipts.BerlinReceiptBuilder

transaction_builder

alias of eth.vm.forks.berlin.transactions.BerlinTransactionBuilder

header
transactions
uncles

eth.vm.forks.berlin.computation module

class eth.vm.forks.berlin.computation.BerlinComputation(state: eth.abc.StateAPI, message: eth.abc.MessageAPI, transaction_context: eth.abc.TransactionContextAPI)

Bases: eth.vm.forks.muir_glacier.computation.MuirGlacierComputation

A class for all execution computations in the Berlin fork. Inherits from MuirGlacierComputation

opcodes = {0: <abc.opcode:STOP object at 0x7fc93d113f28>, 1: <abc.opcode:ADD object at 0x7fc93d113eb8>, 2: <abc.opcode:MUL object at 0x7fc93d113e10>, 3: <abc.opcode:SUB object at 0x7fc93d113f98>, 4: <abc.opcode:DIV object at 0x7fc93d113fd0>, 5: <abc.opcode:SDIV object at 0x7fc93d09b048>, 6: <abc.opcode:MOD object at 0x7fc93d09b080>, 7: <abc.opcode:SMOD object at 0x7fc93d09b0b8>, 8: <abc.opcode:ADDMOD object at 0x7fc93d09b0f0>, 9: <abc.opcode:MULMOD object at 0x7fc93d09b128>, 10: <abc.opcode:EXP object at 0x7fc93d09b160>, 11: <abc.opcode:SIGNEXTEND object at 0x7fc93d09b198>, 16: <abc.opcode:LT object at 0x7fc93d09b1d0>, 17: <abc.opcode:GT object at 0x7fc93d09b208>, 18: <abc.opcode:SLT object at 0x7fc93d09b240>, 19: <abc.opcode:SGT object at 0x7fc93d09b278>, 20: <abc.opcode:EQ object at 0x7fc93d09b2b0>, 21: <abc.opcode:ISZERO object at 0x7fc93d09b2e8>, 22: <abc.opcode:AND object at 0x7fc93d09b320>, 23: <abc.opcode:OR object at 0x7fc93d09b358>, 24: <abc.opcode:XOR object at 0x7fc93d09b390>, 25: <abc.opcode:NOT object at 0x7fc93d09b3c8>, 26: <abc.opcode:BYTE object at 0x7fc93d09b400>, 27: <abc.opcode:SHL object at 0x7fc93d09ccc0>, 28: <abc.opcode:SHR object at 0x7fc93d09ccf8>, 29: <abc.opcode:SAR object at 0x7fc93d09cd30>, 32: <abc.opcode:SHA3 object at 0x7fc93d09b438>, 48: <abc.opcode:ADDRESS object at 0x7fc93d09b470>, 49: <abc.opcode:BALANCE object at 0x7fc93d1087f0>, 50: <abc.opcode:ORIGIN object at 0x7fc93d09b4e0>, 51: <abc.opcode:CALLER object at 0x7fc93d09b518>, 52: <abc.opcode:CALLVALUE object at 0x7fc93d09b550>, 53: <abc.opcode:CALLDATALOAD object at 0x7fc93d09b588>, 54: <abc.opcode:CALLDATASIZE object at 0x7fc93d09b5c0>, 55: <abc.opcode:CALLDATACOPY object at 0x7fc93d09b5f8>, 56: <abc.opcode:CODESIZE object at 0x7fc93d09b630>, 57: <abc.opcode:CODECOPY object at 0x7fc93d09b668>, 58: <abc.opcode:GASPRICE object at 0x7fc93d09b6a0>, 59: <abc.opcode:EXTCODESIZE object at 0x7fc93d108908>, 60: <abc.opcode:EXTCODECOPY object at 0x7fc93d108a58>, 61: <abc.opcode:RETURNDATASIZE object at 0x7fc93d09cc18>, 62: <abc.opcode:RETURNDATACOPY object at 0x7fc93d09cc50>, 63: <abc.opcode:EXTCODEHASH object at 0x7fc93d108c50>, 64: <abc.opcode:BLOCKHASH object at 0x7fc93d09b748>, 65: <abc.opcode:COINBASE object at 0x7fc93d09b780>, 66: <abc.opcode:TIMESTAMP object at 0x7fc93d09b7b8>, 67: <abc.opcode:NUMBER object at 0x7fc93d09b7f0>, 68: <abc.opcode:DIFFICULTY object at 0x7fc93d09b828>, 69: <abc.opcode:GASLIMIT object at 0x7fc93d09b860>, 70: <abc.opcode:CHAINID object at 0x7fc93d09cdd8>, 71: <abc.opcode:SELFBALANCE object at 0x7fc93d09ce10>, 80: <abc.opcode:POP object at 0x7fc93d09b898>, 81: <abc.opcode:MLOAD object at 0x7fc93d09b8d0>, 82: <abc.opcode:MSTORE object at 0x7fc93d09b908>, 83: <abc.opcode:MSTORE8 object at 0x7fc93d09b940>, 84: <abc.opcode:SLOAD object at 0x7fc93d108e48>, 85: <abc.opcode:SSTORE object at 0x7fc93d1130b8>, 86: <abc.opcode:JUMP object at 0x7fc93d09b9e8>, 87: <abc.opcode:JUMPI object at 0x7fc93d09ba20>, 88: <abc.opcode:PC object at 0x7fc93d09ba58>, 89: <abc.opcode:MSIZE object at 0x7fc93d09ba90>, 90: <abc.opcode:GAS object at 0x7fc93d09bac8>, 91: <abc.opcode:JUMPDEST object at 0x7fc93d09bb00>, 96: <abc.opcode:PUSH1 object at 0x7fc93d09bb38>, 97: <abc.opcode:PUSH2 object at 0x7fc93d09bb70>, 98: <abc.opcode:PUSH3 object at 0x7fc93d09bba8>, 99: <abc.opcode:PUSH4 object at 0x7fc93d09bbe0>, 100: <abc.opcode:PUSH5 object at 0x7fc93d09bc18>, 101: <abc.opcode:PUSH6 object at 0x7fc93d09bc50>, 102: <abc.opcode:PUSH7 object at 0x7fc93d09bc88>, 103: <abc.opcode:PUSH8 object at 0x7fc93d09bcc0>, 104: <abc.opcode:PUSH9 object at 0x7fc93d09bcf8>, 105: <abc.opcode:PUSH10 object at 0x7fc93d09bd30>, 106: <abc.opcode:PUSH11 object at 0x7fc93d09bd68>, 107: <abc.opcode:PUSH12 object at 0x7fc93d09bda0>, 108: <abc.opcode:PUSH13 object at 0x7fc93d09bdd8>, 109: <abc.opcode:PUSH14 object at 0x7fc93d09be10>, 110: <abc.opcode:PUSH15 object at 0x7fc93d09be48>, 111: <abc.opcode:PUSH16 object at 0x7fc93d09be80>, 112: <abc.opcode:PUSH17 object at 0x7fc93d09beb8>, 113: <abc.opcode:PUSH18 object at 0x7fc93d09bef0>, 114: <abc.opcode:PUSH19 object at 0x7fc93d09bf28>, 115: <abc.opcode:PUSH20 object at 0x7fc93d09bf60>, 116: <abc.opcode:PUSH21 object at 0x7fc93d09bf98>, 117: <abc.opcode:PUSH22 object at 0x7fc93d09bfd0>, 118: <abc.opcode:PUSH23 object at 0x7fc93d09c048>, 119: <abc.opcode:PUSH24 object at 0x7fc93d09c080>, 120: <abc.opcode:PUSH25 object at 0x7fc93d09c0b8>, 121: <abc.opcode:PUSH26 object at 0x7fc93d09c0f0>, 122: <abc.opcode:PUSH27 object at 0x7fc93d09c128>, 123: <abc.opcode:PUSH28 object at 0x7fc93d09c160>, 124: <abc.opcode:PUSH29 object at 0x7fc93d09c198>, 125: <abc.opcode:PUSH30 object at 0x7fc93d09c1d0>, 126: <abc.opcode:PUSH31 object at 0x7fc93d09c208>, 127: <abc.opcode:PUSH32 object at 0x7fc93d09c240>, 128: <abc.opcode:DUP1 object at 0x7fc93d09c278>, 129: <abc.opcode:DUP2 object at 0x7fc93d09c2b0>, 130: <abc.opcode:DUP3 object at 0x7fc93d09c2e8>, 131: <abc.opcode:DUP4 object at 0x7fc93d09c320>, 132: <abc.opcode:DUP5 object at 0x7fc93d09c358>, 133: <abc.opcode:DUP6 object at 0x7fc93d09c390>, 134: <abc.opcode:DUP7 object at 0x7fc93d09c3c8>, 135: <abc.opcode:DUP8 object at 0x7fc93d09c400>, 136: <abc.opcode:DUP9 object at 0x7fc93d09c438>, 137: <abc.opcode:DUP10 object at 0x7fc93d09c470>, 138: <abc.opcode:DUP11 object at 0x7fc93d09c4a8>, 139: <abc.opcode:DUP12 object at 0x7fc93d09c4e0>, 140: <abc.opcode:DUP13 object at 0x7fc93d09c518>, 141: <abc.opcode:DUP14 object at 0x7fc93d09c550>, 142: <abc.opcode:DUP15 object at 0x7fc93d09c588>, 143: <abc.opcode:DUP16 object at 0x7fc93d09c5c0>, 144: <abc.opcode:SWAP1 object at 0x7fc93d09c5f8>, 145: <abc.opcode:SWAP2 object at 0x7fc93d09c630>, 146: <abc.opcode:SWAP3 object at 0x7fc93d09c668>, 147: <abc.opcode:SWAP4 object at 0x7fc93d09c6a0>, 148: <abc.opcode:SWAP5 object at 0x7fc93d09c6d8>, 149: <abc.opcode:SWAP6 object at 0x7fc93d09c710>, 150: <abc.opcode:SWAP7 object at 0x7fc93d09c748>, 151: <abc.opcode:SWAP8 object at 0x7fc93d09c780>, 152: <abc.opcode:SWAP9 object at 0x7fc93d09c7b8>, 153: <abc.opcode:SWAP10 object at 0x7fc93d09c7f0>, 154: <abc.opcode:SWAP11 object at 0x7fc93d09c828>, 155: <abc.opcode:SWAP12 object at 0x7fc93d09c860>, 156: <abc.opcode:SWAP13 object at 0x7fc93d09c898>, 157: <abc.opcode:SWAP14 object at 0x7fc93d09c8d0>, 158: <abc.opcode:SWAP15 object at 0x7fc93d09c908>, 159: <abc.opcode:SWAP16 object at 0x7fc93d09c940>, 160: <abc.opcode:LOG0 object at 0x7fc93d09c978>, 161: <abc.opcode:LOG1 object at 0x7fc93d09c9b0>, 162: <abc.opcode:LOG2 object at 0x7fc93d09c9e8>, 163: <abc.opcode:LOG3 object at 0x7fc93d09ca20>, 164: <abc.opcode:LOG4 object at 0x7fc93d09ca58>, 240: <abc.opcode:CREATE object at 0x7fc93d1132b0>, 241: <abc.opcode:CALL object at 0x7fc93d113470>, 242: <abc.opcode:CALLCODE object at 0x7fc93d113630>, 243: <abc.opcode:RETURN object at 0x7fc93d09cb38>, 244: <abc.opcode:DELEGATECALL object at 0x7fc93d1137f0>, 245: <abc.opcode:CREATE2 object at 0x7fc93d1139b0>, 250: <abc.opcode:STATICCALL object at 0x7fc93d113b70>, 253: <abc.opcode:REVERT object at 0x7fc93d09cbe0>, 255: <abc.opcode:SELFDESTRUCT object at 0x7fc93d113d68>}

eth.vm.forks.berlin.constants module

eth.vm.forks.berlin.headers module

eth.vm.forks.berlin.logic module

class eth.vm.forks.berlin.logic.CallCodeEIP2929

Bases: eth.vm.forks.berlin.logic.LoadFeeByCacheWarmth, eth.vm.logic.call.CallCodeEIP150

class eth.vm.forks.berlin.logic.CallEIP2929

Bases: eth.vm.forks.berlin.logic.LoadFeeByCacheWarmth, eth.vm.logic.call.CallByzantium

class eth.vm.forks.berlin.logic.Create2EIP2929

Bases: eth.vm.logic.system.Create2

generate_contract_address(stack_data: eth.vm.logic.system.CreateOpcodeStackData, call_data: bytes, computation: eth.abc.ComputationAPI) → NewType.<locals>.new_type
class eth.vm.forks.berlin.logic.CreateEIP2929

Bases: eth.vm.logic.system.CreateByzantium

generate_contract_address(stack_data: eth.vm.logic.system.CreateOpcodeStackData, call_data: bytes, computation: eth.abc.ComputationAPI) → NewType.<locals>.new_type
class eth.vm.forks.berlin.logic.DelegateCallEIP2929

Bases: eth.vm.forks.berlin.logic.LoadFeeByCacheWarmth, eth.vm.logic.call.DelegateCallEIP150

class eth.vm.forks.berlin.logic.LoadFeeByCacheWarmth

Bases: object

get_account_load_fee(computation: eth.abc.ComputationAPI, code_address: NewType.<locals>.new_type) → int
class eth.vm.forks.berlin.logic.StaticCallEIP2929

Bases: eth.vm.forks.berlin.logic.LoadFeeByCacheWarmth, eth.vm.logic.call.StaticCall

eth.vm.forks.berlin.logic.balance_eip2929(computation: eth.abc.ComputationAPI) → None
eth.vm.forks.berlin.logic.extcodecopy_eip2929(computation: eth.abc.ComputationAPI) → None
eth.vm.forks.berlin.logic.extcodehash_eip2929(computation: eth.abc.ComputationAPI) → None

Return the code hash for a given address. EIP: https://github.com/ethereum/EIPs/blob/master/EIPS/eip-1052.md

eth.vm.forks.berlin.logic.extcodesize_eip2929(computation: eth.abc.ComputationAPI) → None
eth.vm.forks.berlin.logic.selfdestruct_eip2929(computation: eth.abc.ComputationAPI) → None
eth.vm.forks.berlin.logic.sload_eip2929(computation: eth.abc.ComputationAPI) → None
eth.vm.forks.berlin.logic.sstore_eip2929
eth.vm.forks.berlin.logic.sstore_eip2929_generic

eth.vm.forks.berlin.opcodes module

eth.vm.forks.berlin.receipts module

class eth.vm.forks.berlin.receipts.BerlinReceiptBuilder

Bases: eth.abc.ReceiptBuilderAPI

legacy_sedes

alias of eth.rlp.receipts.Receipt

typed_receipt_class

alias of TypedReceipt

classmethod decode(encoded: bytes) → eth.abc.ReceiptAPI

This decodes a receipt that is encoded to either a typed receipt, a legacy receipt, or the body of a typed receipt. It assumes that typed receipts are not rlp-encoded first.

If dealing with an object that is always rlp encoded, then use this instead:

rlp.decode(encoded, sedes=ReceiptBuilderAPI)

For example, you may receive a list of receipts via a devp2p request. Each receipt is either a (legacy) rlp list, or a (new-style) bytestring. Even if the receipt is a bytestring, it’s wrapped in an rlp bytestring, in that context. New-style receipts will not be wrapped in an RLP bytestring in other contexts. They will just be an EIP-2718 type-byte plus payload of concatenated bytes, which cannot be decoded as RLP. This happens for example, when calculating the receipt root hash.

classmethod deserialize(encoded: Union[bytes, List[bytes]]) → eth.abc.ReceiptAPI

Extract a receipt from an encoded RLP object.

This method is used by rlp.decode(…, sedes=ReceiptBuilderAPI).

classmethod serialize(obj: eth.abc.ReceiptAPI) → Union[bytes, List[bytes]]

Encode a receipt to a series of bytes used by RLP.

In the case of legacy receipt, it will actually be a list of bytes. That doesn’t show up here, because pyrlp doesn’t export type annotations.

This method is used by rlp.encode(obj).

class eth.vm.forks.berlin.receipts.TypedReceipt(type_id: int, proxy_target: eth.abc.ReceiptAPI)

Bases: eth.abc.ReceiptAPI, eth.abc.ReceiptDecoderAPI

copy(*args, **kwargs) → eth.abc.ReceiptAPI

Return a copy of the receipt, optionally overwriting any of its properties.

classmethod decode(encoded: bytes) → eth.abc.ReceiptAPI

This decodes a receipt that is encoded to either a typed receipt, a legacy receipt, or the body of a typed receipt. It assumes that typed receipts are not rlp-encoded first.

If dealing with an object that is always rlp encoded, then use this instead:

rlp.decode(encoded, sedes=ReceiptBuilderAPI)

For example, you may receive a list of receipts via a devp2p request. Each receipt is either a (legacy) rlp list, or a (new-style) bytestring. Even if the receipt is a bytestring, it’s wrapped in an rlp bytestring, in that context. New-style receipts will not be wrapped in an RLP bytestring in other contexts. They will just be an EIP-2718 type-byte plus payload of concatenated bytes, which cannot be decoded as RLP. This happens for example, when calculating the receipt root hash.

classmethod deserialize(encoded_unchecked: Union[bytes, List[bytes]]) → eth.abc.ReceiptAPI
encode() → bytes

This encodes a receipt, no matter if it’s: a legacy receipt, a typed receipt, or the payload of a typed receipt. See more context in decode.

classmethod get_payload_codec(type_id: int) → Type[eth.abc.ReceiptDecoderAPI]
classmethod serialize(obj: eth.vm.forks.berlin.receipts.TypedReceipt) → Union[bytes, List[bytes]]
bloom
bloom_filter
codecs = {1: <class 'eth.rlp.receipts.Receipt'>}
gas_used
logs
rlp_type = <rlp.sedes.binary.Binary object>
state_root

eth.vm.forks.berlin.state module

class eth.vm.forks.berlin.state.BerlinState(db: eth.abc.AtomicDatabaseAPI, execution_context: eth.abc.ExecutionContextAPI, state_root: NewType.<locals>.new_type)

Bases: eth.vm.forks.muir_glacier.state.MuirGlacierState

computation_class

alias of eth.vm.forks.berlin.computation.BerlinComputation

transaction_executor_class

alias of BerlinTransactionExecutor

class eth.vm.forks.berlin.state.BerlinTransactionExecutor(vm_state: eth.abc.StateAPI)

Bases: eth.vm.forks.spurious_dragon.state.SpuriousDragonTransactionExecutor

build_computation(message: eth.abc.MessageAPI, transaction: eth.abc.SignedTransactionAPI) → eth.abc.ComputationAPI

Apply the message to the VM and use the given transaction to retrieve the context from.

eth.vm.forks.berlin.transactions module

class eth.vm.forks.berlin.transactions.AccessListPayloadDecoder

Bases: eth.abc.TransactionDecoderAPI

classmethod decode(payload: bytes) → eth.abc.SignedTransactionAPI

This decodes a transaction that is encoded to either a typed transaction or a legacy transaction, or even the payload of one of the transaction types. It assumes that typed transactions are not rlp-encoded first.

If dealing with an object that is rlp encoded first, then use this instead:

rlp.decode(encoded, sedes=TransactionBuilderAPI)

For example, you may receive a list of transactions via a devp2p request. Each transaction is either a (legacy) rlp list, or a (new-style) bytestring. Even if the transaction is a bytestring, it’s wrapped in an rlp bytestring, in that context. New-style transactions will not be wrapped in an RLP bytestring in other contexts. They will just be an EIP-2718 type-byte plus payload of concatenated bytes, which cannot be decoded as RLP. An example context for this is calculating the transaction root hash.

class eth.vm.forks.berlin.transactions.AccessListTransaction(*args, **kwargs)

Bases: rlp.sedes.serializable.Serializable, eth.rlp.transactions.SignedTransactionMethods, eth.abc.SignedTransactionAPI

check_signature_validity() → None

Check if the signature is valid. Raise a ValidationError if the signature is invalid.

encode() → bytes

This encodes a transaction, no matter if it’s: a legacy transaction, a typed transaction, or the payload of a typed transaction. See more context in decode.

get_intrinsic_gas() → int

Return the intrinsic gas for the transaction which is defined as the amount of gas that is needed before any code runs.

get_message_for_signing() → bytes

Return the bytestring that should be signed in order to create a signed transaction.

get_sender() → NewType.<locals>.new_type

Get the 20-byte address which sent this transaction.

This can be a slow operation. transaction.sender is always preferred.

make_receipt(status: bytes, gas_used: int, log_entries: Tuple[Tuple[bytes, Tuple[int, ...], bytes], ...]) → eth.abc.ReceiptAPI

Build a receipt for this transaction.

Transactions have this responsibility because there are different types of transactions, which have different types of receipts. (See access-list transactions, which change the receipt encoding)

Parameters:
  • status – success or failure (used to be the state root after execution)
  • gas_used – cumulative usage of this transaction and the previous ones in the header
  • log_entries – logs generated during execution
access_list
chain_id
data
gas
gas_price
hash
max_fee_per_gas

Will default to gas_price if this is a pre-1559 transaction.

max_priority_fee_per_gas

Will default to gas_price if this is a pre-1559 transaction.

nonce
r
s
to
value
y_parity
class eth.vm.forks.berlin.transactions.AccountAccesses(*args, **kwargs)

Bases: rlp.sedes.serializable.Serializable

account
storage_keys
class eth.vm.forks.berlin.transactions.BerlinLegacyTransaction(*args, **kwargs)

Bases: eth.vm.forks.muir_glacier.transactions.MuirGlacierTransaction

data
gas
gas_price
nonce
r
s
to
v
value
class eth.vm.forks.berlin.transactions.BerlinTransactionBuilder

Bases: eth.abc.TransactionBuilderAPI

Responsible for serializing transactions of ambiguous type.

It dispatches to either the legacy transaction type or the new typed transaction, depending on the nature of the encoded/decoded transaction.

legacy_signed

alias of BerlinLegacyTransaction

legacy_unsigned

alias of BerlinUnsignedLegacyTransaction

typed_transaction

alias of TypedTransaction

classmethod create_unsigned_transaction(*, nonce: int, gas_price: int, gas: int, to: NewType.<locals>.new_type, value: int, data: bytes) → eth.abc.UnsignedTransactionAPI

Create an unsigned transaction.

classmethod decode(encoded: bytes) → eth.abc.SignedTransactionAPI

This decodes a transaction that is encoded to either a typed transaction or a legacy transaction, or even the payload of one of the transaction types. It assumes that typed transactions are not rlp-encoded first.

If dealing with an object that is rlp encoded first, then use this instead:

rlp.decode(encoded, sedes=TransactionBuilderAPI)

For example, you may receive a list of transactions via a devp2p request. Each transaction is either a (legacy) rlp list, or a (new-style) bytestring. Even if the transaction is a bytestring, it’s wrapped in an rlp bytestring, in that context. New-style transactions will not be wrapped in an RLP bytestring in other contexts. They will just be an EIP-2718 type-byte plus payload of concatenated bytes, which cannot be decoded as RLP. An example context for this is calculating the transaction root hash.

classmethod deserialize(encoded: Union[bytes, List[bytes]]) → eth.abc.SignedTransactionAPI

Extract a transaction from an encoded RLP object.

This method is used by rlp.decode(…, sedes=TransactionBuilderAPI).

classmethod new_access_list_transaction(chain_id: int, nonce: int, gas_price: int, gas: int, to: NewType.<locals>.new_type, value: int, data: bytes, access_list: Sequence[Tuple[NewType.<locals>.new_type, Sequence[int]]], y_parity: int, r: int, s: int) → eth.vm.forks.berlin.transactions.TypedTransaction
classmethod new_transaction(nonce: int, gas_price: int, gas: int, to: NewType.<locals>.new_type, value: int, data: bytes, v: int, r: int, s: int) → eth.abc.SignedTransactionAPI

Create a signed transaction.

classmethod new_unsigned_access_list_transaction(chain_id: int, nonce: int, gas_price: int, gas: int, to: NewType.<locals>.new_type, value: int, data: bytes, access_list: Sequence[Tuple[NewType.<locals>.new_type, Sequence[int]]]) → eth.vm.forks.berlin.transactions.TypedTransaction
classmethod serialize(obj: eth.abc.SignedTransactionAPI) → Union[bytes, List[bytes]]

Encode a transaction to a series of bytes used by RLP.

In the case of legacy transactions, it will actually be a list of bytes. That doesn’t show up here, because pyrlp doesn’t export type annotations.

This method is used by rlp.encode(obj).

class eth.vm.forks.berlin.transactions.BerlinUnsignedLegacyTransaction(*args, **kwargs)

Bases: eth.vm.forks.muir_glacier.transactions.MuirGlacierUnsignedTransaction

as_signed_transaction(private_key: eth_keys.datatypes.PrivateKey, chain_id: int = None) → eth.vm.forks.berlin.transactions.BerlinLegacyTransaction

Return a version of this transaction which has been signed using the provided private_key

data
gas
gas_price
nonce
to
value
class eth.vm.forks.berlin.transactions.TypedTransaction(type_id: int, proxy_target: eth.abc.SignedTransactionAPI)

Bases: eth.rlp.transactions.SignedTransactionMethods, eth.abc.SignedTransactionAPI, eth.abc.TransactionDecoderAPI

receipt_builder

alias of eth.vm.forks.berlin.receipts.BerlinReceiptBuilder

check_signature_validity() → None

Check if the signature is valid. Raise a ValidationError if the signature is invalid.

copy(**overrides) → eth.vm.forks.berlin.transactions.TypedTransaction

Return a copy of the transaction.

classmethod decode(encoded: bytes) → eth.abc.SignedTransactionAPI

This decodes a transaction that is encoded to either a typed transaction or a legacy transaction, or even the payload of one of the transaction types. It assumes that typed transactions are not rlp-encoded first.

If dealing with an object that is rlp encoded first, then use this instead:

rlp.decode(encoded, sedes=TransactionBuilderAPI)

For example, you may receive a list of transactions via a devp2p request. Each transaction is either a (legacy) rlp list, or a (new-style) bytestring. Even if the transaction is a bytestring, it’s wrapped in an rlp bytestring, in that context. New-style transactions will not be wrapped in an RLP bytestring in other contexts. They will just be an EIP-2718 type-byte plus payload of concatenated bytes, which cannot be decoded as RLP. An example context for this is calculating the transaction root hash.

classmethod deserialize(encoded_unchecked: Union[bytes, List[bytes]]) → eth.abc.SignedTransactionAPI
encode() → bytes

This encodes a transaction, no matter if it’s: a legacy transaction, a typed transaction, or the payload of a typed transaction. See more context in decode.

get_intrinsic_gas() → int

Return the intrinsic gas for the transaction which is defined as the amount of gas that is needed before any code runs.

get_message_for_signing() → bytes

Return the bytestring that should be signed in order to create a signed transaction.

classmethod get_payload_codec(type_id: int) → Type[eth.abc.TransactionDecoderAPI]
get_sender() → NewType.<locals>.new_type

Get the 20-byte address which sent this transaction.

This can be a slow operation. transaction.sender is always preferred.

make_receipt(status: bytes, gas_used: int, log_entries: Tuple[Tuple[bytes, Tuple[int, ...], bytes], ...]) → eth.abc.ReceiptAPI

Build a receipt for this transaction.

Transactions have this responsibility because there are different types of transactions, which have different types of receipts. (See access-list transactions, which change the receipt encoding)

Parameters:
  • status – success or failure (used to be the state root after execution)
  • gas_used – cumulative usage of this transaction and the previous ones in the header
  • log_entries – logs generated during execution
classmethod serialize(obj: eth.vm.forks.berlin.transactions.TypedTransaction) → Union[bytes, List[bytes]]
access_list

Get addresses to be accessed by a transaction, and their storage slots.

chain_id
data
decoders = {1: <class 'eth.vm.forks.berlin.transactions.AccessListPayloadDecoder'>}
gas
gas_price

Will raise AttributeError if get or set on a 1559 transaction.

hash
max_fee_per_gas

Will default to gas_price if this is a pre-1559 transaction.

max_priority_fee_per_gas

Will default to gas_price if this is a pre-1559 transaction.

nonce
r
rlp_type = <rlp.sedes.binary.Binary object>
s
to
value
y_parity

The bit used to disambiguate elliptic curve signatures.

The only values this method will return are 0 or 1.

class eth.vm.forks.berlin.transactions.UnsignedAccessListTransaction(*args, **kwargs)

Bases: rlp.sedes.serializable.Serializable

as_signed_transaction(private_key: eth_keys.datatypes.PrivateKey) → eth.vm.forks.berlin.transactions.TypedTransaction
get_intrinsic_gas() → int
get_message_for_signing() → bytes
validate() → None
access_list
chain_id
data
gas
gas_price
intrinsic_gas
max_fee_per_gas
max_priority_fee_per_gas
nonce
to
value

Module contents

class eth.vm.forks.berlin.BerlinVM(header: eth.abc.BlockHeaderAPI, chaindb: eth.abc.ChainDatabaseAPI, chain_context: eth.abc.ChainContextAPI, consensus_context: eth.abc.ConsensusContextAPI)

Bases: eth.vm.forks.muir_glacier.MuirGlacierVM

block_class

alias of eth.vm.forks.berlin.blocks.BerlinBlock

compute_difficulty

https://github.com/ethereum/EIPs/issues/100

configure_header
create_header_from_parent
fork = 'berlin'

London

Submodules

eth.vm.forks.london.blocks module

class eth.vm.forks.london.blocks.LondonBackwardsHeader

Bases: eth.abc.BlockHeaderSedesAPI

An rlp sedes class for block headers.

It can serialize and deserialize both London and pre-London headers.

classmethod deserialize(encoded: List[bytes]) → eth.abc.BlockHeaderAPI

Extract a header from an encoded RLP object.

This method is used by rlp.decode(…, sedes=TransactionBuilderAPI).

classmethod serialize(obj: eth.abc.BlockHeaderAPI) → List[bytes]

Encode a header to a series of bytes used by RLP.

This method is used by rlp.encode(obj).

class eth.vm.forks.london.blocks.LondonBlock(header: eth.abc.BlockHeaderAPI, transactions: Sequence[eth.abc.SignedTransactionAPI] = None, uncles: Sequence[eth.abc.BlockHeaderAPI] = None)

Bases: eth.vm.forks.berlin.blocks.BerlinBlock

receipt_builder

alias of eth.vm.forks.london.receipts.LondonReceiptBuilder

transaction_builder

alias of eth.vm.forks.london.transactions.LondonTransactionBuilder

header
transactions
uncles
class eth.vm.forks.london.blocks.LondonBlockHeader(difficulty: int, block_number: NewType.<locals>.new_type, gas_limit: int, timestamp: int = None, coinbase: NewType.<locals>.new_type = b'x00x00x00x00x00x00x00x00x00x00x00x00x00x00x00x00x00x00x00x00', parent_hash: NewType.<locals>.new_type = b'x00x00x00x00x00x00x00x00x00x00x00x00x00x00x00x00x00x00x00x00x00x00x00x00x00x00x00x00x00x00x00x00', uncles_hash: NewType.<locals>.new_type = b'x1dxccMxe8xdexc7]zxabx85xb5gxb6xccxd4x1axd3x12Ex1bx94x8atx13xf0xa1Bxfd@xd4x93G', state_root: NewType.<locals>.new_type = b'Vxe8x1fx17x1bxccUxa6xffx83Exe6x92xc0xf8n[Hxe0x1bx99lxadxc0x01b/xb5xe3cxb4!', transaction_root: NewType.<locals>.new_type = b'Vxe8x1fx17x1bxccUxa6xffx83Exe6x92xc0xf8n[Hxe0x1bx99lxadxc0x01b/xb5xe3cxb4!', receipt_root: NewType.<locals>.new_type = b'Vxe8x1fx17x1bxccUxa6xffx83Exe6x92xc0xf8n[Hxe0x1bx99lxadxc0x01b/xb5xe3cxb4!', bloom: int = 0, gas_used: int = 0, extra_data: bytes = b'', mix_hash: NewType.<locals>.new_type = b'x00x00x00x00x00x00x00x00x00x00x00x00x00x00x00x00x00x00x00x00x00x00x00x00x00x00x00x00x00x00x00x00', nonce: bytes = b'x00x00x00x00x00x00x00B', base_fee_per_gas: int = 0)

Bases: rlp.sedes.serializable.Serializable, eth.abc.BlockHeaderAPI

base_fee_per_gas
block_number
bloom
coinbase
difficulty
extra_data
gas_limit
gas_used
hash

Return the hash of the block header.

hex_hash

Return the hash as a hex string.

is_genesis

Return True if this header represents the genesis block of the chain, otherwise False.

mining_hash

Return the mining hash of the block header.

mix_hash
nonce
parent_hash
receipt_root
state_root
timestamp
transaction_root
uncles_hash
class eth.vm.forks.london.blocks.LondonMiningHeader(*args, **kwargs)

Bases: rlp.sedes.serializable.Serializable, eth.abc.MiningHeaderAPI

base_fee_per_gas
block_number
bloom
coinbase
difficulty
extra_data
gas_limit
gas_used
parent_hash
receipt_root
state_root
timestamp
transaction_root
uncles_hash

eth.vm.forks.london.computation module

class eth.vm.forks.london.computation.LondonComputation(state: eth.abc.StateAPI, message: eth.abc.MessageAPI, transaction_context: eth.abc.TransactionContextAPI)

Bases: eth.vm.forks.berlin.computation.BerlinComputation

A class for all execution computations in the London fork. Inherits from BerlinComputation

classmethod validate_contract_code(contract_code: bytes) → None
opcodes = {0: <abc.opcode:STOP object at 0x7fc93d2efe48>, 1: <abc.opcode:ADD object at 0x7fc93d2efe80>, 2: <abc.opcode:MUL object at 0x7fc93d2efeb8>, 3: <abc.opcode:SUB object at 0x7fc93d2efef0>, 4: <abc.opcode:DIV object at 0x7fc93d2eff28>, 5: <abc.opcode:SDIV object at 0x7fc93d2eff60>, 6: <abc.opcode:MOD object at 0x7fc93d2eff98>, 7: <abc.opcode:SMOD object at 0x7fc93d2effd0>, 8: <abc.opcode:ADDMOD object at 0x7fc93d0ca048>, 9: <abc.opcode:MULMOD object at 0x7fc93d0ca080>, 10: <abc.opcode:EXP object at 0x7fc93d0ca0b8>, 11: <abc.opcode:SIGNEXTEND object at 0x7fc93d0ca0f0>, 16: <abc.opcode:LT object at 0x7fc93d0ca128>, 17: <abc.opcode:GT object at 0x7fc93d0ca160>, 18: <abc.opcode:SLT object at 0x7fc93d0ca198>, 19: <abc.opcode:SGT object at 0x7fc93d0ca1d0>, 20: <abc.opcode:EQ object at 0x7fc93d0ca208>, 21: <abc.opcode:ISZERO object at 0x7fc93d0ca240>, 22: <abc.opcode:AND object at 0x7fc93d0ca278>, 23: <abc.opcode:OR object at 0x7fc93d0ca2b0>, 24: <abc.opcode:XOR object at 0x7fc93d0ca2e8>, 25: <abc.opcode:NOT object at 0x7fc93d0ca320>, 26: <abc.opcode:BYTE object at 0x7fc93d0ca358>, 27: <abc.opcode:SHL object at 0x7fc93d0ccc18>, 28: <abc.opcode:SHR object at 0x7fc93d0ccc50>, 29: <abc.opcode:SAR object at 0x7fc93d0ccc88>, 32: <abc.opcode:SHA3 object at 0x7fc93d0ca390>, 48: <abc.opcode:ADDRESS object at 0x7fc93d0ca3c8>, 49: <abc.opcode:BALANCE object at 0x7fc93d0ca400>, 50: <abc.opcode:ORIGIN object at 0x7fc93d0ca438>, 51: <abc.opcode:CALLER object at 0x7fc93d0ca470>, 52: <abc.opcode:CALLVALUE object at 0x7fc93d0ca4a8>, 53: <abc.opcode:CALLDATALOAD object at 0x7fc93d0ca4e0>, 54: <abc.opcode:CALLDATASIZE object at 0x7fc93d0ca518>, 55: <abc.opcode:CALLDATACOPY object at 0x7fc93d0ca550>, 56: <abc.opcode:CODESIZE object at 0x7fc93d0ca588>, 57: <abc.opcode:CODECOPY object at 0x7fc93d0ca5c0>, 58: <abc.opcode:GASPRICE object at 0x7fc93d0ca5f8>, 59: <abc.opcode:EXTCODESIZE object at 0x7fc93d0ca630>, 60: <abc.opcode:EXTCODECOPY object at 0x7fc93d0ca668>, 61: <abc.opcode:RETURNDATASIZE object at 0x7fc93d0ccb70>, 62: <abc.opcode:RETURNDATACOPY object at 0x7fc93d0ccba8>, 63: <abc.opcode:EXTCODEHASH object at 0x7fc93d0cccc0>, 64: <abc.opcode:BLOCKHASH object at 0x7fc93d0ca6a0>, 65: <abc.opcode:COINBASE object at 0x7fc93d0ca6d8>, 66: <abc.opcode:TIMESTAMP object at 0x7fc93d0ca710>, 67: <abc.opcode:NUMBER object at 0x7fc93d0ca748>, 68: <abc.opcode:DIFFICULTY object at 0x7fc93d0ca780>, 69: <abc.opcode:GASLIMIT object at 0x7fc93d0ca7b8>, 70: <abc.opcode:CHAINID object at 0x7fc93d0ccd30>, 71: <abc.opcode:SELFBALANCE object at 0x7fc93d0ccd68>, 72: <abc.opcode:BASEFEE object at 0x7fc93d2efc50>, 80: <abc.opcode:POP object at 0x7fc93d0ca7f0>, 81: <abc.opcode:MLOAD object at 0x7fc93d0ca828>, 82: <abc.opcode:MSTORE object at 0x7fc93d0ca860>, 83: <abc.opcode:MSTORE8 object at 0x7fc93d0ca898>, 84: <abc.opcode:SLOAD object at 0x7fc93d0ca8d0>, 85: <abc.opcode:SSTORE object at 0x7fc93d2efdd8>, 86: <abc.opcode:JUMP object at 0x7fc93d0ca940>, 87: <abc.opcode:JUMPI object at 0x7fc93d0ca978>, 88: <abc.opcode:PC object at 0x7fc93d0ca9b0>, 89: <abc.opcode:MSIZE object at 0x7fc93d0ca9e8>, 90: <abc.opcode:GAS object at 0x7fc93d0caa20>, 91: <abc.opcode:JUMPDEST object at 0x7fc93d0caa58>, 96: <abc.opcode:PUSH1 object at 0x7fc93d0caa90>, 97: <abc.opcode:PUSH2 object at 0x7fc93d0caac8>, 98: <abc.opcode:PUSH3 object at 0x7fc93d0cab00>, 99: <abc.opcode:PUSH4 object at 0x7fc93d0cab38>, 100: <abc.opcode:PUSH5 object at 0x7fc93d0cab70>, 101: <abc.opcode:PUSH6 object at 0x7fc93d0caba8>, 102: <abc.opcode:PUSH7 object at 0x7fc93d0cabe0>, 103: <abc.opcode:PUSH8 object at 0x7fc93d0cac18>, 104: <abc.opcode:PUSH9 object at 0x7fc93d0cac50>, 105: <abc.opcode:PUSH10 object at 0x7fc93d0cac88>, 106: <abc.opcode:PUSH11 object at 0x7fc93d0cacc0>, 107: <abc.opcode:PUSH12 object at 0x7fc93d0cacf8>, 108: <abc.opcode:PUSH13 object at 0x7fc93d0cad30>, 109: <abc.opcode:PUSH14 object at 0x7fc93d0cad68>, 110: <abc.opcode:PUSH15 object at 0x7fc93d0cada0>, 111: <abc.opcode:PUSH16 object at 0x7fc93d0cadd8>, 112: <abc.opcode:PUSH17 object at 0x7fc93d0cae10>, 113: <abc.opcode:PUSH18 object at 0x7fc93d0cae48>, 114: <abc.opcode:PUSH19 object at 0x7fc93d0cae80>, 115: <abc.opcode:PUSH20 object at 0x7fc93d0caeb8>, 116: <abc.opcode:PUSH21 object at 0x7fc93d0caef0>, 117: <abc.opcode:PUSH22 object at 0x7fc93d0caf28>, 118: <abc.opcode:PUSH23 object at 0x7fc93d0caf60>, 119: <abc.opcode:PUSH24 object at 0x7fc93d0caf98>, 120: <abc.opcode:PUSH25 object at 0x7fc93d0cafd0>, 121: <abc.opcode:PUSH26 object at 0x7fc93d0cc048>, 122: <abc.opcode:PUSH27 object at 0x7fc93d0cc080>, 123: <abc.opcode:PUSH28 object at 0x7fc93d0cc0b8>, 124: <abc.opcode:PUSH29 object at 0x7fc93d0cc0f0>, 125: <abc.opcode:PUSH30 object at 0x7fc93d0cc128>, 126: <abc.opcode:PUSH31 object at 0x7fc93d0cc160>, 127: <abc.opcode:PUSH32 object at 0x7fc93d0cc198>, 128: <abc.opcode:DUP1 object at 0x7fc93d0cc1d0>, 129: <abc.opcode:DUP2 object at 0x7fc93d0cc208>, 130: <abc.opcode:DUP3 object at 0x7fc93d0cc240>, 131: <abc.opcode:DUP4 object at 0x7fc93d0cc278>, 132: <abc.opcode:DUP5 object at 0x7fc93d0cc2b0>, 133: <abc.opcode:DUP6 object at 0x7fc93d0cc2e8>, 134: <abc.opcode:DUP7 object at 0x7fc93d0cc320>, 135: <abc.opcode:DUP8 object at 0x7fc93d0cc358>, 136: <abc.opcode:DUP9 object at 0x7fc93d0cc390>, 137: <abc.opcode:DUP10 object at 0x7fc93d0cc3c8>, 138: <abc.opcode:DUP11 object at 0x7fc93d0cc400>, 139: <abc.opcode:DUP12 object at 0x7fc93d0cc438>, 140: <abc.opcode:DUP13 object at 0x7fc93d0cc470>, 141: <abc.opcode:DUP14 object at 0x7fc93d0cc4a8>, 142: <abc.opcode:DUP15 object at 0x7fc93d0cc4e0>, 143: <abc.opcode:DUP16 object at 0x7fc93d0cc518>, 144: <abc.opcode:SWAP1 object at 0x7fc93d0cc550>, 145: <abc.opcode:SWAP2 object at 0x7fc93d0cc588>, 146: <abc.opcode:SWAP3 object at 0x7fc93d0cc5c0>, 147: <abc.opcode:SWAP4 object at 0x7fc93d0cc5f8>, 148: <abc.opcode:SWAP5 object at 0x7fc93d0cc630>, 149: <abc.opcode:SWAP6 object at 0x7fc93d0cc668>, 150: <abc.opcode:SWAP7 object at 0x7fc93d0cc6a0>, 151: <abc.opcode:SWAP8 object at 0x7fc93d0cc6d8>, 152: <abc.opcode:SWAP9 object at 0x7fc93d0cc710>, 153: <abc.opcode:SWAP10 object at 0x7fc93d0cc748>, 154: <abc.opcode:SWAP11 object at 0x7fc93d0cc780>, 155: <abc.opcode:SWAP12 object at 0x7fc93d0cc7b8>, 156: <abc.opcode:SWAP13 object at 0x7fc93d0cc7f0>, 157: <abc.opcode:SWAP14 object at 0x7fc93d0cc828>, 158: <abc.opcode:SWAP15 object at 0x7fc93d0cc860>, 159: <abc.opcode:SWAP16 object at 0x7fc93d0cc898>, 160: <abc.opcode:LOG0 object at 0x7fc93d0cc8d0>, 161: <abc.opcode:LOG1 object at 0x7fc93d0cc908>, 162: <abc.opcode:LOG2 object at 0x7fc93d0cc940>, 163: <abc.opcode:LOG3 object at 0x7fc93d0cc978>, 164: <abc.opcode:LOG4 object at 0x7fc93d0cc9b0>, 240: <abc.opcode:CREATE object at 0x7fc93d0cc9e8>, 241: <abc.opcode:CALL object at 0x7fc93d0cca20>, 242: <abc.opcode:CALLCODE object at 0x7fc93d0cca58>, 243: <abc.opcode:RETURN object at 0x7fc93d0cca90>, 244: <abc.opcode:DELEGATECALL object at 0x7fc93d0ccb00>, 245: <abc.opcode:CREATE2 object at 0x7fc93d0cccf8>, 250: <abc.opcode:STATICCALL object at 0x7fc93d0ccbe0>, 253: <abc.opcode:REVERT object at 0x7fc93d0ccb38>, 255: <abc.opcode:SELFDESTRUCT object at 0x7fc93d0ccac8>}

eth.vm.forks.london.constants module

eth.vm.forks.london.headers module

class eth.vm.forks.london.headers.LondonBackwardsHeader

Bases: eth.abc.BlockHeaderSedesAPI

An rlp sedes class for block headers.

It can serialize and deserialize both London and pre-London headers.

classmethod deserialize(encoded: List[bytes]) → eth.abc.BlockHeaderAPI

Extract a header from an encoded RLP object.

This method is used by rlp.decode(…, sedes=TransactionBuilderAPI).

classmethod serialize(obj: eth.abc.BlockHeaderAPI) → List[bytes]

Encode a header to a series of bytes used by RLP.

This method is used by rlp.encode(obj).

eth.vm.forks.london.headers.calculate_expected_base_fee_per_gas(parent_header: eth.abc.BlockHeaderAPI) → int
eth.vm.forks.london.headers.create_header_from_parent
eth.vm.forks.london.headers.create_london_header_from_parent

eth.vm.forks.london.opcodes module

eth.vm.forks.london.receipts module

class eth.vm.forks.london.receipts.LondonReceiptBuilder

Bases: eth.vm.forks.berlin.receipts.BerlinReceiptBuilder

typed_receipt_class

alias of LondonTypedReceipt

class eth.vm.forks.london.receipts.LondonTypedReceipt(type_id: int, proxy_target: eth.abc.ReceiptAPI)

Bases: eth.vm.forks.berlin.receipts.TypedReceipt

codecs = {1: <class 'eth.rlp.receipts.Receipt'>, 2: <class 'eth.rlp.receipts.Receipt'>}

eth.vm.forks.london.state module

class eth.vm.forks.london.state.LondonState(db: eth.abc.AtomicDatabaseAPI, execution_context: eth.abc.ExecutionContextAPI, state_root: NewType.<locals>.new_type)

Bases: eth.vm.forks.berlin.state.BerlinState

account_db_class

alias of eth.db.account.AccountDB

computation_class

alias of eth.vm.forks.london.computation.LondonComputation

transaction_executor_class

alias of LondonTransactionExecutor

get_gas_price(transaction: eth.abc.SignedTransactionAPI) → int

Return the gas price of the given transaction.

Factor in the current block’s base gase price, if appropriate. (See EIP-1559)

get_tip(transaction: eth.abc.SignedTransactionAPI) → int

Return the gas price that gets allocated to the miner/validator.

Pre-EIP-1559 that would be the full transaction gas price. After, it would be the tip price (potentially reduced, if the base fee is so high that it surpasses the transaction’s maximum gas price after adding the tip).

get_transaction_context(transaction: eth.abc.SignedTransactionAPI) → eth.abc.TransactionContextAPI

London-specific transaction context creation, where gas_price includes the block base fee

validate_transaction(transaction: eth.abc.SignedTransactionAPI) → None

Validate the given transaction.

base_fee

Return the current base_fee from the current execution_context

Raises a NotImplementedError if called in an execution context prior to the London hard fork.

class eth.vm.forks.london.state.LondonTransactionExecutor(vm_state: eth.abc.StateAPI)

Bases: eth.vm.forks.berlin.state.BerlinTransactionExecutor

build_evm_message(transaction: eth.abc.SignedTransactionAPI) → eth.abc.MessageAPI

Build and return a MessageAPI from the given transaction.

classmethod calculate_gas_refund(computation: eth.abc.ComputationAPI, gas_used: int) → int

eth.vm.forks.london.storage module

eth.vm.forks.london.transactions module

class eth.vm.forks.london.transactions.DynamicFeePayloadDecoder

Bases: eth.abc.TransactionDecoderAPI

classmethod decode(payload: bytes) → eth.abc.SignedTransactionAPI

This decodes a transaction that is encoded to either a typed transaction or a legacy transaction, or even the payload of one of the transaction types. It assumes that typed transactions are not rlp-encoded first.

If dealing with an object that is rlp encoded first, then use this instead:

rlp.decode(encoded, sedes=TransactionBuilderAPI)

For example, you may receive a list of transactions via a devp2p request. Each transaction is either a (legacy) rlp list, or a (new-style) bytestring. Even if the transaction is a bytestring, it’s wrapped in an rlp bytestring, in that context. New-style transactions will not be wrapped in an RLP bytestring in other contexts. They will just be an EIP-2718 type-byte plus payload of concatenated bytes, which cannot be decoded as RLP. An example context for this is calculating the transaction root hash.

class eth.vm.forks.london.transactions.DynamicFeeTransaction(*args, **kwargs)

Bases: rlp.sedes.serializable.Serializable, eth.rlp.transactions.SignedTransactionMethods, eth.abc.SignedTransactionAPI

check_signature_validity() → None

Check if the signature is valid. Raise a ValidationError if the signature is invalid.

encode() → bytes

This encodes a transaction, no matter if it’s: a legacy transaction, a typed transaction, or the payload of a typed transaction. See more context in decode.

get_intrinsic_gas() → int

Return the intrinsic gas for the transaction which is defined as the amount of gas that is needed before any code runs.

get_message_for_signing() → bytes

Return the bytestring that should be signed in order to create a signed transaction.

get_sender() → NewType.<locals>.new_type

Get the 20-byte address which sent this transaction.

This can be a slow operation. transaction.sender is always preferred.

make_receipt(status: bytes, gas_used: int, log_entries: Tuple[Tuple[bytes, Tuple[int, ...], bytes], ...]) → eth.abc.ReceiptAPI

Build a receipt for this transaction.

Transactions have this responsibility because there are different types of transactions, which have different types of receipts. (See access-list transactions, which change the receipt encoding)

Parameters:
  • status – success or failure (used to be the state root after execution)
  • gas_used – cumulative usage of this transaction and the previous ones in the header
  • log_entries – logs generated during execution
access_list
chain_id
data
gas
gas_price

Will raise AttributeError if get or set on a 1559 transaction.

hash
max_fee_per_gas
max_priority_fee_per_gas
nonce
r
s
to
value
y_parity
class eth.vm.forks.london.transactions.LondonLegacyTransaction(*args, **kwargs)

Bases: eth.vm.forks.berlin.transactions.BerlinLegacyTransaction

data
gas
gas_price
nonce
r
s
to
v
value
class eth.vm.forks.london.transactions.LondonTransactionBuilder

Bases: eth.vm.forks.berlin.transactions.BerlinTransactionBuilder

legacy_signed

alias of LondonLegacyTransaction

legacy_unsigned

alias of LondonUnsignedLegacyTransaction

typed_transaction

alias of LondonTypedTransaction

classmethod new_dynamic_fee_transaction(chain_id: int, nonce: int, max_priority_fee_per_gas: int, max_fee_per_gas: int, gas: int, to: NewType.<locals>.new_type, value: int, data: bytes, access_list: Sequence[Tuple[NewType.<locals>.new_type, Sequence[int]]], y_parity: int, r: int, s: int) → eth.vm.forks.london.transactions.LondonTypedTransaction
classmethod new_unsigned_dynamic_fee_transaction(chain_id: int, nonce: int, max_priority_fee_per_gas: int, max_fee_per_gas: int, gas: int, to: NewType.<locals>.new_type, value: int, data: bytes, access_list: Sequence[Tuple[NewType.<locals>.new_type, Sequence[int]]]) → eth.vm.forks.london.transactions.LondonTypedTransaction
class eth.vm.forks.london.transactions.LondonTypedTransaction(type_id: int, proxy_target: eth.abc.SignedTransactionAPI)

Bases: eth.vm.forks.berlin.transactions.TypedTransaction

receipt_builder

alias of eth.vm.forks.london.receipts.LondonReceiptBuilder

decoders = {1: <class 'eth.vm.forks.berlin.transactions.AccessListPayloadDecoder'>, 2: <class 'eth.vm.forks.london.transactions.DynamicFeePayloadDecoder'>}
class eth.vm.forks.london.transactions.LondonUnsignedLegacyTransaction(*args, **kwargs)

Bases: eth.vm.forks.berlin.transactions.BerlinUnsignedLegacyTransaction

as_signed_transaction(private_key: eth_keys.datatypes.PrivateKey, chain_id: int = None) → eth.vm.forks.london.transactions.LondonLegacyTransaction

Return a version of this transaction which has been signed using the provided private_key

data
gas
gas_price
nonce
to
value
class eth.vm.forks.london.transactions.UnsignedDynamicFeeTransaction(*args, **kwargs)

Bases: rlp.sedes.serializable.Serializable

as_signed_transaction(private_key: eth_keys.datatypes.PrivateKey) → eth.vm.forks.berlin.transactions.TypedTransaction
get_intrinsic_gas() → int
get_message_for_signing() → bytes
validate() → None
access_list
chain_id
data
gas
intrinsic_gas
max_fee_per_gas
max_priority_fee_per_gas
nonce
to
value

eth.vm.forks.london.validation module

eth.vm.forks.london.validation.validate_london_normalized_transaction(state: eth.abc.StateAPI, transaction: eth.abc.SignedTransactionAPI) → None

Validates a London normalized transaction.

Raise eth.exceptions.ValidationError if the sender cannot afford to send this transaction.

Module contents

class eth.vm.forks.london.LondonVM(header: eth.abc.BlockHeaderAPI, chaindb: eth.abc.ChainDatabaseAPI, chain_context: eth.abc.ChainContextAPI, consensus_context: eth.abc.ConsensusContextAPI)

Bases: eth.vm.forks.berlin.BerlinVM

block_class

alias of eth.vm.forks.london.blocks.LondonBlock

classmethod calculate_net_gas_refund(consumed_gas: int, gross_refund: int) → int
classmethod validate_gas(header: eth.abc.BlockHeaderAPI, parent_header: eth.abc.BlockHeaderAPI) → None
compute_difficulty

https://github.com/ethereum/EIPs/issues/100

configure_header
create_header_from_parent
fork = 'london'

Arrow Glacier

Submodules

eth.vm.forks.arrow_glacier.blocks module

class eth.vm.forks.arrow_glacier.blocks.ArrowGlacierBlock(header: eth.abc.BlockHeaderAPI, transactions: Sequence[eth.abc.SignedTransactionAPI] = None, uncles: Sequence[eth.abc.BlockHeaderAPI] = None)

Bases: eth.vm.forks.london.blocks.LondonBlock

transaction_builder

alias of eth.vm.forks.arrow_glacier.transactions.ArrowGlacierTransactionBuilder

header
transactions
uncles
class eth.vm.forks.arrow_glacier.blocks.ArrowGlacierBlockHeader(difficulty: int, block_number: NewType.<locals>.new_type, gas_limit: int, timestamp: int = None, coinbase: NewType.<locals>.new_type = b'x00x00x00x00x00x00x00x00x00x00x00x00x00x00x00x00x00x00x00x00', parent_hash: NewType.<locals>.new_type = b'x00x00x00x00x00x00x00x00x00x00x00x00x00x00x00x00x00x00x00x00x00x00x00x00x00x00x00x00x00x00x00x00', uncles_hash: NewType.<locals>.new_type = b'x1dxccMxe8xdexc7]zxabx85xb5gxb6xccxd4x1axd3x12Ex1bx94x8atx13xf0xa1Bxfd@xd4x93G', state_root: NewType.<locals>.new_type = b'Vxe8x1fx17x1bxccUxa6xffx83Exe6x92xc0xf8n[Hxe0x1bx99lxadxc0x01b/xb5xe3cxb4!', transaction_root: NewType.<locals>.new_type = b'Vxe8x1fx17x1bxccUxa6xffx83Exe6x92xc0xf8n[Hxe0x1bx99lxadxc0x01b/xb5xe3cxb4!', receipt_root: NewType.<locals>.new_type = b'Vxe8x1fx17x1bxccUxa6xffx83Exe6x92xc0xf8n[Hxe0x1bx99lxadxc0x01b/xb5xe3cxb4!', bloom: int = 0, gas_used: int = 0, extra_data: bytes = b'', mix_hash: NewType.<locals>.new_type = b'x00x00x00x00x00x00x00x00x00x00x00x00x00x00x00x00x00x00x00x00x00x00x00x00x00x00x00x00x00x00x00x00', nonce: bytes = b'x00x00x00x00x00x00x00B', base_fee_per_gas: int = 0)

Bases: eth.vm.forks.london.blocks.LondonBlockHeader, abc.ABC

base_fee_per_gas
block_number
bloom
coinbase
difficulty
extra_data
gas_limit
gas_used
mix_hash
nonce
parent_hash
receipt_root
state_root
timestamp
transaction_root
uncles_hash
class eth.vm.forks.arrow_glacier.blocks.ArrowGlacierMiningHeader(*args, **kwargs)

Bases: eth.vm.forks.london.blocks.LondonMiningHeader, abc.ABC

base_fee_per_gas
block_number
bloom
coinbase
difficulty
extra_data
gas_limit
gas_used
parent_hash
receipt_root
state_root
timestamp
transaction_root
uncles_hash

eth.vm.forks.arrow_glacier.computation module

class eth.vm.forks.arrow_glacier.computation.ArrowGlacierComputation(state: eth.abc.StateAPI, message: eth.abc.MessageAPI, transaction_context: eth.abc.TransactionContextAPI)

Bases: eth.vm.forks.london.computation.LondonComputation

A class for all execution computations in the ArrowGlacier fork. Inherits from LondonComputation

eth.vm.forks.arrow_glacier.headers module

eth.vm.forks.arrow_glacier.state module

class eth.vm.forks.arrow_glacier.state.ArrowGlacierState(db: eth.abc.AtomicDatabaseAPI, execution_context: eth.abc.ExecutionContextAPI, state_root: NewType.<locals>.new_type)

Bases: eth.vm.forks.london.state.LondonState

computation_class

alias of eth.vm.forks.arrow_glacier.computation.ArrowGlacierComputation

transaction_executor_class

alias of ArrowGlacierTransactionExecutor

class eth.vm.forks.arrow_glacier.state.ArrowGlacierTransactionExecutor(vm_state: eth.abc.StateAPI)

Bases: eth.vm.forks.london.state.LondonTransactionExecutor

eth.vm.forks.arrow_glacier.transactions module

class eth.vm.forks.arrow_glacier.transactions.ArrowGlacierLegacyTransaction(*args, **kwargs)

Bases: eth.vm.forks.london.transactions.LondonLegacyTransaction, abc.ABC

data
gas
gas_price
nonce
r
s
to
v
value
class eth.vm.forks.arrow_glacier.transactions.ArrowGlacierTransactionBuilder

Bases: eth.vm.forks.london.transactions.LondonTransactionBuilder

legacy_signed

alias of ArrowGlacierLegacyTransaction

legacy_unsigned

alias of ArrowGlacierUnsignedLegacyTransaction

class eth.vm.forks.arrow_glacier.transactions.ArrowGlacierUnsignedLegacyTransaction(*args, **kwargs)

Bases: eth.vm.forks.london.transactions.LondonUnsignedLegacyTransaction

as_signed_transaction(private_key: eth_keys.datatypes.PrivateKey, chain_id: int = None) → eth.vm.forks.arrow_glacier.transactions.ArrowGlacierLegacyTransaction

Return a version of this transaction which has been signed using the provided private_key

data
gas
gas_price
nonce
to
value

Module contents

class eth.vm.forks.arrow_glacier.ArrowGlacierVM(header: eth.abc.BlockHeaderAPI, chaindb: eth.abc.ChainDatabaseAPI, chain_context: eth.abc.ChainContextAPI, consensus_context: eth.abc.ConsensusContextAPI)

Bases: eth.vm.forks.london.LondonVM

block_class

alias of eth.vm.forks.arrow_glacier.blocks.ArrowGlacierBlock

compute_difficulty

https://github.com/ethereum/EIPs/issues/100

configure_header
create_header_from_parent
fork = 'arrow-glacier'