Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Binary file added cmd/hivechain/bytecode/largelogs.bin
Binary file not shown.
3 changes: 3 additions & 0 deletions cmd/hivechain/contracts.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
//
Expand Down
8 changes: 8 additions & 0 deletions cmd/hivechain/contracts/largelogs.eas
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
;;; -*- mode: asm -*-
;;; outputs a single large log event

#pragma target "frontier"

push 190000
push 0
log0
2 changes: 1 addition & 1 deletion cmd/hivechain/genesis.go
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
54 changes: 54 additions & 0 deletions cmd/hivechain/mod_largereceipt.go
Original file line number Diff line number Diff line change
@@ -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
}