mirror of
https://github.com/ethereum/go-ethereum.git
synced 2026-07-27 15:16:43 +00:00
fix: testcases
This commit is contained in:
parent
43043ed7ec
commit
cec3ee18d8
7 changed files with 39 additions and 13 deletions
|
|
@ -542,6 +542,7 @@ func NewBlockChain(db ethdb.Database, cacheConfig *CacheConfig, genesis *Genesis
|
|||
|
||||
if txLookupLimit == nil {
|
||||
txLookupLimit = new(uint64)
|
||||
*txLookupLimit = txLookupCacheLimit
|
||||
}
|
||||
|
||||
bc.txIndexer = newTxIndexer(*txLookupLimit, bc)
|
||||
|
|
|
|||
|
|
@ -436,6 +436,18 @@ func (bc *BlockChain) GetVMConfig() *vm.Config {
|
|||
return &bc.vmConfig
|
||||
}
|
||||
|
||||
// SetTxLookupLimit is responsible for updating the txlookup limit to the
|
||||
// original one stored in db if the new mismatches with the old one.
|
||||
func (bc *BlockChain) SetTxLookupLimit(limit uint64) {
|
||||
bc.txIndexer.limit = limit
|
||||
}
|
||||
|
||||
// TxLookupLimit retrieves the txlookup limit used by blockchain to prune
|
||||
// stale transaction indices.
|
||||
func (bc *BlockChain) TxLookupLimit() uint64 {
|
||||
return bc.txIndexer.limit
|
||||
}
|
||||
|
||||
// TxIndexProgress returns the transaction indexing progress.
|
||||
func (bc *BlockChain) TxIndexProgress() (TxIndexProgress, error) {
|
||||
if bc.txIndexer == nil {
|
||||
|
|
|
|||
|
|
@ -118,8 +118,14 @@ func testShortSnapSyncedRepair(t *testing.T, snapshots bool) {
|
|||
// not yet committed, but the process crashed. In this case we expect the chain to
|
||||
// detect that it was fast syncing and not delete anything, since we can just pick
|
||||
// up directly where we left off.
|
||||
func TestShortSnapSyncingRepair(t *testing.T) { testShortSnapSyncingRepair(t, false) }
|
||||
func TestShortSnapSyncingRepairWithSnapshots(t *testing.T) { testShortSnapSyncingRepair(t, true) }
|
||||
func TestShortSnapSyncingRepair(t *testing.T) {
|
||||
t.Skip("snap sync not supported in bor")
|
||||
testShortSnapSyncingRepair(t, false)
|
||||
}
|
||||
func TestShortSnapSyncingRepairWithSnapshots(t *testing.T) {
|
||||
t.Skip("snap sync not supported in bor")
|
||||
testShortSnapSyncingRepair(t, true)
|
||||
}
|
||||
|
||||
func testShortSnapSyncingRepair(t *testing.T, snapshots bool) {
|
||||
// Chain:
|
||||
|
|
|
|||
|
|
@ -62,7 +62,7 @@ func TestGeneratePOSChain(t *testing.T) {
|
|||
config.ShanghaiBlock = common.Big0
|
||||
config.CancunBlock = common.Big0
|
||||
config.PragueBlock = common.Big0
|
||||
config.VerkleBlock = common.Big0
|
||||
// config.VerkleBlock = common.Big0
|
||||
|
||||
// init 0xaa with some storage elements
|
||||
storage := make(map[common.Hash]common.Hash)
|
||||
|
|
|
|||
|
|
@ -442,6 +442,7 @@ var (
|
|||
)
|
||||
|
||||
func TestProcessVerkle(t *testing.T) {
|
||||
t.Skip("not relevant to bor")
|
||||
var (
|
||||
config = ¶ms.ChainConfig{
|
||||
ChainID: big.NewInt(1),
|
||||
|
|
|
|||
|
|
@ -18,6 +18,7 @@ package core
|
|||
|
||||
import (
|
||||
"math/big"
|
||||
"os"
|
||||
"testing"
|
||||
|
||||
"github.com/ethereum/go-ethereum/common"
|
||||
|
|
@ -29,7 +30,7 @@ import (
|
|||
"github.com/ethereum/go-ethereum/params"
|
||||
)
|
||||
|
||||
// TestTxIndexer tests the functionalities for managing transaction indexes.
|
||||
// TestTxIndexer tests the tx indexes are updated correctly.
|
||||
func TestTxIndexer(t *testing.T) {
|
||||
var (
|
||||
testBankKey, _ = crypto.GenerateKey()
|
||||
|
|
@ -210,9 +211,12 @@ func TestTxIndexer(t *testing.T) {
|
|||
},
|
||||
}
|
||||
|
||||
borReceipts := make([]types.Receipts, len(receipts))
|
||||
|
||||
for _, c := range cases {
|
||||
db, _ := rawdb.NewDatabaseWithFreezer(rawdb.NewMemoryDatabase(), "", "", false, false, false)
|
||||
rawdb.WriteAncientBlocks(db, append([]*types.Block{gspec.ToBlock()}, blocks...), append([]types.Receipts{{}}, receipts...), nil, big.NewInt(0))
|
||||
frdir := t.TempDir()
|
||||
db, _ := rawdb.NewDatabaseWithFreezer(rawdb.NewMemoryDatabase(), frdir, "", false, false, false)
|
||||
_, _ = rawdb.WriteAncientBlocks(db, append([]*types.Block{gspec.ToBlock()}, blocks...), append([]types.Receipts{{}}, receipts...), append([]types.Receipts{{}}, borReceipts...), big.NewInt(0))
|
||||
|
||||
// Index the initial blocks from ancient store
|
||||
indexer := &txIndexer{
|
||||
|
|
@ -237,5 +241,6 @@ func TestTxIndexer(t *testing.T) {
|
|||
verify(db, 0, indexer)
|
||||
|
||||
db.Close()
|
||||
os.RemoveAll(frdir)
|
||||
}
|
||||
}
|
||||
|
|
|
|||
15
eth/sync.go
15
eth/sync.go
|
|
@ -22,6 +22,7 @@ import (
|
|||
"time"
|
||||
|
||||
"github.com/ethereum/go-ethereum/common"
|
||||
"github.com/ethereum/go-ethereum/core/rawdb"
|
||||
"github.com/ethereum/go-ethereum/core/txpool"
|
||||
"github.com/ethereum/go-ethereum/eth/downloader"
|
||||
"github.com/ethereum/go-ethereum/eth/protocols/eth"
|
||||
|
|
@ -261,13 +262,13 @@ func (h *handler) doSync(op *chainSyncOp) error {
|
|||
// has been indexed. So here for the user-experience wise, it's non-optimal
|
||||
// that user can't change limit during the snap sync. If changed, Geth
|
||||
// will just blindly use the original one.
|
||||
// limit := h.chain.TxLookupLimit()
|
||||
// if stored := rawdb.ReadFastTxLookupLimit(h.database); stored == nil {
|
||||
// rawdb.WriteFastTxLookupLimit(h.database, limit)
|
||||
// } else if *stored != limit {
|
||||
// h.chain.SetTxLookupLimit(*stored)
|
||||
// log.Warn("Update txLookup limit", "provided", limit, "updated", *stored)
|
||||
// }
|
||||
limit := h.chain.TxLookupLimit()
|
||||
if stored := rawdb.ReadFastTxLookupLimit(h.database); stored == nil {
|
||||
rawdb.WriteFastTxLookupLimit(h.database, limit)
|
||||
} else if *stored != limit {
|
||||
h.chain.SetTxLookupLimit(*stored)
|
||||
log.Warn("Update txLookup limit", "provided", limit, "updated", *stored)
|
||||
}
|
||||
}
|
||||
// Run the sync cycle, and disable snap sync if we're past the pivot block
|
||||
err := h.downloader.LegacySync(op.peer.ID(), op.head, op.td, h.chain.Config().TerminalTotalDifficulty, op.mode)
|
||||
|
|
|
|||
Loading…
Reference in a new issue