Merge branch 'juga1980/appendBetter'

This commit is contained in:
Jürgen Gamenik 2025-06-24 17:04:55 +02:00
commit f24e6a0730
8 changed files with 19 additions and 16 deletions

View file

@ -1352,7 +1352,7 @@ const (
// will be directly stored in the ancient, getting rid of the chain migration. // will be directly stored in the ancient, getting rid of the chain migration.
func (bc *BlockChain) InsertReceiptChain(blockChain types.Blocks, receiptChain []rlp.RawValue, ancientLimit uint64) (int, error) { func (bc *BlockChain) InsertReceiptChain(blockChain types.Blocks, receiptChain []rlp.RawValue, ancientLimit uint64) (int, error) {
// Verify the supplied headers before insertion without lock // Verify the supplied headers before insertion without lock
var headers []*types.Header headers := make([]*types.Header, 0, len(blockChain))
for _, block := range blockChain { for _, block := range blockChain {
headers = append(headers, block.Header()) headers = append(headers, block.Header())
// Here we also validate that blob transactions in the block do not // Here we also validate that blob transactions in the block do not
@ -2210,7 +2210,7 @@ func (bc *BlockChain) insertSideChain(block *types.Block, it *insertIterator, ma
} }
// Import all the pruned blocks to make the state available // Import all the pruned blocks to make the state available
var ( var (
blocks []*types.Block blocks = make([]*types.Block, 0, len(hashes))
memory uint64 memory uint64
) )
for i := len(hashes) - 1; i >= 0; i-- { for i := len(hashes) - 1; i >= 0; i-- {

View file

@ -53,6 +53,7 @@ func (info *freezerInfo) size() common.StorageSize {
func inspect(name string, order map[string]freezerTableConfig, reader ethdb.AncientReader) (freezerInfo, error) { func inspect(name string, order map[string]freezerTableConfig, reader ethdb.AncientReader) (freezerInfo, error) {
info := freezerInfo{name: name} info := freezerInfo{name: name}
info.sizes = make([]tableSize, 0, len(order))
for t := range order { for t := range order {
size, err := reader.AncientSize(t) size, err := reader.AncientSize(t)
if err != nil { if err != nil {
@ -78,7 +79,7 @@ func inspect(name string, order map[string]freezerTableConfig, reader ethdb.Anci
// inspectFreezers inspects all freezers registered in the system. // inspectFreezers inspects all freezers registered in the system.
func inspectFreezers(db ethdb.Database) ([]freezerInfo, error) { func inspectFreezers(db ethdb.Database) ([]freezerInfo, error) {
var infos []freezerInfo var infos []freezerInfo = make([]freezerInfo, 0, len(freezers))
for _, freezer := range freezers { for _, freezer := range freezers {
switch freezer { switch freezer {
case ChainFreezerName: case ChainFreezerName:

View file

@ -148,7 +148,7 @@ func iterateTransactions(db ethdb.Database, from uint64, to uint64, reverse bool
log.Warn("Failed to decode block body", "block", data.number, "error", err) log.Warn("Failed to decode block body", "block", data.number, "error", err)
return return
} }
var hashes []common.Hash var hashes []common.Hash = make([]common.Hash, 0, len(body.Transactions))
for _, tx := range body.Transactions { for _, tx := range body.Transactions {
hashes = append(hashes, tx.Hash()) hashes = append(hashes, tx.Hash())
} }

View file

@ -936,7 +936,7 @@ func (t *freezerTable) getIndices(from, count uint64) ([]*indexEntry, error) {
return nil, err return nil, err
} }
var ( var (
indices []*indexEntry indices = make([]*indexEntry, 0, count+1)
offset int offset int
) )
for i := from; i <= from+count; i++ { for i := from; i <= from+count; i++ {

View file

@ -521,7 +521,7 @@ func (p *BlobPool) parseTransaction(id uint64, size uint32, blob []byte) error {
} }
// recheck verifies the pool's content for a specific account and drops anything // recheck verifies the pool's content for a specific account and drops anything
// that does not fit anymore (dangling or filled nonce, overdraft). // that does not fit anymore (dangling or filled nonce, overdraft). // TODO split long method in smaller parts
func (p *BlobPool) recheck(addr common.Address, inclusions map[common.Hash]uint64) { func (p *BlobPool) recheck(addr common.Address, inclusions map[common.Hash]uint64) {
// Sort the transactions belonging to the account so reinjects can be simpler // Sort the transactions belonging to the account so reinjects can be simpler
txs := p.index[addr] txs := p.index[addr]
@ -541,8 +541,8 @@ func (p *BlobPool) recheck(addr common.Address, inclusions map[common.Hash]uint6
) )
if gapped || filled { if gapped || filled {
var ( var (
ids []uint64 ids []uint64 = make([]uint64, 0, len(txs))
nonces []uint64 nonces []uint64 = make([]uint64, 0, len(txs))
) )
for i := 0; i < len(txs); i++ { for i := 0; i < len(txs); i++ {
ids = append(ids, txs[i].id) ids = append(ids, txs[i].id)
@ -659,8 +659,8 @@ func (p *BlobPool) recheck(addr common.Address, inclusions map[common.Hash]uint6
} }
// Otherwise if there's a nonce gap evict all later transactions // Otherwise if there's a nonce gap evict all later transactions
var ( var (
ids []uint64 ids []uint64 = make([]uint64, 0, len(txs))
nonces []uint64 nonces []uint64 = make([]uint64, 0, len(txs))
) )
for j := i; j < len(txs); j++ { for j := i; j < len(txs); j++ {
ids = append(ids, txs[j].id) ids = append(ids, txs[j].id)

View file

@ -645,9 +645,10 @@ func runBn256Pairing(input []byte) ([]byte, error) {
return nil, errBadPairingInput return nil, errBadPairingInput
} }
// Convert the input into a set of coordinates // Convert the input into a set of coordinates
howMuch := len(input) / 192
var ( var (
cs []*bn256.G1 cs []*bn256.G1 = make([]*bn256.G1, 0, howMuch)
ts []*bn256.G2 ts []*bn256.G2 = make([]*bn256.G2, 0, howMuch)
) )
for i := 0; i < len(input); i += 192 { for i := 0; i < len(input); i += 192 {
c, err := newCurvePoint(input[i : i+64]) c, err := newCurvePoint(input[i : i+64])
@ -976,8 +977,8 @@ func (c *bls12381Pairing) Run(input []byte) ([]byte, error) {
} }
var ( var (
p []bls12381.G1Affine p []bls12381.G1Affine = make([]bls12381.G1Affine, 0, k)
q []bls12381.G2Affine q []bls12381.G2Affine = make([]bls12381.G2Affine, 0, k)
) )
// Decode pairs // Decode pairs

View file

@ -60,7 +60,7 @@ func ValidEip(eipNum int) bool {
return ok return ok
} }
func ActivateableEips() []string { func ActivateableEips() []string {
var nums []string nums := make([]string, 0, len(activators))
for k := range activators { for k := range activators {
nums = append(nums, fmt.Sprintf("%d", k)) nums = append(nums, fmt.Sprintf("%d", k))
} }

View file

@ -136,11 +136,12 @@ func NewEVMInterpreter(evm *EVM) *EVMInterpreter {
default: default:
table = &frontierInstructionSet table = &frontierInstructionSet
} }
var extraEips []int extraEips := make([]int, 0, len(evm.Config.ExtraEips))
if len(evm.Config.ExtraEips) > 0 { if len(evm.Config.ExtraEips) > 0 {
// Deep-copy jumptable to prevent modification of opcodes in other tables // Deep-copy jumptable to prevent modification of opcodes in other tables
table = copyJumpTable(table) table = copyJumpTable(table)
} }
for _, eip := range evm.Config.ExtraEips { for _, eip := range evm.Config.ExtraEips {
if err := EnableEIP(eip, table); err != nil { if err := EnableEIP(eip, table); err != nil {
// Disable it, so caller can check if it's activated or not // Disable it, so caller can check if it's activated or not