diff --git a/cmd/hivechain/bytecode/largelogs.bin b/cmd/hivechain/bytecode/largelogs.bin new file mode 100644 index 0000000000..5beae92cf9 Binary files /dev/null and b/cmd/hivechain/bytecode/largelogs.bin differ diff --git a/cmd/hivechain/contracts.go b/cmd/hivechain/contracts.go index 9d2703224c..87fabf547a 100644 --- a/cmd/hivechain/contracts.go +++ b/cmd/hivechain/contracts.go @@ -29,6 +29,9 @@ var emitCode []byte //go:embed bytecode/7702account.bin var mod7702AccountCode []byte +//go:embed bytecode/largelogs.bin +var modLargeReceiptCode []byte + // //go:embed bytecode/deposit.bin // var depositCode []byte // diff --git a/cmd/hivechain/contracts/largelogs.eas b/cmd/hivechain/contracts/largelogs.eas new file mode 100644 index 0000000000..123d9e5b9c --- /dev/null +++ b/cmd/hivechain/contracts/largelogs.eas @@ -0,0 +1,8 @@ +;;; -*- mode: asm -*- +;;; outputs a single large log event + +#pragma target "frontier" + + push 190000 + push 0 + log0 diff --git a/cmd/hivechain/genesis.go b/cmd/hivechain/genesis.go index a75254e109..7d9ce93f2d 100644 --- a/cmd/hivechain/genesis.go +++ b/cmd/hivechain/genesis.go @@ -135,7 +135,7 @@ func (cfg *generatorConfig) createGenesis() *core.Genesis { // Block attributes. g.Difficulty = cfg.genesisDifficulty() g.ExtraData = []byte("hivechain") - g.GasLimit = params.GenesisGasLimit * 8 + g.GasLimit = 300_000_000 zero := new(big.Int) if g.Config.IsLondon(zero) { g.BaseFee = big.NewInt(genesisBaseFee) diff --git a/cmd/hivechain/mod_largereceipt.go b/cmd/hivechain/mod_largereceipt.go new file mode 100644 index 0000000000..f1195c24ad --- /dev/null +++ b/cmd/hivechain/mod_largereceipt.go @@ -0,0 +1,54 @@ +package main + +import ( + "github.com/ethereum/go-ethereum/core/types" + "github.com/ethereum/go-ethereum/params" +) + +func init() { + register("tx-largereceipt", func() blockModifier { + // Gas parameters here are calculated to create a block with > 10MB of receipts. + const logCost = 1607055 + const pushCost = 10 + return &modLargeReceipt{ + gasLimit: logCost + pushCost + params.TxGasContractCreation + params.TxDataNonZeroGasEIP2028*8, + txCount: 56, + } + }) +} + +// modLargeReceipt creates blocks with large receipts. It emits multiple transactions +// within a single block, where each transaction has a single log with large data. +type modLargeReceipt struct { + didRun bool + gasLimit uint64 // gas of single transaction + txCount uint64 // number of transactions added to block + block uint64 // block number where txs were included +} + +func (m *modLargeReceipt) apply(ctx *genBlockContext) bool { + if m.didRun || !ctx.HasGas(m.gasLimit*m.txCount) { + return false + } + + sender := ctx.TxSenderAccount() + for range m.txCount { + ctx.AddNewTx(sender, &types.LegacyTx{ + Nonce: ctx.AccountNonce(sender.addr), + Gas: m.gasLimit, + GasPrice: ctx.TxGasFeeCap(), + Data: modLargeReceiptCode, + }) + } + m.block = ctx.NumberU64() + m.didRun = true + return true +} + +// txInfo is just the block number that has the receipts. +func (m *modLargeReceipt) txInfo() any { + if m.didRun { + return m.block + } + return nil +}