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

[indexer] Use full_objects_history in reads #19290

Merged
merged 8 commits into from
Sep 17, 2024
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
Original file line number Diff line number Diff line change
@@ -0,0 +1,68 @@
processed 12 tasks

task 1, lines 6-23:
//# publish
created: object(1,0)
mutated: object(0,0)
gas summary: computation_cost: 1000000, storage_cost: 5608800, storage_rebate: 0, non_refundable_storage_fee: 0

task 2, line 25:
//# run Test::M1::create --args 0
created: object(2,0)
mutated: object(0,0)
gas summary: computation_cost: 1000000, storage_cost: 2302800, storage_rebate: 978120, non_refundable_storage_fee: 9880

task 3, line 27:
//# create-checkpoint
Checkpoint created: 1

task 4, line 29:
//# advance-epoch
Epoch advanced: 0

task 5, line 31:
//# run Test::M1::mutate --args object(2,0) 1
mutated: object(0,0), object(2,0)
gas summary: computation_cost: 1000000, storage_cost: 2302800, storage_rebate: 2279772, non_refundable_storage_fee: 23028

task 6, line 33:
//# create-checkpoint
Checkpoint created: 3

task 7, lines 35-40:
//# run-graphql
Response: {
"data": {
"object": {
"digest": "ig3beP5kc79atHUitXDvwpmZfH5AM5ZaKzaySVdJxL3"
}
}
}

task 8, lines 42-47:
//# run-graphql
Response: {
"data": {
"object": {
"digest": "HzGF2DsFWkXbAm9bhRwDC8ams4VaxqxVYEw5zwEmVyPj"
}
}
}

task 9, line 49:
//# advance-epoch
Epoch advanced: 1

task 10, lines 51-53:
//# create-checkpoint
Checkpoint created: 5

task 11, lines 54-59:
//# run-graphql --wait-for-checkpoint-pruned 0
Response: {
"data": {
"object": {
"digest": "ig3beP5kc79atHUitXDvwpmZfH5AM5ZaKzaySVdJxL3"
}
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,59 @@
// Copyright (c) Mysten Labs, Inc.
// SPDX-License-Identifier: Apache-2.0

//# init --addresses Test=0x0 --simulator --epochs-to-keep 1

//# publish
module Test::M1 {
public struct Object has key, store {
id: UID,
value: u64,
}

public entry fun create(value: u64, ctx: &mut TxContext) {
transfer::public_transfer(
Object { id: object::new(ctx), value },
ctx.sender(),
)
}

public entry fun mutate(obj: &mut Object, value: u64) {
obj.value = value;
}
}

//# run Test::M1::create --args 0

//# create-checkpoint

//# advance-epoch

//# run Test::M1::mutate --args object(2,0) 1

//# create-checkpoint

//# run-graphql
{
object(address: "@{obj_2_0}", version: 3) {
digest
}
}

//# run-graphql
{
object(address: "@{obj_2_0}", version: 4) {
digest
}
}

//# advance-epoch

//# create-checkpoint

# After pruning, we can still read all historical objects.
//# run-graphql --wait-for-checkpoint-pruned 0
{
object(address: "@{obj_2_0}", version: 3) {
digest
}
}
6 changes: 4 additions & 2 deletions crates/sui-graphql-rpc/src/types/dynamic_field.rs
Original file line number Diff line number Diff line change
Expand Up @@ -274,9 +274,11 @@ impl TryFrom<MoveObject> for DynamicField {
let super_ = &stored.super_;

let native = match &super_.kind {
ObjectKind::NotIndexed(native) | ObjectKind::Indexed(native, _) => native,
ObjectKind::NotIndexed(native) | ObjectKind::Indexed(native, _) => native.clone(),
ObjectKind::Serialized(bytes) => bcs::from_bytes(bytes)
.map_err(|e| Error::Internal(format!("Failed to deserialize object: {e}")))?,

ObjectKind::WrappedOrDeleted(_) => {
ObjectKind::WrappedOrDeleted => {
return Err(Error::Internal(
"DynamicField is wrapped or deleted.".to_string(),
));
Expand Down
Loading
Loading