Compare commits

..

No commits in common. "c3f364ecc517de5c82696b1f78a336319abed002" and "79e4a33b8fa77bdcd18bad96f939880f39beeccd" have entirely different histories.

3 changed files with 54 additions and 15 deletions

View File

@ -5,19 +5,18 @@ import (
"math/big"
"testing"
"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"
"github.com/cerc-io/plugeth-statediff/indexer/database/sql/postgres"
"github.com/cerc-io/plugeth-statediff/indexer/ipld"
"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"
state "github.com/cerc-io/ipld-eth-statedb/direct_by_leaf"
util "github.com/cerc-io/ipld-eth-statedb/internal"
"github.com/cerc-io/ipld-eth-statedb/sql"
@ -344,7 +343,24 @@ func insertHeaderCID(db sql.Database, blockHash, parentHash string, blockNumber
if err != nil {
return err
}
_, err = db.Exec(testCtx, schema.TableHeader.PreparedInsert(false),
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,
blockNumber,
blockHash,
parentHash,
@ -358,7 +374,6 @@ func insertHeaderCID(db sql.Database, blockHash, parentHash string, blockNumber
Header.Time,
Header.Coinbase.String(),
canon,
shared.MaybeStringHash(Header.WithdrawalsHash),
)
return err
}
@ -377,7 +392,19 @@ type stateModel struct {
}
func insertStateCID(db sql.Database, cidModel stateModel) error {
_, err := db.Exec(testCtx, schema.TableStateNode.PreparedInsert(false),
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,
cidModel.BlockNumber,
cidModel.BlockHash,
cidModel.LeafKey,
@ -404,7 +431,17 @@ type storageModel struct {
}
func insertStorageCID(db sql.Database, cidModel storageModel) error {
_, err := db.Exec(testCtx, schema.TableStorageNode.PreparedInsert(false),
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,
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.2
github.com/cerc-io/plugeth-statediff v0.3.1
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,3 +111,5 @@ 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 h1:GuOUqDT6nJRCikyaNxDI2pA7TRnOTWOcyJGlJtwSzHY=
github.com/cerc-io/plugeth-statediff v0.3.2/go.mod h1:r6Mzc6k4V9KD+iN9AXa/LmmRISDsQnnIwKzZMFjJ+eE=
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/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=