diff --git a/pkg/eth/api.go b/pkg/eth/api.go index 257b0bd7..0b9f8e63 100644 --- a/pkg/eth/api.go +++ b/pkg/eth/api.go @@ -25,12 +25,12 @@ import ( "math/big" "time" - "github.com/ethereum/go-ethereum" "github.com/ethereum/go-ethereum/common" "github.com/ethereum/go-ethereum/common/hexutil" "github.com/ethereum/go-ethereum/core" "github.com/ethereum/go-ethereum/core/types" "github.com/ethereum/go-ethereum/crypto" + "github.com/ethereum/go-ethereum/eth/filters" "github.com/ethereum/go-ethereum/ethclient" "github.com/ethereum/go-ethereum/params" "github.com/ethereum/go-ethereum/rlp" @@ -506,21 +506,19 @@ func (pea *PublicEthAPI) remoteGetTransactionReceipt(ctx context.Context, hash c // GetLogs returns logs matching the given argument that are stored within the state. // // https://github.com/ethereum/wiki/wiki/JSON-RPC#eth_getlogs -func (pea *PublicEthAPI) GetLogs(ctx context.Context, crit ethereum.FilterQuery) ([]*types.Log, error) { - logs, err := pea.localGetLogs(ctx, crit) +func (pea *PublicEthAPI) GetLogs(ctx context.Context, crit filters.FilterCriteria) ([]*types.Log, error) { + logs, err := pea.localGetLogs(crit) if err != nil && pea.rpc != nil { - if arg, err := toFilterArg(crit); err == nil { - var res []*types.Log - if err := pea.rpc.CallContext(ctx, &res, "eth_getLogs", arg); err == nil { - go pea.writeStateDiffWithCriteria(crit) - return res, nil - } + var res []*types.Log + if err := pea.rpc.CallContext(ctx, &res, "eth_getLogs", crit); err == nil { + go pea.writeStateDiffWithCriteria(crit) + return res, nil } } return logs, err } -func (pea *PublicEthAPI) localGetLogs(ctx context.Context, crit ethereum.FilterQuery) ([]*types.Log, error) { +func (pea *PublicEthAPI) localGetLogs(crit filters.FilterCriteria) ([]*types.Log, error) { // TODO: this can be optimized away from using the old cid retriever and ipld fetcher interfaces // Convert FilterQuery into ReceiptFilter addrStrs := make([]string, len(crit.Addresses)) @@ -890,7 +888,7 @@ func (pea *PublicEthAPI) writeStateDiffAtOrFor(blockNrOrHash rpc.BlockNumberOrHa } // writeStateDiffWithCriteria calls out to the proxy statediffing geth client to fill in a gap in the index -func (pea *PublicEthAPI) writeStateDiffWithCriteria(crit ethereum.FilterQuery) { +func (pea *PublicEthAPI) writeStateDiffWithCriteria(crit filters.FilterCriteria) { // short circuit right away if the proxy doesn't support diffing if !pea.supportsStateDiff { return diff --git a/pkg/eth/api_test.go b/pkg/eth/api_test.go index 24af5214..abf9266e 100644 --- a/pkg/eth/api_test.go +++ b/pkg/eth/api_test.go @@ -20,11 +20,11 @@ import ( "context" "strconv" - "github.com/ethereum/go-ethereum" "github.com/ethereum/go-ethereum/common" "github.com/ethereum/go-ethereum/common/hexutil" "github.com/ethereum/go-ethereum/core/types" "github.com/ethereum/go-ethereum/crypto" + "github.com/ethereum/go-ethereum/eth/filters" "github.com/ethereum/go-ethereum/rlp" "github.com/ethereum/go-ethereum/rpc" . "github.com/onsi/ginkgo" @@ -554,7 +554,7 @@ var _ = Describe("API", func() { Describe("eth_getLogs", func() { It("Retrieves receipt logs that match the provided topics within the provided range", func() { - crit := ethereum.FilterQuery{ + crit := filters.FilterCriteria{ Topics: [][]common.Hash{ { common.HexToHash("0x04"), @@ -568,7 +568,7 @@ var _ = Describe("API", func() { Expect(len(logs)).To(Equal(1)) Expect(logs).To(Equal([]*types.Log{test_helpers.MockLog1})) - crit = ethereum.FilterQuery{ + crit = filters.FilterCriteria{ Topics: [][]common.Hash{ { common.HexToHash("0x04"), @@ -583,7 +583,7 @@ var _ = Describe("API", func() { Expect(len(logs)).To(Equal(2)) Expect(logs).To(Equal([]*types.Log{test_helpers.MockLog1, test_helpers.MockLog2})) - crit = ethereum.FilterQuery{ + crit = filters.FilterCriteria{ Topics: [][]common.Hash{ { common.HexToHash("0x04"), @@ -598,7 +598,7 @@ var _ = Describe("API", func() { Expect(len(logs)).To(Equal(1)) Expect(logs).To(Equal([]*types.Log{test_helpers.MockLog1})) - crit = ethereum.FilterQuery{ + crit = filters.FilterCriteria{ Topics: [][]common.Hash{ { common.HexToHash("0x04"), @@ -614,7 +614,7 @@ var _ = Describe("API", func() { Expect(err).ToNot(HaveOccurred()) Expect(len(logs)).To(Equal(0)) - crit = ethereum.FilterQuery{ + crit = filters.FilterCriteria{ Topics: [][]common.Hash{ { common.HexToHash("0x04"), @@ -631,7 +631,7 @@ var _ = Describe("API", func() { Expect(len(logs)).To(Equal(1)) Expect(logs).To(Equal([]*types.Log{test_helpers.MockLog1})) - crit = ethereum.FilterQuery{ + crit = filters.FilterCriteria{ Topics: [][]common.Hash{ { common.HexToHash("0x05"), @@ -648,7 +648,7 @@ var _ = Describe("API", func() { Expect(len(logs)).To(Equal(1)) Expect(logs).To(Equal([]*types.Log{test_helpers.MockLog2})) - crit = ethereum.FilterQuery{ + crit = filters.FilterCriteria{ Topics: [][]common.Hash{ { common.HexToHash("0x05"), @@ -666,7 +666,7 @@ var _ = Describe("API", func() { Expect(len(logs)).To(Equal(1)) Expect(logs).To(Equal([]*types.Log{test_helpers.MockLog2})) - crit = ethereum.FilterQuery{ + crit = filters.FilterCriteria{ Topics: [][]common.Hash{ { common.HexToHash("0x04"), @@ -685,7 +685,7 @@ var _ = Describe("API", func() { Expect(len(logs)).To(Equal(2)) Expect(logs).To(Equal([]*types.Log{test_helpers.MockLog1, test_helpers.MockLog2})) - crit = ethereum.FilterQuery{ + crit = filters.FilterCriteria{ Topics: [][]common.Hash{ {}, { @@ -700,7 +700,7 @@ var _ = Describe("API", func() { Expect(len(logs)).To(Equal(1)) Expect(logs).To(Equal([]*types.Log{test_helpers.MockLog2})) - crit = ethereum.FilterQuery{ + crit = filters.FilterCriteria{ Topics: [][]common.Hash{ {}, { @@ -715,7 +715,7 @@ var _ = Describe("API", func() { Expect(len(logs)).To(Equal(1)) Expect(logs).To(Equal([]*types.Log{test_helpers.MockLog1})) - crit = ethereum.FilterQuery{ + crit = filters.FilterCriteria{ Topics: [][]common.Hash{}, FromBlock: test_helpers.MockBlock.Number(), ToBlock: test_helpers.MockBlock.Number(), @@ -728,7 +728,7 @@ var _ = Describe("API", func() { It("Uses the provided blockhash if one is provided", func() { hash := test_helpers.MockBlock.Hash() - crit := ethereum.FilterQuery{ + crit := filters.FilterCriteria{ BlockHash: &hash, Topics: [][]common.Hash{ {}, @@ -742,7 +742,7 @@ var _ = Describe("API", func() { Expect(len(logs)).To(Equal(1)) Expect(logs).To(Equal([]*types.Log{test_helpers.MockLog1})) - crit = ethereum.FilterQuery{ + crit = filters.FilterCriteria{ BlockHash: &hash, Topics: [][]common.Hash{ { @@ -758,7 +758,7 @@ var _ = Describe("API", func() { Expect(len(logs)).To(Equal(1)) Expect(logs).To(Equal([]*types.Log{test_helpers.MockLog1})) - crit = ethereum.FilterQuery{ + crit = filters.FilterCriteria{ BlockHash: &hash, Topics: [][]common.Hash{ {}, @@ -772,7 +772,7 @@ var _ = Describe("API", func() { Expect(len(logs)).To(Equal(1)) Expect(logs).To(Equal([]*types.Log{test_helpers.MockLog2})) - crit = ethereum.FilterQuery{ + crit = filters.FilterCriteria{ BlockHash: &hash, Topics: [][]common.Hash{ { @@ -788,7 +788,7 @@ var _ = Describe("API", func() { Expect(len(logs)).To(Equal(1)) Expect(logs).To(Equal([]*types.Log{test_helpers.MockLog2})) - crit = ethereum.FilterQuery{ + crit = filters.FilterCriteria{ BlockHash: &hash, Topics: [][]common.Hash{ { @@ -803,7 +803,7 @@ var _ = Describe("API", func() { Expect(err).ToNot(HaveOccurred()) Expect(len(logs)).To(Equal(0)) - crit = ethereum.FilterQuery{ + crit = filters.FilterCriteria{ BlockHash: &hash, Topics: [][]common.Hash{ { @@ -820,7 +820,7 @@ var _ = Describe("API", func() { Expect(len(logs)).To(Equal(1)) Expect(logs).To(Equal([]*types.Log{test_helpers.MockLog2})) - crit = ethereum.FilterQuery{ + crit = filters.FilterCriteria{ BlockHash: &hash, Topics: [][]common.Hash{ { @@ -834,7 +834,7 @@ var _ = Describe("API", func() { Expect(len(logs)).To(Equal(2)) Expect(logs).To(Equal([]*types.Log{test_helpers.MockLog1, test_helpers.MockLog2})) - crit = ethereum.FilterQuery{ + crit = filters.FilterCriteria{ BlockHash: &hash, Topics: [][]common.Hash{ { @@ -852,7 +852,7 @@ var _ = Describe("API", func() { Expect(len(logs)).To(Equal(2)) Expect(logs).To(Equal([]*types.Log{test_helpers.MockLog1, test_helpers.MockLog2})) - crit = ethereum.FilterQuery{ + crit = filters.FilterCriteria{ BlockHash: &hash, Topics: [][]common.Hash{}, } @@ -864,7 +864,7 @@ var _ = Describe("API", func() { It("Filters on contract address if any are provided", func() { hash := test_helpers.MockBlock.Hash() - crit := ethereum.FilterQuery{ + crit := filters.FilterCriteria{ BlockHash: &hash, Addresses: []common.Address{ test_helpers.Address, @@ -886,7 +886,7 @@ var _ = Describe("API", func() { Expect(logs).To(Equal([]*types.Log{test_helpers.MockLog1})) hash = test_helpers.MockBlock.Hash() - crit = ethereum.FilterQuery{ + crit = filters.FilterCriteria{ BlockHash: &hash, Addresses: []common.Address{ test_helpers.Address, @@ -909,7 +909,7 @@ var _ = Describe("API", func() { Expect(logs).To(Equal([]*types.Log{test_helpers.MockLog1, test_helpers.MockLog2})) hash = test_helpers.MockBlock.Hash() - crit = ethereum.FilterQuery{ + crit = filters.FilterCriteria{ BlockHash: &hash, Addresses: []common.Address{ test_helpers.Address,