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

Merge main-v0.13.2 into main #169

Merged
merged 13 commits into from
Jul 29, 2024
Merged
Show file tree
Hide file tree
Changes from 12 commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 11 additions & 3 deletions .github/workflows/committer_ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ jobs:
credentials_json: ${{ secrets.COMMITER_PRODUCTS_EXT_WRITER_JSON }}
- uses: 'google-github-actions/setup-gcloud@v2'
- run: echo "OLD_BENCH_INPUT_FILES_PREFIX=$(cat ./crates/committer_cli/src/tests/flow_test_files_prefix)" >> $GITHUB_ENV
- run: gcloud storage cp -r gs://committer-testing-artifacts/$OLD_BENCH_INPUT_FILES_PREFIX/* ./crates/committer_cli/benches
- run: gcloud storage cp -r gs://committer-testing-artifacts/$OLD_BENCH_INPUT_FILES_PREFIX/* ./crates/committer_cli/test_inputs

# List the existing benchmarks.
- run: |
Expand All @@ -71,8 +71,8 @@ jobs:
- run: cargo bench -p committer_cli

# Backup the downloaded files to avoid re-downloading them if they didn't change (overwritten by checkout).
- run: mv ./crates/committer_cli/benches/tree_flow_inputs.json ./crates/committer_cli/benches/tree_flow_inputs.json_bu
- run: mv ./crates/committer_cli/benches/committer_flow_inputs.json ./crates/committer_cli/benches/committer_flow_inputs.json_bu
- run: mv ./crates/committer_cli/test_inputs/tree_flow_inputs.json ./crates/committer_cli/test_inputs/tree_flow_inputs.json_bu
- run: mv ./crates/committer_cli/test_inputs/committer_flow_inputs.json ./crates/committer_cli/test_inputs/committer_flow_inputs.json_bu

# Checkout the new code.
- uses: actions/checkout@v4
Expand All @@ -83,8 +83,16 @@ jobs:
# Input files didn't change.
- if: env.OLD_BENCH_INPUT_FILES_PREFIX == env.NEW_BENCH_INPUT_FILES_PREFIX
run: |
<<<<<<< HEAD
mv ./crates/committer_cli/benches/tree_flow_inputs.json_bu ./crates/committer_cli/test_inputs/tree_flow_inputs.json
mv ./crates/committer_cli/benches/committer_flow_inputs.json_bu ./crates/committer_cli/test_inputs/committer_flow_inputs.json
||||||| a9dc431b
mv ./crates/committer_cli/benches/tree_flow_inputs.json_bu ./crates/committer_cli/benches/tree_flow_inputs.json
mv ./crates/committer_cli/benches/committer_flow_inputs.json_bu ./crates/committer_cli/benches/committer_flow_inputs.json
=======
mv ./crates/committer_cli/test_inputs/tree_flow_inputs.json_bu ./crates/committer_cli/test_inputs/tree_flow_inputs.json
mv ./crates/committer_cli/test_inputs/committer_flow_inputs.json_bu ./crates/committer_cli/test_inputs/committer_flow_inputs.json
>>>>>>> origin/main-v0.13.2

# Input files did change, download new inputs.
- if: env.OLD_BENCH_INPUT_FILES_PREFIX != env.NEW_BENCH_INPUT_FILES_PREFIX
Expand Down
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
use std::collections::HashSet;

use cairo_vm::types::builtin_name::BuiltinName;
use cairo_vm::types::layout_name::LayoutName;
use cairo_vm::types::relocatable::{MaybeRelocatable, Relocatable};
Expand Down Expand Up @@ -29,6 +31,15 @@ pub struct VmExecutionContext<'a> {
pub entry_point_pc: usize,
}

pub const CAIRO0_BUILTINS_NAMES: [BuiltinName; 6] = [
BuiltinName::range_check,
BuiltinName::pedersen,
BuiltinName::ecdsa,
BuiltinName::bitwise,
BuiltinName::ec_op,
BuiltinName::poseidon,
];

/// Executes a specific call to a contract entry point and returns its output.
pub fn execute_entry_point_call(
call: CallEntryPoint,
Expand Down Expand Up @@ -71,9 +82,19 @@ pub fn initialize_execution_context<'a>(
resources: &'a mut ExecutionResources,
context: &'a mut EntryPointExecutionContext,
) -> Result<VmExecutionContext<'a>, PreExecutionError> {
// Verify use of cairo0 builtins only.
let program_builtins: HashSet<&BuiltinName> =
HashSet::from_iter(contract_class.program.iter_builtins());
let unsupported_builtins =
&program_builtins - &HashSet::from_iter(CAIRO0_BUILTINS_NAMES.iter());
if !unsupported_builtins.is_empty() {
return Err(PreExecutionError::UnsupportedCairo0Builtin(
unsupported_builtins.iter().map(|&item| *item).collect(),
));
}

// Resolve initial PC from EP indicator.
let entry_point_pc = resolve_entry_point_pc(call, &contract_class)?;

// Instantiate Cairo runner.
let proof_mode = false;
let trace_enabled = false;
Expand Down
5 changes: 5 additions & 0 deletions crates/blockifier/src/execution/errors.rs
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
use std::collections::HashSet;

use cairo_vm::types::builtin_name::BuiltinName;
use cairo_vm::types::errors::math_errors::MathError;
use cairo_vm::vm::errors::cairo_run_errors::CairoRunError;
use cairo_vm::vm::errors::memory_errors::MemoryError;
Expand Down Expand Up @@ -42,6 +45,8 @@ pub enum PreExecutionError {
StateError(#[from] StateError),
#[error("Requested contract address {:#064x} is not deployed.", .0.key())]
UninitializedStorageAddress(ContractAddress),
#[error("Called builtins: {0:?} are unsupported in a Cairo0 contract")]
UnsupportedCairo0Builtin(HashSet<BuiltinName>),
}

impl From<RunnerError> for PreExecutionError {
Expand Down
2 changes: 1 addition & 1 deletion crates/papyrus_monitoring_gateway/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -313,7 +313,7 @@ async fn node_config_by_secret(
async fn metrics(prometheus_handle: Option<PrometheusHandle>) -> Response {
match prometheus_handle {
Some(handle) => {
Collector::default().prefix(PROCESS_METRICS_PREFIX).collect();
Collector::new(PROCESS_METRICS_PREFIX).collect();
handle.render().into_response()
}
None => StatusCode::METHOD_NOT_ALLOWED.into_response(),
Expand Down
31 changes: 31 additions & 0 deletions crates/sequencing/papyrus_consensus/src/state_machine.rs
Original file line number Diff line number Diff line change
Expand Up @@ -17,11 +17,42 @@ use crate::types::{Round, ValidatorId};
/// Events which the state machine sends/receives.
#[derive(Debug, Clone, PartialEq)]
pub enum StateMachineEvent {
<<<<<<< HEAD
/// Sent by the state machine when a block is required to propose (BlockHash is always None).
/// While waiting for the response of GetProposal, the state machine will buffer all other
/// events. The caller must respond with a valid block hash for this height to the state
/// machine, and the same round sent out.
GetProposal(Option<BlockHash>, Round),
||||||| a9dc431b
/// StartRound is effective 2 questions:
/// 1. Is the local node the proposer for this round?
/// 2. If so, what value should be proposed?
/// While waiting for the response to this event, the state machine will buffer all other
/// events.
///
/// How should the caller handle this event?
/// 1. If the local node is not the proposer, the caller responds with with `None` as the block
/// hash.
/// 2. If the local node is the proposer and a block hash was supplied by the state machine,
/// the caller responds with the supplied block hash.
/// 3. If the local node is the proposer and no block hash was supplied by the state machine,
/// the caller must find/build a block to respond with.
StartRound(Option<BlockHash>, Round),
=======
/// StartRound is effective 2 questions:
/// 1. Is the local node the proposer for this round?
/// 2. If so, what value should be proposed? While waiting for the response to this event, the
/// state machine will buffer all other events.
///
/// How should the caller handle this event?
/// 1. If the local node is not the proposer, the caller responds with with `None` as the block
/// hash.
/// 2. If the local node is the proposer and a block hash was supplied by the state machine,
/// the caller responds with the supplied block hash.
/// 3. If the local node is the proposer and no block hash was supplied by the state machine,
/// the caller must find/build a block to respond with.
StartRound(Option<BlockHash>, Round),
>>>>>>> origin/main-v0.13.2
/// Consensus message, can be both sent from and to the state machine.
Proposal(BlockHash, Round),
/// Consensus message, can be both sent from and to the state machine.
Expand Down
Loading