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

chore: bump kona version #138

Merged
merged 4 commits into from
Oct 3, 2024
Merged
Show file tree
Hide file tree
Changes from all 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
238 changes: 130 additions & 108 deletions Cargo.lock

Large diffs are not rendered by default.

22 changes: 12 additions & 10 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -58,18 +58,20 @@ op-succinct-host-utils = { path = "utils/host" }
op-succinct-proposer = { path = "proposer/succinct" }

# ethereum / op
alloy = { version = "0.3", default-features = false, features = ["full"] }
# sha3-keccak is enabled in 0.8.4
alloy-primitives = { version = "0.8.4", default-features = false, features = ["sha3-keccak"] }
alloy = { version = "0.4", default-features = false, features = ["full"] }
# Uses sha3 instead of tiny-keccak. Reduces cycle count for Keccak by 50%.
alloy-primitives = { version = "0.8.4", default-features = false, features = [
"sha3-keccak",
] }
alloy-rlp = { version = "0.3.8", default-features = false }
alloy-eips = { version = "0.3", default-features = false }
alloy-eips = { version = "0.4", default-features = false }
revm = { version = "14.0", default-features = false, features = ["kzg-rs"] }
alloy-consensus = { version = "0.3.6", default-features = false }
alloy-consensus = { version = "0.4", default-features = false }
alloy-sol-types = { version = "0.8" }
op-alloy-consensus = { version = "0.2.12", default-features = false }
op-alloy-genesis = { version = "0.2.12", default-features = false }
op-alloy-protocol = { version = "0.2.12", default-features = false }
op-alloy-rpc-types-engine = { version = "0.2.12", default-features = false }
op-alloy-consensus = { version = "0.3.3", default-features = false }
op-alloy-genesis = { version = "0.3.3", default-features = false }
op-alloy-protocol = { version = "0.3.3", default-features = false }
op-alloy-rpc-types-engine = { version = "0.3.3", default-features = false }

# sp1
sp1-lib = { version = "3.0.0-rc1", features = ["verify"] }
Expand All @@ -89,4 +91,4 @@ sha2 = { git = "https://github.com/sp1-patches/RustCrypto-hashes", package = "sh
# TODO: Change this back to the original patch branch once the changes to sp1-lib to fix secp256k1 addition have been merged and a stable version tag is released.
ecdsa = { git = "https://github.com/sp1-patches/signatures", branch = "ratan/secp256k1-add-fixes-v0.16.8" }
bn = { git = "https://github.com/0xWOLAND/bn.git", package = "substrate-bn" }
sha3 = { git = "https://github.com/sp1-patches/RustCrypto-hashes", package = "sha3", branch = "patch-sha3-v0.10.8" }
sha3 = { git = "https://github.com/sp1-patches/RustCrypto-hashes", package = "sha3", branch = "patch-sha3-v0.10.8" }
4 changes: 0 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,10 +5,6 @@ OP Succinct turns any OP stack rollup into a full type-1 zkEVM Rollup in 1 hour
**[Docs](https://succinctlabs.github.io/op-succinct)**
| [Learn More](https://succinctlabs.github.io/op-succinct)

> [!CAUTION]
>
> This repository is not meant for production usage.

## Getting Started

Today, you can already use OP Succinct to upgrade any existing OP Stack rollup to a type-1 zkEVM rollup. To get started, make sure you have [Rust](https://rustup.rs/), [Foundry](https://book.getfoundry.sh/), and [Docker](https://docs.docker.com/engine/install/) installed. Then, follow the steps in the [book](https://succinctlabs.github.io/op-succinct/) to deploy the `OPSuccinctL2OutputOracle` contract and start the `op-succinct-proposer` service.
Expand Down
10 changes: 10 additions & 0 deletions book/book.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
[book]
authors = ["ratankaliani"]
language = "en"
multilingual = false
title = "OP Succinct book"

[output.html]
default-theme = "rust"
preferred-dark-theme = "rust"
git-repository-url = "https://github.com/succinctlabs/op-succinct"
2 changes: 2 additions & 0 deletions book/cost-estimator.md
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,8 @@ just cost-estimator <start_l2_block> <end_l2_block>

This command will split the block range into smaller ranges as if the `op-succinct-proposer` service was running. It will then fetch the required data for generating the ZKP for each of these ranges, and execute the SP1 `range` program. Once each program finishes, it will collect the statistics and output the aggregate statistics.

> Running the cost estimator for a large block range may be slow on machines with limited network bandwidth to the L2 node. For optimal performance, we recommend using a remote machine with high-speed connectivity to avoid slow witness generation.

## Example

On Optimism Sepolia, proving the block range 17664000 to 17664125 (125 blocks) takes 4 range proofs and ~11.1B cycles.
Expand Down
32 changes: 17 additions & 15 deletions programs/range/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -12,17 +12,16 @@ extern crate alloc;

use alloc::sync::Arc;

use alloy_consensus::Sealed;
use alloy_consensus::{BlockBody, Sealed};
use alloy_eips::eip2718::Decodable2718;
use cfg_if::cfg_if;
use kona_client::{
l1::{OracleBlobProvider, OracleL1ChainProvider},
BootInfo,
};
use kona_derive::block::OpBlock;
use kona_executor::StatelessL2BlockExecutor;
use log::info;
use op_alloy_consensus::OpTxEnvelope;
use op_alloy_consensus::{OpBlock, OpTxEnvelope};
use op_succinct_client_utils::{
driver::MultiBlockDerivationDriver, l2_chain_provider::MultiblockOracleL2ChainProvider,
precompiles::zkvm_handle_register,
Expand Down Expand Up @@ -152,18 +151,21 @@ fn main() {
// Generate the Payload Envelope, which can be used to derive cached data.
let optimism_block = OpBlock {
header: new_block_header.clone(),
body: payload
.attributes
.transactions
.unwrap()
.iter()
.map(|raw_tx| OpTxEnvelope::decode_2718(&mut raw_tx.as_ref()).unwrap())
.collect::<Vec<OpTxEnvelope>>(),
withdrawals: boot
.rollup_config
.is_canyon_active(new_block_header.timestamp)
.then(Vec::new),
..Default::default()
body: BlockBody {
transactions: payload
.attributes
.transactions
.unwrap()
.iter()
.map(|raw_tx| OpTxEnvelope::decode_2718(&mut raw_tx.as_ref()).unwrap())
.collect::<Vec<OpTxEnvelope>>(),
ommers: Vec::new(),
withdrawals: boot
.rollup_config
.is_canyon_active(new_block_header.timestamp)
.then(Vec::new),
requests: None,
},
};
// Add all data from this block's execution to the cache.
l2_block_info = l2_provider
Expand Down
7 changes: 4 additions & 3 deletions utils/client/src/driver.rs
Original file line number Diff line number Diff line change
Expand Up @@ -15,12 +15,12 @@ use kona_client::{
use kona_derive::{
attributes::StatefulAttributesBuilder,
pipeline::{DerivationPipeline, Pipeline, PipelineBuilder, StepResult},
prelude::{ChainProvider, L2ChainProvider},
sources::EthereumDataSource,
stages::{
AttributesQueue, BatchQueue, BatchStream, ChannelBank, ChannelReader, FrameQueue,
L1Retrieval, L1Traversal,
},
traits::{ChainProvider, L2ChainProvider},
};
use kona_mpt::TrieProvider;
use kona_preimage::{CommsClient, PreimageKey, PreimageKeyType};
Expand All @@ -31,7 +31,7 @@ use log::{debug, error};

/// An oracle-backed derivation pipeline.
pub type OraclePipeline<O> = DerivationPipeline<
OracleAttributesQueue<OracleDataProvider<O>, O>,
MultiblockOracleAttributesQueue<OracleDataProvider<O>, O>,
MultiblockOracleL2ChainProvider<O>,
>;

Expand All @@ -45,12 +45,13 @@ pub type OracleAttributesBuilder<O> =
StatefulAttributesBuilder<OracleL1ChainProvider<O>, MultiblockOracleL2ChainProvider<O>>;

/// An oracle-backed attributes queue for the derivation pipeline.
pub type OracleAttributesQueue<DAP, O> = AttributesQueue<
pub type MultiblockOracleAttributesQueue<DAP, O> = AttributesQueue<
BatchQueue<
BatchStream<
ChannelReader<
ChannelBank<FrameQueue<L1Retrieval<DAP, L1Traversal<OracleL1ChainProvider<O>>>>>,
>,
MultiblockOracleL2ChainProvider<O>,
>,
MultiblockOracleL2ChainProvider<O>,
>,
Expand Down
38 changes: 21 additions & 17 deletions utils/client/src/l2_chain_provider.rs
Original file line number Diff line number Diff line change
@@ -1,19 +1,19 @@
//! Contains the concrete implementation of the [L2ChainProvider] trait for the client program.

use alloc::{boxed::Box, sync::Arc, vec::Vec};
use alloy_consensus::Header;
use alloy_consensus::{BlockBody, Header};
use alloy_eips::eip2718::Decodable2718;
use alloy_primitives::{Address, Bytes, B256};
use alloy_rlp::Decodable;
use anyhow::{anyhow, Result};
use async_trait::async_trait;
use kona_client::{BootInfo, HintType};
use kona_derive::{block::OpBlock, traits::L2ChainProvider};
use kona_derive::pipeline::L2ChainProvider;
use kona_mpt::{OrderedListWalker, TrieHinter, TrieProvider};
use kona_preimage::{CommsClient, PreimageKey, PreimageKeyType};
use op_alloy_consensus::OpTxEnvelope;
use op_alloy_consensus::{OpBlock, OpTxEnvelope};
use op_alloy_genesis::{RollupConfig, SystemConfig};
use op_alloy_protocol::L2BlockInfo;
use op_alloy_protocol::{to_system_config, L2BlockInfo};
use std::{collections::HashMap, sync::Mutex};

use crate::block_on;
Expand Down Expand Up @@ -69,9 +69,9 @@ impl<T: CommsClient> MultiblockOracleL2ChainProvider<T> {
self.system_config_by_number
.lock()
.unwrap()
.insert(header.number, block.to_system_config(config).unwrap());
.insert(header.number, to_system_config(&block, config)?);

let l2_block_info = block.to_l2_block_ref(config)?;
let l2_block_info = L2BlockInfo::from_block_and_genesis(&block, &config.genesis)?;
self.l2_block_info_by_number
.lock()
.unwrap()
Expand Down Expand Up @@ -132,10 +132,11 @@ impl<T: CommsClient + Send + Sync> L2ChainProvider for MultiblockOracleL2ChainPr
}

// Get the payload at the given block number.
let payload = self.block_by_number(number).await?;
let block = self.block_by_number(number).await?;

// Construct the system config from the payload.
Ok(payload.to_l2_block_ref(&self.boot_info.rollup_config)?)
L2BlockInfo::from_block_and_genesis(&block, &self.boot_info.rollup_config.genesis)
.map_err(Into::into)
}

async fn block_by_number(&mut self, number: u64) -> Result<OpBlock> {
Expand Down Expand Up @@ -169,13 +170,16 @@ impl<T: CommsClient + Send + Sync> L2ChainProvider for MultiblockOracleL2ChainPr

let optimism_block = OpBlock {
header,
body: transactions,
withdrawals: self
.boot_info
.rollup_config
.is_canyon_active(timestamp)
.then(Vec::new),
..Default::default()
body: BlockBody {
transactions,
ommers: Vec::new(),
withdrawals: self
.boot_info
.rollup_config
.is_canyon_active(timestamp)
.then(Vec::new),
requests: None,
},
};
Ok(optimism_block)
}
Expand All @@ -191,10 +195,10 @@ impl<T: CommsClient + Send + Sync> L2ChainProvider for MultiblockOracleL2ChainPr
}

// Get the payload at the given block number.
let payload = self.block_by_number(number).await?;
let block = self.block_by_number(number).await?;

// Construct the system config from the payload.
Ok(payload.to_system_config(rollup_config.as_ref())?)
to_system_config(&block, rollup_config.as_ref()).map_err(Into::into)
}
}

Expand Down
2 changes: 1 addition & 1 deletion utils/host/src/fetcher.rs
Original file line number Diff line number Diff line change
Expand Up @@ -289,7 +289,7 @@ impl OPSuccinctDataFetcher {
block_data.push(BlockInfo {
block_number,
transaction_count: block.transactions.len() as u64,
gas_used: block.header.gas_used as u64,
gas_used: block.header.gas_used,
});
}
Ok(block_data)
Expand Down
Loading