Skip to content

Commit

Permalink
Merge branch 'idan/main/add-sequencer-deployment-tools' of github.com…
Browse files Browse the repository at this point in the history
…:starkware-libs/sequencer into idan/main/add-sequencer-deployment-tools
  • Loading branch information
idan-starkware committed Nov 4, 2024
2 parents 620ca93 + 0b92b1e commit 638c476
Show file tree
Hide file tree
Showing 94 changed files with 1,439 additions and 879 deletions.
2 changes: 1 addition & 1 deletion Cargo.lock

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

4 changes: 2 additions & 2 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,6 @@ members = [
"crates/l1-provider",
"crates/mempool",
"crates/mempool_infra",
"crates/mempool_node",
"crates/mempool_p2p",
"crates/mempool_p2p_types",
"crates/mempool_test_utils",
Expand All @@ -39,6 +38,7 @@ members = [
"crates/papyrus_storage",
"crates/papyrus_sync",
"crates/papyrus_test_utils",
"crates/sequencer_node",
"crates/sequencing/papyrus_consensus",
"crates/sequencing/papyrus_consensus_orchestrator",
"crates/starknet_api",
Expand Down Expand Up @@ -218,7 +218,7 @@ starknet_mempool_types = { path = "crates/mempool_types", version = "0.0.0" }
starknet_monitoring_endpoint = { path = "crates/monitoring_endpoint", version = "0.0.0" }
starknet_patricia = { path = "crates/starknet_patricia", version = "0.0.0" }
starknet_sequencer_infra = { path = "crates/mempool_infra", version = "0.0.0" }
starknet_sequencer_node = { path = "crates/mempool_node", version = "0.0.0" }
starknet_sequencer_node = { path = "crates/sequencer_node", version = "0.0.0" }
starknet_sierra_compile = { path = "crates/starknet_sierra_compile", version = "0.0.0" }
starknet_task_executor = { path = "crates/task_executor", version = "0.0.0" }
static_assertions = "1.1.0"
Expand Down
68 changes: 39 additions & 29 deletions config/mempool/default_config.json
Original file line number Diff line number Diff line change
Expand Up @@ -81,13 +81,13 @@
},
"batcher_config.block_builder_config.chain_info.fee_token_addresses.eth_fee_token_address": {
"description": "Address of the ETH fee token.",
"privacy": "Public",
"value": "0x0"
"pointer_target": "eth_fee_token_address",
"privacy": "Public"
},
"batcher_config.block_builder_config.chain_info.fee_token_addresses.strk_fee_token_address": {
"description": "Address of the STRK fee token.",
"privacy": "Public",
"value": "0x0"
"pointer_target": "strk_fee_token_address",
"privacy": "Public"
},
"batcher_config.block_builder_config.execute_config.concurrency_config.chunk_size": {
"description": "The size of the transaction chunk executed in parallel.",
Expand Down Expand Up @@ -204,10 +204,10 @@
"privacy": "Public",
"value": 81920
},
"components.batcher.execution_mode.LocalExecution.enable_remote_connection": {
"description": "Specifies whether the component, when running locally, allows remote connections.",
"components.batcher.execution_mode": {
"description": "The component execution mode.",
"privacy": "Public",
"value": false
"value": "LocalExecutionWithRemoteDisabled"
},
"components.batcher.local_server_config.#is_none": {
"description": "Flag for an optional field.",
Expand Down Expand Up @@ -254,10 +254,10 @@
"privacy": "Public",
"value": "0.0.0.0:8080"
},
"components.consensus_manager.execution_mode.LocalExecution.enable_remote_connection": {
"description": "Specifies whether the component, when running locally, allows remote connections.",
"components.consensus_manager.execution_mode": {
"description": "The component execution mode.",
"privacy": "Public",
"value": false
"value": "LocalExecutionWithRemoteDisabled"
},
"components.consensus_manager.local_server_config.#is_none": {
"description": "Flag for an optional field.",
Expand Down Expand Up @@ -304,10 +304,10 @@
"privacy": "Public",
"value": "0.0.0.0:8080"
},
"components.gateway.execution_mode.LocalExecution.enable_remote_connection": {
"description": "Specifies whether the component, when running locally, allows remote connections.",
"components.gateway.execution_mode": {
"description": "The component execution mode.",
"privacy": "Public",
"value": false
"value": "LocalExecutionWithRemoteDisabled"
},
"components.gateway.local_server_config.#is_none": {
"description": "Flag for an optional field.",
Expand Down Expand Up @@ -354,10 +354,10 @@
"privacy": "Public",
"value": "0.0.0.0:8080"
},
"components.http_server.execution_mode.LocalExecution.enable_remote_connection": {
"description": "Specifies whether the component, when running locally, allows remote connections.",
"components.http_server.execution_mode": {
"description": "The component execution mode.",
"privacy": "Public",
"value": true
"value": "LocalExecutionWithRemoteEnabled"
},
"components.http_server.local_server_config.#is_none": {
"description": "Flag for an optional field.",
Expand Down Expand Up @@ -404,10 +404,10 @@
"privacy": "Public",
"value": "0.0.0.0:8080"
},
"components.mempool.execution_mode.LocalExecution.enable_remote_connection": {
"description": "Specifies whether the component, when running locally, allows remote connections.",
"components.mempool.execution_mode": {
"description": "The component execution mode.",
"privacy": "Public",
"value": false
"value": "LocalExecutionWithRemoteDisabled"
},
"components.mempool.local_server_config.#is_none": {
"description": "Flag for an optional field.",
Expand Down Expand Up @@ -454,10 +454,10 @@
"privacy": "Public",
"value": "0.0.0.0:8080"
},
"components.mempool_p2p.execution_mode.LocalExecution.enable_remote_connection": {
"description": "Specifies whether the component, when running locally, allows remote connections.",
"components.mempool_p2p.execution_mode": {
"description": "The component execution mode.",
"privacy": "Public",
"value": false
"value": "LocalExecutionWithRemoteDisabled"
},
"components.mempool_p2p.local_server_config.#is_none": {
"description": "Flag for an optional field.",
Expand Down Expand Up @@ -504,10 +504,10 @@
"privacy": "Public",
"value": "0.0.0.0:8080"
},
"components.monitoring_endpoint.execution_mode.LocalExecution.enable_remote_connection": {
"description": "Specifies whether the component, when running locally, allows remote connections.",
"components.monitoring_endpoint.execution_mode": {
"description": "The component execution mode.",
"privacy": "Public",
"value": true
"value": "LocalExecutionWithRemoteEnabled"
},
"components.monitoring_endpoint.local_server_config.#is_none": {
"description": "Flag for an optional field.",
Expand Down Expand Up @@ -594,20 +594,25 @@
"privacy": "Public",
"value": "0x0"
},
"eth_fee_token_address": {
"description": "A required param! Address of the ETH fee token.",
"param_type": "String",
"privacy": "TemporaryValue"
},
"gateway_config.chain_info.chain_id": {
"description": "The chain ID of the StarkNet chain.",
"pointer_target": "chain_id",
"privacy": "Public"
},
"gateway_config.chain_info.fee_token_addresses.eth_fee_token_address": {
"description": "Address of the ETH fee token.",
"privacy": "Public",
"value": "0x0"
"pointer_target": "eth_fee_token_address",
"privacy": "Public"
},
"gateway_config.chain_info.fee_token_addresses.strk_fee_token_address": {
"description": "Address of the STRK fee token.",
"privacy": "Public",
"value": "0x0"
"pointer_target": "strk_fee_token_address",
"privacy": "Public"
},
"gateway_config.stateful_tx_validator_config.max_nonce_for_validation_skip": {
"description": "Maximum nonce for which the validation is skipped.",
Expand Down Expand Up @@ -793,5 +798,10 @@
"description": "The url of the rpc server.",
"privacy": "Public",
"value": ""
},
"strk_fee_token_address": {
"description": "A required param! Address of the STRK fee token.",
"param_type": "String",
"privacy": "TemporaryValue"
}
}
19 changes: 19 additions & 0 deletions crates/batcher/src/batcher.rs
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,10 @@ use starknet_batcher_types::batcher_types::{
GetProposalContentInput,
GetProposalContentResponse,
ProposalId,
SendProposalContentInput,
SendProposalContentResponse,
StartHeightInput,
ValidateProposalInput,
};
use starknet_batcher_types::errors::BatcherError;
use starknet_mempool_types::communication::SharedMempoolClient;
Expand Down Expand Up @@ -99,6 +102,22 @@ impl Batcher {
Ok(())
}

#[instrument(skip(self), err)]
pub async fn validate_proposal(
&mut self,
validate_proposal_input: ValidateProposalInput,
) -> BatcherResult<()> {
todo!();
}

#[instrument(skip(self), err)]
pub async fn send_proposal_content(
&mut self,
send_proposal_content_input: SendProposalContentInput,
) -> BatcherResult<SendProposalContentResponse> {
todo!();
}

#[instrument(skip(self), err)]
pub async fn get_proposal_content(
&mut self,
Expand Down
6 changes: 3 additions & 3 deletions crates/batcher/src/block_builder.rs
Original file line number Diff line number Diff line change
Expand Up @@ -145,10 +145,10 @@ impl BlockBuilderTrait for BlockBuilder {
tx_provider: Box<dyn TransactionProvider>,
output_content_sender: tokio::sync::mpsc::UnboundedSender<Transaction>,
) -> BlockBuilderResult<BlockExecutionArtifacts> {
let mut should_close_block = false;
let mut block_is_full = false;
let mut execution_infos = IndexMap::new();
// TODO(yael 6/10/2024): delete the timeout condition once the executor has a timeout
while !should_close_block && tokio::time::Instant::now() < deadline {
while !block_is_full && tokio::time::Instant::now() < deadline {
let next_tx_chunk = tx_provider.get_txs(self.tx_chunk_size).await?;
debug!("Got {} transactions from the transaction provider.", next_tx_chunk.len());
if next_tx_chunk.is_empty() {
Expand All @@ -164,7 +164,7 @@ impl BlockBuilderTrait for BlockBuilder {
}
let results = self.executor.lock().await.add_txs_to_block(&executor_input_chunk);
trace!("Transaction execution results: {:?}", results);
should_close_block = collect_execution_results_and_stream_txs(
block_is_full = collect_execution_results_and_stream_txs(
next_tx_chunk,
results,
&mut execution_infos,
Expand Down
7 changes: 6 additions & 1 deletion crates/batcher/src/communication.rs
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,12 @@ impl ComponentRequestHandler<BatcherRequest, BatcherResponse> for Batcher {
BatcherRequest::DecisionReached(input) => {
BatcherResponse::DecisionReached(self.decision_reached(input).await)
}
_ => unimplemented!(),
BatcherRequest::ValidateProposal(input) => {
BatcherResponse::ValidateProposal(self.validate_proposal(input).await)
}
BatcherRequest::SendProposalContent(input) => {
BatcherResponse::SendProposalContent(self.send_proposal_content(input).await)
}
}
}
}
15 changes: 11 additions & 4 deletions crates/batcher/src/papyrus_state.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,10 @@
// TODO(yael 22/9/2024): This module is copied from native_blockifier, need to how to share it
// between the crates.
use blockifier::execution::contract_class::{ContractClass, ContractClassV0, ContractClassV1};
use blockifier::execution::contract_class::{
ContractClassV0,
ContractClassV1,
RunnableContractClass,
};
use blockifier::state::errors::StateError;
use blockifier::state::global_cache::GlobalContractCache;
use blockifier::state::state_api::{StateReader, StateResult};
Expand Down Expand Up @@ -40,7 +44,7 @@ impl PapyrusReader {
fn get_compiled_contract_class_inner(
&self,
class_hash: ClassHash,
) -> StateResult<ContractClass> {
) -> StateResult<RunnableContractClass> {
let state_number = StateNumber(self.latest_block);
let class_declaration_block_number = self
.reader()?
Expand All @@ -60,7 +64,7 @@ impl PapyrusReader {
inconsistent.",
);

return Ok(ContractClass::V1(ContractClassV1::try_from(casm_contract_class)?));
return Ok(RunnableContractClass::V1(ContractClassV1::try_from(casm_contract_class)?));
}

let v0_contract_class = self
Expand Down Expand Up @@ -118,7 +122,10 @@ impl StateReader for PapyrusReader {
}
}

fn get_compiled_contract_class(&self, class_hash: ClassHash) -> StateResult<ContractClass> {
fn get_compiled_contract_class(
&self,
class_hash: ClassHash,
) -> StateResult<RunnableContractClass> {
// Assumption: the global cache is cleared upon reverted blocks.
let contract_class = self.global_class_hash_to_class.get(&class_hash);

Expand Down
1 change: 1 addition & 0 deletions crates/batcher_types/src/batcher_types.rs
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,7 @@ pub enum GetProposalContent {
pub struct ValidateProposalInput {
pub proposal_id: ProposalId,
pub deadline: chrono::DateTime<Utc>,
pub retrospective_block_hash: Option<BlockHashAndNumber>,
}

impl BuildProposalInput {
Expand Down
4 changes: 2 additions & 2 deletions crates/blockifier/src/blockifier/transaction_executor_test.rs
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ use crate::test_utils::contracts::FeatureContract;
use crate::test_utils::declare::declare_tx;
use crate::test_utils::deploy_account::deploy_account_tx;
use crate::test_utils::initial_test_state::test_state;
use crate::test_utils::l1_handler::l1handler_tx;
use crate::test_utils::{
create_calldata,
maybe_dummy_block_hash_and_number,
Expand All @@ -38,7 +39,6 @@ use crate::transaction::test_utils::{
TestInitData,
};
use crate::transaction::transaction_execution::Transaction;
use crate::transaction::transactions::L1HandlerTransaction;
fn tx_executor_test_body<S: StateReader>(
state: CachedState<S>,
block_context: BlockContext,
Expand Down Expand Up @@ -230,7 +230,7 @@ fn test_l1_handler(block_context: BlockContext) {
let test_contract = FeatureContract::TestContract(CairoVersion::Cairo1);
let state = test_state(&block_context.chain_info, BALANCE, &[(test_contract, 1)]);

let tx = Transaction::L1Handler(L1HandlerTransaction::create_for_testing(
let tx = Transaction::L1Handler(l1handler_tx(
Fee(1908000000000000),
test_contract.get_instance_address(0),
));
Expand Down
6 changes: 3 additions & 3 deletions crates/blockifier/src/concurrency/fee_utils_test.rs
Original file line number Diff line number Diff line change
Expand Up @@ -16,20 +16,20 @@ use crate::transaction::objects::FeeType;
use crate::transaction::test_utils::{
account_invoke_tx,
block_context,
default_l1_resource_bounds,
default_all_resource_bounds,
};

#[rstest]
pub fn test_fill_sequencer_balance_reads(
block_context: BlockContext,
default_l1_resource_bounds: ValidResourceBounds,
default_all_resource_bounds: ValidResourceBounds,
#[values(CairoVersion::Cairo0, CairoVersion::Cairo1)] erc20_version: CairoVersion,
) {
let account = FeatureContract::AccountWithoutValidations(CairoVersion::Cairo1);
let account_tx = account_invoke_tx(invoke_tx_args! {
sender_address: account.get_instance_address(0),
calldata: create_trivial_calldata(account.get_instance_address(0)),
resource_bounds: default_l1_resource_bounds,
resource_bounds: default_all_resource_bounds,
});
let chain_info = &block_context.chain_info;
let state = &mut test_state_inner(chain_info, BALANCE, &[(account, 1)], erc20_version);
Expand Down
9 changes: 6 additions & 3 deletions crates/blockifier/src/concurrency/versioned_state.rs
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ use starknet_types_core::felt::Felt;

use crate::concurrency::versioned_storage::VersionedStorage;
use crate::concurrency::TxIndex;
use crate::execution::contract_class::ContractClass;
use crate::execution::contract_class::RunnableContractClass;
use crate::state::cached_state::{ContractClassMapping, StateMaps};
use crate::state::errors::StateError;
use crate::state::state_api::{StateReader, StateResult, UpdatableState};
Expand All @@ -34,7 +34,7 @@ pub struct VersionedState<S: StateReader> {
// the compiled contract classes mapping. Each key with value false, sohuld not apprear
// in the compiled contract classes mapping.
declared_contracts: VersionedStorage<ClassHash, bool>,
compiled_contract_classes: VersionedStorage<ClassHash, ContractClass>,
compiled_contract_classes: VersionedStorage<ClassHash, RunnableContractClass>,
}

impl<S: StateReader> VersionedState<S> {
Expand Down Expand Up @@ -336,7 +336,10 @@ impl<S: StateReader> StateReader for VersionedStateProxy<S> {
}
}

fn get_compiled_contract_class(&self, class_hash: ClassHash) -> StateResult<ContractClass> {
fn get_compiled_contract_class(
&self,
class_hash: ClassHash,
) -> StateResult<RunnableContractClass> {
let mut state = self.state();
match state.compiled_contract_classes.read(self.tx_index, class_hash) {
Some(value) => Ok(value),
Expand Down
Loading

0 comments on commit 638c476

Please sign in to comment.