-
Notifications
You must be signed in to change notification settings - Fork 34
[WIP] EIP-50 - 6.0 Soft-Fork #100
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Open
kushti
wants to merge
24
commits into
master
Choose a base branch
from
eip50
base: master
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
Show all changes
24 commits
Select commit
Hold shift + click to select a range
a24fc41
EIP-50 initial draft
kushti f7361ba
implementation and tests for new method
kushti ecb6ff3
more issues added
kushti 698c270
fixing class names
kushti 9be47ad
update with new issues and PRs
kushti 278bee5
minor text polishing
kushti 7cbc850
updating header related issues and PRs
kushti 8685ed9
(de)serialization PRs updated
kushti df7ad75
updating issues
kushti 7a1caa8
LangSpec.md, updating serialization PRs
kushti cdd347c
updating statuses
kushti 63a22ae
finalizing 6.0 scope
kushti 32e74a8
update w. fromBigEndianBytes
kushti 6922535
getvar issues update
kushti 1059a13
update towards impl
kushti 1670e76
motivation / main changes started
kushti 0bcbffd
main changes
kushti cdb3c0f
reordering sections
kushti f01f902
statuses removed, header, appendices
kushti 396824a
polishing issues / PRs
kushti 027e8cb
new param and voting relaxation text in motivation
kushti 73234cd
update towards finalized impl
kushti 8f92986
avltree.insert PR
kushti 6102112
reworking appendices
kushti File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change | ||||
|---|---|---|---|---|---|---|
| @@ -0,0 +1,212 @@ | ||||||
| Sigma 6.0 | ||||||
| ========= | ||||||
|
|
||||||
| * Author: kushti | ||||||
| * Status: Proposed | ||||||
| * Created: 25-Nov-2024 | ||||||
| * Implemented: Ergo Protocol Reference Client 6.0.0 | ||||||
| * Last edited: 27-May-2024 | ||||||
| * License: CC0 | ||||||
| * Forking: soft-fork (at least all the miners have to update) | ||||||
|
|
||||||
| Motivation | ||||||
| ---------- | ||||||
|
|
||||||
| To the moment, ErgoTree features are still the same as of mainnet launch (July, 2019), with only JIT costing replacing | ||||||
| AOT introduced in 5.0 soft-fork, along with minimal changes. | ||||||
|
|
||||||
| Within five years after mainnet launch, developers found many ways to improve expressiveness of scripts and make | ||||||
| efficiently things which can be implemented in non-trivial ways only now. Some issues were found as well (happily, nothing critical). | ||||||
| And finally, there are some features planned during Ergo testnets even (2018-19) but not landed in the mainnet. | ||||||
|
|
||||||
| To address developers' feedback, and also fix known issues, we are proposing a soft-fork (with existing nodes validating scripts with old features and skipping scripts with new features, pretty much like e.g. SegWit update in Bitcoin) in this document. | ||||||
|
|
||||||
| Also, we propose to relax voteable parameters validation to support introducing new parameters to vote via soft-forks or | ||||||
| even velvet forks. Also, we propose to add new blockchain parameter to vote since 6.0, namely, average number of sub-blocks | ||||||
| per block, to enhance upcoming sub-blocks implementation. This change is done in soft-fork way also, by disabling soft-forkable rule #215 via miners voting. | ||||||
|
|
||||||
| Main Changes | ||||||
| ------------- | ||||||
|
|
||||||
| The biggest proposed changes are: | ||||||
|
|
||||||
| * new UnsignedBigInt type, unsigned 256-bits integer tailored for cryptographic applications, with modular arithmetic operations and so on | ||||||
|
|
||||||
| * support for serialization and deserialization in the scripts for all the existing types (including composite, | ||||||
| such as collection of optional block headers, `Coll[Option[Header]]` in ErgoScript) | ||||||
|
|
||||||
| * support for serialization and deserialization of instances of Option and Header types. It allows to store them in | ||||||
| register or context extension variables. Also, constructors for Option instances (`Global.some[T]()` and `Global.none[T]` | ||||||
| methods for any type `T`). Also, support for serialization and deserialization of SFunc type, which is providing | ||||||
| support for higher-order functions | ||||||
|
|
||||||
| * support for conversion from nbits-encoded number to big integer and back, to provide support to check difficulty for | ||||||
| Ergo (and Bitcoin) headers efficiently. Examples for checking PoW for Ergo and Bitcoin headers can be found in 6.0 | ||||||
| tests. | ||||||
|
|
||||||
| * new methods to check proof of work for Ergo header (header.checkPow), and also to check PoW for custom variant of | ||||||
| Autolykos2 algorithm for arbitrary message | ||||||
|
|
||||||
| * possibility to read context variable from another input (useful to obtain state transition for a companion input) | ||||||
|
|
||||||
| * methods support for `Byte`, `Short`, `Int`, `Long` types, more methods for all the numeric types (`.toBytes`, `.toBits`, | ||||||
| `.shiftLeft`, `.shiftRight`, `bitwiseOr`, `bitwiseAnd`, `bitwiseXor` etc) | ||||||
|
|
||||||
| * more collection methods (`.get` to optionally get element if a collection contains it, `reverse`, `startsWith`, `endsWith`) | ||||||
|
|
||||||
| And also: | ||||||
|
|
||||||
| * possibility to propose voting for parameters not known to protocol client. It allows for introducing new voteable | ||||||
| parameters via soft or even velvet-forks | ||||||
|
|
||||||
| * new voteable parameter, number of sub-blocks per block (for further sub-blocks implementation) | ||||||
|
|
||||||
| To check how those features are implemented, and to get more features and fixes done, see pointers to concrete issues | ||||||
| and pull requests in the *Corresponding Issues and Pull Requests* section below. | ||||||
|
|
||||||
|
|
||||||
| Corresponding Issues and Pull Requests | ||||||
| -------------------------------------- | ||||||
|
|
||||||
| * *.checkPoW* method of *Header* type to validate Autolykos2 proof of work done on header | ||||||
|
|
||||||
| issue: https://github.com/ScorexFoundation/sigmastate-interpreter/issues/958 | ||||||
| PR #1: https://github.com/ScorexFoundation/sigmastate-interpreter/pull/965 (Autolykos verification for a custom message) | ||||||
| PR #2: https://github.com/ScorexFoundation/sigmastate-interpreter/pull/968 (Header.checkPow) | ||||||
|
|
||||||
|
|
||||||
| * implement conversion from Long-encoded nBits representation to BigInt (long.fromNBits method) and to nBits from BitInt (bigInt.toNBits method) | ||||||
|
|
||||||
| issue: https://github.com/ScorexFoundation/sigmastate-interpreter/issues/675 | ||||||
| PR #1: https://github.com/ScorexFoundation/sigmastate-interpreter/pull/962 (nbits encoding) | ||||||
| PR #2: https://github.com/ScorexFoundation/sigmastate-interpreter/pull/962 (nbits decoding) | ||||||
|
|
||||||
|
|
||||||
| * UnsignedBigInt type for cryptographic applications | ||||||
|
|
||||||
| issue: https://github.com/ScorexFoundation/sigmastate-interpreter/issues/554 | ||||||
| PR: https://github.com/ScorexFoundation/sigmastate-interpreter/pull/997 | ||||||
|
|
||||||
|
|
||||||
| * support MethodCall encoding of Numeric methods | ||||||
|
|
||||||
| issue: https://github.com/ScorexFoundation/sigmastate-interpreter/issues/667 | ||||||
| PR: (Numeric.toBigEndianBytes) https://github.com/ScorexFoundation/sigmastate-interpreter/pull/984 | ||||||
|
|
||||||
| * Add Numeric.toBytes | ||||||
|
|
||||||
| issue: https://github.com/ScorexFoundation/sigmastate-interpreter/issues/486 | ||||||
| PR: (Numeric.toBigEndianBytes) https://github.com/ScorexFoundation/sigmastate-interpreter/pull/984 | ||||||
|
|
||||||
|
|
||||||
| * Add Numeric.toBits | ||||||
|
|
||||||
| issue: https://github.com/ScorexFoundation/sigmastate-interpreter/issues/992 | ||||||
| PR: https://github.com/ScorexFoundation/sigmastate-interpreter/pull/1017 | ||||||
|
|
||||||
|
|
||||||
| * Fix for downcasting BigInt to Long fails | ||||||
|
|
||||||
| issue: https://github.com/ScorexFoundation/sigmastate-interpreter/issues/877 | ||||||
| PR: https://github.com/ScorexFoundation/sigmastate-interpreter/pull/1007 | ||||||
|
|
||||||
|
|
||||||
| * Lazy default evaluation for Option.getOrElse and Coll.getOrElse | ||||||
|
|
||||||
| issue: https://github.com/ScorexFoundation/sigmastate-interpreter/issues/906 | ||||||
| PR: https://github.com/ergoplatform/sigmastate-interpreter/pull/1008 | ||||||
|
|
||||||
| * Implement Some and None constructors as global methods | ||||||
|
|
||||||
| issue: https://github.com/ScorexFoundation/sigmastate-interpreter/issues/462 | ||||||
| PR: https://github.com/ergoplatform/sigmastate-interpreter/pull/1026 | ||||||
|
|
||||||
| * Serialize Option[T] in DataSerializer | ||||||
|
|
||||||
| issue: https://github.com/ScorexFoundation/sigmastate-interpreter/issues/659 | ||||||
| PR: https://github.com/ScorexFoundation/sigmastate-interpreter/pull/990 | ||||||
|
|
||||||
|
|
||||||
| * Add support for Header values (de)serialization in DataSerializer: | ||||||
|
|
||||||
| issue: https://github.com/ScorexFoundation/sigmastate-interpreter/issues/969 | ||||||
| PR: https://github.com/ScorexFoundation/sigmastate-interpreter/pull/972 | ||||||
|
|
||||||
|
|
||||||
| * GetVar(inputIndex, varId) variant for reading context variable from another input | ||||||
|
|
||||||
| issue: https://github.com/ScorexFoundation/sigmastate-interpreter/issues/978 | ||||||
| issue: https://github.com/ScorexFoundation/sigmastate-interpreter/issues/983 | ||||||
| PR: https://github.com/ergoplatform/sigmastate-interpreter/pull/1016 | ||||||
|
|
||||||
| * Implement binary serialization and deserialization for every type | ||||||
|
|
||||||
| issue: https://github.com/ScorexFoundation/sigmastate-interpreter/issues/945 | ||||||
| PR #1 (Global.deserializeTo): https://github.com/ScorexFoundation/sigmastate-interpreter/pull/979 | ||||||
| PR #2 (Global.serialize): https://github.com/ScorexFoundation/sigmastate-interpreter/pull/989 | ||||||
| PR #3 (Numeric.toBigEndianBytes) https://github.com/ScorexFoundation/sigmastate-interpreter/pull/984 | ||||||
| PR #4 (Global.fromBigEndianBytes) https://github.com/ScorexFoundation/sigmastate-interpreter/pull/1013 | ||||||
|
|
||||||
|
|
||||||
| * Fix SubstContants: serialize ErgoTree size | ||||||
|
|
||||||
| issue: https://github.com/ScorexFoundation/sigmastate-interpreter/issues/994 | ||||||
| PR: https://github.com/ScorexFoundation/sigmastate-interpreter/pull/995 | ||||||
|
|
||||||
| * New collection methods for 6.0 | ||||||
|
|
||||||
| issue: https://github.com/ScorexFoundation/sigmastate-interpreter/issues/1004 | ||||||
| PR: https://github.com/ergoplatform/sigmastate-interpreter/pull/1010 | ||||||
|
|
||||||
| * New numeric methods for 6.0 | ||||||
|
|
||||||
| issue: https://github.com/ScorexFoundation/sigmastate-interpreter/issues/1006 | ||||||
| PR: https://github.com/ergoplatform/sigmastate-interpreter/pull/1017 | ||||||
|
|
||||||
| * Implementation of Box.getReg | ||||||
|
|
||||||
| issue: https://github.com/ScorexFoundation/sigmastate-interpreter/issues/416 | ||||||
| PR: https://github.com/ergoplatform/sigmastate-interpreter/pull/1015 | ||||||
|
|
||||||
| * Serialize SFunc in TypeSerializer | ||||||
|
|
||||||
| issue: https://github.com/ScorexFoundation/sigmastate-interpreter/issues/847 | ||||||
| PR: https://github.com/ScorexFoundation/sigmastate-interpreter/pull/1020 | ||||||
|
|
||||||
| * Revise liftToConstant method | ||||||
|
|
||||||
| issue: https://github.com/ScorexFoundation/sigmastate-interpreter/issues/905 | ||||||
| PR: https://github.com/ergoplatform/sigmastate-interpreter/pull/1021 | ||||||
|
|
||||||
| * Improve collections equality | ||||||
|
|
||||||
| issue: https://github.com/ScorexFoundation/sigmastate-interpreter/issues/909 | ||||||
| PR: https://github.com/ergoplatform/sigmastate-interpreter/pull/1011 | ||||||
|
|
||||||
|
|
||||||
| * Revise checkSoftForkCondition | ||||||
|
|
||||||
| issue: https://github.com/ScorexFoundation/sigmastate-interpreter/issues/904 | ||||||
| PR: https://github.com/ergoplatform/sigmastate-interpreter/pull/1029 | ||||||
|
|
||||||
| * Fix semantics of AvlTree.insert | ||||||
|
|
||||||
| issue: https://github.com/ScorexFoundation/sigmastate-interpreter/issues/908 | ||||||
| PR: https://github.com/ergoplatform/sigmastate-interpreter/pull/1038 | ||||||
|
|
||||||
| Activation | ||||||
| ---------- | ||||||
|
|
||||||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Suggested change
Member
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. appendix removed now |
||||||
| To have old clients supporting 6.0 changes after soft-fork activation, some script deserialization validation rules | ||||||
| should be replaced with identical ones but having different ids, namely, rules # 1007, 1008, 1011 ( | ||||||
| done in https://github.com/ergoplatform/sigmastate-interpreter/pull/1029 ). | ||||||
|
|
||||||
| Notes | ||||||
| ----- | ||||||
|
|
||||||
| * You can use methods added in 6.0 and new `UnsignedBigInt` type only within an ErgoTree with version >= 3 | ||||||
|
|
||||||
| * You can't put values of `Option[]`, `Header`, `UnsignedBigInt` types into registers or context extension variables to | ||||||
| avoid versioning issues with 5.0 clients. To bypass the limitation, you can write typed value as bytes and call `Global.deserialize` in a script to get an instance of those types. | ||||||
| * Example of higher order lambdas supported since since this EIP implemented: | ||||||
| [https://github.com/ergoplatform/sigmastate-interpreter/blob/b754e143cf38ed86d95698ede744a470dfa053d6/sigmastate/src/test/scala/special/sigma/SigmaDslSpecification.scala#L10040](https://github.com/ergoplatform/sigmastate-interpreter/blob/b754e143cf38ed86d95698ede744a470dfa053d6/sigmastate/src/test/scala/special/sigma/SigmaDslSpecification.scala#L10040) | ||||||
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Maybe this is not necessary. Looking back is was not good idea to allow both
method callandopcodeencoding for methods. It would be better to forbid method calls for those methods which have dedicated opcodes.The translation MC -> opcode is actually happens in the compiler, but is not strictly enforced. This creates more surface for test coverage and potential bugs.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think it would be better to develop ErgoTree via adding methods, to have simple universal description of the language.