-
Notifications
You must be signed in to change notification settings - Fork 980
fix: clearer readiness while node is still syncing #3894
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
base: staging
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -21,6 +21,7 @@ use crate::handlers::blocks_api::{BlockHandler, HeaderHandler}; | |
| use crate::handlers::chain_api::{ChainHandler, KernelHandler, OutputHandler}; | ||
| use crate::handlers::pool_api::PoolHandler; | ||
| use crate::handlers::transactions_api::TxHashSetHandler; | ||
| use crate::handlers::utils::ensure_not_syncing; | ||
| use crate::handlers::version_api::VersionHandler; | ||
| use crate::pool::{self, BlockChain, PoolAdapter, PoolEntry}; | ||
| use crate::types::{ | ||
|
|
@@ -236,6 +237,7 @@ where | |
| include_proof: Option<bool>, | ||
| _include_merkle_proof: Option<bool>, | ||
| ) -> Result<Vec<OutputPrintable>, Error> { | ||
| ensure_not_syncing(&self.sync_state)?; | ||
| let output_handler = OutputHandler { | ||
| chain: self.chain.clone(), | ||
| }; | ||
|
|
@@ -267,6 +269,7 @@ where | |
| max: u64, | ||
| include_proof: Option<bool>, | ||
| ) -> Result<OutputListing, Error> { | ||
| ensure_not_syncing(&self.sync_state)?; | ||
| let output_handler = OutputHandler { | ||
| chain: self.chain.clone(), | ||
| }; | ||
|
|
@@ -288,6 +291,8 @@ where | |
| start_block_height: u64, | ||
| end_block_height: Option<u64>, | ||
| ) -> Result<OutputListing, Error> { | ||
| // Wallet scan/info hits this early; return a clear signal while syncing (#3546). | ||
|
Contributor
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. Could we shorten this to describe the current behavior and leave the issue history in the PR? |
||
| ensure_not_syncing(&self.sync_state)?; | ||
|
Contributor
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. The current grin-wallet client only deserializes result["Ok"] and ignores result["Err"]. This therefore still becomes null and produces the same OutputListing decode error. Could we test this against the actual wallet response handling? |
||
| let txhashset_handler = TxHashSetHandler { | ||
| chain: self.chain.clone(), | ||
| }; | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -106,7 +106,13 @@ impl TxHashSetHandler { | |
| let chain = w(&self.chain)?; | ||
| let range = chain | ||
| .block_height_range_to_pmmr_indices(start_block_height, end_block_height) | ||
| .map_err(|_| Error::NotFound)?; | ||
| .map_err(|e| { | ||
| // Prefer a descriptive error over empty NotFound (wallet misreports null). | ||
| Error::Argument(format!( | ||
|
Contributor
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. Internal store or PMMR errors can also reach this path. Could we avoid reporting all chain errors as bad arguments? |
||
| "cannot map block heights {}..{:?} to PMMR indices: {}", | ||
| start_block_height, end_block_height, e | ||
| )) | ||
| })?; | ||
| let out = OutputListing { | ||
| last_retrieved_index: range.0, | ||
| highest_index: range.1, | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -52,6 +52,7 @@ where | |
| Error::Argument(msg) => response(StatusCode::BAD_REQUEST, msg), | ||
| Error::RequestError(msg) => response(StatusCode::BAD_REQUEST, msg), | ||
| Error::NotFound => response(StatusCode::NOT_FOUND, "".into()), | ||
| Error::Unavailable(msg) => response(StatusCode::SERVICE_UNAVAILABLE, msg), | ||
|
Contributor
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. None of the changed endpoints reaches this REST path. /v2/foreign still returns HTTP 200. Is the 503 mapping meant to be used elsewhere? |
||
| Error::Internal(msg) => response(StatusCode::INTERNAL_SERVER_ERROR, msg), | ||
| Error::ResponseError(msg) => response(StatusCode::INTERNAL_SERVER_ERROR, msg), | ||
| Error::Router { .. } => response(StatusCode::INTERNAL_SERVER_ERROR, "".into()), | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -878,11 +878,23 @@ impl StratumServer { | |
| let handler = Arc::new(Handler::from_stratum(&self)); | ||
| let h = handler.clone(); | ||
|
|
||
| // Wait until the node has finished syncing before accepting miner connections | ||
|
Contributor
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. Could we shorten this to describe the current behavior and leave the issue history in the PR? |
||
| // (#3546). Previously we listened early and returned confusing "syncing" / | ||
| // failed job responses while the chain was still catching up. | ||
| info!( | ||
| "(Server ID: {}) Stratum waiting for node sync before listening on {}", | ||
| self.id, | ||
| self.config.stratum_server_addr.clone().unwrap() | ||
| ); | ||
| while self.sync_state.is_syncing() { | ||
| thread::sleep(Duration::from_millis(50)); | ||
| } | ||
|
|
||
| let _listener_th = thread::spawn(move || { | ||
| accept_connections(listen_addr, h); | ||
| }); | ||
|
|
||
| // We have started | ||
| // We have started (only after sync so is_running matches actual readiness). | ||
|
Contributor
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. The listener binds in the spawned thread, so this flag can still become true before bind succeeds. Could startup report success before we mark Stratum as running? |
||
| { | ||
| let mut stratum_stats = self.stratum_stats.write(); | ||
| stratum_stats.is_running = true; | ||
|
|
@@ -895,11 +907,6 @@ impl StratumServer { | |
| self.config.stratum_server_addr.clone().unwrap() | ||
| ); | ||
|
|
||
| // Initial Loop. Waiting node complete syncing | ||
| while self.sync_state.is_syncing() { | ||
| thread::sleep(Duration::from_millis(50)); | ||
| } | ||
|
|
||
| handler.run(&self.config, &self.tx_pool); | ||
| } // fn run_loop() | ||
| } // StratumServer | ||
|
|
||
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.
The current grin-wallet client only reads result["Ok"], so these Err responses still become null and produce decode errors. Could we test all three methods through the actual wallet RPC handling?