Skip to content

Commit

Permalink
[dev-inspect] Make epoch a parameter. Limit to fullnode (MystenLabs#7209
Browse files Browse the repository at this point in the history
)

- Make epoch a provided parameter instead of taking from the authority.
- Limit the call to full nodes (should not be run on validators)
  • Loading branch information
tnowacki authored Jan 12, 2023
1 parent d7fc9b0 commit e522de8
Show file tree
Hide file tree
Showing 8 changed files with 324 additions and 103 deletions.
18 changes: 16 additions & 2 deletions crates/sui-core/src/authority.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1019,6 +1019,10 @@ impl AuthorityState {
transaction: TransactionData,
transaction_digest: TransactionDigest,
) -> Result<SuiTransactionEffects, anyhow::Error> {
if !self.is_fullnode() {
return Err(anyhow!("dry-exec is only support on fullnodes"));
}

let (gas_status, input_objects) =
transaction_input_checker::check_transaction_input(&self.database, &transaction)
.await?;
Expand Down Expand Up @@ -1046,7 +1050,12 @@ impl AuthorityState {
&self,
transaction: TransactionData,
transaction_digest: TransactionDigest,
epoch: EpochId,
) -> Result<DevInspectResults, anyhow::Error> {
if !self.is_fullnode() {
return Err(anyhow!("dev-inspect is only supported on fullnodes"));
}

let (gas_status, input_objects) =
transaction_input_checker::check_dev_inspect_input(&self.database, &transaction)
.await?;
Expand All @@ -1065,7 +1074,7 @@ impl AuthorityState {
&self.move_vm,
&self._native_functions,
gas_status,
self.epoch(),
epoch,
);
DevInspectResults::new(effects, execution_result, self.module_cache.as_ref())
}
Expand All @@ -1074,7 +1083,12 @@ impl AuthorityState {
&self,
sender: SuiAddress,
move_call: MoveCall,
epoch: EpochId,
) -> Result<DevInspectResults, anyhow::Error> {
if !self.is_fullnode() {
return Err(anyhow!("dev-inspect is only supported on fullnodes"));
}

let input_objects = move_call.input_objects();
let input_objects = transaction_input_checker::check_dev_inspect_input_objects(
&self.database,
Expand Down Expand Up @@ -1105,7 +1119,7 @@ impl AuthorityState {
transaction_dependencies,
&self.move_vm,
gas_status,
self.epoch(),
epoch,
);

DevInspectResults::new(effects, execution_result, self.module_cache.as_ref())
Expand Down
6 changes: 5 additions & 1 deletion crates/sui-core/src/transaction_input_checker.rs
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,11 @@ pub(crate) fn check_dev_inspect_input_objects(
fp_ensure!(
used_objects.insert(object.id().into()),
SuiError::InvalidBatchTransaction {
error: format!("Mutable object {} cannot appear in more than one single transactions in a batch", object.id()),
error: format!(
"Mutable object {} cannot appear in more than one single \
transactions in a batch",
object.id()
),
}
);
}
Expand Down
Loading

0 comments on commit e522de8

Please sign in to comment.