Skip to content

Commit

Permalink
Activate Prover node (#519)
Browse files Browse the repository at this point in the history
* modify prover process

* refactor runner for proving

* intermediary commit

* simplify runner config

* cleanup configs

* fix config tomls

* create proper prover config

* fix tests

* add prover_getLastScannedL1Slot RPC

* send proofs to da layer

* some fixes in zk context

* fix evm read write order bug -- yet again

* fix

* fix serialization of proofs in risc0 adapter

* fix prover sync tests

* Implement get proof by l1 height ledger rpc

* Encode rpc proof response byte arrays to hex strings

* Store sequencer commitments on prover ledger db

* revert changes on mock sequencer config

* Sleep more

* Impl defaul prover config

* Pass public keys to sequencer

* Make tracing native in stf runner

* Add get proof by slot hash

* Use from func instead of convert funcs

* Serialize validity condition with borsh

* Return err in some prover ledger functions

* Remove unnecessary logs

* Sleep more between proof polling

* Wait for proving to finish before storing commitments

---------

Co-authored-by: Erce Can Bektüre <[email protected]>
  • Loading branch information
eyusufatik and ercecan authored May 10, 2024
1 parent 4ed87bb commit df7990d
Show file tree
Hide file tree
Showing 58 changed files with 1,385 additions and 914 deletions.
6 changes: 1 addition & 5 deletions bin/citrea/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -109,11 +109,7 @@ regex = "1.10"
default = [
] # Deviate from convention by making the "native" feature active by default. This aligns with how this package is meant to be used (as a binary first, library second).

bench = [
"hex",
"sov-risc0-adapter/bench",
"risc0/bench",
]
bench = ["hex", "sov-risc0-adapter/bench", "risc0/bench"]

[[bin]]
name = "citrea"
Expand Down
20 changes: 7 additions & 13 deletions bin/citrea/configs/bitcoin-regtest/rollup_config.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
[public_keys]
sequencer_public_key = "204040e364c10f2bec9c1fe500a1cd4c247c89d650a01ed7e82caba867877c21"
include_tx_body = false

sequencer_da_pub_key = "02588d202afcc1ee4ab5254c7847ec25b9a135bbda0f2bc69ee1a714749fd77dc9"
prover_da_pub_key = ""

Expand All @@ -17,18 +16,13 @@ network = "regtest"
# The path to the rollup's data directory. Paths that do not begin with `/` are interpreted as relative paths.
path = "full-node-db"

# We define the rollup's genesis to occur at block number `start_height`. The rollup will ignore
# any blocks before this height
[runner]
start_height = 3

[runner.rpc_config]
[rpc]
# the host and port to bind the rpc server for
bind_host = "127.0.0.1"
bind_port = 12346

[sequencer_client]
url = "http://0.0.0.0:12345"

[prover_service]
aggregated_proof_block_jump = 1
# We define the rollup's genesis to occur at block number `start_height`. The rollup will ignore
# any blocks before this height
[runner]
sequencer_client_url = "http://0.0.0.0:12345"
include_tx_body = false
16 changes: 2 additions & 14 deletions bin/citrea/configs/bitcoin-regtest/sequencer_rollup_config.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
[public_keys]
sequencer_public_key = "204040e364c10f2bec9c1fe500a1cd4c247c89d650a01ed7e82caba867877c21"
include_tx_body = true

sequencer_da_pub_key = ""
prover_da_pub_key = ""

Expand All @@ -17,18 +16,7 @@ sequencer_da_private_key = "E9873D79C6D87DC0FB6A5778633389F4453213303DA61F20BD67
# The path to the rollup's data directory. Paths that do not begin with `/` are interpreted as relative paths.
path = "sequencer-db"

# We define the rollup's genesis to occur at block number `start_height`. The rollup will ignore
# any blocks before this height
[runner]
start_height = 3

[runner.rpc_config]
[rpc]
# the host and port to bind the rpc server for
bind_host = "127.0.0.1"
bind_port = 12345

[sequencer_client]
url = "http://0.0.0.0:12346"

[prover_service]
aggregated_proof_block_jump = 1
20 changes: 7 additions & 13 deletions bin/citrea/configs/mock-dockerized/rollup_config.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
[public_keys]
sequencer_public_key = "204040e364c10f2bec9c1fe500a1cd4c247c89d650a01ed7e82caba867877c21"
include_tx_body = false

sequencer_da_pub_key = "0000000000000000000000000000000000000000000000000000000000000000"
prover_da_pub_key = ""

Expand All @@ -11,18 +10,13 @@ sender_address = "00000000000000000000000000000000000000000000000000000000000000
# The path to the rollup's data directory. Paths that do not begin with `/` are interpreted as relative paths.
path = "full-node-db"

# We define the rollup's genesis to occur at block number `start_height`. The rollup will ignore
# any blocks before this height
[runner]
start_height = 0

[runner.rpc_config]
[rpc]
# the host and port to bind the rpc server for
bind_host = "0.0.0.0"
bind_port = 8545

[sequencer_client]
url = "http://0.0.0.0:8545"

[prover_service]
aggregated_proof_block_jump = 1
# We define the rollup's genesis to occur at block number `start_height`. The rollup will ignore
# any blocks before this height
[runner]
sequencer_client_url = "http://0.0.0.0:8545"
include_tx_body = false
1 change: 1 addition & 0 deletions bin/citrea/configs/mock/prover_config.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
proving_mode = "execute"
20 changes: 7 additions & 13 deletions bin/citrea/configs/mock/rollup_config.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
[public_keys]
sequencer_public_key = "204040e364c10f2bec9c1fe500a1cd4c247c89d650a01ed7e82caba867877c21"
include_tx_body = false

sequencer_da_pub_key = "0000000000000000000000000000000000000000000000000000000000000000"
prover_da_pub_key = ""

Expand All @@ -11,18 +10,13 @@ sender_address = "00000000000000000000000000000000000000000000000000000000000000
# The path to the rollup's data directory. Paths that do not begin with `/` are interpreted as relative paths.
path = "full-node-db"

# We define the rollup's genesis to occur at block number `start_height`. The rollup will ignore
# any blocks before this height
[runner]
start_height = 0

[runner.rpc_config]
[rpc]
# the host and port to bind the rpc server for
bind_host = "127.0.0.1"
bind_port = 12346

[sequencer_client]
url = "http://0.0.0.0:12345"

[prover_service]
aggregated_proof_block_jump = 1
# We define the rollup's genesis to occur at block number `start_height`. The rollup will ignore
# any blocks before this height
[runner]
include_tx_body = false
sequencer_client_url = "http://0.0.0.0:12345"
16 changes: 2 additions & 14 deletions bin/citrea/configs/mock/sequencer_rollup_config.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
[public_keys]
sequencer_public_key = "204040e364c10f2bec9c1fe500a1cd4c247c89d650a01ed7e82caba867877c21"
include_tx_body = true

sequencer_da_pub_key = "0000000000000000000000000000000000000000000000000000000000000000"
prover_da_pub_key = ""

Expand All @@ -11,19 +10,8 @@ sender_address = "00000000000000000000000000000000000000000000000000000000000000
# The path to the rollup's data directory. Paths that do not begin with `/` are interpreted as relative paths.
path = "sequencer-db"

# We define the rollup's genesis to occur at block number `start_height`. The rollup will ignore
# any blocks before this height
[runner]
start_height = 0

[runner.rpc_config]
[rpc]
# the host and port to bind the rpc server for
bind_host = "127.0.0.1"
bind_port = 12345
max_connections = 10000

[sequencer_client]
url = "http://0.0.0.0:12345"

[prover_service]
aggregated_proof_block_jump = 1
23 changes: 7 additions & 16 deletions bin/citrea/configs/mocknet/rollup_config.toml
Original file line number Diff line number Diff line change
@@ -1,8 +1,5 @@
private_key = "1212121212121212121212121212121212121212121212121212121212121212"
[public_keys]
sequencer_public_key = "204040e364c10f2bec9c1fe500a1cd4c247c89d650a01ed7e82caba867877c21"
min_soft_confirmations_per_commitment = 1000
include_tx_body = false

sequencer_da_pub_key = "0000000000000000000000000000000000000000000000000000000000000000"
prover_da_pub_key = ""

Expand All @@ -13,19 +10,13 @@ sender_address = "00000000000000000000000000000000000000000000000000000000000000
# The path to the rollup's data directory. Paths that do not begin with `/` are interpreted as relative paths.
path = "full-node-db"

# We define the rollup's genesis to occur at block number `start_height`. The rollup will ignore
# any blocks before this height
[runner]
start_height = 0

[runner.rpc_config]
[rpc]
# the host and port to bind the rpc server for
bind_host = "0.0.0.0"
bind_port = 12345

[sequencer_client]
# public ip of the sequencer
url = "http://159.89.214.47:12345"

[prover_service]
aggregated_proof_block_jump = 1
# We define the rollup's genesis to occur at block number `start_height`. The rollup will ignore
# any blocks before this height
[runner]
sequencer_client_url = "http://159.89.214.47:12345"
include_tx_body = false
1 change: 1 addition & 0 deletions bin/citrea/configs/mocknet/sequencer_config.toml
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
private_key = "1212121212121212121212121212121212121212121212121212121212121212"
min_soft_confirmations_per_commitment = 1000
test_mode = false
deposit_mempool_fetch_limit = 10
Expand Down
16 changes: 2 additions & 14 deletions bin/citrea/configs/mocknet/sequencer_rollup_config.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
[public_keys]
sequencer_public_key = "204040e364c10f2bec9c1fe500a1cd4c247c89d650a01ed7e82caba867877c21"
include_tx_body = true

sequencer_da_pub_key = "0000000000000000000000000000000000000000000000000000000000000000"
prover_da_pub_key = ""

Expand All @@ -11,19 +10,8 @@ sender_address = "00000000000000000000000000000000000000000000000000000000000000
# The path to the rollup's data directory. Paths that do not begin with `/` are interpreted as relative paths.
path = "sequencer-db"

# We define the rollup's genesis to occur at block number `start_height`. The rollup will ignore
# any blocks before this height
[runner]
start_height = 0

[runner.rpc_config]
[rpc]
# the host and port to bind the rpc server for
bind_host = "0.0.0.0"
bind_port = 12345
max_connections = 10000

[sequencer_client]
url = "http://0.0.0.0:12345"

[prover_service]
aggregated_proof_block_jump = 1
12 changes: 5 additions & 7 deletions bin/citrea/src/bitcoin_rollup.rs
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@ use bitcoin_da::verifier::BitcoinVerifier;
use citrea_stf::genesis_config::StorageConfig;
use citrea_stf::runtime::Runtime;
use const_rollup_config::{DA_TX_ID_LEADING_ZEROS, ROLLUP_NAME};
use sequencer_client::SequencerClient;
use sov_db::ledger_db::LedgerDB;
use sov_modules_api::default_context::{DefaultContext, ZkDefaultContext};
use sov_modules_api::{Address, Spec};
Expand All @@ -17,7 +16,7 @@ use sov_risc0_adapter::host::Risc0Host;
use sov_rollup_interface::da::DaVerifier;
use sov_rollup_interface::zk::ZkvmHost;
use sov_state::{DefaultStorageSpec, Storage, ZkStorage};
use sov_stf_runner::{ParallelProverService, RollupConfig, RollupProverConfig};
use sov_stf_runner::{ParallelProverService, ProverConfig, RollupConfig};

/// Rollup with BitcoinDa
pub struct BitcoinRollup {}
Expand Down Expand Up @@ -63,7 +62,7 @@ impl RollupBlueprint for BitcoinRollup {
storage: &<Self::NativeContext as Spec>::Storage,
ledger_db: &LedgerDB,
da_service: &Self::DaService,
sequencer_client: Option<SequencerClient>,
sequencer_client_url: Option<String>,
) -> Result<jsonrpsee::RpcModule<()>, anyhow::Error> {
// unused inside register RPC
let sov_sequencer = Address::new([0; 32]);
Expand All @@ -79,7 +78,7 @@ impl RollupBlueprint for BitcoinRollup {
da_service.clone(),
storage.clone(),
&mut rpc_methods,
sequencer_client,
sequencer_client_url,
)?;

Ok(rpc_methods)
Expand Down Expand Up @@ -111,8 +110,8 @@ impl RollupBlueprint for BitcoinRollup {

async fn create_prover_service(
&self,
prover_config: RollupProverConfig,
rollup_config: &RollupConfig<Self::DaConfig>,
prover_config: ProverConfig,
_rollup_config: &RollupConfig<Self::DaConfig>,
_da_service: &Self::DaService,
) -> Self::ProverService {
// TODO: will be BITCOIN_ELF
Expand All @@ -131,7 +130,6 @@ impl RollupBlueprint for BitcoinRollup {
da_verifier,
prover_config,
zk_storage,
rollup_config.prover_service,
)
.expect("Should be able to instantiate prover service")
}
Expand Down
5 changes: 2 additions & 3 deletions bin/citrea/src/eth.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@ use std::str::FromStr;

use anyhow::Context as _;
use ethereum_rpc::{EthRpcConfig, FeeHistoryCacheConfig, GasPriceOracleConfig};
use sequencer_client::SequencerClient;
use sov_modules_api::default_context::DefaultContext;
use sov_prover_storage_manager::SnapshotManager;
use sov_rollup_interface::services::da::DaService;
Expand All @@ -13,7 +12,7 @@ pub(crate) fn register_ethereum<Da: DaService>(
da_service: Da,
storage: ProverStorage<sov_state::DefaultStorageSpec, SnapshotManager>,
methods: &mut jsonrpsee::RpcModule<()>,
sequencer_client: Option<SequencerClient>,
sequencer_client_url: Option<String>,
) -> Result<(), anyhow::Error> {
let eth_rpc_config = {
let eth_signer = eth_dev_signer();
Expand All @@ -28,7 +27,7 @@ pub(crate) fn register_ethereum<Da: DaService>(
da_service,
eth_rpc_config,
storage,
sequencer_client,
sequencer_client_url,
);
methods
.merge(ethereum_rpc)
Expand Down
7 changes: 3 additions & 4 deletions bin/citrea/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -20,10 +20,9 @@ pub fn initialize_logging() {
tracing_subscriber::registry()
.with(fmt::layer())
.with(
EnvFilter::from_str(
&env::var("RUST_LOG")
.unwrap_or_else(|_| "debug,hyper=info,risc0_zkvm=info".to_string()),
)
EnvFilter::from_str(&env::var("RUST_LOG").unwrap_or_else(|_| {
"debug,hyper=info,risc0_zkvm=info,guest_execution=debug".to_string()
}))
.unwrap(),
)
.init();
Expand Down
Loading

0 comments on commit df7990d

Please sign in to comment.