Description
Description
As reported by @alexsporn
iota-proxy
uses the iota-sdk
now to get the latest system state from the JSON-RPC and parse the validators and pending validators.
I think the change we did here is not really backwards compatible with e.g. current Testnet.
iota-json-rpc-api
/// Return the latest IOTA system state object on-chain.
#[method(name = "getLatestIotaSystemState")]
async fn get_latest_iota_system_state(&self) -> RpcResult<IotaSystemStateSummaryV2>;
/// Return the latest IOTA system state object on-chain (version 1).
/// Requires the `client-target-api-version` header to be set into
/// a value `< 0.11` during requests.
#[method(name = "getLatestIotaSystemState", version <= "0.10.99")]
async fn get_latest_iota_system_state_v1(&self) -> RpcResult<IotaSystemStateSummaryV1>;
iota-sdk:
/// Get the latest IOTA system state object on-chain.
///
/// Use this method to access system information, such as the current epoch,
/// the protocol version, the reference gas price, the total stake, active
/// validators, and much more.
pub async fn get_latest_iota_system_state(&self) -> IotaRpcResult<IotaSystemStateSummary> {
Ok(self
.api
.http
.get_latest_iota_system_state()
.await
.map(Into::into)?)
}
So basically the newer SDK cannot be used to target RPC with older versions or else it will fail parsing of the IotaSystemStateSummaryV2
with this:
Rpc(ParseError(Error("missing field
safeModeComputationCharges", line: 1, column: 98140)))
Proposed solution
After discussing with @thibault-martinez and @alexsporn we decided on introducing a new get_latest_iota_system_state_v2
method to return the refactored IotaSystemStateSummary
and let get_latest_iota_system_state
return IotaSystemStateSummaryV1
to be backward compatible.
This implies that iota-sdk
should resolve the node-software version before calling the proper method to get the latest iota system state. cc: @Thoralf-M
Activity