Skip to content

Commit

Permalink
Use different methods for getting protocol version
Browse files Browse the repository at this point in the history
  • Loading branch information
Shaptic committed Sep 24, 2024
1 parent 2b4b1e8 commit 5e18dfd
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 7 deletions.
13 changes: 9 additions & 4 deletions cmd/soroban-rpc/lib/preflight/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,8 @@ mod curr {
pub(crate) use soroban_simulation_curr as soroban_simulation;
#[allow(clippy::duplicate_mod)]
pub(crate) mod shared;

pub(crate) const PROTOCOL: u32 = soroban_env_host::meta::INTERFACE_VERSION.protocol;
}

#[path = "."]
Expand All @@ -46,6 +48,9 @@ mod prev {
pub(crate) use soroban_simulation_prev as soroban_simulation;
#[allow(clippy::duplicate_mod)]
pub(crate) mod shared;

pub(crate) const PROTOCOL: u32 = soroban_env_host::meta::get_ledger_protocol_version(
soroban_env_host::meta::INTERFACE_VERSION);
}

use std::cell::RefCell;
Expand Down Expand Up @@ -164,7 +169,7 @@ pub extern "C" fn preflight_invoke_hf_op(
) -> *mut CPreflightResult {
let proto = ledger_info.protocol_version;
catch_preflight_panic(Box::new(move || {
if proto <= prev::shared::PROTOCOL {
if proto <= prev::PROTOCOL {
prev::shared::preflight_invoke_hf_op_or_maybe_panic(
handle,
invoke_hf_op,
Expand All @@ -173,7 +178,7 @@ pub extern "C" fn preflight_invoke_hf_op(
resource_config,
enable_debug,
)
} else if proto == curr::shared::PROTOCOL {
} else if proto == curr::PROTOCOL {
curr::shared::preflight_invoke_hf_op_or_maybe_panic(
handle,
invoke_hf_op,
Expand All @@ -197,14 +202,14 @@ pub extern "C" fn preflight_footprint_ttl_op(
) -> *mut CPreflightResult {
let proto = ledger_info.protocol_version;
catch_preflight_panic(Box::new(move || {
if proto <= prev::shared::PROTOCOL {
if proto <= prev::PROTOCOL {
prev::shared::preflight_footprint_ttl_op_or_maybe_panic(
handle,
op_body,
footprint,
ledger_info,
)
} else if proto == curr::shared::PROTOCOL {
} else if proto == curr::PROTOCOL {
curr::shared::preflight_footprint_ttl_op_or_maybe_panic(
handle,
op_body,
Expand Down
4 changes: 1 addition & 3 deletions cmd/soroban-rpc/lib/preflight/src/shared.rs
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ use super::soroban_env_host::xdr::{
LedgerFootprint, LedgerKey, LedgerKeyTtl, OperationBody, ReadXdr, ScErrorCode, ScErrorType,
SorobanTransactionData, TtlEntry, WriteXdr,
};
use super::soroban_env_host::{meta, HostError, LedgerInfo, DEFAULT_XDR_RW_LIMITS};
use super::soroban_env_host::{HostError, LedgerInfo, DEFAULT_XDR_RW_LIMITS};
use super::soroban_simulation::simulation::{
simulate_extend_ttl_op, simulate_invoke_host_function_op, simulate_restore_op,
InvokeHostFunctionSimulationResult, LedgerEntryDiff, RestoreOpSimulationResult,
Expand All @@ -41,8 +41,6 @@ use std::convert::TryFrom;
use std::ptr::null_mut;
use std::rc::Rc;

pub(crate) const PROTOCOL: u32 = meta::get_ledger_protocol_version(meta::INTERFACE_VERSION);

fn fill_ledger_info(c_ledger_info: CLedgerInfo, network_config: &NetworkConfig) -> LedgerInfo {
let network_passphrase = unsafe { from_c_string(c_ledger_info.network_passphrase) };
let mut ledger_info = LedgerInfo {
Expand Down

0 comments on commit 5e18dfd

Please sign in to comment.