ethereum.cancun.fork_types
Ethereum Types ^^^^^^^^^^^^^^
.. contents:: Table of Contents :backlinks: none :local:
Introduction
Types re-used throughout the specification, which are specific to Ethereum.
Address
24 | Address = Bytes20 |
---|
Root
25 | Root = Hash32 |
---|
VersionedHash
26 | VersionedHash = Hash32 |
---|
Bloom
28 | Bloom = Bytes256 |
---|
Account
State associated with an address.
31 | @slotted_freezable |
---|
32 | @dataclass |
---|
class Account:
nonce
38 | nonce: Uint |
---|
balance
39 | balance: U256 |
---|
code
40 | code: bytes |
---|
EMPTY_ACCOUNT
43 | EMPTY_ACCOUNT = Account( |
---|---|
44 | nonce=Uint(0), |
45 | balance=U256(0), |
46 | code=bytearray(), |
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 | keccak256(raw_account_data.code), |
63 | ) |
64 | ) |