mirror of
https://gitlab.com/pulsechaincom/erigon-pulse.git
synced 2025-01-01 00:31:21 +00:00
fixes
This commit is contained in:
parent
ee64806c90
commit
e965c0981d
@ -358,7 +358,7 @@ func onNewBlock(senderInfo map[uint64]*senderInfo, unwindTxs TxSlots, minedTxs [
|
||||
//TODO: also check if sender is in list of local-senders
|
||||
i.SubPool |= IsLocal
|
||||
}
|
||||
delete(byHash, string(i.Tx.idHash[:]))
|
||||
byHash[string(i.Tx.idHash[:])] = i
|
||||
})
|
||||
}
|
||||
|
||||
@ -483,11 +483,12 @@ func onSenderChange(sender *senderInfo, protocolBaseFee, blockBaseFee uint64) {
|
||||
// nonces N+1 ... M is no more than B. Set to 0 otherwise. In other words, this bit is
|
||||
// set if there is currently a guarantee that the transaction and all its required prior
|
||||
// transactions will be able to pay for gas.
|
||||
accumulatedSenderSpent = accumulatedSenderSpent.Add(accumulatedSenderSpent, needBalance) // already deleted all transactions with nonce <= sender.nonce
|
||||
it.MetaTx.SubPool &^= EnoughBalance
|
||||
if sender.balance.Gt(accumulatedSenderSpent) || sender.balance.Eq(accumulatedSenderSpent) {
|
||||
it.MetaTx.SubPool |= EnoughBalance
|
||||
fmt.Printf("a3: %b,%d,%d,%d,%t\n", it.MetaTx.SubPool, accumulatedSenderSpent.Uint64(), sender.balance.Uint64(), needBalance.Uint64(), it.MetaTx.SenderHasEnoughBalance)
|
||||
}
|
||||
accumulatedSenderSpent.Add(accumulatedSenderSpent, needBalance) // already deleted all transactions with nonce <= sender.nonce
|
||||
|
||||
// 4. Dynamic fee requirement. Set to 1 if feeCap of the transaction is no less than
|
||||
// baseFee of the currently pending block. Set to 0 otherwise.
|
||||
|
@ -12,6 +12,7 @@ import (
|
||||
"github.com/google/btree"
|
||||
"github.com/holiman/uint256"
|
||||
"github.com/stretchr/testify/assert"
|
||||
"go.uber.org/atomic"
|
||||
)
|
||||
|
||||
// https://blog.golang.org/fuzz-beta
|
||||
@ -153,6 +154,8 @@ func parseTxs(in []byte) (nonces, tips []uint64, values []uint256.Int) {
|
||||
return
|
||||
}
|
||||
|
||||
var txId atomic.Uint64
|
||||
|
||||
func poolsFromFuzzBytes(rawTxNonce, rawValues, rawTips, rawFeeCap, rawSender []byte) (sendersInfo map[uint64]*senderInfo, senderIDs map[string]uint64, txs TxSlots, ok bool) {
|
||||
if len(rawTxNonce) < 1 || len(rawValues) < 1 || len(rawTips) < 1 || len(rawFeeCap) < 1 || len(rawSender) < 1+1+1 {
|
||||
return nil, nil, txs, false
|
||||
@ -183,6 +186,7 @@ func poolsFromFuzzBytes(rawTxNonce, rawValues, rawTips, rawFeeCap, rawSender []b
|
||||
senderIDs[string(senders.At(i%senders.Len()))] = senderID
|
||||
}
|
||||
for i := range txNonce {
|
||||
txId.Inc()
|
||||
txs.txs = append(txs.txs, &TxSlot{
|
||||
nonce: txNonce[i],
|
||||
value: values[i%len(values)],
|
||||
@ -191,6 +195,7 @@ func poolsFromFuzzBytes(rawTxNonce, rawValues, rawTips, rawFeeCap, rawSender []b
|
||||
})
|
||||
txs.senders = append(txs.senders, senders.At(i%senders.Len())...)
|
||||
txs.isLocal = append(txs.isLocal, false)
|
||||
binary.BigEndian.PutUint64(txs.txs[i].idHash[:], txId.Load())
|
||||
}
|
||||
|
||||
return sendersInfo, senderIDs, txs, true
|
||||
@ -312,6 +317,7 @@ func FuzzOnNewBlocks10(f *testing.F) {
|
||||
i := tx.Tx
|
||||
assert.GreaterOrEqual(i.nonce, senders[i.senderID].nonce)
|
||||
if tx.SubPool&EnoughBalance != 0 {
|
||||
|
||||
assert.True(tx.SenderHasEnoughBalance)
|
||||
}
|
||||
|
||||
@ -389,7 +395,7 @@ func FuzzOnNewBlocks10(f *testing.F) {
|
||||
}
|
||||
}
|
||||
for j := range minedTxs.txs {
|
||||
if bytes.Equal(unwindTxs.txs[j].idHash[:], newHash) {
|
||||
if bytes.Equal(minedTxs.txs[j].idHash[:], newHash) {
|
||||
foundInMined = true
|
||||
break
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user