Skip to content

Commit ac118cb

Browse files
committed
fix P256VerifyGas after galileo upgrade
1 parent b36da0c commit ac118cb

File tree

2 files changed

+11
-5
lines changed

2 files changed

+11
-5
lines changed

core/vm/contracts.go

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -140,7 +140,7 @@ var PrecompiledContractsEuclidV2 = map[common.Address]PrecompiledContract{
140140
common.BytesToAddress([]byte{7}): &bn256ScalarMulIstanbul{},
141141
common.BytesToAddress([]byte{8}): &bn256PairingIstanbul{limitInputLength: true},
142142
common.BytesToAddress([]byte{9}): &blake2FDisabled{},
143-
common.BytesToAddress([]byte{0x01, 0x00}): &p256Verify{},
143+
common.BytesToAddress([]byte{0x01, 0x00}): &p256Verify{eip7951: false},
144144
}
145145

146146
// PrecompiledContractsFeynman contains the default set of pre-compiled Ethereum
@@ -155,7 +155,7 @@ var PrecompiledContractsFeynman = map[common.Address]PrecompiledContract{
155155
common.BytesToAddress([]byte{7}): &bn256ScalarMulIstanbul{},
156156
common.BytesToAddress([]byte{8}): &bn256PairingIstanbul{limitInputLength: false},
157157
common.BytesToAddress([]byte{9}): &blake2FDisabled{},
158-
common.BytesToAddress([]byte{0x01, 0x00}): &p256Verify{},
158+
common.BytesToAddress([]byte{0x01, 0x00}): &p256Verify{eip7951: false},
159159
}
160160

161161
// PrecompiledContractsGalileo contains the default set of pre-compiled Ethereum
@@ -170,7 +170,7 @@ var PrecompiledContractsGalileo = map[common.Address]PrecompiledContract{
170170
common.BytesToAddress([]byte{7}): &bn256ScalarMulIstanbul{},
171171
common.BytesToAddress([]byte{8}): &bn256PairingIstanbul{limitInputLength: false},
172172
common.BytesToAddress([]byte{9}): &blake2FDisabled{},
173-
common.BytesToAddress([]byte{0x01, 0x00}): &p256Verify{},
173+
common.BytesToAddress([]byte{0x01, 0x00}): &p256Verify{eip7951: true},
174174
}
175175

176176
// PrecompiledContractsBLS contains the set of pre-compiled Ethereum
@@ -1331,10 +1331,15 @@ func (c *bls12381MapG2) Run(input []byte) ([]byte, error) {
13311331

13321332
// P256VERIFY (secp256r1 signature verification)
13331333
// implemented as a native contract
1334-
type p256Verify struct{}
1334+
type p256Verify struct {
1335+
eip7951 bool
1336+
}
13351337

13361338
// RequiredGas returns the gas required to execute the precompiled contract
13371339
func (c *p256Verify) RequiredGas(input []byte) uint64 {
1340+
if c.eip7951 {
1341+
return params.P256VerifyGasGalileo
1342+
}
13381343
return params.P256VerifyGas
13391344
}
13401345

params/protocol_params.go

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -162,7 +162,8 @@ const (
162162
Bls12381MapG1Gas uint64 = 5500 // Gas price for BLS12-381 mapping field element to G1 operation
163163
Bls12381MapG2Gas uint64 = 110000 // Gas price for BLS12-381 mapping field element to G2 operation
164164

165-
P256VerifyGas uint64 = 3450 // secp256r1 elliptic curve signature verifier gas price
165+
P256VerifyGas uint64 = 3450 // secp256r1 elliptic curve signature verifier gas price after euclidv2 upgrade
166+
P256VerifyGasGalileo uint64 = 6900 // secp256r1 elliptic curve signature verifier gas price after galileo upgrade
166167

167168
// The Refund Quotient is the cap on how much of the used gas can be refunded. Before EIP-3529,
168169
// up to half the consumed gas could be refunded. Redefined as 1/5th in EIP-3529

0 commit comments

Comments
 (0)