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

Feature: Implement KZG commitment functionality and hints #304

Merged
merged 38 commits into from
Sep 10, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
38 commits
Select commit Hold shift + click to select a range
d495445
wip: attempt to handle kzq_da
whichqua Aug 8, 2024
89f845a
add: wip kzg da hints implementation
whichqua Aug 12, 2024
9e2f7e4
wip: kzg unknown da_size
whichqua Aug 12, 2024
40ed956
lint: clippy fix
whichqua Aug 12, 2024
d5b4ccc
fix: rename zkg to kzg
whichqua Aug 13, 2024
f2c0d94
update: kzg fft method and tests
whichqua Aug 14, 2024
b4b3e99
ensure non-negative numbers on diff
ftheirs Aug 15, 2024
2d04a47
fix: os output and add specific tests
whichqua Aug 16, 2024
2119d81
lint: clippy fixes
whichqua Aug 16, 2024
b03648d
fix: update the new api
whichqua Aug 29, 2024
5627ba3
more zkg -> kzg renaming
odesenfans Aug 29, 2024
e3e92ce
fix: use log instead of println
whichqua Aug 30, 2024
dad4b35
fix: remove unnecessary code
whichqua Aug 30, 2024
8700653
Update crates/starknet-os/src/hints/kzg.rs
whichqua Sep 4, 2024
853e611
Merge branch 'main' into gm/kzg-da
whichqua Sep 4, 2024
9ed7262
fix: missing parts of kzg, added vars
whichqua Sep 5, 2024
c474a14
L1 handler tx (#344)
ftheirs Sep 4, 2024
361463c
Chore: bump Blockifier to 0.8.0-rc.3 (#345)
Sep 4, 2024
98d88b0
Look for classes in subcalls in addition to contracts (#347)
notlesh Sep 4, 2024
069a543
Implement kzg commitment hint
notlesh Sep 5, 2024
f7cc94d
Fixes
notlesh Sep 5, 2024
bd62f4a
Merge branch 'main' into gm/kzg-da
notlesh Sep 6, 2024
6cb5fe1
Clean up post-merge
notlesh Sep 6, 2024
54282f4
Add kzg_manager.rs
notlesh Sep 6, 2024
17b6497
Resolve clippy nits
notlesh Sep 6, 2024
b79915c
s/5/6/
notlesh Sep 6, 2024
db1f6ac
Remove orphaned hint
notlesh Sep 6, 2024
6f36912
Clean up mangled comment
notlesh Sep 6, 2024
ac2c035
Remove unused import
notlesh Sep 6, 2024
89f16f7
Fix BLOB_LENGTH constant lookup
notlesh Sep 6, 2024
9c1cd42
Use from c_kzg::Error
notlesh Sep 9, 2024
b3cb200
Add Blob DA blocks to prove_block test
notlesh Sep 9, 2024
175ab71
Oops, wrong block number
notlesh Sep 9, 2024
4b36f7f
Derive number of zkg felts to ignore in os output
notlesh Sep 9, 2024
4dbc4e3
Merge branch 'main' into gm/kzg-da
notlesh Sep 9, 2024
821ddc2
Merge branch 'main' into gm/kzg-da
whichqua Sep 10, 2024
4c31765
doc: improve documentation on fft recursive method
whichqua Sep 10, 2024
d697512
doc: for the recursive fft method
whichqua Sep 10, 2024
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
1 change: 1 addition & 0 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@ cairo-lang-casm = { version = "=2.7.1" }
cairo-type-derive = { version = "0.1.0", path = "crates/cairo-type-derive" }
cairo-vm = { git = "https://github.com/Moonsong-Labs/cairo-vm", rev = "40ebe36e64ffa429ff18cba8ef0bd7d2c122ac12", features = ["cairo-1-hints", "extensive_hints", "mod_builtin"] }
clap = { version = "4.5.4", features = ["derive"] }
c-kzg = { version = "1.0.3" }
env_logger = "0.11.3"
flate2 = "1.0.32"
futures = "0.3.30"
Expand Down
3 changes: 3 additions & 0 deletions crates/bin/prove_block/tests/prove_block.rs
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ use rstest::rstest;
// # * 87019: diff assert values in contract subcall
// # * 90000: one of the subcalls results in a call to `replace_class()`.
// # * 87041: block with nonce bump inconsistency
// # * 66645 / 66776: Blob DA blocks
// # * 97581, 101556, 102076 deploy account txns
#[rstest]
#[case::small_block_with_only_invoke_txs(76793)]
Expand All @@ -24,6 +25,8 @@ use rstest::rstest;
#[case::l1_handler(98000)]
#[case::invoke_with_call_to_deploy_syscall(124534)]
#[case::block_with_nonce_bump_inconsistency(87041)]
#[case::block_with_blob_da_1(66645)]
#[case::block_with_blob_da_2(66776)]
#[case::declare_tx(76840)]
#[case::deploy_account_v1(97581)]
#[case::deploy_account_v3(101556)]
Expand Down
1 change: 1 addition & 0 deletions crates/starknet-os/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ cairo-lang-starknet-classes = { workspace = true }
cairo-lang-casm = { workspace = true }
cairo-type-derive = { path = "../cairo-type-derive" }
cairo-vm = { workspace = true }
c-kzg = { workspace = true }
futures = { workspace = true }
futures-util = { workspace = true }
heck = { workspace = true }
Expand Down
4,163 changes: 4,163 additions & 0 deletions crates/starknet-os/kzg/trusted_setup.txt

Large diffs are not rendered by default.

4 changes: 4 additions & 0 deletions crates/starknet-os/src/execution/helper.rs
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ use tokio::sync::RwLock;

use super::secp_handler::SecpSyscallProcessor;
use crate::config::STORED_BLOCK_HASH_BUFFER;
use crate::starknet::core::os::kzg_manager::KzgManager;
use crate::starknet::starknet_storage::{CommitmentInfo, CommitmentInfoError, PerContractStorage};
use crate::storage::storage::StorageError;

Expand All @@ -27,6 +28,7 @@ where
PCS: PerContractStorage,
{
pub _prev_block_context: Option<BlockContext>,
pub kzg_manager: KzgManager,
// Pointer tx execution info
pub tx_execution_info_iter: IntoIter<TransactionExecutionInfo>,
// Tx info for transaction currently being executed
Expand Down Expand Up @@ -81,6 +83,7 @@ where
fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
f.debug_struct("ExecutionHelper")
.field("_prev_block_context", &self._prev_block_context)
.field("kzg_manager", &self.kzg_manager)
.field("tx_execution_info_iter", &self.tx_execution_info_iter)
.field("tx_execution_info", &self.tx_execution_info)
.field("tx_info_ptr", &self.tx_info_ptr)
Expand Down Expand Up @@ -120,6 +123,7 @@ where
Self {
execution_helper: Rc::new(RwLock::new(ExecutionHelper {
_prev_block_context: prev_block_context,
kzg_manager: Default::default(),
tx_execution_info_iter: tx_execution_infos.into_iter(),
tx_execution_info: None,
tx_info_ptr: None,
Expand Down
4 changes: 2 additions & 2 deletions crates/starknet-os/src/hints/block_context.rs
Original file line number Diff line number Diff line change
Expand Up @@ -342,12 +342,12 @@ pub fn is_leaf(
insert_value_from_var_name(vars::ids::IS_LEAF, is_leaf, vm, ids_data, ap_tracking)
}

pub const WRITE_USE_ZKG_DA_TO_MEM: &str = indoc! {r#"
pub const WRITE_USE_KZG_DA_TO_MEM: &str = indoc! {r#"
memory[fp + 18] = to_felt_or_relocatable(syscall_handler.block_info.use_kzg_da and (
not os_input.full_output
))"#
};
pub fn write_use_zkg_da_to_mem(
pub fn write_use_kzg_da_to_mem(
vm: &mut VirtualMachine,
exec_scopes: &mut ExecutionScopes,
_ids_data: &HashMap<String, HintReference>,
Expand Down
Loading
Loading