diff --git a/statediff/types/types.go b/statediff/types/types.go index 8a6ee0302..0ae9518db 100644 --- a/statediff/types/types.go +++ b/statediff/types/types.go @@ -30,10 +30,10 @@ type StateRoots struct { // StateObject is the final output structure from the builder type StateObject struct { - BlockNumber *big.Int `json:"blockNumber" gencodec:"required"` - BlockHash common.Hash `json:"blockHash" gencodec:"required"` - Nodes []StateNode `json:"nodes" gencodec:"required"` - CodeAndCodeHashes []CodeAndCodeHash `json:"codeMapping"` + BlockNumber *big.Int `json:"blockNumber" gencodec:"required"` + BlockHash common.Hash `json:"blockHash" gencodec:"required"` + Nodes []StateLeafNode `json:"nodes" gencodec:"required"` + IPLDs []IPLD `json:"iplds"` } // AccountMap is a mapping of hex encoded path => account wrapper @@ -41,39 +41,35 @@ type AccountMap map[string]AccountWrapper // AccountWrapper is used to temporary associate the unpacked node with its raw values type AccountWrapper struct { - Account *types.StateAccount - Removed bool - LeafKey []byte - LeafNodeHash []byte + Account *types.StateAccount + LeafKey []byte + NodeHash []byte } -// StateNode holds the data for a single state diff node -type StateNode struct { - Removed bool `json:"removed" gencodec:"required"` - NodeValue []byte `json:"value" gencodec:"required"` - StorageNodes []StorageNode `json:"storage"` - LeafKey []byte `json:"leafKey"` - NodeHash []byte `json:"hash"` +// StateLeafNode holds the data for a single state diff leaf node +type StateLeafNode struct { + Removed bool + AccountWrapper AccountWrapper + StorageDiff []StorageLeafNode } -// StorageNode holds the data for a single storage diff node -type StorageNode struct { - Removed bool `json:"removed" gencodec:"required"` - NodeValue []byte `json:"value" gencodec:"required"` - LeafKey []byte `json:"leafKey"` - NodeHash []byte `json:"hash"` +// StorageLeafNode holds the data for a single storage diff node leaf node +type StorageLeafNode struct { + Removed bool + Value []byte + LeafKey []byte + NodeHash []byte } -// CodeAndCodeHash struct for holding codehash => code mappings -// we can't use an actual map because they are not rlp serializable -type CodeAndCodeHash struct { - Hash common.Hash `json:"codeHash"` - Code []byte `json:"code"` +// IPLD holds a cid:content pair, e.g. for codehash to code mappings or for intermediate node IPLD objects +type IPLD struct { + CID string + Content []byte } -type StateNodeSink func(StateNode) error -type StorageNodeSink func(StorageNode) error -type CodeSink func(CodeAndCodeHash) error +type StateNodeSink func(node StateLeafNode) error +type StorageNodeSink func(node StorageLeafNode) error +type IPLDSink func(IPLD) error // OperationType for type of WatchAddress operation type OperationType string