Skip to content

Commit

Permalink
Remove unstable-next-api feature guards. (#1515)
Browse files Browse the repository at this point in the history
### What

Remove `unstable-next-api` feature guards.

### Why

We don't need these anymore as host has already been switched to v23.

### Known limitations

N/A
  • Loading branch information
dmkozh authored Feb 11, 2025
1 parent 11e5f31 commit 9f2988b
Show file tree
Hide file tree
Showing 3 changed files with 20 additions and 81 deletions.
29 changes: 0 additions & 29 deletions soroban-env-host/src/e2e_invoke.rs
Original file line number Diff line number Diff line change
Expand Up @@ -536,14 +536,6 @@ fn clear_signature(auth_entry: &mut SorobanAuthorizationEntry) {
}

#[cfg(any(test, feature = "recording_mode"))]
#[cfg(not(feature = "unstable-next-api"))]
/// Defines the authorization mode for the `invoke_host_function_in_recording_mode`.
///
/// When `None`, recording authorization with disabled non-root authorization will be used.
/// When `Some()`, enforcing auth will be used with the provided entries.
pub type RecordingInvocationAuthMode = Option<Vec<SorobanAuthorizationEntry>>;

#[cfg(all(any(test, feature = "recording_mode"), feature = "unstable-next-api"))]
/// Defines the authorization mode for the `invoke_host_function_in_recording_mode`.
pub enum RecordingInvocationAuthMode {
/// Use enforcing auth and pass the signed authorization entries to be used.
Expand Down Expand Up @@ -601,9 +593,6 @@ pub fn invoke_host_function_in_recording_mode(
) -> Result<InvokeHostFunctionRecordingModeResult, HostError> {
let storage = Storage::with_recording_footprint(ledger_snapshot.clone());
let host = Host::with_storage_and_budget(storage, budget.clone());
#[cfg(not(feature = "unstable-next-api"))]
let is_recording_auth = auth_mode.is_none();
#[cfg(feature = "unstable-next-api")]
let is_recording_auth = matches!(auth_mode, RecordingInvocationAuthMode::Recording(_));
let ledger_seq = ledger_info.sequence_number;
let host_function = host.xdr_roundtrip(host_fn)?;
Expand All @@ -612,13 +601,6 @@ pub fn invoke_host_function_in_recording_mode(
host.set_ledger_info(ledger_info)?;
host.set_base_prng_seed(base_prng_seed)?;

#[cfg(not(feature = "unstable-next-api"))]
if let Some(auth_entries) = &auth_mode {
host.set_authorization_entries(auth_entries.clone())?;
} else {
host.switch_to_recording_auth(true)?;
}
#[cfg(feature = "unstable-next-api")]
match &auth_mode {
RecordingInvocationAuthMode::Enforcing(auth_entries) => {
host.set_authorization_entries(auth_entries.clone())?;
Expand All @@ -640,17 +622,6 @@ pub fn invoke_host_function_in_recording_mode(
.saturating_add(encoded_result_sc_val.len() as u32);
}

#[cfg(not(feature = "unstable-next-api"))]
let mut output_auth = if let Some(auth_entries) = auth_mode {
auth_entries
} else {
let recorded_auth = host.get_recorded_auth_payloads()?;
recorded_auth
.into_iter()
.map(|a| a.into_auth_entry_with_emulated_signature())
.collect::<Result<Vec<SorobanAuthorizationEntry>, HostError>>()?
};
#[cfg(feature = "unstable-next-api")]
let mut output_auth = if let RecordingInvocationAuthMode::Enforcing(auth_entries) = auth_mode {
auth_entries
} else {
Expand Down
46 changes: 12 additions & 34 deletions soroban-env-host/src/test/e2e_tests.rs
Original file line number Diff line number Diff line change
Expand Up @@ -196,28 +196,6 @@ impl LedgerEntryChangeHelper {
}
}

// NB: this is a temporary helper function that we should remove and embed
// RecordingInvocationAuthMode into code during the `unstable-next-api` cleanup
// when switching to v23.
fn recording_auth_mode() -> RecordingInvocationAuthMode {
#[cfg(not(feature = "unstable-next-api"))]
return None;
#[cfg(feature = "unstable-next-api")]
return RecordingInvocationAuthMode::Recording(true);
}

// NB: this is a temporary helper function that we should remove and embed
// RecordingInvocationAuthMode into code during the `unstable-next-api` cleanup
// when switching to v23.
fn enforcing_auth_mode(
auth_entries: Vec<SorobanAuthorizationEntry>,
) -> RecordingInvocationAuthMode {
#[cfg(not(feature = "unstable-next-api"))]
return Some(auth_entries);
#[cfg(feature = "unstable-next-api")]
return RecordingInvocationAuthMode::Enforcing(auth_entries);
}

struct InvokeHostFunctionHelperResult {
invoke_result: Result<ScVal, HostError>,
ledger_changes: Vec<LedgerEntryChangeHelper>,
Expand Down Expand Up @@ -438,7 +416,7 @@ fn invoke_host_function_using_simulation_with_signers(
enable_diagnostics,
host_fn,
source_account,
recording_auth_mode(),
RecordingInvocationAuthMode::Recording(true),
ledger_info,
ledger_entries_with_ttl.clone(),
prng_seed,
Expand All @@ -456,7 +434,7 @@ fn invoke_host_function_using_simulation_with_signers(
enable_diagnostics,
host_fn,
source_account,
enforcing_auth_mode(signed_auth.clone()),
RecordingInvocationAuthMode::Enforcing(signed_auth.clone()),
ledger_info,
ledger_entries_with_ttl.clone(),
prng_seed,
Expand Down Expand Up @@ -654,7 +632,7 @@ fn test_run_out_of_budget_before_calling_host_in_recording_mode() {
true,
&upload_wasm_host_fn(ADD_I32),
&get_account_id([0; 32]),
recording_auth_mode(),
RecordingInvocationAuthMode::Recording(true),
&default_ledger_info(),
vec![],
&prng_seed(),
Expand Down Expand Up @@ -743,7 +721,7 @@ fn test_wasm_upload_success_in_recording_mode() {
false,
&upload_wasm_host_fn(ADD_I32),
&get_account_id([123; 32]),
recording_auth_mode(),
RecordingInvocationAuthMode::Recording(true),
&ledger_info,
vec![],
&prng_seed(),
Expand Down Expand Up @@ -796,7 +774,7 @@ fn test_wasm_upload_failure_in_recording_mode() {
true,
&upload_wasm_host_fn(&[0_u8; 1000]),
&get_account_id([123; 32]),
recording_auth_mode(),
RecordingInvocationAuthMode::Recording(true),
&ledger_info,
vec![],
&prng_seed(),
Expand Down Expand Up @@ -834,7 +812,7 @@ fn test_unsupported_wasm_upload_failure_in_recording_mode() {
true,
&upload_wasm_host_fn(ADD_F32),
&get_account_id([123; 32]),
recording_auth_mode(),
RecordingInvocationAuthMode::Recording(true),
&ledger_info,
vec![],
&prng_seed(),
Expand Down Expand Up @@ -1246,7 +1224,7 @@ fn test_create_contract_success_in_recording_mode() {
true,
&cd.host_fn,
&cd.deployer,
recording_auth_mode(),
RecordingInvocationAuthMode::Recording(true),
&ledger_info,
vec![(
cd.wasm_entry.clone(),
Expand Down Expand Up @@ -1332,7 +1310,7 @@ fn test_create_contract_success_in_recording_mode_with_custom_account() {
true,
&cd.host_fn,
&cd.deployer,
recording_auth_mode(),
RecordingInvocationAuthMode::Recording(true),
&ledger_info,
vec![
(
Expand Down Expand Up @@ -1448,7 +1426,7 @@ fn test_create_contract_success_in_recording_mode_with_enforced_auth() {
true,
&cd.host_fn,
&cd.deployer,
enforcing_auth_mode(vec![cd.auth_entry.clone()]),
RecordingInvocationAuthMode::Enforcing(vec![cd.auth_entry.clone()]),
&ledger_info,
vec![(
cd.wasm_entry.clone(),
Expand Down Expand Up @@ -1864,7 +1842,7 @@ fn test_invoke_contract_with_storage_ops_success_in_recording_mode() {
true,
&host_fn,
&cd.deployer,
recording_auth_mode(),
RecordingInvocationAuthMode::Recording(true),
&ledger_info,
vec![
(
Expand Down Expand Up @@ -1939,7 +1917,7 @@ fn test_invoke_contract_with_storage_ops_success_in_recording_mode() {
true,
&extend_host_fn,
&cd.deployer,
recording_auth_mode(),
RecordingInvocationAuthMode::Recording(true),
&ledger_info,
vec![
(
Expand Down Expand Up @@ -2042,7 +2020,7 @@ fn test_invoke_contract_with_storage_ops_success_using_simulation() {
true,
&extend_host_fn,
&cd.deployer,
recording_auth_mode(),
RecordingInvocationAuthMode::Recording(true),
&ledger_info,
vec![
(
Expand Down
26 changes: 8 additions & 18 deletions soroban-simulation/src/test/simulation.rs
Original file line number Diff line number Diff line change
Expand Up @@ -101,16 +101,6 @@ fn nonce_entry(address: ScAddress, nonce: i64) -> LedgerEntry {
}))
}

// NB: this is a temporary helper function that we should remove and embed
// RecordingInvocationAuthMode into code during the `unstable-next-api` cleanup
// when switching to v23.
fn recording_auth_mode() -> RecordingInvocationAuthMode {
#[cfg(not(feature = "unstable-next-api"))]
return None;
#[cfg(feature = "unstable-next-api")]
return RecordingInvocationAuthMode::Recording(true);
}

#[test]
fn test_simulate_upload_wasm() {
let source_account = get_account_id([123; 32]);
Expand All @@ -125,7 +115,7 @@ fn test_simulate_upload_wasm() {
&SimulationAdjustmentConfig::no_adjustments(),
&ledger_info,
upload_wasm_host_fn(ADD_I32),
recording_auth_mode(),
RecordingInvocationAuthMode::Recording(true),
&source_account,
[1; 32],
true,
Expand Down Expand Up @@ -174,7 +164,7 @@ fn test_simulate_upload_wasm() {
&test_adjustment_config(),
&ledger_info,
upload_wasm_host_fn(ADD_I32),
recording_auth_mode(),
RecordingInvocationAuthMode::Recording(true),
&source_account,
[1; 32],
true,
Expand Down Expand Up @@ -229,7 +219,7 @@ fn test_simulation_returns_insufficient_budget_error() {
&SimulationAdjustmentConfig::no_adjustments(),
&ledger_info,
upload_wasm_host_fn(ADD_I32),
recording_auth_mode(),
RecordingInvocationAuthMode::Recording(true),
&source_account,
[1; 32],
true,
Expand Down Expand Up @@ -264,7 +254,7 @@ fn test_simulation_returns_logic_error() {
&SimulationAdjustmentConfig::no_adjustments(),
&ledger_info,
upload_wasm_host_fn(&bad_wasm),
recording_auth_mode(),
RecordingInvocationAuthMode::Recording(true),
&source_account,
[1; 32],
true,
Expand Down Expand Up @@ -308,7 +298,7 @@ fn test_simulate_create_contract() {
&SimulationAdjustmentConfig::no_adjustments(),
&ledger_info,
contract.host_fn.clone(),
recording_auth_mode(),
RecordingInvocationAuthMode::Recording(true),
&source_account,
[1; 32],
true,
Expand Down Expand Up @@ -441,7 +431,7 @@ fn test_simulate_invoke_contract_with_auth() {
&SimulationAdjustmentConfig::no_adjustments(),
&ledger_info,
host_fn,
recording_auth_mode(),
RecordingInvocationAuthMode::Recording(true),
&source_account,
[1; 32],
true,
Expand Down Expand Up @@ -1014,7 +1004,7 @@ fn test_simulate_successful_sac_call() {
&SimulationAdjustmentConfig::no_adjustments(),
&ledger_info,
host_fn,
recording_auth_mode(),
RecordingInvocationAuthMode::Recording(true),
&source_account,
[1; 32],
true,
Expand Down Expand Up @@ -1114,7 +1104,7 @@ fn test_simulate_unsuccessful_sac_call_with_try_call() {
&SimulationAdjustmentConfig::no_adjustments(),
&ledger_info,
host_fn,
recording_auth_mode(),
RecordingInvocationAuthMode::Recording(true),
&source_account,
[1; 32],
true,
Expand Down

0 comments on commit 9f2988b

Please sign in to comment.