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

refactor mobilecoind api to not depend on consensus-api #3307

Merged
merged 8 commits into from
Apr 10, 2023
Merged
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
6 changes: 6 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,12 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/).

The crates in this repository do not adhere to [Semantic Versioning](https://semver.org/spec/v2.0.0.html) at this time.

## [5.0.0]

### Changed

- mobilecoind now has its own version of the `LastBlockInfo` proto message. ([#3307])

## [4.1.0]

### Changed
Expand Down
1 change: 0 additions & 1 deletion Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 0 additions & 1 deletion mobilecoind/api/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,6 @@ rust-version = { workspace = true }

[dependencies]
mc-api = { path = "../../api" }
mc-consensus-api = { path = "../../consensus/api" }
mc-util-uri = { path = "../../util/uri" }

futures = "0.3"
Expand Down
5 changes: 0 additions & 5 deletions mobilecoind/api/build.rs
Original file line number Diff line number Diff line change
Expand Up @@ -16,12 +16,7 @@ fn main() {
.depvar("MC_API_PROTOS_PATH")
.expect("Could not read api's protos path")
.to_owned();
let consensus_api_proto_path = env
.depvar("MC_CONSENSUS_API_PROTOS_PATH")
.expect("Could not read api's protos path")
.to_owned();
let mut all_proto_dirs = api_proto_path.split(':').collect::<Vec<&str>>();
all_proto_dirs.extend(consensus_api_proto_path.split(':'));
all_proto_dirs.push(proto_str);

mc_util_build_grpc::compile_protos_and_generate_mod_rs(
Expand Down
26 changes: 23 additions & 3 deletions mobilecoind/api/proto/mobilecoind_api.proto
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@ syntax = "proto3";
import "google/protobuf/empty.proto";
import "external.proto";
import "blockchain.proto";
import "consensus_common.proto";

package mobilecoind_api;

Expand Down Expand Up @@ -961,10 +960,31 @@ message GetNetworkStatusResponse {
// Whether we are behind.
bool is_behind = 4;

// The latest block info reported by a consensus node
consensus_common.LastBlockInfoResponse last_block_info = 5;
// The latest block info data reported by a consensus node
LastBlockInfo last_block_info = 5;
}

// Data about the network state and last block processed by the consensus network
message LastBlockInfo {
cbeck88 marked this conversation as resolved.
Show resolved Hide resolved
// Block index
cbeck88 marked this conversation as resolved.
Show resolved Hide resolved
uint64 index = 1;

// Current MOB minimum fee (kept for backwards compatibility)
uint64 mob_minimum_fee = 2 [deprecated = true];

// A map of token id -> minimum fee
map<uint64, uint64> minimum_fees = 3;

// Current network_block version, appropriate for new transactions.
//
// Note that if the server was just reconfigured, this may be HIGHER than
// the highest block version in the ledger, so for clients this is a better
// source of truth than the local ledger, if the client might possibly be
// creating the first transaction after a reconfigure / redeploy.
uint32 network_block_version = 4;
}


//
// Database encryption
//
Expand Down
1 change: 0 additions & 1 deletion mobilecoind/api/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@ use mc_util_uri::{Uri, UriScheme};
mod autogenerated_code {
// Expose proto data types from included third-party/external proto files.
pub use mc_api::{blockchain, external, printable};
pub use mc_consensus_api::consensus_common;
pub use protobuf::well_known_types::Empty;

// Needed due to how to the auto-generated code references the Empty message.
Expand Down
20 changes: 19 additions & 1 deletion mobilecoind/src/service.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2158,6 +2158,24 @@ impl<T: BlockchainConnection + UserTxConnection + 'static, FPR: FogPubkeyResolve
RpcStatus::with_message(RpcStatusCode::INTERNAL, "no peers reachable".to_owned())
})?;

let mut mcd_last_block_info = api::LastBlockInfo::new();
mcd_last_block_info.set_index(last_block_info.block_index);
cbeck88 marked this conversation as resolved.
Show resolved Hide resolved
mcd_last_block_info.set_mob_minimum_fee(
last_block_info
.minimum_fees
.get(&TokenId::from(0))
.cloned()
.unwrap_or(0),
);
mcd_last_block_info.set_minimum_fees(
last_block_info
.minimum_fees
.into_iter()
.map(|(token_id, fee)| (*token_id, fee))
.collect(),
);
mcd_last_block_info.set_network_block_version(last_block_info.network_block_version);

let mut response = api::GetNetworkStatusResponse::new();

response.set_network_highest_block_index(
Expand All @@ -2172,7 +2190,7 @@ impl<T: BlockchainConnection + UserTxConnection + 'static, FPR: FogPubkeyResolve
);
response.set_local_block_index(local_block_index);
response.set_is_behind(network_state.is_behind(local_block_index));
response.set_last_block_info(last_block_info.into());
response.set_last_block_info(mcd_last_block_info);

Ok(response)
}
Expand Down