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

Feature/livenet on 0.8 #316

Merged
merged 25 commits into from
Jan 24, 2024
Merged

Feature/livenet on 0.8 #316

merged 25 commits into from
Jan 24, 2024

Conversation

kubaplas
Copy link
Contributor

@kubaplas kubaplas commented Jan 15, 2024

This PR restores a support for deploying contracts directly onto livenet.

The configuration of the livenet and accounts is handled via .env files.

Summary by CodeRabbit

  • New Features

    • Introduced live network environment functionality for smart contract interaction.
    • Added client for Casper node interaction, supporting state queries, contract deployment, and account management.
    • Implemented structures to provide environments for executing and interacting with smart contracts on live networks.
  • Enhancements

    • Expanded library capabilities with new modules for call stacks and contract management.
    • Improved contract interaction with methods for setting gas limits and registering contracts.
    • Enhanced event handling with updated parameter types and logic adjustments.
  • Bug Fixes

    • Corrected handling of contract calls and event retrieval with modified method signatures and parameters.
  • Refactor

    • Reorganized import statements and updated code to align with new module structures.
    • Renamed fields and methods for internal consistency.
  • Documentation

    • Updated .gitignore to better manage file exclusions in the repository.
  • Tests

    • Added examples and testing functionality for deploying and interacting with smart contracts in a live network setting.
  • Chores

    • Adjusted test configurations to accommodate new backend environments.

Copy link
Contributor

coderabbitai bot commented Jan 15, 2024

Walkthrough

The recent updates focus on enhancing a Rust-based smart contract library, with key changes in contract interaction, error handling, and environment setup. A new boolean field for mutation tracking, extended host context functionalities, and improved call stack management are notable. The library now supports live network interactions, better error reporting, and a more robust contract environment setup. These refinements aim to streamline contract deployment, execution, and management in a blockchain context.

Changes

File Path Change Summary
.gitignore Updated to ignore dot files/directories, .env files, but include .gitignore.
core/src/call_def.rs Added is_mut field to CallDef, updated methods to handle new field.
core/src/{callstack.rs, contract_container.rs} Improved call stack management, updated import paths, renamed methods/fields.
core/src/{error.rs, lib.rs} Introduced new error variants, added new modules for call stack and contract management.
core/src/{host_context.rs, host_env.rs} Expanded HostContext trait, added register_contract and other methods to HostEnv.
core/src/utils.rs Changed event_absolute_position function to handle u32 indices.
examples/bin/{erc20_on_livenet.rs, livenet_tests.rs} Added examples for live network smart contract interaction.
odra-casper/casper-client/src/casper_client.rs Created Casper client for interacting with a Casper node.
odra-casper/livenet-env/src/lib.rs Introduced functionality for creating a live network environment.
odra-casper/livenet-env/src/livenet_contract_env.rs Implemented LivenetContractEnv for executing smart contracts on the live network.
odra-casper/livenet-env/src/livenet_host.rs Introduced LivenetHost for interacting with the Casper blockchain.
odra-casper/test-vm/src/casper_host.rs Adjusted CasperHost for new contract interaction logic.
odra-casper/test-vm/src/vm/casper_vm.rs Modified CasperVm for new contract deployment and event retrieval logic.
odra-macros/src/ast/deployer_item.rs Overhauled deployer item syntax and control flow for contract loading.
odra-vm/src/odra_vm_host.rs Updated OdraVmHost for OdraVM, added set_gas method.
odra-vm/src/vm/odra_vm.rs Updated Odra VM for new contract interaction logic.
odra-vm/src/vm/odra_vm_state.rs Reorganized import statements in odra_vm_state.rs.
odra-casper/wasm-env/src/host_functions.rs Modified call_contract function to use method access for amount.
odra-test/src/lib.rs Added "livenet" backend handling to env function.

Poem

🐇✨

In the realm of code, where smart contracts thrive,
A rabbit hopped through, making blockchain alive.
With each git commit, the ledger's tale grew,
"To immutable change, we hop and renew!"
🌟📜

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?

Share

Tips

Chat

There are 3 ways to chat with CodeRabbit:

  • Review comments: Directly reply to a review comment made by CodeRabbit. Example:
    • I pushed a fix in commit <commit_id>.
    • Generate unit-tests for this file.
  • Files and specific lines of code (under the "Files changed" tab): Tag @coderabbitai in a new review comment at the desired location with your query. Examples:
    • @coderabbitai generate unit tests for this file.
    • @coderabbitai modularize this function.
  • PR comments: Tag @coderabbitai in a new PR comment to ask questions about the PR branch. For the best results, please provide a very specific query, as very limited context is provided in this mode. Examples:
    • @coderabbitai generate interesting stats about this repository from git and render them as a table.
    • @coderabbitai show all the console.log statements in this repository.
    • @coderabbitai read src/utils.ts and generate unit tests.
    • @coderabbitai read the files in the src/scheduler package and generate a class diagram using mermaid and a README in the markdown format.

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)

  • @coderabbitai pause to pause the reviews on a PR.
  • @coderabbitai resume to resume the paused reviews.
  • @coderabbitai review to trigger a review. This is useful when automatic reviews are disabled for the repository.
  • @coderabbitai resolve resolve all the CodeRabbit review comments.
  • @coderabbitai help to get help.

Additionally, you can add @coderabbitai ignore anywhere in the PR description to prevent this PR from being reviewed.

CodeRabbit Configration File (.coderabbit.yaml)

  • You can programmatically configure CodeRabbit by adding a .coderabbit.yaml file to the root of your repository.
  • The JSON schema for the configuration file is available here.
  • If your editor has YAML language server enabled, you can add the path at the top of this file to enable auto-completion and validation: # yaml-language-server: $schema=https://coderabbit.ai/integrations/coderabbit-overrides.v2.json

CodeRabbit Discord Community

Join our Discord Community to get help, request features, and share feedback.

@kubaplas kubaplas force-pushed the feature/livenet-on-0.8 branch from 4426ff7 to 1dd45bf Compare January 17, 2024 11:28
@kubaplas kubaplas requested review from kpob and zie1ony and removed request for kpob January 23, 2024 15:47
@kubaplas kubaplas marked this pull request as ready for review January 23, 2024 15:47
Copy link
Contributor

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

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

Review Status

Actionable comments generated: 9

Configuration used: CodeRabbit UI

Commits Files that changed from the base of the PR and between 08cf0a8 and 8efc87a.
Files ignored due to path filters (10)
  • Cargo.toml is excluded by: !**/*.toml
  • core/Cargo.toml is excluded by: !**/*.toml
  • examples/Cargo.toml is excluded by: !**/*.toml
  • examples/Odra.toml is excluded by: !**/*.toml
  • odra-casper/casper-client/Cargo.toml is excluded by: !**/*.toml
  • odra-casper/livenet-env/Cargo.toml is excluded by: !**/*.toml
  • odra-casper/livenet/Cargo.toml is excluded by: !**/*.toml
  • odra-casper/livenet/resources/proxy_caller.wasm is excluded by: !**/*.wasm
  • odra-test/Cargo.toml is excluded by: !**/*.toml
  • odra-vm/Cargo.toml is excluded by: !**/*.toml
Files selected for processing (47)
  • .gitignore (1 hunks)
  • core/src/call_def.rs (2 hunks)
  • core/src/callstack.rs (3 hunks)
  • core/src/contract_container.rs (4 hunks)
  • core/src/contract_register.rs (1 hunks)
  • core/src/error.rs (1 hunks)
  • core/src/event.rs (1 hunks)
  • core/src/host_context.rs (2 hunks)
  • core/src/host_env.rs (3 hunks)
  • core/src/lib.rs (1 hunks)
  • examples/.env.sample (1 hunks)
  • examples/bin/erc20_on_livenet.rs (1 hunks)
  • examples/bin/livenet_tests.rs (1 hunks)
  • examples/src/features/livenet.rs (1 hunks)
  • examples/src/features/mod.rs (1 hunks)
  • examples/src/features/module_nesting.rs (1 hunks)
  • odra-casper/casper-client/src/casper_client.rs (1 hunks)
  • odra-casper/casper-client/src/casper_node_port/account.rs (1 hunks)
  • odra-casper/casper-client/src/casper_node_port/contract.rs (1 hunks)
  • odra-casper/casper-client/src/casper_node_port/mod.rs (1 hunks)
  • odra-casper/casper-client/src/casper_node_port/query_balance.rs (1 hunks)
  • odra-casper/casper-client/src/casper_node_port/rpcs.rs (2 hunks)
  • odra-casper/casper-client/src/lib.rs (1 hunks)
  • odra-casper/casper-client/src/log.rs (1 hunks)
  • odra-casper/livenet-env/src/client_env/callstack.rs (1 hunks)
  • odra-casper/livenet-env/src/client_env/contract_container.rs (1 hunks)
  • odra-casper/livenet-env/src/client_env/contract_register.rs (1 hunks)
  • odra-casper/livenet-env/src/lib.rs (1 hunks)
  • odra-casper/livenet-env/src/livenet_contract_env.rs (1 hunks)
  • odra-casper/livenet-env/src/livenet_host_env.rs (1 hunks)
  • odra-casper/test-vm/src/casper_host.rs (2 hunks)
  • odra-casper/test-vm/src/vm/casper_vm.rs (1 hunks)
  • odra-macros/src/ast/deployer_item.rs (7 hunks)
  • odra-macros/src/ast/deployer_utils.rs (4 hunks)
  • odra-macros/src/ast/external_contract_item.rs (2 hunks)
  • odra-macros/src/ast/host_ref_item.rs (11 hunks)
  • odra-macros/src/ast/ref_item.rs (12 hunks)
  • odra-macros/src/ast/ref_utils.rs (1 hunks)
  • odra-macros/src/ast/test_parts.rs (6 hunks)
  • odra-macros/src/ir/attr.rs (1 hunks)
  • odra-macros/src/ir/mod.rs (1 hunks)
  • odra-macros/src/utils/ident.rs (1 hunks)
  • odra-test/src/lib.rs (1 hunks)
  • odra-vm/src/odra_vm_host.rs (2 hunks)
  • odra-vm/src/vm/mod.rs (1 hunks)
  • odra-vm/src/vm/odra_vm.rs (3 hunks)
  • odra-vm/src/vm/odra_vm_state.rs (1 hunks)
Files skipped from review due to trivial changes (5)
  • core/src/contract_register.rs
  • examples/src/features/mod.rs
  • odra-casper/livenet-env/src/client_env/contract_register.rs
  • odra-macros/src/ir/attr.rs
  • odra-vm/src/vm/mod.rs
Additional comments: 64
odra-casper/livenet-env/src/lib.rs (1)
  • 7-10: The function livenet_env creates a new HostEnv with a LivenetEnv instance every time it is called.

This is a standard factory function pattern and looks correct.

odra-casper/livenet-env/src/client_env/callstack.rs (1)
  • 1-3: > 📝 NOTE

This review was outside the diff hunks and was mapped to the diff hunk with the greatest overlap. Original lines [1-13]

The Callstack struct and its methods seem to be correctly implemented.

The methods pop, push, and current are standard stack operations and are implemented as expected.

.gitignore (1)
  • 3-5: The .gitignore file correctly specifies patterns to ignore files and directories starting with a dot, .env files, and ensures the .gitignore file itself is not ignored.

These changes are appropriate for preventing sensitive configuration data from being committed to the repository.

odra-casper/casper-client/src/log.rs (1)
  • 1-14: The logging functions info, error, and wait are correctly delegating to the prettycli crate.

This is a standard pattern for abstracting away the logging implementation details.

odra-casper/casper-client/src/casper_node_port/mod.rs (1)
  • 6-12: The addition of the contract and query_balance modules to the casper_node_port package is noted.

These modules are expected to provide additional functionalities related to contracts and querying balances.

core/src/event.rs (1)
  • 17-19: The addition of the CouldntExtractEventData variant to the EventError enum is a good practice for more granular error handling.

This change allows for more specific error scenarios to be handled and communicated.

odra-test/src/lib.rs (1)
  • 16-16: The addition of the "livenet" branch in the env function is correct.

This allows for the selection of the appropriate environment based on the ODRA_BACKEND variable.

core/src/call_def.rs (2)
  • 9-10: The addition of the is_mut boolean field to the CallDef struct is a significant change.

This field likely indicates whether the call definition is for a mutable function, which is important for contract execution logic.

  • 44-46: The is_mut method is correctly implemented to return the value of the is_mut field.

This getter method follows Rust's naming conventions and encapsulation practices.

examples/.env.sample (1)
  • 13-20: The .env.sample file has been updated with sample values and comments explaining the usage of multiple .env files.

This is a helpful addition for developers to understand how to manage deploys on multiple chains.

odra-casper/casper-client/src/casper_node_port/account.rs (1)
  • 20-22: The named_keys method added to the Account struct correctly returns an iterator over the named keys.

This method provides a way to access the named keys associated with an account, which is a common requirement.

core/src/host_context.rs (1)
  • 11-11: The addition of the set_gas method to the HostContext trait is noted.

This method allows setting a gas limit for contract execution, which is a common feature in blockchain platforms.

odra-casper/livenet-env/src/client_env/contract_container.rs (1)
  • 1-5: > 📝 NOTE

This review was outside the diff hunks and was mapped to the diff hunk with the greatest overlap. Original lines [1-47]

The ContractContainer struct and its methods have been modified to remove dependencies on odra_core and its modules.

This change suggests a refactoring that likely aligns with the new architecture of the system.

core/src/lib.rs (1)
  • 10-16: The addition of new modules callstack, contract_container, and contract_register expands the library's functionality.

These modules are expected to introduce new features and capabilities related to call stacks and contract management.

odra-casper/casper-client/src/casper_node_port/contract.rs (1)
  • 1-16: The Contract struct is correctly defined with fields representing contract details and methods to access them.

The methods provide a clear interface for accessing contract details such as package hash, wasm hash, named keys, entry points, and protocol version.

examples/bin/erc20_on_livenet.rs (1)
  • 6-6: The main function in erc20_on_livenet.rs correctly sets up the environment and demonstrates contract interaction on the livenet.

The code shows proper usage of the odra_casper_livenet_env::livenet_env and contract interaction patterns.

examples/src/features/livenet.rs (1)
  • 7-51: The LivenetContract module and its implementation are correctly defined with methods for contract interaction.

The methods follow the expected patterns for contract operations such as initialization, ownership transfer, and stack operations.

odra-casper/casper-client/src/casper_node_port/query_balance.rs (1)
  • 7-49: The QueryBalanceParams and QueryBalanceResult structs are correctly defined for the "query_balance" RPC request and response.

These structures are well-defined and follow the expected serialization patterns for RPC communication.

core/src/callstack.rs (2)
  • 35-40: The addition of the first method to the Callstack struct is a useful feature.

This method provides access to the first element of the call stack, which can be important in certain execution contexts.

  • 78-80: The is_empty method is correctly implemented to check if the call stack is empty.

This is a standard utility method for stack-like data structures.

odra-macros/src/utils/ident.rs (1)
  • 38-44: The addition of the epc and load functions to ident.rs in the odra-macros module is noted.

These functions are likely used to generate identifiers for new macros or functions related to contract interaction.

examples/bin/livenet_tests.rs (1)
  • 7-59: The main function in livenet_tests.rs demonstrates various contract interaction patterns on the livenet.

The code correctly sets up the environment, demonstrates contract deployment and loading, and shows how to interact with contract endpoints.

odra-vm/src/odra_vm_host.rs (1)
  • 19-21: The set_gas method in OdraVmHost is a placeholder as it does nothing.

This is acceptable if gas management is not applicable in the context of OdraVmHost.

odra-macros/src/ast/ref_utils.rs (1)
  • 52-63: The changes in ref_utils.rs include the addition of the is_mut variable and its usage in the call_def and call_def_with_amount functions.

This change is consistent with the addition of the is_mut field in the CallDef struct and is necessary for the correct construction of CallDef instances.

odra-casper/test-vm/src/casper_host.rs (1)
  • 36-38: The set_gas method in CasperHost is a placeholder as it does nothing.

This is acceptable if gas management is not applicable in the context of CasperHost.

odra-casper/livenet-env/src/livenet_contract_env.rs (4)
  • 25-27: The set_value method in LivenetContractEnv panics with a message that setting a value is not allowed without a deploy.

This panic is a safeguard against unintended writes in a read-only environment context.

  • 37-55: The call_contract method in LivenetContractEnv panics if attempting to call a mutable entrypoint from a non-mutable entrypoint.

This panic is a safeguard against illegal state mutations in a context that should not allow them.

  • 65-67: The emit_event method in LivenetContractEnv panics with a message that emitting events is not allowed.

This panic is a safeguard against emitting events in an environment where it is not supported.

  • 69-71: The transfer_tokens method in LivenetContractEnv panics with a message that transferring tokens is not allowed.

This panic is a safeguard against token transfers in an environment where it is not supported.

odra-macros/src/ast/external_contract_item.rs (2)
  • 69-69: The addition of the boolean argument false to the CallDef::new function call within the mod test module affects the logic related to the balance_of function call. Ensure that the false value is intended and correctly represents whether the call is mutable or not. If this is a change in the contract's behavior, it may require additional changes elsewhere in the codebase to handle the immutability of the call.
  • 133-133: The same boolean argument false is added to the CallDef::new function call here. As mentioned earlier, verify that this is the intended behavior and that it aligns with the contract's logic.
core/src/error.rs (1)
  • 98-98: The addition of the TypeMismatch variant to the ExecutionError enum is a good way to handle specific error scenarios more precisely. Ensure that this new error type is being used wherever type mismatches can occur to improve error handling throughout the codebase.
odra-casper/livenet-env/src/livenet_host_env.rs (1)
  • 88-120: The call_contract method has a branch based on the use_proxy boolean. Ensure that the logic for deciding whether to use a proxy or not is correct and that the proxy functionality is implemented and tested. The current implementation defaults to an empty Bytes result when not using a proxy, which may not be the intended behavior.
odra-vm/src/vm/odra_vm_state.rs (1)
  • 4-4: The reorganization of import statements to use odra_core::callstack instead of super::callstack is a good practice for clarity and maintainability, assuming that the odra_core::callstack module provides the necessary functionality.
odra-casper/casper-client/src/casper_node_port/rpcs.rs (1)
  • 244-246: The addition of the Contract(Contract) variant to the StoredValue enum is a good way to handle contract-related data. Ensure that all parts of the codebase that interact with StoredValue are updated to handle this new variant appropriately.
core/src/host_env.rs (3)
  • 51-51: The new_contract method has been added to create a new contract instance. Ensure that the entry_points_caller parameter is correctly used to register the contract's entry points and that the contract deployment process is thoroughly tested.
  • 60-65: The register_contract method has been added to register a contract with its entry points caller. This is a crucial part of contract management, so ensure that the registration process is correctly implemented and that the contract's entry points are callable after registration.
  • 246-254: New methods caller and set_gas have been added to the HostEnv struct. These methods are essential for contract execution environments, so ensure that they are being used correctly wherever the caller's address and gas limit need to be retrieved or set.
odra-macros/src/ast/deployer_utils.rs (4)
  • 43-75: The DeployerLoadSignature struct and its implementation via TryFrom trait are correctly defined and follow the Rust conventions for struct and trait implementations. The use of Default::default() for initializing tokens and the use of utility functions for identifiers and return types are consistent with Rust idioms.
  • 77-106: The EpcSignature struct and its implementation are also correctly defined. The use of Default::default() and utility functions is consistent, and the implementation of TryFrom is straightforward and idiomatic.
  • 148-169: The CallEpcExpr struct is introduced to encapsulate the expression for calling the entry point caller. The struct is well-defined, and the TryFrom implementation is correct. The use of parse_quote! to generate the expression is appropriate.
  • 211-234: The LoadContractExpr struct and its TryFrom implementation are correct. The struct captures the expression for loading a contract, and the implementation uses parse_quote! effectively to create the necessary expression.
odra-macros/src/ast/deployer_item.rs (5)
  • 6-7: The import statement correctly reflects the new structs added to deployer_utils.rs. It's good to see that the code is kept clean and organized with the use of modules.
  • 38-42: The DeployImplItem struct has been updated to include epc_fn and load_fn while retaining init_fn. This change is consistent with the PR objectives to enhance contract deployment capabilities.
  • 60-71: The ContractEpcFn struct is introduced correctly, with public visibility and the new EpcSignature. The inclusion of EntrypointCallerExpr within the braces is consistent with the structure of the other functions in the file.
  • 90-104: The ContractLoadFn struct is well-defined, with public visibility and the new DeployerLoadSignature. The inclusion of CallEpcExpr and LoadContractExpr is appropriate and aligns with the changes made in deployer_utils.rs.
  • 164-187: > 📝 NOTE

This review was outside the diff hunks and was mapped to the diff hunk with the greatest overlap. Original lines [127-184]

The implementation of Erc20Deployer within the test module has been updated to include the new epc and load functions. The changes are consistent with the PR objectives and the AI-generated summary. The use of odra::EntryPointsCaller::new and the match arms for different contract methods are correctly implemented.

odra-macros/src/ast/ref_item.rs (1)
  • 166-172: > 📝 NOTE

This review was outside the diff hunks and was mapped to the diff hunk with the greatest overlap. Original lines [154-368]

The addition of the boolean argument to the CallDef::new function calls within the ref_item_tests module is consistent across all instances. This change likely indicates a modification in the contract call definition to include a new parameter that specifies whether the call is mutable or not. Ensure that this new boolean parameter is correctly documented and understood in the context of the contract's logic.

odra-macros/src/ast/test_parts.rs (1)
  • 149-155: > 📝 NOTE

This review was outside the diff hunks and was mapped to the diff hunk with the greatest overlap. Original lines [131-196]

The addition of the boolean argument in the CallDef::new calls within the mod test module is consistent and correctly placed. The boolean values false or true are added appropriately for the functions total_supply, pay_to_mint, approve, and airdrop, which likely affects the behavior or configuration of these function calls.

odra-casper/test-vm/src/vm/casper_vm.rs (1)
  • 272-275: The removal of the conditional insertion of CONSTRUCTOR_NAME_ARG in the args map is not visible in the provided code. This change could have implications on how contracts are initialized, potentially affecting the deployment process.
Verification successful

The review comment regarding the removal of the conditional insertion of CONSTRUCTOR_NAME_ARG in the args map has been verified. The script output confirms that CONSTRUCTOR_NAME_ARG is not present in the casper_vm.rs file, indicating that the conditional insertion has been removed as stated.

Scripts Executed

The following scripts were executed for the analysis:


Script:

#!/bin/bash
# Search for the usage of CONSTRUCTOR_NAME_ARG in the codebase to verify its removal.
rg --type rust 'CONSTRUCTOR_NAME_ARG'

Length of output: 217



Script:

#!/bin/bash
# Search for the usage of CONSTRUCTOR_NAME_ARG within casper_vm.rs to verify the removal of its conditional insertion.
rg --type rust 'CONSTRUCTOR_NAME_ARG' odra-casper/test-vm/src/vm/casper_vm.rs

Length of output: 77

odra-macros/src/ir/mod.rs (1)
  • 196-196: The addition of the contract_ref_ident method in the ModuleImplIR implementation is correctly summarized. This method provides a way to obtain a contract reference identifier, which could be used for generating code related to contract references.
odra-vm/src/vm/odra_vm.rs (2)
  • 8-11: The addition of imports for CallstackElement, ContractContainer, and ContractRegister is correctly summarized. These imports are necessary for the new functionality introduced in the OdraVm struct.
  • 97-98: The replacement of CallstackElement::Entrypoint with callstack::Entrypoint is correctly summarized and the corresponding code has been updated accordingly. This change is part of a refactoring effort to improve code clarity and maintainability.
odra-macros/src/ast/host_ref_item.rs (11)
  • 280-280: The addition of the boolean argument false to the CallDef::new call for the function "total_supply" changes the control flow and potentially the behavior of the function call. Ensure that this change is consistent with the intended use cases and that all dependent code has been updated accordingly.
  • 302-302: The addition of the boolean argument true to the CallDef::new call for the function "pay_to_mint" changes the control flow and potentially the behavior of the function call. Verify that this change is intentional and correctly implemented across all usages of this function.
  • 329-329: The addition of the boolean argument true to the CallDef::new call for the function "approve" changes the control flow and potentially the behavior of the function call. Confirm that this change aligns with the expected behavior and that all calls to "approve" have been reviewed to accommodate this change.
  • 353-353: The addition of the boolean argument false to the CallDef::new call for the function "airdrop" changes the control flow and potentially the behavior of the function call. It is crucial to ensure that this change is in line with the desired functionality and that all related code has been updated to reflect this change.
  • 427-427: The addition of the boolean argument false to the CallDef::new call for the function "total_supply" within the host_trait_impl_ref test case. This change should be verified to ensure it matches the intended logic and that the test case accurately reflects the behavior of the production code.
  • 449-449: The addition of the boolean argument true to the CallDef::new call for the function "pay_to_mint" within the host_trait_impl_ref test case. Verify that this change is consistent with the intended behavior and that the test case remains valid.
  • 522-522: The addition of the boolean argument false to the CallDef::new call for the function "total_supply" within the host_ref_delegation test case. Ensure that this change is intentional and that the test case still accurately tests the expected behavior.
  • 544-544: The addition of the boolean argument false to the CallDef::new call for the function "get_owner" within the host_ref_delegation test case. Confirm that this change is correct and that the test case is still valid.
  • 567-567: The addition of the boolean argument true to the CallDef::new call for the function "set_owner" within the host_ref_delegation test case. Verify that this change is consistent with the intended behavior and that the test case remains valid.
  • 591-591: The addition of the boolean argument false to the CallDef::new call for the function "name" within the host_ref_delegation test case. Ensure that this change is intentional and that the test case still accurately tests the expected behavior.
  • 614-614: The addition of the boolean argument false to the CallDef::new call for the function "symbol" within the host_ref_delegation test case. Confirm that this change is correct and that the test case is still valid.

examples/src/features/module_nesting.rs Show resolved Hide resolved
odra-casper/livenet-env/src/livenet_host_env.rs Outdated Show resolved Hide resolved
odra-casper/livenet-env/src/livenet_host_env.rs Outdated Show resolved Hide resolved
core/src/contract_container.rs Outdated Show resolved Hide resolved
core/src/contract_container.rs Outdated Show resolved Hide resolved
odra-casper/casper-client/src/lib.rs Show resolved Hide resolved
core/src/host_context.rs Show resolved Hide resolved
odra-vm/src/odra_vm_host.rs Show resolved Hide resolved
odra-casper/test-vm/src/casper_host.rs Show resolved Hide resolved
Copy link
Contributor

@zie1ony zie1ony left a comment

Choose a reason for hiding this comment

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

Cool :)

                              ████████                      
                        ██████████████████                  
                      ██████████████████████                
                    ██████████████████████████              
                  ████████████████        ████              
                  ████████████████          ██              
                ██████████████████                          
                ██░░          ░░░░██                        
              ██░░░░  ░░░░░░  ░░░░██                        
              ██░░░░  ░░░░░░  ░░░░██                        
            ██░░░░░░          ░░░░░░██                      
            ████████████████████████████                    
  ██████████████▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒████████████████          
  ██████████▒▒▒▒░░░░░░░░░░░░░░░░░░▒▒▒▒████████████          
▒▒▒▒▒▒▒▒▒▒▒▒░░░░░░░░░░░░░░░░░░░░░░░░░░▒▒▒▒▒▒▒▒▒▒▒▒          
▒▒░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░▒▒          
▒▒░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░▒▒          
  ▒▒░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░▒▒            
  ▒▒░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░▒▒            
    ▒▒░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░▒▒              
      ▒▒░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░▒▒                
      ▒▒░░░░░░▒▒▒▒░░░░░░░░░░░░░░▒▒▒▒░░░░░░▒▒                
      ▒▒░░░░▒▒  ▒▒▒▒░░░░░░░░░░▒▒  ▒▒▒▒░░░░▒▒                
      ▒▒░░░░▒▒▒▒▒▒▒▒░░░░░░░░░░▒▒▒▒▒▒▒▒░░░░▒▒                
        ▒▒░░░░▒▒▒▒░░░░░░░░░░░░░░▒▒▒▒░░░░▒▒                  
        ▒▒░░░░░░░░░░    ▒▒    ░░░░░░░░░░▒▒                  
          ▒▒░░░░░░░░          ░░░░░░░░▒▒                    
            ▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒                      
                ████████░░██████████████                    
              ████████░░██░░██████████████                  
              ██░░░░████░░████░░████████████      ▒▒▒▒▒▒    
              ██░░░░░░██░░██░░░░░░██████████      ▒▒    ▒▒  
              ██░░░░██░░░░░░██░░░░████████████      ░░    ▒▒
              ██░░░░░░░░░░░░░░░░░░░░██████████      ▒▒    ▒▒
              ██▒▒░░░░░░░░░░░░░░░░░░░░████████      ▒▒░░  ▒▒
              ██▒▒░░░░░░░░░░░░░░░░░░░░░░██████    ▒▒░░░░░░▒▒
            ████▒▒░░░░░░░░░░░░░░░░░░░░░░██████    ▒▒░░░░▒▒  
            ████▒▒░░░░░░░░░░░░░░░░░░░░░░░░████  ▒▒░░░░░░▒▒  
          ████████▒▒░░░░░░░░░░░░░░░░░░░░░░████▒▒░░░░░░▒▒    
        ██████████▒▒░░░░░░░░░░░░░░░░░░░░░░████░░░░▒▒▒▒      
    ██████████████▒▒░░░░▒▒░░░░░░░░░░░░░░░░████▒▒▒▒          
████████████████████▒▒▒▒██▒▒▒▒▒▒▒▒▒▒▒▒██████                

.gitignore Show resolved Hide resolved
core/src/call_def.rs Show resolved Hide resolved
core/src/contract_container.rs Outdated Show resolved Hide resolved
core/src/contract_container.rs Outdated Show resolved Hide resolved
examples/bin/livenet_tests.rs Outdated Show resolved Hide resolved
odra-casper/livenet-env/src/livenet_host_env.rs Outdated Show resolved Hide resolved
odra-casper/livenet-env/src/livenet_host_env.rs Outdated Show resolved Hide resolved
odra-casper/livenet-env/src/livenet_host_env.rs Outdated Show resolved Hide resolved
odra-casper/livenet-env/src/livenet_host_env.rs Outdated Show resolved Hide resolved
odra-macros/src/utils/ident.rs Show resolved Hide resolved
core/src/host_context.rs Show resolved Hide resolved
core/src/contract_container.rs Show resolved Hide resolved
examples/bin/erc20_on_livenet.rs Show resolved Hide resolved
examples/bin/livenet_tests.rs Outdated Show resolved Hide resolved
odra-casper/casper-client/src/casper_client.rs Outdated Show resolved Hide resolved
odra-casper/livenet-env/src/lib.rs Outdated Show resolved Hide resolved
odra-casper/livenet-env/src/livenet_host_env.rs Outdated Show resolved Hide resolved
Copy link
Contributor

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

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

Review Status

Actionable comments generated: 0

Configuration used: CodeRabbit UI

Commits Files that changed from the base of the PR and between 8efc87a and 223ce76.
Files ignored due to path filters (2)
  • Cargo.toml is excluded by: !**/*.toml
  • core/Cargo.toml is excluded by: !**/*.toml
Files selected for processing (12)
  • core/src/call_def.rs (2 hunks)
  • core/src/contract_container.rs (10 hunks)
  • core/src/error.rs (1 hunks)
  • core/src/lib.rs (1 hunks)
  • odra-macros/src/ast/deployer_item.rs (6 hunks)
  • odra-macros/src/ast/deployer_utils.rs (4 hunks)
  • odra-macros/src/ast/external_contract_item.rs (2 hunks)
  • odra-macros/src/ast/host_ref_item.rs (11 hunks)
  • odra-macros/src/ast/ref_item.rs (12 hunks)
  • odra-macros/src/ast/test_parts.rs (6 hunks)
  • odra-vm/src/vm/mod.rs (1 hunks)
  • odra-vm/src/vm/odra_vm.rs (3 hunks)
Files skipped from review as they are similar to previous changes (11)
  • core/src/call_def.rs
  • core/src/contract_container.rs
  • core/src/error.rs
  • core/src/lib.rs
  • odra-macros/src/ast/deployer_utils.rs
  • odra-macros/src/ast/external_contract_item.rs
  • odra-macros/src/ast/host_ref_item.rs
  • odra-macros/src/ast/ref_item.rs
  • odra-macros/src/ast/test_parts.rs
  • odra-vm/src/vm/mod.rs
  • odra-vm/src/vm/odra_vm.rs
Additional comments: 8
odra-macros/src/ast/deployer_item.rs (8)
  • 6-7: The import statement has been modified to include CallEpcExpr, DeployerLoadSignature, LoadContractExpr, and remove DeployerInitSignature, EntrypointCallerExpr, EntrypointsInitExpr, HostRefInstanceExpr, NewContractExpr. Ensure that the removed entities are no longer used anywhere in the codebase.
  • 40-44: The DeployImplItem struct now includes epc_fn and load_fn fields, replacing the init_fn. This change aligns with the PR's objective to enhance contract deployment and management. Ensure that all references to init_fn are updated to use the new fields.
  • 65-76: The ContractEpcFn struct has been introduced with fields vis, sig, braces, entry_points, and caller. This struct seems to be part of the new deployment flow. Confirm that the EpcSignature and EntrypointsInitExpr types are correctly defined and used in the context of this new struct.
Verification successful

The output from the scripts provides the definitions and TryFrom implementations for both EpcSignature and EntrypointsInitExpr. The EpcSignature struct includes fields that represent a function signature, and the TryFrom implementation constructs an instance from a ModuleImplIR, which is consistent with the expected usage in the context of procedural macros for code generation.

Similarly, the EntrypointsInitExpr struct is designed to hold an expression, and its TryFrom implementation constructs an instance from a ModuleImplIR by mapping over the module's functions to create entry points. This also aligns with the expected usage within the ContractEpcFn struct.

Based on the provided output, the EpcSignature and EntrypointsInitExpr types are correctly defined and used in the context of the new struct ContractEpcFn. The TryFrom implementations indicate that these types are intended to be constructed from a ModuleImplIR, which is consistent with the procedural macro pattern used in Rust.

Given this information, the review comment is verified as the types are correctly defined and used in the context of the ContractEpcFn struct.

Scripts Executed

The following scripts were executed for the analysis:


Script:

#!/bin/bash
# Verify that `EpcSignature` and `EntrypointsInitExpr` types are correctly defined and used.
rg --type rust 'EpcSignature|EntrypointsInitExpr'

Length of output: 724



Script:

#!/bin/bash
# Extract the definitions of `EpcSignature` and `EntrypointsInitExpr` and their `TryFrom` implementations.
rg --type rust --context 10 'pub struct EpcSignature|pub struct EntrypointsInitExpr' odra-macros/src/ast/deployer_utils.rs
rg --type rust --context 10 'impl TryFrom<&'_ ModuleImplIR> for EpcSignature|impl TryFrom<&'_ ModuleImplIR> for EntrypointsInitExpr' odra-macros/src/ast/deployer_utils.rs

Length of output: 1542



Script:

#!/bin/bash
# Correct the script to properly extract the `TryFrom` implementations for `EpcSignature` and `EntrypointsInitExpr`.
rg --type rust --context 10 'impl TryFrom<&'_ ModuleImplIR> for EpcSignature' odra-macros/src/ast/deployer_utils.rs
rg --type rust --context 10 'impl TryFrom<&'_ ModuleImplIR> for EntrypointsInitExpr' odra-macros/src/ast/deployer_utils.rs

Length of output: 300



Script:

#!/bin/bash
# Attempt to properly extract the `TryFrom` implementations for `EpcSignature` and `EntrypointsInitExpr` with correct syntax.
rg --type rust --context 10 'impl TryFrom<.*> for EpcSignature' odra-macros/src/ast/deployer_utils.rs
rg --type rust --context 10 'impl TryFrom<.*> for EntrypointsInitExpr' odra-macros/src/ast/deployer_utils.rs

Length of output: 1491

* 81-89: The `ContractInitFn` struct has been modified to include `caller` of type `CallEpcExpr` and `new_contract` of type `LoadContractExpr`. This change suggests a shift in how contracts are initialized. Verify that the `CallEpcExpr` and `LoadContractExpr` are properly implemented and used throughout the codebase. * 99-111: The `ContractLoadFn` struct has been added, which includes a `caller` field of type `CallEpcExpr` and a `load_contract` field of type `LoadContractExpr`. This struct is likely part of the new functionality for loading contracts. Ensure that the `DeployerLoadSignature` type is correctly defined and that the new struct is integrated properly within the deployment process.
Verification successful

The ContractLoadFn struct is properly integrated within the deployment process as part of the DeployImplItem, and the DeployerLoadSignature type is correctly defined, as evidenced by its usage in ContractLoadFn and the associated conversion logic from ModuleImplIR. The verification process has confirmed the integration and definition as per the review comment.

Scripts Executed

The following scripts were executed for the analysis:


Script:

#!/bin/bash
# Verify that `DeployerLoadSignature` is correctly defined and that `ContractLoadFn` is integrated properly.
rg --type rust 'DeployerLoadSignature|ContractLoadFn'

Length of output: 511



Script:

#!/bin/bash
# Search for usages of `ContractLoadFn` to ensure it is integrated properly within the deployment process.
rg --type rust 'ContractLoadFn' -A 3

Length of output: 542



Script:

#!/bin/bash
# Search for usages of `DeployImplItem` to ensure that the integration of `ContractLoadFn` within it is part of the deployment process.
rg --type rust 'DeployImplItem' -A 3

Length of output: 787



Script:

#!/bin/bash
# Search for instantiations or function calls that use `DeployImplItem` to ensure that `ContractLoadFn` is integrated properly.
rg --type rust 'DeployImplItem' -C 3

Length of output: 1266

* 132-139: > 📝 **NOTE** > This review was outside the diff hunks and was mapped to the diff hunk with the greatest overlap. Original lines [135-162]

The epc method in the Erc20Deployer implementation has been significantly altered. It now returns an odra::EntryPointsCaller and includes a match statement to handle various contract entry points. Ensure that the entry points and their corresponding execution parts (__erc20_exec_parts) are correctly defined and that the error handling is consistent with the rest of the codebase.

Verification successful

The verification process has confirmed that the entry points and their corresponding execution parts (__erc20_exec_parts) are consistently defined across the codebase. Additionally, the error handling using odra::OdraError::ExecutionError is also consistent throughout the codebase.

Scripts Executed

The following scripts were executed for the analysis:


Script:

#!/bin/bash
# Verify that the entry points and their corresponding execution parts are correctly defined.
rg --type rust '__erc20_exec_parts'
# Verify that error handling is consistent with the rest of the codebase.
rg --type rust 'odra::OdraError::ExecutionError'

Length of output: 7930

* 159-169: > 📝 **NOTE** > This review was outside the diff hunks and was mapped to the diff hunk with the greatest overlap. Original lines [165-175]

The init method has been updated to include an optional total_supply parameter and uses the epc method to create a new contract. This change is consistent with the PR's objectives to enhance contract deployment. Confirm that the Erc20HostRef struct and the new_contract method are correctly implemented and used.

Verification successful

The Erc20HostRef struct is defined with fields that are consistent with a reference to an ERC20 token in the host environment. The new_contract method is defined with the appropriate parameters for deploying a contract and is used correctly in the init method to create a new ERC20 contract with an optional total_supply. The changes are consistent with the PR's objectives to enhance contract deployment.

Scripts Executed

The following scripts were executed for the analysis:


Script:

#!/bin/bash
# Verify that `Erc20HostRef` struct and the `new_contract` method are correctly implemented and used.
rg --type rust 'Erc20HostRef|new_contract'

Length of output: 3718



Script:

#!/bin/bash
# Search for the definition of `Erc20HostRef` struct to verify its structure.
ast-grep --lang rust --pattern 'pub struct Erc20HostRef { $$$ }'

# Search for the definition and usage of `new_contract` method to verify its parameters and usage.
ast-grep --lang rust --pattern 'fn new_contract($_, $_, $_) { $$$ }'

Length of output: 137



Script:

#!/bin/bash
# Find the lines where `Erc20HostRef` is defined to inspect its structure.
rg --type rust --context 5 'pub struct Erc20HostRef'

# Find the lines where `new_contract` is defined to inspect its parameters and usage.
rg --type rust --context 5 'fn new_contract'

Length of output: 7607

* 184-191: The `load` method has been added to the `Erc20Deployer` implementation, which registers a contract and returns an `Erc20HostRef`. This method is part of the new functionality for loading contracts. Ensure that the `register_contract` method is correctly implemented and that the `Erc20HostRef` struct is used consistently.

Copy link
Contributor

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

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

Review Status

Actionable comments generated: 1

Configuration used: CodeRabbit UI

Commits Files that changed from the base of the PR and between 223ce76 and 25b76ef.
Files ignored due to path filters (1)
  • odra-casper/livenet-env/Cargo.toml is excluded by: !**/*.toml
Files selected for processing (12)
  • core/src/contract_container.rs (10 hunks)
  • core/src/host_context.rs (2 hunks)
  • core/src/host_env.rs (10 hunks)
  • core/src/utils.rs (1 hunks)
  • odra-casper/casper-client/src/casper_client.rs (1 hunks)
  • odra-casper/livenet-env/src/livenet_host_env.rs (1 hunks)
  • odra-casper/test-vm/src/casper_host.rs (3 hunks)
  • odra-casper/test-vm/src/vm/casper_vm.rs (3 hunks)
  • odra-macros/src/ast/deployer_item.rs (6 hunks)
  • odra-vm/src/odra_vm_host.rs (3 hunks)
  • odra-vm/src/vm/odra_vm.rs (4 hunks)
  • odra-vm/src/vm/odra_vm_state.rs (2 hunks)
Files skipped from review as they are similar to previous changes (10)
  • core/src/contract_container.rs
  • core/src/host_context.rs
  • core/src/host_env.rs
  • odra-casper/casper-client/src/casper_client.rs
  • odra-casper/livenet-env/src/livenet_host_env.rs
  • odra-casper/test-vm/src/casper_host.rs
  • odra-casper/test-vm/src/vm/casper_vm.rs
  • odra-vm/src/odra_vm_host.rs
  • odra-vm/src/vm/odra_vm.rs
  • odra-vm/src/vm/odra_vm_state.rs
Additional comments: 3
core/src/utils.rs (1)
  • 31-45: The event_absolute_position function now accepts a len parameter of type u32 instead of usize and returns Option<u32>. Ensure that all usages of this function throughout the codebase are updated to pass a u32 and handle the returned Option<u32> appropriately.
Verification successful

The events_count function is confirmed to return a u32 as shown in the output from core/src/host_env.rs. This matches the expected type for the len parameter of the event_absolute_position function. The handling of the Option<u32> return type is also correctly implemented with .ok_or(EventError::IndexOutOfBounds)?. Therefore, the usage of event_absolute_position in core/src/host_env.rs is consistent with the changes made to its signature and logic.

Scripts Executed

The following scripts were executed for the analysis:


Script:

#!/bin/bash
# Search for usages of `event_absolute_position` to verify correct parameter and return type handling.
rg --type rust 'event_absolute_position\('

Length of output: 1127



Script:

#!/bin/bash
# Verify the handling of `event_absolute_position` in `core/src/host_env.rs`
# Specifically, we want to check if `events_count` is a `u32` and how the return value is used.
rg --type rust 'let event_absolute_position = crate::utils::event_absolute_position\(events_count, index\)' core/src/host_env.rs

Length of output: 227



Script:

#!/bin/bash
# Extract more context around the usage of `event_absolute_position` to determine the types of `events_count` and `index`
# and to see how the result is being handled.
rg --type rust --context 5 'let event_absolute_position = crate::utils::event_absolute_position\(events_count, index\)' core/src/host_env.rs

Length of output: 647



Script:

#!/bin/bash
# Check the return type of `self.events_count` to ensure it is `u32`.
ast-grep --lang rust --pattern 'impl $_ for $_ {
  fn events_count(&self, $_) -> u32 {
    $$$
  }
}'

Length of output: 103



Script:

#!/bin/bash
# Adjust the pattern to be less specific to capture the `events_count` function regardless of its return type.
ast-grep --lang rust --pattern 'impl $_ for $_ {
  fn events_count(&self, $_) -> $_ {
    $$$
  }
}'

Length of output: 102



Script:

#!/bin/bash
# Use ripgrep to search for the function definition of `events_count` in a more general manner.
rg --type rust 'fn events_count\(&self' -A 3

Length of output: 685

odra-macros/src/ast/deployer_item.rs (2)
  • 35-45: > 📝 NOTE

This review was outside the diff hunks and was mapped to the diff hunk with the greatest overlap. Original lines [38-55]

The DeployImplItem struct has been refactored to replace init_fn with epc_fn and load_fn. This change likely reflects a shift in the deployment process, separating the entry point calling from the contract loading logic. Ensure that the deployment process is correctly updated to reflect these changes in all relevant parts of the codebase.

  • 170-193: > 📝 NOTE

This review was outside the diff hunks and was mapped to the diff hunk with the greatest overlap. Original lines [133-190]

New methods epc and load have been added to the Erc20Deployer implementation. Verify that these methods are being used correctly and that their introduction does not conflict with existing deployment logic.

Verification successful

The epc and load methods have been found in use within the codebase, particularly in contract initialization and loading contexts. The usage patterns are consistent with the expected behavior for these methods, and there are no indications of conflicts with existing deployment logic.

Scripts Executed

The following scripts were executed for the analysis:


Script:

#!/bin/bash
# Search for usages of `epc` and `load` methods to ensure they are integrated correctly.
rg --type rust -C3 'epc\(|load\('

Length of output: 7081

core/src/utils.rs Show resolved Hide resolved
Removed `pub` from CallDef fields.
Copy link
Contributor

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

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

Review Status

Actionable comments generated: 9

Configuration used: CodeRabbit UI

Commits Files that changed from the base of the PR and between 25b76ef and f905c9d.
Files ignored due to path filters (1)
  • odra-casper/casper-client/Cargo.toml is excluded by: !**/*.toml
Files selected for processing (13)
  • core/src/call_def.rs (2 hunks)
  • core/src/callstack.rs (4 hunks)
  • core/src/contract_container.rs (10 hunks)
  • examples/bin/erc20_on_livenet.rs (1 hunks)
  • examples/bin/livenet_tests.rs (1 hunks)
  • odra-casper/casper-client/src/casper_client.rs (1 hunks)
  • odra-casper/livenet-env/src/lib.rs (1 hunks)
  • odra-casper/livenet-env/src/livenet_contract_env.rs (1 hunks)
  • odra-casper/livenet-env/src/livenet_host.rs (1 hunks)
  • odra-casper/test-vm/src/vm/casper_vm.rs (6 hunks)
  • odra-casper/wasm-env/src/host_functions.rs (1 hunks)
  • odra-test/src/lib.rs (1 hunks)
  • odra-vm/src/vm/odra_vm.rs (8 hunks)
Files skipped from review as they are similar to previous changes (10)
  • core/src/call_def.rs
  • core/src/callstack.rs
  • core/src/contract_container.rs
  • examples/bin/erc20_on_livenet.rs
  • examples/bin/livenet_tests.rs
  • odra-casper/casper-client/src/casper_client.rs
  • odra-casper/livenet-env/src/lib.rs
  • odra-casper/livenet-env/src/livenet_contract_env.rs
  • odra-casper/test-vm/src/vm/casper_vm.rs
  • odra-test/src/lib.rs
Additional comments: 5
odra-casper/livenet-env/src/livenet_host.rs (1)
  • 47-54: The set_gas method directly mutates the state of casper_client. Ensure that this state change is safe and does not introduce race conditions if LivenetHost is used concurrently.
odra-casper/wasm-env/src/host_functions.rs (1)
  • 292-298: The call_contract function has been updated to use the amount() method instead of directly accessing the amount field. This is a good encapsulation practice. However, ensure that the amount() method is correctly implemented and that this change does not affect the logic negatively.
odra-vm/src/vm/odra_vm.rs (3)
  • 8-11: The imports for CallstackElement, ContractContainer, and ContractRegister are added, which indicates that these types are now being used in this file. Ensure that their usage is consistent with the rest of the codebase.
  • 83-84: The usage of CallstackElement::Entrypoint has been replaced with callstack::Entrypoint. This change is consistent with the rest of the codebase and follows Rust's idiomatic path usage.
  • 59-60: The call_contract method checks if call_def.amount() is greater than zero before proceeding with a token transfer. This is a good check to prevent unnecessary operations. However, ensure that the checked_transfer_tokens method handles all edge cases correctly.

odra-casper/livenet-env/src/livenet_host.rs Show resolved Hide resolved
odra-casper/livenet-env/src/livenet_host.rs Outdated Show resolved Hide resolved
odra-casper/livenet-env/src/livenet_host.rs Show resolved Hide resolved
odra-casper/livenet-env/src/livenet_host.rs Outdated Show resolved Hide resolved
odra-casper/livenet-env/src/livenet_host.rs Outdated Show resolved Hide resolved
odra-casper/livenet-env/src/livenet_host.rs Outdated Show resolved Hide resolved
odra-casper/wasm-env/src/host_functions.rs Show resolved Hide resolved
odra-vm/src/vm/odra_vm.rs Show resolved Hide resolved
Copy link
Contributor

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

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

Review Status

Actionable comments generated: 0

Configuration used: CodeRabbit UI

Commits Files that changed from the base of the PR and between f905c9d and da1de7f.
Files selected for processing (6)
  • core/src/host_context.rs (2 hunks)
  • core/src/host_env.rs (10 hunks)
  • odra-casper/livenet-env/src/livenet_host.rs (1 hunks)
  • odra-casper/test-vm/src/casper_host.rs (3 hunks)
  • odra-casper/test-vm/src/vm/casper_vm.rs (6 hunks)
  • odra-vm/src/odra_vm_host.rs (3 hunks)
Files skipped from review as they are similar to previous changes (5)
  • core/src/host_context.rs
  • odra-casper/livenet-env/src/livenet_host.rs
  • odra-casper/test-vm/src/casper_host.rs
  • odra-casper/test-vm/src/vm/casper_vm.rs
  • odra-vm/src/odra_vm_host.rs
Additional comments: 5
core/src/host_env.rs (5)
  • 52-66: The new_contract method has been updated with additional arguments and logic for initializing contracts. Ensure that all calls to this method have been updated to pass the new entry_points_caller argument.
  • 72-79: A new method register_contract has been added to the HostEnv struct. This method registers a contract and updates the deployed_contracts and events_count collections. Ensure that the events_count is correctly updated to reflect the current state after registration.
  • 101-107: > 📝 NOTE

This review was outside the diff hunks and was mapped to the diff hunk with the greatest overlap. Original lines [80-118]

The call_contract method's signature has been modified to accept a u32 index instead of an i32. This change should be verified across the codebase to ensure that all calls to call_contract are updated accordingly.

  • 148-150: The get_event method has been updated to use a u32 index. This change aligns with the update to call_contract and should be verified to ensure consistency across the codebase.
  • 261-269: Two new methods, caller and set_gas, have been added. These methods are straightforward and provide additional functionality to the HostEnv struct. Ensure that these methods are used appropriately wherever the caller's address and gas limit need to be retrieved or set.

@kubaplas kubaplas requested review from kpob and zie1ony January 24, 2024 14:19
Copy link
Contributor

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

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

Review Status

Actionable comments generated: 1

Configuration used: CodeRabbit UI

Commits Files that changed from the base of the PR and between da1de7f and 2ed06d0.
Files selected for processing (5)
  • core/src/error.rs (1 hunks)
  • examples/bin/livenet_tests.rs (1 hunks)
  • odra-casper/casper-client/src/casper_client.rs (1 hunks)
  • odra-casper/livenet-env/src/livenet_host.rs (1 hunks)
  • odra-casper/test-vm/src/vm/casper_vm.rs (6 hunks)
Files skipped from review as they are similar to previous changes (4)
  • examples/bin/livenet_tests.rs
  • odra-casper/casper-client/src/casper_client.rs
  • odra-casper/livenet-env/src/livenet_host.rs
  • odra-casper/test-vm/src/vm/casper_vm.rs

core/src/error.rs Outdated Show resolved Hide resolved
Co-authored-by: coderabbitai[bot] <136622811+coderabbitai[bot]@users.noreply.github.com>
@kubaplas kubaplas force-pushed the feature/livenet-on-0.8 branch from 119e361 to c05cca2 Compare January 24, 2024 15:17
Copy link
Contributor

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

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

Review Status

Actionable comments generated: 0

Configuration used: CodeRabbit UI

Commits Files that changed from the base of the PR and between 2ed06d0 and c05cca2.
Files selected for processing (2)
  • core/src/error.rs (1 hunks)
  • odra-casper/casper-client/src/casper_client.rs (1 hunks)
Files skipped from review as they are similar to previous changes (2)
  • core/src/error.rs
  • odra-casper/casper-client/src/casper_client.rs

@kubaplas kubaplas merged commit 10cdfbe into release/0.8.0 Jan 24, 2024
1 check passed
@kubaplas kubaplas mentioned this pull request Jan 25, 2024
@kubaplas kubaplas linked an issue Jan 25, 2024 that may be closed by this pull request
@kubaplas kubaplas deleted the feature/livenet-on-0.8 branch February 16, 2024 08:47
@kubaplas kubaplas restored the feature/livenet-on-0.8 branch March 5, 2024 10:46
@kubaplas kubaplas deleted the feature/livenet-on-0.8 branch March 5, 2024 10:46
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.

Rust Livenet Client
3 participants