Skip to content

Commit a0b97be

Browse files
feat(consensus): introduce AnchorV3GasLimit (#378)
* feat(consensus): introduce `AnchorV3GasLimit` * feat(consensus): introduce `AnchorV3GasLimit`
1 parent 7bf5c0d commit a0b97be

File tree

3 files changed

+26
-3
lines changed

3 files changed

+26
-3
lines changed

consensus/taiko/consensus.go

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,8 @@ var (
3939
AnchorV3Selector = crypto.Keccak256(
4040
[]byte("anchorV3(uint64,bytes32,bytes32,uint32,(uint8,uint8,uint32,uint64,uint32),bytes32[])"),
4141
)[:4]
42-
AnchorGasLimit = uint64(250_000)
42+
AnchorGasLimit = uint64(250_000)
43+
AnchorV3GasLimit = uint64(1_000_000)
4344
)
4445

4546
// Taiko is a consensus engine used by L2 rollup.
@@ -313,8 +314,14 @@ func (t *Taiko) ValidateAnchorTx(tx *types.Transaction, header *types.Header) (b
313314
return false, nil
314315
}
315316

316-
if tx.Gas() != AnchorGasLimit {
317-
return false, nil
317+
if t.chainConfig.IsPacaya(header.Number) {
318+
if tx.Gas() != AnchorV3GasLimit {
319+
return false, nil
320+
}
321+
} else {
322+
if tx.Gas() != AnchorGasLimit {
323+
return false, nil
324+
}
318325
}
319326

320327
if tx.GasFeeCap().Cmp(header.BaseFee) != 0 {

core/taiko_genesis.go

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,11 @@ var (
1414
PreconfDevnetOntakeBlock = common.Big0
1515
HeklaOntakeBlock = new(big.Int).SetUint64(840_512)
1616
MainnetOntakeBlock = new(big.Int).SetUint64(538_304)
17+
18+
InternalDevnetPacayaBlock = new(big.Int).SetUint64(10)
19+
PreconfDevnetPacayaBlock = common.Big0
20+
HeklaPacayaBlock = new(big.Int).SetUint64(999_999_999_999)
21+
MainnetPacayaBlock = new(big.Int).SetUint64(999_999_999_999)
1722
)
1823

1924
// TaikoGenesisBlock returns the Taiko network genesis block configs.
@@ -25,10 +30,12 @@ func TaikoGenesisBlock(networkID uint64) *Genesis {
2530
case params.TaikoMainnetNetworkID.Uint64():
2631
chainConfig.ChainID = params.TaikoMainnetNetworkID
2732
chainConfig.OntakeBlock = MainnetOntakeBlock
33+
chainConfig.PacayaBlock = MainnetPacayaBlock
2834
allocJSON = taikoGenesis.MainnetGenesisAllocJSON
2935
case params.TaikoInternalL2ANetworkID.Uint64():
3036
chainConfig.ChainID = params.TaikoInternalL2ANetworkID
3137
chainConfig.OntakeBlock = InternalDevnetOntakeBlock
38+
chainConfig.PacayaBlock = InternalDevnetPacayaBlock
3239
allocJSON = taikoGenesis.InternalL2AGenesisAllocJSON
3340
case params.TaikoInternalL2BNetworkID.Uint64():
3441
chainConfig.ChainID = params.TaikoInternalL2BNetworkID
@@ -54,14 +61,17 @@ func TaikoGenesisBlock(networkID uint64) *Genesis {
5461
case params.HeklaNetworkID.Uint64():
5562
chainConfig.ChainID = params.HeklaNetworkID
5663
chainConfig.OntakeBlock = HeklaOntakeBlock
64+
chainConfig.PacayaBlock = HeklaPacayaBlock
5765
allocJSON = taikoGenesis.HeklaGenesisAllocJSON
5866
case params.PreconfDevnetNetworkID.Uint64():
5967
chainConfig.ChainID = params.PreconfDevnetNetworkID
6068
chainConfig.OntakeBlock = PreconfDevnetOntakeBlock
69+
chainConfig.PacayaBlock = PreconfDevnetPacayaBlock
6170
allocJSON = taikoGenesis.PreconfDevnetGenesisAllocJSON
6271
default:
6372
chainConfig.ChainID = params.TaikoInternalL2ANetworkID
6473
chainConfig.OntakeBlock = InternalDevnetOntakeBlock
74+
chainConfig.PacayaBlock = InternalDevnetPacayaBlock
6575
allocJSON = taikoGenesis.InternalL2AGenesisAllocJSON
6676
}
6777

params/config.go

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -359,6 +359,7 @@ type ChainConfig struct {
359359
// CHANGE(taiko): Taiko network flag.
360360
Taiko bool `json:"taiko"`
361361
OntakeBlock *big.Int `json:"ontakeBlock,omitempty"` // Ontake switch block (nil = no fork, 0 = already activated)
362+
PacayaBlock *big.Int `json:"pacayaBlock,omitempty"` // Ontake switch block (nil = no fork, 0 = already activated)
362363
}
363364

364365
// EthashConfig is the consensus engine configs for proof-of-work based sealing.
@@ -580,6 +581,11 @@ func (c *ChainConfig) IsOntake(num *big.Int) bool {
580581
return isBlockForked(c.OntakeBlock, num)
581582
}
582583

584+
// CHANGE(taiko): IsPacaya returns whether num is either equal to the pacaya fork block or greater.
585+
func (c *ChainConfig) IsPacaya(num *big.Int) bool {
586+
return isBlockForked(c.PacayaBlock, num)
587+
}
588+
583589
// IsEIP4762 returns whether eip 4762 has been activated at given block.
584590
func (c *ChainConfig) IsEIP4762(num *big.Int, time uint64) bool {
585591
return c.IsVerkle(num, time)

0 commit comments

Comments
 (0)