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

Improved version of Deposit contract #51

Merged
merged 131 commits into from
May 17, 2024
Merged

Conversation

jonas089
Copy link
Contributor

  • Error handling
  • Segregation
  • Create_Purse entry point -> now automatically setup upon contract installation
  • Access Control using SecurityBadges
  • Primitive Access Control

This deposit smart contract targets the release branch of the official casper node repository, e.g. casper-network/release-1.5.6.

Contract types were introduced to write a serialized Deposit to the contract's event storage.

Copy link
Collaborator

@marijanp marijanp left a comment

Choose a reason for hiding this comment

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

Some first comments

contracts/deposit-contract-tests/.env Outdated Show resolved Hide resolved
contracts/Cargo.toml Outdated Show resolved Hide resolved
contracts/contract-types/Cargo.toml Outdated Show resolved Hide resolved
contracts/deposit-contract-tests/Cargo.toml Outdated Show resolved Hide resolved
contracts/contract-types/Cargo.toml Outdated Show resolved Hide resolved
contracts/deposit-contracts/contract/src/detail.rs Outdated Show resolved Hide resolved
contracts/deposit-contracts/contract/src/detail.rs Outdated Show resolved Hide resolved
contracts/deposit-contracts/contract/src/detail.rs Outdated Show resolved Hide resolved
Vec::new()
};

bytesrepr::deserialize(arg_bytes).map_err(|_| invalid)
Copy link
Collaborator

Choose a reason for hiding this comment

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

We loose the actual error cause here. it is a deserialization error but the message is lost and potentially mapped to a wrong invalid type. The user of this does not know that you are going to do that and I could pass in invalid to be ConnectionError and now anyone debugging this would never know what kind of error this was

Copy link
Contributor Author

Choose a reason for hiding this comment

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

This will propagate a Casper APIError to the contract runtime. I did not write any of the code in detail.rs and it was used by Casper Labs in the cep standards.

Copy link
Contributor

Choose a reason for hiding this comment

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

It MIGHT be propagated to ApiError, but it does not have to - depending of what called will do with error. So far I am not worried about losing error details, but rather about this error not being used in the code at all - is arguments handling done properly?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

What do you mean by "is argument handling done properly"?

Copy link
Contributor

Choose a reason for hiding this comment

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

@jonas089 Please don't resolve every conversation once you posted a comment, especially one that involves further discussion. About error handling issues, see related comment.

Copy link
Contributor Author

@jonas089 jonas089 Apr 4, 2024

Choose a reason for hiding this comment

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

Error handling has been improved in the latest verison.

contracts/deposit-contracts/contract/src/detail.rs Outdated Show resolved Hide resolved
jonas089 and others added 6 commits March 26, 2024 18:52
Co-authored-by: Marijan Petričević <marijan.petricevic94@gmail.com>
Co-authored-by: Marijan Petričević <marijan.petricevic94@gmail.com>
Co-authored-by: Marijan Petričević <marijan.petricevic94@gmail.com>
Co-authored-by: Marijan Petričević <marijan.petricevic94@gmail.com>
Co-authored-by: Marijan Petričević <marijan.petricevic94@gmail.com>
Co-authored-by: Marijan Petričević <marijan.petricevic94@gmail.com>
contracts/Cargo.toml Outdated Show resolved Hide resolved
Copy link
Contributor

@koxu1996 koxu1996 left a comment

Choose a reason for hiding this comment

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

First pass

contracts/Cargo.toml Outdated Show resolved Hide resolved
contracts/contract-types/Cargo.toml Outdated Show resolved Hide resolved
contracts/deposit-contract-tests/.env Outdated Show resolved Hide resolved
contracts/deposit-contract-tests/Cargo.toml Outdated Show resolved Hide resolved
contracts/deposit-contracts/contract/Cargo.toml Outdated Show resolved Hide resolved
contracts/deposit-contracts/contract/src/main.rs Outdated Show resolved Hide resolved
contracts/deposit-contracts/contract/src/main.rs Outdated Show resolved Hide resolved
contracts/deposit-contracts/contract/src/main.rs Outdated Show resolved Hide resolved
contracts/deposit-contracts/contract/src/main.rs Outdated Show resolved Hide resolved
contracts/deposit-contracts/contract/src/main.rs Outdated Show resolved Hide resolved
jonas089 and others added 7 commits March 27, 2024 15:29
Co-authored-by: Marijan Petričević <marijan.petricevic94@gmail.com>
Co-authored-by: Marijan Petričević <marijan.petricevic94@gmail.com>
Co-authored-by: Marijan Petričević <marijan.petricevic94@gmail.com>
Co-authored-by: Marijan Petričević <marijan.petricevic94@gmail.com>
Co-authored-by: Marijan Petričević <marijan.petricevic94@gmail.com>
Co-authored-by: Marijan Petričević <marijan.petricevic94@gmail.com>
…e, explain security and change function names
kairos-l1-utils/src/lib.rs Outdated Show resolved Hide resolved
Copy link
Contributor

@Avi-D-coder Avi-D-coder left a comment

Choose a reason for hiding this comment

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

LGTM

Comment on lines +57 to +60

- name: kairos-contracts x86_64-darwin
if: matrix.os == 'macos-latest'
run: nix build -L --no-link --show-trace .#packages.x86_64-darwin.kairos-contracts
Copy link
Contributor

Choose a reason for hiding this comment

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

Let's not add back x86_64-darwin.
aarch64-darwin is enough

Suggested change
- name: kairos-contracts x86_64-darwin
if: matrix.os == 'macos-latest'
run: nix build -L --no-link --show-trace .#packages.x86_64-darwin.kairos-contracts

Copy link
Collaborator

Choose a reason for hiding this comment

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

Will be addressed in other PR as discussed.

Copy link
Contributor

@koxu1996 koxu1996 left a comment

Choose a reason for hiding this comment

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

🚀

@marijanp marijanp merged commit cc4fc85 into main May 17, 2024
7 checks passed
@marijanp marijanp deleted the feature/deposit-contract branch May 17, 2024 17:04
@@ -1,7 +1,6 @@
name: check
on:
pull_request:
branches: [main]
Copy link
Collaborator

Choose a reason for hiding this comment

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

Somehow this sneaked in

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
demo Required for our first demo
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants