Skip to content

Commit 0245ae7

Browse files
authored
get_obj_inclusion_proof API and e2e light-client test (#23960)
## Description Add a new API to fetch an object version at a given checkpoint sequence number along with an inclusion proof the object was written during that checkpoint sequence number. ## Test plan Light client e2e tested + get_object_inclusion_proof happy / unhappy cases --- ## Release notes Check each box that your changes affect. If none of the boxes relate to your changes, release notes aren't required. For each box you select, include information after the relevant heading that describes the impact of your changes that a user might notice and any actions they must take to implement updates. - [ ] Protocol: - [ ] Nodes (Validators and Full nodes): - [ ] gRPC: - [ ] JSON-RPC: - [ ] GraphQL: - [ ] CLI: - [ ] Rust SDK:
1 parent cb96887 commit 0245ae7

File tree

13 files changed

+1484
-17
lines changed

13 files changed

+1484
-17
lines changed

crates/sui-core/src/accumulators/mod.rs

Lines changed: 13 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -71,11 +71,11 @@ impl MergedValue {
7171
split: Self,
7272
root: Argument,
7373
address: &AccumulatorAddress,
74+
checkpoint_seq: u64,
7475
builder: &mut ProgrammableTransactionBuilder,
7576
) {
7677
let ty = ClassifiedType::classify(&address.ty);
7778
let address_arg = builder.pure(address.address).unwrap();
78-
let checkpoint_seq = 0u64; /* TODO: replace with actual checkpoint sequence number */
7979

8080
match (ty, merge, split) {
8181
(
@@ -214,10 +214,9 @@ impl AccumulatorSettlementTxBuilder {
214214
pub fn new(
215215
cache: Option<&dyn TransactionCacheRead>,
216216
ckpt_effects: &[TransactionEffects],
217+
checkpoint_seq: u64,
217218
tx_index_offset: u64,
218219
) -> Self {
219-
let checkpoint_seq = 0u64; /* TODO: replace with actual checkpoint sequence number */
220-
221220
let mut updates = BTreeMap::<_, _>::new();
222221

223222
let mut addresses = HashMap::<_, _>::new();
@@ -322,6 +321,7 @@ impl AccumulatorSettlementTxBuilder {
322321
epoch: u64,
323322
accumulator_root_obj_initial_shared_version: SequenceNumber,
324323
checkpoint_height: u64,
324+
checkpoint_seq: u64,
325325
) -> (
326326
Vec<TransactionKind>, /* settlements */
327327
TransactionKind, /* barrier */
@@ -348,6 +348,7 @@ impl AccumulatorSettlementTxBuilder {
348348
updates.drain(..),
349349
total_input_sui,
350350
total_output_sui,
351+
checkpoint_seq,
351352
)
352353
};
353354

@@ -439,6 +440,7 @@ impl AccumulatorSettlementTxBuilder {
439440
updates: impl Iterator<Item = (AccumulatorObjId, Update)>,
440441
total_input_sui: u64,
441442
total_output_sui: u64,
443+
checkpoint_seq: u64,
442444
) -> TransactionKind {
443445
let mut builder = ProgrammableTransactionBuilder::new();
444446

@@ -465,7 +467,14 @@ impl AccumulatorSettlementTxBuilder {
465467
let address = addresses.get(&accumulator_obj).unwrap();
466468
let merged_value = MergedValue::from(merge);
467469
let split_value = MergedValue::from(split);
468-
MergedValue::add_move_call(merged_value, split_value, root, address, &mut builder);
470+
MergedValue::add_move_call(
471+
merged_value,
472+
split_value,
473+
root,
474+
address,
475+
checkpoint_seq,
476+
&mut builder,
477+
);
469478
}
470479

471480
TransactionKind::ProgrammableSystemTransaction(builder.finish())

crates/sui-core/src/checkpoints/mod.rs

Lines changed: 14 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1437,6 +1437,7 @@ impl CheckpointBuilder {
14371437
&self,
14381438
sorted_tx_effects_included_in_checkpoint: &[TransactionEffects],
14391439
checkpoint_height: CheckpointHeight,
1440+
checkpoint_seq: CheckpointSequenceNumber,
14401441
tx_index_offset: u64,
14411442
) -> (TransactionKey, Vec<TransactionEffects>) {
14421443
let _scope =
@@ -1455,6 +1456,7 @@ impl CheckpointBuilder {
14551456
let builder = AccumulatorSettlementTxBuilder::new(
14561457
Some(self.effects_store.as_ref()),
14571458
sorted_tx_effects_included_in_checkpoint,
1459+
checkpoint_seq,
14581460
tx_index_offset,
14591461
);
14601462

@@ -1465,6 +1467,7 @@ impl CheckpointBuilder {
14651467
epoch,
14661468
accumulator_root_obj_initial_shared_version,
14671469
checkpoint_height,
1470+
checkpoint_seq,
14681471
);
14691472

14701473
let settlement_txns: Vec<_> = settlement_txns
@@ -1661,13 +1664,22 @@ impl CheckpointBuilder {
16611664
sorted.extend(CausalOrder::causal_sort(unsorted));
16621665

16631666
if let Some(settlement_root) = settlement_root {
1664-
// tx_effects.len() gives us the offset for this pending checkpoint's transactions
1665-
// in the final concatenated checkpoint
1667+
//TODO: this is an incorrect heuristic for checkpoint seq number
1668+
// due to checkpoint splitting, to be fixed separately
1669+
let last_checkpoint =
1670+
Self::load_last_built_checkpoint_summary(&self.epoch_store, &self.store)?;
1671+
let next_checkpoint_seq = last_checkpoint
1672+
.as_ref()
1673+
.map(|(seq, _)| *seq)
1674+
.unwrap_or_default()
1675+
+ 1;
16661676
let tx_index_offset = tx_effects.len() as u64;
1677+
16671678
let (tx_key, settlement_effects) = self
16681679
.construct_and_execute_settlement_transactions(
16691680
&sorted,
16701681
pending.details.checkpoint_height,
1682+
next_checkpoint_seq,
16711683
tx_index_offset,
16721684
)
16731685
.await;

crates/sui-core/src/mock_checkpoint_builder.rs

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -131,15 +131,17 @@ impl MockCheckpointBuilder {
131131
.map(|e| e.effects.clone())
132132
.collect();
133133

134-
let builder = AccumulatorSettlementTxBuilder::new(None, &effects, 0);
135-
136134
let checkpoint_height = self.get_next_checkpoint_number();
135+
let checkpoint_seq = checkpoint_height;
136+
137+
let builder = AccumulatorSettlementTxBuilder::new(None, &effects, checkpoint_seq, 0);
137138

138139
let (settlement_txns, barrier_tx) = builder.build_tx(
139140
protocol_config,
140141
self.epoch,
141142
OBJECT_START_VERSION,
142143
checkpoint_height,
144+
checkpoint_seq,
143145
);
144146

145147
settlement_txns

0 commit comments

Comments
 (0)