Skip to content

Commit 0706c43

Browse files
authored
Merge branch 'main' into blacksmith_runners
2 parents 1fe4547 + e7b02e6 commit 0706c43

File tree

55 files changed

+1638
-573
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

55 files changed

+1638
-573
lines changed

.github/workflows/task-lint-cargo.yml

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -45,3 +45,13 @@ jobs:
4545
echo "Running cargo clippy..."
4646
cargo clippy --workspace --no-deps -- -D warnings
4747
cargo clippy --workspace --tests --no-deps -- -D warnings
48+
49+
# TODO(mehul 14/11/2025, hotfix): This is a temporary fix to ensure that the madara is linted.
50+
# Madara does not belong to the toplevel workspace, so we need to lint it separately.
51+
# Remove this once we add madara back to toplevel workspace.
52+
53+
echo "Running cargo clippy for madara..."
54+
cd madara
55+
cargo clippy --workspace --no-deps -- -D warnings
56+
cargo clippy --workspace --tests --no-deps -- -D warnings
57+
cd ..

.github/workflows/task-test-orchestrator.yml

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -118,7 +118,6 @@ jobs:
118118
--features testing \
119119
--lcov \
120120
--output-path lcov.info \
121-
--test-threads=1 \
122121
--package "orchestrator*" \
123122
--no-fail-fast
124123

.gitignore

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -105,4 +105,5 @@ s3
105105
# python virtual env
106106
.venv
107107

108-
sequencer_venv/
108+
sequencer_venv/
109+
sequencer_requirements.txt

Makefile

Lines changed: 60 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@ Targets:
1414

1515
[ SETUP ]
1616

17+
- setup-cairo Setup Cairo 0 environment for building
1718
- setup-l2 Setup orchestrator with L2 layer
1819
- setup-l2-localstack Setup orchestrator with L2 layer and Localstack
1920
- setup-l3 Setup orchestrator with L3 layer
@@ -69,6 +70,11 @@ Targets:
6970
- clean-db Perform clean and remove local database
7071
- fclean Perform clean-db and remove local images
7172

73+
[ BUILDING ]
74+
75+
- build-madara Build Madara with Cairo 0 environment setup
76+
- build-orchestrator Build Orchestrator with Cairo 0 environment setup
77+
7278
[ CODE QUALITY ]
7379

7480
Runs various code quality checks including formatting and linting.
@@ -103,6 +109,8 @@ DOCKER_TAG := madara:latest
103109
DOCKER_IMAGE := ghcr.io/madara-alliance/$(DOCKER_TAG)
104110
DOCKER_GZ := image.tar.gz
105111
ARTIFACTS := ./build-artifacts
112+
VENV := sequencer_venv
113+
VENV_ACTIVATE := . $(VENV)/bin/activate
106114

107115
# Configuration for E2E bridge tests
108116
CARGO_TARGET_DIR ?= target
@@ -195,9 +203,48 @@ artifacts:
195203
@git submodule update --init --recursive
196204
./scripts/artifacts.sh
197205

206+
.PHONY: setup-cairo
207+
setup-cairo:
208+
@echo -e "$(DIM)Setting up Cairo 0 environment...$(RESET)"
209+
@if [ ! -d "$(VENV)" ]; then \
210+
echo -e "$(INFO)Creating Python virtual environment...$(RESET)"; \
211+
python3 -m venv $(VENV); \
212+
else \
213+
echo -e "$(PASS)✅ Virtual environment already exists$(RESET)"; \
214+
fi
215+
@echo -e "$(INFO)Installing Cairo 0 dependencies...$(RESET)"
216+
@if [ ! -f sequencer_requirements.txt ]; then \
217+
CARGO_HOME=$${CARGO_HOME:-$$HOME/.cargo}; \
218+
GIT_CHECKOUTS=$$(readlink -f "$$CARGO_HOME/git" 2>/dev/null || echo "$$CARGO_HOME/git"); \
219+
SEQUENCER_REV=$$(grep -A 2 'name = "blockifier"' Cargo.lock | grep 'sequencer?rev=' | sed -E 's/.*rev=([a-f0-9]+).*/\1/' | cut -c1-7); \
220+
REQUIREMENTS_PATH=$$(find "$$GIT_CHECKOUTS/checkouts" -type f -path "*/sequencer*/$$SEQUENCER_REV*/scripts/requirements.txt" 2>/dev/null | head -n 1); \
221+
if [ -n "$$REQUIREMENTS_PATH" ]; then \
222+
sed 's/numpy==2.0.2/numpy<2.0/' "$$REQUIREMENTS_PATH" > sequencer_requirements.txt; \
223+
echo -e "$(INFO)Found requirements.txt at: $$REQUIREMENTS_PATH$(RESET)"; \
224+
else \
225+
echo -e "$(WARN)⚠️ WARNING: Could not find requirements.txt from sequencer checkout$(RESET)"; \
226+
echo -e "$(INFO)Creating basic requirements with cairo-lang...$(RESET)"; \
227+
echo "cairo-lang==0.14.0.1" > sequencer_requirements.txt; \
228+
echo "numpy<2.0" >> sequencer_requirements.txt; \
229+
fi; \
230+
fi
231+
@$(VENV_ACTIVATE) && pip install --upgrade pip > /dev/null 2>&1 && pip install -r sequencer_requirements.txt > /dev/null 2>&1
232+
@$(VENV_ACTIVATE) && cairo-compile --version > /dev/null 2>&1 && echo -e "$(PASS)✅ Cairo 0 environment ready (cairo-compile $$($(VENV_ACTIVATE) && cairo-compile --version 2>&1))$(RESET)" || (echo -e "$(WARN)❌ Cairo setup failed$(RESET)" && exit 1)
233+
234+
.PHONY: build-madara
235+
build-madara:
236+
@echo -e "$(DIM)Building Madara with Cairo 0 environment...$(RESET)"
237+
@$(VENV_ACTIVATE) && cargo build --manifest-path madara/Cargo.toml --bin madara --release
238+
@echo -e "$(PASS)✅ Build complete!$(RESET)"
239+
240+
.PHONY: build-orchestrator
241+
build-orchestrator: setup-cairo
242+
@echo -e "$(DIM)Building Orchestrator with Cairo 0 environment...$(RESET)"
243+
@$(VENV_ACTIVATE) && cargo build --bin orchestrator --release
244+
@echo -e "$(PASS)✅ Build complete!$(RESET)"
198245

199246
.PHONY: check
200-
check:
247+
check: setup-cairo
201248
@echo -e "$(DIM)Running code quality checks...$(RESET)"
202249
@echo -e "$(INFO)Running prettier check...$(RESET)"
203250
@npm install
@@ -206,20 +253,23 @@ check:
206253
@cargo fmt -- --check
207254
@echo -e "$(INFO)Running taplo fmt check...$(RESET)"
208255
@taplo fmt --config=./taplo/taplo.toml --check
209-
@echo -e "$(INFO)Running cargo clippy workspace checks...$(RESET)"
256+
@echo "Running cargo clippy..."
210257
@cargo clippy --workspace --no-deps -- -D warnings
211-
@echo -e "$(INFO)Running cargo clippy workspace tests...$(RESET)"
212258
@cargo clippy --workspace --tests --no-deps -- -D warnings
213-
@echo -e "$(INFO)Running cargo clippy with testing features...$(RESET)"
214-
@cargo clippy --workspace --exclude madara --features testing --no-deps -- -D warnings
215-
@echo -e "$(INFO)Running cargo clippy with testing features and tests...$(RESET)"
216-
@cargo clippy --workspace --exclude madara --features testing --tests --no-deps -- -D warnings
259+
@# TODO(mehul 14/11/2025, hotfix): This is a temporary fix to ensure that the madara is linted.
260+
@# Madara does not belong to the toplevel workspace, so we need to lint it separately.
261+
@# Remove this once we add madara back to toplevel workspace.
262+
@echo "Running cargo clippy for madara..."
263+
@cd madara && \
264+
cargo clippy --workspace --no-deps -- -D warnings && \
265+
cargo clippy --workspace --tests --no-deps -- -D warnings && \
266+
cd ..
217267
@echo -e "$(INFO)Running markdownlint check...$(RESET)"
218268
@npx markdownlint -c .markdownlint.json -q -p .markdownlintignore .
219269
@echo -e "$(PASS)All code quality checks passed!$(RESET)"
220270

221271
.PHONY: fmt
222-
fmt:
272+
fmt: setup-cairo
223273
@echo -e "$(DIM)Running code formatters...$(RESET)"
224274
@echo -e "$(INFO)Running taplo formatter...$(RESET)"
225275
@npm install
@@ -421,10 +471,10 @@ test: test-e2e test-orchestrator
421471
@echo -e "$(PASS)All tests completed!$(RESET)"
422472

423473
.PHONY: pre-push
424-
pre-push:
474+
pre-push: setup-cairo
425475
@echo -e "$(DIM)Running pre-push checks...$(RESET)"
426476
@echo -e "$(INFO)Running code quality checks...$(RESET)"
427-
@$(MAKE) --silent check
477+
@$(VENV_ACTIVATE) && $(MAKE) --silent check
428478
@echo -e "$(PASS)Pre-push checks completed successfully!$(RESET)"
429479

430480
.PHONY: git-hook

bootstrapper/src/configs/devnet.json

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,6 @@
33
"rollup_declare_v0_seq_url": "http://127.0.0.1:9943",
44
"eth_priv_key": "0xac0974bec39a17e36ba4a6b4d238ff944bacb478cbed5efcae784d7bf4f2ff80",
55
"config_hash_version": "StarknetOsConfig2",
6-
"l2_deployer_address": "0x055be462e718c4166d656d11f89e341115b8bc82389c3762a10eade04fcb225d",
76
"rollup_priv_key": "0x077e56c6dc32d40a67f6f7e6625c8dc5e570abe49c0a24e9202e4ae906abcc07",
87
"eth_chain_id": 31337,
98
"l1_deployer_address": "0xf39Fd6e51aad88F6F4ce6aB8827279cffFb92266",

bootstrapper/src/setup_scripts/udc.rs

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,9 @@ impl<'a> UdcSetup<'a> {
3939
Vec::from([udc_class_hash, Felt::ZERO, Felt::ONE, Felt::ZERO]),
4040
None,
4141
)
42+
.l1_gas(0)
43+
.l1_data_gas(0)
44+
.l2_gas(0)
4245
.send()
4346
.await
4447
.unwrap();

madara/clippy.toml

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
allow-print-in-tests = true
2+
allow-unwrap-in-tests = true
3+
4+
# Suppress large error type warnings - these are common with AWS SDK errors
5+
# and would require significant refactoring to fix properly
6+
too-large-for-stack = 1000
7+
8+
# Allow needless updates - sometimes used for clarity in struct initialization
9+
# Even when all fields are specified, ..Default::default() can make intent clearer
10+
11+
# Set a higher threshold for result-large-err to accommodate AWS SDK errors
12+
# which are inherently large due to comprehensive error handling
13+
type-complexity-threshold = 250

madara/crates/client/block_production/src/executor/mod.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,7 @@ pub enum ExecutorMessage {
4949
exec_ctx: BlockExecutionContext,
5050
},
5151
BatchExecuted(BatchExecutionResult),
52-
EndBlock(BlockExecutionSummary),
52+
EndBlock(Box<BlockExecutionSummary>),
5353
}
5454

5555
#[derive(Default, Debug)]

madara/crates/client/block_production/src/executor/thread.rs

Lines changed: 14 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -2,10 +2,10 @@
22
33
use crate::util::{create_execution_context, BatchToExecute, BlockExecutionContext, ExecutionStats};
44
use anyhow::Context;
5-
use blockifier::{blockifier::transaction_executor::TransactionExecutor, state::state_api::State};
5+
use blockifier::blockifier::transaction_executor::TransactionExecutor;
66
use futures::future::OptionFuture;
77
use mc_db::MadaraBackend;
8-
use mc_exec::{execution::TxInfo, LayeredStateAdapter, MadaraBackendExecutionExt};
8+
use mc_exec::{execution::TxInfo, LayeredStateAdapter};
99
use mp_convert::{Felt, ToFelt};
1010
use starknet_api::contract_class::ContractClass;
1111
use starknet_api::core::ClassHash;
@@ -220,29 +220,14 @@ impl ExecutorThread {
220220
previous_l2_gas_used,
221221
)?;
222222

223-
// Create the TransactionExecution, but reuse the layered_state_adapter.
224-
let mut executor =
225-
self.backend.new_executor_for_block_production(state.state_adaptor, exec_ctx.to_blockifier()?)?;
226-
227-
// Prepare the block_n-10 state diff entry on the 0x1 contract.
228-
if let Some((block_n_min_10, block_hash_n_min_10)) =
229-
self.wait_for_hash_of_block_min_10(exec_ctx.block_number)?
230-
{
231-
let contract_address = 1u64.into();
232-
let key = block_n_min_10.into();
233-
executor
234-
.block_state
235-
.as_mut()
236-
.expect("Blockifier block context has been taken")
237-
.set_storage_at(contract_address, key, block_hash_n_min_10)
238-
.context("Cannot set storage value in cache")?;
223+
// Create the TransactionExecutor with block_n-10 handling, reusing the layered_state_adapter.
224+
let executor = crate::util::create_executor_with_block_n_min_10(
225+
&self.backend,
226+
&exec_ctx,
227+
state.state_adaptor,
228+
|block_n| self.wait_for_hash_of_block_min_10(block_n),
229+
)?;
239230

240-
tracing::debug!(
241-
"State diff inserted {:#x} {:#x} => {block_hash_n_min_10:#x}",
242-
contract_address.to_felt(),
243-
key.to_felt()
244-
);
245-
}
246231
Ok(ExecutorStateExecuting {
247232
exec_ctx,
248233
executor,
@@ -433,7 +418,11 @@ impl ExecutorThread {
433418
);
434419
let block_exec_summary = execution_state.executor.finalize()?;
435420

436-
if self.replies_sender.blocking_send(super::ExecutorMessage::EndBlock(block_exec_summary)).is_err() {
421+
if self
422+
.replies_sender
423+
.blocking_send(super::ExecutorMessage::EndBlock(Box::new(block_exec_summary)))
424+
.is_err()
425+
{
437426
// Receiver closed
438427
break Ok(());
439428
}

0 commit comments

Comments
 (0)