fix for difficult to identify bug due to block_num arg being overriden by optimistic get_storage_at path which then can mess up the pessimistic path in very particular scenarios
This commit is contained in:
parent
f354dca32d
commit
31aec61d7e
@ -31,8 +31,8 @@ var (
|
||||
// block four: non-canonical block with non-canonical slot value is added to the database
|
||||
// block five: entire contract is destructed; another non-canonical block is created but it doesn't include an update for our slot
|
||||
// but it links back to the other non-canonical header (this is to test the ability to resolve canonicity by comparing how many
|
||||
// children reference back to a header
|
||||
// block six: canonical block only, no relevant state changes (check that we returned emptied result at heights where it wasn't emptied)
|
||||
// children reference back to a header)
|
||||
// block six: canonical block only, no relevant state changes (check that we still return emptied result at heights where it wasn't emptied)
|
||||
BlockNumber = big.NewInt(1337)
|
||||
Header = types.Header{Number: BlockNumber}
|
||||
BlockHash = Header.Hash()
|
||||
@ -83,7 +83,6 @@ var (
|
||||
StorageRLP, _ = rlp.EncodeToBytes(&[]interface{}{StoragePartialPath, StoredValueRLP})
|
||||
StorageCID, _ = ipld.RawdataToCid(ipld.MEthStorageTrie, StorageRLP, multihash.KECCAK_256)
|
||||
|
||||
|
||||
RemovedNodeStateCID = "baglacgzayxjemamg64rtzet6pwznzrydydsqbnstzkbcoo337lmaixmfurya"
|
||||
RemovedNodeStorageCID = "bagmacgzayxjemamg64rtzet6pwznzrydydsqbnstzkbcoo337lmaixmfurya"
|
||||
)
|
||||
@ -131,6 +130,18 @@ func TestSuite(t *testing.T) {
|
||||
StorageRoot: Account.Root.String(),
|
||||
Removed: false,
|
||||
}))
|
||||
require.NoError(t, insertStateCID(pool, stateModel{
|
||||
BlockNumber: NonCanonicalBlockNumber4,
|
||||
BlockHash: BlockHash4.String(),
|
||||
LeafKey: AccountLeafKey.String(),
|
||||
CID: AccountCID.String(),
|
||||
Diff: true,
|
||||
Balance: Account.Balance.Uint64(),
|
||||
Nonce: Account.Nonce,
|
||||
CodeHash: AccountCodeHash.String(),
|
||||
StorageRoot: Account.Root.String(),
|
||||
Removed: false,
|
||||
}))
|
||||
require.NoError(t, insertStateCID(pool, stateModel{
|
||||
BlockNumber: BlockNumber5,
|
||||
BlockHash: BlockHash5.String(),
|
||||
@ -169,6 +180,7 @@ func TestSuite(t *testing.T) {
|
||||
Value: StoredValueRLP2,
|
||||
Removed: false,
|
||||
}))
|
||||
// TODO: Add the state account records for every storage update, since updatign storage necessarily means the state account was updated to
|
||||
require.NoError(t, insertStorageCID(pool, storageModel{
|
||||
BlockNumber: BlockNumber4,
|
||||
BlockHash: NonCanonicalHash4.String(),
|
||||
@ -205,6 +217,7 @@ func TestSuite(t *testing.T) {
|
||||
require.NoError(t, err)
|
||||
require.Equal(t, &Account, acct3)
|
||||
|
||||
// check that we don't get the non-canonical account
|
||||
acct4, err := db.StateAccount(AccountLeafKey, BlockHash4)
|
||||
require.NoError(t, err)
|
||||
require.Equal(t, &Account, acct4)
|
||||
@ -234,9 +247,7 @@ func TestSuite(t *testing.T) {
|
||||
require.NoError(t, err)
|
||||
require.Equal(t, StoredValueRLP2, val4)
|
||||
|
||||
// TODO: how is this still returning StoredValueRLP2 when the account was destructed?
|
||||
// it was working before we added non-canonical blocks, so must be related
|
||||
// somehow the non-canonical records are messing up the ability to determine is a state account is removed
|
||||
// this checks that when the entire account was deleted, we return nil result for storage slot
|
||||
val5, err := db.StorageValue(AccountLeafKey, StorageLeafKey, BlockHash5)
|
||||
require.NoError(t, err)
|
||||
require.Nil(t, val5)
|
||||
@ -300,7 +311,6 @@ func insertHeaderCID(db *pgxpool.Pool, blockHash, parentHash string, blockNumber
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
println(cid.String())
|
||||
sql := `INSERT INTO eth.header_cids (
|
||||
block_number,
|
||||
block_hash,
|
||||
|
Loading…
Reference in New Issue
Block a user