Skip to content

Commit b29a308

Browse files
authored
Merge branch 'develop' into feat-reject-txs-withmax-l1-data-fee-in-worker
2 parents f08fb8f + cc9a1dd commit b29a308

39 files changed

+461
-254
lines changed

accounts/abi/bind/backends/simulated.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -640,7 +640,7 @@ func (b *SimulatedBackend) callContract(ctx context.Context, call ethereum.CallM
640640
vmEnv := vm.NewEVM(evmContext, txContext, stateDB, b.config, vm.Config{NoBaseFee: true})
641641
gasPool := new(core.GasPool).AddGas(math.MaxUint64)
642642
signer := types.MakeSigner(b.blockchain.Config(), head.Number, head.Time)
643-
l1DataFee, err := fees.EstimateL1DataFeeForMessage(msg, head.BaseFee, b.blockchain.Config(), signer, stateDB, head.Number)
643+
l1DataFee, err := fees.EstimateL1DataFeeForMessage(msg, head.BaseFee, b.blockchain.Config(), signer, stateDB, head.Number, head.Time)
644644
if err != nil {
645645
return nil, err
646646
}

cmd/evm/internal/t8ntool/execution.go

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -152,6 +152,10 @@ func (pre *Prestate) Apply(vmConfig vm.Config, chainConfig *params.ChainConfig,
152152
if chainConfig.CurieBlock != nil && chainConfig.CurieBlock.Cmp(new(big.Int).SetUint64(pre.Env.Number)) == 0 {
153153
misc.ApplyCurieHardFork(statedb)
154154
}
155+
// Apply Feynman hard fork
156+
if chainConfig.IsFeynmanTransitionBlock(pre.Env.Timestamp, pre.Env.ParentTimestamp) {
157+
misc.ApplyFeynmanHardFork(statedb)
158+
}
155159
// Apply EIP-2935
156160
if pre.Env.BlockHashes != nil && chainConfig.IsFeynman(pre.Env.Timestamp) {
157161
var (
@@ -180,7 +184,7 @@ func (pre *Prestate) Apply(vmConfig vm.Config, chainConfig *params.ChainConfig,
180184
snapshot := statedb.Snapshot()
181185
evm := vm.NewEVM(vmContext, txContext, statedb, chainConfig, vmConfig)
182186

183-
l1DataFee, err := fees.CalculateL1DataFee(tx, statedb, chainConfig, new(big.Int).SetUint64(pre.Env.Number))
187+
l1DataFee, err := fees.CalculateL1DataFee(tx, statedb, chainConfig, new(big.Int).SetUint64(pre.Env.Number), pre.Env.Timestamp)
184188
if err != nil {
185189
log.Info("rejected tx due to fees.CalculateL1DataFee", "index", i, "hash", tx.Hash(), "from", msg.From(), "error", err)
186190
rejectedTxs = append(rejectedTxs, &rejectedTx{i, err.Error()})

cmd/geth/main.go

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -176,6 +176,8 @@ var (
176176
utils.CircuitCapacityCheckWorkersFlag,
177177
utils.RollupVerifyEnabledFlag,
178178
utils.ShadowforkPeersFlag,
179+
utils.TxGossipBroadcastDisabledFlag,
180+
utils.TxGossipReceivingDisabledFlag,
179181
utils.DASyncEnabledFlag,
180182
utils.DABlockNativeAPIEndpointFlag,
181183
utils.DABlobScanAPIEndpointFlag,

cmd/geth/usage.go

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -248,6 +248,8 @@ var AppHelpFlagGroups = []flags.FlagGroup{
248248
utils.DARecoveryProduceBlocksFlag,
249249
utils.CircuitCapacityCheckEnabledFlag,
250250
utils.CircuitCapacityCheckWorkersFlag,
251+
utils.TxGossipBroadcastDisabledFlag,
252+
utils.TxGossipReceivingDisabledFlag,
251253
},
252254
},
253255
{

cmd/utils/flags.go

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -893,6 +893,16 @@ var (
893893
Usage: "peer ids of shadow fork peers",
894894
}
895895

896+
// Tx gossip settings
897+
TxGossipBroadcastDisabledFlag = cli.BoolFlag{
898+
Name: "txgossip.disablebroadcast",
899+
Usage: "Disable gossip broadcast transactions to other peers",
900+
}
901+
TxGossipReceivingDisabledFlag = cli.BoolFlag{
902+
Name: "txgossip.disablereceiving",
903+
Usage: "Disable gossip receiving transactions from other peers",
904+
}
905+
896906
// DA syncing settings
897907
DASyncEnabledFlag = cli.BoolFlag{
898908
Name: "da.sync",
@@ -1790,6 +1800,14 @@ func SetEthConfig(ctx *cli.Context, stack *node.Node, cfg *ethconfig.Config) {
17901800
cfg.ShadowForkPeerIDs = ctx.GlobalStringSlice(ShadowforkPeersFlag.Name)
17911801
log.Info("Shadow fork peers", "ids", cfg.ShadowForkPeerIDs)
17921802
}
1803+
if ctx.GlobalIsSet(TxGossipBroadcastDisabledFlag.Name) {
1804+
cfg.TxGossipBroadcastDisabled = ctx.GlobalBool(TxGossipBroadcastDisabledFlag.Name)
1805+
log.Info("Transaction gossip broadcast disabled", "disabled", cfg.TxGossipBroadcastDisabled)
1806+
}
1807+
if ctx.GlobalIsSet(TxGossipReceivingDisabledFlag.Name) {
1808+
cfg.TxGossipReceivingDisabled = ctx.GlobalBool(TxGossipReceivingDisabledFlag.Name)
1809+
log.Info("Transaction gossip receiving disabled", "disabled", cfg.TxGossipReceivingDisabled)
1810+
}
17931811

17941812
// Cap the cache allowance and tune the garbage collector
17951813
mem, err := gopsutil.VirtualMemory()

consensus/misc/feynman.go

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
package misc
2+
3+
import (
4+
"github.com/scroll-tech/go-ethereum/common"
5+
"github.com/scroll-tech/go-ethereum/core/state"
6+
"github.com/scroll-tech/go-ethereum/log"
7+
"github.com/scroll-tech/go-ethereum/rollup/rcfg"
8+
)
9+
10+
// ApplyFeynmanHardFork modifies the state database according to the Feynman hard-fork rules,
11+
// updating the bytecode and storage of the L1GasPriceOracle contract.
12+
func ApplyFeynmanHardFork(statedb *state.StateDB) {
13+
log.Info("Applying Feynman hard fork")
14+
15+
// update contract byte code
16+
statedb.SetCode(rcfg.L1GasPriceOracleAddress, rcfg.FeynmanL1GasPriceOracleBytecode)
17+
18+
// initialize new storage slots
19+
statedb.SetState(rcfg.L1GasPriceOracleAddress, rcfg.IsFeynmanSlot, common.BytesToHash([]byte{1}))
20+
statedb.SetState(rcfg.L1GasPriceOracleAddress, rcfg.PenaltyThresholdSlot, common.BigToHash(rcfg.InitialPenaltyThreshold))
21+
statedb.SetState(rcfg.L1GasPriceOracleAddress, rcfg.PenaltyFactorSlot, common.BigToHash(rcfg.InitialPenaltyFactor))
22+
}

core/block_validator.go

Lines changed: 0 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -70,13 +70,6 @@ func (v *BlockValidator) ValidateBody(block *types.Block) error {
7070
if v.bc.HasBlockAndState(block.Hash(), block.NumberU64()) {
7171
return ErrKnownBlock
7272
}
73-
if !v.config.Scroll.IsValidTxCount(len(block.Transactions())) {
74-
return consensus.ErrInvalidTxCount
75-
}
76-
// Check if block payload size is smaller than the max size
77-
if !v.config.Scroll.IsValidBlockSize(block.PayloadSize()) {
78-
return ErrInvalidBlockPayloadSize
79-
}
8073
// Header validity is known at this point, check the uncles and transactions
8174
header := block.Header()
8275
if err := v.engine.VerifyUncles(v.bc, block); err != nil {
@@ -127,7 +120,6 @@ func (v *BlockValidator) ValidateL1Messages(block *types.Block) error {
127120
blockHash := block.Hash()
128121

129122
if v.config.Scroll.L1Config == nil {
130-
// TODO: should we allow follower nodes to skip L1 message verification?
131123
panic("Running on L1Message-enabled network but no l1Config was provided")
132124
}
133125

@@ -204,7 +196,6 @@ func (v *BlockValidator) ValidateL1Messages(block *types.Block) error {
204196
}
205197

206198
// skipped messages
207-
// TODO: consider verifying that skipped messages overflow
208199
for index := queueIndex; index < txQueueIndex; index++ {
209200
if exists := it.Next(); !exists {
210201
if err := it.Error(); err != nil {

core/blockchain_test.go

Lines changed: 0 additions & 127 deletions
Original file line numberDiff line numberDiff line change
@@ -3186,70 +3186,6 @@ func TestFeeVault(t *testing.T) {
31863186
}
31873187
}
31883188

3189-
// TestTransactionCountLimit tests that the chain reject blocks with too many transactions.
3190-
func TestTransactionCountLimit(t *testing.T) {
3191-
// Create config that allows at most 1 transaction per block
3192-
config := params.TestChainConfig
3193-
config.Scroll.MaxTxPerBlock = new(int)
3194-
*config.Scroll.MaxTxPerBlock = 1
3195-
defer func() {
3196-
config.Scroll.MaxTxPerBlock = nil
3197-
}()
3198-
3199-
var (
3200-
engine = ethash.NewFaker()
3201-
db = rawdb.NewMemoryDatabase()
3202-
key, _ = crypto.HexToECDSA("b71c71a67e1177ad4e901695e1b4b9ee17ae16c6668d313eac2f96dbcda3f291")
3203-
address = crypto.PubkeyToAddress(key.PublicKey)
3204-
funds = big.NewInt(1000000000000000)
3205-
gspec = &Genesis{Config: config, Alloc: GenesisAlloc{address: {Balance: funds}}}
3206-
genesis = gspec.MustCommit(db)
3207-
)
3208-
3209-
addTx := func(b *BlockGen) {
3210-
tx := types.NewTransaction(b.TxNonce(address), address, big.NewInt(0), 50000, b.header.BaseFee, nil)
3211-
signed, _ := types.SignTx(tx, types.HomesteadSigner{}, key)
3212-
b.AddTx(signed)
3213-
}
3214-
3215-
// Initialize blockchain
3216-
blockchain, err := NewBlockChain(db, nil, config, engine, vm.Config{}, nil, nil)
3217-
if err != nil {
3218-
t.Fatalf("failed to create new chain manager: %v", err)
3219-
}
3220-
defer blockchain.Stop()
3221-
3222-
// Insert empty block
3223-
block1, _ := GenerateChain(config, genesis, ethash.NewFaker(), db, 1, func(i int, b *BlockGen) {
3224-
// empty
3225-
})
3226-
3227-
if _, err := blockchain.InsertChain(block1); err != nil {
3228-
t.Fatalf("failed to insert chain: %v", err)
3229-
}
3230-
3231-
// Insert block with 1 transaction
3232-
block2, _ := GenerateChain(config, genesis, ethash.NewFaker(), db, 1, func(i int, b *BlockGen) {
3233-
addTx(b)
3234-
})
3235-
3236-
if _, err := blockchain.InsertChain(block2); err != nil {
3237-
t.Fatalf("failed to insert chain: %v", err)
3238-
}
3239-
3240-
// Insert block with 2 transactions
3241-
block3, _ := GenerateChain(config, genesis, ethash.NewFaker(), db, 1, func(i int, b *BlockGen) {
3242-
addTx(b)
3243-
addTx(b)
3244-
})
3245-
3246-
_, err = blockchain.InsertChain(block3)
3247-
3248-
if !errors.Is(err, consensus.ErrInvalidTxCount) {
3249-
t.Fatalf("error mismatch: have: %v, want: %v", err, consensus.ErrInvalidTxCount)
3250-
}
3251-
}
3252-
32533189
// TestInsertBlocksWithL1Messages tests that the chain accepts blocks with L1MessageTx transactions.
32543190
func TestInsertBlocksWithL1Messages(t *testing.T) {
32553191
var (
@@ -3443,69 +3379,6 @@ func TestL1MessageValidationFailure(t *testing.T) {
34433379
assert.Equal(t, uint64(4), *queueIndex)
34443380
}
34453381

3446-
func TestBlockPayloadSizeLimit(t *testing.T) {
3447-
// Create config that allows at most 150 bytes per block payload
3448-
config := params.TestChainConfig
3449-
config.Scroll.MaxTxPayloadBytesPerBlock = new(int)
3450-
*config.Scroll.MaxTxPayloadBytesPerBlock = 150
3451-
defer func() {
3452-
config.Scroll.MaxTxPayloadBytesPerBlock = nil
3453-
}()
3454-
3455-
var (
3456-
engine = ethash.NewFaker()
3457-
db = rawdb.NewMemoryDatabase()
3458-
key, _ = crypto.HexToECDSA("b71c71a67e1177ad4e901695e1b4b9ee17ae16c6668d313eac2f96dbcda3f291")
3459-
address = crypto.PubkeyToAddress(key.PublicKey)
3460-
funds = big.NewInt(1000000000000000)
3461-
gspec = &Genesis{Config: config, Alloc: GenesisAlloc{address: {Balance: funds}}}
3462-
genesis = gspec.MustCommit(db)
3463-
)
3464-
3465-
addTx := func(b *BlockGen) {
3466-
tx := types.NewTransaction(b.TxNonce(address), address, big.NewInt(0), 50000, b.header.BaseFee, nil)
3467-
signed, _ := types.SignTx(tx, types.HomesteadSigner{}, key)
3468-
b.AddTx(signed)
3469-
}
3470-
3471-
// Initialize blockchain
3472-
blockchain, err := NewBlockChain(db, nil, config, engine, vm.Config{}, nil, nil)
3473-
if err != nil {
3474-
t.Fatalf("failed to create new chain manager: %v", err)
3475-
}
3476-
defer blockchain.Stop()
3477-
3478-
// Insert empty block
3479-
block1, _ := GenerateChain(config, genesis, ethash.NewFaker(), db, 1, func(i int, b *BlockGen) {
3480-
// empty
3481-
})
3482-
3483-
if _, err := blockchain.InsertChain(block1); err != nil {
3484-
t.Fatalf("failed to insert chain: %v", err)
3485-
}
3486-
3487-
// Insert block with 1 transaction
3488-
block2, _ := GenerateChain(config, genesis, ethash.NewFaker(), db, 1, func(i int, b *BlockGen) {
3489-
addTx(b)
3490-
})
3491-
3492-
if _, err := blockchain.InsertChain(block2); err != nil {
3493-
t.Fatalf("failed to insert chain: %v", err)
3494-
}
3495-
3496-
// Insert block with 2 transactions
3497-
block3, _ := GenerateChain(config, genesis, ethash.NewFaker(), db, 1, func(i int, b *BlockGen) {
3498-
addTx(b)
3499-
addTx(b)
3500-
})
3501-
3502-
_, err = blockchain.InsertChain(block3)
3503-
3504-
if !errors.Is(err, ErrInvalidBlockPayloadSize) {
3505-
t.Fatalf("error mismatch: have: %v, want: %v", err, ErrInvalidBlockPayloadSize)
3506-
}
3507-
}
3508-
35093382
func TestEIP3651(t *testing.T) {
35103383
var (
35113384
addraa = common.HexToAddress("0x000000000000000000000000000000000000aaaa")

core/chain_makers.go

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -249,6 +249,9 @@ func GenerateChain(config *params.ChainConfig, parent *types.Block, engine conse
249249
if config.CurieBlock != nil && config.CurieBlock.Cmp(b.header.Number) == 0 {
250250
misc.ApplyCurieHardFork(statedb)
251251
}
252+
if config.IsFeynmanTransitionBlock(b.Time(), parent.Time()) {
253+
misc.ApplyFeynmanHardFork(statedb)
254+
}
252255
// Execute any user modifications to the block
253256
if gen != nil {
254257
gen(i, b)

core/state_prefetcher.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -71,7 +71,7 @@ func (p *statePrefetcher) Prefetch(block *types.Block, statedb *state.StateDB, c
7171
}
7272
statedb.SetTxContext(tx.Hash(), i)
7373

74-
l1DataFee, err := fees.CalculateL1DataFee(tx, statedb, p.config, block.Number())
74+
l1DataFee, err := fees.CalculateL1DataFee(tx, statedb, p.config, block.Number(), block.Time())
7575
if err != nil {
7676
return
7777
}

0 commit comments

Comments
 (0)