-
Notifications
You must be signed in to change notification settings - Fork 37
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: create executable tx in the gateway process_tx #517
refactor: create executable tx in the gateway process_tx #517
Conversation
This stack of pull requests is managed by Graphite. Learn more about stacking. Join @ArniStarkware and the rest of your teammates on |
528f847
to
1bd225e
Compare
Previously, ArniStarkware (Arnon Hod) wrote…
Done. |
9a5d8bd
to
a5af9bc
Compare
1bd225e
to
ef4229f
Compare
a5af9bc
to
65e6550
Compare
eac85a8
to
9c0e1fa
Compare
65e6550
to
70056e5
Compare
9c0e1fa
to
cf3cdac
Compare
b0a4971
to
10fc2e9
Compare
cf3cdac
to
b056be0
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: all files reviewed, 6 unresolved discussions (waiting on @ArniStarkware, @ayeletstarkware, @MohammadNassar1, and @yair-starkware)
crates/gateway/src/gateway.rs
line 135 at r3 (raw file):
&tx, &gateway_compiler, &stateful_tx_validator.config.chain_info.chain_id,
Can you add a TODO to move the chain ID config out to the GW config?
Code quote:
&stateful_tx_validator.config.chain_info.chain_id,
crates/gateway/src/utils.rs
line 35 at r3 (raw file):
use crate::errors::{GatewaySpecError, StatefulTransactionValidatorResult}; pub fn external_tx_to_executable_tx(
Let's move all this code to SNAPI?
crates/gateway/src/utils.rs
line 35 at r3 (raw file):
use crate::errors::{GatewaySpecError, StatefulTransactionValidatorResult}; pub fn external_tx_to_executable_tx(
Here and everywhere else.
Suggestion:
rpc_tx_to_executable_tx
crates/gateway/src/utils.rs
line 58 at r3 (raw file):
fn external_declare_tx_to_executable_tx( external_tx: &RpcDeclareTransaction, gateway_compiler: &GatewayCompiler,
I think this function should get the compiled class_info
as an argument.
Convert functions shouldn't hide heavy stuff like compilation.
Code quote:
gateway_compiler: &GatewayCompiler,
crates/gateway/src/utils.rs
line 62 at r3 (raw file):
) -> Result<ExecutableDeclareTransaction, GatewaySpecError> { let class_info = gateway_compiler.process_declare_tx(external_tx)?; let RpcDeclareTransaction::V3(tx) = external_tx;
Just to make sure: if we add another version, i.e. RpcDecalareTransaction::V4
, this code won't compile right?
Code quote:
let RpcDeclareTransaction::V3(tx) = external_tx;
crates/gateway/src/utils.rs
line 65 at r3 (raw file):
let declare_tx = DeclareTransaction::V3(DeclareTransactionV3 { class_hash: ClassHash::default(), /* FIXME(yael 15/4/24): call the starknet-api * function once ready */
Is it ready?
Code quote:
class_hash: ClassHash::default(), /* FIXME(yael 15/4/24): call the starknet-api
* function once ready */
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: all files reviewed, 5 unresolved discussions (waiting on @ArniStarkware, @ayeletstarkware, @MohammadNassar1, and @yair-starkware)
crates/gateway/src/gateway.rs
line 135 at r3 (raw file):
Previously, dafnamatsry wrote…
Can you add a TODO to move the chain ID config out to the GW config?
Just noticed you added it in a following PR :)
10fc2e9
to
6bc63b8
Compare
b056be0
to
c993729
Compare
2f03898
to
6530a9d
Compare
e82a9c3
to
db406e5
Compare
6530a9d
to
6a113d0
Compare
db406e5
to
2c78330
Compare
6a113d0
to
12ec5d4
Compare
2c78330
to
2ea95c6
Compare
12ec5d4
to
001ac66
Compare
2ea95c6
to
8803f2b
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 9 files reviewed, 8 unresolved discussions (waiting on @ayeletstarkware, @dafnamatsry, @MohammadNassar1, and @yair-starkware)
crates/gateway/src/compilation.rs
line 33 at r10 (raw file):
Previously, dafnamatsry wrote…
You can do it as part of this PR.
No longer relevant.
crates/gateway/src/compilation.rs
line 60 at r10 (raw file):
Previously, dafnamatsry wrote…
Why did you change the return value?
The role of the compiler is to compile and shouldn't handle any other unrelated declare tx fields.
Please move the conversion logic tocompile_to_casm_and_convert_rpc_to_executable_tx
.
no longer relevant.
crates/gateway/src/gateway_test.rs
line 104 at r10 (raw file):
Previously, dafnamatsry wrote…
Can we calculate the hash without going through an
AccountTransaction
?Maybe you can use
rpc_tx.into().calculate_transaction_hash()
.
This function will be deleted. This is out of the scope of this PR.
crates/gateway/src/utils.rs
line 44 at r10 (raw file):
Previously, dafnamatsry wrote…
No need for the
map_err
right?Note that you are mapping a legitimate
CompilationFailed
andompiledClassHashMismatch
toUnexpectedError
.
Please add a test togateway_test
to make sure we return those errors.
Done.
001ac66
to
fb3deb5
Compare
8803f2b
to
ef6ffeb
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 7 of 7 files at r13, all commit messages.
Reviewable status: 8 of 9 files reviewed, 5 unresolved discussions (waiting on @ArniStarkware, @ayeletstarkware, @MohammadNassar1, and @yair-starkware)
crates/gateway/src/compilation.rs
line 36 at r13 (raw file):
} // TODO(Arni): Squash this function into `process_declare_tx`.
Remove :)
Code quote:
// TODO(Arni): Squash this function into `process_declare_tx`.
crates/gateway/src/compilation_test.rs
line 70 at r13 (raw file):
#[rstest] fn test_class_info_from_declare_tx_tx_success(
Suggestion:
test_process_declare_tx_success
crates/gateway/src/utils.rs
line 39 at r13 (raw file):
/// executable contract class. pub fn compile_contract_and_build_executable_tx( rpc_tx: RpcTransaction,
and then you won't need the clone in the gateway...
In general, I think in most cases we only want to pass references as function arguments (unless you want to enforce that an object can't be used after the function call).
Suggestion:
rpc_tx: &RpcTransaction,
crates/gateway/src/utils.rs
line 85 at r13 (raw file):
fn compile_contract_and_build_executable_declare_tx( rpc_tx: RpcDeclareTransaction,
Suggestion:
rpc_tx: &RpcDeclareTransaction,
fb3deb5
to
25c4fcd
Compare
ef6ffeb
to
865ec2d
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: 6 of 9 files reviewed, 5 unresolved discussions (waiting on @ayeletstarkware, @dafnamatsry, @MohammadNassar1, and @yair-starkware)
crates/gateway/src/compilation.rs
line 36 at r13 (raw file):
Previously, dafnamatsry wrote…
Remove :)
Done.
crates/gateway/src/compilation_test.rs
line 70 at r13 (raw file):
#[rstest] fn test_class_info_from_declare_tx_tx_success(
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 2 of 2 files at r14, all commit messages.
Reviewable status: 8 of 9 files reviewed, all discussions resolved (waiting on @ayeletstarkware, @MohammadNassar1, and @yair-starkware)
Previously, dafnamatsry wrote…
Discussed on DMs. Ignored. |
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 2 files at r8.
Reviewable status:complete! all files reviewed, all discussions resolved (waiting on @ayeletstarkware, @dafnamatsry, @MohammadNassar1, and @yair-starkware)
Merge activity
|
865ec2d
to
d6c9296
Compare
In this PR we create the
executable_tx
. This will be a member ofMempoolInput
.This change is