-
Notifications
You must be signed in to change notification settings - Fork 596
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
fix: deploy syscall address registry #4489
Conversation
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.
Reviewable status: 0 of 1 files reviewed, 2 unresolved discussions (waiting on @enitrat)
a discussion (no related file):
Add a tests in cairo-lang-starknet/cairo-level-tests
.
crates/cairo-lang-runner/src/casm_run/mod.rs
line 984 at r1 (raw file):
Ok(value) => value, Err(mut revert_reason) => { fail_syscall!(revert_reason, b"CONSTRUCTOR_FAILED");
I would assume this failure should revert the deployment as well.
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.
Reviewable status: 0 of 3 files reviewed, 2 unresolved discussions (waiting on @orizi)
a discussion (no related file):
Previously, orizi wrote…
Add a tests in
cairo-lang-starknet/cairo-level-tests
.
Done. Also tested that before the changes, the test failed with
failures:
cairo_level_tests::deployment::test_deploy_in_construct - Panicked with 0x666163746f7279206465706c6f796d656e74206661696c6564 ('factory deployment failed').
Error: test result: FAILED. 47 passed; 1 failed; 0 ignored
Now, it passes.
crates/cairo-lang-runner/src/casm_run/mod.rs
line 984 at r1 (raw file):
Previously, orizi wrote…
I would assume this failure should revert the deployment as well.
Done.
Is this fixed following this PR? Code quote: // The child contract is deployed, but the following line fails without propagating an error. |
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.
Reviewable status: 0 of 3 files reviewed, 3 unresolved discussions (waiting on @ilyalesokhin-starkware and @orizi)
crates/cairo-lang-starknet/cairo_level_tests/deployment.cairo
line 30 at r2 (raw file):
Previously, ilyalesokhin-starkware wrote…
Is this fixed following this PR?
oops - sorry, I missed this comment. Yes, it's fixed following this PR and the test passes 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.
Reviewed 2 of 3 files at r2, 1 of 1 files at r3, all commit messages.
Reviewable status: all files reviewed, 2 unresolved discussions (waiting on @orizi)
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.
Reviewed 2 of 3 files at r2, all commit messages.
Reviewable status: all files reviewed, 1 unresolved discussion (waiting on @enitrat)
crates/cairo-lang-starknet/cairo_level_tests/deployment.cairo
line 74 at r3 (raw file):
let res = IFactoryDispatcher { contract_address: starknet_address }.get_value(); assert(res == 1, 'factory value is not 1') }
Suggestion:
use core::result::ResultTrait;
use starknet::deploy_syscall;
#[starknet::interface]
trait IValue<TContractState> {
fn get_value(self: @TContractState) -> felt252;
fn set_value(ref self: TContractState, value: felt252);
}
#[starknet::contract]
mod self_caller {
use core::traits::TryInto;
use starknet::{ClassHash, deploy_syscall};
use super::{IValueDispatcher, IValueDispatcherTrait};
#[storage]
struct Storage {
value: felt252,
}
#[constructor]
fn constructor(ref self: ContractState) {
IValueDispatcher { contract_address: starknet::get_contract_address() }.set_value(1);
}
#[abi(embed_v0)]
impl ValueImpl of super::IValue<ContractState> {
fn get_value(self: @ContractState) -> felt252 {
self.value.read()
}
fn set_value(ref self: ContractState, value: felt252) {
self.value.write(value);
}
}
}
#[test]
fn test_deploy_in_construct() {
let (contract_address, _) = deploy_syscall(
self_caller::TEST_CLASS_HASH.try_into().unwrap(), 0, array![].span(), false
)
.expect('deployment failed');
assert!(IValueDispatcher { contract_address }.get_value() == 1);
}
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.
Reviewable status: 2 of 3 files reviewed, 1 unresolved discussion (waiting on @ilyalesokhin-starkware and @orizi)
crates/cairo-lang-starknet/cairo_level_tests/deployment.cairo
line 74 at r3 (raw file):
let res = IFactoryDispatcher { contract_address: starknet_address }.get_value(); assert(res == 1, 'factory value is not 1') }
Done.
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.
Reviewed 1 of 1 files at r4, all commit messages.
Reviewable status:complete! all files reviewed, all discussions resolved (waiting on @enitrat)
Fixes #4488
This change is