From ef3c4a0f87a0b99b8db90698c6996de01eeb5f7e Mon Sep 17 00:00:00 2001 From: Alfonso Acosta Date: Fri, 3 Feb 2023 15:50:51 +0100 Subject: [PATCH 01/18] Obtain auth information from rust into Go --- .github/workflows/soroban-rpc.yml | 2 +- Cargo.lock | 100 +++++++++++++++--- Cargo.toml | 2 +- .../internal/methods/simulate_transaction.go | 39 +++++-- .../test/simulate_transaction_test.go | 2 +- cmd/soroban-rpc/lib/preflight.h | 1 + cmd/soroban-rpc/lib/preflight/Cargo.toml | 1 + cmd/soroban-rpc/lib/preflight/src/lib.rs | 79 ++++++++++++-- 8 files changed, 192 insertions(+), 34 deletions(-) diff --git a/.github/workflows/soroban-rpc.yml b/.github/workflows/soroban-rpc.yml index 6b713cf63..cbc0a3f74 100644 --- a/.github/workflows/soroban-rpc.yml +++ b/.github/workflows/soroban-rpc.yml @@ -89,7 +89,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.6.1-1158.c0ad35aa1.focal~soroban + PROTOCOL_20_CORE_DEBIAN_PKG_VERSION: 19.7.1-1178.e352f0012.focal~soroban runs-on: ${{ matrix.os }} steps: - uses: actions/checkout@v3 diff --git a/Cargo.lock b/Cargo.lock index 3f9b41bf1..e2d0b28d8 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -1316,7 +1316,8 @@ name = "preflight" version = "0.1.0" dependencies = [ "libc", - "soroban-env-host", + "sha2 0.10.6", + "soroban-env-host 0.0.12 (git+https://github.com/stellar/rs-soroban-env?rev=66a079a4e400836f1b896c9b02d6e37fea028312)", ] [[package]] @@ -1834,7 +1835,7 @@ dependencies = [ "serde_derive", "serde_json", "sha2 0.10.6", - "soroban-env-host", + "soroban-env-host 0.0.12 (git+https://github.com/stellar/rs-soroban-env?rev=66a079a4e400836f1b896c9b02d6e37fea028312)", "soroban-ledger-snapshot", "soroban-sdk", "soroban-spec", @@ -1849,6 +1850,19 @@ dependencies = [ "wasmparser 0.90.0", ] +[[package]] +name = "soroban-env-common" +version = "0.0.12" +source = "git+https://github.com/stellar/rs-soroban-env?rev=66a079a4e400836f1b896c9b02d6e37fea028312#66a079a4e400836f1b896c9b02d6e37fea028312" +dependencies = [ + "crate-git-revision", + "serde", + "soroban-env-macros 0.0.12 (git+https://github.com/stellar/rs-soroban-env?rev=66a079a4e400836f1b896c9b02d6e37fea028312)", + "soroban-wasmi", + "static_assertions", + "stellar-xdr 0.0.12 (git+https://github.com/stellar/rs-stellar-xdr?rev=6c72271b)", +] + [[package]] name = "soroban-env-common" version = "0.0.12" @@ -1856,10 +1870,10 @@ source = "git+https://github.com/stellar/rs-soroban-env?rev=993c527abce72748405d dependencies = [ "crate-git-revision", "serde", - "soroban-env-macros", + "soroban-env-macros 0.0.12 (git+https://github.com/stellar/rs-soroban-env?rev=993c527abce72748405d71467498bffd63e061c1)", "soroban-wasmi", "static_assertions", - "stellar-xdr", + "stellar-xdr 0.0.12 (git+https://github.com/stellar/rs-stellar-xdr?rev=154e07e)", ] [[package]] @@ -1867,8 +1881,30 @@ name = "soroban-env-guest" version = "0.0.12" source = "git+https://github.com/stellar/rs-soroban-env?rev=993c527abce72748405d71467498bffd63e061c1#993c527abce72748405d71467498bffd63e061c1" dependencies = [ - "soroban-env-common", + "soroban-env-common 0.0.12 (git+https://github.com/stellar/rs-soroban-env?rev=993c527abce72748405d71467498bffd63e061c1)", + "static_assertions", +] + +[[package]] +name = "soroban-env-host" +version = "0.0.12" +source = "git+https://github.com/stellar/rs-soroban-env?rev=66a079a4e400836f1b896c9b02d6e37fea028312#66a079a4e400836f1b896c9b02d6e37fea028312" +dependencies = [ + "backtrace", + "curve25519-dalek", + "dyn-fmt", + "ed25519-dalek", + "hex", + "log", + "num-derive", + "num-integer", + "num-traits", + "sha2 0.10.6", + "soroban-env-common 0.0.12 (git+https://github.com/stellar/rs-soroban-env?rev=66a079a4e400836f1b896c9b02d6e37fea028312)", + "soroban-native-sdk-macros 0.0.12 (git+https://github.com/stellar/rs-soroban-env?rev=66a079a4e400836f1b896c9b02d6e37fea028312)", + "soroban-wasmi", "static_assertions", + "tinyvec", ] [[package]] @@ -1886,13 +1922,28 @@ dependencies = [ "num-integer", "num-traits", "sha2 0.10.6", - "soroban-env-common", - "soroban-native-sdk-macros", + "soroban-env-common 0.0.12 (git+https://github.com/stellar/rs-soroban-env?rev=993c527abce72748405d71467498bffd63e061c1)", + "soroban-native-sdk-macros 0.0.12 (git+https://github.com/stellar/rs-soroban-env?rev=993c527abce72748405d71467498bffd63e061c1)", "soroban-wasmi", "static_assertions", "tinyvec", ] +[[package]] +name = "soroban-env-macros" +version = "0.0.12" +source = "git+https://github.com/stellar/rs-soroban-env?rev=66a079a4e400836f1b896c9b02d6e37fea028312#66a079a4e400836f1b896c9b02d6e37fea028312" +dependencies = [ + "itertools", + "proc-macro2", + "quote", + "serde", + "serde_json", + "stellar-xdr 0.0.12 (git+https://github.com/stellar/rs-stellar-xdr?rev=6c72271b)", + "syn", + "thiserror", +] + [[package]] name = "soroban-env-macros" version = "0.0.12" @@ -1903,7 +1954,7 @@ dependencies = [ "quote", "serde", "serde_json", - "stellar-xdr", + "stellar-xdr 0.0.12 (git+https://github.com/stellar/rs-stellar-xdr?rev=154e07e)", "syn", "thiserror", ] @@ -1915,10 +1966,21 @@ source = "git+https://github.com/stellar/rs-soroban-sdk?rev=e1c3de33942f0e997680 dependencies = [ "serde", "serde_json", - "soroban-env-host", + "soroban-env-host 0.0.12 (git+https://github.com/stellar/rs-soroban-env?rev=993c527abce72748405d71467498bffd63e061c1)", "thiserror", ] +[[package]] +name = "soroban-native-sdk-macros" +version = "0.0.12" +source = "git+https://github.com/stellar/rs-soroban-env?rev=66a079a4e400836f1b896c9b02d6e37fea028312#66a079a4e400836f1b896c9b02d6e37fea028312" +dependencies = [ + "itertools", + "proc-macro2", + "quote", + "syn", +] + [[package]] name = "soroban-native-sdk-macros" version = "0.0.12" @@ -1939,7 +2001,7 @@ dependencies = [ "ed25519-dalek", "rand 0.8.5", "soroban-env-guest", - "soroban-env-host", + "soroban-env-host 0.0.12 (git+https://github.com/stellar/rs-soroban-env?rev=993c527abce72748405d71467498bffd63e061c1)", "soroban-ledger-snapshot", "soroban-sdk-macros", "stellar-strkey 0.0.6", @@ -1955,9 +2017,9 @@ dependencies = [ "proc-macro2", "quote", "sha2 0.10.6", - "soroban-env-common", + "soroban-env-common 0.0.12 (git+https://github.com/stellar/rs-soroban-env?rev=993c527abce72748405d71467498bffd63e061c1)", "soroban-spec", - "stellar-xdr", + "stellar-xdr 0.0.12 (git+https://github.com/stellar/rs-stellar-xdr?rev=154e07e)", "syn", ] @@ -1976,7 +2038,7 @@ dependencies = [ "serde_derive", "serde_json", "sha2 0.10.6", - "stellar-xdr", + "stellar-xdr 0.0.12 (git+https://github.com/stellar/rs-stellar-xdr?rev=154e07e)", "syn", "thiserror", "wasmparser 0.88.0", @@ -2061,6 +2123,18 @@ dependencies = [ "serde_with", ] +[[package]] +name = "stellar-xdr" +version = "0.0.12" +source = "git+https://github.com/stellar/rs-stellar-xdr?rev=6c72271b#6c72271bf3d07f8aa9d583261536e5653e555370" +dependencies = [ + "base64 0.13.1", + "crate-git-revision", + "hex", + "serde", + "serde_with", +] + [[package]] name = "strsim" version = "0.10.0" diff --git a/Cargo.toml b/Cargo.toml index 3275097bb..88f40bccb 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -10,7 +10,7 @@ default-members = ["cmd/soroban-cli"] [workspace.dependencies.soroban-env-host] version = "0.0.12" git = "https://github.com/stellar/rs-soroban-env" -rev = "993c527abce72748405d71467498bffd63e061c1" +rev = "66a079a4e400836f1b896c9b02d6e37fea028312" [workspace.dependencies.soroban-spec] version = "0.4.1" diff --git a/cmd/soroban-rpc/internal/methods/simulate_transaction.go b/cmd/soroban-rpc/internal/methods/simulate_transaction.go index e25a5b5d7..185636aad 100644 --- a/cmd/soroban-rpc/internal/methods/simulate_transaction.go +++ b/cmd/soroban-rpc/internal/methods/simulate_transaction.go @@ -97,16 +97,17 @@ type SimulateTransactionCost struct { MemoryBytes uint64 `json:"memBytes,string"` } -type InvokeHostFunctionResult struct { - XDR string `json:"xdr"` +type SimulateTransactionResult struct { + Auth []string `json:"auth"` + Footprint string `json:"footprint"` + XDR string `json:"xdr"` } type SimulateTransactionResponse struct { - Error string `json:"error,omitempty"` - Results []InvokeHostFunctionResult `json:"results,omitempty"` - Footprint string `json:"footprint"` - Cost SimulateTransactionCost `json:"cost"` - LatestLedger int64 `json:"latestLedger,string"` + Error string `json:"error,omitempty"` + Results []SimulateTransactionResult `json:"results,omitempty"` + Cost SimulateTransactionCost `json:"cost"` + LatestLedger int64 `json:"latestLedger,string"` } // NewSimulateTransactionHandler returns a json rpc handler to run preflight simulations @@ -199,9 +200,29 @@ func NewSimulateTransactionHandler(logger *log.Entry, networkPassphrase string, } } + // Get the auth data + var auth []string + if res.auth != nil { + // CGo doesn't have an easy way to do pointer arithmetic so, + // we are better off transforming the memory buffer into a large slice + // and finding the NULL termination after that + for _, a := range unsafe.Slice(res.auth, 1<<20) { + if a == nil { + // we found the ending nil + break + } + auth = append(auth, C.GoString(a)) + } + } + return SimulateTransactionResponse{ - Results: []InvokeHostFunctionResult{{XDR: C.GoString(res.result)}}, - Footprint: C.GoString(res.preflight), + Results: []SimulateTransactionResult{ + { + XDR: C.GoString(res.result), + Footprint: C.GoString(res.preflight), + Auth: auth, + }, + }, Cost: SimulateTransactionCost{ CPUInstructions: uint64(res.cpu_instructions), MemoryBytes: uint64(res.memory_bytes), diff --git a/cmd/soroban-rpc/internal/test/simulate_transaction_test.go b/cmd/soroban-rpc/internal/test/simulate_transaction_test.go index f8dd9607d..b3f735782 100644 --- a/cmd/soroban-rpc/internal/test/simulate_transaction_test.go +++ b/cmd/soroban-rpc/internal/test/simulate_transaction_test.go @@ -215,7 +215,7 @@ func TestSimulateTransactionSucceeds(t *testing.T) { CPUInstructions: result.Cost.CPUInstructions, MemoryBytes: result.Cost.MemoryBytes, }, - Results: []methods.InvokeHostFunctionResult{ + Results: []methods.SimulateTransactionResult{ {XDR: "AAAABAAAAAEAAAAGAAAAIOqfy4GuVKKfazvyk4R9P9fpo2n9HICsr+xqvVcTF+DC"}, }, LatestLedger: result.LatestLedger, diff --git a/cmd/soroban-rpc/lib/preflight.h b/cmd/soroban-rpc/lib/preflight.h index 5ac44e982..0956b5dd6 100644 --- a/cmd/soroban-rpc/lib/preflight.h +++ b/cmd/soroban-rpc/lib/preflight.h @@ -15,6 +15,7 @@ typedef struct CPreflightResult { char *error; // Error string in case of error, otherwise null char *result; // SCVal XDR in base64 char *preflight; // LedgerFootprint XDR in base64 + char **auth; // NULL terminated array of XDR ContractAuths in base64 uint64_t cpu_instructions; uint64_t memory_bytes; } CPreflightResult; diff --git a/cmd/soroban-rpc/lib/preflight/Cargo.toml b/cmd/soroban-rpc/lib/preflight/Cargo.toml index 44263bde4..d82a7c098 100644 --- a/cmd/soroban-rpc/lib/preflight/Cargo.toml +++ b/cmd/soroban-rpc/lib/preflight/Cargo.toml @@ -7,5 +7,6 @@ crate-type = ["staticlib"] [dependencies] libc = "0.2.2" +sha2 = "0.10.6" soroban-env-host = {workspace = true, features = ["vm"]} diff --git a/cmd/soroban-rpc/lib/preflight/src/lib.rs b/cmd/soroban-rpc/lib/preflight/src/lib.rs index 5c22e700c..301072d5a 100644 --- a/cmd/soroban-rpc/lib/preflight/src/lib.rs +++ b/cmd/soroban-rpc/lib/preflight/src/lib.rs @@ -1,23 +1,25 @@ extern crate libc; +extern crate sha2; extern crate soroban_env_host; +use sha2::{Digest, Sha256}; +use soroban_env_host::auth::RecordedAuthPayload; use soroban_env_host::budget::Budget; use soroban_env_host::storage::{self, AccessType, SnapshotSource, Storage}; use soroban_env_host::xdr::ScUnknownErrorCode::{General, Xdr}; use soroban_env_host::xdr::{ - self, AccountId, HostFunction, LedgerEntry, LedgerKey, ReadXdr, ScHostStorageErrorCode, - ScStatus, WriteXdr, + self, AccountId, AddressWithNonce, ContractAuth, HostFunction, LedgerEntry, LedgerKey, ReadXdr, + ScHostStorageErrorCode, ScStatus, WriteXdr, }; use soroban_env_host::{Host, HostError, LedgerInfo}; use std::convert::TryInto; -use std::error; use std::ffi::{CStr, CString}; use std::panic; use std::ptr::null_mut; use std::rc::Rc; +use std::{error, mem}; use xdr::LedgerFootprint; -// TODO: we may want to pass callbacks instead of using global functions extern "C" { // LedgerKey XDR in base64 string to LedgerEntry XDR in base64 string fn SnapshotSourceGet( @@ -85,11 +87,7 @@ impl From for LedgerInfo { protocol_version: c.protocol_version, sequence_number: c.sequence_number, timestamp: c.timestamp, - network_passphrase: network_passphrase_cstr - .to_str() - .unwrap() - .as_bytes() - .to_vec(), + network_id: Sha256::digest(network_passphrase_cstr.to_str().unwrap().as_bytes()).into(), base_reserve: c.base_reserve, } } @@ -117,6 +115,7 @@ pub struct CPreflightResult { pub error: *mut libc::c_char, // Error string in case of error, otherwise null pub result: *mut libc::c_char, // SCVal XDR in base64 pub footprint: *mut libc::c_char, // LedgerFootprint XDR in base64 + pub auth: *mut *mut libc::c_char, // NULL terminated array of XDR ContractAuths in base64 pub cpu_instructions: u64, pub memory_bytes: u64, } @@ -129,6 +128,7 @@ fn preflight_error(str: String) -> *mut CPreflightResult { error: c_str.into_raw(), result: null_mut(), footprint: null_mut(), + auth: null_mut(), cpu_instructions: 0, memory_bytes: 0, })) @@ -180,11 +180,13 @@ fn preflight_host_function_or_maybe_panic( let budget = Budget::default(); let host = Host::with_storage_and_budget(storage, budget); + host.switch_to_recording_auth(); host.set_source_account(source_account); host.set_ledger_info(ledger_info.into()); // Run the preflight. let result = host.invoke_function(hf)?; + let auth_records = host.get_recorded_auth_payloads()?; // Recover, convert and return the storage footprint and other values to C. let (storage, budget, _) = host.try_finish().unwrap(); @@ -196,11 +198,54 @@ fn preflight_host_function_or_maybe_panic( error: null_mut(), result: result_cstr.into_raw(), footprint: fp_cstr.into_raw(), + // TODO + auth: null_mut(), cpu_instructions: budget.get_cpu_insns_count(), memory_bytes: budget.get_mem_bytes_count(), }) } +fn recoded_auth_payloads_to_c( + payloads: Vec, +) -> Result<*mut *mut libc::c_char, Box> { + // Get a vector of base64-encoded ContractAuths + let mut out_vec: Vec<*mut libc::c_char> = Vec::new(); + for p in payloads.iter() { + let c_str = CString::new(recoded_auth_payload_to_xdr(p).to_xdr_base64()?)?.into_raw(); + out_vec.push(c_str); + } + + // Add the ending NULL + out_vec.push(null_mut()); + + // Make sure length and capacity are the same + out_vec.shrink_to_fit(); + assert!(out_vec.len() == out_vec.capacity()); + + // Get the pointer to our vector, we will deallocate it in free_preflight_result() + let ptr = out_vec.as_mut_ptr(); + mem::forget(out_vec); + + Ok(ptr) +} + +fn recoded_auth_payload_to_xdr(payload: &RecordedAuthPayload) -> ContractAuth { + let address_with_nonce = match (payload.address.clone(), payload.nonce) { + (Some(a), Some(n)) => Some(AddressWithNonce { + address: a, + nonce: n, + }), + // TODO: can the address and the nonce really be present independently? + _ => None, + }; + ContractAuth { + address_with_nonce: address_with_nonce, + root_invocation: payload.invocation.clone(), + // TODO: ??? + signature_args: Default::default(), + } +} + #[no_mangle] pub unsafe extern "C" fn free_preflight_result(result: *mut CPreflightResult) { if result.is_null() { @@ -216,6 +261,22 @@ pub unsafe extern "C" fn free_preflight_result(result: *mut CPreflightResult) { if !(*result).footprint.is_null() { let _ = CString::from_raw((*result).footprint); } + if !(*result).auth.is_null() { + // Iterate until we find a null value + let auth = (*result).auth; + let mut i: usize = 0; + loop { + let c_char_ptr = *(auth.offset(i as isize)); + if c_char_ptr.is_null() { + break; + } + // deallocate each base64 string + let _ = CString::from_raw(c_char_ptr); + i += 1; + } + // deallocate the containing vector + let _ = Vec::from_raw_parts(auth, i + 1, i + 1); + } let _ = Box::from_raw(result); } } From 216821f53ac71d9f2500ee646b61749718dfe063 Mon Sep 17 00:00:00 2001 From: Alfonso Acosta Date: Mon, 6 Feb 2023 15:41:12 +0100 Subject: [PATCH 02/18] Add extra comments --- cmd/soroban-rpc/lib/preflight/src/lib.rs | 2 ++ 1 file changed, 2 insertions(+) diff --git a/cmd/soroban-rpc/lib/preflight/src/lib.rs b/cmd/soroban-rpc/lib/preflight/src/lib.rs index 301072d5a..8ad122127 100644 --- a/cmd/soroban-rpc/lib/preflight/src/lib.rs +++ b/cmd/soroban-rpc/lib/preflight/src/lib.rs @@ -219,10 +219,12 @@ fn recoded_auth_payloads_to_c( out_vec.push(null_mut()); // Make sure length and capacity are the same + // (this allows using the length as the capacity when deallocating the vector) out_vec.shrink_to_fit(); assert!(out_vec.len() == out_vec.capacity()); // Get the pointer to our vector, we will deallocate it in free_preflight_result() + // TODO: replace by `out_vec.into_raw_parts()` once the API stabilizes let ptr = out_vec.as_mut_ptr(); mem::forget(out_vec); From 49c617b1cad2b0f9256c6a273c10e9ff79eea731 Mon Sep 17 00:00:00 2001 From: Alfonso Acosta Date: Mon, 6 Feb 2023 15:59:45 +0100 Subject: [PATCH 03/18] Bump core image --- cmd/soroban-rpc/internal/test/docker-compose.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/cmd/soroban-rpc/internal/test/docker-compose.yml b/cmd/soroban-rpc/internal/test/docker-compose.yml index 34655fb74..dd74d83f7 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 avoid implicit updates which break compatibility between # the Core container and captive core. - image: ${CORE_IMAGE:-sreuland/stellar-core:19.5.1-1137.b3a6bc281.focal-soroban} + image: ${CORE_IMAGE:-2opremio/stellar-core:19.7.1-1178.e352f0012.focal-soroban} depends_on: - core-postgres restart: on-failure From 964516edb015377d9b59cb81c20270659efbf8c9 Mon Sep 17 00:00:00 2001 From: Paul Bellamy Date: Mon, 6 Feb 2023 15:36:35 +0000 Subject: [PATCH 04/18] Fix typo --- cmd/soroban-rpc/lib/preflight/src/lib.rs | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/cmd/soroban-rpc/lib/preflight/src/lib.rs b/cmd/soroban-rpc/lib/preflight/src/lib.rs index 8ad122127..0b70f0bd8 100644 --- a/cmd/soroban-rpc/lib/preflight/src/lib.rs +++ b/cmd/soroban-rpc/lib/preflight/src/lib.rs @@ -205,13 +205,13 @@ fn preflight_host_function_or_maybe_panic( }) } -fn recoded_auth_payloads_to_c( +fn recorded_auth_payloads_to_c( payloads: Vec, ) -> Result<*mut *mut libc::c_char, Box> { // Get a vector of base64-encoded ContractAuths let mut out_vec: Vec<*mut libc::c_char> = Vec::new(); for p in payloads.iter() { - let c_str = CString::new(recoded_auth_payload_to_xdr(p).to_xdr_base64()?)?.into_raw(); + let c_str = CString::new(recorded_auth_payload_to_xdr(p).to_xdr_base64()?)?.into_raw(); out_vec.push(c_str); } @@ -231,7 +231,7 @@ fn recoded_auth_payloads_to_c( Ok(ptr) } -fn recoded_auth_payload_to_xdr(payload: &RecordedAuthPayload) -> ContractAuth { +fn recorded_auth_payload_to_xdr(payload: &RecordedAuthPayload) -> ContractAuth { let address_with_nonce = match (payload.address.clone(), payload.nonce) { (Some(a), Some(n)) => Some(AddressWithNonce { address: a, From 9f4581c3d821e3503385c2fc147bb7e213f5a149 Mon Sep 17 00:00:00 2001 From: Paul Bellamy Date: Mon, 6 Feb 2023 15:36:47 +0000 Subject: [PATCH 05/18] Actually return the auth payloads --- cmd/soroban-rpc/lib/preflight/src/lib.rs | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/cmd/soroban-rpc/lib/preflight/src/lib.rs b/cmd/soroban-rpc/lib/preflight/src/lib.rs index 0b70f0bd8..fd14abc79 100644 --- a/cmd/soroban-rpc/lib/preflight/src/lib.rs +++ b/cmd/soroban-rpc/lib/preflight/src/lib.rs @@ -186,7 +186,7 @@ fn preflight_host_function_or_maybe_panic( // Run the preflight. let result = host.invoke_function(hf)?; - let auth_records = host.get_recorded_auth_payloads()?; + let auth_payloads = host.get_recorded_auth_payloads()?; // Recover, convert and return the storage footprint and other values to C. let (storage, budget, _) = host.try_finish().unwrap(); @@ -198,8 +198,7 @@ fn preflight_host_function_or_maybe_panic( error: null_mut(), result: result_cstr.into_raw(), footprint: fp_cstr.into_raw(), - // TODO - auth: null_mut(), + auth: recorded_auth_payloads_to_c(auth_payloads)?, cpu_instructions: budget.get_cpu_insns_count(), memory_bytes: budget.get_mem_bytes_count(), }) From 2110d01e72bf12b2cf143ae779182733c945a923 Mon Sep 17 00:00:00 2001 From: Paul Bellamy Date: Mon, 6 Feb 2023 15:37:41 +0000 Subject: [PATCH 06/18] Couple style points --- cmd/soroban-rpc/lib/preflight/src/lib.rs | 7 ++----- 1 file changed, 2 insertions(+), 5 deletions(-) diff --git a/cmd/soroban-rpc/lib/preflight/src/lib.rs b/cmd/soroban-rpc/lib/preflight/src/lib.rs index fd14abc79..032da95cd 100644 --- a/cmd/soroban-rpc/lib/preflight/src/lib.rs +++ b/cmd/soroban-rpc/lib/preflight/src/lib.rs @@ -232,15 +232,12 @@ fn recorded_auth_payloads_to_c( fn recorded_auth_payload_to_xdr(payload: &RecordedAuthPayload) -> ContractAuth { let address_with_nonce = match (payload.address.clone(), payload.nonce) { - (Some(a), Some(n)) => Some(AddressWithNonce { - address: a, - nonce: n, - }), + (Some(address), Some(nonce)) => Some(AddressWithNonce { address, nonce }), // TODO: can the address and the nonce really be present independently? _ => None, }; ContractAuth { - address_with_nonce: address_with_nonce, + address_with_nonce, root_invocation: payload.invocation.clone(), // TODO: ??? signature_args: Default::default(), From 548c2b4c8028cb26271a66bc84fdaec67d4b7ae7 Mon Sep 17 00:00:00 2001 From: Paul Bellamy Date: Mon, 6 Feb 2023 15:44:11 +0000 Subject: [PATCH 07/18] Move footprint into the result object --- .../internal/methods/simulate_transaction.go | 4 +-- .../test/simulate_transaction_test.go | 34 ++++++++++--------- 2 files changed, 20 insertions(+), 18 deletions(-) diff --git a/cmd/soroban-rpc/internal/methods/simulate_transaction.go b/cmd/soroban-rpc/internal/methods/simulate_transaction.go index 185636aad..7026486d4 100644 --- a/cmd/soroban-rpc/internal/methods/simulate_transaction.go +++ b/cmd/soroban-rpc/internal/methods/simulate_transaction.go @@ -218,9 +218,9 @@ func NewSimulateTransactionHandler(logger *log.Entry, networkPassphrase string, return SimulateTransactionResponse{ Results: []SimulateTransactionResult{ { - XDR: C.GoString(res.result), - Footprint: C.GoString(res.preflight), Auth: auth, + Footprint: C.GoString(res.preflight), + XDR: C.GoString(res.result), }, }, Cost: SimulateTransactionCost{ diff --git a/cmd/soroban-rpc/internal/test/simulate_transaction_test.go b/cmd/soroban-rpc/internal/test/simulate_transaction_test.go index b3f735782..3f824832b 100644 --- a/cmd/soroban-rpc/internal/test/simulate_transaction_test.go +++ b/cmd/soroban-rpc/internal/test/simulate_transaction_test.go @@ -210,13 +210,15 @@ func TestSimulateTransactionSucceeds(t *testing.T) { assert.Equal( t, methods.SimulateTransactionResponse{ - Footprint: "AAAAAAAAAAEAAAAH6p/Lga5Uop9rO/KThH0/1+mjaf0cgKyv7Gq9VxMX4MI=", Cost: methods.SimulateTransactionCost{ CPUInstructions: result.Cost.CPUInstructions, MemoryBytes: result.Cost.MemoryBytes, }, Results: []methods.SimulateTransactionResult{ - {XDR: "AAAABAAAAAEAAAAGAAAAIOqfy4GuVKKfazvyk4R9P9fpo2n9HICsr+xqvVcTF+DC"}, + { + Footprint: "AAAAAAAAAAEAAAAH6p/Lga5Uop9rO/KThH0/1+mjaf0cgKyv7Gq9VxMX4MI=", + XDR: "AAAABAAAAAEAAAAGAAAAIOqfy4GuVKKfazvyk4R9P9fpo2n9HICsr+xqvVcTF+DC", + }, }, LatestLedger: result.LatestLedger, }, @@ -345,9 +347,22 @@ func TestSimulateInvokeContractTransactionSucceeds(t *testing.T) { assert.NoError(t, err) assert.Empty(t, response.Error) + // check the result + assert.Len(t, response.Results, 1) + var obtainedResult xdr.ScVal + err = xdr.SafeUnmarshalBase64(response.Results[0].XDR, &obtainedResult) + assert.NoError(t, err) + assert.Equal(t, xdr.ScValTypeScvObject, obtainedResult.Type) + obj := *obtainedResult.Obj + assert.Equal(t, xdr.ScObjectTypeScoVec, obj.Type) + assert.Len(t, *obj.Vec, 2) + world := (*obj.Vec)[1] + assert.Equal(t, xdr.ScValTypeScvSymbol, world.Type) + assert.Equal(t, xdr.ScSymbol("world"), *world.Sym) + // check the footprint var obtainedFootprint xdr.LedgerFootprint - err = xdr.SafeUnmarshalBase64(response.Footprint, &obtainedFootprint) + err = xdr.SafeUnmarshalBase64(response.Results[0].Footprint, &obtainedFootprint) assert.NoError(t, err) assert.Len(t, obtainedFootprint.ReadWrite, 0) assert.Len(t, obtainedFootprint.ReadOnly, 2) @@ -364,19 +379,6 @@ func TestSimulateInvokeContractTransactionSucceeds(t *testing.T) { assert.Equal(t, xdr.Hash(contractHash), ro2.ContractCode.Hash) assert.NoError(t, err) - // check the result - assert.Len(t, response.Results, 1) - var obtainedResult xdr.ScVal - err = xdr.SafeUnmarshalBase64(response.Results[0].XDR, &obtainedResult) - assert.NoError(t, err) - assert.Equal(t, xdr.ScValTypeScvObject, obtainedResult.Type) - obj := *obtainedResult.Obj - assert.Equal(t, xdr.ScObjectTypeScoVec, obj.Type) - assert.Len(t, *obj.Vec, 2) - world := (*obj.Vec)[1] - assert.Equal(t, xdr.ScValTypeScvSymbol, world.Type) - assert.Equal(t, xdr.ScSymbol("world"), *world.Sym) - } func TestSimulateTransactionError(t *testing.T) { From 2a38c52ea494cb944fd3b2022835b6c954de1626 Mon Sep 17 00:00:00 2001 From: Paul Bellamy Date: Mon, 6 Feb 2023 15:52:04 +0000 Subject: [PATCH 08/18] add comment --- cmd/soroban-rpc/lib/preflight/src/lib.rs | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/cmd/soroban-rpc/lib/preflight/src/lib.rs b/cmd/soroban-rpc/lib/preflight/src/lib.rs index 032da95cd..5c2a19cc4 100644 --- a/cmd/soroban-rpc/lib/preflight/src/lib.rs +++ b/cmd/soroban-rpc/lib/preflight/src/lib.rs @@ -239,7 +239,8 @@ fn recorded_auth_payload_to_xdr(payload: &RecordedAuthPayload) -> ContractAuth { ContractAuth { address_with_nonce, root_invocation: payload.invocation.clone(), - // TODO: ??? + // signature_args is left empty. This is where the client will put their signatures when + // submitting the transaction. signature_args: Default::default(), } } From b38f5bc3ab00096e6434ce252c4f969a94b804c7 Mon Sep 17 00:00:00 2001 From: Paul Bellamy Date: Mon, 6 Feb 2023 10:28:17 +0000 Subject: [PATCH 09/18] Update go dep --- go.mod | 2 +- go.sum | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/go.mod b/go.mod index 51ee7e88d..53beadd30 100644 --- a/go.mod +++ b/go.mod @@ -64,7 +64,7 @@ require ( github.com/spf13/cast v0.0.0-20150508191742-4d07383ffe94 // indirect github.com/spf13/jwalterweatherman v0.0.0-20141219030609-3d60171a6431 // indirect github.com/spf13/pflag v0.0.0-20161005214240-4bd69631f475 // indirect - github.com/stellar/go v0.0.0-20230126104422-77cf2ca9d550 + github.com/stellar/go v0.0.0-20230202232356-8c3f4c0c23e9 github.com/stellar/go-xdr v0.0.0-20211103144802-8017fc4bdfee // indirect github.com/stretchr/objx v0.4.0 // indirect github.com/xanzy/ssh-agent v0.3.0 // indirect diff --git a/go.sum b/go.sum index bb95fa82e..b8dacab77 100644 --- a/go.sum +++ b/go.sum @@ -169,8 +169,8 @@ github.com/spf13/pflag v0.0.0-20161005214240-4bd69631f475 h1:RtZIgreTwcayPTOw7G5 github.com/spf13/pflag v0.0.0-20161005214240-4bd69631f475/go.mod h1:DYY7MBk1bdzusC3SYhjObp+wFpr4gzcvqqNjLnInEg4= github.com/spf13/viper v0.0.0-20150621231900-db7ff930a189 h1:fvB1AFbBd6SfI9Rd0ooAJp8uLkZDbZaLFHi7ZnNP6uI= github.com/spf13/viper v0.0.0-20150621231900-db7ff930a189/go.mod h1:A8kyI5cUJhb8N+3pkfONlcEcZbueH6nhAm0Fq7SrnBM= -github.com/stellar/go v0.0.0-20230126104422-77cf2ca9d550 h1:GTz5CZnj0dhXin0zyTt9jZixS6X0B/aDcNn7bkKt9IU= -github.com/stellar/go v0.0.0-20230126104422-77cf2ca9d550/go.mod h1:QXwuKmYVvqQZlByv0EeNb0Rgog9AP+eMmARcdt3h2rI= +github.com/stellar/go v0.0.0-20230202232356-8c3f4c0c23e9 h1:MztElpcOTUdgP/VbTuNnYKcR3vzLsab+ACRgezyilgo= +github.com/stellar/go v0.0.0-20230202232356-8c3f4c0c23e9/go.mod h1:QXwuKmYVvqQZlByv0EeNb0Rgog9AP+eMmARcdt3h2rI= github.com/stellar/go-xdr v0.0.0-20211103144802-8017fc4bdfee h1:fbVs0xmXpBvVS4GBeiRmAE3Le70ofAqFMch1GTiq/e8= github.com/stellar/go-xdr v0.0.0-20211103144802-8017fc4bdfee/go.mod h1:yoxyU/M8nl9LKeWIoBrbDPQ7Cy+4jxRcWcOayZ4BMps= github.com/stretchr/objx v0.1.0/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+wExME= From cefa211da4e4c75ebaf293eeb0e58215d9506eae Mon Sep 17 00:00:00 2001 From: Alfonso Acosta Date: Mon, 6 Feb 2023 20:39:42 +0100 Subject: [PATCH 10/18] Align Rust SDK end Env dependencies --- Cargo.lock | 95 +++++++++++++++++++++--------------------------------- Cargo.toml | 10 +++--- 2 files changed, 42 insertions(+), 63 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index e2d0b28d8..af815fd1a 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -1317,7 +1317,7 @@ version = "0.1.0" dependencies = [ "libc", "sha2 0.10.6", - "soroban-env-host 0.0.12 (git+https://github.com/stellar/rs-soroban-env?rev=66a079a4e400836f1b896c9b02d6e37fea028312)", + "soroban-env-host 0.0.12 (git+https://github.com/stellar/rs-soroban-env?rev=c8583e3e12e1f8ac087efa4453ad4f7c4ebf41fe)", ] [[package]] @@ -1803,14 +1803,6 @@ dependencies = [ "winapi", ] -[[package]] -name = "soroban-auth" -version = "0.4.3" -source = "git+https://github.com/stellar/rs-soroban-sdk?rev=e1c3de33942f0e997680645941787102ebf61e85#e1c3de33942f0e997680645941787102ebf61e85" -dependencies = [ - "soroban-sdk", -] - [[package]] name = "soroban-cli" version = "0.4.0" @@ -1835,12 +1827,12 @@ dependencies = [ "serde_derive", "serde_json", "sha2 0.10.6", - "soroban-env-host 0.0.12 (git+https://github.com/stellar/rs-soroban-env?rev=66a079a4e400836f1b896c9b02d6e37fea028312)", + "soroban-env-host 0.0.12 (git+https://github.com/stellar/rs-soroban-env?rev=c8583e3e12e1f8ac087efa4453ad4f7c4ebf41fe)", "soroban-ledger-snapshot", "soroban-sdk", "soroban-spec", "soroban-token-spec", - "stellar-strkey 0.0.7", + "stellar-strkey 0.0.7 (git+https://github.com/stellar/rs-stellar-strkey?rev=6e9bb10)", "termcolor", "termcolor_output", "thiserror", @@ -1853,42 +1845,42 @@ dependencies = [ [[package]] name = "soroban-env-common" version = "0.0.12" -source = "git+https://github.com/stellar/rs-soroban-env?rev=66a079a4e400836f1b896c9b02d6e37fea028312#66a079a4e400836f1b896c9b02d6e37fea028312" +source = "git+https://github.com/stellar/rs-soroban-env?rev=c8583e3e#c8583e3e12e1f8ac087efa4453ad4f7c4ebf41fe" dependencies = [ "crate-git-revision", "serde", - "soroban-env-macros 0.0.12 (git+https://github.com/stellar/rs-soroban-env?rev=66a079a4e400836f1b896c9b02d6e37fea028312)", + "soroban-env-macros 0.0.12 (git+https://github.com/stellar/rs-soroban-env?rev=c8583e3e)", "soroban-wasmi", "static_assertions", - "stellar-xdr 0.0.12 (git+https://github.com/stellar/rs-stellar-xdr?rev=6c72271b)", + "stellar-xdr", ] [[package]] name = "soroban-env-common" version = "0.0.12" -source = "git+https://github.com/stellar/rs-soroban-env?rev=993c527abce72748405d71467498bffd63e061c1#993c527abce72748405d71467498bffd63e061c1" +source = "git+https://github.com/stellar/rs-soroban-env?rev=c8583e3e12e1f8ac087efa4453ad4f7c4ebf41fe#c8583e3e12e1f8ac087efa4453ad4f7c4ebf41fe" dependencies = [ "crate-git-revision", "serde", - "soroban-env-macros 0.0.12 (git+https://github.com/stellar/rs-soroban-env?rev=993c527abce72748405d71467498bffd63e061c1)", + "soroban-env-macros 0.0.12 (git+https://github.com/stellar/rs-soroban-env?rev=c8583e3e12e1f8ac087efa4453ad4f7c4ebf41fe)", "soroban-wasmi", "static_assertions", - "stellar-xdr 0.0.12 (git+https://github.com/stellar/rs-stellar-xdr?rev=154e07e)", + "stellar-xdr", ] [[package]] name = "soroban-env-guest" version = "0.0.12" -source = "git+https://github.com/stellar/rs-soroban-env?rev=993c527abce72748405d71467498bffd63e061c1#993c527abce72748405d71467498bffd63e061c1" +source = "git+https://github.com/stellar/rs-soroban-env?rev=c8583e3e#c8583e3e12e1f8ac087efa4453ad4f7c4ebf41fe" dependencies = [ - "soroban-env-common 0.0.12 (git+https://github.com/stellar/rs-soroban-env?rev=993c527abce72748405d71467498bffd63e061c1)", + "soroban-env-common 0.0.12 (git+https://github.com/stellar/rs-soroban-env?rev=c8583e3e)", "static_assertions", ] [[package]] name = "soroban-env-host" version = "0.0.12" -source = "git+https://github.com/stellar/rs-soroban-env?rev=66a079a4e400836f1b896c9b02d6e37fea028312#66a079a4e400836f1b896c9b02d6e37fea028312" +source = "git+https://github.com/stellar/rs-soroban-env?rev=c8583e3e#c8583e3e12e1f8ac087efa4453ad4f7c4ebf41fe" dependencies = [ "backtrace", "curve25519-dalek", @@ -1900,8 +1892,8 @@ dependencies = [ "num-integer", "num-traits", "sha2 0.10.6", - "soroban-env-common 0.0.12 (git+https://github.com/stellar/rs-soroban-env?rev=66a079a4e400836f1b896c9b02d6e37fea028312)", - "soroban-native-sdk-macros 0.0.12 (git+https://github.com/stellar/rs-soroban-env?rev=66a079a4e400836f1b896c9b02d6e37fea028312)", + "soroban-env-common 0.0.12 (git+https://github.com/stellar/rs-soroban-env?rev=c8583e3e)", + "soroban-native-sdk-macros 0.0.12 (git+https://github.com/stellar/rs-soroban-env?rev=c8583e3e)", "soroban-wasmi", "static_assertions", "tinyvec", @@ -1910,7 +1902,7 @@ dependencies = [ [[package]] name = "soroban-env-host" version = "0.0.12" -source = "git+https://github.com/stellar/rs-soroban-env?rev=993c527abce72748405d71467498bffd63e061c1#993c527abce72748405d71467498bffd63e061c1" +source = "git+https://github.com/stellar/rs-soroban-env?rev=c8583e3e12e1f8ac087efa4453ad4f7c4ebf41fe#c8583e3e12e1f8ac087efa4453ad4f7c4ebf41fe" dependencies = [ "backtrace", "curve25519-dalek", @@ -1922,8 +1914,8 @@ dependencies = [ "num-integer", "num-traits", "sha2 0.10.6", - "soroban-env-common 0.0.12 (git+https://github.com/stellar/rs-soroban-env?rev=993c527abce72748405d71467498bffd63e061c1)", - "soroban-native-sdk-macros 0.0.12 (git+https://github.com/stellar/rs-soroban-env?rev=993c527abce72748405d71467498bffd63e061c1)", + "soroban-env-common 0.0.12 (git+https://github.com/stellar/rs-soroban-env?rev=c8583e3e12e1f8ac087efa4453ad4f7c4ebf41fe)", + "soroban-native-sdk-macros 0.0.12 (git+https://github.com/stellar/rs-soroban-env?rev=c8583e3e12e1f8ac087efa4453ad4f7c4ebf41fe)", "soroban-wasmi", "static_assertions", "tinyvec", @@ -1932,14 +1924,14 @@ dependencies = [ [[package]] name = "soroban-env-macros" version = "0.0.12" -source = "git+https://github.com/stellar/rs-soroban-env?rev=66a079a4e400836f1b896c9b02d6e37fea028312#66a079a4e400836f1b896c9b02d6e37fea028312" +source = "git+https://github.com/stellar/rs-soroban-env?rev=c8583e3e#c8583e3e12e1f8ac087efa4453ad4f7c4ebf41fe" dependencies = [ "itertools", "proc-macro2", "quote", "serde", "serde_json", - "stellar-xdr 0.0.12 (git+https://github.com/stellar/rs-stellar-xdr?rev=6c72271b)", + "stellar-xdr", "syn", "thiserror", ] @@ -1947,14 +1939,14 @@ dependencies = [ [[package]] name = "soroban-env-macros" version = "0.0.12" -source = "git+https://github.com/stellar/rs-soroban-env?rev=993c527abce72748405d71467498bffd63e061c1#993c527abce72748405d71467498bffd63e061c1" +source = "git+https://github.com/stellar/rs-soroban-env?rev=c8583e3e12e1f8ac087efa4453ad4f7c4ebf41fe#c8583e3e12e1f8ac087efa4453ad4f7c4ebf41fe" dependencies = [ "itertools", "proc-macro2", "quote", "serde", "serde_json", - "stellar-xdr 0.0.12 (git+https://github.com/stellar/rs-stellar-xdr?rev=154e07e)", + "stellar-xdr", "syn", "thiserror", ] @@ -1962,18 +1954,18 @@ dependencies = [ [[package]] name = "soroban-ledger-snapshot" version = "0.4.3" -source = "git+https://github.com/stellar/rs-soroban-sdk?rev=e1c3de33942f0e997680645941787102ebf61e85#e1c3de33942f0e997680645941787102ebf61e85" +source = "git+https://github.com/stellar/rs-soroban-sdk?rev=e7910c7057088b3418d84af04f2c04313d0c756f#e7910c7057088b3418d84af04f2c04313d0c756f" dependencies = [ "serde", "serde_json", - "soroban-env-host 0.0.12 (git+https://github.com/stellar/rs-soroban-env?rev=993c527abce72748405d71467498bffd63e061c1)", + "soroban-env-host 0.0.12 (git+https://github.com/stellar/rs-soroban-env?rev=c8583e3e)", "thiserror", ] [[package]] name = "soroban-native-sdk-macros" version = "0.0.12" -source = "git+https://github.com/stellar/rs-soroban-env?rev=66a079a4e400836f1b896c9b02d6e37fea028312#66a079a4e400836f1b896c9b02d6e37fea028312" +source = "git+https://github.com/stellar/rs-soroban-env?rev=c8583e3e#c8583e3e12e1f8ac087efa4453ad4f7c4ebf41fe" dependencies = [ "itertools", "proc-macro2", @@ -1984,7 +1976,7 @@ dependencies = [ [[package]] name = "soroban-native-sdk-macros" version = "0.0.12" -source = "git+https://github.com/stellar/rs-soroban-env?rev=993c527abce72748405d71467498bffd63e061c1#993c527abce72748405d71467498bffd63e061c1" +source = "git+https://github.com/stellar/rs-soroban-env?rev=c8583e3e12e1f8ac087efa4453ad4f7c4ebf41fe#c8583e3e12e1f8ac087efa4453ad4f7c4ebf41fe" dependencies = [ "itertools", "proc-macro2", @@ -1995,38 +1987,38 @@ dependencies = [ [[package]] name = "soroban-sdk" version = "0.4.3" -source = "git+https://github.com/stellar/rs-soroban-sdk?rev=e1c3de33942f0e997680645941787102ebf61e85#e1c3de33942f0e997680645941787102ebf61e85" +source = "git+https://github.com/stellar/rs-soroban-sdk?rev=e7910c7057088b3418d84af04f2c04313d0c756f#e7910c7057088b3418d84af04f2c04313d0c756f" dependencies = [ "bytes-lit", "ed25519-dalek", "rand 0.8.5", "soroban-env-guest", - "soroban-env-host 0.0.12 (git+https://github.com/stellar/rs-soroban-env?rev=993c527abce72748405d71467498bffd63e061c1)", + "soroban-env-host 0.0.12 (git+https://github.com/stellar/rs-soroban-env?rev=c8583e3e)", "soroban-ledger-snapshot", "soroban-sdk-macros", - "stellar-strkey 0.0.6", + "stellar-strkey 0.0.7 (git+https://github.com/stellar/rs-stellar-strkey)", ] [[package]] name = "soroban-sdk-macros" version = "0.4.3" -source = "git+https://github.com/stellar/rs-soroban-sdk?rev=e1c3de33942f0e997680645941787102ebf61e85#e1c3de33942f0e997680645941787102ebf61e85" +source = "git+https://github.com/stellar/rs-soroban-sdk?rev=e7910c7057088b3418d84af04f2c04313d0c756f#e7910c7057088b3418d84af04f2c04313d0c756f" dependencies = [ "darling", "itertools", "proc-macro2", "quote", "sha2 0.10.6", - "soroban-env-common 0.0.12 (git+https://github.com/stellar/rs-soroban-env?rev=993c527abce72748405d71467498bffd63e061c1)", + "soroban-env-common 0.0.12 (git+https://github.com/stellar/rs-soroban-env?rev=c8583e3e)", "soroban-spec", - "stellar-xdr 0.0.12 (git+https://github.com/stellar/rs-stellar-xdr?rev=154e07e)", + "stellar-xdr", "syn", ] [[package]] name = "soroban-spec" version = "0.4.3" -source = "git+https://github.com/stellar/rs-soroban-sdk?rev=e1c3de33942f0e997680645941787102ebf61e85#e1c3de33942f0e997680645941787102ebf61e85" +source = "git+https://github.com/stellar/rs-soroban-sdk?rev=e7910c7057088b3418d84af04f2c04313d0c756f#e7910c7057088b3418d84af04f2c04313d0c756f" dependencies = [ "base64 0.13.1", "darling", @@ -2038,7 +2030,7 @@ dependencies = [ "serde_derive", "serde_json", "sha2 0.10.6", - "stellar-xdr 0.0.12 (git+https://github.com/stellar/rs-stellar-xdr?rev=154e07e)", + "stellar-xdr", "syn", "thiserror", "wasmparser 0.88.0", @@ -2047,9 +2039,8 @@ dependencies = [ [[package]] name = "soroban-token-spec" version = "0.4.3" -source = "git+https://github.com/stellar/rs-soroban-sdk?rev=e1c3de33942f0e997680645941787102ebf61e85#e1c3de33942f0e997680645941787102ebf61e85" +source = "git+https://github.com/stellar/rs-soroban-sdk?rev=e7910c7057088b3418d84af04f2c04313d0c756f#e7910c7057088b3418d84af04f2c04313d0c756f" dependencies = [ - "soroban-auth", "soroban-sdk", ] @@ -2095,8 +2086,8 @@ checksum = "a2eb9349b6444b326872e140eb1cf5e7c522154d69e7a0ffb0fb81c06b37543f" [[package]] name = "stellar-strkey" -version = "0.0.6" -source = "git+https://github.com/stellar/rs-stellar-strkey?rev=5e582a8b#5e582a8b48f85443df60dc78e2e98959862400d6" +version = "0.0.7" +source = "git+https://github.com/stellar/rs-stellar-strkey?rev=6e9bb10#6e9bb102249585e851bf36be2ab069a1955c3b09" dependencies = [ "base32", "thiserror", @@ -2105,24 +2096,12 @@ dependencies = [ [[package]] name = "stellar-strkey" version = "0.0.7" -source = "git+https://github.com/stellar/rs-stellar-strkey?rev=6e9bb10#6e9bb102249585e851bf36be2ab069a1955c3b09" +source = "git+https://github.com/stellar/rs-stellar-strkey#e6ba45c60c16de28c7522586b80ed0150157df73" dependencies = [ "base32", "thiserror", ] -[[package]] -name = "stellar-xdr" -version = "0.0.12" -source = "git+https://github.com/stellar/rs-stellar-xdr?rev=154e07e#154e07ebbb0ad307475fd665d5a0dcf169a9596f" -dependencies = [ - "base64 0.13.1", - "crate-git-revision", - "hex", - "serde", - "serde_with", -] - [[package]] name = "stellar-xdr" version = "0.0.12" diff --git a/Cargo.toml b/Cargo.toml index 88f40bccb..95fa393ad 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -10,27 +10,27 @@ default-members = ["cmd/soroban-cli"] [workspace.dependencies.soroban-env-host] version = "0.0.12" git = "https://github.com/stellar/rs-soroban-env" -rev = "66a079a4e400836f1b896c9b02d6e37fea028312" +rev = "c8583e3e12e1f8ac087efa4453ad4f7c4ebf41fe" [workspace.dependencies.soroban-spec] version = "0.4.1" git = "https://github.com/stellar/rs-soroban-sdk" -rev = "e1c3de33942f0e997680645941787102ebf61e85" +rev = "e7910c7057088b3418d84af04f2c04313d0c756f" [workspace.dependencies.soroban-token-spec] version = "0.4.1" git = "https://github.com/stellar/rs-soroban-sdk" -rev = "e1c3de33942f0e997680645941787102ebf61e85" +rev = "e7910c7057088b3418d84af04f2c04313d0c756f" [workspace.dependencies.soroban-sdk] version = "0.4.1" git = "https://github.com/stellar/rs-soroban-sdk" -rev = "e1c3de33942f0e997680645941787102ebf61e85" +rev = "e7910c7057088b3418d84af04f2c04313d0c756f" [workspace.dependencies.soroban-ledger-snapshot] version = "0.4.1" git = "https://github.com/stellar/rs-soroban-sdk" -rev = "e1c3de33942f0e997680645941787102ebf61e85" +rev = "e7910c7057088b3418d84af04f2c04313d0c756f" [workspace.dependencies.stellar-strkey] version = "0.0.7" From def790ce91e22caff14ce9fc7fe5863942d43587 Mon Sep 17 00:00:00 2001 From: Alfonso Acosta Date: Mon, 6 Feb 2023 21:06:42 +0100 Subject: [PATCH 11/18] Make test wasms compile --- .../test-wasms/custom_type/src/lib.rs | 6 +-- .../invoker_account_exists/Cargo.toml | 18 --------- .../invoker_account_exists/src/lib.rs | 39 ------------------- 3 files changed, 3 insertions(+), 60 deletions(-) delete mode 100644 cmd/soroban-cli/tests/fixtures/test-wasms/invoker_account_exists/Cargo.toml delete mode 100644 cmd/soroban-cli/tests/fixtures/test-wasms/invoker_account_exists/src/lib.rs diff --git a/cmd/soroban-cli/tests/fixtures/test-wasms/custom_type/src/lib.rs b/cmd/soroban-cli/tests/fixtures/test-wasms/custom_type/src/lib.rs index 94a125f7d..5406c5734 100644 --- a/cmd/soroban-cli/tests/fixtures/test-wasms/custom_type/src/lib.rs +++ b/cmd/soroban-cli/tests/fixtures/test-wasms/custom_type/src/lib.rs @@ -1,5 +1,5 @@ #![no_std] -use soroban_sdk::{contractimpl, contracttype, symbol, vec, AccountId, Bytes, Env, Symbol, Vec}; +use soroban_sdk::{contractimpl, contracttype, symbol, vec, Address, Bytes, Env, Symbol, Vec}; pub struct Contract; @@ -63,8 +63,8 @@ impl Contract { complex } - pub fn account(_env: Env, account: AccountId) -> AccountId { - account + pub fn account(_env: Env, address: Address) -> Address { + address } pub fn bytes(_env: Env, bytes: Bytes) -> Bytes { diff --git a/cmd/soroban-cli/tests/fixtures/test-wasms/invoker_account_exists/Cargo.toml b/cmd/soroban-cli/tests/fixtures/test-wasms/invoker_account_exists/Cargo.toml deleted file mode 100644 index 3a7b7c867..000000000 --- a/cmd/soroban-cli/tests/fixtures/test-wasms/invoker_account_exists/Cargo.toml +++ /dev/null @@ -1,18 +0,0 @@ -[package] -name = "test_invoker_account_exists" -version = "0.4.0" -authors = ["Stellar Development Foundation "] -license = "Apache-2.0" -edition = "2021" -publish = false -rust-version = "1.66" - -[lib] -crate-type = ["cdylib", "rlib"] -doctest = false - -[dependencies] -soroban-sdk = { workspace = true } - -[dev-dependencies] -soroban-sdk = { workspace = true, features = ["testutils"]} diff --git a/cmd/soroban-cli/tests/fixtures/test-wasms/invoker_account_exists/src/lib.rs b/cmd/soroban-cli/tests/fixtures/test-wasms/invoker_account_exists/src/lib.rs deleted file mode 100644 index 221060570..000000000 --- a/cmd/soroban-cli/tests/fixtures/test-wasms/invoker_account_exists/src/lib.rs +++ /dev/null @@ -1,39 +0,0 @@ -#![no_std] -use soroban_sdk::{contracterror, contractimpl, panic_with_error, Address, Env}; - -#[contracterror] -#[derive(Copy, Clone)] -#[repr(u32)] -pub enum Error { - InvokerIsContract = 1, -} - -pub struct Contract; - -#[contractimpl] -impl Contract { - pub fn invkexists(env: Env) -> bool { - match env.invoker() { - Address::Account(account_id) => env.accounts().get(&account_id).is_some(), - Address::Contract(_) => panic_with_error!(&env, Error::InvokerIsContract), - } - } -} - -#[cfg(test)] -mod test { - use soroban_sdk::{testutils::Accounts, Env}; - - use crate::{Contract, ContractClient}; - - #[test] - fn test_invoker() { - let env = Env::default(); - let contract_id = env.register_contract(None, Contract); - let client = ContractClient::new(&env, &contract_id); - - let addr = env.accounts().generate(); - let exists = client.with_source_account(&addr).invkexists(); - assert!(exists); - } -} From 51e98b1b886b2aeb60729c8101f9cd75ff8d1076 Mon Sep 17 00:00:00 2001 From: Paul Bellamy Date: Mon, 6 Feb 2023 20:52:45 +0000 Subject: [PATCH 12/18] update strkey rust dependency --- Cargo.lock | 11 ++--------- Cargo.toml | 2 +- 2 files changed, 3 insertions(+), 10 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index af815fd1a..76c14e741 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -1832,7 +1832,7 @@ dependencies = [ "soroban-sdk", "soroban-spec", "soroban-token-spec", - "stellar-strkey 0.0.7 (git+https://github.com/stellar/rs-stellar-strkey?rev=6e9bb10)", + "stellar-strkey 0.0.7 (git+https://github.com/stellar/rs-stellar-strkey?rev=e6ba45c60c16de28c7522586b80ed0150157df73)", "termcolor", "termcolor_output", "thiserror", @@ -2087,7 +2087,7 @@ checksum = "a2eb9349b6444b326872e140eb1cf5e7c522154d69e7a0ffb0fb81c06b37543f" [[package]] name = "stellar-strkey" version = "0.0.7" -source = "git+https://github.com/stellar/rs-stellar-strkey?rev=6e9bb10#6e9bb102249585e851bf36be2ab069a1955c3b09" +source = "git+https://github.com/stellar/rs-stellar-strkey?rev=e6ba45c60c16de28c7522586b80ed0150157df73#e6ba45c60c16de28c7522586b80ed0150157df73" dependencies = [ "base32", "thiserror", @@ -2227,13 +2227,6 @@ dependencies = [ "soroban-sdk", ] -[[package]] -name = "test_invoker_account_exists" -version = "0.4.0" -dependencies = [ - "soroban-sdk", -] - [[package]] name = "textwrap" version = "0.16.0" diff --git a/Cargo.toml b/Cargo.toml index 95fa393ad..97d2a76bd 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -35,7 +35,7 @@ rev = "e7910c7057088b3418d84af04f2c04313d0c756f" [workspace.dependencies.stellar-strkey] version = "0.0.7" git = "https://github.com/stellar/rs-stellar-strkey" -rev = "6e9bb10" +rev = "e6ba45c60c16de28c7522586b80ed0150157df73" # [patch."https://github.com/stellar/rs-soroban-env"] # soroban-env-host = { path = "../rs-soroban-env/soroban-env-host/" } From e15a8b35a2559dd4142e91f43256f2270151a2cd Mon Sep 17 00:00:00 2001 From: Paul Bellamy Date: Mon, 6 Feb 2023 20:57:54 +0000 Subject: [PATCH 13/18] Trying to update simulateTransaction test to check auth --- .../test-wasms/hello_world/src/lib.rs | 7 +++- .../test/simulate_transaction_test.go | 38 +++++++++++++++++-- 2 files changed, 40 insertions(+), 5 deletions(-) diff --git a/cmd/soroban-cli/tests/fixtures/test-wasms/hello_world/src/lib.rs b/cmd/soroban-cli/tests/fixtures/test-wasms/hello_world/src/lib.rs index f42c3c745..278146001 100644 --- a/cmd/soroban-cli/tests/fixtures/test-wasms/hello_world/src/lib.rs +++ b/cmd/soroban-cli/tests/fixtures/test-wasms/hello_world/src/lib.rs @@ -1,5 +1,5 @@ #![no_std] -use soroban_sdk::{contractimpl, symbol, vec, Env, Symbol, Vec}; +use soroban_sdk::{contractimpl, symbol, vec, Address, Env, Symbol, Vec}; pub struct Contract; @@ -16,6 +16,11 @@ impl Contract { pub fn not(env: Env, boolean: bool) -> Vec { vec![&env, !boolean] } + + pub fn auth(env: Env, addr: Address, world: Symbol) -> Vec { + addr.require_auth(vec![&env, world.into()]); + vec![&env, symbol!("Hello"), world] + } } #[cfg(test)] diff --git a/cmd/soroban-rpc/internal/test/simulate_transaction_test.go b/cmd/soroban-rpc/internal/test/simulate_transaction_test.go index 3f824832b..dfef5afea 100644 --- a/cmd/soroban-rpc/internal/test/simulate_transaction_test.go +++ b/cmd/soroban-rpc/internal/test/simulate_transaction_test.go @@ -216,6 +216,7 @@ func TestSimulateTransactionSucceeds(t *testing.T) { }, Results: []methods.SimulateTransactionResult{ { + Auth: []string{"TODO"}, Footprint: "AAAAAAAAAAEAAAAH6p/Lga5Uop9rO/KThH0/1+mjaf0cgKyv7Gq9VxMX4MI=", XDR: "AAAABAAAAAEAAAAGAAAAIOqfy4GuVKKfazvyk4R9P9fpo2n9HICsr+xqvVcTF+DC", }, @@ -322,15 +323,38 @@ func TestSimulateInvokeContractTransactionSucceeds(t *testing.T) { contractID := getContractID(t, address, testSalt, StandaloneNetworkPassphrase) contractFnParameterSym := xdr.ScSymbol("world") - contractFnParameter := xdr.ScVal{ - Type: xdr.ScValTypeScvSymbol, - Sym: &contractFnParameterSym, + sourceAccountIDBytes, err := sourceAccount.FromAddress().MarshalBinary() + assert.NoError(t, err) + var sourceAccountID xdr.Uint256 + copy(sourceAccountID[:], sourceAccountIDBytes) + addressObject := &xdr.ScObject{ + Type: xdr.ScObjectTypeScoAddress, + Address: &xdr.ScAddress{ + Type: xdr.ScAddressTypeScAddressTypeAccount, + AccountId: &xdr.AccountId{ + Type: xdr.PublicKeyTypePublicKeyTypeEd25519, + Ed25519: &sourceAccountID, + }, + }, } tx, err = txnbuild.NewTransaction(txnbuild.TransactionParams{ SourceAccount: &account, IncrementSequenceNum: true, Operations: []txnbuild.Operation{ - createInvokeHostOperation(address, xdr.LedgerFootprint{}, contractID, "hello", contractFnParameter), + createInvokeHostOperation( + address, + xdr.LedgerFootprint{}, + contractID, + "auth", + xdr.ScVal{ + Type: xdr.ScValTypeScvObject, + Obj: &addressObject, + }, + xdr.ScVal{ + Type: xdr.ScValTypeScvSymbol, + Sym: &contractFnParameterSym, + }, + ), }, BaseFee: txnbuild.MinBaseFee, Preconditions: txnbuild.Preconditions{ @@ -379,6 +403,12 @@ func TestSimulateInvokeContractTransactionSucceeds(t *testing.T) { assert.Equal(t, xdr.Hash(contractHash), ro2.ContractCode.Hash) assert.NoError(t, err) + // check the auth + assert.Len(t, response.Results[0].Auth, 1) + var obtainedAuth xdr.ContractAuth + err = xdr.SafeUnmarshalBase64(response.Results[0].Auth[0], &obtainedAuth) + assert.NoError(t, err) + // TODO: check the auth } func TestSimulateTransactionError(t *testing.T) { From ffd44c95737d04aa607af686e2a15cec0500a783 Mon Sep 17 00:00:00 2001 From: Paul Bellamy Date: Mon, 6 Feb 2023 21:27:13 +0000 Subject: [PATCH 14/18] WIP-- working on auth test for rpc --- cmd/soroban-rpc/internal/test/simulate_transaction_test.go | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/cmd/soroban-rpc/internal/test/simulate_transaction_test.go b/cmd/soroban-rpc/internal/test/simulate_transaction_test.go index dfef5afea..d38dafde9 100644 --- a/cmd/soroban-rpc/internal/test/simulate_transaction_test.go +++ b/cmd/soroban-rpc/internal/test/simulate_transaction_test.go @@ -216,7 +216,6 @@ func TestSimulateTransactionSucceeds(t *testing.T) { }, Results: []methods.SimulateTransactionResult{ { - Auth: []string{"TODO"}, Footprint: "AAAAAAAAAAEAAAAH6p/Lga5Uop9rO/KThH0/1+mjaf0cgKyv7Gq9VxMX4MI=", XDR: "AAAABAAAAAEAAAAGAAAAIOqfy4GuVKKfazvyk4R9P9fpo2n9HICsr+xqvVcTF+DC", }, @@ -385,10 +384,11 @@ func TestSimulateInvokeContractTransactionSucceeds(t *testing.T) { assert.Equal(t, xdr.ScSymbol("world"), *world.Sym) // check the footprint + t.Log("Footprint:", response.Results[0].Footprint) var obtainedFootprint xdr.LedgerFootprint err = xdr.SafeUnmarshalBase64(response.Results[0].Footprint, &obtainedFootprint) assert.NoError(t, err) - assert.Len(t, obtainedFootprint.ReadWrite, 0) + assert.Len(t, obtainedFootprint.ReadWrite, 1) assert.Len(t, obtainedFootprint.ReadOnly, 2) ro1 := obtainedFootprint.ReadOnly[0] assert.Equal(t, xdr.LedgerEntryTypeContractData, ro1.Type) From 00937d36c5b1c788afb2ea54c8ed3217d6b91028 Mon Sep 17 00:00:00 2001 From: Alfonso Acosta Date: Tue, 7 Feb 2023 00:10:01 +0100 Subject: [PATCH 15/18] Finish the simulate transaction test --- .../test/simulate_transaction_test.go | 29 ++++++++++++------- 1 file changed, 18 insertions(+), 11 deletions(-) diff --git a/cmd/soroban-rpc/internal/test/simulate_transaction_test.go b/cmd/soroban-rpc/internal/test/simulate_transaction_test.go index d38dafde9..76414477a 100644 --- a/cmd/soroban-rpc/internal/test/simulate_transaction_test.go +++ b/cmd/soroban-rpc/internal/test/simulate_transaction_test.go @@ -322,18 +322,13 @@ func TestSimulateInvokeContractTransactionSucceeds(t *testing.T) { contractID := getContractID(t, address, testSalt, StandaloneNetworkPassphrase) contractFnParameterSym := xdr.ScSymbol("world") - sourceAccountIDBytes, err := sourceAccount.FromAddress().MarshalBinary() - assert.NoError(t, err) - var sourceAccountID xdr.Uint256 - copy(sourceAccountID[:], sourceAccountIDBytes) + authAddrArg := "GBRPYHIL2CI3FNQ4BXLFMNDLFJUNPU2HY3ZMFSHONUCEOASW7QC7OX2H" + authAccountIDArg := xdr.MustAddress(authAddrArg) addressObject := &xdr.ScObject{ Type: xdr.ScObjectTypeScoAddress, Address: &xdr.ScAddress{ - Type: xdr.ScAddressTypeScAddressTypeAccount, - AccountId: &xdr.AccountId{ - Type: xdr.PublicKeyTypePublicKeyTypeEd25519, - Ed25519: &sourceAccountID, - }, + Type: xdr.ScAddressTypeScAddressTypeAccount, + AccountId: &authAccountIDArg, }, } tx, err = txnbuild.NewTransaction(txnbuild.TransactionParams{ @@ -384,7 +379,6 @@ func TestSimulateInvokeContractTransactionSucceeds(t *testing.T) { assert.Equal(t, xdr.ScSymbol("world"), *world.Sym) // check the footprint - t.Log("Footprint:", response.Results[0].Footprint) var obtainedFootprint xdr.LedgerFootprint err = xdr.SafeUnmarshalBase64(response.Results[0].Footprint, &obtainedFootprint) assert.NoError(t, err) @@ -408,7 +402,20 @@ func TestSimulateInvokeContractTransactionSucceeds(t *testing.T) { var obtainedAuth xdr.ContractAuth err = xdr.SafeUnmarshalBase64(response.Results[0].Auth[0], &obtainedAuth) assert.NoError(t, err) - // TODO: check the auth + assert.Nil(t, obtainedAuth.SignatureArgs) + + assert.Equal(t, xdr.Uint64(0), obtainedAuth.AddressWithNonce.Nonce) + assert.Equal(t, xdr.ScAddressTypeScAddressTypeAccount, obtainedAuth.AddressWithNonce.Address.Type) + assert.Equal(t, authAddrArg, obtainedAuth.AddressWithNonce.Address.AccountId.Address()) + + assert.Equal(t, xdr.Hash(contractID), obtainedAuth.RootInvocation.ContractId) + assert.Equal(t, xdr.ScSymbol("auth"), obtainedAuth.RootInvocation.FunctionName) + assert.Len(t, obtainedAuth.RootInvocation.Args, 1) + world = obtainedAuth.RootInvocation.Args[0] + assert.Equal(t, xdr.ScValTypeScvSymbol, world.Type) + assert.Equal(t, xdr.ScSymbol("world"), *world.Sym) + assert.Nil(t, obtainedAuth.RootInvocation.SubInvocations) + } func TestSimulateTransactionError(t *testing.T) { From 93f7bb334efa1b269ec86b434c7c789a46fdf23d Mon Sep 17 00:00:00 2001 From: Alfonso Acosta Date: Tue, 7 Feb 2023 00:39:26 +0100 Subject: [PATCH 16/18] Bump SDK and Env dependencies --- Cargo.lock | 78 +++++++++++-------- Cargo.toml | 10 +-- .../test-wasms/hello_world/src/lib.rs | 2 +- .../internal/methods/simulate_transaction.go | 1 + .../test/simulate_transaction_test.go | 4 +- 5 files changed, 54 insertions(+), 41 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 76c14e741..dd870310c 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -1317,7 +1317,7 @@ version = "0.1.0" dependencies = [ "libc", "sha2 0.10.6", - "soroban-env-host 0.0.12 (git+https://github.com/stellar/rs-soroban-env?rev=c8583e3e12e1f8ac087efa4453ad4f7c4ebf41fe)", + "soroban-env-host 0.0.12 (git+https://github.com/stellar/rs-soroban-env?rev=d65b04f1793c48471995bf67850fffee53b90bd2)", ] [[package]] @@ -1827,7 +1827,7 @@ dependencies = [ "serde_derive", "serde_json", "sha2 0.10.6", - "soroban-env-host 0.0.12 (git+https://github.com/stellar/rs-soroban-env?rev=c8583e3e12e1f8ac087efa4453ad4f7c4ebf41fe)", + "soroban-env-host 0.0.12 (git+https://github.com/stellar/rs-soroban-env?rev=d65b04f1793c48471995bf67850fffee53b90bd2)", "soroban-ledger-snapshot", "soroban-sdk", "soroban-spec", @@ -1845,42 +1845,42 @@ dependencies = [ [[package]] name = "soroban-env-common" version = "0.0.12" -source = "git+https://github.com/stellar/rs-soroban-env?rev=c8583e3e#c8583e3e12e1f8ac087efa4453ad4f7c4ebf41fe" +source = "git+https://github.com/stellar/rs-soroban-env?rev=ade7d47#ade7d475675d694a142146cafb30140e0dca64dd" dependencies = [ "crate-git-revision", "serde", - "soroban-env-macros 0.0.12 (git+https://github.com/stellar/rs-soroban-env?rev=c8583e3e)", + "soroban-env-macros 0.0.12 (git+https://github.com/stellar/rs-soroban-env?rev=ade7d47)", "soroban-wasmi", "static_assertions", - "stellar-xdr", + "stellar-xdr 0.0.12 (git+https://github.com/stellar/rs-stellar-xdr?rev=02299043)", ] [[package]] name = "soroban-env-common" version = "0.0.12" -source = "git+https://github.com/stellar/rs-soroban-env?rev=c8583e3e12e1f8ac087efa4453ad4f7c4ebf41fe#c8583e3e12e1f8ac087efa4453ad4f7c4ebf41fe" +source = "git+https://github.com/stellar/rs-soroban-env?rev=d65b04f1793c48471995bf67850fffee53b90bd2#d65b04f1793c48471995bf67850fffee53b90bd2" dependencies = [ "crate-git-revision", "serde", - "soroban-env-macros 0.0.12 (git+https://github.com/stellar/rs-soroban-env?rev=c8583e3e12e1f8ac087efa4453ad4f7c4ebf41fe)", + "soroban-env-macros 0.0.12 (git+https://github.com/stellar/rs-soroban-env?rev=d65b04f1793c48471995bf67850fffee53b90bd2)", "soroban-wasmi", "static_assertions", - "stellar-xdr", + "stellar-xdr 0.0.12 (git+https://github.com/stellar/rs-stellar-xdr?rev=ea8a54526fe896412b106c67c0ba35181ae12ee4)", ] [[package]] name = "soroban-env-guest" version = "0.0.12" -source = "git+https://github.com/stellar/rs-soroban-env?rev=c8583e3e#c8583e3e12e1f8ac087efa4453ad4f7c4ebf41fe" +source = "git+https://github.com/stellar/rs-soroban-env?rev=ade7d47#ade7d475675d694a142146cafb30140e0dca64dd" dependencies = [ - "soroban-env-common 0.0.12 (git+https://github.com/stellar/rs-soroban-env?rev=c8583e3e)", + "soroban-env-common 0.0.12 (git+https://github.com/stellar/rs-soroban-env?rev=ade7d47)", "static_assertions", ] [[package]] name = "soroban-env-host" version = "0.0.12" -source = "git+https://github.com/stellar/rs-soroban-env?rev=c8583e3e#c8583e3e12e1f8ac087efa4453ad4f7c4ebf41fe" +source = "git+https://github.com/stellar/rs-soroban-env?rev=ade7d47#ade7d475675d694a142146cafb30140e0dca64dd" dependencies = [ "backtrace", "curve25519-dalek", @@ -1892,8 +1892,8 @@ dependencies = [ "num-integer", "num-traits", "sha2 0.10.6", - "soroban-env-common 0.0.12 (git+https://github.com/stellar/rs-soroban-env?rev=c8583e3e)", - "soroban-native-sdk-macros 0.0.12 (git+https://github.com/stellar/rs-soroban-env?rev=c8583e3e)", + "soroban-env-common 0.0.12 (git+https://github.com/stellar/rs-soroban-env?rev=ade7d47)", + "soroban-native-sdk-macros 0.0.12 (git+https://github.com/stellar/rs-soroban-env?rev=ade7d47)", "soroban-wasmi", "static_assertions", "tinyvec", @@ -1902,7 +1902,7 @@ dependencies = [ [[package]] name = "soroban-env-host" version = "0.0.12" -source = "git+https://github.com/stellar/rs-soroban-env?rev=c8583e3e12e1f8ac087efa4453ad4f7c4ebf41fe#c8583e3e12e1f8ac087efa4453ad4f7c4ebf41fe" +source = "git+https://github.com/stellar/rs-soroban-env?rev=d65b04f1793c48471995bf67850fffee53b90bd2#d65b04f1793c48471995bf67850fffee53b90bd2" dependencies = [ "backtrace", "curve25519-dalek", @@ -1914,8 +1914,8 @@ dependencies = [ "num-integer", "num-traits", "sha2 0.10.6", - "soroban-env-common 0.0.12 (git+https://github.com/stellar/rs-soroban-env?rev=c8583e3e12e1f8ac087efa4453ad4f7c4ebf41fe)", - "soroban-native-sdk-macros 0.0.12 (git+https://github.com/stellar/rs-soroban-env?rev=c8583e3e12e1f8ac087efa4453ad4f7c4ebf41fe)", + "soroban-env-common 0.0.12 (git+https://github.com/stellar/rs-soroban-env?rev=d65b04f1793c48471995bf67850fffee53b90bd2)", + "soroban-native-sdk-macros 0.0.12 (git+https://github.com/stellar/rs-soroban-env?rev=d65b04f1793c48471995bf67850fffee53b90bd2)", "soroban-wasmi", "static_assertions", "tinyvec", @@ -1924,14 +1924,14 @@ dependencies = [ [[package]] name = "soroban-env-macros" version = "0.0.12" -source = "git+https://github.com/stellar/rs-soroban-env?rev=c8583e3e#c8583e3e12e1f8ac087efa4453ad4f7c4ebf41fe" +source = "git+https://github.com/stellar/rs-soroban-env?rev=ade7d47#ade7d475675d694a142146cafb30140e0dca64dd" dependencies = [ "itertools", "proc-macro2", "quote", "serde", "serde_json", - "stellar-xdr", + "stellar-xdr 0.0.12 (git+https://github.com/stellar/rs-stellar-xdr?rev=02299043)", "syn", "thiserror", ] @@ -1939,14 +1939,14 @@ dependencies = [ [[package]] name = "soroban-env-macros" version = "0.0.12" -source = "git+https://github.com/stellar/rs-soroban-env?rev=c8583e3e12e1f8ac087efa4453ad4f7c4ebf41fe#c8583e3e12e1f8ac087efa4453ad4f7c4ebf41fe" +source = "git+https://github.com/stellar/rs-soroban-env?rev=d65b04f1793c48471995bf67850fffee53b90bd2#d65b04f1793c48471995bf67850fffee53b90bd2" dependencies = [ "itertools", "proc-macro2", "quote", "serde", "serde_json", - "stellar-xdr", + "stellar-xdr 0.0.12 (git+https://github.com/stellar/rs-stellar-xdr?rev=ea8a54526fe896412b106c67c0ba35181ae12ee4)", "syn", "thiserror", ] @@ -1954,18 +1954,18 @@ dependencies = [ [[package]] name = "soroban-ledger-snapshot" version = "0.4.3" -source = "git+https://github.com/stellar/rs-soroban-sdk?rev=e7910c7057088b3418d84af04f2c04313d0c756f#e7910c7057088b3418d84af04f2c04313d0c756f" +source = "git+https://github.com/stellar/rs-soroban-sdk?rev=8a11d747d969b137ef0dccbc37f23f2966f5fcd1#8a11d747d969b137ef0dccbc37f23f2966f5fcd1" dependencies = [ "serde", "serde_json", - "soroban-env-host 0.0.12 (git+https://github.com/stellar/rs-soroban-env?rev=c8583e3e)", + "soroban-env-host 0.0.12 (git+https://github.com/stellar/rs-soroban-env?rev=ade7d47)", "thiserror", ] [[package]] name = "soroban-native-sdk-macros" version = "0.0.12" -source = "git+https://github.com/stellar/rs-soroban-env?rev=c8583e3e#c8583e3e12e1f8ac087efa4453ad4f7c4ebf41fe" +source = "git+https://github.com/stellar/rs-soroban-env?rev=ade7d47#ade7d475675d694a142146cafb30140e0dca64dd" dependencies = [ "itertools", "proc-macro2", @@ -1976,7 +1976,7 @@ dependencies = [ [[package]] name = "soroban-native-sdk-macros" version = "0.0.12" -source = "git+https://github.com/stellar/rs-soroban-env?rev=c8583e3e12e1f8ac087efa4453ad4f7c4ebf41fe#c8583e3e12e1f8ac087efa4453ad4f7c4ebf41fe" +source = "git+https://github.com/stellar/rs-soroban-env?rev=d65b04f1793c48471995bf67850fffee53b90bd2#d65b04f1793c48471995bf67850fffee53b90bd2" dependencies = [ "itertools", "proc-macro2", @@ -1987,13 +1987,13 @@ dependencies = [ [[package]] name = "soroban-sdk" version = "0.4.3" -source = "git+https://github.com/stellar/rs-soroban-sdk?rev=e7910c7057088b3418d84af04f2c04313d0c756f#e7910c7057088b3418d84af04f2c04313d0c756f" +source = "git+https://github.com/stellar/rs-soroban-sdk?rev=8a11d747d969b137ef0dccbc37f23f2966f5fcd1#8a11d747d969b137ef0dccbc37f23f2966f5fcd1" dependencies = [ "bytes-lit", "ed25519-dalek", "rand 0.8.5", "soroban-env-guest", - "soroban-env-host 0.0.12 (git+https://github.com/stellar/rs-soroban-env?rev=c8583e3e)", + "soroban-env-host 0.0.12 (git+https://github.com/stellar/rs-soroban-env?rev=ade7d47)", "soroban-ledger-snapshot", "soroban-sdk-macros", "stellar-strkey 0.0.7 (git+https://github.com/stellar/rs-stellar-strkey)", @@ -2002,23 +2002,23 @@ dependencies = [ [[package]] name = "soroban-sdk-macros" version = "0.4.3" -source = "git+https://github.com/stellar/rs-soroban-sdk?rev=e7910c7057088b3418d84af04f2c04313d0c756f#e7910c7057088b3418d84af04f2c04313d0c756f" +source = "git+https://github.com/stellar/rs-soroban-sdk?rev=8a11d747d969b137ef0dccbc37f23f2966f5fcd1#8a11d747d969b137ef0dccbc37f23f2966f5fcd1" dependencies = [ "darling", "itertools", "proc-macro2", "quote", "sha2 0.10.6", - "soroban-env-common 0.0.12 (git+https://github.com/stellar/rs-soroban-env?rev=c8583e3e)", + "soroban-env-common 0.0.12 (git+https://github.com/stellar/rs-soroban-env?rev=ade7d47)", "soroban-spec", - "stellar-xdr", + "stellar-xdr 0.0.12 (git+https://github.com/stellar/rs-stellar-xdr?rev=ea8a54526fe896412b106c67c0ba35181ae12ee4)", "syn", ] [[package]] name = "soroban-spec" version = "0.4.3" -source = "git+https://github.com/stellar/rs-soroban-sdk?rev=e7910c7057088b3418d84af04f2c04313d0c756f#e7910c7057088b3418d84af04f2c04313d0c756f" +source = "git+https://github.com/stellar/rs-soroban-sdk?rev=8a11d747d969b137ef0dccbc37f23f2966f5fcd1#8a11d747d969b137ef0dccbc37f23f2966f5fcd1" dependencies = [ "base64 0.13.1", "darling", @@ -2030,7 +2030,7 @@ dependencies = [ "serde_derive", "serde_json", "sha2 0.10.6", - "stellar-xdr", + "stellar-xdr 0.0.12 (git+https://github.com/stellar/rs-stellar-xdr?rev=ea8a54526fe896412b106c67c0ba35181ae12ee4)", "syn", "thiserror", "wasmparser 0.88.0", @@ -2039,7 +2039,7 @@ dependencies = [ [[package]] name = "soroban-token-spec" version = "0.4.3" -source = "git+https://github.com/stellar/rs-soroban-sdk?rev=e7910c7057088b3418d84af04f2c04313d0c756f#e7910c7057088b3418d84af04f2c04313d0c756f" +source = "git+https://github.com/stellar/rs-soroban-sdk?rev=8a11d747d969b137ef0dccbc37f23f2966f5fcd1#8a11d747d969b137ef0dccbc37f23f2966f5fcd1" dependencies = [ "soroban-sdk", ] @@ -2105,7 +2105,19 @@ dependencies = [ [[package]] name = "stellar-xdr" version = "0.0.12" -source = "git+https://github.com/stellar/rs-stellar-xdr?rev=6c72271b#6c72271bf3d07f8aa9d583261536e5653e555370" +source = "git+https://github.com/stellar/rs-stellar-xdr?rev=02299043#0229904359bf47633b89612b6e21ae39a34dcbcf" +dependencies = [ + "base64 0.13.1", + "crate-git-revision", + "hex", + "serde", + "serde_with", +] + +[[package]] +name = "stellar-xdr" +version = "0.0.12" +source = "git+https://github.com/stellar/rs-stellar-xdr?rev=ea8a54526fe896412b106c67c0ba35181ae12ee4#ea8a54526fe896412b106c67c0ba35181ae12ee4" dependencies = [ "base64 0.13.1", "crate-git-revision", diff --git a/Cargo.toml b/Cargo.toml index 97d2a76bd..084ad37ad 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -10,27 +10,27 @@ default-members = ["cmd/soroban-cli"] [workspace.dependencies.soroban-env-host] version = "0.0.12" git = "https://github.com/stellar/rs-soroban-env" -rev = "c8583e3e12e1f8ac087efa4453ad4f7c4ebf41fe" +rev = "d65b04f1793c48471995bf67850fffee53b90bd2" [workspace.dependencies.soroban-spec] version = "0.4.1" git = "https://github.com/stellar/rs-soroban-sdk" -rev = "e7910c7057088b3418d84af04f2c04313d0c756f" +rev = "8a11d747d969b137ef0dccbc37f23f2966f5fcd1" [workspace.dependencies.soroban-token-spec] version = "0.4.1" git = "https://github.com/stellar/rs-soroban-sdk" -rev = "e7910c7057088b3418d84af04f2c04313d0c756f" +rev = "8a11d747d969b137ef0dccbc37f23f2966f5fcd1" [workspace.dependencies.soroban-sdk] version = "0.4.1" git = "https://github.com/stellar/rs-soroban-sdk" -rev = "e7910c7057088b3418d84af04f2c04313d0c756f" +rev = "8a11d747d969b137ef0dccbc37f23f2966f5fcd1" [workspace.dependencies.soroban-ledger-snapshot] version = "0.4.1" git = "https://github.com/stellar/rs-soroban-sdk" -rev = "e7910c7057088b3418d84af04f2c04313d0c756f" +rev = "8a11d747d969b137ef0dccbc37f23f2966f5fcd1" [workspace.dependencies.stellar-strkey] version = "0.0.7" diff --git a/cmd/soroban-cli/tests/fixtures/test-wasms/hello_world/src/lib.rs b/cmd/soroban-cli/tests/fixtures/test-wasms/hello_world/src/lib.rs index 278146001..e10e345f5 100644 --- a/cmd/soroban-cli/tests/fixtures/test-wasms/hello_world/src/lib.rs +++ b/cmd/soroban-cli/tests/fixtures/test-wasms/hello_world/src/lib.rs @@ -18,7 +18,7 @@ impl Contract { } pub fn auth(env: Env, addr: Address, world: Symbol) -> Vec { - addr.require_auth(vec![&env, world.into()]); + addr.require_auth(); vec![&env, symbol!("Hello"), world] } } diff --git a/cmd/soroban-rpc/internal/methods/simulate_transaction.go b/cmd/soroban-rpc/internal/methods/simulate_transaction.go index 7026486d4..d674be90d 100644 --- a/cmd/soroban-rpc/internal/methods/simulate_transaction.go +++ b/cmd/soroban-rpc/internal/methods/simulate_transaction.go @@ -203,6 +203,7 @@ func NewSimulateTransactionHandler(logger *log.Entry, networkPassphrase string, // Get the auth data var auth []string if res.auth != nil { + // CGo doesn't have an easy way to do pointer arithmetic so, // we are better off transforming the memory buffer into a large slice // and finding the NULL termination after that diff --git a/cmd/soroban-rpc/internal/test/simulate_transaction_test.go b/cmd/soroban-rpc/internal/test/simulate_transaction_test.go index 76414477a..a2c86077b 100644 --- a/cmd/soroban-rpc/internal/test/simulate_transaction_test.go +++ b/cmd/soroban-rpc/internal/test/simulate_transaction_test.go @@ -410,8 +410,8 @@ func TestSimulateInvokeContractTransactionSucceeds(t *testing.T) { assert.Equal(t, xdr.Hash(contractID), obtainedAuth.RootInvocation.ContractId) assert.Equal(t, xdr.ScSymbol("auth"), obtainedAuth.RootInvocation.FunctionName) - assert.Len(t, obtainedAuth.RootInvocation.Args, 1) - world = obtainedAuth.RootInvocation.Args[0] + assert.Len(t, obtainedAuth.RootInvocation.Args, 2) + world = obtainedAuth.RootInvocation.Args[1] assert.Equal(t, xdr.ScValTypeScvSymbol, world.Type) assert.Equal(t, xdr.ScSymbol("world"), *world.Sym) assert.Nil(t, obtainedAuth.RootInvocation.SubInvocations) From e2e96435c56da22660c66d0650930a8aca2121f2 Mon Sep 17 00:00:00 2001 From: Alfonso Acosta Date: Tue, 7 Feb 2023 13:25:56 +0100 Subject: [PATCH 17/18] Bump Env version --- Cargo.lock | 40 ++++++++++++++++++++-------------------- Cargo.toml | 2 +- 2 files changed, 21 insertions(+), 21 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index dd870310c..59fddabde 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -1317,7 +1317,7 @@ version = "0.1.0" dependencies = [ "libc", "sha2 0.10.6", - "soroban-env-host 0.0.12 (git+https://github.com/stellar/rs-soroban-env?rev=d65b04f1793c48471995bf67850fffee53b90bd2)", + "soroban-env-host 0.0.12 (git+https://github.com/stellar/rs-soroban-env?rev=2431bd416010215cc9759b435662a7274206a4c0)", ] [[package]] @@ -1827,7 +1827,7 @@ dependencies = [ "serde_derive", "serde_json", "sha2 0.10.6", - "soroban-env-host 0.0.12 (git+https://github.com/stellar/rs-soroban-env?rev=d65b04f1793c48471995bf67850fffee53b90bd2)", + "soroban-env-host 0.0.12 (git+https://github.com/stellar/rs-soroban-env?rev=2431bd416010215cc9759b435662a7274206a4c0)", "soroban-ledger-snapshot", "soroban-sdk", "soroban-spec", @@ -1845,27 +1845,27 @@ dependencies = [ [[package]] name = "soroban-env-common" version = "0.0.12" -source = "git+https://github.com/stellar/rs-soroban-env?rev=ade7d47#ade7d475675d694a142146cafb30140e0dca64dd" +source = "git+https://github.com/stellar/rs-soroban-env?rev=2431bd416010215cc9759b435662a7274206a4c0#2431bd416010215cc9759b435662a7274206a4c0" dependencies = [ "crate-git-revision", "serde", - "soroban-env-macros 0.0.12 (git+https://github.com/stellar/rs-soroban-env?rev=ade7d47)", + "soroban-env-macros 0.0.12 (git+https://github.com/stellar/rs-soroban-env?rev=2431bd416010215cc9759b435662a7274206a4c0)", "soroban-wasmi", "static_assertions", - "stellar-xdr 0.0.12 (git+https://github.com/stellar/rs-stellar-xdr?rev=02299043)", + "stellar-xdr 0.0.12 (git+https://github.com/stellar/rs-stellar-xdr?rev=ea8a54526fe896412b106c67c0ba35181ae12ee4)", ] [[package]] name = "soroban-env-common" version = "0.0.12" -source = "git+https://github.com/stellar/rs-soroban-env?rev=d65b04f1793c48471995bf67850fffee53b90bd2#d65b04f1793c48471995bf67850fffee53b90bd2" +source = "git+https://github.com/stellar/rs-soroban-env?rev=ade7d47#ade7d475675d694a142146cafb30140e0dca64dd" dependencies = [ "crate-git-revision", "serde", - "soroban-env-macros 0.0.12 (git+https://github.com/stellar/rs-soroban-env?rev=d65b04f1793c48471995bf67850fffee53b90bd2)", + "soroban-env-macros 0.0.12 (git+https://github.com/stellar/rs-soroban-env?rev=ade7d47)", "soroban-wasmi", "static_assertions", - "stellar-xdr 0.0.12 (git+https://github.com/stellar/rs-stellar-xdr?rev=ea8a54526fe896412b106c67c0ba35181ae12ee4)", + "stellar-xdr 0.0.12 (git+https://github.com/stellar/rs-stellar-xdr?rev=02299043)", ] [[package]] @@ -1880,7 +1880,7 @@ dependencies = [ [[package]] name = "soroban-env-host" version = "0.0.12" -source = "git+https://github.com/stellar/rs-soroban-env?rev=ade7d47#ade7d475675d694a142146cafb30140e0dca64dd" +source = "git+https://github.com/stellar/rs-soroban-env?rev=2431bd416010215cc9759b435662a7274206a4c0#2431bd416010215cc9759b435662a7274206a4c0" dependencies = [ "backtrace", "curve25519-dalek", @@ -1892,8 +1892,8 @@ dependencies = [ "num-integer", "num-traits", "sha2 0.10.6", - "soroban-env-common 0.0.12 (git+https://github.com/stellar/rs-soroban-env?rev=ade7d47)", - "soroban-native-sdk-macros 0.0.12 (git+https://github.com/stellar/rs-soroban-env?rev=ade7d47)", + "soroban-env-common 0.0.12 (git+https://github.com/stellar/rs-soroban-env?rev=2431bd416010215cc9759b435662a7274206a4c0)", + "soroban-native-sdk-macros 0.0.12 (git+https://github.com/stellar/rs-soroban-env?rev=2431bd416010215cc9759b435662a7274206a4c0)", "soroban-wasmi", "static_assertions", "tinyvec", @@ -1902,7 +1902,7 @@ dependencies = [ [[package]] name = "soroban-env-host" version = "0.0.12" -source = "git+https://github.com/stellar/rs-soroban-env?rev=d65b04f1793c48471995bf67850fffee53b90bd2#d65b04f1793c48471995bf67850fffee53b90bd2" +source = "git+https://github.com/stellar/rs-soroban-env?rev=ade7d47#ade7d475675d694a142146cafb30140e0dca64dd" dependencies = [ "backtrace", "curve25519-dalek", @@ -1914,8 +1914,8 @@ dependencies = [ "num-integer", "num-traits", "sha2 0.10.6", - "soroban-env-common 0.0.12 (git+https://github.com/stellar/rs-soroban-env?rev=d65b04f1793c48471995bf67850fffee53b90bd2)", - "soroban-native-sdk-macros 0.0.12 (git+https://github.com/stellar/rs-soroban-env?rev=d65b04f1793c48471995bf67850fffee53b90bd2)", + "soroban-env-common 0.0.12 (git+https://github.com/stellar/rs-soroban-env?rev=ade7d47)", + "soroban-native-sdk-macros 0.0.12 (git+https://github.com/stellar/rs-soroban-env?rev=ade7d47)", "soroban-wasmi", "static_assertions", "tinyvec", @@ -1924,14 +1924,14 @@ dependencies = [ [[package]] name = "soroban-env-macros" version = "0.0.12" -source = "git+https://github.com/stellar/rs-soroban-env?rev=ade7d47#ade7d475675d694a142146cafb30140e0dca64dd" +source = "git+https://github.com/stellar/rs-soroban-env?rev=2431bd416010215cc9759b435662a7274206a4c0#2431bd416010215cc9759b435662a7274206a4c0" dependencies = [ "itertools", "proc-macro2", "quote", "serde", "serde_json", - "stellar-xdr 0.0.12 (git+https://github.com/stellar/rs-stellar-xdr?rev=02299043)", + "stellar-xdr 0.0.12 (git+https://github.com/stellar/rs-stellar-xdr?rev=ea8a54526fe896412b106c67c0ba35181ae12ee4)", "syn", "thiserror", ] @@ -1939,14 +1939,14 @@ dependencies = [ [[package]] name = "soroban-env-macros" version = "0.0.12" -source = "git+https://github.com/stellar/rs-soroban-env?rev=d65b04f1793c48471995bf67850fffee53b90bd2#d65b04f1793c48471995bf67850fffee53b90bd2" +source = "git+https://github.com/stellar/rs-soroban-env?rev=ade7d47#ade7d475675d694a142146cafb30140e0dca64dd" dependencies = [ "itertools", "proc-macro2", "quote", "serde", "serde_json", - "stellar-xdr 0.0.12 (git+https://github.com/stellar/rs-stellar-xdr?rev=ea8a54526fe896412b106c67c0ba35181ae12ee4)", + "stellar-xdr 0.0.12 (git+https://github.com/stellar/rs-stellar-xdr?rev=02299043)", "syn", "thiserror", ] @@ -1965,7 +1965,7 @@ dependencies = [ [[package]] name = "soroban-native-sdk-macros" version = "0.0.12" -source = "git+https://github.com/stellar/rs-soroban-env?rev=ade7d47#ade7d475675d694a142146cafb30140e0dca64dd" +source = "git+https://github.com/stellar/rs-soroban-env?rev=2431bd416010215cc9759b435662a7274206a4c0#2431bd416010215cc9759b435662a7274206a4c0" dependencies = [ "itertools", "proc-macro2", @@ -1976,7 +1976,7 @@ dependencies = [ [[package]] name = "soroban-native-sdk-macros" version = "0.0.12" -source = "git+https://github.com/stellar/rs-soroban-env?rev=d65b04f1793c48471995bf67850fffee53b90bd2#d65b04f1793c48471995bf67850fffee53b90bd2" +source = "git+https://github.com/stellar/rs-soroban-env?rev=ade7d47#ade7d475675d694a142146cafb30140e0dca64dd" dependencies = [ "itertools", "proc-macro2", diff --git a/Cargo.toml b/Cargo.toml index 084ad37ad..5038f42e4 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -10,7 +10,7 @@ default-members = ["cmd/soroban-cli"] [workspace.dependencies.soroban-env-host] version = "0.0.12" git = "https://github.com/stellar/rs-soroban-env" -rev = "d65b04f1793c48471995bf67850fffee53b90bd2" +rev = "2431bd416010215cc9759b435662a7274206a4c0" [workspace.dependencies.soroban-spec] version = "0.4.1" From 2f827352d75c2efa4646729d96ed1dd221b65205 Mon Sep 17 00:00:00 2001 From: Alfonso Acosta Date: Tue, 7 Feb 2023 14:32:11 +0100 Subject: [PATCH 18/18] Fix auth test --- .../test/simulate_transaction_test.go | 27 ++++++++++++++++--- 1 file changed, 23 insertions(+), 4 deletions(-) diff --git a/cmd/soroban-rpc/internal/test/simulate_transaction_test.go b/cmd/soroban-rpc/internal/test/simulate_transaction_test.go index a2c86077b..5943e13fd 100644 --- a/cmd/soroban-rpc/internal/test/simulate_transaction_test.go +++ b/cmd/soroban-rpc/internal/test/simulate_transaction_test.go @@ -324,6 +324,23 @@ func TestSimulateInvokeContractTransactionSucceeds(t *testing.T) { contractFnParameterSym := xdr.ScSymbol("world") authAddrArg := "GBRPYHIL2CI3FNQ4BXLFMNDLFJUNPU2HY3ZMFSHONUCEOASW7QC7OX2H" authAccountIDArg := xdr.MustAddress(authAddrArg) + tx, err = txnbuild.NewTransaction(txnbuild.TransactionParams{ + SourceAccount: &account, + IncrementSequenceNum: true, + Operations: []txnbuild.Operation{ + &txnbuild.CreateAccount{ + Destination: authAddrArg, + Amount: "100000", + SourceAccount: address, + }, + }, + BaseFee: txnbuild.MinBaseFee, + Preconditions: txnbuild.Preconditions{ + TimeBounds: txnbuild.NewInfiniteTimeout(), + }, + }) + assert.NoError(t, err) + sendSuccessfulTransaction(t, client, sourceAccount, tx) addressObject := &xdr.ScObject{ Type: xdr.ScObjectTypeScoAddress, Address: &xdr.ScAddress{ @@ -383,13 +400,16 @@ func TestSimulateInvokeContractTransactionSucceeds(t *testing.T) { err = xdr.SafeUnmarshalBase64(response.Results[0].Footprint, &obtainedFootprint) assert.NoError(t, err) assert.Len(t, obtainedFootprint.ReadWrite, 1) - assert.Len(t, obtainedFootprint.ReadOnly, 2) - ro1 := obtainedFootprint.ReadOnly[0] + assert.Len(t, obtainedFootprint.ReadOnly, 3) + ro0 := obtainedFootprint.ReadOnly[0] + assert.Equal(t, xdr.LedgerEntryTypeAccount, ro0.Type) + assert.Equal(t, authAddrArg, ro0.Account.AccountId.Address()) + ro1 := obtainedFootprint.ReadOnly[1] assert.Equal(t, xdr.LedgerEntryTypeContractData, ro1.Type) assert.Equal(t, xdr.Hash(contractID), ro1.ContractData.ContractId) assert.Equal(t, xdr.ScValTypeScvStatic, ro1.ContractData.Key.Type) assert.Equal(t, xdr.ScStaticScsLedgerKeyContractCode, *ro1.ContractData.Key.Ic) - ro2 := obtainedFootprint.ReadOnly[1] + ro2 := obtainedFootprint.ReadOnly[2] assert.Equal(t, xdr.LedgerEntryTypeContractCode, ro2.Type) installContractCodeArgs, err := xdr.InstallContractCodeArgs{Code: helloWorldContract}.MarshalBinary() assert.NoError(t, err) @@ -415,7 +435,6 @@ func TestSimulateInvokeContractTransactionSucceeds(t *testing.T) { assert.Equal(t, xdr.ScValTypeScvSymbol, world.Type) assert.Equal(t, xdr.ScSymbol("world"), *world.Sym) assert.Nil(t, obtainedAuth.RootInvocation.SubInvocations) - } func TestSimulateTransactionError(t *testing.T) {