(VDB-354) Queue unrecognized storage diffs
- If we recognize a storage diff as coming from a watched contract but don't recognize the key, queue it for retrying later (after we've seen an event that might help us recognize the key) - Remove unused errs and args - Panic on unrecognized types (should not happen)
This commit is contained in:
@@ -17,6 +17,7 @@
|
||||
package shared
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"github.com/ethereum/go-ethereum/common"
|
||||
"math/big"
|
||||
)
|
||||
@@ -30,7 +31,7 @@ func Decode(row StorageDiffRow, metadata StorageValueMetadata) (interface{}, err
|
||||
case Bytes32:
|
||||
return row.StorageValue.Hex(), nil
|
||||
default:
|
||||
return nil, ErrTypeNotFound{}
|
||||
panic(fmt.Sprintf("can't decode unknown type: %d", metadata.Type))
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -46,13 +46,4 @@ var _ = Describe("Storage decoder", func() {
|
||||
Expect(err).NotTo(HaveOccurred())
|
||||
Expect(result).To(Equal(fakeAddress.Hex()))
|
||||
})
|
||||
|
||||
It("returns error if attempting to decode unknown type", func() {
|
||||
metadata := shared.StorageValueMetadata{Type: 100}
|
||||
|
||||
_, err := shared.Decode(shared.StorageDiffRow{}, metadata)
|
||||
|
||||
Expect(err).To(HaveOccurred())
|
||||
Expect(err).To(MatchError(shared.ErrTypeNotFound{}))
|
||||
})
|
||||
})
|
||||
|
||||
@@ -28,16 +28,6 @@ func (e ErrContractNotFound) Error() string {
|
||||
return fmt.Sprintf("transformer not found for contract: %s", e.Contract)
|
||||
}
|
||||
|
||||
type ErrHeaderMismatch struct {
|
||||
BlockHeight int
|
||||
DbHash string
|
||||
DiffHash string
|
||||
}
|
||||
|
||||
func (e ErrHeaderMismatch) Error() string {
|
||||
return fmt.Sprintf("header hash in row does not match db at height %d - row: %s, db: %s", e.BlockHeight, e.DbHash, e.DiffHash)
|
||||
}
|
||||
|
||||
type ErrMetadataMalformed struct {
|
||||
MissingData Key
|
||||
}
|
||||
@@ -61,11 +51,3 @@ type ErrStorageKeyNotFound struct {
|
||||
func (e ErrStorageKeyNotFound) Error() string {
|
||||
return fmt.Sprintf("unknown storage key: %s", e.Key)
|
||||
}
|
||||
|
||||
type ErrTypeNotFound struct {
|
||||
Type int
|
||||
}
|
||||
|
||||
func (e ErrTypeNotFound) Error() string {
|
||||
return fmt.Sprintf("no decoder for type: %d", e.Type)
|
||||
}
|
||||
|
||||
@@ -25,10 +25,10 @@ const ExpectedRowLength = 5
|
||||
|
||||
type StorageDiffRow struct {
|
||||
Contract common.Address
|
||||
BlockHash common.Hash
|
||||
BlockHeight int
|
||||
StorageKey common.Hash
|
||||
StorageValue common.Hash
|
||||
BlockHash common.Hash `db:"block_hash"`
|
||||
BlockHeight int `db:"block_height"`
|
||||
StorageKey common.Hash `db:"storage_key"`
|
||||
StorageValue common.Hash `db:"storage_value"`
|
||||
}
|
||||
|
||||
func FromStrings(csvRow []string) (StorageDiffRow, error) {
|
||||
|
||||
Reference in New Issue
Block a user