github.com/theQRL/go-zond@v0.1.1/core/vm/contracts_test.go (about)

     1  // Copyright 2017 The go-ethereum Authors
     2  // This file is part of the go-ethereum library.
     3  //
     4  // The go-ethereum library is free software: you can redistribute it and/or modify
     5  // it under the terms of the GNU Lesser General Public License as published by
     6  // the Free Software Foundation, either version 3 of the License, or
     7  // (at your option) any later version.
     8  //
     9  // The go-ethereum library is distributed in the hope that it will be useful,
    10  // but WITHOUT ANY WARRANTY; without even the implied warranty of
    11  // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
    12  // GNU Lesser General Public License for more details.
    13  //
    14  // You should have received a copy of the GNU Lesser General Public License
    15  // along with the go-ethereum library. If not, see <http://www.gnu.org/licenses/>.
    16  
    17  package vm
    18  
    19  import (
    20  	"bytes"
    21  	"encoding/json"
    22  	"fmt"
    23  	"os"
    24  	"testing"
    25  	"time"
    26  
    27  	"github.com/theQRL/go-zond/common"
    28  )
    29  
    30  // precompiledTest defines the input/output pairs for precompiled contract tests.
    31  type precompiledTest struct {
    32  	Input, Expected string
    33  	Gas             uint64
    34  	Name            string
    35  	NoBenchmark     bool // Benchmark primarily the worst-cases
    36  }
    37  
    38  // precompiledFailureTest defines the input/error pairs for precompiled
    39  // contract failure tests.
    40  type precompiledFailureTest struct {
    41  	Input         string
    42  	ExpectedError string
    43  	Name          string
    44  }
    45  
    46  // allPrecompiles does not map to the actual set of precompiles, as it also contains
    47  // repriced versions of precompiles at certain slots
    48  var allPrecompiles = map[common.Address]PrecompiledContract{
    49  	// common.BytesToAddress([]byte{1}):    &ecrecover{},
    50  	common.BytesToAddress([]byte{1}):    &depositroot{},
    51  	common.BytesToAddress([]byte{2}):    &sha256hash{},
    52  	common.BytesToAddress([]byte{3}):    &ripemd160hash{},
    53  	common.BytesToAddress([]byte{4}):    &dataCopy{},
    54  	common.BytesToAddress([]byte{5}):    &bigModExp{eip2565: false},
    55  	common.BytesToAddress([]byte{0xf5}): &bigModExp{eip2565: true},
    56  	common.BytesToAddress([]byte{6}):    &bn256AddIstanbul{},
    57  	common.BytesToAddress([]byte{7}):    &bn256ScalarMulIstanbul{},
    58  	common.BytesToAddress([]byte{8}):    &bn256PairingIstanbul{},
    59  	common.BytesToAddress([]byte{9}):    &blake2F{},
    60  	common.BytesToAddress([]byte{0x0a}): &kzgPointEvaluation{},
    61  
    62  	common.BytesToAddress([]byte{0x0f, 0x0a}): &bls12381G1Add{},
    63  	common.BytesToAddress([]byte{0x0f, 0x0b}): &bls12381G1Mul{},
    64  	common.BytesToAddress([]byte{0x0f, 0x0c}): &bls12381G1MultiExp{},
    65  	common.BytesToAddress([]byte{0x0f, 0x0d}): &bls12381G2Add{},
    66  	common.BytesToAddress([]byte{0x0f, 0x0e}): &bls12381G2Mul{},
    67  	common.BytesToAddress([]byte{0x0f, 0x0f}): &bls12381G2MultiExp{},
    68  	common.BytesToAddress([]byte{0x0f, 0x10}): &bls12381Pairing{},
    69  	common.BytesToAddress([]byte{0x0f, 0x11}): &bls12381MapG1{},
    70  	common.BytesToAddress([]byte{0x0f, 0x12}): &bls12381MapG2{},
    71  }
    72  
    73  // EIP-152 test vectors
    74  var blake2FMalformedInputTests = []precompiledFailureTest{
    75  	{
    76  		Input:         "",
    77  		ExpectedError: errBlake2FInvalidInputLength.Error(),
    78  		Name:          "vector 0: empty input",
    79  	},
    80  	{
    81  		Input:         "00000c48c9bdf267e6096a3ba7ca8485ae67bb2bf894fe72f36e3cf1361d5f3af54fa5d182e6ad7f520e511f6c3e2b8c68059b6bbd41fbabd9831f79217e1319cde05b61626300000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000300000000000000000000000000000001",
    82  		ExpectedError: errBlake2FInvalidInputLength.Error(),
    83  		Name:          "vector 1: less than 213 bytes input",
    84  	},
    85  	{
    86  		Input:         "000000000c48c9bdf267e6096a3ba7ca8485ae67bb2bf894fe72f36e3cf1361d5f3af54fa5d182e6ad7f520e511f6c3e2b8c68059b6bbd41fbabd9831f79217e1319cde05b61626300000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000300000000000000000000000000000001",
    87  		ExpectedError: errBlake2FInvalidInputLength.Error(),
    88  		Name:          "vector 2: more than 213 bytes input",
    89  	},
    90  	{
    91  		Input:         "0000000c48c9bdf267e6096a3ba7ca8485ae67bb2bf894fe72f36e3cf1361d5f3af54fa5d182e6ad7f520e511f6c3e2b8c68059b6bbd41fbabd9831f79217e1319cde05b61626300000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000300000000000000000000000000000002",
    92  		ExpectedError: errBlake2FInvalidFinalFlag.Error(),
    93  		Name:          "vector 3: malformed final block indicator flag",
    94  	},
    95  }
    96  
    97  func testPrecompiled(addr string, test precompiledTest, t *testing.T) {
    98  	p := allPrecompiles[common.HexToAddress(addr)]
    99  	in := common.Hex2Bytes(test.Input)
   100  	gas := p.RequiredGas(in)
   101  	t.Run(fmt.Sprintf("%s-Gas=%d", test.Name, gas), func(t *testing.T) {
   102  		if res, _, err := RunPrecompiledContract(p, in, gas); err != nil {
   103  			t.Error(err)
   104  		} else if common.Bytes2Hex(res) != test.Expected {
   105  			t.Errorf("Expected %v, got %v", test.Expected, common.Bytes2Hex(res))
   106  		}
   107  		if expGas := test.Gas; expGas != gas {
   108  			t.Errorf("%v: gas wrong, expected %d, got %d", test.Name, expGas, gas)
   109  		}
   110  		// Verify that the precompile did not touch the input buffer
   111  		exp := common.Hex2Bytes(test.Input)
   112  		if !bytes.Equal(in, exp) {
   113  			t.Errorf("Precompiled %v modified input data", addr)
   114  		}
   115  	})
   116  }
   117  
   118  func testPrecompiledOOG(addr string, test precompiledTest, t *testing.T) {
   119  	p := allPrecompiles[common.HexToAddress(addr)]
   120  	in := common.Hex2Bytes(test.Input)
   121  	gas := p.RequiredGas(in) - 1
   122  
   123  	t.Run(fmt.Sprintf("%s-Gas=%d", test.Name, gas), func(t *testing.T) {
   124  		_, _, err := RunPrecompiledContract(p, in, gas)
   125  		if err.Error() != "out of gas" {
   126  			t.Errorf("Expected error [out of gas], got [%v]", err)
   127  		}
   128  		// Verify that the precompile did not touch the input buffer
   129  		exp := common.Hex2Bytes(test.Input)
   130  		if !bytes.Equal(in, exp) {
   131  			t.Errorf("Precompiled %v modified input data", addr)
   132  		}
   133  	})
   134  }
   135  
   136  func testPrecompiledFailure(addr string, test precompiledFailureTest, t *testing.T) {
   137  	p := allPrecompiles[common.HexToAddress(addr)]
   138  	in := common.Hex2Bytes(test.Input)
   139  	gas := p.RequiredGas(in)
   140  	t.Run(test.Name, func(t *testing.T) {
   141  		_, _, err := RunPrecompiledContract(p, in, gas)
   142  		if err.Error() != test.ExpectedError {
   143  			t.Errorf("Expected error [%v], got [%v]", test.ExpectedError, err)
   144  		}
   145  		// Verify that the precompile did not touch the input buffer
   146  		exp := common.Hex2Bytes(test.Input)
   147  		if !bytes.Equal(in, exp) {
   148  			t.Errorf("Precompiled %v modified input data", addr)
   149  		}
   150  	})
   151  }
   152  
   153  func benchmarkPrecompiled(addr string, test precompiledTest, bench *testing.B) {
   154  	if test.NoBenchmark {
   155  		return
   156  	}
   157  	p := allPrecompiles[common.HexToAddress(addr)]
   158  	in := common.Hex2Bytes(test.Input)
   159  	reqGas := p.RequiredGas(in)
   160  
   161  	var (
   162  		res  []byte
   163  		err  error
   164  		data = make([]byte, len(in))
   165  	)
   166  
   167  	bench.Run(fmt.Sprintf("%s-Gas=%d", test.Name, reqGas), func(bench *testing.B) {
   168  		bench.ReportAllocs()
   169  		start := time.Now()
   170  		bench.ResetTimer()
   171  		for i := 0; i < bench.N; i++ {
   172  			copy(data, in)
   173  			res, _, err = RunPrecompiledContract(p, data, reqGas)
   174  		}
   175  		bench.StopTimer()
   176  		elapsed := uint64(time.Since(start))
   177  		if elapsed < 1 {
   178  			elapsed = 1
   179  		}
   180  		gasUsed := reqGas * uint64(bench.N)
   181  		bench.ReportMetric(float64(reqGas), "gas/op")
   182  		// Keep it as uint64, multiply 100 to get two digit float later
   183  		mgasps := (100 * 1000 * gasUsed) / elapsed
   184  		bench.ReportMetric(float64(mgasps)/100, "mgas/s")
   185  		//Check if it is correct
   186  		if err != nil {
   187  			bench.Error(err)
   188  			return
   189  		}
   190  		if common.Bytes2Hex(res) != test.Expected {
   191  			bench.Errorf("Expected %v, got %v", test.Expected, common.Bytes2Hex(res))
   192  			return
   193  		}
   194  	})
   195  }
   196  
   197  /*
   198  // Benchmarks the sample inputs from the ECRECOVER precompile.
   199  func BenchmarkPrecompiledEcrecover(bench *testing.B) {
   200  	t := precompiledTest{
   201  		Input:    "38d18acb67d25c8bb9942764b62f18e17054f66a817bd4295423adf9ed98873e000000000000000000000000000000000000000000000000000000000000001b38d18acb67d25c8bb9942764b62f18e17054f66a817bd4295423adf9ed98873e789d1dd423d25f0772d2748d60f7e4b81bb14d086eba8e8e8efb6dcff8a4ae02",
   202  		Expected: "000000000000000000000000ceaccac640adf55b2028469bd36ba501f28b699d",
   203  		Name:     "",
   204  	}
   205  	benchmarkPrecompiled("01", t, bench)
   206  }
   207  */
   208  
   209  // TODO(rgeraldes24)
   210  // Benchmarks the sample inputs from the DEPOSITROOT precompile.
   211  /*
   212  func BenchmarkPrecompiledDepositroot(bench *testing.B) {
   213  	t := precompiledTest{
   214  		Input:    "38d18acb67d25c8bb9942764b62f18e17054f66a817bd4295423adf9ed98873e000000000000000000000000000000000000000000000000000000000000001b38d18acb67d25c8bb9942764b62f18e17054f66a817bd4295423adf9ed98873e789d1dd423d25f0772d2748d60f7e4b81bb14d086eba8e8e8efb6dcff8a4ae02",
   215  		Expected: "000000000000000000000000ceaccac640adf55b2028469bd36ba501f28b699d",
   216  		Name:     "",
   217  	}
   218  	benchmarkPrecompiled("01", t, bench)
   219  }
   220  */
   221  
   222  // Benchmarks the sample inputs from the SHA256 precompile.
   223  func BenchmarkPrecompiledSha256(bench *testing.B) {
   224  	t := precompiledTest{
   225  		Input:    "38d18acb67d25c8bb9942764b62f18e17054f66a817bd4295423adf9ed98873e000000000000000000000000000000000000000000000000000000000000001b38d18acb67d25c8bb9942764b62f18e17054f66a817bd4295423adf9ed98873e789d1dd423d25f0772d2748d60f7e4b81bb14d086eba8e8e8efb6dcff8a4ae02",
   226  		Expected: "811c7003375852fabd0d362e40e68607a12bdabae61a7d068fe5fdd1dbbf2a5d",
   227  		Name:     "128",
   228  	}
   229  	benchmarkPrecompiled("02", t, bench)
   230  }
   231  
   232  // Benchmarks the sample inputs from the RIPEMD precompile.
   233  func BenchmarkPrecompiledRipeMD(bench *testing.B) {
   234  	t := precompiledTest{
   235  		Input:    "38d18acb67d25c8bb9942764b62f18e17054f66a817bd4295423adf9ed98873e000000000000000000000000000000000000000000000000000000000000001b38d18acb67d25c8bb9942764b62f18e17054f66a817bd4295423adf9ed98873e789d1dd423d25f0772d2748d60f7e4b81bb14d086eba8e8e8efb6dcff8a4ae02",
   236  		Expected: "0000000000000000000000009215b8d9882ff46f0dfde6684d78e831467f65e6",
   237  		Name:     "128",
   238  	}
   239  	benchmarkPrecompiled("03", t, bench)
   240  }
   241  
   242  // Benchmarks the sample inputs from the identiy precompile.
   243  func BenchmarkPrecompiledIdentity(bench *testing.B) {
   244  	t := precompiledTest{
   245  		Input:    "38d18acb67d25c8bb9942764b62f18e17054f66a817bd4295423adf9ed98873e000000000000000000000000000000000000000000000000000000000000001b38d18acb67d25c8bb9942764b62f18e17054f66a817bd4295423adf9ed98873e789d1dd423d25f0772d2748d60f7e4b81bb14d086eba8e8e8efb6dcff8a4ae02",
   246  		Expected: "38d18acb67d25c8bb9942764b62f18e17054f66a817bd4295423adf9ed98873e000000000000000000000000000000000000000000000000000000000000001b38d18acb67d25c8bb9942764b62f18e17054f66a817bd4295423adf9ed98873e789d1dd423d25f0772d2748d60f7e4b81bb14d086eba8e8e8efb6dcff8a4ae02",
   247  		Name:     "128",
   248  	}
   249  	benchmarkPrecompiled("04", t, bench)
   250  }
   251  
   252  // Tests the sample inputs from the ModExp EIP 198.
   253  func TestPrecompiledModExp(t *testing.T)      { testJson("modexp", "05", t) }
   254  func BenchmarkPrecompiledModExp(b *testing.B) { benchJson("modexp", "05", b) }
   255  
   256  func TestPrecompiledModExpEip2565(t *testing.T)      { testJson("modexp_eip2565", "f5", t) }
   257  func BenchmarkPrecompiledModExpEip2565(b *testing.B) { benchJson("modexp_eip2565", "f5", b) }
   258  
   259  // Tests the sample inputs from the elliptic curve addition EIP 213.
   260  func TestPrecompiledBn256Add(t *testing.T)      { testJson("bn256Add", "06", t) }
   261  func BenchmarkPrecompiledBn256Add(b *testing.B) { benchJson("bn256Add", "06", b) }
   262  
   263  // Tests OOG
   264  func TestPrecompiledModExpOOG(t *testing.T) {
   265  	modexpTests, err := loadJson("modexp")
   266  	if err != nil {
   267  		t.Fatal(err)
   268  	}
   269  	for _, test := range modexpTests {
   270  		testPrecompiledOOG("05", test, t)
   271  	}
   272  }
   273  
   274  // Tests the sample inputs from the elliptic curve scalar multiplication EIP 213.
   275  func TestPrecompiledBn256ScalarMul(t *testing.T)      { testJson("bn256ScalarMul", "07", t) }
   276  func BenchmarkPrecompiledBn256ScalarMul(b *testing.B) { benchJson("bn256ScalarMul", "07", b) }
   277  
   278  // Tests the sample inputs from the elliptic curve pairing check EIP 197.
   279  func TestPrecompiledBn256Pairing(t *testing.T)      { testJson("bn256Pairing", "08", t) }
   280  func BenchmarkPrecompiledBn256Pairing(b *testing.B) { benchJson("bn256Pairing", "08", b) }
   281  
   282  func TestPrecompiledBlake2F(t *testing.T)      { testJson("blake2F", "09", t) }
   283  func BenchmarkPrecompiledBlake2F(b *testing.B) { benchJson("blake2F", "09", b) }
   284  
   285  func TestPrecompileBlake2FMalformedInput(t *testing.T) {
   286  	for _, test := range blake2FMalformedInputTests {
   287  		testPrecompiledFailure("09", test, t)
   288  	}
   289  }
   290  
   291  // func TestPrecompiledEcrecover(t *testing.T) { testJson("ecRecover", "01", t) }
   292  
   293  // TODO(rgeraldes24)
   294  // func TestPrecompiledDepositroot(t *testing.T) { testJson("depositRoot", "01", t) }
   295  
   296  func testJson(name, addr string, t *testing.T) {
   297  	tests, err := loadJson(name)
   298  	if err != nil {
   299  		t.Fatal(err)
   300  	}
   301  	for _, test := range tests {
   302  		testPrecompiled(addr, test, t)
   303  	}
   304  }
   305  
   306  func testJsonFail(name, addr string, t *testing.T) {
   307  	tests, err := loadJsonFail(name)
   308  	if err != nil {
   309  		t.Fatal(err)
   310  	}
   311  	for _, test := range tests {
   312  		testPrecompiledFailure(addr, test, t)
   313  	}
   314  }
   315  
   316  func benchJson(name, addr string, b *testing.B) {
   317  	tests, err := loadJson(name)
   318  	if err != nil {
   319  		b.Fatal(err)
   320  	}
   321  	for _, test := range tests {
   322  		benchmarkPrecompiled(addr, test, b)
   323  	}
   324  }
   325  
   326  func TestPrecompiledBLS12381G1Add(t *testing.T)      { testJson("blsG1Add", "f0a", t) }
   327  func TestPrecompiledBLS12381G1Mul(t *testing.T)      { testJson("blsG1Mul", "f0b", t) }
   328  func TestPrecompiledBLS12381G1MultiExp(t *testing.T) { testJson("blsG1MultiExp", "f0c", t) }
   329  func TestPrecompiledBLS12381G2Add(t *testing.T)      { testJson("blsG2Add", "f0d", t) }
   330  func TestPrecompiledBLS12381G2Mul(t *testing.T)      { testJson("blsG2Mul", "f0e", t) }
   331  func TestPrecompiledBLS12381G2MultiExp(t *testing.T) { testJson("blsG2MultiExp", "f0f", t) }
   332  func TestPrecompiledBLS12381Pairing(t *testing.T)    { testJson("blsPairing", "f10", t) }
   333  func TestPrecompiledBLS12381MapG1(t *testing.T)      { testJson("blsMapG1", "f11", t) }
   334  func TestPrecompiledBLS12381MapG2(t *testing.T)      { testJson("blsMapG2", "f12", t) }
   335  
   336  func TestPrecompiledPointEvaluation(t *testing.T) { testJson("pointEvaluation", "0a", t) }
   337  
   338  func BenchmarkPrecompiledBLS12381G1Add(b *testing.B)      { benchJson("blsG1Add", "f0a", b) }
   339  func BenchmarkPrecompiledBLS12381G1Mul(b *testing.B)      { benchJson("blsG1Mul", "f0b", b) }
   340  func BenchmarkPrecompiledBLS12381G1MultiExp(b *testing.B) { benchJson("blsG1MultiExp", "f0c", b) }
   341  func BenchmarkPrecompiledBLS12381G2Add(b *testing.B)      { benchJson("blsG2Add", "f0d", b) }
   342  func BenchmarkPrecompiledBLS12381G2Mul(b *testing.B)      { benchJson("blsG2Mul", "f0e", b) }
   343  func BenchmarkPrecompiledBLS12381G2MultiExp(b *testing.B) { benchJson("blsG2MultiExp", "f0f", b) }
   344  func BenchmarkPrecompiledBLS12381Pairing(b *testing.B)    { benchJson("blsPairing", "f10", b) }
   345  func BenchmarkPrecompiledBLS12381MapG1(b *testing.B)      { benchJson("blsMapG1", "f11", b) }
   346  func BenchmarkPrecompiledBLS12381MapG2(b *testing.B)      { benchJson("blsMapG2", "f12", b) }
   347  
   348  // Failure tests
   349  func TestPrecompiledBLS12381G1AddFail(t *testing.T)      { testJsonFail("blsG1Add", "f0a", t) }
   350  func TestPrecompiledBLS12381G1MulFail(t *testing.T)      { testJsonFail("blsG1Mul", "f0b", t) }
   351  func TestPrecompiledBLS12381G1MultiExpFail(t *testing.T) { testJsonFail("blsG1MultiExp", "f0c", t) }
   352  func TestPrecompiledBLS12381G2AddFail(t *testing.T)      { testJsonFail("blsG2Add", "f0d", t) }
   353  func TestPrecompiledBLS12381G2MulFail(t *testing.T)      { testJsonFail("blsG2Mul", "f0e", t) }
   354  func TestPrecompiledBLS12381G2MultiExpFail(t *testing.T) { testJsonFail("blsG2MultiExp", "f0f", t) }
   355  func TestPrecompiledBLS12381PairingFail(t *testing.T)    { testJsonFail("blsPairing", "f10", t) }
   356  func TestPrecompiledBLS12381MapG1Fail(t *testing.T)      { testJsonFail("blsMapG1", "f11", t) }
   357  func TestPrecompiledBLS12381MapG2Fail(t *testing.T)      { testJsonFail("blsMapG2", "f12", t) }
   358  
   359  func loadJson(name string) ([]precompiledTest, error) {
   360  	data, err := os.ReadFile(fmt.Sprintf("testdata/precompiles/%v.json", name))
   361  	if err != nil {
   362  		return nil, err
   363  	}
   364  	var testcases []precompiledTest
   365  	err = json.Unmarshal(data, &testcases)
   366  	return testcases, err
   367  }
   368  
   369  func loadJsonFail(name string) ([]precompiledFailureTest, error) {
   370  	data, err := os.ReadFile(fmt.Sprintf("testdata/precompiles/fail-%v.json", name))
   371  	if err != nil {
   372  		return nil, err
   373  	}
   374  	var testcases []precompiledFailureTest
   375  	err = json.Unmarshal(data, &testcases)
   376  	return testcases, err
   377  }
   378  
   379  // BenchmarkPrecompiledBLS12381G1MultiExpWorstCase benchmarks the worst case we could find that still fits a gaslimit of 10MGas.
   380  func BenchmarkPrecompiledBLS12381G1MultiExpWorstCase(b *testing.B) {
   381  	task := "0000000000000000000000000000000008d8c4a16fb9d8800cce987c0eadbb6b3b005c213d44ecb5adeed713bae79d606041406df26169c35df63cf972c94be1" +
   382  		"0000000000000000000000000000000011bc8afe71676e6730702a46ef817060249cd06cd82e6981085012ff6d013aa4470ba3a2c71e13ef653e1e223d1ccfe9" +
   383  		"FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF"
   384  	input := task
   385  	for i := 0; i < 4787; i++ {
   386  		input = input + task
   387  	}
   388  	testcase := precompiledTest{
   389  		Input:       input,
   390  		Expected:    "0000000000000000000000000000000005a6310ea6f2a598023ae48819afc292b4dfcb40aabad24a0c2cb6c19769465691859eeb2a764342a810c5038d700f18000000000000000000000000000000001268ac944437d15923dc0aec00daa9250252e43e4b35ec7a19d01f0d6cd27f6e139d80dae16ba1c79cc7f57055a93ff5",
   391  		Name:        "WorstCaseG1",
   392  		NoBenchmark: false,
   393  	}
   394  	benchmarkPrecompiled("0c", testcase, b)
   395  }
   396  
   397  // BenchmarkPrecompiledBLS12381G2MultiExpWorstCase benchmarks the worst case we could find that still fits a gaslimit of 10MGas.
   398  func BenchmarkPrecompiledBLS12381G2MultiExpWorstCase(b *testing.B) {
   399  	task := "000000000000000000000000000000000d4f09acd5f362e0a516d4c13c5e2f504d9bd49fdfb6d8b7a7ab35a02c391c8112b03270d5d9eefe9b659dd27601d18f" +
   400  		"000000000000000000000000000000000fd489cb75945f3b5ebb1c0e326d59602934c8f78fe9294a8877e7aeb95de5addde0cb7ab53674df8b2cfbb036b30b99" +
   401  		"00000000000000000000000000000000055dbc4eca768714e098bbe9c71cf54b40f51c26e95808ee79225a87fb6fa1415178db47f02d856fea56a752d185f86b" +
   402  		"000000000000000000000000000000001239b7640f416eb6e921fe47f7501d504fadc190d9cf4e89ae2b717276739a2f4ee9f637c35e23c480df029fd8d247c7" +
   403  		"FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF"
   404  	input := task
   405  	for i := 0; i < 1040; i++ {
   406  		input = input + task
   407  	}
   408  
   409  	testcase := precompiledTest{
   410  		Input:       input,
   411  		Expected:    "0000000000000000000000000000000018f5ea0c8b086095cfe23f6bb1d90d45de929292006dba8cdedd6d3203af3c6bbfd592e93ecb2b2c81004961fdcbb46c00000000000000000000000000000000076873199175664f1b6493a43c02234f49dc66f077d3007823e0343ad92e30bd7dc209013435ca9f197aca44d88e9dac000000000000000000000000000000000e6f07f4b23b511eac1e2682a0fc224c15d80e122a3e222d00a41fab15eba645a700b9ae84f331ae4ed873678e2e6c9b000000000000000000000000000000000bcb4849e460612aaed79617255fd30c03f51cf03d2ed4163ca810c13e1954b1e8663157b957a601829bb272a4e6c7b8",
   412  		Name:        "WorstCaseG2",
   413  		NoBenchmark: false,
   414  	}
   415  	benchmarkPrecompiled("0f", testcase, b)
   416  }