From ca4d3731d7d24f979cd2c18fd23deaeb3464fcd4 Mon Sep 17 00:00:00 2001 From: Xiaying Peng Date: Thu, 10 Oct 2024 16:36:15 -0700 Subject: [PATCH 1/5] Update client.go --- examples/ethereum/client/client.go | 44 +++++++++++------------------- 1 file changed, 16 insertions(+), 28 deletions(-) diff --git a/examples/ethereum/client/client.go b/examples/ethereum/client/client.go index a17abca..a22541e 100644 --- a/examples/ethereum/client/client.go +++ b/examples/ethereum/client/client.go @@ -61,55 +61,43 @@ func (c *EthereumClient) GetBlockReceipts( txs []evmClient.RPCTransaction, baseFee *big.Int, ) ([]*evmClient.RosettaTxReceipt, error) { - receipts := make([]*evmClient.RosettaTxReceipt, len(txs)) if len(txs) == 0 { - return receipts, nil + return []*evmClient.RosettaTxReceipt{}, nil } - ethReceipts := make([]*EthTypes.Receipt, len(txs)) - reqs := make([]rpc.BatchElem, len(txs)) - for i := range reqs { - reqs[i] = rpc.BatchElem{ - Method: "eth_getTransactionReceipt", - Args: []interface{}{txs[i].TxExtraInfo.TxHash.String()}, - Result: ðReceipts[i], - } - } - if err := c.BatchCallContext(ctx, reqs); err != nil { + var ethReceipts []*EthTypes.Receipt + err := c.CallContext(ctx, ðReceipts, "eth_getBlockReceipts", blockHash.Hex()) + if err != nil { return nil, err } - for i := range reqs { - if reqs[i].Error != nil { - return nil, reqs[i].Error - } + if len(ethReceipts) != len(txs) { + return nil, fmt.Errorf("mismatch in number of transactions and receipts") + } + + receipts := make([]*evmClient.RosettaTxReceipt, len(txs)) + for i, ethReceipt := range ethReceipts { gasPrice, err := evmClient.EffectiveGasPrice(txs[i].Tx, baseFee) if err != nil { return nil, err } - gasUsed := new(big.Int).SetUint64(ethReceipts[i].GasUsed) + gasUsed := new(big.Int).SetUint64(ethReceipt.GasUsed) feeAmount := new(big.Int).Mul(gasUsed, gasPrice) - receipt := &evmClient.RosettaTxReceipt{ - Type: ethReceipts[i].Type, + receipts[i] = &evmClient.RosettaTxReceipt{ + Type: ethReceipt.Type, GasPrice: gasPrice, GasUsed: gasUsed, - Logs: ethReceipts[i].Logs, + Logs: ethReceipt.Logs, RawMessage: nil, TransactionFee: feeAmount, } - receipts[i] = receipt - - if ethReceipts[i] == nil { - return nil, fmt.Errorf("got empty receipt for %x", txs[i].Tx.Hash().Hex()) - } - - if ethReceipts[i].BlockHash != blockHash { + if ethReceipt.BlockHash != blockHash { return nil, fmt.Errorf( "expected block hash %s for Transaction but got %s: %w", blockHash.Hex(), - ethReceipts[i].BlockHash.Hex(), + ethReceipt.BlockHash.Hex(), sdkTypes.ErrClientBlockOrphaned, ) } From 29e6646365eb8ea6e5b3c803bf859e163d5e5fc7 Mon Sep 17 00:00:00 2001 From: Xiaying Peng Date: Thu, 10 Oct 2024 16:40:38 -0700 Subject: [PATCH 2/5] Update client.go --- examples/ethereum/client/client.go | 1 - 1 file changed, 1 deletion(-) diff --git a/examples/ethereum/client/client.go b/examples/ethereum/client/client.go index a22541e..5754ad3 100644 --- a/examples/ethereum/client/client.go +++ b/examples/ethereum/client/client.go @@ -24,7 +24,6 @@ import ( "github.com/ethereum/go-ethereum" "github.com/ethereum/go-ethereum/common" - "github.com/ethereum/go-ethereum/rpc" "log" "math/big" From ff97455e1d9069ad5f29c8528ea4e84625163c10 Mon Sep 17 00:00:00 2001 From: Xiaying Peng Date: Thu, 10 Oct 2024 16:55:53 -0700 Subject: [PATCH 3/5] Update docker-compose.yml --- .github/actions/geth/docker-compose.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/actions/geth/docker-compose.yml b/.github/actions/geth/docker-compose.yml index 539c808..859f85a 100644 --- a/.github/actions/geth/docker-compose.yml +++ b/.github/actions/geth/docker-compose.yml @@ -16,7 +16,7 @@ version: '3' services: geth: - image: ethereum/client-go:v1.10.23 + image: ethereum/client-go:v1.14.11 environment: - DEVMODE=true volumes: From d8cc579e5e6e6efd94ee65f0774a78adae5ac1ed Mon Sep 17 00:00:00 2001 From: Xiaying Peng Date: Thu, 10 Oct 2024 17:06:00 -0700 Subject: [PATCH 4/5] Update docker-compose.yml --- .github/actions/geth/docker-compose.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/actions/geth/docker-compose.yml b/.github/actions/geth/docker-compose.yml index 859f85a..30a6506 100644 --- a/.github/actions/geth/docker-compose.yml +++ b/.github/actions/geth/docker-compose.yml @@ -16,7 +16,7 @@ version: '3' services: geth: - image: ethereum/client-go:v1.14.11 + image: ethereum/client-go:v1.14.6 environment: - DEVMODE=true volumes: From 58a89e68ece0230ae3a985ccd144b362baec1147 Mon Sep 17 00:00:00 2001 From: Xiaying Peng Date: Thu, 10 Oct 2024 17:07:42 -0700 Subject: [PATCH 5/5] Update ci.yml --- .github/workflows/ci.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 125d2c8..8b80b10 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -32,8 +32,8 @@ jobs: uses: ./.github/actions/geth id: geth - - name: Sleep for 20 seconds - run: sleep 20s + - name: Sleep for 60 seconds + run: sleep 60s shell: bash - name: Get latest block from geth node