-
Notifications
You must be signed in to change notification settings - Fork 1
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
Mdjakovic/random generator #1
base: main
Are you sure you want to change the base?
Mdjakovic/random generator #1
Conversation
WalkthroughThis update introduces a Rust project called Changes
Poem
Thank you for using CodeRabbit. We offer it for free to the OSS community and would appreciate your support in helping us grow. If you find it useful, would you consider giving us a shout-out on your favorite social media? TipsChatThere are 3 ways to chat with CodeRabbit:
Note: Be mindful of the bot's finite context window. It's strongly recommended to break down tasks such as reading entire modules into smaller chunks. For a focused discussion, use review comments to chat about specific files and their changes, instead of using the PR comments. CodeRabbit Commands (invoked as PR comments)
Additionally, you can add CodeRabbit Configuration File (
|
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.
Actionable comments posted: 5
Outside diff range, codebase verification and nitpick comments (1)
andromeda-random-generator/.circleci/config.yml (1)
50-51
: Consider including more branches in the CI pipeline.Currently, the CI pipeline is configured to run only on the master branch and tagged commits. Including additional active development branches might help in early detection of issues.
Also applies to: 58-59
Review details
Configuration used: CodeRabbit UI
Review profile: CHILL
Files ignored due to path filters (1)
andromeda-random-generator/Cargo.lock
is excluded by!**/*.lock
Files selected for processing (19)
- andromeda-random-generator/.cargo/config (1 hunks)
- andromeda-random-generator/.circleci/config.yml (1 hunks)
- andromeda-random-generator/.editorconfig (1 hunks)
- andromeda-random-generator/.github/workflows/Basic.yml (1 hunks)
- andromeda-random-generator/.github/workflows/Release.yml (1 hunks)
- andromeda-random-generator/.gitignore (1 hunks)
- andromeda-random-generator/Cargo.toml (1 hunks)
- andromeda-random-generator/LICENSE (1 hunks)
- andromeda-random-generator/NOTICE (1 hunks)
- andromeda-random-generator/README.md (1 hunks)
- andromeda-random-generator/src/bin/schema.rs (1 hunks)
- andromeda-random-generator/src/contract.rs (1 hunks)
- andromeda-random-generator/src/error.rs (1 hunks)
- andromeda-random-generator/src/lib.rs (1 hunks)
- andromeda-random-generator/src/msg.rs (1 hunks)
- andromeda-random-generator/src/state.rs (1 hunks)
- andromeda-random-generator/src/testing/mock.rs (1 hunks)
- andromeda-random-generator/src/testing/mod.rs (1 hunks)
- andromeda-random-generator/src/testing/tests.rs (1 hunks)
Files skipped from review due to trivial changes (8)
- andromeda-random-generator/.cargo/config
- andromeda-random-generator/.editorconfig
- andromeda-random-generator/.gitignore
- andromeda-random-generator/Cargo.toml
- andromeda-random-generator/LICENSE
- andromeda-random-generator/NOTICE
- andromeda-random-generator/src/lib.rs
- andromeda-random-generator/src/testing/mod.rs
Additional context used
LanguageTool
andromeda-random-generator/README.md
[formatting] ~2-~2: If the ‘because’ clause is essential to the meaning, do not use a comma before the clause.
Context: ...rate the random value based on blockhash, because all of the block hash are different. #...(COMMA_BEFORE_BECAUSE)
[style] ~2-~2: Consider removing “of” to be more concise
Context: ...andom value based on blockhash, because all of the block hash are different. ### Messages...(ALL_OF_THE)
[uncategorized] ~2-~2: The grammatical number of this noun doesn’t look right. Consider replacing it.
Context: ... on blockhash, because all of the block hash are different. ### Messages ***Instan...(AI_EN_LECTOR_REPLACEMENT_NOUN_NUMBER)
[uncategorized] ~24-~24: This verb does not appear to agree with the subject. Consider using a different form.
Context: ...once value is increased every time user call this.IncreaseNonce {}
***Qu...(AI_EN_LECTOR_REPLACEMENT_VERB_AGREEMENT)
[misspelling] ~47-~47: The word ‘informations’ is a legal term. In standard English, the word ‘information’ is a non-count noun.
Context: ...om**: Returns MD5 hash value from block informations.GetRandom {},
Returns: ``...(INFORMATIONS)
Markdownlint
andromeda-random-generator/README.md
4-4: Expected: h2; Actual: h3
Heading levels should only increment by one level at a time(MD001, heading-increment)
7-7: null
Fenced code blocks should have a language specified(MD040, fenced-code-language)
16-16: null
Fenced code blocks should have a language specified(MD040, fenced-code-language)
26-26: null
Fenced code blocks should have a language specified(MD040, fenced-code-language)
34-34: null
Fenced code blocks should have a language specified(MD040, fenced-code-language)
39-39: null
Fenced code blocks should have a language specified(MD040, fenced-code-language)
48-48: null
Fenced code blocks should have a language specified(MD040, fenced-code-language)
53-53: null
Fenced code blocks should have a language specified(MD040, fenced-code-language)
63-63: null
Fenced code blocks should have a language specified(MD040, fenced-code-language)
Additional comments not posted (11)
andromeda-random-generator/src/state.rs (1)
1-5
: State management setup looks good.The constants and state items are correctly defined using
cw_storage_plus
, which is standard for managing state in CosmWasm contracts.andromeda-random-generator/src/bin/schema.rs (1)
1-11
: Schema generation setup is correct.Using
write_api!
to generate schema files for the contract's messages is a best practice in CosmWasm development, ensuring that interfaces are well-documented.andromeda-random-generator/src/error.rs (1)
1-13
: Error handling setup is appropriate.The use of
thiserror
to define custom contract errors is standard and appropriate. The definitions forStd
andUnauthorized
cover typical error scenarios in contract execution.andromeda-random-generator/src/msg.rs (1)
1-32
: Message definitions are well-structured.The use of
andr_*
attributes along withcw_serde
for serialization correctly sets up the contract's interfaces for instantiation, execution, and queries. The response structures are also appropriately defined.andromeda-random-generator/src/testing/tests.rs (3)
5-10
: Test for Instantiation: Well-structured and clear.This test checks that the nonce is initialized to zero, which is a good practice to ensure the contract starts in a known state.
12-19
: Test for Nonce Increment: Correct and effective.This test verifies that the nonce is incremented correctly. It's well-implemented and covers the basic functionality of the
IncreaseNonce
message.
21-32
: Test for Random Number Generation: Ensure variability.This test checks that two consecutive calls to
query_generate_random
after nonce increments yield different results. This is crucial for ensuring the randomness mechanism is functioning properly.andromeda-random-generator/.github/workflows/Release.yml (1)
1-35
: GitHub Actions Workflow for Release: Well-configured and comprehensive.This workflow is set up to handle the release process smoothly by automating the optimization and upload of WASM binaries. It uses well-known actions and is triggered appropriately on release creation.
andromeda-random-generator/src/testing/mock.rs (1)
1-52
: Mock Setup in Rust: Well-implemented and crucial for testing.The mock functions provided are essential for isolating functionality and ensuring that each component of the Random Generator ADO can be tested independently. The use of
mock_dependencies_custom
andmock_info
is appropriate and follows best practices for contract testing in Rust.andromeda-random-generator/.github/workflows/Basic.yml (2)
1-1
: Reference to external workflow example.It's good to see a reference to an existing workflow example, which helps maintain transparency about the source of the workflow's structure.
3-75
: Review of GitHub Actions Workflow.
- General Setup: The workflow is triggered on push and pull request events, which is standard for continuous integration setups.
- Test Job:
- Toolchain Installation: Specifying a fixed Rust toolchain version (
1.60.0
) is good for consistency. However, consider updating to a newer stable version if applicable.- Unit Tests and WASM Compilation: The steps are well-structured, but the
command: wasm
in line 35 might be incorrect if it's intended to compile a WASM binary. Usually, the command should be something likecargo build --target wasm32-unknown-unknown
.- Lint Job:
- Formatting and Clippy Checks: These are essential for maintaining code quality. The use of
--check
withcargo fmt
and-D warnings
withclippy
ensures that format issues and warnings break the CI build, which enforces code quality.- Schema Generation and Validation: The step to generate and check for uncommitted schema changes is a good practice for projects where the schema is expected to evolve.
Consider verifying the exact commands used, especially for WASM compilation, to ensure they align with the project's requirements.
- command: wasm + command: build + args: --target wasm32-unknown-unknown --locked
ADO Purpose
With the Random Generator ADO, user can generate the random value based on blockhash, because all of the block hash are different.
Messages
Instantiation (What is specified and stored at instantiation)
Execute Messages (What are the messages that can be executed)
IncreaseNonce: Nonce value is increased every time user call this.
Query Messages (What are the messages that can be queried, what does each return)
Returns:
Returns:
State
The contract maintains the following state:
Summary by CodeRabbit
New Features
Documentation
Chores
.gitignore
,.editorconfig
, andCargo.toml
for project setup and consistency.