-
Notifications
You must be signed in to change notification settings - Fork 36
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
[WIP] EIP-50 - Sigma 6.0 #100
Open
kushti
wants to merge
14
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 4 commits
Commits
Show all changes
14 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 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 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,112 @@ | ||||||
Sigma 6.0 | ||||||
========= | ||||||
|
||||||
This EIP contains proposed changes for Ergo contractual layer, called Sigma. These changes are based on found issues | ||||||
in the current version of Sigma, as well as feedback got from users, i.e. Ergo ecosystem developers. | ||||||
|
||||||
|
||||||
Activation | ||||||
---------- | ||||||
|
||||||
Rule 1011 should be replaced with another one, likely with the same rule but under different id. | ||||||
|
||||||
Features Set | ||||||
------------ | ||||||
|
||||||
* *.validatePoW* method of *Header* type to validate Autolykos2 proof of work done on header | ||||||
|
||||||
issue: https://github.com/ScorexFoundation/sigmastate-interpreter/issues/958 | ||||||
|
||||||
* 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: https://github.com/ScorexFoundation/sigmastate-interpreter/pull/962 (nbits encoding) | ||||||
|
||||||
|
||||||
* implement Boolean to Byte conversion (boolean.toByte method) | ||||||
|
||||||
issue: https://github.com/ScorexFoundation/sigmastate-interpreter/issues/931 | ||||||
PR: https://github.com/ScorexFoundation/sigmastate-interpreter/pull/932 | ||||||
|
||||||
* implement BigIntModQ type (unsigned bigints mod Q, where Q is the order of secp256k1 group) | ||||||
|
||||||
issue: https://github.com/ScorexFoundation/sigmastate-interpreter/issues/554 | ||||||
|
||||||
|
||||||
* finish executeFromVar implementation | ||||||
|
||||||
issue: https://github.com/ScorexFoundation/sigmastate-interpreter/issues/443 , https://github.com/ScorexFoundation/sigmastate-interpreter/issues/612 | ||||||
|
||||||
* support MethodCall encoding of Numeric methods | ||||||
|
||||||
issue: https://github.com/ScorexFoundation/sigmastate-interpreter/issues/667 | ||||||
|
||||||
|
||||||
* Add Numeric.toBytes, .toBits | ||||||
|
||||||
issue: https://github.com/ScorexFoundation/sigmastate-interpreter/issues/486 | ||||||
|
||||||
* Fix for downcasting BigInt to Long fails | ||||||
|
||||||
issue: https://github.com/ScorexFoundation/sigmastate-interpreter/issues/877 | ||||||
|
||||||
|
||||||
* Lazy default evaluation for Option.getOrElse | ||||||
|
||||||
issue: https://github.com/ScorexFoundation/sigmastate-interpreter/issues/906 | ||||||
|
||||||
* Implement Some and None as global methods | ||||||
|
||||||
issue: https://github.com/ScorexFoundation/sigmastate-interpreter/issues/462 | ||||||
|
||||||
* Serialize Option[T] in DataSerializer | ||||||
|
||||||
issue: https://github.com/ScorexFoundation/sigmastate-interpreter/issues/659 | ||||||
|
||||||
|
||||||
|
||||||
|
||||||
How to add a new method | ||||||
----------------------- | ||||||
|
||||||
Here are instructions on how to add a (as 6.0 is heavily about adding new methods). | ||||||
|
||||||
Implementation: | ||||||
|
||||||
* Checkout new branch based on "v6.0.0" branch | ||||||
|
||||||
* Find appropriate type (e.g. *SBigInt*) to add a desirable method (e.g. *nbits*) | ||||||
|
||||||
* Add method description there and add description handle to *getMethods()* in a class \*Methods corresponding to the type (*SBigIntMethods* in our example), add *method_eval* to be used via reflection in the compiler | ||||||
|
||||||
* Add method implementation to corresponding type in *SigmaDsl.scala* | ||||||
|
||||||
|
||||||
* Add method evaluation to *ErgoTreeEvaluator* interface and its instantiation *CErgoTreeEvaluator* | ||||||
|
||||||
* Add new method to reflection-related descriptions in *ReflectionData* (needed for compiler mostly?) | ||||||
|
||||||
* Add pattern matching in GraphBuilding.scala to the compiler to get support for the new method in ErgoScript, e.g. | ||||||
``` | ||||||
case Select(obj, SBigIntMethods.ToNBits.name, _) if obj.tpe == SBigInt && VersionContext.current.isV6SoftForkActivated => | ||||||
``` | ||||||
|
||||||
* Add new method to *SigmaDslUnit.scala* / *SigmaDslImpl.scala* (needed for compiler only) | ||||||
|
||||||
|
||||||
Tests: | ||||||
|
||||||
|
||||||
* Add compilation test in *TestingInterpreterSpecification* | ||||||
|
||||||
* Add roundtrip test in *MethodCallSerializerSpecification* | ||||||
|
||||||
* Add evaluation test (see "nbits evaluation" test) | ||||||
|
||||||
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
|
||||||
|
||||||
|
||||||
How to add a new type | ||||||
--------------------- | ||||||
|
||||||
[TODO: complete] |
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 call
andopcode
encoding 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.