clean up from PR review

This commit is contained in:
Roy Crihfield 2023-06-30 13:50:23 +08:00
parent fbc87c0410
commit 8fc463bfad
7 changed files with 5 additions and 52 deletions

View File

@ -242,9 +242,9 @@ track this process:
Our Postgres schemas are built around a single IPFS backing Postgres IPLD blockstore table
(`ipld.blocks`) that conforms with
[go-ds-sql](https://github.com/ipfs/go-ds-sql/blob/master/postgres/postgres.go). All IPLD objects
are stored in this table, where `key` is the blockstore-prefixed multihash key for the IPLD object
and `data` contains the bytes for the IPLD block (in the case of all Ethereum IPLDs, this is the RLP
byte encoding of the Ethereum object).
are stored in this table, where `key` is the CID for the IPLD object and `data` contains the bytes
for the IPLD block (in the case of all Ethereum IPLDs, this is the RLP byte encoding of the Ethereum
object).
The IPLD objects in this table can be traversed using an IPLD DAG interface, but since this table
only maps CID to raw IPLD object it is not very suitable for looking up Ethereum objects by their

1
api.go
View File

@ -29,7 +29,6 @@ import (
const APIName = "statediff"
// APIVersion is the version of the state diffing service API
// TODO: match package version?
const APIVersion = "0.0.1"
// PublicStateDiffAPI provides an RPC subscription interface

View File

@ -25,8 +25,6 @@ type BlockChain interface {
GetBlockByNumber(number uint64) *types.Block
GetReceiptsByHash(hash common.Hash) types.Receipts
GetTd(hash common.Hash, number uint64) *big.Int
// TODO LockTrie is never used
// UnlockTrie(root core.Hash)
StateCache() adapt.StateView
}
@ -49,8 +47,7 @@ func (b *pluginBlockChain) SubscribeChainEvent(ch chan<- core.ChainEvent) event.
go func() {
for event := range bufferChan {
block := utils.MustDecode[types.Block](event.Block)
// TODO: apparently we ignore the logs
// logs := utils.MustDecode[types.Log](chainEvent.Logs)
// Note: logs are processed with receipts while building the payload
ch <- core.ChainEvent{
Block: block,
Hash: common.Hash(event.Hash),

View File

@ -58,7 +58,7 @@ func processTransactions(txs []*types.Transaction) ([]*EthTx, error) {
// processReceiptsAndLogs will take in receipts
// to return IPLD node slices for eth-rct and eth-log
func processReceiptsAndLogs(rcts types.Receipts) ([]*EthReceipt, [][]*EthLog, error) {
func processReceiptsAndLogs(rcts []*types.Receipt) ([]*EthReceipt, [][]*EthLog, error) {
// Pre allocating memory.
ethRctNodes := make([]*EthReceipt, len(rcts))
ethLogNodes := make([][]*EthLog, len(rcts))
@ -81,31 +81,6 @@ func processReceiptsAndLogs(rcts types.Receipts) ([]*EthReceipt, [][]*EthLog, er
return ethRctNodes, ethLogNodes, nil
}
// // processReceiptsAndLogs will take in receipts
// // to return IPLD node slices for eth-rct and eth-log
// func processReceiptsAndLogs(rcts []*types.Receipt) ([]*EthReceipt, [][]*EthLog, error) {
// // Pre allocating memory.
// ethRctNodes := make([]*EthReceipt, len(rcts))
// ethLogNodes := make([][]*EthLog, len(rcts))
// for idx, rct := range rcts {
// logNodes, err := processLogs(rct.Logs)
// if err != nil {
// return nil, nil, err
// }
// ethRct, err := NewReceipt(rct)
// if err != nil {
// return nil, nil, err
// }
// ethRctNodes[idx] = ethRct
// ethLogNodes[idx] = logNodes
// }
// return ethRctNodes, ethLogNodes, nil
// }
func processLogs(logs []*types.Log) ([]*EthLog, error) {
logNodes := make([]*EthLog, len(logs))
for idx, log := range logs {

View File

@ -25,13 +25,6 @@ var (
func Initialize(ctx core.Context, pl core.PluginLoader, logger core.Logger) {
log.SetDefaultLogger(logger)
// lvl, err := strconv.ParseInt(ctx.String("verbosity"), 10, 8)
// if err != nil {
// log.Error("cannot parse verbosity", "error", err)
// }
// log.TestLogger.SetLevel(int(lvl))
// log.SetDefaultLogger(log.TestLogger)
pluginLoader = pl
gethContext = ctx

View File

@ -436,11 +436,6 @@ func (sds *Service) processStateDiff(currentBlock *types.Block, parentRoot commo
BlockHash: currentBlock.Hash(),
BlockNumber: currentBlock.Number(),
}, params)
// allow dereferencing of parent, keep current locked as it should be the next parent
// sds.BlockChain.UnlockTrie(parentRoot)
// if err != nil {
// return nil, err
// }
stateDiffRlp, err := rlp.EncodeToBytes(&stateDiff)
if err != nil {
return nil, err
@ -753,10 +748,6 @@ func (sds *Service) writeStateDiff(block *types.Block, parentRoot common.Hash, p
if err = tx.Submit(err); err != nil {
return fmt.Errorf("batch transaction submission failed: %w", err)
}
// allow dereferencing of parent, keep current locked as it should be the next parent
// TODO never locked
// sds.BlockChain.UnlockTrie(parentRoot)
return nil
}

View File

@ -149,8 +149,6 @@ func (bc *BlockChain) SetTd(hash common.Hash, blockNum uint64, td *big.Int) {
bc.TDByNum[blockNum] = td
}
// func (bc *BlockChain) UnlockTrie(root core.Hash) {}
// TODO
func (bc *BlockChain) StateCache() adapt.StateView {
return nil