-
Notifications
You must be signed in to change notification settings - Fork 2
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
Conversation
WalkthroughThe 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
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 Configration File (
|
4426ff7
to
1dd45bf
Compare
Switching accounts Multiple enviroments
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.
Review Status
Actionable comments generated: 9
Configuration used: CodeRabbit UI
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 newHostEnv
with aLivenetEnv
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
, andcurrent
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
, andwait
are correctly delegating to theprettycli
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
andquery_balance
modules to thecasper_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 theEventError
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 theCallDef
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 theis_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 theAccount
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 theHostContext
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 onodra_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
, andcontract_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
andQueryBalanceResult
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 theCallstack
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
andload
functions toident.rs
in theodra-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 inOdraVmHost
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 theis_mut
variable and its usage in thecall_def
andcall_def_with_amount
functions.This change is consistent with the addition of the
is_mut
field in theCallDef
struct and is necessary for the correct construction ofCallDef
instances.odra-casper/test-vm/src/casper_host.rs (1)
- 36-38: The
set_gas
method inCasperHost
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 inLivenetContractEnv
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 inLivenetContractEnv
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 inLivenetContractEnv
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 inLivenetContractEnv
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 theCallDef::new
function call within themod test
module affects the logic related to thebalance_of
function call. Ensure that thefalse
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 theCallDef::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 theExecutionError
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 theuse_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 emptyBytes
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 ofsuper::callstack
is a good practice for clarity and maintainability, assuming that theodra_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 theStoredValue
enum is a good way to handle contract-related data. Ensure that all parts of the codebase that interact withStoredValue
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 theentry_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
andset_gas
have been added to theHostEnv
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 viaTryFrom
trait are correctly defined and follow the Rust conventions for struct and trait implementations. The use ofDefault::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 ofDefault::default()
and utility functions is consistent, and the implementation ofTryFrom
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 theTryFrom
implementation is correct. The use ofparse_quote!
to generate the expression is appropriate.- 211-234: The
LoadContractExpr
struct and itsTryFrom
implementation are correct. The struct captures the expression for loading a contract, and the implementation usesparse_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 includeepc_fn
andload_fn
while retaininginit_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 newEpcSignature
. The inclusion ofEntrypointCallerExpr
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 newDeployerLoadSignature
. The inclusion ofCallEpcExpr
andLoadContractExpr
is appropriate and aligns with the changes made indeployer_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 newepc
andload
functions. The changes are consistent with the PR objectives and the AI-generated summary. The use ofodra::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 theref_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 themod test
module is consistent and correctly placed. The boolean valuesfalse
ortrue
are added appropriately for the functionstotal_supply
,pay_to_mint
,approve
, andairdrop
, 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 theargs
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 theargs
map has been verified. The script output confirms thatCONSTRUCTOR_NAME_ARG
is not present in thecasper_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.rsLength of output: 77
odra-macros/src/ir/mod.rs (1)
- 196-196: The addition of the
contract_ref_ident
method in theModuleImplIR
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
, andContractRegister
is correctly summarized. These imports are necessary for the new functionality introduced in theOdraVm
struct.- 97-98: The replacement of
CallstackElement::Entrypoint
withcallstack::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 theCallDef::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 theCallDef::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 theCallDef::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 theCallDef::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 theCallDef::new
call for the function "total_supply" within thehost_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 theCallDef::new
call for the function "pay_to_mint" within thehost_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 theCallDef::new
call for the function "total_supply" within thehost_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 theCallDef::new
call for the function "get_owner" within thehost_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 theCallDef::new
call for the function "set_owner" within thehost_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 theCallDef::new
call for the function "name" within thehost_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 theCallDef::new
call for the function "symbol" within thehost_ref_delegation
test case. Confirm that this change is correct and that the test case is still valid.
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.
Cool :)
████████
██████████████████
██████████████████████
██████████████████████████
████████████████ ████
████████████████ ██
██████████████████
██░░ ░░░░██
██░░░░ ░░░░░░ ░░░░██
██░░░░ ░░░░░░ ░░░░██
██░░░░░░ ░░░░░░██
████████████████████████████
██████████████▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒████████████████
██████████▒▒▒▒░░░░░░░░░░░░░░░░░░▒▒▒▒████████████
▒▒▒▒▒▒▒▒▒▒▒▒░░░░░░░░░░░░░░░░░░░░░░░░░░▒▒▒▒▒▒▒▒▒▒▒▒
▒▒░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░▒▒
▒▒░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░▒▒
▒▒░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░▒▒
▒▒░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░▒▒
▒▒░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░▒▒
▒▒░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░▒▒
▒▒░░░░░░▒▒▒▒░░░░░░░░░░░░░░▒▒▒▒░░░░░░▒▒
▒▒░░░░▒▒ ▒▒▒▒░░░░░░░░░░▒▒ ▒▒▒▒░░░░▒▒
▒▒░░░░▒▒▒▒▒▒▒▒░░░░░░░░░░▒▒▒▒▒▒▒▒░░░░▒▒
▒▒░░░░▒▒▒▒░░░░░░░░░░░░░░▒▒▒▒░░░░▒▒
▒▒░░░░░░░░░░ ▒▒ ░░░░░░░░░░▒▒
▒▒░░░░░░░░ ░░░░░░░░▒▒
▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒
████████░░██████████████
████████░░██░░██████████████
██░░░░████░░████░░████████████ ▒▒▒▒▒▒
██░░░░░░██░░██░░░░░░██████████ ▒▒ ▒▒
██░░░░██░░░░░░██░░░░████████████ ░░ ▒▒
██░░░░░░░░░░░░░░░░░░░░██████████ ▒▒ ▒▒
██▒▒░░░░░░░░░░░░░░░░░░░░████████ ▒▒░░ ▒▒
██▒▒░░░░░░░░░░░░░░░░░░░░░░██████ ▒▒░░░░░░▒▒
████▒▒░░░░░░░░░░░░░░░░░░░░░░██████ ▒▒░░░░▒▒
████▒▒░░░░░░░░░░░░░░░░░░░░░░░░████ ▒▒░░░░░░▒▒
████████▒▒░░░░░░░░░░░░░░░░░░░░░░████▒▒░░░░░░▒▒
██████████▒▒░░░░░░░░░░░░░░░░░░░░░░████░░░░▒▒▒▒
██████████████▒▒░░░░▒▒░░░░░░░░░░░░░░░░████▒▒▒▒
████████████████████▒▒▒▒██▒▒▒▒▒▒▒▒▒▒▒▒██████
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.
Review Status
Actionable comments generated: 0
Configuration used: CodeRabbit UI
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 removeDeployerInitSignature
,EntrypointCallerExpr
,EntrypointsInitExpr
,HostRefInstanceExpr
,NewContractExpr
. Ensure that the removed entities are no longer used anywhere in the codebase.- 40-44: The
DeployImplItem
struct now includesepc_fn
andload_fn
fields, replacing theinit_fn
. This change aligns with the PR's objective to enhance contract deployment and management. Ensure that all references toinit_fn
are updated to use the new fields.- 65-76: The
ContractEpcFn
struct has been introduced with fieldsvis
,sig
,braces
,entry_points
, andcaller
. This struct seems to be part of the new deployment flow. Confirm that theEpcSignature
andEntrypointsInitExpr
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 bothEpcSignature
andEntrypointsInitExpr
. TheEpcSignature
struct includes fields that represent a function signature, and theTryFrom
implementation constructs an instance from aModuleImplIR
, 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 itsTryFrom
implementation constructs an instance from aModuleImplIR
by mapping over the module's functions to create entry points. This also aligns with the expected usage within theContractEpcFn
struct.Based on the provided output, the
EpcSignature
andEntrypointsInitExpr
types are correctly defined and used in the context of the new structContractEpcFn
. TheTryFrom
implementations indicate that these types are intended to be constructed from aModuleImplIR
, 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.* 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.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.rsLength 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.rsLength 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.rsLength of output: 1491
Verification successful
The
ContractLoadFn
struct is properly integrated within the deployment process as part of theDeployImplItem
, and theDeployerLoadSignature
type is correctly defined, as evidenced by its usage inContractLoadFn
and the associated conversion logic fromModuleImplIR
. The verification process has confirmed the integration and definition as per the review comment.* 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]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 3Length 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 3Length 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 3Length of output: 1266
The
epc
method in theErc20Deployer
implementation has been significantly altered. It now returns anodra::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 usingodra::OdraError::ExecutionError
is also consistent throughout the codebase.* 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]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
The
init
method has been updated to include an optionaltotal_supply
parameter and uses theepc
method to create a new contract. This change is consistent with the PR's objectives to enhance contract deployment. Confirm that theErc20HostRef
struct and thenew_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. Thenew_contract
method is defined with the appropriate parameters for deploying a contract and is used correctly in theinit
method to create a new ERC20 contract with an optionaltotal_supply
. The changes are consistent with the PR's objectives to enhance contract deployment.* 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.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
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.
Review Status
Actionable comments generated: 1
Configuration used: CodeRabbit UI
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 alen
parameter of typeu32
instead ofusize
and returnsOption<u32>
. Ensure that all usages of this function throughout the codebase are updated to pass au32
and handle the returnedOption<u32>
appropriately.Verification successful
The
events_count
function is confirmed to return au32
as shown in the output fromcore/src/host_env.rs
. This matches the expected type for thelen
parameter of theevent_absolute_position
function. The handling of theOption<u32>
return type is also correctly implemented with.ok_or(EventError::IndexOutOfBounds)?
. Therefore, the usage ofevent_absolute_position
incore/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.rsLength 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.rsLength 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 3Length 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 replaceinit_fn
withepc_fn
andload_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
andload
have been added to theErc20Deployer
implementation. Verify that these methods are being used correctly and that their introduction does not conflict with existing deployment logic.Verification successful
The
epc
andload
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
Removed `pub` from CallDef fields.
de4b476
to
8479f1a
Compare
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.
Review Status
Actionable comments generated: 9
Configuration used: CodeRabbit UI
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 ofcasper_client
. Ensure that this state change is safe and does not introduce race conditions ifLivenetHost
is used concurrently.odra-casper/wasm-env/src/host_functions.rs (1)
- 292-298: The
call_contract
function has been updated to use theamount()
method instead of directly accessing theamount
field. This is a good encapsulation practice. However, ensure that theamount()
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
, andContractRegister
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 withcallstack::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 ifcall_def.amount()
is greater than zero before proceeding with a token transfer. This is a good check to prevent unnecessary operations. However, ensure that thechecked_transfer_tokens
method handles all edge cases correctly.
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.
Review Status
Actionable comments generated: 0
Configuration used: CodeRabbit UI
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 newentry_points_caller
argument.- 72-79: A new method
register_contract
has been added to theHostEnv
struct. This method registers a contract and updates thedeployed_contracts
andevents_count
collections. Ensure that theevents_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 au32
index instead of ani32
. This change should be verified across the codebase to ensure that all calls tocall_contract
are updated accordingly.
- 148-150: The
get_event
method has been updated to use au32
index. This change aligns with the update tocall_contract
and should be verified to ensure consistency across the codebase.- 261-269: Two new methods,
caller
andset_gas
, have been added. These methods are straightforward and provide additional functionality to theHostEnv
struct. Ensure that these methods are used appropriately wherever the caller's address and gas limit need to be retrieved or set.
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.
Review Status
Actionable comments generated: 1
Configuration used: CodeRabbit UI
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
19ba3a6
to
119e361
Compare
Co-authored-by: coderabbitai[bot] <136622811+coderabbitai[bot]@users.noreply.github.com>
119e361
to
c05cca2
Compare
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.
Review Status
Actionable comments generated: 0
Configuration used: CodeRabbit UI
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
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
Enhancements
Bug Fixes
Refactor
Documentation
.gitignore
to better manage file exclusions in the repository.Tests
Chores