Skip to content

Commit a3b5c4c

Browse files
marcello33lucca30
andauthored
v2.5.0 candidate (ethereum#1878)
* chore: MadhugiriPro hf * params: use stable tag * chore: set new HF heights * Reinforce Precompile Check on any new HF (ethereum#1881) * Include missing check of P256 on Amoy (ethereum#1877) * checks p256 instruction * lint fix * reinforce precompilers check --------- Co-authored-by: Lucca Martins <[email protected]>
1 parent c8412f6 commit a3b5c4c

File tree

8 files changed

+154
-43
lines changed

8 files changed

+154
-43
lines changed

builder/files/genesis-mainnet-v1.json

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -23,13 +23,14 @@
2323
"ahmedabadBlock": 62278656,
2424
"bhilaiBlock": 73440256,
2525
"rioBlock": 77414656,
26-
"madhugiriBlock": 79783223,
26+
"madhugiriBlock": 80084800,
27+
"madhugiriProBlock": 80084800,
2728
"stateSyncConfirmationDelay": {
2829
"44934656": 128
2930
},
3031
"period": {
3132
"0": 2,
32-
"79783223": 1
33+
"80084800": 1
3334
},
3435
"producerDelay": {
3536
"0": 6,
@@ -43,7 +44,7 @@
4344
"0": 2
4445
},
4546
"coinbase": {
46-
"0": "0x0000000000000000000000000000000000000000",
47+
"0": "0x0000000000000000000000000000000000000000",
4748
"77414656": "0x7Ee41D8A25641000661B1EF5E6AE8A00400466B0"
4849
},
4950
"validatorContract": "0x0000000000000000000000000000000000001000",
@@ -60,7 +61,11 @@
6061
"14953856": 0
6162
},
6263
"overrideStateSyncRecordsInRange": [
63-
{ "startBlock": 73812433, "endBlock": 73826700, "value": 0 }
64+
{
65+
"startBlock": 73812433,
66+
"endBlock": 73826700,
67+
"value": 0
68+
}
6469
],
6570
"blockAlloc": {
6671
"22156660": {

core/vm/contracts.go

Lines changed: 39 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -186,15 +186,39 @@ var PrecompiledContractsMadhugiri = PrecompiledContracts{
186186
common.BytesToAddress([]byte{0x11}): &bls12381MapG2{},
187187
}
188188

189+
// PrecompiledContractsMadhugiriPro contains the set of pre-compiled Ethereum
190+
// contracts used in the MadhugiriPro release (bor HF).
191+
var PrecompiledContractsMadhugiriPro = PrecompiledContracts{
192+
common.BytesToAddress([]byte{0x01}): &ecrecover{},
193+
common.BytesToAddress([]byte{0x02}): &sha256hash{},
194+
common.BytesToAddress([]byte{0x03}): &ripemd160hash{},
195+
common.BytesToAddress([]byte{0x04}): &dataCopy{},
196+
common.BytesToAddress([]byte{0x05}): &bigModExp{eip2565: true, eip7823: true, eip7883: true},
197+
common.BytesToAddress([]byte{0x06}): &bn256AddIstanbul{},
198+
common.BytesToAddress([]byte{0x07}): &bn256ScalarMulIstanbul{},
199+
common.BytesToAddress([]byte{0x08}): &bn256PairingIstanbul{},
200+
common.BytesToAddress([]byte{0x09}): &blake2F{},
201+
common.BytesToAddress([]byte{0x0a}): &kzgPointEvaluation{},
202+
common.BytesToAddress([]byte{0x0b}): &bls12381G1Add{},
203+
common.BytesToAddress([]byte{0x0c}): &bls12381G1MultiExp{},
204+
common.BytesToAddress([]byte{0x0d}): &bls12381G2Add{},
205+
common.BytesToAddress([]byte{0x0e}): &bls12381G2MultiExp{},
206+
common.BytesToAddress([]byte{0x0f}): &bls12381Pairing{},
207+
common.BytesToAddress([]byte{0x10}): &bls12381MapG1{},
208+
common.BytesToAddress([]byte{0x11}): &bls12381MapG2{},
209+
common.BytesToAddress([]byte{0x01, 0x00}): &p256Verify{},
210+
}
211+
189212
var (
190-
PrecompiledAddressesMadhugiri []common.Address
191-
PrecompiledAddressesOsaka []common.Address
192-
PrecompiledAddressesPrague []common.Address
193-
PrecompiledAddressesCancun []common.Address
194-
PrecompiledAddressesBerlin []common.Address
195-
PrecompiledAddressesIstanbul []common.Address
196-
PrecompiledAddressesByzantium []common.Address
197-
PrecompiledAddressesHomestead []common.Address
213+
PrecompiledAddressesMadhugiriPro []common.Address
214+
PrecompiledAddressesMadhugiri []common.Address
215+
PrecompiledAddressesOsaka []common.Address
216+
PrecompiledAddressesPrague []common.Address
217+
PrecompiledAddressesCancun []common.Address
218+
PrecompiledAddressesBerlin []common.Address
219+
PrecompiledAddressesIstanbul []common.Address
220+
PrecompiledAddressesByzantium []common.Address
221+
PrecompiledAddressesHomestead []common.Address
198222
)
199223

200224
func init() {
@@ -225,10 +249,15 @@ func init() {
225249
for k := range PrecompiledContractsMadhugiri {
226250
PrecompiledAddressesMadhugiri = append(PrecompiledAddressesMadhugiri, k)
227251
}
252+
for k := range PrecompiledContractsMadhugiriPro {
253+
PrecompiledAddressesMadhugiriPro = append(PrecompiledAddressesMadhugiriPro, k)
254+
}
228255
}
229256

230257
func activePrecompiledContracts(rules params.Rules) PrecompiledContracts {
231258
switch {
259+
case rules.IsMadhugiriPro:
260+
return PrecompiledContractsMadhugiriPro
232261
case rules.IsMadhugiri:
233262
return PrecompiledContractsMadhugiri
234263
case rules.IsVerkle:
@@ -258,6 +287,8 @@ func ActivePrecompiledContracts(rules params.Rules) PrecompiledContracts {
258287
// ActivePrecompiles returns the precompile addresses enabled with the current configuration.
259288
func ActivePrecompiles(rules params.Rules) []common.Address {
260289
switch {
290+
case rules.IsMadhugiriPro:
291+
return PrecompiledAddressesMadhugiriPro
261292
case rules.IsMadhugiri:
262293
return PrecompiledAddressesMadhugiri
263294
case rules.IsOsaka:

core/vm/contracts_test.go

Lines changed: 62 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@ import (
2323
"math"
2424
"math/big"
2525
"os"
26+
"reflect"
2627
"testing"
2728
"time"
2829

@@ -458,3 +459,64 @@ func TestPrecompiledP256VerifyAlwaysAvailableInHFs(t *testing.T) {
458459
assert.Equal(t, &p256Verify{}, preCompiledContracts[precompiledP256VerifyAddress])
459460
}
460461
}
462+
463+
// If this test failed, it likely means a new HF were introduced and is very likely that PreCompiles got changed (by introducing new ones, changing olds ones or removing).
464+
// Please follow the instructions here to properly handle this new HF
465+
//
466+
// 1. Make sure if p256Verify were properly set on this Hardfork, it was introduced by us in PIP-27
467+
//
468+
// 2. Double check all the changes on the preCompiles of the current HF and the new one.
469+
// You should also pay attention for any params changes like in &bigModExp{eip2565: true, eip7823: true, eip7883: true}
470+
// Make sure all changes reflects the Ethereum's new proposals while reflecting the changes we did internally. Currently just PIP-27
471+
//
472+
// 3. Check if Erigon reflects the exact same configuration for the PreCompiles, including also the same params for precompiles
473+
//
474+
// 4. Runs a e2e test which includes all the preCompiles in a single transaction. If a new preCompile were introduced, please reflect the new one on the tests
475+
// The test must run on a multiclient network, including both Erigon and Bor. The test is available in our e2e repository.
476+
//
477+
// 5. After all checks done, you can increase insert the NewHF on the expected list to make the test pass
478+
func TestReinforceMultiClientPreCompilesTest(t *testing.T) {
479+
rulesType := reflect.TypeOf(params.Rules{})
480+
481+
// Extract actual field names
482+
actual := make([]string, 0, rulesType.NumField())
483+
for i := 0; i < rulesType.NumField(); i++ {
484+
actual = append(actual, rulesType.Field(i).Name)
485+
}
486+
487+
// Expected field names (in order)
488+
expected := []string{
489+
"ChainID",
490+
"IsHomestead",
491+
"IsEIP150",
492+
"IsEIP155",
493+
"IsEIP158",
494+
"IsEIP2929",
495+
"IsEIP4762",
496+
"IsByzantium",
497+
"IsConstantinople",
498+
"IsPetersburg",
499+
"IsIstanbul",
500+
"IsBerlin",
501+
"IsLondon",
502+
"IsMerge",
503+
"IsShanghai",
504+
"IsCancun",
505+
"IsPrague",
506+
"IsOsaka",
507+
"IsVerkle",
508+
"IsMadhugiri",
509+
"IsMadhugiriPro",
510+
}
511+
512+
if len(actual) != len(expected) {
513+
t.Fatalf("A new hardfork were detected. Please read and follow the instruction on the comment section of this test")
514+
}
515+
516+
// Compare names one-by-one for stability
517+
for i := range expected {
518+
if actual[i] != expected[i] {
519+
t.Fatalf("A new hardfork were detected. Please read and follow the instruction on the comment section of this test")
520+
}
521+
}
522+
}

core/vm/jump_table_export.go

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,8 @@ func LookupInstructionSet(rules params.Rules) (JumpTable, error) {
2828
switch {
2929
case rules.IsVerkle:
3030
return newCancunInstructionSet(), errors.New("verkle-fork not defined yet")
31+
case rules.IsMadhugiriPro:
32+
return newPragueInstructionSet(), errors.New("madhugiriPro-fork not defined yet")
3133
case rules.IsMadhugiri:
3234
return newPragueInstructionSet(), errors.New("madhugiri-fork not defined yet")
3335
case rules.IsOsaka:

internal/cli/server/chains/amoy.go

Lines changed: 8 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -30,13 +30,14 @@ var amoyTestnet = &Chain{
3030
CancunBlock: big.NewInt(5423600),
3131
PragueBlock: big.NewInt(22765056),
3232
Bor: &params.BorConfig{
33-
JaipurBlock: big.NewInt(73100),
34-
DelhiBlock: big.NewInt(73100),
35-
IndoreBlock: big.NewInt(73100),
36-
AhmedabadBlock: big.NewInt(11865856),
37-
BhilaiBlock: big.NewInt(22765056),
38-
RioBlock: big.NewInt(26272256),
39-
MadhugiriBlock: big.NewInt(28899616),
33+
JaipurBlock: big.NewInt(73100),
34+
DelhiBlock: big.NewInt(73100),
35+
IndoreBlock: big.NewInt(73100),
36+
AhmedabadBlock: big.NewInt(11865856),
37+
BhilaiBlock: big.NewInt(22765056),
38+
RioBlock: big.NewInt(26272256),
39+
MadhugiriBlock: big.NewInt(28899616),
40+
MadhugiriProBlock: big.NewInt(29287400),
4041
StateSyncConfirmationDelay: map[string]uint64{
4142
"0": 128,
4243
},

internal/cli/server/chains/mainnet.go

Lines changed: 9 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -31,19 +31,20 @@ var mainnetBor = &Chain{
3131
CancunBlock: big.NewInt(54876000),
3232
PragueBlock: big.NewInt(73440256),
3333
Bor: &params.BorConfig{
34-
JaipurBlock: big.NewInt(23850000),
35-
DelhiBlock: big.NewInt(38189056),
36-
IndoreBlock: big.NewInt(44934656),
37-
AhmedabadBlock: big.NewInt(62278656),
38-
BhilaiBlock: big.NewInt(73440256),
39-
RioBlock: big.NewInt(77414656),
40-
MadhugiriBlock: big.NewInt(79783223),
34+
JaipurBlock: big.NewInt(23850000),
35+
DelhiBlock: big.NewInt(38189056),
36+
IndoreBlock: big.NewInt(44934656),
37+
AhmedabadBlock: big.NewInt(62278656),
38+
BhilaiBlock: big.NewInt(73440256),
39+
RioBlock: big.NewInt(77414656),
40+
MadhugiriBlock: big.NewInt(80084800),
41+
MadhugiriProBlock: big.NewInt(80084800),
4142
StateSyncConfirmationDelay: map[string]uint64{
4243
"44934656": 128,
4344
},
4445
Period: map[string]uint64{
4546
"0": 2,
46-
"79783223": 1,
47+
"80084800": 1,
4748
},
4849
ProducerDelay: map[string]uint64{
4950
"0": 6,

params/config.go

Lines changed: 24 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -332,13 +332,14 @@ var (
332332
CancunBlock: big.NewInt(5423600),
333333
PragueBlock: big.NewInt(22765056),
334334
Bor: &BorConfig{
335-
JaipurBlock: big.NewInt(73100),
336-
DelhiBlock: big.NewInt(73100),
337-
IndoreBlock: big.NewInt(73100),
338-
AhmedabadBlock: big.NewInt(11865856),
339-
BhilaiBlock: big.NewInt(22765056),
340-
RioBlock: big.NewInt(26272256),
341-
MadhugiriBlock: big.NewInt(28899616),
335+
JaipurBlock: big.NewInt(73100),
336+
DelhiBlock: big.NewInt(73100),
337+
IndoreBlock: big.NewInt(73100),
338+
AhmedabadBlock: big.NewInt(11865856),
339+
BhilaiBlock: big.NewInt(22765056),
340+
RioBlock: big.NewInt(26272256),
341+
MadhugiriBlock: big.NewInt(28899616),
342+
MadhugiriProBlock: big.NewInt(29287400),
342343
StateSyncConfirmationDelay: map[string]uint64{
343344
"0": 128,
344345
},
@@ -414,20 +415,21 @@ var (
414415
CancunBlock: big.NewInt(54876000),
415416
PragueBlock: big.NewInt(73440256),
416417
Bor: &BorConfig{
417-
JaipurBlock: big.NewInt(23850000),
418-
DelhiBlock: big.NewInt(38189056),
419-
IndoreBlock: big.NewInt(44934656),
420-
AhmedabadBlock: big.NewInt(62278656),
421-
BhilaiBlock: big.NewInt(73440256),
422-
RioBlock: big.NewInt(77414656),
423-
MadhugiriBlock: big.NewInt(79783223),
418+
JaipurBlock: big.NewInt(23850000),
419+
DelhiBlock: big.NewInt(38189056),
420+
IndoreBlock: big.NewInt(44934656),
421+
AhmedabadBlock: big.NewInt(62278656),
422+
BhilaiBlock: big.NewInt(73440256),
423+
RioBlock: big.NewInt(77414656),
424+
MadhugiriBlock: big.NewInt(80084800),
425+
MadhugiriProBlock: big.NewInt(80084800),
424426
StateSyncConfirmationDelay: map[string]uint64{
425427
"44934656": 128,
426428
},
427429

428430
Period: map[string]uint64{
429431
"0": 2,
430-
"79783223": 1,
432+
"80084800": 1,
431433
},
432434
ProducerDelay: map[string]uint64{
433435
"0": 6,
@@ -885,6 +887,7 @@ type BorConfig struct {
885887
BhilaiBlock *big.Int `json:"bhilaiBlock"` // Bhilai switch block (nil = no fork, 0 = already on bhilai)
886888
RioBlock *big.Int `json:"rioBlock"` // Rio switch block (nil = no fork, 0 = already on rio)
887889
MadhugiriBlock *big.Int `json:"madhugiriBlock"` // Madhugiri switch block (nil = no fork, 0 = already on madhugiri)
890+
MadhugiriProBlock *big.Int `json:"madhugiriProBlock"` // MadhugiriPro switch block (nil = no fork, 0 = already on madhugiriPro)
888891
}
889892

890893
// String implements the stringer interface, returning the consensus engine details.
@@ -940,6 +943,10 @@ func (c *BorConfig) IsMadhugiri(number *big.Int) bool {
940943
return isBlockForked(c.MadhugiriBlock, number)
941944
}
942945

946+
func (c *BorConfig) IsMadhugiriPro(number *big.Int) bool {
947+
return isBlockForked(c.MadhugiriProBlock, number)
948+
}
949+
943950
// // TODO: modify this function once the block number is finalized
944951
// func (c *BorConfig) IsNapoli(number *big.Int) bool {
945952
// if c.NapoliBlock != nil {
@@ -1640,6 +1647,7 @@ type Rules struct {
16401647
IsMerge, IsShanghai, IsCancun, IsPrague, IsOsaka bool
16411648
IsVerkle bool
16421649
IsMadhugiri bool
1650+
IsMadhugiriPro bool
16431651
}
16441652

16451653
// Rules ensures c's ChainID is not nil.
@@ -1672,5 +1680,6 @@ func (c *ChainConfig) Rules(num *big.Int, isMerge bool, timestamp uint64) Rules
16721680
IsOsaka: c.IsOsaka(num),
16731681
IsEIP4762: c.IsVerkle(num),
16741682
IsMadhugiri: c.Bor != nil && c.Bor.IsMadhugiri(num),
1683+
IsMadhugiriPro: c.Bor != nil && c.Bor.IsMadhugiriPro(num),
16751684
}
16761685
}

params/version.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ import (
2424

2525
const (
2626
VersionMajor = 2 // Major version component of the current release
27-
VersionMinor = 4 // Minor version component of the current release
27+
VersionMinor = 5 // Minor version component of the current release
2828
VersionPatch = 0 // Patch version component of the current release
2929
VersionMeta = "" // Version metadata to append to the version string
3030
)

0 commit comments

Comments
 (0)