Skip to content

Documentation update for ABC base classes #2064

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
80 changes: 77 additions & 3 deletions eth/abc.py
Original file line number Diff line number Diff line change
Expand Up @@ -190,6 +190,9 @@ class LogAPI(ABC):
@property
@abstractmethod
def bloomables(self) -> Tuple[bytes, ...]:
"""
Return a general aggregation of log contents that can be added to a Bloom filter.
"""
...


Expand All @@ -206,21 +209,33 @@ def state_root(self) -> bytes:
@property
@abstractmethod
def gas_used(self) -> int:
"""
Return the total value of the gas used in the transaction.
"""
...

@property
@abstractmethod
def bloom(self) -> int:
"""
Return the bloom value of the receipt.
"""
...

@property
@abstractmethod
def logs(self) -> Sequence[LogAPI]:
"""
Return logs generated during execution of the transaction.
"""
...

@property
@abstractmethod
def bloom_filter(self) -> BloomFilter:
"""
Return a BloomFilter of the receipt.
"""
...

# We can remove this API and inherit from rlp.Serializable when it becomes typesafe
Expand Down Expand Up @@ -368,6 +383,9 @@ class TransactionFieldsAPI(ABC):
@property
@abstractmethod
def nonce(self) -> int:
"""
Return the transaction nonce.
"""
...

@property
Expand Down Expand Up @@ -397,31 +415,49 @@ def max_priority_fee_per_gas(self) -> int:
@property
@abstractmethod
def gas(self) -> int:
"""
Return the amount of gas specified for the execution of the transaction.
"""
...

@property
@abstractmethod
def to(self) -> Address:
"""
Return transaction receiver address.
"""
...

@property
@abstractmethod
def value(self) -> int:
"""
Return the transaction value (how many wei was sent to the 'to' address).
"""
...

@property
@abstractmethod
def data(self) -> bytes:
"""
Return the transaction data.
"""
...

@property
@abstractmethod
def r(self) -> int:
"""
Return the 'r' value of the transaction's signature.
"""
...

@property
@abstractmethod
def s(self) -> int:
"""
Return the 's' value of the transaction's signature.
"""
...

@property
Expand All @@ -435,10 +471,19 @@ def hash(self) -> Hash32:
@property
@abstractmethod
def chain_id(self) -> Optional[int]:
"""
Return the chain id of the transaction (on which blockchain was the
transaction executed, ETH, ETC, ...).
"""
...


class LegacyTransactionFieldsAPI(TransactionFieldsAPI):
"""
A class giving access to legacy transaction fields
(these fields are accessed differently or not accessed at all
in new usages).
"""
@property
@abstractmethod
def v(self) -> int:
Expand Down Expand Up @@ -580,13 +625,13 @@ def new_transaction(


class SignedTransactionAPI(BaseTransactionAPI, TransactionFieldsAPI):
"""
A class representing a transaction that was signed with a private key.
"""

def __init__(self, *args: Any, **kwargs: Any) -> None:
...

"""
A class representing a transaction that was signed with a private key.
"""
@property
@abstractmethod
def sender(self) -> Address:
Expand Down Expand Up @@ -799,15 +844,25 @@ def hashes(self) -> FrozenSet[Hash32]:
@property
@abstractmethod
def accounts_queried(self) -> FrozenSet[Address]:
"""
Return the set of addresses of the accounts queried.
"""
...

@property
@abstractmethod
def account_bytecodes_queried(self) -> FrozenSet[Address]:
"""
Return the set of addresses of the accounts of which the bytecodes were queried.
"""
...

@abstractmethod
def get_slots_queried(self, address: Address) -> FrozenSet[int]:
"""
Return the slots queried for a given address.
Return an empty set if the address was not queried.
"""
...

@property
Expand Down Expand Up @@ -1313,21 +1368,37 @@ class MessageAPI(ABC):
@property
@abstractmethod
def code_address(self) -> Address:
"""
Return the address of the code to be executed.
It is usually the same as the 'to' address except when an alternative
accounts code needs to be executed.
"""
...

@property
@abstractmethod
def storage_address(self) -> Address:
"""
Return the address of the storage space.
It is usually the same as the 'to' address except when an alternative
storage address needs to be used.
"""
...

@property
@abstractmethod
def is_create(self) -> bool:
"""
Return whether the message refers to a contract creation or not.
"""
...

@property
@abstractmethod
def data_as_bytes(self) -> bytes:
"""
Return the bytes representation of the message data.
"""
...


Expand Down Expand Up @@ -1623,6 +1694,9 @@ def is_valid_opcode(self, position: int) -> bool:


class StackManipulationAPI(ABC):
"""
A class representing various operations on the stack.
"""
@abstractmethod
def stack_pop_ints(self, num_items: int) -> Tuple[int, ...]:
"""
Expand Down