Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
57 commits
Select commit Hold shift + click to select a range
452fb28
first working version of new state sync tx
lucca30 Aug 27, 2025
ada4bcc
remove logs
lucca30 Sep 3, 2025
4853b71
Merge remote-tracking branch 'origin/develop' into lmartins/state-syn…
lucca30 Sep 3, 2025
d57e485
fix lint
lucca30 Sep 3, 2025
a6b395c
fix integration tests
lucca30 Sep 3, 2025
feb65bf
test fixes
lucca30 Sep 4, 2025
030eb31
lint fix
lucca30 Sep 4, 2025
854fabe
fix parallel processor
lucca30 Sep 4, 2025
6f8186c
type improvement and unit tests
lucca30 Sep 4, 2025
55ba461
remove duplicates
lucca30 Sep 4, 2025
340a5bb
Merge remote-tracking branch 'origin/develop' into lmartins/state-syn…
lucca30 Sep 29, 2025
d634bc1
ignore data test output
lucca30 Oct 6, 2025
f76174b
fixing method calls and fields
lucca30 Oct 6, 2025
7f00fe6
Merge remote-tracking branch 'origin/develop' into lmartins/state-syn…
lucca30 Oct 6, 2025
b23546e
Merge remote-tracking branch 'origin/develop' into lmartins/state-syn…
lucca30 Oct 9, 2025
0b556fa
build fix
lucca30 Oct 9, 2025
90b03da
remove bor filter for after hf blocks
lucca30 Oct 9, 2025
15d3a69
sort logs just when necessary
lucca30 Oct 9, 2025
27562ef
Merge remote-tracking branch 'origin/develop' into lmartins/state-syn…
kamuikatsurgi Oct 15, 2025
d028c82
Merge remote-tracking branch 'origin/develop' into lmartins/state-syn…
kamuikatsurgi Oct 16, 2025
d56cdc0
ssTxs: fix receiptsHash mismatch (#1829)
kamuikatsurgi Oct 17, 2025
2f5a20d
core(tx): fix Hash method for StateSyncTxType (#1830)
kamuikatsurgi Oct 17, 2025
be7f430
eth: fixes in receipt handling via p2p post HF (#1825)
manav2401 Oct 20, 2025
4b07936
core/types: return nil for chainID() call over state-sync tx
manav2401 Oct 21, 2025
6d6d37f
internal/ethapi: handle bor txs and receipts post HF (#1834)
manav2401 Oct 21, 2025
223f7f9
Merge remote-tracking branch 'origin/develop' into lmartins/state-syn…
kamuikatsurgi Oct 22, 2025
74627f0
fix: cumulativeGasUsed in insertStateSyncTransactionAndCalculateRecei…
kamuikatsurgi Oct 22, 2025
09b31d5
fix: sort logs and remove duplicate append in Finalize (#1836)
kamuikatsurgi Oct 23, 2025
8960a93
chore: nit (#1838)
kamuikatsurgi Oct 24, 2025
c1fb88e
chore: typos
kamuikatsurgi Oct 24, 2025
64e78d6
fix: lint
kamuikatsurgi Oct 26, 2025
1e3176e
Renaming to Madhugiri HF
lucca30 Oct 27, 2025
af543ae
chore: nits
kamuikatsurgi Oct 27, 2025
097fc2f
(fix): handle pointers to receipt list received via p2p
manav2401 Oct 27, 2025
d1b7dbf
(chore): rename tests with HF name
manav2401 Oct 27, 2025
61d2113
chore: more nits
kamuikatsurgi Oct 27, 2025
bdab391
Merge branch 'lmartins/state-sync-txs-on-block-body' of ssh://github.…
kamuikatsurgi Oct 27, 2025
b41ee03
core: implement eip7883
marcello33 Oct 27, 2025
59c8f65
core: implement eip7825
marcello33 Oct 27, 2025
5e6c603
fix lint
marcello33 Oct 27, 2025
8984375
fix isOsaka condition
marcello33 Oct 27, 2025
1ad4f76
fix lint and add comment for int test failing
marcello33 Oct 27, 2025
bf37d9a
fix failing test / address comments
marcello33 Oct 28, 2025
24302c6
core: add blocktime in bor receipt logs (#1848)
manav2401 Oct 28, 2025
b1ddd41
core/types: derive bloom for bor receipts
manav2401 Oct 28, 2025
ad9a9ed
prioritize ss hf / remove todo
marcello33 Oct 28, 2025
087e863
fix lint
marcello33 Oct 28, 2025
68fbcd0
split precompiled contracts and addresses for madhugiri HF from osaka
marcello33 Oct 29, 2025
4671831
revert err msg to align with geth
marcello33 Oct 29, 2025
00768c5
Merge remote-tracking branch 'origin/develop' into lmartins/state-syn…
kamuikatsurgi Oct 30, 2025
3d29814
Merge remote-tracking branch 'origin/lmartins/state-sync-txs-on-block…
kamuikatsurgi Oct 30, 2025
a5a8ff4
eth/gasestimator: check ErrGasLimitTooHigh conditions (#32348)
mininny Aug 5, 2025
39bdea6
internal/ethapi: skip tx gas limit check for calls (#32641)
fjl Sep 19, 2025
c37546e
internal/ethapi: use gas from gaspool for call defaults
manav2401 Oct 30, 2025
f2efaf3
eth/gasestimator: check for madhugiri HF
manav2401 Oct 30, 2025
3cec783
consensus/bor: honour MaxTxGas for system calls
manav2401 Oct 30, 2025
4d1a3d7
Merge branch 'develop' into mardizzone/geth-eips
manav2401 Oct 30, 2025
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
9 changes: 9 additions & 0 deletions cmd/evm/internal/t8ntool/transaction.go
Original file line number Diff line number Diff line change
Expand Up @@ -202,6 +202,15 @@ func Transaction(ctx *cli.Context) error {
r.Error = errors.New("max initcode size exceeded")
}

// Bor: EIP-7825 at Madhugiri HF block
isOsaka := chainConfig.IsOsaka(new(big.Int))
isMadhugiri := chainConfig.Bor != nil && chainConfig.Bor.IsMadhugiri(new(big.Int))

// Verify tx gas limit does not exceed EIP-7825 cap.
if (isOsaka || isMadhugiri) && tx.Gas() > params.MaxTxGas {
r.Error = errors.New("gas limit exceeds maximum")
}

results = append(results, r)
}

Expand Down
10 changes: 9 additions & 1 deletion consensus/bor/contract/client.go
Original file line number Diff line number Diff line change
Expand Up @@ -118,7 +118,15 @@ func (gc *GenesisContractsClient) LastStateId(state *state.StateDB, number uint6

msgData := (hexutil.Bytes)(data)
toAddress := common.HexToAddress(gc.StateReceiverContract)
gas := (hexutil.Uint64)(uint64(math.MaxUint64 / 2))
var gas hexutil.Uint64

// Bor: EIP-7825 at Madhugiri HF block
IsMadhugiri := gc.chainConfig.Bor != nil && gc.chainConfig.Bor.IsMadhugiri(big.NewInt(int64(number)))
if IsMadhugiri {
gas = (hexutil.Uint64)(params.MaxTxGas)
} else {
gas = (hexutil.Uint64)(math.MaxUint64 / 2)
}
Comment thread
kamuikatsurgi marked this conversation as resolved.

// BOR: Do a 'CallWithState' so that we can fetch the last state ID from a given (incoming)
// state instead of local(canonical) chain's state.
Expand Down
3 changes: 1 addition & 2 deletions consensus/bor/statefull/processor.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@ package statefull
import (
"bytes"
"context"
"math"
"math/big"

"github.com/ethereum/go-ethereum"
Expand Down Expand Up @@ -55,7 +54,7 @@ func GetSystemMessage(toAddress common.Address, data []byte) Callmsg {
return Callmsg{
ethereum.CallMsg{
From: systemAddress,
Gas: math.MaxUint64 / 2,
Gas: params.MaxTxGas, // should be more than enough for state-sync related syscalls
Comment thread
kamuikatsurgi marked this conversation as resolved.
GasPrice: big.NewInt(0),
Value: big.NewInt(0),
To: &toAddress,
Expand Down
3 changes: 3 additions & 0 deletions core/error.go
Original file line number Diff line number Diff line change
Expand Up @@ -148,6 +148,9 @@ var (
// Message validation errors:
ErrEmptyAuthList = errors.New("EIP-7702 transaction with empty auth list")
ErrSetCodeTxCreate = errors.New("EIP-7702 transaction cannot be used to create contract")

// -- EIP-7825 errors --
ErrGasLimitTooHigh = errors.New("transaction gas limit too high")
)

// EIP-7702 state transition errors.
Expand Down
15 changes: 11 additions & 4 deletions core/state_processor_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -131,6 +131,7 @@ func TestStateProcessorErrors(t *testing.T) {
bigNumber := new(big.Int).SetBytes(common.MaxHash.Bytes())
tooBigNumber := new(big.Int).Set(bigNumber)
tooBigNumber.Add(tooBigNumber, common.Big1)
gasLimit := blockchain.CurrentHeader().GasLimit
for i, tt := range []struct {
txs []*types.Transaction
want string
Expand All @@ -156,9 +157,9 @@ func TestStateProcessorErrors(t *testing.T) {
},
{ // ErrGasLimitReached
txs: []*types.Transaction{
makeTx(key1, 0, common.Address{}, big.NewInt(0), 21000000, big.NewInt(875000000), nil),
makeTx(key1, 0, common.Address{}, big.NewInt(0), gasLimit+1, big.NewInt(875000000), nil),
},
want: "could not apply tx 0 [0xbd49d8dadfd47fb846986695f7d4da3f7b2c48c8da82dbc211a26eb124883de9]: gas limit reached",
want: "could not apply tx 0 [0xd0fb3ea181e800cd55c4637c55c1f2f78137efb6bb9723e50bda3cad97208db2]: gas limit reached",
},
{ // ErrInsufficientFundsForTransfer
txs: []*types.Transaction{
Expand All @@ -184,9 +185,9 @@ func TestStateProcessorErrors(t *testing.T) {
},
{ // ErrGasLimitReached
txs: []*types.Transaction{
makeTx(key1, 0, common.Address{}, big.NewInt(0), params.TxGas*1000, big.NewInt(875000000), nil),
makeTx(key1, 0, common.Address{}, big.NewInt(0), gasLimit+1, big.NewInt(875000000), nil),
},
want: "could not apply tx 0 [0xbd49d8dadfd47fb846986695f7d4da3f7b2c48c8da82dbc211a26eb124883de9]: gas limit reached",
want: "could not apply tx 0 [0xd0fb3ea181e800cd55c4637c55c1f2f78137efb6bb9723e50bda3cad97208db2]: gas limit reached",
},
{ // ErrFeeCapTooLow
txs: []*types.Transaction{
Expand Down Expand Up @@ -255,6 +256,12 @@ func TestStateProcessorErrors(t *testing.T) {
},
// ErrSetCodeTxCreate cannot be tested here: it is impossible to create a SetCode-tx with nil `to`.
// The EstimateGas API tests test this case.
{ // ErrGasLimitTooHigh
txs: []*types.Transaction{
makeTx(key1, 0, common.Address{}, big.NewInt(0), params.MaxTxGas+1, big.NewInt(875000000), nil),
},
want: "could not apply tx 0 [0x16505812a6da0b0150593e4d4eb90190ba64816a04b27d19ca926ebd6aff8aa0]: transaction gas limit too high (cap: 16777216, tx: 16777217)",
},
} {
block := GenerateBadBlock(gspec.ToBlock(), beacon.New(ethash.NewFaker()), tt.txs, gspec.Config, false)
_, err := blockchain.InsertChain(types.Blocks{block}, false)
Expand Down
19 changes: 15 additions & 4 deletions core/state_transition.go
Original file line number Diff line number Diff line change
Expand Up @@ -179,8 +179,12 @@ type Message struct {
// or the state prefetching.
SkipNonceChecks bool

// When SkipFromEOACheck is true, the message sender is not checked to be an EOA.
SkipFromEOACheck bool
// When set, the message is not treated as a transaction, and certain
// transaction-specific checks are skipped:
//
// - From is not verified to be an EOA
// - GasLimit is not checked against the protocol defined tx gaslimit
SkipTransactionChecks bool
}

// TransactionToMessage converts a transaction into a Message.
Expand All @@ -197,7 +201,7 @@ func TransactionToMessage(tx *types.Transaction, s types.Signer, baseFee *big.In
AccessList: tx.AccessList(),
SetCodeAuthorizations: tx.SetCodeAuthorizations(),
SkipNonceChecks: false,
SkipFromEOACheck: false,
SkipTransactionChecks: false,
BlobHashes: tx.BlobHashes(),
BlobGasFeeCap: tx.BlobGasFeeCap(),
}
Expand Down Expand Up @@ -351,7 +355,14 @@ func (st *stateTransition) preCheck() error {
msg.From.Hex(), stNonce)
}
}
if !msg.SkipFromEOACheck {
isOsaka := st.evm.ChainConfig().IsOsaka(st.evm.Context.BlockNumber)
isMadhugiri := st.evm.ChainConfig().Bor != nil && st.evm.ChainConfig().Bor.IsMadhugiri(st.evm.Context.BlockNumber)

if !msg.SkipTransactionChecks {
// Verify tx gas limit does not exceed EIP-7825 cap.
if (isOsaka || isMadhugiri) && msg.GasLimit > params.MaxTxGas {
return fmt.Errorf("%w (cap: %d, tx: %d)", ErrGasLimitTooHigh, params.MaxTxGas, msg.GasLimit)
}
// Make sure the sender is an EOA
code := st.state.GetCode(msg.From)
_, delegated := types.ParseDelegation(code)
Expand Down
5 changes: 5 additions & 0 deletions core/txpool/blobpool/blobpool.go
Original file line number Diff line number Diff line change
Expand Up @@ -1639,6 +1639,11 @@ func (p *BlobPool) Pending(filter txpool.PendingFilter, interrupt *atomic.Bool)
break // blobfee too low, cannot be included, discard rest of txs from the account
}
}
if filter.GasLimitCap != 0 {
if tx.execGas > filter.GasLimitCap {
break // execution gas limit is too high
}
}
// Transaction was accepted according to the filter, append to the pending list
lazies = append(lazies, &txpool.LazyTransaction{
Pool: p,
Expand Down
34 changes: 30 additions & 4 deletions core/txpool/legacypool/legacypool.go
Original file line number Diff line number Diff line change
Expand Up @@ -589,11 +589,19 @@ func (pool *LegacyPool) Pending(filter txpool.PendingFilter, interrupt *atomic.B
txs := list.Flatten()

// If the miner requests tip enforcement, cap the lists now
if minTipBig != nil {
if minTipBig != nil || filter.GasLimitCap != 0 {
for i, tx := range txs {
if tx.EffectiveGasTipIntCmp(minTipBig, baseFeeBig) < 0 {
txs = txs[:i]
break
if minTipBig != nil {
if tx.EffectiveGasTipIntCmp(minTipBig, baseFeeBig) < 0 {
txs = txs[:i]
break
}
}
if filter.GasLimitCap != 0 {
if tx.Gas() > filter.GasLimitCap {
Comment thread
marcello33 marked this conversation as resolved.
txs = txs[:i]
break
}
}
}
}
Expand Down Expand Up @@ -1377,6 +1385,24 @@ func (pool *LegacyPool) runReorg(done chan struct{}, reset *txpoolResetRequest,
lockTime := time.Now()
pool.mu.Lock()
if reset != nil {
if reset.newHead != nil && reset.oldHead != nil {
// Bor: EIP-7825 at Madhugiri HF block
isOsaka := pool.chainconfig.IsOsaka(reset.newHead.Number) && !pool.chainconfig.IsOsaka(reset.oldHead.Number)
isMadhugiri := pool.chainconfig.Bor != nil && (pool.chainconfig.Bor.IsMadhugiri(reset.newHead.Number) && !pool.chainconfig.Bor.IsMadhugiri(reset.oldHead.Number))
// Discard the transactions with the gas limit higher than the cap.
if isOsaka || isMadhugiri {
var hashes []common.Hash
pool.all.Range(func(hash common.Hash, tx *types.Transaction) bool {
if tx.Gas() > params.MaxTxGas {
hashes = append(hashes, hash)
}
return true
})
for _, hash := range hashes {
pool.removeTx(hash, true, true)
}
}
}
// Reset from the old head to the new, rescheduling any reorged transactions
pool.reset(reset.oldHead, reset.newHead)

Expand Down
7 changes: 4 additions & 3 deletions core/txpool/subpool.go
Original file line number Diff line number Diff line change
Expand Up @@ -74,9 +74,10 @@ type LazyResolver interface {
// a very specific call site in mind and each one can be evaluated very cheaply
// by the pool implementations. Only add new ones that satisfy those constraints.
type PendingFilter struct {
MinTip *uint256.Int // Minimum miner tip required to include a transaction
BaseFee *uint256.Int // Minimum 1559 basefee needed to include a transaction
BlobFee *uint256.Int // Minimum 4844 blobfee needed to include a blob transaction
MinTip *uint256.Int // Minimum miner tip required to include a transaction
BaseFee *uint256.Int // Minimum 1559 basefee needed to include a transaction
BlobFee *uint256.Int // Minimum 4844 blobfee needed to include a blob transaction
GasLimitCap uint64 // Maximum gas can be used for a single transaction execution (0 means no limit)

OnlyPlainTxs bool // Return only plain EVM transactions (peer-join announces, block space filling)
OnlyBlobTxs bool // Return only blob transactions (block blob-space filling)
Expand Down
4 changes: 4 additions & 0 deletions core/txpool/validation.go
Original file line number Diff line number Diff line change
Expand Up @@ -92,6 +92,10 @@ func ValidateTransaction(tx *types.Transaction, head *types.Header, signer types
if rules.IsShanghai && tx.To() == nil && len(tx.Data()) > params.MaxInitCodeSize {
return fmt.Errorf("%w: code size %v, limit %v", core.ErrMaxInitCodeSizeExceeded, len(tx.Data()), params.MaxInitCodeSize)
}
// Bor: EIP-7825 at Madhugiri HF block
if (rules.IsOsaka || rules.IsMadhugiri) && tx.Gas() > params.MaxTxGas {
return fmt.Errorf("%w (cap: %d, tx: %d)", core.ErrGasLimitTooHigh, params.MaxTxGas, tx.Gas())
}
// Transactions can't be negative. This may never happen using RLP decoded
// transactions but may occur for transactions created using the RPC.
if tx.Value().Sign() < 0 {
Expand Down
31 changes: 30 additions & 1 deletion core/vm/contracts.go
Original file line number Diff line number Diff line change
Expand Up @@ -164,7 +164,30 @@ var PrecompiledContractsOsaka = PrecompiledContracts{
common.BytesToAddress([]byte{0x11}): &bls12381MapG2{},
}

// PrecompiledContractsMadhugiri contains the set of pre-compiled Ethereum
// contracts used in the Madhugiri release (bor HF).
var PrecompiledContractsMadhugiri = PrecompiledContracts{
common.BytesToAddress([]byte{0x01}): &ecrecover{},
common.BytesToAddress([]byte{0x02}): &sha256hash{},
common.BytesToAddress([]byte{0x03}): &ripemd160hash{},
common.BytesToAddress([]byte{0x04}): &dataCopy{},
common.BytesToAddress([]byte{0x05}): &bigModExp{eip2565: true, eip7823: true, eip7883: true},
common.BytesToAddress([]byte{0x06}): &bn256AddIstanbul{},
common.BytesToAddress([]byte{0x07}): &bn256ScalarMulIstanbul{},
common.BytesToAddress([]byte{0x08}): &bn256PairingIstanbul{},
common.BytesToAddress([]byte{0x09}): &blake2F{},
common.BytesToAddress([]byte{0x0a}): &kzgPointEvaluation{},
common.BytesToAddress([]byte{0x0b}): &bls12381G1Add{},
common.BytesToAddress([]byte{0x0c}): &bls12381G1MultiExp{},
common.BytesToAddress([]byte{0x0d}): &bls12381G2Add{},
common.BytesToAddress([]byte{0x0e}): &bls12381G2MultiExp{},
common.BytesToAddress([]byte{0x0f}): &bls12381Pairing{},
common.BytesToAddress([]byte{0x10}): &bls12381MapG1{},
common.BytesToAddress([]byte{0x11}): &bls12381MapG2{},
}

var (
PrecompiledAddressesMadhugiri []common.Address
PrecompiledAddressesOsaka []common.Address
PrecompiledAddressesPrague []common.Address
PrecompiledAddressesCancun []common.Address
Expand Down Expand Up @@ -203,6 +226,8 @@ func init() {

func activePrecompiledContracts(rules params.Rules) PrecompiledContracts {
switch {
case rules.IsMadhugiri:
return PrecompiledContractsMadhugiri
case rules.IsVerkle:
return PrecompiledContractsVerkle
case rules.IsOsaka:
Expand Down Expand Up @@ -230,6 +255,8 @@ func ActivePrecompiledContracts(rules params.Rules) PrecompiledContracts {
// ActivePrecompiles returns the precompile addresses enabled with the current configuration.
func ActivePrecompiles(rules params.Rules) []common.Address {
switch {
case rules.IsMadhugiri:
return PrecompiledAddressesMadhugiri
case rules.IsOsaka:
return PrecompiledAddressesOsaka
case rules.IsPrague:
Expand Down Expand Up @@ -479,7 +506,9 @@ func (c *bigModExp) RequiredGas(input []byte) uint64 {
gas.Mul(gas, adjExpLen)
}
// 2. Different divisor (`GQUADDIVISOR`) (3)
gas.Div(gas, big3)
if !c.eip7883 {
gas.Div(gas, big3)
}

if gas.BitLen() > 64 {
return math.MaxUint64
Expand Down
2 changes: 2 additions & 0 deletions core/vm/jump_table_export.go
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,8 @@ func LookupInstructionSet(rules params.Rules) (JumpTable, error) {
switch {
case rules.IsVerkle:
return newCancunInstructionSet(), errors.New("verkle-fork not defined yet")
case rules.IsMadhugiri:
return newPragueInstructionSet(), errors.New("madhugiri-fork not defined yet")
case rules.IsOsaka:
return newPragueInstructionSet(), errors.New("osaka-fork not defined yet")
case rules.IsPrague:
Expand Down
Loading
Loading