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

Realtime Subscription RPCs #916

Merged
merged 34 commits into from
Jul 25, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
34 commits
Select commit Hold shift + click to select a range
40d0625
Separate rpc Ethereum context into its file
yaziciahmet Jul 22, 2024
24c27bd
Separate debug trace
yaziciahmet Jul 22, 2024
c5517c8
Carry subscriptions at the end
yaziciahmet Jul 22, 2024
96bdab0
Create eth subscription handler signature
yaziciahmet Jul 22, 2024
f022b11
Pass tx to ledger db
yaziciahmet Jul 22, 2024
63ac5c3
Pass down the tx to rpc context
yaziciahmet Jul 22, 2024
01e94bc
Send height after commit
yaziciahmet Jul 22, 2024
5a23d73
Update new head handler fn signature
yaziciahmet Jul 22, 2024
1ae585a
Finalize handling
yaziciahmet Jul 22, 2024
c7adbcc
Add test
yaziciahmet Jul 22, 2024
d0174f0
unwrap to expect
yaziciahmet Jul 22, 2024
5cde45e
Remove notifying from ledger db
yaziciahmet Jul 23, 2024
5b5ac8e
Send new l2 block notif in sequencer and fullnode
yaziciahmet Jul 23, 2024
e9e26a9
Add to prover as well
yaziciahmet Jul 23, 2024
75550b2
Make tx optional in rpc
yaziciahmet Jul 23, 2024
a349c1a
Use params sequence
yaziciahmet Jul 23, 2024
1867614
Rename
yaziciahmet Jul 23, 2024
9b72af0
Fix doc
yaziciahmet Jul 23, 2024
0b4e547
Replace tx with rx in rpc
yaziciahmet Jul 23, 2024
60f3ecc
Rename file
yaziciahmet Jul 23, 2024
c1ad447
IMplement SubscriptionManager
yaziciahmet Jul 23, 2024
d577518
Use SubscriptionManager
yaziciahmet Jul 23, 2024
6ec1b46
Minor changes
yaziciahmet Jul 23, 2024
cfbcc80
Implemented logs subscription
yaziciahmet Jul 23, 2024
33f724b
Add log subscription test
yaziciahmet Jul 24, 2024
661b339
Simplify logs subscription flow
yaziciahmet Jul 24, 2024
af215de
Disable debug_subscribe if subscriptions disabled
yaziciahmet Jul 25, 2024
e7b7531
Update configs
yaziciahmet Jul 25, 2024
f64a593
Rename
yaziciahmet Jul 25, 2024
0903903
Add new conf params
yaziciahmet Jul 25, 2024
3f4aa0d
UPdate log_matches_filter
yaziciahmet Jul 25, 2024
c94154b
recreate working set
yaziciahmet Jul 25, 2024
e88ecbd
Replace disable with enable
yaziciahmet Jul 25, 2024
d141d6d
Rename config
yaziciahmet Jul 25, 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
3 changes: 3 additions & 0 deletions bin/citrea/src/eth.rs
Original file line number Diff line number Diff line change
Expand Up @@ -6,13 +6,15 @@ use sov_modules_api::default_context::DefaultContext;
use sov_prover_storage_manager::SnapshotManager;
use sov_rollup_interface::services::da::DaService;
use sov_state::ProverStorage;
use tokio::sync::broadcast;

// register ethereum methods.
pub(crate) fn register_ethereum<Da: DaService>(
da_service: Da,
storage: ProverStorage<sov_state::DefaultStorageSpec, SnapshotManager>,
methods: &mut jsonrpsee::RpcModule<()>,
sequencer_client_url: Option<String>,
soft_confirmation_rx: Option<broadcast::Receiver<u64>>,
) -> Result<(), anyhow::Error> {
let eth_rpc_config = {
let eth_signer = eth_dev_signer();
Expand All @@ -28,6 +30,7 @@ pub(crate) fn register_ethereum<Da: DaService>(
eth_rpc_config,
storage,
sequencer_client_url,
soft_confirmation_rx,
);
methods
.merge(ethereum_rpc)
Expand Down
3 changes: 3 additions & 0 deletions bin/citrea/src/rollup/bitcoin.rs
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ use sov_rollup_interface::da::DaVerifier;
use sov_rollup_interface::zk::{Zkvm, ZkvmHost};
use sov_state::{DefaultStorageSpec, Storage, ZkStorage};
use sov_stf_runner::{FullNodeConfig, ProverConfig};
use tokio::sync::broadcast;
use tracing::instrument;

use crate::CitreaRollupBlueprint;
Expand Down Expand Up @@ -61,6 +62,7 @@ impl RollupBlueprint for BitcoinRollup {
ledger_db: &LedgerDB,
da_service: &Self::DaService,
sequencer_client_url: Option<String>,
soft_confirmation_rx: Option<broadcast::Receiver<u64>>,
) -> Result<jsonrpsee::RpcModule<()>, anyhow::Error> {
// unused inside register RPC
let sov_sequencer = Address::new([0; 32]);
Expand All @@ -77,6 +79,7 @@ impl RollupBlueprint for BitcoinRollup {
storage.clone(),
&mut rpc_methods,
sequencer_client_url,
soft_confirmation_rx,
)?;

Ok(rpc_methods)
Expand Down
3 changes: 3 additions & 0 deletions bin/citrea/src/rollup/mock.rs
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ use sov_prover_storage_manager::ProverStorageManager;
use sov_rollup_interface::zk::{Zkvm, ZkvmHost};
use sov_state::{DefaultStorageSpec, Storage, ZkStorage};
use sov_stf_runner::{FullNodeConfig, ProverConfig};
use tokio::sync::broadcast;

use crate::CitreaRollupBlueprint;

Expand Down Expand Up @@ -55,6 +56,7 @@ impl RollupBlueprint for MockDemoRollup {
ledger_db: &LedgerDB,
da_service: &Self::DaService,
sequencer_client_url: Option<String>,
soft_confirmation_rx: Option<broadcast::Receiver<u64>>,
) -> Result<jsonrpsee::RpcModule<()>, anyhow::Error> {
// TODO set the sequencer address
let sequencer = Address::new([0; 32]);
Expand All @@ -71,6 +73,7 @@ impl RollupBlueprint for MockDemoRollup {
storage.clone(),
&mut rpc_methods,
sequencer_client_url,
soft_confirmation_rx,
)?;

Ok(rpc_methods)
Expand Down
36 changes: 34 additions & 2 deletions bin/citrea/src/rollup/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ use sov_modules_rollup_blueprint::RollupBlueprint;
use sov_modules_stf_blueprint::{Runtime as RuntimeTrait, StfBlueprint};
use sov_state::storage::NativeStorage;
use sov_stf_runner::{FullNodeConfig, InitVariant, ProverConfig};
use tokio::sync::broadcast;
use tracing::instrument;
mod bitcoin;
mod mock;
Expand Down Expand Up @@ -43,9 +44,21 @@ pub trait CitreaRollupBlueprint: RollupBlueprint {
let mut storage_manager = self.create_storage_manager(&rollup_config)?;
let prover_storage = storage_manager.create_finalized_storage()?;

let (soft_confirmation_tx, soft_confirmation_rx) = broadcast::channel(10);
// If subscriptions disabled, pass None
let soft_confirmation_rx = if rollup_config.rpc.enable_subscriptions {
Some(soft_confirmation_rx)
} else {
None
};
// TODO(https://github.com/Sovereign-Labs/sovereign-sdk/issues/1218)
let rpc_methods =
self.create_rpc_methods(&prover_storage, &ledger_db, &da_service, None)?;
let rpc_methods = self.create_rpc_methods(
eyusufatik marked this conversation as resolved.
Show resolved Hide resolved
&prover_storage,
&ledger_db,
&da_service,
None,
soft_confirmation_rx,
)?;

let native_stf = StfBlueprint::new();

Expand Down Expand Up @@ -75,6 +88,7 @@ pub trait CitreaRollupBlueprint: RollupBlueprint {
rollup_config.public_keys,
ledger_db,
rollup_config.rpc,
soft_confirmation_tx,
)
.unwrap();

Expand Down Expand Up @@ -110,12 +124,20 @@ pub trait CitreaRollupBlueprint: RollupBlueprint {
let prover_storage = storage_manager.create_finalized_storage()?;

let runner_config = rollup_config.runner.expect("Runner config is missing");
let (soft_confirmation_tx, soft_confirmation_rx) = broadcast::channel(10);
// If subscriptions disabled, pass None
let soft_confirmation_rx = if rollup_config.rpc.enable_subscriptions {
Some(soft_confirmation_rx)
} else {
None
};
// TODO(https://github.com/Sovereign-Labs/sovereign-sdk/issues/1218)
let rpc_methods = self.create_rpc_methods(
&prover_storage,
&ledger_db,
&da_service,
Some(runner_config.sequencer_client_url.clone()),
soft_confirmation_rx,
)?;

let native_stf = StfBlueprint::new();
Expand Down Expand Up @@ -149,6 +171,7 @@ pub trait CitreaRollupBlueprint: RollupBlueprint {
init_variant,
code_commitment,
rollup_config.sync_blocks_count,
soft_confirmation_tx,
)?;

Ok(FullNode {
Expand Down Expand Up @@ -187,13 +210,21 @@ pub trait CitreaRollupBlueprint: RollupBlueprint {
let mut storage_manager = self.create_storage_manager(&rollup_config)?;
let prover_storage = storage_manager.create_finalized_storage()?;

let (soft_confirmation_tx, soft_confirmation_rx) = broadcast::channel(10);
// If subscriptions disabled, pass None
let soft_confirmation_rx = if rollup_config.rpc.enable_subscriptions {
Some(soft_confirmation_rx)
} else {
None
};
let runner_config = rollup_config.runner.expect("Runner config is missing");
// TODO(https://github.com/Sovereign-Labs/sovereign-sdk/issues/1218)
let rpc_methods = self.create_rpc_methods(
&prover_storage,
&ledger_db,
&da_service,
Some(runner_config.sequencer_client_url.clone()),
soft_confirmation_rx,
)?;

let native_stf = StfBlueprint::new();
Expand Down Expand Up @@ -229,6 +260,7 @@ pub trait CitreaRollupBlueprint: RollupBlueprint {
Some(prover_config),
code_commitment,
rollup_config.sync_blocks_count,
soft_confirmation_tx,
)?;

Ok(Prover {
Expand Down
2 changes: 2 additions & 0 deletions bin/citrea/src/test_rpc.rs
Original file line number Diff line number Diff line change
Expand Up @@ -99,6 +99,8 @@ fn test_helper(
max_request_body_size: 10 * 1024 * 1024,
max_response_body_size: 10 * 1024 * 1024,
batch_requests_limit: 50,
enable_subscriptions: true,
max_subscriptions_per_connection: 100,
};

queries_test_runner(test_queries, rpc_config).await;
Expand Down
1 change: 1 addition & 0 deletions bin/citrea/tests/evm/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ use crate::{

mod archival_state;
mod gas_price;
mod subscription;
mod tracing;

#[tokio::test(flavor = "multi_thread")]
Expand Down
Loading
Loading