linting and test fixes
This commit is contained in:
parent
970b7c8581
commit
57188bef8f
@ -139,7 +139,7 @@ type CacheConfig struct {
|
||||
|
||||
SnapshotNoBuild bool // Whether the background generation is allowed
|
||||
SnapshotWait bool // Wait for snapshot construction on startup. TODO(karalabe): This is a dirty hack for testing, nuke it
|
||||
StateDiffing bool // Whether or not the statediffing service is running
|
||||
StateDiffing bool // Whether the statediffing service is running
|
||||
}
|
||||
|
||||
// defaultCacheConfig are the default caching values if none are specified by the
|
||||
@ -982,8 +982,7 @@ func (bc *BlockChain) Stop() {
|
||||
}
|
||||
}
|
||||
for !bc.triegc.Empty() {
|
||||
pruneRootV := bc.triegc.PopItem()
|
||||
pruneRoot := (common.Hash)(pruneRootV)
|
||||
pruneRoot := bc.triegc.PopItem()
|
||||
if !bc.TrieLocked(pruneRoot) {
|
||||
triedb.Dereference(pruneRoot)
|
||||
}
|
||||
@ -1419,10 +1418,9 @@ func (bc *BlockChain) writeBlockWithState(block *types.Block, receipts []*types.
|
||||
bc.triegc.Push(root, number)
|
||||
break
|
||||
}
|
||||
pruneRoot := (common.Hash)(root)
|
||||
if !bc.TrieLocked(pruneRoot) {
|
||||
log.Debug("Dereferencing", "root", (common.Hash)(root).Hex())
|
||||
bc.triedb.Dereference(pruneRoot)
|
||||
if !bc.TrieLocked(root) {
|
||||
log.Debug("Dereferencing", "root", root.Hex())
|
||||
bc.triedb.Dereference(root)
|
||||
}
|
||||
}
|
||||
return nil
|
||||
@ -2514,7 +2512,7 @@ func (bc *BlockChain) SetTrieFlushInterval(interval time.Duration) {
|
||||
atomic.StoreInt64(&bc.flushInterval, int64(interval))
|
||||
}
|
||||
|
||||
// TrieLocked returns whether the trie associated with the provided root is locked for use
|
||||
// TrieLocked returns whether the trie associated with the provided root is locked for use
|
||||
func (bc *BlockChain) TrieLocked(root common.Hash) bool {
|
||||
bc.trieLock.Lock()
|
||||
locked, ok := bc.lockedRoots[root]
|
||||
|
@ -17,7 +17,7 @@
|
||||
package ipld
|
||||
|
||||
import (
|
||||
"io/ioutil"
|
||||
"os"
|
||||
"path/filepath"
|
||||
"testing"
|
||||
|
||||
@ -63,7 +63,7 @@ func loadBlockData(t *testing.T) []testCase {
|
||||
fileDir := "./eip2930_test_data"
|
||||
testCases := make([]testCase, len(blockFileNames))
|
||||
for i, blockFileName := range blockFileNames {
|
||||
blockRLP, err := ioutil.ReadFile(filepath.Join(fileDir, blockFileName))
|
||||
blockRLP, err := os.ReadFile(filepath.Join(fileDir, blockFileName))
|
||||
if err != nil {
|
||||
t.Fatalf("failed to load blockRLP from file, err %v", err)
|
||||
}
|
||||
@ -72,7 +72,7 @@ func loadBlockData(t *testing.T) []testCase {
|
||||
t.Fatalf("failed to decode blockRLP, err %v", err)
|
||||
}
|
||||
receiptsFileName := receiptsFileNames[i]
|
||||
receiptsRLP, err := ioutil.ReadFile(filepath.Join(fileDir, receiptsFileName))
|
||||
receiptsRLP, err := os.ReadFile(filepath.Join(fileDir, receiptsFileName))
|
||||
if err != nil {
|
||||
t.Fatalf("failed to load receiptsRLP from file, err %s", err)
|
||||
}
|
||||
|
@ -55,7 +55,6 @@ var (
|
||||
BaseFee: big.NewInt(params.InitialBaseFee),
|
||||
Coinbase: common.HexToAddress("0xaE9BEa628c4Ce503DcFD7E305CaB4e29E7476777"),
|
||||
}
|
||||
a = trie.Trie{}
|
||||
MockTransactions, MockReceipts, SenderAddr = createTransactionsAndReceipts(TestConfig, BlockNumber)
|
||||
MockBlock = types.NewBlock(&MockHeader, MockTransactions, nil, MockReceipts, trie.NewEmpty(nil))
|
||||
MockHeaderRlp, _ = rlp.EncodeToBytes(MockBlock.Header())
|
||||
|
@ -20,15 +20,13 @@ import (
|
||||
"bytes"
|
||||
"encoding/json"
|
||||
"fmt"
|
||||
"io/ioutil"
|
||||
"io"
|
||||
"log"
|
||||
"math/big"
|
||||
"os"
|
||||
"sort"
|
||||
"testing"
|
||||
|
||||
ipld2 "github.com/ethereum/go-ethereum/statediff/indexer/ipld"
|
||||
|
||||
"github.com/ethereum/go-ethereum/common"
|
||||
"github.com/ethereum/go-ethereum/consensus/ethash"
|
||||
"github.com/ethereum/go-ethereum/core"
|
||||
@ -37,9 +35,9 @@ import (
|
||||
"github.com/ethereum/go-ethereum/core/vm"
|
||||
"github.com/ethereum/go-ethereum/crypto"
|
||||
"github.com/ethereum/go-ethereum/ethdb"
|
||||
"github.com/ethereum/go-ethereum/params"
|
||||
"github.com/ethereum/go-ethereum/rlp"
|
||||
"github.com/ethereum/go-ethereum/statediff"
|
||||
ipld2 "github.com/ethereum/go-ethereum/statediff/indexer/ipld"
|
||||
"github.com/ethereum/go-ethereum/statediff/test_helpers"
|
||||
sdtypes "github.com/ethereum/go-ethereum/statediff/types"
|
||||
)
|
||||
@ -467,7 +465,7 @@ func loadBlockFromRLPFile(filename string) (*types.Block, []byte, error) {
|
||||
return nil, nil, err
|
||||
}
|
||||
defer f.Close()
|
||||
blockRLP, err := ioutil.ReadAll(f)
|
||||
blockRLP, err := io.ReadAll(f)
|
||||
if err != nil {
|
||||
return nil, nil, err
|
||||
}
|
||||
@ -476,7 +474,7 @@ func loadBlockFromRLPFile(filename string) (*types.Block, []byte, error) {
|
||||
}
|
||||
|
||||
func TestBuilderOnMainnetBlocks(t *testing.T) {
|
||||
chain, _ := core.NewBlockChain(db, nil, params.MainnetChainConfig, ethash.NewFaker(), vm.Config{}, nil, nil)
|
||||
chain, _ := core.NewBlockChain(db, nil, nil, nil, ethash.NewFaker(), vm.Config{}, nil, nil)
|
||||
_, err := chain.InsertChain([]*types.Block{block1, block2, block3})
|
||||
if err != nil {
|
||||
t.Error(err)
|
||||
|
@ -30,8 +30,10 @@ import (
|
||||
)
|
||||
|
||||
func GenesisBlockForTesting(db ethdb.Database, addr common.Address, balance, baseFee *big.Int, initialGasLimit uint64) *types.Block {
|
||||
alloc := map[common.Address]core.GenesisAccount{
|
||||
addr: core.GenesisAccount{Balance: balance}}
|
||||
g := core.Genesis{
|
||||
Alloc: core.GenesisAlloc{addr: {Balance: balance}},
|
||||
Alloc: alloc,
|
||||
BaseFee: baseFee,
|
||||
}
|
||||
if initialGasLimit != 0 {
|
||||
|
@ -104,7 +104,7 @@ func (gen *prefixGenerator) Next() {
|
||||
|
||||
// MakePaths generates paths that cut trie domain into `nbins` uniform conterminous bins (w/ opt. prefix)
|
||||
// eg. MakePaths([], 2) => [[0] [8]]
|
||||
// MakePaths([4], 32) => [[4 0 0] [4 0 8] [4 1 0]... [4 f 8]]
|
||||
// MakePaths([4], 32) => [[4 0 0] [4 0 8] [4 1 0]... [4 f 8]]
|
||||
func MakePaths(prefix []byte, nbins uint) [][]byte {
|
||||
var res [][]byte
|
||||
for it := newPrefixGenerator(nbins); it.HasNext(); it.Next() {
|
||||
|
@ -24,10 +24,14 @@ func TestMakePaths(t *testing.T) {
|
||||
}
|
||||
|
||||
func TestIterator(t *testing.T) {
|
||||
edb, err := rawdb.NewLevelDBDatabaseWithFreezer(
|
||||
fixt.ChainDataPath, 1024, 256, fixt.AncientDataPath,
|
||||
"eth-pg-ipfs-state-snapshot", false,
|
||||
)
|
||||
kvdb, ldberr := rawdb.NewLevelDBDatabase(fixt.ChainDataPath, 1024, 256, "vdb-geth", false)
|
||||
if ldberr != nil {
|
||||
t.Fatal(ldberr)
|
||||
}
|
||||
edb, err := rawdb.NewDatabaseWithFreezer(kvdb, fixt.AncientDataPath, "vdb-geth", false)
|
||||
if err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
if err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user