-
Notifications
You must be signed in to change notification settings - Fork 301
feat(fortuna): Improve startup flow #2638
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
Conversation
The latest updates on your projects. Learn more about Vercel for Git ↗︎
|
apps/fortuna/src/api.rs
Outdated
#[derive(Clone)] | ||
pub struct ApiState { | ||
pub chains: Arc<HashMap<ChainId, BlockchainState>>, | ||
pub chains: Arc<RwLock<HashMap<ChainId, BlockchainState>>>, |
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.
you can use Dashmap for a concurrent hashmap https://docs.rs/dashmap/latest/dashmap/struct.DashMap.html
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.
Also I think this should be a HashMap<ChainId, Option<BlockchainState>>
so "chain is uninitialized" isn't conflated with "unknown chain id". You could make BlockchainState an enum or something as well to handle this.
apps/fortuna/src/command/run.rs
Outdated
chains.insert(chain_id.clone(), state); | ||
match state { | ||
Ok(state) => { | ||
keeper_metrics.add_chain(chain_id.clone(), state.provider_address); |
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.
it's probably better to run this for every chain before it's set up (?) wondering how we will report metrics in the case where the chain never gets initialized.
apps/fortuna/src/state.rs
Outdated
} | ||
|
||
pub fn from_config( | ||
pub async fn from_config( |
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.
can i suggest making a separate constructor method that spawns the original from_config in a blocking thread? like from_config_async
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.
nice
pub enum ApiBlockChainState { | ||
Uninitialized, | ||
Initialized(BlockchainState), | ||
} |
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.
👍
apps/fortuna/src/command/run.rs
Outdated
} | ||
|
||
#[allow(clippy::too_many_arguments)] | ||
async fn setup_chain( |
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.
setup_chain_and_run_keeper ?
[[package]] | ||
name = "fortuna" | ||
version = "7.5.2" | ||
version = "7.5.3" |
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.
why is this here but not in Cargo.toml
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.
main branch didn't updated the Cargo.lock
Summary
Rationale
These changes improve the reliability of running fortuna in production.
How has this been tested?