ethereum.forks.berlin.fork_typesethereum.forks.london.fork_types

Ethereum Types.

.. contents:: Table of Contents :backlinks: none :local:

Introduction

Types reused throughout the specification, which are specific to Ethereum.

Address

23
Address = Bytes20

Root

24
Root = Hash32

Bloom

26
Bloom = Bytes256

EMPTY_CODE_HASH

28
EMPTY_CODE_HASH = keccak256(b"")

Account

State associated with an address.

31
@slotted_freezable
32
@dataclass
class Account:

nonce

38
    nonce: Uint

balance

39
    balance: U256

code_hash

40
    code_hash: Hash32

EMPTY_ACCOUNT

43
EMPTY_ACCOUNT = Account(
44
    nonce=Uint(0),
45
    balance=U256(0),
46
    code_hash=EMPTY_CODE_HASH,
47
)

encode_account

Encode Account dataclass.

Storage is not stored in the Account dataclass, so Accounts cannot be encoded without providing a storage root.

def encode_account(raw_account_data: Account, ​​storage_root: Bytes) -> Bytes:
51
    """
52
    Encode `Account` dataclass.
53
54
    Storage is not stored in the `Account` dataclass, so `Accounts` cannot be
55
    encoded without providing a storage root.
56
    """
57
    return rlp.encode(
58
        (
59
            raw_account_data.nonce,
60
            raw_account_data.balance,
61
            storage_root,
62
            raw_account_data.code_hash,
63
        )
64
    )