-
Notifications
You must be signed in to change notification settings - Fork 604
feat(starknet-plugin): Typed deployer #7749
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
base: main
Are you sure you want to change the base?
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.
Reviewed all commit messages.
Reviewable status: 0 of 4 files reviewed, 2 unresolved discussions
a discussion (no related file):
additionally change tests in crates/cairo-lang-starknet/cairo_level_tests/deployment.cairo
.
crates/cairo-lang-starknet/src/plugin/plugin_test_data/contracts/storage_accesses
line 237 at r1 (raw file):
pub class_hash: starknet::ClassHash, pub deploy_from_zero: bool, }
should not be generated - should be part of library code.
Code quote:
pub struct storage_accessesDeployer {
pub class_hash: starknet::ClassHash,
pub deploy_from_zero: bool,
}
3f98438
to
d3d89d3
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.
Reviewed 3 of 3 files at r3, all commit messages.
Reviewable status: 3 of 4 files reviewed, 4 unresolved discussions (waiting on @kkawula)
crates/cairo-lang-starknet/src/plugin/starknet_module/contract.rs
line 361 at r3 (raw file):
} fn generate_deploy_function(
doc
crates/cairo-lang-starknet/src/plugin/starknet_module/contract.rs
line 418 at r3 (raw file):
) }} }}
i see no reason for this being "method" based.
Suggestion:
fn deploy(
deployment_info: starknet::DeploymentInfo,
{param_declarations_str}
) -> starknet::SyscallResult<(starknet::ContractAddress, core::array::Span<felt252>)> \
{{
let mut calldata: core::array::Array<felt252> = core::array::ArrayTrait::new();
{calldata_serialization_str}
starknet::syscalls::deploy_syscall(
deployment_info.class_hash,
deployment_info.contract_address_salt,
core::array::ArrayTrait::span(@calldata),
deployment_info.deploy_from_zero,
)
}}
3682bd9
to
635ed76
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.
Reviewable status: 1 of 5 files reviewed, 5 unresolved discussions (waiting on @kkawula)
crates/cairo-lang-starknet/src/plugin/starknet_module/contract.rs
line 442 at r4 (raw file):
{param_names_str} ) }}
add a helper to create the basic DeploymentInfo
from a ClassHashor just add a
#[cfg(feature: "test")]
fn deploy_for_testing..`
with no params and the test class hash.
Suggestion:
pub fn deploy(
deployment_info: starknet::DeploymentInfo,
{param_declarations_str}
) -> starknet::SyscallResult<(starknet::ContractAddress, core::array::Span<felt252>)> {{
let mut calldata: core::array::Array<felt252> = core::array::ArrayTrait::new();
{calldata_serialization_str}
starknet::syscalls::deploy_syscall(
deployment_info.class_hash,
deployment_info.contract_address_salt,
core::array::ArrayTrait::span(@calldata),
deployment_info.deploy_from_zero,
)
}}
corelib/src/starknet.cairo
line 161 at r4 (raw file):
pub contract_address_salt: felt252, pub deploy_from_zero: bool, }
if you plan for this to be the way for performing deployment in general - add doc - and doc all the fields further.
additionally shorten names,
and move to new deployment.cairo
.
(do add a pub use deployment::DeploymentInfo;
)
Suggestion:
/// Configuration for contract deployment
///
/// This structure contains all parameters needed to deploy a new contract instance
/// It is used by typed deployment function generated by starknet cairo plugin
#[derive(Drop, Copy, Debug, PartialEq, Serde)]
pub struct DeploymentInfo {
/// The class hash of the contract to be deployed.
pub class_hash: starknet::ClassHash,
/// The salt, an arbitrary value provided by the deployer, used in the computation of the contract's address.
pub salt: felt252,
/// Deploy the contract from the zero address.
pub deploy_from_zero: bool,
}
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: 1 of 5 files reviewed, 5 unresolved discussions (waiting on @kkawula)
a discussion (no related file):
Previously, orizi wrote…
additionally change tests in
crates/cairo-lang-starknet/cairo_level_tests/deployment.cairo
.
still - update the test to show the actual usage of this.
Naming of this is bit confusing to me, it looks like something that would be returned, not accepted by a function. Maybe |
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: 1 of 5 files reviewed, 7 unresolved discussions (waiting on @kkawula and @orizi)
crates/cairo-lang-starknet/src/plugin/starknet_module/contract.rs
line 412 at r4 (raw file):
RewriteNode::Text(formatdoc!( " pub fn deploy_custom(
Can we rename this? Not sure what's a proper name for this, but even deploy_with_details
sounds better to me. deploy_custom
is quite cryptic in what it does.
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 all commit messages.
Reviewable status: 1 of 5 files reviewed, 7 unresolved discussions (waiting on @cptartur and @kkawula)
corelib/src/starknet.cairo
line 157 at r4 (raw file):
Previously, cptartur (Artur Michałek) wrote…
Naming of this is bit confusing to me, it looks like something that would be returned, not accepted by a function. Maybe
DeploymentDetails
or something else?
DeploymentParams
?
a7d0d33
to
a30869c
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.
Reviewable status: 1 of 6 files reviewed, 7 unresolved discussions (waiting on @cptartur and @orizi)
a discussion (no related file):
Previously, orizi wrote…
still - update the test to show the actual usage of this.
Added, I didn't get used to reviewable that's why I missed your comment
corelib/src/starknet.cairo
line 157 at r4 (raw file):
Previously, orizi wrote…
DeploymentParams
?
Renamed to DeploymenetParams
, imo fits well with renamed function
crates/cairo-lang-starknet/src/plugin/plugin_test_data/contracts/storage_accesses
line 237 at r1 (raw file):
Previously, orizi wrote…
should not be generated - should be part of library code.
Done.
crates/cairo-lang-starknet/src/plugin/starknet_module/contract.rs
line 361 at r3 (raw file):
Previously, orizi wrote…
doc
Done.
crates/cairo-lang-starknet/src/plugin/starknet_module/contract.rs
line 412 at r4 (raw file):
Previously, cptartur (Artur Michałek) wrote…
Can we rename this? Not sure what's a proper name for this, but even
deploy_with_details
sounds better to me.deploy_custom
is quite cryptic in what it does.
Renamed
crates/cairo-lang-starknet/src/plugin/starknet_module/contract.rs
line 442 at r4 (raw file):
Previously, orizi wrote…
add a helper to create the basic
DeploymentInfo
from a ClassHashor just add a
#[cfg(feature: "test")]fn deploy_for_testing..`
with no params and the test class hash.
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.
Reviewable status: 1 of 11 files reviewed, 7 unresolved discussions (waiting on @cptartur and @orizi)
corelib/src/starknet.cairo
line 161 at r4 (raw file):
Previously, orizi wrote…
if you plan for this to be the way for performing deployment in general - add doc - and doc all the fields further.
additionally shorten names,
and move to newdeployment.cairo
.
(do add apub use deployment::DeploymentInfo;
)
I hope that docs are right now.
No description provided.