openethereum/json/src/spec/builtin.rs

246 lines
6.4 KiB
Rust
Raw Normal View History

// Copyright 2015-2019 Parity Technologies (UK) Ltd.
// This file is part of Parity Ethereum.
2016-03-17 13:41:11 +01:00
// Parity Ethereum is free software: you can redistribute it and/or modify
2016-03-17 13:41:11 +01:00
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
// Parity Ethereum is distributed in the hope that it will be useful,
2016-03-17 13:41:11 +01:00
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
// You should have received a copy of the GNU General Public License
// along with Parity Ethereum. If not, see <http://www.gnu.org/licenses/>.
2016-03-17 13:41:11 +01:00
//! Spec builtin deserialization.
[builtin]: support `multiple prices and activations` in chain spec (#11039) * [builtin]: impl new builtin type Have an enum to deserialize either a builtin of a single price or several prices * [builtin]: style cleanup * [builtin]: fix tests * [builtin]: replace boxing with wrapper enum * cleanup * fix: make it backward compatible with old builtin * fix: update chain specs * fix: revert use of `type alias` on enum The CI doesn't use the latest rust. This commit reverts that change * fix: builtin tests * fix: revert use of `type alias` on enum * [basic-authority]: update test-chainspec * fix failing tests * [builtin]: multi-prices add `info field` It might be hard to read chain specs with several activations points. This commit introduces a `info` field which may be used to write some information about the current activation such as: `Istanbul hardfork EIP-1108` or something similar. * fix: bad rebase Co-Authored-By: David <dvdplm@gmail.com> * fix(grumbles): make it backward compatible * grumbles: resolve `NOTE` * revert chain specs changes * rename test Co-Authored-By: David <dvdplm@gmail.com> * [builtin docs]: price -> Fixed price Co-Authored-By: Andronik Ordian <write@reusable.software> * [json]: address naming grumbles InnerPricing -> PricingInner PriceWithActivationAt -> PricingAt * docs: revert changes for `AltBn128ConstOperations` * [json]: usize -> u64 Use explicit types to cope with platform dependent issues for `usize` * grumble: simplify `spec_backward_compability.json` * docs: add issue link to `TODO` * [builtin]: replace `match` with `map` * [builtin]: add deprecation message `eip1108` params * nits * [json spec tests]: fix json indentation * [json docs]: fix typos * [json]: `compability layer` + deser to BTreeMap Previously we had to match `Pricing::Single` and `PricingMulti` which this fixes. It does by introducing a compability layer and into() implemenentation. In addition, I switched the deserialization to `BTreeMap` instead of `Vec`. That changes the format of the chain spec again * [json]: rename `BuiltinCombat` -> `BuiltinCompat` * Update ethcore/builtin/src/lib.rs Co-Authored-By: David <dvdplm@gmail.com> * [json builtin]: improve docs Co-Authored-By: David <dvdplm@gmail.com> * [json builtin]: improve docs Co-Authored-By: David <dvdplm@gmail.com> * chore(builtin): sort dependencies * [json builtin]: deprecate `eip1108` params * [machine]: add bench for calling builtin contract * [machine]: reduce calls to `Builtin::is_active` * [builtin]: fix nits * [json]: revert breakage of chain specs * [json builtin]: remove `eip1108` params * [chain specs]: update to new format * [machine]: revert changes * [devp2p]: revert change * [builtin]: doc nits
2019-10-31 17:09:08 +01:00
use std::collections::BTreeMap;
use crate::uint::Uint;
use serde::Deserialize;
2016-03-18 19:08:57 +01:00
/// Linear pricing.
#[derive(Debug, PartialEq, Deserialize, Clone)]
#[serde(deny_unknown_fields)]
2016-03-17 13:41:11 +01:00
pub struct Linear {
/// Base price.
[builtin]: support `multiple prices and activations` in chain spec (#11039) * [builtin]: impl new builtin type Have an enum to deserialize either a builtin of a single price or several prices * [builtin]: style cleanup * [builtin]: fix tests * [builtin]: replace boxing with wrapper enum * cleanup * fix: make it backward compatible with old builtin * fix: update chain specs * fix: revert use of `type alias` on enum The CI doesn't use the latest rust. This commit reverts that change * fix: builtin tests * fix: revert use of `type alias` on enum * [basic-authority]: update test-chainspec * fix failing tests * [builtin]: multi-prices add `info field` It might be hard to read chain specs with several activations points. This commit introduces a `info` field which may be used to write some information about the current activation such as: `Istanbul hardfork EIP-1108` or something similar. * fix: bad rebase Co-Authored-By: David <dvdplm@gmail.com> * fix(grumbles): make it backward compatible * grumbles: resolve `NOTE` * revert chain specs changes * rename test Co-Authored-By: David <dvdplm@gmail.com> * [builtin docs]: price -> Fixed price Co-Authored-By: Andronik Ordian <write@reusable.software> * [json]: address naming grumbles InnerPricing -> PricingInner PriceWithActivationAt -> PricingAt * docs: revert changes for `AltBn128ConstOperations` * [json]: usize -> u64 Use explicit types to cope with platform dependent issues for `usize` * grumble: simplify `spec_backward_compability.json` * docs: add issue link to `TODO` * [builtin]: replace `match` with `map` * [builtin]: add deprecation message `eip1108` params * nits * [json spec tests]: fix json indentation * [json docs]: fix typos * [json]: `compability layer` + deser to BTreeMap Previously we had to match `Pricing::Single` and `PricingMulti` which this fixes. It does by introducing a compability layer and into() implemenentation. In addition, I switched the deserialization to `BTreeMap` instead of `Vec`. That changes the format of the chain spec again * [json]: rename `BuiltinCombat` -> `BuiltinCompat` * Update ethcore/builtin/src/lib.rs Co-Authored-By: David <dvdplm@gmail.com> * [json builtin]: improve docs Co-Authored-By: David <dvdplm@gmail.com> * [json builtin]: improve docs Co-Authored-By: David <dvdplm@gmail.com> * chore(builtin): sort dependencies * [json builtin]: deprecate `eip1108` params * [machine]: add bench for calling builtin contract * [machine]: reduce calls to `Builtin::is_active` * [builtin]: fix nits * [json]: revert breakage of chain specs * [json builtin]: remove `eip1108` params * [chain specs]: update to new format * [machine]: revert changes * [devp2p]: revert change * [builtin]: doc nits
2019-10-31 17:09:08 +01:00
pub base: u64,
/// Price for word.
[builtin]: support `multiple prices and activations` in chain spec (#11039) * [builtin]: impl new builtin type Have an enum to deserialize either a builtin of a single price or several prices * [builtin]: style cleanup * [builtin]: fix tests * [builtin]: replace boxing with wrapper enum * cleanup * fix: make it backward compatible with old builtin * fix: update chain specs * fix: revert use of `type alias` on enum The CI doesn't use the latest rust. This commit reverts that change * fix: builtin tests * fix: revert use of `type alias` on enum * [basic-authority]: update test-chainspec * fix failing tests * [builtin]: multi-prices add `info field` It might be hard to read chain specs with several activations points. This commit introduces a `info` field which may be used to write some information about the current activation such as: `Istanbul hardfork EIP-1108` or something similar. * fix: bad rebase Co-Authored-By: David <dvdplm@gmail.com> * fix(grumbles): make it backward compatible * grumbles: resolve `NOTE` * revert chain specs changes * rename test Co-Authored-By: David <dvdplm@gmail.com> * [builtin docs]: price -> Fixed price Co-Authored-By: Andronik Ordian <write@reusable.software> * [json]: address naming grumbles InnerPricing -> PricingInner PriceWithActivationAt -> PricingAt * docs: revert changes for `AltBn128ConstOperations` * [json]: usize -> u64 Use explicit types to cope with platform dependent issues for `usize` * grumble: simplify `spec_backward_compability.json` * docs: add issue link to `TODO` * [builtin]: replace `match` with `map` * [builtin]: add deprecation message `eip1108` params * nits * [json spec tests]: fix json indentation * [json docs]: fix typos * [json]: `compability layer` + deser to BTreeMap Previously we had to match `Pricing::Single` and `PricingMulti` which this fixes. It does by introducing a compability layer and into() implemenentation. In addition, I switched the deserialization to `BTreeMap` instead of `Vec`. That changes the format of the chain spec again * [json]: rename `BuiltinCombat` -> `BuiltinCompat` * Update ethcore/builtin/src/lib.rs Co-Authored-By: David <dvdplm@gmail.com> * [json builtin]: improve docs Co-Authored-By: David <dvdplm@gmail.com> * [json builtin]: improve docs Co-Authored-By: David <dvdplm@gmail.com> * chore(builtin): sort dependencies * [json builtin]: deprecate `eip1108` params * [machine]: add bench for calling builtin contract * [machine]: reduce calls to `Builtin::is_active` * [builtin]: fix nits * [json]: revert breakage of chain specs * [json builtin]: remove `eip1108` params * [chain specs]: update to new format * [machine]: revert changes * [devp2p]: revert change * [builtin]: doc nits
2019-10-31 17:09:08 +01:00
pub word: u64,
2016-03-17 13:41:11 +01:00
}
/// Pricing for modular exponentiation.
#[derive(Debug, PartialEq, Deserialize, Clone)]
#[serde(deny_unknown_fields)]
pub struct Modexp {
/// Price divisor.
[builtin]: support `multiple prices and activations` in chain spec (#11039) * [builtin]: impl new builtin type Have an enum to deserialize either a builtin of a single price or several prices * [builtin]: style cleanup * [builtin]: fix tests * [builtin]: replace boxing with wrapper enum * cleanup * fix: make it backward compatible with old builtin * fix: update chain specs * fix: revert use of `type alias` on enum The CI doesn't use the latest rust. This commit reverts that change * fix: builtin tests * fix: revert use of `type alias` on enum * [basic-authority]: update test-chainspec * fix failing tests * [builtin]: multi-prices add `info field` It might be hard to read chain specs with several activations points. This commit introduces a `info` field which may be used to write some information about the current activation such as: `Istanbul hardfork EIP-1108` or something similar. * fix: bad rebase Co-Authored-By: David <dvdplm@gmail.com> * fix(grumbles): make it backward compatible * grumbles: resolve `NOTE` * revert chain specs changes * rename test Co-Authored-By: David <dvdplm@gmail.com> * [builtin docs]: price -> Fixed price Co-Authored-By: Andronik Ordian <write@reusable.software> * [json]: address naming grumbles InnerPricing -> PricingInner PriceWithActivationAt -> PricingAt * docs: revert changes for `AltBn128ConstOperations` * [json]: usize -> u64 Use explicit types to cope with platform dependent issues for `usize` * grumble: simplify `spec_backward_compability.json` * docs: add issue link to `TODO` * [builtin]: replace `match` with `map` * [builtin]: add deprecation message `eip1108` params * nits * [json spec tests]: fix json indentation * [json docs]: fix typos * [json]: `compability layer` + deser to BTreeMap Previously we had to match `Pricing::Single` and `PricingMulti` which this fixes. It does by introducing a compability layer and into() implemenentation. In addition, I switched the deserialization to `BTreeMap` instead of `Vec`. That changes the format of the chain spec again * [json]: rename `BuiltinCombat` -> `BuiltinCompat` * Update ethcore/builtin/src/lib.rs Co-Authored-By: David <dvdplm@gmail.com> * [json builtin]: improve docs Co-Authored-By: David <dvdplm@gmail.com> * [json builtin]: improve docs Co-Authored-By: David <dvdplm@gmail.com> * chore(builtin): sort dependencies * [json builtin]: deprecate `eip1108` params * [machine]: add bench for calling builtin contract * [machine]: reduce calls to `Builtin::is_active` * [builtin]: fix nits * [json]: revert breakage of chain specs * [json builtin]: remove `eip1108` params * [chain specs]: update to new format * [machine]: revert changes * [devp2p]: revert change * [builtin]: doc nits
2019-10-31 17:09:08 +01:00
pub divisor: u64,
}
/// Pricing for constant alt_bn128 operations (ECADD and ECMUL)
#[derive(Debug, PartialEq, Deserialize, Clone)]
#[serde(deny_unknown_fields)]
pub struct AltBn128ConstOperations {
/// price
[builtin]: support `multiple prices and activations` in chain spec (#11039) * [builtin]: impl new builtin type Have an enum to deserialize either a builtin of a single price or several prices * [builtin]: style cleanup * [builtin]: fix tests * [builtin]: replace boxing with wrapper enum * cleanup * fix: make it backward compatible with old builtin * fix: update chain specs * fix: revert use of `type alias` on enum The CI doesn't use the latest rust. This commit reverts that change * fix: builtin tests * fix: revert use of `type alias` on enum * [basic-authority]: update test-chainspec * fix failing tests * [builtin]: multi-prices add `info field` It might be hard to read chain specs with several activations points. This commit introduces a `info` field which may be used to write some information about the current activation such as: `Istanbul hardfork EIP-1108` or something similar. * fix: bad rebase Co-Authored-By: David <dvdplm@gmail.com> * fix(grumbles): make it backward compatible * grumbles: resolve `NOTE` * revert chain specs changes * rename test Co-Authored-By: David <dvdplm@gmail.com> * [builtin docs]: price -> Fixed price Co-Authored-By: Andronik Ordian <write@reusable.software> * [json]: address naming grumbles InnerPricing -> PricingInner PriceWithActivationAt -> PricingAt * docs: revert changes for `AltBn128ConstOperations` * [json]: usize -> u64 Use explicit types to cope with platform dependent issues for `usize` * grumble: simplify `spec_backward_compability.json` * docs: add issue link to `TODO` * [builtin]: replace `match` with `map` * [builtin]: add deprecation message `eip1108` params * nits * [json spec tests]: fix json indentation * [json docs]: fix typos * [json]: `compability layer` + deser to BTreeMap Previously we had to match `Pricing::Single` and `PricingMulti` which this fixes. It does by introducing a compability layer and into() implemenentation. In addition, I switched the deserialization to `BTreeMap` instead of `Vec`. That changes the format of the chain spec again * [json]: rename `BuiltinCombat` -> `BuiltinCompat` * Update ethcore/builtin/src/lib.rs Co-Authored-By: David <dvdplm@gmail.com> * [json builtin]: improve docs Co-Authored-By: David <dvdplm@gmail.com> * [json builtin]: improve docs Co-Authored-By: David <dvdplm@gmail.com> * chore(builtin): sort dependencies * [json builtin]: deprecate `eip1108` params * [machine]: add bench for calling builtin contract * [machine]: reduce calls to `Builtin::is_active` * [builtin]: fix nits * [json]: revert breakage of chain specs * [json builtin]: remove `eip1108` params * [chain specs]: update to new format * [machine]: revert changes * [devp2p]: revert change * [builtin]: doc nits
2019-10-31 17:09:08 +01:00
pub price: u64,
}
/// Pricing for alt_bn128_pairing.
#[derive(Debug, PartialEq, Deserialize, Clone)]
#[serde(deny_unknown_fields)]
pub struct AltBn128Pairing {
/// Base price.
[builtin]: support `multiple prices and activations` in chain spec (#11039) * [builtin]: impl new builtin type Have an enum to deserialize either a builtin of a single price or several prices * [builtin]: style cleanup * [builtin]: fix tests * [builtin]: replace boxing with wrapper enum * cleanup * fix: make it backward compatible with old builtin * fix: update chain specs * fix: revert use of `type alias` on enum The CI doesn't use the latest rust. This commit reverts that change * fix: builtin tests * fix: revert use of `type alias` on enum * [basic-authority]: update test-chainspec * fix failing tests * [builtin]: multi-prices add `info field` It might be hard to read chain specs with several activations points. This commit introduces a `info` field which may be used to write some information about the current activation such as: `Istanbul hardfork EIP-1108` or something similar. * fix: bad rebase Co-Authored-By: David <dvdplm@gmail.com> * fix(grumbles): make it backward compatible * grumbles: resolve `NOTE` * revert chain specs changes * rename test Co-Authored-By: David <dvdplm@gmail.com> * [builtin docs]: price -> Fixed price Co-Authored-By: Andronik Ordian <write@reusable.software> * [json]: address naming grumbles InnerPricing -> PricingInner PriceWithActivationAt -> PricingAt * docs: revert changes for `AltBn128ConstOperations` * [json]: usize -> u64 Use explicit types to cope with platform dependent issues for `usize` * grumble: simplify `spec_backward_compability.json` * docs: add issue link to `TODO` * [builtin]: replace `match` with `map` * [builtin]: add deprecation message `eip1108` params * nits * [json spec tests]: fix json indentation * [json docs]: fix typos * [json]: `compability layer` + deser to BTreeMap Previously we had to match `Pricing::Single` and `PricingMulti` which this fixes. It does by introducing a compability layer and into() implemenentation. In addition, I switched the deserialization to `BTreeMap` instead of `Vec`. That changes the format of the chain spec again * [json]: rename `BuiltinCombat` -> `BuiltinCompat` * Update ethcore/builtin/src/lib.rs Co-Authored-By: David <dvdplm@gmail.com> * [json builtin]: improve docs Co-Authored-By: David <dvdplm@gmail.com> * [json builtin]: improve docs Co-Authored-By: David <dvdplm@gmail.com> * chore(builtin): sort dependencies * [json builtin]: deprecate `eip1108` params * [machine]: add bench for calling builtin contract * [machine]: reduce calls to `Builtin::is_active` * [builtin]: fix nits * [json]: revert breakage of chain specs * [json builtin]: remove `eip1108` params * [chain specs]: update to new format * [machine]: revert changes * [devp2p]: revert change * [builtin]: doc nits
2019-10-31 17:09:08 +01:00
pub base: u64,
/// Price per point pair.
[builtin]: support `multiple prices and activations` in chain spec (#11039) * [builtin]: impl new builtin type Have an enum to deserialize either a builtin of a single price or several prices * [builtin]: style cleanup * [builtin]: fix tests * [builtin]: replace boxing with wrapper enum * cleanup * fix: make it backward compatible with old builtin * fix: update chain specs * fix: revert use of `type alias` on enum The CI doesn't use the latest rust. This commit reverts that change * fix: builtin tests * fix: revert use of `type alias` on enum * [basic-authority]: update test-chainspec * fix failing tests * [builtin]: multi-prices add `info field` It might be hard to read chain specs with several activations points. This commit introduces a `info` field which may be used to write some information about the current activation such as: `Istanbul hardfork EIP-1108` or something similar. * fix: bad rebase Co-Authored-By: David <dvdplm@gmail.com> * fix(grumbles): make it backward compatible * grumbles: resolve `NOTE` * revert chain specs changes * rename test Co-Authored-By: David <dvdplm@gmail.com> * [builtin docs]: price -> Fixed price Co-Authored-By: Andronik Ordian <write@reusable.software> * [json]: address naming grumbles InnerPricing -> PricingInner PriceWithActivationAt -> PricingAt * docs: revert changes for `AltBn128ConstOperations` * [json]: usize -> u64 Use explicit types to cope with platform dependent issues for `usize` * grumble: simplify `spec_backward_compability.json` * docs: add issue link to `TODO` * [builtin]: replace `match` with `map` * [builtin]: add deprecation message `eip1108` params * nits * [json spec tests]: fix json indentation * [json docs]: fix typos * [json]: `compability layer` + deser to BTreeMap Previously we had to match `Pricing::Single` and `PricingMulti` which this fixes. It does by introducing a compability layer and into() implemenentation. In addition, I switched the deserialization to `BTreeMap` instead of `Vec`. That changes the format of the chain spec again * [json]: rename `BuiltinCombat` -> `BuiltinCompat` * Update ethcore/builtin/src/lib.rs Co-Authored-By: David <dvdplm@gmail.com> * [json builtin]: improve docs Co-Authored-By: David <dvdplm@gmail.com> * [json builtin]: improve docs Co-Authored-By: David <dvdplm@gmail.com> * chore(builtin): sort dependencies * [json builtin]: deprecate `eip1108` params * [machine]: add bench for calling builtin contract * [machine]: reduce calls to `Builtin::is_active` * [builtin]: fix nits * [json]: revert breakage of chain specs * [json builtin]: remove `eip1108` params * [chain specs]: update to new format * [machine]: revert changes * [devp2p]: revert change * [builtin]: doc nits
2019-10-31 17:09:08 +01:00
pub pair: u64,
}
2016-03-18 19:08:57 +01:00
/// Pricing variants.
#[derive(Debug, PartialEq, Deserialize, Clone)]
#[serde(deny_unknown_fields)]
#[serde(rename_all = "snake_case")]
2016-03-18 19:08:57 +01:00
pub enum Pricing {
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
2019-09-10 00:26:45 +02:00
/// Pricing for Blake2 compression function: each call costs the same amount per round.
Blake2F {
/// Price per round of Blake2 compression function.
gas_per_round: u64,
},
2016-03-18 19:08:57 +01:00
/// Linear pricing.
Linear(Linear),
/// Pricing for modular exponentiation.
Modexp(Modexp),
/// Pricing for alt_bn128_pairing exponentiation.
AltBn128Pairing(AltBn128Pairing),
/// Pricing for constant alt_bn128 operations
AltBn128ConstOperations(AltBn128ConstOperations),
2016-03-18 19:08:57 +01:00
}
[builtin]: support `multiple prices and activations` in chain spec (#11039) * [builtin]: impl new builtin type Have an enum to deserialize either a builtin of a single price or several prices * [builtin]: style cleanup * [builtin]: fix tests * [builtin]: replace boxing with wrapper enum * cleanup * fix: make it backward compatible with old builtin * fix: update chain specs * fix: revert use of `type alias` on enum The CI doesn't use the latest rust. This commit reverts that change * fix: builtin tests * fix: revert use of `type alias` on enum * [basic-authority]: update test-chainspec * fix failing tests * [builtin]: multi-prices add `info field` It might be hard to read chain specs with several activations points. This commit introduces a `info` field which may be used to write some information about the current activation such as: `Istanbul hardfork EIP-1108` or something similar. * fix: bad rebase Co-Authored-By: David <dvdplm@gmail.com> * fix(grumbles): make it backward compatible * grumbles: resolve `NOTE` * revert chain specs changes * rename test Co-Authored-By: David <dvdplm@gmail.com> * [builtin docs]: price -> Fixed price Co-Authored-By: Andronik Ordian <write@reusable.software> * [json]: address naming grumbles InnerPricing -> PricingInner PriceWithActivationAt -> PricingAt * docs: revert changes for `AltBn128ConstOperations` * [json]: usize -> u64 Use explicit types to cope with platform dependent issues for `usize` * grumble: simplify `spec_backward_compability.json` * docs: add issue link to `TODO` * [builtin]: replace `match` with `map` * [builtin]: add deprecation message `eip1108` params * nits * [json spec tests]: fix json indentation * [json docs]: fix typos * [json]: `compability layer` + deser to BTreeMap Previously we had to match `Pricing::Single` and `PricingMulti` which this fixes. It does by introducing a compability layer and into() implemenentation. In addition, I switched the deserialization to `BTreeMap` instead of `Vec`. That changes the format of the chain spec again * [json]: rename `BuiltinCombat` -> `BuiltinCompat` * Update ethcore/builtin/src/lib.rs Co-Authored-By: David <dvdplm@gmail.com> * [json builtin]: improve docs Co-Authored-By: David <dvdplm@gmail.com> * [json builtin]: improve docs Co-Authored-By: David <dvdplm@gmail.com> * chore(builtin): sort dependencies * [json builtin]: deprecate `eip1108` params * [machine]: add bench for calling builtin contract * [machine]: reduce calls to `Builtin::is_active` * [builtin]: fix nits * [json]: revert breakage of chain specs * [json builtin]: remove `eip1108` params * [chain specs]: update to new format * [machine]: revert changes * [devp2p]: revert change * [builtin]: doc nits
2019-10-31 17:09:08 +01:00
/// Builtin compability layer
#[derive(Debug, PartialEq, Deserialize, Clone)]
#[serde(deny_unknown_fields)]
[builtin]: support `multiple prices and activations` in chain spec (#11039) * [builtin]: impl new builtin type Have an enum to deserialize either a builtin of a single price or several prices * [builtin]: style cleanup * [builtin]: fix tests * [builtin]: replace boxing with wrapper enum * cleanup * fix: make it backward compatible with old builtin * fix: update chain specs * fix: revert use of `type alias` on enum The CI doesn't use the latest rust. This commit reverts that change * fix: builtin tests * fix: revert use of `type alias` on enum * [basic-authority]: update test-chainspec * fix failing tests * [builtin]: multi-prices add `info field` It might be hard to read chain specs with several activations points. This commit introduces a `info` field which may be used to write some information about the current activation such as: `Istanbul hardfork EIP-1108` or something similar. * fix: bad rebase Co-Authored-By: David <dvdplm@gmail.com> * fix(grumbles): make it backward compatible * grumbles: resolve `NOTE` * revert chain specs changes * rename test Co-Authored-By: David <dvdplm@gmail.com> * [builtin docs]: price -> Fixed price Co-Authored-By: Andronik Ordian <write@reusable.software> * [json]: address naming grumbles InnerPricing -> PricingInner PriceWithActivationAt -> PricingAt * docs: revert changes for `AltBn128ConstOperations` * [json]: usize -> u64 Use explicit types to cope with platform dependent issues for `usize` * grumble: simplify `spec_backward_compability.json` * docs: add issue link to `TODO` * [builtin]: replace `match` with `map` * [builtin]: add deprecation message `eip1108` params * nits * [json spec tests]: fix json indentation * [json docs]: fix typos * [json]: `compability layer` + deser to BTreeMap Previously we had to match `Pricing::Single` and `PricingMulti` which this fixes. It does by introducing a compability layer and into() implemenentation. In addition, I switched the deserialization to `BTreeMap` instead of `Vec`. That changes the format of the chain spec again * [json]: rename `BuiltinCombat` -> `BuiltinCompat` * Update ethcore/builtin/src/lib.rs Co-Authored-By: David <dvdplm@gmail.com> * [json builtin]: improve docs Co-Authored-By: David <dvdplm@gmail.com> * [json builtin]: improve docs Co-Authored-By: David <dvdplm@gmail.com> * chore(builtin): sort dependencies * [json builtin]: deprecate `eip1108` params * [machine]: add bench for calling builtin contract * [machine]: reduce calls to `Builtin::is_active` * [builtin]: fix nits * [json]: revert breakage of chain specs * [json builtin]: remove `eip1108` params * [chain specs]: update to new format * [machine]: revert changes * [devp2p]: revert change * [builtin]: doc nits
2019-10-31 17:09:08 +01:00
pub struct BuiltinCompat {
/// Builtin name.
name: String,
/// Builtin pricing.
pricing: PricingCompat,
/// Activation block.
activate_at: Option<Uint>,
}
/// Spec builtin.
#[derive(Debug, PartialEq, Clone)]
2016-03-17 13:41:11 +01:00
pub struct Builtin {
/// Builtin name.
pub name: String,
/// Builtin pricing.
[builtin]: support `multiple prices and activations` in chain spec (#11039) * [builtin]: impl new builtin type Have an enum to deserialize either a builtin of a single price or several prices * [builtin]: style cleanup * [builtin]: fix tests * [builtin]: replace boxing with wrapper enum * cleanup * fix: make it backward compatible with old builtin * fix: update chain specs * fix: revert use of `type alias` on enum The CI doesn't use the latest rust. This commit reverts that change * fix: builtin tests * fix: revert use of `type alias` on enum * [basic-authority]: update test-chainspec * fix failing tests * [builtin]: multi-prices add `info field` It might be hard to read chain specs with several activations points. This commit introduces a `info` field which may be used to write some information about the current activation such as: `Istanbul hardfork EIP-1108` or something similar. * fix: bad rebase Co-Authored-By: David <dvdplm@gmail.com> * fix(grumbles): make it backward compatible * grumbles: resolve `NOTE` * revert chain specs changes * rename test Co-Authored-By: David <dvdplm@gmail.com> * [builtin docs]: price -> Fixed price Co-Authored-By: Andronik Ordian <write@reusable.software> * [json]: address naming grumbles InnerPricing -> PricingInner PriceWithActivationAt -> PricingAt * docs: revert changes for `AltBn128ConstOperations` * [json]: usize -> u64 Use explicit types to cope with platform dependent issues for `usize` * grumble: simplify `spec_backward_compability.json` * docs: add issue link to `TODO` * [builtin]: replace `match` with `map` * [builtin]: add deprecation message `eip1108` params * nits * [json spec tests]: fix json indentation * [json docs]: fix typos * [json]: `compability layer` + deser to BTreeMap Previously we had to match `Pricing::Single` and `PricingMulti` which this fixes. It does by introducing a compability layer and into() implemenentation. In addition, I switched the deserialization to `BTreeMap` instead of `Vec`. That changes the format of the chain spec again * [json]: rename `BuiltinCombat` -> `BuiltinCompat` * Update ethcore/builtin/src/lib.rs Co-Authored-By: David <dvdplm@gmail.com> * [json builtin]: improve docs Co-Authored-By: David <dvdplm@gmail.com> * [json builtin]: improve docs Co-Authored-By: David <dvdplm@gmail.com> * chore(builtin): sort dependencies * [json builtin]: deprecate `eip1108` params * [machine]: add bench for calling builtin contract * [machine]: reduce calls to `Builtin::is_active` * [builtin]: fix nits * [json]: revert breakage of chain specs * [json builtin]: remove `eip1108` params * [chain specs]: update to new format * [machine]: revert changes * [devp2p]: revert change * [builtin]: doc nits
2019-10-31 17:09:08 +01:00
pub pricing: BTreeMap<u64, PricingAt>,
}
impl From<BuiltinCompat> for Builtin {
fn from(legacy: BuiltinCompat) -> Self {
let pricing = match legacy.pricing {
PricingCompat::Single(pricing) => {
let mut map = BTreeMap::new();
let activate_at: u64 = legacy.activate_at.map_or(0, Into::into);
map.insert(activate_at, PricingAt { info: None, price: pricing });
map
}
PricingCompat::Multi(pricings) => {
pricings.into_iter().map(|(a, p)| (a.into(), p)).collect()
}
};
Self { name: legacy.name, pricing }
}
}
/// Compability layer for different pricings
#[derive(Debug, PartialEq, Deserialize, Clone)]
#[serde(rename_all = "snake_case")]
#[serde(deny_unknown_fields)]
#[serde(untagged)]
enum PricingCompat {
/// Single builtin
Single(Pricing),
/// Multiple builtins
Multi(BTreeMap<Uint, PricingAt>),
}
/// Price for a builtin, with the block number to activate it on
#[derive(Debug, PartialEq, Deserialize, Clone)]
#[serde(deny_unknown_fields)]
pub struct PricingAt {
/// Description of the activation, e.g. "PunyPony HF, March 12, 2025".
pub info: Option<String>,
/// Builtin pricing.
pub price: Pricing,
2016-03-17 13:41:11 +01:00
}
#[cfg(test)]
mod tests {
[builtin]: support `multiple prices and activations` in chain spec (#11039) * [builtin]: impl new builtin type Have an enum to deserialize either a builtin of a single price or several prices * [builtin]: style cleanup * [builtin]: fix tests * [builtin]: replace boxing with wrapper enum * cleanup * fix: make it backward compatible with old builtin * fix: update chain specs * fix: revert use of `type alias` on enum The CI doesn't use the latest rust. This commit reverts that change * fix: builtin tests * fix: revert use of `type alias` on enum * [basic-authority]: update test-chainspec * fix failing tests * [builtin]: multi-prices add `info field` It might be hard to read chain specs with several activations points. This commit introduces a `info` field which may be used to write some information about the current activation such as: `Istanbul hardfork EIP-1108` or something similar. * fix: bad rebase Co-Authored-By: David <dvdplm@gmail.com> * fix(grumbles): make it backward compatible * grumbles: resolve `NOTE` * revert chain specs changes * rename test Co-Authored-By: David <dvdplm@gmail.com> * [builtin docs]: price -> Fixed price Co-Authored-By: Andronik Ordian <write@reusable.software> * [json]: address naming grumbles InnerPricing -> PricingInner PriceWithActivationAt -> PricingAt * docs: revert changes for `AltBn128ConstOperations` * [json]: usize -> u64 Use explicit types to cope with platform dependent issues for `usize` * grumble: simplify `spec_backward_compability.json` * docs: add issue link to `TODO` * [builtin]: replace `match` with `map` * [builtin]: add deprecation message `eip1108` params * nits * [json spec tests]: fix json indentation * [json docs]: fix typos * [json]: `compability layer` + deser to BTreeMap Previously we had to match `Pricing::Single` and `PricingMulti` which this fixes. It does by introducing a compability layer and into() implemenentation. In addition, I switched the deserialization to `BTreeMap` instead of `Vec`. That changes the format of the chain spec again * [json]: rename `BuiltinCombat` -> `BuiltinCompat` * Update ethcore/builtin/src/lib.rs Co-Authored-By: David <dvdplm@gmail.com> * [json builtin]: improve docs Co-Authored-By: David <dvdplm@gmail.com> * [json builtin]: improve docs Co-Authored-By: David <dvdplm@gmail.com> * chore(builtin): sort dependencies * [json builtin]: deprecate `eip1108` params * [machine]: add bench for calling builtin contract * [machine]: reduce calls to `Builtin::is_active` * [builtin]: fix nits * [json]: revert breakage of chain specs * [json builtin]: remove `eip1108` params * [chain specs]: update to new format * [machine]: revert changes * [devp2p]: revert change * [builtin]: doc nits
2019-10-31 17:09:08 +01:00
use super::{Builtin, BuiltinCompat, BTreeMap, Pricing, PricingAt, Linear, Modexp, AltBn128ConstOperations};
use macros::map;
2016-03-17 13:41:11 +01:00
#[test]
fn builtin_deserialization() {
let s = r#"{
"name": "ecrecover",
2016-03-18 22:54:36 +01:00
"pricing": { "linear": { "base": 3000, "word": 0 } }
2016-03-17 13:41:11 +01:00
}"#;
[builtin]: support `multiple prices and activations` in chain spec (#11039) * [builtin]: impl new builtin type Have an enum to deserialize either a builtin of a single price or several prices * [builtin]: style cleanup * [builtin]: fix tests * [builtin]: replace boxing with wrapper enum * cleanup * fix: make it backward compatible with old builtin * fix: update chain specs * fix: revert use of `type alias` on enum The CI doesn't use the latest rust. This commit reverts that change * fix: builtin tests * fix: revert use of `type alias` on enum * [basic-authority]: update test-chainspec * fix failing tests * [builtin]: multi-prices add `info field` It might be hard to read chain specs with several activations points. This commit introduces a `info` field which may be used to write some information about the current activation such as: `Istanbul hardfork EIP-1108` or something similar. * fix: bad rebase Co-Authored-By: David <dvdplm@gmail.com> * fix(grumbles): make it backward compatible * grumbles: resolve `NOTE` * revert chain specs changes * rename test Co-Authored-By: David <dvdplm@gmail.com> * [builtin docs]: price -> Fixed price Co-Authored-By: Andronik Ordian <write@reusable.software> * [json]: address naming grumbles InnerPricing -> PricingInner PriceWithActivationAt -> PricingAt * docs: revert changes for `AltBn128ConstOperations` * [json]: usize -> u64 Use explicit types to cope with platform dependent issues for `usize` * grumble: simplify `spec_backward_compability.json` * docs: add issue link to `TODO` * [builtin]: replace `match` with `map` * [builtin]: add deprecation message `eip1108` params * nits * [json spec tests]: fix json indentation * [json docs]: fix typos * [json]: `compability layer` + deser to BTreeMap Previously we had to match `Pricing::Single` and `PricingMulti` which this fixes. It does by introducing a compability layer and into() implemenentation. In addition, I switched the deserialization to `BTreeMap` instead of `Vec`. That changes the format of the chain spec again * [json]: rename `BuiltinCombat` -> `BuiltinCompat` * Update ethcore/builtin/src/lib.rs Co-Authored-By: David <dvdplm@gmail.com> * [json builtin]: improve docs Co-Authored-By: David <dvdplm@gmail.com> * [json builtin]: improve docs Co-Authored-By: David <dvdplm@gmail.com> * chore(builtin): sort dependencies * [json builtin]: deprecate `eip1108` params * [machine]: add bench for calling builtin contract * [machine]: reduce calls to `Builtin::is_active` * [builtin]: fix nits * [json]: revert breakage of chain specs * [json builtin]: remove `eip1108` params * [chain specs]: update to new format * [machine]: revert changes * [devp2p]: revert change * [builtin]: doc nits
2019-10-31 17:09:08 +01:00
let builtin: Builtin = serde_json::from_str::<BuiltinCompat>(s).unwrap().into();
assert_eq!(builtin.name, "ecrecover");
assert_eq!(builtin.pricing, map![
0 => PricingAt {
info: None,
price: Pricing::Linear(Linear { base: 3000, word: 0 })
}
]);
}
#[test]
fn deserialize_multiple_pricings() {
let s = r#"{
"name": "ecrecover",
"pricing": {
"0": {
"price": {"linear": { "base": 3000, "word": 0 }}
},
"500": {
"info": "enable fake EIP at block 500",
"price": {"linear": { "base": 10, "word": 0 }}
}
}
}"#;
let builtin: Builtin = serde_json::from_str::<BuiltinCompat>(s).unwrap().into();
assert_eq!(builtin.name, "ecrecover");
assert_eq!(builtin.pricing, map![
0 => PricingAt {
info: None,
price: Pricing::Linear(Linear { base: 3000, word: 0 })
},
500 => PricingAt {
info: Some(String::from("enable fake EIP at block 500")),
price: Pricing::Linear(Linear { base: 10, word: 0 })
}
]);
}
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
2019-09-10 00:26:45 +02:00
#[test]
fn deserialization_blake2_f_builtin() {
let s = r#"{
"name": "blake2_f",
"activate_at": "0xffffff",
"pricing": { "blake2_f": { "gas_per_round": 123 } }
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
2019-09-10 00:26:45 +02:00
}"#;
[builtin]: support `multiple prices and activations` in chain spec (#11039) * [builtin]: impl new builtin type Have an enum to deserialize either a builtin of a single price or several prices * [builtin]: style cleanup * [builtin]: fix tests * [builtin]: replace boxing with wrapper enum * cleanup * fix: make it backward compatible with old builtin * fix: update chain specs * fix: revert use of `type alias` on enum The CI doesn't use the latest rust. This commit reverts that change * fix: builtin tests * fix: revert use of `type alias` on enum * [basic-authority]: update test-chainspec * fix failing tests * [builtin]: multi-prices add `info field` It might be hard to read chain specs with several activations points. This commit introduces a `info` field which may be used to write some information about the current activation such as: `Istanbul hardfork EIP-1108` or something similar. * fix: bad rebase Co-Authored-By: David <dvdplm@gmail.com> * fix(grumbles): make it backward compatible * grumbles: resolve `NOTE` * revert chain specs changes * rename test Co-Authored-By: David <dvdplm@gmail.com> * [builtin docs]: price -> Fixed price Co-Authored-By: Andronik Ordian <write@reusable.software> * [json]: address naming grumbles InnerPricing -> PricingInner PriceWithActivationAt -> PricingAt * docs: revert changes for `AltBn128ConstOperations` * [json]: usize -> u64 Use explicit types to cope with platform dependent issues for `usize` * grumble: simplify `spec_backward_compability.json` * docs: add issue link to `TODO` * [builtin]: replace `match` with `map` * [builtin]: add deprecation message `eip1108` params * nits * [json spec tests]: fix json indentation * [json docs]: fix typos * [json]: `compability layer` + deser to BTreeMap Previously we had to match `Pricing::Single` and `PricingMulti` which this fixes. It does by introducing a compability layer and into() implemenentation. In addition, I switched the deserialization to `BTreeMap` instead of `Vec`. That changes the format of the chain spec again * [json]: rename `BuiltinCombat` -> `BuiltinCompat` * Update ethcore/builtin/src/lib.rs Co-Authored-By: David <dvdplm@gmail.com> * [json builtin]: improve docs Co-Authored-By: David <dvdplm@gmail.com> * [json builtin]: improve docs Co-Authored-By: David <dvdplm@gmail.com> * chore(builtin): sort dependencies * [json builtin]: deprecate `eip1108` params * [machine]: add bench for calling builtin contract * [machine]: reduce calls to `Builtin::is_active` * [builtin]: fix nits * [json]: revert breakage of chain specs * [json builtin]: remove `eip1108` params * [chain specs]: update to new format * [machine]: revert changes * [devp2p]: revert change * [builtin]: doc nits
2019-10-31 17:09:08 +01:00
let builtin: Builtin = serde_json::from_str::<BuiltinCompat>(s).unwrap().into();
assert_eq!(builtin.name, "blake2_f");
assert_eq!(builtin.pricing, map![
0xffffff => PricingAt {
info: None,
price: Pricing::Blake2F { gas_per_round: 123 }
}
]);
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
2019-09-10 00:26:45 +02:00
}
#[test]
fn deserialization_alt_bn128_const_operations() {
let s = r#"{
"name": "alt_bn128_mul",
"pricing": {
"100500": {
"price": { "alt_bn128_const_operations": { "price": 123 }}
}
}
}"#;
let builtin: Builtin = serde_json::from_str::<BuiltinCompat>(s).unwrap().into();
assert_eq!(builtin.name, "alt_bn128_mul");
assert_eq!(builtin.pricing, map![
100500 => PricingAt {
info: None,
price: Pricing::AltBn128ConstOperations(AltBn128ConstOperations {
price: 123,
}),
}
]);
}
#[test]
fn activate_at() {
let s = r#"{
"name": "late_start",
"activate_at": 100000,
"pricing": { "modexp": { "divisor": 5 } }
}"#;
[builtin]: support `multiple prices and activations` in chain spec (#11039) * [builtin]: impl new builtin type Have an enum to deserialize either a builtin of a single price or several prices * [builtin]: style cleanup * [builtin]: fix tests * [builtin]: replace boxing with wrapper enum * cleanup * fix: make it backward compatible with old builtin * fix: update chain specs * fix: revert use of `type alias` on enum The CI doesn't use the latest rust. This commit reverts that change * fix: builtin tests * fix: revert use of `type alias` on enum * [basic-authority]: update test-chainspec * fix failing tests * [builtin]: multi-prices add `info field` It might be hard to read chain specs with several activations points. This commit introduces a `info` field which may be used to write some information about the current activation such as: `Istanbul hardfork EIP-1108` or something similar. * fix: bad rebase Co-Authored-By: David <dvdplm@gmail.com> * fix(grumbles): make it backward compatible * grumbles: resolve `NOTE` * revert chain specs changes * rename test Co-Authored-By: David <dvdplm@gmail.com> * [builtin docs]: price -> Fixed price Co-Authored-By: Andronik Ordian <write@reusable.software> * [json]: address naming grumbles InnerPricing -> PricingInner PriceWithActivationAt -> PricingAt * docs: revert changes for `AltBn128ConstOperations` * [json]: usize -> u64 Use explicit types to cope with platform dependent issues for `usize` * grumble: simplify `spec_backward_compability.json` * docs: add issue link to `TODO` * [builtin]: replace `match` with `map` * [builtin]: add deprecation message `eip1108` params * nits * [json spec tests]: fix json indentation * [json docs]: fix typos * [json]: `compability layer` + deser to BTreeMap Previously we had to match `Pricing::Single` and `PricingMulti` which this fixes. It does by introducing a compability layer and into() implemenentation. In addition, I switched the deserialization to `BTreeMap` instead of `Vec`. That changes the format of the chain spec again * [json]: rename `BuiltinCombat` -> `BuiltinCompat` * Update ethcore/builtin/src/lib.rs Co-Authored-By: David <dvdplm@gmail.com> * [json builtin]: improve docs Co-Authored-By: David <dvdplm@gmail.com> * [json builtin]: improve docs Co-Authored-By: David <dvdplm@gmail.com> * chore(builtin): sort dependencies * [json builtin]: deprecate `eip1108` params * [machine]: add bench for calling builtin contract * [machine]: reduce calls to `Builtin::is_active` * [builtin]: fix nits * [json]: revert breakage of chain specs * [json builtin]: remove `eip1108` params * [chain specs]: update to new format * [machine]: revert changes * [devp2p]: revert change * [builtin]: doc nits
2019-10-31 17:09:08 +01:00
let builtin: Builtin = serde_json::from_str::<BuiltinCompat>(s).unwrap().into();
assert_eq!(builtin.name, "late_start");
assert_eq!(builtin.pricing, map![
100_000 => PricingAt {
info: None,
price: Pricing::Modexp(Modexp { divisor: 5 })
}
]);
2016-03-17 13:41:11 +01:00
}
}