diff --git a/pkg/eth/api.go b/pkg/eth/api.go index fb8b5881..9d4efd02 100644 --- a/pkg/eth/api.go +++ b/pkg/eth/api.go @@ -25,8 +25,6 @@ import ( "math/big" "time" - "github.com/ethereum/go-ethereum/statediff" - "github.com/ethereum/go-ethereum" "github.com/ethereum/go-ethereum/common" "github.com/ethereum/go-ethereum/common/hexutil" @@ -37,6 +35,7 @@ import ( "github.com/ethereum/go-ethereum/params" "github.com/ethereum/go-ethereum/rlp" "github.com/ethereum/go-ethereum/rpc" + "github.com/ethereum/go-ethereum/statediff" "github.com/sirupsen/logrus" "github.com/vulcanize/ipld-eth-indexer/pkg/eth" @@ -53,7 +52,7 @@ type PublicEthAPI struct { // Local db backend B *Backend - // Remote node for forwarding cache misses + // Proxy node for forwarding cache misses supportsStateDiff bool // Whether or not the remote node supports the statediff_writeStateDiffAt endpoint, if it does we can fill the local cache when we hit a miss rpc *rpc.Client ethClient *ethclient.Client @@ -874,8 +873,12 @@ func DoCall(ctx context.Context, b *Backend, args CallArgs, blockNrOrHash rpc.Bl return result.Return(), result.UsedGas, result.Failed(), err } -// writeStateDiffAtOrFor calls out to the statediffing geth client to fill in a gap in the index +// writeStateDiffAtOrFor calls out to the proxy statediffing geth client to fill in a gap in the index func (pea *PublicEthAPI) writeStateDiffAtOrFor(blockNrOrHash rpc.BlockNumberOrHash) { + // short circuit right away if the proxy doesn't support diffing + if !pea.supportsStateDiff { + return + } if blockNr, ok := blockNrOrHash.Number(); ok { pea.writeStateDiffAt(blockNr.Int64()) return @@ -885,8 +888,12 @@ func (pea *PublicEthAPI) writeStateDiffAtOrFor(blockNrOrHash rpc.BlockNumberOrHa } } -// writeStateDiffWithCriteria calls out to the statediffing geth client to fill in a gap in the index +// writeStateDiffWithCriteria calls out to the proxy statediffing geth client to fill in a gap in the index func (pea *PublicEthAPI) writeStateDiffWithCriteria(crit ethereum.FilterQuery) { + // short circuit right away if the proxy doesn't support diffing + if !pea.supportsStateDiff { + return + } if crit.BlockHash != nil { pea.writeStateDiffFor(*crit.BlockHash) return @@ -905,7 +912,7 @@ func (pea *PublicEthAPI) writeStateDiffWithCriteria(crit ethereum.FilterQuery) { } } -// writeStateDiffAt calls out to the statediffing geth client to fill in a gap in the index +// writeStateDiffAt calls out to the proxy statediffing geth client to fill in a gap in the index func (pea *PublicEthAPI) writeStateDiffAt(height int64) { if !pea.supportsStateDiff { return @@ -927,7 +934,7 @@ func (pea *PublicEthAPI) writeStateDiffAt(height int64) { } } -// writeStateDiffFor calls out to the statediffing geth client to fill in a gap in the index +// writeStateDiffFor calls out to the proxy statediffing geth client to fill in a gap in the index func (pea *PublicEthAPI) writeStateDiffFor(blockHash common.Hash) { if !pea.supportsStateDiff { return diff --git a/pkg/eth/backend.go b/pkg/eth/backend.go index a0cc1732..2be41efc 100644 --- a/pkg/eth/backend.go +++ b/pkg/eth/backend.go @@ -22,11 +22,8 @@ import ( "fmt" "math/big" - "github.com/ethereum/go-ethereum/trie" - - "github.com/ethereum/go-ethereum/common/hexutil" - "github.com/ethereum/go-ethereum/common" + "github.com/ethereum/go-ethereum/common/hexutil" "github.com/ethereum/go-ethereum/common/math" "github.com/ethereum/go-ethereum/consensus" "github.com/ethereum/go-ethereum/consensus/ethash" @@ -41,8 +38,9 @@ import ( "github.com/ethereum/go-ethereum/params" "github.com/ethereum/go-ethereum/rlp" "github.com/ethereum/go-ethereum/rpc" - "github.com/vulcanize/ipfs-ethdb" + "github.com/ethereum/go-ethereum/trie" + "github.com/vulcanize/ipfs-ethdb" "github.com/vulcanize/ipld-eth-indexer/pkg/postgres" shared2 "github.com/vulcanize/ipld-eth-indexer/pkg/shared" diff --git a/pkg/eth/eth_state_test.go b/pkg/eth/eth_state_test.go index de7dac51..79784951 100644 --- a/pkg/eth/eth_state_test.go +++ b/pkg/eth/eth_state_test.go @@ -22,8 +22,6 @@ import ( "io/ioutil" "math/big" - "github.com/vulcanize/ipld-eth-indexer/pkg/shared" - "github.com/ethereum/go-ethereum/accounts/abi" "github.com/ethereum/go-ethereum/common" "github.com/ethereum/go-ethereum/common/hexutil" @@ -39,6 +37,7 @@ import ( eth2 "github.com/vulcanize/ipld-eth-indexer/pkg/eth" "github.com/vulcanize/ipld-eth-indexer/pkg/postgres" + "github.com/vulcanize/ipld-eth-indexer/pkg/shared" "github.com/vulcanize/ipld-eth-server/pkg/eth" "github.com/vulcanize/ipld-eth-server/pkg/eth/test_helpers" diff --git a/pkg/graphql/service.go b/pkg/graphql/service.go index d9e74e01..726e0d98 100644 --- a/pkg/graphql/service.go +++ b/pkg/graphql/service.go @@ -23,7 +23,6 @@ import ( "github.com/ethereum/go-ethereum/cmd/utils" "github.com/ethereum/go-ethereum/node" - "github.com/ethereum/go-ethereum/p2p" "github.com/ethereum/go-ethereum/rpc" "github.com/graph-gophers/graphql-go" diff --git a/pkg/rpc/ws.go b/pkg/rpc/ws.go index 02143f2b..ac4b8477 100644 --- a/pkg/rpc/ws.go +++ b/pkg/rpc/ws.go @@ -22,8 +22,8 @@ import ( "github.com/ethereum/go-ethereum/cmd/utils" "github.com/ethereum/go-ethereum/node" - "github.com/ethereum/go-ethereum/rpc" + "github.com/vulcanize/ipld-eth-server/pkg/prom" )