Skip to content

Commit

Permalink
[transaction-block-rename][1/n] rename transaction methods (#9951)
Browse files Browse the repository at this point in the history
## Description 
renamed the following methods
// reading
get_transaction → get_transaction_block
multi_get_transactions → multi_get_transaction_blocks
get_total_transaction_number → get_total_transaction_blocks
query_transactions → query_transaction_blocks

// writing
execute_transaction → execute_transaction_block
dev_inspect_transaction → dev_inspect_transaction_block
dry_run_transaction → dry_run_transaction_block

## Next PRs
1. rename data structure names
2. rename RPC endpoint names (and TS usage)

## Test Plan 

CI build

---
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 27, 2023
1 parent 6f5dab5 commit 24d90f3
Show file tree
Hide file tree
Showing 54 changed files with 263 additions and 204 deletions.
10 changes: 8 additions & 2 deletions crates/sui-benchmark/src/bank.rs
Original file line number Diff line number Diff line change
Expand Up @@ -135,7 +135,10 @@ impl BenchmarkBank {
// transferring it to recipients
let verified_tx =
self.make_split_coin_tx(split_amounts.clone(), Some(gas_price), &self.primary_gas.2)?;
let effects = self.proxy.execute_transaction(verified_tx.into()).await?;
let effects = self
.proxy
.execute_transaction_block(verified_tx.into())
.await?;
let updated_gas = effects
.mutated()
.into_iter()
Expand All @@ -160,7 +163,10 @@ impl BenchmarkBank {
&self.primary_gas.2,
Some(gas_price),
)?;
let effects = self.proxy.execute_transaction(verified_tx.into()).await?;
let effects = self
.proxy
.execute_transaction_block(verified_tx.into())
.await?;
let address_map: HashMap<SuiAddress, Arc<AccountKeyPair>> = coin_configs
.iter()
.map(|c| (c.address, c.keypair.clone()))
Expand Down
4 changes: 2 additions & 2 deletions crates/sui-benchmark/src/drivers/bench_driver.rs
Original file line number Diff line number Diff line change
Expand Up @@ -377,7 +377,7 @@ impl Driver<(BenchmarkStats, StressStats)> for BenchDriver {
let committee_cloned = Arc::new(worker.proxy.clone_committee());
let start = Arc::new(Instant::now());
let res = worker.proxy
.execute_transaction(b.0.clone().into())
.execute_transaction_block(b.0.clone().into())
.then(|res| async move {
match res {
Ok(effects) => {
Expand Down Expand Up @@ -429,7 +429,7 @@ impl Driver<(BenchmarkStats, StressStats)> for BenchDriver {
// TODO: clone committee for each request is not ideal.
let committee_cloned = Arc::new(worker.proxy.clone_committee());
let res = worker.proxy
.execute_transaction(tx.clone().into())
.execute_transaction_block(tx.clone().into())
.then(|res| async move {
match res {
Ok(effects) => {
Expand Down
10 changes: 5 additions & 5 deletions crates/sui-benchmark/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -160,7 +160,7 @@ pub trait ValidatorProxy {

async fn get_latest_system_state_object(&self) -> Result<SuiSystemStateSummary, anyhow::Error>;

async fn execute_transaction(&self, tx: Transaction) -> anyhow::Result<ExecutionEffects>;
async fn execute_transaction_block(&self, tx: Transaction) -> anyhow::Result<ExecutionEffects>;

/// This function is similar to `execute_transaction` but does not check any validator's
/// signature. It should only be used for benchmarks.
Expand Down Expand Up @@ -284,7 +284,7 @@ impl ValidatorProxy for LocalValidatorAggregatorProxy {
.into_sui_system_state_summary())
}

async fn execute_transaction(&self, tx: Transaction) -> anyhow::Result<ExecutionEffects> {
async fn execute_transaction_block(&self, tx: Transaction) -> anyhow::Result<ExecutionEffects> {
if std::env::var("BENCH_MODE").is_ok() {
return self.execute_bench_transaction(tx).await;
}
Expand Down Expand Up @@ -573,7 +573,7 @@ impl ValidatorProxy for FullNodeProxy {
.await?)
}

async fn execute_transaction(&self, tx: Transaction) -> anyhow::Result<ExecutionEffects> {
async fn execute_transaction_block(&self, tx: Transaction) -> anyhow::Result<ExecutionEffects> {
let tx_digest = *tx.digest();
let tx = tx.verify()?;
let mut retry_cnt = 0;
Expand All @@ -583,7 +583,7 @@ impl ValidatorProxy for FullNodeProxy {
match self
.sui_client
.quorum_driver()
.execute_transaction(
.execute_transaction_block(
tx.clone(),
SuiTransactionResponseOptions::new().with_effects(),
None,
Expand All @@ -609,7 +609,7 @@ impl ValidatorProxy for FullNodeProxy {
}

async fn execute_bench_transaction(&self, tx: Transaction) -> anyhow::Result<ExecutionEffects> {
self.execute_transaction(tx).await
self.execute_transaction_block(tx).await
}

fn clone_committee(&self) -> Committee {
Expand Down
5 changes: 4 additions & 1 deletion crates/sui-benchmark/src/util.rs
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,9 @@ pub async fn publish_basics_package(
path.push("../../sui_programmability/examples/basics");
let transaction =
create_publish_move_package_transaction(gas, path, sender, keypair, Some(gas_price));
let effects = proxy.execute_transaction(transaction.into()).await.unwrap();
let effects = proxy
.execute_transaction_block(transaction.into())
.await
.unwrap();
parse_package_ref(&effects.created()).unwrap()
}
5 changes: 4 additions & 1 deletion crates/sui-benchmark/src/workloads/adversarial.rs
Original file line number Diff line number Diff line change
Expand Up @@ -298,7 +298,10 @@ impl Workload<dyn Payload> for AdversarialWorkload {
Some(reference_gas_price),
gas_budget,
);
let effects = proxy.execute_transaction(transaction.into()).await.unwrap();
let effects = proxy
.execute_transaction_block(transaction.into())
.await
.unwrap();
let created = effects.created();

// should only create the package object, upgrade cap, dynamic field top level obj, and NUM_DYNAMIC_FIELDS df objects. otherwise, there are some object initializers running and we will need to disambiguate
Expand Down
5 changes: 4 additions & 1 deletion crates/sui-benchmark/src/workloads/shared_counter.rs
Original file line number Diff line number Diff line change
Expand Up @@ -200,7 +200,10 @@ impl Workload<dyn Payload> for SharedCounterWorkload {
);
let proxy_ref = proxy.clone();
futures.push(async move {
if let Ok(effects) = proxy_ref.execute_transaction(transaction.into()).await {
if let Ok(effects) = proxy_ref
.execute_transaction_block(transaction.into())
.await
{
effects.created()[0].0
} else {
panic!("Failed to create shared counter!");
Expand Down
2 changes: 1 addition & 1 deletion crates/sui-cluster-test/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -134,7 +134,7 @@ impl TestContext {
let resp = self
.get_fullnode_client()
.quorum_driver()
.execute_transaction(
.execute_transaction_block(
Transaction::from_data(txn_data, Intent::default(), vec![signature])
.verify()
.unwrap(),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ impl TestCaseImpl for FullNodeExecuteTransactionTest {

let response = fullnode
.quorum_driver()
.execute_transaction(
.execute_transaction_block(
txn,
SuiTransactionResponseOptions::new().with_effects(),
Some(ExecuteTransactionRequestType::WaitForEffectsCert),
Expand All @@ -84,7 +84,7 @@ impl TestCaseImpl for FullNodeExecuteTransactionTest {

let response = fullnode
.quorum_driver()
.execute_transaction(
.execute_transaction_block(
txn,
SuiTransactionResponseOptions::new().with_effects(),
Some(ExecuteTransactionRequestType::WaitForLocalExecution),
Expand Down
14 changes: 7 additions & 7 deletions crates/sui-core/src/authority.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1122,7 +1122,7 @@ impl AuthorityState {
}

/// The object ID for gas can be any object ID, even for an uncreated object
pub async fn dev_inspect_transaction(
pub async fn dev_inspect_transaction_block(
&self,
sender: SuiAddress,
transaction_kind: TransactionKind,
Expand Down Expand Up @@ -2229,15 +2229,15 @@ impl AuthorityState {
}
}

pub fn get_total_transaction_number(&self) -> Result<u64, anyhow::Error> {
pub fn get_total_transaction_blocks(&self) -> Result<u64, anyhow::Error> {
Ok(self.get_indexes()?.next_sequence_number())
}

pub async fn get_executed_transaction_and_effects(
&self,
digest: TransactionDigest,
) -> Result<(VerifiedTransaction, TransactionEffects), anyhow::Error> {
let transaction = self.database.get_transaction(&digest)?;
let transaction = self.database.get_transaction_block(&digest)?;
let effects = self.database.get_executed_effects(&digest)?;
match (transaction, effects) {
(Some(transaction), Some(effects)) => Ok((transaction, effects)),
Expand All @@ -2249,7 +2249,7 @@ impl AuthorityState {
&self,
digest: TransactionDigest,
) -> Result<VerifiedTransaction, anyhow::Error> {
let transaction = self.database.get_transaction(&digest)?;
let transaction = self.database.get_transaction_block(&digest)?;
transaction.ok_or_else(|| anyhow!(SuiError::TransactionNotFound { digest }))
}

Expand All @@ -2265,7 +2265,7 @@ impl AuthorityState {
&self,
digests: &[TransactionDigest],
) -> Result<Vec<Option<VerifiedTransaction>>, anyhow::Error> {
Ok(self.database.multi_get_transactions(digests)?)
Ok(self.database.multi_get_transaction_blocks(digests)?)
}

pub async fn multi_get_executed_effects(
Expand Down Expand Up @@ -2582,7 +2582,7 @@ impl AuthorityState {
let Some(cert_sig) = epoch_store.get_transaction_cert_sig(tx_digest)? else {
return Ok(None);
};
let Some(transaction) = self.database.get_transaction(tx_digest)? else {
let Some(transaction) = self.database.get_transaction_block(tx_digest)? else {
return Ok(None);
};

Expand All @@ -2604,7 +2604,7 @@ impl AuthorityState {
if let Some(effects) =
self.get_signed_effects_and_maybe_resign(transaction_digest, epoch_store)?
{
if let Some(transaction) = self.database.get_transaction(transaction_digest)? {
if let Some(transaction) = self.database.get_transaction_block(transaction_digest)? {
let cert_sig = epoch_store.get_transaction_cert_sig(transaction_digest)?;
let events = if let Some(digest) = effects.events_digest() {
self.get_transaction_events(digest)?
Expand Down
4 changes: 2 additions & 2 deletions crates/sui-core/src/authority/authority_store.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1318,7 +1318,7 @@ impl AuthorityStore {
Ok(())
}

pub fn multi_get_transactions(
pub fn multi_get_transaction_blocks(
&self,
tx_digests: &[TransactionDigest],
) -> Result<Vec<Option<VerifiedTransaction>>, SuiError> {
Expand All @@ -1329,7 +1329,7 @@ impl AuthorityStore {
.map(|v| v.into_iter().map(|v| v.map(|v| v.into())).collect())?)
}

pub fn get_transaction(
pub fn get_transaction_block(
&self,
tx_digest: &TransactionDigest,
) -> Result<Option<VerifiedTransaction>, TypedStoreError> {
Expand Down
2 changes: 1 addition & 1 deletion crates/sui-core/src/authority_aggregator.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1581,7 +1581,7 @@ where
}
}

pub async fn execute_transaction(
pub async fn execute_transaction_block(
&self,
transaction: &VerifiedTransaction,
) -> Result<VerifiedCertifiedTransactionEffects, anyhow::Error> {
Expand Down
8 changes: 4 additions & 4 deletions crates/sui-core/src/checkpoints/checkpoint_executor/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -551,7 +551,7 @@ fn extract_end_of_epoch_tx(
.expect("Final checkpoint must have at least one transaction");

let change_epoch_tx = authority_store
.get_transaction(&digests.transaction)
.get_transaction_block(&digests.transaction)
.expect("read cannot fail");

let change_epoch_tx = VerifiedExecutableTransaction::new_from_checkpoint(
Expand Down Expand Up @@ -606,7 +606,7 @@ fn get_unexecuted_transactions(
.transaction;

let change_epoch_tx = authority_store
.get_transaction(&change_epoch_tx_digest)
.get_transaction_block(&change_epoch_tx_digest)
.expect("read cannot fail")
.unwrap_or_else(||
panic!(
Expand Down Expand Up @@ -642,7 +642,7 @@ fn get_unexecuted_transactions(

// read remaining unexecuted transactions from store
let executable_txns: Vec<_> = authority_store
.multi_get_transactions(&unexecuted_txns)
.multi_get_transaction_blocks(&unexecuted_txns)
.expect("Failed to get checkpoint txes from store")
.into_iter()
.enumerate()
Expand Down Expand Up @@ -746,7 +746,7 @@ async fn execute_transactions(
let pending_digest = missing_digests.first().unwrap();
let missing_input = transaction_manager.get_missing_input(pending_digest);
let pending_transaction = authority_store
.get_transaction(pending_digest)?
.get_transaction_block(pending_digest)?
.expect("state-sync should have ensured that the transaction exists");

warn!(
Expand Down
2 changes: 1 addition & 1 deletion crates/sui-core/src/quorum_driver/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -501,7 +501,7 @@ where
let result = self
.validators
.load()
.execute_transaction(&verified_transaction)
.execute_transaction_block(&verified_transaction)
.await
.tap_ok(|_resp| {
debug!(
Expand Down
4 changes: 2 additions & 2 deletions crates/sui-core/src/storage.rs
Original file line number Diff line number Diff line change
Expand Up @@ -96,11 +96,11 @@ impl ReadStore for RocksDbStore {
Ok(self.committee_store.get_committee(&epoch).unwrap())
}

fn get_transaction(
fn get_transaction_block(
&self,
digest: &TransactionDigest,
) -> Result<Option<VerifiedTransaction>, Self::Error> {
self.authority_store.get_transaction(digest)
self.authority_store.get_transaction_block(digest)
}

fn get_transaction_effects(
Expand Down
2 changes: 1 addition & 1 deletion crates/sui-core/src/transaction_orchestrator.rs
Original file line number Diff line number Diff line change
Expand Up @@ -171,7 +171,7 @@ where
tx_type = ?request.transaction_type(),
),
err)]
pub async fn execute_transaction(
pub async fn execute_transaction_block(
&self,
request: ExecuteTransactionRequest,
) -> Result<ExecuteTransactionResponse, QuorumDriverError> {
Expand Down
14 changes: 7 additions & 7 deletions crates/sui-core/src/unit_tests/authority_tests.rs
Original file line number Diff line number Diff line change
Expand Up @@ -211,7 +211,7 @@ async fn construct_shared_object_transaction_with_sequence_number(
}

#[tokio::test]
async fn test_dry_run_transaction() {
async fn test_dry_run_transaction_block() {
let (validator, fullnode, transaction, gas_object_id, shared_object_id) =
construct_shared_object_transaction_with_sequence_number(None).await;
let initial_shared_object_version = validator
Expand Down Expand Up @@ -577,7 +577,7 @@ async fn test_dev_inspect_dynamic_field() {
};
let kind = TransactionKind::programmable(pt);
let DevInspectResults { error, .. } = fullnode
.dev_inspect_transaction(sender, kind, Some(1))
.dev_inspect_transaction_block(sender, kind, Some(1))
.await
.unwrap();
// produces an error
Expand Down Expand Up @@ -819,7 +819,7 @@ async fn test_dev_inspect_gas_coin_argument() {
};
let kind = TransactionKind::programmable(pt);
let results = fullnode
.dev_inspect_transaction(sender, kind, Some(1))
.dev_inspect_transaction_block(sender, kind, Some(1))
.await
.unwrap()
.results
Expand Down Expand Up @@ -881,7 +881,7 @@ async fn test_dev_inspect_uses_unbound_object() {
let kind = TransactionKind::programmable(pt);

let result = fullnode
.dev_inspect_transaction(sender, kind, Some(1))
.dev_inspect_transaction_block(sender, kind, Some(1))
.await;
let Err(err) = result else { panic!() };
assert!(err.to_string().contains("ObjectNotFound"));
Expand Down Expand Up @@ -3266,7 +3266,7 @@ async fn test_store_revert_transfer_sui() {
);
// Transaction should not be deleted on revert in case it's needed
// to execute a future state sync checkpoint.
assert!(db.get_transaction(&tx_digest).unwrap().is_some());
assert!(db.get_transaction_block(&tx_digest).unwrap().is_some());
assert!(!db.as_ref().is_tx_already_executed(&tx_digest).unwrap());
}

Expand Down Expand Up @@ -4569,7 +4569,7 @@ pub async fn call_dev_inspect(
));
let kind = TransactionKind::programmable(builder.finish());
authority
.dev_inspect_transaction(*sender, kind, Some(1))
.dev_inspect_transaction_block(*sender, kind, Some(1))
.await
}

Expand Down Expand Up @@ -5129,7 +5129,7 @@ async fn test_for_inc_201_dev_inspect() {
builder.command(Command::Publish(modules, system_package_ids()));
let kind = TransactionKind::programmable(builder.finish());
let DevInspectResults { events, .. } = fullnode
.dev_inspect_transaction(sender, kind, Some(1))
.dev_inspect_transaction_block(sender, kind, Some(1))
.await
.unwrap();

Expand Down
4 changes: 2 additions & 2 deletions crates/sui-core/src/unit_tests/execution_driver_tests.rs
Original file line number Diff line number Diff line change
Expand Up @@ -95,7 +95,7 @@ async fn pending_exec_notify_ready_certificates() {
let mut certs = Vec::new();
while let Some(t) = transactions.pop() {
let (_cert, effects) = sender_aggregator
.execute_transaction(&t)
.execute_transaction_block(&t)
.await
.expect("All ok.");
Expand Down Expand Up @@ -185,7 +185,7 @@ async fn pending_exec_full() {
let mut certs = Vec::new();
while let Some(t) = transactions.pop() {
let (_cert, effects) = sender_aggregator
.execute_transaction(&t)
.execute_transaction_block(&t)
.await
.expect("All ok.");
Expand Down
2 changes: 1 addition & 1 deletion crates/sui-faucet/src/faucet/simple_faucet.rs
Original file line number Diff line number Diff line change
Expand Up @@ -410,7 +410,7 @@ impl SimpleFaucet {
let client = self.wallet.get_client().await?;
Ok(client
.quorum_driver()
.execute_transaction(
.execute_transaction_block(
tx.clone(),
SuiTransactionResponseOptions::new().with_effects(),
Some(ExecuteTransactionRequestType::WaitForLocalExecution),
Expand Down
Loading

0 comments on commit 24d90f3

Please sign in to comment.