Skip to content
Permalink

Comparing changes

This is a direct comparison between two commits made in this repository or its related repositories. View the default comparison for this range or learn more about diff comparisons.

Open a pull request

Create a new pull request by comparing changes across two branches. If you need to, you can also . Learn more about diff comparisons here.
base repository: starkware-libs/sequencer
Failed to load repositories. Confirm that selected base ref is valid, then try again.
Loading
base: 1f3a521c45affcae61362ce19323dd8edc5c1c2d
Choose a base ref
..
head repository: starkware-libs/sequencer
Failed to load repositories. Confirm that selected head ref is valid, then try again.
Loading
compare: 97e4c2f954014782666d731f1e0744907b5efc8c
Choose a head ref
Showing with 543 additions and 333 deletions.
  1. +8 −11 .github/workflows/blockifier_ci.yml
  2. +15 −2 .github/workflows/main.yml
  3. +3 −3 .github/workflows/papyrus_docker-publish.yml
  4. +3 −0 .gitignore
  5. +2 −0 Cargo.lock
  6. +33 −33 Cargo.toml
  7. +1 −1 build_native_blockifier.sh → build_native_blockifier_in_docker.sh
  8. +2 −0 commitlint.config.js
  9. +1 −1 crates/blockifier/Cargo.toml
  10. +1 −5 crates/blockifier/src/transaction/account_transaction.rs
  11. +2 −3 crates/committer/src/patricia_merkle_tree/node_data/inner_node.rs
  12. +6 −28 crates/committer/src/patricia_merkle_tree/original_skeleton_tree/create_tree_test.rs
  13. +23 −4 crates/committer/src/patricia_merkle_tree/original_skeleton_tree/skeleton_forest_test.rs
  14. +4 −2 crates/committer_cli/Cargo.toml
  15. +30 −14 crates/committer_cli/src/tests/regression_tests.rs
  16. +6 −6 crates/gateway/Cargo.toml
  17. +1 −1 crates/mempool/Cargo.toml
  18. +2 −2 crates/mempool_node/Cargo.toml
  19. +3 −5 crates/mempool_test_utils/Cargo.toml
  20. +1 −1 crates/mempool_types/Cargo.toml
  21. +18 −0 crates/native_blockifier/.cargo/config.toml
  22. +3 −5 crates/papyrus_base_layer/Cargo.toml
  23. +5 −5 crates/papyrus_common/Cargo.toml
  24. +3 −3 crates/papyrus_config/Cargo.toml
  25. +3 −3 crates/papyrus_execution/Cargo.toml
  26. +3 −3 crates/papyrus_load_test/Cargo.toml
  27. +1 −1 crates/papyrus_monitoring_gateway/Cargo.toml
  28. +10 −10 crates/papyrus_network/Cargo.toml
  29. +7 −7 crates/papyrus_node/Cargo.toml
  30. +2 −2 crates/papyrus_p2p_sync/Cargo.toml
  31. +2 −2 crates/papyrus_proc_macros/Cargo.toml
  32. +2 −2 crates/papyrus_protobuf/Cargo.toml
  33. +6 −6 crates/papyrus_rpc/Cargo.toml
  34. +7 −10 crates/papyrus_storage/Cargo.toml
  35. +8 −8 crates/papyrus_sync/Cargo.toml
  36. +4 −4 crates/papyrus_test_utils/Cargo.toml
  37. +2 −2 crates/sequencing/papyrus_block_builder/Cargo.toml
  38. +5 −3 crates/sequencing/papyrus_consensus/Cargo.toml
  39. +6 −3 crates/sequencing/papyrus_consensus/src/papyrus_consensus_context.rs
  40. +2 −1 crates/sequencing/papyrus_consensus/src/papyrus_consensus_context_test.rs
  41. +67 −48 crates/sequencing/papyrus_consensus/src/single_height_consensus.rs
  42. +157 −61 crates/sequencing/papyrus_consensus/src/single_height_consensus_test.rs
  43. +1 −0 crates/sequencing/papyrus_consensus/src/types.rs
  44. +0 −1 crates/starknet_api/Cargo.toml
  45. +4 −4 crates/starknet_client/Cargo.toml
  46. +3 −3 crates/starknet_sierra_compile/Cargo.toml
  47. +7 −7 crates/tests-integration/Cargo.toml
  48. +4 −4 rustfmt.toml
  49. +21 −0 scripts/build_native_blockifier.sh
  50. +27 −0 scripts/committer/generate_committer_flamegraph.sh
  51. +2 −1 scripts/merge_branches.py
  52. +2 −2 scripts/merge_status.py
  53. +2 −0 taplo.toml
19 changes: 8 additions & 11 deletions .github/workflows/blockifier_ci.yml
Original file line number Diff line number Diff line change
@@ -9,6 +9,9 @@ on:
- v[0-9].**
paths:
- 'crates/blockifier/**'
- 'crates/native_blockifier/**'
- 'build_native_blockifier_in_docker.sh'
- 'scripts/build_native_blockifier.sh'

pull_request:
types:
@@ -19,6 +22,9 @@ on:
- edited
paths:
- 'crates/blockifier/**'
- 'crates/native_blockifier/**'
- 'build_native_blockifier_in_docker.sh'
- 'scripts/build_native_blockifier.sh'

jobs:
featureless-build:
@@ -40,10 +46,10 @@ jobs:

- uses: Swatinem/rust-cache@v2
with:
prefix-key: "v0-rust-ubuntu-20.04"
prefix-key: "v1-rust-ubuntu-20.04"

- name: Build native blockifier
run: ./build_native_blockifier.sh
run: ./build_native_blockifier_in_docker.sh

# Commit hash on pull request event would be the head commit of the branch.
- name: Get commit hash prefix for PR update
@@ -77,12 +83,3 @@ jobs:
with:
path: "target/release/native_blockifier.pypy39-pp73-x86_64-linux-gnu.so"
destination: "native_blockifier_artifacts/${{ env.SHORT_HASH }}/release/"

# Keep the name 'udeps' to match original action name, so we don't need to define specific branch
# rules on Github for specific version branches.
udeps:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- name: Run Machete (detect unused dependencies)
uses: bnjbvr/cargo-machete@main
17 changes: 15 additions & 2 deletions .github/workflows/main.yml
Original file line number Diff line number Diff line change
@@ -28,14 +28,14 @@ jobs:
run: npm install --global @commitlint/cli @commitlint/config-conventional

- name: Validate PR commits with commitlint
if: github.event_name == 'pull_request' && !(contains(github.event.pull_request.title, '/merge-main') || contains(github.event.pull_request.title, '/merge main'))
if: github.event_name == 'pull_request' && !(contains(github.event.pull_request.title, 'merge-main') || contains(github.event.pull_request.title, 'merge main'))
env:
BASE_SHA: ${{ github.event.pull_request.base.sha }}
HEAD_SHA: ${{ github.event.pull_request.head.sha }}
run: commitlint --from "$BASE_SHA" --to "$HEAD_SHA" --verbose

- name: Validate PR title with commitlint
if: github.event_name != 'merge_group' && github.event_name != 'push' && !(contains(github.event.pull_request.title, '/merge-main') || contains(github.event.pull_request.title, '/merge main'))
if: github.event_name != 'merge_group' && github.event_name != 'push' && !(contains(github.event.pull_request.title, 'merge-main') || contains(github.event.pull_request.title, 'merge main'))
env:
TITLE: ${{ github.event.pull_request.title }}
run: echo "$TITLE" | commitlint --verbose
@@ -133,6 +133,19 @@ jobs:
env:
SEED: 0

taplo:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: dtolnay/rust-toolchain@stable
- uses: Swatinem/rust-cache@v2
- uses: baptiste0928/cargo-install@v3
with:
crate: taplo-cli
version: '0.9.0'
locked: true
- run: scripts/taplo.sh

machete:
runs-on: ubuntu-latest
steps:
6 changes: 3 additions & 3 deletions .github/workflows/papyrus_docker-publish.yml
Original file line number Diff line number Diff line change
@@ -37,8 +37,8 @@ jobs:
uses: docker/login-action@v2.1.0
with:
registry: ${{ env.REGISTRY }}
username: ${{ secrets.GHCR_USERNAME }}
password: ${{ secrets.GHCR_TOKEN }}
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}
logout: true

# Extract metadata (tags, labels) for Docker
@@ -47,7 +47,7 @@ jobs:
id: meta
uses: docker/metadata-action@v4.1.1
with:
images: ${{ env.REGISTRY }}/${{ env.REPO_NAME }}
images: ${{ env.REGISTRY }}/${{ env.REPO_NAME }}/papyrus
tags: |
type=semver,pattern={{raw}}
type=semver,pattern={{version}}
3 changes: 3 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -23,3 +23,6 @@ tmp_venv/*
/.vscode
# Git hooks
/.husky

# Python artifacts.
scripts/__pycache__
2 changes: 2 additions & 0 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

66 changes: 33 additions & 33 deletions Cargo.toml
Original file line number Diff line number Diff line change
@@ -4,39 +4,39 @@
resolver = "2"

members = [
"crates/batcher",
"crates/blockifier",
"crates/committer",
"crates/committer_cli",
"crates/gateway",
"crates/mempool",
"crates/mempool_infra",
"crates/mempool_node",
"crates/mempool_test_utils",
"crates/mempool_types",
"crates/native_blockifier",
"crates/papyrus_base_layer",
"crates/papyrus_common",
"crates/papyrus_config",
"crates/papyrus_execution",
"crates/papyrus_load_test",
"crates/papyrus_monitoring_gateway",
"crates/papyrus_network",
"crates/papyrus_node",
"crates/papyrus_p2p_sync",
"crates/papyrus_proc_macros",
"crates/papyrus_protobuf",
"crates/papyrus_rpc",
"crates/papyrus_storage",
"crates/papyrus_sync",
"crates/papyrus_test_utils",
"crates/sequencing/papyrus_block_builder",
"crates/sequencing/papyrus_consensus",
"crates/starknet_api",
"crates/starknet_client",
"crates/starknet_sierra_compile",
"crates/task_executor",
"crates/tests-integration",
"crates/batcher",
"crates/blockifier",
"crates/committer",
"crates/committer_cli",
"crates/gateway",
"crates/mempool",
"crates/mempool_infra",
"crates/mempool_node",
"crates/mempool_test_utils",
"crates/mempool_types",
"crates/native_blockifier",
"crates/papyrus_base_layer",
"crates/papyrus_common",
"crates/papyrus_config",
"crates/papyrus_execution",
"crates/papyrus_load_test",
"crates/papyrus_monitoring_gateway",
"crates/papyrus_network",
"crates/papyrus_node",
"crates/papyrus_p2p_sync",
"crates/papyrus_proc_macros",
"crates/papyrus_protobuf",
"crates/papyrus_rpc",
"crates/papyrus_storage",
"crates/papyrus_sync",
"crates/papyrus_test_utils",
"crates/sequencing/papyrus_block_builder",
"crates/sequencing/papyrus_consensus",
"crates/starknet_api",
"crates/starknet_client",
"crates/starknet_sierra_compile",
"crates/task_executor",
"crates/tests-integration",
]

[workspace.package]
Original file line number Diff line number Diff line change
@@ -13,4 +13,4 @@ docker run \
-v "${HOME}:${HOME}" \
--workdir ${PWD} \
${docker_image_name} \
cargo build --release -p native_blockifier --features "testing"
scripts/build_native_blockifier.sh
2 changes: 2 additions & 0 deletions commitlint.config.js
Original file line number Diff line number Diff line change
@@ -23,6 +23,7 @@ const Configuration = {
'batcher',
'block_builder',
'block_hash',
'blockifier',
'ci',
'common',
'concurrency',
@@ -44,6 +45,7 @@ const Configuration = {
'protobuf',
'release',
'skeleton',
'starknet_api',
'starknet_client',
'state',
'storage',
2 changes: 1 addition & 1 deletion crates/blockifier/Cargo.toml
Original file line number Diff line number Diff line change
@@ -38,7 +38,7 @@ num-integer.workspace = true
num-rational.workspace = true
num-traits.workspace = true
once_cell.workspace = true
papyrus_config = { path = "../papyrus_config", version = "0.4.0-rc.0"}
papyrus_config = { path = "../papyrus_config", version = "0.4.0-rc.0" }
paste.workspace = true
phf.workspace = true
rand = { workspace = true, optional = true }
6 changes: 1 addition & 5 deletions crates/blockifier/src/transaction/account_transaction.rs
Original file line number Diff line number Diff line change
@@ -75,11 +75,7 @@ impl HasRelatedFeeType for AccountTransaction {
match self {
Self::Declare(tx) => tx.tx.version(),
Self::DeployAccount(tx) => tx.tx.version(),
Self::Invoke(tx) => match tx.tx {
starknet_api::transaction::InvokeTransaction::V0(_) => TransactionVersion::ZERO,
starknet_api::transaction::InvokeTransaction::V1(_) => TransactionVersion::ONE,
starknet_api::transaction::InvokeTransaction::V3(_) => TransactionVersion::THREE,
},
Self::Invoke(tx) => tx.tx.version(),
}
}

Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
use ethnum::U256;
use strum_macros::{EnumDiscriminants, EnumIter};

use crate::felt::Felt;
use crate::hash::hash_trait::HashOutput;
@@ -12,8 +11,8 @@ use crate::patricia_merkle_tree::types::{NodeIndex, SubTreeHeight};
pub mod inner_node_test;

#[derive(Clone, Debug, PartialEq, Eq)]
#[cfg_attr(any(test, feature = "testing"), derive(EnumDiscriminants))]
#[cfg_attr(any(test, feature = "testing"), strum_discriminants(derive(EnumIter)))]
#[cfg_attr(any(test, feature = "testing"), derive(strum_macros::EnumDiscriminants))]
#[cfg_attr(any(test, feature = "testing"), strum_discriminants(derive(strum_macros::EnumIter)))]
// A Patricia-Merkle tree node's data, i.e., the pre-image of its hash.
pub enum NodeData<L: Leaf> {
Binary(BinaryData),
Original file line number Diff line number Diff line change
@@ -5,17 +5,15 @@ use pretty_assertions::assert_eq;
use rstest::rstest;

use super::OriginalSkeletonTreeImpl;
use crate::block_committer::input::StarknetStorageValue;
use crate::felt::Felt;
use crate::hash::hash_trait::HashOutput;
use crate::patricia_merkle_tree::filled_tree::node::{ClassHash, CompiledClassHash, Nonce};
use crate::patricia_merkle_tree::internal_test_utils::{
small_tree_index_to_full,
MockLeaf,
OriginalSkeletonMockTrieConfig,
};
use crate::patricia_merkle_tree::node_data::inner_node::{EdgePath, EdgePathLength, PathToBottom};
use crate::patricia_merkle_tree::node_data::leaf::{ContractState, LeafModifications};
use crate::patricia_merkle_tree::node_data::leaf::LeafModifications;
use crate::patricia_merkle_tree::original_skeleton_tree::create_tree::SubTree;
use crate::patricia_merkle_tree::original_skeleton_tree::node::OriginalSkeletonNode;
use crate::patricia_merkle_tree::original_skeleton_tree::tree::OriginalSkeletonTree;
@@ -137,9 +135,9 @@ use crate::storage::storage_trait::{create_db_key, StarknetPrefix, StorageKey, S
/// / \
/// 26 90
/// / / \
/// * 25 65
/// / 25 65
/// / \ / \
/// 24 * 6 59
/// 24 \ 6 59
/// / \ \ / / \
/// 11 13 20 5 19 40
///
@@ -151,9 +149,9 @@ use crate::storage::storage_trait::{create_db_key, StarknetPrefix, StorageKey, S
/// / \
/// E B
/// / / \
/// * E B
/// / E B
/// / \ / \
/// 24 * E B
/// 24 \ E B
/// \ / \
/// 20 5 40
#[case::tree_of_height_4_with_long_edge(
@@ -295,7 +293,7 @@ fn test_create_tree(
///
/// 1
/// / \
/// * *
/// ^ /
/// / \ /
/// 4 5 6
/// / \ / \ /
@@ -412,26 +410,6 @@ pub(crate) fn create_mock_leaf_entry(val: u128) -> (StorageKey, StorageValue) {
(leaf.get_db_key(&leaf.0.to_bytes_be()), leaf.serialize())
}

pub(crate) fn create_storage_leaf_entry(val: u128) -> (StorageKey, StorageValue) {
let leaf = StarknetStorageValue(Felt::from(val));
(leaf.get_db_key(&leaf.0.to_bytes_be()), leaf.serialize())
}

pub(crate) fn create_compiled_class_leaf_entry(val: u128) -> (StorageKey, StorageValue) {
let leaf = CompiledClassHash(Felt::from(val));
(leaf.get_db_key(&leaf.0.to_bytes_be()), leaf.serialize())
}

pub(crate) fn create_contract_state_leaf_entry(val: u128) -> (StorageKey, StorageValue) {
let felt = Felt::from(val);
let leaf = ContractState {
nonce: Nonce(felt),
storage_root_hash: HashOutput(felt),
class_hash: ClassHash(felt),
};
(leaf.get_db_key(&felt.to_bytes_be()), leaf.serialize())
}

fn create_patricia_key(val: u128) -> StorageKey {
create_db_key(StarknetPrefix::InnerNode.to_storage_prefix(), &U256::from(val).to_be_bytes())
}
Original file line number Diff line number Diff line change
@@ -21,19 +21,18 @@ use crate::patricia_merkle_tree::original_skeleton_tree::create_tree::create_tre
create_32_bytes_entry,
create_binary_entry,
create_binary_skeleton_node,
create_compiled_class_leaf_entry,
create_contract_state_leaf_entry,
create_edge_entry,
create_edge_skeleton_node,
create_expected_skeleton_nodes,
create_root_edge_entry,
create_storage_leaf_entry,
create_unmodified_subtree_skeleton_node,
};
use crate::patricia_merkle_tree::original_skeleton_tree::skeleton_forest::ForestSortedIndices;
use crate::patricia_merkle_tree::original_skeleton_tree::tree::OriginalSkeletonTreeImpl;
use crate::patricia_merkle_tree::types::{NodeIndex, SortedLeafIndices, SubTreeHeight};
use crate::storage::db_object::DBObject;
use crate::storage::map_storage::MapStorage;
use crate::storage::storage_trait::{StorageKey, StorageValue};

macro_rules! compare_skeleton_tree {
($actual_skeleton:expr, $expected_skeleton:expr, $expected_indices:expr) => {{
@@ -45,6 +44,26 @@ macro_rules! compare_skeleton_tree {
}};
}

pub(crate) fn create_storage_leaf_entry(val: u128) -> (StorageKey, StorageValue) {
let leaf = StarknetStorageValue(Felt::from(val));
(leaf.get_db_key(&leaf.0.to_bytes_be()), leaf.serialize())
}

pub(crate) fn create_compiled_class_leaf_entry(val: u128) -> (StorageKey, StorageValue) {
let leaf = CompiledClassHash(Felt::from(val));
(leaf.get_db_key(&leaf.0.to_bytes_be()), leaf.serialize())
}

pub(crate) fn create_contract_state_leaf_entry(val: u128) -> (StorageKey, StorageValue) {
let felt = Felt::from(val);
let leaf = ContractState {
nonce: Nonce(felt),
storage_root_hash: HashOutput(felt),
class_hash: ClassHash(felt),
};
(leaf.get_db_key(&felt.to_bytes_be()), leaf.serialize())
}

// This test assumes for simplicity that hash is addition (i.e hash(a,b) = a + b).
// I.e., the value of a binary node is the sum of its children's values, and the value of an edge
// node is the sum of its path, bottom value and path length.
@@ -92,7 +111,7 @@ macro_rules! compare_skeleton_tree {
/// / \ /
/// E E B
/// / \ / \
/// * B B E
/// / B B E
/// / / \ \
/// 303 NZ 47 UB
///
Loading