Skip to content

Commit

Permalink
DB commit takes all arguments by ref
Browse files Browse the repository at this point in the history
  • Loading branch information
msmouse committed Oct 17, 2024
1 parent 02380fb commit 51c6917
Show file tree
Hide file tree
Showing 13 changed files with 20 additions and 20 deletions.
2 changes: 1 addition & 1 deletion execution/executor/src/block_executor.rs
Original file line number Diff line number Diff line change
Expand Up @@ -373,7 +373,7 @@ where
ledger_update.first_version(),
parent_block.output.state().base_version,
false,
result_in_memory_state,
&result_in_memory_state,
ledger_update.state_updates_until_last_checkpoint.as_ref(),
Some(&ledger_update.sharded_state_cache),
)?;
Expand Down
2 changes: 1 addition & 1 deletion execution/executor/src/chunk_executor.rs
Original file line number Diff line number Diff line change
Expand Up @@ -263,7 +263,7 @@ impl<V: VMExecutor> ChunkExecutorInner<V> {
persisted_state.base_version,
chunk.ledger_info.as_ref(),
false, // sync_commit
chunk.result_state.clone(),
&chunk.result_state,
chunk
.ledger_update_output
.state_updates_until_last_checkpoint
Expand Down
2 changes: 1 addition & 1 deletion execution/executor/src/db_bootstrapper.rs
Original file line number Diff line number Diff line change
Expand Up @@ -108,7 +108,7 @@ impl GenesisCommitter {
self.base_state_version,
self.output.ledger_info.as_ref(),
true, /* sync_commit */
self.output.result_state.clone(),
&self.output.result_state,
self.output
.ledger_update_output
.state_updates_until_last_checkpoint
Expand Down
2 changes: 1 addition & 1 deletion execution/executor/src/fuzzing.rs
Original file line number Diff line number Diff line change
Expand Up @@ -119,7 +119,7 @@ impl DbWriter for FakeDb {
_first_version: Version,
_base_state_version: Option<Version>,
_sync_commit: bool,
_latest_in_memory_state: StateDelta,
_latest_in_memory_state: &StateDelta,
_state_updates_until_last_checkpoint: Option<&ShardedStateUpdates>,
_sharded_state_cache: Option<&ShardedStateCache>,
) -> aptos_storage_interface::Result<()> {
Expand Down
4 changes: 2 additions & 2 deletions execution/executor/src/tests/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -507,7 +507,7 @@ fn apply_transaction_by_writeset(
ledger_view.state().base_version,
ledger_info.as_ref(),
true, /* sync_commit */
result_state,
&result_state,
ledger_update_output
.state_updates_until_last_checkpoint
.as_ref(),
Expand Down Expand Up @@ -718,7 +718,7 @@ fn run_transactions_naive(
ledger_view.state().base_version,
ledger_info.as_ref(),
true, /* sync_commit */
result_state,
&result_state,
ledger_update_output
.state_updates_until_last_checkpoint
.as_ref(),
Expand Down
2 changes: 1 addition & 1 deletion state-sync/state-sync-driver/src/tests/mocks.rs
Original file line number Diff line number Diff line change
Expand Up @@ -331,7 +331,7 @@ mock! {
base_state_version: Option<Version>,
ledger_info_with_sigs: Option<&'a LedgerInfoWithSignatures>,
sync_commit: bool,
in_memory_state: StateDelta,
in_memory_state: &'b StateDelta,
state_updates_until_last_checkpoint: Option<&'b ShardedStateUpdates>,
sharded_state_cache: Option<&'b ShardedStateCache>,
) -> Result<()>;
Expand Down
2 changes: 1 addition & 1 deletion storage/aptosdb/src/db/include/aptosdb_testonly.rs
Original file line number Diff line number Diff line change
Expand Up @@ -149,7 +149,7 @@ impl AptosDB {
base_state_version,
ledger_info_with_sigs,
sync_commit,
latest_in_memory_state,
&latest_in_memory_state,
state_updates_until_last_checkpoint.as_ref(),
None,
)
Expand Down
4 changes: 2 additions & 2 deletions storage/aptosdb/src/db/include/aptosdb_writer.rs
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ impl DbWriter for AptosDB {
first_version: Version,
base_state_version: Option<Version>,
sync_commit: bool,
latest_in_memory_state: StateDelta,
latest_in_memory_state: &StateDelta,
state_updates_until_last_checkpoint: Option<&ShardedStateUpdates>,
sharded_state_cache: Option<&ShardedStateCache>,
) -> Result<()> {
Expand All @@ -31,7 +31,7 @@ impl DbWriter for AptosDB {
txns_to_commit,
first_version,
base_state_version,
&latest_in_memory_state,
latest_in_memory_state,
)?;
let last_version = first_version + txns_to_commit.len() as u64 - 1;

Expand Down
6 changes: 3 additions & 3 deletions storage/aptosdb/src/db/test_helper.rs
Original file line number Diff line number Diff line change
Expand Up @@ -969,7 +969,7 @@ pub fn put_as_state_root(db: &AptosDB, version: Version, key: StateKey, value: S
db.state_store
.buffered_state()
.lock()
.update(None, in_memory_state, true)
.update(None, &in_memory_state, true)
.unwrap();
}

Expand Down Expand Up @@ -1005,7 +1005,7 @@ pub fn test_sync_transactions_impl(
base_state_version,
None,
false, /* sync_commit */
in_memory_state.clone(),
&in_memory_state,
gather_state_updates_until_last_checkpoint(
cur_ver,
&in_memory_state,
Expand All @@ -1025,7 +1025,7 @@ pub fn test_sync_transactions_impl(
base_state_version,
Some(ledger_info_with_sigs),
false, /* sync_commit */
in_memory_state.clone(),
&in_memory_state,
gather_state_updates_until_last_checkpoint(ver, &in_memory_state, txns_to_commit_batch)
.as_ref(),
None,
Expand Down
2 changes: 1 addition & 1 deletion storage/aptosdb/src/fast_sync_storage_wrapper.rs
Original file line number Diff line number Diff line change
Expand Up @@ -175,7 +175,7 @@ impl DbWriter for FastSyncStorageWrapper {
first_version: Version,
base_state_version: Option<Version>,
sync_commit: bool,
latest_in_memory_state: StateDelta,
latest_in_memory_state: &StateDelta,
state_updates_until_last_checkpoint: Option<&ShardedStateUpdates>,
sharded_state_cache: Option<&ShardedStateCache>,
) -> Result<()> {
Expand Down
6 changes: 3 additions & 3 deletions storage/aptosdb/src/state_store/buffered_state.rs
Original file line number Diff line number Diff line change
Expand Up @@ -155,7 +155,7 @@ impl BufferedState {
pub fn update(
&mut self,
updates_until_next_checkpoint_since_current_option: Option<&ShardedStateUpdates>,
new_state_after_checkpoint: StateDelta,
new_state_after_checkpoint: &StateDelta,
sync_commit: bool,
) -> Result<()> {
assert!(new_state_after_checkpoint
Expand All @@ -180,7 +180,7 @@ impl BufferedState {
self.state_after_checkpoint.current_version = new_state_after_checkpoint.base_version;
let state_after_checkpoint = self
.state_after_checkpoint
.replace_with(new_state_after_checkpoint);
.replace_with(new_state_after_checkpoint.clone());
if let Some(ref mut delta) = self.state_until_checkpoint {
delta.merge(state_after_checkpoint);
} else {
Expand All @@ -191,7 +191,7 @@ impl BufferedState {
new_state_after_checkpoint.base_version == self.state_after_checkpoint.base_version,
"Diff between base and latest checkpoints not provided.",
);
self.state_after_checkpoint = new_state_after_checkpoint;
self.state_after_checkpoint = new_state_after_checkpoint.clone();
}
self.maybe_commit(sync_commit);
self.report_latest_committed_version();
Expand Down
2 changes: 1 addition & 1 deletion storage/aptosdb/src/state_store/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -542,7 +542,7 @@ impl StateStore {
// synchronously commit the snapshot at the last checkpoint here if not committed to disk yet.
buffered_state.update(
updates_until_last_checkpoint.as_ref(),
state_after_last_checkpoint,
&state_after_last_checkpoint,
true, /* sync_commit */
)?;
}
Expand Down
4 changes: 2 additions & 2 deletions storage/storage-interface/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -547,7 +547,7 @@ pub trait DbWriter: Send + Sync {
base_state_version: Option<Version>,
ledger_info_with_sigs: Option<&LedgerInfoWithSignatures>,
sync_commit: bool,
latest_in_memory_state: StateDelta,
latest_in_memory_state: &StateDelta,
state_updates_until_last_checkpoint: Option<&ShardedStateUpdates>,
sharded_state_cache: Option<&ShardedStateCache>,
) -> Result<()> {
Expand Down Expand Up @@ -595,7 +595,7 @@ pub trait DbWriter: Send + Sync {
first_version: Version,
base_state_version: Option<Version>,
sync_commit: bool,
latest_in_memory_state: StateDelta,
latest_in_memory_state: &StateDelta,
state_updates_until_last_checkpoint: Option<&ShardedStateUpdates>,
sharded_state_cache: Option<&ShardedStateCache>,
) -> Result<()> {
Expand Down

0 comments on commit 51c6917

Please sign in to comment.