From 89faa85871ff3697b3f59f127b9f7ba998184d08 Mon Sep 17 00:00:00 2001 From: Ian Norden Date: Fri, 9 Aug 2019 11:22:29 -0500 Subject: [PATCH] fix transaction signing, also removes need for rpc call to do it --- pkg/ipfs/converter.go | 16 +++++++--------- pkg/seed_node/service.go | 4 +++- 2 files changed, 10 insertions(+), 10 deletions(-) diff --git a/pkg/ipfs/converter.go b/pkg/ipfs/converter.go index c7b9aa23..0296be86 100644 --- a/pkg/ipfs/converter.go +++ b/pkg/ipfs/converter.go @@ -17,14 +17,11 @@ package ipfs import ( - "context" - "github.com/ethereum/go-ethereum/common" "github.com/ethereum/go-ethereum/core/types" + "github.com/ethereum/go-ethereum/params" "github.com/ethereum/go-ethereum/rlp" "github.com/ethereum/go-ethereum/statediff" - - "github.com/vulcanize/vulcanizedb/pkg/core" ) // PayloadConverter interface is used to convert a geth statediff.Payload to our IPLDPayload type @@ -34,13 +31,13 @@ type PayloadConverter interface { // Converter is the underlying struct for the PayloadConverter interface type Converter struct { - client core.EthClient + chainConfig *params.ChainConfig } // NewPayloadConverter creates a pointer to a new Converter which satisfies the PayloadConverter interface -func NewPayloadConverter(client core.EthClient) *Converter { +func NewPayloadConverter(chainConfig *params.ChainConfig) *Converter { return &Converter{ - client: client, + chainConfig: chainConfig, } } @@ -69,9 +66,10 @@ func (pc *Converter) Convert(payload statediff.Payload) (*IPLDPayload, error) { StateNodes: make(map[common.Hash]StateNode), StorageNodes: make(map[common.Hash][]StorageNode), } - for gethTransactionIndex, trx := range block.Transactions() { + signer := types.MakeSigner(pc.chainConfig, block.Number()) + for _, trx := range block.Transactions() { // Extract to and from data from the the transactions for indexing - from, err := pc.client.TransactionSender(context.Background(), trx, block.Hash(), uint(gethTransactionIndex)) + from, err := types.Sender(signer, trx) if err != nil { return nil, err } diff --git a/pkg/seed_node/service.go b/pkg/seed_node/service.go index c70e0ceb..b8609611 100644 --- a/pkg/seed_node/service.go +++ b/pkg/seed_node/service.go @@ -19,6 +19,8 @@ package seed_node import ( "sync" + "github.com/ethereum/go-ethereum/params" + "github.com/vulcanize/vulcanizedb/libraries/shared/streamer" "github.com/vulcanize/vulcanizedb/pkg/ipfs" @@ -98,7 +100,7 @@ func NewProcessor(ipfsPath string, db *postgres.DB, ethClient core.EthClient, rp return &Service{ Streamer: streamer.NewStateDiffStreamer(rpcClient), Repository: NewCIDRepository(db), - Converter: ipfs.NewPayloadConverter(ethClient), + Converter: ipfs.NewPayloadConverter(params.MainnetChainConfig), Publisher: publisher, Filterer: NewResponseFilterer(), Fetcher: fetcher,