Write state diffs directly to Postgres #30
@@ -118,7 +118,7 @@ func (sdi *StateDiffIndexer) PushBlock(block *types.Block, receipts types.Receip
|
||||
|
|
||||
traceMsg += fmt.Sprintf("postgres transaction commit duration: %s\r\n", tDiff.String())
|
||||
}
|
||||
traceMsg += fmt.Sprintf(" TOTAL PROCESSING DURATION: %s\r\n", time.Now().Sub(start).String())
|
||||
log.Info(traceMsg)
|
||||
|
i-norden
commented
We should change this to the Debug level We should change this to the Debug level
|
||||
log.Debug(traceMsg)
|
||||
|
i-norden
commented
We should change this to the Debug level We should change this to the Debug level
|
||||
return err
|
||||
},
|
||||
}
|
||||
|
||||
|
i-norden
commented
We should change this to the Debug level We should change this to the Debug level
i-norden
commented
We should change this to the Debug level We should change this to the Debug level
|
||||
@@ -26,11 +26,11 @@ import (
|
||||
"github.com/ethereum/go-ethereum/core/state"
|
||||
"github.com/ethereum/go-ethereum/core/types"
|
||||
"github.com/ethereum/go-ethereum/crypto"
|
||||
"github.com/ethereum/go-ethereum/log"
|
||||
"github.com/ethereum/go-ethereum/params"
|
||||
"github.com/ethereum/go-ethereum/rlp"
|
||||
"github.com/ipfs/go-block-format"
|
||||
"github.com/multiformats/go-multihash"
|
||||
log "github.com/sirupsen/logrus"
|
||||
|
||||
"github.com/ethereum/go-ethereum/statediff/indexer/ipfs/ipld"
|
||||
"github.com/ethereum/go-ethereum/statediff/indexer/models"
|
||||
@@ -423,23 +423,23 @@ func createTransactionsAndReceipts() (types.Transactions, types.Receipts, common
|
||||
mockCurve := elliptic.P256()
|
||||
mockPrvKey, err := ecdsa.GenerateKey(mockCurve, rand.Reader)
|
||||
if err != nil {
|
||||
log.Fatal(err)
|
||||
log.Crit(err.Error())
|
||||
}
|
||||
signedTrx1, err := types.SignTx(trx1, transactionSigner, mockPrvKey)
|
||||
if err != nil {
|
||||
log.Fatal(err)
|
||||
log.Crit(err.Error())
|
||||
}
|
||||
signedTrx2, err := types.SignTx(trx2, transactionSigner, mockPrvKey)
|
||||
if err != nil {
|
||||
log.Fatal(err)
|
||||
log.Crit(err.Error())
|
||||
}
|
||||
signedTrx3, err := types.SignTx(trx3, transactionSigner, mockPrvKey)
|
||||
if err != nil {
|
||||
log.Fatal(err)
|
||||
log.Crit(err.Error())
|
||||
}
|
||||
SenderAddr, err := types.Sender(transactionSigner, signedTrx1) // same for both trx
|
||||
if err != nil {
|
||||
log.Fatal(err)
|
||||
log.Crit(err.Error())
|
||||
}
|
||||
// make receipts
|
||||
mockReceipt1 := types.NewReceipt(common.HexToHash("0x0").Bytes(), false, 50)
|
||||
|
||||
@@ -20,14 +20,14 @@ import (
|
||||
"io/ioutil"
|
||||
"testing"
|
||||
|
||||
log "github.com/sirupsen/logrus"
|
||||
"github.com/ethereum/go-ethereum/log"
|
||||
|
||||
. "github.com/onsi/ginkgo"
|
||||
. "github.com/onsi/gomega"
|
||||
)
|
||||
|
||||
func init() {
|
||||
log.SetOutput(ioutil.Discard)
|
||||
log.Root().SetHandler(log.DiscardHandler())
|
||||
}
|
||||
|
||||
func TestPostgres(t *testing.T) {
|
||||
|
||||
@@ -18,6 +18,7 @@ package shared
|
||||
|
i-norden
commented
We should update all the ported packages to use Geth's log package We should update all the ported packages to use Geth's log package
i-norden
commented
We should update all the ported packages to use Geth's log package We should update all the ported packages to use Geth's log package
i-norden
commented
Similarly, we should update any tests we ported over to use the default test pkg that the rest of geth uses instead of ginko/gomega Similarly, we should update any tests we ported over to use the default test pkg that the rest of geth uses instead of ginko/gomega
i-norden
commented
Similarly, we should update any tests we ported over to use the default test pkg that the rest of geth uses instead of ginko/gomega Similarly, we should update any tests we ported over to use the default test pkg that the rest of geth uses instead of ginko/gomega
|
||||
|
||||
import (
|
||||
"github.com/ethereum/go-ethereum/common"
|
||||
"github.com/ethereum/go-ethereum/log"
|
||||
|
i-norden
commented
We should update all the ported packages to use Geth's log package We should update all the ported packages to use Geth's log package
i-norden
commented
Similarly, we should update any tests we ported over to use the default test pkg that the rest of geth uses instead of ginko/gomega Similarly, we should update any tests we ported over to use the default test pkg that the rest of geth uses instead of ginko/gomega
|
||||
"github.com/ethereum/go-ethereum/statediff/indexer/ipfs/ipld"
|
||||
|
||||
"github.com/ipfs/go-cid"
|
||||
@@ -26,7 +27,6 @@ import (
|
||||
|
i-norden
commented
We should update all the ported packages to use Geth's log package We should update all the ported packages to use Geth's log package
i-norden
commented
We should update all the ported packages to use Geth's log package We should update all the ported packages to use Geth's log package
i-norden
commented
Similarly, we should update any tests we ported over to use the default test pkg that the rest of geth uses instead of ginko/gomega Similarly, we should update any tests we ported over to use the default test pkg that the rest of geth uses instead of ginko/gomega
i-norden
commented
Similarly, we should update any tests we ported over to use the default test pkg that the rest of geth uses instead of ginko/gomega Similarly, we should update any tests we ported over to use the default test pkg that the rest of geth uses instead of ginko/gomega
|
||||
node "github.com/ipfs/go-ipld-format"
|
||||
"github.com/jmoiron/sqlx"
|
||||
"github.com/multiformats/go-multihash"
|
||||
"github.com/sirupsen/logrus"
|
||||
|
i-norden
commented
We should update all the ported packages to use Geth's log package We should update all the ported packages to use Geth's log package
i-norden
commented
Similarly, we should update any tests we ported over to use the default test pkg that the rest of geth uses instead of ginko/gomega Similarly, we should update any tests we ported over to use the default test pkg that the rest of geth uses instead of ginko/gomega
|
||||
)
|
||||
|
||||
// HandleZeroAddrPointer will return an emtpy string for a nil address pointer
|
||||
@@ -48,7 +48,7 @@ func HandleZeroAddr(to common.Address) string {
|
||||
|
i-norden
commented
We should update all the ported packages to use Geth's log package We should update all the ported packages to use Geth's log package
i-norden
commented
We should update all the ported packages to use Geth's log package We should update all the ported packages to use Geth's log package
i-norden
commented
Similarly, we should update any tests we ported over to use the default test pkg that the rest of geth uses instead of ginko/gomega Similarly, we should update any tests we ported over to use the default test pkg that the rest of geth uses instead of ginko/gomega
i-norden
commented
Similarly, we should update any tests we ported over to use the default test pkg that the rest of geth uses instead of ginko/gomega Similarly, we should update any tests we ported over to use the default test pkg that the rest of geth uses instead of ginko/gomega
|
||||
// Rollback sql transaction and log any error
|
||||
func Rollback(tx *sqlx.Tx) {
|
||||
if err := tx.Rollback(); err != nil {
|
||||
logrus.Error(err)
|
||||
|
i-norden
commented
We should update all the ported packages to use Geth's log package We should update all the ported packages to use Geth's log package
i-norden
commented
Similarly, we should update any tests we ported over to use the default test pkg that the rest of geth uses instead of ginko/gomega Similarly, we should update any tests we ported over to use the default test pkg that the rest of geth uses instead of ginko/gomega
|
||||
log.Error(err.Error())
|
||||
|
i-norden
commented
We should update all the ported packages to use Geth's log package We should update all the ported packages to use Geth's log package
i-norden
commented
Similarly, we should update any tests we ported over to use the default test pkg that the rest of geth uses instead of ginko/gomega Similarly, we should update any tests we ported over to use the default test pkg that the rest of geth uses instead of ginko/gomega
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
i-norden
commented
We should update all the ported packages to use Geth's log package We should update all the ported packages to use Geth's log package
i-norden
commented
We should update all the ported packages to use Geth's log package We should update all the ported packages to use Geth's log package
i-norden
commented
Similarly, we should update any tests we ported over to use the default test pkg that the rest of geth uses instead of ginko/gomega Similarly, we should update any tests we ported over to use the default test pkg that the rest of geth uses instead of ginko/gomega
i-norden
commented
Similarly, we should update any tests we ported over to use the default test pkg that the rest of geth uses instead of ginko/gomega Similarly, we should update any tests we ported over to use the default test pkg that the rest of geth uses instead of ginko/gomega
|
||||
@@ -19,7 +19,7 @@ package utils
|
||||
import (
|
||||
"errors"
|
||||
|
||||
"github.com/sirupsen/logrus"
|
||||
"github.com/ethereum/go-ethereum/log"
|
||||
|
||||
"github.com/ethereum/go-ethereum/statediff/indexer/node"
|
||||
"github.com/ethereum/go-ethereum/statediff/indexer/postgres"
|
||||
@@ -28,7 +28,7 @@ import (
|
||||
func LoadPostgres(database postgres.Config, node node.Info) postgres.DB {
|
||||
db, err := postgres.NewDB(database, node)
|
||||
if err != nil {
|
||||
logrus.Fatal("Error loading postgres: ", err)
|
||||
log.Fatal("Error loading postgres: ", err)
|
||||
}
|
||||
return *db
|
||||
}
|
||||
|
||||
We should change this to the Debug level
We should change this to the Debug level