Skip to content
This repository has been archived by the owner on Nov 6, 2020. It is now read-only.

[builtin]: support multiple prices and activations in chain spec #11039

Merged
merged 53 commits into from
Oct 31, 2019

Conversation

niklasad1
Copy link
Collaborator

@niklasad1 niklasad1 commented Sep 12, 2019

This PR tries to close #11014 and close #11063

To summarize the important change with this PR is that the chain spec format for builtins which support old format (with single pricing/activation) and new format as map to support multiple pricing/activations follows:

"builtin": {
    "name": "single_activation_old_format",
    "pricing": { "linear": {"base": 60, "word": 12 } },
     "activate_at": 0
}

"builtin": {
    "name": "multi_prices_and_activation",
    "pricing": {
        "4370000": {
            "info": "Hardfork X enable EIP ZZ",
            "price": {
                "linear": {
                        "base": 500,
                        "word": 0
                }
            }
        },
        "36028797018963967": { 
           "info": "Hardfork Y enable EIP ZZ", 
            "price": {
                "linear": {
                        "base": 150,
                        "word": 0
                }
            }
        }
    }     
}

@dvdplm
Copy link
Collaborator

dvdplm commented Sep 13, 2019

Would something like this work?

"builtin": {
	"name": "single_activation",
	"pricing": {
		"linear": {"base": 60, "word": 12 }, "activate_at": 87
	}
}
"builtin": {
	"name": "multi_prices_and_activation",
	"pricing": [
		{ "linear": {"base": 60, "word": 12 }, "activate_at": 123 },
		{ "modexp": {"divisor": 3.14 }, "activate_at": 456123 }
	]
}

@niklasad1
Copy link
Collaborator Author

Would something like this work?

Yes, except the floating-point/fraction part. I'm not really sure if it makes sense to change price model on the same builtin but I guess it is more future-proof than just changing values if it is needed.

@dvdplm
Copy link
Collaborator

dvdplm commented Sep 13, 2019

makes sense to change price model on the same builtin but I guess it is more future-proof than just changing values if it is needed.

It is most likely completely non-sensical, but yeah, the world is a crazy place!

@ordian ordian added A3-inprogress ⏳ Pull request is in progress. No review needed at this stage. M2-config 📂 Chain specifications and node configurations. M4-core ⛓ Core client code / Rust. labels Sep 19, 2019
@ordian ordian added this to the 2.7 milestone Sep 19, 2019
@niklasad1 niklasad1 force-pushed the na-builtin-refactor branch 6 times, most recently from a5c52b8 to 8db3971 Compare October 1, 2019 15:21
@niklasad1 niklasad1 marked this pull request as ready for review October 1, 2019 15:28
@niklasad1 niklasad1 added A0-pleasereview 🤓 Pull request needs code review. B0-patch-stable 🕷 Pull request should also be back-ported to the stable branch. B1-patch-beta 🕷🕷 and removed A3-inprogress ⏳ Pull request is in progress. No review needed at this stage. labels Oct 1, 2019
ethcore/builtin/src/lib.rs Outdated Show resolved Hide resolved
ethcore/builtin/src/lib.rs Outdated Show resolved Hide resolved
ethcore/builtin/src/lib.rs Outdated Show resolved Hide resolved
json/src/spec/spec.rs Outdated Show resolved Hide resolved
ethcore/res/ethereum/classic.json Show resolved Hide resolved
ethcore/builtin/src/lib.rs Outdated Show resolved Hide resolved
ethcore/builtin/src/lib.rs Outdated Show resolved Hide resolved
ethcore/builtin/src/lib.rs Outdated Show resolved Hide resolved
dvdplm
dvdplm previously requested changes Oct 4, 2019
Copy link
Collaborator

@dvdplm dvdplm left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good stuff here, thank you for taking it on.
On the json formatting side I think we should be using hex consistently. I have some comments/questions around the new Single/Multi.

ethcore/res/authority_round.json Outdated Show resolved Hide resolved
ethcore/res/authority_round.json Outdated Show resolved Hide resolved
ethcore/res/authority_round.json Outdated Show resolved Hide resolved
ethcore/res/authority_round_block_reward_contract.json Outdated Show resolved Hide resolved
ethcore/res/ethereum/callisto.json Outdated Show resolved Hide resolved
json/src/spec/builtin.rs Show resolved Hide resolved
json/src/spec/builtin.rs Outdated Show resolved Hide resolved
json/src/spec/builtin.rs Outdated Show resolved Hide resolved
json/src/spec/spec.rs Outdated Show resolved Hide resolved
json/src/spec/builtin.rs Outdated Show resolved Hide resolved
@niklasad1 niklasad1 force-pushed the na-builtin-refactor branch 2 times, most recently from bceeac1 to 4510485 Compare October 4, 2019 17:06
ethcore/builtin/src/lib.rs Outdated Show resolved Hide resolved
json/src/spec/builtin.rs Outdated Show resolved Hide resolved
ethcore/res/spec_backward_compability.json Outdated Show resolved Hide resolved
ethcore/builtin/src/lib.rs Outdated Show resolved Hide resolved
ethcore/builtin/src/lib.rs Outdated Show resolved Hide resolved
Have an enum to deserialize either a builtin of a single price or several prices
@niklasad1 niklasad1 added A0-pleasereview 🤓 Pull request needs code review. B0-patch-stable 🕷 Pull request should also be back-ported to the stable branch. B1-patch-beta 🕷🕷 B7-releasenotes 📜 Changes should be mentioned in the release notes of the next minor version release. and removed A3-inprogress ⏳ Pull request is in progress. No review needed at this stage. labels Oct 31, 2019
Copy link
Collaborator

@ordian ordian left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm not sure about omitting is_active check in some places, but other than that looks good.

@niklasad1
Copy link
Collaborator Author

niklasad1 commented Oct 31, 2019

I'm not sure about omitting is_active check in some places, but other than that looks good.

Fair enough, I can revert those to be on the safe side, however, machine calls is_active three times instead of one IIRC. I can handle that in another PR that doesn't have to be backported

Copy link
Collaborator

@dvdplm dvdplm left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

minor nits

ethcore/machine/src/executive.rs Outdated Show resolved Hide resolved
ethcore/machine/src/executive.rs Outdated Show resolved Hide resolved
ethcore/builtin/src/lib.rs Outdated Show resolved Hide resolved
ethcore/builtin/src/lib.rs Outdated Show resolved Hide resolved
pub fn execute(&self, input: &[u8], output: &mut BytesRef) -> Result<(), &'static str> {
self.native.execute(input, output)
}

/// Whether the builtin is activated at the given block number.
#[inline]
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Just curious: did you measure that these #[inline]s matter or is it hunch-based optimization?

Copy link
Collaborator Author

@niklasad1 niklasad1 Oct 31, 2019

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think those were already inlined thus I didn't see any measurable difference IIRC, do you want the annotations removed?

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No, it's fine, I was just curious.

@ordian ordian merged commit 13729a0 into master Oct 31, 2019
@ordian ordian deleted the na-builtin-refactor branch October 31, 2019 16:09
niklasad1 added a commit that referenced this pull request Nov 2, 2019
…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
varasev added a commit to poanetwork/posdao-contracts that referenced this pull request Nov 4, 2019
soc1c pushed a commit that referenced this pull request Nov 5, 2019
* ethcore-builtin (#10850)

* ethcore-builtin

* rename ethcore-builtin Impl to Implementation

* [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

* manually adjust spec

* [chain specs]: activate `Istanbul` on mainnet (#11228)

* [chains spec]: activate istanbul at mainnet

* Activate `Block >= 9,069,000` on the Ethereum mainnet
* Enable Blake2 compression function `F` precompile

* [chain specs]: add comments for EIP1108 activation

* [chainspec mainnet]: enable Istanbul transitions

* [chainspec mainnet]: simply configuration

* ethcore/res: add mordor testnet configuration (#11200)

* ethcore/res: add mordor testnet configuration

* ethcore/spec: add mordor testnet configuration

* parity/cli: add mordor testnet configuration

* parity/config: fix tests

* ethcore/res: update mordor spec with agharta hardfork block 301243

*  ethcore/res: update kotti with agharta block 1705549

* ethcore/res: update morden with agharta block 5000381

* ethcore/res: multiple prices and activations for mordor testnet

* fix mordor spec json

* fix mordor spec json

* fix bad merge

* [ethereum tests]: revert `725dbc73a725dbc73a`
This was referenced Nov 5, 2019
niklasad1 added a commit that referenced this pull request Nov 5, 2019
…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
dvdplm added a commit that referenced this pull request Nov 6, 2019
* master: (21 commits)
  ropsten #6631425 foundation #8798209 (#11201)
  Update list of bootnodes for xDai chain (#11236)
  ethcore/res: add mordor testnet configuration (#11200)
  [chain specs]: activate `Istanbul` on mainnet (#11228)
  [builtin]: support `multiple prices and activations` in chain spec (#11039)
  Insert explicit warning into the panic hook (#11225)
  Snapshot restoration overhaul (#11219)
  Fix docker centos build (#11226)
  retry on gitlab system failures (#11222)
  Update bootnodes. (#11203)
  Use provided usd-per-eth value if an endpoint is specified (#11209)
  Use a lock instead of atomics for snapshot Progress (#11197)
  [informant]: `MillisecondDuration` -> `as_millis()` (#11211)
  Step duration map configuration parameter ported from the POA Network fork (#10902)
  Upgrade jsonrpc to latest (#11206)
  [export hardcoded sync]: use debug for `H256` (#11204)
  Pause pruning while snapshotting (#11178)
  Type annotation for next_key() matching of json filter options (#11192)
  Crypto primitives removed from ethkey (#11174)
  Made ecrecover implementation trait public (#11188)
  ...
s3krit pushed a commit that referenced this pull request Nov 11, 2019
* ropsten #6631425 foundation #8798209 (#11201)
* [stable] builtin, istanbul and mordor testnet backports (#11234)
  * ethcore-builtin (#10850)
  * [builtin]: support `multiple prices and activations` in chain spec (#11039)
  * [chain specs]: activate `Istanbul` on mainnet (#11228)
  * ethcore/res: add mordor testnet configuration (#11200)
* Update list of bootnodes for xDai chain (#11236)
* ethcore: remove `test-helper feat` from build (#11047)
* Secret store: fix Instant::now() related race in net_keep_alive (#11155) (#11159)
* [stable]: backport #10691 and #10683 (#11143)
  * Fix compiler warning (that will become an error) (#10683)
  * Refactor Clique stepping (#10691)
* Add Constantinople eips to the dev (instant_seal) config (#10809)
* Add cargo-remote dir to .gitignore (?)
* Insert explicit warning into the panic hook (#11225)
* Fix docker centos build (#11226)
* Update MIX bootnodes. (#11203)
* Use provided usd-per-eth value if an endpoint is specified (#11209)
* Add new line after writing block to hex file. (#10984)
* Type annotation for next_key() matching of json filter options (#11192) (but no `FilterOption` in 2.5 so…)
* Upgrade jsonrpc to latest (#11206)
* [CI] check evmbin build (#11096)
* Correct EIP-712 encoding (#11092)
* [client]: Fix for incorrectly dropped consensus messages (#11086)
* Fix block detail updating (#11015)
* Switching sccache from local to Redis (#10971)
* Made ecrecover implementation trait public (#11188)
* [dependencies]: jsonrpc `14.0.1` (#11183)
* [receipt]: add `sender` & `receiver` to `RichReceipts` (#11179)
* [ethcore/builtin]: do not panic in blake2pricer on short input (#11180)
* util Host: fix a double Read Lock bug in fn Host::session_readable() (#11175)
* ethcore client: fix a double Read Lock bug in fn Client::logs() (#11172)
* Change how RPCs eth_call and eth_estimateGas handle "Pending" (#11127)
* Cleanup stratum a bit (#11161)
* Upgrade to jsonrpc v14 (#11151)
* SecretStore: expose restore_key_public in HTTP API (#10241)
s3krit pushed a commit that referenced this pull request Nov 11, 2019
* [CI] check evmbin build (#11096)
* Correct EIP-712 encoding (#11092)
* [client]: Fix for incorrectly dropped consensus messages (#11082) (#11086)
* Update hardcoded headers (foundation, classic, kovan, xdai, ewc, ...) (#11053)
* Add cargo-remote dir to .gitignore (?)
* Update light client headers: ropsten 6631425 foundation 8798209 (#11201)
* Update list of bootnodes for xDai chain (#11236)
* ethcore/res: add mordor testnet configuration (#11200)
* [chain specs]: activate Istanbul on mainnet (#11228)
* [builtin]: support multiple prices and activations in chain spec (#11039)
* [receipt]: add sender & receiver to RichReceipts (#11179)
* [ethcore/builtin]: do not panic in blake2pricer on short input (#11180)
* Made ecrecover implementation trait public (#11188)
* Fix docker centos build (#11226)
* Update MIX bootnodes. (#11203)
* Insert explicit warning into the panic hook (#11225)
* Use provided usd-per-eth value if an endpoint is specified (#11209)
* Cleanup stratum a bit (#11161)
* Add Constantinople EIPs to the dev (instant_seal) config (#10809) (already backported)
* util Host: fix a double Read Lock bug in fn Host::session_readable() (#11175)
* ethcore client: fix a double Read Lock bug in fn Client::logs() (#11172)
* Type annotation for next_key() matching of json filter options (#11192)
* Upgrade jsonrpc to latest (#11206)
* [dependencies]: jsonrpc 14.0.1 (#11183)
* Upgrade to jsonrpc v14 (#11151)
* Switching sccache from local to Redis (#10971)
* Snapshot restoration overhaul (#11219)
* Add new line after writing block to hex file. (#10984)
* Pause pruning while snapshotting (#11178)
* Change how RPCs eth_call and eth_estimateGas handle "Pending" (#11127)
* Fix block detail updating (#11015)
* Make InstantSeal Instant again #11186
* Filter out some bad ropsten warp snapshots (#11247)
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
A0-pleasereview 🤓 Pull request needs code review. B0-patch-stable 🕷 Pull request should also be back-ported to the stable branch. B7-releasenotes 📜 Changes should be mentioned in the release notes of the next minor version release. M2-config 📂 Chain specifications and node configurations. M4-core ⛓ Core client code / Rust.
Projects
None yet
4 participants