Add blake2_f precompile (#11017)
* feat: implement eip1108 * doc nit: price per point pair Co-Authored-By: David <dvdplm@gmail.com> * fix: test-build * fix: update chain specs * fix: basic_authority.json chain spec * fix: change `eip_transition == 0x7fffffffffffff` * Merge na-eip1108 * Pre-compile plumbing * Use type alias instead of struct * Extract the data from incoming EVM call and forward it to blake2_f * Fetch parity-common from git for now * Fix broken cost impl Add remaining test vectors * cleanup * Trailing comma in json spec * Update ethcore/builtin/src/lib.rs Co-Authored-By: Andronik Ordian <write@reusable.software> * Update ethcore/builtin/src/lib.rs Co-Authored-By: Andronik Ordian <write@reusable.software> * Rename pricer to be Blake2-specific Return a cost of u32::MAX if conversion fails Fix docs and todos * Fix error handling in cost() * fix chainspec * EIP-152 crate * Update ethcore/builtin/src/lib.rs Co-Authored-By: Seun LanLege <seunlanlege@gmail.com> * Address grumbles * Update ethcore/builtin/src/lib.rs Co-Authored-By: Niklas Adolfsson <niklasadolfsson1@gmail.com> * Switch tests to use hex! * remove parity-crypto from git * Sort out the SIGMA * Prefer arrays to vecs * Update util/EIP-152/src/lib.rs Co-Authored-By: Niklas Adolfsson <niklasadolfsson1@gmail.com> * Update json/src/spec/builtin.rs Co-Authored-By: Andronik Ordian <write@reusable.software> * Update json/src/spec/builtin.rs Co-Authored-By: Andronik Ordian <write@reusable.software> * Review feedback * Do not change chainspecs yet * Do not assume endianess: precompile output is LE
This commit is contained in:
@@ -18,6 +18,9 @@
|
||||
|
||||
use uint::Uint;
|
||||
|
||||
/// Price per round of Blake2 compression.
|
||||
pub type Blake2F = u64;
|
||||
|
||||
/// Linear pricing.
|
||||
#[derive(Debug, PartialEq, Deserialize, Clone)]
|
||||
#[serde(deny_unknown_fields)]
|
||||
@@ -65,6 +68,8 @@ pub struct AltBn128Pairing {
|
||||
#[serde(deny_unknown_fields)]
|
||||
#[serde(rename_all = "snake_case")]
|
||||
pub enum Pricing {
|
||||
/// Pricing for Blake2 compression function: each call costs the same amount per round.
|
||||
Blake2F(Blake2F),
|
||||
/// Linear pricing.
|
||||
Linear(Linear),
|
||||
/// Pricing for modular exponentiation.
|
||||
@@ -107,6 +112,19 @@ mod tests {
|
||||
assert!(deserialized.activate_at.is_none());
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn deserialization_blake2_f_builtin() {
|
||||
let s = r#"{
|
||||
"name": "blake2_f",
|
||||
"activate_at": "0xffffff",
|
||||
"pricing": { "blake2_f": 123 }
|
||||
}"#;
|
||||
let deserialized: Builtin = serde_json::from_str(s).unwrap();
|
||||
assert_eq!(deserialized.name, "blake2_f");
|
||||
assert_eq!(deserialized.pricing, Pricing::Blake2F(123));
|
||||
assert!(deserialized.activate_at.is_some());
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn activate_at() {
|
||||
let s = r#"{
|
||||
|
||||
Reference in New Issue
Block a user