-
Notifications
You must be signed in to change notification settings - Fork 21
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
refactor(transaction): make the only query field in declare tx public #170
refactor(transaction): make the only query field in declare tx public #170
Conversation
ebb40ea
to
03cc397
Compare
03cc397
to
906d838
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: 0 of 1 files reviewed, 1 unresolved discussion (waiting on @noaov1)
a discussion (no related file):
@tdelabro
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.
Doing this allow to create an incorrect declare transaction (we want to enforce calling verify_contract_class_version
).
Reviewed 1 of 1 files at r1, all commit messages.
Reviewable status: all files reviewed, 1 unresolved discussion (waiting on @noaov1)
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.
You can let the create
method be public. We may need to consider the necessity of the method new_for_query
(and maybe define new
only for tests).
Reviewable status: all files reviewed, 1 unresolved discussion (waiting on @noaov1)
906d838
to
d8c8b8d
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: 0 of 1 files reviewed, 2 unresolved discussions (waiting on @noaov1)
crates/blockifier/src/transaction/transactions.rs
line 136 at r2 (raw file):
pub tx_hash: TransactionHash, // Indicates the presence of the only_query bit in the version. only_query: bool,
Changing only query to a pub trait will allow users to create a Declare tx struct without using create. we want to enforce calling verify_contract_class_version
so it is problematic.
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 @noaov1)
crates/blockifier/src/transaction/transactions.rs
line 136 at r2 (raw file):
Previously, meship-starkware (Meshi Peled) wrote…
Changing only query to a pub trait will allow users to create a Declare tx struct without using create. we want to enforce calling
verify_contract_class_version
so it is problematic.
@tdelabro WDYT? Do you have another suggestion?
@meship-starkware You then need to be coherent and make it private for the other transactions types too |
d8c8b8d
to
f1a6805
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: 0 of 1 files reviewed, 3 unresolved discussions (waiting on @noaov1)
crates/blockifier/src/transaction/transactions.rs
line 292 at r2 (raw file):
// Indicates the presence of the only_query bit in the version. pub only_query: bool, }
This change means that we will have to create a Deploy Account tx using new and new for query.
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.
After some discussion, we decided that making it private is not a good solution because it is less readable, it is not clear why the only query is private there, and it is a breaking change. A solution that @noaov1 has suggested is making the only query public in declare but making the class info private. This is also a breaking change, but it makes more sense because the declare struct needs to be private because we need to check the class info in the constructor.
Reviewable status: 0 of 1 files reviewed, 3 unresolved discussions (waiting on @noaov1)
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.
making it private is not a good solution because it is less readable
What about adding a getter? tx.is_query()
is not less readable thattx.only_query
making the only query public in declare but making the class info private
@noaov1 has a good point that if we force users to use our create
method in order to check for the class_info
data, maybe we shouldn't allow users to change it's content afterward.
Note that the create method don't just use the class_info
fn create(
declare_tx: starknet_api::transaction::DeclareTransaction,
tx_hash: TransactionHash,
class_info: ClassInfo,
only_query: bool,
) -> TransactionExecutionResult<Self> {
let declare_version = declare_tx.version();
verify_contract_class_version(&class_info.contract_class(), declare_version)?;
Ok(Self { tx: declare_tx, tx_hash, class_info, only_query })
}
It uses data from both declare_tx
and class_info
to call verify_contract_class_version
, so those two fields should be private and only accessible through getters
Reviewable status: 0 of 1 files reviewed, 3 unresolved discussions (waiting on @noaov1)
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.
It will be solved in a future PR.
Reviewable status: 0 of 1 files reviewed, 3 unresolved discussions (waiting on @noaov1)
This change is