Skip to content

Commit

Permalink
[json rpc] deprecate indexes (#18236)
Browse files Browse the repository at this point in the history
PR marks as deprecated following indexes:
* transactions_by_input_object_id
* transactions_by_mutated_object_id
* loaded_child_object_versions
  • Loading branch information
phoenix-o authored Jun 13, 2024
1 parent 1686aaa commit ef071fd
Show file tree
Hide file tree
Showing 10 changed files with 223 additions and 477 deletions.
10 changes: 0 additions & 10 deletions crates/sui-core/src/authority.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2072,7 +2072,6 @@ impl AuthorityState {
digest,
timestamp_ms,
tx_coins,
&inner_temporary_store.loaded_runtime_objects,
)
.await
}
Expand Down Expand Up @@ -3538,15 +3537,6 @@ impl AuthorityState {
}
}

#[instrument(level = "trace", skip_all)]
pub fn loaded_child_object_versions(
&self,
transaction_digest: &TransactionDigest,
) -> SuiResult<Option<Vec<(ObjectID, SequenceNumber)>>> {
self.get_indexes()?
.loaded_child_object_versions(transaction_digest)
}

pub async fn get_transactions_for_tests(
self: &Arc<Self>,
filter: Option<TransactionFilter>,
Expand Down
12 changes: 0 additions & 12 deletions crates/sui-indexer/src/apis/read_api.rs
Original file line number Diff line number Diff line change
Expand Up @@ -24,8 +24,6 @@ use sui_types::base_types::{ObjectID, SequenceNumber};
use sui_types::digests::{ChainIdentifier, TransactionDigest};
use sui_types::sui_serde::BigInt;

use sui_json_rpc_types::SuiLoadedChildObjectsResponse;

#[derive(Clone)]
pub(crate) struct ReadApi<T: R2D2Connection + 'static> {
inner: IndexerReader<T>,
Expand Down Expand Up @@ -269,16 +267,6 @@ impl<T: R2D2Connection + 'static> ReadApiServer for ReadApi<T> {
.map_err(Into::into)
}

async fn get_loaded_child_objects(
&self,
_digest: TransactionDigest,
) -> RpcResult<SuiLoadedChildObjectsResponse> {
Err(jsonrpsee::types::error::CallError::Custom(
jsonrpsee::types::error::ErrorCode::MethodNotFound.into(),
)
.into())
}

async fn get_protocol_config(
&self,
version: Option<BigInt<u64>>,
Expand Down
8 changes: 1 addition & 7 deletions crates/sui-json-rpc-api/src/read.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4,12 +4,12 @@
use jsonrpsee::core::RpcResult;
use jsonrpsee::proc_macros::rpc;

use sui_json_rpc_types::ProtocolConfigResponse;
use sui_json_rpc_types::{
Checkpoint, CheckpointId, CheckpointPage, SuiEvent, SuiGetPastObjectRequest,
SuiObjectDataOptions, SuiObjectResponse, SuiPastObjectResponse, SuiTransactionBlockResponse,
SuiTransactionBlockResponseOptions,
};
use sui_json_rpc_types::{ProtocolConfigResponse, SuiLoadedChildObjectsResponse};
use sui_open_rpc_macros::open_rpc;
use sui_types::base_types::{ObjectID, SequenceNumber, TransactionDigest};
use sui_types::sui_serde::BigInt;
Expand Down Expand Up @@ -100,12 +100,6 @@ pub trait ReadApi {
options: Option<SuiObjectDataOptions>,
) -> RpcResult<Vec<SuiPastObjectResponse>>;

#[method(name = "getLoadedChildObjects")]
async fn get_loaded_child_objects(
&self,
digest: TransactionDigest,
) -> RpcResult<SuiLoadedChildObjectsResponse>;

/// Return a checkpoint
#[method(name = "getCheckpoint")]
async fn get_checkpoint(
Expand Down
34 changes: 0 additions & 34 deletions crates/sui-json-rpc-types/src/sui_transaction.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2322,40 +2322,6 @@ pub enum SuiObjectArg {
},
}

#[serde_as]
#[derive(Eq, PartialEq, Clone, Debug, Serialize, Deserialize, JsonSchema)]
#[serde(rename = "LoadedChildObject", rename_all = "camelCase")]
pub struct SuiLoadedChildObject {
object_id: ObjectID,
#[schemars(with = "AsSequenceNumber")]
#[serde_as(as = "AsSequenceNumber")]
sequence_number: SequenceNumber,
}

impl SuiLoadedChildObject {
pub fn new(object_id: ObjectID, sequence_number: SequenceNumber) -> Self {
Self {
object_id,
sequence_number,
}
}

pub fn object_id(&self) -> ObjectID {
self.object_id
}

pub fn sequence_number(&self) -> SequenceNumber {
self.sequence_number
}
}

#[serde_as]
#[derive(Serialize, Deserialize, Debug, JsonSchema, Clone, Default)]
#[serde(rename_all = "camelCase", rename = "LoadedChildObjectsResponse")]
pub struct SuiLoadedChildObjectsResponse {
pub loaded_child_objects: Vec<SuiLoadedChildObject>,
}

#[derive(Clone)]
pub struct EffectsWithInput {
pub effects: SuiTransactionBlockEffects,
Expand Down
12 changes: 0 additions & 12 deletions crates/sui-json-rpc/src/authority_state.rs
Original file line number Diff line number Diff line change
Expand Up @@ -235,11 +235,6 @@ pub trait StateRead: Send + Sync {

fn get_latest_checkpoint_sequence_number(&self) -> StateReadResult<CheckpointSequenceNumber>;

fn loaded_child_object_versions(
&self,
transaction_digest: &TransactionDigest,
) -> StateReadResult<Option<Vec<(ObjectID, SequenceNumber)>>>;

fn get_chain_identifier(&self) -> StateReadResult<ChainIdentifier>;
}

Expand Down Expand Up @@ -566,13 +561,6 @@ impl StateRead for AuthorityState {
Ok(self.get_latest_checkpoint_sequence_number()?)
}

fn loaded_child_object_versions(
&self,
transaction_digest: &TransactionDigest,
) -> StateReadResult<Option<Vec<(ObjectID, SequenceNumber)>>> {
Ok(self.loaded_child_object_versions(transaction_digest)?)
}

fn get_chain_identifier(&self) -> StateReadResult<ChainIdentifier> {
Ok(self
.get_chain_identifier()
Expand Down
27 changes: 0 additions & 27 deletions crates/sui-json-rpc/src/read_api.rs
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,6 @@ use sui_json_rpc_types::{
SuiTransactionBlock, SuiTransactionBlockEvents, SuiTransactionBlockResponse,
SuiTransactionBlockResponseOptions,
};
use sui_json_rpc_types::{SuiLoadedChildObject, SuiLoadedChildObjectsResponse};
use sui_open_rpc::Module;
use sui_protocol_config::{ProtocolConfig, ProtocolVersion};
use sui_storage::key_value_store::TransactionKeyValueStore;
Expand Down Expand Up @@ -1013,32 +1012,6 @@ impl ReadApiServer for ReadApi {
})
}

#[instrument(skip(self))]
async fn get_loaded_child_objects(
&self,
digest: TransactionDigest,
) -> RpcResult<SuiLoadedChildObjectsResponse> {
with_tracing!(async move {
Ok(SuiLoadedChildObjectsResponse {
loaded_child_objects: match self
.state
.loaded_child_object_versions(&digest)
.map_err(|e| {
error!(
"Failed to get loaded child objects at {digest:?} with error: {e:?}"
);
Error::StateReadError(e)
})? {
Some(v) => v
.into_iter()
.map(|q| SuiLoadedChildObject::new(q.0, q.1))
.collect::<Vec<_>>(),
None => vec![],
},
})
})
}

#[instrument(skip(self))]
async fn get_protocol_config(
&self,
Expand Down
Loading

0 comments on commit ef071fd

Please sign in to comment.