From b2229a3c98aa020e926c449e68258667a93080a8 Mon Sep 17 00:00:00 2001 From: Alfonso Acosta Date: Mon, 23 Oct 2023 19:45:52 +0200 Subject: [PATCH] all: Bump XDR and Rust/Go/Core dependencies (#1029) --------- Co-authored-by: Willem Wyndham --- .github/workflows/soroban-rpc.yml | 2 +- Cargo.lock | 22 +-- Cargo.toml | 14 +- cmd/crates/soroban-spec-json/src/lib.rs | 4 +- cmd/crates/soroban-spec-json/src/types.rs | 2 +- cmd/crates/soroban-spec-tools/src/lib.rs | 30 ++-- cmd/crates/soroban-spec-tools/src/utils.rs | 13 +- .../src/boilerplate.rs | 2 +- cmd/crates/soroban-spec-typescript/src/lib.rs | 4 +- .../soroban-spec-typescript/src/types.rs | 2 +- .../tests/it/integration/custom_types.rs | 4 +- .../tests/it/integration/hello_world.rs | 8 +- .../soroban-test/tests/it/integration/util.rs | 14 +- .../commands/contract/{bump.rs => extend.rs} | 55 +++---- .../src/commands/contract/fetch.rs | 2 +- .../src/commands/contract/install.rs | 2 +- cmd/soroban-cli/src/commands/contract/mod.rs | 10 +- cmd/soroban-cli/src/commands/contract/read.rs | 8 +- .../src/commands/contract/restore.rs | 38 ++--- .../src/commands/lab/token/wrap.rs | 2 +- cmd/soroban-cli/src/key.rs | 6 +- cmd/soroban-cli/src/rpc/mod.rs | 16 +- cmd/soroban-cli/src/rpc/transaction.rs | 2 +- cmd/soroban-rpc/internal/db/ledger_test.go | 4 +- cmd/soroban-rpc/internal/db/ledgerentry.go | 44 ++--- .../internal/db/ledgerentry_test.go | 45 +++--- cmd/soroban-rpc/internal/ingest/service.go | 2 +- .../internal/ingest/service_test.go | 4 +- .../internal/methods/get_events_test.go | 4 +- .../methods/get_latest_ledger_test.go | 4 +- .../internal/methods/get_ledger_entries.go | 19 ++- .../internal/methods/get_ledger_entry.go | 12 +- .../internal/methods/get_transaction_test.go | 13 +- .../internal/methods/simulate_transaction.go | 8 +- .../internal/preflight/preflight.go | 29 ++-- .../internal/preflight/preflight_test.go | 34 ++-- .../test/captive-core-integration-tests.cfg | 4 +- cmd/soroban-rpc/internal/test/cli_test.go | 112 +++++++------ .../internal/test/docker-compose.yml | 2 +- .../test/simulate_transaction_test.go | 101 ++++-------- .../test/stellar-core-integration-tests.cfg | 5 +- .../internal/test/transaction_test.go | 16 +- .../transactions/transactions_test.go | 7 +- cmd/soroban-rpc/lib/preflight.h | 16 +- cmd/soroban-rpc/lib/preflight/src/fees.rs | 153 ++++++++---------- .../lib/preflight/src/ledger_storage.rs | 119 +++++++------- cmd/soroban-rpc/lib/preflight/src/lib.rs | 22 +-- .../lib/preflight/src/preflight.rs | 16 +- .../lib/preflight/src/state_expiration.rs | 70 -------- .../lib/preflight/src/state_ttl.rs | 67 ++++++++ docs/soroban-cli-full-docs.md | 36 ++--- go.mod | 2 +- go.sum | 50 +++++- 53 files changed, 638 insertions(+), 644 deletions(-) rename cmd/soroban-cli/src/commands/contract/{bump.rs => extend.rs} (76%) delete mode 100644 cmd/soroban-rpc/lib/preflight/src/state_expiration.rs create mode 100644 cmd/soroban-rpc/lib/preflight/src/state_ttl.rs diff --git a/.github/workflows/soroban-rpc.yml b/.github/workflows/soroban-rpc.yml index 99dc6fc40..98ed89f91 100644 --- a/.github/workflows/soroban-rpc.yml +++ b/.github/workflows/soroban-rpc.yml @@ -112,7 +112,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.13.1-1481.3acf6dd26.focal + PROTOCOL_20_CORE_DEBIAN_PKG_VERSION: 19.14.1-1529.fcbbad4ce.focal steps: - uses: actions/checkout@v3 with: diff --git a/Cargo.lock b/Cargo.lock index 658160012..0c6f50d4f 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -2518,7 +2518,7 @@ dependencies = [ [[package]] name = "soroban-env-common" version = "20.0.0-rc2" -source = "git+https://github.com/stellar/rs-soroban-env?rev=8c63bff68a15d79aca3a705ee6916a68db57b7e6#8c63bff68a15d79aca3a705ee6916a68db57b7e6" +source = "git+https://github.com/stellar/rs-soroban-env?rev=91f44778389490ad863d61a8a90ac9875ba6d8fd#91f44778389490ad863d61a8a90ac9875ba6d8fd" dependencies = [ "arbitrary", "crate-git-revision 0.0.6", @@ -2535,7 +2535,7 @@ dependencies = [ [[package]] name = "soroban-env-guest" version = "20.0.0-rc2" -source = "git+https://github.com/stellar/rs-soroban-env?rev=8c63bff68a15d79aca3a705ee6916a68db57b7e6#8c63bff68a15d79aca3a705ee6916a68db57b7e6" +source = "git+https://github.com/stellar/rs-soroban-env?rev=91f44778389490ad863d61a8a90ac9875ba6d8fd#91f44778389490ad863d61a8a90ac9875ba6d8fd" dependencies = [ "soroban-env-common", "static_assertions", @@ -2544,7 +2544,7 @@ dependencies = [ [[package]] name = "soroban-env-host" version = "20.0.0-rc2" -source = "git+https://github.com/stellar/rs-soroban-env?rev=8c63bff68a15d79aca3a705ee6916a68db57b7e6#8c63bff68a15d79aca3a705ee6916a68db57b7e6" +source = "git+https://github.com/stellar/rs-soroban-env?rev=91f44778389490ad863d61a8a90ac9875ba6d8fd#91f44778389490ad863d61a8a90ac9875ba6d8fd" dependencies = [ "backtrace", "ed25519-dalek 2.0.0", @@ -2567,7 +2567,7 @@ dependencies = [ [[package]] name = "soroban-env-macros" version = "20.0.0-rc2" -source = "git+https://github.com/stellar/rs-soroban-env?rev=8c63bff68a15d79aca3a705ee6916a68db57b7e6#8c63bff68a15d79aca3a705ee6916a68db57b7e6" +source = "git+https://github.com/stellar/rs-soroban-env?rev=91f44778389490ad863d61a8a90ac9875ba6d8fd#91f44778389490ad863d61a8a90ac9875ba6d8fd" dependencies = [ "itertools 0.10.5", "proc-macro2", @@ -2585,7 +2585,7 @@ version = "20.0.0-rc4" [[package]] name = "soroban-ledger-snapshot" version = "20.0.0-rc2" -source = "git+https://github.com/stellar/rs-soroban-sdk?rev=0992413f9b05e5bfb1f872bce99e89d9129b2e61#0992413f9b05e5bfb1f872bce99e89d9129b2e61" +source = "git+https://github.com/stellar/rs-soroban-sdk?rev=729ed3ac5fe8600a3245d5816eadd3c95ab2eb54#729ed3ac5fe8600a3245d5816eadd3c95ab2eb54" dependencies = [ "serde", "serde_json", @@ -2597,7 +2597,7 @@ dependencies = [ [[package]] name = "soroban-native-sdk-macros" version = "20.0.0-rc2" -source = "git+https://github.com/stellar/rs-soroban-env?rev=8c63bff68a15d79aca3a705ee6916a68db57b7e6#8c63bff68a15d79aca3a705ee6916a68db57b7e6" +source = "git+https://github.com/stellar/rs-soroban-env?rev=91f44778389490ad863d61a8a90ac9875ba6d8fd#91f44778389490ad863d61a8a90ac9875ba6d8fd" dependencies = [ "itertools 0.10.5", "proc-macro2", @@ -2608,7 +2608,7 @@ dependencies = [ [[package]] name = "soroban-sdk" version = "20.0.0-rc2" -source = "git+https://github.com/stellar/rs-soroban-sdk?rev=0992413f9b05e5bfb1f872bce99e89d9129b2e61#0992413f9b05e5bfb1f872bce99e89d9129b2e61" +source = "git+https://github.com/stellar/rs-soroban-sdk?rev=729ed3ac5fe8600a3245d5816eadd3c95ab2eb54#729ed3ac5fe8600a3245d5816eadd3c95ab2eb54" dependencies = [ "arbitrary", "bytes-lit", @@ -2625,7 +2625,7 @@ dependencies = [ [[package]] name = "soroban-sdk-macros" version = "20.0.0-rc2" -source = "git+https://github.com/stellar/rs-soroban-sdk?rev=0992413f9b05e5bfb1f872bce99e89d9129b2e61#0992413f9b05e5bfb1f872bce99e89d9129b2e61" +source = "git+https://github.com/stellar/rs-soroban-sdk?rev=729ed3ac5fe8600a3245d5816eadd3c95ab2eb54#729ed3ac5fe8600a3245d5816eadd3c95ab2eb54" dependencies = [ "crate-git-revision 0.0.6", "darling", @@ -2644,7 +2644,7 @@ dependencies = [ [[package]] name = "soroban-spec" version = "20.0.0-rc2" -source = "git+https://github.com/stellar/rs-soroban-sdk?rev=0992413f9b05e5bfb1f872bce99e89d9129b2e61#0992413f9b05e5bfb1f872bce99e89d9129b2e61" +source = "git+https://github.com/stellar/rs-soroban-sdk?rev=729ed3ac5fe8600a3245d5816eadd3c95ab2eb54#729ed3ac5fe8600a3245d5816eadd3c95ab2eb54" dependencies = [ "base64 0.13.1", "stellar-xdr", @@ -2669,7 +2669,7 @@ dependencies = [ [[package]] name = "soroban-spec-rust" version = "20.0.0-rc2" -source = "git+https://github.com/stellar/rs-soroban-sdk?rev=0992413f9b05e5bfb1f872bce99e89d9129b2e61#0992413f9b05e5bfb1f872bce99e89d9129b2e61" +source = "git+https://github.com/stellar/rs-soroban-sdk?rev=729ed3ac5fe8600a3245d5816eadd3c95ab2eb54#729ed3ac5fe8600a3245d5816eadd3c95ab2eb54" dependencies = [ "prettyplease", "proc-macro2", @@ -2805,7 +2805,7 @@ dependencies = [ [[package]] name = "stellar-xdr" version = "20.0.0-rc1" -source = "git+https://github.com/stellar/rs-stellar-xdr?rev=d5ce0c9e7aa83461773a6e81662067f35d39e4c1#d5ce0c9e7aa83461773a6e81662067f35d39e4c1" +source = "git+https://github.com/stellar/rs-stellar-xdr?rev=9c97e4fa909a0b6455547a4f4a95800696b2a69a#9c97e4fa909a0b6455547a4f4a95800696b2a69a" dependencies = [ "arbitrary", "base64 0.13.1", diff --git a/Cargo.toml b/Cargo.toml index 6747e6aeb..7ccadcac0 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -16,18 +16,18 @@ version = "20.0.0-rc4" [workspace.dependencies.soroban-env-host] version = "20.0.0-rc2" git = "https://github.com/stellar/rs-soroban-env" -rev = "8c63bff68a15d79aca3a705ee6916a68db57b7e6" +rev = "91f44778389490ad863d61a8a90ac9875ba6d8fd" [workspace.dependencies.soroban-spec] version = "20.0.0-rc2" git = "https://github.com/stellar/rs-soroban-sdk" -rev = "0992413f9b05e5bfb1f872bce99e89d9129b2e61" +rev = "729ed3ac5fe8600a3245d5816eadd3c95ab2eb54" # path = "../rs-soroban-sdk/soroban-spec" [workspace.dependencies.soroban-spec-rust] version = "20.0.0-rc2" git = "https://github.com/stellar/rs-soroban-sdk" -rev = "0992413f9b05e5bfb1f872bce99e89d9129b2e61" +rev = "729ed3ac5fe8600a3245d5816eadd3c95ab2eb54" # path = "../rs-soroban-sdk/soroban-spec-rust" [workspace.dependencies.soroban-spec-json] @@ -45,12 +45,12 @@ path = "./cmd/crates/soroban-spec-tools" [workspace.dependencies.soroban-sdk] version = "20.0.0-rc2" git = "https://github.com/stellar/rs-soroban-sdk" -rev = "0992413f9b05e5bfb1f872bce99e89d9129b2e61" +rev = "729ed3ac5fe8600a3245d5816eadd3c95ab2eb54" [workspace.dependencies.soroban-ledger-snapshot] version = "20.0.0-rc2" git = "https://github.com/stellar/rs-soroban-sdk" -rev = "0992413f9b05e5bfb1f872bce99e89d9129b2e61" +rev = "729ed3ac5fe8600a3245d5816eadd3c95ab2eb54" [workspace.dependencies.soroban-cli] version = "20.0.0-rc4" @@ -59,8 +59,8 @@ path = "cmd/soroban-cli" [workspace.dependencies.stellar-xdr] version = "20.0.0-rc1" git = "https://github.com/stellar/rs-stellar-xdr" -rev = "d5ce0c9e7aa83461773a6e81662067f35d39e4c1" -default-features = false +rev = "9c97e4fa909a0b6455547a4f4a95800696b2a69a" +default-features = true [workspace.dependencies] base64 = "0.21.2" diff --git a/cmd/crates/soroban-spec-json/src/lib.rs b/cmd/crates/soroban-spec-json/src/lib.rs index e7310ccfd..cdc64665b 100644 --- a/cmd/crates/soroban-spec-json/src/lib.rs +++ b/cmd/crates/soroban-spec-json/src/lib.rs @@ -3,8 +3,8 @@ use std::{fs, io}; pub mod types; use sha2::{Digest, Sha256}; -use stellar_xdr::ScSpecEntry; +use stellar_xdr::curr::ScSpecEntry; use types::Entry; use soroban_spec::read::{from_wasm, FromWasmError}; @@ -16,7 +16,7 @@ pub enum GenerateFromFileError { #[error("sha256 does not match, expected: {expected}")] VerifySha256 { expected: String }, #[error("parsing contract spec: {0}")] - Parse(stellar_xdr::Error), + Parse(stellar_xdr::curr::Error), #[error("getting contract spec: {0}")] GetSpec(FromWasmError), } diff --git a/cmd/crates/soroban-spec-json/src/types.rs b/cmd/crates/soroban-spec-json/src/types.rs index 863132ca8..6fcc483e1 100644 --- a/cmd/crates/soroban-spec-json/src/types.rs +++ b/cmd/crates/soroban-spec-json/src/types.rs @@ -1,5 +1,5 @@ use serde::Serialize; -use stellar_xdr::{ +use stellar_xdr::curr::{ ScSpecEntry, ScSpecFunctionInputV0, ScSpecTypeDef, ScSpecUdtEnumCaseV0, ScSpecUdtErrorEnumCaseV0, ScSpecUdtStructFieldV0, ScSpecUdtUnionCaseV0, }; diff --git a/cmd/crates/soroban-spec-tools/src/lib.rs b/cmd/crates/soroban-spec-tools/src/lib.rs index 4458f30e2..a95bc9454 100644 --- a/cmd/crates/soroban-spec-tools/src/lib.rs +++ b/cmd/crates/soroban-spec-tools/src/lib.rs @@ -3,7 +3,7 @@ use std::str::FromStr; use itertools::Itertools; use serde_json::{json, Value}; -use stellar_xdr::{ +use stellar_xdr::curr::{ AccountId, BytesM, ContractExecutable, Error as XdrError, Hash, Int128Parts, Int256Parts, PublicKey, ScAddress, ScBytes, ScContractInstance, ScMap, ScMapEntry, ScNonceKey, ScSpecEntry, ScSpecFunctionV0, ScSpecTypeDef as ScType, ScSpecTypeMap, ScSpecTypeOption, ScSpecTypeResult, @@ -1025,9 +1025,9 @@ pub fn to_json(v: &ScVal) -> Result { .. }) => json!({ "hash": hash }), ScVal::ContractInstance(ScContractInstance { - executable: ContractExecutable::Token, + executable: ContractExecutable::StellarAsset, .. - }) => json!({"token": true}), + }) => json!({"SAC": true}), ScVal::LedgerKeyNonce(ScNonceKey { nonce }) => { Value::Number(serde_json::Number::from(*nonce)) } @@ -1175,11 +1175,10 @@ impl Spec { .iter() .map(|f| { Some(match f { - stellar_xdr::ScSpecUdtUnionCaseV0::VoidV0(ScSpecUdtUnionCaseVoidV0 { - name, - .. - }) => name.to_string_lossy(), - stellar_xdr::ScSpecUdtUnionCaseV0::TupleV0(ScSpecUdtUnionCaseTupleV0 { + ScSpecUdtUnionCaseV0::VoidV0(ScSpecUdtUnionCaseVoidV0 { name, .. }) => { + name.to_string_lossy() + } + ScSpecUdtUnionCaseV0::TupleV0(ScSpecUdtUnionCaseTupleV0 { name, type_, .. @@ -1331,14 +1330,11 @@ impl Spec { .cases .iter() .map(|case| match case { - stellar_xdr::ScSpecUdtUnionCaseV0::VoidV0(ScSpecUdtUnionCaseVoidV0 { - name, - .. - }) => Some(format!("\"{}\"", name.to_string_lossy())), - stellar_xdr::ScSpecUdtUnionCaseV0::TupleV0(ScSpecUdtUnionCaseTupleV0 { - name, - type_, - .. + ScSpecUdtUnionCaseV0::VoidV0(ScSpecUdtUnionCaseVoidV0 { name, .. }) => { + Some(format!("\"{}\"", name.to_string_lossy())) + } + ScSpecUdtUnionCaseV0::TupleV0(ScSpecUdtUnionCaseTupleV0 { + name, type_, .. }) => { if type_.len() == 1 { let single = self.example(&type_[0])?; @@ -1362,7 +1358,7 @@ impl Spec { mod tests { use super::*; - use stellar_xdr::ScSpecTypeBytesN; + use stellar_xdr::curr::ScSpecTypeBytesN; #[test] fn from_json_primitives_bytesn() { diff --git a/cmd/crates/soroban-spec-tools/src/utils.rs b/cmd/crates/soroban-spec-tools/src/utils.rs index f53c24bc9..50cd5ee7a 100644 --- a/cmd/crates/soroban-spec-tools/src/utils.rs +++ b/cmd/crates/soroban-spec-tools/src/utils.rs @@ -5,7 +5,7 @@ use std::{ io::{self, Cursor}, }; -use stellar_xdr::{ +use stellar_xdr::curr::{ DepthLimitedRead, ReadXdr, ScEnvMetaEntry, ScMetaEntry, ScMetaV0, ScSpecEntry, ScSpecFunctionV0, ScSpecUdtEnumV0, ScSpecUdtErrorEnumV0, ScSpecUdtStructV0, ScSpecUdtUnionV0, StringM, @@ -33,7 +33,7 @@ pub enum Error { error: wasmparser::BinaryReaderError, }, #[error("xdr processing error: {0}")] - Xdr(#[from] stellar_xdr::Error), + Xdr(#[from] stellar_xdr::curr::Error), #[error(transparent)] Parser(#[from] wasmparser::BinaryReaderError), @@ -62,8 +62,7 @@ impl ContractSpec { env_meta_base64 = Some(base64.encode(env_meta)); let cursor = Cursor::new(env_meta); let mut depth_limit_read = DepthLimitedRead::new(cursor, 100); - ScEnvMetaEntry::read_xdr_iter(&mut depth_limit_read) - .collect::, stellar_xdr::Error>>()? + ScEnvMetaEntry::read_xdr_iter(&mut depth_limit_read).collect::, _>>()? } else { vec![] }; @@ -73,8 +72,7 @@ impl ContractSpec { meta_base64 = Some(base64.encode(meta)); let cursor = Cursor::new(meta); let mut depth_limit_read = DepthLimitedRead::new(cursor, 100); - ScMetaEntry::read_xdr_iter(&mut depth_limit_read) - .collect::, stellar_xdr::Error>>()? + ScMetaEntry::read_xdr_iter(&mut depth_limit_read).collect::, _>>()? } else { vec![] }; @@ -84,8 +82,7 @@ impl ContractSpec { spec_base64 = Some(base64.encode(spec)); let cursor = Cursor::new(spec); let mut depth_limit_read = DepthLimitedRead::new(cursor, 100); - ScSpecEntry::read_xdr_iter(&mut depth_limit_read) - .collect::, stellar_xdr::Error>>()? + ScSpecEntry::read_xdr_iter(&mut depth_limit_read).collect::, _>>()? } else { vec![] }; diff --git a/cmd/crates/soroban-spec-typescript/src/boilerplate.rs b/cmd/crates/soroban-spec-typescript/src/boilerplate.rs index ae14ae476..95b690591 100644 --- a/cmd/crates/soroban-spec-typescript/src/boilerplate.rs +++ b/cmd/crates/soroban-spec-typescript/src/boilerplate.rs @@ -6,7 +6,7 @@ use std::{ io::Write, path::{Path, PathBuf}, }; -use stellar_xdr::ScSpecEntry; +use stellar_xdr::curr::ScSpecEntry; use super::generate; diff --git a/cmd/crates/soroban-spec-typescript/src/lib.rs b/cmd/crates/soroban-spec-typescript/src/lib.rs index 5e8f8f210..7dff04756 100644 --- a/cmd/crates/soroban-spec-typescript/src/lib.rs +++ b/cmd/crates/soroban-spec-typescript/src/lib.rs @@ -10,7 +10,7 @@ use crate::types::Type; use heck::ToLowerCamelCase; use itertools::Itertools; use sha2::{Digest, Sha256}; -use stellar_xdr::{ScSpecEntry, WriteXdr}; +use stellar_xdr::curr::{ScSpecEntry, WriteXdr}; use types::Entry; @@ -27,7 +27,7 @@ pub enum GenerateFromFileError { #[error("sha256 does not match, expected: {expected}")] VerifySha256 { expected: String }, #[error("parsing contract spec: {0}")] - Parse(stellar_xdr::Error), + Parse(stellar_xdr::curr::Error), #[error("getting contract spec: {0}")] GetSpec(FromWasmError), } diff --git a/cmd/crates/soroban-spec-typescript/src/types.rs b/cmd/crates/soroban-spec-typescript/src/types.rs index b70bb6836..350d41296 100644 --- a/cmd/crates/soroban-spec-typescript/src/types.rs +++ b/cmd/crates/soroban-spec-typescript/src/types.rs @@ -1,5 +1,5 @@ use serde::Serialize; -use stellar_xdr::{ +use stellar_xdr::curr::{ ScSpecEntry, ScSpecFunctionInputV0, ScSpecTypeDef, ScSpecUdtEnumCaseV0, ScSpecUdtErrorEnumCaseV0, ScSpecUdtStructFieldV0, ScSpecUdtStructV0, ScSpecUdtUnionCaseV0, }; diff --git a/cmd/crates/soroban-test/tests/it/integration/custom_types.rs b/cmd/crates/soroban-test/tests/it/integration/custom_types.rs index fe4ef9786..4e36b452c 100644 --- a/cmd/crates/soroban-test/tests/it/integration/custom_types.rs +++ b/cmd/crates/soroban-test/tests/it/integration/custom_types.rs @@ -3,7 +3,7 @@ use serde_json::json; use soroban_cli::commands; use soroban_test::TestEnv; -use crate::integration::util::{bump_contract, deploy_custom, CUSTOM_TYPES}; +use crate::integration::util::{deploy_custom, extend_contract, CUSTOM_TYPES}; use super::util::invoke_with_roundtrip; @@ -17,7 +17,7 @@ fn invoke_custom(e: &TestEnv, id: &str, func: &str) -> assert_cmd::Command { async fn parse() { let sandbox = &TestEnv::default(); let id = &deploy_custom(sandbox); - bump_contract(sandbox, id, CUSTOM_TYPES).await; + extend_contract(sandbox, id, CUSTOM_TYPES).await; symbol(sandbox, id); string_with_quotes(sandbox, id).await; symbol_with_quotes(sandbox, id).await; diff --git a/cmd/crates/soroban-test/tests/it/integration/hello_world.rs b/cmd/crates/soroban-test/tests/it/integration/hello_world.rs index 1b77da220..fed4f4493 100644 --- a/cmd/crates/soroban-test/tests/it/integration/hello_world.rs +++ b/cmd/crates/soroban-test/tests/it/integration/hello_world.rs @@ -4,10 +4,10 @@ use soroban_cli::commands::{ }; use soroban_test::TestEnv; -use crate::{integration::util::bump_contract, util::DEFAULT_SEED_PHRASE}; +use crate::{integration::util::extend_contract, util::DEFAULT_SEED_PHRASE}; use super::util::{ - add_test_seed, bump, deploy_hello, network_passphrase, network_passphrase_arg, rpc_url, + add_test_seed, deploy_hello, extend, network_passphrase, network_passphrase_arg, rpc_url, rpc_url_arg, DEFAULT_PUB_KEY, DEFAULT_PUB_KEY_1, DEFAULT_SECRET_KEY, HELLO_WORLD, }; @@ -16,7 +16,7 @@ use super::util::{ async fn invoke() { let sandbox = &TestEnv::default(); let id = &deploy_hello(sandbox); - bump_contract(sandbox, id, HELLO_WORLD).await; + extend_contract(sandbox, id, HELLO_WORLD).await; // Note that all functions tested here have no state invoke_hello_world(sandbox, id); invoke_hello_world_with_lib(sandbox, id).await; @@ -193,7 +193,7 @@ async fn contract_data_read() { let id = &deploy_hello(sandbox); let res = sandbox.invoke(&["--id", id, "--", "inc"]).await.unwrap(); assert_eq!(res.trim(), "1"); - bump(sandbox, id, Some(KEY)).await; + extend(sandbox, id, Some(KEY)).await; sandbox .new_assert_cmd("contract") diff --git a/cmd/crates/soroban-test/tests/it/integration/util.rs b/cmd/crates/soroban-test/tests/it/integration/util.rs index 951f20340..878f8a055 100644 --- a/cmd/crates/soroban-test/tests/it/integration/util.rs +++ b/cmd/crates/soroban-test/tests/it/integration/util.rs @@ -86,32 +86,32 @@ pub fn deploy_contract(sandbox: &TestEnv, wasm: &Wasm) -> String { TEST_CONTRACT_ID.to_string() } -pub async fn bump_contract(sandbox: &TestEnv, id: &str, wasm: &Wasm<'_>) { - bump(sandbox, id, None).await; - let cmd: contract::bump::Cmd = sandbox.cmd_arr(&[ +pub async fn extend_contract(sandbox: &TestEnv, id: &str, wasm: &Wasm<'_>) { + extend(sandbox, id, None).await; + let cmd: contract::extend::Cmd = sandbox.cmd_arr(&[ "--wasm-hash", wasm.hash().unwrap().to_string().as_str(), "--durability", "persistent", - "--ledgers-to-expire", + "--ledgers-to-extend", "100000", ]); cmd.run().await.unwrap(); } -pub async fn bump(sandbox: &TestEnv, id: &str, value: Option<&str>) { +pub async fn extend(sandbox: &TestEnv, id: &str, value: Option<&str>) { let mut args = vec![ "--id", id, "--durability", "persistent", - "--ledgers-to-expire", + "--ledgers-to-extend", "100000", ]; if let Some(value) = value { args.push("--key"); args.push(value); } - let cmd: contract::bump::Cmd = sandbox.cmd_arr(&args); + let cmd: contract::extend::Cmd = sandbox.cmd_arr(&args); cmd.run().await.unwrap(); } diff --git a/cmd/soroban-cli/src/commands/contract/bump.rs b/cmd/soroban-cli/src/commands/contract/extend.rs similarity index 76% rename from cmd/soroban-cli/src/commands/contract/bump.rs rename to cmd/soroban-cli/src/commands/contract/extend.rs index 8d3b33370..d98fb311f 100644 --- a/cmd/soroban-cli/src/commands/contract/bump.rs +++ b/cmd/soroban-cli/src/commands/contract/extend.rs @@ -2,10 +2,10 @@ use std::{fmt::Debug, path::Path, str::FromStr}; use clap::{command, Parser}; use soroban_env_host::xdr::{ - BumpFootprintExpirationOp, Error as XdrError, ExpirationEntry, ExtensionPoint, LedgerEntry, - LedgerEntryChange, LedgerEntryData, LedgerFootprint, Memo, MuxedAccount, Operation, - OperationBody, Preconditions, SequenceNumber, SorobanResources, SorobanTransactionData, - Transaction, TransactionExt, TransactionMeta, TransactionMetaV3, Uint256, + Error as XdrError, ExtendFootprintTtlOp, ExtensionPoint, LedgerEntry, LedgerEntryChange, + LedgerEntryData, LedgerFootprint, Memo, MuxedAccount, Operation, OperationBody, Preconditions, + SequenceNumber, SorobanResources, SorobanTransactionData, Transaction, TransactionExt, + TransactionMeta, TransactionMetaV3, TtlEntry, Uint256, }; use crate::{ @@ -15,22 +15,19 @@ use crate::{ wasm, Pwd, }; -const MAX_LEDGERS_TO_EXPIRE: u32 = 535_679; +const MAX_LEDGERS_TO_EXTEND: u32 = 535_679; #[derive(Parser, Debug, Clone)] #[group(skip)] pub struct Cmd { /// Number of ledgers to extend the entries #[arg(long, required = true)] - pub ledgers_to_expire: u32, - - /// Only print the new expiration ledger + pub ledgers_to_extend: u32, + /// Only print the new TTL ledger #[arg(long)] - pub expiration_ledger_only: bool, - + pub extension_ledger_only: bool, #[command(flatten)] pub key: key::Args, - #[command(flatten)] pub config: config::Args, #[command(flatten)] @@ -84,20 +81,20 @@ impl Cmd { #[allow(clippy::too_many_lines)] pub async fn run(&self) -> Result<(), Error> { let expiration_ledger_seq = self.run_against_rpc_server().await?; - if self.expiration_ledger_only { + if self.extension_ledger_only { println!("{expiration_ledger_seq}"); } else { - println!("New expiration ledger: {expiration_ledger_seq}"); + println!("New ttl ledger: {expiration_ledger_seq}"); } Ok(()) } - fn ledgers_to_expire(&self) -> u32 { - let res = u32::min(self.ledgers_to_expire, MAX_LEDGERS_TO_EXPIRE); - if res < self.ledgers_to_expire { + fn ledgers_to_extend(&self) -> u32 { + let res = u32::min(self.ledgers_to_extend, MAX_LEDGERS_TO_EXTEND); + if res < self.ledgers_to_extend { tracing::warn!( - "Ledgers to expire is too large, using max value of {MAX_LEDGERS_TO_EXPIRE}" + "Ledgers to extend is too large, using max value of {MAX_LEDGERS_TO_EXTEND}" ); } res @@ -110,7 +107,7 @@ impl Cmd { let network = &self.config.get_network()?; let client = Client::new(&network.rpc_url)?; let key = self.config.key_pair()?; - let ledgers_to_expire = self.ledgers_to_expire(); + let extend_to = self.ledgers_to_extend(); // Get the account sequence number let public_strkey = @@ -126,9 +123,9 @@ impl Cmd { memo: Memo::None, operations: vec![Operation { source_account: None, - body: OperationBody::BumpFootprintExpiration(BumpFootprintExpirationOp { + body: OperationBody::ExtendFootprintTtl(ExtendFootprintTtlOp { ext: ExtensionPoint::V0, - ledgers_to_expire, + extend_to, }), }] .try_into()?, @@ -143,7 +140,7 @@ impl Cmd { read_bytes: 0, write_bytes: 0, }, - refundable_fee: 0, + resource_fee: 0, }), }; @@ -157,13 +154,13 @@ impl Cmd { tracing::info!("Events:\n {events:#?}"); } - // The transaction from core will succeed regardless of whether it actually found & bumped + // The transaction from core will succeed regardless of whether it actually found & extended // the entry, so we have to inspect the result meta to tell if it worked or not. let TransactionMeta::V3(TransactionMetaV3 { operations, .. }) = meta else { return Err(Error::LedgerEntryNotFound); }; - // Simply check if there is exactly one entry here. We only support bumping a single + // Simply check if there is exactly one entry here. We only support extending a single // entry via this command (which we should fix separately, but). if operations.len() == 0 { return Err(Error::LedgerEntryNotFound); @@ -171,9 +168,9 @@ impl Cmd { if operations[0].changes.is_empty() { let entry = client.get_full_ledger_entries(&keys).await?; - let expire = entry.entries[0].expiration_ledger_seq; - if entry.latest_ledger + i64::from(ledgers_to_expire) < i64::from(expire) { - return Ok(expire); + let extension = entry.entries[0].live_until_ledger_seq; + if entry.latest_ledger + i64::from(extend_to) < i64::from(extension) { + return Ok(extension); } } @@ -182,13 +179,13 @@ impl Cmd { LedgerEntryChange::State(_), LedgerEntryChange::Updated(LedgerEntry { data: - LedgerEntryData::Expiration(ExpirationEntry { - expiration_ledger_seq, + LedgerEntryData::Ttl(TtlEntry { + live_until_ledger_seq, .. }), .. }), - ) => Ok(*expiration_ledger_seq), + ) => Ok(*live_until_ledger_seq), _ => Err(Error::LedgerEntryNotFound), } } diff --git a/cmd/soroban-cli/src/commands/contract/fetch.rs b/cmd/soroban-cli/src/commands/contract/fetch.rs index 9097ffdea..9929f3832 100644 --- a/cmd/soroban-cli/src/commands/contract/fetch.rs +++ b/cmd/soroban-cli/src/commands/contract/fetch.rs @@ -176,7 +176,7 @@ pub fn get_contract_wasm_from_storage( Err(FromWasmError::NotFound) } } - ContractExecutable::Token => todo!(), + ContractExecutable::StellarAsset => todo!(), }, _ => Err(FromWasmError::NotFound), }, diff --git a/cmd/soroban-cli/src/commands/contract/install.rs b/cmd/soroban-cli/src/commands/contract/install.rs index 05e867bc9..87c2877a7 100644 --- a/cmd/soroban-cli/src/commands/contract/install.rs +++ b/cmd/soroban-cli/src/commands/contract/install.rs @@ -106,7 +106,7 @@ impl Cmd { }, config: self.config.clone(), fee: self.fee.clone(), - ledgers_to_expire: None, + ledgers_to_extend: None, } .run_against_rpc_server() .await?; diff --git a/cmd/soroban-cli/src/commands/contract/mod.rs b/cmd/soroban-cli/src/commands/contract/mod.rs index d9566b6ce..b07011a28 100644 --- a/cmd/soroban-cli/src/commands/contract/mod.rs +++ b/cmd/soroban-cli/src/commands/contract/mod.rs @@ -1,7 +1,7 @@ pub mod bindings; pub mod build; -pub mod bump; pub mod deploy; +pub mod extend; pub mod fetch; pub mod inspect; pub mod install; @@ -22,8 +22,8 @@ pub enum Cmd { /// Extend the expiry ledger of a contract-data ledger entry. /// - /// If no keys are specified the contract itself is bumped. - Bump(bump::Cmd), + /// If no keys are specified the contract itself is extended. + Extend(extend::Cmd), /// Deploy a contract Deploy(deploy::Cmd), @@ -68,7 +68,7 @@ pub enum Error { Build(#[from] build::Error), #[error(transparent)] - Bump(#[from] bump::Error), + Extend(#[from] extend::Error), #[error(transparent)] Deploy(#[from] deploy::Error), @@ -100,7 +100,7 @@ impl Cmd { match &self { Cmd::Bindings(bindings) => bindings.run().await?, Cmd::Build(build) => build.run()?, - Cmd::Bump(bump) => bump.run().await?, + Cmd::Extend(extend) => extend.run().await?, Cmd::Deploy(deploy) => deploy.run().await?, Cmd::Inspect(inspect) => inspect.run()?, Cmd::Install(install) => install.run().await?, diff --git a/cmd/soroban-cli/src/commands/contract/read.rs b/cmd/soroban-cli/src/commands/contract/read.rs index bf161f3ff..8fa943273 100644 --- a/cmd/soroban-cli/src/commands/contract/read.rs +++ b/cmd/soroban-cli/src/commands/contract/read.rs @@ -112,7 +112,7 @@ impl Cmd { for FullLedgerEntry { key, val, - expiration_ledger_seq, + live_until_ledger_seq, last_modified_ledger, } in &entries.entries { @@ -134,7 +134,7 @@ impl Cmd { error: e, })?, last_modified_ledger.to_string(), - expiration_ledger_seq.to_string(), + live_until_ledger_seq.to_string(), ], Output::Json => [ serde_json::to_string_pretty(&key).map_err(|error| { @@ -155,7 +155,7 @@ impl Cmd { error, } })?, - serde_json::to_string_pretty(&expiration_ledger_seq).map_err(|error| { + serde_json::to_string_pretty(&live_until_ledger_seq).map_err(|error| { Error::CannotPrintJsonResult { result: val.clone(), error, @@ -166,7 +166,7 @@ impl Cmd { key.to_xdr_base64()?, val.to_xdr_base64()?, last_modified_ledger.to_xdr_base64()?, - expiration_ledger_seq.to_xdr_base64()?, + live_until_ledger_seq.to_xdr_base64()?, ], }; out.write_record(output) diff --git a/cmd/soroban-cli/src/commands/contract/restore.rs b/cmd/soroban-cli/src/commands/contract/restore.rs index e709ebf7a..f10cdb780 100644 --- a/cmd/soroban-cli/src/commands/contract/restore.rs +++ b/cmd/soroban-cli/src/commands/contract/restore.rs @@ -2,17 +2,17 @@ use std::{fmt::Debug, path::Path, str::FromStr}; use clap::{command, Parser}; use soroban_env_host::xdr::{ - Error as XdrError, ExpirationEntry, ExtensionPoint, LedgerEntry, LedgerEntryChange, - LedgerEntryData, LedgerFootprint, Memo, MuxedAccount, Operation, OperationBody, OperationMeta, - Preconditions, RestoreFootprintOp, SequenceNumber, SorobanResources, SorobanTransactionData, - Transaction, TransactionExt, TransactionMeta, TransactionMetaV3, Uint256, + Error as XdrError, ExtensionPoint, LedgerEntry, LedgerEntryChange, LedgerEntryData, + LedgerFootprint, Memo, MuxedAccount, Operation, OperationBody, OperationMeta, Preconditions, + RestoreFootprintOp, SequenceNumber, SorobanResources, SorobanTransactionData, Transaction, + TransactionExt, TransactionMeta, TransactionMetaV3, TtlEntry, Uint256, }; use stellar_strkey::DecodeError; use crate::{ commands::{ config::{self, locator}, - contract::bump, + contract::extend, }, key, rpc::{self, Client}, @@ -26,7 +26,7 @@ pub struct Cmd { pub key: key::Args, /// Number of ledgers to extend the entry #[arg(long)] - pub ledgers_to_expire: Option, + pub ledgers_to_extend: Option, #[command(flatten)] pub config: config::Args, #[command(flatten)] @@ -78,7 +78,7 @@ pub enum Error { #[error(transparent)] Key(#[from] key::Error), #[error(transparent)] - Bump(#[from] bump::Error), + Extend(#[from] extend::Error), } impl Cmd { @@ -86,18 +86,18 @@ impl Cmd { pub async fn run(&self) -> Result<(), Error> { let expiration_ledger_seq = self.run_against_rpc_server().await?; - if let Some(ledgers_to_expire) = self.ledgers_to_expire { - bump::Cmd { + if let Some(ledgers_to_extend) = self.ledgers_to_extend { + extend::Cmd { key: self.key.clone(), - ledgers_to_expire, + ledgers_to_extend, config: self.config.clone(), fee: self.fee.clone(), - expiration_ledger_only: false, + extension_ledger_only: false, } .run() .await?; } else { - println!("New expiration ledger: {expiration_ledger_seq}"); + println!("New ttl ledger: {expiration_ledger_seq}"); } Ok(()) @@ -141,7 +141,7 @@ impl Cmd { read_bytes: 0, write_bytes: 0, }, - refundable_fee: 0, + resource_fee: 0, }), }; @@ -162,7 +162,7 @@ impl Cmd { }; tracing::debug!("Operations:\nlen:{}\n{operations:#?}", operations.len()); - // Simply check if there is exactly one entry here. We only support bumping a single + // Simply check if there is exactly one entry here. We only support extending a single // entry via this command (which we should fix separately, but). if operations.len() == 0 { return Err(Error::LedgerEntryNotFound); @@ -183,20 +183,20 @@ fn parse_operations(ops: &[OperationMeta]) -> Option { op.changes.iter().find_map(|entry| match entry { LedgerEntryChange::Updated(LedgerEntry { data: - LedgerEntryData::Expiration(ExpirationEntry { - expiration_ledger_seq, + LedgerEntryData::Ttl(TtlEntry { + live_until_ledger_seq, .. }), .. }) | LedgerEntryChange::Created(LedgerEntry { data: - LedgerEntryData::Expiration(ExpirationEntry { - expiration_ledger_seq, + LedgerEntryData::Ttl(TtlEntry { + live_until_ledger_seq, .. }), .. - }) => Some(*expiration_ledger_seq), + }) => Some(*live_until_ledger_seq), _ => None, }) }) diff --git a/cmd/soroban-cli/src/commands/lab/token/wrap.rs b/cmd/soroban-cli/src/commands/lab/token/wrap.rs index b2f878ca2..2b6f4dd4f 100644 --- a/cmd/soroban-cli/src/commands/lab/token/wrap.rs +++ b/cmd/soroban-cli/src/commands/lab/token/wrap.rs @@ -152,7 +152,7 @@ fn build_wrap_token_tx( body: OperationBody::InvokeHostFunction(InvokeHostFunctionOp { host_function: HostFunction::CreateContract(CreateContractArgs { contract_id_preimage: ContractIdPreimage::Asset(asset.clone()), - executable: ContractExecutable::Token, + executable: ContractExecutable::StellarAsset, }), auth: VecM::default(), }), diff --git a/cmd/soroban-cli/src/key.rs b/cmd/soroban-cli/src/key.rs index d48c61683..ae3086f54 100644 --- a/cmd/soroban-cli/src/key.rs +++ b/cmd/soroban-cli/src/key.rs @@ -26,7 +26,7 @@ pub enum Error { #[group(skip)] pub struct Args { /// Contract ID to which owns the data entries. - /// If no keys provided the Contract's instance will be bumped + /// If no keys provided the Contract's instance will be extended #[arg( long = "id", required_unless_present = "wasm", @@ -39,7 +39,7 @@ pub struct Args { /// Storage key (base64-encoded XDR) #[arg(long = "key-xdr", conflicts_with = "key")] pub key_xdr: Option>, - /// Path to Wasm file of contract code to bump + /// Path to Wasm file of contract code to extend #[arg( long, conflicts_with = "contract_id", @@ -48,7 +48,7 @@ pub struct Args { conflicts_with = "wasm_hash" )] pub wasm: Option, - /// Path to Wasm file of contract code to bump + /// Path to Wasm file of contract code to extend #[arg( long, conflicts_with = "contract_id", diff --git a/cmd/soroban-cli/src/rpc/mod.rs b/cmd/soroban-cli/src/rpc/mod.rs index 5123f0f17..46da57a91 100644 --- a/cmd/soroban-cli/src/rpc/mod.rs +++ b/cmd/soroban-cli/src/rpc/mod.rs @@ -98,8 +98,6 @@ pub enum Error { SpecBase64(#[from] soroban_spec::read::ParseSpecBase64Error), #[error("Fee was too large {0}")] LargeFee(u64), - #[error("Failed to parse LedgerEntryData\nkey:{0:?}\nvalue:{1:?}\nexpiration:{2:?}")] - FailedParseLedgerEntryData(LedgerKey, LedgerEntryData, LedgerEntryData), } #[derive(serde::Deserialize, serde::Serialize, Debug)] @@ -154,12 +152,12 @@ pub struct LedgerEntryResult { )] pub last_modified_ledger: u32, #[serde( - rename = "expirationLedgerSeq", + rename = "liveUntilLedgerSeqLedgerSeq", skip_serializing_if = "Option::is_none", deserialize_with = "deserialize_option_number_from_string", default )] - pub expiration_ledger_seq: Option, + pub live_until_ledger_seq_ledger_seq: Option, } #[derive(serde::Deserialize, serde::Serialize, Debug)] @@ -435,7 +433,7 @@ pub struct FullLedgerEntry { pub key: LedgerKey, pub val: LedgerEntryData, pub last_modified_ledger: u32, - pub expiration_ledger_seq: u32, + pub live_until_ledger_seq: u32, } #[derive(Debug)] @@ -777,7 +775,7 @@ soroban config identity fund {address} --helper-url "# ) -> Result { let keys = ledger_keys .iter() - .filter(|key| !matches!(key, LedgerKey::Expiration(_))) + .filter(|key| !matches!(key, LedgerKey::Ttl(_))) .map(Clone::clone) .collect::>(); tracing::trace!("keys: {keys:#?}"); @@ -794,12 +792,12 @@ soroban config identity fund {address} --helper-url "# key, xdr, last_modified_ledger, - expiration_ledger_seq, + live_until_ledger_seq_ledger_seq, }| { Ok(FullLedgerEntry { key: LedgerKey::from_xdr_base64(key)?, val: LedgerEntryData::from_xdr_base64(xdr)?, - expiration_ledger_seq: expiration_ledger_seq.unwrap_or_default(), + live_until_ledger_seq: live_until_ledger_seq_ledger_seq.unwrap_or_default(), last_modified_ledger: *last_modified_ledger, }) }, @@ -920,7 +918,7 @@ soroban config identity fund {address} --helper-url "# .map_err(Error::CouldNotParseContractSpec)? .spec), xdr::ScVal::ContractInstance(xdr::ScContractInstance { - executable: xdr::ContractExecutable::Token, + executable: xdr::ContractExecutable::StellarAsset, .. }) => Ok(soroban_spec::read::parse_raw( &token::StellarAssetSpec::spec_xdr(), diff --git a/cmd/soroban-cli/src/rpc/transaction.rs b/cmd/soroban-cli/src/rpc/transaction.rs index f2ed5eeee..bdd3dfc68 100644 --- a/cmd/soroban-cli/src/rpc/transaction.rs +++ b/cmd/soroban-cli/src/rpc/transaction.rs @@ -274,7 +274,7 @@ mod tests { read_bytes: 5, write_bytes: 0, }, - refundable_fee: 0, + resource_fee: 0, ext: ExtensionPoint::V0, } } diff --git a/cmd/soroban-rpc/internal/db/ledger_test.go b/cmd/soroban-rpc/internal/db/ledger_test.go index 362f33653..bbbfdbee8 100644 --- a/cmd/soroban-rpc/internal/db/ledger_test.go +++ b/cmd/soroban-rpc/internal/db/ledger_test.go @@ -11,8 +11,8 @@ import ( func createLedger(ledgerSequence uint32) xdr.LedgerCloseMeta { return xdr.LedgerCloseMeta{ - V: 2, - V2: &xdr.LedgerCloseMetaV2{ + V: 1, + V1: &xdr.LedgerCloseMetaV1{ LedgerHeader: xdr.LedgerHeaderHistoryEntry{ Hash: xdr.Hash{}, Header: xdr.LedgerHeader{ diff --git a/cmd/soroban-rpc/internal/db/ledgerentry.go b/cmd/soroban-rpc/internal/db/ledgerentry.go index 87fbd75dd..2e22cbc7a 100644 --- a/cmd/soroban-rpc/internal/db/ledgerentry.go +++ b/cmd/soroban-rpc/internal/db/ledgerentry.go @@ -24,9 +24,9 @@ type LedgerEntryReader interface { } type LedgerKeyAndEntry struct { - Key xdr.LedgerKey - Entry xdr.LedgerEntry - ExpirationLedgerSeq *uint32 // optional expiration ledger seq, when applicable. + Key xdr.LedgerKey + Entry xdr.LedgerEntry + LiveUntilLedgerSeq *uint32 // optional live-until ledger seq, when applicable. } type LedgerEntryReadTx interface { @@ -228,14 +228,14 @@ func GetLedgerEntry(tx LedgerEntryReadTx, key xdr.LedgerKey) (bool, xdr.LedgerEn return false, xdr.LedgerEntry{}, nil, nil case 1: // expected length - return true, keyEntries[0].Entry, keyEntries[0].ExpirationLedgerSeq, nil + return true, keyEntries[0].Entry, keyEntries[0].LiveUntilLedgerSeq, nil default: return false, xdr.LedgerEntry{}, nil, fmt.Errorf("multiple entries (%d) for key %v", len(keyEntries), key) } } -// isExpirableKey check to see if the key type is expected to be accompanied by a LedgerExpirationEntry -func isExpirableKey(key xdr.LedgerKey) bool { +// hasTTLKey check to see if the key type is expected to be accompanied by a LedgerTTLEntry +func hasTTLKey(key xdr.LedgerKey) bool { switch key.Type { case xdr.LedgerEntryTypeContractData: return true @@ -246,23 +246,23 @@ func isExpirableKey(key xdr.LedgerKey) bool { return false } -func entryKeyToExpirationEntryKey(key xdr.LedgerKey) (xdr.LedgerKey, error) { +func entryKeyToTTLEntryKey(key xdr.LedgerKey) (xdr.LedgerKey, error) { buf, err := key.MarshalBinary() if err != nil { return xdr.LedgerKey{}, err } - var expirationEntry xdr.LedgerKey - err = expirationEntry.SetExpiration(xdr.Hash(sha256.Sum256(buf))) + var ttlEntry xdr.LedgerKey + err = ttlEntry.SetTtl(sha256.Sum256(buf)) if err != nil { return xdr.LedgerKey{}, err } - return expirationEntry, nil + return ttlEntry, nil } func (l *ledgerEntryReadTx) GetLedgerEntries(keys ...xdr.LedgerKey) ([]LedgerKeyAndEntry, error) { encodedKeys := make([]string, len(keys), 2*len(keys)) encodedKeyToKey := make(map[string]xdr.LedgerKey, len(keys)) - encodedKeyToEncodedExpirationLedgerKey := make(map[string]string, len(keys)) + encodedKeyToEncodedTTLLedgerKey := make(map[string]string, len(keys)) for _, k := range keys { encodedKey, err := encodeLedgerKey(l.buffer, k) if err != nil { @@ -270,19 +270,19 @@ func (l *ledgerEntryReadTx) GetLedgerEntries(keys ...xdr.LedgerKey) ([]LedgerKey } encodedKeys = append(encodedKeys, encodedKey) encodedKeyToKey[encodedKey] = k - if !isExpirableKey(k) { + if !hasTTLKey(k) { continue } - expirationEntryKey, err := entryKeyToExpirationEntryKey(k) + ttlEntryKey, err := entryKeyToTTLEntryKey(k) if err != nil { return nil, err } - encodedExpirationKey, err := encodeLedgerKey(l.buffer, expirationEntryKey) + encodedTTLKey, err := encodeLedgerKey(l.buffer, ttlEntryKey) if err != nil { return nil, err } - encodedKeyToEncodedExpirationLedgerKey[encodedKey] = encodedExpirationKey - encodedKeys = append(encodedKeys, encodedExpirationKey) + encodedKeyToEncodedTTLLedgerKey[encodedKey] = encodedTTLKey + encodedKeys = append(encodedKeys, encodedTTLKey) } rawResult, err := l.getRawLedgerEntries(encodedKeys...) @@ -300,22 +300,22 @@ func (l *ledgerEntryReadTx) GetLedgerEntries(keys ...xdr.LedgerKey) ([]LedgerKey if err := xdr.SafeUnmarshal([]byte(encodedEntry), &entry); err != nil { return nil, errors.Wrap(err, "cannot decode ledger entry from DB") } - encodedExpKey, has := encodedKeyToEncodedExpirationLedgerKey[encodedKey] + encodedExpKey, has := encodedKeyToEncodedTTLLedgerKey[encodedKey] if !has { result = append(result, LedgerKeyAndEntry{key, entry, nil}) continue } encodedExpEntry, ok := rawResult[encodedExpKey] if !ok { - // missing expiration key. this should no happen. - return nil, errors.New("missing expiration key entry") + // missing ttl key. This should not happen. + return nil, errors.New("missing ttl key entry") } var expEntry xdr.LedgerEntry if err := xdr.SafeUnmarshal([]byte(encodedExpEntry), &expEntry); err != nil { - return nil, errors.Wrap(err, "cannot decode expiration ledger entry from DB") + return nil, errors.Wrap(err, "cannot decode TTL ledger entry from DB") } - expSeq := uint32(expEntry.Data.Expiration.ExpirationLedgerSeq) - result = append(result, LedgerKeyAndEntry{key, entry, &expSeq}) + liveUntilSeq := uint32(expEntry.Data.Ttl.LiveUntilLedgerSeq) + result = append(result, LedgerKeyAndEntry{key, entry, &liveUntilSeq}) } return result, nil diff --git a/cmd/soroban-rpc/internal/db/ledgerentry_test.go b/cmd/soroban-rpc/internal/db/ledgerentry_test.go index 5da7791ef..2e6b0012c 100644 --- a/cmd/soroban-rpc/internal/db/ledgerentry_test.go +++ b/cmd/soroban-rpc/internal/db/ledgerentry_test.go @@ -75,19 +75,19 @@ func TestGoldenPath(t *testing.T) { key, entry := getContractDataLedgerEntry(t, data) assert.NoError(t, writer.UpsertLedgerEntry(entry)) - expLedgerKey, err := entryKeyToExpirationEntryKey(key) + expLedgerKey, err := entryKeyToTTLEntryKey(key) assert.NoError(t, err) - expLegerEntry := getExpirationLedgerEntry(expLedgerKey) + expLegerEntry := getTTLLedgerEntry(expLedgerKey) assert.NoError(t, writer.UpsertLedgerEntry(expLegerEntry)) ledgerSequence := uint32(23) assert.NoError(t, tx.Commit(ledgerSequence)) - present, obtainedEntry, obtainedLedgerSequence, expSeq := getLedgerEntryAndLatestLedgerSequence(t, db, key) + present, obtainedEntry, obtainedLedgerSequence, liveUntilSeq := getLedgerEntryAndLatestLedgerSequence(t, db, key) assert.True(t, present) assert.Equal(t, ledgerSequence, obtainedLedgerSequence) - require.NotNil(t, expSeq) - assert.Equal(t, uint32(expLegerEntry.Data.Expiration.ExpirationLedgerSeq), *expSeq) + require.NotNil(t, liveUntilSeq) + assert.Equal(t, uint32(expLegerEntry.Data.Ttl.LiveUntilLedgerSeq), *liveUntilSeq) assert.Equal(t, obtainedEntry.Data.Type, xdr.LedgerEntryTypeContractData) assert.Equal(t, xdr.Hash{0xca, 0xfe}, *obtainedEntry.Data.ContractData.Contract.ContractId) assert.Equal(t, six, *obtainedEntry.Data.ContractData.Val.U32) @@ -108,9 +108,9 @@ func TestGoldenPath(t *testing.T) { ledgerSequence = uint32(24) assert.NoError(t, tx.Commit(ledgerSequence)) - present, obtainedEntry, obtainedLedgerSequence, expSeq = getLedgerEntryAndLatestLedgerSequence(t, db, key) + present, obtainedEntry, obtainedLedgerSequence, liveUntilSeq = getLedgerEntryAndLatestLedgerSequence(t, db, key) assert.True(t, present) - require.NotNil(t, expSeq) + require.NotNil(t, liveUntilSeq) assert.Equal(t, ledgerSequence, obtainedLedgerSequence) assert.Equal(t, eight, *obtainedEntry.Data.ContractData.Val.U32) @@ -124,9 +124,9 @@ func TestGoldenPath(t *testing.T) { ledgerSequence = uint32(25) assert.NoError(t, tx.Commit(ledgerSequence)) - present, _, obtainedLedgerSequence, expSeq = getLedgerEntryAndLatestLedgerSequence(t, db, key) + present, _, obtainedLedgerSequence, liveUntilSeq = getLedgerEntryAndLatestLedgerSequence(t, db, key) assert.False(t, present) - assert.Nil(t, expSeq) + assert.Nil(t, liveUntilSeq) assert.Equal(t, ledgerSequence, obtainedLedgerSequence) obtainedLedgerSequence, err = NewLedgerEntryReader(db).GetLatestLedgerSequence(context.Background()) @@ -192,11 +192,11 @@ func getContractDataLedgerEntry(t require.TestingT, data xdr.ContractDataEntry) return key, entry } -func getExpirationLedgerEntry(key xdr.LedgerKey) xdr.LedgerEntry { +func getTTLLedgerEntry(key xdr.LedgerKey) xdr.LedgerEntry { var expLegerEntry xdr.LedgerEntry - expLegerEntry.Data.Expiration = &xdr.ExpirationEntry{ - KeyHash: key.Expiration.KeyHash, - ExpirationLedgerSeq: 100, + expLegerEntry.Data.Ttl = &xdr.TtlEntry{ + KeyHash: key.Ttl.KeyHash, + LiveUntilLedgerSeq: 100, } expLegerEntry.Data.Type = key.Type return expLegerEntry @@ -235,9 +235,9 @@ func TestReadTxsDuringWriteTx(t *testing.T) { key, entry := getContractDataLedgerEntry(t, data) assert.NoError(t, writer.UpsertLedgerEntry(entry)) - expLedgerKey, err := entryKeyToExpirationEntryKey(key) + expLedgerKey, err := entryKeyToTTLEntryKey(key) assert.NoError(t, err) - expLegerEntry := getExpirationLedgerEntry(expLedgerKey) + expLegerEntry := getTTLLedgerEntry(expLedgerKey) assert.NoError(t, writer.UpsertLedgerEntry(expLegerEntry)) // Before committing the changes, make sure multiple concurrent transactions can query the DB @@ -321,9 +321,9 @@ func TestWriteTxsDuringReadTxs(t *testing.T) { key, entry := getContractDataLedgerEntry(t, data) assert.NoError(t, writer.UpsertLedgerEntry(entry)) - expLedgerKey, err := entryKeyToExpirationEntryKey(key) + expLedgerKey, err := entryKeyToTTLEntryKey(key) assert.NoError(t, err) - expLegerEntry := getExpirationLedgerEntry(expLedgerKey) + expLegerEntry := getTTLLedgerEntry(expLedgerKey) assert.NoError(t, writer.UpsertLedgerEntry(expLegerEntry)) // Third read transaction, after the first insert has happened in the write transaction @@ -404,9 +404,9 @@ func TestConcurrentReadersAndWriter(t *testing.T) { for i := 0; i < 200; i++ { key, entry := getContractDataLedgerEntry(t, data(i)) assert.NoError(t, writer.UpsertLedgerEntry(entry)) - expLedgerKey, err := entryKeyToExpirationEntryKey(key) + expLedgerKey, err := entryKeyToTTLEntryKey(key) assert.NoError(t, err) - expLegerEntry := getExpirationLedgerEntry(expLedgerKey) + expLegerEntry := getTTLLedgerEntry(expLedgerKey) assert.NoError(t, writer.UpsertLedgerEntry(expLegerEntry)) } assert.NoError(t, tx.Commit(ledgerSequence)) @@ -480,7 +480,7 @@ forloop: } -func benchmarkLedgerEntry(b *testing.B, cached bool, includeExpired bool) { +func benchmarkLedgerEntry(b *testing.B, cached bool) { db := NewTestDB(b) keyUint32 := xdr.Uint32(0) data := xdr.ContractDataEntry{ @@ -528,9 +528,8 @@ func benchmarkLedgerEntry(b *testing.B, cached bool, includeExpired bool) { } func BenchmarkGetLedgerEntry(b *testing.B) { - b.Run("With cache, include expired", func(b *testing.B) { benchmarkLedgerEntry(b, true, true) }) - b.Run("With cache, exclude expired", func(b *testing.B) { benchmarkLedgerEntry(b, true, false) }) - b.Run("Without cache, exclude expired", func(b *testing.B) { benchmarkLedgerEntry(b, false, false) }) + b.Run("With cache", func(b *testing.B) { benchmarkLedgerEntry(b, true) }) + b.Run("Without cache", func(b *testing.B) { benchmarkLedgerEntry(b, false) }) } func BenchmarkLedgerUpdate(b *testing.B) { diff --git a/cmd/soroban-rpc/internal/ingest/service.go b/cmd/soroban-rpc/internal/ingest/service.go index fab1cd2d7..744e515f9 100644 --- a/cmd/soroban-rpc/internal/ingest/service.go +++ b/cmd/soroban-rpc/internal/ingest/service.go @@ -258,7 +258,7 @@ func (s *Service) ingest(ctx context.Context, sequence uint32) error { } // EvictedTemporaryLedgerKeys will include both temporary ledger keys which - // have been evicted and their corresponding expiration ledger entries + // have been evicted and their corresponding ttl ledger entries evictedTempLedgerKeys, err := ledgerCloseMeta.EvictedTemporaryLedgerKeys() if err != nil { return err diff --git a/cmd/soroban-rpc/internal/ingest/service_test.go b/cmd/soroban-rpc/internal/ingest/service_test.go index 9c76a81fd..4993d326f 100644 --- a/cmd/soroban-rpc/internal/ingest/service_test.go +++ b/cmd/soroban-rpc/internal/ingest/service_test.go @@ -176,8 +176,8 @@ func TestIngestion(t *testing.T) { }, } ledger := xdr.LedgerCloseMeta{ - V: 2, - V2: &xdr.LedgerCloseMetaV2{ + V: 1, + V1: &xdr.LedgerCloseMetaV1{ LedgerHeader: xdr.LedgerHeaderHistoryEntry{Header: xdr.LedgerHeader{LedgerVersion: 10}}, TxSet: xdr.GeneralizedTransactionSet{ V: 1, diff --git a/cmd/soroban-rpc/internal/methods/get_events_test.go b/cmd/soroban-rpc/internal/methods/get_events_test.go index 8c7e8ce7c..dcaa5b306 100644 --- a/cmd/soroban-rpc/internal/methods/get_events_test.go +++ b/cmd/soroban-rpc/internal/methods/get_events_test.go @@ -1117,8 +1117,8 @@ func ledgerCloseMetaWithEvents(sequence uint32, closeTimestamp int64, txMeta ... } return xdr.LedgerCloseMeta{ - V: 2, - V2: &xdr.LedgerCloseMetaV2{ + V: 1, + V1: &xdr.LedgerCloseMetaV1{ LedgerHeader: xdr.LedgerHeaderHistoryEntry{ Hash: xdr.Hash{}, Header: xdr.LedgerHeader{ diff --git a/cmd/soroban-rpc/internal/methods/get_latest_ledger_test.go b/cmd/soroban-rpc/internal/methods/get_latest_ledger_test.go index 124ec6a33..474b3b8da 100644 --- a/cmd/soroban-rpc/internal/methods/get_latest_ledger_test.go +++ b/cmd/soroban-rpc/internal/methods/get_latest_ledger_test.go @@ -60,8 +60,8 @@ func (ledgerReader *ConstantLedgerReader) StreamAllLedgers(ctx context.Context, func createLedger(ledgerSequence uint32, protocolVersion uint32, hash byte) xdr.LedgerCloseMeta { return xdr.LedgerCloseMeta{ - V: 2, - V2: &xdr.LedgerCloseMetaV2{ + V: 1, + V1: &xdr.LedgerCloseMetaV1{ LedgerHeader: xdr.LedgerHeaderHistoryEntry{ Hash: xdr.Hash{hash}, Header: xdr.LedgerHeader{ diff --git a/cmd/soroban-rpc/internal/methods/get_ledger_entries.go b/cmd/soroban-rpc/internal/methods/get_ledger_entries.go index 00c3ad22a..d37347ef5 100644 --- a/cmd/soroban-rpc/internal/methods/get_ledger_entries.go +++ b/cmd/soroban-rpc/internal/methods/get_ledger_entries.go @@ -7,14 +7,13 @@ import ( "github.com/creachadair/jrpc2" "github.com/creachadair/jrpc2/handler" "github.com/stellar/go/gxdr" - "github.com/stellar/go/support/log" "github.com/stellar/go/xdr" "github.com/stellar/soroban-tools/cmd/soroban-rpc/internal/db" ) -var ErrLedgerExpirationEntriesCannotBeQueriedDirectly = "ledger expiration entries cannot be queried directly" +var ErrLedgerTtlEntriesCannotBeQueriedDirectly = "ledger ttl entries cannot be queried directly" type GetLedgerEntriesRequest struct { Keys []string `json:"keys"` @@ -27,8 +26,8 @@ type LedgerEntryResult struct { XDR string `json:"xdr"` // Last modified ledger for this entry. LastModifiedLedger int64 `json:"lastModifiedLedgerSeq,string"` - // The expiration ledger, available for entries that have expiration ledgers. - ExpirationLedger *uint32 `json:"expirationLedgerSeq,string,omitempty"` + // The ledger sequence until the entry is live, available for entries that have associated ttl ledger entries. + LiveUntilLedgerSeq *uint32 `json:"liveUntilLedgerSeqLedgerSeq,string,omitempty"` } type GetLedgerEntriesResponse struct { @@ -68,12 +67,12 @@ func NewGetLedgerEntriesHandler(logger *log.Entry, ledgerEntryReader db.LedgerEn Message: fmt.Sprintf("cannot unmarshal key value %s at index %d", requestKey, i), } } - if ledgerKey.Type == xdr.LedgerEntryTypeExpiration { + if ledgerKey.Type == xdr.LedgerEntryTypeTtl { logger.WithField("request", request). - Infof("could not provide ledger expiration entry %s at index %d from getLedgerEntries request", requestKey, i) + Infof("could not provide ledger ttl entry %s at index %d from getLedgerEntries request", requestKey, i) return GetLedgerEntriesResponse{}, &jrpc2.Error{ Code: jrpc2.InvalidParams, - Message: ErrLedgerExpirationEntriesCannotBeQueriedDirectly, + Message: ErrLedgerTtlEntriesCannotBeQueriedDirectly, } } ledgerKeys = append(ledgerKeys, ledgerKey) @@ -102,10 +101,10 @@ func NewGetLedgerEntriesHandler(logger *log.Entry, ledgerEntryReader db.LedgerEn ledgerKeysAndEntries, err := tx.GetLedgerEntries(ledgerKeys...) if err != nil { logger.WithError(err).WithField("request", request). - Info("could not obtain ledger entryies from storage") + Info("could not obtain ledger entries from storage") return GetLedgerEntriesResponse{}, &jrpc2.Error{ Code: jrpc2.InternalError, - Message: "could not obtain ledger entryies from storage", + Message: "could not obtain ledger entries from storage", } } @@ -124,7 +123,7 @@ func NewGetLedgerEntriesHandler(logger *log.Entry, ledgerEntryReader db.LedgerEn Key: request.Keys[i], XDR: ledgerXDR, LastModifiedLedger: int64(ledgerKeyAndEntry.Entry.LastModifiedLedgerSeq), - ExpirationLedger: ledgerKeyAndEntry.ExpirationLedgerSeq, + LiveUntilLedgerSeq: ledgerKeyAndEntry.LiveUntilLedgerSeq, }) } diff --git a/cmd/soroban-rpc/internal/methods/get_ledger_entry.go b/cmd/soroban-rpc/internal/methods/get_ledger_entry.go index 1da93f9dd..614c6e634 100644 --- a/cmd/soroban-rpc/internal/methods/get_ledger_entry.go +++ b/cmd/soroban-rpc/internal/methods/get_ledger_entry.go @@ -26,8 +26,8 @@ type GetLedgerEntryResponse struct { XDR string `json:"xdr"` LastModifiedLedger int64 `json:"lastModifiedLedgerSeq,string"` LatestLedger int64 `json:"latestLedger,string"` - // The expiration ledger, available for entries that have expiration ledgers. - ExpirationLedger *uint32 `json:"expirationLedgerSeq,string,omitempty"` + // The ledger sequence until the entry is live, available for entries that have associated ttl ledger entries. + LiveUntilLedgerSeq *uint32 `json:"LiveUntilLedgerSeq,string,omitempty"` } var invalidLedgerKeyXdrError = &jrpc2.Error{ @@ -52,10 +52,10 @@ func NewGetLedgerEntryHandler(logger *log.Entry, ledgerEntryReader db.LedgerEntr return GetLedgerEntryResponse{}, invalidLedgerKeyXdrError } - if key.Type == xdr.LedgerEntryTypeExpiration { + if key.Type == xdr.LedgerEntryTypeTtl { return GetLedgerEntryResponse{}, &jrpc2.Error{ Code: jrpc2.InvalidParams, - Message: ErrLedgerExpirationEntriesCannotBeQueriedDirectly, + Message: ErrLedgerTtlEntriesCannotBeQueriedDirectly, } } @@ -78,7 +78,7 @@ func NewGetLedgerEntryHandler(logger *log.Entry, ledgerEntryReader db.LedgerEntr } } - present, ledgerEntry, ledgerExpirationSeq, err := db.GetLedgerEntry(tx, key) + present, ledgerEntry, liveUntilLedgerSeq, err := db.GetLedgerEntry(tx, key) if err != nil { logger.WithError(err).WithField("request", request). Info("could not obtain ledger entry from storage") @@ -98,7 +98,7 @@ func NewGetLedgerEntryHandler(logger *log.Entry, ledgerEntryReader db.LedgerEntr response := GetLedgerEntryResponse{ LastModifiedLedger: int64(ledgerEntry.LastModifiedLedgerSeq), LatestLedger: int64(latestLedger), - ExpirationLedger: ledgerExpirationSeq, + LiveUntilLedgerSeq: liveUntilLedgerSeq, } if response.XDR, err = xdr.MarshalBase64(ledgerEntry.Data); err != nil { logger.WithError(err).WithField("request", request). diff --git a/cmd/soroban-rpc/internal/methods/get_transaction_test.go b/cmd/soroban-rpc/internal/methods/get_transaction_test.go index e0c3e5721..1b30cb762 100644 --- a/cmd/soroban-rpc/internal/methods/get_transaction_test.go +++ b/cmd/soroban-rpc/internal/methods/get_transaction_test.go @@ -8,6 +8,7 @@ import ( "github.com/stretchr/testify/assert" "github.com/stellar/go/network" + "github.com/stellar/soroban-tools/cmd/soroban-rpc/internal/daemon/interfaces" "github.com/stellar/soroban-tools/cmd/soroban-rpc/internal/transactions" ) @@ -70,8 +71,8 @@ func txMeta(acctSeq uint32, successful bool) xdr.LedgerCloseMeta { }, } return xdr.LedgerCloseMeta{ - V: 2, - V2: &xdr.LedgerCloseMetaV2{ + V: 1, + V1: &xdr.LedgerCloseMetaV1{ LedgerHeader: xdr.LedgerHeaderHistoryEntry{ Header: xdr.LedgerHeader{ ScpValue: xdr.StellarValue{ @@ -134,11 +135,11 @@ func TestGetTransaction(t *testing.T) { tx, err = GetTransaction(store, GetTransactionRequest{hash}) assert.NoError(t, err) - expectedTxResult, err := xdr.MarshalBase64(meta.V2.TxProcessing[0].Result.Result) + expectedTxResult, err := xdr.MarshalBase64(meta.V1.TxProcessing[0].Result.Result) assert.NoError(t, err) expectedEnvelope, err := xdr.MarshalBase64(txEnvelope(1)) assert.NoError(t, err) - expectedTxMeta, err := xdr.MarshalBase64(meta.V2.TxProcessing[0].TxApplyProcessing) + expectedTxMeta, err := xdr.MarshalBase64(meta.V1.TxProcessing[0].TxApplyProcessing) assert.NoError(t, err) assert.Equal(t, GetTransactionResponse{ Status: TransactionStatusSuccess, @@ -182,11 +183,11 @@ func TestGetTransaction(t *testing.T) { xdrHash = txHash(2) hash = hex.EncodeToString(xdrHash[:]) - expectedTxResult, err = xdr.MarshalBase64(meta.V2.TxProcessing[0].Result.Result) + expectedTxResult, err = xdr.MarshalBase64(meta.V1.TxProcessing[0].Result.Result) assert.NoError(t, err) expectedEnvelope, err = xdr.MarshalBase64(txEnvelope(2)) assert.NoError(t, err) - expectedTxMeta, err = xdr.MarshalBase64(meta.V2.TxProcessing[0].TxApplyProcessing) + expectedTxMeta, err = xdr.MarshalBase64(meta.V1.TxProcessing[0].TxApplyProcessing) assert.NoError(t, err) tx, err = GetTransaction(store, GetTransactionRequest{hash}) diff --git a/cmd/soroban-rpc/internal/methods/simulate_transaction.go b/cmd/soroban-rpc/internal/methods/simulate_transaction.go index 638a6a7b5..cd6a8bae1 100644 --- a/cmd/soroban-rpc/internal/methods/simulate_transaction.go +++ b/cmd/soroban-rpc/internal/methods/simulate_transaction.go @@ -86,10 +86,10 @@ func NewSimulateTransactionHandler(logger *log.Entry, ledgerEntryReader db.Ledge footprint := xdr.LedgerFootprint{} switch op.Body.Type { case xdr.OperationTypeInvokeHostFunction: - case xdr.OperationTypeBumpFootprintExpiration, xdr.OperationTypeRestoreFootprint: + case xdr.OperationTypeExtendFootprintTtl, xdr.OperationTypeRestoreFootprint: if txEnvelope.Type != xdr.EnvelopeTypeEnvelopeTypeTx && txEnvelope.V1.Tx.Ext.V != 1 { return SimulateTransactionResponse{ - Error: "To perform a SimulateTransaction for BumpFootprintExpiration or RestoreFootprint operations, SorobanTransactionData must be provided", + Error: "To perform a SimulateTransaction for ExtendFootprintTtl or RestoreFootprint operations, SorobanTransactionData must be provided", } } footprint = txEnvelope.V1.Tx.Ext.SorobanData.Resources.Footprint @@ -177,8 +177,8 @@ func getBucketListSize(ctx context.Context, ledgerReader db.LedgerReader, latest if !ok { return 0, fmt.Errorf("missing meta for latest ledger (%d)", latestLedger) } - if closeMeta.V != 2 { + if closeMeta.V != 1 { return 0, fmt.Errorf("latest ledger (%d) meta has unexpected verion (%d)", latestLedger, closeMeta.V) } - return uint64(closeMeta.V2.TotalByteSizeOfBucketList), nil + return uint64(closeMeta.V1.TotalByteSizeOfBucketList), nil } diff --git a/cmd/soroban-rpc/internal/preflight/preflight.go b/cmd/soroban-rpc/internal/preflight/preflight.go index c353252a1..20ddcb4bc 100644 --- a/cmd/soroban-rpc/internal/preflight/preflight.go +++ b/cmd/soroban-rpc/internal/preflight/preflight.go @@ -46,7 +46,7 @@ func SnapshotSourceGet(handle C.uintptr_t, cLedgerKey C.xdr_t) C.xdr_t { if err := xdr.SafeUnmarshal(ledgerKeyXDR, &ledgerKey); err != nil { panic(err) } - // TODO : the expiration sequence here is being ignored for now; it should be passed downstream. + // TODO : the live-until sequence here is being ignored for now; it should be passed downstream. present, entry, _, err := db.GetLedgerEntry(h.readTx, ledgerKey) if err != nil { h.logger.WithError(err).Error("SnapshotSourceGet(): GetLedgerEntry() failed") @@ -119,14 +119,14 @@ func GetPreflight(ctx context.Context, params PreflightParameters) (Preflight, e switch params.OpBody.Type { case xdr.OperationTypeInvokeHostFunction: return getInvokeHostFunctionPreflight(params) - case xdr.OperationTypeBumpFootprintExpiration, xdr.OperationTypeRestoreFootprint: - return getFootprintExpirationPreflight(params) + case xdr.OperationTypeExtendFootprintTtl, xdr.OperationTypeRestoreFootprint: + return getFootprintTtlPreflight(params) default: return Preflight{}, fmt.Errorf("unsupported operation type: %s", params.OpBody.Type.String()) } } -func getFootprintExpirationPreflight(params PreflightParameters) (Preflight, error) { +func getFootprintTtlPreflight(params PreflightParameters) (Preflight, error) { opBodyXDR, err := params.OpBody.MarshalBinary() if err != nil { return Preflight{}, err @@ -145,7 +145,7 @@ func getFootprintExpirationPreflight(params PreflightParameters) (Preflight, err return Preflight{}, err } - res := C.preflight_footprint_expiration_op( + res := C.preflight_footprint_ttl_op( C.uintptr_t(handle), C.uint64_t(params.BucketListSize), opBodyCXDR, @@ -183,20 +183,17 @@ func getInvokeHostFunctionPreflight(params PreflightParameters) (Preflight, erro } sourceAccountCXDR := CXDR(sourceAccountXDR) - hasConfig, stateExpirationConfig, expSeq, err := db.GetLedgerEntry(params.LedgerEntryReadTx, xdr.LedgerKey{ + hasConfig, stateArchivalConfig, _, err := db.GetLedgerEntry(params.LedgerEntryReadTx, xdr.LedgerKey{ Type: xdr.LedgerEntryTypeConfigSetting, ConfigSetting: &xdr.LedgerKeyConfigSetting{ - ConfigSettingId: xdr.ConfigSettingIdConfigSettingStateExpiration, + ConfigSettingId: xdr.ConfigSettingIdConfigSettingStateArchival, }, }) if err != nil { return Preflight{}, err } - if expSeq != nil { - return Preflight{}, errors.New("configuration setting are not expected to be expiring, yet, an expiration ledger sequence was found for ledger entry") - } if !hasConfig { - return Preflight{}, errors.New("state expiration config setting missing in ledger storage") + return Preflight{}, errors.New("state archival config setting missing in ledger storage") } simulationLedgerSeq, err := getSimulationLedgerSeq(params.LedgerEntryReadTx) @@ -204,17 +201,17 @@ func getInvokeHostFunctionPreflight(params PreflightParameters) (Preflight, erro return Preflight{}, err } - stateExpiration := stateExpirationConfig.Data.MustConfigSetting().MustStateExpirationSettings() + stateArchival := stateArchivalConfig.Data.MustConfigSetting().MustStateArchivalSettings() li := C.ledger_info_t{ network_passphrase: C.CString(params.NetworkPassphrase), sequence_number: C.uint32_t(simulationLedgerSeq), protocol_version: 20, timestamp: C.uint64_t(time.Now().Unix()), // Current base reserve is 0.5XLM (in stroops) - base_reserve: 5_000_000, - min_temp_entry_expiration: C.uint(stateExpiration.MinTempEntryExpiration), - min_persistent_entry_expiration: C.uint(stateExpiration.MinPersistentEntryExpiration), - max_entry_expiration: C.uint(stateExpiration.MaxEntryExpiration), + base_reserve: 5_000_000, + min_temp_entry_ttl: C.uint(stateArchival.MinTemporaryTtl), + min_persistent_entry_ttl: C.uint(stateArchival.MinPersistentTtl), + max_entry_ttl: C.uint(stateArchival.MaxEntryTtl), } handle := cgo.NewHandle(snapshotSourceHandle{params.LedgerEntryReadTx, params.Logger}) diff --git a/cmd/soroban-rpc/internal/preflight/preflight_test.go b/cmd/soroban-rpc/internal/preflight/preflight_test.go index 0b87159ba..1dca591b4 100644 --- a/cmd/soroban-rpc/internal/preflight/preflight_test.go +++ b/cmd/soroban-rpc/internal/preflight/preflight_test.go @@ -32,7 +32,7 @@ var contractCostParams = func() *xdr.ContractCostParams { return &result }() -var mockLedgerEntriesWithoutExpirations = []xdr.LedgerEntry{ +var mockLedgerEntriesWithoutTTLs = []xdr.LedgerEntry{ { LastModifiedLedgerSeq: 1, Data: xdr.LedgerEntryData{ @@ -154,14 +154,14 @@ var mockLedgerEntriesWithoutExpirations = []xdr.LedgerEntry{ Data: xdr.LedgerEntryData{ Type: xdr.LedgerEntryTypeConfigSetting, ConfigSetting: &xdr.ConfigSettingEntry{ - ConfigSettingId: xdr.ConfigSettingIdConfigSettingStateExpiration, - StateExpirationSettings: &xdr.StateExpirationSettings{ - MaxEntryExpiration: 100, - MinTempEntryExpiration: 100, - MinPersistentEntryExpiration: 100, + ConfigSettingId: xdr.ConfigSettingIdConfigSettingStateArchival, + StateArchivalSettings: &xdr.StateArchivalSettings{ + MaxEntryTtl: 100, + MinTemporaryTtl: 100, + MinPersistentTtl: 100, PersistentRentRateDenominator: 100, TempRentRateDenominator: 100, - MaxEntriesToExpire: 100, + MaxEntriesToArchive: 100, BucketListSizeWindowSampleSize: 100, EvictionScanSize: 100, }, @@ -192,10 +192,10 @@ var mockLedgerEntriesWithoutExpirations = []xdr.LedgerEntry{ }, } -// Adds expiration entries to mockLedgerEntriesWithoutExpirations +// Adds ttl entries to mockLedgerEntriesWithoutTTLs var mockLedgerEntries = func() []xdr.LedgerEntry { - result := make([]xdr.LedgerEntry, 0, len(mockLedgerEntriesWithoutExpirations)) - for _, entry := range mockLedgerEntriesWithoutExpirations { + result := make([]xdr.LedgerEntry, 0, len(mockLedgerEntriesWithoutTTLs)) + for _, entry := range mockLedgerEntriesWithoutTTLs { result = append(result, entry) if entry.Data.Type == xdr.LedgerEntryTypeContractData || entry.Data.Type == xdr.LedgerEntryTypeContractCode { @@ -207,18 +207,18 @@ var mockLedgerEntries = func() []xdr.LedgerEntry { if err != nil { panic(err) } - expirationEntry := xdr.LedgerEntry{ + ttlEntry := xdr.LedgerEntry{ LastModifiedLedgerSeq: entry.LastModifiedLedgerSeq, Data: xdr.LedgerEntryData{ - Type: xdr.LedgerEntryTypeExpiration, - Expiration: &xdr.ExpirationEntry{ + Type: xdr.LedgerEntryTypeTtl, + Ttl: &xdr.TtlEntry{ KeyHash: sha256.Sum256(bin), - // Make sure it doesn't expire - ExpirationLedgerSeq: 1000, + // Make sure it doesn't ttl + LiveUntilLedgerSeq: 1000, }, }, } - result = append(result, expirationEntry) + result = append(result, ttlEntry) } } return result @@ -248,7 +248,7 @@ func (m inMemoryLedgerEntryReadTx) GetLedgerEntries(keys ...xdr.LedgerKey) ([]db if !ok { continue } - // We don't check the expiration but that's ok for the test + // We don't check the TTL but that's ok for the test result = append(result, db.LedgerKeyAndEntry{ Key: key, Entry: entry, diff --git a/cmd/soroban-rpc/internal/test/captive-core-integration-tests.cfg b/cmd/soroban-rpc/internal/test/captive-core-integration-tests.cfg index 45b9a8e61..275599bac 100644 --- a/cmd/soroban-rpc/internal/test/captive-core-integration-tests.cfg +++ b/cmd/soroban-rpc/internal/test/captive-core-integration-tests.cfg @@ -5,8 +5,8 @@ UNSAFE_QUORUM=true FAILURE_SAFETY=0 ENABLE_SOROBAN_DIAGNOSTIC_EVENTS=true -# Lower the expiration of persistent ledger entries -# so that ledger expiration/restoring becomes testeable +# Lower the TTL of persistent ledger entries +# so that ledger entry extension/restoring becomes testeable TESTING_MINIMUM_PERSISTENT_ENTRY_LIFETIME=10 TESTING_SOROBAN_HIGH_LIMIT_OVERRIDE=true diff --git a/cmd/soroban-rpc/internal/test/cli_test.go b/cmd/soroban-rpc/internal/test/cli_test.go index ba39b7722..4af05ccf4 100644 --- a/cmd/soroban-rpc/internal/test/cli_test.go +++ b/cmd/soroban-rpc/internal/test/cli_test.go @@ -17,10 +17,11 @@ import ( "github.com/stellar/go/strkey" "github.com/stellar/go/txnbuild" "github.com/stellar/go/xdr" - "github.com/stellar/soroban-tools/cmd/soroban-rpc/internal/methods" "github.com/stretchr/testify/assert" "github.com/stretchr/testify/require" "gotest.tools/v3/icmd" + + "github.com/stellar/soroban-tools/cmd/soroban-rpc/internal/methods" ) func cargoTest(t *testing.T, name string) { @@ -115,17 +116,17 @@ func TestCLIRestorePreamble(t *testing.T) { count = runSuccessfulCLICmd(t, fmt.Sprintf("contract invoke --id %s -- inc", strkeyContractID)) require.Equal(t, "2", count) - // Wait for the counter ledger entry to expire and successfully invoke the `inc` contract function again + // Wait for the counter ledger entry to ttl and successfully invoke the `inc` contract function again // This ensures that the CLI restores the entry (using the RestorePreamble in the simulateTransaction response) ch := jhttp.NewChannel(test.sorobanRPCURL(), nil) client := jrpc2.NewClient(ch, nil) - waitForLedgerEntryToExpire(t, client, getCounterLedgerKey(parseContractStrKey(t, strkeyContractID))) + waitUntilLedgerEntryTTL(t, client, getCounterLedgerKey(parseContractStrKey(t, strkeyContractID))) count = runSuccessfulCLICmd(t, fmt.Sprintf("contract invoke --id %s -- inc", strkeyContractID)) require.Equal(t, "3", count) } -func TestCLIBump(t *testing.T) { +func TestCLIExtend(t *testing.T) { test := NewCLITest(t) strkeyContractID := runSuccessfulCLICmd(t, fmt.Sprintf("contract deploy --salt=%s --wasm %s", hex.EncodeToString(testSalt[:]), helloWorldContractPath)) count := runSuccessfulCLICmd(t, fmt.Sprintf("contract invoke --id %s -- inc", strkeyContractID)) @@ -134,22 +135,22 @@ func TestCLIBump(t *testing.T) { ch := jhttp.NewChannel(test.sorobanRPCURL(), nil) client := jrpc2.NewClient(ch, nil) - expirationKey := getCounterLedgerKey(parseContractStrKey(t, strkeyContractID)) - initialExpirationSeq := getExpirationForLedgerEntry(t, client, expirationKey) + ttlKey := getCounterLedgerKey(parseContractStrKey(t, strkeyContractID)) + initialLiveUntilSeq := getLedgerEntryLiveUntil(t, client, ttlKey) - bumpOutput := runSuccessfulCLICmd( + extendOutput := runSuccessfulCLICmd( t, fmt.Sprintf( - "contract bump --id %s --key COUNTER --durability persistent --ledgers-to-expire 20", + "contract extend --id %s --key COUNTER --durability persistent --ledgers-to-extend 20", strkeyContractID, ), ) - newExpirationSeq := getExpirationForLedgerEntry(t, client, expirationKey) - assert.Greater(t, newExpirationSeq, initialExpirationSeq) - assert.Equal(t, fmt.Sprintf("New expiration ledger: %d", newExpirationSeq), bumpOutput) + newLiveUntilSeq := getLedgerEntryLiveUntil(t, client, ttlKey) + assert.Greater(t, newLiveUntilSeq, initialLiveUntilSeq) + assert.Equal(t, fmt.Sprintf("New ttl ledger: %d", newLiveUntilSeq), extendOutput) } -func TestCLIBumpTooLow(t *testing.T) { +func TestCLIExtendTooLow(t *testing.T) { test := NewCLITest(t) strkeyContractID := runSuccessfulCLICmd(t, fmt.Sprintf("contract deploy --salt=%s --wasm %s", hex.EncodeToString(testSalt[:]), helloWorldContractPath)) count := runSuccessfulCLICmd(t, fmt.Sprintf("contract invoke --id %s -- inc", strkeyContractID)) @@ -158,20 +159,20 @@ func TestCLIBumpTooLow(t *testing.T) { ch := jhttp.NewChannel(test.sorobanRPCURL(), nil) client := jrpc2.NewClient(ch, nil) - expirationKey := getCounterLedgerKey(parseContractStrKey(t, strkeyContractID)) - initialExpirationSeq := parseInt(t, getExpirationForLedgerEntry(t, client, expirationKey).GoString()) + ttlKey := getCounterLedgerKey(parseContractStrKey(t, strkeyContractID)) + initialLiveUntilSeq := parseInt(t, getLedgerEntryLiveUntil(t, client, ttlKey).GoString()) - bumpOutput := bump(t, strkeyContractID, "400", "--key COUNTER ") + extendOutput := extend(t, strkeyContractID, "400", "--key COUNTER ") - newExpirationSeq := parseInt(t, getExpirationForLedgerEntry(t, client, expirationKey).GoString()) - assert.Greater(t, newExpirationSeq, initialExpirationSeq) - assert.Equal(t, newExpirationSeq, bumpOutput) + newLiveUntilSeq := parseInt(t, getLedgerEntryLiveUntil(t, client, ttlKey).GoString()) + assert.Greater(t, newLiveUntilSeq, initialLiveUntilSeq) + assert.Equal(t, newLiveUntilSeq, extendOutput) - updatedExpirationSeq := bump(t, strkeyContractID, "15", "--key COUNTER") - assert.Equal(t, bumpOutput, updatedExpirationSeq) + updatedLiveUntilSeq := extend(t, strkeyContractID, "15", "--key COUNTER") + assert.Equal(t, extendOutput, updatedLiveUntilSeq) } -func TestCLIBumpTooHigh(t *testing.T) { +func TestCLIExtendTooHigh(t *testing.T) { test := NewCLITest(t) strkeyContractID := runSuccessfulCLICmd(t, fmt.Sprintf("contract deploy --salt=%s --wasm %s", hex.EncodeToString(testSalt[:]), helloWorldContractPath)) count := runSuccessfulCLICmd(t, fmt.Sprintf("contract invoke --id %s -- inc", strkeyContractID)) @@ -180,14 +181,14 @@ func TestCLIBumpTooHigh(t *testing.T) { ch := jhttp.NewChannel(test.sorobanRPCURL(), nil) client := jrpc2.NewClient(ch, nil) - expirationKey := getCounterLedgerKey(parseContractStrKey(t, strkeyContractID)) - initialExpirationSeq := parseInt(t, getExpirationForLedgerEntry(t, client, expirationKey).GoString()) + ttlKey := getCounterLedgerKey(parseContractStrKey(t, strkeyContractID)) + initialLiveUntilSeq := parseInt(t, getLedgerEntryLiveUntil(t, client, ttlKey).GoString()) - bumpOutput := bump(t, strkeyContractID, "100000000", "--key COUNTER ") + extendOutput := extend(t, strkeyContractID, "100000000", "--key COUNTER ") - newExpirationSeq := parseInt(t, getExpirationForLedgerEntry(t, client, expirationKey).GoString()) - assert.Greater(t, newExpirationSeq, initialExpirationSeq) - assert.Equal(t, newExpirationSeq, bumpOutput) + newLiveUntilSeq := parseInt(t, getLedgerEntryLiveUntil(t, client, ttlKey).GoString()) + assert.Greater(t, newLiveUntilSeq, initialLiveUntilSeq) + assert.Equal(t, newLiveUntilSeq, extendOutput) } func TestCLIRestore(t *testing.T) { @@ -199,11 +200,11 @@ func TestCLIRestore(t *testing.T) { ch := jhttp.NewChannel(test.sorobanRPCURL(), nil) client := jrpc2.NewClient(ch, nil) - expirationKey := getCounterLedgerKey(parseContractStrKey(t, strkeyContractID)) - initialExpirationSeq := getExpirationForLedgerEntry(t, client, expirationKey) - // Wait for the counter ledger entry to expire and successfully invoke the `inc` contract function again + ttlKey := getCounterLedgerKey(parseContractStrKey(t, strkeyContractID)) + initialLiveUntilSeq := getLedgerEntryLiveUntil(t, client, ttlKey) + // Wait for the counter ledger entry to ttl and successfully invoke the `inc` contract function again // This ensures that the CLI restores the entry (using the RestorePreamble in the simulateTransaction response) - waitForLedgerEntryToExpire(t, client, expirationKey) + waitUntilLedgerEntryTTL(t, client, ttlKey) restoreOutput := runSuccessfulCLICmd( t, @@ -213,37 +214,39 @@ func TestCLIRestore(t *testing.T) { ), ) - newExpirationSeq := getExpirationForLedgerEntry(t, client, getCounterLedgerKey(parseContractStrKey(t, strkeyContractID))) - assert.Greater(t, newExpirationSeq, initialExpirationSeq) - assert.Equal(t, fmt.Sprintf("New expiration ledger: %d", newExpirationSeq), restoreOutput) + newLiveUntilSeq := getLedgerEntryLiveUntil(t, client, getCounterLedgerKey(parseContractStrKey(t, strkeyContractID))) + assert.Greater(t, newLiveUntilSeq, initialLiveUntilSeq) + assert.Equal(t, fmt.Sprintf("New ttl ledger: %d", newLiveUntilSeq), restoreOutput) - // test to see that we get an error when requesting the expiration ledger entry explicitly. - ledgerExpirationEntry := getExpirationKey(t, getCounterLedgerKey(parseContractStrKey(t, strkeyContractID))) - ledgerExpirationEntryB64, err := xdr.MarshalBase64(ledgerExpirationEntry) + // FIXME: the following checks shouldn't live here: + + // test to see that we get an error when requesting the ttl ledger entry explicitly. + ledgerTTLEntry := getTtlKey(t, getCounterLedgerKey(parseContractStrKey(t, strkeyContractID))) + ledgerTTLEntryB64, err := xdr.MarshalBase64(ledgerTTLEntry) require.NoError(t, err) var getLedgerEntryResult methods.GetLedgerEntryResponse err = client.CallResult(context.Background(), "getLedgerEntry", methods.GetLedgerEntryRequest{ - Key: ledgerExpirationEntryB64, + Key: ledgerTTLEntryB64, }, &getLedgerEntryResult) require.Error(t, err) - require.Contains(t, err.Error(), methods.ErrLedgerExpirationEntriesCannotBeQueriedDirectly) + require.Contains(t, err.Error(), methods.ErrLedgerTtlEntriesCannotBeQueriedDirectly) // repeat with getLedgerEntries var getLedgerEntriesResult methods.GetLedgerEntriesResponse err = client.CallResult(context.Background(), "getLedgerEntries", methods.GetLedgerEntriesRequest{ - Keys: []string{ledgerExpirationEntryB64}, + Keys: []string{ledgerTTLEntryB64}, }, &getLedgerEntriesResult) require.Error(t, err) - require.Contains(t, err.Error(), methods.ErrLedgerExpirationEntriesCannotBeQueriedDirectly) + require.Contains(t, err.Error(), methods.ErrLedgerTtlEntriesCannotBeQueriedDirectly) } -func getExpirationKey(t *testing.T, key xdr.LedgerKey) xdr.LedgerKey { +func getTtlKey(t *testing.T, key xdr.LedgerKey) xdr.LedgerKey { assert.True(t, key.Type == xdr.LedgerEntryTypeContractCode || key.Type == xdr.LedgerEntryTypeContractData) binKey, err := key.MarshalBinary() assert.NoError(t, err) return xdr.LedgerKey{ - Type: xdr.LedgerEntryTypeExpiration, - Expiration: &xdr.LedgerKeyExpiration{ + Type: xdr.LedgerEntryTypeTtl, + Ttl: &xdr.LedgerKeyTtl{ KeyHash: sha256.Sum256(binKey), }, } @@ -321,12 +324,12 @@ func parseInt(t *testing.T, s string) uint64 { return i } -func bump(t *testing.T, contractId string, amount string, rest string) uint64 { +func extend(t *testing.T, contractId string, amount string, rest string) uint64 { res := runSuccessfulCLICmd( t, fmt.Sprintf( - "contract bump --expiration-ledger-only --id=%s --durability persistent --ledgers-to-expire=%s %s", + "contract extend --extension-ledger-only --id=%s --durability persistent --ledgers-to-extend=%s %s", contractId, amount, rest, @@ -335,3 +338,20 @@ func bump(t *testing.T, contractId string, amount string, rest string) uint64 { return parseInt(t, res) } + +func getLedgerEntryLiveUntil(t *testing.T, client *jrpc2.Client, ttlLedgerKey xdr.LedgerKey) xdr.Uint32 { + keyB64, err := xdr.MarshalBase64(ttlLedgerKey) + require.NoError(t, err) + getLedgerEntryrequest := methods.GetLedgerEntryRequest{ + Key: keyB64, + } + var getLedgerEntryResult methods.GetLedgerEntryResponse + err = client.CallResult(context.Background(), "getLedgerEntry", getLedgerEntryrequest, &getLedgerEntryResult) + require.NoError(t, err) + var entry xdr.LedgerEntryData + require.NoError(t, xdr.SafeUnmarshalBase64(getLedgerEntryResult.XDR, &entry)) + + require.Contains(t, []xdr.LedgerEntryType{xdr.LedgerEntryTypeContractCode, xdr.LedgerEntryTypeContractData}, entry.Type) + require.NotNil(t, getLedgerEntryResult.LiveUntilLedgerSeq) + return xdr.Uint32(*getLedgerEntryResult.LiveUntilLedgerSeq) +} diff --git a/cmd/soroban-rpc/internal/test/docker-compose.yml b/cmd/soroban-rpc/internal/test/docker-compose.yml index 7d8fd89ea..bac17e52e 100644 --- a/cmd/soroban-rpc/internal/test/docker-compose.yml +++ b/cmd/soroban-rpc/internal/test/docker-compose.yml @@ -15,7 +15,7 @@ services: # Note: Please keep the image pinned to an immutable tag matching the Captive Core version. # This avoids implicit updates which break compatibility between # the Core container and captive core. - image: ${CORE_IMAGE:-stellar/stellar-core:19.13.1-1481.3acf6dd26.focal} + image: ${CORE_IMAGE:-2opremio/stellar-core:19.14.1-1529.fcbbad4ce.focal} depends_on: - core-postgres restart: on-failure diff --git a/cmd/soroban-rpc/internal/test/simulate_transaction_test.go b/cmd/soroban-rpc/internal/test/simulate_transaction_test.go index 13eb9b894..04ac395ea 100644 --- a/cmd/soroban-rpc/internal/test/simulate_transaction_test.go +++ b/cmd/soroban-rpc/internal/test/simulate_transaction_test.go @@ -159,7 +159,7 @@ func preflightTransactionParamsLocally(t *testing.T, params txnbuild.Transaction auth = append(auth, a) } v.Auth = auth - case *txnbuild.BumpFootprintExpiration: + case *txnbuild.ExtendFootprintTtl: require.Len(t, response.Results, 0) v.Ext = xdr.TransactionExt{ V: 1, @@ -236,7 +236,7 @@ func TestSimulateTransactionSucceeds(t *testing.T) { ReadBytes: 48, WriteBytes: 7048, }, - RefundableFee: 20056, + ResourceFee: 130498, } // First, decode and compare the transaction data so we get a decent diff if it fails. @@ -246,8 +246,8 @@ func TestSimulateTransactionSucceeds(t *testing.T) { assert.Equal(t, expectedTransactionData.Resources.Footprint, transactionData.Resources.Footprint) assert.InDelta(t, uint32(expectedTransactionData.Resources.Instructions), uint32(transactionData.Resources.Instructions), 200000) assert.InDelta(t, uint32(expectedTransactionData.Resources.ReadBytes), uint32(transactionData.Resources.ReadBytes), 10) - assert.InDelta(t, uint32(expectedTransactionData.Resources.WriteBytes), uint32(transactionData.Resources.WriteBytes), 500) - assert.InDelta(t, int64(expectedTransactionData.RefundableFee), int64(transactionData.RefundableFee), 2000) + assert.InDelta(t, uint32(expectedTransactionData.Resources.WriteBytes), uint32(transactionData.Resources.WriteBytes), 300) + assert.InDelta(t, int64(expectedTransactionData.ResourceFee), int64(transactionData.ResourceFee), 3000) // Then decode and check the result xdr, separately so we get a decent diff if it fails. assert.Len(t, result.Results, 1) @@ -494,7 +494,7 @@ func TestSimulateInvokeContractTransactionSucceeds(t *testing.T) { assert.Equal(t, xdr.Hash(contractHash), ro2.ContractCode.Hash) assert.NoError(t, err) - assert.NotZero(t, obtainedTransactionData.RefundableFee) + assert.NotZero(t, obtainedTransactionData.ResourceFee) assert.NotZero(t, obtainedTransactionData.Resources.Instructions) assert.NotZero(t, obtainedTransactionData.Resources.ReadBytes) assert.NotZero(t, obtainedTransactionData.Resources.WriteBytes) @@ -538,7 +538,6 @@ func TestSimulateInvokeContractTransactionSucceeds(t *testing.T) { assert.Len(t, event.Event.Body.V0.Topics, 1) assert.Equal(t, xdr.ScValTypeScvString, event.Event.Body.V0.Topics[0].Type) assert.Equal(t, xdr.ScString("auth"), *event.Event.Body.V0.Topics[0].Str) - metrics := getMetrics(test) 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") @@ -669,7 +668,7 @@ func TestSimulateTransactionUnmarshalError(t *testing.T) { ) } -func TestSimulateTransactionBumpAndRestoreFootprint(t *testing.T) { +func TestSimulateTransactionExtendAndRestoreFootprint(t *testing.T) { test := NewTest(t) ch := jhttp.NewChannel(test.sorobanRPCURL(), nil) @@ -732,7 +731,7 @@ func TestSimulateTransactionBumpAndRestoreFootprint(t *testing.T) { assert.NoError(t, err) sendSuccessfulTransaction(t, client, sourceAccount, tx) - // get the counter ledger entry expiration + // get the counter ledger entry TTL key := getCounterLedgerKey(contractID) keyB64, err := xdr.MarshalBase64(key) @@ -747,17 +746,17 @@ func TestSimulateTransactionBumpAndRestoreFootprint(t *testing.T) { var entry xdr.LedgerEntryData assert.NoError(t, xdr.SafeUnmarshalBase64(getLedgerEntryResult.XDR, &entry)) assert.Equal(t, xdr.LedgerEntryTypeContractData, entry.Type) - require.NotNil(t, getLedgerEntryResult.ExpirationLedger) + require.NotNil(t, getLedgerEntryResult.LiveUntilLedgerSeq) - initialExpirationSeq := *getLedgerEntryResult.ExpirationLedger + initialLiveUntil := *getLedgerEntryResult.LiveUntilLedgerSeq - // bump the initial expiration + // Extend the initial TTL params = preflightTransactionParams(t, client, txnbuild.TransactionParams{ SourceAccount: &account, IncrementSequenceNum: true, Operations: []txnbuild.Operation{ - &txnbuild.BumpFootprintExpiration{ - LedgersToExpire: 20, + &txnbuild.ExtendFootprintTtl{ + ExtendTo: 20, Ext: xdr.TransactionExt{ V: 1, SorobanData: &xdr.SorobanTransactionData{ @@ -783,32 +782,12 @@ func TestSimulateTransactionBumpAndRestoreFootprint(t *testing.T) { assert.NoError(t, err) assert.NoError(t, xdr.SafeUnmarshalBase64(getLedgerEntryResult.XDR, &entry)) assert.Equal(t, xdr.LedgerEntryTypeContractData, entry.Type) - require.NotNil(t, getLedgerEntryResult.ExpirationLedger) - newExpirationSeq := *getLedgerEntryResult.ExpirationLedger - assert.Greater(t, newExpirationSeq, initialExpirationSeq) - - // Wait until it expires - waitForExpiration := func() { - expired := false - for i := 0; i < 50; i++ { - err = client.CallResult(context.Background(), "getLedgerEntry", getLedgerEntryrequest, &getLedgerEntryResult) - assert.NoError(t, err) - assert.NoError(t, xdr.SafeUnmarshalBase64(getLedgerEntryResult.XDR, &entry)) - assert.Equal(t, xdr.LedgerEntryTypeContractData, entry.Type) - // See https://soroban.stellar.org/docs/fundamentals-and-concepts/state-expiration#expiration-ledger - currentLedger := getLedgerEntryResult.LatestLedger + 1 - require.NotNil(t, getLedgerEntryResult.ExpirationLedger) - if uint32(currentLedger) > *getLedgerEntryResult.ExpirationLedger { - expired = true - t.Logf("ledger entry expired") - break - } - t.Log("waiting for ledger entry to expire at ledger", *getLedgerEntryResult.ExpirationLedger) - time.Sleep(time.Second) - } - require.True(t, expired) - } - waitForExpiration() + require.NotNil(t, getLedgerEntryResult.LiveUntilLedgerSeq) + newLiveUntilSeq := *getLedgerEntryResult.LiveUntilLedgerSeq + assert.Greater(t, newLiveUntilSeq, initialLiveUntil) + + // Wait until it is not live anymore + waitUntilLedgerEntryTTL(t, client, key) // and restore it params = preflightTransactionParams(t, client, txnbuild.TransactionParams{ @@ -837,8 +816,8 @@ func TestSimulateTransactionBumpAndRestoreFootprint(t *testing.T) { assert.NoError(t, err) sendSuccessfulTransaction(t, client, sourceAccount, tx) - // Wait for expiration again and check the pre-restore field when trying to exec the contract again - waitForLedgerEntryToExpire(t, client, key) + // Wait for TTL again and check the pre-restore field when trying to exec the contract again + waitUntilLedgerEntryTTL(t, client, key) simulationResult := simulateTransactionFromTxParams(t, client, invokeIncPresistentEntryParams) require.NotNil(t, simulationResult.RestorePreamble) @@ -851,6 +830,7 @@ func TestSimulateTransactionBumpAndRestoreFootprint(t *testing.T) { Operations: []txnbuild.Operation{ &txnbuild.RestoreFootprint{}, }, + BaseFee: txnbuild.MinBaseFee, Preconditions: txnbuild.Preconditions{ TimeBounds: txnbuild.NewInfiniteTimeout(), }, @@ -892,30 +872,13 @@ func getCounterLedgerKey(contractID [32]byte) xdr.LedgerKey { return key } -func getExpirationForLedgerEntry(t *testing.T, client *jrpc2.Client, expirationLedgerKey xdr.LedgerKey) xdr.Uint32 { - keyB64, err := xdr.MarshalBase64(expirationLedgerKey) - require.NoError(t, err) - getLedgerEntryrequest := methods.GetLedgerEntryRequest{ - Key: keyB64, - } - var getLedgerEntryResult methods.GetLedgerEntryResponse - err = client.CallResult(context.Background(), "getLedgerEntry", getLedgerEntryrequest, &getLedgerEntryResult) - require.NoError(t, err) - var entry xdr.LedgerEntryData - require.NoError(t, xdr.SafeUnmarshalBase64(getLedgerEntryResult.XDR, &entry)) - - require.Contains(t, []xdr.LedgerEntryType{xdr.LedgerEntryTypeContractCode, xdr.LedgerEntryTypeContractData}, entry.Type) - require.NotNil(t, getLedgerEntryResult.ExpirationLedger) - return xdr.Uint32(*getLedgerEntryResult.ExpirationLedger) -} - -func waitForLedgerEntryToExpire(t *testing.T, client *jrpc2.Client, ledgerKey xdr.LedgerKey) { +func waitUntilLedgerEntryTTL(t *testing.T, client *jrpc2.Client, ledgerKey xdr.LedgerKey) { keyB64, err := xdr.MarshalBase64(ledgerKey) require.NoError(t, err) request := methods.GetLedgerEntriesRequest{ Keys: []string{keyB64}, } - expired := false + ttled := false for i := 0; i < 50; i++ { var result methods.GetLedgerEntriesResponse var entry xdr.LedgerEntryData @@ -923,19 +886,19 @@ func waitForLedgerEntryToExpire(t *testing.T, client *jrpc2.Client, ledgerKey xd require.NoError(t, err) require.NotEmpty(t, result.Entries) require.NoError(t, xdr.SafeUnmarshalBase64(result.Entries[0].XDR, &entry)) - require.NotEqual(t, xdr.LedgerEntryTypeExpiration, entry.Type) - expirationLedgerSeq := xdr.Uint32(*result.Entries[0].ExpirationLedger) + require.NotEqual(t, xdr.LedgerEntryTypeTtl, entry.Type) + liveUntilLedgerSeq := xdr.Uint32(*result.Entries[0].LiveUntilLedgerSeq) // See https://soroban.stellar.org/docs/fundamentals-and-concepts/state-expiration#expiration-ledger currentLedger := result.LatestLedger + 1 - if xdr.Uint32(currentLedger) > expirationLedgerSeq { - expired = true - t.Logf("ledger entry expired") + if xdr.Uint32(currentLedger) > liveUntilLedgerSeq { + ttled = true + t.Logf("ledger entry ttl'ed") break } - t.Log("waiting for ledger entry to expire at ledger", expirationLedgerSeq) + t.Log("waiting for ledger entry to ttl at ledger", liveUntilLedgerSeq) time.Sleep(time.Second) } - require.True(t, expired) + require.True(t, ttled) } func TestSimulateInvokePrng_u64_in_range(t *testing.T) { @@ -1158,8 +1121,8 @@ func TestSimulateSystemEvent(t *testing.T) { err = xdr.SafeUnmarshalBase64(response.TransactionData, &transactionData) require.NoError(t, err) - assert.InDelta(t, 7260, uint32(transactionData.Resources.ReadBytes), 200) - assert.InDelta(t, 45, int64(transactionData.RefundableFee), 10) + assert.InDelta(t, 7464, uint32(transactionData.Resources.ReadBytes), 200) + assert.InDelta(t, 98339, int64(transactionData.ResourceFee), 2000) assert.InDelta(t, 104, uint32(transactionData.Resources.WriteBytes), 15) require.GreaterOrEqual(t, len(response.Events), 3) } diff --git a/cmd/soroban-rpc/internal/test/stellar-core-integration-tests.cfg b/cmd/soroban-rpc/internal/test/stellar-core-integration-tests.cfg index d41ccb021..594a35b24 100644 --- a/cmd/soroban-rpc/internal/test/stellar-core-integration-tests.cfg +++ b/cmd/soroban-rpc/internal/test/stellar-core-integration-tests.cfg @@ -14,9 +14,8 @@ FAILURE_SAFETY=0 DATABASE="postgresql://user=postgres password=mysecretpassword host=core-postgres port=5641 dbname=stellar" -ENABLE_SOROBAN_DIAGNOSTIC_EVENTS=true -# Lower the expiration of persistent ledger entries -# so that ledger expiration/restoring becomes testeable +# Lower the TTL of persistent ledger entries +# so that ledger entry extension/restoring becomes testeable TESTING_MINIMUM_PERSISTENT_ENTRY_LIFETIME=10 TESTING_SOROBAN_HIGH_LIMIT_OVERRIDE=true diff --git a/cmd/soroban-rpc/internal/test/transaction_test.go b/cmd/soroban-rpc/internal/test/transaction_test.go index b53c8f25b..ff8473420 100644 --- a/cmd/soroban-rpc/internal/test/transaction_test.go +++ b/cmd/soroban-rpc/internal/test/transaction_test.go @@ -161,19 +161,19 @@ func TestSendTransactionFailedInLedger(t *testing.T) { address := kp.Address() account := txnbuild.NewSimpleAccount(address, 0) - op := createInstallContractCodeOperation(account.AccountID, getHelloWorldContract(t)) - // without the presources the tx will fail - op.Ext = xdr.TransactionExt{ - V: 1, - SorobanData: &xdr.SorobanTransactionData{}, - } tx, err := txnbuild.NewTransaction(txnbuild.TransactionParams{ SourceAccount: &account, IncrementSequenceNum: true, Operations: []txnbuild.Operation{ - op, + &txnbuild.Payment{ + // Destination doesn't exist, making the transaction fail + Destination: "GA7QYNF7SOWQ3GLR2BGMZEHXAVIRZA4KVWLTJJFC7MGXUA74P7UJVSGZ", + Amount: "100000.0000000", + Asset: txnbuild.NativeAsset{}, + SourceAccount: "", + }, }, - BaseFee: txnbuild.MinBaseFee * 1000, + BaseFee: txnbuild.MinBaseFee, Preconditions: txnbuild.Preconditions{ TimeBounds: txnbuild.NewInfiniteTimeout(), }, diff --git a/cmd/soroban-rpc/internal/transactions/transactions_test.go b/cmd/soroban-rpc/internal/transactions/transactions_test.go index cf78976c9..64fabff1f 100644 --- a/cmd/soroban-rpc/internal/transactions/transactions_test.go +++ b/cmd/soroban-rpc/internal/transactions/transactions_test.go @@ -5,8 +5,9 @@ import ( "github.com/stellar/go/network" "github.com/stellar/go/xdr" - "github.com/stellar/soroban-tools/cmd/soroban-rpc/internal/daemon/interfaces" "github.com/stretchr/testify/require" + + "github.com/stellar/soroban-tools/cmd/soroban-rpc/internal/daemon/interfaces" ) func expectedTransaction(ledger uint32, feeBump bool) Transaction { @@ -107,8 +108,8 @@ func txMeta(ledgerSequence uint32, feeBump bool) xdr.LedgerCloseMeta { }, } return xdr.LedgerCloseMeta{ - V: 2, - V2: &xdr.LedgerCloseMetaV2{ + V: 1, + V1: &xdr.LedgerCloseMetaV1{ LedgerHeader: xdr.LedgerHeaderHistoryEntry{ Header: xdr.LedgerHeader{ ScpValue: xdr.StellarValue{ diff --git a/cmd/soroban-rpc/lib/preflight.h b/cmd/soroban-rpc/lib/preflight.h index faf77699b..fce089c95 100644 --- a/cmd/soroban-rpc/lib/preflight.h +++ b/cmd/soroban-rpc/lib/preflight.h @@ -10,9 +10,9 @@ typedef struct ledger_info_t { uint64_t timestamp; const char *network_passphrase; uint32_t base_reserve; - uint32_t min_temp_entry_expiration; - uint32_t min_persistent_entry_expiration; - uint32_t max_entry_expiration; + uint32_t min_temp_entry_ttl; + uint32_t min_persistent_entry_ttl; + uint32_t max_entry_ttl; } ledger_info_t; typedef struct xdr_t { @@ -45,11 +45,11 @@ preflight_result_t *preflight_invoke_hf_op(uintptr_t handle, // Go Handle to for const ledger_info_t ledger_info, bool enable_debug); -preflight_result_t *preflight_footprint_expiration_op(uintptr_t handle, // Go Handle to forward to SnapshotSourceGet - uint64_t bucket_list_size, // Bucket list size of current ledger - const xdr_t op_body, // OperationBody XDR - const xdr_t footprint, // LedgerFootprint XDR - uint32_t current_ledger_seq); // Current ledger sequence +preflight_result_t *preflight_footprint_ttl_op(uintptr_t handle, // Go Handle to forward to SnapshotSourceGet + uint64_t bucket_list_size, // Bucket list size of current ledger + const xdr_t op_body, // OperationBody XDR + const xdr_t footprint, // LedgerFootprint XDR + uint32_t current_ledger_seq); // Current ledger sequence // LedgerKey XDR to LedgerEntry XDR diff --git a/cmd/soroban-rpc/lib/preflight/src/fees.rs b/cmd/soroban-rpc/lib/preflight/src/fees.rs index d30497700..20e002b3d 100644 --- a/cmd/soroban-rpc/lib/preflight/src/fees.rs +++ b/cmd/soroban-rpc/lib/preflight/src/fees.rs @@ -2,32 +2,27 @@ use anyhow::{bail, ensure, Context, Error, Result}; use ledger_storage::LedgerStorage; use soroban_env_host::budget::Budget; use soroban_env_host::e2e_invoke::{ - extract_rent_changes, get_ledger_changes, ExpirationEntryMap, LedgerEntryChange, + extract_rent_changes, get_ledger_changes, LedgerEntryChange, TtlEntryMap, }; use soroban_env_host::fees::{ compute_rent_fee, compute_transaction_resource_fee, compute_write_fee_per_1kb, FeeConfiguration, LedgerEntryRentChange, RentFeeConfiguration, TransactionResources, - WriteFeeConfiguration, + WriteFeeConfiguration, TTL_ENTRY_SIZE, }; use soroban_env_host::storage::{AccessType, Footprint, Storage}; use soroban_env_host::xdr; use soroban_env_host::xdr::ContractDataDurability::Persistent; use soroban_env_host::xdr::{ - BumpFootprintExpirationOp, ConfigSettingEntry, ConfigSettingId, ContractEventType, - DecoratedSignature, DiagnosticEvent, ExtensionPoint, InvokeHostFunctionOp, LedgerFootprint, - LedgerKey, Memo, MuxedAccount, MuxedAccountMed25519, Operation, OperationBody, Preconditions, + ConfigSettingEntry, ConfigSettingId, ContractEventType, DecoratedSignature, DiagnosticEvent, + ExtendFootprintTtlOp, ExtensionPoint, InvokeHostFunctionOp, LedgerFootprint, LedgerKey, Memo, + MuxedAccount, MuxedAccountMed25519, Operation, OperationBody, Preconditions, RestoreFootprintOp, ScVal, SequenceNumber, Signature, SignatureHint, SorobanResources, SorobanTransactionData, Transaction, TransactionExt, TransactionV1Envelope, Uint256, WriteXdr, }; -use state_expiration::{get_restored_ledger_sequence, ExpirableLedgerEntry}; +use state_ttl::{get_restored_ledger_sequence, TTLLedgerEntry}; use std::cmp::max; use std::convert::{TryFrom, TryInto}; -// TODO: this should be imported from soroban_env_host::fees instead -/// Serialize XDR size for any `ExpirationEntry` ledger entry. -const EXPIRATION_ENTRY_SIZE: u32 = 48; - -// TODO: this should perhaps be an new type #[allow(clippy::too_many_arguments)] pub(crate) fn compute_host_function_transaction_data_and_min_fee( op: &InvokeHostFunctionOp, @@ -39,8 +34,7 @@ pub(crate) fn compute_host_function_transaction_data_and_min_fee( bucket_list_size: u64, current_ledger_seq: u32, ) -> Result<(SorobanTransactionData, i64)> { - let ledger_changes = - get_ledger_changes(budget, post_storage, pre_storage, ExpirationEntryMap::new())?; + 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) .context("cannot compute host function resources")?; @@ -114,7 +108,7 @@ fn estimate_max_transaction_size_for_operation( read_bytes: 0, write_bytes: 0, }, - refundable_fee: 0, + resource_fee: 0, ext: ExtensionPoint::V0, }), }, @@ -139,12 +133,7 @@ fn calculate_host_function_soroban_resources( .context("cannot convert storage footprint to ledger footprint")?; let read_bytes: u32 = ledger_changes .iter() - .map(|c| { - c.old_entry_size_bytes - + c.expiration_change - .as_ref() - .map_or(0, |_| EXPIRATION_ENTRY_SIZE) - }) + .map(|c| c.old_entry_size_bytes + c.ttl_change.as_ref().map_or(0, |_| TTL_ENTRY_SIZE)) .sum(); let write_bytes: u32 = ledger_changes @@ -200,10 +189,10 @@ fn get_fee_configurations( bail!("unexpected config setting entry for BandwidthV0 key"); }; - let ConfigSettingEntry::StateExpiration(state_expiration) = - ledger_storage.get_configuration_setting(ConfigSettingId::StateExpiration)? + let ConfigSettingEntry::StateArchival(state_archival) = + ledger_storage.get_configuration_setting(ConfigSettingId::StateArchival)? else { - bail!("unexpected config setting entry for StateExpiration key"); + bail!("unexpected config setting entry for StateArchival key"); }; let write_fee_configuration = WriteFeeConfiguration { @@ -229,18 +218,18 @@ fn get_fee_configurations( let rent_fee_configuration = RentFeeConfiguration { fee_per_write_1kb: write_fee_per_1kb, fee_per_write_entry: ledger_cost.fee_write_ledger_entry, - persistent_rent_rate_denominator: state_expiration.persistent_rent_rate_denominator, - temporary_rent_rate_denominator: state_expiration.temp_rent_rate_denominator, + persistent_rent_rate_denominator: state_archival.persistent_rent_rate_denominator, + temporary_rent_rate_denominator: state_archival.temp_rent_rate_denominator, }; Ok((fee_configuration, rent_fee_configuration)) } -// Calculate the implicit ExpirationEntry bytes that will be read for expirable LedgerEntries -fn calculate_expiration_entry_bytes(ledger_entries: &[LedgerKey]) -> u32 { +// Calculate the implicit TTLEntry bytes that will be read for TTLLedgerEntries +fn calculate_ttl_entry_bytes(ledger_entries: &[LedgerKey]) -> u32 { ledger_entries .iter() .map(|lk| match lk { - LedgerKey::ContractData(_) | LedgerKey::ContractCode(_) => EXPIRATION_ENTRY_SIZE, + LedgerKey::ContractData(_) | LedgerKey::ContractCode(_) => TTL_ENTRY_SIZE, _ => 0, }) .sum() @@ -250,12 +239,12 @@ fn calculate_expiration_entry_bytes(ledger_entries: &[LedgerKey]) -> u32 { fn calculate_unmodified_ledger_entry_bytes( ledger_entries: &[LedgerKey], pre_storage: &LedgerStorage, - include_expired: bool, + include_not_live: bool, ) -> Result { let mut res: usize = 0; for lk in ledger_entries { let entry_xdr = pre_storage - .get_xdr(lk, include_expired) + .get_xdr(lk, include_not_live) .with_context(|| format!("cannot get xdr of ledger entry with key {lk:?}"))?; let entry_size = entry_xdr.len(); res += entry_size; @@ -308,34 +297,32 @@ fn finalize_transaction_data_and_min_fee( let (non_refundable_fee, refundable_fee) = compute_transaction_resource_fee(transaction_resources, &fee_configuration); let rent_fee = compute_rent_fee(rent_changes, &rent_fee_configuration, current_ledger_seq); + let resource_fee = refundable_fee + non_refundable_fee + rent_fee; let transaction_data = SorobanTransactionData { resources: soroban_resources, - refundable_fee: refundable_fee + rent_fee, + resource_fee, ext: ExtensionPoint::V0, }; - let res = ( - transaction_data, - refundable_fee + non_refundable_fee + rent_fee, - ); + let res = (transaction_data, resource_fee); Ok(res) } -pub(crate) fn compute_bump_footprint_exp_transaction_data_and_min_fee( +pub(crate) fn compute_extend_footprint_ttl_transaction_data_and_min_fee( footprint: LedgerFootprint, - ledgers_to_expire: u32, + extend_to: u32, ledger_storage: &LedgerStorage, bucket_list_size: u64, current_ledger_seq: u32, ) -> Result<(SorobanTransactionData, i64)> { - let rent_changes = compute_bump_footprint_rent_changes( + let rent_changes = compute_extend_footprint_rent_changes( &footprint, ledger_storage, - ledgers_to_expire, + extend_to, current_ledger_seq, ) - .context("cannot compute bump rent changes")?; + .context("cannot compute extend rent changes")?; - let expiration_bytes = calculate_expiration_entry_bytes(footprint.read_only.as_slice()); + let ttl_bytes: u32 = calculate_ttl_entry_bytes(footprint.read_only.as_vec()); let unmodified_entry_bytes = calculate_unmodified_ledger_entry_bytes( footprint.read_only.as_slice(), @@ -347,13 +334,13 @@ pub(crate) fn compute_bump_footprint_exp_transaction_data_and_min_fee( let soroban_resources = SorobanResources { footprint, instructions: 0, - read_bytes: unmodified_entry_bytes + expiration_bytes, + read_bytes: unmodified_entry_bytes + ttl_bytes, write_bytes: 0, }; let transaction_size_bytes = estimate_max_transaction_size_for_operation( - &OperationBody::BumpFootprintExpiration(BumpFootprintExpirationOp { + &OperationBody::ExtendFootprintTtl(ExtendFootprintTtlOp { ext: ExtensionPoint::V0, - ledgers_to_expire, + extend_to, }), &soroban_resources.footprint, ) @@ -378,35 +365,36 @@ pub(crate) fn compute_bump_footprint_exp_transaction_data_and_min_fee( } #[allow(clippy::cast_possible_truncation)] -fn compute_bump_footprint_rent_changes( +fn compute_extend_footprint_rent_changes( footprint: &LedgerFootprint, ledger_storage: &LedgerStorage, - ledgers_to_expire: u32, + extend_to: u32, current_ledger_seq: u32, ) -> Result> { let mut rent_changes: Vec = Vec::with_capacity(footprint.read_only.len()); for key in footprint.read_only.as_slice() { - let unmodified_entry_and_expiration = ledger_storage - .get(key, false) - .with_context(|| format!("cannot find bump footprint ledger entry with key {key:?}"))?; - let size = (key.to_xdr()?.len() + unmodified_entry_and_expiration.0.to_xdr()?.len()) as u32; - let expirable_entry: Box = (&unmodified_entry_and_expiration) - .try_into() - .map_err(|e: String| { - Error::msg(e.clone()).context("incorrect ledger entry type in footprint") - })?; - let new_expiration_ledger = current_ledger_seq + ledgers_to_expire; - if new_expiration_ledger <= expirable_entry.expiration_ledger_seq() { - // The bump would be ineffective + let unmodified_entry_and_ttl = ledger_storage.get(key, false).with_context(|| { + format!("cannot find extend footprint ledger entry with key {key:?}") + })?; + let size = (key.to_xdr()?.len() + unmodified_entry_and_ttl.0.to_xdr()?.len()) as u32; + let ttl_entry: Box = + (&unmodified_entry_and_ttl) + .try_into() + .map_err(|e: String| { + Error::msg(e.clone()).context("incorrect ledger entry type in footprint") + })?; + let new_live_until_ledger = current_ledger_seq + extend_to; + if new_live_until_ledger <= ttl_entry.live_until_ledger_seq() { + // The extend would be ineffective continue; } let rent_change = LedgerEntryRentChange { - is_persistent: expirable_entry.durability() == Persistent, + is_persistent: ttl_entry.durability() == Persistent, old_size_bytes: size, new_size_bytes: size, - old_expiration_ledger: expirable_entry.expiration_ledger_seq(), - new_expiration_ledger, + old_live_until_ledger: ttl_entry.live_until_ledger_seq(), + new_live_until_ledger, }; rent_changes.push(rent_change); } @@ -419,20 +407,20 @@ pub(crate) fn compute_restore_footprint_transaction_data_and_min_fee( bucket_list_size: u64, current_ledger_seq: u32, ) -> Result<(SorobanTransactionData, i64)> { - let ConfigSettingEntry::StateExpiration(state_expiration) = - ledger_storage.get_configuration_setting(ConfigSettingId::StateExpiration)? + let ConfigSettingEntry::StateArchival(state_archival) = + ledger_storage.get_configuration_setting(ConfigSettingId::StateArchival)? else { - bail!("unexpected config setting entry for StateExpiration key"); + bail!("unexpected config setting entry for StateArchival key"); }; let rent_changes = compute_restore_footprint_rent_changes( &footprint, ledger_storage, - state_expiration.min_persistent_entry_expiration, + state_archival.min_persistent_ttl, current_ledger_seq, ) .context("cannot compute restore rent changes")?; - let expiration_bytes = calculate_expiration_entry_bytes(footprint.read_write.as_vec()); + let ttl_bytes: u32 = calculate_ttl_entry_bytes(footprint.read_write.as_vec()); let write_bytes = calculate_unmodified_ledger_entry_bytes( footprint.read_write.as_vec(), ledger_storage, @@ -442,7 +430,7 @@ pub(crate) fn compute_restore_footprint_transaction_data_and_min_fee( let soroban_resources = SorobanResources { footprint, instructions: 0, - read_bytes: write_bytes + expiration_bytes, + read_bytes: write_bytes + ttl_bytes, write_bytes, }; let transaction_size_bytes = estimate_max_transaction_size_for_operation( @@ -475,37 +463,38 @@ pub(crate) fn compute_restore_footprint_transaction_data_and_min_fee( fn compute_restore_footprint_rent_changes( footprint: &LedgerFootprint, ledger_storage: &LedgerStorage, - min_persistent_entry_expiration: u32, + min_persistent_ttl: u32, current_ledger_seq: u32, ) -> Result> { let mut rent_changes: Vec = Vec::with_capacity(footprint.read_write.len()); for key in footprint.read_write.as_vec() { - let unmodified_entry_and_expiration = ledger_storage.get(key, true).with_context(|| { + let unmodified_entry_and_ttl = ledger_storage.get(key, true).with_context(|| { format!("cannot find restore footprint ledger entry with key {key:?}") })?; - let size = (key.to_xdr()?.len() + unmodified_entry_and_expiration.0.to_xdr()?.len()) as u32; - let expirable_entry: Box = (&unmodified_entry_and_expiration) - .try_into() - .map_err(|e: String| { - Error::msg(e.clone()).context("incorrect ledger entry type in footprint") - })?; + let size = (key.to_xdr()?.len() + unmodified_entry_and_ttl.0.to_xdr()?.len()) as u32; + let ttl_entry: Box = + (&unmodified_entry_and_ttl) + .try_into() + .map_err(|e: String| { + Error::msg(e.clone()).context("incorrect ledger entry type in footprint") + })?; ensure!( - expirable_entry.durability() == Persistent, + ttl_entry.durability() == Persistent, "non-persistent entry in footprint: key = {key:?}" ); - if !expirable_entry.has_expired(current_ledger_seq) { - // noop (the entry hadn't expired) + if ttl_entry.is_live(current_ledger_seq) { + // noop (the entry is alive) continue; } - let new_expiration_ledger = - get_restored_ledger_sequence(current_ledger_seq, min_persistent_entry_expiration); + let new_live_until_ledger = + get_restored_ledger_sequence(current_ledger_seq, min_persistent_ttl); let rent_change = LedgerEntryRentChange { is_persistent: true, old_size_bytes: 0, new_size_bytes: size, - old_expiration_ledger: 0, - new_expiration_ledger, + old_live_until_ledger: 0, + new_live_until_ledger, }; rent_changes.push(rent_change); } diff --git a/cmd/soroban-rpc/lib/preflight/src/ledger_storage.rs b/cmd/soroban-rpc/lib/preflight/src/ledger_storage.rs index 4eac57269..3581e6956 100644 --- a/cmd/soroban-rpc/lib/preflight/src/ledger_storage.rs +++ b/cmd/soroban-rpc/lib/preflight/src/ledger_storage.rs @@ -2,12 +2,12 @@ use sha2::Digest; use soroban_env_host::storage::SnapshotSource; use soroban_env_host::xdr::ContractDataDurability::{Persistent, Temporary}; use soroban_env_host::xdr::{ - ConfigSettingEntry, ConfigSettingId, Error as XdrError, ExpirationEntry, Hash, LedgerEntry, - LedgerEntryData, LedgerKey, LedgerKeyConfigSetting, LedgerKeyExpiration, ReadXdr, ScError, - ScErrorCode, WriteXdr, + ConfigSettingEntry, ConfigSettingId, Error as XdrError, Hash, LedgerEntry, LedgerEntryData, + LedgerKey, LedgerKeyConfigSetting, LedgerKeyTtl, ReadXdr, ScError, ScErrorCode, TtlEntry, + WriteXdr, }; use soroban_env_host::HostError; -use state_expiration::{get_restored_ledger_sequence, has_expired, ExpirableLedgerEntry}; +use state_ttl::{get_restored_ledger_sequence, is_live, TTLLedgerEntry}; use std::cell::RefCell; use std::collections::HashSet; use std::convert::TryInto; @@ -28,8 +28,8 @@ extern "C" { pub(crate) enum Error { #[error("not found")] NotFound, - #[error("entry expired")] - EntryExpired, + #[error("entry is not live")] + NotLive, #[error("xdr processing error: {0}")] Xdr(#[from] XdrError), #[error("nul error: {0}")] @@ -38,16 +38,14 @@ pub(crate) enum Error { Utf8Error(#[from] Utf8Error), #[error("unexpected config ledger entry for setting_id {setting_id}")] UnexpectedConfigLedgerEntry { setting_id: String }, - #[error("unexpected ledger entry type ({ledger_entry_type}) for expiration ledger key")] - UnexpectedLedgerEntryTypeForExpirationKey { ledger_entry_type: String }, + #[error("unexpected ledger entry type ({ledger_entry_type}) for ttl ledger key")] + UnexpectedLedgerEntryTypeForTtlKey { ledger_entry_type: String }, } impl From for HostError { fn from(value: Error) -> Self { match value { - Error::NotFound | Error::EntryExpired => { - ScError::Storage(ScErrorCode::MissingValue).into() - } + Error::NotFound | Error::NotLive => ScError::Storage(ScErrorCode::MissingValue).into(), Error::Xdr(_) => ScError::Value(ScErrorCode::InvalidInput).into(), _ => ScError::Context(ScErrorCode::InternalError).into(), } @@ -55,39 +53,37 @@ impl From for HostError { } struct EntryRestoreTracker { - min_persistent_entry_expiration: u32, + min_persistent_ttl: u32, // RefCell is needed to mutate the hashset inside SnapshotSource::get(), which is an immutable method ledger_keys_requiring_restore: RefCell>, } impl EntryRestoreTracker { - // Tracks ledger entries which need to be restored and returns its expiration as it was restored + // Tracks ledger entries which need to be restored and returns its ttl as it was restored pub(crate) fn track_and_restore( &self, current_ledger_sequence: u32, key: &LedgerKey, - entry_and_expiration: &(LedgerEntry, Option), + entry_and_ttl: &(LedgerEntry, Option), ) -> Option { - let expirable_entry: Box = match entry_and_expiration.try_into() { + let ttl_entry: Box = match entry_and_ttl.try_into() { Ok(e) => e, Err(_) => { - // Nothing to track, the entry isn't expirable + // Nothing to track, the entry does not have a ttl return None; } }; - if expirable_entry.durability() != Persistent - || !expirable_entry.has_expired(current_ledger_sequence) - { + if ttl_entry.durability() != Persistent || ttl_entry.is_live(current_ledger_sequence) { // Nothing to track, the entry isn't persistent (and thus not restorable) or - // it hasn't expired - return Some(expirable_entry.expiration_ledger_seq()); + // it is alive + return Some(ttl_entry.live_until_ledger_seq()); } self.ledger_keys_requiring_restore .borrow_mut() .insert(key.clone()); Some(get_restored_ledger_sequence( current_ledger_sequence, - self.min_persistent_entry_expiration, + self.min_persistent_ttl, )) } } @@ -117,23 +113,23 @@ impl LedgerStorage { current_ledger_sequence, restore_tracker: None, }; - let setting_id = ConfigSettingId::StateExpiration; - let ConfigSettingEntry::StateExpiration(state_expiration) = + let setting_id = ConfigSettingId::StateArchival; + let ConfigSettingEntry::StateArchival(state_archival) = ledger_storage.get_configuration_setting(setting_id)? else { return Err(Error::UnexpectedConfigLedgerEntry { setting_id: setting_id.name().to_string(), }); }; - // Now that we have the state expiration config, we can build the tracker + // Now that we have the state archival config, we can build the tracker ledger_storage.restore_tracker = Some(EntryRestoreTracker { ledger_keys_requiring_restore: RefCell::new(HashSet::new()), - min_persistent_entry_expiration: state_expiration.min_persistent_entry_expiration, + min_persistent_ttl: state_archival.min_persistent_ttl, }); Ok(ledger_storage) } - // Get the XDR, regardless of expiration + // Get the XDR, regardless of ttl fn get_xdr_internal(&self, key_xdr: &mut Vec) -> Result, Error> { let key_c_xdr = CXDR { xdr: key_xdr.as_mut_ptr(), @@ -151,52 +147,56 @@ impl LedgerStorage { pub(crate) fn get( &self, key: &LedgerKey, - include_expired: bool, + include_not_live: bool, ) -> Result<(LedgerEntry, Option), Error> { let mut key_xdr = key.to_xdr()?; let xdr = self.get_xdr_internal(&mut key_xdr)?; - let expiration_seq = match key { + let live_until_ledger_seq = match key { // TODO: it would probably be more efficient to do all of this in the Go side // (e.g. it would allow us to query multiple entries at once) LedgerKey::ContractData(_) | LedgerKey::ContractCode(_) => { let key_hash: [u8; 32] = sha2::Sha256::digest(key_xdr).into(); - let expiration_key = LedgerKey::Expiration(LedgerKeyExpiration { + let ttl_key = LedgerKey::Ttl(LedgerKeyTtl { key_hash: Hash(key_hash), }); - let mut expiration_key_xdr = expiration_key.to_xdr()?; - let expiration_entry_xdr = self.get_xdr_internal(&mut expiration_key_xdr)?; - let expiration_entry = LedgerEntry::from_xdr(expiration_entry_xdr)?; - if let LedgerEntryData::Expiration(ExpirationEntry { - expiration_ledger_seq, + let mut ttl_key_xdr = ttl_key.to_xdr()?; + let ttl_entry_xdr = self.get_xdr_internal(&mut ttl_key_xdr)?; + let ttl_entry = LedgerEntry::from_xdr(ttl_entry_xdr)?; + if let LedgerEntryData::Ttl(TtlEntry { + live_until_ledger_seq, .. - }) = expiration_entry.data + }) = ttl_entry.data { - Some(expiration_ledger_seq) + Some(live_until_ledger_seq) } else { - return Err(Error::UnexpectedLedgerEntryTypeForExpirationKey { - ledger_entry_type: expiration_entry.data.name().to_string(), + return Err(Error::UnexpectedLedgerEntryTypeForTtlKey { + ledger_entry_type: ttl_entry.data.name().to_string(), }); } } _ => None, }; - if !include_expired - && expiration_seq.is_some() - && has_expired(expiration_seq.unwrap(), self.current_ledger_sequence) + if !include_not_live + && live_until_ledger_seq.is_some() + && !is_live(live_until_ledger_seq.unwrap(), self.current_ledger_sequence) { - return Err(Error::EntryExpired); + return Err(Error::NotLive); } let entry = LedgerEntry::from_xdr(xdr)?; - Ok((entry, expiration_seq)) + Ok((entry, live_until_ledger_seq)) } - pub(crate) fn get_xdr(&self, key: &LedgerKey, include_expired: bool) -> Result, Error> { + pub(crate) fn get_xdr( + &self, + key: &LedgerKey, + include_not_live: bool, + ) -> Result, Error> { // TODO: this can be optimized since for entry types other than ContractCode/ContractData, // they don't need to be deserialized and serialized again - let (entry, _) = self.get(key, include_expired)?; + let (entry, _) = self.get(key, include_not_live)?; Ok(entry.to_xdr()?) } @@ -232,25 +232,22 @@ impl LedgerStorage { impl SnapshotSource for LedgerStorage { fn get(&self, key: &Rc) -> Result<(Rc, Option), HostError> { if let Some(ref tracker) = self.restore_tracker { - let mut entry_and_expiration = self.get(key, true)?; - // Explicitly discard temporary expired entries - if let Ok(expirable_entry) = - TryInto::>::try_into(&entry_and_expiration) - { - if expirable_entry.durability() == Temporary - && expirable_entry.has_expired(self.current_ledger_sequence) + let mut entry_and_ttl = self.get(key, true)?; + // Explicitly discard temporary ttl'ed entries + if let Ok(ttl_entry) = TryInto::>::try_into(&entry_and_ttl) { + if ttl_entry.durability() == Temporary + && !ttl_entry.is_live(self.current_ledger_sequence) { - return Err(HostError::from(Error::EntryExpired)); + return Err(HostError::from(Error::NotLive)); } } - // If the entry expired, we modify the expiration to make it seem like it was restored - entry_and_expiration.1 = - tracker.track_and_restore(self.current_ledger_sequence, key, &entry_and_expiration); - return Ok((entry_and_expiration.0.into(), entry_and_expiration.1)); + // If the entry is not live, we modify the ttl to make it seem like it was restored + entry_and_ttl.1 = + tracker.track_and_restore(self.current_ledger_sequence, key, &entry_and_ttl); + return Ok((entry_and_ttl.0.into(), entry_and_ttl.1)); } - let entry_and_expiration = - ::get(self, key, false).map_err(HostError::from)?; - Ok((entry_and_expiration.0.into(), entry_and_expiration.1)) + let entry_and_ttl = ::get(self, key, false).map_err(HostError::from)?; + Ok((entry_and_ttl.0.into(), entry_and_ttl.1)) } fn has(&self, key: &Rc) -> Result { diff --git a/cmd/soroban-rpc/lib/preflight/src/lib.rs b/cmd/soroban-rpc/lib/preflight/src/lib.rs index f2f98f287..8f3a86431 100644 --- a/cmd/soroban-rpc/lib/preflight/src/lib.rs +++ b/cmd/soroban-rpc/lib/preflight/src/lib.rs @@ -1,7 +1,7 @@ mod fees; mod ledger_storage; mod preflight; -mod state_expiration; +mod state_ttl; extern crate anyhow; extern crate base64; @@ -30,9 +30,9 @@ pub struct CLedgerInfo { pub timestamp: u64, pub network_passphrase: *const libc::c_char, pub base_reserve: u32, - pub min_temp_entry_expiration: u32, - pub min_persistent_entry_expiration: u32, - pub max_entry_expiration: u32, + pub min_temp_entry_ttl: u32, + pub min_persistent_entry_ttl: u32, + pub max_entry_ttl: u32, } impl From for LedgerInfo { @@ -44,9 +44,9 @@ impl From for LedgerInfo { timestamp: c.timestamp, network_id: Sha256::digest(network_passphrase).into(), base_reserve: c.base_reserve, - min_temp_entry_expiration: c.min_temp_entry_expiration, - min_persistent_entry_expiration: c.min_persistent_entry_expiration, - max_entry_expiration: c.max_entry_expiration, + min_temp_entry_ttl: c.min_temp_entry_ttl, + min_persistent_entry_ttl: c.min_persistent_entry_ttl, + max_entry_ttl: c.max_entry_ttl, } } } @@ -171,7 +171,7 @@ fn preflight_invoke_hf_op_or_maybe_panic( } #[no_mangle] -pub extern "C" fn preflight_footprint_expiration_op( +pub extern "C" fn preflight_footprint_ttl_op( handle: libc::uintptr_t, // Go Handle to forward to SnapshotSourceGet and SnapshotSourceHas bucket_list_size: u64, // Bucket list size for current ledger op_body: CXDR, // OperationBody XDR @@ -179,7 +179,7 @@ pub extern "C" fn preflight_footprint_expiration_op( current_ledger_seq: u32, ) -> *mut CPreflightResult { catch_preflight_panic(Box::new(move || { - preflight_footprint_expiration_op_or_maybe_panic( + preflight_footprint_ttl_op_or_maybe_panic( handle, bucket_list_size, op_body, @@ -189,7 +189,7 @@ pub extern "C" fn preflight_footprint_expiration_op( })) } -fn preflight_footprint_expiration_op_or_maybe_panic( +fn preflight_footprint_ttl_op_or_maybe_panic( handle: libc::uintptr_t, bucket_list_size: u64, op_body: CXDR, @@ -199,7 +199,7 @@ fn preflight_footprint_expiration_op_or_maybe_panic( let op_body = OperationBody::from_xdr(from_c_xdr(op_body)).unwrap(); let footprint = LedgerFootprint::from_xdr(from_c_xdr(footprint)).unwrap(); let ledger_storage = &LedgerStorage::new(handle, current_ledger_seq); - let result = preflight::preflight_footprint_expiration_op( + let result = preflight::preflight_footprint_ttl_op( ledger_storage, bucket_list_size, op_body, diff --git a/cmd/soroban-rpc/lib/preflight/src/preflight.rs b/cmd/soroban-rpc/lib/preflight/src/preflight.rs index 35b024884..a818b7dd2 100644 --- a/cmd/soroban-rpc/lib/preflight/src/preflight.rs +++ b/cmd/soroban-rpc/lib/preflight/src/preflight.rs @@ -241,7 +241,7 @@ fn get_budget_from_network_config_params(ledger_storage: &LedgerStorage) -> Resu Ok(budget) } -pub(crate) fn preflight_footprint_expiration_op( +pub(crate) fn preflight_footprint_ttl_op( ledger_storage: &LedgerStorage, bucket_list_size: u64, op_body: OperationBody, @@ -249,9 +249,9 @@ pub(crate) fn preflight_footprint_expiration_op( current_ledger_seq: u32, ) -> Result { match op_body { - OperationBody::BumpFootprintExpiration(op) => preflight_bump_footprint_expiration( + OperationBody::ExtendFootprintTtl(op) => preflight_extend_footprint_ttl( footprint, - op.ledgers_to_expire, + op.extend_to, ledger_storage, bucket_list_size, current_ledger_seq, @@ -263,23 +263,23 @@ pub(crate) fn preflight_footprint_expiration_op( current_ledger_seq, ), op => Err(anyhow!( - "preflight_footprint_expiration_op(): unsupported operation type {}", + "preflight_footprint_ttl_op(): unsupported operation type {}", op.name() )), } } -fn preflight_bump_footprint_expiration( +fn preflight_extend_footprint_ttl( footprint: LedgerFootprint, - ledgers_to_expire: u32, + extend_to: u32, ledger_storage: &LedgerStorage, bucket_list_size: u64, current_ledger_seq: u32, ) -> Result { let (transaction_data, min_fee) = - fees::compute_bump_footprint_exp_transaction_data_and_min_fee( + fees::compute_extend_footprint_ttl_transaction_data_and_min_fee( footprint, - ledgers_to_expire, + extend_to, ledger_storage, bucket_list_size, current_ledger_seq, diff --git a/cmd/soroban-rpc/lib/preflight/src/state_expiration.rs b/cmd/soroban-rpc/lib/preflight/src/state_expiration.rs deleted file mode 100644 index c5a485f1f..000000000 --- a/cmd/soroban-rpc/lib/preflight/src/state_expiration.rs +++ /dev/null @@ -1,70 +0,0 @@ -use soroban_env_host::xdr::ContractDataDurability::Persistent; -use soroban_env_host::xdr::{ - ContractCodeEntry, ContractDataDurability, ContractDataEntry, LedgerEntry, LedgerEntryData, -}; -use std::convert::TryInto; - -pub(crate) trait ExpirableLedgerEntry { - fn durability(&self) -> ContractDataDurability; - fn expiration_ledger_seq(&self) -> u32; - fn has_expired(&self, current_ledger_seq: u32) -> bool { - has_expired(self.expiration_ledger_seq(), current_ledger_seq) - } -} - -impl ExpirableLedgerEntry for (&ContractCodeEntry, u32) { - fn durability(&self) -> ContractDataDurability { - Persistent - } - - fn expiration_ledger_seq(&self) -> u32 { - self.1 - } -} - -impl ExpirableLedgerEntry for (&ContractDataEntry, u32) { - fn durability(&self) -> ContractDataDurability { - self.0.durability - } - - fn expiration_ledger_seq(&self) -> u32 { - self.1 - } -} - -// Convert a ledger entry and its expiration into an ExpirableLedgerEntry -impl<'a> TryInto> for &'a (LedgerEntry, Option) { - type Error = String; - - fn try_into(self) -> Result, Self::Error> { - match (&self.0.data, self.1) { - (LedgerEntryData::ContractData(d), Some(expiration_seq)) => { - Ok(Box::new((d, expiration_seq))) - } - (LedgerEntryData::ContractCode(c), Some(expiration_seq)) => { - Ok(Box::new((c, expiration_seq))) - } - (LedgerEntryData::ContractData(_) | LedgerEntryData::ContractCode(_), _) => { - Err(format!( - "missing expiration for expirable ledger entry ({})", - self.0.data.name() - )) - } - _ => Err(format!( - "ledger entry type ({}) is not expirable", - self.0.data.name() - )), - } - } -} - -pub(crate) fn has_expired(expiration_ledger_seq: u32, current_ledger_seq: u32) -> bool { - current_ledger_seq > expiration_ledger_seq -} - -pub(crate) fn get_restored_ledger_sequence( - current_ledger_seq: u32, - min_persistent_entry_expiration: u32, -) -> u32 { - current_ledger_seq + min_persistent_entry_expiration - 1 -} diff --git a/cmd/soroban-rpc/lib/preflight/src/state_ttl.rs b/cmd/soroban-rpc/lib/preflight/src/state_ttl.rs new file mode 100644 index 000000000..5373177c9 --- /dev/null +++ b/cmd/soroban-rpc/lib/preflight/src/state_ttl.rs @@ -0,0 +1,67 @@ +use soroban_env_host::xdr::ContractDataDurability::Persistent; +use soroban_env_host::xdr::{ + ContractCodeEntry, ContractDataDurability, ContractDataEntry, LedgerEntry, LedgerEntryData, +}; +use std::convert::TryInto; + +pub(crate) trait TTLLedgerEntry { + fn durability(&self) -> ContractDataDurability; + fn live_until_ledger_seq(&self) -> u32; + fn is_live(&self, current_ledger_seq: u32) -> bool { + is_live(self.live_until_ledger_seq(), current_ledger_seq) + } +} + +impl TTLLedgerEntry for (&ContractCodeEntry, u32) { + fn durability(&self) -> ContractDataDurability { + Persistent + } + + fn live_until_ledger_seq(&self) -> u32 { + self.1 + } +} + +impl TTLLedgerEntry for (&ContractDataEntry, u32) { + fn durability(&self) -> ContractDataDurability { + self.0.durability + } + + fn live_until_ledger_seq(&self) -> u32 { + self.1 + } +} + +// Convert a ledger entry and its Time to live (i.e. live_until_seq) into a TTLLedgerEntry +impl<'a> TryInto> for &'a (LedgerEntry, Option) { + type Error = String; + + fn try_into(self) -> Result, Self::Error> { + match (&self.0.data, self.1) { + (LedgerEntryData::ContractData(d), Some(live_until_seq)) => { + Ok(Box::new((d, live_until_seq))) + } + (LedgerEntryData::ContractCode(c), Some(live_until_seq)) => { + Ok(Box::new((c, live_until_seq))) + } + (LedgerEntryData::ContractData(_) | LedgerEntryData::ContractCode(_), _) => Err( + format!("missing ttl for ledger entry ({})", self.0.data.name()), + ), + _ => Err(format!( + "ledger entry type ({}) cannot have a TTL", + self.0.data.name() + )), + } + } +} + +pub(crate) fn is_live(live_until_ledger_seq: u32, current_ledger_seq: u32) -> bool { + live_until_ledger_seq >= current_ledger_seq +} + +pub(crate) fn get_restored_ledger_sequence( + current_ledger_seq: u32, + min_persistent_ttl: u32, +) -> u32 { + current_ledger_seq + min_persistent_ttl - 1 +} diff --git a/docs/soroban-cli-full-docs.md b/docs/soroban-cli-full-docs.md index e47682473..30ffbe4b7 100644 --- a/docs/soroban-cli-full-docs.md +++ b/docs/soroban-cli-full-docs.md @@ -12,7 +12,7 @@ This document contains the help content for the `soroban` command-line program. * [`soroban contract bindings rust`↴](#soroban-contract-bindings-rust) * [`soroban contract bindings typescript`↴](#soroban-contract-bindings-typescript) * [`soroban contract build`↴](#soroban-contract-build) -* [`soroban contract bump`↴](#soroban-contract-bump) +* [`soroban contract extend`↴](#soroban-contract-extend) * [`soroban contract deploy`↴](#soroban-contract-deploy) * [`soroban contract fetch`↴](#soroban-contract-fetch) * [`soroban contract inspect`↴](#soroban-contract-inspect) @@ -127,7 +127,7 @@ Tools for smart contract developers * `bindings` — Generate code client bindings for a contract * `build` — Build a contract from source -* `bump` — Extend the expiry ledger of a contract-data ledger entry +* `extend` — Extend the expiry ledger of a contract-data ledger entry * `deploy` — Deploy a contract * `fetch` — Fetch a contract's Wasm binary * `inspect` — Inspect a WASM file listing contract functions, meta, etc @@ -224,23 +224,23 @@ To view the commands that will be executed, without executing them, use the --pr -## `soroban contract bump` +## `soroban contract extend` Extend the expiry ledger of a contract-data ledger entry. -If no keys are specified the contract itself is bumped. +If no keys are specified the contract itself is extended. -**Usage:** `soroban contract bump [OPTIONS] --ledgers-to-expire --durability ` +**Usage:** `soroban contract extend [OPTIONS] --ledgers-to-extend --durability ` ###### **Options:** -* `--ledgers-to-expire ` — Number of ledgers to extend the entries -* `--expiration-ledger-only` — Only print the new expiration ledger -* `--id ` — Contract ID to which owns the data entries. If no keys provided the Contract's instance will be bumped +* `--ledgers-to-extend ` — Number of ledgers to extend the entries +* `--extension-ledger-only` — Only print the new TTL ledger +* `--id ` — Contract ID to which owns the data entries. If no keys provided the Contract's instance will be extended * `--key ` — Storage key (symbols only) * `--key-xdr ` — Storage key (base64-encoded XDR) -* `--wasm ` — Path to Wasm file of contract code to bump -* `--wasm-hash ` — Path to Wasm file of contract code to bump +* `--wasm ` — Path to Wasm file of contract code to extend +* `--wasm-hash ` — Path to Wasm file of contract code to extend * `--durability ` — Storage entry durability Possible values: @@ -416,11 +416,11 @@ Print the current value of a contract-data ledger entry - `xdr`: XDR -* `--id ` — Contract ID to which owns the data entries. If no keys provided the Contract's instance will be bumped +* `--id ` — Contract ID to which owns the data entries. If no keys provided the Contract's instance will be extended * `--key ` — Storage key (symbols only) * `--key-xdr ` — Storage key (base64-encoded XDR) -* `--wasm ` — Path to Wasm file of contract code to bump -* `--wasm-hash ` — Path to Wasm file of contract code to bump +* `--wasm ` — Path to Wasm file of contract code to extend +* `--wasm-hash ` — Path to Wasm file of contract code to extend * `--durability ` — Storage entry durability Possible values: @@ -449,11 +449,11 @@ If no keys are specificed the contract itself is restored. ###### **Options:** -* `--id ` — Contract ID to which owns the data entries. If no keys provided the Contract's instance will be bumped +* `--id ` — Contract ID to which owns the data entries. If no keys provided the Contract's instance will be extended * `--key ` — Storage key (symbols only) * `--key-xdr ` — Storage key (base64-encoded XDR) -* `--wasm ` — Path to Wasm file of contract code to bump -* `--wasm-hash ` — Path to Wasm file of contract code to bump +* `--wasm ` — Path to Wasm file of contract code to extend +* `--wasm-hash ` — Path to Wasm file of contract code to extend * `--durability ` — Storage entry durability Possible values: @@ -462,7 +462,7 @@ If no keys are specificed the contract itself is restored. - `temporary`: Temporary -* `--ledgers-to-expire ` — Number of ledgers to extend the entry +* `--ledgers-to-extend ` — Number of ledgers to extend the entry * `--rpc-url ` — RPC server endpoint * `--network-passphrase ` — Network passphrase to sign the transaction sent to the rpc server * `--network ` — Name of network to use from config @@ -831,7 +831,7 @@ Decode XDR * `--type ` — XDR type to decode to - Possible values: `Value`, `ScpBallot`, `ScpStatementType`, `ScpNomination`, `ScpStatement`, `ScpStatementPledges`, `ScpStatementPrepare`, `ScpStatementConfirm`, `ScpStatementExternalize`, `ScpEnvelope`, `ScpQuorumSet`, `ConfigSettingContractExecutionLanesV0`, `ConfigSettingContractComputeV0`, `ConfigSettingContractLedgerCostV0`, `ConfigSettingContractHistoricalDataV0`, `ConfigSettingContractEventsV0`, `ConfigSettingContractBandwidthV0`, `ContractCostType`, `ContractCostParamEntry`, `StateExpirationSettings`, `EvictionIterator`, `ContractCostParams`, `ConfigSettingId`, `ConfigSettingEntry`, `ScEnvMetaKind`, `ScEnvMetaEntry`, `ScMetaV0`, `ScMetaKind`, `ScMetaEntry`, `ScSpecType`, `ScSpecTypeOption`, `ScSpecTypeResult`, `ScSpecTypeVec`, `ScSpecTypeMap`, `ScSpecTypeTuple`, `ScSpecTypeBytesN`, `ScSpecTypeUdt`, `ScSpecTypeDef`, `ScSpecUdtStructFieldV0`, `ScSpecUdtStructV0`, `ScSpecUdtUnionCaseVoidV0`, `ScSpecUdtUnionCaseTupleV0`, `ScSpecUdtUnionCaseV0Kind`, `ScSpecUdtUnionCaseV0`, `ScSpecUdtUnionV0`, `ScSpecUdtEnumCaseV0`, `ScSpecUdtEnumV0`, `ScSpecUdtErrorEnumCaseV0`, `ScSpecUdtErrorEnumV0`, `ScSpecFunctionInputV0`, `ScSpecFunctionV0`, `ScSpecEntryKind`, `ScSpecEntry`, `ScValType`, `ScErrorType`, `ScErrorCode`, `ScError`, `UInt128Parts`, `Int128Parts`, `UInt256Parts`, `Int256Parts`, `ContractExecutableType`, `ContractExecutable`, `ScAddressType`, `ScAddress`, `ScVec`, `ScMap`, `ScBytes`, `ScString`, `ScSymbol`, `ScNonceKey`, `ScContractInstance`, `ScVal`, `ScMapEntry`, `StoredTransactionSet`, `PersistedScpStateV0`, `PersistedScpStateV1`, `PersistedScpState`, `Thresholds`, `String32`, `String64`, `SequenceNumber`, `DataValue`, `PoolId`, `AssetCode4`, `AssetCode12`, `AssetType`, `AssetCode`, `AlphaNum4`, `AlphaNum12`, `Asset`, `Price`, `Liabilities`, `ThresholdIndexes`, `LedgerEntryType`, `Signer`, `AccountFlags`, `SponsorshipDescriptor`, `AccountEntryExtensionV3`, `AccountEntryExtensionV2`, `AccountEntryExtensionV2Ext`, `AccountEntryExtensionV1`, `AccountEntryExtensionV1Ext`, `AccountEntry`, `AccountEntryExt`, `TrustLineFlags`, `LiquidityPoolType`, `TrustLineAsset`, `TrustLineEntryExtensionV2`, `TrustLineEntryExtensionV2Ext`, `TrustLineEntry`, `TrustLineEntryExt`, `TrustLineEntryV1`, `TrustLineEntryV1Ext`, `OfferEntryFlags`, `OfferEntry`, `OfferEntryExt`, `DataEntry`, `DataEntryExt`, `ClaimPredicateType`, `ClaimPredicate`, `ClaimantType`, `Claimant`, `ClaimantV0`, `ClaimableBalanceIdType`, `ClaimableBalanceId`, `ClaimableBalanceFlags`, `ClaimableBalanceEntryExtensionV1`, `ClaimableBalanceEntryExtensionV1Ext`, `ClaimableBalanceEntry`, `ClaimableBalanceEntryExt`, `LiquidityPoolConstantProductParameters`, `LiquidityPoolEntry`, `LiquidityPoolEntryBody`, `LiquidityPoolEntryConstantProduct`, `ContractDataDurability`, `ContractDataEntry`, `ContractCodeEntry`, `ExpirationEntry`, `LedgerEntryExtensionV1`, `LedgerEntryExtensionV1Ext`, `LedgerEntry`, `LedgerEntryData`, `LedgerEntryExt`, `LedgerKey`, `LedgerKeyAccount`, `LedgerKeyTrustLine`, `LedgerKeyOffer`, `LedgerKeyData`, `LedgerKeyClaimableBalance`, `LedgerKeyLiquidityPool`, `LedgerKeyContractData`, `LedgerKeyContractCode`, `LedgerKeyConfigSetting`, `LedgerKeyExpiration`, `EnvelopeType`, `UpgradeType`, `StellarValueType`, `LedgerCloseValueSignature`, `StellarValue`, `StellarValueExt`, `LedgerHeaderFlags`, `LedgerHeaderExtensionV1`, `LedgerHeaderExtensionV1Ext`, `LedgerHeader`, `LedgerHeaderExt`, `LedgerUpgradeType`, `ConfigUpgradeSetKey`, `LedgerUpgrade`, `ConfigUpgradeSet`, `BucketEntryType`, `BucketMetadata`, `BucketMetadataExt`, `BucketEntry`, `TxSetComponentType`, `TxSetComponent`, `TxSetComponentTxsMaybeDiscountedFee`, `TransactionPhase`, `TransactionSet`, `TransactionSetV1`, `GeneralizedTransactionSet`, `TransactionResultPair`, `TransactionResultSet`, `TransactionHistoryEntry`, `TransactionHistoryEntryExt`, `TransactionHistoryResultEntry`, `TransactionHistoryResultEntryExt`, `LedgerHeaderHistoryEntry`, `LedgerHeaderHistoryEntryExt`, `LedgerScpMessages`, `ScpHistoryEntryV0`, `ScpHistoryEntry`, `LedgerEntryChangeType`, `LedgerEntryChange`, `LedgerEntryChanges`, `OperationMeta`, `TransactionMetaV1`, `TransactionMetaV2`, `ContractEventType`, `ContractEvent`, `ContractEventBody`, `ContractEventV0`, `DiagnosticEvent`, `SorobanTransactionMeta`, `TransactionMetaV3`, `InvokeHostFunctionSuccessPreImage`, `TransactionMeta`, `TransactionResultMeta`, `UpgradeEntryMeta`, `LedgerCloseMetaV0`, `LedgerCloseMetaV1`, `LedgerCloseMetaV2`, `LedgerCloseMeta`, `ErrorCode`, `SError`, `SendMore`, `SendMoreExtended`, `AuthCert`, `Hello`, `Auth`, `IpAddrType`, `PeerAddress`, `PeerAddressIp`, `MessageType`, `DontHave`, `SurveyMessageCommandType`, `SurveyMessageResponseType`, `SurveyRequestMessage`, `SignedSurveyRequestMessage`, `EncryptedBody`, `SurveyResponseMessage`, `SignedSurveyResponseMessage`, `PeerStats`, `PeerStatList`, `TopologyResponseBodyV0`, `TopologyResponseBodyV1`, `SurveyResponseBody`, `TxAdvertVector`, `FloodAdvert`, `TxDemandVector`, `FloodDemand`, `StellarMessage`, `AuthenticatedMessage`, `AuthenticatedMessageV0`, `LiquidityPoolParameters`, `MuxedAccount`, `MuxedAccountMed25519`, `DecoratedSignature`, `OperationType`, `CreateAccountOp`, `PaymentOp`, `PathPaymentStrictReceiveOp`, `PathPaymentStrictSendOp`, `ManageSellOfferOp`, `ManageBuyOfferOp`, `CreatePassiveSellOfferOp`, `SetOptionsOp`, `ChangeTrustAsset`, `ChangeTrustOp`, `AllowTrustOp`, `ManageDataOp`, `BumpSequenceOp`, `CreateClaimableBalanceOp`, `ClaimClaimableBalanceOp`, `BeginSponsoringFutureReservesOp`, `RevokeSponsorshipType`, `RevokeSponsorshipOp`, `RevokeSponsorshipOpSigner`, `ClawbackOp`, `ClawbackClaimableBalanceOp`, `SetTrustLineFlagsOp`, `LiquidityPoolDepositOp`, `LiquidityPoolWithdrawOp`, `HostFunctionType`, `ContractIdPreimageType`, `ContractIdPreimage`, `ContractIdPreimageFromAddress`, `CreateContractArgs`, `InvokeContractArgs`, `HostFunction`, `SorobanAuthorizedFunctionType`, `SorobanAuthorizedFunction`, `SorobanAuthorizedInvocation`, `SorobanAddressCredentials`, `SorobanCredentialsType`, `SorobanCredentials`, `SorobanAuthorizationEntry`, `InvokeHostFunctionOp`, `BumpFootprintExpirationOp`, `RestoreFootprintOp`, `Operation`, `OperationBody`, `HashIdPreimage`, `HashIdPreimageOperationId`, `HashIdPreimageRevokeId`, `HashIdPreimageContractId`, `HashIdPreimageSorobanAuthorization`, `MemoType`, `Memo`, `TimeBounds`, `LedgerBounds`, `PreconditionsV2`, `PreconditionType`, `Preconditions`, `LedgerFootprint`, `SorobanResources`, `SorobanTransactionData`, `TransactionV0`, `TransactionV0Ext`, `TransactionV0Envelope`, `Transaction`, `TransactionExt`, `TransactionV1Envelope`, `FeeBumpTransaction`, `FeeBumpTransactionInnerTx`, `FeeBumpTransactionExt`, `FeeBumpTransactionEnvelope`, `TransactionEnvelope`, `TransactionSignaturePayload`, `TransactionSignaturePayloadTaggedTransaction`, `ClaimAtomType`, `ClaimOfferAtomV0`, `ClaimOfferAtom`, `ClaimLiquidityAtom`, `ClaimAtom`, `CreateAccountResultCode`, `CreateAccountResult`, `PaymentResultCode`, `PaymentResult`, `PathPaymentStrictReceiveResultCode`, `SimplePaymentResult`, `PathPaymentStrictReceiveResult`, `PathPaymentStrictReceiveResultSuccess`, `PathPaymentStrictSendResultCode`, `PathPaymentStrictSendResult`, `PathPaymentStrictSendResultSuccess`, `ManageSellOfferResultCode`, `ManageOfferEffect`, `ManageOfferSuccessResult`, `ManageOfferSuccessResultOffer`, `ManageSellOfferResult`, `ManageBuyOfferResultCode`, `ManageBuyOfferResult`, `SetOptionsResultCode`, `SetOptionsResult`, `ChangeTrustResultCode`, `ChangeTrustResult`, `AllowTrustResultCode`, `AllowTrustResult`, `AccountMergeResultCode`, `AccountMergeResult`, `InflationResultCode`, `InflationPayout`, `InflationResult`, `ManageDataResultCode`, `ManageDataResult`, `BumpSequenceResultCode`, `BumpSequenceResult`, `CreateClaimableBalanceResultCode`, `CreateClaimableBalanceResult`, `ClaimClaimableBalanceResultCode`, `ClaimClaimableBalanceResult`, `BeginSponsoringFutureReservesResultCode`, `BeginSponsoringFutureReservesResult`, `EndSponsoringFutureReservesResultCode`, `EndSponsoringFutureReservesResult`, `RevokeSponsorshipResultCode`, `RevokeSponsorshipResult`, `ClawbackResultCode`, `ClawbackResult`, `ClawbackClaimableBalanceResultCode`, `ClawbackClaimableBalanceResult`, `SetTrustLineFlagsResultCode`, `SetTrustLineFlagsResult`, `LiquidityPoolDepositResultCode`, `LiquidityPoolDepositResult`, `LiquidityPoolWithdrawResultCode`, `LiquidityPoolWithdrawResult`, `InvokeHostFunctionResultCode`, `InvokeHostFunctionResult`, `BumpFootprintExpirationResultCode`, `BumpFootprintExpirationResult`, `RestoreFootprintResultCode`, `RestoreFootprintResult`, `OperationResultCode`, `OperationResult`, `OperationResultTr`, `TransactionResultCode`, `InnerTransactionResult`, `InnerTransactionResultResult`, `InnerTransactionResultExt`, `InnerTransactionResultPair`, `TransactionResult`, `TransactionResultResult`, `TransactionResultExt`, `Hash`, `Uint256`, `Uint32`, `Int32`, `Uint64`, `Int64`, `TimePoint`, `Duration`, `ExtensionPoint`, `CryptoKeyType`, `PublicKeyType`, `SignerKeyType`, `PublicKey`, `SignerKey`, `SignerKeyEd25519SignedPayload`, `Signature`, `SignatureHint`, `NodeId`, `AccountId`, `Curve25519Secret`, `Curve25519Public`, `HmacSha256Key`, `HmacSha256Mac` + Possible values: `Value`, `ScpBallot`, `ScpStatementType`, `ScpNomination`, `ScpStatement`, `ScpStatementPledges`, `ScpStatementPrepare`, `ScpStatementConfirm`, `ScpStatementExternalize`, `ScpEnvelope`, `ScpQuorumSet`, `ConfigSettingContractExecutionLanesV0`, `ConfigSettingContractComputeV0`, `ConfigSettingContractLedgerCostV0`, `ConfigSettingContractHistoricalDataV0`, `ConfigSettingContractEventsV0`, `ConfigSettingContractBandwidthV0`, `ContractCostType`, `ContractCostParamEntry`, `StateArchivalSettings`, `EvictionIterator`, `ContractCostParams`, `ConfigSettingId`, `ConfigSettingEntry`, `ScEnvMetaKind`, `ScEnvMetaEntry`, `ScMetaV0`, `ScMetaKind`, `ScMetaEntry`, `ScSpecType`, `ScSpecTypeOption`, `ScSpecTypeResult`, `ScSpecTypeVec`, `ScSpecTypeMap`, `ScSpecTypeTuple`, `ScSpecTypeBytesN`, `ScSpecTypeUdt`, `ScSpecTypeDef`, `ScSpecUdtStructFieldV0`, `ScSpecUdtStructV0`, `ScSpecUdtUnionCaseVoidV0`, `ScSpecUdtUnionCaseTupleV0`, `ScSpecUdtUnionCaseV0Kind`, `ScSpecUdtUnionCaseV0`, `ScSpecUdtUnionV0`, `ScSpecUdtEnumCaseV0`, `ScSpecUdtEnumV0`, `ScSpecUdtErrorEnumCaseV0`, `ScSpecUdtErrorEnumV0`, `ScSpecFunctionInputV0`, `ScSpecFunctionV0`, `ScSpecEntryKind`, `ScSpecEntry`, `ScValType`, `ScErrorType`, `ScErrorCode`, `ScError`, `UInt128Parts`, `Int128Parts`, `UInt256Parts`, `Int256Parts`, `ContractExecutableType`, `ContractExecutable`, `ScAddressType`, `ScAddress`, `ScVec`, `ScMap`, `ScBytes`, `ScString`, `ScSymbol`, `ScNonceKey`, `ScContractInstance`, `ScVal`, `ScMapEntry`, `StoredTransactionSet`, `StoredDebugTransactionSet`, `PersistedScpStateV0`, `PersistedScpStateV1`, `PersistedScpState`, `Thresholds`, `String32`, `String64`, `SequenceNumber`, `DataValue`, `PoolId`, `AssetCode4`, `AssetCode12`, `AssetType`, `AssetCode`, `AlphaNum4`, `AlphaNum12`, `Asset`, `Price`, `Liabilities`, `ThresholdIndexes`, `LedgerEntryType`, `Signer`, `AccountFlags`, `SponsorshipDescriptor`, `AccountEntryExtensionV3`, `AccountEntryExtensionV2`, `AccountEntryExtensionV2Ext`, `AccountEntryExtensionV1`, `AccountEntryExtensionV1Ext`, `AccountEntry`, `AccountEntryExt`, `TrustLineFlags`, `LiquidityPoolType`, `TrustLineAsset`, `TrustLineEntryExtensionV2`, `TrustLineEntryExtensionV2Ext`, `TrustLineEntry`, `TrustLineEntryExt`, `TrustLineEntryV1`, `TrustLineEntryV1Ext`, `OfferEntryFlags`, `OfferEntry`, `OfferEntryExt`, `DataEntry`, `DataEntryExt`, `ClaimPredicateType`, `ClaimPredicate`, `ClaimantType`, `Claimant`, `ClaimantV0`, `ClaimableBalanceIdType`, `ClaimableBalanceId`, `ClaimableBalanceFlags`, `ClaimableBalanceEntryExtensionV1`, `ClaimableBalanceEntryExtensionV1Ext`, `ClaimableBalanceEntry`, `ClaimableBalanceEntryExt`, `LiquidityPoolConstantProductParameters`, `LiquidityPoolEntry`, `LiquidityPoolEntryBody`, `LiquidityPoolEntryConstantProduct`, `ContractDataDurability`, `ContractDataEntry`, `ContractCodeEntry`, `TtlEntry`, `LedgerEntryExtensionV1`, `LedgerEntryExtensionV1Ext`, `LedgerEntry`, `LedgerEntryData`, `LedgerEntryExt`, `LedgerKey`, `LedgerKeyAccount`, `LedgerKeyTrustLine`, `LedgerKeyOffer`, `LedgerKeyData`, `LedgerKeyClaimableBalance`, `LedgerKeyLiquidityPool`, `LedgerKeyContractData`, `LedgerKeyContractCode`, `LedgerKeyConfigSetting`, `LedgerKeyTtl`, `EnvelopeType`, `UpgradeType`, `StellarValueType`, `LedgerCloseValueSignature`, `StellarValue`, `StellarValueExt`, `LedgerHeaderFlags`, `LedgerHeaderExtensionV1`, `LedgerHeaderExtensionV1Ext`, `LedgerHeader`, `LedgerHeaderExt`, `LedgerUpgradeType`, `ConfigUpgradeSetKey`, `LedgerUpgrade`, `ConfigUpgradeSet`, `BucketEntryType`, `BucketMetadata`, `BucketMetadataExt`, `BucketEntry`, `TxSetComponentType`, `TxSetComponent`, `TxSetComponentTxsMaybeDiscountedFee`, `TransactionPhase`, `TransactionSet`, `TransactionSetV1`, `GeneralizedTransactionSet`, `TransactionResultPair`, `TransactionResultSet`, `TransactionHistoryEntry`, `TransactionHistoryEntryExt`, `TransactionHistoryResultEntry`, `TransactionHistoryResultEntryExt`, `LedgerHeaderHistoryEntry`, `LedgerHeaderHistoryEntryExt`, `LedgerScpMessages`, `ScpHistoryEntryV0`, `ScpHistoryEntry`, `LedgerEntryChangeType`, `LedgerEntryChange`, `LedgerEntryChanges`, `OperationMeta`, `TransactionMetaV1`, `TransactionMetaV2`, `ContractEventType`, `ContractEvent`, `ContractEventBody`, `ContractEventV0`, `DiagnosticEvent`, `SorobanTransactionMeta`, `TransactionMetaV3`, `InvokeHostFunctionSuccessPreImage`, `TransactionMeta`, `TransactionResultMeta`, `UpgradeEntryMeta`, `LedgerCloseMetaV0`, `LedgerCloseMetaV1`, `LedgerCloseMeta`, `ErrorCode`, `SError`, `SendMore`, `SendMoreExtended`, `AuthCert`, `Hello`, `Auth`, `IpAddrType`, `PeerAddress`, `PeerAddressIp`, `MessageType`, `DontHave`, `SurveyMessageCommandType`, `SurveyMessageResponseType`, `SurveyRequestMessage`, `SignedSurveyRequestMessage`, `EncryptedBody`, `SurveyResponseMessage`, `SignedSurveyResponseMessage`, `PeerStats`, `PeerStatList`, `TopologyResponseBodyV0`, `TopologyResponseBodyV1`, `SurveyResponseBody`, `TxAdvertVector`, `FloodAdvert`, `TxDemandVector`, `FloodDemand`, `StellarMessage`, `AuthenticatedMessage`, `AuthenticatedMessageV0`, `LiquidityPoolParameters`, `MuxedAccount`, `MuxedAccountMed25519`, `DecoratedSignature`, `OperationType`, `CreateAccountOp`, `PaymentOp`, `PathPaymentStrictReceiveOp`, `PathPaymentStrictSendOp`, `ManageSellOfferOp`, `ManageBuyOfferOp`, `CreatePassiveSellOfferOp`, `SetOptionsOp`, `ChangeTrustAsset`, `ChangeTrustOp`, `AllowTrustOp`, `ManageDataOp`, `BumpSequenceOp`, `CreateClaimableBalanceOp`, `ClaimClaimableBalanceOp`, `BeginSponsoringFutureReservesOp`, `RevokeSponsorshipType`, `RevokeSponsorshipOp`, `RevokeSponsorshipOpSigner`, `ClawbackOp`, `ClawbackClaimableBalanceOp`, `SetTrustLineFlagsOp`, `LiquidityPoolDepositOp`, `LiquidityPoolWithdrawOp`, `HostFunctionType`, `ContractIdPreimageType`, `ContractIdPreimage`, `ContractIdPreimageFromAddress`, `CreateContractArgs`, `InvokeContractArgs`, `HostFunction`, `SorobanAuthorizedFunctionType`, `SorobanAuthorizedFunction`, `SorobanAuthorizedInvocation`, `SorobanAddressCredentials`, `SorobanCredentialsType`, `SorobanCredentials`, `SorobanAuthorizationEntry`, `InvokeHostFunctionOp`, `ExtendFootprintTtlOp`, `RestoreFootprintOp`, `Operation`, `OperationBody`, `HashIdPreimage`, `HashIdPreimageOperationId`, `HashIdPreimageRevokeId`, `HashIdPreimageContractId`, `HashIdPreimageSorobanAuthorization`, `MemoType`, `Memo`, `TimeBounds`, `LedgerBounds`, `PreconditionsV2`, `PreconditionType`, `Preconditions`, `LedgerFootprint`, `SorobanResources`, `SorobanTransactionData`, `TransactionV0`, `TransactionV0Ext`, `TransactionV0Envelope`, `Transaction`, `TransactionExt`, `TransactionV1Envelope`, `FeeBumpTransaction`, `FeeBumpTransactionInnerTx`, `FeeBumpTransactionExt`, `FeeBumpTransactionEnvelope`, `TransactionEnvelope`, `TransactionSignaturePayload`, `TransactionSignaturePayloadTaggedTransaction`, `ClaimAtomType`, `ClaimOfferAtomV0`, `ClaimOfferAtom`, `ClaimLiquidityAtom`, `ClaimAtom`, `CreateAccountResultCode`, `CreateAccountResult`, `PaymentResultCode`, `PaymentResult`, `PathPaymentStrictReceiveResultCode`, `SimplePaymentResult`, `PathPaymentStrictReceiveResult`, `PathPaymentStrictReceiveResultSuccess`, `PathPaymentStrictSendResultCode`, `PathPaymentStrictSendResult`, `PathPaymentStrictSendResultSuccess`, `ManageSellOfferResultCode`, `ManageOfferEffect`, `ManageOfferSuccessResult`, `ManageOfferSuccessResultOffer`, `ManageSellOfferResult`, `ManageBuyOfferResultCode`, `ManageBuyOfferResult`, `SetOptionsResultCode`, `SetOptionsResult`, `ChangeTrustResultCode`, `ChangeTrustResult`, `AllowTrustResultCode`, `AllowTrustResult`, `AccountMergeResultCode`, `AccountMergeResult`, `InflationResultCode`, `InflationPayout`, `InflationResult`, `ManageDataResultCode`, `ManageDataResult`, `BumpSequenceResultCode`, `BumpSequenceResult`, `CreateClaimableBalanceResultCode`, `CreateClaimableBalanceResult`, `ClaimClaimableBalanceResultCode`, `ClaimClaimableBalanceResult`, `BeginSponsoringFutureReservesResultCode`, `BeginSponsoringFutureReservesResult`, `EndSponsoringFutureReservesResultCode`, `EndSponsoringFutureReservesResult`, `RevokeSponsorshipResultCode`, `RevokeSponsorshipResult`, `ClawbackResultCode`, `ClawbackResult`, `ClawbackClaimableBalanceResultCode`, `ClawbackClaimableBalanceResult`, `SetTrustLineFlagsResultCode`, `SetTrustLineFlagsResult`, `LiquidityPoolDepositResultCode`, `LiquidityPoolDepositResult`, `LiquidityPoolWithdrawResultCode`, `LiquidityPoolWithdrawResult`, `InvokeHostFunctionResultCode`, `InvokeHostFunctionResult`, `ExtendFootprintTtlResultCode`, `ExtendFootprintTtlResult`, `RestoreFootprintResultCode`, `RestoreFootprintResult`, `OperationResultCode`, `OperationResult`, `OperationResultTr`, `TransactionResultCode`, `InnerTransactionResult`, `InnerTransactionResultResult`, `InnerTransactionResultExt`, `InnerTransactionResultPair`, `TransactionResult`, `TransactionResultResult`, `TransactionResultExt`, `Hash`, `Uint256`, `Uint32`, `Int32`, `Uint64`, `Int64`, `TimePoint`, `Duration`, `ExtensionPoint`, `CryptoKeyType`, `PublicKeyType`, `SignerKeyType`, `PublicKey`, `SignerKey`, `SignerKeyEd25519SignedPayload`, `Signature`, `SignatureHint`, `NodeId`, `AccountId`, `Curve25519Secret`, `Curve25519Public`, `HmacSha256Key`, `HmacSha256Mac` * `--xdr ` — XDR (base64 encoded) to decode * `--output ` — Type of output diff --git a/go.mod b/go.mod index c150f42c0..5e29662fe 100644 --- a/go.mod +++ b/go.mod @@ -16,7 +16,7 @@ require ( github.com/sirupsen/logrus v1.9.3 github.com/spf13/cobra v1.7.0 github.com/spf13/pflag v1.0.5 - github.com/stellar/go v0.0.0-20231018140335-d50c63e68acc + github.com/stellar/go v0.0.0-20231016174715-c7d3a47ee7a2 github.com/stretchr/testify v1.8.4 golang.org/x/mod v0.13.0 gotest.tools/v3 v3.5.0 diff --git a/go.sum b/go.sum index 68f5d4753..4408009fe 100644 --- a/go.sum +++ b/go.sum @@ -52,9 +52,13 @@ github.com/ProtonMail/go-crypto v0.0.0-20230923063757-afb1ddc0824c/go.mod h1:EjA github.com/acomagu/bufpipe v1.0.4 h1:e3H4WUzM3npvo5uv95QuJM3cQspFNtFBzvJ2oNjKIDQ= github.com/acomagu/bufpipe v1.0.4/go.mod h1:mxdxdup/WdsKVreO5GpW4+M/1CE2sMG4jeGJ2sYmHc4= github.com/ajg/form v0.0.0-20160822230020-523a5da1a92f h1:zvClvFQwU++UpIUBGC8YmDlfhUrweEy1R1Fj1gu5iIM= +github.com/ajg/form v0.0.0-20160822230020-523a5da1a92f/go.mod h1:uL1WgH+h2mgNtvBq0339dVnzXdBETtL2LeUXaIv25UY= github.com/andybalholm/brotli v1.0.4 h1:V7DdXeJtZscaqfNuAdSRuRFzuiKlHSC/Zh3zl9qY3JY= +github.com/andybalholm/brotli v1.0.4/go.mod h1:fO7iG3H7G2nSZ7m0zPUDn85XEX2GTukHGRSepvi9Eig= github.com/anmitsu/go-shlex v0.0.0-20200514113438-38f4b401e2be h1:9AeTilPcZAjCFIImctFaOjnTIavg87rW78vTPkQqLI8= +github.com/anmitsu/go-shlex v0.0.0-20200514113438-38f4b401e2be/go.mod h1:ySMOLuWl6zY27l47sB3qLNK6tF2fkHG55UZxx8oIVo4= github.com/armon/go-socks5 v0.0.0-20160902184237-e75332964ef5 h1:0CwZNZbxp69SHPdPJAN/hZIm0C4OItdklCFmMRWYpio= +github.com/armon/go-socks5 v0.0.0-20160902184237-e75332964ef5/go.mod h1:wHh0iHkYZB8zMSxRWpUBQtwG5a7fFgvEO+odwuTv2gs= github.com/asaskevich/govalidator v0.0.0-20230301143203-a9d515a09cc2 h1:DklsrG3dyBCFEj5IhUbnKptjxatkF07cF2ak3yi77so= github.com/asaskevich/govalidator v0.0.0-20230301143203-a9d515a09cc2/go.mod h1:WaHUgvxTVq04UNunO+XhnAqY/wQc+bxr74GqbsZ/Jqw= github.com/aws/aws-sdk-go v1.45.27 h1:b+zOTPkAG4i2RvqPdHxkJZafmhhVaVHBp4r41Tu4I6U= @@ -89,6 +93,7 @@ github.com/davecgh/go-spew v1.1.1/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSs github.com/davecgh/go-spew v1.1.2-0.20180830191138-d8f796af33cc h1:U9qPSI2PIWSS1VwoXQT9A3Wy9MM3WgvqSxFWenqJduM= github.com/davecgh/go-spew v1.1.2-0.20180830191138-d8f796af33cc/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38= github.com/elazarl/goproxy v0.0.0-20230808193330-2592e75ae04a h1:mATvB/9r/3gvcejNsXKSkQ6lcIaNec2nyfOdlTBR2lU= +github.com/elazarl/goproxy v0.0.0-20230808193330-2592e75ae04a/go.mod h1:Ro8st/ElPeALwNFlcTpWmkr6IoMFfkjXAvTHpevnDsM= github.com/emirpasic/gods v1.18.1 h1:FXtiHYKDGKCW2KzwZKx0iC0PQmdlorYgdFG9jPXJ1Bc= github.com/emirpasic/gods v1.18.1/go.mod h1:8tpGGwCnJ5H4r6BWwaV6OrWmMoPhUl5jm/FMNAnJvWQ= github.com/envoyproxy/go-control-plane v0.9.0/go.mod h1:YTl/9mNaCwkRvm6d1a2C3ymFceY/DCBVvsKhRF0iEA4= @@ -98,12 +103,17 @@ github.com/envoyproxy/go-control-plane v0.9.7/go.mod h1:cwu0lG7PUMfa9snN8LXBig5y github.com/envoyproxy/go-control-plane v0.9.9-0.20201210154907-fd9021fe5dad/go.mod h1:cXg6YxExXjJnVBQHBLXeUAgxn2UodCpnH306RInaBQk= github.com/envoyproxy/protoc-gen-validate v0.1.0/go.mod h1:iSmxcyjqTsJpI2R4NaDN7+kN2VEUnK/pcBlmesArF7c= github.com/fatih/structs v1.0.0 h1:BrX964Rv5uQ3wwS+KRUAJCBBw5PQmgJfJ6v4yly5QwU= +github.com/fatih/structs v1.0.0/go.mod h1:9NiDSp5zOcgEDl+j00MP/WkGVPOlPRLejGD8Ga6PJ7M= github.com/fortytw2/leaktest v1.3.0 h1:u8491cBMTQ8ft8aeV+adlcytMZylmA5nnwwkRZjI8vw= +github.com/fortytw2/leaktest v1.3.0/go.mod h1:jDsjWgpAGjm2CA7WthBh/CdZYEPF31XHquHwclZch5g= github.com/frankban/quicktest v1.14.4 h1:g2rn0vABPOOXmZUj+vbmUp0lPoXEMuhTpIluN0XL9UY= +github.com/frankban/quicktest v1.14.4/go.mod h1:4ptaffx2x8+WTWXmUCuVU6aPUX1/Mz7zb5vbUoiM6w0= github.com/fsnotify/fsnotify v1.6.0 h1:n+5WquG0fcWoWp6xPWfHdbskMCQaFnG6PfBrh1Ky4HY= github.com/fsnotify/fsnotify v1.6.0/go.mod h1:sl3t1tCWJFWoRz9R8WJCbQihKKwmorjAbSClcnxKAGw= github.com/gavv/monotime v0.0.0-20161010190848-47d58efa6955 h1:gmtGRvSexPU4B1T/yYo0sLOKzER1YT+b4kPxPpm0Ty4= +github.com/gavv/monotime v0.0.0-20161010190848-47d58efa6955/go.mod h1:vmp8DIyckQMXOPl0AQVHt+7n5h7Gb7hS6CUydiV8QeA= github.com/gliderlabs/ssh v0.3.5 h1:OcaySEmAQJgyYcArR+gGGTHCyE7nvhEMTlYY+Dp8CpY= +github.com/gliderlabs/ssh v0.3.5/go.mod h1:8XB4KraRrX39qHhT6yxPsHedjA08I/uBVwj4xC+/+z4= github.com/go-chi/chi v4.1.2+incompatible h1:fGFk2Gmi/YKXk0OmGfBh0WgmN3XB8lVnEyNz34tQRec= github.com/go-chi/chi v4.1.2+incompatible/go.mod h1:eB3wogJHnLi3x/kFX2A+IbTBlXxmMeXJVKy9tTv1XzQ= github.com/go-errors/errors v1.5.1 h1:ZwEMSLRCapFLflTpT7NKaAc7ukJ8ZPEjzlxt8rPN8bk= @@ -113,6 +123,7 @@ github.com/go-git/gcfg v1.5.1-0.20230307220236-3a3c6141e376/go.mod h1:an3vInlBmS github.com/go-git/go-billy/v5 v5.5.0 h1:yEY4yhzCDuMGSv83oGxiBotRzhwhNr8VZyphhiu+mTU= github.com/go-git/go-billy/v5 v5.5.0/go.mod h1:hmexnoNsr2SJU1Ju67OaNz5ASJY3+sHgFRpCtpDCKow= github.com/go-git/go-git-fixtures/v4 v4.3.2-0.20230305113008-0c11038e723f h1:Pz0DHeFij3XFhoBRGUDPzSJ+w2UcK5/0JvF8DRI58r8= +github.com/go-git/go-git-fixtures/v4 v4.3.2-0.20230305113008-0c11038e723f/go.mod h1:8LHG1a3SRW71ettAD/jW13h8c6AqjVSeL11RAdgaqpo= github.com/go-git/go-git/v5 v5.9.0 h1:cD9SFA7sHVRdJ7AYck1ZaAa/yeuBvGPxwXDL8cxrObY= github.com/go-git/go-git/v5 v5.9.0/go.mod h1:RKIqga24sWdMGZF+1Ekv9kylsDz6LzdTSI2s/OsZWE0= github.com/go-gl/glfw v0.0.0-20190409004039-e6da0acd62b1/go.mod h1:vR7hzQXu2zJy9AVAgeJqvqgH9Q5CA+iKCZ2gyEVpxRU= @@ -123,8 +134,12 @@ github.com/go-gorp/gorp/v3 v3.1.0/go.mod h1:dLEjIyyRNiXvNZ8PSmzpt1GsWAUK8kjVhEpj github.com/go-sql-driver/mysql v1.6.0 h1:BCTh4TKNUYmOmMUcQ3IipzF5prigylS7XXjEkfCHuOE= github.com/go-sql-driver/mysql v1.6.0/go.mod h1:DCzpHaOWr8IXmIStZouvnhqoel9Qv2LBy8hT2VhHyBg= github.com/gobuffalo/logger v1.0.6 h1:nnZNpxYo0zx+Aj9RfMPBm+x9zAU2OayFh/xrAWi34HU= +github.com/gobuffalo/logger v1.0.6/go.mod h1:J31TBEHR1QLV2683OXTAItYIg8pv2JMHnF/quuAbMjs= github.com/gobuffalo/packd v1.0.2 h1:Yg523YqnOxGIWCp69W12yYBKsoChwI7mtu6ceM9Bwfw= +github.com/gobuffalo/packd v1.0.2/go.mod h1:sUc61tDqGMXON80zpKGp92lDb86Km28jfvX7IAyxFT8= +github.com/gobuffalo/packr v1.30.1 h1:hu1fuVR3fXEZR7rXNW3h8rqSML8EVAf6KNm0NKO/wKg= github.com/gobuffalo/packr/v2 v2.8.3 h1:xE1yzvnO56cUC0sTpKR3DIbxZgB54AftTFMhB2XEWlY= +github.com/gobuffalo/packr/v2 v2.8.3/go.mod h1:0SahksCVcx4IMnigTjiFuyldmTrdTctXsOdiU5KwbKc= github.com/golang/glog v0.0.0-20160126235308-23def4e6c14b/go.mod h1:SBH7ygxi8pfUlaOkMMuAQtPIUF8ecWP5IEl/CR7VP2Q= github.com/golang/groupcache v0.0.0-20190702054246-869f871628b6/go.mod h1:cIg4eruTrX1D+g88fzRXU5OdNfaM+9IcxsU14FzY7Hc= github.com/golang/groupcache v0.0.0-20191227052852-215e87163ea7/go.mod h1:cIg4eruTrX1D+g88fzRXU5OdNfaM+9IcxsU14FzY7Hc= @@ -168,6 +183,7 @@ github.com/google/go-cmp v0.5.5/go.mod h1:v8dTdLbMG2kIc/vJvl+f65V22dbkXbowE6jgT/ github.com/google/go-cmp v0.5.9 h1:O2Tfq5qg4qc4AmwVlvv0oLiVAGB7enBSJ2x2DqQFi38= github.com/google/go-cmp v0.5.9/go.mod h1:17dUlkBOakJ0+DkrSSNjCkIjxS6bF9zb3elmeNGIjoY= github.com/google/go-querystring v0.0.0-20160401233042-9235644dd9e5 h1:oERTZ1buOUYlpmKaqlO5fYmz8cZ1rYu5DieJzF4ZVmU= +github.com/google/go-querystring v0.0.0-20160401233042-9235644dd9e5/go.mod h1:odCYkC5MyYFN7vkCjXpyrEuKhc/BUO6wN/zVPAxq5ck= github.com/google/martian v2.1.0+incompatible/go.mod h1:9I4somxYTbIHy5NJKHRl3wXiIaQGbYVAs8BPL6v8lEs= github.com/google/martian/v3 v3.0.0/go.mod h1:y5Zk1BBys9G+gd6Jrk0W3cC1+ELVxBWuIGO+w/tUAp0= github.com/google/martian/v3 v3.1.0/go.mod h1:y5Zk1BBys9G+gd6Jrk0W3cC1+ELVxBWuIGO+w/tUAp0= @@ -188,7 +204,8 @@ github.com/google/uuid v1.1.2/go.mod h1:TIyPZe4MgqvfeYDBFedMoGGpEw/LqOeaOT+nhxU+ github.com/googleapis/gax-go/v2 v2.0.4/go.mod h1:0Wqv26UfaUD9n4G6kQubkQ+KchISgw+vpHVxEJEs9eg= github.com/googleapis/gax-go/v2 v2.0.5/go.mod h1:DWXyrwAJ9X0FpwwEdw+IPEYBICEFu5mhpdKc/us6bOk= github.com/googleapis/google-cloud-go-testing v0.0.0-20200911160855-bcd43fbb19e8/go.mod h1:dvDLG8qkwmyD9a/MJJN3XJcT3xFxOKAvTZGvuZmac9g= -github.com/gorilla/schema v1.2.0 h1:YufUaxZYCKGFuAq3c96BOhjgd5nmXiOY9NGzF247Tsc= +github.com/gorilla/schema v1.1.0 h1:CamqUDOFUBqzrvxuz2vEwo8+SUdwsluFh7IlzJh30LY= +github.com/gorilla/schema v1.1.0/go.mod h1:kgLaKoK1FELgZqMAVxx/5cbj0kT+57qxUrAlIO2eleU= github.com/hashicorp/golang-lru v0.5.0/go.mod h1:/m3WP610KZHVQ1SGc6re/UDhFvYD7pJ4Ao+sR/qLZy8= github.com/hashicorp/golang-lru v0.5.1/go.mod h1:/m3WP610KZHVQ1SGc6re/UDhFvYD7pJ4Ao+sR/qLZy8= github.com/hashicorp/hcl v1.0.0 h1:0Anlzjpi4vEasTeNFn2mLJgTSwt0+6sfsiTG8qcWGx4= @@ -196,9 +213,11 @@ github.com/hashicorp/hcl v1.0.0/go.mod h1:E5yfLk+7swimpb2L/Alb/PJmXilQ/rhwaUYs4T github.com/ianlancetaylor/demangle v0.0.0-20181102032728-5e5cf60278f6/go.mod h1:aSSvb/t6k1mPoxDqO4vJh6VOCGPwU4O0C2/Eqndh1Sc= github.com/ianlancetaylor/demangle v0.0.0-20200824232613-28f6c0f3b639/go.mod h1:aSSvb/t6k1mPoxDqO4vJh6VOCGPwU4O0C2/Eqndh1Sc= github.com/imkira/go-interpol v1.1.0 h1:KIiKr0VSG2CUW1hl1jpiyuzuJeKUUpC8iM1AIE7N1Vk= +github.com/imkira/go-interpol v1.1.0/go.mod h1:z0h2/2T3XF8kyEPpRgJ3kmNv+C43p+I/CoI+jC3w2iA= github.com/inconshreveable/mousetrap v1.1.0 h1:wN+x4NVGpMsO7ErUn/mUI3vEoE6Jt13X2s0bqwp9tc8= github.com/inconshreveable/mousetrap v1.1.0/go.mod h1:vpF70FUmC8bwa3OWnCshd2FqLfsEA9PFc4w1p2J65bw= github.com/jarcoal/httpmock v0.0.0-20161210151336-4442edb3db31 h1:Aw95BEvxJ3K6o9GGv5ppCd1P8hkeIeEJ30FO+OhOJpM= +github.com/jarcoal/httpmock v0.0.0-20161210151336-4442edb3db31/go.mod h1:ks+b9deReOc7jgqp+e7LuFiCBH6Rm5hL32cLcEAArb4= github.com/jbenet/go-context v0.0.0-20150711004518-d14ea06fba99 h1:BQSFePA1RWJOlocH6Fxy8MmwDt+yVQYULKfN0RoTN8A= github.com/jbenet/go-context v0.0.0-20150711004518-d14ea06fba99/go.mod h1:1lJo3i6rXxKeerYnT8Nvf0QmHCRC1n8sfWVwXF2Frvo= github.com/jmespath/go-jmespath v0.4.0 h1:BEgLn5cpjn8UN1mAw4NjwDrS35OdebyEtFe+9YPoQUg= @@ -210,13 +229,16 @@ github.com/jmoiron/sqlx v1.3.5/go.mod h1:nRVWtLre0KfCLJvgxzCsLVMogSvQ1zNJtpYr2Cc github.com/jstemmer/go-junit-report v0.0.0-20190106144839-af01ea7f8024/go.mod h1:6v2b51hI/fHJwM22ozAgKL4VKDeJcHhJFhtBdhmNjmU= github.com/jstemmer/go-junit-report v0.9.1/go.mod h1:Brl9GWCQeLvo8nXZwPNNblvFj/XSXhF0NWZEnDohbsk= github.com/karrick/godirwalk v1.16.1 h1:DynhcF+bztK8gooS0+NDJFrdNZjJ3gzVzC545UNA9iw= +github.com/karrick/godirwalk v1.16.1/go.mod h1:j4mkqPuvaLI8mp1DroR3P6ad7cyYd4c1qeJ3RV7ULlk= github.com/kevinburke/ssh_config v1.2.0 h1:x584FjTGwHzMwvHx18PXxbBVzfnxogHaAReU4gf13a4= github.com/kevinburke/ssh_config v1.2.0/go.mod h1:CT57kijsi8u/K/BOFA39wgDQJ9CxiF4nAY/ojJ6r6mM= github.com/kisielk/gotool v1.0.0/go.mod h1:XhKaO+MFFWcvkIS/tQcRk01m1F5IRFswLeQ+oQHNcck= github.com/klauspost/compress v1.17.0 h1:Rnbp4K9EjcDuVuHtd0dgA4qNuv9yKDYKK1ulpJwgrqM= +github.com/klauspost/compress v1.17.0/go.mod h1:ntbaceVETuRiXiv4DpjP66DpAtAGkEQskQzEyD//IeE= github.com/kr/fs v0.1.0/go.mod h1:FFnZGqtBN9Gxj7eW1uZ42v5BccTP0vu6NEaFoC2HwRg= github.com/kr/pretty v0.1.0/go.mod h1:dAy3ld7l9f0ibDNOQOHHMYYIIbhfbHSm3C4ZsoJORNo= github.com/kr/pretty v0.3.1 h1:flRD4NNwYAUpkphVc1HcthR4KEIFJ65n8Mw5qdRn3LE= +github.com/kr/pretty v0.3.1/go.mod h1:hoEshYVHaxMs3cyo3Yncou5ZscifuDolrwPKZanG3xk= github.com/kr/pty v1.1.1/go.mod h1:pFQYn66WHrOpPYNljwOMqo10TkYh1fy3cYio2l3bCsQ= github.com/kr/text v0.1.0/go.mod h1:4Jbv+DJW3UT/LiOwJeYQe1efqtUx/iVham/4vfdArNI= github.com/kr/text v0.2.0 h1:5Nx0Ya0ZqY2ygV366QzturHI13Jq95ApcVaJBhpS+AY= @@ -230,9 +252,13 @@ github.com/lib/pq v1.10.9/go.mod h1:AlVN5x4E4T544tWzH6hKfbfQvm3HdbOxrmggDNAPY9o= github.com/magiconair/properties v1.8.7 h1:IeQXZAiQcpL9mgcAe1Nu6cX9LLw6ExEHKjN0VQdvPDY= github.com/magiconair/properties v1.8.7/go.mod h1:Dhd985XPs7jluiymwWYZ0G4Z61jb3vdS329zhj2hYo0= github.com/manucorporat/sse v0.0.0-20160126180136-ee05b128a739 h1:ykXz+pRRTibcSjG1yRhpdSHInF8yZY/mfn+Rz2Nd1rE= +github.com/manucorporat/sse v0.0.0-20160126180136-ee05b128a739/go.mod h1:zUx1mhth20V3VKgL5jbd1BSQcW4Fy6Qs4PZvQwRFwzM= github.com/markbates/errx v1.1.0 h1:QDFeR+UP95dO12JgW+tgi2UVfo0V8YBHiUIOaeBPiEI= +github.com/markbates/errx v1.1.0/go.mod h1:PLa46Oex9KNbVDZhKel8v1OT7hD5JZ2eI7AHhA0wswc= github.com/markbates/oncer v1.0.0 h1:E83IaVAHygyndzPimgUYJjbshhDTALZyXxvk9FOlQRY= +github.com/markbates/oncer v1.0.0/go.mod h1:Z59JA581E9GP6w96jai+TGqafHPW+cPfRxz2aSZ0mcI= github.com/markbates/safe v1.0.1 h1:yjZkbvRM6IzKj9tlu/zMJLS0n/V351OZWRnF3QfaUxI= +github.com/markbates/safe v1.0.1/go.mod h1:nAqgmRi7cY2nqMc92/bSEeQA+R4OheNU2T1kNSCBdG0= github.com/matryer/is v1.2.0 h1:92UTHpy8CDwaJ08GqLDzhhuixiBUUD1p3AU6PHddz4A= github.com/matryer/is v1.2.0/go.mod h1:2fLPjFQM9rhQ15aVEtbuwhJinnOqrmgXPNdZsdwlWXA= github.com/mattn/go-sqlite3 v1.14.6/go.mod h1:NyWgC/yNuGj7Q9rpYnZvas74GogHl5/Z4A/KQRfk6bU= @@ -243,9 +269,13 @@ github.com/matttproud/golang_protobuf_extensions/v2 v2.0.0/go.mod h1:QUyp042oQth github.com/mitchellh/mapstructure v1.5.0 h1:jeMsZIYE/09sWLaz43PL7Gy6RuMjD2eJVyuac5Z2hdY= github.com/mitchellh/mapstructure v1.5.0/go.mod h1:bFUtVrKA4DC2yAKiSyO/QUcy7e+RRV2QTWOzhPopBRo= github.com/moul/http2curl v0.0.0-20161031194548-4e24498b31db h1:eZgFHVkk9uOTaOQLC6tgjkzdp7Ays8eEVecBcfHZlJQ= +github.com/moul/http2curl v0.0.0-20161031194548-4e24498b31db/go.mod h1:8UbvGypXm98wA/IqH45anm5Y2Z6ep6O31QGOAZ3H0fQ= github.com/nxadm/tail v1.4.8 h1:nPr65rt6Y5JFSKQO7qToXr7pePgD6Gwiw05lkbyAQTE= +github.com/nxadm/tail v1.4.8/go.mod h1:+ncqLTQzXmGhMZNUePPaPqPvBxHAIsmXswZKocGu+AU= github.com/onsi/ginkgo v1.16.5 h1:8xi0RTUf59SOSfEtZMvwTvXYMzG4gV23XVHOZiXNtnE= +github.com/onsi/ginkgo v1.16.5/go.mod h1:+E8gABHa3K6zRBolWtd+ROzc/U5bkGt0FwiG042wbpU= github.com/onsi/gomega v1.27.10 h1:naR28SdDFlqrG6kScpT8VWpu1xWY5nJRCF3XaYyBjhI= +github.com/onsi/gomega v1.27.10/go.mod h1:RsS8tutOdbdgzbPtzzATp12yT7kM5I5aElG3evPbQ0M= github.com/pelletier/go-toml v1.9.5 h1:4yBQzkHv+7BHq2PQUZF3Mx0IYxG7LsP222s7Agd3ve8= github.com/pelletier/go-toml v1.9.5/go.mod h1:u1nR/EPcESfeI/szUZKdtJ0xRNbUoANCkoOuaOx1Y+c= github.com/pelletier/go-toml/v2 v2.1.0 h1:FnwAJ4oYMvbT/34k9zzHuZNrhlz48GB3/s6at6/MHO4= @@ -259,6 +289,7 @@ github.com/pmezard/go-difflib v1.0.0/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZN github.com/pmezard/go-difflib v1.0.1-0.20181226105442-5d4384ee4fb2 h1:Jamvg5psRIccs7FGNTlIRMkT8wgtp5eCXdBlqhYGL6U= github.com/pmezard/go-difflib v1.0.1-0.20181226105442-5d4384ee4fb2/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4= github.com/poy/onpar v1.1.2 h1:QaNrNiZx0+Nar5dLgTVp5mXkyoVFIbepjyEoGSnhbAY= +github.com/poy/onpar v1.1.2/go.mod h1:6X8FLNoxyr9kkmnlqpK6LSoiOtrO6MICtWwEuWkLjzg= github.com/prometheus/client_golang v1.17.0 h1:rl2sfwZMtSthVU752MqfjQozy7blglC+1SOtjMAMh+Q= github.com/prometheus/client_golang v1.17.0/go.mod h1:VeL+gMmOAxkS2IqfCq0ZmHSL+LjWfWDUmp1mBz9JgUY= github.com/prometheus/client_model v0.0.0-20190812154241-14fe0d1b01d4/go.mod h1:xMI15A0UPsDsEKsMN9yxemIoYk6Tm2C1GtYGdfGttqA= @@ -270,6 +301,7 @@ github.com/prometheus/procfs v0.12.0 h1:jluTpSng7V9hY0O2R9DzzJHYb2xULk9VTR1V1R/k github.com/prometheus/procfs v0.12.0/go.mod h1:pcuDEFsWDnvcgNzo4EEweacyhjeA9Zk3cnaOZAZEfOo= github.com/rogpeppe/go-internal v1.3.0/go.mod h1:M8bDsm7K2OlrFYOpmOWEs/qY81heoFRclV5y23lUDJ4= github.com/rogpeppe/go-internal v1.11.0 h1:cWPaGQEPrBb5/AsnsZesgZZ9yb1OQ+GOISoDNXVBh4M= +github.com/rogpeppe/go-internal v1.11.0/go.mod h1:ddIwULY96R17DhadqLgMfk9H9tvdUzkipdSkR5nkCZA= github.com/rs/cors v1.10.1 h1:L0uuZVXIKlI1SShY2nhFfo44TYvDPQ1w4oFkUJNfhyo= github.com/rs/cors v1.10.1/go.mod h1:XyqrcTp5zjWr1wsJ8PIRZssZ8b/WMcMf71DJnit4EMU= github.com/rubenv/sql-migrate v1.5.2 h1:bMDqOnrJVV/6JQgQ/MxOpU+AdO8uzYYA/TxFUBzFtS0= @@ -300,8 +332,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 v1.17.0 h1:I5txKw7MJasPL/BrfkbA0Jyo/oELqVmux4pR/UxOMfI= github.com/spf13/viper v1.17.0/go.mod h1:BmMMMLQXSbcHK6KAOiFLz0l5JHrU89OdIRHvsk0+yVI= -github.com/stellar/go v0.0.0-20231018140335-d50c63e68acc h1:FlT7AjN+0tVm8NpFwhQzAaBSfAIzm1vduOwQ0rin7m0= -github.com/stellar/go v0.0.0-20231018140335-d50c63e68acc/go.mod h1:Xkzo5tTJI31Y9VIR5FjviXZWYsHXZKChm+Ii8uHaG30= +github.com/stellar/go v0.0.0-20231016174715-c7d3a47ee7a2 h1:IOOHd1yrwmK0wiAuNDmoHUPTucO0oGkkKa3CE1pgn2E= +github.com/stellar/go v0.0.0-20231016174715-c7d3a47ee7a2/go.mod h1:g78pyZyDFnKMJUaBIXxH7xyQ7PdDrvrJTFCxdGMMb3c= github.com/stellar/go-xdr v0.0.0-20230919160922-6c7b68458206 h1:UFuvvpbWL8+jqO1QmKYWSVhiMp4MRiIFd8/zQlUINH0= github.com/stellar/go-xdr v0.0.0-20230919160922-6c7b68458206/go.mod h1:yoxyU/M8nl9LKeWIoBrbDPQ7Cy+4jxRcWcOayZ4BMps= github.com/stretchr/objx v0.1.0/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+wExME= @@ -321,17 +353,25 @@ github.com/stretchr/testify v1.8.4/go.mod h1:sz/lmYIOXD/1dqDmKjjqLyZ2RngseejIcXl github.com/subosito/gotenv v1.6.0 h1:9NlTDc1FTs4qu0DDq7AEtTPNw6SVm7uBMsUCUjABIf8= github.com/subosito/gotenv v1.6.0/go.mod h1:Dk4QP5c2W3ibzajGcXpNraDfq2IrhjMIvMSWPKKo0FU= github.com/valyala/bytebufferpool v1.0.0 h1:GqA5TC/0021Y/b9FG4Oi9Mr3q7XYx6KllzawFIhcdPw= +github.com/valyala/bytebufferpool v1.0.0/go.mod h1:6bBcMArwyJ5K/AmCkWv1jt77kVWyCJ6HpOuEn7z0Csc= github.com/valyala/fasthttp v1.34.0 h1:d3AAQJ2DRcxJYHm7OXNXtXt2as1vMDfxeIcFvhmGGm4= +github.com/valyala/fasthttp v1.34.0/go.mod h1:epZA5N+7pY6ZaEKRmstzOuYJx9HI8DI1oaCGZpdH4h0= github.com/xanzy/ssh-agent v0.3.3 h1:+/15pJfg/RsTxqYcX6fHqOXZwwMP+2VyYWJeWM2qQFM= github.com/xanzy/ssh-agent v0.3.3/go.mod h1:6dzNDKs0J9rVPHPhaGCukekBHKqfl+L3KghI1Bc68Uw= github.com/xdrpp/goxdr v0.1.1 h1:E1B2c6E8eYhOVyd7yEpOyopzTPirUeF6mVOfXfGyJyc= github.com/xdrpp/goxdr v0.1.1/go.mod h1:dXo1scL/l6s7iME1gxHWo2XCppbHEKZS7m/KyYWkNzA= github.com/xeipuuv/gojsonpointer v0.0.0-20151027082146-e0fe6f683076 h1:KM4T3G70MiR+JtqplcYkNVoNz7pDwYaBxWBXQK804So= +github.com/xeipuuv/gojsonpointer v0.0.0-20151027082146-e0fe6f683076/go.mod h1:N2zxlSyiKSe5eX1tZViRH5QA0qijqEDrYZiPEAiq3wU= github.com/xeipuuv/gojsonreference v0.0.0-20150808065054-e02fc20de94c h1:XZWnr3bsDQWAZg4Ne+cPoXRPILrNlPNQfxBuwLl43is= +github.com/xeipuuv/gojsonreference v0.0.0-20150808065054-e02fc20de94c/go.mod h1:GwrjFmJcFw6At/Gs6z4yjiIwzuJ1/+UwLxMQDVQXShQ= github.com/xeipuuv/gojsonschema v0.0.0-20161231055540-f06f290571ce h1:cVSRGH8cOveJNwFEEZLXtB+XMnRqKLjUP6V/ZFYQCXI= +github.com/xeipuuv/gojsonschema v0.0.0-20161231055540-f06f290571ce/go.mod h1:5yf86TLmAcydyeJq5YvxkGPE2fm/u4myDekKRoLuqhs= github.com/yalp/jsonpath v0.0.0-20150812003900-31a79c7593bb h1:06WAhQa+mYv7BiOk13B/ywyTlkoE/S7uu6TBKU6FHnE= +github.com/yalp/jsonpath v0.0.0-20150812003900-31a79c7593bb/go.mod h1:/LWChgwKmvncFJFHJ7Gvn9wZArjbV5/FppcK2fKk/tI= github.com/yudai/gojsondiff v0.0.0-20170107030110-7b1b7adf999d h1:yJIizrfO599ot2kQ6Af1enICnwBD3XoxgX3MrMwot2M= +github.com/yudai/gojsondiff v0.0.0-20170107030110-7b1b7adf999d/go.mod h1:AY32+k2cwILAkW1fbgxQ5mUmMiZFgLIV+FBNExI05xg= github.com/yudai/golcs v0.0.0-20150405163532-d1c525dea8ce h1:888GrqRxabUce7lj4OaoShPxodm3kXOMpSa85wdYzfY= +github.com/yudai/golcs v0.0.0-20150405163532-d1c525dea8ce/go.mod h1:lgjkn3NuSvDfVJdfcVVdX+jpBxNmX4rDAzaS45IcYoM= github.com/yuin/goldmark v1.1.25/go.mod h1:3hX8gzYuyVAZsxl0MRgGTJEmQBFcNTphYh9decYSb74= github.com/yuin/goldmark v1.1.27/go.mod h1:3hX8gzYuyVAZsxl0MRgGTJEmQBFcNTphYh9decYSb74= github.com/yuin/goldmark v1.1.32/go.mod h1:3hX8gzYuyVAZsxl0MRgGTJEmQBFcNTphYh9decYSb74= @@ -514,6 +554,7 @@ golang.org/x/term v0.2.0/go.mod h1:TVmDHMZPmdnySmBfhjOoOdhjzdE1h4u1VwSiw2l1Nuc= golang.org/x/term v0.5.0/go.mod h1:jMB1sMXY+tzblOD4FWmEbocvup2/aLOaQEp7JmGp78k= golang.org/x/term v0.6.0/go.mod h1:m6U89DPEgQRMq3DNkDClhWw02AUbt2daBVO4cn4Hv9U= golang.org/x/term v0.13.0 h1:bb+I9cTfFazGW51MZqBVmZy7+JEJMouUHTUSKVQLBek= +golang.org/x/term v0.13.0/go.mod h1:LTmsnFJwVN6bCy1rVCoS+qHT1HhALEFxKncY3WNNh4U= golang.org/x/text v0.0.0-20170915032832-14c0d48ead0c/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ= golang.org/x/text v0.3.0/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ= golang.org/x/text v0.3.1-0.20180807135948-17ff2d5776d2/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ= @@ -680,11 +721,14 @@ gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8 gopkg.in/check.v1 v1.0.0-20180628173108-788fd7840127/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0= gopkg.in/check.v1 v1.0.0-20190902080502-41f04d3bba15/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0= gopkg.in/check.v1 v1.0.0-20201130134442-10cb98267c6c h1:Hei/4ADfdWqJk1ZMxUNpqntNwaWcugrBjAiHlqqRiVk= +gopkg.in/check.v1 v1.0.0-20201130134442-10cb98267c6c/go.mod h1:JHkPIbrfpd72SG/EVd6muEfDQjcINNoR0C8j2r3qZ4Q= gopkg.in/errgo.v2 v2.1.0/go.mod h1:hNsd1EY+bozCKY1Ytp96fpM3vjJbqLJn88ws8XvfDNI= gopkg.in/gavv/httpexpect.v1 v1.0.0-20170111145843-40724cf1e4a0 h1:r5ptJ1tBxVAeqw4CrYWhXIMr0SybY3CDHuIbCg5CFVw= +gopkg.in/gavv/httpexpect.v1 v1.0.0-20170111145843-40724cf1e4a0/go.mod h1:WtiW9ZA1LdaWqtQRo1VbIL/v4XZ8NDta+O/kSpGgVek= gopkg.in/ini.v1 v1.67.0 h1:Dgnx+6+nfE+IfzjUEISNeydPJh9AXNNsWbGP9KzCsOA= gopkg.in/ini.v1 v1.67.0/go.mod h1:pNLf8WUiyNEtQjuu5G5vTm06TEv9tsIgeAvK8hOrP4k= gopkg.in/tomb.v1 v1.0.0-20141024135613-dd632973f1e7 h1:uRGJdciOHaEIrze2W8Q3AKkepLTh2hOroT7a+7czfdQ= +gopkg.in/tomb.v1 v1.0.0-20141024135613-dd632973f1e7/go.mod h1:dt/ZhP58zS4L8KSrWDmTeBkI65Dw0HsyUHuEVlX15mw= gopkg.in/tylerb/graceful.v1 v1.2.15 h1:1JmOyhKqAyX3BgTXMI84LwT6FOJ4tP2N9e2kwTCM0nQ= gopkg.in/tylerb/graceful.v1 v1.2.15/go.mod h1:yBhekWvR20ACXVObSSdD3u6S9DeSylanL2PAbAC/uJ8= gopkg.in/warnings.v0 v0.1.2 h1:wFXVbFY8DY5/xOe1ECiWdKCzZlxgshcYVNkBHstARME=