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

feat(kona-derive): Towards Derivation #243

Merged
merged 39 commits into from
Jun 15, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
39 commits
Select commit Hold shift + click to select a range
96e8a36
feat: small fixes and kona deriver
refcell Jun 11, 2024
41b7b12
fixes
refcell Jun 12, 2024
385c8ee
fixes
refcell Jun 12, 2024
09a7e9e
start derivation fixes
clabby Jun 12, 2024
355dd49
first valid payload
clabby Jun 12, 2024
e25e3bd
cleanup
clabby Jun 12, 2024
c33a873
fixes
clabby Jun 12, 2024
03d8edf
fix: lints
refcell Jun 12, 2024
8b930c7
updates
clabby Jun 12, 2024
4e6538e
fix: lints
refcell Jun 12, 2024
f347480
fix: bin cleanup
refcell Jun 12, 2024
491eee3
fix: lints
refcell Jun 12, 2024
520e6e1
fix: ignore tests for now
refcell Jun 12, 2024
8dc116e
fix: blob decoding
clabby Jun 13, 2024
269b29f
fix: tests and logs
refcell Jun 13, 2024
11412a6
fix: validation
refcell Jun 13, 2024
ce0eade
fix: update deps
refcell Jun 13, 2024
3025b6b
feat: superchain registry types
refcell Jun 13, 2024
b16b15d
fix: make sync less verbose by default
clabby Jun 13, 2024
54d7da3
fix: print l2 attributes timestamp
clabby Jun 13, 2024
74ec607
fix: pipeline interface and cursor updates
refcell Jun 13, 2024
4395c11
fixes
refcell Jun 13, 2024
94efcf7
cleanup
refcell Jun 13, 2024
a728426
fix: broken tests from scr
refcell Jun 13, 2024
1503174
fix: ecotone batches working
clabby Jun 14, 2024
8dfcf01
attempt cov fix
clabby Jun 14, 2024
01f05fa
fix: move kona-sync to example
refcell Jun 14, 2024
2580787
fix: move validation to trusted-sync example
refcell Jun 14, 2024
8518fb1
fix(examples): validation hardcoded canyon timestamp
refcell Jun 14, 2024
e4edf4f
fix: exclude examples in cannon and asterisc builds
refcell Jun 14, 2024
d4aaf9d
fix(primitives): make types impl hash
refcell Jun 14, 2024
0bcdb10
chore: clean kona-derive examples
refcell Jun 14, 2024
fa102f6
fix(kona-derive): remove async bound on online pipeline constructor
refcell Jun 14, 2024
7aa6c77
fix: batch encoding/decoding tests
refcell Jun 14, 2024
6b7518b
fix: batch reader test
refcell Jun 14, 2024
f2434b1
fix(derive): last batch queue test
refcell Jun 14, 2024
ddce263
chore: remove execution validation log match
refcell Jun 14, 2024
3747351
fix: nit
refcell Jun 15, 2024
1ee10d8
nit fix
refcell Jun 15, 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
2 changes: 1 addition & 1 deletion .github/workflows/coverage.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ jobs:
with:
submodules: true
- name: Install stable
uses: dtolnay/rust-toolchain@stable
uses: dtolnay/rust-toolchain@1.78.0
with:
components: llvm-tools-preview
- name: Rust cache
Expand Down
66 changes: 56 additions & 10 deletions Cargo.lock

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

3 changes: 2 additions & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
[workspace]
members = ["crates/*", "bin/host", "bin/programs/*"]
members = ["crates/*", "bin/host", "bin/programs/*", "examples/*"]
default-members = ["bin/host", "bin/programs/*"]
exclude = ["fpvm-tests/cannon-rs-tests"]
resolver = "2"

Expand Down
25 changes: 22 additions & 3 deletions bin/programs/client/src/l2/executor/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -418,9 +418,15 @@ where
.next_block_excess_blob_gas()
.or_else(|| spec_id.is_enabled_in(SpecId::ECOTONE).then_some(0))
.map(|x| BlobExcessGasAndPrice::new(x as u64));
let next_block_base_fee = parent_header
.next_block_base_fee(config.base_fee_params_at_timestamp(payload_attrs.timestamp))
.unwrap_or_default();
// If the payload attribute timestamp is past canyon activation,
// use the canyon base fee params from the rollup config.
let base_fee_params = if config.is_canyon_active(payload_attrs.timestamp) {
config.canyon_base_fee_params.expect("Canyon base fee params not provided")
} else {
config.base_fee_params
};
let next_block_base_fee =
parent_header.next_block_base_fee(base_fee_params).unwrap_or_default();

BlockEnv {
number: U256::from(parent_header.number + 1),
Expand Down Expand Up @@ -581,6 +587,7 @@ mod test {
use super::*;
use alloy_primitives::{address, b256, hex};
use alloy_rlp::Decodable;
use kona_derive::types::{OP_BASE_FEE_PARAMS, OP_CANYON_BASE_FEE_PARAMS};
use kona_mpt::NoopTrieDBHinter;
use serde::Deserialize;
use std::{collections::HashMap, format};
Expand Down Expand Up @@ -640,6 +647,8 @@ mod test {
canyon_time: Some(0),
delta_time: Some(0),
ecotone_time: Some(0),
base_fee_params: OP_BASE_FEE_PARAMS,
canyon_base_fee_params: Some(OP_CANYON_BASE_FEE_PARAMS),
..Default::default()
};

Expand Down Expand Up @@ -691,6 +700,8 @@ mod test {
canyon_time: Some(0),
delta_time: Some(0),
ecotone_time: Some(0),
base_fee_params: OP_BASE_FEE_PARAMS,
canyon_base_fee_params: Some(OP_CANYON_BASE_FEE_PARAMS),
..Default::default()
};

Expand Down Expand Up @@ -746,6 +757,8 @@ mod test {
canyon_time: Some(0),
delta_time: Some(0),
ecotone_time: Some(0),
base_fee_params: OP_BASE_FEE_PARAMS,
canyon_base_fee_params: Some(OP_CANYON_BASE_FEE_PARAMS),
..Default::default()
};

Expand Down Expand Up @@ -808,6 +821,8 @@ mod test {
canyon_time: Some(0),
delta_time: Some(0),
ecotone_time: Some(0),
base_fee_params: OP_BASE_FEE_PARAMS,
canyon_base_fee_params: Some(OP_CANYON_BASE_FEE_PARAMS),
..Default::default()
};

Expand Down Expand Up @@ -864,6 +879,8 @@ mod test {
canyon_time: Some(0),
delta_time: Some(0),
ecotone_time: Some(0),
base_fee_params: OP_BASE_FEE_PARAMS,
canyon_base_fee_params: Some(OP_CANYON_BASE_FEE_PARAMS),
..Default::default()
};

Expand Down Expand Up @@ -929,6 +946,8 @@ mod test {
canyon_time: Some(0),
delta_time: Some(0),
ecotone_time: Some(0),
base_fee_params: OP_BASE_FEE_PARAMS,
canyon_base_fee_params: Some(OP_CANYON_BASE_FEE_PARAMS),
..Default::default()
};

Expand Down
45 changes: 2 additions & 43 deletions crates/derive/USAGE.md
Original file line number Diff line number Diff line change
@@ -1,46 +1,5 @@
## Usage

```rust
use alloc::sync::Arc;
use kona_derive::online::*;
use kona_derive::pipeline::*;
use kona_primitives::{BlockInfo, L2BlockInfo, RollupConfig};
See the [examples][examples] for example usage of the derivation pipeline.

// Creates a new chain provider using the `L1_RPC_URL` environment variable.
let l1_rpc_url = std::env::var("L1_RPC_URL").expect("L1_RPC_URL must be set");
let chain_provider = AlloyChainProvider::new_http(l1_rpc_url.parse().unwrap());

// Creates a new l2 chain provider using the `L2_RPC_URL` environment variable.
let l2_rpc_url = std::env::var("L2_RPC_URL").expect("L2_RPC_URL must be set");
let l2_chain_provider = AlloyL2ChainProvider::new_http(l2_rpc_url.parse().unwrap());

// TODO(refcell): replace this will a rollup config
// fetched from the superchain-registry via network id.
let rollup_config = Arc::new(RollupConfig::default());

// Create the beacon client used to fetch blob data.
let beacon_url = std::env::var("BEACON_URL").expect("BEACON_URL must be set");
let beacon_client = OnlineBeaconClient::new_http(beacon_url.parse().unwrap());

// Build the online blob provider.
let blob_provider = OnlineBlobProvider::<_, SimpleSlotDerivation>::new(true, beacon_client, None, None);

// Build the ethereum data source
let dap_source = EthereumDataSource::new(chain_provider.clone(), blob_provider, &rollup_config);

// The payload attributes builder that is stateful.
let attributes_builder = StatefulAttributesBuilder::new(rollup_config.clone(), l2_chain_provider.clone(), chain_provider.clone());

// Build the pipeline.
let pipeline = PipelineBuilder::new()
.rollup_config(rollup_config)
.dap_source(dap_source)
.l2_chain_provider(l2_chain_provider)
.chain_provider(chain_provider)
.builder(attributes_builder)
.build();

// The pipeline should be at the default state.
assert_eq!(pipeline.tip, BlockInfo::default());
assert_eq!(pipeline.cursor, L2BlockInfo::default());
```
[examples]: ../../examples/
2 changes: 1 addition & 1 deletion crates/derive/src/online/alloy_providers.rs
Original file line number Diff line number Diff line change
Expand Up @@ -219,7 +219,7 @@ impl L2ChainProvider for AlloyL2ChainProvider {
rollup_config: Arc<RollupConfig>,
) -> Result<SystemConfig> {
if let Some(system_config) = self.system_config_by_number_cache.get(&number) {
return Ok(*system_config);
return Ok(system_config.clone());
}

let envelope = self.payload_by_number(number).await?;
Expand Down
Loading
Loading