@@ -47,6 +47,7 @@ import (
4747type PrecompiledContract interface {
4848 RequiredGas (input []byte ) uint64 // RequiredPrice calculates the contract gas use
4949 Run (input []byte ) ([]byte , error ) // Run runs the precompiled contract
50+ Name () string
5051}
5152
5253// PrecompiledContracts contains the precompiled contracts supported at the given fork.
@@ -309,6 +310,10 @@ func (c *ecrecover) Run(input []byte) ([]byte, error) {
309310 return common .LeftPadBytes (crypto .Keccak256 (pubKey [1 :])[12 :], 32 ), nil
310311}
311312
313+ func (c * ecrecover ) Name () string {
314+ return "ECREC"
315+ }
316+
312317// SHA256 implemented as a native contract.
313318type sha256hash struct {}
314319
@@ -324,6 +329,10 @@ func (c *sha256hash) Run(input []byte) ([]byte, error) {
324329 return h [:], nil
325330}
326331
332+ func (c * sha256hash ) Name () string {
333+ return "SHA256"
334+ }
335+
327336// RIPEMD160 implemented as a native contract.
328337type ripemd160hash struct {}
329338
@@ -340,6 +349,10 @@ func (c *ripemd160hash) Run(input []byte) ([]byte, error) {
340349 return common .LeftPadBytes (ripemd .Sum (nil ), 32 ), nil
341350}
342351
352+ func (c * ripemd160hash ) Name () string {
353+ return "RIPEMD160"
354+ }
355+
343356// data copy implemented as a native contract.
344357type dataCopy struct {}
345358
@@ -354,6 +367,10 @@ func (c *dataCopy) Run(in []byte) ([]byte, error) {
354367 return common .CopyBytes (in ), nil
355368}
356369
370+ func (c * dataCopy ) Name () string {
371+ return "ID"
372+ }
373+
357374// bigModExp implements a native big integer exponential modular operation.
358375type bigModExp struct {
359376 eip2565 bool
@@ -543,6 +560,10 @@ func (c *bigModExp) Run(input []byte) ([]byte, error) {
543560 return common .LeftPadBytes (v , int (modLen )), nil
544561}
545562
563+ func (c * bigModExp ) Name () string {
564+ return "MODEXP"
565+ }
566+
546567// newCurvePoint unmarshals a binary blob into a bn256 elliptic curve point,
547568// returning it, or an error if the point is invalid.
548569func newCurvePoint (blob []byte ) (* bn256.G1 , error ) {
@@ -592,6 +613,10 @@ func (c *bn256AddIstanbul) Run(input []byte) ([]byte, error) {
592613 return runBn256Add (input )
593614}
594615
616+ func (c * bn256AddIstanbul ) Name () string {
617+ return "BN254_ADD"
618+ }
619+
595620// bn256AddByzantium implements a native elliptic curve point addition
596621// conforming to Byzantium consensus rules.
597622type bn256AddByzantium struct {}
@@ -605,6 +630,10 @@ func (c *bn256AddByzantium) Run(input []byte) ([]byte, error) {
605630 return runBn256Add (input )
606631}
607632
633+ func (c * bn256AddByzantium ) Name () string {
634+ return "BN254_ADD"
635+ }
636+
608637// runBn256ScalarMul implements the Bn256ScalarMul precompile, referenced by
609638// both Byzantium and Istanbul operations.
610639func runBn256ScalarMul (input []byte ) ([]byte , error ) {
@@ -630,6 +659,10 @@ func (c *bn256ScalarMulIstanbul) Run(input []byte) ([]byte, error) {
630659 return runBn256ScalarMul (input )
631660}
632661
662+ func (c * bn256ScalarMulIstanbul ) Name () string {
663+ return "BN254_MUL"
664+ }
665+
633666// bn256ScalarMulByzantium implements a native elliptic curve scalar
634667// multiplication conforming to Byzantium consensus rules.
635668type bn256ScalarMulByzantium struct {}
@@ -643,6 +676,10 @@ func (c *bn256ScalarMulByzantium) Run(input []byte) ([]byte, error) {
643676 return runBn256ScalarMul (input )
644677}
645678
679+ func (c * bn256ScalarMulByzantium ) Name () string {
680+ return "BN254_MUL"
681+ }
682+
646683var (
647684 // true32Byte is returned if the bn256 pairing check succeeds.
648685 true32Byte = []byte {0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 1 }
@@ -698,6 +735,10 @@ func (c *bn256PairingIstanbul) Run(input []byte) ([]byte, error) {
698735 return runBn256Pairing (input )
699736}
700737
738+ func (c * bn256PairingIstanbul ) Name () string {
739+ return "BN254_PAIRING"
740+ }
741+
701742// bn256PairingByzantium implements a pairing pre-compile for the bn256 curve
702743// conforming to Byzantium consensus rules.
703744type bn256PairingByzantium struct {}
@@ -711,6 +752,10 @@ func (c *bn256PairingByzantium) Run(input []byte) ([]byte, error) {
711752 return runBn256Pairing (input )
712753}
713754
755+ func (c * bn256PairingByzantium ) Name () string {
756+ return "BN254_PAIRING"
757+ }
758+
714759type blake2F struct {}
715760
716761func (c * blake2F ) RequiredGas (input []byte ) uint64 {
@@ -772,6 +817,10 @@ func (c *blake2F) Run(input []byte) ([]byte, error) {
772817 return output , nil
773818}
774819
820+ func (c * blake2F ) Name () string {
821+ return "BLAKE2F"
822+ }
823+
775824var (
776825 errBLS12381InvalidInputLength = errors .New ("invalid input length" )
777826 errBLS12381InvalidFieldElementTopBytes = errors .New ("invalid field element top bytes" )
@@ -815,6 +864,10 @@ func (c *bls12381G1Add) Run(input []byte) ([]byte, error) {
815864 return encodePointG1 (p0 ), nil
816865}
817866
867+ func (c * bls12381G1Add ) Name () string {
868+ return "BLS12_G1ADD"
869+ }
870+
818871// bls12381G1MultiExp implements EIP-2537 G1MultiExp precompile.
819872type bls12381G1MultiExp struct {}
820873
@@ -875,6 +928,10 @@ func (c *bls12381G1MultiExp) Run(input []byte) ([]byte, error) {
875928 return encodePointG1 (r ), nil
876929}
877930
931+ func (c * bls12381G1MultiExp ) Name () string {
932+ return "BLS12_G1MSM"
933+ }
934+
878935// bls12381G2Add implements EIP-2537 G2Add precompile.
879936type bls12381G2Add struct {}
880937
@@ -912,6 +969,10 @@ func (c *bls12381G2Add) Run(input []byte) ([]byte, error) {
912969 return encodePointG2 (r ), nil
913970}
914971
972+ func (c * bls12381G2Add ) Name () string {
973+ return "BLS12_G2ADD"
974+ }
975+
915976// bls12381G2MultiExp implements EIP-2537 G2MultiExp precompile.
916977type bls12381G2MultiExp struct {}
917978
@@ -972,6 +1033,10 @@ func (c *bls12381G2MultiExp) Run(input []byte) ([]byte, error) {
9721033 return encodePointG2 (r ), nil
9731034}
9741035
1036+ func (c * bls12381G2MultiExp ) Name () string {
1037+ return "BLS12_G2MSM"
1038+ }
1039+
9751040// bls12381Pairing implements EIP-2537 Pairing precompile.
9761041type bls12381Pairing struct {}
9771042
@@ -1035,6 +1100,10 @@ func (c *bls12381Pairing) Run(input []byte) ([]byte, error) {
10351100 return out , nil
10361101}
10371102
1103+ func (c * bls12381Pairing ) Name () string {
1104+ return "BLS12_PAIRING_CHECK"
1105+ }
1106+
10381107func decodePointG1 (in []byte ) (* bls12381.G1Affine , error ) {
10391108 if len (in ) != 128 {
10401109 return nil , errors .New ("invalid g1 point length" )
@@ -1153,6 +1222,10 @@ func (c *bls12381MapG1) Run(input []byte) ([]byte, error) {
11531222 return encodePointG1 (& r ), nil
11541223}
11551224
1225+ func (c * bls12381MapG1 ) Name () string {
1226+ return "BLS12_MAP_FP_TO_G1"
1227+ }
1228+
11561229// bls12381MapG2 implements EIP-2537 MapG2 precompile.
11571230type bls12381MapG2 struct {}
11581231
@@ -1186,6 +1259,10 @@ func (c *bls12381MapG2) Run(input []byte) ([]byte, error) {
11861259 return encodePointG2 (& r ), nil
11871260}
11881261
1262+ func (c * bls12381MapG2 ) Name () string {
1263+ return "BLS12_MAP_FP2_TO_G2"
1264+ }
1265+
11891266// kzgPointEvaluation implements the EIP-4844 point evaluation precompile.
11901267type kzgPointEvaluation struct {}
11911268
@@ -1242,6 +1319,10 @@ func (b *kzgPointEvaluation) Run(input []byte) ([]byte, error) {
12421319 return common .Hex2Bytes (blobPrecompileReturnValue ), nil
12431320}
12441321
1322+ func (b * kzgPointEvaluation ) Name () string {
1323+ return "KZG_POINT_EVALUATION"
1324+ }
1325+
12451326// kZGToVersionedHash implements kzg_to_versioned_hash from EIP-4844
12461327func kZGToVersionedHash (kzg kzg4844.Commitment ) common.Hash {
12471328 h := sha256 .Sum256 (kzg [:])
@@ -1277,3 +1358,7 @@ func (c *p256Verify) Run(input []byte) ([]byte, error) {
12771358 }
12781359 return nil , nil
12791360}
1361+
1362+ func (c * p256Verify ) Name () string {
1363+ return "P256VERIFY"
1364+ }
0 commit comments