Skip to content

Commit ad27b78

Browse files
committed
precompiles: Remove redundant BLS MUL precompiles
Remove redundant G1/G2 MUL precompiles easily replaceable with MSMs. Spec update: ethereum/EIPs#8945.
1 parent ec75566 commit ad27b78

File tree

4 files changed

+8
-44
lines changed

4 files changed

+8
-44
lines changed

test/state/precompiles.cpp

Lines changed: 0 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -428,20 +428,6 @@ ExecutionResult bls12_g1add_execute(const uint8_t* input, size_t input_size, uin
428428
return {EVMC_SUCCESS, 128};
429429
}
430430

431-
ExecutionResult bls12_g1mul_execute(const uint8_t* input, size_t input_size, uint8_t* output,
432-
[[maybe_unused]] size_t output_size) noexcept
433-
{
434-
if (input_size != 160)
435-
return {EVMC_PRECOMPILE_FAILURE, 0};
436-
437-
assert(output_size == 128);
438-
439-
if (!crypto::bls::g1_mul(output, &output[64], input, &input[64], &input[128]))
440-
return {EVMC_PRECOMPILE_FAILURE, 0};
441-
442-
return {EVMC_SUCCESS, 128};
443-
}
444-
445431
ExecutionResult bls12_g1msm_execute(const uint8_t* input, size_t input_size, uint8_t* output,
446432
[[maybe_unused]] size_t output_size) noexcept
447433
{
@@ -470,20 +456,6 @@ ExecutionResult bls12_g2add_execute(const uint8_t* input, size_t input_size, uin
470456
return {EVMC_SUCCESS, 256};
471457
}
472458

473-
ExecutionResult bls12_g2mul_execute(const uint8_t* input, size_t input_size, uint8_t* output,
474-
[[maybe_unused]] size_t output_size) noexcept
475-
{
476-
if (input_size != 288)
477-
return {EVMC_PRECOMPILE_FAILURE, 0};
478-
479-
assert(output_size == 256);
480-
481-
if (!crypto::bls::g2_mul(output, &output[128], input, &input[128], &input[256]))
482-
return {EVMC_PRECOMPILE_FAILURE, 0};
483-
484-
return {EVMC_SUCCESS, 256};
485-
}
486-
487459
ExecutionResult bls12_g2msm_execute(const uint8_t* input, size_t input_size, uint8_t* output,
488460
[[maybe_unused]] size_t output_size) noexcept
489461
{
@@ -562,10 +534,8 @@ inline constexpr auto traits = []() noexcept {
562534
{blake2bf_analyze, blake2bf_execute},
563535
{point_evaluation_analyze, point_evaluation_execute},
564536
{bls12_g1add_analyze, bls12_g1add_execute},
565-
{bls12_g1mul_analyze, bls12_g1mul_execute},
566537
{bls12_g1msm_analyze, bls12_g1msm_execute},
567538
{bls12_g2add_analyze, bls12_g2add_execute},
568-
{bls12_g2mul_analyze, bls12_g2mul_execute},
569539
{bls12_g2msm_analyze, bls12_g2msm_execute},
570540
{bls12_pairing_check_analyze, bls12_pairing_check_execute},
571541
{bls12_map_fp_to_g1_analyze, bls12_map_fp_to_g1_execute},

test/state/precompiles.hpp

Lines changed: 6 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -23,14 +23,12 @@ enum class PrecompileId : uint8_t
2323
blake2bf = 0x09,
2424
point_evaluation = 0x0a,
2525
bls12_g1add = 0x0b,
26-
bls12_g1mul = 0x0c,
27-
bls12_g1msm = 0x0d,
28-
bls12_g2add = 0x0e,
29-
bls12_g2mul = 0x0f,
30-
bls12_g2msm = 0x10,
31-
bls12_pairing_check = 0x11,
32-
bls12_map_fp_to_g1 = 0x12,
33-
bls12_map_fp2_to_g2 = 0x13,
26+
bls12_g1msm = 0x0c,
27+
bls12_g2add = 0x0d,
28+
bls12_g2msm = 0x0e,
29+
bls12_pairing_check = 0x0f,
30+
bls12_map_fp_to_g1 = 0x10,
31+
bls12_map_fp2_to_g2 = 0x11,
3432

3533
since_byzantium = expmod, ///< The first precompile introduced in Byzantium.
3634
since_istanbul = blake2bf, ///< The first precompile introduced in Istanbul.

test/state/precompiles_internal.hpp

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -57,14 +57,10 @@ ExecutionResult point_evaluation_execute(
5757
const uint8_t* input, size_t input_size, uint8_t* output, size_t output_size) noexcept;
5858
ExecutionResult bls12_g1add_execute(
5959
const uint8_t* input, size_t input_size, uint8_t* output, size_t output_size) noexcept;
60-
ExecutionResult bls12_g1mul_execute(
61-
const uint8_t* input, size_t input_size, uint8_t* output, size_t output_size) noexcept;
6260
ExecutionResult bls12_g1msm_execute(
6361
const uint8_t* input, size_t input_size, uint8_t* output, size_t output_size) noexcept;
6462
ExecutionResult bls12_g2add_execute(
6563
const uint8_t* input, size_t input_size, uint8_t* output, size_t output_size) noexcept;
66-
ExecutionResult bls12_g2mul_execute(
67-
const uint8_t* input, size_t input_size, uint8_t* output, size_t output_size) noexcept;
6864
ExecutionResult bls12_g2msm_execute(
6965
const uint8_t* input, size_t input_size, uint8_t* output, size_t output_size) noexcept;
7066
ExecutionResult bls12_pairing_check_execute(

test/unittests/state_precompiles_test.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -42,10 +42,10 @@ TEST(state_precompiles, is_precompile)
4242
EXPECT_EQ(is_precompile(rev, 0x0f_address), rev >= EVMC_PRAGUE);
4343
EXPECT_EQ(is_precompile(rev, 0x10_address), rev >= EVMC_PRAGUE);
4444
EXPECT_EQ(is_precompile(rev, 0x11_address), rev >= EVMC_PRAGUE);
45-
EXPECT_EQ(is_precompile(rev, 0x12_address), rev >= EVMC_PRAGUE);
46-
EXPECT_EQ(is_precompile(rev, 0x13_address), rev >= EVMC_PRAGUE);
4745

4846
// Future?
47+
EXPECT_FALSE(is_precompile(rev, 0x12_address));
48+
EXPECT_FALSE(is_precompile(rev, 0x13_address));
4949
EXPECT_FALSE(is_precompile(rev, 0x14_address));
5050
EXPECT_FALSE(is_precompile(rev, 0x15_address));
5151
EXPECT_FALSE(is_precompile(rev, 0x16_address));

0 commit comments

Comments
 (0)