Skip to content

Commit

Permalink
[transaction-block-rename][3/n] Update RPC types and endpoints (Myste…
Browse files Browse the repository at this point in the history
…nLabs#9972)

## Description 

Describe the changes or additions included in this PR.

## Test Plan 

How did you test the new or updated feature?

---
If your changes are not user-facing and not a breaking change, you can
skip the following section. Otherwise, please indicate what changed, and
then add to the Release Notes section as highlighted during the release
process.

### Type of Change (Check all that apply)

- [ ] user-visible impact
- [ ] breaking change for a client SDKs
- [ ] breaking change for FNs (FN binary must upgrade)
- [ ] breaking change for validators or node operators (must upgrade
binaries)
- [ ] breaking change for on-chain data layout
- [ ] necessitate either a data wipe or data migration

### Release notes
  • Loading branch information
666lcz authored Mar 28, 2023
1 parent 8060106 commit 56f3eaa
Show file tree
Hide file tree
Showing 22 changed files with 358 additions and 306 deletions.
2 changes: 1 addition & 1 deletion .changeset/kind-cooks-hear.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,4 +2,4 @@
"@mysten/sui.js": minor
---

Change functions in json-rpc-provider.ts of ts-sdk such that: `getTotalTransactionNumber`, `getReferenceGasPrice` return a `bigint`, `getLatestCheckpointSequenceNumber` returns a `string`, `gasPrice` of `devInspectTransaction` is defined as a `string`, checkpoint sequence number of `getCheckpoint` is defined as a `string`, `cursor` of `getCheckpoints` is defined as a `string`. Introduce `SuiCheckpointSequenceNumber` type in sui-json-rpc-types that is a `BigInt` to use instead of `CheckpointSequenceNumber` of sui-types.
Change functions in json-rpc-provider.ts of ts-sdk such that: `getTotalTransactionBlocks`, `getReferenceGasPrice` return a `bigint`, `getLatestCheckpointSequenceNumber` returns a `string`, `gasPrice` of `devInspectTransactionBlock` is defined as a `string`, checkpoint sequence number of `getCheckpoint` is defined as a `string`, `cursor` of `getCheckpoints` is defined as a `string`. Introduce `SuiCheckpointSequenceNumber` type in sui-json-rpc-types that is a `BigInt` to use instead of `CheckpointSequenceNumber` of sui-types.
2 changes: 1 addition & 1 deletion apps/explorer/src/pages/checkpoints/Transactions.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ export function CheckpointTransactions({
const { data: txData, isLoading } = useQuery(
['checkpoint-transactions', digest],
async () => {
// todo: replace this with `sui_queryTransactions` call when we are
// todo: replace this with `suix_queryTransactionBlocks` call when we are
// able to query by checkpoint digest
const txData = await getDataOnTxDigests(rpc, transactions!);
return genTableDataFromTxData(txData);
Expand Down
8 changes: 4 additions & 4 deletions crates/sui-core/src/authority.rs
Original file line number Diff line number Diff line change
Expand Up @@ -46,8 +46,8 @@ use sui_config::genesis::Genesis;
use sui_config::node::{AuthorityStorePruningConfig, DBCheckpointConfig};
use sui_framework::{MoveStdlib, SuiFramework, SuiSystem, SystemPackage};
use sui_json_rpc_types::{
Checkpoint, DevInspectResults, DryRunTransactionResponse, EventFilter, SuiEvent, SuiMoveValue,
SuiObjectDataFilter, SuiTransactionBlockEvents,
Checkpoint, DevInspectResults, DryRunTransactionBlockResponse, EventFilter, SuiEvent,
SuiMoveValue, SuiObjectDataFilter, SuiTransactionBlockEvents,
};
use sui_macros::{fail_point, fail_point_async, nondeterministic};
use sui_protocol_config::SupportedProtocolVersions;
Expand Down Expand Up @@ -1019,7 +1019,7 @@ impl AuthorityState {
transaction_digest: TransactionDigest,
) -> Result<
(
DryRunTransactionResponse,
DryRunTransactionBlockResponse,
BTreeMap<ObjectID, (ObjectRef, Object, WriteKind)>,
TransactionEffects,
),
Expand Down Expand Up @@ -1105,7 +1105,7 @@ impl AuthorityState {
let balance_changes = Vec::new();

Ok((
DryRunTransactionResponse {
DryRunTransactionBlockResponse {
effects: effects.clone().try_into()?,
events: SuiTransactionBlockEvents::try_from(
inner_temp_store.events.clone(),
Expand Down
2 changes: 1 addition & 1 deletion crates/sui-core/src/unit_tests/authority_tests.rs
Original file line number Diff line number Diff line change
Expand Up @@ -5165,7 +5165,7 @@ async fn test_for_inc_201_dry_run() {
let txn_data = TransactionData::new_with_gas_coins(kind, sender, vec![], 10000, 1);

let signed = to_sender_signed_transaction(txn_data, &sender_key);
let (DryRunTransactionResponse { events, .. }, _, _) = fullnode
let (DryRunTransactionBlockResponse { events, .. }, _, _) = fullnode
.dry_exec_transaction(
signed.data().intent_message().value.clone(),
*signed.digest(),
Expand Down
4 changes: 2 additions & 2 deletions crates/sui-indexer/src/apis/write_api.rs
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ use jsonrpsee::RpcModule;
use sui_json_rpc::api::{WriteApiClient, WriteApiServer};
use sui_json_rpc::SuiRpcModule;
use sui_json_rpc_types::{
BigInt, DevInspectResults, DryRunTransactionResponse, SuiTransactionBlockResponse,
BigInt, DevInspectResults, DryRunTransactionBlockResponse, SuiTransactionBlockResponse,
SuiTransactionBlockResponseOptions,
};
use sui_open_rpc::Module;
Expand Down Expand Up @@ -57,7 +57,7 @@ impl WriteApiServer for WriteApi {
async fn dry_run_transaction_block(
&self,
tx_bytes: Base64,
) -> RpcResult<DryRunTransactionResponse> {
) -> RpcResult<DryRunTransactionBlockResponse> {
self.fullnode.dry_run_transaction_block(tx_bytes).await
}
}
Expand Down
42 changes: 16 additions & 26 deletions crates/sui-json-rpc-types/src/sui_transaction.rs
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,11 @@ impl Display for BigInt {
pub type SuiEpochId = BigInt;

#[derive(Debug, Clone, Deserialize, Serialize, JsonSchema, Default)]
#[serde(rename_all = "camelCase", rename = "TransactionResponseQuery", default)]
#[serde(
rename_all = "camelCase",
rename = "TransactionBlockResponseQuery",
default
)]
pub struct SuiTransactionBlockResponseQuery {
/// If None, no filter will be applied
pub filter: Option<TransactionFilter>,
Expand Down Expand Up @@ -99,7 +103,7 @@ pub type TransactionBlocksPage = Page<SuiTransactionBlockResponse, TransactionDi
#[derive(Debug, Clone, Deserialize, Serialize, JsonSchema, Eq, PartialEq, Default)]
#[serde(
rename_all = "camelCase",
rename = "TransactionResponseOptions",
rename = "TransactionBlockResponseOptions",
default
)]
pub struct SuiTransactionBlockResponseOptions {
Expand Down Expand Up @@ -196,7 +200,7 @@ impl SuiTransactionBlockResponseOptions {

#[serde_as]
#[derive(Serialize, Deserialize, Debug, JsonSchema, Clone, Default)]
#[serde(rename_all = "camelCase", rename = "TransactionResponse")]
#[serde(rename_all = "camelCase", rename = "TransactionBlockResponse")]
pub struct SuiTransactionBlockResponse {
pub digest: TransactionDigest,
/// Transaction input data
Expand Down Expand Up @@ -253,7 +257,7 @@ impl PartialEq for SuiTransactionBlockResponse {
}

#[derive(Debug, Clone, Serialize, Deserialize, JsonSchema, PartialEq, Eq)]
#[serde(rename = "TransactionKind", tag = "kind")]
#[serde(rename = "TransactionBlockKind", tag = "kind")]
pub enum SuiTransactionBlockKind {
/// A system transaction that will update epoch information on-chain.
ChangeEpoch(SuiChangeEpoch),
Expand Down Expand Up @@ -355,7 +359,7 @@ pub struct SuiChangeEpoch {
#[derive(Debug, Deserialize, Serialize, JsonSchema, Clone, PartialEq, Eq)]
#[enum_dispatch(SuiTransactionBlockEffectsAPI)]
#[serde(
rename = "TransactionEffects",
rename = "TransactionBlockEffects",
rename_all = "camelCase",
tag = "messageVersion"
)]
Expand Down Expand Up @@ -390,7 +394,7 @@ pub trait SuiTransactionBlockEffectsAPI {

#[derive(Eq, PartialEq, Clone, Debug, Serialize, Deserialize, JsonSchema)]
#[serde(
rename = "TransactionEffectsModifiedAtVersions",
rename = "TransactionBlockEffectsModifiedAtVersions",
rename_all = "camelCase"
)]
pub struct SuiTransactionBlockEffectsModifiedAtVersions {
Expand All @@ -400,7 +404,7 @@ pub struct SuiTransactionBlockEffectsModifiedAtVersions {

/// The response from processing a transaction or a certified transaction
#[derive(Eq, PartialEq, Clone, Debug, Serialize, Deserialize, JsonSchema)]
#[serde(rename = "TransactionEffectsV1", rename_all = "camelCase")]
#[serde(rename = "TransactionBlockEffectsV1", rename_all = "camelCase")]
pub struct SuiTransactionBlockEffectsV1 {
/// The status of the execution
pub status: SuiExecutionStatus,
Expand Down Expand Up @@ -650,15 +654,15 @@ impl Display for SuiTransactionBlockEffects {

#[derive(Eq, PartialEq, Clone, Debug, Serialize, Deserialize, JsonSchema)]
#[serde(rename_all = "camelCase")]
pub struct DryRunTransactionResponse {
pub struct DryRunTransactionBlockResponse {
pub effects: SuiTransactionBlockEffects,
pub events: SuiTransactionBlockEvents,
pub object_changes: Vec<ObjectChange>,
pub balance_changes: Vec<BalanceChange>,
}

#[derive(Eq, PartialEq, Clone, Debug, Default, Serialize, Deserialize, JsonSchema)]
#[serde(rename = "TransactionEvents", transparent)]
#[serde(rename = "TransactionBlockEvents", transparent)]
pub struct SuiTransactionBlockEvents {
pub data: Vec<SuiEvent>,
}
Expand Down Expand Up @@ -865,7 +869,7 @@ pub struct SuiGasData {
#[derive(Debug, Deserialize, Serialize, JsonSchema, Clone, PartialEq, Eq)]
#[enum_dispatch(SuiTransactionBlockDataAPI)]
#[serde(
rename = "TransactionData",
rename = "TransactionBlockData",
rename_all = "camelCase",
tag = "messageVersion"
)]
Expand All @@ -881,7 +885,7 @@ pub trait SuiTransactionBlockDataAPI {
}

#[derive(Debug, Deserialize, Serialize, JsonSchema, Clone, PartialEq, Eq)]
#[serde(rename = "TransactionDataV1", rename_all = "camelCase")]
#[serde(rename = "TransactionBlockDataV1", rename_all = "camelCase")]
pub struct SuiTransactionBlockDataV1 {
pub transaction: SuiTransactionBlockKind,
pub sender: SuiAddress,
Expand Down Expand Up @@ -972,7 +976,7 @@ impl SuiTransactionBlockData {
}

#[derive(Debug, Deserialize, Serialize, JsonSchema, Clone, PartialEq, Eq)]
#[serde(rename = "Transaction", rename_all = "camelCase")]
#[serde(rename = "TransactionBlock", rename_all = "camelCase")]
pub struct SuiTransactionBlock {
pub data: SuiTransactionBlockData,
pub tx_signatures: Vec<GenericSignature>,
Expand Down Expand Up @@ -1014,20 +1018,6 @@ pub struct SuiConsensusCommitPrologue {
pub commit_timestamp_ms: u64,
}

#[derive(Debug, PartialEq, Eq, Clone, Serialize, Deserialize, JsonSchema)]
#[serde(rename = "TransferObject", rename_all = "camelCase")]
pub struct SuiTransferObject {
pub recipient: SuiAddress,
pub object_ref: SuiObjectRef,
}

#[derive(Debug, PartialEq, Eq, Clone, Serialize, Deserialize, JsonSchema)]
#[serde(rename = "TransferSui", rename_all = "camelCase")]
pub struct SuiTransferSui {
pub recipient: SuiAddress,
pub amount: Option<u64>,
}

#[derive(Debug, PartialEq, Eq, Clone, Serialize, Deserialize, JsonSchema)]
#[serde(rename = "InputObjectKind")]
pub enum SuiInputObjectKind {
Expand Down
2 changes: 1 addition & 1 deletion crates/sui-json-rpc/src/api/indexer.rs
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ pub trait IndexerApi {
) -> RpcResult<ObjectsPage>;

/// Return list of transactions for a specified query criteria.
#[method(name = "queryTransactions")]
#[method(name = "queryTransactionBlocks")]
async fn query_transaction_blocks(
&self,
/// the transaction query criteria.
Expand Down
6 changes: 3 additions & 3 deletions crates/sui-json-rpc/src/api/read.rs
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ use sui_types::base_types::{ObjectID, SequenceNumber, TransactionDigest};
#[rpc(server, client, namespace = "sui")]
pub trait ReadApi {
/// Return the transaction response object.
#[method(name = "getTransaction")]
#[method(name = "getTransactionBlock")]
async fn get_transaction_block(
&self,
/// the digest of the queried transaction
Expand All @@ -28,7 +28,7 @@ pub trait ReadApi {
/// Returns an ordered list of transaction responses
/// The method will throw an error if the input contains any duplicate or
/// the input size exceeds QUERY_MAX_RESULT_LIMIT
#[method(name = "multiGetTransactions")]
#[method(name = "multiGetTransactionBlocks")]
async fn multi_get_transaction_blocks(
&self,
/// A list of transaction digests.
Expand Down Expand Up @@ -114,7 +114,7 @@ pub trait ReadApi {
) -> RpcResult<Vec<SuiEvent>>;

/// Return the total number of transactions known to the server.
#[method(name = "getTotalTransactionNumber")]
#[method(name = "getTotalTransactionBlocks")]
async fn get_total_transaction_blocks(&self) -> RpcResult<BigInt>;

/// Return the sequence number of the latest checkpoint that has been executed
Expand Down
10 changes: 5 additions & 5 deletions crates/sui-json-rpc/src/api/write.rs
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ use fastcrypto::encoding::Base64;
use jsonrpsee::core::RpcResult;
use jsonrpsee_proc_macros::rpc;
use sui_json_rpc_types::{
BigInt, DevInspectResults, DryRunTransactionResponse, SuiTransactionBlockResponse,
BigInt, DevInspectResults, DryRunTransactionBlockResponse, SuiTransactionBlockResponse,
SuiTransactionBlockResponseOptions,
};

Expand All @@ -26,7 +26,7 @@ pub trait WriteApi {
/// However if the node fails to execute the transaction locally in a timely manner,
/// a bool type in the response is set to false to indicated the case.
/// request_type is default to be `WaitForEffectsCert` unless options.show_events or options.show_effects is true
#[method(name = "executeTransaction", deprecated)]
#[method(name = "executeTransactionBlock")]
async fn execute_transaction_block(
&self,
/// BCS serialized transaction data bytes without its type tag, as base-64 encoded string.
Expand All @@ -42,7 +42,7 @@ pub trait WriteApi {
/// Runs the transaction in dev-inspect mode. Which allows for nearly any
/// transaction (or Move call) with any arguments. Detailed results are
/// provided, including both the transaction effects and any return values.
#[method(name = "devInspectTransaction")]
#[method(name = "devInspectTransactionBlock")]
async fn dev_inspect_transaction_block(
&self,
sender_address: SuiAddress,
Expand All @@ -56,9 +56,9 @@ pub trait WriteApi {

/// Return transaction execution effects including the gas cost summary,
/// while the effects are not committed to the chain.
#[method(name = "dryRunTransaction")]
#[method(name = "dryRunTransactionBlock")]
async fn dry_run_transaction_block(
&self,
tx_bytes: Base64,
) -> RpcResult<DryRunTransactionResponse>;
) -> RpcResult<DryRunTransactionBlockResponse>;
}
8 changes: 4 additions & 4 deletions crates/sui-json-rpc/src/transaction_execution_api.rs
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ use sui_core::authority::AuthorityState;
use sui_core::authority_client::NetworkAuthorityClient;
use sui_core::transaction_orchestrator::TransactiondOrchestrator;
use sui_json_rpc_types::{
BigInt, DevInspectResults, DryRunTransactionResponse, SuiTransactionBlock,
BigInt, DevInspectResults, DryRunTransactionBlockResponse, SuiTransactionBlock,
SuiTransactionBlockEvents, SuiTransactionBlockResponse, SuiTransactionBlockResponseOptions,
};
use sui_open_rpc::Module;
Expand Down Expand Up @@ -156,7 +156,7 @@ impl TransactionExecutionApi {
async fn dry_run_transaction_block(
&self,
tx_bytes: Base64,
) -> Result<DryRunTransactionResponse, Error> {
) -> Result<DryRunTransactionBlockResponse, Error> {
let (txn_data, txn_digest) = get_transaction_data_and_digest(tx_bytes)?;
let (resp, written_objects, transaction_effects) = self
.state
Expand All @@ -174,7 +174,7 @@ impl TransactionExecutionApi {
)
.await?;

Ok(DryRunTransactionResponse {
Ok(DryRunTransactionBlockResponse {
effects: resp.effects,
events: resp.events,
object_changes,
Expand Down Expand Up @@ -215,7 +215,7 @@ impl WriteApiServer for TransactionExecutionApi {
async fn dry_run_transaction_block(
&self,
tx_bytes: Base64,
) -> RpcResult<DryRunTransactionResponse> {
) -> RpcResult<DryRunTransactionBlockResponse> {
Ok(self.dry_run_transaction_block(tx_bytes).await?)
}
}
Expand Down
Loading

0 comments on commit 56f3eaa

Please sign in to comment.