Update plugeth-statediff #7
@ -5,17 +5,18 @@ import (
|
|||||||
"math/big"
|
"math/big"
|
||||||
"testing"
|
"testing"
|
||||||
|
|
||||||
"github.com/holiman/uint256"
|
|
||||||
"github.com/lib/pq"
|
|
||||||
"github.com/multiformats/go-multihash"
|
|
||||||
"github.com/stretchr/testify/require"
|
|
||||||
|
|
||||||
"github.com/cerc-io/plugeth-statediff/indexer/database/sql/postgres"
|
"github.com/cerc-io/plugeth-statediff/indexer/database/sql/postgres"
|
||||||
"github.com/cerc-io/plugeth-statediff/indexer/ipld"
|
"github.com/cerc-io/plugeth-statediff/indexer/ipld"
|
||||||
|
"github.com/cerc-io/plugeth-statediff/indexer/shared"
|
||||||
|
"github.com/cerc-io/plugeth-statediff/indexer/shared/schema"
|
||||||
"github.com/ethereum/go-ethereum/common"
|
"github.com/ethereum/go-ethereum/common"
|
||||||
"github.com/ethereum/go-ethereum/core/types"
|
"github.com/ethereum/go-ethereum/core/types"
|
||||||
"github.com/ethereum/go-ethereum/crypto"
|
"github.com/ethereum/go-ethereum/crypto"
|
||||||
"github.com/ethereum/go-ethereum/rlp"
|
"github.com/ethereum/go-ethereum/rlp"
|
||||||
|
"github.com/holiman/uint256"
|
||||||
|
"github.com/lib/pq"
|
||||||
|
"github.com/multiformats/go-multihash"
|
||||||
|
"github.com/stretchr/testify/require"
|
||||||
|
|
||||||
state "github.com/cerc-io/ipld-eth-statedb/direct_by_leaf"
|
state "github.com/cerc-io/ipld-eth-statedb/direct_by_leaf"
|
||||||
util "github.com/cerc-io/ipld-eth-statedb/internal"
|
util "github.com/cerc-io/ipld-eth-statedb/internal"
|
||||||
@ -343,24 +344,7 @@ func insertHeaderCID(db sql.Database, blockHash, parentHash string, blockNumber
|
|||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
sql := `INSERT INTO eth.header_cids (
|
_, err = db.Exec(testCtx, schema.TableHeader.PreparedInsert(false),
|
||||||
block_number,
|
|
||||||
block_hash,
|
|
||||||
parent_hash,
|
|
||||||
cid,
|
|
||||||
td,
|
|
||||||
node_ids,
|
|
||||||
reward,
|
|
||||||
state_root,
|
|
||||||
tx_root,
|
|
||||||
receipt_root,
|
|
||||||
uncles_hash,
|
|
||||||
bloom,
|
|
||||||
timestamp,
|
|
||||||
coinbase,
|
|
||||||
canonical
|
|
||||||
) VALUES ($1, $2, $3, $4, $5, $6, $7, $8, $9, $10, $11, $12, $13, $14, $15)`
|
|
||||||
_, err = db.Exec(testCtx, sql,
|
|
||||||
blockNumber,
|
blockNumber,
|
||||||
blockHash,
|
blockHash,
|
||||||
parentHash,
|
parentHash,
|
||||||
@ -374,6 +358,7 @@ func insertHeaderCID(db sql.Database, blockHash, parentHash string, blockNumber
|
|||||||
Header.Time,
|
Header.Time,
|
||||||
Header.Coinbase.String(),
|
Header.Coinbase.String(),
|
||||||
canon,
|
canon,
|
||||||
|
shared.MaybeStringHash(Header.WithdrawalsHash),
|
||||||
)
|
)
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
@ -392,19 +377,7 @@ type stateModel struct {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func insertStateCID(db sql.Database, cidModel stateModel) error {
|
func insertStateCID(db sql.Database, cidModel stateModel) error {
|
||||||
sql := `INSERT INTO eth.state_cids (
|
_, err := db.Exec(testCtx, schema.TableStateNode.PreparedInsert(false),
|
||||||
block_number,
|
|
||||||
header_id,
|
|
||||||
state_leaf_key,
|
|
||||||
cid,
|
|
||||||
diff,
|
|
||||||
balance,
|
|
||||||
nonce,
|
|
||||||
code_hash,
|
|
||||||
storage_root,
|
|
||||||
removed
|
|
||||||
) VALUES ($1, $2, $3, $4, $5, $6, $7, $8, $9, $10)`
|
|
||||||
_, err := db.Exec(testCtx, sql,
|
|
||||||
cidModel.BlockNumber,
|
cidModel.BlockNumber,
|
||||||
cidModel.BlockHash,
|
cidModel.BlockHash,
|
||||||
cidModel.LeafKey,
|
cidModel.LeafKey,
|
||||||
@ -431,17 +404,7 @@ type storageModel struct {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func insertStorageCID(db sql.Database, cidModel storageModel) error {
|
func insertStorageCID(db sql.Database, cidModel storageModel) error {
|
||||||
sql := `INSERT INTO eth.storage_cids (
|
_, err := db.Exec(testCtx, schema.TableStorageNode.PreparedInsert(false),
|
||||||
block_number,
|
|
||||||
header_id,
|
|
||||||
state_leaf_key,
|
|
||||||
storage_leaf_key,
|
|
||||||
cid,
|
|
||||||
diff,
|
|
||||||
val,
|
|
||||||
removed
|
|
||||||
) VALUES ($1, $2, $3, $4, $5, $6, $7, $8)`
|
|
||||||
_, err := db.Exec(testCtx, sql,
|
|
||||||
cidModel.BlockNumber,
|
cidModel.BlockNumber,
|
||||||
cidModel.BlockHash,
|
cidModel.BlockHash,
|
||||||
cidModel.LeafKey,
|
cidModel.LeafKey,
|
||||||
|
Loading…
Reference in New Issue
Block a user