From f4a11c2d6e448aaf65ad76eb861eec0d3e89a061 Mon Sep 17 00:00:00 2001 From: Andrey Date: Tue, 18 Jun 2024 13:33:20 +0300 Subject: [PATCH 1/2] Add fix for moonworm provider. --- .../crawler/moonstream_ethereum_state_provider.py | 12 +++++++----- moonworm/version.py | 2 +- 2 files changed, 8 insertions(+), 6 deletions(-) diff --git a/moonworm/crawler/moonstream_ethereum_state_provider.py b/moonworm/crawler/moonstream_ethereum_state_provider.py index 153c1c0..0fa5738 100644 --- a/moonworm/crawler/moonstream_ethereum_state_provider.py +++ b/moonworm/crawler/moonstream_ethereum_state_provider.py @@ -69,11 +69,9 @@ class MoonstreamEthereumStateProvider(EthereumStateProvider): return last_block.block_number @staticmethod - def _transform_to_w3_tx( - tx_raw: tx_raw_types, - ) -> Dict[str, Any]: + def _transform_to_w3_tx(tx_raw: tx_raw_types, raw_block) -> Dict[str, Any]: tx = { - "blockHash": tx_raw.block_hash, + "blockHash": raw_block.hash, "blockNumber": tx_raw.block_number, "from": tx_raw.from_address, "gas": tx_raw.gas, @@ -121,8 +119,10 @@ class MoonstreamEthereumStateProvider(EthereumStateProvider): block_transactions = {} for raw_tx in raw_block_transactions: + if block_transactions.get(raw_tx.block_number) is None: block_transactions[raw_tx.block_number] = [] + block_transactions[raw_tx.block_number].append(raw_tx) if block_transactions.get(block_number) is None: @@ -134,7 +134,9 @@ class MoonstreamEthereumStateProvider(EthereumStateProvider): for block, txs in block_transactions.items(): self.blocks_cache[block] = { "timestamp": blocks[block].timestamp, - "transactions": [self._transform_to_w3_tx(tx) for tx in txs], + "transactions": [ + self._transform_to_w3_tx(tx, blocks[block]) for tx in txs + ], } return self.blocks_cache[block_number] diff --git a/moonworm/version.py b/moonworm/version.py index f56663f..924cd55 100644 --- a/moonworm/version.py +++ b/moonworm/version.py @@ -1 +1 @@ -MOONWORM_VERSION = "0.9.1" +MOONWORM_VERSION = "0.9.2" From d88400430a23d05325650c768b3ff20892891009 Mon Sep 17 00:00:00 2001 From: Andrey Date: Tue, 18 Jun 2024 21:19:15 +0300 Subject: [PATCH 2/2] Remove print --- moonworm/crawler/function_call_crawler.py | 5 +---- moonworm/crawler/moonstream_ethereum_state_provider.py | 2 -- 2 files changed, 1 insertion(+), 6 deletions(-) diff --git a/moonworm/crawler/function_call_crawler.py b/moonworm/crawler/function_call_crawler.py index 297de0a..9a67030 100644 --- a/moonworm/crawler/function_call_crawler.py +++ b/moonworm/crawler/function_call_crawler.py @@ -198,10 +198,7 @@ class FunctionCallCrawler: method_id = transaction.get("input")[:10] if method_id in self.whitelisted_methods: self.process_transaction(transaction) - else: - print( - f"Function not in ABI, MethodID: {method_id} tx: {transaction['hash'].hex()}. Ignored." - ) + self.state.state if flush_state: self.state.flush() diff --git a/moonworm/crawler/moonstream_ethereum_state_provider.py b/moonworm/crawler/moonstream_ethereum_state_provider.py index 0fa5738..f57cab3 100644 --- a/moonworm/crawler/moonstream_ethereum_state_provider.py +++ b/moonworm/crawler/moonstream_ethereum_state_provider.py @@ -119,10 +119,8 @@ class MoonstreamEthereumStateProvider(EthereumStateProvider): block_transactions = {} for raw_tx in raw_block_transactions: - if block_transactions.get(raw_tx.block_number) is None: block_transactions[raw_tx.block_number] = [] - block_transactions[raw_tx.block_number].append(raw_tx) if block_transactions.get(block_number) is None: