Changes for using single-node v4 db schema
This commit is contained in:
parent
05b0ddcffc
commit
ed370ccb84
@ -425,7 +425,7 @@ func TestFileIndexer(t *testing.T) {
|
|||||||
}
|
}
|
||||||
for i := range rcts {
|
for i := range rcts {
|
||||||
results := make([]logIPLD, 0)
|
results := make([]logIPLD, 0)
|
||||||
pgStr = `SELECT log_cids.index, log_cids.address, COALESCE(log_cids.topic0, '') as topic0, COALESCE(log_cids.topic1, '') as topic1, data FROM eth.log_cids
|
pgStr = `SELECT log_cids.index, log_cids.address, log_cids.topic0, log_cids.topic1, data FROM eth.log_cids
|
||||||
INNER JOIN eth.receipt_cids ON (log_cids.rct_id = receipt_cids.tx_id)
|
INNER JOIN eth.receipt_cids ON (log_cids.rct_id = receipt_cids.tx_id)
|
||||||
INNER JOIN public.blocks ON (log_cids.leaf_mh_key = blocks.key)
|
INNER JOIN public.blocks ON (log_cids.leaf_mh_key = blocks.key)
|
||||||
WHERE receipt_cids.leaf_cid = $1 ORDER BY eth.log_cids.index ASC`
|
WHERE receipt_cids.leaf_cid = $1 ORDER BY eth.log_cids.index ASC`
|
||||||
@ -480,7 +480,7 @@ func TestFileIndexer(t *testing.T) {
|
|||||||
|
|
||||||
for idx, c := range rcts {
|
for idx, c := range rcts {
|
||||||
result := make([]models.IPLDModel, 0)
|
result := make([]models.IPLDModel, 0)
|
||||||
pgStr = `SELECT COALESCE(data, '') as data
|
pgStr = `SELECT data
|
||||||
FROM eth.receipt_cids
|
FROM eth.receipt_cids
|
||||||
INNER JOIN public.blocks ON (receipt_cids.leaf_mh_key = public.blocks.key)
|
INNER JOIN public.blocks ON (receipt_cids.leaf_mh_key = public.blocks.key)
|
||||||
WHERE receipt_cids.leaf_cid = $1`
|
WHERE receipt_cids.leaf_cid = $1`
|
||||||
@ -510,7 +510,7 @@ func TestFileIndexer(t *testing.T) {
|
|||||||
if err != nil {
|
if err != nil {
|
||||||
t.Fatal(err)
|
t.Fatal(err)
|
||||||
}
|
}
|
||||||
postStatePgStr := `SELECT COALESCE(post_state, '') as post_state FROM eth.receipt_cids WHERE leaf_cid = $1`
|
postStatePgStr := `SELECT post_state FROM eth.receipt_cids WHERE leaf_cid = $1`
|
||||||
switch c {
|
switch c {
|
||||||
case rct1CID.String():
|
case rct1CID.String():
|
||||||
require.Equal(t, rctLeaf1, data)
|
require.Equal(t, rctLeaf1, data)
|
||||||
@ -564,7 +564,7 @@ func TestFileIndexer(t *testing.T) {
|
|||||||
|
|
||||||
// check that state nodes were properly indexed and published
|
// check that state nodes were properly indexed and published
|
||||||
stateNodes := make([]models.StateNodeModel, 0)
|
stateNodes := make([]models.StateNodeModel, 0)
|
||||||
pgStr := `SELECT state_cids.cid, state_cids.state_leaf_key, state_cids.node_type, COALESCE(state_cids.state_path, '') as state_path, state_cids.header_id
|
pgStr := `SELECT state_cids.cid, state_cids.state_leaf_key, state_cids.node_type, state_cids.state_path, state_cids.header_id
|
||||||
FROM eth.state_cids INNER JOIN eth.header_cids ON (state_cids.header_id = header_cids.block_hash)
|
FROM eth.state_cids INNER JOIN eth.header_cids ON (state_cids.header_id = header_cids.block_hash)
|
||||||
WHERE header_cids.block_number = $1 AND node_type != 3`
|
WHERE header_cids.block_number = $1 AND node_type != 3`
|
||||||
err = sqlxdb.Select(&stateNodes, pgStr, mocks.BlockNumber.Uint64())
|
err = sqlxdb.Select(&stateNodes, pgStr, mocks.BlockNumber.Uint64())
|
||||||
@ -584,7 +584,7 @@ func TestFileIndexer(t *testing.T) {
|
|||||||
if err != nil {
|
if err != nil {
|
||||||
t.Fatal(err)
|
t.Fatal(err)
|
||||||
}
|
}
|
||||||
pgStr = `SELECT cast(block_number AS TEXT), header_id, state_path, cast(balance AS TEXT), nonce, COALESCE(code_hash, '') as code_hash, storage_root from eth.state_accounts WHERE header_id = $1 AND state_path = $2`
|
pgStr = `SELECT cast(block_number AS TEXT), header_id, state_path, cast(balance AS TEXT), nonce, code_hash, storage_root from eth.state_accounts WHERE header_id = $1 AND state_path = $2`
|
||||||
var account models.StateAccountModel
|
var account models.StateAccountModel
|
||||||
err = sqlxdb.Get(&account, pgStr, stateNode.HeaderID, stateNode.Path)
|
err = sqlxdb.Get(&account, pgStr, stateNode.HeaderID, stateNode.Path)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
@ -668,7 +668,7 @@ func TestFileIndexer(t *testing.T) {
|
|||||||
|
|
||||||
// check that storage nodes were properly indexed
|
// check that storage nodes were properly indexed
|
||||||
storageNodes := make([]models.StorageNodeWithStateKeyModel, 0)
|
storageNodes := make([]models.StorageNodeWithStateKeyModel, 0)
|
||||||
pgStr := `SELECT cast(storage_cids.block_number AS TEXT), storage_cids.cid, state_cids.state_leaf_key, storage_cids.storage_leaf_key, storage_cids.node_type, COALESCE(storage_cids.storage_path, '') as storage_path
|
pgStr := `SELECT cast(storage_cids.block_number AS TEXT), storage_cids.cid, state_cids.state_leaf_key, storage_cids.storage_leaf_key, storage_cids.node_type, storage_cids.storage_path
|
||||||
FROM eth.storage_cids, eth.state_cids, eth.header_cids
|
FROM eth.storage_cids, eth.state_cids, eth.header_cids
|
||||||
WHERE (storage_cids.state_path, storage_cids.header_id) = (state_cids.state_path, state_cids.header_id)
|
WHERE (storage_cids.state_path, storage_cids.header_id) = (state_cids.state_path, state_cids.header_id)
|
||||||
AND state_cids.header_id = header_cids.block_hash
|
AND state_cids.header_id = header_cids.block_hash
|
||||||
@ -702,7 +702,7 @@ func TestFileIndexer(t *testing.T) {
|
|||||||
|
|
||||||
// check that Removed storage nodes were properly indexed
|
// check that Removed storage nodes were properly indexed
|
||||||
storageNodes = make([]models.StorageNodeWithStateKeyModel, 0)
|
storageNodes = make([]models.StorageNodeWithStateKeyModel, 0)
|
||||||
pgStr = `SELECT cast(storage_cids.block_number AS TEXT), storage_cids.cid, state_cids.state_leaf_key, storage_cids.storage_leaf_key, storage_cids.node_type, COALESCE(storage_cids.storage_path, '') as storage_path
|
pgStr = `SELECT cast(storage_cids.block_number AS TEXT), storage_cids.cid, state_cids.state_leaf_key, storage_cids.storage_leaf_key, storage_cids.node_type, storage_cids.storage_path
|
||||||
FROM eth.storage_cids, eth.state_cids, eth.header_cids
|
FROM eth.storage_cids, eth.state_cids, eth.header_cids
|
||||||
WHERE (storage_cids.state_path, storage_cids.header_id) = (state_cids.state_path, state_cids.header_id)
|
WHERE (storage_cids.state_path, storage_cids.header_id) = (state_cids.state_path, state_cids.header_id)
|
||||||
AND state_cids.header_id = header_cids.block_hash
|
AND state_cids.header_id = header_cids.block_hash
|
||||||
|
@ -22,7 +22,7 @@ var (
|
|||||||
db sql.Database
|
db sql.Database
|
||||||
err error
|
err error
|
||||||
ind interfaces.StateDiffIndexer
|
ind interfaces.StateDiffIndexer
|
||||||
ipfsPgGet = `SELECT COALESCE(data, '') as data FROM public.blocks
|
ipfsPgGet = `SELECT data FROM public.blocks
|
||||||
WHERE key = $1 AND block_number = $2`
|
WHERE key = $1 AND block_number = $2`
|
||||||
tx1, tx2, tx3, tx4, tx5, rct1, rct2, rct3, rct4, rct5 []byte
|
tx1, tx2, tx3, tx4, tx5, rct1, rct2, rct3, rct4, rct5 []byte
|
||||||
mockBlock *types.Block
|
mockBlock *types.Block
|
||||||
|
@ -257,7 +257,7 @@ func TestPGXIndexer(t *testing.T) {
|
|||||||
AND transaction_cids.header_id = header_cids.block_hash
|
AND transaction_cids.header_id = header_cids.block_hash
|
||||||
AND header_cids.block_number = $1
|
AND header_cids.block_number = $1
|
||||||
ORDER BY transaction_cids.index`
|
ORDER BY transaction_cids.index`
|
||||||
logsPgStr := `SELECT log_cids.index, log_cids.address, COALESCE(log_cids.topic0, '') as topic0, COALESCE(log_cids.topic1, '') as topic1, data FROM eth.log_cids
|
logsPgStr := `SELECT log_cids.index, log_cids.address, log_cids.topic0, log_cids.topic1, data FROM eth.log_cids
|
||||||
INNER JOIN eth.receipt_cids ON (log_cids.rct_id = receipt_cids.tx_id)
|
INNER JOIN eth.receipt_cids ON (log_cids.rct_id = receipt_cids.tx_id)
|
||||||
INNER JOIN public.blocks ON (log_cids.leaf_mh_key = blocks.key)
|
INNER JOIN public.blocks ON (log_cids.leaf_mh_key = blocks.key)
|
||||||
WHERE receipt_cids.leaf_cid = $1 ORDER BY eth.log_cids.index ASC`
|
WHERE receipt_cids.leaf_cid = $1 ORDER BY eth.log_cids.index ASC`
|
||||||
@ -328,7 +328,7 @@ func TestPGXIndexer(t *testing.T) {
|
|||||||
|
|
||||||
for idx, c := range rcts {
|
for idx, c := range rcts {
|
||||||
result := make([]models.IPLDModel, 0)
|
result := make([]models.IPLDModel, 0)
|
||||||
pgStr = `SELECT COALESCE(data, '') as data
|
pgStr = `SELECT data
|
||||||
FROM eth.receipt_cids
|
FROM eth.receipt_cids
|
||||||
INNER JOIN public.blocks ON (receipt_cids.leaf_mh_key = public.blocks.key)
|
INNER JOIN public.blocks ON (receipt_cids.leaf_mh_key = public.blocks.key)
|
||||||
WHERE receipt_cids.leaf_cid = $1`
|
WHERE receipt_cids.leaf_cid = $1`
|
||||||
@ -359,7 +359,7 @@ func TestPGXIndexer(t *testing.T) {
|
|||||||
t.Fatal(err)
|
t.Fatal(err)
|
||||||
}
|
}
|
||||||
|
|
||||||
postStatePgStr := `SELECT COALESCE(post_state, '') as post_state FROM eth.receipt_cids WHERE leaf_cid = $1`
|
postStatePgStr := `SELECT post_state FROM eth.receipt_cids WHERE leaf_cid = $1`
|
||||||
switch c {
|
switch c {
|
||||||
case rct1CID.String():
|
case rct1CID.String():
|
||||||
require.Equal(t, rctLeaf1, data)
|
require.Equal(t, rctLeaf1, data)
|
||||||
@ -412,7 +412,7 @@ func TestPGXIndexer(t *testing.T) {
|
|||||||
defer checkTxClosure(t, 1, 0, 1)
|
defer checkTxClosure(t, 1, 0, 1)
|
||||||
// check that state nodes were properly indexed and published
|
// check that state nodes were properly indexed and published
|
||||||
stateNodes := make([]models.StateNodeModel, 0)
|
stateNodes := make([]models.StateNodeModel, 0)
|
||||||
pgStr := `SELECT state_cids.cid, state_cids.state_leaf_key, state_cids.node_type, COALESCE(state_cids.state_path, '') as state_path, state_cids.header_id
|
pgStr := `SELECT state_cids.cid, state_cids.state_leaf_key, state_cids.node_type, state_cids.state_path, state_cids.header_id
|
||||||
FROM eth.state_cids INNER JOIN eth.header_cids ON (state_cids.header_id = header_cids.block_hash)
|
FROM eth.state_cids INNER JOIN eth.header_cids ON (state_cids.header_id = header_cids.block_hash)
|
||||||
WHERE header_cids.block_number = $1 AND node_type != 3`
|
WHERE header_cids.block_number = $1 AND node_type != 3`
|
||||||
err = db.Select(context.Background(), &stateNodes, pgStr, mocks.BlockNumber.Uint64())
|
err = db.Select(context.Background(), &stateNodes, pgStr, mocks.BlockNumber.Uint64())
|
||||||
@ -432,7 +432,7 @@ func TestPGXIndexer(t *testing.T) {
|
|||||||
if err != nil {
|
if err != nil {
|
||||||
t.Fatal(err)
|
t.Fatal(err)
|
||||||
}
|
}
|
||||||
pgStr = `SELECT cast(block_number AS TEXT), header_id, state_path, cast(balance AS TEXT), nonce, COALESCE(code_hash, '') as code_hash, storage_root from eth.state_accounts WHERE header_id = $1 AND state_path = $2`
|
pgStr = `SELECT cast(block_number AS TEXT), header_id, state_path, cast(balance AS TEXT), nonce, code_hash, storage_root from eth.state_accounts WHERE header_id = $1 AND state_path = $2`
|
||||||
var account models.StateAccountModel
|
var account models.StateAccountModel
|
||||||
err = db.Get(context.Background(), &account, pgStr, stateNode.HeaderID, stateNode.Path)
|
err = db.Get(context.Background(), &account, pgStr, stateNode.HeaderID, stateNode.Path)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
@ -472,7 +472,7 @@ func TestPGXIndexer(t *testing.T) {
|
|||||||
|
|
||||||
// check that Removed state nodes were properly indexed and published
|
// check that Removed state nodes were properly indexed and published
|
||||||
stateNodes = make([]models.StateNodeModel, 0)
|
stateNodes = make([]models.StateNodeModel, 0)
|
||||||
pgStr = `SELECT state_cids.cid, state_cids.state_leaf_key, state_cids.node_type, COALESCE(state_cids.state_path, '') as state_path, state_cids.header_id
|
pgStr = `SELECT state_cids.cid, state_cids.state_leaf_key, state_cids.node_type, state_cids.state_path, state_cids.header_id
|
||||||
FROM eth.state_cids INNER JOIN eth.header_cids ON (state_cids.header_id = header_cids.block_hash)
|
FROM eth.state_cids INNER JOIN eth.header_cids ON (state_cids.header_id = header_cids.block_hash)
|
||||||
WHERE header_cids.block_number = $1 AND node_type = 3`
|
WHERE header_cids.block_number = $1 AND node_type = 3`
|
||||||
err = db.Select(context.Background(), &stateNodes, pgStr, mocks.BlockNumber.Uint64())
|
err = db.Select(context.Background(), &stateNodes, pgStr, mocks.BlockNumber.Uint64())
|
||||||
@ -515,7 +515,7 @@ func TestPGXIndexer(t *testing.T) {
|
|||||||
defer checkTxClosure(t, 1, 0, 1)
|
defer checkTxClosure(t, 1, 0, 1)
|
||||||
// check that storage nodes were properly indexed
|
// check that storage nodes were properly indexed
|
||||||
storageNodes := make([]models.StorageNodeWithStateKeyModel, 0)
|
storageNodes := make([]models.StorageNodeWithStateKeyModel, 0)
|
||||||
pgStr := `SELECT cast(storage_cids.block_number AS TEXT), storage_cids.cid, state_cids.state_leaf_key, storage_cids.storage_leaf_key, storage_cids.node_type, COALESCE(storage_cids.storage_path, '') as storage_path
|
pgStr := `SELECT cast(storage_cids.block_number AS TEXT), storage_cids.cid, state_cids.state_leaf_key, storage_cids.storage_leaf_key, storage_cids.node_type, storage_cids.storage_path
|
||||||
FROM eth.storage_cids, eth.state_cids, eth.header_cids
|
FROM eth.storage_cids, eth.state_cids, eth.header_cids
|
||||||
WHERE (storage_cids.state_path, storage_cids.header_id) = (state_cids.state_path, state_cids.header_id)
|
WHERE (storage_cids.state_path, storage_cids.header_id) = (state_cids.state_path, state_cids.header_id)
|
||||||
AND state_cids.header_id = header_cids.block_hash
|
AND state_cids.header_id = header_cids.block_hash
|
||||||
@ -549,7 +549,7 @@ func TestPGXIndexer(t *testing.T) {
|
|||||||
|
|
||||||
// check that Removed storage nodes were properly indexed
|
// check that Removed storage nodes were properly indexed
|
||||||
storageNodes = make([]models.StorageNodeWithStateKeyModel, 0)
|
storageNodes = make([]models.StorageNodeWithStateKeyModel, 0)
|
||||||
pgStr = `SELECT cast(storage_cids.block_number AS TEXT), storage_cids.cid, state_cids.state_leaf_key, storage_cids.storage_leaf_key, storage_cids.node_type, COALESCE(storage_cids.storage_path, '') as storage_path
|
pgStr = `SELECT cast(storage_cids.block_number AS TEXT), storage_cids.cid, state_cids.state_leaf_key, storage_cids.storage_leaf_key, storage_cids.node_type, storage_cids.storage_path
|
||||||
FROM eth.storage_cids, eth.state_cids, eth.header_cids
|
FROM eth.storage_cids, eth.state_cids, eth.header_cids
|
||||||
WHERE (storage_cids.state_path, storage_cids.header_id) = (state_cids.state_path, state_cids.header_id)
|
WHERE (storage_cids.state_path, storage_cids.header_id) = (state_cids.state_path, state_cids.header_id)
|
||||||
AND state_cids.header_id = header_cids.block_hash
|
AND state_cids.header_id = header_cids.block_hash
|
||||||
|
@ -40,25 +40,25 @@ type DB struct {
|
|||||||
func (db *DB) InsertHeaderStm() string {
|
func (db *DB) InsertHeaderStm() string {
|
||||||
return `INSERT INTO eth.header_cids (block_number, block_hash, parent_hash, cid, td, node_id, reward, state_root, tx_root, receipt_root, uncle_root, bloom, timestamp, mh_key, times_validated, coinbase)
|
return `INSERT INTO eth.header_cids (block_number, block_hash, parent_hash, cid, td, node_id, reward, state_root, tx_root, receipt_root, uncle_root, bloom, timestamp, mh_key, times_validated, coinbase)
|
||||||
VALUES ($1, $2, $3, $4, $5, $6, $7, $8, $9, $10, $11, $12, $13, $14, $15, $16)
|
VALUES ($1, $2, $3, $4, $5, $6, $7, $8, $9, $10, $11, $12, $13, $14, $15, $16)
|
||||||
ON CONFLICT DO NOTHING`
|
ON CONFLICT (block_hash, block_number) DO UPDATE SET (parent_hash, cid, td, node_id, reward, state_root, tx_root, receipt_root, uncle_root, bloom, timestamp, mh_key, times_validated, coinbase) = ($3, $4, $5, $6, $7, $8, $9, $10, $11, $12, $13, $14, eth.header_cids.times_validated + 1, $16)`
|
||||||
}
|
}
|
||||||
|
|
||||||
// InsertUncleStm satisfies the sql.Statements interface
|
// InsertUncleStm satisfies the sql.Statements interface
|
||||||
func (db *DB) InsertUncleStm() string {
|
func (db *DB) InsertUncleStm() string {
|
||||||
return `INSERT INTO eth.uncle_cids (block_number, block_hash, header_id, parent_hash, cid, reward, mh_key) VALUES ($1, $2, $3, $4, $5, $6, $7)
|
return `INSERT INTO eth.uncle_cids (block_number, block_hash, header_id, parent_hash, cid, reward, mh_key) VALUES ($1, $2, $3, $4, $5, $6, $7)
|
||||||
ON CONFLICT DO NOTHING`
|
ON CONFLICT (block_hash, block_number) DO NOTHING`
|
||||||
}
|
}
|
||||||
|
|
||||||
// InsertTxStm satisfies the sql.Statements interface
|
// InsertTxStm satisfies the sql.Statements interface
|
||||||
func (db *DB) InsertTxStm() string {
|
func (db *DB) InsertTxStm() string {
|
||||||
return `INSERT INTO eth.transaction_cids (block_number, header_id, tx_hash, cid, dst, src, index, mh_key, tx_data, tx_type, value) VALUES ($1, $2, $3, $4, $5, $6, $7, $8, $9, $10, $11)
|
return `INSERT INTO eth.transaction_cids (block_number, header_id, tx_hash, cid, dst, src, index, mh_key, tx_data, tx_type, value) VALUES ($1, $2, $3, $4, $5, $6, $7, $8, $9, $10, $11)
|
||||||
ON CONFLICT DO NOTHING`
|
ON CONFLICT (tx_hash, block_number) DO NOTHING`
|
||||||
}
|
}
|
||||||
|
|
||||||
// InsertAccessListElementStm satisfies the sql.Statements interface
|
// InsertAccessListElementStm satisfies the sql.Statements interface
|
||||||
func (db *DB) InsertAccessListElementStm() string {
|
func (db *DB) InsertAccessListElementStm() string {
|
||||||
return `INSERT INTO eth.access_list_elements (block_number, tx_id, index, address, storage_keys) VALUES ($1, $2, $3, $4, $5)
|
return `INSERT INTO eth.access_list_elements (block_number, tx_id, index, address, storage_keys) VALUES ($1, $2, $3, $4, $5)
|
||||||
ON CONFLICT DO NOTHING`
|
ON CONFLICT (tx_id, index, block_number) DO NOTHING`
|
||||||
}
|
}
|
||||||
|
|
||||||
// InsertRctStm satisfies the sql.Statements interface
|
// InsertRctStm satisfies the sql.Statements interface
|
||||||
@ -70,13 +70,13 @@ func (db *DB) InsertRctStm() string {
|
|||||||
// InsertLogStm satisfies the sql.Statements interface
|
// InsertLogStm satisfies the sql.Statements interface
|
||||||
func (db *DB) InsertLogStm() string {
|
func (db *DB) InsertLogStm() string {
|
||||||
return `INSERT INTO eth.log_cids (block_number, leaf_cid, leaf_mh_key, rct_id, address, index, topic0, topic1, topic2, topic3, log_data) VALUES ($1, $2, $3, $4, $5, $6, $7, $8, $9, $10, $11)
|
return `INSERT INTO eth.log_cids (block_number, leaf_cid, leaf_mh_key, rct_id, address, index, topic0, topic1, topic2, topic3, log_data) VALUES ($1, $2, $3, $4, $5, $6, $7, $8, $9, $10, $11)
|
||||||
ON CONFLICT DO NOTHING`
|
ON CONFLICT (rct_id, index, block_number) DO NOTHING`
|
||||||
}
|
}
|
||||||
|
|
||||||
// InsertStateStm satisfies the sql.Statements interface
|
// InsertStateStm satisfies the sql.Statements interface
|
||||||
func (db *DB) InsertStateStm() string {
|
func (db *DB) InsertStateStm() string {
|
||||||
return `INSERT INTO eth.state_cids (block_number, header_id, state_leaf_key, cid, state_path, node_type, diff, mh_key) VALUES ($1, $2, $3, $4, $5, $6, $7, $8)
|
return `INSERT INTO eth.state_cids (block_number, header_id, state_leaf_key, cid, state_path, node_type, diff, mh_key) VALUES ($1, $2, $3, $4, $5, $6, $7, $8)
|
||||||
ON CONFLICT DO NOTHING`
|
ON CONFLICT (header_id, state_path, block_number) DO UPDATE SET (block_number, state_leaf_key, cid, node_type, diff, mh_key) = ($1, $3, $4, $6, $7, $8)`
|
||||||
}
|
}
|
||||||
|
|
||||||
// InsertAccountStm satisfies the sql.Statements interface
|
// InsertAccountStm satisfies the sql.Statements interface
|
||||||
|
@ -253,7 +253,7 @@ func TestSQLXIndexer(t *testing.T) {
|
|||||||
AND transaction_cids.header_id = header_cids.block_hash
|
AND transaction_cids.header_id = header_cids.block_hash
|
||||||
AND header_cids.block_number = $1
|
AND header_cids.block_number = $1
|
||||||
ORDER BY transaction_cids.index`
|
ORDER BY transaction_cids.index`
|
||||||
logsPgStr := `SELECT log_cids.index, log_cids.address, COALESCE(log_cids.topic0, '') as topic0, COALESCE(log_cids.topic1, '') as topic1, data FROM eth.log_cids
|
logsPgStr := `SELECT log_cids.index, log_cids.address, log_cids.topic0, log_cids.topic1, data FROM eth.log_cids
|
||||||
INNER JOIN eth.receipt_cids ON (log_cids.rct_id = receipt_cids.tx_id)
|
INNER JOIN eth.receipt_cids ON (log_cids.rct_id = receipt_cids.tx_id)
|
||||||
INNER JOIN public.blocks ON (log_cids.leaf_mh_key = blocks.key)
|
INNER JOIN public.blocks ON (log_cids.leaf_mh_key = blocks.key)
|
||||||
WHERE receipt_cids.leaf_cid = $1 ORDER BY eth.log_cids.index ASC`
|
WHERE receipt_cids.leaf_cid = $1 ORDER BY eth.log_cids.index ASC`
|
||||||
@ -322,7 +322,7 @@ func TestSQLXIndexer(t *testing.T) {
|
|||||||
|
|
||||||
for idx, c := range rcts {
|
for idx, c := range rcts {
|
||||||
result := make([]models.IPLDModel, 0)
|
result := make([]models.IPLDModel, 0)
|
||||||
pgStr = `SELECT COALESCE(data, '') as data
|
pgStr = `SELECT data
|
||||||
FROM eth.receipt_cids
|
FROM eth.receipt_cids
|
||||||
INNER JOIN public.blocks ON (receipt_cids.leaf_mh_key = public.blocks.key)
|
INNER JOIN public.blocks ON (receipt_cids.leaf_mh_key = public.blocks.key)
|
||||||
WHERE receipt_cids.leaf_cid = $1`
|
WHERE receipt_cids.leaf_cid = $1`
|
||||||
@ -352,7 +352,7 @@ func TestSQLXIndexer(t *testing.T) {
|
|||||||
if err != nil {
|
if err != nil {
|
||||||
t.Fatal(err)
|
t.Fatal(err)
|
||||||
}
|
}
|
||||||
postStatePgStr := `SELECT COALESCE(post_state, '') as post_state FROM eth.receipt_cids WHERE leaf_cid = $1`
|
postStatePgStr := `SELECT post_state FROM eth.receipt_cids WHERE leaf_cid = $1`
|
||||||
switch c {
|
switch c {
|
||||||
case rct1CID.String():
|
case rct1CID.String():
|
||||||
require.Equal(t, rctLeaf1, data)
|
require.Equal(t, rctLeaf1, data)
|
||||||
@ -405,7 +405,7 @@ func TestSQLXIndexer(t *testing.T) {
|
|||||||
defer checkTxClosure(t, 0, 0, 0)
|
defer checkTxClosure(t, 0, 0, 0)
|
||||||
// check that state nodes were properly indexed and published
|
// check that state nodes were properly indexed and published
|
||||||
stateNodes := make([]models.StateNodeModel, 0)
|
stateNodes := make([]models.StateNodeModel, 0)
|
||||||
pgStr := `SELECT state_cids.cid, state_cids.state_leaf_key, state_cids.node_type, COALESCE(state_cids.state_path, '') as state_path, state_cids.header_id
|
pgStr := `SELECT state_cids.cid, state_cids.state_leaf_key, state_cids.node_type, state_cids.state_path, state_cids.header_id
|
||||||
FROM eth.state_cids INNER JOIN eth.header_cids ON (state_cids.header_id = header_cids.block_hash)
|
FROM eth.state_cids INNER JOIN eth.header_cids ON (state_cids.header_id = header_cids.block_hash)
|
||||||
WHERE header_cids.block_number = $1 AND node_type != 3`
|
WHERE header_cids.block_number = $1 AND node_type != 3`
|
||||||
err = db.Select(context.Background(), &stateNodes, pgStr, mocks.BlockNumber.Uint64())
|
err = db.Select(context.Background(), &stateNodes, pgStr, mocks.BlockNumber.Uint64())
|
||||||
@ -465,7 +465,7 @@ func TestSQLXIndexer(t *testing.T) {
|
|||||||
|
|
||||||
// check that Removed state nodes were properly indexed and published
|
// check that Removed state nodes were properly indexed and published
|
||||||
stateNodes = make([]models.StateNodeModel, 0)
|
stateNodes = make([]models.StateNodeModel, 0)
|
||||||
pgStr = `SELECT state_cids.cid, state_cids.state_leaf_key, state_cids.node_type, COALESCE(state_cids.state_path, '') as state_path, state_cids.header_id
|
pgStr = `SELECT state_cids.cid, state_cids.state_leaf_key, state_cids.node_type, state_cids.state_path, state_cids.header_id
|
||||||
FROM eth.state_cids INNER JOIN eth.header_cids ON (state_cids.header_id = header_cids.block_hash)
|
FROM eth.state_cids INNER JOIN eth.header_cids ON (state_cids.header_id = header_cids.block_hash)
|
||||||
WHERE header_cids.block_number = $1 AND node_type = 3`
|
WHERE header_cids.block_number = $1 AND node_type = 3`
|
||||||
err = db.Select(context.Background(), &stateNodes, pgStr, mocks.BlockNumber.Uint64())
|
err = db.Select(context.Background(), &stateNodes, pgStr, mocks.BlockNumber.Uint64())
|
||||||
@ -508,7 +508,7 @@ func TestSQLXIndexer(t *testing.T) {
|
|||||||
defer checkTxClosure(t, 0, 0, 0)
|
defer checkTxClosure(t, 0, 0, 0)
|
||||||
// check that storage nodes were properly indexed
|
// check that storage nodes were properly indexed
|
||||||
storageNodes := make([]models.StorageNodeWithStateKeyModel, 0)
|
storageNodes := make([]models.StorageNodeWithStateKeyModel, 0)
|
||||||
pgStr := `SELECT cast(storage_cids.block_number AS TEXT), storage_cids.cid, state_cids.state_leaf_key, storage_cids.storage_leaf_key, storage_cids.node_type, COALESCE(storage_cids.storage_path, '') as storage_path
|
pgStr := `SELECT cast(storage_cids.block_number AS TEXT), storage_cids.cid, state_cids.state_leaf_key, storage_cids.storage_leaf_key, storage_cids.node_type, storage_cids.storage_path
|
||||||
FROM eth.storage_cids, eth.state_cids, eth.header_cids
|
FROM eth.storage_cids, eth.state_cids, eth.header_cids
|
||||||
WHERE (storage_cids.state_path, storage_cids.header_id) = (state_cids.state_path, state_cids.header_id)
|
WHERE (storage_cids.state_path, storage_cids.header_id) = (state_cids.state_path, state_cids.header_id)
|
||||||
AND state_cids.header_id = header_cids.block_hash
|
AND state_cids.header_id = header_cids.block_hash
|
||||||
@ -542,7 +542,7 @@ func TestSQLXIndexer(t *testing.T) {
|
|||||||
|
|
||||||
// check that Removed storage nodes were properly indexed
|
// check that Removed storage nodes were properly indexed
|
||||||
storageNodes = make([]models.StorageNodeWithStateKeyModel, 0)
|
storageNodes = make([]models.StorageNodeWithStateKeyModel, 0)
|
||||||
pgStr = `SELECT cast(storage_cids.block_number AS TEXT), storage_cids.cid, state_cids.state_leaf_key, storage_cids.storage_leaf_key, storage_cids.node_type, COALESCE(storage_cids.storage_path, '') as storage_path
|
pgStr = `SELECT cast(storage_cids.block_number AS TEXT), storage_cids.cid, state_cids.state_leaf_key, storage_cids.storage_leaf_key, storage_cids.node_type, storage_cids.storage_path
|
||||||
FROM eth.storage_cids, eth.state_cids, eth.header_cids
|
FROM eth.storage_cids, eth.state_cids, eth.header_cids
|
||||||
WHERE (storage_cids.state_path, storage_cids.header_id) = (state_cids.state_path, state_cids.header_id)
|
WHERE (storage_cids.state_path, storage_cids.header_id) = (state_cids.state_path, state_cids.header_id)
|
||||||
AND state_cids.header_id = header_cids.block_hash
|
AND state_cids.header_id = header_cids.block_hash
|
||||||
|
Loading…
Reference in New Issue
Block a user