update code

This commit is contained in:
Roy Crihfield 2024-04-24 19:28:57 +08:00
parent 4105ddb7e1
commit 4cabfc65ad
2 changed files with 14 additions and 7 deletions

View File

@ -10,7 +10,8 @@ import (
"github.com/cerc-io/plugeth-statediff/utils" "github.com/cerc-io/plugeth-statediff/utils"
"github.com/ethereum/go-ethereum/common" "github.com/ethereum/go-ethereum/common"
"github.com/ethereum/go-ethereum/params" "github.com/ethereum/go-ethereum/params"
"github.com/ethereum/go-ethereum/trie" "github.com/ethereum/go-ethereum/triedb"
"github.com/ethereum/go-ethereum/triedb/hashdb"
"github.com/spf13/viper" "github.com/spf13/viper"
pkg "github.com/cerc-io/eth-statediff-service/pkg" pkg "github.com/cerc-io/eth-statediff-service/pkg"
@ -117,10 +118,12 @@ func instantiateLevelDBReader() (pkg.Reader, *params.ChainConfig, node.Info) {
// create LevelDB reader // create LevelDB reader
logWithCommand.Debug("Creating LevelDB reader") logWithCommand.Debug("Creating LevelDB reader")
readerConf := pkg.LvLDBReaderConfig{ readerConf := pkg.LvLDBReaderConfig{
TrieConfig: &trie.Config{ TrieConfig: &triedb.Config{
Cache: viper.GetInt("cache.trie"),
Journal: "",
Preimages: false, Preimages: false,
IsVerkle: false,
HashDB: &hashdb.Config{
CleanCacheSize: viper.GetInt("cache.trie"),
},
}, },
ChainConfig: chainConf, ChainConfig: chainConf,
Mode: mode, Mode: mode,

View File

@ -27,7 +27,7 @@ import (
"github.com/ethereum/go-ethereum/core/types" "github.com/ethereum/go-ethereum/core/types"
"github.com/ethereum/go-ethereum/ethdb" "github.com/ethereum/go-ethereum/ethdb"
"github.com/ethereum/go-ethereum/params" "github.com/ethereum/go-ethereum/params"
"github.com/ethereum/go-ethereum/trie" "github.com/ethereum/go-ethereum/triedb"
) )
// Reader interface required by the statediffing service // Reader interface required by the statediffing service
@ -49,7 +49,7 @@ type LvlDBReader struct {
// LvLDBReaderConfig struct for initializing a LvlDBReader // LvLDBReaderConfig struct for initializing a LvlDBReader
type LvLDBReaderConfig struct { type LvLDBReaderConfig struct {
TrieConfig *trie.Config TrieConfig *triedb.Config
ChainConfig *params.ChainConfig ChainConfig *params.ChainConfig
Mode string Mode string
Path, AncientPath, Url string Path, AncientPath, Url string
@ -114,7 +114,11 @@ func (ldr *LvlDBReader) GetReceiptsByHash(hash common.Hash) (types.Receipts, err
if number == nil { if number == nil {
return nil, fmt.Errorf("unable to read header height for header hash %s", hash) return nil, fmt.Errorf("unable to read header height for header hash %s", hash)
} }
receipts := rawdb.ReadReceipts(ldr.ethDB, hash, *number, ldr.chainConfig) header := rawdb.ReadHeader(ldr.ethDB, hash, *number)
if header == nil {
return nil, fmt.Errorf("unable to read header for header hash %s", hash)
}
receipts := rawdb.ReadReceipts(ldr.ethDB, hash, *number, header.Time, ldr.chainConfig)
if receipts == nil { if receipts == nil {
return nil, fmt.Errorf("unable to read receipts at height %d hash %s", number, hash) return nil, fmt.Errorf("unable to read receipts at height %d hash %s", number, hash)
} }