-
Notifications
You must be signed in to change notification settings - Fork 32
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
feat: bitmap #119
feat: bitmap #119
Conversation
✅ Deploy Preview for contracts-stylus canceled.
|
Codecov ReportAttention: Patch coverage is
Additional details and impacted files
|
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.
Looks good at a first glance, will do a proper review when I get some time.
One question I have is that I think this is a good candidate for implementing StorageType
, right? What do you think?
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.
Looks good ✅
I think yes. I can reuse this contract to build consecutive on top. We don't need to use stylus inheritance just aggregation |
#[motsu::test] | ||
fn set_value() { | ||
proptest!(|(value: U256)| { | ||
let mut bit_map = BitMap::default(); |
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.
This one seems a bit debatable decision, but now #[motsu::test]
macro locks storage for a test execution even if there is no contract argument.
Assuming that rust contract struct can be created during test.
And the state of this contract will be single per test.
What do you think @alexfertel ? Or may be use with_context
function?
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 with_context
is slightly cleaner because we are instantiating the contract twice this way (with default
), right?
In any case, I'm fine either way, I'll leave it to your judgment!
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.
Looks great! 🚀
Besides the question about StorageType
I left a few small changes. In any case, I think it's fine to merge as is, and later update it if we need to.
} | ||
|
||
/// Get bucket index. | ||
fn get_bucket(index: U256) -> U256 { |
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.
Should we #[inline]
these? They are private & small.
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 used to think that those small and private functions should be unlined by default by rust compiler
#[motsu::test] | ||
fn set_value() { | ||
proptest!(|(value: U256)| { | ||
let mut bit_map = BitMap::default(); |
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 with_context
is slightly cleaner because we are instantiating the contract twice this way (with default
), right?
In any case, I'm fine either way, I'll leave it to your judgment!
Co-authored-by: Alexander González <[email protected]>
Co-authored-by: Alexander González <[email protected]>
Co-authored-by: Alexander González <[email protected]>
Resolves #77