Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update EIP-3026 and EIP-2539 #1173

Merged
merged 4 commits into from
Sep 11, 2023
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
22 changes: 15 additions & 7 deletions frame/evm/precompile/bw6761/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,15 @@ use fp_evm::{

/// Gas discount table for BW6-761 G1 and G2 multi exponentiation operations.
// TODO::to be estimated
const BW6761_MULTIEXP_DISCOUNT_TABLE: [u16; 128] = [0u16; 128];
const BW6761_MULTIEXP_DISCOUNT_TABLE: [u16; 128] = [
1266, 733, 561, 474, 422, 387, 362, 344, 329, 318, 308, 300, 296, 289, 283, 279, 275, 272, 269,
266, 265, 260, 259, 256, 255, 254, 252, 251, 250, 249, 249, 220, 228, 225, 223, 219, 216, 214,
212, 209, 209, 205, 203, 202, 200, 198, 196, 199, 195, 192, 192, 191, 190, 187, 186, 185, 184,
184, 181, 181, 181, 180, 178, 179, 176, 177, 176, 175, 174, 173, 171, 171, 170, 170, 169, 168,
168, 167, 167, 166, 165, 167, 166, 166, 165, 165, 164, 164, 163, 163, 162, 162, 160, 163, 159,
162, 159, 160, 159, 159, 158, 158, 158, 158, 157, 157, 156, 155, 155, 156, 155, 155, 154, 155,
154, 153, 153, 153, 152, 152, 152, 152, 151, 151, 151, 151, 151, 150,
];

/// Encode Fq as `96` bytes by performing Big-Endian encoding of the corresponding (unsigned) integer.
fn encode_fq(field: Fq) -> [u8; 96] {
Expand Down Expand Up @@ -179,7 +187,7 @@ pub struct Bw6761G1Add;

impl Bw6761G1Add {
// TODO::to be estimated
const GAS_COST: u64 = 0;
const GAS_COST: u64 = 180;
}

impl Precompile for Bw6761G1Add {
Expand Down Expand Up @@ -217,7 +225,7 @@ pub struct Bw6761G1Mul;

impl Bw6761G1Mul {
// TODO::to be estimated
const GAS_COST: u64 = 0;
const GAS_COST: u64 = 64_000;
}

impl Precompile for Bw6761G1Mul {
Expand Down Expand Up @@ -327,7 +335,7 @@ pub struct Bw6761G2Add;

impl Bw6761G2Add {
// TODO::to be estimated
const GAS_COST: u64 = 0;
const GAS_COST: u64 = 180;
}

impl Precompile for Bw6761G2Add {
Expand Down Expand Up @@ -365,7 +373,7 @@ pub struct Bw6761G2Mul;

impl Bw6761G2Mul {
// TODO::to be estimated
const GAS_COST: u64 = 0;
const GAS_COST: u64 = 64_000;
}

impl Precompile for Bw6761G2Mul {
Expand Down Expand Up @@ -475,8 +483,8 @@ pub struct Bw6761Pairing;

impl Bw6761Pairing {
// TODO::to be estimated
const BASE_GAS: u64 = 0;
const PER_PAIR_GAS: u64 = 0;
const BASE_GAS: u64 = 120_000;
const PER_PAIR_GAS: u64 = 320_000;
}

impl Precompile for Bw6761Pairing {
Expand Down