core/vm, protocol_params: implement eip-2565 modexp repricing (#21607)
* core/vm, protocol_params: implement eip-2565 modexp repricing * core/vm: fix review concerns
This commit is contained in:
committed by
GitHub
parent
0703c91fba
commit
6f4cccf8d2
@ -43,7 +43,29 @@ type precompiledFailureTest struct {
|
||||
Name string
|
||||
}
|
||||
|
||||
var allPrecompiles = PrecompiledContractsYoloV2
|
||||
// allPrecompiles does not map to the actual set of precompiles, as it also contains
|
||||
// repriced versions of precompiles at certain slots
|
||||
var allPrecompiles = map[common.Address]PrecompiledContract{
|
||||
common.BytesToAddress([]byte{1}): &ecrecover{},
|
||||
common.BytesToAddress([]byte{2}): &sha256hash{},
|
||||
common.BytesToAddress([]byte{3}): &ripemd160hash{},
|
||||
common.BytesToAddress([]byte{4}): &dataCopy{},
|
||||
common.BytesToAddress([]byte{5}): &bigModExp{eip2565: false},
|
||||
common.BytesToAddress([]byte{0xf5}): &bigModExp{eip2565: true},
|
||||
common.BytesToAddress([]byte{6}): &bn256AddIstanbul{},
|
||||
common.BytesToAddress([]byte{7}): &bn256ScalarMulIstanbul{},
|
||||
common.BytesToAddress([]byte{8}): &bn256PairingIstanbul{},
|
||||
common.BytesToAddress([]byte{9}): &blake2F{},
|
||||
common.BytesToAddress([]byte{10}): &bls12381G1Add{},
|
||||
common.BytesToAddress([]byte{11}): &bls12381G1Mul{},
|
||||
common.BytesToAddress([]byte{12}): &bls12381G1MultiExp{},
|
||||
common.BytesToAddress([]byte{13}): &bls12381G2Add{},
|
||||
common.BytesToAddress([]byte{14}): &bls12381G2Mul{},
|
||||
common.BytesToAddress([]byte{15}): &bls12381G2MultiExp{},
|
||||
common.BytesToAddress([]byte{16}): &bls12381Pairing{},
|
||||
common.BytesToAddress([]byte{17}): &bls12381MapG1{},
|
||||
common.BytesToAddress([]byte{18}): &bls12381MapG2{},
|
||||
}
|
||||
|
||||
// EIP-152 test vectors
|
||||
var blake2FMalformedInputTests = []precompiledFailureTest{
|
||||
@ -213,6 +235,9 @@ func BenchmarkPrecompiledIdentity(bench *testing.B) {
|
||||
func TestPrecompiledModExp(t *testing.T) { testJson("modexp", "05", t) }
|
||||
func BenchmarkPrecompiledModExp(b *testing.B) { benchJson("modexp", "05", b) }
|
||||
|
||||
func TestPrecompiledModExpEip2565(t *testing.T) { testJson("modexp_eip2565", "f5", t) }
|
||||
func BenchmarkPrecompiledModExpEip2565(b *testing.B) { benchJson("modexp_eip2565", "f5", b) }
|
||||
|
||||
// Tests the sample inputs from the elliptic curve addition EIP 213.
|
||||
func TestPrecompiledBn256Add(t *testing.T) { testJson("bn256Add", "06", t) }
|
||||
func BenchmarkPrecompiledBn256Add(b *testing.B) { benchJson("bn256Add", "06", b) }
|
||||
|
Reference in New Issue
Block a user