Skip to content

Commit

Permalink
Cut xdr2json dependency on soroban host.
Browse files Browse the repository at this point in the history
  • Loading branch information
graydon committed Aug 30, 2024
1 parent 4bd23cb commit 60ebdaf
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 4 deletions.
3 changes: 1 addition & 2 deletions cmd/soroban-rpc/lib/xdr2json/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -15,5 +15,4 @@ anyhow = { workspace = true }
serde_json = { workspace = true }
rand = { workspace = true }

stellar-xdr = { workspace = true }
soroban-env-host = { workspace = true, features = ["unstable-next-api"]}
stellar-xdr = { workspace = true }
18 changes: 16 additions & 2 deletions cmd/soroban-rpc/lib/xdr2json/src/lib.rs
Original file line number Diff line number Diff line change
@@ -1,16 +1,30 @@
extern crate anyhow;
extern crate ffi;
extern crate soroban_env_host;
extern crate stellar_xdr;

use std::{panic, str::FromStr};
use stellar_xdr::curr as xdr;

use anyhow::Result;

// We really do need everything.
#[allow(clippy::wildcard_imports)]
use ffi::*;
use soroban_env_host::{xdr, DEFAULT_XDR_RW_LIMITS};

// This is the same limit as the soroban serialization limit
// but we redefine it here for two reasons:
//
// 1. To depend only on the XDR crate, not the soroban host.
// 2. To allow customizing it here, since this function may
// serialize many XDR types that are larger than the types
// soroban allows serializing (eg. transaction sets or ledger
// entries or whatever). Soroban is conservative and stops
// at 32MiB.

const DEFAULT_XDR_RW_LIMITS: xdr::Limits = xdr::Limits {
depth: 500,
len: 32 * 1024 * 1024,
};

#[repr(C)]
pub struct ConversionResult {
Expand Down

0 comments on commit 60ebdaf

Please sign in to comment.