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

First contract minor fixes #6

Open
wants to merge 2 commits into
base: main
Choose a base branch
from

Conversation

sydhds
Copy link

@sydhds sydhds commented Oct 26, 2024

  • Fix read_value return type (from i64 to u32)
  • Add the flag -Znext-lockfile-bump for compiling the SC otherwise cargo complains with the following error:
sydh@sydh:~/dev/perso/dusk_network/my-first-contract$ cargo --version
cargo 1.75.0-nightly (7046d992f 2023-11-08)
sydh@sydh:~/dev/perso/dusk_network/my-first-contract$ cargo build --target wasm32-unknown-unknown --release
error: failed to parse lock file at: /home/sydh/dev/perso/dusk_network/my-first-contract/Cargo.lock

Caused by:
  lock file version 4 requires `-Znext-lockfile-bump`

Also I was thinking about adding a section to deploy the SC using rusk-wallet (instead of dusk-deploy-cli).

On testnet, I've tried the following command:

cargo run --release -- -n testnet -p dusk_p1 contract-deploy -c /home/sydh/dev/perso/dusk_network/my-first-contract/target/wasm32-unknown-unknown/release/my_first_contract.wasm --deploy-nonce 2 -p 2000 -l 506286400
    Finished release [optimized] target(s) in 0.14s
     Running `/home/sydh/dev/perso/dusk_network/rusk/target/release/rusk-wallet -n testnet -p 'dusk_p1' contract-deploy -c /home/sydh/dev/perso/dusk_network/my-first-contract/target/wasm32-unknown-unknown/release/my_first_contract.wasm --deploy-nonce 2 -p 2000 -l 506286400`
✔ Please enter wallet password: · [hidden]
2024-10-26T11:34:42.396948Z  INFO rusk_wallet::io::status: status="Opening notes database"
2024-10-26T11:34:42.411258Z  INFO rusk_wallet::io::status: status="Fetching account-data..."
2024-10-26T11:34:42.701375Z  INFO rusk_wallet::io::status: status="account-data received!"
2024-10-26T11:34:42.701400Z  INFO rusk_wallet::io::status: status="Fetching chain_id..."
2024-10-26T11:34:43.725219Z  INFO rusk_wallet::io::status: status="Chain id received!"
2024-10-26T11:34:43.733871Z  INFO rusk_wallet::io::status: status="Attempt to preverify tx..."
2024-10-26T11:34:46.608984Z  INFO rusk_wallet::io::status: status="Preverify success!"
2024-10-26T11:34:46.609011Z  INFO rusk_wallet::io::status: status="Propagating tx..."
2024-10-26T11:34:48.240465Z  INFO rusk_wallet::io::status: status="Transaction propagated!"
2024-10-26T11:34:48.499926Z  INFO rusk_wallet::io::status: status="Waiting for tx to be included into a block..."
2024-10-26T11:34:49.761170Z  INFO rusk_wallet::io::status: status="Waiting for tx to be included into a block..."
2024-10-26T11:34:51.711532Z  INFO rusk_wallet::io::status: status="Waiting for tx to be included into a block..."
2024-10-26T11:34:53.964293Z  INFO rusk_wallet::io::status: status="Waiting for tx to be included into a block..."
2024-10-26T11:34:55.602170Z  INFO rusk_wallet::io::status: status="Waiting for tx to be included into a block..."
2024-10-26T11:34:57.547514Z  INFO rusk_wallet::io::status: status="Waiting for tx to be included into a block..."
2024-10-26T11:34:59.493037Z  INFO rusk_wallet::io::status: status="Waiting for tx to be included into a block..."
2024-10-26T11:35:00.824358Z  INFO rusk_wallet::io::status: status="Waiting for tx to be included into a block..."
2024-10-26T11:35:02.503571Z  INFO rusk_wallet::io::status: status="Waiting for tx to be included into a block..."
Transaction error: Panic: failed deployment: Panic("Argument should correctly deserialize: ContextError(ArchiveError(OutOfBounds { base: 0x100820, offset: -4, range: 0x100820..0x100820 }))")

Let me know if I should open an issue on rusk repo and if adding a section to deploy with rusk-wallet would be accepted? :)

@lufa23 lufa23 requested a review from HDauven November 12, 2024 14:42
@HDauven
Copy link
Member

HDauven commented Nov 12, 2024

Thank you for your contribution @sydhds! What you recommend would be a welcome and nice addition.

On the change from i64 to u32, I do think it might lead people to think that the no_mangle argument buffer being u32 by default might lead people to think that there's a 1-1 mapping between the argument buffer and the value on the contract.

Maybe it makes sense to change the contract counter state to hold u64 or i64 on the read_value, init and increment function, as well as the value field in the Counter struct.

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.

3 participants