mirror of
https://github.com/ethereum/go-ethereum.git
synced 2026-07-26 06:36:43 +00:00
upstream: fixed txpool/* and state/*
This commit is contained in:
parent
e53660318e
commit
7e115f3519
7 changed files with 14 additions and 24 deletions
|
|
@ -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:
|
||||||
|
|
@ -665,6 +665,7 @@ func (s *StateDB) Version() blockstm.Version {
|
||||||
}
|
}
|
||||||
|
|
||||||
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 {
|
||||||
stateObject := s.getStateObject(addr)
|
stateObject := s.getStateObject(addr)
|
||||||
if stateObject != nil {
|
if stateObject != nil {
|
||||||
if s.witness != nil {
|
if s.witness != nil {
|
||||||
|
|
@ -672,14 +673,6 @@ func (s *StateDB) GetCode(addr common.Address) []byte {
|
||||||
}
|
}
|
||||||
return stateObject.Code()
|
return stateObject.Code()
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
func (s *StateDB) GetCode(addr common.Address) []byte {
|
|
||||||
return MVRead(s, blockstm.NewSubpathKey(addr, CodePath), nil, func(s *StateDB) []byte {
|
|
||||||
stateObject := s.getStateObject(addr)
|
|
||||||
if stateObject != nil {
|
|
||||||
return stateObject.Code()
|
|
||||||
}
|
|
||||||
|
|
||||||
return nil
|
return nil
|
||||||
})
|
})
|
||||||
|
|
@ -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())
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -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())
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -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
|
||||||
|
|
|
||||||
|
|
@ -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)
|
||||||
|
|
|
||||||
|
|
@ -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)
|
||||||
|
|
|
||||||
|
|
@ -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]
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -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})
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue