Skip to content

Commit

Permalink
Update (again) CLI and soroban-rpc to the latest XDR changes (stellar…
Browse files Browse the repository at this point in the history
  • Loading branch information
2opremio authored Aug 10, 2023
1 parent d788665 commit 739231f
Show file tree
Hide file tree
Showing 10 changed files with 32 additions and 46 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/soroban-rpc.yml
Original file line number Diff line number Diff line change
Expand Up @@ -110,7 +110,7 @@ jobs:
env:
SOROBAN_RPC_INTEGRATION_TESTS_ENABLED: true
SOROBAN_RPC_INTEGRATION_TESTS_CAPTIVE_CORE_BIN: /usr/bin/stellar-core
PROTOCOL_20_CORE_DEBIAN_PKG_VERSION: 19.12.1-1425.df613c240.focal~soroban
PROTOCOL_20_CORE_DEBIAN_PKG_VERSION: 19.13.1-1434.35170ec6c.focal~soroban
runs-on: ${{ matrix.os }}
steps:
- uses: actions/checkout@v3
Expand Down
22 changes: 11 additions & 11 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

12 changes: 6 additions & 6 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -16,18 +16,18 @@ version = "0.9.4"
[workspace.dependencies.soroban-env-host]
version = "0.0.17"
git = "https://github.com/stellar/rs-soroban-env"
rev = "c5607a2e9e296b2636b46dc910387aa3446b3e29"
rev = "048be90e10dfda6486141f96ea86e32fb91681f4"

[workspace.dependencies.soroban-spec]
version = "0.9.1"
git = "https://github.com/stellar/rs-soroban-sdk"
rev = "5943aa66baf85ebb70d946c37e297abc80d13a78"
rev = "df9334d4e3a1a2c2e0034cfabb643972d4d7f717"
# path = "../rs-soroban-sdk/soroban-spec"

[workspace.dependencies.soroban-spec-rust]
version = "0.9.1"
git = "https://github.com/stellar/rs-soroban-sdk"
rev = "5943aa66baf85ebb70d946c37e297abc80d13a78"
rev = "df9334d4e3a1a2c2e0034cfabb643972d4d7f717"
# path = "../rs-soroban-sdk/soroban-spec-rust"

[workspace.dependencies.soroban-spec-json]
Expand All @@ -45,12 +45,12 @@ path = "./cmd/crates/soroban-spec-tools"
[workspace.dependencies.soroban-sdk]
version = "0.9.1"
git = "https://github.com/stellar/rs-soroban-sdk"
rev = "5943aa66baf85ebb70d946c37e297abc80d13a78"
rev = "df9334d4e3a1a2c2e0034cfabb643972d4d7f717"

[workspace.dependencies.soroban-ledger-snapshot]
version = "0.9.1"
git = "https://github.com/stellar/rs-soroban-sdk"
rev = "5943aa66baf85ebb70d946c37e297abc80d13a78"
rev = "df9334d4e3a1a2c2e0034cfabb643972d4d7f717"

[workspace.dependencies.soroban-cli]
version = "0.9.4"
Expand All @@ -59,7 +59,7 @@ path = "cmd/soroban-cli"
[workspace.dependencies.stellar-xdr]
version = "0.0.17"
git = "https://github.com/stellar/rs-stellar-xdr"
rev = "d6e02584ac9f4046bf38eaf445ced0d4f33631fd"
rev = "4876e5eb20016caebbd13bcf6401626dc6073b8e"
default-features = false

[workspace.dependencies]
Expand Down
2 changes: 1 addition & 1 deletion cmd/soroban-rpc/internal/test/docker-compose.yml
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ services:
# Note: Please keep the image pinned to an immutable tag matching the Captive Core version.
# This avoid implicit updates which break compatibility between
# the Core container and captive core.
image: ${CORE_IMAGE:-2opremio/stellar-core:19.12.1-1425.df613c240.focal-soroban}
image: ${CORE_IMAGE:-2opremio/stellar-core:19.13.1-1434.35170ec6c.focal-soroban}
depends_on:
- core-postgres
restart: on-failure
Expand Down
4 changes: 2 additions & 2 deletions cmd/soroban-rpc/internal/test/simulate_transaction_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -238,7 +238,7 @@ func TestSimulateTransactionSucceeds(t *testing.T) {
},
},
},
Instructions: 88144,
Instructions: 73776,
ReadBytes: 40,
WriteBytes: 112,
ContractEventsSizeBytes: 0,
Expand Down Expand Up @@ -499,7 +499,7 @@ func TestSimulateInvokeContractTransactionSucceeds(t *testing.T) {
require.Contains(t, metrics, "soroban_rpc_json_rpc_request_duration_seconds_count{endpoint=\"simulateTransaction\",status=\"ok\"} 3")
require.Contains(t, metrics, "soroban_rpc_preflight_pool_request_ledger_get_duration_seconds_count{status=\"ok\",type=\"db\"} 3")
require.Contains(t, metrics, "soroban_rpc_preflight_pool_request_ledger_get_duration_seconds_count{status=\"ok\",type=\"all\"} 3")
require.Contains(t, metrics, "soroban_rpc_preflight_pool_request_ledger_entries_fetched_sum 48")
require.Contains(t, metrics, "soroban_rpc_preflight_pool_request_ledger_entries_fetched_sum 52")
}

func TestSimulateTransactionError(t *testing.T) {
Expand Down
24 changes: 5 additions & 19 deletions cmd/soroban-rpc/lib/preflight/src/fees.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
use ledger_storage;
use ledger_storage::LedgerStorage;
use soroban_env_host::budget::Budget;
use soroban_env_host::e2e_invoke::{extract_rent_changes, get_ledger_changes, LedgerEntryChange};
use soroban_env_host::fees::{
Expand Down Expand Up @@ -34,8 +33,7 @@ pub(crate) fn compute_host_function_transaction_data_and_min_fee(
let ledger_changes = get_ledger_changes(budget, post_storage, pre_storage)?;
let soroban_resources = calculate_host_function_soroban_resources(
&ledger_changes,
pre_storage,
post_storage,
&post_storage.footprint,
budget,
events,
)?;
Expand Down Expand Up @@ -123,24 +121,12 @@ fn estimate_max_transaction_size_for_operation(

fn calculate_host_function_soroban_resources(
ledger_changes: &Vec<LedgerEntryChange>,
pre_storage: &LedgerStorage,
post_storage: &Storage,
footprint: &Footprint,
budget: &Budget,
events: &Vec<DiagnosticEvent>,
) -> Result<SorobanResources, Box<dyn error::Error>> {
let ledger_footprint = storage_footprint_to_ledger_footprint(&post_storage.footprint)?;
// FIXME: This hack is needed due to a bug in recording mode which prevents get_ledger_changes() from
// including unmodified ledger entries.
// Remove once this is fixed upstream.
let mut unmodified_ledger_keys: Vec<LedgerKey> = Vec::new();
for k in ledger_footprint.read_only.as_vec() {
if !post_storage.map.contains_key::<LedgerKey>(k, budget)? {
unmodified_ledger_keys.push(k.clone());
}
}
let unmodified_entries_read_bytes =
calculate_unmodified_ledger_entry_bytes(&unmodified_ledger_keys, pre_storage, false)?;
let modified_entries_read_bytes: u32 = ledger_changes
let ledger_footprint = storage_footprint_to_ledger_footprint(footprint)?;
let read_bytes: u32 = ledger_changes
.iter()
.map(|c| c.encoded_key.len() as u32 + c.old_entry_size_bytes)
.sum();
Expand All @@ -162,7 +148,7 @@ fn calculate_host_function_soroban_resources(
Ok(SorobanResources {
footprint: ledger_footprint,
instructions: u32::try_from(instructions)?,
read_bytes: unmodified_entries_read_bytes + modified_entries_read_bytes,
read_bytes,
write_bytes,
contract_events_size_bytes,
})
Expand Down
4 changes: 2 additions & 2 deletions cmd/soroban-rpc/lib/preflight/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -189,12 +189,12 @@ fn get_budget_from_network_config_params(
);
};

let budget = Budget::from_configs(
let budget = Budget::try_from_configs(
compute.tx_max_instructions as u64,
compute.tx_memory_limit as u64,
cost_params_cpu,
cost_params_memory,
);
)?;
Ok(budget)
}

Expand Down
2 changes: 1 addition & 1 deletion docs/soroban-cli-full-docs.md

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ require (
github.com/sirupsen/logrus v1.4.1
github.com/spf13/cobra v0.0.0-20160830174925-9c28e4bbd74e
github.com/spf13/pflag v1.0.5
github.com/stellar/go v0.0.0-20230804153331-498d556f4dd7
github.com/stellar/go v0.0.0-20230810143226-6a5c4124d746
github.com/stretchr/testify v1.8.0
golang.org/x/mod v0.6.0
)
Expand Down
4 changes: 2 additions & 2 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -169,8 +169,8 @@ github.com/spf13/pflag v1.0.5 h1:iy+VFUOCP1a+8yFto/drg2CJ5u0yRoB7fZw3DKv/JXA=
github.com/spf13/pflag v1.0.5/go.mod h1:McXfInJRrz4CZXVZOBLb0bTZqETkiAhM9Iw0y3An2Bg=
github.com/spf13/viper v0.0.0-20150621231900-db7ff930a189 h1:fvB1AFbBd6SfI9Rd0ooAJp8uLkZDbZaLFHi7ZnNP6uI=
github.com/spf13/viper v0.0.0-20150621231900-db7ff930a189/go.mod h1:A8kyI5cUJhb8N+3pkfONlcEcZbueH6nhAm0Fq7SrnBM=
github.com/stellar/go v0.0.0-20230804153331-498d556f4dd7 h1:EhQ8kQko3rFE9GP8lH5/R1IDkeWyyZKTEjJ7Wiu5pz4=
github.com/stellar/go v0.0.0-20230804153331-498d556f4dd7/go.mod h1:m9ABBUAExq/TfafyQrLie0owyyAR6IYCRhujttELLHU=
github.com/stellar/go v0.0.0-20230810143226-6a5c4124d746 h1:JwM5CpjEmd5YMNzSaAgIgErMHLBXdphboON53fLo73A=
github.com/stellar/go v0.0.0-20230810143226-6a5c4124d746/go.mod h1:m9ABBUAExq/TfafyQrLie0owyyAR6IYCRhujttELLHU=
github.com/stellar/go-xdr v0.0.0-20211103144802-8017fc4bdfee h1:fbVs0xmXpBvVS4GBeiRmAE3Le70ofAqFMch1GTiq/e8=
github.com/stellar/go-xdr v0.0.0-20211103144802-8017fc4bdfee/go.mod h1:yoxyU/M8nl9LKeWIoBrbDPQ7Cy+4jxRcWcOayZ4BMps=
github.com/stretchr/objx v0.1.0/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+wExME=
Expand Down

0 comments on commit 739231f

Please sign in to comment.