Skip to content
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

[6.0.0] Conversion from Long-encoded nBits representation to BigInt and back #962

Merged
merged 33 commits into from
Nov 19, 2024

Conversation

kushti
Copy link
Member

@kushti kushti commented Apr 10, 2024

In this PR, two new methods, Global.encodeNbits() and Global.decodeNbits() are introduced, to support conversion from NBits-encoded numbers to big integers and back

Among new tests Bitcoin PoW check example can be found.

close #675

@aslesarenko
Copy link
Member

@kushti, I suggest to add these operations as methods of SGlobal (i.e. in SGlobalMethods)

@kushti kushti changed the base branch from develop to v6.0.0 June 4, 2024 19:38
@kushti kushti changed the title [6.0.0] Long.decodeNbits (nbits decoding support) [6.0.0] Conversion from Long-encoded nBits representation to BigInt and back Jul 31, 2024
@kushti
Copy link
Member Author

kushti commented Jul 31, 2024

@kushti, I suggest to add these operations as methods of SGlobal (i.e. in SGlobalMethods)

moved, also, the PR is finalized now, please review. If you think anything is not tested, please specify what exactly, and so I will be able to add tests.

Copy link
Member

@aslesarenko aslesarenko left a comment

Choose a reason for hiding this comment

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

IMO, the most important tests are those in LanguageSpecification, more specifically using verifyCases method.
When they are done, not only full coverage is ensured, but also cost profiling can be done.
I suggest to test these new operations as two separate property()

core/shared/src/main/scala/sigma/SigmaDsl.scala Outdated Show resolved Hide resolved
data/shared/src/main/scala/sigma/ast/methods.scala Outdated Show resolved Hide resolved
@kushti
Copy link
Member Author

kushti commented Nov 18, 2024

IMO, the most important tests are those in LanguageSpecification, more specifically using verifyCases method. When they are done, not only full coverage is ensured, but also cost profiling can be done. I suggest to test these new operations as two separate property()

Done, two new property() tests done in LSV6

@kushti kushti requested a review from aslesarenko November 18, 2024 21:42
@kushti
Copy link
Member Author

kushti commented Nov 18, 2024

@aslesarenko comments addresses, please make another pass!

Copy link
Member

@aslesarenko aslesarenko left a comment

Choose a reason for hiding this comment

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

LGTM, please see one new comment.


private lazy val EncodeNBitsCost = FixedCost(JitCost(25)) // the same cost for nbits encoding and decoding

private lazy val DecodeNBitsCost = FixedCost(JitCost(50)) // the same cost for nbits encoding and decoding
Copy link
Member

Choose a reason for hiding this comment

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

The comment looks like obsolete.

Copy link
Member Author

Choose a reason for hiding this comment

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

thanks, fixed

@kushti kushti merged commit 494221a into v6.0.0 Nov 19, 2024
3 of 4 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants