Skip to content
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

feat(starknet_consensus_orchestrator): pass central objects from batcher to cende #3384

Merged

Conversation

Yael-Starkware
Copy link
Contributor

No description provided.

@reviewable-StarkWare
Copy link

This change is Reviewable

Copy link
Contributor Author

@Yael-Starkware Yael-Starkware left a 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 7 files reviewed, 1 unresolved discussion (waiting on @dafnamatsry and @DvirYo-starkware)


crates/starknet_batcher_types/src/batcher_types.rs line 93 at r1 (raw file):

}

#[derive(Clone, Debug, Serialize, Deserialize, PartialEq)]

I spoke to @Itay-Tsabary-Starkware , and he approved that all derive(Clone) can be removed from this file.

Code quote:

Clone, 

Copy link
Contributor

@DvirYo-starkware DvirYo-starkware left a 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 r1, all commit messages.
Reviewable status: all files reviewed, 8 unresolved discussions (waiting on @dafnamatsry and @Yael-Starkware)


crates/sequencing/papyrus_consensus_orchestrator/src/cende/mod.rs line 39 at r1 (raw file):

    transactions: Vec<CentralTransactionWritten>,
    execution_infos: Vec<CentralTransactionExecutionInfo>,
    bouncer_weights: BouncerWeights,

Move this to before the transactions fields

Code quote:

bouncer_weights: BouncerWeights,

crates/sequencing/papyrus_consensus_orchestrator/src/cende/mod.rs line 196 at r1 (raw file):

    pub(crate) transactions: Vec<Transaction>,
    pub(crate) execution_infos: Vec<TransactionExecutionInfo>,
    pub(crate) bouncer_weights: BouncerWeights,
  1. also here move before transaction fields.
  2. add a comment or create a type alias type CentralBouncerWeights = BouncerWeight to be clear that "by mistake" the Rust struct is good for us.

Code quote:

pub(crate) bouncer_weights: BouncerWeights

crates/starknet_batcher_types/Cargo.toml line 16 at r1 (raw file):

[dependencies]
async-trait.workspace = true
blockifier = { workspace = true, features = ["transaction_serde"] }

Can you remind me again what this feature means?

Code quote:

features = ["transaction_serde"]

crates/starknet_batcher/src/batcher.rs line 430 at r1 (raw file):

        .await?;
        let execution_infos: Vec<_> =
            block_execution_artifacts.execution_infos.into_iter().map(|(_, info)| info).collect();

We need to get the execution info in the same order as the transactions in the block.
If we can sort them, the batcher would be the best, but I don't know if this information is available for the batcher. Another solution could be to pass them with the hashes to Cende, and it will sort them.

Code quote:

        let execution_infos: Vec<_> =
            block_execution_artifacts.execution_infos.into_iter().map(|(_, info)| info).collect();

crates/sequencing/papyrus_consensus_orchestrator/src/sequencer_consensus_context.rs line 389 at r1 (raw file):

                state_diff,
                transactions,
                execution_infos: *execution_infos,

I think you don't need the Box in the enum and thus do not need the * here.
Vector is already pointer to the heap so it should be of fixed small size on the stack.

Code quote:

execution_infos: *execution_infos

crates/starknet_batcher_types/src/batcher_types.rs line 2 at r1 (raw file):

use std::fmt::Debug;

Add a TODO to create the new crate with the blockifier api.


crates/starknet_batcher_types/src/batcher_types.rs line 96 at r1 (raw file):

#[derive(Debug, Serialize, Deserialize, PartialEq)]
pub struct CentralObjects {

As I said above, I don't think you need the Box here.

Copy link
Contributor

@DvirYo-starkware DvirYo-starkware left a 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, 9 unresolved discussions (waiting on @dafnamatsry and @Yael-Starkware)


a discussion (no related file):
In addition, we also need to get the compressed state diff from the batcher. It can be done in a different PR if you prefer.

@Yael-Starkware Yael-Starkware force-pushed the yael/central_execution_info_testing2 branch from a42a94f to 73a72a0 Compare January 19, 2025 07:19
Copy link
Contributor Author

@Yael-Starkware Yael-Starkware left a 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, 9 unresolved discussions (waiting on @dafnamatsry and @DvirYo-starkware)


crates/sequencing/papyrus_consensus_orchestrator/src/sequencer_consensus_context.rs line 389 at r1 (raw file):

Previously, DvirYo-starkware wrote…

I think you don't need the Box in the enum and thus do not need the * here.
Vector is already pointer to the heap so it should be of fixed small size on the stack.

I need the box since I get a warning, but you are right, it is not specific for the execution_info, I moved it to point on the entire CentralObjects.
Done.


crates/sequencing/papyrus_consensus_orchestrator/src/cende/mod.rs line 39 at r1 (raw file):

Previously, DvirYo-starkware wrote…

Move this to before the transactions fields

not sure why, but ok done.


crates/sequencing/papyrus_consensus_orchestrator/src/cende/mod.rs line 196 at r1 (raw file):

Previously, DvirYo-starkware wrote…
  1. also here move before transaction fields.
  2. add a comment or create a type alias type CentralBouncerWeights = BouncerWeight to be clear that "by mistake" the Rust struct is good for us.

Done.


crates/starknet_batcher/src/batcher.rs line 430 at r1 (raw file):

Previously, DvirYo-starkware wrote…

We need to get the execution info in the same order as the transactions in the block.
If we can sort them, the batcher would be the best, but I don't know if this information is available for the batcher. Another solution could be to pass them with the hashes to Cende, and it will sort them.

The order of the execution info is already in the same order as the transactions in the block as the block_builder built it, and is stored in an indexmap, which keeps this order:
please see

async fn collect_execution_results_and_stream_txs(


crates/starknet_batcher_types/Cargo.toml line 16 at r1 (raw file):

Previously, DvirYo-starkware wrote…

Can you remind me again what this feature means?

it is needed in order to derive deserialize,
for some unknown reason - that is the way this implement it in the blockifier, may worth clarifying with Dori why .


crates/starknet_batcher_types/src/batcher_types.rs line 2 at r1 (raw file):

Previously, DvirYo-starkware wrote…

Add a TODO to create the new crate with the blockifier api.

there is a monday task :
https://starkware.monday.com/boards/8251190975/pulses/8127522567


crates/starknet_batcher_types/src/batcher_types.rs line 96 at r1 (raw file):

Previously, DvirYo-starkware wrote…

As I said above, I don't think you need the Box here.

replied above

@Yael-Starkware Yael-Starkware force-pushed the yael/central_execution_info_testing2 branch from 73a72a0 to 009aef5 Compare January 19, 2025 10:06
@Yael-Starkware Yael-Starkware force-pushed the yael/pass_central_objects_from_batcher_to_cende branch from 89ce8a3 to eb1832f Compare January 19, 2025 10:06
@Yael-Starkware Yael-Starkware force-pushed the yael/central_execution_info_testing2 branch from 009aef5 to 5e8456b Compare January 19, 2025 12:34
@Yael-Starkware Yael-Starkware force-pushed the yael/pass_central_objects_from_batcher_to_cende branch from eb1832f to 978f677 Compare January 19, 2025 12:36
@Yael-Starkware Yael-Starkware force-pushed the yael/central_execution_info_testing2 branch from 5e8456b to c48a6ac Compare January 19, 2025 13:56
@Yael-Starkware Yael-Starkware force-pushed the yael/pass_central_objects_from_batcher_to_cende branch from 978f677 to 9981c23 Compare January 19, 2025 13:58
Copy link
Contributor Author

@Yael-Starkware Yael-Starkware left a 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 9 files reviewed, 9 unresolved discussions (waiting on @dafnamatsry and @DvirYo-starkware)


a discussion (no related file):

Previously, DvirYo-starkware wrote…

In addition, we also need to get the compressed state diff from the batcher. It can be done in a different PR if you prefer.

will do in a separate PR

Copy link
Contributor

@DvirYo-starkware DvirYo-starkware left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Reviewed 3 of 7 files at r2, 1 of 3 files at r3, 3 of 3 files at r4, all commit messages.
Reviewable status: 8 of 9 files reviewed, 5 unresolved discussions (waiting on @dafnamatsry and @Yael-Starkware)


crates/sequencing/papyrus_consensus_orchestrator/src/sequencer_consensus_context.rs line 389 at r1 (raw file):

Previously, Yael-Starkware (YaelD) wrote…

I need the box since I get a warning, but you are right, it is not specific for the execution_info, I moved it to point on the entire CentralObjects.
Done.

I checked that. The size of the variant DecisionReached(BatcherResult<DecisionReachedResponse>) is 544 bytes (the second largest variant is 40 bytes).
the 544 bytes is as follow:

  • ThinStateDiff is 384
  • BouncerWeights is 128
  • Vec<TransactionExecutionInfo> is 24
  • GasAmount is 8

the problem is not the CentralObject. We should make all the DecisionReachedResponse in a Box and not the CentralObject


crates/starknet_batcher/src/batcher.rs line 430 at r1 (raw file):

Previously, Yael-Starkware (YaelD) wrote…

The order of the execution info is already in the same order as the transactions in the block as the block_builder built it, and is stored in an indexmap, which keeps this order:
please see

async fn collect_execution_results_and_stream_txs(

Because you use IndexMap? It's worth adding a test for that. If the transactions that we send to the recorder are not in the correct order, that is a big bug in starkness.


crates/sequencing/papyrus_consensus_orchestrator/src/cende/mod.rs line 31 at r4 (raw file):

use url::Url;

type CentralBouncerWeights = BouncerWeights;

Move this to the central objects module.

Code quote:

type CentralBouncerWeights = BouncerWeights;

@Yael-Starkware Yael-Starkware force-pushed the yael/central_execution_info_testing2 branch from c48a6ac to 23a612e Compare January 21, 2025 07:25
@Yael-Starkware Yael-Starkware force-pushed the yael/pass_central_objects_from_batcher_to_cende branch from 9981c23 to b4519ca Compare January 21, 2025 07:44
Copy link
Contributor Author

@Yael-Starkware Yael-Starkware left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Reviewable status: 3 of 11 files reviewed, 4 unresolved discussions (waiting on @dafnamatsry and @DvirYo-starkware)


crates/sequencing/papyrus_consensus_orchestrator/src/sequencer_consensus_context.rs line 389 at r1 (raw file):

Previously, DvirYo-starkware wrote…

I checked that. The size of the variant DecisionReached(BatcherResult<DecisionReachedResponse>) is 544 bytes (the second largest variant is 40 bytes).
the 544 bytes is as follow:

  • ThinStateDiff is 384
  • BouncerWeights is 128
  • Vec<TransactionExecutionInfo> is 24
  • GasAmount is 8

the problem is not the CentralObject. We should make all the DecisionReachedResponse in a Box and not the CentralObject

I agree that this is a better option.
Done.


crates/sequencing/papyrus_consensus_orchestrator/src/cende/mod.rs line 31 at r4 (raw file):

Previously, DvirYo-starkware wrote…

Move this to the central objects module.

Done.


crates/starknet_batcher/src/batcher.rs line 430 at r1 (raw file):

Previously, DvirYo-starkware wrote…

Because you use IndexMap? It's worth adding a test for that. If the transactions that we send to the recorder are not in the correct order, that is a big bug in starkness.

what exactly do you want me to test?
that indexmap keeps the order of insertion?

I can pass the tx_hashes if we think it's safer. now you made me worried about this.

Copy link
Contributor

@DvirYo-starkware DvirYo-starkware left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Reviewed 8 of 8 files at r5, all commit messages.
Reviewable status: all files reviewed, 3 unresolved discussions (waiting on @dafnamatsry and @Yael-Starkware)


crates/starknet_batcher/src/batcher.rs line 430 at r1 (raw file):

Previously, Yael-Starkware (YaelD) wrote…

what exactly do you want me to test?
that indexmap keeps the order of insertion?

I can pass the tx_hashes if we think it's safer. now you made me worried about this.

I am afraid that someone in the future will change something in the batcher that doesn't save the order of transactions (for example, use a hash map instead of an index map).

  1. Document in the API of the batcher that the transaction returns in the order of the block
  2. Add a test to ensure that the execution information returned is in the order of the block. Create a batcher, pass him transactions, call desiction_reached, and check that the order of the exec info is as expected.

crates/starknet_batcher_types/src/communication.rs line 107 at r5 (raw file):

    ValidateBlock(BatcherResult<()>),
    SendProposalContent(BatcherResult<SendProposalContentResponse>),
    StartHeight(BatcherResult<()>),

See how it is done in the link. there is some weird trick with Box on the types crates.

Copy link
Contributor

@DvirYo-starkware DvirYo-starkware left a 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, 4 unresolved discussions (waiting on @dafnamatsry and @Yael-Starkware)


crates/starknet_batcher_types/src/batcher_types.rs line 97 at r5 (raw file):

#[derive(Debug, Serialize, Deserialize, PartialEq)]
pub struct CentralObjects {
    // The box is required because the object is big and causes a large variance in enum size.

remove this

Code quote:

// The box is required because the object is big and causes a large variance in enum size.

@Yael-Starkware Yael-Starkware force-pushed the yael/central_execution_info_testing2 branch 3 times, most recently from 6c5a4af to 5e1b2c6 Compare January 22, 2025 06:02
@Yael-Starkware Yael-Starkware force-pushed the yael/pass_central_objects_from_batcher_to_cende branch from b4519ca to b864072 Compare January 22, 2025 06:16
Copy link
Contributor Author

@Yael-Starkware Yael-Starkware left a 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 14 files reviewed, 4 unresolved discussions (waiting on @dafnamatsry and @DvirYo-starkware)


crates/starknet_batcher/src/batcher.rs line 430 at r1 (raw file):

Previously, DvirYo-starkware wrote…

I am afraid that someone in the future will change something in the batcher that doesn't save the order of transactions (for example, use a hash map instead of an index map).

  1. Document in the API of the batcher that the transaction returns in the order of the block
  2. Add a test to ensure that the execution information returned is in the order of the block. Create a batcher, pass him transactions, call desiction_reached, and check that the order of the exec info is as expected.

ok, will do it in a separate PR :
moday task : https://starkware.monday.com/boards/8251190975/pulses/8296565726


crates/starknet_batcher_types/src/batcher_types.rs line 97 at r5 (raw file):

Previously, DvirYo-starkware wrote…

remove this

Done.


crates/starknet_batcher_types/src/communication.rs line 107 at r5 (raw file):

Previously, DvirYo-starkware wrote…

See how it is done in the link. there is some weird trick with Box on the types crates.

Done.

@Yael-Starkware Yael-Starkware force-pushed the yael/pass_central_objects_from_batcher_to_cende branch from b864072 to 6f39759 Compare January 22, 2025 06:20
Copy link

Benchmark movements:
tree_computation_flow performance improved 😺
tree_computation_flow time: [34.800 ms 34.831 ms 34.864 ms]
change: [-4.3749% -2.7802% -1.3546%] (p = 0.00 < 0.05)
Performance has improved.
Found 6 outliers among 100 measurements (6.00%)
6 (6.00%) high mild

@Yael-Starkware Yael-Starkware changed the title feat(sequencing): pass central objects from batcher to cende feat(starknet_consensus_orchestrator): pass central objects from batcher to cende Jan 22, 2025
@Yael-Starkware Yael-Starkware force-pushed the yael/pass_central_objects_from_batcher_to_cende branch from 6f39759 to 0fdff97 Compare January 22, 2025 06:37
Copy link

Benchmark movements:
tree_computation_flow performance improved 😺
tree_computation_flow time: [34.782 ms 34.815 ms 34.850 ms]
change: [-4.1179% -2.5804% -1.2192%] (p = 0.00 < 0.05)
Performance has improved.
Found 13 outliers among 100 measurements (13.00%)
10 (10.00%) high mild
3 (3.00%) high severe

Copy link
Contributor

@DvirYo-starkware DvirYo-starkware left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

:lgtm:

Reviewed 7 of 13 files at r6, 1 of 1 files at r7, all commit messages.
Reviewable status: 9 of 14 files reviewed, 1 unresolved discussion (waiting on @dafnamatsry and @Yael-Starkware)

@Yael-Starkware Yael-Starkware force-pushed the yael/pass_central_objects_from_batcher_to_cende branch from 0fdff97 to 813751e Compare January 22, 2025 12:14
@Yael-Starkware Yael-Starkware changed the base branch from yael/central_execution_info_testing2 to main January 22, 2025 12:14
@Yael-Starkware Yael-Starkware force-pushed the yael/pass_central_objects_from_batcher_to_cende branch 2 times, most recently from 4ed0886 to e1e5269 Compare January 22, 2025 12:52
@Yael-Starkware Yael-Starkware force-pushed the yael/pass_central_objects_from_batcher_to_cende branch from e1e5269 to 29f0aca Compare January 22, 2025 12:53
Copy link
Contributor

@DvirYo-starkware DvirYo-starkware left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

:lgtm:

Reviewed 52 of 52 files at r8, all commit messages.
Reviewable status: :shipit: complete! all files reviewed, all discussions resolved (waiting on @dafnamatsry)

@Yael-Starkware Yael-Starkware added this pull request to the merge queue Jan 22, 2025
Merged via the queue into main with commit 6dffb41 Jan 22, 2025
20 checks passed
@github-actions github-actions bot locked and limited conversation to collaborators Jan 24, 2025
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants