Compare commits

..

2 Commits

Author SHA1 Message Date
c3f364ecc5 fix inserts using lib schema
All checks were successful
Run tests / Run unit tests (pull_request) Successful in 6m14s
2024-07-13 19:48:30 +08:00
78218a3162 update plugeth-statediff 2024-07-13 19:23:32 +08:00
3 changed files with 13 additions and 52 deletions

View File

@ -5,17 +5,18 @@ import (
"math/big"
"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/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/core/types"
"github.com/ethereum/go-ethereum/crypto"
"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"
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 {
return err
}
sql := `INSERT INTO eth.header_cids (
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,
_, err = db.Exec(testCtx, schema.TableHeader.PreparedInsert(false),
blockNumber,
blockHash,
parentHash,
@ -374,6 +358,7 @@ func insertHeaderCID(db sql.Database, blockHash, parentHash string, blockNumber
Header.Time,
Header.Coinbase.String(),
canon,
shared.MaybeStringHash(Header.WithdrawalsHash),
)
return err
}
@ -392,19 +377,7 @@ type stateModel struct {
}
func insertStateCID(db sql.Database, cidModel stateModel) error {
sql := `INSERT INTO eth.state_cids (
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,
_, err := db.Exec(testCtx, schema.TableStateNode.PreparedInsert(false),
cidModel.BlockNumber,
cidModel.BlockHash,
cidModel.LeafKey,
@ -431,17 +404,7 @@ type storageModel struct {
}
func insertStorageCID(db sql.Database, cidModel storageModel) error {
sql := `INSERT INTO eth.storage_cids (
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,
_, err := db.Exec(testCtx, schema.TableStorageNode.PreparedInsert(false),
cidModel.BlockNumber,
cidModel.BlockHash,
cidModel.LeafKey,

4
go.mod
View File

@ -5,7 +5,7 @@ go 1.21
require (
github.com/VictoriaMetrics/fastcache v1.12.2
github.com/cerc-io/ipfs-ethdb/v5 v5.1.0-alpha
github.com/cerc-io/plugeth-statediff v0.3.1
github.com/cerc-io/plugeth-statediff v0.3.2
github.com/crate-crypto/go-ipa v0.0.0-20231025140028-3c0104f4b233
github.com/davecgh/go-spew v1.1.1
github.com/ethereum/go-ethereum v1.13.14
@ -111,5 +111,3 @@ require (
lukechampine.com/blake3 v1.2.2 // indirect
rsc.io/tmplfunc v0.0.3 // indirect
)
replace github.com/cerc-io/plugeth-statediff => github.com/cerc-io/plugeth-statediff v0.3.2-0.20240711085659-6fe622e4bf33

4
go.sum
View File

@ -22,8 +22,8 @@ github.com/cerc-io/eth-testing v0.5.1 h1:xxcQf9ymJS0911yWIrUiGvCvqfvEjYmHvhBJkCD
github.com/cerc-io/eth-testing v0.5.1/go.mod h1:p86je2PjSM7u8Qd7rMIG/Zw+tQlBoS5Emkh1ECnC5t0=
github.com/cerc-io/ipfs-ethdb/v5 v5.1.0-alpha h1:+XhYHvzC3zFIvcWEb466SNDfeLrvcW3xe/d0cbVVVRA=
github.com/cerc-io/ipfs-ethdb/v5 v5.1.0-alpha/go.mod h1:w5g07b6Uz+c6r/ySml58TEOJdUYAibYYF05H5ULVv2I=
github.com/cerc-io/plugeth-statediff v0.3.2-0.20240711085659-6fe622e4bf33 h1:t0hSbThg5uX4r34eIFI0Pj2WbTIquDc+lKChLqieaMc=
github.com/cerc-io/plugeth-statediff v0.3.2-0.20240711085659-6fe622e4bf33/go.mod h1:r6Mzc6k4V9KD+iN9AXa/LmmRISDsQnnIwKzZMFjJ+eE=
github.com/cerc-io/plugeth-statediff v0.3.2 h1:GuOUqDT6nJRCikyaNxDI2pA7TRnOTWOcyJGlJtwSzHY=
github.com/cerc-io/plugeth-statediff v0.3.2/go.mod h1:r6Mzc6k4V9KD+iN9AXa/LmmRISDsQnnIwKzZMFjJ+eE=
github.com/cespare/xxhash/v2 v2.2.0 h1:DC2CZ1Ep5Y4k3ZQ899DldepgrayRUGE6BBZ/cd9Cj44=
github.com/cespare/xxhash/v2 v2.2.0/go.mod h1:VGX0DQ3Q6kWi7AoAeZDth3/j3BFtOZR5XLFGgcrjCOs=
github.com/cockroachdb/apd v1.1.0 h1:3LFP3629v+1aKXU5Q37mxmRxX/pIu1nijXydLShEq5I=