-
Notifications
You must be signed in to change notification settings - Fork 26
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(consensus): calculate the executable_transaction in consensus_context #2458
fix(consensus): calculate the executable_transaction in consensus_context #2458
Conversation
9713629
to
ab8d583
Compare
c461854
to
d90d875
Compare
Benchmark movements: |
d90d875
to
3f229bf
Compare
ab8d583
to
73c1991
Compare
3f229bf
to
a23e3cf
Compare
73c1991
to
71551ed
Compare
a23e3cf
to
3a3d2bf
Compare
Codecov ReportAttention: Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## main #2458 +/- ##
===========================================
- Coverage 40.10% 18.44% -21.66%
===========================================
Files 26 225 +199
Lines 1895 30735 +28840
Branches 1895 30735 +28840
===========================================
+ Hits 760 5670 +4910
- Misses 1100 24632 +23532
- Partials 35 433 +398 ☔ View full report in Codecov by Sentry. |
71551ed
to
f38cee5
Compare
3a3d2bf
to
0a4b210
Compare
Benchmark movements: |
605abe6
to
b411773
Compare
0a4b210
to
f377d1f
Compare
b411773
to
75de4cd
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 @alonh5, @guy-starkware, @matan-starkware, and @MohammadNassar1)
crates/papyrus_node/src/config/snapshots/papyrus_node__config__config_test__dump_default_config.snap.new
line at r1 (raw file):
Previously, alonh5 (Alon Haramati) wrote…
Why is there a new file in this PR?
yeah it seems like it slipped here by accident. removing.
Benchmark movements: |
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 @alonh5, @guy-starkware, and @matan-starkware)
crates/starknet_api/src/transaction.rs
line 142 at r1 (raw file):
Previously, Yael-Starkware (YaelD) wrote…
after digging into this function, it seems that a failure here indicates a bug in the code.
but I will double check this.
@MohammadNassar1 , I see your name on some of this code . how can this function fail?
The function fails when the transaction fields are inappropriate, such as invalid resources. It also fails if an incorrect format for the provided chain_id.
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 5 of 5 files at r2, all commit messages.
Reviewable status: all files reviewed, 5 unresolved discussions (waiting on @alonh5 and @guy-starkware)
crates/sequencing/papyrus_consensus_orchestrator/src/sequencer_consensus_context.rs
line 539 at r1 (raw file):
Previously, Yael-Starkware (YaelD) wrote…
This entire code does not return errors , only panics.
Panic can be handled as error when returning from the handle.join(), but in fact I couldn't find this handling in the code.
@matan-starkware can you explain how you handle these panics?
We don't handle panics as errors. We planned to map out the failure paths and break them into those that cause us to reach an invalid state (think the mutex on valid_proposals
being poisoned) or those that simply mean a specific flow failed. I was actually waiting for you to answer Alon's first question to comment here. As in:
- If building the executable TX means we received invalid input from the network then this just means this proposal is invalid and we want to handle that.
- If this instead points to an error within the node maybe it means we really do need to panic?
I can't answer how we should handle this failure since IDK what this failure means.
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 @alonh5, @guy-starkware, and @matan-starkware)
crates/starknet_api/src/transaction.rs
line 142 at r1 (raw file):
Previously, MohammadNassar1 (mohammad-starkware) wrote…
The function fails when the transaction fields are inappropriate, such as invalid resources. It also fails if an incorrect format for the provided chain_id.
After another look, the resources can no longer be invalid, as the resource mapping was updated from the old dictionary-based implementation to a struct-based approach.
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 @alonh5, @guy-starkware, and @matan-starkware)
crates/sequencing/papyrus_consensus_orchestrator/src/sequencer_consensus_context.rs
line 539 at r1 (raw file):
Previously, matan-starkware wrote…
We don't handle panics as errors. We planned to map out the failure paths and break them into those that cause us to reach an invalid state (think the mutex on
valid_proposals
being poisoned) or those that simply mean a specific flow failed. I was actually waiting for you to answer Alon's first question to comment here. As in:
- If building the executable TX means we received invalid input from the network then this just means this proposal is invalid and we want to handle that.
- If this instead points to an error within the node maybe it means we really do need to panic?
I can't answer how we should handle this failure since IDK what this failure means.
this specific failure means a real panic, specifically that the ChainId is illegal.
I'm asking cause I was searching the code to see where these errors are mapped to panic/invalid and couldn't find it. Now I understand that this part was not implemented yet, right?
crates/starknet_api/src/transaction.rs
line 142 at r1 (raw file):
Previously, MohammadNassar1 (mohammad-starkware) wrote…
After another look, the resources can no longer be invalid, as the resource mapping was updated from the old dictionary-based implementation to a struct-based approach.
Continuing the previous discussion:
So the conclusion is that this can only return error in case of invalid ChainId- which means the code should panic.
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 @alonh5, @guy-starkware, and @Yael-Starkware)
crates/sequencing/papyrus_consensus_orchestrator/src/sequencer_consensus_context.rs
line 539 at r1 (raw file):
Previously, Yael-Starkware (YaelD) wrote…
this specific failure means a real panic, specifically that the ChainId is illegal.
I'm asking cause I was searching the code to see where these errors are mapped to panic/invalid and couldn't find it. Now I understand that this part was not implemented yet, right?
Yep not implemented.
Ok so if this does not mean the TX was invalid then expect is good and we do not want to handle this.
crates/starknet_api/src/transaction.rs
line 142 at r1 (raw file):
Previously, Yael-Starkware (YaelD) wrote…
Continuing the previous discussion:
So the conclusion is that this can only return error in case of invalid ChainId- which means the code should panic.
Thanks @MohammadNassar1
crates/sequencing/papyrus_consensus_orchestrator/src/sequencer_consensus_context.rs
line 542 at r2 (raw file):
(tx, &chain_id) .try_into() .expect("Failed to convert transaction to executable_transation.")
Suggestion:
// An error means we have an invalid chain_id.
(tx, &chain_id)
.try_into()
.expect("Failed to convert transaction to executable_transation.")
c2c682d
to
c2a12a3
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: 5 of 6 files reviewed, 4 unresolved discussions (waiting on @alonh5, @guy-starkware, and @matan-starkware)
crates/sequencing/papyrus_consensus_orchestrator/src/sequencer_consensus_context.rs
line 539 at r1 (raw file):
Previously, matan-starkware wrote…
Yep not implemented.
Ok so if this does not mean the TX was invalid then expect is good and we do not want to handle this.
Done.
crates/sequencing/papyrus_consensus_orchestrator/src/sequencer_consensus_context.rs
line 542 at r2 (raw file):
(tx, &chain_id) .try_into() .expect("Failed to convert transaction to executable_transation.")
done
c2a12a3
to
6da7a51
Compare
Benchmark movements: |
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: 4 of 6 files reviewed, 4 unresolved discussions (waiting on @alonh5, @matan-starkware, and @Yael-Starkware)
crates/sequencing/papyrus_consensus_orchestrator/src/sequencer_consensus_context_test.rs
Show resolved
Hide resolved
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 5 files at r2, 2 of 2 files at r4, all commit messages.
Reviewable status: all files reviewed, 3 unresolved discussions (waiting on @matan-starkware and @Yael-Starkware)
crates/sequencing/papyrus_consensus_orchestrator/src/sequencer_consensus_context.rs
line 400 at r4 (raw file):
let chain_id = self.chain_id.clone(); let handle = tokio::spawn({
I don't think you need these brackets now.
Code quote:
{
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 r4, all commit messages.
Reviewable status: all files reviewed, 2 unresolved discussions (waiting on @Yael-Starkware)
6da7a51
to
f1fe5c1
Compare
Benchmark movements: |
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, 2 unresolved discussions (waiting on @guy-starkware)
crates/sequencing/papyrus_consensus_orchestrator/src/sequencer_consensus_context_test.rs
Show resolved
Hide resolved
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, 1 unresolved discussion (waiting on @guy-starkware)
crates/sequencing/papyrus_consensus_orchestrator/src/sequencer_consensus_context.rs
line 400 at r4 (raw file):
Previously, alonh5 (Alon Haramati) wrote…
I don't think you need these brackets now.
done
f1fe5c1
to
fd4efc9
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: 5 of 6 files reviewed, all discussions resolved (waiting on @alonh5 and @matan-starkware)
fd4efc9
to
0b267dd
Compare
Benchmark movements: |
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 r6, all commit messages.
Reviewable status: complete! all files reviewed, all discussions resolved (waiting on @matan-starkware)
chore(starknet_consensus_manager): add chain_id to config
feat(consensus): calculate the executable_transaction in consensus_context