Skip to content

feat(rpc): Add invalidateblock and reconsiderblock RPC methods #9266

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

Closed
wants to merge 14 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
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
118 changes: 99 additions & 19 deletions zebra-rpc/src/methods.rs
Original file line number Diff line number Diff line change
Expand Up @@ -341,6 +341,24 @@
address_strings: AddressStrings,
) -> Result<Vec<GetAddressUtxos>>;

/// Invalidates a block if it is not yet finalized, removing it from the non-finalized
/// state if it is present and rejecting it during contextual validation if it is submitted.
///
/// # Parameters
///
/// - `block_hash`: (hex-encoded block hash, required) The block hash to invalidate.
// TODO: Invalidate block hashes even if they're not present in the non-finalized state.
#[method(name = "invalidateblock")]
async fn invalidate_block(&self, block_hash: GetBlockHash) -> Result<()>;

/// Reconsiders a previously invalidated block if it exists in the cache of previously invalidated blocks.
///
/// # Parameters
///
/// - `block_hash`: (hex-encoded block hash, required) The block hash to reconsider.
#[method(name = "reconsiderblock")]
async fn reconsider_block(&self, block_hash: GetBlockHash) -> Result<()>;

/// Stop the running zebrad process.
///
/// # Notes
Expand All @@ -357,7 +375,7 @@

/// RPC method implementations.
#[derive(Clone)]
pub struct RpcImpl<Mempool, State, Tip, AddressBook>
pub struct RpcImpl<Mempool, State, ReadState, Tip, AddressBook>
where
Mempool: Service<
mempool::Request,
Expand All @@ -369,14 +387,23 @@
+ 'static,
Mempool::Future: Send,
State: Service<
zebra_state::Request,
Response = zebra_state::Response,
Error = zebra_state::BoxError,
> + Clone
+ Send
+ Sync
+ 'static,
State::Future: Send,
ReadState: Service<
zebra_state::ReadRequest,
Response = zebra_state::ReadResponse,
Error = zebra_state::BoxError,
> + Clone
+ Send
+ Sync
+ 'static,
State::Future: Send,
ReadState::Future: Send,
Tip: ChainTip + Clone + Send + Sync + 'static,
AddressBook: AddressBookPeers + Clone + Send + Sync + 'static,
{
Expand Down Expand Up @@ -407,6 +434,9 @@
/// A handle to the state service.
state: State,

/// A handle to the state service.
read_state: ReadState,

/// Allows efficient access to the best tip of the blockchain.
latest_chain_tip: Tip,

Expand All @@ -425,7 +455,8 @@
/// A type alias for the last event logged by the server.
pub type LoggedLastEvent = watch::Receiver<Option<(String, tracing::Level, chrono::DateTime<Utc>)>>;

impl<Mempool, State, Tip, AddressBook> Debug for RpcImpl<Mempool, State, Tip, AddressBook>
impl<Mempool, State, ReadState, Tip, AddressBook> Debug
for RpcImpl<Mempool, State, ReadState, Tip, AddressBook>
where
Mempool: Service<
mempool::Request,
Expand All @@ -437,14 +468,23 @@
+ 'static,
Mempool::Future: Send,
State: Service<
zebra_state::Request,
Response = zebra_state::Response,
Error = zebra_state::BoxError,
> + Clone
+ Send
+ Sync
+ 'static,
State::Future: Send,
ReadState: Service<
zebra_state::ReadRequest,
Response = zebra_state::ReadResponse,
Error = zebra_state::BoxError,
> + Clone
+ Send
+ Sync
+ 'static,
State::Future: Send,
ReadState::Future: Send,
Tip: ChainTip + Clone + Send + Sync + 'static,
AddressBook: AddressBookPeers + Clone + Send + Sync + 'static,
{
Expand All @@ -460,7 +500,8 @@
}
}

impl<Mempool, State, Tip, AddressBook> RpcImpl<Mempool, State, Tip, AddressBook>
impl<Mempool, State, ReadState, Tip, AddressBook>
RpcImpl<Mempool, State, ReadState, Tip, AddressBook>
where
Mempool: Service<
mempool::Request,
Expand All @@ -472,14 +513,23 @@
+ 'static,
Mempool::Future: Send,
State: Service<
zebra_state::Request,
Response = zebra_state::Response,
Error = zebra_state::BoxError,
> + Clone
+ Send
+ Sync
+ 'static,
State::Future: Send,
ReadState: Service<
zebra_state::ReadRequest,
Response = zebra_state::ReadResponse,
Error = zebra_state::BoxError,
> + Clone
+ Send
+ Sync
+ 'static,
State::Future: Send,
ReadState::Future: Send,
Tip: ChainTip + Clone + Send + Sync + 'static,
AddressBook: AddressBookPeers + Clone + Send + Sync + 'static,
{
Expand All @@ -496,6 +546,7 @@
debug_like_zcashd: bool,
mempool: Mempool,
state: State,
read_state: ReadState,
latest_chain_tip: Tip,
address_book: AddressBook,
last_warn_error_log_rx: LoggedLastEvent,
Expand All @@ -521,7 +572,8 @@
debug_force_finished_sync,
debug_like_zcashd,
mempool: mempool.clone(),
state: state.clone(),
state,
read_state: read_state.clone(),
latest_chain_tip: latest_chain_tip.clone(),
queue_sender,
address_book,
Expand All @@ -531,7 +583,7 @@
// run the process queue
let rpc_tx_queue_task_handle = tokio::spawn(
runner
.run(mempool, state, latest_chain_tip, network)
.run(mempool, read_state, latest_chain_tip, network)
.in_current_span(),
);

Expand All @@ -540,7 +592,8 @@
}

#[async_trait]
impl<Mempool, State, Tip, AddressBook> RpcServer for RpcImpl<Mempool, State, Tip, AddressBook>
impl<Mempool, State, ReadState, Tip, AddressBook> RpcServer
for RpcImpl<Mempool, State, ReadState, Tip, AddressBook>
where
Mempool: Service<
mempool::Request,
Expand All @@ -552,14 +605,23 @@
+ 'static,
Mempool::Future: Send,
State: Service<
zebra_state::Request,
Response = zebra_state::Response,
Error = zebra_state::BoxError,
> + Clone
+ Send
+ Sync
+ 'static,
State::Future: Send,
ReadState: Service<
zebra_state::ReadRequest,
Response = zebra_state::ReadResponse,
Error = zebra_state::BoxError,
> + Clone
+ Send
+ Sync
+ 'static,
State::Future: Send,
ReadState::Future: Send,
Tip: ChainTip + Clone + Send + Sync + 'static,
AddressBook: AddressBookPeers + Clone + Send + Sync + 'static,
{
Expand Down Expand Up @@ -590,8 +652,8 @@

let relay_fee = zebra_chain::transaction::zip317::MIN_MEMPOOL_TX_FEE_RATE as f64
/ (zebra_chain::amount::COIN as f64);
let difficulty = chain_tip_difficulty(self.network.clone(), self.state.clone(), true)

Check failure on line 655 in zebra-rpc/src/methods.rs

View workflow job for this annotation

GitHub Actions / Build and Deploy Zebra Internal Docs

the trait bound `State: tower::Service<ReadRequest>` is not satisfied

Check failure on line 655 in zebra-rpc/src/methods.rs

View workflow job for this annotation

GitHub Actions / Build and Deploy Zebra Internal Docs

the trait bound `State: tower::Service<ReadRequest>` is not satisfied

Check failure on line 655 in zebra-rpc/src/methods.rs

View workflow job for this annotation

GitHub Actions / Clippy (stable) Results

the trait bound `State: tower::Service<zebra_state::ReadRequest>` is not satisfied

error[E0277]: the trait bound `State: tower::Service<zebra_state::ReadRequest>` is not satisfied --> zebra-rpc/src/methods.rs:655:26 | 655 | let difficulty = chain_tip_difficulty(self.network.clone(), self.state.clone(), true) | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ the trait `tower::Service<zebra_state::ReadRequest>` is not implemented for `State` | note: required by a bound in `methods::chain_tip_difficulty` --> zebra-rpc/src/methods.rs:2800:12 | 2794 | pub async fn chain_tip_difficulty<State>( | -------------------- required by a bound in this function ... 2800 | State: Service< | ____________^ 2801 | | zebra_state::ReadRequest, 2802 | | Response = zebra_state::ReadResponse, 2803 | | Error = zebra_state::BoxError, 2804 | | > + Clone | |_________^ required by this bound in `chain_tip_difficulty`

Check failure on line 655 in zebra-rpc/src/methods.rs

View workflow job for this annotation

GitHub Actions / Clippy (stable) Results

the trait bound `State: tower::Service<zebra_state::ReadRequest>` is not satisfied

error[E0277]: the trait bound `State: tower::Service<zebra_state::ReadRequest>` is not satisfied --> zebra-rpc/src/methods.rs:655:69 | 655 | let difficulty = chain_tip_difficulty(self.network.clone(), self.state.clone(), true) | -------------------- ^^^^^^^^^^^^^^^^^^ the trait `tower::Service<zebra_state::ReadRequest>` is not implemented for `State` | | | required by a bound introduced by this call | note: required by a bound in `methods::chain_tip_difficulty` --> zebra-rpc/src/methods.rs:2800:12 | 2794 | pub async fn chain_tip_difficulty<State>( | -------------------- required by a bound in this function ... 2800 | State: Service< | ____________^ 2801 | | zebra_state::ReadRequest, 2802 | | Response = zebra_state::ReadResponse, 2803 | | Error = zebra_state::BoxError, 2804 | | > + Clone | |_________^ required by this bound in `chain_tip_difficulty`

Check failure on line 655 in zebra-rpc/src/methods.rs

View workflow job for this annotation

GitHub Actions / Clippy (stable) Results

the trait bound `State: tower::Service<zebra_state::ReadRequest>` is not satisfied

error[E0277]: the trait bound `State: tower::Service<zebra_state::ReadRequest>` is not satisfied --> zebra-rpc/src/methods.rs:655:26 | 655 | let difficulty = chain_tip_difficulty(self.network.clone(), self.state.clone(), true) | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ the trait `tower::Service<zebra_state::ReadRequest>` is not implemented for `State` | note: required by a bound in `methods::chain_tip_difficulty` --> zebra-rpc/src/methods.rs:2800:12 | 2794 | pub async fn chain_tip_difficulty<State>( | -------------------- required by a bound in this function ... 2800 | State: Service< | ____________^ 2801 | | zebra_state::ReadRequest, 2802 | | Response = zebra_state::ReadResponse, 2803 | | Error = zebra_state::BoxError, 2804 | | > + Clone | |_________^ required by this bound in `chain_tip_difficulty`

Check failure on line 655 in zebra-rpc/src/methods.rs

View workflow job for this annotation

GitHub Actions / Clippy (stable) Results

the trait bound `State: tower::Service<zebra_state::ReadRequest>` is not satisfied

error[E0277]: the trait bound `State: tower::Service<zebra_state::ReadRequest>` is not satisfied --> zebra-rpc/src/methods.rs:655:69 | 655 | let difficulty = chain_tip_difficulty(self.network.clone(), self.state.clone(), true) | -------------------- ^^^^^^^^^^^^^^^^^^ the trait `tower::Service<zebra_state::ReadRequest>` is not implemented for `State` | | | required by a bound introduced by this call | note: required by a bound in `methods::chain_tip_difficulty` --> zebra-rpc/src/methods.rs:2800:12 | 2794 | pub async fn chain_tip_difficulty<State>( | -------------------- required by a bound in this function ... 2800 | State: Service< | ____________^ 2801 | | zebra_state::ReadRequest, 2802 | | Response = zebra_state::ReadResponse, 2803 | | Error = zebra_state::BoxError, 2804 | | > + Clone | |_________^ required by this bound in `chain_tip_difficulty`

Check failure on line 655 in zebra-rpc/src/methods.rs

View workflow job for this annotation

GitHub Actions / Clippy (stable) Results

the trait bound `State: tower::Service<zebra_state::ReadRequest>` is not satisfied

error[E0277]: the trait bound `State: tower::Service<zebra_state::ReadRequest>` is not satisfied --> zebra-rpc/src/methods.rs:655:26 | 655 | let difficulty = chain_tip_difficulty(self.network.clone(), self.state.clone(), true) | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ the trait `tower::Service<zebra_state::ReadRequest>` is not implemented for `State` | note: required by a bound in `methods::chain_tip_difficulty` --> zebra-rpc/src/methods.rs:2800:12 | 2794 | pub async fn chain_tip_difficulty<State>( | -------------------- required by a bound in this function ... 2800 | State: Service< | ____________^ 2801 | | zebra_state::ReadRequest, 2802 | | Response = zebra_state::ReadResponse, 2803 | | Error = zebra_state::BoxError, 2804 | | > + Clone | |_________^ required by this bound in `chain_tip_difficulty`

Check failure on line 655 in zebra-rpc/src/methods.rs

View workflow job for this annotation

GitHub Actions / Clippy (stable) Results

the trait bound `State: tower::Service<zebra_state::ReadRequest>` is not satisfied

error[E0277]: the trait bound `State: tower::Service<zebra_state::ReadRequest>` is not satisfied --> zebra-rpc/src/methods.rs:655:69 | 655 | let difficulty = chain_tip_difficulty(self.network.clone(), self.state.clone(), true) | -------------------- ^^^^^^^^^^^^^^^^^^ the trait `tower::Service<zebra_state::ReadRequest>` is not implemented for `State` | | | required by a bound introduced by this call | note: required by a bound in `methods::chain_tip_difficulty` --> zebra-rpc/src/methods.rs:2800:12 | 2794 | pub async fn chain_tip_difficulty<State>( | -------------------- required by a bound in this function ... 2800 | State: Service< | ____________^ 2801 | | zebra_state::ReadRequest, 2802 | | Response = zebra_state::ReadResponse, 2803 | | Error = zebra_state::BoxError, 2804 | | > + Clone | |_________^ required by this bound in `chain_tip_difficulty`

Check failure on line 655 in zebra-rpc/src/methods.rs

View workflow job for this annotation

GitHub Actions / Build zebra-utils crate

the trait bound `State: tower::Service<zebra_state::ReadRequest>` is not satisfied

Check failure on line 655 in zebra-rpc/src/methods.rs

View workflow job for this annotation

GitHub Actions / Build zebra-utils crate

the trait bound `State: tower::Service<zebra_state::ReadRequest>` is not satisfied

Check failure on line 655 in zebra-rpc/src/methods.rs

View workflow job for this annotation

GitHub Actions / Test stable on ubuntu-latest

the trait bound `State: tower::Service<ReadRequest>` is not satisfied

Check failure on line 655 in zebra-rpc/src/methods.rs

View workflow job for this annotation

GitHub Actions / Test stable on ubuntu-latest

the trait bound `State: tower::Service<ReadRequest>` is not satisfied

Check failure on line 655 in zebra-rpc/src/methods.rs

View workflow job for this annotation

GitHub Actions / Check Cargo.lock is up to date

the trait bound `State: tower::Service<ReadRequest>` is not satisfied

Check failure on line 655 in zebra-rpc/src/methods.rs

View workflow job for this annotation

GitHub Actions / Check Cargo.lock is up to date

the trait bound `State: tower::Service<ReadRequest>` is not satisfied

Check failure on line 655 in zebra-rpc/src/methods.rs

View workflow job for this annotation

GitHub Actions / Test beta on ubuntu-latest

the trait bound `State: tower::Service<ReadRequest>` is not satisfied

Check failure on line 655 in zebra-rpc/src/methods.rs

View workflow job for this annotation

GitHub Actions / Test beta on ubuntu-latest

the trait bound `State: tower::Service<ReadRequest>` is not satisfied

Check failure on line 655 in zebra-rpc/src/methods.rs

View workflow job for this annotation

GitHub Actions / Test stable on macos-latest

the trait bound `State: tower::Service<ReadRequest>` is not satisfied

Check failure on line 655 in zebra-rpc/src/methods.rs

View workflow job for this annotation

GitHub Actions / Test stable on macos-latest

the trait bound `State: tower::Service<ReadRequest>` is not satisfied

Check failure on line 655 in zebra-rpc/src/methods.rs

View workflow job for this annotation

GitHub Actions / Install zebrad from lockfile without cache on ubuntu-latest

the trait bound `State: tower::Service<ReadRequest>` is not satisfied

Check failure on line 655 in zebra-rpc/src/methods.rs

View workflow job for this annotation

GitHub Actions / Install zebrad from lockfile without cache on ubuntu-latest

the trait bound `State: tower::Service<ReadRequest>` is not satisfied

Check failure on line 655 in zebra-rpc/src/methods.rs

View workflow job for this annotation

GitHub Actions / Test stable on windows-latest

the trait bound `State: tower::Service<ReadRequest>` is not satisfied

Check failure on line 655 in zebra-rpc/src/methods.rs

View workflow job for this annotation

GitHub Actions / Test stable on windows-latest

the trait bound `State: tower::Service<ReadRequest>` is not satisfied

Check failure on line 655 in zebra-rpc/src/methods.rs

View workflow job for this annotation

GitHub Actions / Test beta on windows-latest

the trait bound `State: tower::Service<ReadRequest>` is not satisfied

Check failure on line 655 in zebra-rpc/src/methods.rs

View workflow job for this annotation

GitHub Actions / Test beta on windows-latest

the trait bound `State: tower::Service<ReadRequest>` is not satisfied
.await

Check failure on line 656 in zebra-rpc/src/methods.rs

View workflow job for this annotation

GitHub Actions / Build and Deploy Zebra Internal Docs

the trait bound `State: tower::Service<ReadRequest>` is not satisfied

Check failure on line 656 in zebra-rpc/src/methods.rs

View workflow job for this annotation

GitHub Actions / Clippy (stable) Results

the trait bound `State: tower::Service<zebra_state::ReadRequest>` is not satisfied

error[E0277]: the trait bound `State: tower::Service<zebra_state::ReadRequest>` is not satisfied --> zebra-rpc/src/methods.rs:656:14 | 656 | .await | ^^^^^ the trait `tower::Service<zebra_state::ReadRequest>` is not implemented for `State` | note: required by a bound in `methods::chain_tip_difficulty` --> zebra-rpc/src/methods.rs:2800:12 | 2794 | pub async fn chain_tip_difficulty<State>( | -------------------- required by a bound in this function ... 2800 | State: Service< | ____________^ 2801 | | zebra_state::ReadRequest, 2802 | | Response = zebra_state::ReadResponse, 2803 | | Error = zebra_state::BoxError, 2804 | | > + Clone | |_________^ required by this bound in `chain_tip_difficulty`

Check failure on line 656 in zebra-rpc/src/methods.rs

View workflow job for this annotation

GitHub Actions / Clippy (stable) Results

the trait bound `State: tower::Service<zebra_state::ReadRequest>` is not satisfied

error[E0277]: the trait bound `State: tower::Service<zebra_state::ReadRequest>` is not satisfied --> zebra-rpc/src/methods.rs:656:14 | 656 | .await | ^^^^^ the trait `tower::Service<zebra_state::ReadRequest>` is not implemented for `State` | note: required by a bound in `methods::chain_tip_difficulty` --> zebra-rpc/src/methods.rs:2800:12 | 2794 | pub async fn chain_tip_difficulty<State>( | -------------------- required by a bound in this function ... 2800 | State: Service< | ____________^ 2801 | | zebra_state::ReadRequest, 2802 | | Response = zebra_state::ReadResponse, 2803 | | Error = zebra_state::BoxError, 2804 | | > + Clone | |_________^ required by this bound in `chain_tip_difficulty`

Check failure on line 656 in zebra-rpc/src/methods.rs

View workflow job for this annotation

GitHub Actions / Clippy (stable) Results

the trait bound `State: tower::Service<zebra_state::ReadRequest>` is not satisfied

error[E0277]: the trait bound `State: tower::Service<zebra_state::ReadRequest>` is not satisfied --> zebra-rpc/src/methods.rs:656:14 | 656 | .await | ^^^^^ the trait `tower::Service<zebra_state::ReadRequest>` is not implemented for `State` | note: required by a bound in `methods::chain_tip_difficulty` --> zebra-rpc/src/methods.rs:2800:12 | 2794 | pub async fn chain_tip_difficulty<State>( | -------------------- required by a bound in this function ... 2800 | State: Service< | ____________^ 2801 | | zebra_state::ReadRequest, 2802 | | Response = zebra_state::ReadResponse, 2803 | | Error = zebra_state::BoxError, 2804 | | > + Clone | |_________^ required by this bound in `chain_tip_difficulty`

Check failure on line 656 in zebra-rpc/src/methods.rs

View workflow job for this annotation

GitHub Actions / Build zebra-utils crate

the trait bound `State: tower::Service<zebra_state::ReadRequest>` is not satisfied

Check failure on line 656 in zebra-rpc/src/methods.rs

View workflow job for this annotation

GitHub Actions / Test stable on ubuntu-latest

the trait bound `State: tower::Service<ReadRequest>` is not satisfied

Check failure on line 656 in zebra-rpc/src/methods.rs

View workflow job for this annotation

GitHub Actions / Check Cargo.lock is up to date

the trait bound `State: tower::Service<ReadRequest>` is not satisfied

Check failure on line 656 in zebra-rpc/src/methods.rs

View workflow job for this annotation

GitHub Actions / Test beta on ubuntu-latest

the trait bound `State: tower::Service<ReadRequest>` is not satisfied

Check failure on line 656 in zebra-rpc/src/methods.rs

View workflow job for this annotation

GitHub Actions / Test stable on macos-latest

the trait bound `State: tower::Service<ReadRequest>` is not satisfied

Check failure on line 656 in zebra-rpc/src/methods.rs

View workflow job for this annotation

GitHub Actions / Install zebrad from lockfile without cache on ubuntu-latest

the trait bound `State: tower::Service<ReadRequest>` is not satisfied

Check failure on line 656 in zebra-rpc/src/methods.rs

View workflow job for this annotation

GitHub Actions / Test stable on windows-latest

the trait bound `State: tower::Service<ReadRequest>` is not satisfied

Check failure on line 656 in zebra-rpc/src/methods.rs

View workflow job for this annotation

GitHub Actions / Test beta on windows-latest

the trait bound `State: tower::Service<ReadRequest>` is not satisfied
.expect("should always be Ok when `should_use_default` is true");

let response = GetInfo {
Expand Down Expand Up @@ -620,11 +682,11 @@

let (usage_info_rsp, tip_pool_values_rsp, chain_tip_difficulty) = {
use zebra_state::ReadRequest::*;
let state_call = |request| self.state.clone().oneshot(request);
let state_call = |request| self.read_state.clone().oneshot(request);
tokio::join!(

Check failure on line 686 in zebra-rpc/src/methods.rs

View workflow job for this annotation

GitHub Actions / Build and Deploy Zebra Internal Docs

the trait bound `State: tower::Service<ReadRequest>` is not satisfied

Check failure on line 686 in zebra-rpc/src/methods.rs

View workflow job for this annotation

GitHub Actions / Build zebra-utils crate

the trait bound `State: tower::Service<zebra_state::ReadRequest>` is not satisfied

Check failure on line 686 in zebra-rpc/src/methods.rs

View workflow job for this annotation

GitHub Actions / Test stable on ubuntu-latest

the trait bound `State: tower::Service<ReadRequest>` is not satisfied

Check failure on line 686 in zebra-rpc/src/methods.rs

View workflow job for this annotation

GitHub Actions / Check Cargo.lock is up to date

the trait bound `State: tower::Service<ReadRequest>` is not satisfied

Check failure on line 686 in zebra-rpc/src/methods.rs

View workflow job for this annotation

GitHub Actions / Test beta on ubuntu-latest

the trait bound `State: tower::Service<ReadRequest>` is not satisfied

Check failure on line 686 in zebra-rpc/src/methods.rs

View workflow job for this annotation

GitHub Actions / Test stable on macos-latest

the trait bound `State: tower::Service<ReadRequest>` is not satisfied

Check failure on line 686 in zebra-rpc/src/methods.rs

View workflow job for this annotation

GitHub Actions / Install zebrad from lockfile without cache on ubuntu-latest

the trait bound `State: tower::Service<ReadRequest>` is not satisfied

Check failure on line 686 in zebra-rpc/src/methods.rs

View workflow job for this annotation

GitHub Actions / Test stable on windows-latest

the trait bound `State: tower::Service<ReadRequest>` is not satisfied

Check failure on line 686 in zebra-rpc/src/methods.rs

View workflow job for this annotation

GitHub Actions / Test beta on windows-latest

the trait bound `State: tower::Service<ReadRequest>` is not satisfied
state_call(UsageInfo),
state_call(TipPoolValues),
chain_tip_difficulty(network.clone(), self.state.clone(), true)

Check failure on line 689 in zebra-rpc/src/methods.rs

View workflow job for this annotation

GitHub Actions / Build and Deploy Zebra Internal Docs

the trait bound `State: tower::Service<ReadRequest>` is not satisfied

Check failure on line 689 in zebra-rpc/src/methods.rs

View workflow job for this annotation

GitHub Actions / Build and Deploy Zebra Internal Docs

the trait bound `State: tower::Service<ReadRequest>` is not satisfied

Check failure on line 689 in zebra-rpc/src/methods.rs

View workflow job for this annotation

GitHub Actions / Clippy (stable) Results

the trait bound `State: tower::Service<zebra_state::ReadRequest>` is not satisfied

error[E0277]: the trait bound `State: tower::Service<zebra_state::ReadRequest>` is not satisfied --> zebra-rpc/src/methods.rs:689:17 | 689 | chain_tip_difficulty(network.clone(), self.state.clone(), true) | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ the trait `tower::Service<zebra_state::ReadRequest>` is not implemented for `State` | note: required by a bound in `methods::chain_tip_difficulty` --> zebra-rpc/src/methods.rs:2800:12 | 2794 | pub async fn chain_tip_difficulty<State>( | -------------------- required by a bound in this function ... 2800 | State: Service< | ____________^ 2801 | | zebra_state::ReadRequest, 2802 | | Response = zebra_state::ReadResponse, 2803 | | Error = zebra_state::BoxError, 2804 | | > + Clone | |_________^ required by this bound in `chain_tip_difficulty`

Check failure on line 689 in zebra-rpc/src/methods.rs

View workflow job for this annotation

GitHub Actions / Clippy (stable) Results

the trait bound `State: tower::Service<zebra_state::ReadRequest>` is not satisfied

error[E0277]: the trait bound `State: tower::Service<zebra_state::ReadRequest>` is not satisfied --> zebra-rpc/src/methods.rs:689:55 | 689 | chain_tip_difficulty(network.clone(), self.state.clone(), true) | -------------------- ^^^^^^^^^^^^^^^^^^ the trait `tower::Service<zebra_state::ReadRequest>` is not implemented for `State` | | | required by a bound introduced by this call | note: required by a bound in `methods::chain_tip_difficulty` --> zebra-rpc/src/methods.rs:2800:12 | 2794 | pub async fn chain_tip_difficulty<State>( | -------------------- required by a bound in this function ... 2800 | State: Service< | ____________^ 2801 | | zebra_state::ReadRequest, 2802 | | Response = zebra_state::ReadResponse, 2803 | | Error = zebra_state::BoxError, 2804 | | > + Clone | |_________^ required by this bound in `chain_tip_difficulty`

Check failure on line 689 in zebra-rpc/src/methods.rs

View workflow job for this annotation

GitHub Actions / Clippy (stable) Results

the trait bound `State: tower::Service<zebra_state::ReadRequest>` is not satisfied

error[E0277]: the trait bound `State: tower::Service<zebra_state::ReadRequest>` is not satisfied --> zebra-rpc/src/methods.rs:689:17 | 689 | chain_tip_difficulty(network.clone(), self.state.clone(), true) | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ the trait `tower::Service<zebra_state::ReadRequest>` is not implemented for `State` | note: required by a bound in `methods::chain_tip_difficulty` --> zebra-rpc/src/methods.rs:2800:12 | 2794 | pub async fn chain_tip_difficulty<State>( | -------------------- required by a bound in this function ... 2800 | State: Service< | ____________^ 2801 | | zebra_state::ReadRequest, 2802 | | Response = zebra_state::ReadResponse, 2803 | | Error = zebra_state::BoxError, 2804 | | > + Clone | |_________^ required by this bound in `chain_tip_difficulty`

Check failure on line 689 in zebra-rpc/src/methods.rs

View workflow job for this annotation

GitHub Actions / Clippy (stable) Results

the trait bound `State: tower::Service<zebra_state::ReadRequest>` is not satisfied

error[E0277]: the trait bound `State: tower::Service<zebra_state::ReadRequest>` is not satisfied --> zebra-rpc/src/methods.rs:689:55 | 689 | chain_tip_difficulty(network.clone(), self.state.clone(), true) | -------------------- ^^^^^^^^^^^^^^^^^^ the trait `tower::Service<zebra_state::ReadRequest>` is not implemented for `State` | | | required by a bound introduced by this call | note: required by a bound in `methods::chain_tip_difficulty` --> zebra-rpc/src/methods.rs:2800:12 | 2794 | pub async fn chain_tip_difficulty<State>( | -------------------- required by a bound in this function ... 2800 | State: Service< | ____________^ 2801 | | zebra_state::ReadRequest, 2802 | | Response = zebra_state::ReadResponse, 2803 | | Error = zebra_state::BoxError, 2804 | | > + Clone | |_________^ required by this bound in `chain_tip_difficulty`

Check failure on line 689 in zebra-rpc/src/methods.rs

View workflow job for this annotation

GitHub Actions / Clippy (stable) Results

the trait bound `State: tower::Service<zebra_state::ReadRequest>` is not satisfied

error[E0277]: the trait bound `State: tower::Service<zebra_state::ReadRequest>` is not satisfied --> zebra-rpc/src/methods.rs:689:17 | 689 | chain_tip_difficulty(network.clone(), self.state.clone(), true) | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ the trait `tower::Service<zebra_state::ReadRequest>` is not implemented for `State` | note: required by a bound in `methods::chain_tip_difficulty` --> zebra-rpc/src/methods.rs:2800:12 | 2794 | pub async fn chain_tip_difficulty<State>( | -------------------- required by a bound in this function ... 2800 | State: Service< | ____________^ 2801 | | zebra_state::ReadRequest, 2802 | | Response = zebra_state::ReadResponse, 2803 | | Error = zebra_state::BoxError, 2804 | | > + Clone | |_________^ required by this bound in `chain_tip_difficulty`

Check failure on line 689 in zebra-rpc/src/methods.rs

View workflow job for this annotation

GitHub Actions / Clippy (stable) Results

the trait bound `State: tower::Service<zebra_state::ReadRequest>` is not satisfied

error[E0277]: the trait bound `State: tower::Service<zebra_state::ReadRequest>` is not satisfied --> zebra-rpc/src/methods.rs:689:55 | 689 | chain_tip_difficulty(network.clone(), self.state.clone(), true) | -------------------- ^^^^^^^^^^^^^^^^^^ the trait `tower::Service<zebra_state::ReadRequest>` is not implemented for `State` | | | required by a bound introduced by this call | note: required by a bound in `methods::chain_tip_difficulty` --> zebra-rpc/src/methods.rs:2800:12 | 2794 | pub async fn chain_tip_difficulty<State>( | -------------------- required by a bound in this function ... 2800 | State: Service< | ____________^ 2801 | | zebra_state::ReadRequest, 2802 | | Response = zebra_state::ReadResponse, 2803 | | Error = zebra_state::BoxError, 2804 | | > + Clone | |_________^ required by this bound in `chain_tip_difficulty`

Check failure on line 689 in zebra-rpc/src/methods.rs

View workflow job for this annotation

GitHub Actions / Build zebra-utils crate

the trait bound `State: tower::Service<zebra_state::ReadRequest>` is not satisfied

Check failure on line 689 in zebra-rpc/src/methods.rs

View workflow job for this annotation

GitHub Actions / Build zebra-utils crate

the trait bound `State: tower::Service<zebra_state::ReadRequest>` is not satisfied

Check failure on line 689 in zebra-rpc/src/methods.rs

View workflow job for this annotation

GitHub Actions / Test stable on ubuntu-latest

the trait bound `State: tower::Service<ReadRequest>` is not satisfied

Check failure on line 689 in zebra-rpc/src/methods.rs

View workflow job for this annotation

GitHub Actions / Test stable on ubuntu-latest

the trait bound `State: tower::Service<ReadRequest>` is not satisfied

Check failure on line 689 in zebra-rpc/src/methods.rs

View workflow job for this annotation

GitHub Actions / Check Cargo.lock is up to date

the trait bound `State: tower::Service<ReadRequest>` is not satisfied

Check failure on line 689 in zebra-rpc/src/methods.rs

View workflow job for this annotation

GitHub Actions / Check Cargo.lock is up to date

the trait bound `State: tower::Service<ReadRequest>` is not satisfied

Check failure on line 689 in zebra-rpc/src/methods.rs

View workflow job for this annotation

GitHub Actions / Test beta on ubuntu-latest

the trait bound `State: tower::Service<ReadRequest>` is not satisfied

Check failure on line 689 in zebra-rpc/src/methods.rs

View workflow job for this annotation

GitHub Actions / Test beta on ubuntu-latest

the trait bound `State: tower::Service<ReadRequest>` is not satisfied

Check failure on line 689 in zebra-rpc/src/methods.rs

View workflow job for this annotation

GitHub Actions / Test stable on macos-latest

the trait bound `State: tower::Service<ReadRequest>` is not satisfied

Check failure on line 689 in zebra-rpc/src/methods.rs

View workflow job for this annotation

GitHub Actions / Test stable on macos-latest

the trait bound `State: tower::Service<ReadRequest>` is not satisfied

Check failure on line 689 in zebra-rpc/src/methods.rs

View workflow job for this annotation

GitHub Actions / Install zebrad from lockfile without cache on ubuntu-latest

the trait bound `State: tower::Service<ReadRequest>` is not satisfied

Check failure on line 689 in zebra-rpc/src/methods.rs

View workflow job for this annotation

GitHub Actions / Install zebrad from lockfile without cache on ubuntu-latest

the trait bound `State: tower::Service<ReadRequest>` is not satisfied

Check failure on line 689 in zebra-rpc/src/methods.rs

View workflow job for this annotation

GitHub Actions / Test stable on windows-latest

the trait bound `State: tower::Service<ReadRequest>` is not satisfied

Check failure on line 689 in zebra-rpc/src/methods.rs

View workflow job for this annotation

GitHub Actions / Test stable on windows-latest

the trait bound `State: tower::Service<ReadRequest>` is not satisfied

Check failure on line 689 in zebra-rpc/src/methods.rs

View workflow job for this annotation

GitHub Actions / Test beta on windows-latest

the trait bound `State: tower::Service<ReadRequest>` is not satisfied

Check failure on line 689 in zebra-rpc/src/methods.rs

View workflow job for this annotation

GitHub Actions / Test beta on windows-latest

the trait bound `State: tower::Service<ReadRequest>` is not satisfied
)
};

Expand Down Expand Up @@ -741,7 +803,7 @@
}

async fn get_address_balance(&self, address_strings: AddressStrings) -> Result<AddressBalance> {
let state = self.state.clone();
let state = self.read_state.clone();

let valid_addresses = address_strings.valid_addresses()?;

Expand Down Expand Up @@ -824,7 +886,7 @@
// - use `height_from_signed_int()` to handle negative heights
// (this might be better in the state request, because it needs the state height)
async fn get_block(&self, hash_or_height: String, verbosity: Option<u8>) -> Result<GetBlock> {
let mut state = self.state.clone();
let mut state = self.read_state.clone();
let verbosity = verbosity.unwrap_or(1);
let network = self.network.clone();
let original_hash_or_height = hash_or_height.clone();
Expand Down Expand Up @@ -1008,7 +1070,7 @@
hash_or_height: String,
verbose: Option<bool>,
) -> Result<GetBlockHeader> {
let state = self.state.clone();
let state = self.read_state.clone();
let verbose = verbose.unwrap_or(true);
let network = self.network.clone();

Expand Down Expand Up @@ -1232,7 +1294,7 @@
txid: String,
verbose: Option<u8>,
) -> Result<GetRawTransaction> {
let mut state = self.state.clone();
let mut state = self.read_state.clone();
let mut mempool = self.mempool.clone();
let verbose = verbose.unwrap_or(0) != 0;

Expand Down Expand Up @@ -1305,7 +1367,7 @@
// - use `height_from_signed_int()` to handle negative heights
// (this might be better in the state request, because it needs the state height)
async fn z_get_treestate(&self, hash_or_height: String) -> Result<GetTreestate> {
let mut state = self.state.clone();
let mut state = self.read_state.clone();
let network = self.network.clone();

let hash_or_height =
Expand Down Expand Up @@ -1394,7 +1456,7 @@
start_index: NoteCommitmentSubtreeIndex,
limit: Option<NoteCommitmentSubtreeIndex>,
) -> Result<GetSubtrees> {
let mut state = self.state.clone();
let mut state = self.read_state.clone();

const POOL_LIST: &[&str] = &["sapling", "orchard"];

Expand Down Expand Up @@ -1460,7 +1522,7 @@
}

async fn get_address_tx_ids(&self, request: GetAddressTxIdsRequest) -> Result<Vec<String>> {
let mut state = self.state.clone();
let mut state = self.read_state.clone();
let latest_chain_tip = self.latest_chain_tip.clone();

let height_range = build_height_range(
Expand Down Expand Up @@ -1515,7 +1577,7 @@
&self,
address_strings: AddressStrings,
) -> Result<Vec<GetAddressUtxos>> {
let mut state = self.state.clone();
let mut state = self.read_state.clone();
let mut response_utxos = vec![];

let valid_addresses = address_strings.valid_addresses()?;
Expand Down Expand Up @@ -1567,6 +1629,24 @@
Ok(response_utxos)
}

async fn invalidate_block(&self, GetBlockHash(block_hash): GetBlockHash) -> Result<()> {
self.state
.clone()
.oneshot(zebra_state::Request::InvalidateBlock(block_hash))
.await
.map(|rsp| assert_eq!(rsp, zebra_state::Response::Committed(block_hash)))
.map_misc_error()
}

async fn reconsider_block(&self, GetBlockHash(block_hash): GetBlockHash) -> Result<()> {
self.state
.clone()
.oneshot(zebra_state::Request::ReconsiderBlock(block_hash))
.await
.map(|rsp| assert_eq!(rsp, zebra_state::Response::Committed(block_hash)))
.map_misc_error()
}

fn stop(&self) -> Result<String> {
#[cfg(not(target_os = "windows"))]
if self.network.is_regtest() {
Expand Down
14 changes: 12 additions & 2 deletions zebra-rpc/src/methods/tests/prop.rs
Original file line number Diff line number Diff line change
Expand Up @@ -938,6 +938,14 @@ fn mock_services<Tip>(
zebra_node_services::mempool::Response,
zebra_test::mock_service::PropTestAssertion,
>,
tower::buffer::Buffer<
zebra_test::mock_service::MockService<
zebra_state::Request,
zebra_state::Response,
zebra_test::mock_service::PropTestAssertion,
>,
zebra_state::Request,
>,
tower::buffer::Buffer<
zebra_test::mock_service::MockService<
zebra_state::ReadRequest,
Expand All @@ -956,6 +964,7 @@ where
{
let mempool = MockService::build().for_prop_tests();
let state = MockService::build().for_prop_tests();
let read_state = MockService::build().for_prop_tests();

let (_tx, rx) = tokio::sync::watch::channel(None);
let (rpc, mempool_tx_queue) = RpcImpl::new(
Expand All @@ -965,11 +974,12 @@ where
false,
true,
mempool.clone(),
Buffer::new(state.clone(), 1),
Buffer::new(state, 1),
Buffer::new(read_state.clone(), 1),
chain_tip,
MockAddressBookPeers::new(vec![]),
rx,
);

(mempool, state, rpc, mempool_tx_queue)
(mempool, read_state, rpc, mempool_tx_queue)
}
Loading
Loading