Write state diffs directly to Postgres #30

Merged
telackey merged 19 commits from statediff-into-postgres into statediff_at_anyblock-1.9.11 2020-11-11 16:26:25 +00:00
5 changed files with 13 additions and 13 deletions
Showing only changes of commit cd8ae90e9e - Show all commits
+1 -1
View File
@@ -118,7 +118,7 @@ func (sdi *StateDiffIndexer) PushBlock(block *types.Block, receipts types.Receip
Review

We should change this to the Debug level

We should change this to the Debug level
Review

We should change this to the Debug level

We should change this to the Debug level
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)
Review

We should change this to the Debug level

We should change this to the Debug level
log.Debug(traceMsg)
Review

We should change this to the Debug level

We should change this to the Debug level
return err
},
}
Review

We should change this to the Debug level

We should change this to the Debug level
Review

We should change this to the Debug level

We should change this to the Debug level
+6 -6
View File
@@ -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) {
+2 -2
View File
@@ -18,6 +18,7 @@ package shared
Review

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
Review

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
Review

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
Review

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"
Review

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
Review

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 (
Review

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
Review

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
Review

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
Review

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"
Review

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
Review

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 {
Review

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
Review

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
Review

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
Review

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)
Review

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
Review

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())
Review

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
Review

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
}
}
Review

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
Review

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
Review

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
Review

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
+2 -2
View File
@@ -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
}