-
Notifications
You must be signed in to change notification settings - Fork 47
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(warp): added warp update
to madara and other changes
#393
Merged
Merged
Changes from all commits
Commits
Show all changes
86 commits
Select commit
Hold shift + click to select a range
135a3c0
feat(rate-limit): removed rpc rate limiting in Madara
Trantorian1 5e4f779
feat(endpoint): added a separate `admin` endpoint
Trantorian1 5e8ee41
feat(changelog): updated `CHANGELOG.md`
Trantorian1 75e3d91
fix(lint)
Trantorian1 c4a0055
feat(endpoint): seperated user and admin rpc method versions
Trantorian1 b0c456d
fix(tests): invalid version import in tests
Trantorian1 f8ab3e4
fix(test)
Trantorian1 f774276
Merge branch 'main' into feat/engine_endpoint
Trantorian1 b29f886
feat(enpoint): updated `rpc-methods` cli arg to work better with new …
Trantorian1 fbd89b6
docs(endpoint): renamed `rpc-methods` cli argument to `rpc-enpoints`
Trantorian1 a72deba
Merge branch 'main' into feat/engine_endpoint
Trantorian1 d2afdf2
build(profiling): added profiling build target
Trantorian1 3fbe996
fix(fgw): include `l1_to_l2_consumed_message` in L1 handler receipt
jbcaron 7263c8d
fix comment: MAX_H160
jbcaron 6ac5b72
update dependencies starknet-rs, starknet-types, blockifier, cairo
jbcaron 3141d73
add FIXME for FeePayment conversion
jbcaron 7d10c97
rename FeederClient to GatewayProvider
jbcaron 555c2d8
add `add_transaction` gateway client
jbcaron 3acaa86
fix mock fgw
jbcaron 8f969bd
fix comment, remove crate error
jbcaron 14c8209
refactor: replace starknet-rs BlockId with types-rs BlockId, remove r…
jbcaron 912e0c9
remove type `FetchBlockId`
jbcaron c841913
revert get_storage_at
jbcaron 31baf41
Merge branch 'fix/fgw-l1l2msg' into feat/engine_endpoint
Trantorian1 d564466
Merge branch 'feat/fgw-add-tx' into feat/engine_endpoint
Trantorian1 340171d
Merge branch 'refactor/rpc-types' into feat/engine_endpoint
Trantorian1 7c7031b
Merge branch 'main' into feat/engine_endpoint
Trantorian1 0813c0e
Merge branch 'main' into feat/engine_endpoint
Trantorian1 bc7fe96
fix(comments)
Trantorian1 6f52fce
fix(comments)
Trantorian1 0e0a120
fix(comments)
Trantorian1 1135eb6
fix(tests)
Trantorian1 71278b2
Merge branch 'main' into feat/engine_endpoint
Trantorian1 2646179
feat(cancellation): added service cancellation boilerplate
Trantorian1 69c287c
build(symbols): updated symbols build element to work with cargo work…
Trantorian1 804a235
feat(sync): added `stop-on-sync` cli flag
Trantorian1 e50bf22
Merge branch 'main' into debug
Trantorian1 817f97d
feat(changelog)
Trantorian1 6b81330
fix(lint)
Trantorian1 76a82ba
fix(tests)
Trantorian1 4c05802
Merge branch 'main' into debug
Trantorian1 b55d686
fix(changelog)
Trantorian1 6bbfee7
fix(comments)
Trantorian1 e9256d2
Merge branch 'main' into feat/engine_endpoint
jbcaron 8e08cbe
fix(comments)
Trantorian1 7482581
fix(rebase)
Trantorian1 0d75dc6
feat(rpc): moved rpc server config creation to service start
Trantorian1 a9c1574
feat(rpc): added `node_stop` rpc method
Trantorian1 74023d3
Merge branch 'main' into feat/stop_node
Trantorian1 23ad801
Merge branch 'main' into feat/stop_node
Trantorian1 14a5501
tmp
Trantorian1 6c3b211
refactor(sync): cleared up various sync function signatures
Trantorian1 5233339
refactor(db): `maybe_flush` is now `flush` and will flush each time i…
Trantorian1 9b01100
docs(warp): added docs on warp update
Trantorian1 0fded70
docs(review): got feature ready for review
Trantorian1 373e55d
Merge branch 'main' into feat/warp_update
Trantorian1 be08e4c
fix(ci)
Trantorian1 675f214
fix(ci)
Trantorian1 a614117
feat(rpc): added `pulse` admin rpc method
Trantorian1 b3b781d
feat(service): strarted work on `ServiceContext`
Trantorian1 5a3e244
feat(service): added `ServiceContext` to `Service`
Trantorian1 998017f
fix(tests): updated tests to use `ServiceContext`
Trantorian1 93455d9
feat(service): inter-process service communication
Trantorian1 2d88efa
feat(service): impled cross-service shitdown for rpc and sync
Trantorian1 46fa8cf
feat(warp): warp update clip args
Trantorian1 be2f41c
Merge branch 'main' into feat/warp_update
Trantorian1 ab5759a
docs(readme): updated readme
Trantorian1 fa020c1
Merge branch 'main' into feat/warp_update
antiyro ada9a64
feat(admin): reset admin rpc versions to v0.1.0
Trantorian1 556d640
fix(log): fixed log level
Trantorian1 dc83e43
fix(e2e): tests now use `ServiceContext` with services activated by d…
Trantorian1 5e9ff44
fix(l2): channel close error in `fetch/mod.rs`
Trantorian1 1e23f46
feat(l2): `sync_parallelism` in warp update now set based on number o…
Trantorian1 529561c
fix(tests)
Trantorian1 64743aa
Merge branch 'main' into feat/warp_update
jbcaron 0d71ca1
docs(admin): updated admin rpc methods docs
Trantorian1 602d705
refactor(service): replaced `ServiceContext::branch` with clone, adde…
Trantorian1 7448c4b
refactor(serive): renamed capabilities to services
Trantorian1 f5754d6
fix(comments)
Trantorian1 3950c1a
fix(comments)
Trantorian1 3769030
fix(comments)
Trantorian1 75dc17d
docs(fetch): added doccumentation to l2 fetch methods
Trantorian1 4c0b1f8
docs(args): added docs to `ArgsPresetParams`
Trantorian1 17eb84d
feat(db): added `--flush-every-n-seconds` cli flag
Trantorian1 b91914a
Merge branch 'main' into feat/warp_update
Trantorian1 470890b
fix(comments)
Trantorian1 File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,19 +1,18 @@ | ||
//! Madara database | ||
|
||
use anyhow::{Context, Result}; | ||
use anyhow::Context; | ||
use bonsai_db::{BonsaiDb, DatabaseKeyMapping}; | ||
use bonsai_trie::id::BasicId; | ||
use bonsai_trie::{BonsaiStorage, BonsaiStorageConfig}; | ||
use db_metrics::DbMetrics; | ||
use mp_chain_config::ChainConfig; | ||
use mp_utils::service::Service; | ||
use mp_utils::service::{MadaraService, Service}; | ||
use rocksdb::backup::{BackupEngine, BackupEngineOptions}; | ||
use rocksdb::{BoundColumnFamily, ColumnFamilyDescriptor, DBWithThreadMode, Env, FlushOptions, MultiThreaded}; | ||
use rocksdb_options::rocksdb_global_options; | ||
use starknet_types_core::hash::{Pedersen, Poseidon, StarkHash}; | ||
use std::path::{Path, PathBuf}; | ||
use std::sync::{Arc, Mutex}; | ||
use std::time::{Duration, Instant}; | ||
use std::sync::Arc; | ||
use std::{fmt, fs}; | ||
use tokio::sync::{mpsc, oneshot}; | ||
|
||
|
@@ -37,7 +36,7 @@ pub type WriteBatchWithTransaction = rocksdb::WriteBatchWithTransaction<false>; | |
|
||
const DB_UPDATES_BATCH_SIZE: usize = 1024; | ||
|
||
pub fn open_rocksdb(path: &Path) -> Result<Arc<DB>> { | ||
pub fn open_rocksdb(path: &Path) -> anyhow::Result<Arc<DB>> { | ||
let opts = rocksdb_global_options()?; | ||
tracing::debug!("opening db at {:?}", path.display()); | ||
let db = DB::open_cf_descriptors( | ||
|
@@ -49,14 +48,14 @@ pub fn open_rocksdb(path: &Path) -> Result<Arc<DB>> { | |
Ok(Arc::new(db)) | ||
} | ||
|
||
/// This runs in anothr thread as the backup engine is not thread safe | ||
/// This runs in another thread as the backup engine is not thread safe | ||
fn spawn_backup_db_task( | ||
backup_dir: &Path, | ||
restore_from_latest_backup: bool, | ||
db_path: &Path, | ||
db_restored_cb: oneshot::Sender<()>, | ||
mut recv: mpsc::Receiver<BackupRequest>, | ||
) -> Result<()> { | ||
) -> anyhow::Result<()> { | ||
let mut backup_opts = BackupEngineOptions::new(backup_dir).context("Creating backup options")?; | ||
let cores = std::thread::available_parallelism().map(|e| e.get() as i32).unwrap_or(1); | ||
backup_opts.set_max_background_operations(cores); | ||
|
@@ -254,7 +253,6 @@ impl DatabaseExt for DB { | |
pub struct MadaraBackend { | ||
backup_handle: Option<mpsc::Sender<BackupRequest>>, | ||
db: Arc<DB>, | ||
last_flush_time: Mutex<Option<Instant>>, | ||
chain_config: Arc<ChainConfig>, | ||
db_metrics: DbMetrics, | ||
sender_block_info: tokio::sync::broadcast::Sender<mp_block::MadaraBlockInfo>, | ||
|
@@ -305,7 +303,11 @@ impl DatabaseService { | |
} | ||
} | ||
|
||
impl Service for DatabaseService {} | ||
impl Service for DatabaseService { | ||
fn id(&self) -> MadaraService { | ||
MadaraService::Database | ||
} | ||
} | ||
|
||
struct BackupRequest { | ||
callback: oneshot::Sender<()>, | ||
|
@@ -315,7 +317,7 @@ struct BackupRequest { | |
impl Drop for MadaraBackend { | ||
fn drop(&mut self) { | ||
tracing::info!("⏳ Gracefully closing the database..."); | ||
self.maybe_flush(true).expect("Error when flushing the database"); // flush :) | ||
self.flush().expect("Error when flushing the database"); // flush :) | ||
} | ||
} | ||
|
||
|
@@ -330,7 +332,6 @@ impl MadaraBackend { | |
Arc::new(Self { | ||
backup_handle: None, | ||
db: open_rocksdb(temp_dir.as_ref()).unwrap(), | ||
last_flush_time: Default::default(), | ||
chain_config, | ||
db_metrics: DbMetrics::register().unwrap(), | ||
sender_block_info: tokio::sync::broadcast::channel(100).0, | ||
|
@@ -344,7 +345,7 @@ impl MadaraBackend { | |
backup_dir: Option<PathBuf>, | ||
restore_from_latest_backup: bool, | ||
chain_config: Arc<ChainConfig>, | ||
) -> Result<Arc<MadaraBackend>> { | ||
) -> anyhow::Result<Arc<MadaraBackend>> { | ||
let db_path = db_config_dir.join("db"); | ||
|
||
// when backups are enabled, a thread is spawned that owns the rocksdb BackupEngine (it is not thread safe) and it receives backup requests using a mpsc channel | ||
|
@@ -374,7 +375,6 @@ impl MadaraBackend { | |
db_metrics: DbMetrics::register().context("Registering db metrics")?, | ||
backup_handle, | ||
db, | ||
last_flush_time: Default::default(), | ||
chain_config: Arc::clone(&chain_config), | ||
sender_block_info: tokio::sync::broadcast::channel(100).0, | ||
#[cfg(feature = "testing")] | ||
|
@@ -384,30 +384,21 @@ impl MadaraBackend { | |
Ok(backend) | ||
} | ||
|
||
pub fn maybe_flush(&self, force: bool) -> Result<bool> { | ||
let mut inst = self.last_flush_time.lock().expect("poisoned mutex"); | ||
let will_flush = force | ||
|| match *inst { | ||
Some(inst) => inst.elapsed() >= Duration::from_secs(5), | ||
None => true, | ||
}; | ||
if will_flush { | ||
tracing::debug!("doing a db flush"); | ||
let mut opts = FlushOptions::default(); | ||
opts.set_wait(true); | ||
// we have to collect twice here :/ | ||
let columns = Column::ALL.iter().map(|e| self.db.get_column(*e)).collect::<Vec<_>>(); | ||
let columns = columns.iter().collect::<Vec<_>>(); | ||
self.db.flush_cfs_opt(&columns, &opts).context("Flushing database")?; | ||
|
||
*inst = Some(Instant::now()); | ||
} | ||
pub fn flush(&self) -> anyhow::Result<()> { | ||
tracing::debug!("doing a db flush"); | ||
let mut opts = FlushOptions::default(); | ||
opts.set_wait(true); | ||
// we have to collect twice here :/ | ||
let columns = Column::ALL.iter().map(|e| self.db.get_column(*e)).collect::<Vec<_>>(); | ||
let columns = columns.iter().collect::<Vec<_>>(); | ||
|
||
Ok(will_flush) | ||
self.db.flush_cfs_opt(&columns, &opts).context("Flushing database")?; | ||
|
||
Ok(()) | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Not mandatory now but we should add metrics to follow the flush frequency and behavior |
||
} | ||
|
||
#[tracing::instrument(skip(self))] | ||
pub async fn backup(&self) -> Result<()> { | ||
pub async fn backup(&self) -> anyhow::Result<()> { | ||
let (callback_sender, callback_recv) = oneshot::channel(); | ||
let _res = self | ||
.backup_handle | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
aaah!! no, we really need to flush every block, always, in block_production mode
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This has no importance anymore as
maybe_flush
has been removed and will always flush anyways, soalways_force_flush
is no longer needed. This is after I noticed the only part of the code we were performing this check was in the block import, so instead we just do the check there while other parts of the code just callflush
directly.