Skip to content
Merged
Show file tree
Hide file tree
Changes from 7 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
5 changes: 5 additions & 0 deletions .github/workflows/kurtosis-e2e.yml
Original file line number Diff line number Diff line change
Expand Up @@ -86,6 +86,7 @@ jobs:
- name: Pre kurtosis run
uses: ./.github/actions/setup
with:
main_branch: develop
docker_username: ${{ secrets.DOCKERHUB }}
docker_token: ${{ secrets.DOCKERHUB_KEY }}

Expand Down Expand Up @@ -129,6 +130,9 @@ jobs:
- name: Inspect enclave
run: kurtosis enclave inspect ${{ env.ENCLAVE_NAME }}

- name: Sleep for 1 minute
run: sleep 60

- name: Test state syncs
uses: ./.github/actions/test-state-sync
with:
Expand Down Expand Up @@ -165,4 +169,5 @@ jobs:
if: always()
uses: ./.github/actions/cleanup
with:
main_branch: develop
enclave_name: ${{ env.ENCLAVE_NAME }}
2 changes: 2 additions & 0 deletions .github/workflows/kurtosis-stateless-e2e.yml
Original file line number Diff line number Diff line change
Expand Up @@ -86,6 +86,7 @@ jobs:
- name: Pre kurtosis run
uses: ./.github/actions/setup
with:
main_branch: develop
docker_username: ${{ secrets.DOCKERHUB }}
docker_token: ${{ secrets.DOCKERHUB_KEY }}

Expand Down Expand Up @@ -154,4 +155,5 @@ jobs:
if: always()
uses: ./.github/actions/cleanup
with:
main_branch: develop
enclave_name: ${{ env.ENCLAVE_NAME }}
31 changes: 31 additions & 0 deletions core/vm/contracts.go
Original file line number Diff line number Diff line change
Expand Up @@ -224,7 +224,31 @@ var PrecompiledContractsMadhugiriPro = PrecompiledContracts{
common.BytesToAddress([]byte{0x01, 0x00}): &p256Verify{},
}

// PrecompiledContractsTBDHF contains the set of pre-compiled Ethereum
// contracts used in the TBDHF release (bor HF).
var PrecompiledContractsTBDHF = 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{},
common.BytesToAddress([]byte{0x01, 0x00}): &p256Verify{eip7951: true},
}

var (
PrecompiledAddressesTBDHF []common.Address
PrecompiledAddressesMadhugiriPro []common.Address
PrecompiledAddressesMadhugiri []common.Address
PrecompiledAddressesOsaka []common.Address
Expand Down Expand Up @@ -267,10 +291,15 @@ func init() {
for k := range PrecompiledContractsMadhugiriPro {
PrecompiledAddressesMadhugiriPro = append(PrecompiledAddressesMadhugiriPro, k)
}
for k := range PrecompiledContractsTBDHF {
PrecompiledAddressesTBDHF = append(PrecompiledAddressesTBDHF, k)
}
}

func activePrecompiledContracts(rules params.Rules) PrecompiledContracts {
switch {
case rules.IsTBDHF:
return PrecompiledContractsTBDHF
case rules.IsMadhugiriPro:
return PrecompiledContractsMadhugiriPro
case rules.IsMadhugiri:
Expand Down Expand Up @@ -302,6 +331,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.IsTBDHF:
return PrecompiledAddressesTBDHF
case rules.IsMadhugiriPro:
return PrecompiledAddressesMadhugiriPro
case rules.IsMadhugiri:
Expand Down
39 changes: 39 additions & 0 deletions core/vm/contracts_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -534,6 +534,7 @@ func TestReinforceMultiClientPreCompilesTest(t *testing.T) {
"IsVerkle",
"IsMadhugiri",
"IsMadhugiriPro",
"IsTBDHF",
}

if len(actual) != len(expected) {
Expand All @@ -547,3 +548,41 @@ func TestReinforceMultiClientPreCompilesTest(t *testing.T) {
}
}
}

// TestTBDHFP256VerifyGasCost verifies P256 precompile gas cost changes at TBDHF.
func TestTBDHFP256VerifyGasCost(t *testing.T) {
preTBDHF := &p256Verify{eip7951: false}
postTBDHF := &p256Verify{eip7951: true}

preGas := preTBDHF.RequiredGas(nil)
postGas := postTBDHF.RequiredGas(nil)

if preGas != params.P256VerifyGas {
t.Errorf("pre-TBDHF gas: got %d, want %d", preGas, params.P256VerifyGas)
}
if postGas != params.P256VerifyGasEIP7951 {
t.Errorf("post-TBDHF gas: got %d, want %d", postGas, params.P256VerifyGasEIP7951)
}
if preGas >= postGas {
t.Errorf("post-TBDHF gas (%d) should be higher than pre-TBDHF (%d)", postGas, preGas)
}
}

// TestTBDHFCLZOpcode verifies CLZ opcode availability at TBDHF.
func TestTBDHFCLZOpcode(t *testing.T) {
preTBDHF := newPragueInstructionSet()
postTBDHF := newTBDHFInstructionSet()

// Pre-TBDHF: CLZ should be undefined.
if preTBDHF[CLZ].execute != nil && preTBDHF[CLZ].constantGas != 0 {
t.Error("CLZ opcode should not be defined pre-TBDHF")
}

// Post-TBDHF: CLZ should be defined.
if postTBDHF[CLZ].execute == nil {
t.Error("CLZ opcode should be defined post-TBDHF")
}
if postTBDHF[CLZ].constantGas != GasFastStep {
t.Errorf("CLZ gas: got %d, want %d", postTBDHF[CLZ].constantGas, GasFastStep)
}
}
3 changes: 2 additions & 1 deletion core/vm/evm.go
Original file line number Diff line number Diff line change
Expand Up @@ -150,10 +150,11 @@ func NewEVM(blockCtx BlockContext, statedb StateDB, chainConfig *params.ChainCon
evm.precompiles = activePrecompiledContracts(evm.chainRules)

switch {
case evm.chainRules.IsTBDHF:
evm.table = &tbdhfInstructionSet
case evm.chainRules.IsOsaka:
evm.table = &osakaInstructionSet
case evm.chainRules.IsVerkle:
// TODO replace with proper instruction set when fork is specified
evm.table = &verkleInstructionSet
case evm.chainRules.IsPrague:
evm.table = &pragueInstructionSet
Expand Down
13 changes: 10 additions & 3 deletions core/vm/jump_table.go
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,7 @@ var (
verkleInstructionSet = newVerkleInstructionSet()
pragueInstructionSet = newPragueInstructionSet()
osakaInstructionSet = newOsakaInstructionSet()
tbdhfInstructionSet = newTBDHFInstructionSet()
)

// JumpTable contains the EVM opcodes supported at a given fork.
Expand All @@ -87,9 +88,9 @@ func validate(jt JumpTable) JumpTable {
return jt
}

func newVerkleInstructionSet() JumpTable {
instructionSet := newShanghaiInstructionSet()
enable4762(&instructionSet)
func newTBDHFInstructionSet() JumpTable {
instructionSet := newPragueInstructionSet()
enable7939(&instructionSet) // EIP-7939 (CLZ opcode)
return validate(instructionSet)
}

Expand All @@ -99,6 +100,12 @@ func newOsakaInstructionSet() JumpTable {
return validate(instructionSet)
}

func newVerkleInstructionSet() JumpTable {
instructionSet := newShanghaiInstructionSet()
enable4762(&instructionSet)
return validate(instructionSet)
}

func newPragueInstructionSet() JumpTable {
instructionSet := newCancunInstructionSet()
enable7702(&instructionSet) // EIP-7702 Setcode transaction type
Expand Down
12 changes: 8 additions & 4 deletions core/vm/jump_table_export.go
Original file line number Diff line number Diff line change
Expand Up @@ -26,14 +26,18 @@ import (
// the rules.
func LookupInstructionSet(rules params.Rules) (JumpTable, error) {
switch {
case rules.IsVerkle:
return newCancunInstructionSet(), errors.New("verkle-fork not defined yet")
// Note: geth only returns an error for the verkle-fork.
// Return nil for other forks.
case rules.IsTBDHF:
return newTBDHFInstructionSet(), nil
case rules.IsMadhugiriPro:
return newPragueInstructionSet(), errors.New("madhugiriPro-fork not defined yet")
return newPragueInstructionSet(), nil
case rules.IsMadhugiri:
return newPragueInstructionSet(), errors.New("madhugiri-fork not defined yet")
return newPragueInstructionSet(), nil
case rules.IsOsaka:
return newOsakaInstructionSet(), nil
case rules.IsVerkle:
return newCancunInstructionSet(), errors.New("verkle-fork not defined yet")
case rules.IsPrague:
return newPragueInstructionSet(), nil
case rules.IsCancun:
Expand Down
1 change: 1 addition & 0 deletions internal/cli/server/chains/amoy.go
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@ var amoyTestnet = &Chain{
MadhugiriBlock: big.NewInt(28899616),
MadhugiriProBlock: big.NewInt(29287400),
DandeliBlock: big.NewInt(31890000),
TBDHFBlock: nil,
Comment thread
kamuikatsurgi marked this conversation as resolved.
Outdated
StateSyncConfirmationDelay: map[string]uint64{
"0": 128,
},
Expand Down
1 change: 1 addition & 0 deletions internal/cli/server/chains/mainnet.go
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,7 @@ var mainnetBor = &Chain{
MadhugiriBlock: big.NewInt(80084800),
MadhugiriProBlock: big.NewInt(80084800),
DandeliBlock: big.NewInt(81424000),
TBDHFBlock: nil,
StateSyncConfirmationDelay: map[string]uint64{
"44934656": 128,
},
Expand Down
11 changes: 11 additions & 0 deletions params/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -729,6 +729,7 @@ var (
MadhugiriBlock: big.NewInt(0),
MadhugiriProBlock: big.NewInt(0),
DandeliBlock: big.NewInt(0),
TBDHFBlock: big.NewInt(0),
},
}

Expand Down Expand Up @@ -928,6 +929,7 @@ type BorConfig struct {
MadhugiriBlock *big.Int `json:"madhugiriBlock"` // Madhugiri switch block (nil = no fork, 0 = already on madhugiri)
MadhugiriProBlock *big.Int `json:"madhugiriProBlock"` // MadhugiriPro switch block (nil = no fork, 0 = already on madhugiriPro)
DandeliBlock *big.Int `json:"dandeliBlock"` // Dandeli switch block (nil = no fork, 0 = already on dandeli)
TBDHFBlock *big.Int `json:"tbdhfBlock"` // TBDHF switch block (nil = no fork, 0 = already on tbdhf)
}

// String implements the stringer interface, returning the consensus engine details.
Expand Down Expand Up @@ -991,6 +993,10 @@ func (c *BorConfig) IsDandeli(number *big.Int) bool {
return isBlockForked(c.DandeliBlock, number)
}

func (c *BorConfig) IsTBDHF(number *big.Int) bool {
return isBlockForked(c.TBDHFBlock, number)
}

// GetTargetGasPercentage returns the target gas percentage for gas limit calculation.
// After Dandeli hard fork, this value can be configured via CLI flags (stored in BorConfig at runtime).
// It validates the configured value and falls back to defaults if invalid or nil.
Expand Down Expand Up @@ -1124,6 +1130,9 @@ func (c *ChainConfig) Description() string {
if c.Bor.DandeliBlock != nil {
banner += fmt.Sprintf(" - Dandeli: #%-8v\n", c.Bor.DandeliBlock)
}
if c.Bor.TBDHFBlock != nil {
banner += fmt.Sprintf(" - TBDHF: #%-8v\n", c.Bor.TBDHFBlock)
}
return banner
}

Expand Down Expand Up @@ -1760,6 +1769,7 @@ type Rules struct {
IsVerkle bool
IsMadhugiri bool
IsMadhugiriPro bool
IsTBDHF bool
}

// Rules ensures c's ChainID is not nil.
Expand Down Expand Up @@ -1793,5 +1803,6 @@ func (c *ChainConfig) Rules(num *big.Int, isMerge bool, _ uint64) Rules {
IsEIP4762: c.IsVerkle(num),
IsMadhugiri: c.Bor != nil && c.Bor.IsMadhugiri(num),
IsMadhugiriPro: c.Bor != nil && c.Bor.IsMadhugiriPro(num),
IsTBDHF: c.Bor != nil && c.Bor.IsTBDHF(num),
}
}
Loading