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

EIP 1108: Reduce alt_bn128 precompile gas costs #11008

Merged
merged 7 commits into from
Sep 2, 2019
Merged

EIP 1108: Reduce alt_bn128 precompile gas costs #11008

merged 7 commits into from
Sep 2, 2019

Conversation

niklasad1
Copy link
Collaborator

@niklasad1 niklasad1 commented Aug 29, 2019

Attempt to close #10998 and implement https://eips.ethereum.org/EIPS/eip-1108

Warning, this is not an elegant PR because ethcore/builtins reads the values directly from JSON and I tried to implement it as best effort.

If this is good enough, I will update the chain spec accordingly

@niklasad1 niklasad1 force-pushed the na-eip1108 branch 2 times, most recently from b045765 to 7bf1f51 Compare August 29, 2019 15:17
Box::new(AltBn128ConstOperations {
price: pricer.price,
eip1108_transition_price: pricer.eip1108_transition_price,
eip1108_transition_at: b.eip1108_transition.map_or(u64::max_value(), Into::into)
Copy link
Collaborator Author

Choose a reason for hiding this comment

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

deny-by-default

base: pricer.base,
pair: pricer.pair,
},
eip1108_transition_at: b.eip1108_transition.map_or(u64::max_value(), Into::into),
Copy link
Collaborator Author

Choose a reason for hiding this comment

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

deny-by-default

@niklasad1 niklasad1 marked this pull request as ready for review August 29, 2019 15:41
@niklasad1 niklasad1 added A0-pleasereview 🤓 Pull request needs code review. M4-core ⛓ Core client code / Rust. labels Aug 29, 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.

minor comments&feedback

ethcore/builtin/src/lib.rs Show resolved Hide resolved
ethcore/types/src/engines/params.rs Outdated Show resolved Hide resolved
json/src/spec/builtin.rs Outdated Show resolved Hide resolved
@dvdplm
Copy link
Collaborator

dvdplm commented Aug 29, 2019

If this is good enough, I will update the chain spec accordingly

Can you elaborate on this? What further changes to the chainspec do we need?

As for "good enough" I'm interested in hearing if Wei has a better idea. I think juggling these transitions is always a bit inelegant but maybe he has a better approach.

@niklasad1 how would you refactor the Pricer trait to avoid the extra param?

@sorpaas
Copy link
Collaborator

sorpaas commented Aug 29, 2019

@dvdplm A better approach I can think of maybe something like this: we define a new type builtinMulti (as a field in json::Account). It takes a hashmap, where keys are block number, and values are Builtin. We then activate/deactivate builtins based on the block number. The resulting config will look something like this:

"accounts": {
  "0000000000000000000000000000000000000008": { "builtinMulti": {
    "0": { "name": "alt_bn128_pairing", "activate_at": 2000000, "pricing": { "alt_bn128_pairing": { "base": 100000, "pair": 80000 } } } },
    "12345678": { "name": "alt_bn128_pairing", "activate_at": 2000000, "pricing": { "alt_bn128_pairing": { "base": 900, "pair": 1000 } } } },
  }
}

However, this will probably take some time to refactor, and given our time constraints, I think @niklasad1's approach should be good enough!

@niklasad1
Copy link
Collaborator Author

@dvdplm

Can you elaborate on this? What further changes to the chainspec do we need?

We need to update all other chain specs with the eip1108_transition params

As for "good enough" I'm interested in hearing if Wei has a better idea. I think juggling these transitions is always a bit inelegant but maybe he has a better approach.

Yes, it is not pretty I agree

how would you refactor the Pricer trait to avoid the extra param?

I think it should be possible to revert it completely if we could handle it within JSON (builtinMulti as Wei suggested). Otherwise, I have no good idea without reworking the entire thing.

@dvdplm
Copy link
Collaborator

dvdplm commented Aug 30, 2019

update all other chain specs with the eip1108_transition params

Right, of course. Ok, overall lgtm. Holler when you're done with this and I'll give it a once-over again. :)

@niklasad1
Copy link
Collaborator Author

I'm done 👍

@@ -38,9 +38,11 @@ trait Implementation: Send + Sync {
}

/// A gas pricing scheme for built-in contracts.
// NOTE(niklasad1): maybe refactor this trait because only `bn128_operations` are using
Copy link
Collaborator

Choose a reason for hiding this comment

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

Please add an issue and include a link here.

@dvdplm
Copy link
Collaborator

dvdplm commented Sep 2, 2019

@sorpaas looks good to you? Let's merge this! :)

@sorpaas sorpaas merged commit a9cb572 into master Sep 2, 2019
@sorpaas sorpaas deleted the na-eip1108 branch September 2, 2019 09:38
@ordian ordian added this to the 2.7 milestone Sep 2, 2019
@ordian ordian added A8-looksgood 🦄 Pull request is reviewed well. B0-patch-stable 🕷 Pull request should also be back-ported to the stable branch. B1-patch-beta 🕷🕷 and removed A0-pleasereview 🤓 Pull request needs code review. labels Sep 2, 2019
ordian added a commit to ordian/parity that referenced this pull request Sep 2, 2019
* master:
  EIP 1108: Reduce alt_bn128 precompile gas costs (openethereum#11008)
  Fix deadlock in `network-devp2p` (openethereum#11013)
dvdplm added a commit that referenced this pull request Sep 2, 2019
* master:
  EIP 1108: Reduce alt_bn128 precompile gas costs (#11008)
  Fix deadlock in `network-devp2p` (#11013)
  Implement EIP-1283 reenable transition, EIP-1706 and EIP-2200 (#10191)
dvdplm added a commit that referenced this pull request Sep 3, 2019
…he-right-place

* master:
  Extract snapshot to own crate (#11010)
  Edit publish-onchain.sh to use https (#11016)
  EIP 1108: Reduce alt_bn128 precompile gas costs (#11008)
  Fix deadlock in `network-devp2p` (#11013)
  Implement EIP-1283 reenable transition, EIP-1706 and EIP-2200 (#10191)
  EIP 1884 Re-pricing of trie-size dependent operations (#10992)
@holiman
Copy link
Contributor

holiman commented Sep 6, 2019

Wow, nice job on the PR number; 11008 for 1108!

@dvdplm
Copy link
Collaborator

dvdplm commented Sep 6, 2019

Glad someone finally noticed! ;)

dvdplm pushed a commit that referenced this pull request Sep 11, 2019
* 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`

* add issue link to `TODO`
s3krit pushed a commit that referenced this pull request Sep 11, 2019
* 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`

* add issue link to `TODO`
This was referenced Sep 12, 2019
s3krit added a commit that referenced this pull request Sep 12, 2019
* add more tx tests (#11038)
* Fix parallel transactions race-condition (#10995)
* Add blake2_f precompile (#11017)
* [trace] introduce trace failed to Ext (#11019)
* Edit publish-onchain.sh to use https (#11016)
* Fix deadlock in network-devp2p (#11013)
* EIP 1108: Reduce alt_bn128 precompile gas costs (#11008)
* xDai chain support and nodes list update (#10989)
* EIP 2028: transaction gas lowered from 68 to 16 (#10987)
* EIP-1344 Add CHAINID op-code (#10983)
* manual publish jobs for releases, no changes for nightlies (#10977)
* [blooms-db] Fix benchmarks (#10974)
* Verify transaction against its block during import (#10954)
* Better error message for rpc gas price errors (#10931)
* Fix fork choice (#10837)
* Fix compilation on recent nightlies (#10991)
s3krit added a commit that referenced this pull request Sep 12, 2019
* add more tx tests (#11038)
* Fix parallel transactions race-condition (#10995)
* Add blake2_f precompile (#11017)
* [trace] introduce trace failed to Ext (#11019)
* Edit publish-onchain.sh to use https (#11016)
* Fix deadlock in network-devp2p (#11013)
* EIP 1108: Reduce alt_bn128 precompile gas costs (#11008)
* xDai chain support and nodes list update (#10989)
* EIP 2028: transaction gas lowered from 68 to 16 (#10987)
* EIP-1344 Add CHAINID op-code (#10983)
* manual publish jobs for releases, no changes for nightlies (#10977)
* [blooms-db] Fix benchmarks (#10974)
* Verify transaction against its block during import (#10954)
* Better error message for rpc gas price errors (#10931)
* tx-pool: accept local tx with higher gas price when pool full (#10901)
* Fix fork choice (#10837)
* Cleanup unused vm dependencies (#10787)
* Fix compilation on recent nightlies (#10991)
@phahulin
Copy link
Contributor

In future releases it might be a good idea to provide instructions about required updates in chainspec or other breaking changes in Changelog, for those who run custom networks

@dvdplm
Copy link
Collaborator

dvdplm commented Sep 16, 2019

@phahulin I agree, we did not handle that optimally. Apologies. OTOH it's non-trivial to keep track of exactly what changes affect which (advanced) users; do you have any concrete suggestions for us, other than writing more detailed changelogs?

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
A8-looksgood 🦄 Pull request is reviewed well. B0-patch-stable 🕷 Pull request should also be back-ported to the stable branch. M4-core ⛓ Core client code / Rust.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

EIP 1108: Reduce alt_bn128 precompile gas costs
6 participants