diff --git a/.github/actions/geth/docker-compose.yml b/.github/actions/geth/docker-compose.yml index 539c808..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.10.23 + image: ethereum/client-go:v1.14.6 environment: - DEVMODE=true volumes: 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 diff --git a/examples/ethereum/client/client.go b/examples/ethereum/client/client.go index a17abca..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" @@ -61,55 +60,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, ) }