diff --git a/crates/ethcore/res/chainspec/test/berlin_test.json b/crates/ethcore/res/chainspec/test/berlin_test.json index 610684a3e..1cc68c7b7 100644 --- a/crates/ethcore/res/chainspec/test/berlin_test.json +++ b/crates/ethcore/res/chainspec/test/berlin_test.json @@ -115,8 +115,10 @@ "name": "modexp", "activate_at": "0x00", "pricing": { - "modexp": { - "divisor": 20 + "0": { + "price": { + "modexp2565": {} + } } } } @@ -199,106 +201,6 @@ } } } - }, - "000000000000000000000000000000000000000a": { - "builtin": { - "name": "bls12_381_g1_add", - "activate_at": "0", - "pricing": { - "bls12_const_operations": { - "price": 600 - } - } - } - }, - "000000000000000000000000000000000000000b": { - "builtin": { - "name": "bls12_381_g1_mul", - "activate_at": "0", - "pricing": { - "bls12_const_operations": { - "price": 12000 - } - } - } - }, - "000000000000000000000000000000000000000c": { - "builtin": { - "name": "bls12_381_g1_multiexp", - "activate_at": "0", - "pricing": { - "bls12_g1_multiexp": { - "base": 12000 - } - } - } - }, - "000000000000000000000000000000000000000d": { - "builtin": { - "name": "bls12_381_g2_add", - "activate_at": "0", - "pricing": { - "bls12_const_operations": { - "price": 4500 - } - } - } - }, - "000000000000000000000000000000000000000e": { - "builtin": { - "name": "bls12_381_g2_mul", - "activate_at": "0", - "pricing": { - "bls12_const_operations": { - "price": 55000 - } - } - } - }, - "000000000000000000000000000000000000000f": { - "builtin": { - "name": "bls12_381_g2_multiexp", - "activate_at": "0", - "pricing": { - "bls12_g2_multiexp": { - "base": 55000 - } - } - } - }, - "0000000000000000000000000000000000000010": { - "builtin": { - "name": "bls12_381_pairing", - "activate_at": "0", - "pricing": { - "bls12_pairing": { - "base": 115000, - "pair": 23000 - } - } - } - }, - "0000000000000000000000000000000000000011": { - "builtin": { - "name": "bls12_381_fp_to_g1", - "activate_at": "0", - "pricing": { - "bls12_const_operations": { - "price": 5500 - } - } - } - }, - "0000000000000000000000000000000000000012": { - "builtin": { - "name": "bls12_381_fp2_to_g2", - "activate_at": "0", - "pricing": { - "bls12_const_operations": { - "price": 110000 - } - } - } } } } \ No newline at end of file diff --git a/crates/ethcore/res/json_tests b/crates/ethcore/res/json_tests index f55f344ad..1508126ea 160000 --- a/crates/ethcore/res/json_tests +++ b/crates/ethcore/res/json_tests @@ -1 +1 @@ -Subproject commit f55f344ad25cb97ebf4f3d72eca7a263aabde818 +Subproject commit 1508126ea04cd61495b60db2f036ac823de274b1 diff --git a/crates/vm/builtin/src/lib.rs b/crates/vm/builtin/src/lib.rs index 62caf5e38..5ba924772 100644 --- a/crates/vm/builtin/src/lib.rs +++ b/crates/vm/builtin/src/lib.rs @@ -260,7 +260,7 @@ impl Pricer for Modexp2565Pricer { } bit_no -= 1; } - 0 + 1 } fn calculate_multiplication_complexity(base_len: u64, modulus_len: u64) -> f64 { @@ -283,17 +283,21 @@ impl Pricer for Modexp2565Pricer { let (base_len, exp_len, exp_low, mod_len) = ModexpPricer::parse_input(input); - if let Some(cost) = ModexpPricer::check_input_boundaries(&base_len, &exp_len, &mod_len) { - return cost; - } + let cost = if let Some(cost) = + ModexpPricer::check_input_boundaries(&base_len, &exp_len, &mod_len) + { + cost + } else { + let (base_len, exp_len, mod_len) = + (base_len.low_u64(), exp_len.low_u64(), mod_len.low_u64()); - let (base_len, exp_len, mod_len) = - (base_len.low_u64(), exp_len.low_u64(), mod_len.low_u64()); - - let multiplication_complexity = calculate_multiplication_complexity(base_len, mod_len); - let iteration_count = calculate_iteration_count(exp_len, &exp_low); - let computed = (multiplication_complexity * iteration_count as f64 / 3f64).floor() as u64; - U256::from(std::cmp::max(200, computed)) + let multiplication_complexity = calculate_multiplication_complexity(base_len, mod_len); + let iteration_count = calculate_iteration_count(exp_len, &exp_low); + let computed = + (multiplication_complexity * iteration_count as f64 / 3f64).floor() as u64; + U256::from(computed) + }; + std::cmp::max(U256::from(200), cost) } }