Skip to content

Commit d4f8dcb

Browse files
s1naMariusVanDerWijden
authored andcommitted
core/vm: implement EIP-2537 spec updates (#30978)
Reference: - Remove MUL precompiles: ethereum/EIPs#8945 - Pricing change for pairing operation: ethereum/EIPs#9098 - Pricing change for add, mapping and mul operations: ethereum/EIPs#9097 - Pricing change for MSM operations: ethereum/EIPs#9116 --------- Co-authored-by: Marius van der Wijden <[email protected]>
1 parent 78de582 commit d4f8dcb

File tree

3 files changed

+4
-74
lines changed

3 files changed

+4
-74
lines changed

tests/fuzzers/bls12381/bls12381_fuzz.go

Lines changed: 0 additions & 50 deletions
Original file line numberDiff line numberDiff line change
@@ -225,56 +225,6 @@ func fuzzCrossG1MultiExp(data []byte) int {
225225
return 1
226226
}
227227

228-
func fuzzCrossG1Mul(data []byte) int {
229-
input := bytes.NewReader(data)
230-
gp, blpAffine, err := getG1Points(input)
231-
if err != nil {
232-
return 0
233-
}
234-
scalar, err := randomScalar(input, fp.Modulus())
235-
if err != nil {
236-
return 0
237-
}
238-
239-
blScalar := new(blst.Scalar).FromBEndian(common.LeftPadBytes(scalar.Bytes(), 32))
240-
241-
blp := new(blst.P1)
242-
blp.FromAffine(blpAffine)
243-
244-
resBl := blp.Mult(blScalar)
245-
resGeth := (new(gnark.G1Affine)).ScalarMultiplication(gp, scalar)
246-
247-
if !bytes.Equal(resGeth.Marshal(), resBl.Serialize()) {
248-
panic("bytes(blst.G1) != bytes(geth.G1)")
249-
}
250-
return 1
251-
}
252-
253-
func fuzzCrossG2Mul(data []byte) int {
254-
input := bytes.NewReader(data)
255-
gp, blpAffine, err := getG2Points(input)
256-
if err != nil {
257-
return 0
258-
}
259-
scalar, err := randomScalar(input, fp.Modulus())
260-
if err != nil {
261-
return 0
262-
}
263-
264-
blScalar := new(blst.Scalar).FromBEndian(common.LeftPadBytes(scalar.Bytes(), 32))
265-
266-
blp := new(blst.P2)
267-
blp.FromAffine(blpAffine)
268-
269-
resBl := blp.Mult(blScalar)
270-
resGeth := (new(gnark.G2Affine)).ScalarMultiplication(gp, scalar)
271-
272-
if !bytes.Equal(resGeth.Marshal(), resBl.Serialize()) {
273-
panic("bytes(blst.G1) != bytes(geth.G1)")
274-
}
275-
return 1
276-
}
277-
278228
func fuzzCrossG2MultiExp(data []byte) int {
279229
var (
280230
input = bytes.NewReader(data)

tests/fuzzers/bls12381/bls12381_test.go

Lines changed: 0 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -57,12 +57,6 @@ func FuzzG1Add(f *testing.F) {
5757
})
5858
}
5959

60-
func FuzzCrossG1Mul(f *testing.F) {
61-
f.Fuzz(func(t *testing.T, data []byte) {
62-
fuzzCrossG1Mul(data)
63-
})
64-
}
65-
6660
func FuzzG1MultiExp(f *testing.F) {
6761
f.Fuzz(func(t *testing.T, data []byte) {
6862
fuzz(blsG1MultiExp, data)
@@ -75,12 +69,6 @@ func FuzzG2Add(f *testing.F) {
7569
})
7670
}
7771

78-
func FuzzCrossG2Mul(f *testing.F) {
79-
f.Fuzz(func(t *testing.T, data []byte) {
80-
fuzzCrossG2Mul(data)
81-
})
82-
}
83-
8472
func FuzzG2MultiExp(f *testing.F) {
8573
f.Fuzz(func(t *testing.T, data []byte) {
8674
fuzz(blsG2MultiExp, data)
@@ -116,15 +104,3 @@ func FuzzG2SubgroupChecks(f *testing.F) {
116104
fuzzG2SubgroupChecks(data)
117105
})
118106
}
119-
120-
func FuzzG2Mul(f *testing.F) {
121-
f.Fuzz(func(t *testing.T, data []byte) {
122-
fuzz(blsG2Mul, data)
123-
})
124-
}
125-
126-
func FuzzG1Mul(f *testing.F) {
127-
f.Fuzz(func(t *testing.T, data []byte) {
128-
fuzz(blsG1Mul, data)
129-
})
130-
}

tests/state_test.go

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -54,6 +54,10 @@ func initMatcher(st *testMatcher) {
5454
// Uses 1GB RAM per tested fork
5555
st.skipLoad(`^stStaticCall/static_Call1MB`)
5656

57+
// Out-of-date EIP-2537 tests
58+
// TODO (@s1na) reenable in the future
59+
st.skipLoad(`^stEIP2537/`)
60+
5761
// Broken tests:
5862
// EOF is not part of cancun
5963
st.skipLoad(`^stEOF/`)

0 commit comments

Comments
 (0)