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

Validate args at deploy time #418

Merged
merged 2 commits into from
May 7, 2024

Conversation

kpob
Copy link
Contributor

@kpob kpob commented Apr 26, 2024

Resolves #409 Now on both backends: odra-vm and casper a missing argument error should almost the same

Summary by CodeRabbit

  • New Features

    • Improved error handling across components with the introduction of ExecutionError for specific scenarios.
    • Updated functions like get_named_arg to return OdraResult, enhancing argument retrieval reliability.
  • Bug Fixes

    • Addressed potential crashes by implementing structured error handling in contract environments.
  • Refactor

    • Streamlined error management by transitioning from VmError to ExecutionError in multiple files.

@kpob kpob linked an issue Apr 26, 2024 that may be closed by this pull request
Copy link
Contributor

coderabbitai bot commented Apr 26, 2024

Walkthrough

The recent update focuses on enhancing error handling by transitioning from VmError to ExecutionError across various components. This change aims to improve error clarity and consistency, especially concerning missing arguments and other execution-related issues. It spans multiple core files and extends to test environments to ensure more descriptive and appropriate error responses.

Changes

File Path Change Summary
contract_container.rs, host.rs Updated error handling from VmError to ExecutionError.
contract_context.rs, contract_env.rs Improved error handling with OdraResult.
error.rs ExecutionError updated with new variants, VmError variants removed.
.../livenet_contract_env.rs, .../wasm_contract_env.rs, .../odra_vm_contract_env.rs Introduced ExecutionError and modified return types to OdraResult<Bytes>.
casper_vm.rs, odra_vm.rs Refactored error handling to utilize structured ExecutionError cases.

Assessment against linked issues

Objective Addressed Explanation
#409: HostRef::deploy should validate arguments. The changes do not directly address argument validation in HostRef::deploy.

Poem

🐇 "In the land of code, where the errors hide,
🌟 A rabbit hopped through, with a stride so wide.
🛠️ Swapped old errors, with ones anew,
📜 Now clearer messages, for me and you.
🎉 Celebrate the change, let’s all cheer,
🐾 For better coding days, are now here!"


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 testing code for this file.
    • Open a follow-up GitHub issue for this discussion.
  • 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 testing code 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 and render them as a table.
    • @coderabbitai show all the console.log statements in this repository.
    • @coderabbitai read src/utils.ts and generate unit testing code.
    • @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.
  • Please see the configuration documentation for more information.
  • 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/schema.v2.json

Documentation and Community

  • Visit our Documentation for detailed information on how to use CodeRabbit.
  • Join our Discord Community to get help, request features, and share feedback.
  • Follow us on X/Twitter for updates and announcements.

Copy link

Benchmark report

Action Details Gas diff
Wasm Deploy Filename: Benchmark.wasm 🔴 +0.64742901 CSPR (0.72%)
Contract Call Entry point: set_variable 🔴 +0.00270484 CSPR (1.43%)
Contract Call Entry point: get_variable 🔴 +0.00330448 CSPR (1.01%)
Contract Call Entry point: set_struct_variable 🔴 +0.00270566 CSPR (0.88%)
Contract Call Entry point: get_struct_variable 🔴 +0.00330448 CSPR (0.82%)
Contract Call Entry point: set_mapping 🔴 +0.00315178 CSPR (1.49%)
Contract Call Entry point: get_mapping 🔴 +0.00375142 CSPR (0.94%)
Contract Call Entry point: push_list 🔴 +0.00410354 CSPR (1.02%)
Contract Call Entry point: get_list 🔴 +0.00375142 CSPR (0.92%)
Contract Call Entry point: init_submodule 🔴 +0.01266468 CSPR (0.97%)
Contract Call Entry point: call_submodule 🔴 +0.00330448 CSPR (0.96%)
Contract Call Entry point: call_payable 🔴 +0.00277509 CSPR (0.05%)
Contract Call Entry point: transfer_back 🔴 +0.00330536 CSPR (0.13%)
Contract Call Entry point: emit_event 🔴 +0.00435062 CSPR (1.68%)
Contract Call Entry point: set_named_key 🔴 +0.0000292 CSPR (0.02%)
Contract Call Entry point: get_named_key 🔴 +0.00225746 CSPR (0.69%)
Contract Call Entry point: set_dictionary 🔴 +0.00289834 CSPR (1.11%)
Contract Call Entry point: get_dictionary 🔴 +0.00375174 CSPR (0.83%)

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.

Actionable comments posted: 1

odra-casper/test-vm/src/vm/casper_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.

Actionable comments posted: 0

Review Details

Configuration used: CodeRabbit UI
Review profile: CHILL

Commits Files that changed from the base of the PR and between d07f430 and b2378d2.
Files selected for processing (1)
  • core/src/error.rs (3 hunks)
Additional comments not posted (2)
core/src/error.rs (2)

128-129: Added MissingArg to ExecutionError enum.

This addition aligns with the PR's objective to standardize error handling for missing arguments across different backends. It's a clear and direct way to handle such errors.


153-153: Conversion from ExecutionError to OdraError.

This change is straightforward and maintains the encapsulation of ExecutionError within OdraError, which is beneficial for error handling consistency across the system.

Copy link

github-actions bot commented May 7, 2024

Benchmark report

Action Details Gas diff
Wasm Deploy Filename: Benchmark.wasm 🔴 +0.64175901 CSPR (0.71%)
Contract Call Entry point: set_variable 🔴 +0.00270484 CSPR (1.43%)
Contract Call Entry point: get_variable 🔴 +0.00330448 CSPR (1.01%)
Contract Call Entry point: set_struct_variable 🔴 +0.00270566 CSPR (0.88%)
Contract Call Entry point: get_struct_variable 🔴 +0.00330448 CSPR (0.82%)
Contract Call Entry point: set_mapping 🔴 +0.00315178 CSPR (1.49%)
Contract Call Entry point: get_mapping 🔴 +0.00375142 CSPR (0.94%)
Contract Call Entry point: push_list 🔴 +0.00410354 CSPR (1.02%)
Contract Call Entry point: get_list 🔴 +0.00375142 CSPR (0.92%)
Contract Call Entry point: init_submodule 🔴 +0.01266468 CSPR (0.97%)
Contract Call Entry point: call_submodule 🔴 +0.00330448 CSPR (0.96%)
Contract Call Entry point: call_payable 🔴 +0.00277509 CSPR (0.05%)
Contract Call Entry point: transfer_back 🔴 +0.00330536 CSPR (0.13%)
Contract Call Entry point: emit_event 🔴 +0.00435062 CSPR (1.68%)
Contract Call Entry point: set_named_key 🔴 +0.0000292 CSPR (0.02%)
Contract Call Entry point: get_named_key 🔴 +0.00225746 CSPR (0.69%)
Contract Call Entry point: set_dictionary 🔴 +0.00289834 CSPR (1.11%)
Contract Call Entry point: get_dictionary 🔴 +0.00375174 CSPR (0.83%)

@kpob kpob merged commit a460225 into release/1.0.0 May 7, 2024
3 of 4 checks passed
@kpob kpob deleted the fix/hostrefdeploy-should-validate-arguments branch May 7, 2024 09:23
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.

HostRef::deploy should validate arguments.
2 participants