Skip to content

RPC types changes/fixes#604

Merged
Boog900 merged 5 commits intomainfrom
rpc-types-fixes
May 5, 2026
Merged

RPC types changes/fixes#604
Boog900 merged 5 commits intomainfrom
rpc-types-fixes

Conversation

@Boog900
Copy link
Copy Markdown
Member

@Boog900 Boog900 commented Apr 28, 2026

Will add comments on the main changes.

@github-actions github-actions Bot added A-dependency Area: Related to dependencies, or changes to a Cargo.{toml,lock} file. A-workspace Area: Changes to a root workspace file or general repo file. A-rpc Area: Related to RPC. A-binaries Area: Related to binaries. labels Apr 28, 2026
Comment thread rpc/types/src/bin.rs
start_height: u64,
},
AccessResponseBase {
m_blocks_ids: ByteArrayVec<32> = default::<ByteArrayVec<32>>(), "default",
Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Typo fix The field name in monerod is m_block_ids.

Comment thread rpc/types/src/bin.rs
Comment on lines -74 to -88
#[cfg(feature = "epee")]
define_request_and_response! {
get_o_indexesbin,
"cc73fe71162d564ffda8e549b79a350bca53c454" =>
core_rpc_server_commands_defs.h => 487..=510,
GetOutputIndexes,
#[derive(Copy)]
Request {
txid: [u8; 32],
},
AccessResponseBase {
o_indexes: Vec<u64> as ContainerAsBlob<u64>,
}
}

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Removed the duplicate of GetOutputIndexes that wrapped o_indexes in ContainerAsBlob<u64>. monerod uses plain KV_SERIALIZE(o_indexes) for both, not KV_SERIALIZE_CONTAINER_POD_AS_BLOB.

Comment thread rpc/types/src/bin.rs
GetOuts,
Request {
outputs: Vec<GetOutputsOut> = default::<Vec<GetOutputsOut>>(), "default",
get_txid: bool,
Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Comment thread rpc/types/src/json.rs
Comment on lines +732 to +881
define_request_and_response! {
UNDOCUMENTED_METHOD,
"cc73fe71162d564ffda8e549b79a350bca53c454" =>
core_rpc_server_commands_defs.h => 2522..=2556,

RpcAccessInfo,

Request {
client: String,
},

AccessResponseBase {
hashing_blob: String,
seed_height: u64,
seed_hash: String,
next_seed_hash: String,
cookie: u32,
diff: u64,
credits_per_hash_found: u64,
height: u64,
}
}

define_request_and_response! {
UNDOCUMENTED_METHOD,
"cc73fe71162d564ffda8e549b79a350bca53c454" =>
core_rpc_server_commands_defs.h => 2558..=2580,

RpcAccessSubmitNonce,

Request {
client: String,
nonce: u32,
cookie: u32,
},

AccessResponseBase {}
}

define_request_and_response! {
UNDOCUMENTED_METHOD,
"cc73fe71162d564ffda8e549b79a350bca53c454" =>
core_rpc_server_commands_defs.h => 2582..=2604,

RpcAccessPay,

Request {
client: String,
paying_for: String,
payment: u64,
},

AccessResponseBase {}
}

/// An entry in [`RpcAccessTrackingResponse`].
#[derive(
serde::Serialize, serde::Deserialize, Clone, Debug, Ord, PartialOrd, Eq, PartialEq, Hash,
)]
pub struct RpcAccessTrackingEntry {
rpc: String,
count: u64,
time: u64,
credits: u64,
}

cuprate_epee_encoding::epee_object!(
RpcAccessTrackingEntry,
rpc: String,
count: u64,
time: u64,
credits: u64,
);

define_request_and_response! {
UNDOCUMENTED_METHOD,
"cc73fe71162d564ffda8e549b79a350bca53c454" =>
core_rpc_server_commands_defs.h => 2606..=2644,

RpcAccessTracking (restricted),

Request {
clear: bool,
},

ResponseBase {
data: Vec<RpcAccessTrackingEntry>,
}
}

/// An entry in [`RpcAccessDataResponse`].
#[derive(
serde::Serialize, serde::Deserialize, Clone, Debug, Ord, PartialOrd, Eq, PartialEq, Hash,
)]
pub struct RpcAccessDataEntry {
client: String,
balance: u64,
last_update_time: u64,
credits_total: u64,
credits_used: u64,
nonces_good: u64,
nonces_stale: u64,
nonces_bad: u64,
nonces_dupe: u64,
}

cuprate_epee_encoding::epee_object!(
RpcAccessDataEntry,
client: String,
balance: u64,
last_update_time: u64,
credits_total: u64,
credits_used: u64,
nonces_good: u64,
nonces_stale: u64,
nonces_bad: u64,
nonces_dupe: u64,
);

define_request_and_response! {
UNDOCUMENTED_METHOD,
"cc73fe71162d564ffda8e549b79a350bca53c454" =>
core_rpc_server_commands_defs.h => 2646..=2692,

RpcAccessData (restricted),

Request { },

ResponseBase {
entries: Vec<RpcAccessDataEntry>,
hashrate: u32,
}
}

define_request_and_response! {
UNDOCUMENTED_METHOD,
"cc73fe71162d564ffda8e549b79a350bca53c454" =>
core_rpc_server_commands_defs.h => 2695..=2720,

RpcAccessAccount (restricted),

Request {
client: String,
delta_balance: i64 = default::<i64>(), "default",
},

ResponseBase {
credits: u64,
}
}
Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

These types were all not included with the initial RPC stuff, added them now, although they wont be used.

Comment thread rpc/types/src/json.rs
Comment on lines +511 to +513
current_height: u64 = default::<u64>(), "default",
#[cfg_attr(feature = "serde", serde(skip_serializing_if = "crate::free::is_zero"))]
target_height: u64 = default::<u64>(), "default",
Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Comment thread rpc/types/src/json.rs
Comment on lines +949 to +950
impl<'de> Deserialize<'de> for JsonRpcRequest {
fn deserialize<D: serde::Deserializer<'de>>(deserializer: D) -> Result<Self, D::Error> {
Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I wanted to avoid this, but I don't think we can. I added 2 step deserialisation as it's the only way to handle the different ways the empty params field can be accepted.

Comment thread rpc/types/src/json.rs
SetBans(SetBansRequest),
GetBans(GetBansRequest),
Banned(BannedRequest),
FlushTransactionPool(FlushTransactionPoolRequest),
Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Comment thread rpc/types/src/other.rs
#[cfg_attr(feature = "serde", derive(Deserialize, Serialize))]
#[cfg_attr(feature = "serde", serde(untagged))]
pub enum OtherRequest {
GetInfo(GetInfoRequest),
Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Comment on lines +25 to +30
fn compress_integer_array(v: &[u64]) -> Vec<u8> {
let mut out = Vec::with_capacity(v.len() * 2);
for val in v {
VarInt::write(val, &mut out).expect("Writing to vec should not fail");
}
out
Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Comment on lines +227 to 246
match name {
"start_height" => self.start_height = Some(read_epee_value(r)?),
"base" => self.base = Some(read_epee_value(r)?),
"amount" => self.amount = Some(read_epee_value(r)?),
"binary" => self.binary = Some(read_epee_value(r)?),
"compress" => self.compress = Some(read_epee_value(r)?),
"compressed_data" => self.compressed_data = Some(read_epee_value(r)?),
// `distribution` arrives as a raw LE-u64 blob when `binary=true`
// (monerod uses `KV_SERIALIZE_CONTAINER_POD_AS_BLOB_N`) or as a
// typed EPEE u64 array when `binary=false`. Detect via marker.
"distribution" => {
let marker = read_marker(r)?;
self.distribution = Some(if marker == ContainerAsBlob::<u64>::MARKER {
ContainerAsBlob::<u64>::read(r, &marker)?.into()
} else {
Vec::<u64>::read(r, &marker)?
});
}
_ => return Ok(false),
}
Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@github-actions github-actions Bot added the A-docs Area: Related to documentation. label Apr 30, 2026
@Boog900 Boog900 marked this pull request as ready for review May 1, 2026 17:27
#[doc = monero_definition_link!("cc73fe71162d564ffda8e549b79a350bca53c454", "/rpc/core_rpc_server_commands_defs.h", 91)]
/// RPC miror version.
pub const CORE_RPC_VERSION_MINOR: u32 = 14;
pub const CORE_RPC_VERSION_MINOR: u32 = 15;
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

MINOR bump to 15: the still relevant addition in monerod is monero-project/monero#9383, which adds top_block_hash to /getblocks.bin's response

Should be added with the bump or new issue? theres already a TODO for it fwiw

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ah yeah, this PR is split from my wider RPC changes, where this is already done. I'll leave this for now as it'll be ok once the rest is merged.

Comment thread rpc/types/src/json.rs Outdated
Comment thread rpc/types/src/json.rs
Comment on lines +1027 to +1029
"rpc_access_submit_nonce" => {
Self::RpcAccessSubmitNonce(de!(RpcAccessSubmitNonceRequest))
}
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nits: maybe inhibit rustfmt here to have unified formatting ?

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

would rather just leave this

Copy link
Copy Markdown
Member

@SyntheticBird45 SyntheticBird45 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

first pass. Will approve tomorrow

@github-actions github-actions Bot added the A-types Area: Related to types. label May 5, 2026
@github-actions github-actions Bot added the A-ci Area: Related to CI. label May 5, 2026
@Boog900 Boog900 requested a review from SyntheticBird45 May 5, 2026 09:41
@Boog900
Copy link
Copy Markdown
Member Author

Boog900 commented May 5, 2026

fuzz CI error is not due to this PR

@Boog900 Boog900 merged commit 704a665 into main May 5, 2026
13 of 19 checks passed
@Boog900 Boog900 deleted the rpc-types-fixes branch May 5, 2026 11:54
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

A-binaries Area: Related to binaries. A-ci Area: Related to CI. A-dependency Area: Related to dependencies, or changes to a Cargo.{toml,lock} file. A-docs Area: Related to documentation. A-rpc Area: Related to RPC. A-types Area: Related to types. A-workspace Area: Changes to a root workspace file or general repo file.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants