From 9e216ae66f6e93f2c0fd798c05dbd4a87cb0f357 Mon Sep 17 00:00:00 2001 From: "Tyler.S" Date: Wed, 13 Dec 2023 16:42:58 -0800 Subject: [PATCH 1/8] Allow budget instruction leeway to be configured by clients --- .../internal/methods/simulate_transaction.go | 7 ++++--- cmd/soroban-rpc/internal/preflight/pool.go | 3 ++- cmd/soroban-rpc/internal/preflight/preflight.go | 17 +++++++++++++++++ cmd/soroban-rpc/lib/preflight.h | 5 +++++ cmd/soroban-rpc/lib/preflight/src/fees.rs | 8 ++++++-- cmd/soroban-rpc/lib/preflight/src/lib.rs | 10 ++++++++++ cmd/soroban-rpc/lib/preflight/src/preflight.rs | 4 ++++ 7 files changed, 48 insertions(+), 6 deletions(-) diff --git a/cmd/soroban-rpc/internal/methods/simulate_transaction.go b/cmd/soroban-rpc/internal/methods/simulate_transaction.go index 49d95eecb..47badadfd 100644 --- a/cmd/soroban-rpc/internal/methods/simulate_transaction.go +++ b/cmd/soroban-rpc/internal/methods/simulate_transaction.go @@ -15,7 +15,8 @@ import ( ) type SimulateTransactionRequest struct { - Transaction string `json:"transaction"` + Transaction string `json:"transaction"` + ResourceConfig *preflight.ResourceConfig `json:"resourceConfig,omitempty"` } type SimulateTransactionCost struct { @@ -46,7 +47,7 @@ type SimulateTransactionResponse struct { } type PreflightGetter interface { - GetPreflight(ctx context.Context, readTx db.LedgerEntryReadTx, bucketListSize uint64, sourceAccount xdr.AccountId, opBody xdr.OperationBody, footprint xdr.LedgerFootprint) (preflight.Preflight, error) + GetPreflight(ctx context.Context, readTx db.LedgerEntryReadTx, bucketListSize uint64, sourceAccount xdr.AccountId, opBody xdr.OperationBody, footprint xdr.LedgerFootprint, resourceConfig *preflight.ResourceConfig) (preflight.Preflight, error) } // NewSimulateTransactionHandler returns a json rpc handler to run preflight simulations @@ -113,7 +114,7 @@ func NewSimulateTransactionHandler(logger *log.Entry, ledgerEntryReader db.Ledge } } - result, err := getter.GetPreflight(ctx, readTx, bucketListSize, sourceAccount, op.Body, footprint) + result, err := getter.GetPreflight(ctx, readTx, bucketListSize, sourceAccount, op.Body, footprint, request.ResourceConfig) if err != nil { return SimulateTransactionResponse{ Error: err.Error(), diff --git a/cmd/soroban-rpc/internal/preflight/pool.go b/cmd/soroban-rpc/internal/preflight/pool.go index da391b576..6a49df3e7 100644 --- a/cmd/soroban-rpc/internal/preflight/pool.go +++ b/cmd/soroban-rpc/internal/preflight/pool.go @@ -139,7 +139,7 @@ func (m *metricsLedgerEntryWrapper) GetLedgerEntries(keys ...xdr.LedgerKey) ([]d return entries, err } -func (pwp *PreflightWorkerPool) GetPreflight(ctx context.Context, readTx db.LedgerEntryReadTx, bucketListSize uint64, sourceAccount xdr.AccountId, opBody xdr.OperationBody, footprint xdr.LedgerFootprint) (Preflight, error) { +func (pwp *PreflightWorkerPool) GetPreflight(ctx context.Context, readTx db.LedgerEntryReadTx, bucketListSize uint64, sourceAccount xdr.AccountId, opBody xdr.OperationBody, footprint xdr.LedgerFootprint, resourceConfig *ResourceConfig) (Preflight, error) { if pwp.isClosed.Load() { return Preflight{}, errors.New("preflight worker pool is closed") } @@ -154,6 +154,7 @@ func (pwp *PreflightWorkerPool) GetPreflight(ctx context.Context, readTx db.Ledg LedgerEntryReadTx: &wrappedTx, BucketListSize: bucketListSize, Footprint: footprint, + ResourceConfig: resourceConfig, EnableDebug: pwp.enableDebug, } resultC := make(chan workerResult) diff --git a/cmd/soroban-rpc/internal/preflight/preflight.go b/cmd/soroban-rpc/internal/preflight/preflight.go index 20ddcb4bc..99c23ec43 100644 --- a/cmd/soroban-rpc/internal/preflight/preflight.go +++ b/cmd/soroban-rpc/internal/preflight/preflight.go @@ -35,6 +35,10 @@ type snapshotSourceHandle struct { logger *log.Entry } +const ( + defaultInstructionLeeway uint64 = 1000000 +) + // SnapshotSourceGet takes a LedgerKey XDR in base64 string and returns its matching LedgerEntry XDR in base64 string // It's used by the Rust preflight code to obtain ledger entries. // @@ -71,6 +75,10 @@ func FreeGoXDR(xdr C.xdr_t) { C.free(unsafe.Pointer(xdr.xdr)) } +type ResourceConfig struct { + InstructionLeeway uint64 `json:"instructionLeeway"` +} + type PreflightParameters struct { Logger *log.Entry SourceAccount xdr.AccountId @@ -79,6 +87,7 @@ type PreflightParameters struct { NetworkPassphrase string LedgerEntryReadTx db.LedgerEntryReadTx BucketListSize uint64 + ResourceConfig *ResourceConfig EnableDebug bool } @@ -216,12 +225,20 @@ func getInvokeHostFunctionPreflight(params PreflightParameters) (Preflight, erro handle := cgo.NewHandle(snapshotSourceHandle{params.LedgerEntryReadTx, params.Logger}) defer handle.Delete() + instructionLeeway := defaultInstructionLeeway + if params.ResourceConfig != nil { + instructionLeeway = params.ResourceConfig.InstructionLeeway + } + resourceConfig := C.resource_config_t{ + instruction_leeway: C.uint64_t(instructionLeeway), + } res := C.preflight_invoke_hf_op( C.uintptr_t(handle), C.uint64_t(params.BucketListSize), invokeHostFunctionCXDR, sourceAccountCXDR, li, + resourceConfig, C.bool(params.EnableDebug), ) FreeGoXDR(invokeHostFunctionCXDR) diff --git a/cmd/soroban-rpc/lib/preflight.h b/cmd/soroban-rpc/lib/preflight.h index fce089c95..81db0c54f 100644 --- a/cmd/soroban-rpc/lib/preflight.h +++ b/cmd/soroban-rpc/lib/preflight.h @@ -25,6 +25,10 @@ typedef struct xdr_vector_t { size_t len; } xdr_vector_t; +typedef struct resource_config_t { + uint64_t instruction_leeway; // Allow this many extra instructions when budgeting +} resource_config_t; + typedef struct preflight_result_t { char *error; // Error string in case of error, otherwise null xdr_vector_t auth; // array of SorobanAuthorizationEntries @@ -43,6 +47,7 @@ preflight_result_t *preflight_invoke_hf_op(uintptr_t handle, // Go Handle to for const xdr_t invoke_hf_op, // InvokeHostFunctionOp XDR const xdr_t source_account, // AccountId XDR const ledger_info_t ledger_info, + const resource_config_t resource_config, bool enable_debug); preflight_result_t *preflight_footprint_ttl_op(uintptr_t handle, // Go Handle to forward to SnapshotSourceGet diff --git a/cmd/soroban-rpc/lib/preflight/src/fees.rs b/cmd/soroban-rpc/lib/preflight/src/fees.rs index 1cfc16b16..7e28f9e4f 100644 --- a/cmd/soroban-rpc/lib/preflight/src/fees.rs +++ b/cmd/soroban-rpc/lib/preflight/src/fees.rs @@ -23,12 +23,15 @@ use state_ttl::{get_restored_ledger_sequence, TTLLedgerEntry}; use std::cmp::max; use std::convert::{TryFrom, TryInto}; +use crate::CResourceConfig; + #[allow(clippy::too_many_arguments)] pub(crate) fn compute_host_function_transaction_data_and_min_fee( op: &InvokeHostFunctionOp, pre_storage: &LedgerStorage, post_storage: &Storage, budget: &Budget, + resource_config: CResourceConfig, events: &[DiagnosticEvent], invocation_result: &ScVal, bucket_list_size: u64, @@ -36,7 +39,7 @@ pub(crate) fn compute_host_function_transaction_data_and_min_fee( ) -> Result<(SorobanTransactionData, i64)> { let ledger_changes = get_ledger_changes(budget, post_storage, pre_storage, TtlEntryMap::new())?; let soroban_resources = - calculate_host_function_soroban_resources(&ledger_changes, &post_storage.footprint, budget) + calculate_host_function_soroban_resources(&ledger_changes, &post_storage.footprint, budget, resource_config) .context("cannot compute host function resources")?; let contract_events_size = @@ -128,6 +131,7 @@ fn calculate_host_function_soroban_resources( ledger_changes: &[LedgerEntryChange], footprint: &Footprint, budget: &Budget, + resource_config: CResourceConfig ) -> Result { let ledger_footprint = storage_footprint_to_ledger_footprint(footprint) .context("cannot convert storage footprint to ledger footprint")?; @@ -143,7 +147,7 @@ fn calculate_host_function_soroban_resources( .get_cpu_insns_consumed() .context("cannot get instructions consumed")?; let instructions = max( - budget_instructions + 1000000, + budget_instructions + resource_config.instruction_leeway, budget_instructions * 120 / 100, ); Ok(SorobanResources { diff --git a/cmd/soroban-rpc/lib/preflight/src/lib.rs b/cmd/soroban-rpc/lib/preflight/src/lib.rs index f49a131e8..40f23b55c 100644 --- a/cmd/soroban-rpc/lib/preflight/src/lib.rs +++ b/cmd/soroban-rpc/lib/preflight/src/lib.rs @@ -81,6 +81,12 @@ fn get_default_c_xdr_vector() -> CXDRVector { } } +#[repr(C)] +#[derive(Copy, Clone)] +pub struct CResourceConfig { + pub instruction_leeway: u64 +} + #[repr(C)] #[derive(Copy, Clone)] pub struct CPreflightResult { @@ -133,6 +139,7 @@ pub extern "C" fn preflight_invoke_hf_op( invoke_hf_op: CXDR, // InvokeHostFunctionOp XDR in base64 source_account: CXDR, // AccountId XDR in base64 ledger_info: CLedgerInfo, + resource_config: CResourceConfig, enable_debug: bool, ) -> *mut CPreflightResult { catch_preflight_panic(Box::new(move || { @@ -142,6 +149,7 @@ pub extern "C" fn preflight_invoke_hf_op( invoke_hf_op, source_account, ledger_info, + resource_config, enable_debug, ) })) @@ -153,6 +161,7 @@ fn preflight_invoke_hf_op_or_maybe_panic( invoke_hf_op: CXDR, // InvokeHostFunctionOp XDR in base64 source_account: CXDR, // AccountId XDR in base64 ledger_info: CLedgerInfo, + resource_config: CResourceConfig, enable_debug: bool, ) -> Result { let invoke_hf_op = @@ -166,6 +175,7 @@ fn preflight_invoke_hf_op_or_maybe_panic( invoke_hf_op, source_account, LedgerInfo::from(ledger_info), + resource_config, enable_debug, )?; Ok(result.into()) diff --git a/cmd/soroban-rpc/lib/preflight/src/preflight.rs b/cmd/soroban-rpc/lib/preflight/src/preflight.rs index a818b7dd2..cfafe14c7 100644 --- a/cmd/soroban-rpc/lib/preflight/src/preflight.rs +++ b/cmd/soroban-rpc/lib/preflight/src/preflight.rs @@ -16,6 +16,8 @@ use std::convert::{TryFrom, TryInto}; use std::iter::FromIterator; use std::rc::Rc; +use crate::CResourceConfig; + pub(crate) struct RestorePreamble { pub(crate) transaction_data: SorobanTransactionData, pub(crate) min_fee: i64, @@ -40,6 +42,7 @@ pub(crate) fn preflight_invoke_hf_op( invoke_hf_op: InvokeHostFunctionOp, source_account: AccountId, ledger_info: LedgerInfo, + resource_config: CResourceConfig, enable_debug: bool, ) -> Result { let ledger_storage_rc = Rc::new(ledger_storage); @@ -117,6 +120,7 @@ pub(crate) fn preflight_invoke_hf_op( &ledger_storage_rc, &storage, &budget, + resource_config, &diagnostic_events, &result, bucket_list_size, From a959a784cfd2d0e158632e3b753394a9b9cf1586 Mon Sep 17 00:00:00 2001 From: "Tyler.S" Date: Thu, 14 Dec 2023 10:37:09 -0800 Subject: [PATCH 2/8] Cargo fmt --- cmd/soroban-rpc/lib/preflight/src/fees.rs | 12 ++++++++---- cmd/soroban-rpc/lib/preflight/src/lib.rs | 2 +- 2 files changed, 9 insertions(+), 5 deletions(-) diff --git a/cmd/soroban-rpc/lib/preflight/src/fees.rs b/cmd/soroban-rpc/lib/preflight/src/fees.rs index 7e28f9e4f..1ae6f8990 100644 --- a/cmd/soroban-rpc/lib/preflight/src/fees.rs +++ b/cmd/soroban-rpc/lib/preflight/src/fees.rs @@ -38,9 +38,13 @@ pub(crate) fn compute_host_function_transaction_data_and_min_fee( current_ledger_seq: u32, ) -> Result<(SorobanTransactionData, i64)> { let ledger_changes = get_ledger_changes(budget, post_storage, pre_storage, TtlEntryMap::new())?; - let soroban_resources = - calculate_host_function_soroban_resources(&ledger_changes, &post_storage.footprint, budget, resource_config) - .context("cannot compute host function resources")?; + let soroban_resources = calculate_host_function_soroban_resources( + &ledger_changes, + &post_storage.footprint, + budget, + resource_config, + ) + .context("cannot compute host function resources")?; let contract_events_size = calculate_contract_events_size_bytes(events).context("cannot calculate events size")?; @@ -131,7 +135,7 @@ fn calculate_host_function_soroban_resources( ledger_changes: &[LedgerEntryChange], footprint: &Footprint, budget: &Budget, - resource_config: CResourceConfig + resource_config: CResourceConfig, ) -> Result { let ledger_footprint = storage_footprint_to_ledger_footprint(footprint) .context("cannot convert storage footprint to ledger footprint")?; diff --git a/cmd/soroban-rpc/lib/preflight/src/lib.rs b/cmd/soroban-rpc/lib/preflight/src/lib.rs index 40f23b55c..e2c51c2db 100644 --- a/cmd/soroban-rpc/lib/preflight/src/lib.rs +++ b/cmd/soroban-rpc/lib/preflight/src/lib.rs @@ -84,7 +84,7 @@ fn get_default_c_xdr_vector() -> CXDRVector { #[repr(C)] #[derive(Copy, Clone)] pub struct CResourceConfig { - pub instruction_leeway: u64 + pub instruction_leeway: u64, } #[repr(C)] From 500720931748a4c4869214f335add14d0df13a80 Mon Sep 17 00:00:00 2001 From: "Tyler.S" Date: Fri, 15 Dec 2023 10:49:35 -0800 Subject: [PATCH 3/8] Fix CLI tests --- cmd/soroban-cli/src/rpc/mod.rs | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/cmd/soroban-cli/src/rpc/mod.rs b/cmd/soroban-cli/src/rpc/mod.rs index 57a7b1994..535426292 100644 --- a/cmd/soroban-cli/src/rpc/mod.rs +++ b/cmd/soroban-cli/src/rpc/mod.rs @@ -693,9 +693,11 @@ soroban config identity fund {address} --helper-url "# ) -> Result { tracing::trace!("Simulating:\n{tx:#?}"); let base64_tx = tx.to_xdr_base64(Limits::none())?; + let mut builder = ObjectParams::new(); + builder.insert("transaction", base64_tx)?; let response: SimulateTransactionResponse = self .client()? - .request("simulateTransaction", rpc_params![base64_tx]) + .request("simulateTransaction", builder) .await?; tracing::trace!("Simulation response:\n {response:#?}"); match response.error { From 29781a94a030a50baca6ad522c0f516875182762 Mon Sep 17 00:00:00 2001 From: "Tyler.S" Date: Fri, 15 Dec 2023 11:36:51 -0800 Subject: [PATCH 4/8] Update resource fee in simulate transaction test --- cmd/soroban-rpc/internal/test/simulate_transaction_test.go | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/cmd/soroban-rpc/internal/test/simulate_transaction_test.go b/cmd/soroban-rpc/internal/test/simulate_transaction_test.go index 340f68085..4fb2efdda 100644 --- a/cmd/soroban-rpc/internal/test/simulate_transaction_test.go +++ b/cmd/soroban-rpc/internal/test/simulate_transaction_test.go @@ -240,7 +240,7 @@ func TestSimulateTransactionSucceeds(t *testing.T) { // for test purposes, the most deterministic way to assert the resulting fee is expected value in test scope, is to capture // the resulting fee from current preflight output and re-plug it in here, rather than try to re-implement the cost-model algo // in the test. - ResourceFee: 135910, + ResourceFee: 115910, } // First, decode and compare the transaction data so we get a decent diff if it fails. @@ -1130,7 +1130,7 @@ func TestSimulateSystemEvent(t *testing.T) { // for test purposes, the most deterministic way to assert the resulting fee is expected value in test scope, is to capture // the resulting fee from current preflight output and re-plug it in here, rather than try to re-implement the cost-model algo // in the test. - assert.InDelta(t, 100980, int64(transactionData.ResourceFee), 5000) + assert.InDelta(t, 80980, int64(transactionData.ResourceFee), 5000) assert.InDelta(t, 104, uint32(transactionData.Resources.WriteBytes), 15) require.GreaterOrEqual(t, len(response.Events), 3) } From cf4cf0d18deace3634c168067284988f2bdb6eba Mon Sep 17 00:00:00 2001 From: "Tyler.S" Date: Fri, 15 Dec 2023 11:37:22 -0800 Subject: [PATCH 5/8] Refactor GetPreflight parameters into struct --- .../internal/methods/simulate_transaction.go | 16 +++++++++++-- cmd/soroban-rpc/internal/preflight/pool.go | 18 +++++++-------- .../internal/preflight/preflight.go | 23 ++++++++++++++----- 3 files changed, 40 insertions(+), 17 deletions(-) diff --git a/cmd/soroban-rpc/internal/methods/simulate_transaction.go b/cmd/soroban-rpc/internal/methods/simulate_transaction.go index 47badadfd..a278c9c23 100644 --- a/cmd/soroban-rpc/internal/methods/simulate_transaction.go +++ b/cmd/soroban-rpc/internal/methods/simulate_transaction.go @@ -47,7 +47,7 @@ type SimulateTransactionResponse struct { } type PreflightGetter interface { - GetPreflight(ctx context.Context, readTx db.LedgerEntryReadTx, bucketListSize uint64, sourceAccount xdr.AccountId, opBody xdr.OperationBody, footprint xdr.LedgerFootprint, resourceConfig *preflight.ResourceConfig) (preflight.Preflight, error) + GetPreflight(ctx context.Context, params preflight.PreflightGetterParameters) (preflight.Preflight, error) } // NewSimulateTransactionHandler returns a json rpc handler to run preflight simulations @@ -114,7 +114,19 @@ func NewSimulateTransactionHandler(logger *log.Entry, ledgerEntryReader db.Ledge } } - result, err := getter.GetPreflight(ctx, readTx, bucketListSize, sourceAccount, op.Body, footprint, request.ResourceConfig) + resource_config := preflight.DefaultResourceConfig() + if request.ResourceConfig != nil { + resource_config = *request.ResourceConfig + } + params := preflight.PreflightGetterParameters{ + LedgerEntryReadTx: readTx, + BucketListSize: bucketListSize, + SourceAccount: sourceAccount, + OperationBody: op.Body, + Footprint: footprint, + ResourceConfig: resource_config, + } + result, err := getter.GetPreflight(ctx, params) if err != nil { return SimulateTransactionResponse{ Error: err.Error(), diff --git a/cmd/soroban-rpc/internal/preflight/pool.go b/cmd/soroban-rpc/internal/preflight/pool.go index 6a49df3e7..1d1824115 100644 --- a/cmd/soroban-rpc/internal/preflight/pool.go +++ b/cmd/soroban-rpc/internal/preflight/pool.go @@ -139,27 +139,27 @@ func (m *metricsLedgerEntryWrapper) GetLedgerEntries(keys ...xdr.LedgerKey) ([]d return entries, err } -func (pwp *PreflightWorkerPool) GetPreflight(ctx context.Context, readTx db.LedgerEntryReadTx, bucketListSize uint64, sourceAccount xdr.AccountId, opBody xdr.OperationBody, footprint xdr.LedgerFootprint, resourceConfig *ResourceConfig) (Preflight, error) { +func (pwp *PreflightWorkerPool) GetPreflight(ctx context.Context, params PreflightGetterParameters) (Preflight, error) { if pwp.isClosed.Load() { return Preflight{}, errors.New("preflight worker pool is closed") } wrappedTx := metricsLedgerEntryWrapper{ - LedgerEntryReadTx: readTx, + LedgerEntryReadTx: params.LedgerEntryReadTx, } - params := PreflightParameters{ + preflightParams := PreflightParameters{ Logger: pwp.logger, - SourceAccount: sourceAccount, - OpBody: opBody, + SourceAccount: params.SourceAccount, + OpBody: params.OperationBody, NetworkPassphrase: pwp.networkPassphrase, LedgerEntryReadTx: &wrappedTx, - BucketListSize: bucketListSize, - Footprint: footprint, - ResourceConfig: resourceConfig, + BucketListSize: params.BucketListSize, + Footprint: params.Footprint, + ResourceConfig: params.ResourceConfig, EnableDebug: pwp.enableDebug, } resultC := make(chan workerResult) select { - case pwp.requestChan <- workerRequest{ctx, params, resultC}: + case pwp.requestChan <- workerRequest{ctx, preflightParams, resultC}: result := <-resultC if wrappedTx.ledgerEntriesFetched > 0 { status := "ok" diff --git a/cmd/soroban-rpc/internal/preflight/preflight.go b/cmd/soroban-rpc/internal/preflight/preflight.go index 99c23ec43..920691578 100644 --- a/cmd/soroban-rpc/internal/preflight/preflight.go +++ b/cmd/soroban-rpc/internal/preflight/preflight.go @@ -79,6 +79,21 @@ type ResourceConfig struct { InstructionLeeway uint64 `json:"instructionLeeway"` } +func DefaultResourceConfig() ResourceConfig { + return ResourceConfig{ + InstructionLeeway: defaultInstructionLeeway, + } +} + +type PreflightGetterParameters struct { + LedgerEntryReadTx db.LedgerEntryReadTx + BucketListSize uint64 + SourceAccount xdr.AccountId + OperationBody xdr.OperationBody + Footprint xdr.LedgerFootprint + ResourceConfig ResourceConfig +} + type PreflightParameters struct { Logger *log.Entry SourceAccount xdr.AccountId @@ -87,7 +102,7 @@ type PreflightParameters struct { NetworkPassphrase string LedgerEntryReadTx db.LedgerEntryReadTx BucketListSize uint64 - ResourceConfig *ResourceConfig + ResourceConfig ResourceConfig EnableDebug bool } @@ -225,12 +240,8 @@ func getInvokeHostFunctionPreflight(params PreflightParameters) (Preflight, erro handle := cgo.NewHandle(snapshotSourceHandle{params.LedgerEntryReadTx, params.Logger}) defer handle.Delete() - instructionLeeway := defaultInstructionLeeway - if params.ResourceConfig != nil { - instructionLeeway = params.ResourceConfig.InstructionLeeway - } resourceConfig := C.resource_config_t{ - instruction_leeway: C.uint64_t(instructionLeeway), + instruction_leeway: C.uint64_t(params.ResourceConfig.InstructionLeeway), } res := C.preflight_invoke_hf_op( C.uintptr_t(handle), From cf984a5e6efcd026c15ab4e27bfcd2cfb7825e51 Mon Sep 17 00:00:00 2001 From: "Tyler.S" Date: Fri, 15 Dec 2023 11:40:17 -0800 Subject: [PATCH 6/8] Update default instruction leeway to 3 million --- cmd/soroban-rpc/internal/preflight/preflight.go | 2 +- cmd/soroban-rpc/internal/test/simulate_transaction_test.go | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/cmd/soroban-rpc/internal/preflight/preflight.go b/cmd/soroban-rpc/internal/preflight/preflight.go index 920691578..e342ab434 100644 --- a/cmd/soroban-rpc/internal/preflight/preflight.go +++ b/cmd/soroban-rpc/internal/preflight/preflight.go @@ -36,7 +36,7 @@ type snapshotSourceHandle struct { } const ( - defaultInstructionLeeway uint64 = 1000000 + defaultInstructionLeeway uint64 = 3000000 ) // SnapshotSourceGet takes a LedgerKey XDR in base64 string and returns its matching LedgerEntry XDR in base64 string diff --git a/cmd/soroban-rpc/internal/test/simulate_transaction_test.go b/cmd/soroban-rpc/internal/test/simulate_transaction_test.go index 4fb2efdda..340f68085 100644 --- a/cmd/soroban-rpc/internal/test/simulate_transaction_test.go +++ b/cmd/soroban-rpc/internal/test/simulate_transaction_test.go @@ -240,7 +240,7 @@ func TestSimulateTransactionSucceeds(t *testing.T) { // for test purposes, the most deterministic way to assert the resulting fee is expected value in test scope, is to capture // the resulting fee from current preflight output and re-plug it in here, rather than try to re-implement the cost-model algo // in the test. - ResourceFee: 115910, + ResourceFee: 135910, } // First, decode and compare the transaction data so we get a decent diff if it fails. @@ -1130,7 +1130,7 @@ func TestSimulateSystemEvent(t *testing.T) { // for test purposes, the most deterministic way to assert the resulting fee is expected value in test scope, is to capture // the resulting fee from current preflight output and re-plug it in here, rather than try to re-implement the cost-model algo // in the test. - assert.InDelta(t, 80980, int64(transactionData.ResourceFee), 5000) + assert.InDelta(t, 100980, int64(transactionData.ResourceFee), 5000) assert.InDelta(t, 104, uint32(transactionData.Resources.WriteBytes), 15) require.GreaterOrEqual(t, len(response.Events), 3) } From 2b217a9fe69f325b5961a7af7791d60cdf5a2dbb Mon Sep 17 00:00:00 2001 From: "Tyler.S" Date: Fri, 15 Dec 2023 14:09:30 -0800 Subject: [PATCH 7/8] Update workflow file to test against SDK update --- .github/workflows/e2e.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/e2e.yml b/.github/workflows/e2e.yml index 60ad0c3f2..c83b8e622 100644 --- a/.github/workflows/e2e.yml +++ b/.github/workflows/e2e.yml @@ -40,8 +40,8 @@ jobs: # option #2, set the version of stellar-sdk used as a ref to a gh repo if # a value is set on SYSTEM_TEST_JS_STELLAR_SDK_GH_REPO, it takes # precedence over any SYSTEM_TEST_JS_STELLAR_SDK_NPM_VERSION - SYSTEM_TEST_JS_STELLAR_SDK_GH_REPO: - SYSTEM_TEST_JS_STELLAR_SDK_GH_REF: + SYSTEM_TEST_JS_STELLAR_SDK_GH_REPO: stellar/js-stellar-sdk + SYSTEM_TEST_JS_STELLAR_SDK_GH_REF: 6f758c6dd72e5986d2ab311e5cac3aab701f7f32 # the version of rs-stellar-xdr to use for quickstart SYSTEM_TEST_RS_XDR_GIT_REF: v20.0.1 From 256dcecae094c74de161da95fa1c0215b6bc9666 Mon Sep 17 00:00:00 2001 From: "Tyler.S" Date: Fri, 15 Dec 2023 14:54:53 -0800 Subject: [PATCH 8/8] Update SDK NPM version for system tests --- .github/workflows/e2e.yml | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/.github/workflows/e2e.yml b/.github/workflows/e2e.yml index c83b8e622..0d885b688 100644 --- a/.github/workflows/e2e.yml +++ b/.github/workflows/e2e.yml @@ -36,12 +36,12 @@ jobs: # resolution options, using npm release or a gh ref: # # option #1, set the version of stellar-sdk based on a npm release version - SYSTEM_TEST_JS_STELLAR_SDK_NPM_VERSION: 11.0.1 + SYSTEM_TEST_JS_STELLAR_SDK_NPM_VERSION: 11.1.0 # option #2, set the version of stellar-sdk used as a ref to a gh repo if # a value is set on SYSTEM_TEST_JS_STELLAR_SDK_GH_REPO, it takes # precedence over any SYSTEM_TEST_JS_STELLAR_SDK_NPM_VERSION - SYSTEM_TEST_JS_STELLAR_SDK_GH_REPO: stellar/js-stellar-sdk - SYSTEM_TEST_JS_STELLAR_SDK_GH_REF: 6f758c6dd72e5986d2ab311e5cac3aab701f7f32 + SYSTEM_TEST_JS_STELLAR_SDK_GH_REPO: + SYSTEM_TEST_JS_STELLAR_SDK_GH_REF: # the version of rs-stellar-xdr to use for quickstart SYSTEM_TEST_RS_XDR_GIT_REF: v20.0.1