upstream: fixed txpool/* and state/*

This commit is contained in:
Pratik Patil 2025-05-01 15:54:01 +05:30
parent e53660318e
commit 7e115f3519
No known key found for this signature in database
GPG key ID: AFDCA496554874B3
7 changed files with 14 additions and 24 deletions

View file

@ -416,7 +416,7 @@ func (s *StateDB) ApplyMVWriteSet(writes []blockstm.WriteDescriptor) {
case BalancePath: case BalancePath:
s.SetBalance(addr, sr.GetBalance(addr), tracing.BalanceChangeUnspecified) s.SetBalance(addr, sr.GetBalance(addr), tracing.BalanceChangeUnspecified)
case NoncePath: case NoncePath:
s.SetNonce(addr, sr.GetNonce(addr)) s.SetNonce(addr, sr.GetNonce(addr), tracing.NonceChangeUnspecified)
case CodePath: case CodePath:
s.SetCode(addr, sr.GetCode(addr)) s.SetCode(addr, sr.GetCode(addr))
case SuicidePath: case SuicidePath:
@ -664,20 +664,13 @@ func (s *StateDB) Version() blockstm.Version {
} }
} }
func (s *StateDB) GetCode(addr common.Address) []byte {
stateObject := s.getStateObject(addr)
if stateObject != nil {
if s.witness != nil {
s.witness.AddCode(stateObject.Code())
}
return stateObject.Code()
}
}
func (s *StateDB) GetCode(addr common.Address) []byte { func (s *StateDB) GetCode(addr common.Address) []byte {
return MVRead(s, blockstm.NewSubpathKey(addr, CodePath), nil, func(s *StateDB) []byte { return MVRead(s, blockstm.NewSubpathKey(addr, CodePath), nil, func(s *StateDB) []byte {
stateObject := s.getStateObject(addr) stateObject := s.getStateObject(addr)
if stateObject != nil { if stateObject != nil {
if s.witness != nil {
s.witness.AddCode(stateObject.Code())
}
return stateObject.Code() return stateObject.Code()
} }
@ -965,7 +958,7 @@ func (s *StateDB) updateStateObject(obj *stateObject) {
// deleteStateObject removes the given object from the state trie. // deleteStateObject removes the given object from the state trie.
func (s *StateDB) deleteStateObject(addr common.Address) { func (s *StateDB) deleteStateObject(addr common.Address) {
// Track the amount of time wasted on deleting the account from the trie // Track the amount of time wasted on deleting the account from the trie
if metrics.Enabled { if metrics.Enabled() {
defer func(start time.Time) { s.AccountUpdates += time.Since(start) }(time.Now()) defer func(start time.Time) { s.AccountUpdates += time.Since(start) }(time.Now())
} }

View file

@ -1185,13 +1185,13 @@ func TestApplyMVWriteSet(t *testing.T) {
// Tx1 write // Tx1 write
states[1].SetState(addr1, key2, val2) states[1].SetState(addr1, key2, val2)
states[1].SetBalance(addr1, balance2, tracing.BalanceChangeTransfer) states[1].SetBalance(addr1, balance2, tracing.BalanceChangeTransfer)
states[1].SetNonce(addr1, 1) states[1].SetNonce(addr1, 1, tracing.NonceChangeUnspecified)
states[1].Finalise(true) states[1].Finalise(true)
states[1].FlushMVWriteSet() states[1].FlushMVWriteSet()
sSingleProcess.SetState(addr1, key2, val2) sSingleProcess.SetState(addr1, key2, val2)
sSingleProcess.SetBalance(addr1, balance2, tracing.BalanceChangeTransfer) sSingleProcess.SetBalance(addr1, balance2, tracing.BalanceChangeTransfer)
sSingleProcess.SetNonce(addr1, 1) sSingleProcess.SetNonce(addr1, 1, tracing.NonceChangeUnspecified)
sClean.ApplyMVWriteSet(states[1].MVWriteList()) sClean.ApplyMVWriteSet(states[1].MVWriteList())
@ -1200,13 +1200,13 @@ func TestApplyMVWriteSet(t *testing.T) {
// Tx2 write // Tx2 write
states[2].SetState(addr1, key1, val2) states[2].SetState(addr1, key1, val2)
states[2].SetBalance(addr1, balance2, tracing.BalanceChangeTransfer) states[2].SetBalance(addr1, balance2, tracing.BalanceChangeTransfer)
states[2].SetNonce(addr1, 2) states[2].SetNonce(addr1, 2, tracing.NonceChangeUnspecified)
states[2].Finalise(true) states[2].Finalise(true)
states[2].FlushMVWriteSet() states[2].FlushMVWriteSet()
sSingleProcess.SetState(addr1, key1, val2) sSingleProcess.SetState(addr1, key1, val2)
sSingleProcess.SetBalance(addr1, balance2, tracing.BalanceChangeTransfer) sSingleProcess.SetBalance(addr1, balance2, tracing.BalanceChangeTransfer)
sSingleProcess.SetNonce(addr1, 2) sSingleProcess.SetNonce(addr1, 2, tracing.NonceChangeUnspecified)
sClean.ApplyMVWriteSet(states[2].MVWriteList()) sClean.ApplyMVWriteSet(states[2].MVWriteList())

View file

@ -139,7 +139,7 @@ func (bc *testBlockChain) CurrentBlock() *types.Header {
tmp := mid.Uint64() tmp := mid.Uint64()
if eip4844.CalcBlobFee(bc.Config(), &types.Header{ if eip4844.CalcBlobFee(bc.Config(), &types.Header{
Number: blockNumber, Number: blockNumber,
Time: blockTime, Time: uint64(blockTime),
ExcessBlobGas: &tmp, ExcessBlobGas: &tmp,
}).Cmp(bc.blobfee.ToBig()) > 0 { }).Cmp(bc.blobfee.ToBig()) > 0 {
hi = mid hi = mid

View file

@ -1653,9 +1653,6 @@ func (pool *LegacyPool) demoteUnexecutables() {
} }
pendingGauge.Dec(int64(len(olds) + len(drops) + len(invalids) + len(txConditionalsRemoved))) pendingGauge.Dec(int64(len(olds) + len(drops) + len(invalids) + len(txConditionalsRemoved)))
if pool.locals.contains(addr) {
localGauge.Dec(int64(len(olds) + len(drops) + len(invalids) + len(txConditionalsRemoved)))
}
// If there's a gap in front, alert (should never happen) and postpone all transactions // If there's a gap in front, alert (should never happen) and postpone all transactions
if list.Len() > 0 && list.txs.Get(nonce) == nil { if list.Len() > 0 && list.txs.Get(nonce) == nil {
gapped := list.Cap(0) gapped := list.Cap(0)

View file

@ -3168,7 +3168,7 @@ func TestPoolMultiAccountBatchInsertRace(t *testing.T) {
pending = pool.Pending(txpool.PendingFilter{}) pending = pool.Pending(txpool.PendingFilter{})
total = len(pending) total = len(pending)
_ = pool.Locals() // _ = pool.Locals()
if total >= n { if total >= n {
close(done) close(done)

View file

@ -77,7 +77,7 @@ func (m *SortedMap) Get(nonce uint64) *types.Transaction {
return m.items[nonce] return m.items[nonce]
} }
func (m *sortedMap) Has(nonce uint64) bool { func (m *SortedMap) Has(nonce uint64) bool {
if m == nil { if m == nil {
return false return false
} }
@ -273,7 +273,7 @@ func (m *SortedMap) flatten() types.Transactions {
return m.cache return m.cache
} }
func (m *sortedMap) lastElement() *types.Transaction { func (m *SortedMap) lastElement() *types.Transaction {
cache := m.flatten() cache := m.flatten()
return cache[len(cache)-1] return cache[len(cache)-1]
} }

View file

@ -66,7 +66,7 @@ func newTestEnv(t *testing.T, n int, gasTip uint64, journal string) *testEnv {
}) })
db := rawdb.NewMemoryDatabase() db := rawdb.NewMemoryDatabase()
chain, _ := core.NewBlockChain(db, nil, gspec, nil, ethash.NewFaker(), vm.Config{}, nil) chain, _ := core.NewBlockChain(db, nil, gspec, nil, ethash.NewFaker(), vm.Config{}, nil, nil, nil)
legacyPool := legacypool.New(legacypool.DefaultConfig, chain) legacyPool := legacypool.New(legacypool.DefaultConfig, chain)
pool, err := txpool.New(gasTip, chain, []txpool.SubPool{legacyPool}) pool, err := txpool.New(gasTip, chain, []txpool.SubPool{legacyPool})