chainlib-eth

Ethereum implementation of the chainlib interface
Log | Files | Refs | README | LICENSE

commit 5d82f02c1928ba86d709611f4bde4a5293ab9d31
parent daef7e915dc3ee79ccc1f7d4e724671513a92ce9
Author: lash <dev@holbrook.no>
Date:   Sun, 13 Aug 2023 17:54:12 +0100

Implement dialect filters for tx, receipt sources, connect eth base dialect

Diffstat:
MCHANGELOG | 6++++++
Mchainlib/eth/block.py | 4++++
Mchainlib/eth/dialect/__init__.py | 9++++++---
Mchainlib/eth/tx.py | 12+++++-------
Mrequirements.txt | 2+-
Msetup.cfg | 2+-
Mtest_requirements.txt | 1-
7 files changed, 23 insertions(+), 13 deletions(-)

diff --git a/CHANGELOG b/CHANGELOG @@ -1,3 +1,9 @@ +- 0.5.1 + * Pass dialect filter to load tx from src + * Apply dialect to receipts / results + * Make eth base dialect usable for all sources +- 0.5.0 + * Implement rpc batch limiting - 0.4.27 * Fix break in encoding string values for eth-encode CLI tool - 0.4.26 diff --git a/chainlib/eth/block.py b/chainlib/eth/block.py @@ -14,6 +14,7 @@ from hexathon import ( # local imports from chainlib.eth.tx import Tx +from chainlib.eth.tx import eth_dialect_filter from .src import Src logg = logging.getLogger(__name__) @@ -123,6 +124,9 @@ class Block(BaseBlock, Src): self.parent_hash = self.src['parent_hash'] + def tx_by_index(self, idx, dialect_filter=eth_dialect_filter): + return super(Block, self).tx_by_index(idx, dialect_filter=dialect_filter) + def tx_index_by_hash(self, tx_hash): i = 0 diff --git a/chainlib/eth/dialect/__init__.py b/chainlib/eth/dialect/__init__.py @@ -14,10 +14,13 @@ class DefaultErrorParser: class DialectFilter(BaseDialectFilter): - def apply_src(self, src): + def apply_tx(self, src): try: inpt = src['input'] except KeyError: - inpt = src['data'] - src['input'] = src['data'] + try: + inpt = src['data'] + src['input'] = src['data'] + except KeyError: + pass return src diff --git a/chainlib/eth/tx.py b/chainlib/eth/tx.py @@ -606,7 +606,9 @@ class Tx(BaseTx, Src): # src = super(Tx, self).apply_src(src, dialect_filter=dialect_filter) - def load_src(self, dialect_filter=None): + def load_src(self, dialect_filter=eth_dialect_filter): + src = dialect_filter.apply_tx(self.src) + self.apply_src(src) hsh = self.normal(self.src['hash'], SrcItem.HASH) self.set_hash(hsh) @@ -652,18 +654,14 @@ class Tx(BaseTx, Src): self.r = self.src.get('r') self.s = self.src.get('s') - #self.status = Status.PENDING - if dialect_filter != None: - dialect_filter.apply_tx(self) - def as_dict(self): return self.src def apply_receipt(self, rcpt, strict=False, dialect_filter=None): - result = TxResult(src=rcpt) - self.apply_result(result) + result = TxResult(src=rcpt, dialect_filter=dialect_filter) + self.apply_result(result, dialect_filter=dialect_filter) def apply_result(self, result, strict=False, dialect_filter=None): diff --git a/requirements.txt b/requirements.txt @@ -3,4 +3,4 @@ safe-pysha3==1.0.4 hexathon~=0.1.7 websocket-client==0.57.0 potaahto~=0.1.1 -chainlib~=0.5.0 +chainlib~=0.5.2 diff --git a/setup.cfg b/setup.cfg @@ -1,6 +1,6 @@ [metadata] name = chainlib-eth -version = 0.5.0 +version = 0.5.1 description = Ethereum implementation of the chainlib interface author = Louis Holbrook author_email = dev@holbrook.no diff --git a/test_requirements.txt b/test_requirements.txt @@ -1,5 +1,4 @@ eth_tester==0.5.0b3 py-evm==0.3.0a20 rlp==2.0.1 -pytest==6.0.1 coverage==5.5