From c6e34b5201eaa49ea74cb9450ed4a9c8c0d6e918 Mon Sep 17 00:00:00 2001 From: tamirms Date: Mon, 18 Sep 2023 15:55:02 +0100 Subject: [PATCH 01/16] Update changelog for 2.27.0 release (#5055) --- services/horizon/CHANGELOG.md | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/services/horizon/CHANGELOG.md b/services/horizon/CHANGELOG.md index 823078bbc3..a83bf9629e 100644 --- a/services/horizon/CHANGELOG.md +++ b/services/horizon/CHANGELOG.md @@ -4,13 +4,20 @@ All notable changes to this project will be documented in this file. This project adheres to [Semantic Versioning](http://semver.org/). -## Unreleased +## 2.27.0 + +**Upgrading to this version from <= 2.26.1 will trigger a state rebuild. During this process (which will take at least 10 minutes), Horizon will not ingest new ledgers.** + +**This release adds support for Protocol 20** ### Breaking Changes - The command line flag `--remote-captive-core-url` has been removed, as remote captive core functionality is now deprecated ([4940](https://github.com/stellar/go/pull/4940)). ### Added - Added new command-line flag `--network` to specify the Stellar network (pubnet or testnet), aiming at simplifying the configuration process by automatically configuring the following parameters based on the chosen network: `--history-archive-urls`, `--network-passphrase`, and `--captive-core-config-path` ([4949](https://github.com/stellar/go/pull/4949)). +- Added `contract_credited` and `contract_debited` effects which are emitted whenever a Soroban contracts sends or receives a Stellar asset ([4832](https://github.com/stellar/go/pull/4832)). +* Added `num_contracts` (total number of Soroban contracts which hold an asset) and `contracts_amount` (total amount of the asset held by all Soroban contracts) fields to asset stat summaries at `/assets` ([4805](https://github.com/stellar/go/pull/4805)). +* Added responses for new operations introduced in protocol 20: `invoke_host_function`, `bump_footprint_expiration`, and `restore_footprint` ([4905](https://github.com/stellar/go/pull/4905)). ### Fixed - The same slippage calculation from the [`v2.26.1`](#2261) hotfix now properly excludes spikes for smoother trade aggregation plots ([4999](https://github.com/stellar/go/pull/4999)). From 4b0bc23a321edd18715519af440a2b59851c72f5 Mon Sep 17 00:00:00 2001 From: tamirms Date: Tue, 19 Sep 2023 15:30:41 +0100 Subject: [PATCH 02/16] fix operations query --- services/horizon/internal/db2/history/operation.go | 3 ++- .../db2/history/operation_batch_insert_builder.go | 11 ++++++++--- .../horizon/internal/db2/history/operation_test.go | 9 +++++---- 3 files changed, 15 insertions(+), 8 deletions(-) diff --git a/services/horizon/internal/db2/history/operation.go b/services/horizon/internal/db2/history/operation.go index 94064e8f28..d0dbfffc26 100644 --- a/services/horizon/internal/db2/history/operation.go +++ b/services/horizon/internal/db2/history/operation.go @@ -8,6 +8,7 @@ import ( "text/template" sq "github.com/Masterminds/squirrel" + "github.com/stellar/go/services/horizon/internal/db2" "github.com/stellar/go/support/errors" "github.com/stellar/go/toid" @@ -394,7 +395,7 @@ var selectOperation = sq.Select( "hop.details, " + "hop.source_account, " + "hop.source_account_muxed, " + - "hop.is_payment, " + + "COALESCE(hop.is_payment, false) as is_payment, " + "ht.transaction_hash, " + "ht.tx_result, " + "COALESCE(ht.successful, true) as transaction_successful"). diff --git a/services/horizon/internal/db2/history/operation_batch_insert_builder.go b/services/horizon/internal/db2/history/operation_batch_insert_builder.go index b2a9db6c88..d44aeec193 100644 --- a/services/horizon/internal/db2/history/operation_batch_insert_builder.go +++ b/services/horizon/internal/db2/history/operation_batch_insert_builder.go @@ -4,6 +4,7 @@ import ( "context" "github.com/guregu/null" + "github.com/stellar/go/support/db" "github.com/stellar/go/xdr" ) @@ -52,7 +53,7 @@ func (i *operationBatchInsertBuilder) Add( sourceAccountMuxed null.String, isPayment bool, ) error { - return i.builder.Row(ctx, map[string]interface{}{ + row := map[string]interface{}{ "id": id, "transaction_id": transactionID, "application_order": applicationOrder, @@ -60,8 +61,12 @@ func (i *operationBatchInsertBuilder) Add( "details": details, "source_account": sourceAccount, "source_account_muxed": sourceAccountMuxed, - "is_payment": isPayment, - }) + "is_payment": nil, + } + if isPayment { + row["is_payment"] = true + } + return i.builder.Row(ctx, row) } diff --git a/services/horizon/internal/db2/history/operation_test.go b/services/horizon/internal/db2/history/operation_test.go index 480ec9c837..5ba24d3e31 100644 --- a/services/horizon/internal/db2/history/operation_test.go +++ b/services/horizon/internal/db2/history/operation_test.go @@ -5,6 +5,7 @@ import ( sq "github.com/Masterminds/squirrel" "github.com/guregu/null" + "github.com/stellar/go/services/horizon/internal/db2" "github.com/stellar/go/services/horizon/internal/test" "github.com/stellar/go/toid" @@ -172,7 +173,7 @@ func TestOperationQueryBuilder(t *testing.T) { tt.Assert.NoError(err) // Operations for account queries will use hopp.history_operation_id in their predicates. - want := "SELECT hop.id, hop.transaction_id, hop.application_order, hop.type, hop.details, hop.source_account, hop.source_account_muxed, hop.is_payment, ht.transaction_hash, ht.tx_result, COALESCE(ht.successful, true) as transaction_successful FROM history_operations hop LEFT JOIN history_transactions ht ON ht.id = hop.transaction_id JOIN history_operation_participants hopp ON hopp.history_operation_id = hop.id WHERE hopp.history_account_id = ? AND hopp.history_operation_id > ? ORDER BY hopp.history_operation_id asc LIMIT 10" + want := "SELECT hop.id, hop.transaction_id, hop.application_order, hop.type, hop.details, hop.source_account, hop.source_account_muxed, COALESCE(hop.is_payment, false) as is_payment, ht.transaction_hash, ht.tx_result, COALESCE(ht.successful, true) as transaction_successful FROM history_operations hop LEFT JOIN history_transactions ht ON ht.id = hop.transaction_id JOIN history_operation_participants hopp ON hopp.history_operation_id = hop.id WHERE hopp.history_account_id = ? AND hopp.history_operation_id > ? ORDER BY hopp.history_operation_id asc LIMIT 10" tt.Assert.EqualValues(want, got) opsQ = q.Operations().ForLedger(tt.Ctx, 2).Page(db2.PageQuery{Cursor: "8589938689", Order: "asc", Limit: 10}) @@ -181,7 +182,7 @@ func TestOperationQueryBuilder(t *testing.T) { tt.Assert.NoError(err) // Other operation queries will use hop.id in their predicates. - want = "SELECT hop.id, hop.transaction_id, hop.application_order, hop.type, hop.details, hop.source_account, hop.source_account_muxed, hop.is_payment, ht.transaction_hash, ht.tx_result, COALESCE(ht.successful, true) as transaction_successful FROM history_operations hop LEFT JOIN history_transactions ht ON ht.id = hop.transaction_id WHERE hop.id >= ? AND hop.id < ? AND hop.id > ? ORDER BY hop.id asc LIMIT 10" + want = "SELECT hop.id, hop.transaction_id, hop.application_order, hop.type, hop.details, hop.source_account, hop.source_account_muxed, COALESCE(hop.is_payment, false) as is_payment, ht.transaction_hash, ht.tx_result, COALESCE(ht.successful, true) as transaction_successful FROM history_operations hop LEFT JOIN history_transactions ht ON ht.id = hop.transaction_id WHERE hop.id >= ? AND hop.id < ? AND hop.id > ? ORDER BY hop.id asc LIMIT 10" tt.Assert.EqualValues(want, got) } @@ -243,7 +244,7 @@ func TestOperationIncludeFailed(t *testing.T) { sql, _, err := query.sql.ToSql() tt.Assert.NoError(err) - tt.Assert.Equal("SELECT hop.id, hop.transaction_id, hop.application_order, hop.type, hop.details, hop.source_account, hop.source_account_muxed, hop.is_payment, ht.transaction_hash, ht.tx_result, COALESCE(ht.successful, true) as transaction_successful FROM history_operations hop LEFT JOIN history_transactions ht ON ht.id = hop.transaction_id JOIN history_operation_participants hopp ON hopp.history_operation_id = hop.id WHERE hopp.history_account_id = ?", sql) + tt.Assert.Equal("SELECT hop.id, hop.transaction_id, hop.application_order, hop.type, hop.details, hop.source_account, hop.source_account_muxed, COALESCE(hop.is_payment, false) as is_payment, ht.transaction_hash, ht.tx_result, COALESCE(ht.successful, true) as transaction_successful FROM history_operations hop LEFT JOIN history_transactions ht ON ht.id = hop.transaction_id JOIN history_operation_participants hopp ON hopp.history_operation_id = hop.id WHERE hopp.history_account_id = ?", sql) } // TestPaymentsSuccessfulOnly tests if default query returns payments in @@ -306,7 +307,7 @@ func TestPaymentsIncludeFailed(t *testing.T) { sql, _, err := query.sql.ToSql() tt.Assert.NoError(err) - tt.Assert.Equal("SELECT hop.id, hop.transaction_id, hop.application_order, hop.type, hop.details, hop.source_account, hop.source_account_muxed, hop.is_payment, ht.transaction_hash, ht.tx_result, COALESCE(ht.successful, true) as transaction_successful FROM history_operations hop LEFT JOIN history_transactions ht ON ht.id = hop.transaction_id JOIN history_operation_participants hopp ON hopp.history_operation_id = hop.id WHERE (hop.type IN (?,?,?,?,?) OR hop.is_payment = ?) AND hopp.history_account_id = ?", sql) + tt.Assert.Equal("SELECT hop.id, hop.transaction_id, hop.application_order, hop.type, hop.details, hop.source_account, hop.source_account_muxed, COALESCE(hop.is_payment, false) as is_payment, ht.transaction_hash, ht.tx_result, COALESCE(ht.successful, true) as transaction_successful FROM history_operations hop LEFT JOIN history_transactions ht ON ht.id = hop.transaction_id JOIN history_operation_participants hopp ON hopp.history_operation_id = hop.id WHERE (hop.type IN (?,?,?,?,?) OR hop.is_payment = ?) AND hopp.history_account_id = ?", sql) } func TestExtraChecksOperationsTransactionSuccessfulTrueResultFalse(t *testing.T) { From 5bfe563642586f3700b64c9a2027446328b64bc3 Mon Sep 17 00:00:00 2001 From: tamirms Date: Fri, 22 Sep 2023 15:57:33 +0100 Subject: [PATCH 03/16] horizon: Improve performance of migrations/64_add_payment_flag_history_ops.sql (#5056) Remove index_history_operations_on_is_payment because it is not actually used in the payments query. --- .../horizon/internal/db2/schema/bindata.go | 29 +++++++++++++++++-- .../64_add_payment_flag_history_ops.sql | 2 -- .../migrations/65_drop_payment_index.sql | 7 +++++ 3 files changed, 33 insertions(+), 5 deletions(-) create mode 100644 services/horizon/internal/db2/schema/migrations/65_drop_payment_index.sql diff --git a/services/horizon/internal/db2/schema/bindata.go b/services/horizon/internal/db2/schema/bindata.go index 46546303d1..bf2121170b 100644 --- a/services/horizon/internal/db2/schema/bindata.go +++ b/services/horizon/internal/db2/schema/bindata.go @@ -60,7 +60,8 @@ // migrations/61_trust_lines_by_account_type_code_issuer.sql (383B) // migrations/62_claimable_balance_claimants.sql (1.428kB) // migrations/63_add_contract_id_to_asset_stats.sql (153B) -// migrations/64_add_payment_flag_history_ops.sql (300B) +// migrations/64_add_payment_flag_history_ops.sql (145B) +// migrations/65_drop_payment_index.sql (260B) // migrations/6_create_assets_table.sql (366B) // migrations/7_modify_trades_table.sql (2.303kB) // migrations/8_add_aggregators.sql (907B) @@ -1334,7 +1335,7 @@ func migrations63_add_contract_id_to_asset_statsSql() (*asset, error) { return a, nil } -var _migrations64_add_payment_flag_history_opsSql = []byte("\x1f\x8b\x08\x00\x00\x00\x00\x00\x00\xff\x94\x8f\x41\xca\xc2\x30\x10\x46\xf7\x73\x8a\xa1\xab\xff\x47\x7a\x82\xac\x62\x13\xa4\x50\x53\xa9\x2d\xb8\x0b\x29\x0e\x1a\xb0\x99\x92\x06\xb4\xb7\x17\xdc\xb4\xa0\x20\xee\xe7\xcd\xfb\x5e\x9e\xe3\x66\xf0\x97\xe8\x12\x61\x37\x02\xc8\xaa\xd5\x0d\xb6\x72\x5b\x69\xbc\xfa\x29\x71\x9c\x2d\x8f\x14\x5d\xf2\x1c\x26\x94\x4a\xa1\x9f\xec\xe8\xe6\x81\x42\xc2\x9e\xf9\x46\x2e\x08\x28\x1a\x2d\x5b\x8d\xa5\x51\xfa\x84\x99\x0f\x67\x7a\xd8\x77\xdc\x72\xb0\x0b\x9d\x61\x6d\x3e\x39\xba\x63\x69\x76\xd8\xa7\x48\x84\x7f\xcb\xf9\xbf\x00\x58\xaf\x55\x7c\x0f\x00\xaa\xa9\x0f\x3f\x6a\xc5\xb7\xc8\xd7\xcf\xa2\xae\xba\xbd\x59\xc5\x0a\x78\x06\x00\x00\xff\xff\xc0\xa1\x37\xd4\x2c\x01\x00\x00") +var _migrations64_add_payment_flag_history_opsSql = []byte("\x1f\x8b\x08\x00\x00\x00\x00\x00\x00\xff\xd2\xd5\x55\xd0\xce\xcd\x4c\x2f\x4a\x2c\x49\x55\x08\x2d\xe0\xe2\x72\xf4\x09\x71\x0d\x52\x08\x71\x74\xf2\x71\x55\xc8\xc8\x2c\x2e\xc9\x2f\xaa\x8c\xcf\x2f\x48\x2d\x4a\x2c\xc9\xcc\xcf\x2b\x56\x70\x74\x71\x51\xc8\x2c\x8e\x2f\x48\xac\xcc\x4d\xcd\x2b\x51\x48\xca\xcf\xcf\x49\x4d\xcc\xb3\xe6\xe2\x42\x36\xc7\x25\xbf\x3c\x8f\xa0\x49\x2e\x41\xfe\x01\x0a\xce\xfe\x3e\xa1\xbe\x7e\x48\x26\x5a\x73\x01\x02\x00\x00\xff\xff\xcc\xf9\x34\xcb\x91\x00\x00\x00") func migrations64_add_payment_flag_history_opsSqlBytes() ([]byte, error) { return bindataRead( @@ -1350,7 +1351,27 @@ func migrations64_add_payment_flag_history_opsSql() (*asset, error) { } info := bindataFileInfo{name: "migrations/64_add_payment_flag_history_ops.sql", size: 0, mode: os.FileMode(0), modTime: time.Unix(0, 0)} - a := &asset{bytes: bytes, info: info, digest: [32]uint8{0x7e, 0x2d, 0x87, 0xe0, 0xa7, 0x38, 0xdc, 0xb7, 0xfb, 0xda, 0xc5, 0xad, 0xfb, 0x70, 0x15, 0xde, 0xb, 0x27, 0x97, 0x87, 0xc, 0xdb, 0xd3, 0x4b, 0x6c, 0x51, 0x39, 0x3a, 0xb4, 0xd3, 0x20, 0x42}} + a := &asset{bytes: bytes, info: info, digest: [32]uint8{0xa7, 0x6d, 0xb6, 0x2e, 0x50, 0x40, 0x71, 0x1f, 0x97, 0xd9, 0xd9, 0xfb, 0xcf, 0x45, 0x0, 0xd1, 0x93, 0x79, 0x5d, 0x70, 0xb3, 0x2e, 0x31, 0x44, 0x13, 0x63, 0xdf, 0x70, 0xd9, 0xc9, 0x6b, 0x43}} + return a, nil +} + +var _migrations65_drop_payment_indexSql = []byte("\x1f\x8b\x08\x00\x00\x00\x00\x00\x00\xff\x8c\xcf\xc1\x4a\xc3\x40\x10\xc6\xf1\x7b\x9e\xe2\xa3\x57\x8d\xeb\xc1\x0a\xea\x35\x15\x72\x51\xb1\x0a\xbd\x2d\xdb\x66\x48\x06\x9a\x99\x65\x67\x96\x9a\xb7\x17\x5b\xf0\xdc\x07\xf8\x7e\x7c\xff\xb6\xc5\xcd\xcc\x63\x49\x4e\xf8\xce\x4d\xd3\xb6\x60\x19\xe8\x27\x4e\x6c\xae\x65\x89\x9a\xa9\x24\x67\x15\x8b\x2a\x91\x2d\xe6\xb4\xcc\x24\x8e\x53\x32\xa4\x61\xa0\x01\x2c\xb8\x10\xac\x82\xc7\x07\xec\xab\x83\x1d\x5e\x8b\x18\xb4\xfa\x1f\xea\x13\x5d\xe0\xf3\x4e\xd4\x21\x74\x20\xb3\x54\x96\x5b\x18\x11\x26\xf7\x6c\xcf\x21\x8c\xec\x53\xdd\xdf\x1d\x74\x0e\xe6\x74\x3c\xa6\x12\x46\x0d\x6c\x56\xc9\xc2\xfa\x7e\xfd\xd4\x74\x9f\xef\x1f\xe8\xdf\xba\xcd\x0e\xfd\x2b\x36\xbb\x7e\xfb\xb5\xc5\xea\xba\xd7\xab\x97\x73\xe2\x7f\x72\xa7\x27\x69\x7e\x03\x00\x00\xff\xff\x15\xa3\x47\xcb\x04\x01\x00\x00") + +func migrations65_drop_payment_indexSqlBytes() ([]byte, error) { + return bindataRead( + _migrations65_drop_payment_indexSql, + "migrations/65_drop_payment_index.sql", + ) +} + +func migrations65_drop_payment_indexSql() (*asset, error) { + bytes, err := migrations65_drop_payment_indexSqlBytes() + if err != nil { + return nil, err + } + + info := bindataFileInfo{name: "migrations/65_drop_payment_index.sql", size: 0, mode: os.FileMode(0), modTime: time.Unix(0, 0)} + a := &asset{bytes: bytes, info: info, digest: [32]uint8{0xf2, 0xe4, 0xb0, 0xad, 0x98, 0x6a, 0x5, 0xb8, 0x1e, 0xbb, 0xf6, 0x3d, 0x63, 0x93, 0xd5, 0x45, 0x29, 0xd7, 0x23, 0x23, 0x9b, 0xfc, 0x27, 0xb5, 0x8f, 0x37, 0x20, 0x66, 0x6c, 0x97, 0x45, 0x4a}} return a, nil } @@ -1606,6 +1627,7 @@ var _bindata = map[string]func() (*asset, error){ "migrations/62_claimable_balance_claimants.sql": migrations62_claimable_balance_claimantsSql, "migrations/63_add_contract_id_to_asset_stats.sql": migrations63_add_contract_id_to_asset_statsSql, "migrations/64_add_payment_flag_history_ops.sql": migrations64_add_payment_flag_history_opsSql, + "migrations/65_drop_payment_index.sql": migrations65_drop_payment_indexSql, "migrations/6_create_assets_table.sql": migrations6_create_assets_tableSql, "migrations/7_modify_trades_table.sql": migrations7_modify_trades_tableSql, "migrations/8_add_aggregators.sql": migrations8_add_aggregatorsSql, @@ -1718,6 +1740,7 @@ var _bintree = &bintree{nil, map[string]*bintree{ "62_claimable_balance_claimants.sql": {migrations62_claimable_balance_claimantsSql, map[string]*bintree{}}, "63_add_contract_id_to_asset_stats.sql": {migrations63_add_contract_id_to_asset_statsSql, map[string]*bintree{}}, "64_add_payment_flag_history_ops.sql": {migrations64_add_payment_flag_history_opsSql, map[string]*bintree{}}, + "65_drop_payment_index.sql": {migrations65_drop_payment_indexSql, map[string]*bintree{}}, "6_create_assets_table.sql": {migrations6_create_assets_tableSql, map[string]*bintree{}}, "7_modify_trades_table.sql": {migrations7_modify_trades_tableSql, map[string]*bintree{}}, "8_add_aggregators.sql": {migrations8_add_aggregatorsSql, map[string]*bintree{}}, diff --git a/services/horizon/internal/db2/schema/migrations/64_add_payment_flag_history_ops.sql b/services/horizon/internal/db2/schema/migrations/64_add_payment_flag_history_ops.sql index f95192f669..ad19f441fe 100644 --- a/services/horizon/internal/db2/schema/migrations/64_add_payment_flag_history_ops.sql +++ b/services/horizon/internal/db2/schema/migrations/64_add_payment_flag_history_ops.sql @@ -1,9 +1,7 @@ -- +migrate Up ALTER TABLE history_operations ADD is_payment boolean; -CREATE INDEX "index_history_operations_on_is_payment" ON history_operations USING btree (is_payment); -- +migrate Down -DROP INDEX "index_history_operations_on_is_payment"; ALTER TABLE history_operations DROP COLUMN is_payment; diff --git a/services/horizon/internal/db2/schema/migrations/65_drop_payment_index.sql b/services/horizon/internal/db2/schema/migrations/65_drop_payment_index.sql new file mode 100644 index 0000000000..325719a284 --- /dev/null +++ b/services/horizon/internal/db2/schema/migrations/65_drop_payment_index.sql @@ -0,0 +1,7 @@ +-- +migrate Up + +-- index_history_operations_on_is_payment was added in migration 64 but it turns out +-- the index was not necessary, see https://github.com/stellar/go/issues/5059 +DROP INDEX IF EXISTS "index_history_operations_on_is_payment"; + +-- +migrate Down From 9477bf5f229d267eb31ac44f329ac5634a942d76 Mon Sep 17 00:00:00 2001 From: tamirms Date: Mon, 25 Sep 2023 17:11:29 +0100 Subject: [PATCH 04/16] updated changelog notes for 2.27.0-rc2 release (#5063) Co-authored-by: Shawn Reuland --- services/horizon/CHANGELOG.md | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/services/horizon/CHANGELOG.md b/services/horizon/CHANGELOG.md index a83bf9629e..62700067f8 100644 --- a/services/horizon/CHANGELOG.md +++ b/services/horizon/CHANGELOG.md @@ -4,7 +4,11 @@ All notable changes to this project will be documented in this file. This project adheres to [Semantic Versioning](http://semver.org/). -## 2.27.0 +## 2.27.0-rc2 +### Fixed +- treat null is_payment values as equivalent to false values, avoid sql nil conversion errors([5060](https://github.com/stellar/go/pull/5060)). + +## 2.27.0-rc1 **Upgrading to this version from <= 2.26.1 will trigger a state rebuild. During this process (which will take at least 10 minutes), Horizon will not ingest new ledgers.** From 4ecb6434e657c73d6603c003158c439978610c83 Mon Sep 17 00:00:00 2001 From: tamirms Date: Fri, 6 Oct 2023 18:31:18 +0100 Subject: [PATCH 05/16] ingest: Extract ledger entry changes from Tx Meta in a deterministic order (#5070) --- ingest/change.go | 56 +++++ ingest/change_test.go | 215 ++++++++++++++++++ ingest/ledger_change_reader.go | 1 + services/horizon/CHANGELOG.md | 4 + .../ingest/processors/effects_processor.go | 20 +- .../transaction_operation_wrapper_test.go | 10 +- .../integration/liquidity_pool_test.go | 34 ++- xdr/ledger_close_meta.go | 4 +- 8 files changed, 318 insertions(+), 26 deletions(-) create mode 100644 ingest/change_test.go diff --git a/ingest/change.go b/ingest/change.go index 7d9b761db2..027b37b861 100644 --- a/ingest/change.go +++ b/ingest/change.go @@ -2,6 +2,7 @@ package ingest import ( "bytes" + "sort" "github.com/stellar/go/support/errors" "github.com/stellar/go/xdr" @@ -20,6 +21,13 @@ type Change struct { Post *xdr.LedgerEntry } +func (c *Change) ledgerKey() (xdr.LedgerKey, error) { + if c.Pre != nil { + return c.Pre.LedgerKey() + } + return c.Post.LedgerKey() +} + // GetChangesFromLedgerEntryChanges transforms LedgerEntryChanges to []Change. // Each `update` and `removed` is preceded with `state` and `create` changes // are alone, without `state`. The transformation we're doing is to move each @@ -64,9 +72,57 @@ func GetChangesFromLedgerEntryChanges(ledgerEntryChanges xdr.LedgerEntryChanges) } } + sortChanges(changes) return changes } +type sortableChanges struct { + changes []Change + ledgerKeys [][]byte +} + +func newSortableChanges(changes []Change) sortableChanges { + ledgerKeys := make([][]byte, len(changes)) + for i, c := range changes { + lk, err := c.ledgerKey() + if err != nil { + panic(err) + } + lkBytes, err := lk.MarshalBinary() + if err != nil { + panic(err) + } + ledgerKeys[i] = lkBytes + } + return sortableChanges{ + changes: changes, + ledgerKeys: ledgerKeys, + } +} + +func (s sortableChanges) Len() int { + return len(s.changes) +} + +func (s sortableChanges) Less(i, j int) bool { + return bytes.Compare(s.ledgerKeys[i], s.ledgerKeys[j]) < 0 +} + +func (s sortableChanges) Swap(i, j int) { + s.changes[i], s.changes[j] = s.changes[j], s.changes[i] + s.ledgerKeys[i], s.ledgerKeys[j] = s.ledgerKeys[j], s.ledgerKeys[i] +} + +// sortChanges is applied on a list of changes to ensure that LedgerEntryChanges +// from Tx Meta are ingested in a deterministic order. +// The changes are sorted by ledger key. It is unexpected for there to be +// multiple changes with the same ledger key in a LedgerEntryChanges group, +// but if that is the case, we fall back to the original ordering of the changes +// by using a stable sorting algorithm. +func sortChanges(changes []Change) { + sort.Stable(newSortableChanges(changes)) +} + // LedgerEntryChangeType returns type in terms of LedgerEntryChangeType. func (c *Change) LedgerEntryChangeType() xdr.LedgerEntryChangeType { switch { diff --git a/ingest/change_test.go b/ingest/change_test.go new file mode 100644 index 0000000000..d8ae9492dc --- /dev/null +++ b/ingest/change_test.go @@ -0,0 +1,215 @@ +package ingest + +import ( + "testing" + + "github.com/stretchr/testify/assert" + + "github.com/stellar/go/xdr" +) + +func assertChangesAreEqual(t *testing.T, a, b Change) { + assert.Equal(t, a.Type, b.Type) + if a.Pre == nil { + assert.Nil(t, b.Pre) + } else { + aBytes, err := a.Pre.MarshalBinary() + assert.NoError(t, err) + bBytes, err := b.Pre.MarshalBinary() + assert.NoError(t, err) + assert.Equal(t, aBytes, bBytes) + } + if a.Post == nil { + assert.Nil(t, b.Post) + } else { + aBytes, err := a.Post.MarshalBinary() + assert.NoError(t, err) + bBytes, err := b.Post.MarshalBinary() + assert.NoError(t, err) + assert.Equal(t, aBytes, bBytes) + } +} + +func TestSortChanges(t *testing.T) { + for _, testCase := range []struct { + input []Change + expected []Change + }{ + {[]Change{}, []Change{}}, + { + []Change{ + { + Type: xdr.LedgerEntryTypeAccount, + Pre: nil, + Post: &xdr.LedgerEntry{ + LastModifiedLedgerSeq: 11, + Data: xdr.LedgerEntryData{ + Type: xdr.LedgerEntryTypeAccount, + Account: &xdr.AccountEntry{ + AccountId: xdr.MustAddress("GC3C4AKRBQLHOJ45U4XG35ESVWRDECWO5XLDGYADO6DPR3L7KIDVUMML"), + }, + }, + }, + }, + }, + []Change{ + { + Type: xdr.LedgerEntryTypeAccount, + Pre: nil, + Post: &xdr.LedgerEntry{ + LastModifiedLedgerSeq: 11, + Data: xdr.LedgerEntryData{ + Type: xdr.LedgerEntryTypeAccount, + Account: &xdr.AccountEntry{ + AccountId: xdr.MustAddress("GC3C4AKRBQLHOJ45U4XG35ESVWRDECWO5XLDGYADO6DPR3L7KIDVUMML"), + }, + }, + }, + }, + }, + }, + { + []Change{ + { + Type: xdr.LedgerEntryTypeAccount, + Pre: nil, + Post: &xdr.LedgerEntry{ + LastModifiedLedgerSeq: 11, + Data: xdr.LedgerEntryData{ + Type: xdr.LedgerEntryTypeAccount, + Account: &xdr.AccountEntry{ + AccountId: xdr.MustAddress("GC3C4AKRBQLHOJ45U4XG35ESVWRDECWO5XLDGYADO6DPR3L7KIDVUMML"), + Balance: 25, + }, + }, + }, + }, + { + Type: xdr.LedgerEntryTypeAccount, + Pre: &xdr.LedgerEntry{ + LastModifiedLedgerSeq: 11, + Data: xdr.LedgerEntryData{ + Type: xdr.LedgerEntryTypeAccount, + Account: &xdr.AccountEntry{ + AccountId: xdr.MustAddress("GCMNSW2UZMSH3ZFRLWP6TW2TG4UX4HLSYO5HNIKUSFMLN2KFSF26JKWF"), + Balance: 20, + }, + }, + }, + Post: nil, + }, + { + Type: xdr.LedgerEntryTypeExpiration, + Pre: &xdr.LedgerEntry{ + LastModifiedLedgerSeq: 11, + Data: xdr.LedgerEntryData{ + Type: xdr.LedgerEntryTypeExpiration, + Expiration: &xdr.ExpirationEntry{ + KeyHash: xdr.Hash{1}, + ExpirationLedgerSeq: 50, + }, + }, + }, + Post: &xdr.LedgerEntry{ + LastModifiedLedgerSeq: 11, + Data: xdr.LedgerEntryData{ + Type: xdr.LedgerEntryTypeExpiration, + Expiration: &xdr.ExpirationEntry{ + KeyHash: xdr.Hash{1}, + ExpirationLedgerSeq: 100, + }, + }, + }, + }, + { + Type: xdr.LedgerEntryTypeAccount, + Pre: &xdr.LedgerEntry{ + LastModifiedLedgerSeq: 11, + Data: xdr.LedgerEntryData{ + Type: xdr.LedgerEntryTypeAccount, + Account: &xdr.AccountEntry{ + AccountId: xdr.MustAddress("GC3C4AKRBQLHOJ45U4XG35ESVWRDECWO5XLDGYADO6DPR3L7KIDVUMML"), + Balance: 25, + }, + }, + }, + Post: nil, + }, + }, + []Change{ + { + Type: xdr.LedgerEntryTypeAccount, + Pre: &xdr.LedgerEntry{ + LastModifiedLedgerSeq: 11, + Data: xdr.LedgerEntryData{ + Type: xdr.LedgerEntryTypeAccount, + Account: &xdr.AccountEntry{ + AccountId: xdr.MustAddress("GCMNSW2UZMSH3ZFRLWP6TW2TG4UX4HLSYO5HNIKUSFMLN2KFSF26JKWF"), + Balance: 20, + }, + }, + }, + Post: nil, + }, + { + Type: xdr.LedgerEntryTypeAccount, + Pre: nil, + Post: &xdr.LedgerEntry{ + LastModifiedLedgerSeq: 11, + Data: xdr.LedgerEntryData{ + Type: xdr.LedgerEntryTypeAccount, + Account: &xdr.AccountEntry{ + AccountId: xdr.MustAddress("GC3C4AKRBQLHOJ45U4XG35ESVWRDECWO5XLDGYADO6DPR3L7KIDVUMML"), + Balance: 25, + }, + }, + }, + }, + { + Type: xdr.LedgerEntryTypeAccount, + Pre: &xdr.LedgerEntry{ + LastModifiedLedgerSeq: 11, + Data: xdr.LedgerEntryData{ + Type: xdr.LedgerEntryTypeAccount, + Account: &xdr.AccountEntry{ + AccountId: xdr.MustAddress("GC3C4AKRBQLHOJ45U4XG35ESVWRDECWO5XLDGYADO6DPR3L7KIDVUMML"), + Balance: 25, + }, + }, + }, + Post: nil, + }, + + { + Type: xdr.LedgerEntryTypeExpiration, + Pre: &xdr.LedgerEntry{ + LastModifiedLedgerSeq: 11, + Data: xdr.LedgerEntryData{ + Type: xdr.LedgerEntryTypeExpiration, + Expiration: &xdr.ExpirationEntry{ + KeyHash: xdr.Hash{1}, + ExpirationLedgerSeq: 50, + }, + }, + }, + Post: &xdr.LedgerEntry{ + LastModifiedLedgerSeq: 11, + Data: xdr.LedgerEntryData{ + Type: xdr.LedgerEntryTypeExpiration, + Expiration: &xdr.ExpirationEntry{ + KeyHash: xdr.Hash{1}, + ExpirationLedgerSeq: 100, + }, + }, + }, + }, + }, + }, + } { + sortChanges(testCase.input) + assert.Equal(t, len(testCase.input), len(testCase.expected)) + for i := range testCase.input { + assertChangesAreEqual(t, testCase.input[i], testCase.expected[i]) + } + } +} diff --git a/ingest/ledger_change_reader.go b/ingest/ledger_change_reader.go index a539e057ea..d09c579dbd 100644 --- a/ingest/ledger_change_reader.go +++ b/ingest/ledger_change_reader.go @@ -139,6 +139,7 @@ func (r *LedgerChangeReader) Read() (Change, error) { Post: nil, } } + sortChanges(changes) r.pending = append(r.pending, changes...) r.state++ return r.Read() diff --git a/services/horizon/CHANGELOG.md b/services/horizon/CHANGELOG.md index 62700067f8..4e82f15246 100644 --- a/services/horizon/CHANGELOG.md +++ b/services/horizon/CHANGELOG.md @@ -3,6 +3,10 @@ All notable changes to this project will be documented in this file. This project adheres to [Semantic Versioning](http://semver.org/). +## 2.27.0 + +### Fixed +- Ordering of effects are now deterministic. Previously the order of some Horizon effects could vary upon reingestion but this issue has now been fixed ([5070](https://github.com/stellar/go/pull/5070)). ## 2.27.0-rc2 ### Fixed diff --git a/services/horizon/internal/ingest/processors/effects_processor.go b/services/horizon/internal/ingest/processors/effects_processor.go index 4cfd703bd2..d6c0d781d6 100644 --- a/services/horizon/internal/ingest/processors/effects_processor.go +++ b/services/horizon/internal/ingest/processors/effects_processor.go @@ -10,6 +10,7 @@ import ( "strconv" "github.com/guregu/null" + "github.com/stellar/go/amount" "github.com/stellar/go/ingest" "github.com/stellar/go/keypair" @@ -1241,12 +1242,6 @@ func setTrustLineFlagDetails(flagDetails map[string]interface{}, flags xdr.Trust } } -type sortableClaimableBalanceEntries []*xdr.ClaimableBalanceEntry - -func (s sortableClaimableBalanceEntries) Len() int { return len(s) } -func (s sortableClaimableBalanceEntries) Less(i, j int) bool { return s[i].Asset.LessThan(s[j].Asset) } -func (s sortableClaimableBalanceEntries) Swap(i, j int) { s[i], s[j] = s[j], s[i] } - func (e *effectsWrapper) addLiquidityPoolRevokedEffect() error { source := e.operation.SourceAccount() lp, delta, err := e.operation.getLiquidityPoolAndProductDelta(nil) @@ -1262,7 +1257,6 @@ func (e *effectsWrapper) addLiquidityPoolRevokedEffect() error { return err } assetToCBID := map[string]string{} - var cbs sortableClaimableBalanceEntries for _, change := range changes { if change.Type == xdr.LedgerEntryTypeClaimableBalance && change.Pre == nil && change.Post != nil { cb := change.Post.Data.ClaimableBalance @@ -1271,21 +1265,15 @@ func (e *effectsWrapper) addLiquidityPoolRevokedEffect() error { return err } assetToCBID[cb.Asset.StringCanonical()] = id - cbs = append(cbs, cb) + if err := e.addClaimableBalanceEntryCreatedEffects(source, cb); err != nil { + return err + } } } if len(assetToCBID) == 0 { // no claimable balances were created, and thus, no revocation happened return nil } - // Core's claimable balance metadata isn't ordered, so we order it ourselves - // so that effects are ordered consistently - sort.Sort(cbs) - for _, cb := range cbs { - if err := e.addClaimableBalanceEntryCreatedEffects(source, cb); err != nil { - return err - } - } reservesRevoked := make([]map[string]string, 0, 2) for _, aa := range []base.AssetAmount{ diff --git a/services/horizon/internal/ingest/processors/transaction_operation_wrapper_test.go b/services/horizon/internal/ingest/processors/transaction_operation_wrapper_test.go index a96d4efef9..97b83f8f1b 100644 --- a/services/horizon/internal/ingest/processors/transaction_operation_wrapper_test.go +++ b/services/horizon/internal/ingest/processors/transaction_operation_wrapper_test.go @@ -5,10 +5,11 @@ package processors import ( "testing" - "github.com/stellar/go/protocols/horizon/base" "github.com/stretchr/testify/assert" "github.com/stretchr/testify/suite" + "github.com/stellar/go/protocols/horizon/base" + "github.com/stellar/go/ingest" "github.com/stellar/go/services/horizon/internal/db2/history" . "github.com/stellar/go/services/horizon/internal/test/transactions" @@ -1521,6 +1522,13 @@ func getSponsoredSandwichWrappers() []*transactionOperationWrapper { { Type: xdr.LedgerEntryChangeTypeLedgerEntryCreated, Created: &xdr.LedgerEntry{ + Data: xdr.LedgerEntryData{ + Type: xdr.LedgerEntryTypeAccount, + Account: &xdr.AccountEntry{ + AccountId: xdr.MustAddress("GAUJETIZVEP2NRYLUESJ3LS66NVCEGMON4UDCBCSBEVPIID773P2W6AY"), + Balance: 100, + }, + }, LastModifiedLedgerSeq: xdr.Uint32(ledgerSeq), Ext: xdr.LedgerEntryExt{ V: 1, diff --git a/services/horizon/internal/integration/liquidity_pool_test.go b/services/horizon/internal/integration/liquidity_pool_test.go index 3f792486ad..9106003179 100644 --- a/services/horizon/internal/integration/liquidity_pool_test.go +++ b/services/horizon/internal/integration/liquidity_pool_test.go @@ -606,27 +606,45 @@ func TestLiquidityPoolRevoke(t *testing.T) { tt.Equal(master.Address(), ef4.Asset.Issuer) tt.Equal(shareAccount.GetAccountID(), ef4.Trustor) + // the ordering of the claimable_balance_created effects depends on + // the ids of the claimable balances which can vary between test runs. + // we assert that there will be two claimable balances created, + // one holding 777 usd and another holding 400 xlm but + // we don't know the ordering since it depends on the claimable + // balance ids which we don't know ahead of time. + usdAsset := fmt.Sprintf("USD:%s", master.Address()) + expectedAmount := map[string]string{ + usdAsset: "777.0000000", + "native": "400.0000000", + } ef5 := (effs.Embedded.Records[4]).(effects.ClaimableBalanceCreated) tt.Equal("claimable_balance_created", ef5.Type) - tt.Equal("native", ef5.Asset) - tt.Equal("400.0000000", ef5.Amount) + var expectedNextAsset string + if ef5.Asset == usdAsset { + expectedNextAsset = "native" + } else if ef5.Asset == "native" { + expectedNextAsset = usdAsset + } else { + tt.Failf("unexpected asset %v", ef5.Asset) + } + tt.Equal(expectedAmount[ef5.Asset], ef5.Amount) ef6 := (effs.Embedded.Records[5]).(effects.ClaimableBalanceClaimantCreated) tt.Equal("claimable_balance_claimant_created", ef6.Type) - tt.Equal("native", ef6.Asset) - tt.Equal("400.0000000", ef6.Amount) + tt.Equal(ef5.Asset, ef6.Asset) + tt.Equal(ef5.Amount, ef6.Amount) tt.Equal(shareKeys.Address(), ef6.Account) tt.Equal(xdr.ClaimPredicateTypeClaimPredicateUnconditional, ef6.Predicate.Type) ef7 := (effs.Embedded.Records[6]).(effects.ClaimableBalanceCreated) tt.Equal("claimable_balance_created", ef7.Type) - tt.Equal(fmt.Sprintf("USD:%s", master.Address()), ef7.Asset) - tt.Equal("777.0000000", ef7.Amount) + tt.Equal(expectedNextAsset, ef7.Asset) + tt.Equal(expectedAmount[ef7.Asset], ef7.Amount) ef8 := (effs.Embedded.Records[7]).(effects.ClaimableBalanceClaimantCreated) tt.Equal("claimable_balance_claimant_created", ef8.Type) - tt.Equal(fmt.Sprintf("USD:%s", master.Address()), ef8.Asset) - tt.Equal("777.0000000", ef8.Amount) + tt.Equal(ef7.Asset, ef8.Asset) + tt.Equal(ef7.Amount, ef8.Amount) tt.Equal(shareKeys.Address(), ef8.Account) tt.Equal(xdr.ClaimPredicateTypeClaimPredicateUnconditional, ef8.Predicate.Type) diff --git a/xdr/ledger_close_meta.go b/xdr/ledger_close_meta.go index c8b85bae97..c2b352b613 100644 --- a/xdr/ledger_close_meta.go +++ b/xdr/ledger_close_meta.go @@ -1,6 +1,8 @@ package xdr -import "fmt" +import ( + "fmt" +) func (l LedgerCloseMeta) LedgerHeaderHistoryEntry() LedgerHeaderHistoryEntry { switch l.V { From 48d228444f8a5254746553535994c25ce68f7adf Mon Sep 17 00:00:00 2001 From: Alfonso Acosta Date: Tue, 17 Oct 2023 20:20:19 +0200 Subject: [PATCH 06/16] all: Bump XDR for soroban-pubnet release (#5079) Update XDR to [`bdb81c3710ecb12f0fcc23268b211eb237500019`](https://github.com/stellar/stellar-xdr/tree/bdb81c3710ecb12f0fcc23268b211eb237500019) --- .github/workflows/horizon.yml | 6 +- Makefile | 4 +- go.mod | 2 +- go.sum | 4 +- gxdr/xdr_generated.go | 685 +- ingest/change_test.go | 36 +- ingest/ledger_change_reader_test.go | 8 +- .../buffered_meta_pipe_reader.go | 2 +- ingest/stats_change_processor.go | 20 +- ingest/stats_change_processor_test.go | 6 +- protocols/horizon/operations/main.go | 14 +- services/horizon/internal/codes/main.go | 18 +- services/horizon/internal/codes/main_test.go | 5 +- services/horizon/internal/ingest/main_test.go | 2 +- .../ingest/processors/contract_data.go | 2 +- .../ingest/processors/effects_processor.go | 2 +- .../ingest/processors/operations_processor.go | 9 +- .../processors/operations_processor_test.go | 2 +- .../stats_ledger_transaction_processor.go | 6 +- services/horizon/internal/ingest/verify.go | 8 +- .../horizon/internal/ingest/verify_test.go | 6 +- .../internal/integration/contracts/Cargo.lock | 211 +- .../internal/integration/contracts/Cargo.toml | 4 +- .../horizon/internal/integration/db_test.go | 12 +- ...n_test.go => extend_footprint_ttl_test.go} | 19 +- .../integration/invokehostfunction_test.go | 18 +- .../horizon/internal/integration/sac_test.go | 2 +- .../integration/testdata/soroban_add_u64.wasm | Bin 618 -> 631 bytes .../testdata/soroban_increment_contract.wasm | Bin 697 -> 701 bytes .../testdata/soroban_sac_test.wasm | Bin 1904 -> 1924 bytes .../internal/integration/txsub_test.go | 4 +- .../internal/resourceadapter/operations.go | 4 +- .../internal/test/integration/integration.go | 4 +- txnbuild/bump_footprint_expiration.go | 59 - txnbuild/extend_footprint_ttl.go | 59 + txnbuild/invoke_host_function_test.go | 2 +- txnbuild/operation.go | 4 +- xdr/Stellar-contract-config-setting.x | 80 +- xdr/Stellar-contract.x | 4 +- xdr/Stellar-internal.x | 7 + xdr/Stellar-ledger-entries.x | 18 +- xdr/Stellar-ledger.x | 28 +- xdr/Stellar-transaction.x | 58 +- xdr/ledger_close_meta.go | 43 +- xdr/ledger_entry.go | 4 +- xdr/ledger_key.go | 18 +- xdr/main.go | 2 +- xdr/scval.go | 2 +- xdr/xdr_commit_generated.txt | 2 +- xdr/xdr_generated.go | 9201 ++++++++++------- 50 files changed, 6081 insertions(+), 4635 deletions(-) rename services/horizon/internal/integration/{bump_footprint_expiration_test.go => extend_footprint_ttl_test.go} (82%) delete mode 100644 txnbuild/bump_footprint_expiration.go create mode 100644 txnbuild/extend_footprint_ttl.go diff --git a/.github/workflows/horizon.yml b/.github/workflows/horizon.yml index 5720fbe7e7..fd167bfce7 100644 --- a/.github/workflows/horizon.yml +++ b/.github/workflows/horizon.yml @@ -33,9 +33,9 @@ jobs: env: HORIZON_INTEGRATION_TESTS_ENABLED: true HORIZON_INTEGRATION_TESTS_CORE_MAX_SUPPORTED_PROTOCOL: ${{ matrix.protocol-version }} - PROTOCOL_20_CORE_DEBIAN_PKG_VERSION: 19.13.1-1481.3acf6dd26.focal - PROTOCOL_20_CORE_DOCKER_IMG: stellar/stellar-core:19.13.1-1481.3acf6dd26.focal - PROTOCOL_20_SOROBAN_RPC_DOCKER_IMG: stellar/soroban-rpc:20.0.0-rc1-35 + PROTOCOL_20_CORE_DEBIAN_PKG_VERSION: 19.14.1-1529.fcbbad4ce.focal + PROTOCOL_20_CORE_DOCKER_IMG: 2opremio/stellar-core:19.14.1-1529.fcbbad4ce.focal + PROTOCOL_20_SOROBAN_RPC_DOCKER_IMG: stellar/soroban-rpc:20.0.0-rc4pubnet-42 PROTOCOL_19_CORE_DEBIAN_PKG_VERSION: 19.12.0-1378.2109a168a.focal PROTOCOL_19_CORE_DOCKER_IMG: stellar/stellar-core:19.12.0-1378.2109a168a.focal PGHOST: localhost diff --git a/Makefile b/Makefile index 126384b1d3..4266730900 100644 --- a/Makefile +++ b/Makefile @@ -14,8 +14,8 @@ xdr/Stellar-contract.x \ xdr/Stellar-internal.x \ xdr/Stellar-contract-config-setting.x -XDRGEN_COMMIT=80e38ef2a96489f6b501d4db3a350406e5aa3bab -XDR_COMMIT=9ac02641139e6717924fdad716f6e958d0168491 +XDRGEN_COMMIT=a231a92475ac6154c0c2f46dc503809823985060 +XDR_COMMIT=6a620d160aab22609c982d54578ff6a63bfcdc01 .PHONY: xdr xdr-clean xdr-update diff --git a/go.mod b/go.mod index 6bdf00bb0e..ac3f078197 100644 --- a/go.mod +++ b/go.mod @@ -42,7 +42,7 @@ require ( github.com/spf13/cobra v0.0.5 github.com/spf13/pflag v1.0.3 github.com/spf13/viper v1.3.2 - github.com/stellar/go-xdr v0.0.0-20211103144802-8017fc4bdfee + github.com/stellar/go-xdr v0.0.0-20230919160922-6c7b68458206 github.com/stellar/throttled v2.2.3-0.20190823235211-89d75816f59d+incompatible github.com/stretchr/testify v1.8.1 github.com/tyler-smith/go-bip39 v0.0.0-20180618194314-52158e4697b8 diff --git a/go.sum b/go.sum index b98832a696..4fbfb8b2c5 100644 --- a/go.sum +++ b/go.sum @@ -325,8 +325,8 @@ github.com/spf13/pflag v1.0.3 h1:zPAT6CGy6wXeQ7NtTnaTerfKOsV6V6F8agHXFiazDkg= github.com/spf13/pflag v1.0.3/go.mod h1:DYY7MBk1bdzusC3SYhjObp+wFpr4gzcvqqNjLnInEg4= github.com/spf13/viper v1.3.2 h1:VUFqw5KcqRf7i70GOzW7N+Q7+gxVBkSSqiXB12+JQ4M= github.com/spf13/viper v1.3.2/go.mod h1:ZiWeW+zYFKm7srdB9IoDzzZXaJaI5eL9QjNiN/DMA2s= -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/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/stellar/throttled v2.2.3-0.20190823235211-89d75816f59d+incompatible h1:jMXXAcz6xTarGDQ4VtVbtERogcmDQw4RaE85Cr9CgoQ= github.com/stellar/throttled v2.2.3-0.20190823235211-89d75816f59d+incompatible/go.mod h1:7CJ23pXirXBJq45DqvO6clzTEGM/l1SfKrgrzLry8b4= github.com/stretchr/objx v0.1.0/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+wExME= diff --git a/gxdr/xdr_generated.go b/gxdr/xdr_generated.go index d1b8635d15..2c20497952 100644 --- a/gxdr/xdr_generated.go +++ b/gxdr/xdr_generated.go @@ -205,7 +205,7 @@ const ( CONTRACT_DATA LedgerEntryType = 6 CONTRACT_CODE LedgerEntryType = 7 CONFIG_SETTING LedgerEntryType = 8 - EXPIRATION LedgerEntryType = 9 + TTL LedgerEntryType = 9 ) type Signer struct { @@ -645,10 +645,10 @@ type ContractCodeEntry struct { Code []byte } -type ExpirationEntry struct { - // Hash of the LedgerKey that is associated with this ExpirationEntry - KeyHash Hash - ExpirationLedgerSeq Uint32 +type TTLEntry struct { + // Hash of the LedgerKey that is associated with this TTLEntry + KeyHash Hash + LiveUntilLedgerSeq Uint32 } type LedgerEntryExtensionV1 struct { @@ -689,8 +689,8 @@ type XdrAnon_LedgerEntry_Data struct { // ContractCode() *ContractCodeEntry // CONFIG_SETTING: // ConfigSetting() *ConfigSettingEntry - // EXPIRATION: - // Expiration() *ExpirationEntry + // TTL: + // Ttl() *TTLEntry Type LedgerEntryType _u interface{} } @@ -726,8 +726,8 @@ type LedgerKey struct { // ContractCode() *XdrAnon_LedgerKey_ContractCode // CONFIG_SETTING: // ConfigSetting() *XdrAnon_LedgerKey_ConfigSetting - // EXPIRATION: - // Expiration() *XdrAnon_LedgerKey_Expiration + // TTL: + // Ttl() *XdrAnon_LedgerKey_Ttl Type LedgerEntryType _u interface{} } @@ -763,8 +763,8 @@ type XdrAnon_LedgerKey_ContractCode struct { type XdrAnon_LedgerKey_ConfigSetting struct { ConfigSettingID ConfigSettingID } -type XdrAnon_LedgerKey_Expiration struct { - // Hash of the LedgerKey that is associated with this ExpirationEntry +type XdrAnon_LedgerKey_Ttl struct { + // Hash of the LedgerKey that is associated with this TTLEntry KeyHash Hash } @@ -1274,21 +1274,8 @@ type LedgerCloseMetaV0 struct { } type LedgerCloseMetaV1 struct { - LedgerHeader LedgerHeaderHistoryEntry - TxSet GeneralizedTransactionSet - // NB: transactions are sorted in apply order here - // fees for all transactions are processed first - // followed by applying transactions - TxProcessing []TransactionResultMeta - // upgrades are applied last - UpgradesProcessing []UpgradeEntryMeta - // other misc information attached to the ledger close - ScpInfo []SCPHistoryEntry -} - -type LedgerCloseMetaV2 struct { - // We forgot to add an ExtensionPoint in v1 but at least - // we can add one now in v2. + // We forgot to add an ExtensionPoint in v0 but at least + // we can add one now in v1. Ext ExtensionPoint LedgerHeader LedgerHeaderHistoryEntry TxSet GeneralizedTransactionSet @@ -1303,9 +1290,9 @@ type LedgerCloseMetaV2 struct { // Size in bytes of BucketList, to support downstream // systems calculating storage fees correctly. TotalByteSizeOfBucketList Uint64 - // Expired temp keys that are being evicted at this ledger. + // Temp keys that are being evicted at this ledger. EvictedTemporaryLedgerKeys []LedgerKey - // Expired restorable ledger entries that are being + // Archived restorable ledger entries that are being // evicted at this ledger. EvictedPersistentLedgerEntries []LedgerEntry } @@ -1316,8 +1303,6 @@ type LedgerCloseMeta struct { // V0() *LedgerCloseMetaV0 // 1: // V1() *LedgerCloseMetaV1 - // 2: - // V2() *LedgerCloseMetaV2 V int32 _u interface{} } @@ -1663,7 +1648,7 @@ const ( LIQUIDITY_POOL_DEPOSIT OperationType = 22 LIQUIDITY_POOL_WITHDRAW OperationType = 23 INVOKE_HOST_FUNCTION OperationType = 24 - BUMP_FOOTPRINT_EXPIRATION OperationType = 25 + EXTEND_FOOTPRINT_TTL OperationType = 25 RESTORE_FOOTPRINT OperationType = 26 ) @@ -2187,20 +2172,20 @@ type InvokeHostFunctionOp struct { } /* -Bump the expiration ledger of the entries specified in the readOnly footprint +Extend the TTL of the entries specified in the readOnly footprint - so they'll expire at least ledgersToExpire ledgers from lcl. + so they will live at least extendTo ledgers from lcl. Threshold: med - Result: BumpFootprintExpirationResult + Result: ExtendFootprintTTLResult */ -type BumpFootprintExpirationOp struct { - Ext ExtensionPoint - LedgersToExpire Uint32 +type ExtendFootprintTTLOp struct { + Ext ExtensionPoint + ExtendTo Uint32 } /* -Restore the expired or evicted entries specified in the readWrite footprint. +Restore the archived entries specified in the readWrite footprint. Threshold: med Result: RestoreFootprintOp @@ -2269,8 +2254,8 @@ type XdrAnon_Operation_Body struct { // LiquidityPoolWithdrawOp() *LiquidityPoolWithdrawOp // INVOKE_HOST_FUNCTION: // InvokeHostFunctionOp() *InvokeHostFunctionOp - // BUMP_FOOTPRINT_EXPIRATION: - // BumpFootprintExpirationOp() *BumpFootprintExpirationOp + // EXTEND_FOOTPRINT_TTL: + // ExtendFootprintTTLOp() *ExtendFootprintTTLOp // RESTORE_FOOTPRINT: // RestoreFootprintOp() *RestoreFootprintOp Type OperationType @@ -2421,8 +2406,16 @@ type SorobanResources struct { type SorobanTransactionData struct { Ext ExtensionPoint Resources SorobanResources - // Portion of transaction `fee` allocated to refundable fees. - RefundableFee Int64 + // Amount of the transaction `fee` allocated to the Soroban resource fees. + // The fraction of `resourceFee` corresponding to `resources` specified + // above is *not* refundable (i.e. fees for instructions, ledger I/O), as + // well as fees for the transaction size. + // The remaining part of the fee is refundable and the charged value is + // based on the actual consumption of refundable resources (events, ledger + // rent bumps). + // The `inclusionFee` used for prioritization of the transaction is defined + // as `tx.fee - resourceFee`. + ResourceFee Int64 } // TransactionV0 is a transaction with the AccountID discriminant stripped off, @@ -3320,7 +3313,7 @@ const ( INVOKE_HOST_FUNCTION_MALFORMED InvokeHostFunctionResultCode = -1 INVOKE_HOST_FUNCTION_TRAPPED InvokeHostFunctionResultCode = -2 INVOKE_HOST_FUNCTION_RESOURCE_LIMIT_EXCEEDED InvokeHostFunctionResultCode = -3 - INVOKE_HOST_FUNCTION_ENTRY_EXPIRED InvokeHostFunctionResultCode = -4 + INVOKE_HOST_FUNCTION_ENTRY_ARCHIVED InvokeHostFunctionResultCode = -4 INVOKE_HOST_FUNCTION_INSUFFICIENT_REFUNDABLE_FEE InvokeHostFunctionResultCode = -5 ) @@ -3328,30 +3321,30 @@ type InvokeHostFunctionResult struct { // The union discriminant Code selects among the following arms: // INVOKE_HOST_FUNCTION_SUCCESS: // Success() *Hash - // INVOKE_HOST_FUNCTION_MALFORMED, INVOKE_HOST_FUNCTION_TRAPPED, INVOKE_HOST_FUNCTION_RESOURCE_LIMIT_EXCEEDED, INVOKE_HOST_FUNCTION_ENTRY_EXPIRED, INVOKE_HOST_FUNCTION_INSUFFICIENT_REFUNDABLE_FEE: + // INVOKE_HOST_FUNCTION_MALFORMED, INVOKE_HOST_FUNCTION_TRAPPED, INVOKE_HOST_FUNCTION_RESOURCE_LIMIT_EXCEEDED, INVOKE_HOST_FUNCTION_ENTRY_ARCHIVED, INVOKE_HOST_FUNCTION_INSUFFICIENT_REFUNDABLE_FEE: // void Code InvokeHostFunctionResultCode _u interface{} } -type BumpFootprintExpirationResultCode int32 +type ExtendFootprintTTLResultCode int32 const ( // codes considered as "success" for the operation - BUMP_FOOTPRINT_EXPIRATION_SUCCESS BumpFootprintExpirationResultCode = 0 + EXTEND_FOOTPRINT_TTL_SUCCESS ExtendFootprintTTLResultCode = 0 // codes considered as "failure" for the operation - BUMP_FOOTPRINT_EXPIRATION_MALFORMED BumpFootprintExpirationResultCode = -1 - BUMP_FOOTPRINT_EXPIRATION_RESOURCE_LIMIT_EXCEEDED BumpFootprintExpirationResultCode = -2 - BUMP_FOOTPRINT_EXPIRATION_INSUFFICIENT_REFUNDABLE_FEE BumpFootprintExpirationResultCode = -3 + EXTEND_FOOTPRINT_TTL_MALFORMED ExtendFootprintTTLResultCode = -1 + EXTEND_FOOTPRINT_TTL_RESOURCE_LIMIT_EXCEEDED ExtendFootprintTTLResultCode = -2 + EXTEND_FOOTPRINT_TTL_INSUFFICIENT_REFUNDABLE_FEE ExtendFootprintTTLResultCode = -3 ) -type BumpFootprintExpirationResult struct { +type ExtendFootprintTTLResult struct { // The union discriminant Code selects among the following arms: - // BUMP_FOOTPRINT_EXPIRATION_SUCCESS: + // EXTEND_FOOTPRINT_TTL_SUCCESS: // void - // BUMP_FOOTPRINT_EXPIRATION_MALFORMED, BUMP_FOOTPRINT_EXPIRATION_RESOURCE_LIMIT_EXCEEDED, BUMP_FOOTPRINT_EXPIRATION_INSUFFICIENT_REFUNDABLE_FEE: + // EXTEND_FOOTPRINT_TTL_MALFORMED, EXTEND_FOOTPRINT_TTL_RESOURCE_LIMIT_EXCEEDED, EXTEND_FOOTPRINT_TTL_INSUFFICIENT_REFUNDABLE_FEE: // void - Code BumpFootprintExpirationResultCode + Code ExtendFootprintTTLResultCode _u interface{} } @@ -3457,8 +3450,8 @@ type XdrAnon_OperationResult_Tr struct { // LiquidityPoolWithdrawResult() *LiquidityPoolWithdrawResult // INVOKE_HOST_FUNCTION: // InvokeHostFunctionResult() *InvokeHostFunctionResult - // BUMP_FOOTPRINT_EXPIRATION: - // BumpFootprintExpirationResult() *BumpFootprintExpirationResult + // EXTEND_FOOTPRINT_TTL: + // ExtendFootprintTTLResult() *ExtendFootprintTTLResult // RESTORE_FOOTPRINT: // RestoreFootprintResult() *RestoreFootprintResult Type OperationType @@ -4050,15 +4043,15 @@ type Int256Parts struct { type ContractExecutableType int32 const ( - CONTRACT_EXECUTABLE_WASM ContractExecutableType = 0 - CONTRACT_EXECUTABLE_TOKEN ContractExecutableType = 1 + CONTRACT_EXECUTABLE_WASM ContractExecutableType = 0 + CONTRACT_EXECUTABLE_STELLAR_ASSET ContractExecutableType = 1 ) type ContractExecutable struct { // The union discriminant Type selects among the following arms: // CONTRACT_EXECUTABLE_WASM: // Wasm_hash() *Hash - // CONTRACT_EXECUTABLE_TOKEN: + // CONTRACT_EXECUTABLE_STELLAR_ASSET: // void Type ContractExecutableType _u interface{} @@ -4167,6 +4160,12 @@ type StoredTransactionSet struct { _u interface{} } +type StoredDebugTransactionSet struct { + TxSet StoredTransactionSet + LedgerSeq Uint32 + ScpValue StellarValue +} + type PersistedSCPStateV0 struct { ScpEnvelopes []SCPEnvelope QuorumSets []SCPQuorumSet @@ -4274,64 +4273,54 @@ type ContractCostType int32 const ( // Cost of running 1 wasm instruction WasmInsnExec ContractCostType = 0 - // Cost of growing wasm linear memory by 1 page - WasmMemAlloc ContractCostType = 1 - // Cost of allocating a chuck of host memory (in bytes) - HostMemAlloc ContractCostType = 2 - // Cost of copying a chuck of bytes into a pre-allocated host memory - HostMemCpy ContractCostType = 3 - // Cost of comparing two slices of host memory - HostMemCmp ContractCostType = 4 + // Cost of allocating a slice of memory (in bytes) + MemAlloc ContractCostType = 1 + // Cost of copying a slice of bytes into a pre-allocated memory + MemCpy ContractCostType = 2 + // Cost of comparing two slices of memory + MemCmp ContractCostType = 3 // Cost of a host function dispatch, not including the actual work done by // the function nor the cost of VM invocation machinary - DispatchHostFunction ContractCostType = 5 + DispatchHostFunction ContractCostType = 4 // Cost of visiting a host object from the host object storage. Exists to // make sure some baseline cost coverage, i.e. repeatly visiting objects // by the guest will always incur some charges. - VisitObject ContractCostType = 6 + VisitObject ContractCostType = 5 // Cost of serializing an xdr object to bytes - ValSer ContractCostType = 7 + ValSer ContractCostType = 6 // Cost of deserializing an xdr object from bytes - ValDeser ContractCostType = 8 + ValDeser ContractCostType = 7 // Cost of computing the sha256 hash from bytes - ComputeSha256Hash ContractCostType = 9 + ComputeSha256Hash ContractCostType = 8 // Cost of computing the ed25519 pubkey from bytes - ComputeEd25519PubKey ContractCostType = 10 - // Cost of accessing an entry in a Map. - MapEntry ContractCostType = 11 - // Cost of accessing an entry in a Vec - VecEntry ContractCostType = 12 + ComputeEd25519PubKey ContractCostType = 9 // Cost of verifying ed25519 signature of a payload. - VerifyEd25519Sig ContractCostType = 13 - // Cost of reading a slice of vm linear memory - VmMemRead ContractCostType = 14 - // Cost of writing to a slice of vm linear memory - VmMemWrite ContractCostType = 15 + VerifyEd25519Sig ContractCostType = 10 // Cost of instantiation a VM from wasm bytes code. - VmInstantiation ContractCostType = 16 + VmInstantiation ContractCostType = 11 // Cost of instantiation a VM from a cached state. - VmCachedInstantiation ContractCostType = 17 + VmCachedInstantiation ContractCostType = 12 // Cost of invoking a function on the VM. If the function is a host function, // additional cost will be covered by `DispatchHostFunction`. - InvokeVmFunction ContractCostType = 18 + InvokeVmFunction ContractCostType = 13 // Cost of computing a keccak256 hash from bytes. - ComputeKeccak256Hash ContractCostType = 19 - // Cost of computing an ECDSA secp256k1 pubkey from bytes. - ComputeEcdsaSecp256k1Key ContractCostType = 20 + ComputeKeccak256Hash ContractCostType = 14 // Cost of computing an ECDSA secp256k1 signature from bytes. - ComputeEcdsaSecp256k1Sig ContractCostType = 21 + ComputeEcdsaSecp256k1Sig ContractCostType = 15 // Cost of recovering an ECDSA secp256k1 key from a signature. - RecoverEcdsaSecp256k1Key ContractCostType = 22 + RecoverEcdsaSecp256k1Key ContractCostType = 16 // Cost of int256 addition (`+`) and subtraction (`-`) operations - Int256AddSub ContractCostType = 23 + Int256AddSub ContractCostType = 17 // Cost of int256 multiplication (`*`) operation - Int256Mul ContractCostType = 24 + Int256Mul ContractCostType = 18 // Cost of int256 division (`/`) operation - Int256Div ContractCostType = 25 + Int256Div ContractCostType = 19 // Cost of int256 power (`exp`) operation - Int256Pow ContractCostType = 26 + Int256Pow ContractCostType = 20 // Cost of int256 shift (`shl`, `shr`) operation - Int256Shift ContractCostType = 27 + Int256Shift ContractCostType = 21 + // Cost of drawing random bytes using a ChaCha20 PRNG + ChaCha20DrawBytes ContractCostType = 22 ) type ContractCostParamEntry struct { @@ -4341,15 +4330,15 @@ type ContractCostParamEntry struct { LinearTerm Int64 } -type StateExpirationSettings struct { - MaxEntryExpiration Uint32 - MinTempEntryExpiration Uint32 - MinPersistentEntryExpiration Uint32 +type StateArchivalSettings struct { + MaxEntryTTL Uint32 + MinTemporaryTTL Uint32 + MinPersistentTTL Uint32 // rent_fee = wfee_rate_average / rent_rate_denominator_for_type PersistentRentRateDenominator Int64 TempRentRateDenominator Int64 - // max number of entries that emit expiration meta in a single ledger - MaxEntriesToExpire Uint32 + // max number of entries that emit archival meta in a single ledger + MaxEntriesToArchive Uint32 // Number of snapshots to use when calculating average BucketList size BucketListSizeWindowSampleSize Uint32 // Maximum number of bytes that we scan for eviction per ledger @@ -4383,7 +4372,7 @@ const ( CONFIG_SETTING_CONTRACT_COST_PARAMS_MEMORY_BYTES ConfigSettingID = 7 CONFIG_SETTING_CONTRACT_DATA_KEY_SIZE_BYTES ConfigSettingID = 8 CONFIG_SETTING_CONTRACT_DATA_ENTRY_SIZE_BYTES ConfigSettingID = 9 - CONFIG_SETTING_STATE_EXPIRATION ConfigSettingID = 10 + CONFIG_SETTING_STATE_ARCHIVAL ConfigSettingID = 10 CONFIG_SETTING_CONTRACT_EXECUTION_LANES ConfigSettingID = 11 CONFIG_SETTING_BUCKETLIST_SIZE_WINDOW ConfigSettingID = 12 CONFIG_SETTING_EVICTION_ITERATOR ConfigSettingID = 13 @@ -4411,8 +4400,8 @@ type ConfigSettingEntry struct { // ContractDataKeySizeBytes() *Uint32 // CONFIG_SETTING_CONTRACT_DATA_ENTRY_SIZE_BYTES: // ContractDataEntrySizeBytes() *Uint32 - // CONFIG_SETTING_STATE_EXPIRATION: - // StateExpirationSettings() *StateExpirationSettings + // CONFIG_SETTING_STATE_ARCHIVAL: + // StateArchivalSettings() *StateArchivalSettings // CONFIG_SETTING_CONTRACT_EXECUTION_LANES: // ContractExecutionLanes() *ConfigSettingContractExecutionLanesV0 // CONFIG_SETTING_BUCKETLIST_SIZE_WINDOW: @@ -5497,7 +5486,7 @@ var _XdrNames_LedgerEntryType = map[int32]string{ int32(CONTRACT_DATA): "CONTRACT_DATA", int32(CONTRACT_CODE): "CONTRACT_CODE", int32(CONFIG_SETTING): "CONFIG_SETTING", - int32(EXPIRATION): "EXPIRATION", + int32(TTL): "TTL", } var _XdrValues_LedgerEntryType = map[string]int32{ "ACCOUNT": int32(ACCOUNT), @@ -5509,7 +5498,7 @@ var _XdrValues_LedgerEntryType = map[string]int32{ "CONTRACT_DATA": int32(CONTRACT_DATA), "CONTRACT_CODE": int32(CONTRACT_CODE), "CONFIG_SETTING": int32(CONFIG_SETTING), - "EXPIRATION": int32(EXPIRATION), + "TTL": int32(TTL), } func (LedgerEntryType) XdrEnumNames() map[int32]string { @@ -7950,20 +7939,20 @@ func (v *ContractCodeEntry) XdrRecurse(x XDR, name string) { } func XDR_ContractCodeEntry(v *ContractCodeEntry) *ContractCodeEntry { return v } -type XdrType_ExpirationEntry = *ExpirationEntry +type XdrType_TTLEntry = *TTLEntry -func (v *ExpirationEntry) XdrPointer() interface{} { return v } -func (ExpirationEntry) XdrTypeName() string { return "ExpirationEntry" } -func (v ExpirationEntry) XdrValue() interface{} { return v } -func (v *ExpirationEntry) XdrMarshal(x XDR, name string) { x.Marshal(name, v) } -func (v *ExpirationEntry) XdrRecurse(x XDR, name string) { +func (v *TTLEntry) XdrPointer() interface{} { return v } +func (TTLEntry) XdrTypeName() string { return "TTLEntry" } +func (v TTLEntry) XdrValue() interface{} { return v } +func (v *TTLEntry) XdrMarshal(x XDR, name string) { x.Marshal(name, v) } +func (v *TTLEntry) XdrRecurse(x XDR, name string) { if name != "" { name = x.Sprintf("%s.", name) } x.Marshal(x.Sprintf("%skeyHash", name), XDR_Hash(&v.KeyHash)) - x.Marshal(x.Sprintf("%sexpirationLedgerSeq", name), XDR_Uint32(&v.ExpirationLedgerSeq)) + x.Marshal(x.Sprintf("%sliveUntilLedgerSeq", name), XDR_Uint32(&v.LiveUntilLedgerSeq)) } -func XDR_ExpirationEntry(v *ExpirationEntry) *ExpirationEntry { return v } +func XDR_TTLEntry(v *TTLEntry) *TTLEntry { return v } var _XdrTags_XdrAnon_LedgerEntryExtensionV1_Ext = map[int32]bool{ XdrToI32(0): true, @@ -8048,7 +8037,7 @@ var _XdrTags_XdrAnon_LedgerEntry_Data = map[int32]bool{ XdrToI32(CONTRACT_DATA): true, XdrToI32(CONTRACT_CODE): true, XdrToI32(CONFIG_SETTING): true, - XdrToI32(EXPIRATION): true, + XdrToI32(TTL): true, } func (_ XdrAnon_LedgerEntry_Data) XdrValidTags() map[int32]bool { @@ -8189,24 +8178,24 @@ func (u *XdrAnon_LedgerEntry_Data) ConfigSetting() *ConfigSettingEntry { return nil } } -func (u *XdrAnon_LedgerEntry_Data) Expiration() *ExpirationEntry { +func (u *XdrAnon_LedgerEntry_Data) Ttl() *TTLEntry { switch u.Type { - case EXPIRATION: - if v, ok := u._u.(*ExpirationEntry); ok { + case TTL: + if v, ok := u._u.(*TTLEntry); ok { return v } else { - var zero ExpirationEntry + var zero TTLEntry u._u = &zero return &zero } default: - XdrPanic("XdrAnon_LedgerEntry_Data.Expiration accessed when Type == %v", u.Type) + XdrPanic("XdrAnon_LedgerEntry_Data.Ttl accessed when Type == %v", u.Type) return nil } } func (u XdrAnon_LedgerEntry_Data) XdrValid() bool { switch u.Type { - case ACCOUNT, TRUSTLINE, OFFER, DATA, CLAIMABLE_BALANCE, LIQUIDITY_POOL, CONTRACT_DATA, CONTRACT_CODE, CONFIG_SETTING, EXPIRATION: + case ACCOUNT, TRUSTLINE, OFFER, DATA, CLAIMABLE_BALANCE, LIQUIDITY_POOL, CONTRACT_DATA, CONTRACT_CODE, CONFIG_SETTING, TTL: return true } return false @@ -8237,8 +8226,8 @@ func (u *XdrAnon_LedgerEntry_Data) XdrUnionBody() XdrType { return XDR_ContractCodeEntry(u.ContractCode()) case CONFIG_SETTING: return XDR_ConfigSettingEntry(u.ConfigSetting()) - case EXPIRATION: - return XDR_ExpirationEntry(u.Expiration()) + case TTL: + return XDR_TTLEntry(u.Ttl()) } return nil } @@ -8262,8 +8251,8 @@ func (u *XdrAnon_LedgerEntry_Data) XdrUnionBodyName() string { return "ContractCode" case CONFIG_SETTING: return "ConfigSetting" - case EXPIRATION: - return "Expiration" + case TTL: + return "Ttl" } return "" } @@ -8307,8 +8296,8 @@ func (u *XdrAnon_LedgerEntry_Data) XdrRecurse(x XDR, name string) { case CONFIG_SETTING: x.Marshal(x.Sprintf("%sconfigSetting", name), XDR_ConfigSettingEntry(u.ConfigSetting())) return - case EXPIRATION: - x.Marshal(x.Sprintf("%sexpiration", name), XDR_ExpirationEntry(u.Expiration())) + case TTL: + x.Marshal(x.Sprintf("%sttl", name), XDR_TTLEntry(u.Ttl())) return } XdrPanic("invalid Type (%v) in XdrAnon_LedgerEntry_Data", u.Type) @@ -8553,21 +8542,19 @@ func XDR_XdrAnon_LedgerKey_ConfigSetting(v *XdrAnon_LedgerKey_ConfigSetting) *Xd return v } -type XdrType_XdrAnon_LedgerKey_Expiration = *XdrAnon_LedgerKey_Expiration +type XdrType_XdrAnon_LedgerKey_Ttl = *XdrAnon_LedgerKey_Ttl -func (v *XdrAnon_LedgerKey_Expiration) XdrPointer() interface{} { return v } -func (XdrAnon_LedgerKey_Expiration) XdrTypeName() string { return "XdrAnon_LedgerKey_Expiration" } -func (v XdrAnon_LedgerKey_Expiration) XdrValue() interface{} { return v } -func (v *XdrAnon_LedgerKey_Expiration) XdrMarshal(x XDR, name string) { x.Marshal(name, v) } -func (v *XdrAnon_LedgerKey_Expiration) XdrRecurse(x XDR, name string) { +func (v *XdrAnon_LedgerKey_Ttl) XdrPointer() interface{} { return v } +func (XdrAnon_LedgerKey_Ttl) XdrTypeName() string { return "XdrAnon_LedgerKey_Ttl" } +func (v XdrAnon_LedgerKey_Ttl) XdrValue() interface{} { return v } +func (v *XdrAnon_LedgerKey_Ttl) XdrMarshal(x XDR, name string) { x.Marshal(name, v) } +func (v *XdrAnon_LedgerKey_Ttl) XdrRecurse(x XDR, name string) { if name != "" { name = x.Sprintf("%s.", name) } x.Marshal(x.Sprintf("%skeyHash", name), XDR_Hash(&v.KeyHash)) } -func XDR_XdrAnon_LedgerKey_Expiration(v *XdrAnon_LedgerKey_Expiration) *XdrAnon_LedgerKey_Expiration { - return v -} +func XDR_XdrAnon_LedgerKey_Ttl(v *XdrAnon_LedgerKey_Ttl) *XdrAnon_LedgerKey_Ttl { return v } var _XdrTags_LedgerKey = map[int32]bool{ XdrToI32(ACCOUNT): true, @@ -8579,7 +8566,7 @@ var _XdrTags_LedgerKey = map[int32]bool{ XdrToI32(CONTRACT_DATA): true, XdrToI32(CONTRACT_CODE): true, XdrToI32(CONFIG_SETTING): true, - XdrToI32(EXPIRATION): true, + XdrToI32(TTL): true, } func (_ LedgerKey) XdrValidTags() map[int32]bool { @@ -8720,24 +8707,24 @@ func (u *LedgerKey) ConfigSetting() *XdrAnon_LedgerKey_ConfigSetting { return nil } } -func (u *LedgerKey) Expiration() *XdrAnon_LedgerKey_Expiration { +func (u *LedgerKey) Ttl() *XdrAnon_LedgerKey_Ttl { switch u.Type { - case EXPIRATION: - if v, ok := u._u.(*XdrAnon_LedgerKey_Expiration); ok { + case TTL: + if v, ok := u._u.(*XdrAnon_LedgerKey_Ttl); ok { return v } else { - var zero XdrAnon_LedgerKey_Expiration + var zero XdrAnon_LedgerKey_Ttl u._u = &zero return &zero } default: - XdrPanic("LedgerKey.Expiration accessed when Type == %v", u.Type) + XdrPanic("LedgerKey.Ttl accessed when Type == %v", u.Type) return nil } } func (u LedgerKey) XdrValid() bool { switch u.Type { - case ACCOUNT, TRUSTLINE, OFFER, DATA, CLAIMABLE_BALANCE, LIQUIDITY_POOL, CONTRACT_DATA, CONTRACT_CODE, CONFIG_SETTING, EXPIRATION: + case ACCOUNT, TRUSTLINE, OFFER, DATA, CLAIMABLE_BALANCE, LIQUIDITY_POOL, CONTRACT_DATA, CONTRACT_CODE, CONFIG_SETTING, TTL: return true } return false @@ -8768,8 +8755,8 @@ func (u *LedgerKey) XdrUnionBody() XdrType { return XDR_XdrAnon_LedgerKey_ContractCode(u.ContractCode()) case CONFIG_SETTING: return XDR_XdrAnon_LedgerKey_ConfigSetting(u.ConfigSetting()) - case EXPIRATION: - return XDR_XdrAnon_LedgerKey_Expiration(u.Expiration()) + case TTL: + return XDR_XdrAnon_LedgerKey_Ttl(u.Ttl()) } return nil } @@ -8793,8 +8780,8 @@ func (u *LedgerKey) XdrUnionBodyName() string { return "ContractCode" case CONFIG_SETTING: return "ConfigSetting" - case EXPIRATION: - return "Expiration" + case TTL: + return "Ttl" } return "" } @@ -8838,8 +8825,8 @@ func (u *LedgerKey) XdrRecurse(x XDR, name string) { case CONFIG_SETTING: x.Marshal(x.Sprintf("%sconfigSetting", name), XDR_XdrAnon_LedgerKey_ConfigSetting(u.ConfigSetting())) return - case EXPIRATION: - x.Marshal(x.Sprintf("%sexpiration", name), XDR_XdrAnon_LedgerKey_Expiration(u.Expiration())) + case TTL: + x.Marshal(x.Sprintf("%sttl", name), XDR_XdrAnon_LedgerKey_Ttl(u.Ttl())) return } XdrPanic("invalid Type (%v) in LedgerKey", u.Type) @@ -12355,24 +12342,6 @@ func (v *LedgerCloseMetaV0) XdrRecurse(x XDR, name string) { } func XDR_LedgerCloseMetaV0(v *LedgerCloseMetaV0) *LedgerCloseMetaV0 { return v } -type XdrType_LedgerCloseMetaV1 = *LedgerCloseMetaV1 - -func (v *LedgerCloseMetaV1) XdrPointer() interface{} { return v } -func (LedgerCloseMetaV1) XdrTypeName() string { return "LedgerCloseMetaV1" } -func (v LedgerCloseMetaV1) XdrValue() interface{} { return v } -func (v *LedgerCloseMetaV1) XdrMarshal(x XDR, name string) { x.Marshal(name, v) } -func (v *LedgerCloseMetaV1) XdrRecurse(x XDR, name string) { - if name != "" { - name = x.Sprintf("%s.", name) - } - x.Marshal(x.Sprintf("%sledgerHeader", name), XDR_LedgerHeaderHistoryEntry(&v.LedgerHeader)) - x.Marshal(x.Sprintf("%stxSet", name), XDR_GeneralizedTransactionSet(&v.TxSet)) - x.Marshal(x.Sprintf("%stxProcessing", name), (*_XdrVec_unbounded_TransactionResultMeta)(&v.TxProcessing)) - x.Marshal(x.Sprintf("%supgradesProcessing", name), (*_XdrVec_unbounded_UpgradeEntryMeta)(&v.UpgradesProcessing)) - x.Marshal(x.Sprintf("%sscpInfo", name), (*_XdrVec_unbounded_SCPHistoryEntry)(&v.ScpInfo)) -} -func XDR_LedgerCloseMetaV1(v *LedgerCloseMetaV1) *LedgerCloseMetaV1 { return v } - type _XdrVec_unbounded_LedgerKey []LedgerKey func (_XdrVec_unbounded_LedgerKey) XdrBound() uint32 { @@ -12487,13 +12456,13 @@ func (v *_XdrVec_unbounded_LedgerEntry) XdrPointer() interface{} { return func (v _XdrVec_unbounded_LedgerEntry) XdrValue() interface{} { return ([]LedgerEntry)(v) } func (v *_XdrVec_unbounded_LedgerEntry) XdrMarshal(x XDR, name string) { x.Marshal(name, v) } -type XdrType_LedgerCloseMetaV2 = *LedgerCloseMetaV2 +type XdrType_LedgerCloseMetaV1 = *LedgerCloseMetaV1 -func (v *LedgerCloseMetaV2) XdrPointer() interface{} { return v } -func (LedgerCloseMetaV2) XdrTypeName() string { return "LedgerCloseMetaV2" } -func (v LedgerCloseMetaV2) XdrValue() interface{} { return v } -func (v *LedgerCloseMetaV2) XdrMarshal(x XDR, name string) { x.Marshal(name, v) } -func (v *LedgerCloseMetaV2) XdrRecurse(x XDR, name string) { +func (v *LedgerCloseMetaV1) XdrPointer() interface{} { return v } +func (LedgerCloseMetaV1) XdrTypeName() string { return "LedgerCloseMetaV1" } +func (v LedgerCloseMetaV1) XdrValue() interface{} { return v } +func (v *LedgerCloseMetaV1) XdrMarshal(x XDR, name string) { x.Marshal(name, v) } +func (v *LedgerCloseMetaV1) XdrRecurse(x XDR, name string) { if name != "" { name = x.Sprintf("%s.", name) } @@ -12507,12 +12476,11 @@ func (v *LedgerCloseMetaV2) XdrRecurse(x XDR, name string) { x.Marshal(x.Sprintf("%sevictedTemporaryLedgerKeys", name), (*_XdrVec_unbounded_LedgerKey)(&v.EvictedTemporaryLedgerKeys)) x.Marshal(x.Sprintf("%sevictedPersistentLedgerEntries", name), (*_XdrVec_unbounded_LedgerEntry)(&v.EvictedPersistentLedgerEntries)) } -func XDR_LedgerCloseMetaV2(v *LedgerCloseMetaV2) *LedgerCloseMetaV2 { return v } +func XDR_LedgerCloseMetaV1(v *LedgerCloseMetaV1) *LedgerCloseMetaV1 { return v } var _XdrTags_LedgerCloseMeta = map[int32]bool{ XdrToI32(0): true, XdrToI32(1): true, - XdrToI32(2): true, } func (_ LedgerCloseMeta) XdrValidTags() map[int32]bool { @@ -12548,24 +12516,9 @@ func (u *LedgerCloseMeta) V1() *LedgerCloseMetaV1 { return nil } } -func (u *LedgerCloseMeta) V2() *LedgerCloseMetaV2 { - switch u.V { - case 2: - if v, ok := u._u.(*LedgerCloseMetaV2); ok { - return v - } else { - var zero LedgerCloseMetaV2 - u._u = &zero - return &zero - } - default: - XdrPanic("LedgerCloseMeta.V2 accessed when V == %v", u.V) - return nil - } -} func (u LedgerCloseMeta) XdrValid() bool { switch u.V { - case 0, 1, 2: + case 0, 1: return true } return false @@ -12582,8 +12535,6 @@ func (u *LedgerCloseMeta) XdrUnionBody() XdrType { return XDR_LedgerCloseMetaV0(u.V0()) case 1: return XDR_LedgerCloseMetaV1(u.V1()) - case 2: - return XDR_LedgerCloseMetaV2(u.V2()) } return nil } @@ -12593,8 +12544,6 @@ func (u *LedgerCloseMeta) XdrUnionBodyName() string { return "V0" case 1: return "V1" - case 2: - return "V2" } return "" } @@ -12617,9 +12566,6 @@ func (u *LedgerCloseMeta) XdrRecurse(x XDR, name string) { case 1: x.Marshal(x.Sprintf("%sv1", name), XDR_LedgerCloseMetaV1(u.V1())) return - case 2: - x.Marshal(x.Sprintf("%sv2", name), XDR_LedgerCloseMetaV2(u.V2())) - return } XdrPanic("invalid V (%v) in LedgerCloseMeta", u.V) } @@ -14418,7 +14364,7 @@ var _XdrNames_OperationType = map[int32]string{ int32(LIQUIDITY_POOL_DEPOSIT): "LIQUIDITY_POOL_DEPOSIT", int32(LIQUIDITY_POOL_WITHDRAW): "LIQUIDITY_POOL_WITHDRAW", int32(INVOKE_HOST_FUNCTION): "INVOKE_HOST_FUNCTION", - int32(BUMP_FOOTPRINT_EXPIRATION): "BUMP_FOOTPRINT_EXPIRATION", + int32(EXTEND_FOOTPRINT_TTL): "EXTEND_FOOTPRINT_TTL", int32(RESTORE_FOOTPRINT): "RESTORE_FOOTPRINT", } var _XdrValues_OperationType = map[string]int32{ @@ -14447,7 +14393,7 @@ var _XdrValues_OperationType = map[string]int32{ "LIQUIDITY_POOL_DEPOSIT": int32(LIQUIDITY_POOL_DEPOSIT), "LIQUIDITY_POOL_WITHDRAW": int32(LIQUIDITY_POOL_WITHDRAW), "INVOKE_HOST_FUNCTION": int32(INVOKE_HOST_FUNCTION), - "BUMP_FOOTPRINT_EXPIRATION": int32(BUMP_FOOTPRINT_EXPIRATION), + "EXTEND_FOOTPRINT_TTL": int32(EXTEND_FOOTPRINT_TTL), "RESTORE_FOOTPRINT": int32(RESTORE_FOOTPRINT), } @@ -16259,20 +16205,20 @@ func (v *InvokeHostFunctionOp) XdrRecurse(x XDR, name string) { } func XDR_InvokeHostFunctionOp(v *InvokeHostFunctionOp) *InvokeHostFunctionOp { return v } -type XdrType_BumpFootprintExpirationOp = *BumpFootprintExpirationOp +type XdrType_ExtendFootprintTTLOp = *ExtendFootprintTTLOp -func (v *BumpFootprintExpirationOp) XdrPointer() interface{} { return v } -func (BumpFootprintExpirationOp) XdrTypeName() string { return "BumpFootprintExpirationOp" } -func (v BumpFootprintExpirationOp) XdrValue() interface{} { return v } -func (v *BumpFootprintExpirationOp) XdrMarshal(x XDR, name string) { x.Marshal(name, v) } -func (v *BumpFootprintExpirationOp) XdrRecurse(x XDR, name string) { +func (v *ExtendFootprintTTLOp) XdrPointer() interface{} { return v } +func (ExtendFootprintTTLOp) XdrTypeName() string { return "ExtendFootprintTTLOp" } +func (v ExtendFootprintTTLOp) XdrValue() interface{} { return v } +func (v *ExtendFootprintTTLOp) XdrMarshal(x XDR, name string) { x.Marshal(name, v) } +func (v *ExtendFootprintTTLOp) XdrRecurse(x XDR, name string) { if name != "" { name = x.Sprintf("%s.", name) } x.Marshal(x.Sprintf("%sext", name), XDR_ExtensionPoint(&v.Ext)) - x.Marshal(x.Sprintf("%sledgersToExpire", name), XDR_Uint32(&v.LedgersToExpire)) + x.Marshal(x.Sprintf("%sextendTo", name), XDR_Uint32(&v.ExtendTo)) } -func XDR_BumpFootprintExpirationOp(v *BumpFootprintExpirationOp) *BumpFootprintExpirationOp { return v } +func XDR_ExtendFootprintTTLOp(v *ExtendFootprintTTLOp) *ExtendFootprintTTLOp { return v } type XdrType_RestoreFootprintOp = *RestoreFootprintOp @@ -16314,7 +16260,7 @@ var _XdrTags_XdrAnon_Operation_Body = map[int32]bool{ XdrToI32(LIQUIDITY_POOL_DEPOSIT): true, XdrToI32(LIQUIDITY_POOL_WITHDRAW): true, XdrToI32(INVOKE_HOST_FUNCTION): true, - XdrToI32(BUMP_FOOTPRINT_EXPIRATION): true, + XdrToI32(EXTEND_FOOTPRINT_TTL): true, XdrToI32(RESTORE_FOOTPRINT): true, } @@ -16666,18 +16612,18 @@ func (u *XdrAnon_Operation_Body) InvokeHostFunctionOp() *InvokeHostFunctionOp { return nil } } -func (u *XdrAnon_Operation_Body) BumpFootprintExpirationOp() *BumpFootprintExpirationOp { +func (u *XdrAnon_Operation_Body) ExtendFootprintTTLOp() *ExtendFootprintTTLOp { switch u.Type { - case BUMP_FOOTPRINT_EXPIRATION: - if v, ok := u._u.(*BumpFootprintExpirationOp); ok { + case EXTEND_FOOTPRINT_TTL: + if v, ok := u._u.(*ExtendFootprintTTLOp); ok { return v } else { - var zero BumpFootprintExpirationOp + var zero ExtendFootprintTTLOp u._u = &zero return &zero } default: - XdrPanic("XdrAnon_Operation_Body.BumpFootprintExpirationOp accessed when Type == %v", u.Type) + XdrPanic("XdrAnon_Operation_Body.ExtendFootprintTTLOp accessed when Type == %v", u.Type) return nil } } @@ -16698,7 +16644,7 @@ func (u *XdrAnon_Operation_Body) RestoreFootprintOp() *RestoreFootprintOp { } func (u XdrAnon_Operation_Body) XdrValid() bool { switch u.Type { - case CREATE_ACCOUNT, PAYMENT, PATH_PAYMENT_STRICT_RECEIVE, MANAGE_SELL_OFFER, CREATE_PASSIVE_SELL_OFFER, SET_OPTIONS, CHANGE_TRUST, ALLOW_TRUST, ACCOUNT_MERGE, INFLATION, MANAGE_DATA, BUMP_SEQUENCE, MANAGE_BUY_OFFER, PATH_PAYMENT_STRICT_SEND, CREATE_CLAIMABLE_BALANCE, CLAIM_CLAIMABLE_BALANCE, BEGIN_SPONSORING_FUTURE_RESERVES, END_SPONSORING_FUTURE_RESERVES, REVOKE_SPONSORSHIP, CLAWBACK, CLAWBACK_CLAIMABLE_BALANCE, SET_TRUST_LINE_FLAGS, LIQUIDITY_POOL_DEPOSIT, LIQUIDITY_POOL_WITHDRAW, INVOKE_HOST_FUNCTION, BUMP_FOOTPRINT_EXPIRATION, RESTORE_FOOTPRINT: + case CREATE_ACCOUNT, PAYMENT, PATH_PAYMENT_STRICT_RECEIVE, MANAGE_SELL_OFFER, CREATE_PASSIVE_SELL_OFFER, SET_OPTIONS, CHANGE_TRUST, ALLOW_TRUST, ACCOUNT_MERGE, INFLATION, MANAGE_DATA, BUMP_SEQUENCE, MANAGE_BUY_OFFER, PATH_PAYMENT_STRICT_SEND, CREATE_CLAIMABLE_BALANCE, CLAIM_CLAIMABLE_BALANCE, BEGIN_SPONSORING_FUTURE_RESERVES, END_SPONSORING_FUTURE_RESERVES, REVOKE_SPONSORSHIP, CLAWBACK, CLAWBACK_CLAIMABLE_BALANCE, SET_TRUST_LINE_FLAGS, LIQUIDITY_POOL_DEPOSIT, LIQUIDITY_POOL_WITHDRAW, INVOKE_HOST_FUNCTION, EXTEND_FOOTPRINT_TTL, RESTORE_FOOTPRINT: return true } return false @@ -16761,8 +16707,8 @@ func (u *XdrAnon_Operation_Body) XdrUnionBody() XdrType { return XDR_LiquidityPoolWithdrawOp(u.LiquidityPoolWithdrawOp()) case INVOKE_HOST_FUNCTION: return XDR_InvokeHostFunctionOp(u.InvokeHostFunctionOp()) - case BUMP_FOOTPRINT_EXPIRATION: - return XDR_BumpFootprintExpirationOp(u.BumpFootprintExpirationOp()) + case EXTEND_FOOTPRINT_TTL: + return XDR_ExtendFootprintTTLOp(u.ExtendFootprintTTLOp()) case RESTORE_FOOTPRINT: return XDR_RestoreFootprintOp(u.RestoreFootprintOp()) } @@ -16820,8 +16766,8 @@ func (u *XdrAnon_Operation_Body) XdrUnionBodyName() string { return "LiquidityPoolWithdrawOp" case INVOKE_HOST_FUNCTION: return "InvokeHostFunctionOp" - case BUMP_FOOTPRINT_EXPIRATION: - return "BumpFootprintExpirationOp" + case EXTEND_FOOTPRINT_TTL: + return "ExtendFootprintTTLOp" case RESTORE_FOOTPRINT: return "RestoreFootprintOp" } @@ -16913,8 +16859,8 @@ func (u *XdrAnon_Operation_Body) XdrRecurse(x XDR, name string) { case INVOKE_HOST_FUNCTION: x.Marshal(x.Sprintf("%sinvokeHostFunctionOp", name), XDR_InvokeHostFunctionOp(u.InvokeHostFunctionOp())) return - case BUMP_FOOTPRINT_EXPIRATION: - x.Marshal(x.Sprintf("%sbumpFootprintExpirationOp", name), XDR_BumpFootprintExpirationOp(u.BumpFootprintExpirationOp())) + case EXTEND_FOOTPRINT_TTL: + x.Marshal(x.Sprintf("%sextendFootprintTTLOp", name), XDR_ExtendFootprintTTLOp(u.ExtendFootprintTTLOp())) return case RESTORE_FOOTPRINT: x.Marshal(x.Sprintf("%srestoreFootprintOp", name), XDR_RestoreFootprintOp(u.RestoreFootprintOp())) @@ -17960,7 +17906,7 @@ func (v *SorobanTransactionData) XdrRecurse(x XDR, name string) { } x.Marshal(x.Sprintf("%sext", name), XDR_ExtensionPoint(&v.Ext)) x.Marshal(x.Sprintf("%sresources", name), XDR_SorobanResources(&v.Resources)) - x.Marshal(x.Sprintf("%srefundableFee", name), XDR_Int64(&v.RefundableFee)) + x.Marshal(x.Sprintf("%sresourceFee", name), XDR_Int64(&v.ResourceFee)) } func XDR_SorobanTransactionData(v *SorobanTransactionData) *SorobanTransactionData { return v } @@ -22563,7 +22509,7 @@ var _XdrNames_InvokeHostFunctionResultCode = map[int32]string{ int32(INVOKE_HOST_FUNCTION_MALFORMED): "INVOKE_HOST_FUNCTION_MALFORMED", int32(INVOKE_HOST_FUNCTION_TRAPPED): "INVOKE_HOST_FUNCTION_TRAPPED", int32(INVOKE_HOST_FUNCTION_RESOURCE_LIMIT_EXCEEDED): "INVOKE_HOST_FUNCTION_RESOURCE_LIMIT_EXCEEDED", - int32(INVOKE_HOST_FUNCTION_ENTRY_EXPIRED): "INVOKE_HOST_FUNCTION_ENTRY_EXPIRED", + int32(INVOKE_HOST_FUNCTION_ENTRY_ARCHIVED): "INVOKE_HOST_FUNCTION_ENTRY_ARCHIVED", int32(INVOKE_HOST_FUNCTION_INSUFFICIENT_REFUNDABLE_FEE): "INVOKE_HOST_FUNCTION_INSUFFICIENT_REFUNDABLE_FEE", } var _XdrValues_InvokeHostFunctionResultCode = map[string]int32{ @@ -22571,7 +22517,7 @@ var _XdrValues_InvokeHostFunctionResultCode = map[string]int32{ "INVOKE_HOST_FUNCTION_MALFORMED": int32(INVOKE_HOST_FUNCTION_MALFORMED), "INVOKE_HOST_FUNCTION_TRAPPED": int32(INVOKE_HOST_FUNCTION_TRAPPED), "INVOKE_HOST_FUNCTION_RESOURCE_LIMIT_EXCEEDED": int32(INVOKE_HOST_FUNCTION_RESOURCE_LIMIT_EXCEEDED), - "INVOKE_HOST_FUNCTION_ENTRY_EXPIRED": int32(INVOKE_HOST_FUNCTION_ENTRY_EXPIRED), + "INVOKE_HOST_FUNCTION_ENTRY_ARCHIVED": int32(INVOKE_HOST_FUNCTION_ENTRY_ARCHIVED), "INVOKE_HOST_FUNCTION_INSUFFICIENT_REFUNDABLE_FEE": int32(INVOKE_HOST_FUNCTION_INSUFFICIENT_REFUNDABLE_FEE), } @@ -22627,7 +22573,7 @@ var _XdrTags_InvokeHostFunctionResult = map[int32]bool{ XdrToI32(INVOKE_HOST_FUNCTION_MALFORMED): true, XdrToI32(INVOKE_HOST_FUNCTION_TRAPPED): true, XdrToI32(INVOKE_HOST_FUNCTION_RESOURCE_LIMIT_EXCEEDED): true, - XdrToI32(INVOKE_HOST_FUNCTION_ENTRY_EXPIRED): true, + XdrToI32(INVOKE_HOST_FUNCTION_ENTRY_ARCHIVED): true, XdrToI32(INVOKE_HOST_FUNCTION_INSUFFICIENT_REFUNDABLE_FEE): true, } @@ -22653,7 +22599,7 @@ func (u *InvokeHostFunctionResult) Success() *Hash { } func (u InvokeHostFunctionResult) XdrValid() bool { switch u.Code { - case INVOKE_HOST_FUNCTION_SUCCESS, INVOKE_HOST_FUNCTION_MALFORMED, INVOKE_HOST_FUNCTION_TRAPPED, INVOKE_HOST_FUNCTION_RESOURCE_LIMIT_EXCEEDED, INVOKE_HOST_FUNCTION_ENTRY_EXPIRED, INVOKE_HOST_FUNCTION_INSUFFICIENT_REFUNDABLE_FEE: + case INVOKE_HOST_FUNCTION_SUCCESS, INVOKE_HOST_FUNCTION_MALFORMED, INVOKE_HOST_FUNCTION_TRAPPED, INVOKE_HOST_FUNCTION_RESOURCE_LIMIT_EXCEEDED, INVOKE_HOST_FUNCTION_ENTRY_ARCHIVED, INVOKE_HOST_FUNCTION_INSUFFICIENT_REFUNDABLE_FEE: return true } return false @@ -22668,7 +22614,7 @@ func (u *InvokeHostFunctionResult) XdrUnionBody() XdrType { switch u.Code { case INVOKE_HOST_FUNCTION_SUCCESS: return XDR_Hash(u.Success()) - case INVOKE_HOST_FUNCTION_MALFORMED, INVOKE_HOST_FUNCTION_TRAPPED, INVOKE_HOST_FUNCTION_RESOURCE_LIMIT_EXCEEDED, INVOKE_HOST_FUNCTION_ENTRY_EXPIRED, INVOKE_HOST_FUNCTION_INSUFFICIENT_REFUNDABLE_FEE: + case INVOKE_HOST_FUNCTION_MALFORMED, INVOKE_HOST_FUNCTION_TRAPPED, INVOKE_HOST_FUNCTION_RESOURCE_LIMIT_EXCEEDED, INVOKE_HOST_FUNCTION_ENTRY_ARCHIVED, INVOKE_HOST_FUNCTION_INSUFFICIENT_REFUNDABLE_FEE: return nil } return nil @@ -22677,7 +22623,7 @@ func (u *InvokeHostFunctionResult) XdrUnionBodyName() string { switch u.Code { case INVOKE_HOST_FUNCTION_SUCCESS: return "Success" - case INVOKE_HOST_FUNCTION_MALFORMED, INVOKE_HOST_FUNCTION_TRAPPED, INVOKE_HOST_FUNCTION_RESOURCE_LIMIT_EXCEEDED, INVOKE_HOST_FUNCTION_ENTRY_EXPIRED, INVOKE_HOST_FUNCTION_INSUFFICIENT_REFUNDABLE_FEE: + case INVOKE_HOST_FUNCTION_MALFORMED, INVOKE_HOST_FUNCTION_TRAPPED, INVOKE_HOST_FUNCTION_RESOURCE_LIMIT_EXCEEDED, INVOKE_HOST_FUNCTION_ENTRY_ARCHIVED, INVOKE_HOST_FUNCTION_INSUFFICIENT_REFUNDABLE_FEE: return "" } return "" @@ -22698,141 +22644,135 @@ func (u *InvokeHostFunctionResult) XdrRecurse(x XDR, name string) { case INVOKE_HOST_FUNCTION_SUCCESS: x.Marshal(x.Sprintf("%ssuccess", name), XDR_Hash(u.Success())) return - case INVOKE_HOST_FUNCTION_MALFORMED, INVOKE_HOST_FUNCTION_TRAPPED, INVOKE_HOST_FUNCTION_RESOURCE_LIMIT_EXCEEDED, INVOKE_HOST_FUNCTION_ENTRY_EXPIRED, INVOKE_HOST_FUNCTION_INSUFFICIENT_REFUNDABLE_FEE: + case INVOKE_HOST_FUNCTION_MALFORMED, INVOKE_HOST_FUNCTION_TRAPPED, INVOKE_HOST_FUNCTION_RESOURCE_LIMIT_EXCEEDED, INVOKE_HOST_FUNCTION_ENTRY_ARCHIVED, INVOKE_HOST_FUNCTION_INSUFFICIENT_REFUNDABLE_FEE: return } XdrPanic("invalid Code (%v) in InvokeHostFunctionResult", u.Code) } func XDR_InvokeHostFunctionResult(v *InvokeHostFunctionResult) *InvokeHostFunctionResult { return v } -var _XdrNames_BumpFootprintExpirationResultCode = map[int32]string{ - int32(BUMP_FOOTPRINT_EXPIRATION_SUCCESS): "BUMP_FOOTPRINT_EXPIRATION_SUCCESS", - int32(BUMP_FOOTPRINT_EXPIRATION_MALFORMED): "BUMP_FOOTPRINT_EXPIRATION_MALFORMED", - int32(BUMP_FOOTPRINT_EXPIRATION_RESOURCE_LIMIT_EXCEEDED): "BUMP_FOOTPRINT_EXPIRATION_RESOURCE_LIMIT_EXCEEDED", - int32(BUMP_FOOTPRINT_EXPIRATION_INSUFFICIENT_REFUNDABLE_FEE): "BUMP_FOOTPRINT_EXPIRATION_INSUFFICIENT_REFUNDABLE_FEE", +var _XdrNames_ExtendFootprintTTLResultCode = map[int32]string{ + int32(EXTEND_FOOTPRINT_TTL_SUCCESS): "EXTEND_FOOTPRINT_TTL_SUCCESS", + int32(EXTEND_FOOTPRINT_TTL_MALFORMED): "EXTEND_FOOTPRINT_TTL_MALFORMED", + int32(EXTEND_FOOTPRINT_TTL_RESOURCE_LIMIT_EXCEEDED): "EXTEND_FOOTPRINT_TTL_RESOURCE_LIMIT_EXCEEDED", + int32(EXTEND_FOOTPRINT_TTL_INSUFFICIENT_REFUNDABLE_FEE): "EXTEND_FOOTPRINT_TTL_INSUFFICIENT_REFUNDABLE_FEE", } -var _XdrValues_BumpFootprintExpirationResultCode = map[string]int32{ - "BUMP_FOOTPRINT_EXPIRATION_SUCCESS": int32(BUMP_FOOTPRINT_EXPIRATION_SUCCESS), - "BUMP_FOOTPRINT_EXPIRATION_MALFORMED": int32(BUMP_FOOTPRINT_EXPIRATION_MALFORMED), - "BUMP_FOOTPRINT_EXPIRATION_RESOURCE_LIMIT_EXCEEDED": int32(BUMP_FOOTPRINT_EXPIRATION_RESOURCE_LIMIT_EXCEEDED), - "BUMP_FOOTPRINT_EXPIRATION_INSUFFICIENT_REFUNDABLE_FEE": int32(BUMP_FOOTPRINT_EXPIRATION_INSUFFICIENT_REFUNDABLE_FEE), +var _XdrValues_ExtendFootprintTTLResultCode = map[string]int32{ + "EXTEND_FOOTPRINT_TTL_SUCCESS": int32(EXTEND_FOOTPRINT_TTL_SUCCESS), + "EXTEND_FOOTPRINT_TTL_MALFORMED": int32(EXTEND_FOOTPRINT_TTL_MALFORMED), + "EXTEND_FOOTPRINT_TTL_RESOURCE_LIMIT_EXCEEDED": int32(EXTEND_FOOTPRINT_TTL_RESOURCE_LIMIT_EXCEEDED), + "EXTEND_FOOTPRINT_TTL_INSUFFICIENT_REFUNDABLE_FEE": int32(EXTEND_FOOTPRINT_TTL_INSUFFICIENT_REFUNDABLE_FEE), } -func (BumpFootprintExpirationResultCode) XdrEnumNames() map[int32]string { - return _XdrNames_BumpFootprintExpirationResultCode +func (ExtendFootprintTTLResultCode) XdrEnumNames() map[int32]string { + return _XdrNames_ExtendFootprintTTLResultCode } -func (v BumpFootprintExpirationResultCode) String() string { - if s, ok := _XdrNames_BumpFootprintExpirationResultCode[int32(v)]; ok { +func (v ExtendFootprintTTLResultCode) String() string { + if s, ok := _XdrNames_ExtendFootprintTTLResultCode[int32(v)]; ok { return s } - return fmt.Sprintf("BumpFootprintExpirationResultCode#%d", v) + return fmt.Sprintf("ExtendFootprintTTLResultCode#%d", v) } -func (v *BumpFootprintExpirationResultCode) Scan(ss fmt.ScanState, _ rune) error { +func (v *ExtendFootprintTTLResultCode) Scan(ss fmt.ScanState, _ rune) error { if tok, err := ss.Token(true, XdrSymChar); err != nil { return err } else { stok := string(tok) - if val, ok := _XdrValues_BumpFootprintExpirationResultCode[stok]; ok { - *v = BumpFootprintExpirationResultCode(val) + if val, ok := _XdrValues_ExtendFootprintTTLResultCode[stok]; ok { + *v = ExtendFootprintTTLResultCode(val) return nil - } else if stok == "BumpFootprintExpirationResultCode" { + } else if stok == "ExtendFootprintTTLResultCode" { if n, err := fmt.Fscanf(ss, "#%d", (*int32)(v)); n == 1 && err == nil { return nil } } - return XdrError(fmt.Sprintf("%s is not a valid BumpFootprintExpirationResultCode.", stok)) + return XdrError(fmt.Sprintf("%s is not a valid ExtendFootprintTTLResultCode.", stok)) } } -func (v BumpFootprintExpirationResultCode) GetU32() uint32 { return uint32(v) } -func (v *BumpFootprintExpirationResultCode) SetU32(n uint32) { - *v = BumpFootprintExpirationResultCode(n) -} -func (v *BumpFootprintExpirationResultCode) XdrPointer() interface{} { return v } -func (BumpFootprintExpirationResultCode) XdrTypeName() string { - return "BumpFootprintExpirationResultCode" -} -func (v BumpFootprintExpirationResultCode) XdrValue() interface{} { return v } -func (v *BumpFootprintExpirationResultCode) XdrMarshal(x XDR, name string) { x.Marshal(name, v) } +func (v ExtendFootprintTTLResultCode) GetU32() uint32 { return uint32(v) } +func (v *ExtendFootprintTTLResultCode) SetU32(n uint32) { *v = ExtendFootprintTTLResultCode(n) } +func (v *ExtendFootprintTTLResultCode) XdrPointer() interface{} { return v } +func (ExtendFootprintTTLResultCode) XdrTypeName() string { return "ExtendFootprintTTLResultCode" } +func (v ExtendFootprintTTLResultCode) XdrValue() interface{} { return v } +func (v *ExtendFootprintTTLResultCode) XdrMarshal(x XDR, name string) { x.Marshal(name, v) } -type XdrType_BumpFootprintExpirationResultCode = *BumpFootprintExpirationResultCode +type XdrType_ExtendFootprintTTLResultCode = *ExtendFootprintTTLResultCode -func XDR_BumpFootprintExpirationResultCode(v *BumpFootprintExpirationResultCode) *BumpFootprintExpirationResultCode { +func XDR_ExtendFootprintTTLResultCode(v *ExtendFootprintTTLResultCode) *ExtendFootprintTTLResultCode { return v } -var _XdrComments_BumpFootprintExpirationResultCode = map[int32]string{ - int32(BUMP_FOOTPRINT_EXPIRATION_SUCCESS): "codes considered as \"success\" for the operation", - int32(BUMP_FOOTPRINT_EXPIRATION_MALFORMED): "codes considered as \"failure\" for the operation", +var _XdrComments_ExtendFootprintTTLResultCode = map[int32]string{ + int32(EXTEND_FOOTPRINT_TTL_SUCCESS): "codes considered as \"success\" for the operation", + int32(EXTEND_FOOTPRINT_TTL_MALFORMED): "codes considered as \"failure\" for the operation", } -func (e BumpFootprintExpirationResultCode) XdrEnumComments() map[int32]string { - return _XdrComments_BumpFootprintExpirationResultCode +func (e ExtendFootprintTTLResultCode) XdrEnumComments() map[int32]string { + return _XdrComments_ExtendFootprintTTLResultCode } -var _XdrTags_BumpFootprintExpirationResult = map[int32]bool{ - XdrToI32(BUMP_FOOTPRINT_EXPIRATION_SUCCESS): true, - XdrToI32(BUMP_FOOTPRINT_EXPIRATION_MALFORMED): true, - XdrToI32(BUMP_FOOTPRINT_EXPIRATION_RESOURCE_LIMIT_EXCEEDED): true, - XdrToI32(BUMP_FOOTPRINT_EXPIRATION_INSUFFICIENT_REFUNDABLE_FEE): true, +var _XdrTags_ExtendFootprintTTLResult = map[int32]bool{ + XdrToI32(EXTEND_FOOTPRINT_TTL_SUCCESS): true, + XdrToI32(EXTEND_FOOTPRINT_TTL_MALFORMED): true, + XdrToI32(EXTEND_FOOTPRINT_TTL_RESOURCE_LIMIT_EXCEEDED): true, + XdrToI32(EXTEND_FOOTPRINT_TTL_INSUFFICIENT_REFUNDABLE_FEE): true, } -func (_ BumpFootprintExpirationResult) XdrValidTags() map[int32]bool { - return _XdrTags_BumpFootprintExpirationResult +func (_ ExtendFootprintTTLResult) XdrValidTags() map[int32]bool { + return _XdrTags_ExtendFootprintTTLResult } -func (u BumpFootprintExpirationResult) XdrValid() bool { +func (u ExtendFootprintTTLResult) XdrValid() bool { switch u.Code { - case BUMP_FOOTPRINT_EXPIRATION_SUCCESS, BUMP_FOOTPRINT_EXPIRATION_MALFORMED, BUMP_FOOTPRINT_EXPIRATION_RESOURCE_LIMIT_EXCEEDED, BUMP_FOOTPRINT_EXPIRATION_INSUFFICIENT_REFUNDABLE_FEE: + case EXTEND_FOOTPRINT_TTL_SUCCESS, EXTEND_FOOTPRINT_TTL_MALFORMED, EXTEND_FOOTPRINT_TTL_RESOURCE_LIMIT_EXCEEDED, EXTEND_FOOTPRINT_TTL_INSUFFICIENT_REFUNDABLE_FEE: return true } return false } -func (u *BumpFootprintExpirationResult) XdrUnionTag() XdrNum32 { - return XDR_BumpFootprintExpirationResultCode(&u.Code) +func (u *ExtendFootprintTTLResult) XdrUnionTag() XdrNum32 { + return XDR_ExtendFootprintTTLResultCode(&u.Code) } -func (u *BumpFootprintExpirationResult) XdrUnionTagName() string { +func (u *ExtendFootprintTTLResult) XdrUnionTagName() string { return "Code" } -func (u *BumpFootprintExpirationResult) XdrUnionBody() XdrType { +func (u *ExtendFootprintTTLResult) XdrUnionBody() XdrType { switch u.Code { - case BUMP_FOOTPRINT_EXPIRATION_SUCCESS: + case EXTEND_FOOTPRINT_TTL_SUCCESS: return nil - case BUMP_FOOTPRINT_EXPIRATION_MALFORMED, BUMP_FOOTPRINT_EXPIRATION_RESOURCE_LIMIT_EXCEEDED, BUMP_FOOTPRINT_EXPIRATION_INSUFFICIENT_REFUNDABLE_FEE: + case EXTEND_FOOTPRINT_TTL_MALFORMED, EXTEND_FOOTPRINT_TTL_RESOURCE_LIMIT_EXCEEDED, EXTEND_FOOTPRINT_TTL_INSUFFICIENT_REFUNDABLE_FEE: return nil } return nil } -func (u *BumpFootprintExpirationResult) XdrUnionBodyName() string { +func (u *ExtendFootprintTTLResult) XdrUnionBodyName() string { switch u.Code { - case BUMP_FOOTPRINT_EXPIRATION_SUCCESS: + case EXTEND_FOOTPRINT_TTL_SUCCESS: return "" - case BUMP_FOOTPRINT_EXPIRATION_MALFORMED, BUMP_FOOTPRINT_EXPIRATION_RESOURCE_LIMIT_EXCEEDED, BUMP_FOOTPRINT_EXPIRATION_INSUFFICIENT_REFUNDABLE_FEE: + case EXTEND_FOOTPRINT_TTL_MALFORMED, EXTEND_FOOTPRINT_TTL_RESOURCE_LIMIT_EXCEEDED, EXTEND_FOOTPRINT_TTL_INSUFFICIENT_REFUNDABLE_FEE: return "" } return "" } -type XdrType_BumpFootprintExpirationResult = *BumpFootprintExpirationResult +type XdrType_ExtendFootprintTTLResult = *ExtendFootprintTTLResult -func (v *BumpFootprintExpirationResult) XdrPointer() interface{} { return v } -func (BumpFootprintExpirationResult) XdrTypeName() string { return "BumpFootprintExpirationResult" } -func (v BumpFootprintExpirationResult) XdrValue() interface{} { return v } -func (v *BumpFootprintExpirationResult) XdrMarshal(x XDR, name string) { x.Marshal(name, v) } -func (u *BumpFootprintExpirationResult) XdrRecurse(x XDR, name string) { +func (v *ExtendFootprintTTLResult) XdrPointer() interface{} { return v } +func (ExtendFootprintTTLResult) XdrTypeName() string { return "ExtendFootprintTTLResult" } +func (v ExtendFootprintTTLResult) XdrValue() interface{} { return v } +func (v *ExtendFootprintTTLResult) XdrMarshal(x XDR, name string) { x.Marshal(name, v) } +func (u *ExtendFootprintTTLResult) XdrRecurse(x XDR, name string) { if name != "" { name = x.Sprintf("%s.", name) } - XDR_BumpFootprintExpirationResultCode(&u.Code).XdrMarshal(x, x.Sprintf("%scode", name)) + XDR_ExtendFootprintTTLResultCode(&u.Code).XdrMarshal(x, x.Sprintf("%scode", name)) switch u.Code { - case BUMP_FOOTPRINT_EXPIRATION_SUCCESS: + case EXTEND_FOOTPRINT_TTL_SUCCESS: return - case BUMP_FOOTPRINT_EXPIRATION_MALFORMED, BUMP_FOOTPRINT_EXPIRATION_RESOURCE_LIMIT_EXCEEDED, BUMP_FOOTPRINT_EXPIRATION_INSUFFICIENT_REFUNDABLE_FEE: + case EXTEND_FOOTPRINT_TTL_MALFORMED, EXTEND_FOOTPRINT_TTL_RESOURCE_LIMIT_EXCEEDED, EXTEND_FOOTPRINT_TTL_INSUFFICIENT_REFUNDABLE_FEE: return } - XdrPanic("invalid Code (%v) in BumpFootprintExpirationResult", u.Code) -} -func XDR_BumpFootprintExpirationResult(v *BumpFootprintExpirationResult) *BumpFootprintExpirationResult { - return v + XdrPanic("invalid Code (%v) in ExtendFootprintTTLResult", u.Code) } +func XDR_ExtendFootprintTTLResult(v *ExtendFootprintTTLResult) *ExtendFootprintTTLResult { return v } var _XdrNames_RestoreFootprintResultCode = map[int32]string{ int32(RESTORE_FOOTPRINT_SUCCESS): "RESTORE_FOOTPRINT_SUCCESS", @@ -23052,7 +22992,7 @@ var _XdrTags_XdrAnon_OperationResult_Tr = map[int32]bool{ XdrToI32(LIQUIDITY_POOL_DEPOSIT): true, XdrToI32(LIQUIDITY_POOL_WITHDRAW): true, XdrToI32(INVOKE_HOST_FUNCTION): true, - XdrToI32(BUMP_FOOTPRINT_EXPIRATION): true, + XdrToI32(EXTEND_FOOTPRINT_TTL): true, XdrToI32(RESTORE_FOOTPRINT): true, } @@ -23434,18 +23374,18 @@ func (u *XdrAnon_OperationResult_Tr) InvokeHostFunctionResult() *InvokeHostFunct return nil } } -func (u *XdrAnon_OperationResult_Tr) BumpFootprintExpirationResult() *BumpFootprintExpirationResult { +func (u *XdrAnon_OperationResult_Tr) ExtendFootprintTTLResult() *ExtendFootprintTTLResult { switch u.Type { - case BUMP_FOOTPRINT_EXPIRATION: - if v, ok := u._u.(*BumpFootprintExpirationResult); ok { + case EXTEND_FOOTPRINT_TTL: + if v, ok := u._u.(*ExtendFootprintTTLResult); ok { return v } else { - var zero BumpFootprintExpirationResult + var zero ExtendFootprintTTLResult u._u = &zero return &zero } default: - XdrPanic("XdrAnon_OperationResult_Tr.BumpFootprintExpirationResult accessed when Type == %v", u.Type) + XdrPanic("XdrAnon_OperationResult_Tr.ExtendFootprintTTLResult accessed when Type == %v", u.Type) return nil } } @@ -23466,7 +23406,7 @@ func (u *XdrAnon_OperationResult_Tr) RestoreFootprintResult() *RestoreFootprintR } func (u XdrAnon_OperationResult_Tr) XdrValid() bool { switch u.Type { - case CREATE_ACCOUNT, PAYMENT, PATH_PAYMENT_STRICT_RECEIVE, MANAGE_SELL_OFFER, CREATE_PASSIVE_SELL_OFFER, SET_OPTIONS, CHANGE_TRUST, ALLOW_TRUST, ACCOUNT_MERGE, INFLATION, MANAGE_DATA, BUMP_SEQUENCE, MANAGE_BUY_OFFER, PATH_PAYMENT_STRICT_SEND, CREATE_CLAIMABLE_BALANCE, CLAIM_CLAIMABLE_BALANCE, BEGIN_SPONSORING_FUTURE_RESERVES, END_SPONSORING_FUTURE_RESERVES, REVOKE_SPONSORSHIP, CLAWBACK, CLAWBACK_CLAIMABLE_BALANCE, SET_TRUST_LINE_FLAGS, LIQUIDITY_POOL_DEPOSIT, LIQUIDITY_POOL_WITHDRAW, INVOKE_HOST_FUNCTION, BUMP_FOOTPRINT_EXPIRATION, RESTORE_FOOTPRINT: + case CREATE_ACCOUNT, PAYMENT, PATH_PAYMENT_STRICT_RECEIVE, MANAGE_SELL_OFFER, CREATE_PASSIVE_SELL_OFFER, SET_OPTIONS, CHANGE_TRUST, ALLOW_TRUST, ACCOUNT_MERGE, INFLATION, MANAGE_DATA, BUMP_SEQUENCE, MANAGE_BUY_OFFER, PATH_PAYMENT_STRICT_SEND, CREATE_CLAIMABLE_BALANCE, CLAIM_CLAIMABLE_BALANCE, BEGIN_SPONSORING_FUTURE_RESERVES, END_SPONSORING_FUTURE_RESERVES, REVOKE_SPONSORSHIP, CLAWBACK, CLAWBACK_CLAIMABLE_BALANCE, SET_TRUST_LINE_FLAGS, LIQUIDITY_POOL_DEPOSIT, LIQUIDITY_POOL_WITHDRAW, INVOKE_HOST_FUNCTION, EXTEND_FOOTPRINT_TTL, RESTORE_FOOTPRINT: return true } return false @@ -23529,8 +23469,8 @@ func (u *XdrAnon_OperationResult_Tr) XdrUnionBody() XdrType { return XDR_LiquidityPoolWithdrawResult(u.LiquidityPoolWithdrawResult()) case INVOKE_HOST_FUNCTION: return XDR_InvokeHostFunctionResult(u.InvokeHostFunctionResult()) - case BUMP_FOOTPRINT_EXPIRATION: - return XDR_BumpFootprintExpirationResult(u.BumpFootprintExpirationResult()) + case EXTEND_FOOTPRINT_TTL: + return XDR_ExtendFootprintTTLResult(u.ExtendFootprintTTLResult()) case RESTORE_FOOTPRINT: return XDR_RestoreFootprintResult(u.RestoreFootprintResult()) } @@ -23588,8 +23528,8 @@ func (u *XdrAnon_OperationResult_Tr) XdrUnionBodyName() string { return "LiquidityPoolWithdrawResult" case INVOKE_HOST_FUNCTION: return "InvokeHostFunctionResult" - case BUMP_FOOTPRINT_EXPIRATION: - return "BumpFootprintExpirationResult" + case EXTEND_FOOTPRINT_TTL: + return "ExtendFootprintTTLResult" case RESTORE_FOOTPRINT: return "RestoreFootprintResult" } @@ -23683,8 +23623,8 @@ func (u *XdrAnon_OperationResult_Tr) XdrRecurse(x XDR, name string) { case INVOKE_HOST_FUNCTION: x.Marshal(x.Sprintf("%sinvokeHostFunctionResult", name), XDR_InvokeHostFunctionResult(u.InvokeHostFunctionResult())) return - case BUMP_FOOTPRINT_EXPIRATION: - x.Marshal(x.Sprintf("%sbumpFootprintExpirationResult", name), XDR_BumpFootprintExpirationResult(u.BumpFootprintExpirationResult())) + case EXTEND_FOOTPRINT_TTL: + x.Marshal(x.Sprintf("%sextendFootprintTTLResult", name), XDR_ExtendFootprintTTLResult(u.ExtendFootprintTTLResult())) return case RESTORE_FOOTPRINT: x.Marshal(x.Sprintf("%srestoreFootprintResult", name), XDR_RestoreFootprintResult(u.RestoreFootprintResult())) @@ -26988,12 +26928,12 @@ func (v *Int256Parts) XdrRecurse(x XDR, name string) { func XDR_Int256Parts(v *Int256Parts) *Int256Parts { return v } var _XdrNames_ContractExecutableType = map[int32]string{ - int32(CONTRACT_EXECUTABLE_WASM): "CONTRACT_EXECUTABLE_WASM", - int32(CONTRACT_EXECUTABLE_TOKEN): "CONTRACT_EXECUTABLE_TOKEN", + int32(CONTRACT_EXECUTABLE_WASM): "CONTRACT_EXECUTABLE_WASM", + int32(CONTRACT_EXECUTABLE_STELLAR_ASSET): "CONTRACT_EXECUTABLE_STELLAR_ASSET", } var _XdrValues_ContractExecutableType = map[string]int32{ - "CONTRACT_EXECUTABLE_WASM": int32(CONTRACT_EXECUTABLE_WASM), - "CONTRACT_EXECUTABLE_TOKEN": int32(CONTRACT_EXECUTABLE_TOKEN), + "CONTRACT_EXECUTABLE_WASM": int32(CONTRACT_EXECUTABLE_WASM), + "CONTRACT_EXECUTABLE_STELLAR_ASSET": int32(CONTRACT_EXECUTABLE_STELLAR_ASSET), } func (ContractExecutableType) XdrEnumNames() map[int32]string { @@ -27033,8 +26973,8 @@ type XdrType_ContractExecutableType = *ContractExecutableType func XDR_ContractExecutableType(v *ContractExecutableType) *ContractExecutableType { return v } var _XdrTags_ContractExecutable = map[int32]bool{ - XdrToI32(CONTRACT_EXECUTABLE_WASM): true, - XdrToI32(CONTRACT_EXECUTABLE_TOKEN): true, + XdrToI32(CONTRACT_EXECUTABLE_WASM): true, + XdrToI32(CONTRACT_EXECUTABLE_STELLAR_ASSET): true, } func (_ ContractExecutable) XdrValidTags() map[int32]bool { @@ -27057,7 +26997,7 @@ func (u *ContractExecutable) Wasm_hash() *Hash { } func (u ContractExecutable) XdrValid() bool { switch u.Type { - case CONTRACT_EXECUTABLE_WASM, CONTRACT_EXECUTABLE_TOKEN: + case CONTRACT_EXECUTABLE_WASM, CONTRACT_EXECUTABLE_STELLAR_ASSET: return true } return false @@ -27072,7 +27012,7 @@ func (u *ContractExecutable) XdrUnionBody() XdrType { switch u.Type { case CONTRACT_EXECUTABLE_WASM: return XDR_Hash(u.Wasm_hash()) - case CONTRACT_EXECUTABLE_TOKEN: + case CONTRACT_EXECUTABLE_STELLAR_ASSET: return nil } return nil @@ -27081,7 +27021,7 @@ func (u *ContractExecutable) XdrUnionBodyName() string { switch u.Type { case CONTRACT_EXECUTABLE_WASM: return "Wasm_hash" - case CONTRACT_EXECUTABLE_TOKEN: + case CONTRACT_EXECUTABLE_STELLAR_ASSET: return "" } return "" @@ -27102,7 +27042,7 @@ func (u *ContractExecutable) XdrRecurse(x XDR, name string) { case CONTRACT_EXECUTABLE_WASM: x.Marshal(x.Sprintf("%swasm_hash", name), XDR_Hash(u.Wasm_hash())) return - case CONTRACT_EXECUTABLE_TOKEN: + case CONTRACT_EXECUTABLE_STELLAR_ASSET: return } XdrPanic("invalid Type (%v) in ContractExecutable", u.Type) @@ -28158,6 +28098,22 @@ func (u *StoredTransactionSet) XdrRecurse(x XDR, name string) { } func XDR_StoredTransactionSet(v *StoredTransactionSet) *StoredTransactionSet { return v } +type XdrType_StoredDebugTransactionSet = *StoredDebugTransactionSet + +func (v *StoredDebugTransactionSet) XdrPointer() interface{} { return v } +func (StoredDebugTransactionSet) XdrTypeName() string { return "StoredDebugTransactionSet" } +func (v StoredDebugTransactionSet) XdrValue() interface{} { return v } +func (v *StoredDebugTransactionSet) XdrMarshal(x XDR, name string) { x.Marshal(name, v) } +func (v *StoredDebugTransactionSet) XdrRecurse(x XDR, name string) { + if name != "" { + name = x.Sprintf("%s.", name) + } + x.Marshal(x.Sprintf("%stxSet", name), XDR_StoredTransactionSet(&v.TxSet)) + x.Marshal(x.Sprintf("%sledgerSeq", name), XDR_Uint32(&v.LedgerSeq)) + x.Marshal(x.Sprintf("%sscpValue", name), XDR_StellarValue(&v.ScpValue)) +} +func XDR_StoredDebugTransactionSet(v *StoredDebugTransactionSet) *StoredDebugTransactionSet { return v } + type _XdrVec_unbounded_StoredTransactionSet []StoredTransactionSet func (_XdrVec_unbounded_StoredTransactionSet) XdrBound() uint32 { @@ -28469,26 +28425,20 @@ func XDR_ConfigSettingContractBandwidthV0(v *ConfigSettingContractBandwidthV0) * var _XdrNames_ContractCostType = map[int32]string{ int32(WasmInsnExec): "WasmInsnExec", - int32(WasmMemAlloc): "WasmMemAlloc", - int32(HostMemAlloc): "HostMemAlloc", - int32(HostMemCpy): "HostMemCpy", - int32(HostMemCmp): "HostMemCmp", + int32(MemAlloc): "MemAlloc", + int32(MemCpy): "MemCpy", + int32(MemCmp): "MemCmp", int32(DispatchHostFunction): "DispatchHostFunction", int32(VisitObject): "VisitObject", int32(ValSer): "ValSer", int32(ValDeser): "ValDeser", int32(ComputeSha256Hash): "ComputeSha256Hash", int32(ComputeEd25519PubKey): "ComputeEd25519PubKey", - int32(MapEntry): "MapEntry", - int32(VecEntry): "VecEntry", int32(VerifyEd25519Sig): "VerifyEd25519Sig", - int32(VmMemRead): "VmMemRead", - int32(VmMemWrite): "VmMemWrite", int32(VmInstantiation): "VmInstantiation", int32(VmCachedInstantiation): "VmCachedInstantiation", int32(InvokeVmFunction): "InvokeVmFunction", int32(ComputeKeccak256Hash): "ComputeKeccak256Hash", - int32(ComputeEcdsaSecp256k1Key): "ComputeEcdsaSecp256k1Key", int32(ComputeEcdsaSecp256k1Sig): "ComputeEcdsaSecp256k1Sig", int32(RecoverEcdsaSecp256k1Key): "RecoverEcdsaSecp256k1Key", int32(Int256AddSub): "Int256AddSub", @@ -28496,29 +28446,24 @@ var _XdrNames_ContractCostType = map[int32]string{ int32(Int256Div): "Int256Div", int32(Int256Pow): "Int256Pow", int32(Int256Shift): "Int256Shift", + int32(ChaCha20DrawBytes): "ChaCha20DrawBytes", } var _XdrValues_ContractCostType = map[string]int32{ "WasmInsnExec": int32(WasmInsnExec), - "WasmMemAlloc": int32(WasmMemAlloc), - "HostMemAlloc": int32(HostMemAlloc), - "HostMemCpy": int32(HostMemCpy), - "HostMemCmp": int32(HostMemCmp), + "MemAlloc": int32(MemAlloc), + "MemCpy": int32(MemCpy), + "MemCmp": int32(MemCmp), "DispatchHostFunction": int32(DispatchHostFunction), "VisitObject": int32(VisitObject), "ValSer": int32(ValSer), "ValDeser": int32(ValDeser), "ComputeSha256Hash": int32(ComputeSha256Hash), "ComputeEd25519PubKey": int32(ComputeEd25519PubKey), - "MapEntry": int32(MapEntry), - "VecEntry": int32(VecEntry), "VerifyEd25519Sig": int32(VerifyEd25519Sig), - "VmMemRead": int32(VmMemRead), - "VmMemWrite": int32(VmMemWrite), "VmInstantiation": int32(VmInstantiation), "VmCachedInstantiation": int32(VmCachedInstantiation), "InvokeVmFunction": int32(InvokeVmFunction), "ComputeKeccak256Hash": int32(ComputeKeccak256Hash), - "ComputeEcdsaSecp256k1Key": int32(ComputeEcdsaSecp256k1Key), "ComputeEcdsaSecp256k1Sig": int32(ComputeEcdsaSecp256k1Sig), "RecoverEcdsaSecp256k1Key": int32(RecoverEcdsaSecp256k1Key), "Int256AddSub": int32(Int256AddSub), @@ -28526,6 +28471,7 @@ var _XdrValues_ContractCostType = map[string]int32{ "Int256Div": int32(Int256Div), "Int256Pow": int32(Int256Pow), "Int256Shift": int32(Int256Shift), + "ChaCha20DrawBytes": int32(ChaCha20DrawBytes), } func (ContractCostType) XdrEnumNames() map[int32]string { @@ -28566,26 +28512,20 @@ func XDR_ContractCostType(v *ContractCostType) *ContractCostType { return v } var _XdrComments_ContractCostType = map[int32]string{ int32(WasmInsnExec): "Cost of running 1 wasm instruction", - int32(WasmMemAlloc): "Cost of growing wasm linear memory by 1 page", - int32(HostMemAlloc): "Cost of allocating a chuck of host memory (in bytes)", - int32(HostMemCpy): "Cost of copying a chuck of bytes into a pre-allocated host memory", - int32(HostMemCmp): "Cost of comparing two slices of host memory", + int32(MemAlloc): "Cost of allocating a slice of memory (in bytes)", + int32(MemCpy): "Cost of copying a slice of bytes into a pre-allocated memory", + int32(MemCmp): "Cost of comparing two slices of memory", int32(DispatchHostFunction): "Cost of a host function dispatch, not including the actual work done by the function nor the cost of VM invocation machinary", int32(VisitObject): "Cost of visiting a host object from the host object storage. Exists to make sure some baseline cost coverage, i.e. repeatly visiting objects by the guest will always incur some charges.", int32(ValSer): "Cost of serializing an xdr object to bytes", int32(ValDeser): "Cost of deserializing an xdr object from bytes", int32(ComputeSha256Hash): "Cost of computing the sha256 hash from bytes", int32(ComputeEd25519PubKey): "Cost of computing the ed25519 pubkey from bytes", - int32(MapEntry): "Cost of accessing an entry in a Map.", - int32(VecEntry): "Cost of accessing an entry in a Vec", int32(VerifyEd25519Sig): "Cost of verifying ed25519 signature of a payload.", - int32(VmMemRead): "Cost of reading a slice of vm linear memory", - int32(VmMemWrite): "Cost of writing to a slice of vm linear memory", int32(VmInstantiation): "Cost of instantiation a VM from wasm bytes code.", int32(VmCachedInstantiation): "Cost of instantiation a VM from a cached state.", int32(InvokeVmFunction): "Cost of invoking a function on the VM. If the function is a host function, additional cost will be covered by `DispatchHostFunction`.", int32(ComputeKeccak256Hash): "Cost of computing a keccak256 hash from bytes.", - int32(ComputeEcdsaSecp256k1Key): "Cost of computing an ECDSA secp256k1 pubkey from bytes.", int32(ComputeEcdsaSecp256k1Sig): "Cost of computing an ECDSA secp256k1 signature from bytes.", int32(RecoverEcdsaSecp256k1Key): "Cost of recovering an ECDSA secp256k1 key from a signature.", int32(Int256AddSub): "Cost of int256 addition (`+`) and subtraction (`-`) operations", @@ -28593,6 +28533,7 @@ var _XdrComments_ContractCostType = map[int32]string{ int32(Int256Div): "Cost of int256 division (`/`) operation", int32(Int256Pow): "Cost of int256 power (`exp`) operation", int32(Int256Shift): "Cost of int256 shift (`shl`, `shr`) operation", + int32(ChaCha20DrawBytes): "Cost of drawing random bytes using a ChaCha20 PRNG", } func (e ContractCostType) XdrEnumComments() map[int32]string { @@ -28615,27 +28556,27 @@ func (v *ContractCostParamEntry) XdrRecurse(x XDR, name string) { } func XDR_ContractCostParamEntry(v *ContractCostParamEntry) *ContractCostParamEntry { return v } -type XdrType_StateExpirationSettings = *StateExpirationSettings +type XdrType_StateArchivalSettings = *StateArchivalSettings -func (v *StateExpirationSettings) XdrPointer() interface{} { return v } -func (StateExpirationSettings) XdrTypeName() string { return "StateExpirationSettings" } -func (v StateExpirationSettings) XdrValue() interface{} { return v } -func (v *StateExpirationSettings) XdrMarshal(x XDR, name string) { x.Marshal(name, v) } -func (v *StateExpirationSettings) XdrRecurse(x XDR, name string) { +func (v *StateArchivalSettings) XdrPointer() interface{} { return v } +func (StateArchivalSettings) XdrTypeName() string { return "StateArchivalSettings" } +func (v StateArchivalSettings) XdrValue() interface{} { return v } +func (v *StateArchivalSettings) XdrMarshal(x XDR, name string) { x.Marshal(name, v) } +func (v *StateArchivalSettings) XdrRecurse(x XDR, name string) { if name != "" { name = x.Sprintf("%s.", name) } - x.Marshal(x.Sprintf("%smaxEntryExpiration", name), XDR_Uint32(&v.MaxEntryExpiration)) - x.Marshal(x.Sprintf("%sminTempEntryExpiration", name), XDR_Uint32(&v.MinTempEntryExpiration)) - x.Marshal(x.Sprintf("%sminPersistentEntryExpiration", name), XDR_Uint32(&v.MinPersistentEntryExpiration)) + x.Marshal(x.Sprintf("%smaxEntryTTL", name), XDR_Uint32(&v.MaxEntryTTL)) + x.Marshal(x.Sprintf("%sminTemporaryTTL", name), XDR_Uint32(&v.MinTemporaryTTL)) + x.Marshal(x.Sprintf("%sminPersistentTTL", name), XDR_Uint32(&v.MinPersistentTTL)) x.Marshal(x.Sprintf("%spersistentRentRateDenominator", name), XDR_Int64(&v.PersistentRentRateDenominator)) x.Marshal(x.Sprintf("%stempRentRateDenominator", name), XDR_Int64(&v.TempRentRateDenominator)) - x.Marshal(x.Sprintf("%smaxEntriesToExpire", name), XDR_Uint32(&v.MaxEntriesToExpire)) + x.Marshal(x.Sprintf("%smaxEntriesToArchive", name), XDR_Uint32(&v.MaxEntriesToArchive)) x.Marshal(x.Sprintf("%sbucketListSizeWindowSampleSize", name), XDR_Uint32(&v.BucketListSizeWindowSampleSize)) x.Marshal(x.Sprintf("%sevictionScanSize", name), XDR_Uint64(&v.EvictionScanSize)) x.Marshal(x.Sprintf("%sstartingEvictionScanLevel", name), XDR_Uint32(&v.StartingEvictionScanLevel)) } -func XDR_StateExpirationSettings(v *StateExpirationSettings) *StateExpirationSettings { return v } +func XDR_StateArchivalSettings(v *StateArchivalSettings) *StateArchivalSettings { return v } type XdrType_EvictionIterator = *EvictionIterator @@ -28735,7 +28676,7 @@ var _XdrNames_ConfigSettingID = map[int32]string{ int32(CONFIG_SETTING_CONTRACT_COST_PARAMS_MEMORY_BYTES): "CONFIG_SETTING_CONTRACT_COST_PARAMS_MEMORY_BYTES", int32(CONFIG_SETTING_CONTRACT_DATA_KEY_SIZE_BYTES): "CONFIG_SETTING_CONTRACT_DATA_KEY_SIZE_BYTES", int32(CONFIG_SETTING_CONTRACT_DATA_ENTRY_SIZE_BYTES): "CONFIG_SETTING_CONTRACT_DATA_ENTRY_SIZE_BYTES", - int32(CONFIG_SETTING_STATE_EXPIRATION): "CONFIG_SETTING_STATE_EXPIRATION", + int32(CONFIG_SETTING_STATE_ARCHIVAL): "CONFIG_SETTING_STATE_ARCHIVAL", int32(CONFIG_SETTING_CONTRACT_EXECUTION_LANES): "CONFIG_SETTING_CONTRACT_EXECUTION_LANES", int32(CONFIG_SETTING_BUCKETLIST_SIZE_WINDOW): "CONFIG_SETTING_BUCKETLIST_SIZE_WINDOW", int32(CONFIG_SETTING_EVICTION_ITERATOR): "CONFIG_SETTING_EVICTION_ITERATOR", @@ -28751,7 +28692,7 @@ var _XdrValues_ConfigSettingID = map[string]int32{ "CONFIG_SETTING_CONTRACT_COST_PARAMS_MEMORY_BYTES": int32(CONFIG_SETTING_CONTRACT_COST_PARAMS_MEMORY_BYTES), "CONFIG_SETTING_CONTRACT_DATA_KEY_SIZE_BYTES": int32(CONFIG_SETTING_CONTRACT_DATA_KEY_SIZE_BYTES), "CONFIG_SETTING_CONTRACT_DATA_ENTRY_SIZE_BYTES": int32(CONFIG_SETTING_CONTRACT_DATA_ENTRY_SIZE_BYTES), - "CONFIG_SETTING_STATE_EXPIRATION": int32(CONFIG_SETTING_STATE_EXPIRATION), + "CONFIG_SETTING_STATE_ARCHIVAL": int32(CONFIG_SETTING_STATE_ARCHIVAL), "CONFIG_SETTING_CONTRACT_EXECUTION_LANES": int32(CONFIG_SETTING_CONTRACT_EXECUTION_LANES), "CONFIG_SETTING_BUCKETLIST_SIZE_WINDOW": int32(CONFIG_SETTING_BUCKETLIST_SIZE_WINDOW), "CONFIG_SETTING_EVICTION_ITERATOR": int32(CONFIG_SETTING_EVICTION_ITERATOR), @@ -28861,7 +28802,7 @@ var _XdrTags_ConfigSettingEntry = map[int32]bool{ XdrToI32(CONFIG_SETTING_CONTRACT_COST_PARAMS_MEMORY_BYTES): true, XdrToI32(CONFIG_SETTING_CONTRACT_DATA_KEY_SIZE_BYTES): true, XdrToI32(CONFIG_SETTING_CONTRACT_DATA_ENTRY_SIZE_BYTES): true, - XdrToI32(CONFIG_SETTING_STATE_EXPIRATION): true, + XdrToI32(CONFIG_SETTING_STATE_ARCHIVAL): true, XdrToI32(CONFIG_SETTING_CONTRACT_EXECUTION_LANES): true, XdrToI32(CONFIG_SETTING_BUCKETLIST_SIZE_WINDOW): true, XdrToI32(CONFIG_SETTING_EVICTION_ITERATOR): true, @@ -29020,18 +28961,18 @@ func (u *ConfigSettingEntry) ContractDataEntrySizeBytes() *Uint32 { return nil } } -func (u *ConfigSettingEntry) StateExpirationSettings() *StateExpirationSettings { +func (u *ConfigSettingEntry) StateArchivalSettings() *StateArchivalSettings { switch u.ConfigSettingID { - case CONFIG_SETTING_STATE_EXPIRATION: - if v, ok := u._u.(*StateExpirationSettings); ok { + case CONFIG_SETTING_STATE_ARCHIVAL: + if v, ok := u._u.(*StateArchivalSettings); ok { return v } else { - var zero StateExpirationSettings + var zero StateArchivalSettings u._u = &zero return &zero } default: - XdrPanic("ConfigSettingEntry.StateExpirationSettings accessed when ConfigSettingID == %v", u.ConfigSettingID) + XdrPanic("ConfigSettingEntry.StateArchivalSettings accessed when ConfigSettingID == %v", u.ConfigSettingID) return nil } } @@ -29082,7 +29023,7 @@ func (u *ConfigSettingEntry) EvictionIterator() *EvictionIterator { } func (u ConfigSettingEntry) XdrValid() bool { switch u.ConfigSettingID { - case CONFIG_SETTING_CONTRACT_MAX_SIZE_BYTES, CONFIG_SETTING_CONTRACT_COMPUTE_V0, CONFIG_SETTING_CONTRACT_LEDGER_COST_V0, CONFIG_SETTING_CONTRACT_HISTORICAL_DATA_V0, CONFIG_SETTING_CONTRACT_EVENTS_V0, CONFIG_SETTING_CONTRACT_BANDWIDTH_V0, CONFIG_SETTING_CONTRACT_COST_PARAMS_CPU_INSTRUCTIONS, CONFIG_SETTING_CONTRACT_COST_PARAMS_MEMORY_BYTES, CONFIG_SETTING_CONTRACT_DATA_KEY_SIZE_BYTES, CONFIG_SETTING_CONTRACT_DATA_ENTRY_SIZE_BYTES, CONFIG_SETTING_STATE_EXPIRATION, CONFIG_SETTING_CONTRACT_EXECUTION_LANES, CONFIG_SETTING_BUCKETLIST_SIZE_WINDOW, CONFIG_SETTING_EVICTION_ITERATOR: + case CONFIG_SETTING_CONTRACT_MAX_SIZE_BYTES, CONFIG_SETTING_CONTRACT_COMPUTE_V0, CONFIG_SETTING_CONTRACT_LEDGER_COST_V0, CONFIG_SETTING_CONTRACT_HISTORICAL_DATA_V0, CONFIG_SETTING_CONTRACT_EVENTS_V0, CONFIG_SETTING_CONTRACT_BANDWIDTH_V0, CONFIG_SETTING_CONTRACT_COST_PARAMS_CPU_INSTRUCTIONS, CONFIG_SETTING_CONTRACT_COST_PARAMS_MEMORY_BYTES, CONFIG_SETTING_CONTRACT_DATA_KEY_SIZE_BYTES, CONFIG_SETTING_CONTRACT_DATA_ENTRY_SIZE_BYTES, CONFIG_SETTING_STATE_ARCHIVAL, CONFIG_SETTING_CONTRACT_EXECUTION_LANES, CONFIG_SETTING_BUCKETLIST_SIZE_WINDOW, CONFIG_SETTING_EVICTION_ITERATOR: return true } return false @@ -29115,8 +29056,8 @@ func (u *ConfigSettingEntry) XdrUnionBody() XdrType { return XDR_Uint32(u.ContractDataKeySizeBytes()) case CONFIG_SETTING_CONTRACT_DATA_ENTRY_SIZE_BYTES: return XDR_Uint32(u.ContractDataEntrySizeBytes()) - case CONFIG_SETTING_STATE_EXPIRATION: - return XDR_StateExpirationSettings(u.StateExpirationSettings()) + case CONFIG_SETTING_STATE_ARCHIVAL: + return XDR_StateArchivalSettings(u.StateArchivalSettings()) case CONFIG_SETTING_CONTRACT_EXECUTION_LANES: return XDR_ConfigSettingContractExecutionLanesV0(u.ContractExecutionLanes()) case CONFIG_SETTING_BUCKETLIST_SIZE_WINDOW: @@ -29148,8 +29089,8 @@ func (u *ConfigSettingEntry) XdrUnionBodyName() string { return "ContractDataKeySizeBytes" case CONFIG_SETTING_CONTRACT_DATA_ENTRY_SIZE_BYTES: return "ContractDataEntrySizeBytes" - case CONFIG_SETTING_STATE_EXPIRATION: - return "StateExpirationSettings" + case CONFIG_SETTING_STATE_ARCHIVAL: + return "StateArchivalSettings" case CONFIG_SETTING_CONTRACT_EXECUTION_LANES: return "ContractExecutionLanes" case CONFIG_SETTING_BUCKETLIST_SIZE_WINDOW: @@ -29202,8 +29143,8 @@ func (u *ConfigSettingEntry) XdrRecurse(x XDR, name string) { case CONFIG_SETTING_CONTRACT_DATA_ENTRY_SIZE_BYTES: x.Marshal(x.Sprintf("%scontractDataEntrySizeBytes", name), XDR_Uint32(u.ContractDataEntrySizeBytes())) return - case CONFIG_SETTING_STATE_EXPIRATION: - x.Marshal(x.Sprintf("%sstateExpirationSettings", name), XDR_StateExpirationSettings(u.StateExpirationSettings())) + case CONFIG_SETTING_STATE_ARCHIVAL: + x.Marshal(x.Sprintf("%sstateArchivalSettings", name), XDR_StateArchivalSettings(u.StateArchivalSettings())) return case CONFIG_SETTING_CONTRACT_EXECUTION_LANES: x.Marshal(x.Sprintf("%scontractExecutionLanes", name), XDR_ConfigSettingContractExecutionLanesV0(u.ContractExecutionLanes())) diff --git a/ingest/change_test.go b/ingest/change_test.go index d8ae9492dc..03af4f2cb4 100644 --- a/ingest/change_test.go +++ b/ingest/change_test.go @@ -99,24 +99,24 @@ func TestSortChanges(t *testing.T) { Post: nil, }, { - Type: xdr.LedgerEntryTypeExpiration, + Type: xdr.LedgerEntryTypeTtl, Pre: &xdr.LedgerEntry{ LastModifiedLedgerSeq: 11, Data: xdr.LedgerEntryData{ - Type: xdr.LedgerEntryTypeExpiration, - Expiration: &xdr.ExpirationEntry{ - KeyHash: xdr.Hash{1}, - ExpirationLedgerSeq: 50, + Type: xdr.LedgerEntryTypeTtl, + Ttl: &xdr.TtlEntry{ + KeyHash: xdr.Hash{1}, + LiveUntilLedgerSeq: 50, }, }, }, Post: &xdr.LedgerEntry{ LastModifiedLedgerSeq: 11, Data: xdr.LedgerEntryData{ - Type: xdr.LedgerEntryTypeExpiration, - Expiration: &xdr.ExpirationEntry{ - KeyHash: xdr.Hash{1}, - ExpirationLedgerSeq: 100, + Type: xdr.LedgerEntryTypeTtl, + Ttl: &xdr.TtlEntry{ + KeyHash: xdr.Hash{1}, + LiveUntilLedgerSeq: 100, }, }, }, @@ -181,24 +181,24 @@ func TestSortChanges(t *testing.T) { }, { - Type: xdr.LedgerEntryTypeExpiration, + Type: xdr.LedgerEntryTypeTtl, Pre: &xdr.LedgerEntry{ LastModifiedLedgerSeq: 11, Data: xdr.LedgerEntryData{ - Type: xdr.LedgerEntryTypeExpiration, - Expiration: &xdr.ExpirationEntry{ - KeyHash: xdr.Hash{1}, - ExpirationLedgerSeq: 50, + Type: xdr.LedgerEntryTypeTtl, + Ttl: &xdr.TtlEntry{ + KeyHash: xdr.Hash{1}, + LiveUntilLedgerSeq: 50, }, }, }, Post: &xdr.LedgerEntry{ LastModifiedLedgerSeq: 11, Data: xdr.LedgerEntryData{ - Type: xdr.LedgerEntryTypeExpiration, - Expiration: &xdr.ExpirationEntry{ - KeyHash: xdr.Hash{1}, - ExpirationLedgerSeq: 100, + Type: xdr.LedgerEntryTypeTtl, + Ttl: &xdr.TtlEntry{ + KeyHash: xdr.Hash{1}, + LiveUntilLedgerSeq: 100, }, }, }, diff --git a/ingest/ledger_change_reader_test.go b/ingest/ledger_change_reader_test.go index dea3794cb5..0b077007e5 100644 --- a/ingest/ledger_change_reader_test.go +++ b/ingest/ledger_change_reader_test.go @@ -394,8 +394,8 @@ func TestLedgerChangeLedgerCloseMetaV2(t *testing.T) { ContractId: &contractID, } 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, @@ -605,8 +605,8 @@ func TestLedgerChangeLedgerCloseMetaV2Empty(t *testing.T) { baseFee := xdr.Int64(100) 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/ingest/ledgerbackend/buffered_meta_pipe_reader.go b/ingest/ledgerbackend/buffered_meta_pipe_reader.go index f73d714324..791d9be72b 100644 --- a/ingest/ledgerbackend/buffered_meta_pipe_reader.go +++ b/ingest/ledgerbackend/buffered_meta_pipe_reader.go @@ -97,7 +97,7 @@ func (b *bufferedLedgerMetaReader) readLedgerMetaFromPipe() (*xdr.LedgerCloseMet } var xlcm xdr.LedgerCloseMeta - _, err = xlcm.DecodeFrom(b.decoder) + _, err = xlcm.DecodeFrom(b.decoder, xdr3.DecodeDefaultMaxDepth) if err != nil { return nil, errors.Wrap(err, "unmarshaling framed LedgerCloseMeta") } diff --git a/ingest/stats_change_processor.go b/ingest/stats_change_processor.go index 01f33da466..43a82011cb 100644 --- a/ingest/stats_change_processor.go +++ b/ingest/stats_change_processor.go @@ -51,9 +51,9 @@ type StatsChangeProcessorResults struct { ConfigSettingsUpdated int64 ConfigSettingsRemoved int64 - ExpirationCreated int64 - ExpirationUpdated int64 - ExpirationRemoved int64 + TtlCreated int64 + TtlUpdated int64 + TtlRemoved int64 } func (p *StatsChangeProcessor) ProcessChange(ctx context.Context, change Change) error { @@ -139,14 +139,14 @@ func (p *StatsChangeProcessor) ProcessChange(ctx context.Context, change Change) case xdr.LedgerEntryChangeTypeLedgerEntryRemoved: p.results.ConfigSettingsRemoved++ } - case xdr.LedgerEntryTypeExpiration: + case xdr.LedgerEntryTypeTtl: switch change.LedgerEntryChangeType() { case xdr.LedgerEntryChangeTypeLedgerEntryCreated: - p.results.ExpirationCreated++ + p.results.TtlCreated++ case xdr.LedgerEntryChangeTypeLedgerEntryUpdated: - p.results.ExpirationUpdated++ + p.results.TtlUpdated++ case xdr.LedgerEntryChangeTypeLedgerEntryRemoved: - p.results.ExpirationRemoved++ + p.results.TtlRemoved++ } default: return fmt.Errorf("unsupported ledger entry type: %s", change.Type.String()) @@ -197,8 +197,8 @@ func (stats *StatsChangeProcessorResults) Map() map[string]interface{} { "stats_config_settings_updated": stats.ConfigSettingsUpdated, "stats_config_settings_removed": stats.ConfigSettingsRemoved, - "stats_expiration_created": stats.ExpirationCreated, - "stats_expiration_updated": stats.ExpirationUpdated, - "stats_expiration_removed": stats.ExpirationRemoved, + "stats_ttl_created": stats.TtlCreated, + "stats_ttl_updated": stats.TtlUpdated, + "stats_ttl_removed": stats.TtlRemoved, } } diff --git a/ingest/stats_change_processor_test.go b/ingest/stats_change_processor_test.go index fe14af56e3..95cb6f1a85 100644 --- a/ingest/stats_change_processor_test.go +++ b/ingest/stats_change_processor_test.go @@ -45,7 +45,7 @@ func TestStatsChangeProcessor(t *testing.T) { assert.Equal(t, int64(1), results.ContractDataCreated) assert.Equal(t, int64(1), results.ContractCodeCreated) assert.Equal(t, int64(1), results.ConfigSettingsCreated) - assert.Equal(t, int64(1), results.ExpirationCreated) + assert.Equal(t, int64(1), results.TtlCreated) assert.Equal(t, int64(1), results.AccountsUpdated) assert.Equal(t, int64(1), results.ClaimableBalancesUpdated) @@ -56,7 +56,7 @@ func TestStatsChangeProcessor(t *testing.T) { assert.Equal(t, int64(1), results.ContractDataUpdated) assert.Equal(t, int64(1), results.ContractCodeUpdated) assert.Equal(t, int64(1), results.ConfigSettingsUpdated) - assert.Equal(t, int64(1), results.ExpirationUpdated) + assert.Equal(t, int64(1), results.TtlUpdated) assert.Equal(t, int64(1), results.AccountsRemoved) assert.Equal(t, int64(1), results.ClaimableBalancesRemoved) @@ -67,7 +67,7 @@ func TestStatsChangeProcessor(t *testing.T) { assert.Equal(t, int64(1), results.ContractCodeRemoved) assert.Equal(t, int64(1), results.ContractDataRemoved) assert.Equal(t, int64(1), results.ConfigSettingsRemoved) - assert.Equal(t, int64(1), results.ExpirationRemoved) + assert.Equal(t, int64(1), results.TtlRemoved) assert.Equal(t, len(xdr.LedgerEntryTypeMap)*3, len(results.Map())) } diff --git a/protocols/horizon/operations/main.go b/protocols/horizon/operations/main.go index e56bbc3649..3e4af748b8 100644 --- a/protocols/horizon/operations/main.go +++ b/protocols/horizon/operations/main.go @@ -39,7 +39,7 @@ var TypeNames = map[xdr.OperationType]string{ xdr.OperationTypeLiquidityPoolDeposit: "liquidity_pool_deposit", xdr.OperationTypeLiquidityPoolWithdraw: "liquidity_pool_withdraw", xdr.OperationTypeInvokeHostFunction: "invoke_host_function", - xdr.OperationTypeBumpFootprintExpiration: "bump_footprint_expiration", + xdr.OperationTypeExtendFootprintTtl: "extend_footprint_ttl", xdr.OperationTypeRestoreFootprint: "restore_footprint", } @@ -373,11 +373,11 @@ type HostFunctionParameter struct { Type string `json:"type"` } -// BumpFootprintExpiration is the json resource representing a single BumpFootprintExpirationOp. -// The model for BumpFootprintExpiration assimilates BumpFootprintExpirationOp, but is simplified. -type BumpFootprintExpiration struct { +// ExtendFootprintTtl is the json resource representing a single ExtendFootprintTtlOp. +// The model for ExtendFootprintTtl assimilates ExtendFootprintTtlOp, but is simplified. +type ExtendFootprintTtl struct { Base - LedgersToExpire uint32 `json:"ledgers_to_expire"` + ExtendTo uint32 `json:"extend_to"` } // RestoreFootprint is the json resource representing a single RestoreFootprint. @@ -642,8 +642,8 @@ func UnmarshalOperation(operationTypeID int32, dataString []byte) (ops Operation return } ops = op - case xdr.OperationTypeBumpFootprintExpiration: - var op BumpFootprintExpiration + case xdr.OperationTypeExtendFootprintTtl: + var op ExtendFootprintTtl if err = json.Unmarshal(dataString, &op); err != nil { return } diff --git a/services/horizon/internal/codes/main.go b/services/horizon/internal/codes/main.go index d2574f2e22..5af63bed1a 100644 --- a/services/horizon/internal/codes/main.go +++ b/services/horizon/internal/codes/main.go @@ -502,20 +502,20 @@ func String(code interface{}) (string, error) { return "function_trapped", nil case xdr.InvokeHostFunctionResultCodeInvokeHostFunctionResourceLimitExceeded: return "resource_limit_exceeded", nil - case xdr.InvokeHostFunctionResultCodeInvokeHostFunctionEntryExpired: - return "entry_expired", nil + case xdr.InvokeHostFunctionResultCodeInvokeHostFunctionEntryArchived: + return "entry_archived", nil case xdr.InvokeHostFunctionResultCodeInvokeHostFunctionInsufficientRefundableFee: return "insufficient_refundable_fee", nil } - case xdr.BumpFootprintExpirationResultCode: + case xdr.ExtendFootprintTtlResultCode: switch code { - case xdr.BumpFootprintExpirationResultCodeBumpFootprintExpirationSuccess: + case xdr.ExtendFootprintTtlResultCodeExtendFootprintTtlSuccess: return OpSuccess, nil - case xdr.BumpFootprintExpirationResultCodeBumpFootprintExpirationMalformed: + case xdr.ExtendFootprintTtlResultCodeExtendFootprintTtlMalformed: return OpMalformed, nil - case xdr.BumpFootprintExpirationResultCodeBumpFootprintExpirationResourceLimitExceeded: + case xdr.ExtendFootprintTtlResultCodeExtendFootprintTtlResourceLimitExceeded: return "resource_limit_exceeded", nil - case xdr.BumpFootprintExpirationResultCodeBumpFootprintExpirationInsufficientRefundableFee: + case xdr.ExtendFootprintTtlResultCodeExtendFootprintTtlInsufficientRefundableFee: return "insufficient_refundable_fee", nil } case xdr.RestoreFootprintResultCode: @@ -595,8 +595,8 @@ func ForOperationResult(opr xdr.OperationResult) (string, error) { ic = ir.MustLiquidityPoolWithdrawResult().Code case xdr.OperationTypeInvokeHostFunction: ic = ir.MustInvokeHostFunctionResult().Code - case xdr.OperationTypeBumpFootprintExpiration: - ic = ir.MustBumpFootprintExpirationResult().Code + case xdr.OperationTypeExtendFootprintTtl: + ic = ir.MustExtendFootprintTtlResult().Code case xdr.OperationTypeRestoreFootprint: ic = ir.MustRestoreFootprintResult().Code } diff --git a/services/horizon/internal/codes/main_test.go b/services/horizon/internal/codes/main_test.go index 51593b91c3..88c622440a 100644 --- a/services/horizon/internal/codes/main_test.go +++ b/services/horizon/internal/codes/main_test.go @@ -5,8 +5,9 @@ import ( "reflect" "testing" - "github.com/stellar/go/xdr" "github.com/stretchr/testify/assert" + + "github.com/stellar/go/xdr" ) func TestForOperationResultCoversForAllOpTypes(t *testing.T) { @@ -51,7 +52,7 @@ func TestForOperationResultCoversForAllOpTypes(t *testing.T) { xdr.OperationTypeLiquidityPoolDeposit: reflect.TypeOf(xdr.LiquidityPoolDepositResultCode(0)), xdr.OperationTypeLiquidityPoolWithdraw: reflect.TypeOf(xdr.LiquidityPoolWithdrawResultCode(0)), xdr.OperationTypeInvokeHostFunction: reflect.TypeOf(xdr.InvokeHostFunctionResultCode(0)), - xdr.OperationTypeBumpFootprintExpiration: reflect.TypeOf(xdr.BumpFootprintExpirationResultCode(0)), + xdr.OperationTypeExtendFootprintTtl: reflect.TypeOf(xdr.ExtendFootprintTtlResultCode(0)), xdr.OperationTypeRestoreFootprint: reflect.TypeOf(xdr.RestoreFootprintResultCode(0)), } // If this is not equal it means one or more result struct is missing in resultTypes map. diff --git a/services/horizon/internal/ingest/main_test.go b/services/horizon/internal/ingest/main_test.go index fb5ad15948..24b11aa00b 100644 --- a/services/horizon/internal/ingest/main_test.go +++ b/services/horizon/internal/ingest/main_test.go @@ -130,7 +130,7 @@ func TestStateMachineTransition(t *testing.T) { } historyQ.On("GetTx").Return(nil).Once() - historyQ.On("Begin", mock.AnythingOfType("*context.emptyCtx")).Return(errors.New("my error")).Once() + historyQ.On("Begin", mock.Anything).Return(errors.New("my error")).Once() historyQ.On("GetTx").Return(&sqlx.Tx{}).Once() assert.PanicsWithValue(t, "unexpected transaction", func() { diff --git a/services/horizon/internal/ingest/processors/contract_data.go b/services/horizon/internal/ingest/processors/contract_data.go index 08ac0484d0..dec9199747 100644 --- a/services/horizon/internal/ingest/processors/contract_data.go +++ b/services/horizon/internal/ingest/processors/contract_data.go @@ -437,7 +437,7 @@ func AssetToContractData(isNative bool, code, issuer string, contractID [32]byte Type: xdr.ScValTypeScvContractInstance, Instance: &xdr.ScContractInstance{ Executable: xdr.ContractExecutable{ - Type: xdr.ContractExecutableTypeContractExecutableToken, + Type: xdr.ContractExecutableTypeContractExecutableStellarAsset, }, Storage: storageMap, }, diff --git a/services/horizon/internal/ingest/processors/effects_processor.go b/services/horizon/internal/ingest/processors/effects_processor.go index d6c0d781d6..7cefca4919 100644 --- a/services/horizon/internal/ingest/processors/effects_processor.go +++ b/services/horizon/internal/ingest/processors/effects_processor.go @@ -245,7 +245,7 @@ func (operation *transactionOperationWrapper) effects() ([]effect, error) { // For now, the only effects are related to the events themselves. // Possible add'l work: https://github.com/stellar/go/issues/4585 err = wrapper.addInvokeHostFunctionEffects(filterEvents(diagnosticEvents)) - case xdr.OperationTypeBumpFootprintExpiration, xdr.OperationTypeRestoreFootprint: + case xdr.OperationTypeExtendFootprintTtl, xdr.OperationTypeRestoreFootprint: // do not produce effects for these operations as horizon only provides // limited visibility into soroban operations default: diff --git a/services/horizon/internal/ingest/processors/operations_processor.go b/services/horizon/internal/ingest/processors/operations_processor.go index c9c0e4f72f..ffb1710bc9 100644 --- a/services/horizon/internal/ingest/processors/operations_processor.go +++ b/services/horizon/internal/ingest/processors/operations_processor.go @@ -5,6 +5,7 @@ import ( "encoding/base64" "encoding/json" "fmt" + "github.com/guregu/null" "github.com/stellar/go/amount" @@ -685,9 +686,9 @@ func (operation *transactionOperationWrapper) Details() (map[string]interface{}, default: panic(fmt.Errorf("unknown host function type: %s", op.HostFunction.Type)) } - case xdr.OperationTypeBumpFootprintExpiration: - op := operation.operation.Body.MustBumpFootprintExpirationOp() - details["ledgers_to_expire"] = op.LedgersToExpire + case xdr.OperationTypeExtendFootprintTtl: + op := operation.operation.Body.MustExtendFootprintTtlOp() + details["extend_to"] = op.ExtendTo case xdr.OperationTypeRestoreFootprint: default: panic(fmt.Errorf("unknown operation type: %s", operation.OperationType())) @@ -983,7 +984,7 @@ func (operation *transactionOperationWrapper) Participants() ([]xdr.AccountId, e // the only direct participant is the source_account case xdr.OperationTypeInvokeHostFunction: // the only direct participant is the source_account - case xdr.OperationTypeBumpFootprintExpiration: + case xdr.OperationTypeExtendFootprintTtl: // the only direct participant is the source_account case xdr.OperationTypeRestoreFootprint: // the only direct participant is the source_account diff --git a/services/horizon/internal/ingest/processors/operations_processor_test.go b/services/horizon/internal/ingest/processors/operations_processor_test.go index ff7b8c3d94..5784ba3150 100644 --- a/services/horizon/internal/ingest/processors/operations_processor_test.go +++ b/services/horizon/internal/ingest/processors/operations_processor_test.go @@ -215,7 +215,7 @@ func (s *OperationsProcessorTestSuiteLedger) TestOperationTypeInvokeHostFunction }, }, Executable: xdr.ContractExecutable{ - Type: xdr.ContractExecutableTypeContractExecutableToken, + Type: xdr.ContractExecutableTypeContractExecutableStellarAsset, }, }, }, diff --git a/services/horizon/internal/ingest/processors/stats_ledger_transaction_processor.go b/services/horizon/internal/ingest/processors/stats_ledger_transaction_processor.go index 115c15f874..720cc0c2a0 100644 --- a/services/horizon/internal/ingest/processors/stats_ledger_transaction_processor.go +++ b/services/horizon/internal/ingest/processors/stats_ledger_transaction_processor.go @@ -50,7 +50,7 @@ type StatsLedgerTransactionProcessorResults struct { OperationsLiquidityPoolDeposit int64 OperationsLiquidityPoolWithdraw int64 OperationsInvokeHostFunction int64 - OperationsBumpFootprintExpiration int64 + OperationsExtendFootprintTtl int64 OperationsRestoreFootprint int64 } @@ -120,8 +120,8 @@ func (p *StatsLedgerTransactionProcessor) ProcessTransaction(ctx context.Context p.results.OperationsLiquidityPoolWithdraw++ case xdr.OperationTypeInvokeHostFunction: p.results.OperationsInvokeHostFunction++ - case xdr.OperationTypeBumpFootprintExpiration: - p.results.OperationsBumpFootprintExpiration++ + case xdr.OperationTypeExtendFootprintTtl: + p.results.OperationsExtendFootprintTtl++ case xdr.OperationTypeRestoreFootprint: p.results.OperationsRestoreFootprint++ default: diff --git a/services/horizon/internal/ingest/verify.go b/services/horizon/internal/ingest/verify.go index ddacbb43c0..c7d6c8f0d6 100644 --- a/services/horizon/internal/ingest/verify.go +++ b/services/horizon/internal/ingest/verify.go @@ -242,13 +242,13 @@ func (s *system) verifyState(verifyAgainstLatestCheckpoint bool) error { return errors.Wrap(err, "Error running assetStats.AddContractData") } totalByType["contract_data"]++ - case xdr.LedgerEntryTypeExpiration: - // we don't store expiration entries in the db, + case xdr.LedgerEntryTypeTtl: + // we don't store ttl entries in the db, // so there is nothing to verify in that case. if err = verifier.Write(entry); err != nil { return err } - totalByType["expiration"]++ + totalByType["ttl"]++ default: return errors.New("GetLedgerEntries return unexpected type") } @@ -322,7 +322,7 @@ func (s *system) verifyState(verifyAgainstLatestCheckpoint bool) error { err = verifier.Verify( countAccounts + countData + countOffers + countTrustLines + countClaimableBalances + - countLiquidityPools + int(totalByType["contract_data"]) + int(totalByType["expiration"]), + countLiquidityPools + int(totalByType["contract_data"]) + int(totalByType["ttl"]), ) if err != nil { return errors.Wrap(err, "verifier.Verify failed") diff --git a/services/horizon/internal/ingest/verify_test.go b/services/horizon/internal/ingest/verify_test.go index 47d29cb6ee..4acd944f49 100644 --- a/services/horizon/internal/ingest/verify_test.go +++ b/services/horizon/internal/ingest/verify_test.go @@ -174,14 +174,14 @@ func genContractCode(tt *test.T, gen randxdr.Generator) xdr.LedgerEntryChange { return change } -func genExpiration(tt *test.T, gen randxdr.Generator) xdr.LedgerEntryChange { +func genTTL(tt *test.T, gen randxdr.Generator) xdr.LedgerEntryChange { change := xdr.LedgerEntryChange{} shape := &gxdr.LedgerEntryChange{} gen.Next( shape, []randxdr.Preset{ {randxdr.FieldEquals("type"), randxdr.SetU32(gxdr.LEDGER_ENTRY_CREATED.GetU32())}, - {randxdr.FieldEquals("created.data.type"), randxdr.SetU32(gxdr.EXPIRATION.GetU32())}, + {randxdr.FieldEquals("created.data.type"), randxdr.SetU32(gxdr.TTL.GetU32())}, }, ) tt.Assert.NoError(gxdr.Convert(shape, &change)) @@ -340,7 +340,7 @@ func TestStateVerifier(t *testing.T) { genAccountData(tt, gen), genContractCode(tt, gen), genConfigSetting(tt, gen), - genExpiration(tt, gen), + genTTL(tt, gen), ) changes = append(changes, genAssetContractMetadata(tt, gen)...) } diff --git a/services/horizon/internal/integration/contracts/Cargo.lock b/services/horizon/internal/integration/contracts/Cargo.lock index 07b698504d..417d3ff74f 100644 --- a/services/horizon/internal/integration/contracts/Cargo.lock +++ b/services/horizon/internal/integration/contracts/Cargo.lock @@ -34,9 +34,9 @@ dependencies = [ [[package]] name = "arbitrary" -version = "1.3.0" +version = "1.3.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e2d098ff73c1ca148721f37baad5ea6a465a13f9573aba8641fbbbae8164a54e" +checksum = "a2e1373abdaa212b704512ec2bd8b26bd0b7d5c3f70117411a5d9a451383c859" dependencies = [ "derive_arbitrary", ] @@ -82,9 +82,9 @@ checksum = "9e1b586273c5702936fe7b7d6896644d8be71e6314cfe09d3167c95f712589e8" [[package]] name = "base64" -version = "0.21.3" +version = "0.21.4" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "414dcefbc63d77c526a76b3afcf6fbb9b5e2791c19c3aa2297733208750c6e53" +checksum = "9ba43ea6f343b788c8764558649e08df62f86c6ef251fdaeb1ffd010a9ae50a2" [[package]] name = "base64ct" @@ -103,9 +103,9 @@ dependencies = [ [[package]] name = "bumpalo" -version = "3.13.0" +version = "3.14.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a3e2c3daef883ecc1b5d58c15adae93470a91d425f3532ba1695849656af3fc1" +checksum = "7f30e7476521f6f8af1a1c4c0b8cc94f0bee37d91763d0ca2665f299b6cd8aec" [[package]] name = "bytes-lit" @@ -136,9 +136,9 @@ checksum = "baf1de4339761588bc0619e3cbc0120ee582ebb74b53b4efbf79117bd2da40fd" [[package]] name = "chrono" -version = "0.4.28" +version = "0.4.31" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "95ed24df0632f708f5f6d8082675bef2596f7084dee3dd55f632290bf35bfe0f" +checksum = "7f2c685bad3eb3d45a01354cedb7d5faa66194d1d58ba6e267a8de788f79db38" dependencies = [ "android-tzdata", "iana-time-zone", @@ -181,9 +181,9 @@ dependencies = [ [[package]] name = "crypto-bigint" -version = "0.5.2" +version = "0.5.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "cf4c2f4e1afd912bc40bfd6fed5d9dc1f288e0ba01bfcc835cc5bc3eb13efe15" +checksum = "740fe28e594155f10cfc383984cbefd529d7396050557148f79cb0f621204124" dependencies = [ "generic-array", "rand_core", @@ -203,9 +203,9 @@ dependencies = [ [[package]] name = "ctor" -version = "0.2.4" +version = "0.2.5" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1f34ba9a9bcb8645379e9de8cb3ecfcf4d1c85ba66d90deb3259206fa5aa193b" +checksum = "37e366bff8cd32dd8754b0991fb66b279dc48f598c3a18914852a6673deef583" dependencies = [ "quote", "syn", @@ -213,9 +213,9 @@ dependencies = [ [[package]] name = "curve25519-dalek" -version = "4.0.0" +version = "4.1.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f711ade317dd348950a9910f81c5947e3d8907ebd2b83f76203ff1807e6a2bc2" +checksum = "e89b8c6a2e4b1f45971ad09761aafb85514a84744b67a95e32c3cc1352d1f65c" dependencies = [ "cfg-if", "cpufeatures", @@ -286,10 +286,11 @@ dependencies = [ [[package]] name = "deranged" -version = "0.3.8" +version = "0.3.9" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f2696e8a945f658fd14dc3b87242e6b80cd0f36ff04ea560fa39082368847946" +checksum = "0f32d04922c60427da6f9fef14d042d9edddef64cb9d4ce0d64d0685fbeb1fd3" dependencies = [ + "powerfmt", "serde", ] @@ -338,9 +339,9 @@ dependencies = [ [[package]] name = "ed25519" -version = "2.2.2" +version = "2.2.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "60f6d271ca33075c88028be6f04d502853d63a5ece419d269c15315d4fc1cf1d" +checksum = "115531babc129696a58c64a4fef0a8bf9e9698629fb97e9e40767d235cfbcd53" dependencies = [ "pkcs8", "signature", @@ -368,9 +369,9 @@ checksum = "a26ae43d7bcc3b814de94796a5e736d4029efb0ee900c12e2d54c993ad1a1e07" [[package]] name = "elliptic-curve" -version = "0.13.5" +version = "0.13.6" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "968405c8fdc9b3bf4df0a6638858cc0b52462836ab6b1c87377785dd09cf1c0b" +checksum = "d97ca172ae9dc9f9b779a6e3a65d308f2af74e5b8c921299075bdb4a0370e914" dependencies = [ "base16ct", "crypto-bigint", @@ -409,9 +410,9 @@ dependencies = [ [[package]] name = "fiat-crypto" -version = "0.1.20" +version = "0.2.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e825f6987101665dea6ec934c09ec6d721de7bc1bf92248e1d5810c8cd636b77" +checksum = "d0870c84016d4b481be5c9f323c24f65e31e901ae618f0e80f4308fb00de1d2d" [[package]] name = "fnv" @@ -468,9 +469,9 @@ checksum = "8a9ee70c43aaf417c914396645a0fa852624801b24ebb7ae78fe8272889ac888" [[package]] name = "hashbrown" -version = "0.14.0" +version = "0.14.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "2c6201b9ff9fd90a5a3bac2e56a830d0caa509576f0e503818ee82c181b3437a" +checksum = "7dfda62a12f55daeae5015f81b0baea145391cb4520f86c248fc615d72640d12" [[package]] name = "hex" @@ -532,12 +533,12 @@ dependencies = [ [[package]] name = "indexmap" -version = "2.0.0" +version = "2.0.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d5477fe2230a79769d8dc68e0eabf5437907c0457a5614a9e8dddb67f65eb65d" +checksum = "8adf3ddd720272c6ea8bf59463c04e0f93d0bbf7c5439b691bca2987e0270897" dependencies = [ "equivalent", - "hashbrown 0.14.0", + "hashbrown 0.14.1", "serde", ] @@ -596,15 +597,15 @@ dependencies = [ [[package]] name = "libc" -version = "0.2.147" +version = "0.2.149" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b4668fb0ea861c1df094127ac5f1da3409a82116a4ba74fca2e58ef927159bb3" +checksum = "a08173bc88b7955d1b3145aa561539096c421ac8debde8cbc3612ec635fee29b" [[package]] name = "libm" -version = "0.2.7" +version = "0.2.8" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f7012b1bbb0719e1097c47611d3898568c546d597c2e74d66f6087edd5233ff4" +checksum = "4ec2a862134d2a7d32d7983ddcdd1c4923530833c9f2ea1a44fc5fa473989058" [[package]] name = "log" @@ -614,9 +615,9 @@ checksum = "b5e6163cb8c49088c2c36f57875e58ccd8c87c7427f7fbd50ea6710b2f3f2e8f" [[package]] name = "memchr" -version = "2.6.2" +version = "2.6.4" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5486aed0026218e61b8a01d5fbd5a0a134649abb71a0e53b7bc088529dced86e" +checksum = "f665ee40bc4a3c5590afb1e9677db74a508659dfd71e126420da8274909a0167" [[package]] name = "miniz_oxide" @@ -640,9 +641,9 @@ dependencies = [ [[package]] name = "num-derive" -version = "0.4.0" +version = "0.4.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9e6a0fd4f737c707bd9086cc16c925f294943eb62eb71499e9fd4cf71f8b9f4e" +checksum = "cfb77679af88f8b125209d354a202862602672222e7f2313fdd6dc349bad4712" dependencies = [ "proc-macro2", "quote", @@ -661,18 +662,18 @@ dependencies = [ [[package]] name = "num-traits" -version = "0.2.16" +version = "0.2.17" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f30b0abd723be7e2ffca1272140fac1a2f084c77ec3e123c192b66af1ee9e6c2" +checksum = "39e3200413f237f41ab11ad6d161bc7239c84dcb631773ccd7de3dfe4b5c267c" dependencies = [ "autocfg", ] [[package]] name = "object" -version = "0.32.0" +version = "0.32.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "77ac5bbd07aea88c60a577a1ce218075ffd59208b2d7ca97adf9bfc5aeb21ebe" +checksum = "9cf5f9dd3933bd50a9e1f149ec995f39ae2c496d31fd772c1fd45ebc27e902b0" dependencies = [ "memchr", ] @@ -705,6 +706,12 @@ version = "3.1.2" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "4503fa043bf02cee09a9582e9554b4c6403b2ef55e4612e96561d294419429f8" +[[package]] +name = "powerfmt" +version = "0.2.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "439ee305def115ba05938db6eb1644ff94165c5ab5e9420d1c1bcedbba909391" + [[package]] name = "ppv-lite86" version = "0.2.17" @@ -713,9 +720,9 @@ checksum = "5b40af805b3121feab8a3c29f04d8ad262fa8e0561883e7653e024ae4479e6de" [[package]] name = "prettyplease" -version = "0.2.12" +version = "0.2.15" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "6c64d9ba0963cdcea2e1b2230fbae2bab30eb25a174be395c41e764bfb65dd62" +checksum = "ae005bd773ab59b4725093fd7df83fd7892f7d8eafb48dbd7de6e024e4215f9d" dependencies = [ "proc-macro2", "syn", @@ -723,9 +730,9 @@ dependencies = [ [[package]] name = "proc-macro2" -version = "1.0.66" +version = "1.0.69" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "18fb31db3f9bddb2ea821cde30a9f70117e3f119938b5ee630b7403aa6e2ead9" +checksum = "134c189feb4956b20f6f547d2cf727d4c0fe06722b20a0eec87ed445a97f92da" dependencies = [ "unicode-ident", ] @@ -816,24 +823,24 @@ dependencies = [ [[package]] name = "semver" -version = "1.0.18" +version = "1.0.20" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b0293b4b29daaf487284529cc2f5675b8e57c61f70167ba415a463651fd6a918" +checksum = "836fa6a3e1e547f9a2c4040802ec865b5d85f4014efe00555d7090a3dcaa1090" [[package]] name = "serde" -version = "1.0.188" +version = "1.0.189" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "cf9e0fcba69a370eed61bcf2b728575f726b50b55cba78064753d708ddc7549e" +checksum = "8e422a44e74ad4001bdc8eede9a4570ab52f71190e9c076d14369f38b9200537" dependencies = [ "serde_derive", ] [[package]] name = "serde_derive" -version = "1.0.188" +version = "1.0.189" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4eca7ac642d82aa35b60049a6eccb4be6be75e599bd2e9adb5f875a737654af2" +checksum = "1e48d1f918009ce3145511378cf68d613e3b3d9137d67272562080d68a2b32d5" dependencies = [ "proc-macro2", "quote", @@ -842,9 +849,9 @@ dependencies = [ [[package]] name = "serde_json" -version = "1.0.105" +version = "1.0.107" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "693151e1ac27563d6dbcec9dee9fbd5da8539b20fa14ad3752b2e6d363ace360" +checksum = "6b420ce6e3d8bd882e9b243c6eed35dbc9a6110c9769e74b584e0d68d1f20c65" dependencies = [ "itoa", "ryu", @@ -857,11 +864,11 @@ version = "3.3.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "1ca3b16a3d82c4088f343b7480a93550b3eabe1a358569c2dfe38bbcead07237" dependencies = [ - "base64 0.21.3", + "base64 0.21.4", "chrono", "hex", "indexmap 1.9.3", - "indexmap 2.0.0", + "indexmap 2.0.2", "serde", "serde_json", "serde_with_macros", @@ -882,9 +889,9 @@ dependencies = [ [[package]] name = "sha2" -version = "0.10.7" +version = "0.10.8" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "479fb9d862239e610720565ca91403019f2f00410f1864c5aa7479b950a76ed8" +checksum = "793db75ad2bcafc3ffa7c68b215fee268f537982cd901d132f89c6343f3a3dc8" dependencies = [ "cfg-if", "cpufeatures", @@ -913,14 +920,14 @@ dependencies = [ [[package]] name = "smallvec" -version = "1.11.0" +version = "1.11.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "62bb4feee49fdd9f707ef802e22365a35de4b7b299de4763d44bfea899442ff9" +checksum = "942b4a808e05215192e39f4ab80813e599068285906cc91aa64f923db842bd5a" [[package]] name = "soroban-env-common" -version = "0.0.17" -source = "git+https://github.com/stellar/rs-soroban-env?rev=eb5a9ba053a7b64a8eff605db625525378f7bea0#eb5a9ba053a7b64a8eff605db625525378f7bea0" +version = "20.0.0-rc2" +source = "git+https://github.com/stellar/rs-soroban-env?rev=91f44778389490ad863d61a8a90ac9875ba6d8fd#91f44778389490ad863d61a8a90ac9875ba6d8fd" dependencies = [ "arbitrary", "crate-git-revision", @@ -936,8 +943,8 @@ dependencies = [ [[package]] name = "soroban-env-guest" -version = "0.0.17" -source = "git+https://github.com/stellar/rs-soroban-env?rev=eb5a9ba053a7b64a8eff605db625525378f7bea0#eb5a9ba053a7b64a8eff605db625525378f7bea0" +version = "20.0.0-rc2" +source = "git+https://github.com/stellar/rs-soroban-env?rev=91f44778389490ad863d61a8a90ac9875ba6d8fd#91f44778389490ad863d61a8a90ac9875ba6d8fd" dependencies = [ "soroban-env-common", "static_assertions", @@ -945,16 +952,13 @@ dependencies = [ [[package]] name = "soroban-env-host" -version = "0.0.17" -source = "git+https://github.com/stellar/rs-soroban-env?rev=eb5a9ba053a7b64a8eff605db625525378f7bea0#eb5a9ba053a7b64a8eff605db625525378f7bea0" +version = "20.0.0-rc2" +source = "git+https://github.com/stellar/rs-soroban-env?rev=91f44778389490ad863d61a8a90ac9875ba6d8fd#91f44778389490ad863d61a8a90ac9875ba6d8fd" dependencies = [ "backtrace", - "curve25519-dalek", "ed25519-dalek", "getrandom", - "hex", "k256", - "log", "num-derive", "num-integer", "num-traits", @@ -971,8 +975,8 @@ dependencies = [ [[package]] name = "soroban-env-macros" -version = "0.0.17" -source = "git+https://github.com/stellar/rs-soroban-env?rev=eb5a9ba053a7b64a8eff605db625525378f7bea0#eb5a9ba053a7b64a8eff605db625525378f7bea0" +version = "20.0.0-rc2" +source = "git+https://github.com/stellar/rs-soroban-env?rev=91f44778389490ad863d61a8a90ac9875ba6d8fd#91f44778389490ad863d61a8a90ac9875ba6d8fd" dependencies = [ "itertools", "proc-macro2", @@ -992,8 +996,8 @@ dependencies = [ [[package]] name = "soroban-ledger-snapshot" -version = "0.9.2" -source = "git+https://github.com/stellar/rs-soroban-sdk?rev=18b8fa1a358aa84afd196e2f6d44942798c8f335#18b8fa1a358aa84afd196e2f6d44942798c8f335" +version = "20.0.0-rc2" +source = "git+https://github.com/stellar/rs-soroban-sdk?rev=729ed3ac5fe8600a3245d5816eadd3c95ab2eb54#729ed3ac5fe8600a3245d5816eadd3c95ab2eb54" dependencies = [ "serde", "serde_json", @@ -1004,8 +1008,8 @@ dependencies = [ [[package]] name = "soroban-native-sdk-macros" -version = "0.0.17" -source = "git+https://github.com/stellar/rs-soroban-env?rev=eb5a9ba053a7b64a8eff605db625525378f7bea0#eb5a9ba053a7b64a8eff605db625525378f7bea0" +version = "20.0.0-rc2" +source = "git+https://github.com/stellar/rs-soroban-env?rev=91f44778389490ad863d61a8a90ac9875ba6d8fd#91f44778389490ad863d61a8a90ac9875ba6d8fd" dependencies = [ "itertools", "proc-macro2", @@ -1022,8 +1026,8 @@ dependencies = [ [[package]] name = "soroban-sdk" -version = "0.9.2" -source = "git+https://github.com/stellar/rs-soroban-sdk?rev=18b8fa1a358aa84afd196e2f6d44942798c8f335#18b8fa1a358aa84afd196e2f6d44942798c8f335" +version = "20.0.0-rc2" +source = "git+https://github.com/stellar/rs-soroban-sdk?rev=729ed3ac5fe8600a3245d5816eadd3c95ab2eb54#729ed3ac5fe8600a3245d5816eadd3c95ab2eb54" dependencies = [ "arbitrary", "bytes-lit", @@ -1039,8 +1043,8 @@ dependencies = [ [[package]] name = "soroban-sdk-macros" -version = "0.9.2" -source = "git+https://github.com/stellar/rs-soroban-sdk?rev=18b8fa1a358aa84afd196e2f6d44942798c8f335#18b8fa1a358aa84afd196e2f6d44942798c8f335" +version = "20.0.0-rc2" +source = "git+https://github.com/stellar/rs-soroban-sdk?rev=729ed3ac5fe8600a3245d5816eadd3c95ab2eb54#729ed3ac5fe8600a3245d5816eadd3c95ab2eb54" dependencies = [ "crate-git-revision", "darling", @@ -1058,8 +1062,8 @@ dependencies = [ [[package]] name = "soroban-spec" -version = "0.9.2" -source = "git+https://github.com/stellar/rs-soroban-sdk?rev=18b8fa1a358aa84afd196e2f6d44942798c8f335#18b8fa1a358aa84afd196e2f6d44942798c8f335" +version = "20.0.0-rc2" +source = "git+https://github.com/stellar/rs-soroban-sdk?rev=729ed3ac5fe8600a3245d5816eadd3c95ab2eb54#729ed3ac5fe8600a3245d5816eadd3c95ab2eb54" dependencies = [ "base64 0.13.1", "stellar-xdr", @@ -1069,8 +1073,8 @@ dependencies = [ [[package]] name = "soroban-spec-rust" -version = "0.9.2" -source = "git+https://github.com/stellar/rs-soroban-sdk?rev=18b8fa1a358aa84afd196e2f6d44942798c8f335#18b8fa1a358aa84afd196e2f6d44942798c8f335" +version = "20.0.0-rc2" +source = "git+https://github.com/stellar/rs-soroban-sdk?rev=729ed3ac5fe8600a3245d5816eadd3c95ab2eb54#729ed3ac5fe8600a3245d5816eadd3c95ab2eb54" dependencies = [ "prettyplease", "proc-macro2", @@ -1084,8 +1088,8 @@ dependencies = [ [[package]] name = "soroban-wasmi" -version = "0.30.0-soroban" -source = "git+https://github.com/stellar/wasmi?rev=284c963ba080703061797e2a3cba0853edee0dd4#284c963ba080703061797e2a3cba0853edee0dd4" +version = "0.31.0-soroban1" +source = "git+https://github.com/stellar/wasmi?rev=7e63b4c9e08c4163f417d118d81f7ea34789d0be#7e63b4c9e08c4163f417d118d81f7ea34789d0be" dependencies = [ "smallvec", "spin", @@ -1134,8 +1138,8 @@ dependencies = [ [[package]] name = "stellar-xdr" -version = "0.0.17" -source = "git+https://github.com/stellar/rs-stellar-xdr?rev=39904e09941046dab61e6e35fc89e31bf2dea1cd#39904e09941046dab61e6e35fc89e31bf2dea1cd" +version = "20.0.0-rc1" +source = "git+https://github.com/stellar/rs-stellar-xdr?rev=9c97e4fa909a0b6455547a4f4a95800696b2a69a#9c97e4fa909a0b6455547a4f4a95800696b2a69a" dependencies = [ "arbitrary", "base64 0.13.1", @@ -1159,9 +1163,9 @@ checksum = "81cdd64d312baedb58e21336b31bc043b77e01cc99033ce76ef539f78e965ebc" [[package]] name = "syn" -version = "2.0.29" +version = "2.0.38" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c324c494eba9d92503e6f1ef2e6df781e78f6a7705a0202d9801b198807d518a" +checksum = "e96b79aaa137db8f61e26363a0c9b47d8b4ec75da28b7d1d614c2303e232408b" dependencies = [ "proc-macro2", "quote", @@ -1170,18 +1174,18 @@ dependencies = [ [[package]] name = "thiserror" -version = "1.0.47" +version = "1.0.49" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "97a802ec30afc17eee47b2855fc72e0c4cd62be9b4efe6591edde0ec5bd68d8f" +checksum = "1177e8c6d7ede7afde3585fd2513e611227efd6481bd78d2e82ba1ce16557ed4" dependencies = [ "thiserror-impl", ] [[package]] name = "thiserror-impl" -version = "1.0.47" +version = "1.0.49" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "6bb623b56e39ab7dcd4b1b98bb6c8f8d907ed255b18de254088016b27a8ee19b" +checksum = "10712f02019e9288794769fba95cd6847df9874d49d871d062172f9dd41bc4cc" dependencies = [ "proc-macro2", "quote", @@ -1190,12 +1194,13 @@ dependencies = [ [[package]] name = "time" -version = "0.3.28" +version = "0.3.30" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "17f6bb557fd245c28e6411aa56b6403c689ad95061f50e4be16c274e70a17e48" +checksum = "c4a34ab300f2dee6e562c10a046fc05e358b29f9bf92277f30c3c8d82275f6f5" dependencies = [ "deranged", "itoa", + "powerfmt", "serde", "time-core", "time-macros", @@ -1203,30 +1208,30 @@ dependencies = [ [[package]] name = "time-core" -version = "0.1.1" +version = "0.1.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7300fbefb4dadc1af235a9cef3737cea692a9d97e1b9cbcd4ebdae6f8868e6fb" +checksum = "ef927ca75afb808a4d64dd374f00a2adf8d0fcff8e7b184af886c3c87ec4a3f3" [[package]] name = "time-macros" -version = "0.2.14" +version = "0.2.15" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1a942f44339478ef67935ab2bbaec2fb0322496cf3cbe84b261e06ac3814c572" +checksum = "4ad70d68dba9e1f8aceda7aa6711965dfec1cac869f311a51bd08b3a2ccbce20" dependencies = [ "time-core", ] [[package]] name = "typenum" -version = "1.16.0" +version = "1.17.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "497961ef93d974e23eb6f433eb5fe1b7930b659f06d12dec6fc44a8f554c0bba" +checksum = "42ff0bf0c66b8238c6f3b578df37d0b7848e55df8577b3f74f92a69acceeb825" [[package]] name = "unicode-ident" -version = "1.0.11" +version = "1.0.12" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "301abaae475aa91687eb82514b328ab47a211a533026cb25fc3e519b86adfc3c" +checksum = "3354b9ac3fae1ff6755cb6db53683adb661634f67557942dea4facebec0fee4b" [[package]] name = "version_check" @@ -1297,12 +1302,12 @@ checksum = "ca6ad05a4870b2bf5fe995117d3728437bd27d7cd5f06f13c17443ef369775a1" [[package]] name = "wasmi_arena" version = "0.4.0" -source = "git+https://github.com/stellar/wasmi?rev=284c963ba080703061797e2a3cba0853edee0dd4#284c963ba080703061797e2a3cba0853edee0dd4" +source = "git+https://github.com/stellar/wasmi?rev=7e63b4c9e08c4163f417d118d81f7ea34789d0be#7e63b4c9e08c4163f417d118d81f7ea34789d0be" [[package]] name = "wasmi_core" -version = "0.12.0" -source = "git+https://github.com/stellar/wasmi?rev=284c963ba080703061797e2a3cba0853edee0dd4#284c963ba080703061797e2a3cba0853edee0dd4" +version = "0.13.0" +source = "git+https://github.com/stellar/wasmi?rev=7e63b4c9e08c4163f417d118d81f7ea34789d0be#7e63b4c9e08c4163f417d118d81f7ea34789d0be" dependencies = [ "downcast-rs", "libm", diff --git a/services/horizon/internal/integration/contracts/Cargo.toml b/services/horizon/internal/integration/contracts/Cargo.toml index 7e413dfed7..f7e3b81aed 100644 --- a/services/horizon/internal/integration/contracts/Cargo.toml +++ b/services/horizon/internal/integration/contracts/Cargo.toml @@ -22,6 +22,6 @@ codegen-units = 1 lto = true [workspace.dependencies.soroban-sdk] -version = "20.0.0-rc1" +version = "20.0.0-rc2" git = "https://github.com/stellar/rs-soroban-sdk" -rev = "f743d6f9e49caa08924318907cd0588b60d7f187" +rev = "729ed3ac5fe8600a3245d5816eadd3c95ab2eb54" diff --git a/services/horizon/internal/integration/db_test.go b/services/horizon/internal/integration/db_test.go index 020d934930..e1e7c70c70 100644 --- a/services/horizon/internal/integration/db_test.go +++ b/services/horizon/internal/integration/db_test.go @@ -167,18 +167,18 @@ func submitSorobanOps(itest *integration.Test, tt *assert.Assertions) (submitted installContractOp := assembleInstallContractCodeOp(itest.CurrentTest(), itest.Master().Address(), add_u64_contract) itest.MustSubmitOperations(itest.MasterAccount(), itest.Master(), installContractOp) - bumpFootprintExpirationOp := &txnbuild.BumpFootprintExpiration{ - LedgersToExpire: 100, - SourceAccount: itest.Master().Address(), + extendFootprintTtlOp := &txnbuild.ExtendFootprintTtl{ + ExtendTo: 100, + SourceAccount: itest.Master().Address(), } - itest.MustSubmitOperations(itest.MasterAccount(), itest.Master(), bumpFootprintExpirationOp) + itest.MustSubmitOperations(itest.MasterAccount(), itest.Master(), extendFootprintTtlOp) restoreFootprintOp := &txnbuild.RestoreFootprint{ SourceAccount: itest.Master().Address(), } txResp := itest.MustSubmitOperations(itest.MasterAccount(), itest.Master(), restoreFootprintOp) - return []txnbuild.Operation{installContractOp, bumpFootprintExpirationOp, restoreFootprintOp}, txResp.Ledger + return []txnbuild.Operation{installContractOp, extendFootprintTtlOp, restoreFootprintOp}, txResp.Ledger } func submitSponsorshipOps(itest *integration.Test, tt *assert.Assertions) (submittedOperations []txnbuild.Operation, lastLedger int32) { @@ -441,7 +441,7 @@ func initializeDBIntegrationTest(t *testing.T) (*integration.Test, int32) { submitters = append(submitters, submitSorobanOps) } else { delete(allOpTypes, xdr.OperationTypeInvokeHostFunction) - delete(allOpTypes, xdr.OperationTypeBumpFootprintExpiration) + delete(allOpTypes, xdr.OperationTypeExtendFootprintTtl) delete(allOpTypes, xdr.OperationTypeRestoreFootprint) } diff --git a/services/horizon/internal/integration/bump_footprint_expiration_test.go b/services/horizon/internal/integration/extend_footprint_ttl_test.go similarity index 82% rename from services/horizon/internal/integration/bump_footprint_expiration_test.go rename to services/horizon/internal/integration/extend_footprint_ttl_test.go index 314dc26d40..a9de3b5f69 100644 --- a/services/horizon/internal/integration/bump_footprint_expiration_test.go +++ b/services/horizon/internal/integration/extend_footprint_ttl_test.go @@ -12,7 +12,7 @@ import ( "github.com/stretchr/testify/require" ) -func TestBumpFootPrintExpiration(t *testing.T) { +func TestExtendFootprintTtl(t *testing.T) { if integration.GetCoreMaxSupportedProtocol() < 20 { t.Skip("This test run does not support less than Protocol 20") } @@ -30,7 +30,7 @@ func TestBumpFootPrintExpiration(t *testing.T) { installContractOp := assembleInstallContractCodeOp(t, itest.Master().Address(), add_u64_contract) preFlightOp, minFee := itest.PreflightHostFunctions(&sourceAccount, *installContractOp) - tx := itest.MustSubmitOperationsWithFee(&sourceAccount, itest.Master(), minFee, &preFlightOp) + tx := itest.MustSubmitOperationsWithFee(&sourceAccount, itest.Master(), minFee+txnbuild.MinBaseFee, &preFlightOp) _, err = itest.Client().TransactionDetail(tx.Hash) require.NoError(t, err) @@ -40,29 +40,30 @@ func TestBumpFootPrintExpiration(t *testing.T) { }) require.NoError(t, err) - bumpFootPrint := txnbuild.BumpFootprintExpiration{ - LedgersToExpire: 10000, - SourceAccount: "", + bumpFootPrint := txnbuild.ExtendFootprintTtl{ + ExtendTo: 10000, + SourceAccount: "", Ext: xdr.TransactionExt{ V: 1, SorobanData: &xdr.SorobanTransactionData{ + Ext: xdr.ExtensionPoint{}, Resources: xdr.SorobanResources{ Footprint: xdr.LedgerFootprint{ ReadOnly: preFlightOp.Ext.SorobanData.Resources.Footprint.ReadWrite, ReadWrite: nil, }, }, - RefundableFee: 0, + ResourceFee: 0, }, }, } bumpFootPrint, minFee = itest.PreflightBumpFootprintExpiration(&sourceAccount, bumpFootPrint) - tx = itest.MustSubmitOperationsWithFee(&sourceAccount, itest.Master(), minFee, &bumpFootPrint) + tx = itest.MustSubmitOperationsWithFee(&sourceAccount, itest.Master(), minFee+txnbuild.MinBaseFee, &bumpFootPrint) ops, err := itest.Client().Operations(horizonclient.OperationRequest{ForTransaction: tx.Hash}) require.NoError(t, err) require.Len(t, ops.Embedded.Records, 1) - op := ops.Embedded.Records[0].(operations.BumpFootprintExpiration) - require.Equal(t, uint32(10000), op.LedgersToExpire) + op := ops.Embedded.Records[0].(operations.ExtendFootprintTtl) + require.Equal(t, uint32(10000), op.ExtendTo) } diff --git a/services/horizon/internal/integration/invokehostfunction_test.go b/services/horizon/internal/integration/invokehostfunction_test.go index 54fd2fba1f..275f0de23b 100644 --- a/services/horizon/internal/integration/invokehostfunction_test.go +++ b/services/horizon/internal/integration/invokehostfunction_test.go @@ -42,7 +42,7 @@ func TestContractInvokeHostFunctionInstallContract(t *testing.T) { installContractOp := assembleInstallContractCodeOp(t, itest.Master().Address(), add_u64_contract) preFlightOp, minFee := itest.PreflightHostFunctions(&sourceAccount, *installContractOp) - tx := itest.MustSubmitOperationsWithFee(&sourceAccount, itest.Master(), minFee, &preFlightOp) + tx := itest.MustSubmitOperationsWithFee(&sourceAccount, itest.Master(), minFee+txnbuild.MinBaseFee, &preFlightOp) clientTx, err := itest.Client().TransactionDetail(tx.Hash) require.NoError(t, err) @@ -93,12 +93,12 @@ func TestContractInvokeHostFunctionCreateContractByAddress(t *testing.T) { // Install the contract installContractOp := assembleInstallContractCodeOp(t, itest.Master().Address(), add_u64_contract) preFlightOp, minFee := itest.PreflightHostFunctions(&sourceAccount, *installContractOp) - itest.MustSubmitOperationsWithFee(&sourceAccount, itest.Master(), minFee, &preFlightOp) + itest.MustSubmitOperationsWithFee(&sourceAccount, itest.Master(), minFee+txnbuild.MinBaseFee, &preFlightOp) // Create the contract createContractOp := assembleCreateContractOp(t, itest.Master().Address(), add_u64_contract, "a1", itest.GetPassPhrase()) preFlightOp, minFee = itest.PreflightHostFunctions(&sourceAccount, *createContractOp) - tx, err := itest.SubmitOperationsWithFee(&sourceAccount, itest.Master(), minFee, &preFlightOp) + tx, err := itest.SubmitOperationsWithFee(&sourceAccount, itest.Master(), minFee+txnbuild.MinBaseFee, &preFlightOp) require.NoError(t, err) clientTx, err := itest.Client().TransactionDetail(tx.Hash) @@ -147,12 +147,12 @@ func TestContractInvokeHostFunctionInvokeStatelessContractFn(t *testing.T) { // Install the contract installContractOp := assembleInstallContractCodeOp(t, itest.Master().Address(), add_u64_contract) preFlightOp, minFee := itest.PreflightHostFunctions(&sourceAccount, *installContractOp) - itest.MustSubmitOperationsWithFee(&sourceAccount, itest.Master(), minFee, &preFlightOp) + itest.MustSubmitOperationsWithFee(&sourceAccount, itest.Master(), minFee+txnbuild.MinBaseFee, &preFlightOp) // Create the contract createContractOp := assembleCreateContractOp(t, itest.Master().Address(), add_u64_contract, "a1", itest.GetPassPhrase()) preFlightOp, minFee = itest.PreflightHostFunctions(&sourceAccount, *createContractOp) - tx, err := itest.SubmitOperationsWithFee(&sourceAccount, itest.Master(), minFee, &preFlightOp) + tx, err := itest.SubmitOperationsWithFee(&sourceAccount, itest.Master(), minFee+txnbuild.MinBaseFee, &preFlightOp) require.NoError(t, err) // contract has been deployed, now invoke a simple 'add' fn on the contract @@ -191,7 +191,7 @@ func TestContractInvokeHostFunctionInvokeStatelessContractFn(t *testing.T) { } preFlightOp, minFee = itest.PreflightHostFunctions(&sourceAccount, *invokeHostFunctionOp) - tx, err = itest.SubmitOperationsWithFee(&sourceAccount, itest.Master(), minFee, &preFlightOp) + tx, err = itest.SubmitOperationsWithFee(&sourceAccount, itest.Master(), minFee+txnbuild.MinBaseFee, &preFlightOp) require.NoError(t, err) clientTx, err := itest.Client().TransactionDetail(tx.Hash) @@ -257,13 +257,13 @@ func TestContractInvokeHostFunctionInvokeStatefulContractFn(t *testing.T) { installContractOp := assembleInstallContractCodeOp(t, itest.Master().Address(), increment_contract) preFlightOp, minFee := itest.PreflightHostFunctions(&sourceAccount, *installContractOp) - itest.MustSubmitOperationsWithFee(&sourceAccount, itest.Master(), minFee, &preFlightOp) + itest.MustSubmitOperationsWithFee(&sourceAccount, itest.Master(), minFee+txnbuild.MinBaseFee, &preFlightOp) // Create the contract createContractOp := assembleCreateContractOp(t, itest.Master().Address(), increment_contract, "a1", itest.GetPassPhrase()) preFlightOp, minFee = itest.PreflightHostFunctions(&sourceAccount, *createContractOp) - tx, err := itest.SubmitOperationsWithFee(&sourceAccount, itest.Master(), minFee, &preFlightOp) + tx, err := itest.SubmitOperationsWithFee(&sourceAccount, itest.Master(), minFee+txnbuild.MinBaseFee, &preFlightOp) require.NoError(t, err) // contract has been deployed, now invoke a simple 'add' fn on the contract @@ -287,7 +287,7 @@ func TestContractInvokeHostFunctionInvokeStatefulContractFn(t *testing.T) { } preFlightOp, minFee = itest.PreflightHostFunctions(&sourceAccount, *invokeHostFunctionOp) - tx, err = itest.SubmitOperationsWithFee(&sourceAccount, itest.Master(), minFee, &preFlightOp) + tx, err = itest.SubmitOperationsWithFee(&sourceAccount, itest.Master(), minFee+txnbuild.MinBaseFee, &preFlightOp) require.NoError(t, err) clientTx, err := itest.Client().TransactionDetail(tx.Hash) diff --git a/services/horizon/internal/integration/sac_test.go b/services/horizon/internal/integration/sac_test.go index 18a167969a..06bca5a86d 100644 --- a/services/horizon/internal/integration/sac_test.go +++ b/services/horizon/internal/integration/sac_test.go @@ -894,7 +894,7 @@ func createSAC(itest *integration.Test, sourceAccount string, asset xdr.Asset) * FromAsset: &asset, }, Executable: xdr.ContractExecutable{ - Type: xdr.ContractExecutableTypeContractExecutableToken, + Type: xdr.ContractExecutableTypeContractExecutableStellarAsset, WasmHash: nil, }, }, diff --git a/services/horizon/internal/integration/testdata/soroban_add_u64.wasm b/services/horizon/internal/integration/testdata/soroban_add_u64.wasm index 638cf8f7c04711e0d4c97aa8aa0845063ced5e7c..9aac34ea654e19ee731b56ced4e60fd08bd60c89 100755 GIT binary patch delta 121 zcmaFG@||TuJ4+7}YwW~sRZgeo2@MSmjEamCH{6{p$K*4)hf$u{g`s%zIz}~LV?6@~ z7~m)>E>6iVODzHl7#kVr0ikYDvXQd6k!5O%abmJ*TB?PafkC3Nk%?)FsfD3gYGO)? Qak8apVv15Fi4iTo{TcUu9JDHP(ZP zGB9uy6&I&um!%c~<&BLD^ng&eDA`Ea+{iLD#W*q9G%eM_%)lVg*vP~*#ni&kEHyDD R#W>m0G%?92HObV30RT)^AR_<( delta 79 zcmdnXx|4Oo7RJe%OmfVY4EdA2nA8}JCKob^8|oS8S?U=n8(Jh;q$L_A8k<@qCR&&z jrllBKnxz`0nWdPRSeh7_TUsPrq!}BVGB8Zu%vcHlNTC$Y diff --git a/services/horizon/internal/integration/testdata/soroban_sac_test.wasm b/services/horizon/internal/integration/testdata/soroban_sac_test.wasm index 48e2fcb1cc248af0dc15bc86c04ab87b070deed5..eb836a2f576d96c97493a5cabed6e29171002644 100755 GIT binary patch delta 520 zcmZ8d%}T>S5Z>8Mnn={flT{EmR{R4cCQVaMnqc)LRPZis6U7xlTJUHEf9k=5x(b56 zffvE2&^PcIym(d+XR97`7G`I@{pOq5dFwsOp05svgu)(d5&~OLA`E@l@kK;xATD+< z;8{}mfK&Miw|(!xpr!3YD}R7SB3ItiAzCTRC%OZs4B2Sj6cM%0)T@21Jcq~?qaAuo zvlgbNY_a~XL!i)teYzm;*ueU758))T1&4UP9WqQXGBGl{sl`crc#aByX$%f12<&5} z?l6o_IuU#eu%Bw=S}}0|t2s!jtwLL_X@&8uux}KfSe#+Q@5!t-{r|BCZEz%q^VpY) z&FLh|RmwOejV8n-LtzDR`Kq~Dn^R7(A6`0kms7e^#!^EdU?{R0$%sth7~RCOxW+Rm zlM@m9vncv^QOJ;2`qJZeMhE$#53@zmlpp%oia+C$Uo#ucX0pAPHW2VVcLvXNqweKH lZ!S&zYCYIUOGVeM`d%SOg3@d;ttN?Ip9`urFRcXy@&&fhacTen delta 521 zcmY*VJxeP=6uoz5lPs*htQLM0>a2!`Her*j+1WRvf1E$*2)=WyoEJ;=ZRIa?ZwfZ;Cw1Hg5Zz^RASS5S4B z>iO0=K5B*^*w&wT-T#3cTUHZW6MIw;KY_kyBY3Bu*#`PLsY=Y)=+ z^pM*GJmerCc9pR7fVG6j`o9&d+RD8$R&WF-?Pmz*gmr)76&mC0M`LpWk}up(USPQw z1dDA&&s~@d!KS!<*CB`06bBCtB#ICgeiTWV{8bL{3qHFi3tgV2<*< zTn{*outb(bsbb!>EEd0ZEsHGrHZ!l^v!gtMP2HFKyHGCr@LTrw&Q7hdyS7b4(Jw~D s@_sZ0Yryk)ZZ4RoY*x&QzG diff --git a/services/horizon/internal/integration/txsub_test.go b/services/horizon/internal/integration/txsub_test.go index 90266768ee..2f6b98e905 100644 --- a/services/horizon/internal/integration/txsub_test.go +++ b/services/horizon/internal/integration/txsub_test.go @@ -75,7 +75,7 @@ func TestTxSubLimitsBodySize(t *testing.T) { installContractOp := assembleInstallContractCodeOp(t, itest.Master().Address(), "soroban_sac_test.wasm") preFlightOp, minFee := itest.PreflightHostFunctions(&sourceAccount, *installContractOp) - _, err = itest.SubmitOperationsWithFee(&sourceAccount, itest.Master(), minFee, &preFlightOp) + _, err = itest.SubmitOperationsWithFee(&sourceAccount, itest.Master(), minFee+txnbuild.MinBaseFee, &preFlightOp) assert.EqualError( t, err, "horizon error: \"Transaction Malformed\" - check horizon.Error.Problem for more information", @@ -88,7 +88,7 @@ func TestTxSubLimitsBodySize(t *testing.T) { installContractOp = assembleInstallContractCodeOp(t, itest.Master().Address(), "soroban_add_u64.wasm") preFlightOp, minFee = itest.PreflightHostFunctions(&sourceAccount, *installContractOp) - tx, err := itest.SubmitOperationsWithFee(&sourceAccount, itest.Master(), minFee, &preFlightOp) + tx, err := itest.SubmitOperationsWithFee(&sourceAccount, itest.Master(), minFee+txnbuild.MinBaseFee, &preFlightOp) require.NoError(t, err) require.True(t, tx.Successful) } diff --git a/services/horizon/internal/resourceadapter/operations.go b/services/horizon/internal/resourceadapter/operations.go index fdd083782c..2f995fb395 100644 --- a/services/horizon/internal/resourceadapter/operations.go +++ b/services/horizon/internal/resourceadapter/operations.go @@ -150,8 +150,8 @@ func NewOperation( e := operations.InvokeHostFunction{Base: base} err = operationRow.UnmarshalDetails(&e) result = e - case xdr.OperationTypeBumpFootprintExpiration: - e := operations.BumpFootprintExpiration{Base: base} + case xdr.OperationTypeExtendFootprintTtl: + e := operations.ExtendFootprintTtl{Base: base} err = operationRow.UnmarshalDetails(&e) result = e case xdr.OperationTypeRestoreFootprint: diff --git a/services/horizon/internal/test/integration/integration.go b/services/horizon/internal/test/integration/integration.go index e83b061b3e..71bf86a14a 100644 --- a/services/horizon/internal/test/integration/integration.go +++ b/services/horizon/internal/test/integration/integration.go @@ -707,8 +707,8 @@ func (i *Test) syncWithSorobanRPC(ledgerToWaitFor uint32) { } func (i *Test) PreflightBumpFootprintExpiration( - sourceAccount txnbuild.Account, bumpFootprint txnbuild.BumpFootprintExpiration, -) (txnbuild.BumpFootprintExpiration, int64) { + sourceAccount txnbuild.Account, bumpFootprint txnbuild.ExtendFootprintTtl, +) (txnbuild.ExtendFootprintTtl, int64) { result, transactionData := i.simulateTransaction(sourceAccount, &bumpFootprint) bumpFootprint.Ext = xdr.TransactionExt{ V: 1, diff --git a/txnbuild/bump_footprint_expiration.go b/txnbuild/bump_footprint_expiration.go deleted file mode 100644 index 169c3068af..0000000000 --- a/txnbuild/bump_footprint_expiration.go +++ /dev/null @@ -1,59 +0,0 @@ -package txnbuild - -import ( - "github.com/stellar/go/support/errors" - "github.com/stellar/go/xdr" -) - -type BumpFootprintExpiration struct { - LedgersToExpire uint32 - SourceAccount string - Ext xdr.TransactionExt -} - -func (f *BumpFootprintExpiration) BuildXDR() (xdr.Operation, error) { - xdrOp := xdr.BumpFootprintExpirationOp{ - Ext: xdr.ExtensionPoint{ - V: 0, - }, - LedgersToExpire: xdr.Uint32(f.LedgersToExpire), - } - - body, err := xdr.NewOperationBody(xdr.OperationTypeBumpFootprintExpiration, xdrOp) - if err != nil { - return xdr.Operation{}, errors.Wrap(err, "failed to build XDR Operation") - } - - op := xdr.Operation{Body: body} - - SetOpSourceAccount(&op, f.SourceAccount) - return op, nil -} - -func (f *BumpFootprintExpiration) FromXDR(xdrOp xdr.Operation) error { - result, ok := xdrOp.Body.GetBumpFootprintExpirationOp() - if !ok { - return errors.New("error parsing invoke host function operation from xdr") - } - f.SourceAccount = accountFromXDR(xdrOp.SourceAccount) - f.LedgersToExpire = uint32(result.LedgersToExpire) - return nil -} - -func (f *BumpFootprintExpiration) Validate() error { - if f.SourceAccount != "" { - _, err := xdr.AddressToMuxedAccount(f.SourceAccount) - if err != nil { - return NewValidationError("SourceAccount", err.Error()) - } - } - return nil -} - -func (f *BumpFootprintExpiration) GetSourceAccount() string { - return f.SourceAccount -} - -func (f *BumpFootprintExpiration) BuildTransactionExt() (xdr.TransactionExt, error) { - return f.Ext, nil -} diff --git a/txnbuild/extend_footprint_ttl.go b/txnbuild/extend_footprint_ttl.go new file mode 100644 index 0000000000..f28dee6e15 --- /dev/null +++ b/txnbuild/extend_footprint_ttl.go @@ -0,0 +1,59 @@ +package txnbuild + +import ( + "github.com/stellar/go/support/errors" + "github.com/stellar/go/xdr" +) + +type ExtendFootprintTtl struct { + ExtendTo uint32 + SourceAccount string + Ext xdr.TransactionExt +} + +func (f *ExtendFootprintTtl) BuildXDR() (xdr.Operation, error) { + xdrOp := xdr.ExtendFootprintTtlOp{ + Ext: xdr.ExtensionPoint{ + V: 0, + }, + ExtendTo: xdr.Uint32(f.ExtendTo), + } + + body, err := xdr.NewOperationBody(xdr.OperationTypeExtendFootprintTtl, xdrOp) + if err != nil { + return xdr.Operation{}, errors.Wrap(err, "failed to build XDR Operation") + } + + op := xdr.Operation{Body: body} + + SetOpSourceAccount(&op, f.SourceAccount) + return op, nil +} + +func (f *ExtendFootprintTtl) FromXDR(xdrOp xdr.Operation) error { + result, ok := xdrOp.Body.GetExtendFootprintTtlOp() + if !ok { + return errors.New("error parsing invoke host function operation from xdr") + } + f.SourceAccount = accountFromXDR(xdrOp.SourceAccount) + f.ExtendTo = uint32(result.ExtendTo) + return nil +} + +func (f *ExtendFootprintTtl) Validate() error { + if f.SourceAccount != "" { + _, err := xdr.AddressToMuxedAccount(f.SourceAccount) + if err != nil { + return NewValidationError("SourceAccount", err.Error()) + } + } + return nil +} + +func (f *ExtendFootprintTtl) GetSourceAccount() string { + return f.SourceAccount +} + +func (f *ExtendFootprintTtl) BuildTransactionExt() (xdr.TransactionExt, error) { + return f.Ext, nil +} diff --git a/txnbuild/invoke_host_function_test.go b/txnbuild/invoke_host_function_test.go index 25c6d177ea..8fd5e6e48e 100644 --- a/txnbuild/invoke_host_function_test.go +++ b/txnbuild/invoke_host_function_test.go @@ -143,7 +143,7 @@ func TestInvokeHostFunctionRoundTrip(t *testing.T) { ReadBytes: 0, WriteBytes: 0, }, - RefundableFee: 1, + ResourceFee: 1, Ext: xdr.ExtensionPoint{ V: 0, }, diff --git a/txnbuild/operation.go b/txnbuild/operation.go index 8182ada8a8..a436271592 100644 --- a/txnbuild/operation.go +++ b/txnbuild/operation.go @@ -78,8 +78,8 @@ func operationFromXDR(xdrOp xdr.Operation) (Operation, error) { newOp = &LiquidityPoolWithdraw{} case xdr.OperationTypeInvokeHostFunction: newOp = &InvokeHostFunction{} - case xdr.OperationTypeBumpFootprintExpiration: - newOp = &BumpFootprintExpiration{} + case xdr.OperationTypeExtendFootprintTtl: + newOp = &ExtendFootprintTtl{} case xdr.OperationTypeRestoreFootprint: newOp = &RestoreFootprint{} default: diff --git a/xdr/Stellar-contract-config-setting.x b/xdr/Stellar-contract-config-setting.x index 9512f0c4d6..b187a18c5a 100644 --- a/xdr/Stellar-contract-config-setting.x +++ b/xdr/Stellar-contract-config-setting.x @@ -92,64 +92,54 @@ struct ConfigSettingContractBandwidthV0 enum ContractCostType { // Cost of running 1 wasm instruction WasmInsnExec = 0, - // Cost of growing wasm linear memory by 1 page - WasmMemAlloc = 1, - // Cost of allocating a chuck of host memory (in bytes) - HostMemAlloc = 2, - // Cost of copying a chuck of bytes into a pre-allocated host memory - HostMemCpy = 3, - // Cost of comparing two slices of host memory - HostMemCmp = 4, + // Cost of allocating a slice of memory (in bytes) + MemAlloc = 1, + // Cost of copying a slice of bytes into a pre-allocated memory + MemCpy = 2, + // Cost of comparing two slices of memory + MemCmp = 3, // Cost of a host function dispatch, not including the actual work done by // the function nor the cost of VM invocation machinary - DispatchHostFunction = 5, + DispatchHostFunction = 4, // Cost of visiting a host object from the host object storage. Exists to // make sure some baseline cost coverage, i.e. repeatly visiting objects // by the guest will always incur some charges. - VisitObject = 6, + VisitObject = 5, // Cost of serializing an xdr object to bytes - ValSer = 7, + ValSer = 6, // Cost of deserializing an xdr object from bytes - ValDeser = 8, + ValDeser = 7, // Cost of computing the sha256 hash from bytes - ComputeSha256Hash = 9, + ComputeSha256Hash = 8, // Cost of computing the ed25519 pubkey from bytes - ComputeEd25519PubKey = 10, - // Cost of accessing an entry in a Map. - MapEntry = 11, - // Cost of accessing an entry in a Vec - VecEntry = 12, + ComputeEd25519PubKey = 9, // Cost of verifying ed25519 signature of a payload. - VerifyEd25519Sig = 13, - // Cost of reading a slice of vm linear memory - VmMemRead = 14, - // Cost of writing to a slice of vm linear memory - VmMemWrite = 15, + VerifyEd25519Sig = 10, // Cost of instantiation a VM from wasm bytes code. - VmInstantiation = 16, + VmInstantiation = 11, // Cost of instantiation a VM from a cached state. - VmCachedInstantiation = 17, + VmCachedInstantiation = 12, // Cost of invoking a function on the VM. If the function is a host function, // additional cost will be covered by `DispatchHostFunction`. - InvokeVmFunction = 18, + InvokeVmFunction = 13, // Cost of computing a keccak256 hash from bytes. - ComputeKeccak256Hash = 19, - // Cost of computing an ECDSA secp256k1 pubkey from bytes. - ComputeEcdsaSecp256k1Key = 20, + ComputeKeccak256Hash = 14, // Cost of computing an ECDSA secp256k1 signature from bytes. - ComputeEcdsaSecp256k1Sig = 21, + ComputeEcdsaSecp256k1Sig = 15, // Cost of recovering an ECDSA secp256k1 key from a signature. - RecoverEcdsaSecp256k1Key = 22, + RecoverEcdsaSecp256k1Key = 16, // Cost of int256 addition (`+`) and subtraction (`-`) operations - Int256AddSub = 23, + Int256AddSub = 17, // Cost of int256 multiplication (`*`) operation - Int256Mul = 24, + Int256Mul = 18, // Cost of int256 division (`/`) operation - Int256Div = 25, + Int256Div = 19, // Cost of int256 power (`exp`) operation - Int256Pow = 26, + Int256Pow = 20, // Cost of int256 shift (`shl`, `shr`) operation - Int256Shift = 27 + Int256Shift = 21, + // Cost of drawing random bytes using a ChaCha20 PRNG + ChaCha20DrawBytes = 22 }; struct ContractCostParamEntry { @@ -160,17 +150,17 @@ struct ContractCostParamEntry { int64 linearTerm; }; -struct StateExpirationSettings { - uint32 maxEntryExpiration; - uint32 minTempEntryExpiration; - uint32 minPersistentEntryExpiration; +struct StateArchivalSettings { + uint32 maxEntryTTL; + uint32 minTemporaryTTL; + uint32 minPersistentTTL; // rent_fee = wfee_rate_average / rent_rate_denominator_for_type int64 persistentRentRateDenominator; int64 tempRentRateDenominator; - // max number of entries that emit expiration meta in a single ledger - uint32 maxEntriesToExpire; + // max number of entries that emit archival meta in a single ledger + uint32 maxEntriesToArchive; // Number of snapshots to use when calculating average BucketList size uint32 bucketListSizeWindowSampleSize; @@ -206,7 +196,7 @@ enum ConfigSettingID CONFIG_SETTING_CONTRACT_COST_PARAMS_MEMORY_BYTES = 7, CONFIG_SETTING_CONTRACT_DATA_KEY_SIZE_BYTES = 8, CONFIG_SETTING_CONTRACT_DATA_ENTRY_SIZE_BYTES = 9, - CONFIG_SETTING_STATE_EXPIRATION = 10, + CONFIG_SETTING_STATE_ARCHIVAL = 10, CONFIG_SETTING_CONTRACT_EXECUTION_LANES = 11, CONFIG_SETTING_BUCKETLIST_SIZE_WINDOW = 12, CONFIG_SETTING_EVICTION_ITERATOR = 13 @@ -234,8 +224,8 @@ case CONFIG_SETTING_CONTRACT_DATA_KEY_SIZE_BYTES: uint32 contractDataKeySizeBytes; case CONFIG_SETTING_CONTRACT_DATA_ENTRY_SIZE_BYTES: uint32 contractDataEntrySizeBytes; -case CONFIG_SETTING_STATE_EXPIRATION: - StateExpirationSettings stateExpirationSettings; +case CONFIG_SETTING_STATE_ARCHIVAL: + StateArchivalSettings stateArchivalSettings; case CONFIG_SETTING_CONTRACT_EXECUTION_LANES: ConfigSettingContractExecutionLanesV0 contractExecutionLanes; case CONFIG_SETTING_BUCKETLIST_SIZE_WINDOW: diff --git a/xdr/Stellar-contract.x b/xdr/Stellar-contract.x index 7c7469c7e8..511300562e 100644 --- a/xdr/Stellar-contract.x +++ b/xdr/Stellar-contract.x @@ -165,14 +165,14 @@ struct Int256Parts { enum ContractExecutableType { CONTRACT_EXECUTABLE_WASM = 0, - CONTRACT_EXECUTABLE_TOKEN = 1 + CONTRACT_EXECUTABLE_STELLAR_ASSET = 1 }; union ContractExecutable switch (ContractExecutableType type) { case CONTRACT_EXECUTABLE_WASM: Hash wasm_hash; -case CONTRACT_EXECUTABLE_TOKEN: +case CONTRACT_EXECUTABLE_STELLAR_ASSET: void; }; diff --git a/xdr/Stellar-internal.x b/xdr/Stellar-internal.x index 73684db7ac..02f1b81e8e 100644 --- a/xdr/Stellar-internal.x +++ b/xdr/Stellar-internal.x @@ -17,6 +17,13 @@ case 1: GeneralizedTransactionSet generalizedTxSet; }; +struct StoredDebugTransactionSet +{ + StoredTransactionSet txSet; + uint32 ledgerSeq; + StellarValue scpValue; +}; + struct PersistedSCPStateV0 { SCPEnvelope scpEnvelopes<>; diff --git a/xdr/Stellar-ledger-entries.x b/xdr/Stellar-ledger-entries.x index f066484001..8a8784e2bb 100644 --- a/xdr/Stellar-ledger-entries.x +++ b/xdr/Stellar-ledger-entries.x @@ -101,7 +101,7 @@ enum LedgerEntryType CONTRACT_DATA = 6, CONTRACT_CODE = 7, CONFIG_SETTING = 8, - EXPIRATION = 9 + TTL = 9 }; struct Signer @@ -515,10 +515,10 @@ struct ContractCodeEntry { opaque code<>; }; -struct ExpirationEntry { - // Hash of the LedgerKey that is associated with this ExpirationEntry +struct TTLEntry { + // Hash of the LedgerKey that is associated with this TTLEntry Hash keyHash; - uint32 expirationLedgerSeq; + uint32 liveUntilLedgerSeq; }; struct LedgerEntryExtensionV1 @@ -557,8 +557,8 @@ struct LedgerEntry ContractCodeEntry contractCode; case CONFIG_SETTING: ConfigSettingEntry configSetting; - case EXPIRATION: - ExpirationEntry expiration; + case TTL: + TTLEntry ttl; } data; @@ -630,12 +630,12 @@ case CONFIG_SETTING: { ConfigSettingID configSettingID; } configSetting; -case EXPIRATION: +case TTL: struct { - // Hash of the LedgerKey that is associated with this ExpirationEntry + // Hash of the LedgerKey that is associated with this TTLEntry Hash keyHash; - } expiration; + } ttl; }; // list of all envelope types used in the application diff --git a/xdr/Stellar-ledger.x b/xdr/Stellar-ledger.x index a1bbac4b64..b18a3a0d57 100644 --- a/xdr/Stellar-ledger.x +++ b/xdr/Stellar-ledger.x @@ -486,26 +486,8 @@ struct LedgerCloseMetaV0 struct LedgerCloseMetaV1 { - LedgerHeaderHistoryEntry ledgerHeader; - - GeneralizedTransactionSet txSet; - - // NB: transactions are sorted in apply order here - // fees for all transactions are processed first - // followed by applying transactions - TransactionResultMeta txProcessing<>; - - // upgrades are applied last - UpgradeEntryMeta upgradesProcessing<>; - - // other misc information attached to the ledger close - SCPHistoryEntry scpInfo<>; -}; - -struct LedgerCloseMetaV2 -{ - // We forgot to add an ExtensionPoint in v1 but at least - // we can add one now in v2. + // We forgot to add an ExtensionPoint in v0 but at least + // we can add one now in v1. ExtensionPoint ext; LedgerHeaderHistoryEntry ledgerHeader; @@ -527,10 +509,10 @@ struct LedgerCloseMetaV2 // systems calculating storage fees correctly. uint64 totalByteSizeOfBucketList; - // Expired temp keys that are being evicted at this ledger. + // Temp keys that are being evicted at this ledger. LedgerKey evictedTemporaryLedgerKeys<>; - // Expired restorable ledger entries that are being + // Archived restorable ledger entries that are being // evicted at this ledger. LedgerEntry evictedPersistentLedgerEntries<>; }; @@ -541,7 +523,5 @@ case 0: LedgerCloseMetaV0 v0; case 1: LedgerCloseMetaV1 v1; -case 2: - LedgerCloseMetaV2 v2; }; } diff --git a/xdr/Stellar-transaction.x b/xdr/Stellar-transaction.x index 2e3c22b318..c7f0f5e276 100644 --- a/xdr/Stellar-transaction.x +++ b/xdr/Stellar-transaction.x @@ -63,7 +63,7 @@ enum OperationType LIQUIDITY_POOL_DEPOSIT = 22, LIQUIDITY_POOL_WITHDRAW = 23, INVOKE_HOST_FUNCTION = 24, - BUMP_FOOTPRINT_EXPIRATION = 25, + EXTEND_FOOTPRINT_TTL = 25, RESTORE_FOOTPRINT = 26 }; @@ -585,19 +585,19 @@ struct InvokeHostFunctionOp SorobanAuthorizationEntry auth<>; }; -/* Bump the expiration ledger of the entries specified in the readOnly footprint - so they'll expire at least ledgersToExpire ledgers from lcl. +/* Extend the TTL of the entries specified in the readOnly footprint + so they will live at least extendTo ledgers from lcl. Threshold: med - Result: BumpFootprintExpirationResult + Result: ExtendFootprintTTLResult */ -struct BumpFootprintExpirationOp +struct ExtendFootprintTTLOp { ExtensionPoint ext; - uint32 ledgersToExpire; + uint32 extendTo; }; -/* Restore the expired or evicted entries specified in the readWrite footprint. +/* Restore the archived entries specified in the readWrite footprint. Threshold: med Result: RestoreFootprintOp @@ -667,8 +667,8 @@ struct Operation LiquidityPoolWithdrawOp liquidityPoolWithdrawOp; case INVOKE_HOST_FUNCTION: InvokeHostFunctionOp invokeHostFunctionOp; - case BUMP_FOOTPRINT_EXPIRATION: - BumpFootprintExpirationOp bumpFootprintExpirationOp; + case EXTEND_FOOTPRINT_TTL: + ExtendFootprintTTLOp extendFootprintTTLOp; case RESTORE_FOOTPRINT: RestoreFootprintOp restoreFootprintOp; } @@ -821,8 +821,16 @@ struct SorobanTransactionData { ExtensionPoint ext; SorobanResources resources; - // Portion of transaction `fee` allocated to refundable fees. - int64 refundableFee; + // Amount of the transaction `fee` allocated to the Soroban resource fees. + // The fraction of `resourceFee` corresponding to `resources` specified + // above is *not* refundable (i.e. fees for instructions, ledger I/O), as + // well as fees for the transaction size. + // The remaining part of the fee is refundable and the charged value is + // based on the actual consumption of refundable resources (events, ledger + // rent bumps). + // The `inclusionFee` used for prioritization of the transaction is defined + // as `tx.fee - resourceFee`. + int64 resourceFee; }; // TransactionV0 is a transaction with the AccountID discriminant stripped off, @@ -1789,7 +1797,7 @@ enum InvokeHostFunctionResultCode INVOKE_HOST_FUNCTION_MALFORMED = -1, INVOKE_HOST_FUNCTION_TRAPPED = -2, INVOKE_HOST_FUNCTION_RESOURCE_LIMIT_EXCEEDED = -3, - INVOKE_HOST_FUNCTION_ENTRY_EXPIRED = -4, + INVOKE_HOST_FUNCTION_ENTRY_ARCHIVED = -4, INVOKE_HOST_FUNCTION_INSUFFICIENT_REFUNDABLE_FEE = -5 }; @@ -1800,29 +1808,29 @@ case INVOKE_HOST_FUNCTION_SUCCESS: case INVOKE_HOST_FUNCTION_MALFORMED: case INVOKE_HOST_FUNCTION_TRAPPED: case INVOKE_HOST_FUNCTION_RESOURCE_LIMIT_EXCEEDED: -case INVOKE_HOST_FUNCTION_ENTRY_EXPIRED: +case INVOKE_HOST_FUNCTION_ENTRY_ARCHIVED: case INVOKE_HOST_FUNCTION_INSUFFICIENT_REFUNDABLE_FEE: void; }; -enum BumpFootprintExpirationResultCode +enum ExtendFootprintTTLResultCode { // codes considered as "success" for the operation - BUMP_FOOTPRINT_EXPIRATION_SUCCESS = 0, + EXTEND_FOOTPRINT_TTL_SUCCESS = 0, // codes considered as "failure" for the operation - BUMP_FOOTPRINT_EXPIRATION_MALFORMED = -1, - BUMP_FOOTPRINT_EXPIRATION_RESOURCE_LIMIT_EXCEEDED = -2, - BUMP_FOOTPRINT_EXPIRATION_INSUFFICIENT_REFUNDABLE_FEE = -3 + EXTEND_FOOTPRINT_TTL_MALFORMED = -1, + EXTEND_FOOTPRINT_TTL_RESOURCE_LIMIT_EXCEEDED = -2, + EXTEND_FOOTPRINT_TTL_INSUFFICIENT_REFUNDABLE_FEE = -3 }; -union BumpFootprintExpirationResult switch (BumpFootprintExpirationResultCode code) +union ExtendFootprintTTLResult switch (ExtendFootprintTTLResultCode code) { -case BUMP_FOOTPRINT_EXPIRATION_SUCCESS: +case EXTEND_FOOTPRINT_TTL_SUCCESS: void; -case BUMP_FOOTPRINT_EXPIRATION_MALFORMED: -case BUMP_FOOTPRINT_EXPIRATION_RESOURCE_LIMIT_EXCEEDED: -case BUMP_FOOTPRINT_EXPIRATION_INSUFFICIENT_REFUNDABLE_FEE: +case EXTEND_FOOTPRINT_TTL_MALFORMED: +case EXTEND_FOOTPRINT_TTL_RESOURCE_LIMIT_EXCEEDED: +case EXTEND_FOOTPRINT_TTL_INSUFFICIENT_REFUNDABLE_FEE: void; }; @@ -1915,8 +1923,8 @@ case opINNER: LiquidityPoolWithdrawResult liquidityPoolWithdrawResult; case INVOKE_HOST_FUNCTION: InvokeHostFunctionResult invokeHostFunctionResult; - case BUMP_FOOTPRINT_EXPIRATION: - BumpFootprintExpirationResult bumpFootprintExpirationResult; + case EXTEND_FOOTPRINT_TTL: + ExtendFootprintTTLResult extendFootprintTTLResult; case RESTORE_FOOTPRINT: RestoreFootprintResult restoreFootprintResult; } diff --git a/xdr/ledger_close_meta.go b/xdr/ledger_close_meta.go index c2b352b613..2290f3bee1 100644 --- a/xdr/ledger_close_meta.go +++ b/xdr/ledger_close_meta.go @@ -10,8 +10,6 @@ func (l LedgerCloseMeta) LedgerHeaderHistoryEntry() LedgerHeaderHistoryEntry { return l.MustV0().LedgerHeader case 1: return l.MustV1().LedgerHeader - case 2: - return l.MustV2().LedgerHeader default: panic(fmt.Sprintf("Unsupported LedgerCloseMeta.V: %d", l.V)) } @@ -43,8 +41,7 @@ func (l LedgerCloseMeta) CountTransactions() int { return len(l.MustV0().TxProcessing) case 1: return len(l.MustV1().TxProcessing) - case 2: - return len(l.MustV2().TxProcessing) + default: panic(fmt.Sprintf("Unsupported LedgerCloseMeta.V: %d", l.V)) } @@ -54,15 +51,9 @@ func (l LedgerCloseMeta) TransactionEnvelopes() []TransactionEnvelope { switch l.V { case 0: return l.MustV0().TxSet.Txs - case 1, 2: + case 1: var envelopes = make([]TransactionEnvelope, 0, l.CountTransactions()) - var phases []TransactionPhase - if l.V == 1 { - phases = l.MustV1().TxSet.V1TxSet.Phases - } else { - phases = l.MustV2().TxSet.V1TxSet.Phases - } - for _, phase := range phases { + for _, phase := range l.MustV1().TxSet.V1TxSet.Phases { for _, component := range *phase.V0Components { envelopes = append(envelopes, component.TxsMaybeDiscountedFee.Txs...) } @@ -80,8 +71,6 @@ func (l LedgerCloseMeta) TransactionHash(i int) Hash { return l.MustV0().TxProcessing[i].Result.TransactionHash case 1: return l.MustV1().TxProcessing[i].Result.TransactionHash - case 2: - return l.MustV2().TxProcessing[i].Result.TransactionHash default: panic(fmt.Sprintf("Unsupported LedgerCloseMeta.V: %d", l.V)) } @@ -94,8 +83,6 @@ func (l LedgerCloseMeta) TransactionResultPair(i int) TransactionResultPair { return l.MustV0().TxProcessing[i].Result case 1: return l.MustV1().TxProcessing[i].Result - case 2: - return l.MustV2().TxProcessing[i].Result default: panic(fmt.Sprintf("Unsupported LedgerCloseMeta.V: %d", l.V)) } @@ -108,8 +95,6 @@ func (l LedgerCloseMeta) FeeProcessing(i int) LedgerEntryChanges { return l.MustV0().TxProcessing[i].FeeProcessing case 1: return l.MustV1().TxProcessing[i].FeeProcessing - case 2: - return l.MustV2().TxProcessing[i].FeeProcessing default: panic(fmt.Sprintf("Unsupported LedgerCloseMeta.V: %d", l.V)) } @@ -121,12 +106,10 @@ func (l LedgerCloseMeta) TxApplyProcessing(i int) TransactionMeta { case 0: return l.MustV0().TxProcessing[i].TxApplyProcessing case 1: - return l.MustV1().TxProcessing[i].TxApplyProcessing - case 2: - if l.MustV2().TxProcessing[i].TxApplyProcessing.V != 3 { - panic("TransactionResult unavailable because LedgerCloseMeta.V = 2 and TransactionMeta.V != 3") + if l.MustV1().TxProcessing[i].TxApplyProcessing.V != 3 { + panic("TransactionResult unavailable because LedgerCloseMeta.V = 1 and TransactionMeta.V != 3") } - return l.MustV2().TxProcessing[i].TxApplyProcessing + return l.MustV1().TxProcessing[i].TxApplyProcessing default: panic(fmt.Sprintf("Unsupported LedgerCloseMeta.V: %d", l.V)) } @@ -139,8 +122,6 @@ func (l LedgerCloseMeta) UpgradesProcessing() []UpgradeEntryMeta { return l.MustV0().UpgradesProcessing case 1: return l.MustV1().UpgradesProcessing - case 2: - return l.MustV2().UpgradesProcessing default: panic(fmt.Sprintf("Unsupported LedgerCloseMeta.V: %d", l.V)) } @@ -150,10 +131,10 @@ func (l LedgerCloseMeta) UpgradesProcessing() []UpgradeEntryMeta { // temporary ledger entries that have been evicted in this ledger. func (l LedgerCloseMeta) EvictedTemporaryLedgerKeys() ([]LedgerKey, error) { switch l.V { - case 0, 1: + case 0: return nil, nil - case 2: - return l.MustV2().EvictedTemporaryLedgerKeys, nil + case 1: + return l.MustV1().EvictedTemporaryLedgerKeys, nil default: panic(fmt.Sprintf("Unsupported LedgerCloseMeta.V: %d", l.V)) } @@ -163,10 +144,10 @@ func (l LedgerCloseMeta) EvictedTemporaryLedgerKeys() ([]LedgerKey, error) { // which have been evicted in this ledger. func (l LedgerCloseMeta) EvictedPersistentLedgerEntries() ([]LedgerEntry, error) { switch l.V { - case 0, 1: + case 0: return nil, nil - case 2: - return l.MustV2().EvictedPersistentLedgerEntries, nil + case 1: + return l.MustV1().EvictedPersistentLedgerEntries, nil default: panic(fmt.Sprintf("Unsupported LedgerCloseMeta.V: %d", l.V)) } diff --git a/xdr/ledger_entry.go b/xdr/ledger_entry.go index 8df379bffe..c04defb693 100644 --- a/xdr/ledger_entry.go +++ b/xdr/ledger_entry.go @@ -173,8 +173,8 @@ func (data *LedgerEntryData) LedgerKey() (LedgerKey, error) { if err := key.SetConfigSetting(data.ConfigSetting.ConfigSettingId); err != nil { return key, err } - case LedgerEntryTypeExpiration: - if err := key.SetExpiration(data.Expiration.KeyHash); err != nil { + case LedgerEntryTypeTtl: + if err := key.SetTtl(data.Ttl.KeyHash); err != nil { return key, err } default: diff --git a/xdr/ledger_key.go b/xdr/ledger_key.go index df4d01e9fc..88ba800cf2 100644 --- a/xdr/ledger_key.go +++ b/xdr/ledger_key.go @@ -53,9 +53,9 @@ func (key *LedgerKey) Equals(other LedgerKey) bool { l := key.MustClaimableBalance() r := other.MustClaimableBalance() return l.BalanceId.MustV0() == r.BalanceId.MustV0() - case LedgerEntryTypeExpiration: - l := key.MustExpiration() - r := other.MustExpiration() + case LedgerEntryTypeTtl: + l := key.MustTtl() + r := other.MustTtl() return l.KeyHash == r.KeyHash default: panic(fmt.Errorf("unknown ledger key type: %v", key.Type)) @@ -188,13 +188,13 @@ func (key *LedgerKey) SetConfigSetting(configSettingID ConfigSettingId) error { return nil } -// SetExpiration mutates `key` such that it represents the identity of an +// SetTtl mutates `key` such that it represents the identity of an // expiration entry. -func (key *LedgerKey) SetExpiration(keyHash Hash) error { - data := LedgerKeyExpiration{ +func (key *LedgerKey) SetTtl(keyHash Hash) error { + data := LedgerKeyTtl{ KeyHash: keyHash, } - nkey, err := NewLedgerKey(LedgerEntryTypeExpiration, data) + nkey, err := NewLedgerKey(LedgerEntryTypeTtl, data) if err != nil { return err } @@ -259,8 +259,8 @@ func (e *EncodingBuffer) ledgerKeyCompressEncodeTo(key LedgerKey) error { return err case LedgerEntryTypeConfigSetting: return key.ConfigSetting.ConfigSettingId.EncodeTo(e.encoder) - case LedgerEntryTypeExpiration: - return key.Expiration.KeyHash.EncodeTo(e.encoder) + case LedgerEntryTypeTtl: + return key.Ttl.KeyHash.EncodeTo(e.encoder) default: panic("Unknown type") } diff --git a/xdr/main.go b/xdr/main.go index 04d0204508..b0c31ad5d8 100644 --- a/xdr/main.go +++ b/xdr/main.go @@ -112,7 +112,7 @@ func NewBytesDecoder() *BytesDecoder { func (d *BytesDecoder) DecodeBytes(v DecoderFrom, b []byte) (int, error) { d.reader.Reset(b) - return v.DecodeFrom(d.decoder) + return v.DecodeFrom(d.decoder, xdr.DecodeDefaultMaxDepth) } func marshalString(encoder func([]byte) string, v interface{}) (string, error) { diff --git a/xdr/scval.go b/xdr/scval.go index 559941c27a..4648a6ab82 100644 --- a/xdr/scval.go +++ b/xdr/scval.go @@ -34,7 +34,7 @@ func (s ContractExecutable) Equals(o ContractExecutable) bool { return false } switch s.Type { - case ContractExecutableTypeContractExecutableToken: + case ContractExecutableTypeContractExecutableStellarAsset: return true case ContractExecutableTypeContractExecutableWasm: return s.MustWasmHash().Equals(o.MustWasmHash()) diff --git a/xdr/xdr_commit_generated.txt b/xdr/xdr_commit_generated.txt index c5e549e9c1..3c6d18d90d 100644 --- a/xdr/xdr_commit_generated.txt +++ b/xdr/xdr_commit_generated.txt @@ -1 +1 @@ -9ac02641139e6717924fdad716f6e958d0168491 \ No newline at end of file +6a620d160aab22609c982d54578ff6a63bfcdc01 \ No newline at end of file diff --git a/xdr/xdr_generated.go b/xdr/xdr_generated.go index 4e97b35d32..f4f59553cc 100644 --- a/xdr/xdr_generated.go +++ b/xdr/xdr_generated.go @@ -22,6 +22,7 @@ package xdr import ( "bytes" "encoding" + "errors" "fmt" "io" @@ -31,32 +32,34 @@ import ( // XdrFilesSHA256 is the SHA256 hashes of source files. var XdrFilesSHA256 = map[string]string{ "xdr/Stellar-SCP.x": "8f32b04d008f8bc33b8843d075e69837231a673691ee41d8b821ca229a6e802a", - "xdr/Stellar-contract-config-setting.x": "fd8709d1bcc36a90a1f7b1fd8cb4407f7733bec5ca06494cac9b6a99b942ef99", + "xdr/Stellar-contract-config-setting.x": "e466c4dfae1d5d181afbd990b91f26c5d8ed84a7fa987875f8d643cf97e34a77", "xdr/Stellar-contract-env-meta.x": "928a30de814ee589bc1d2aadd8dd81c39f71b7e6f430f56974505ccb1f49654b", "xdr/Stellar-contract-meta.x": "f01532c11ca044e19d9f9f16fe373e9af64835da473be556b9a807ee3319ae0d", "xdr/Stellar-contract-spec.x": "c7ffa21d2e91afb8e666b33524d307955426ff553a486d670c29217ed9888d49", - "xdr/Stellar-contract.x": "234d2adf0c9bdf7c42ea64a2650884d8e36ed31cd1cbe13fb8d12b335fb4e5c3", - "xdr/Stellar-internal.x": "368706dd6e2efafd16a8f63daf3374845b791d097b15c502aa7653a412b68b68", - "xdr/Stellar-ledger-entries.x": "73b467bce654c5b19d0fba24008c9ccae77b439320a4c9eef9128e1818fdd76d", - "xdr/Stellar-ledger.x": "247d1b486d546f5c37f3d8a719b195e3331106302bcdc54cd1f52a6f94a9a7ed", + "xdr/Stellar-contract.x": "7f665e4103e146a88fcdabce879aaaacd3bf9283feb194cc47ff986264c1e315", + "xdr/Stellar-internal.x": "227835866c1b2122d1eaf28839ba85ea7289d1cb681dda4ca619c2da3d71fe00", + "xdr/Stellar-ledger-entries.x": "4f8f2324f567a40065f54f696ea1428740f043ea4154f5986d9f499ad00ac333", + "xdr/Stellar-ledger.x": "2c842f3fe6e269498af5467f849cf6818554e90babc845f34c87cda471298d0f", "xdr/Stellar-overlay.x": "de3957c58b96ae07968b3d3aebea84f83603e95322d1fa336360e13e3aba737a", - "xdr/Stellar-transaction.x": "ce8194511afb4cbb165921c720d057381bcd4829999027d42753c11d5dcaa7f8", + "xdr/Stellar-transaction.x": "c5dd8507bc84e10b67bf3bc74c8f716a660b425814b015025c6f6b6f20cb70e7", "xdr/Stellar-types.x": "6e3b13f0d3e360b09fa5e2b0e55d43f4d974a769df66afb34e8aecbb329d3f15", } +var ErrMaxDecodingDepthReached = errors.New("maximum decoding depth reached") + type xdrType interface { xdrType() } type decoderFrom interface { - DecodeFrom(d *xdr.Decoder) (int, error) + DecodeFrom(d *xdr.Decoder, maxDepth uint) (int, error) } // Unmarshal reads an xdr element from `r` into `v`. func Unmarshal(r io.Reader, v interface{}) (int, error) { if decodable, ok := v.(decoderFrom); ok { d := xdr.NewDecoder(r) - return decodable.DecodeFrom(d) + return decodable.DecodeFrom(d, xdr.DecodeDefaultMaxDepth) } // delegate to xdr package's Unmarshal return xdr.Unmarshal(r, v) @@ -94,13 +97,17 @@ func (s Value) EncodeTo(e *xdr.Encoder) error { var _ decoderFrom = (*Value)(nil) // DecodeFrom decodes this value using the Decoder. -func (s *Value) DecodeFrom(d *xdr.Decoder) (int, error) { +func (s *Value) DecodeFrom(d *xdr.Decoder, maxDepth uint) (int, error) { + if maxDepth == 0 { + return 0, fmt.Errorf("decoding Value: %w", ErrMaxDecodingDepthReached) + } + maxDepth -= 1 var err error var n, nTmp int (*s), nTmp, err = d.DecodeOpaque(0) n += nTmp if err != nil { - return n, fmt.Errorf("decoding Value: %s", err) + return n, fmt.Errorf("decoding Value: %w", err) } return n, nil } @@ -117,7 +124,7 @@ func (s Value) MarshalBinary() ([]byte, error) { func (s *Value) UnmarshalBinary(inp []byte) error { r := bytes.NewReader(inp) d := xdr.NewDecoder(r) - _, err := s.DecodeFrom(d) + _, err := s.DecodeFrom(d, xdr.DecodeDefaultMaxDepth) return err } @@ -159,18 +166,22 @@ func (s *ScpBallot) EncodeTo(e *xdr.Encoder) error { var _ decoderFrom = (*ScpBallot)(nil) // DecodeFrom decodes this value using the Decoder. -func (s *ScpBallot) DecodeFrom(d *xdr.Decoder) (int, error) { +func (s *ScpBallot) DecodeFrom(d *xdr.Decoder, maxDepth uint) (int, error) { + if maxDepth == 0 { + return 0, fmt.Errorf("decoding ScpBallot: %w", ErrMaxDecodingDepthReached) + } + maxDepth -= 1 var err error var n, nTmp int - nTmp, err = s.Counter.DecodeFrom(d) + nTmp, err = s.Counter.DecodeFrom(d, maxDepth) n += nTmp if err != nil { - return n, fmt.Errorf("decoding Uint32: %s", err) + return n, fmt.Errorf("decoding Uint32: %w", err) } - nTmp, err = s.Value.DecodeFrom(d) + nTmp, err = s.Value.DecodeFrom(d, maxDepth) n += nTmp if err != nil { - return n, fmt.Errorf("decoding Value: %s", err) + return n, fmt.Errorf("decoding Value: %w", err) } return n, nil } @@ -187,7 +198,7 @@ func (s ScpBallot) MarshalBinary() ([]byte, error) { func (s *ScpBallot) UnmarshalBinary(inp []byte) error { r := bytes.NewReader(inp) d := xdr.NewDecoder(r) - _, err := s.DecodeFrom(d) + _, err := s.DecodeFrom(d, xdr.DecodeDefaultMaxDepth) return err } @@ -252,10 +263,14 @@ func (e ScpStatementType) EncodeTo(enc *xdr.Encoder) error { var _ decoderFrom = (*ScpStatementType)(nil) // DecodeFrom decodes this value using the Decoder. -func (e *ScpStatementType) DecodeFrom(d *xdr.Decoder) (int, error) { +func (e *ScpStatementType) DecodeFrom(d *xdr.Decoder, maxDepth uint) (int, error) { + if maxDepth == 0 { + return 0, fmt.Errorf("decoding ScpStatementType: %w", ErrMaxDecodingDepthReached) + } + maxDepth -= 1 v, n, err := d.DecodeInt() if err != nil { - return n, fmt.Errorf("decoding ScpStatementType: %s", err) + return n, fmt.Errorf("decoding ScpStatementType: %w", err) } if _, ok := scpStatementTypeMap[v]; !ok { return n, fmt.Errorf("'%d' is not a valid ScpStatementType enum value", v) @@ -276,7 +291,7 @@ func (s ScpStatementType) MarshalBinary() ([]byte, error) { func (s *ScpStatementType) UnmarshalBinary(inp []byte) error { r := bytes.NewReader(inp) d := xdr.NewDecoder(r) - _, err := s.DecodeFrom(d) + _, err := s.DecodeFrom(d, xdr.DecodeDefaultMaxDepth) return err } @@ -333,44 +348,48 @@ func (s *ScpNomination) EncodeTo(e *xdr.Encoder) error { var _ decoderFrom = (*ScpNomination)(nil) // DecodeFrom decodes this value using the Decoder. -func (s *ScpNomination) DecodeFrom(d *xdr.Decoder) (int, error) { +func (s *ScpNomination) DecodeFrom(d *xdr.Decoder, maxDepth uint) (int, error) { + if maxDepth == 0 { + return 0, fmt.Errorf("decoding ScpNomination: %w", ErrMaxDecodingDepthReached) + } + maxDepth -= 1 var err error var n, nTmp int - nTmp, err = s.QuorumSetHash.DecodeFrom(d) + nTmp, err = s.QuorumSetHash.DecodeFrom(d, maxDepth) n += nTmp if err != nil { - return n, fmt.Errorf("decoding Hash: %s", err) + return n, fmt.Errorf("decoding Hash: %w", err) } var l uint32 l, nTmp, err = d.DecodeUint() n += nTmp if err != nil { - return n, fmt.Errorf("decoding Value: %s", err) + return n, fmt.Errorf("decoding Value: %w", err) } s.Votes = nil if l > 0 { s.Votes = make([]Value, l) for i := uint32(0); i < l; i++ { - nTmp, err = s.Votes[i].DecodeFrom(d) + nTmp, err = s.Votes[i].DecodeFrom(d, maxDepth) n += nTmp if err != nil { - return n, fmt.Errorf("decoding Value: %s", err) + return n, fmt.Errorf("decoding Value: %w", err) } } } l, nTmp, err = d.DecodeUint() n += nTmp if err != nil { - return n, fmt.Errorf("decoding Value: %s", err) + return n, fmt.Errorf("decoding Value: %w", err) } s.Accepted = nil if l > 0 { s.Accepted = make([]Value, l) for i := uint32(0); i < l; i++ { - nTmp, err = s.Accepted[i].DecodeFrom(d) + nTmp, err = s.Accepted[i].DecodeFrom(d, maxDepth) n += nTmp if err != nil { - return n, fmt.Errorf("decoding Value: %s", err) + return n, fmt.Errorf("decoding Value: %w", err) } } } @@ -389,7 +408,7 @@ func (s ScpNomination) MarshalBinary() ([]byte, error) { func (s *ScpNomination) UnmarshalBinary(inp []byte) error { r := bytes.NewReader(inp) d := xdr.NewDecoder(r) - _, err := s.DecodeFrom(d) + _, err := s.DecodeFrom(d, xdr.DecodeDefaultMaxDepth) return err } @@ -461,57 +480,61 @@ func (s *ScpStatementPrepare) EncodeTo(e *xdr.Encoder) error { var _ decoderFrom = (*ScpStatementPrepare)(nil) // DecodeFrom decodes this value using the Decoder. -func (s *ScpStatementPrepare) DecodeFrom(d *xdr.Decoder) (int, error) { +func (s *ScpStatementPrepare) DecodeFrom(d *xdr.Decoder, maxDepth uint) (int, error) { + if maxDepth == 0 { + return 0, fmt.Errorf("decoding ScpStatementPrepare: %w", ErrMaxDecodingDepthReached) + } + maxDepth -= 1 var err error var n, nTmp int - nTmp, err = s.QuorumSetHash.DecodeFrom(d) + nTmp, err = s.QuorumSetHash.DecodeFrom(d, maxDepth) n += nTmp if err != nil { - return n, fmt.Errorf("decoding Hash: %s", err) + return n, fmt.Errorf("decoding Hash: %w", err) } - nTmp, err = s.Ballot.DecodeFrom(d) + nTmp, err = s.Ballot.DecodeFrom(d, maxDepth) n += nTmp if err != nil { - return n, fmt.Errorf("decoding ScpBallot: %s", err) + return n, fmt.Errorf("decoding ScpBallot: %w", err) } var b bool b, nTmp, err = d.DecodeBool() n += nTmp if err != nil { - return n, fmt.Errorf("decoding ScpBallot: %s", err) + return n, fmt.Errorf("decoding ScpBallot: %w", err) } s.Prepared = nil if b { s.Prepared = new(ScpBallot) - nTmp, err = s.Prepared.DecodeFrom(d) + nTmp, err = s.Prepared.DecodeFrom(d, maxDepth) n += nTmp if err != nil { - return n, fmt.Errorf("decoding ScpBallot: %s", err) + return n, fmt.Errorf("decoding ScpBallot: %w", err) } } b, nTmp, err = d.DecodeBool() n += nTmp if err != nil { - return n, fmt.Errorf("decoding ScpBallot: %s", err) + return n, fmt.Errorf("decoding ScpBallot: %w", err) } s.PreparedPrime = nil if b { s.PreparedPrime = new(ScpBallot) - nTmp, err = s.PreparedPrime.DecodeFrom(d) + nTmp, err = s.PreparedPrime.DecodeFrom(d, maxDepth) n += nTmp if err != nil { - return n, fmt.Errorf("decoding ScpBallot: %s", err) + return n, fmt.Errorf("decoding ScpBallot: %w", err) } } - nTmp, err = s.NC.DecodeFrom(d) + nTmp, err = s.NC.DecodeFrom(d, maxDepth) n += nTmp if err != nil { - return n, fmt.Errorf("decoding Uint32: %s", err) + return n, fmt.Errorf("decoding Uint32: %w", err) } - nTmp, err = s.NH.DecodeFrom(d) + nTmp, err = s.NH.DecodeFrom(d, maxDepth) n += nTmp if err != nil { - return n, fmt.Errorf("decoding Uint32: %s", err) + return n, fmt.Errorf("decoding Uint32: %w", err) } return n, nil } @@ -528,7 +551,7 @@ func (s ScpStatementPrepare) MarshalBinary() ([]byte, error) { func (s *ScpStatementPrepare) UnmarshalBinary(inp []byte) error { r := bytes.NewReader(inp) d := xdr.NewDecoder(r) - _, err := s.DecodeFrom(d) + _, err := s.DecodeFrom(d, xdr.DecodeDefaultMaxDepth) return err } @@ -585,33 +608,37 @@ func (s *ScpStatementConfirm) EncodeTo(e *xdr.Encoder) error { var _ decoderFrom = (*ScpStatementConfirm)(nil) // DecodeFrom decodes this value using the Decoder. -func (s *ScpStatementConfirm) DecodeFrom(d *xdr.Decoder) (int, error) { +func (s *ScpStatementConfirm) DecodeFrom(d *xdr.Decoder, maxDepth uint) (int, error) { + if maxDepth == 0 { + return 0, fmt.Errorf("decoding ScpStatementConfirm: %w", ErrMaxDecodingDepthReached) + } + maxDepth -= 1 var err error var n, nTmp int - nTmp, err = s.Ballot.DecodeFrom(d) + nTmp, err = s.Ballot.DecodeFrom(d, maxDepth) n += nTmp if err != nil { - return n, fmt.Errorf("decoding ScpBallot: %s", err) + return n, fmt.Errorf("decoding ScpBallot: %w", err) } - nTmp, err = s.NPrepared.DecodeFrom(d) + nTmp, err = s.NPrepared.DecodeFrom(d, maxDepth) n += nTmp if err != nil { - return n, fmt.Errorf("decoding Uint32: %s", err) + return n, fmt.Errorf("decoding Uint32: %w", err) } - nTmp, err = s.NCommit.DecodeFrom(d) + nTmp, err = s.NCommit.DecodeFrom(d, maxDepth) n += nTmp if err != nil { - return n, fmt.Errorf("decoding Uint32: %s", err) + return n, fmt.Errorf("decoding Uint32: %w", err) } - nTmp, err = s.NH.DecodeFrom(d) + nTmp, err = s.NH.DecodeFrom(d, maxDepth) n += nTmp if err != nil { - return n, fmt.Errorf("decoding Uint32: %s", err) + return n, fmt.Errorf("decoding Uint32: %w", err) } - nTmp, err = s.QuorumSetHash.DecodeFrom(d) + nTmp, err = s.QuorumSetHash.DecodeFrom(d, maxDepth) n += nTmp if err != nil { - return n, fmt.Errorf("decoding Hash: %s", err) + return n, fmt.Errorf("decoding Hash: %w", err) } return n, nil } @@ -628,7 +655,7 @@ func (s ScpStatementConfirm) MarshalBinary() ([]byte, error) { func (s *ScpStatementConfirm) UnmarshalBinary(inp []byte) error { r := bytes.NewReader(inp) d := xdr.NewDecoder(r) - _, err := s.DecodeFrom(d) + _, err := s.DecodeFrom(d, xdr.DecodeDefaultMaxDepth) return err } @@ -675,23 +702,27 @@ func (s *ScpStatementExternalize) EncodeTo(e *xdr.Encoder) error { var _ decoderFrom = (*ScpStatementExternalize)(nil) // DecodeFrom decodes this value using the Decoder. -func (s *ScpStatementExternalize) DecodeFrom(d *xdr.Decoder) (int, error) { +func (s *ScpStatementExternalize) DecodeFrom(d *xdr.Decoder, maxDepth uint) (int, error) { + if maxDepth == 0 { + return 0, fmt.Errorf("decoding ScpStatementExternalize: %w", ErrMaxDecodingDepthReached) + } + maxDepth -= 1 var err error var n, nTmp int - nTmp, err = s.Commit.DecodeFrom(d) + nTmp, err = s.Commit.DecodeFrom(d, maxDepth) n += nTmp if err != nil { - return n, fmt.Errorf("decoding ScpBallot: %s", err) + return n, fmt.Errorf("decoding ScpBallot: %w", err) } - nTmp, err = s.NH.DecodeFrom(d) + nTmp, err = s.NH.DecodeFrom(d, maxDepth) n += nTmp if err != nil { - return n, fmt.Errorf("decoding Uint32: %s", err) + return n, fmt.Errorf("decoding Uint32: %w", err) } - nTmp, err = s.CommitQuorumSetHash.DecodeFrom(d) + nTmp, err = s.CommitQuorumSetHash.DecodeFrom(d, maxDepth) n += nTmp if err != nil { - return n, fmt.Errorf("decoding Hash: %s", err) + return n, fmt.Errorf("decoding Hash: %w", err) } return n, nil } @@ -708,7 +739,7 @@ func (s ScpStatementExternalize) MarshalBinary() ([]byte, error) { func (s *ScpStatementExternalize) UnmarshalBinary(inp []byte) error { r := bytes.NewReader(inp) d := xdr.NewDecoder(r) - _, err := s.DecodeFrom(d) + _, err := s.DecodeFrom(d, xdr.DecodeDefaultMaxDepth) return err } @@ -793,28 +824,28 @@ func NewScpStatementPledges(aType ScpStatementType, value interface{}) (result S case ScpStatementTypeScpStPrepare: tv, ok := value.(ScpStatementPrepare) if !ok { - err = fmt.Errorf("invalid value, must be ScpStatementPrepare") + err = errors.New("invalid value, must be ScpStatementPrepare") return } result.Prepare = &tv case ScpStatementTypeScpStConfirm: tv, ok := value.(ScpStatementConfirm) if !ok { - err = fmt.Errorf("invalid value, must be ScpStatementConfirm") + err = errors.New("invalid value, must be ScpStatementConfirm") return } result.Confirm = &tv case ScpStatementTypeScpStExternalize: tv, ok := value.(ScpStatementExternalize) if !ok { - err = fmt.Errorf("invalid value, must be ScpStatementExternalize") + err = errors.New("invalid value, must be ScpStatementExternalize") return } result.Externalize = &tv case ScpStatementTypeScpStNominate: tv, ok := value.(ScpNomination) if !ok { - err = fmt.Errorf("invalid value, must be ScpNomination") + err = errors.New("invalid value, must be ScpNomination") return } result.Nominate = &tv @@ -956,45 +987,49 @@ func (u ScpStatementPledges) EncodeTo(e *xdr.Encoder) error { var _ decoderFrom = (*ScpStatementPledges)(nil) // DecodeFrom decodes this value using the Decoder. -func (u *ScpStatementPledges) DecodeFrom(d *xdr.Decoder) (int, error) { +func (u *ScpStatementPledges) DecodeFrom(d *xdr.Decoder, maxDepth uint) (int, error) { + if maxDepth == 0 { + return 0, fmt.Errorf("decoding ScpStatementPledges: %w", ErrMaxDecodingDepthReached) + } + maxDepth -= 1 var err error var n, nTmp int - nTmp, err = u.Type.DecodeFrom(d) + nTmp, err = u.Type.DecodeFrom(d, maxDepth) n += nTmp if err != nil { - return n, fmt.Errorf("decoding ScpStatementType: %s", err) + return n, fmt.Errorf("decoding ScpStatementType: %w", err) } switch ScpStatementType(u.Type) { case ScpStatementTypeScpStPrepare: u.Prepare = new(ScpStatementPrepare) - nTmp, err = (*u.Prepare).DecodeFrom(d) + nTmp, err = (*u.Prepare).DecodeFrom(d, maxDepth) n += nTmp if err != nil { - return n, fmt.Errorf("decoding ScpStatementPrepare: %s", err) + return n, fmt.Errorf("decoding ScpStatementPrepare: %w", err) } return n, nil case ScpStatementTypeScpStConfirm: u.Confirm = new(ScpStatementConfirm) - nTmp, err = (*u.Confirm).DecodeFrom(d) + nTmp, err = (*u.Confirm).DecodeFrom(d, maxDepth) n += nTmp if err != nil { - return n, fmt.Errorf("decoding ScpStatementConfirm: %s", err) + return n, fmt.Errorf("decoding ScpStatementConfirm: %w", err) } return n, nil case ScpStatementTypeScpStExternalize: u.Externalize = new(ScpStatementExternalize) - nTmp, err = (*u.Externalize).DecodeFrom(d) + nTmp, err = (*u.Externalize).DecodeFrom(d, maxDepth) n += nTmp if err != nil { - return n, fmt.Errorf("decoding ScpStatementExternalize: %s", err) + return n, fmt.Errorf("decoding ScpStatementExternalize: %w", err) } return n, nil case ScpStatementTypeScpStNominate: u.Nominate = new(ScpNomination) - nTmp, err = (*u.Nominate).DecodeFrom(d) + nTmp, err = (*u.Nominate).DecodeFrom(d, maxDepth) n += nTmp if err != nil { - return n, fmt.Errorf("decoding ScpNomination: %s", err) + return n, fmt.Errorf("decoding ScpNomination: %w", err) } return n, nil } @@ -1013,7 +1048,7 @@ func (s ScpStatementPledges) MarshalBinary() ([]byte, error) { func (s *ScpStatementPledges) UnmarshalBinary(inp []byte) error { r := bytes.NewReader(inp) d := xdr.NewDecoder(r) - _, err := s.DecodeFrom(d) + _, err := s.DecodeFrom(d, xdr.DecodeDefaultMaxDepth) return err } @@ -1092,23 +1127,27 @@ func (s *ScpStatement) EncodeTo(e *xdr.Encoder) error { var _ decoderFrom = (*ScpStatement)(nil) // DecodeFrom decodes this value using the Decoder. -func (s *ScpStatement) DecodeFrom(d *xdr.Decoder) (int, error) { +func (s *ScpStatement) DecodeFrom(d *xdr.Decoder, maxDepth uint) (int, error) { + if maxDepth == 0 { + return 0, fmt.Errorf("decoding ScpStatement: %w", ErrMaxDecodingDepthReached) + } + maxDepth -= 1 var err error var n, nTmp int - nTmp, err = s.NodeId.DecodeFrom(d) + nTmp, err = s.NodeId.DecodeFrom(d, maxDepth) n += nTmp if err != nil { - return n, fmt.Errorf("decoding NodeId: %s", err) + return n, fmt.Errorf("decoding NodeId: %w", err) } - nTmp, err = s.SlotIndex.DecodeFrom(d) + nTmp, err = s.SlotIndex.DecodeFrom(d, maxDepth) n += nTmp if err != nil { - return n, fmt.Errorf("decoding Uint64: %s", err) + return n, fmt.Errorf("decoding Uint64: %w", err) } - nTmp, err = s.Pledges.DecodeFrom(d) + nTmp, err = s.Pledges.DecodeFrom(d, maxDepth) n += nTmp if err != nil { - return n, fmt.Errorf("decoding ScpStatementPledges: %s", err) + return n, fmt.Errorf("decoding ScpStatementPledges: %w", err) } return n, nil } @@ -1125,7 +1164,7 @@ func (s ScpStatement) MarshalBinary() ([]byte, error) { func (s *ScpStatement) UnmarshalBinary(inp []byte) error { r := bytes.NewReader(inp) d := xdr.NewDecoder(r) - _, err := s.DecodeFrom(d) + _, err := s.DecodeFrom(d, xdr.DecodeDefaultMaxDepth) return err } @@ -1167,18 +1206,22 @@ func (s *ScpEnvelope) EncodeTo(e *xdr.Encoder) error { var _ decoderFrom = (*ScpEnvelope)(nil) // DecodeFrom decodes this value using the Decoder. -func (s *ScpEnvelope) DecodeFrom(d *xdr.Decoder) (int, error) { +func (s *ScpEnvelope) DecodeFrom(d *xdr.Decoder, maxDepth uint) (int, error) { + if maxDepth == 0 { + return 0, fmt.Errorf("decoding ScpEnvelope: %w", ErrMaxDecodingDepthReached) + } + maxDepth -= 1 var err error var n, nTmp int - nTmp, err = s.Statement.DecodeFrom(d) + nTmp, err = s.Statement.DecodeFrom(d, maxDepth) n += nTmp if err != nil { - return n, fmt.Errorf("decoding ScpStatement: %s", err) + return n, fmt.Errorf("decoding ScpStatement: %w", err) } - nTmp, err = s.Signature.DecodeFrom(d) + nTmp, err = s.Signature.DecodeFrom(d, maxDepth) n += nTmp if err != nil { - return n, fmt.Errorf("decoding Signature: %s", err) + return n, fmt.Errorf("decoding Signature: %w", err) } return n, nil } @@ -1195,7 +1238,7 @@ func (s ScpEnvelope) MarshalBinary() ([]byte, error) { func (s *ScpEnvelope) UnmarshalBinary(inp []byte) error { r := bytes.NewReader(inp) d := xdr.NewDecoder(r) - _, err := s.DecodeFrom(d) + _, err := s.DecodeFrom(d, xdr.DecodeDefaultMaxDepth) return err } @@ -1252,44 +1295,48 @@ func (s *ScpQuorumSet) EncodeTo(e *xdr.Encoder) error { var _ decoderFrom = (*ScpQuorumSet)(nil) // DecodeFrom decodes this value using the Decoder. -func (s *ScpQuorumSet) DecodeFrom(d *xdr.Decoder) (int, error) { +func (s *ScpQuorumSet) DecodeFrom(d *xdr.Decoder, maxDepth uint) (int, error) { + if maxDepth == 0 { + return 0, fmt.Errorf("decoding ScpQuorumSet: %w", ErrMaxDecodingDepthReached) + } + maxDepth -= 1 var err error var n, nTmp int - nTmp, err = s.Threshold.DecodeFrom(d) + nTmp, err = s.Threshold.DecodeFrom(d, maxDepth) n += nTmp if err != nil { - return n, fmt.Errorf("decoding Uint32: %s", err) + return n, fmt.Errorf("decoding Uint32: %w", err) } var l uint32 l, nTmp, err = d.DecodeUint() n += nTmp if err != nil { - return n, fmt.Errorf("decoding NodeId: %s", err) + return n, fmt.Errorf("decoding NodeId: %w", err) } s.Validators = nil if l > 0 { s.Validators = make([]NodeId, l) for i := uint32(0); i < l; i++ { - nTmp, err = s.Validators[i].DecodeFrom(d) + nTmp, err = s.Validators[i].DecodeFrom(d, maxDepth) n += nTmp if err != nil { - return n, fmt.Errorf("decoding NodeId: %s", err) + return n, fmt.Errorf("decoding NodeId: %w", err) } } } l, nTmp, err = d.DecodeUint() n += nTmp if err != nil { - return n, fmt.Errorf("decoding ScpQuorumSet: %s", err) + return n, fmt.Errorf("decoding ScpQuorumSet: %w", err) } s.InnerSets = nil if l > 0 { s.InnerSets = make([]ScpQuorumSet, l) for i := uint32(0); i < l; i++ { - nTmp, err = s.InnerSets[i].DecodeFrom(d) + nTmp, err = s.InnerSets[i].DecodeFrom(d, maxDepth) n += nTmp if err != nil { - return n, fmt.Errorf("decoding ScpQuorumSet: %s", err) + return n, fmt.Errorf("decoding ScpQuorumSet: %w", err) } } } @@ -1308,7 +1355,7 @@ func (s ScpQuorumSet) MarshalBinary() ([]byte, error) { func (s *ScpQuorumSet) UnmarshalBinary(inp []byte) error { r := bytes.NewReader(inp) d := xdr.NewDecoder(r) - _, err := s.DecodeFrom(d) + _, err := s.DecodeFrom(d, xdr.DecodeDefaultMaxDepth) return err } @@ -1345,13 +1392,17 @@ func (s *Thresholds) EncodeTo(e *xdr.Encoder) error { var _ decoderFrom = (*Thresholds)(nil) // DecodeFrom decodes this value using the Decoder. -func (s *Thresholds) DecodeFrom(d *xdr.Decoder) (int, error) { +func (s *Thresholds) DecodeFrom(d *xdr.Decoder, maxDepth uint) (int, error) { + if maxDepth == 0 { + return 0, fmt.Errorf("decoding Thresholds: %w", ErrMaxDecodingDepthReached) + } + maxDepth -= 1 var err error var n, nTmp int nTmp, err = d.DecodeFixedOpaqueInplace(s[:]) n += nTmp if err != nil { - return n, fmt.Errorf("decoding Thresholds: %s", err) + return n, fmt.Errorf("decoding Thresholds: %w", err) } return n, nil } @@ -1368,7 +1419,7 @@ func (s Thresholds) MarshalBinary() ([]byte, error) { func (s *Thresholds) UnmarshalBinary(inp []byte) error { r := bytes.NewReader(inp) d := xdr.NewDecoder(r) - _, err := s.DecodeFrom(d) + _, err := s.DecodeFrom(d, xdr.DecodeDefaultMaxDepth) return err } @@ -1405,14 +1456,18 @@ func (s String32) EncodeTo(e *xdr.Encoder) error { var _ decoderFrom = (*String32)(nil) // DecodeFrom decodes this value using the Decoder. -func (s *String32) DecodeFrom(d *xdr.Decoder) (int, error) { +func (s *String32) DecodeFrom(d *xdr.Decoder, maxDepth uint) (int, error) { + if maxDepth == 0 { + return 0, fmt.Errorf("decoding String32: %w", ErrMaxDecodingDepthReached) + } + maxDepth -= 1 var err error var n, nTmp int var v string v, nTmp, err = d.DecodeString(32) n += nTmp if err != nil { - return n, fmt.Errorf("decoding String32: %s", err) + return n, fmt.Errorf("decoding String32: %w", err) } *s = String32(v) return n, nil @@ -1430,7 +1485,7 @@ func (s String32) MarshalBinary() ([]byte, error) { func (s *String32) UnmarshalBinary(inp []byte) error { r := bytes.NewReader(inp) d := xdr.NewDecoder(r) - _, err := s.DecodeFrom(d) + _, err := s.DecodeFrom(d, xdr.DecodeDefaultMaxDepth) return err } @@ -1467,14 +1522,18 @@ func (s String64) EncodeTo(e *xdr.Encoder) error { var _ decoderFrom = (*String64)(nil) // DecodeFrom decodes this value using the Decoder. -func (s *String64) DecodeFrom(d *xdr.Decoder) (int, error) { +func (s *String64) DecodeFrom(d *xdr.Decoder, maxDepth uint) (int, error) { + if maxDepth == 0 { + return 0, fmt.Errorf("decoding String64: %w", ErrMaxDecodingDepthReached) + } + maxDepth -= 1 var err error var n, nTmp int var v string v, nTmp, err = d.DecodeString(64) n += nTmp if err != nil { - return n, fmt.Errorf("decoding String64: %s", err) + return n, fmt.Errorf("decoding String64: %w", err) } *s = String64(v) return n, nil @@ -1492,7 +1551,7 @@ func (s String64) MarshalBinary() ([]byte, error) { func (s *String64) UnmarshalBinary(inp []byte) error { r := bytes.NewReader(inp) d := xdr.NewDecoder(r) - _, err := s.DecodeFrom(d) + _, err := s.DecodeFrom(d, xdr.DecodeDefaultMaxDepth) return err } @@ -1524,13 +1583,17 @@ func (s SequenceNumber) EncodeTo(e *xdr.Encoder) error { var _ decoderFrom = (*SequenceNumber)(nil) // DecodeFrom decodes this value using the Decoder. -func (s *SequenceNumber) DecodeFrom(d *xdr.Decoder) (int, error) { +func (s *SequenceNumber) DecodeFrom(d *xdr.Decoder, maxDepth uint) (int, error) { + if maxDepth == 0 { + return 0, fmt.Errorf("decoding SequenceNumber: %w", ErrMaxDecodingDepthReached) + } + maxDepth -= 1 var err error var n, nTmp int - nTmp, err = (*Int64)(s).DecodeFrom(d) + nTmp, err = (*Int64)(s).DecodeFrom(d, maxDepth) n += nTmp if err != nil { - return n, fmt.Errorf("decoding Int64: %s", err) + return n, fmt.Errorf("decoding Int64: %w", err) } return n, nil } @@ -1547,7 +1610,7 @@ func (s SequenceNumber) MarshalBinary() ([]byte, error) { func (s *SequenceNumber) UnmarshalBinary(inp []byte) error { r := bytes.NewReader(inp) d := xdr.NewDecoder(r) - _, err := s.DecodeFrom(d) + _, err := s.DecodeFrom(d, xdr.DecodeDefaultMaxDepth) return err } @@ -1584,13 +1647,17 @@ func (s DataValue) EncodeTo(e *xdr.Encoder) error { var _ decoderFrom = (*DataValue)(nil) // DecodeFrom decodes this value using the Decoder. -func (s *DataValue) DecodeFrom(d *xdr.Decoder) (int, error) { +func (s *DataValue) DecodeFrom(d *xdr.Decoder, maxDepth uint) (int, error) { + if maxDepth == 0 { + return 0, fmt.Errorf("decoding DataValue: %w", ErrMaxDecodingDepthReached) + } + maxDepth -= 1 var err error var n, nTmp int (*s), nTmp, err = d.DecodeOpaque(64) n += nTmp if err != nil { - return n, fmt.Errorf("decoding DataValue: %s", err) + return n, fmt.Errorf("decoding DataValue: %w", err) } return n, nil } @@ -1607,7 +1674,7 @@ func (s DataValue) MarshalBinary() ([]byte, error) { func (s *DataValue) UnmarshalBinary(inp []byte) error { r := bytes.NewReader(inp) d := xdr.NewDecoder(r) - _, err := s.DecodeFrom(d) + _, err := s.DecodeFrom(d, xdr.DecodeDefaultMaxDepth) return err } @@ -1639,13 +1706,17 @@ func (s *PoolId) EncodeTo(e *xdr.Encoder) error { var _ decoderFrom = (*PoolId)(nil) // DecodeFrom decodes this value using the Decoder. -func (s *PoolId) DecodeFrom(d *xdr.Decoder) (int, error) { +func (s *PoolId) DecodeFrom(d *xdr.Decoder, maxDepth uint) (int, error) { + if maxDepth == 0 { + return 0, fmt.Errorf("decoding PoolId: %w", ErrMaxDecodingDepthReached) + } + maxDepth -= 1 var err error var n, nTmp int - nTmp, err = (*Hash)(s).DecodeFrom(d) + nTmp, err = (*Hash)(s).DecodeFrom(d, maxDepth) n += nTmp if err != nil { - return n, fmt.Errorf("decoding Hash: %s", err) + return n, fmt.Errorf("decoding Hash: %w", err) } return n, nil } @@ -1662,7 +1733,7 @@ func (s PoolId) MarshalBinary() ([]byte, error) { func (s *PoolId) UnmarshalBinary(inp []byte) error { r := bytes.NewReader(inp) d := xdr.NewDecoder(r) - _, err := s.DecodeFrom(d) + _, err := s.DecodeFrom(d, xdr.DecodeDefaultMaxDepth) return err } @@ -1699,13 +1770,17 @@ func (s *AssetCode4) EncodeTo(e *xdr.Encoder) error { var _ decoderFrom = (*AssetCode4)(nil) // DecodeFrom decodes this value using the Decoder. -func (s *AssetCode4) DecodeFrom(d *xdr.Decoder) (int, error) { +func (s *AssetCode4) DecodeFrom(d *xdr.Decoder, maxDepth uint) (int, error) { + if maxDepth == 0 { + return 0, fmt.Errorf("decoding AssetCode4: %w", ErrMaxDecodingDepthReached) + } + maxDepth -= 1 var err error var n, nTmp int nTmp, err = d.DecodeFixedOpaqueInplace(s[:]) n += nTmp if err != nil { - return n, fmt.Errorf("decoding AssetCode4: %s", err) + return n, fmt.Errorf("decoding AssetCode4: %w", err) } return n, nil } @@ -1722,7 +1797,7 @@ func (s AssetCode4) MarshalBinary() ([]byte, error) { func (s *AssetCode4) UnmarshalBinary(inp []byte) error { r := bytes.NewReader(inp) d := xdr.NewDecoder(r) - _, err := s.DecodeFrom(d) + _, err := s.DecodeFrom(d, xdr.DecodeDefaultMaxDepth) return err } @@ -1759,13 +1834,17 @@ func (s *AssetCode12) EncodeTo(e *xdr.Encoder) error { var _ decoderFrom = (*AssetCode12)(nil) // DecodeFrom decodes this value using the Decoder. -func (s *AssetCode12) DecodeFrom(d *xdr.Decoder) (int, error) { +func (s *AssetCode12) DecodeFrom(d *xdr.Decoder, maxDepth uint) (int, error) { + if maxDepth == 0 { + return 0, fmt.Errorf("decoding AssetCode12: %w", ErrMaxDecodingDepthReached) + } + maxDepth -= 1 var err error var n, nTmp int nTmp, err = d.DecodeFixedOpaqueInplace(s[:]) n += nTmp if err != nil { - return n, fmt.Errorf("decoding AssetCode12: %s", err) + return n, fmt.Errorf("decoding AssetCode12: %w", err) } return n, nil } @@ -1782,7 +1861,7 @@ func (s AssetCode12) MarshalBinary() ([]byte, error) { func (s *AssetCode12) UnmarshalBinary(inp []byte) error { r := bytes.NewReader(inp) d := xdr.NewDecoder(r) - _, err := s.DecodeFrom(d) + _, err := s.DecodeFrom(d, xdr.DecodeDefaultMaxDepth) return err } @@ -1847,10 +1926,14 @@ func (e AssetType) EncodeTo(enc *xdr.Encoder) error { var _ decoderFrom = (*AssetType)(nil) // DecodeFrom decodes this value using the Decoder. -func (e *AssetType) DecodeFrom(d *xdr.Decoder) (int, error) { +func (e *AssetType) DecodeFrom(d *xdr.Decoder, maxDepth uint) (int, error) { + if maxDepth == 0 { + return 0, fmt.Errorf("decoding AssetType: %w", ErrMaxDecodingDepthReached) + } + maxDepth -= 1 v, n, err := d.DecodeInt() if err != nil { - return n, fmt.Errorf("decoding AssetType: %s", err) + return n, fmt.Errorf("decoding AssetType: %w", err) } if _, ok := assetTypeMap[v]; !ok { return n, fmt.Errorf("'%d' is not a valid AssetType enum value", v) @@ -1871,7 +1954,7 @@ func (s AssetType) MarshalBinary() ([]byte, error) { func (s *AssetType) UnmarshalBinary(inp []byte) error { r := bytes.NewReader(inp) d := xdr.NewDecoder(r) - _, err := s.DecodeFrom(d) + _, err := s.DecodeFrom(d, xdr.DecodeDefaultMaxDepth) return err } @@ -1929,14 +2012,14 @@ func NewAssetCode(aType AssetType, value interface{}) (result AssetCode, err err case AssetTypeAssetTypeCreditAlphanum4: tv, ok := value.(AssetCode4) if !ok { - err = fmt.Errorf("invalid value, must be AssetCode4") + err = errors.New("invalid value, must be AssetCode4") return } result.AssetCode4 = &tv case AssetTypeAssetTypeCreditAlphanum12: tv, ok := value.(AssetCode12) if !ok { - err = fmt.Errorf("invalid value, must be AssetCode12") + err = errors.New("invalid value, must be AssetCode12") return } result.AssetCode12 = &tv @@ -2018,29 +2101,33 @@ func (u AssetCode) EncodeTo(e *xdr.Encoder) error { var _ decoderFrom = (*AssetCode)(nil) // DecodeFrom decodes this value using the Decoder. -func (u *AssetCode) DecodeFrom(d *xdr.Decoder) (int, error) { +func (u *AssetCode) DecodeFrom(d *xdr.Decoder, maxDepth uint) (int, error) { + if maxDepth == 0 { + return 0, fmt.Errorf("decoding AssetCode: %w", ErrMaxDecodingDepthReached) + } + maxDepth -= 1 var err error var n, nTmp int - nTmp, err = u.Type.DecodeFrom(d) + nTmp, err = u.Type.DecodeFrom(d, maxDepth) n += nTmp if err != nil { - return n, fmt.Errorf("decoding AssetType: %s", err) + return n, fmt.Errorf("decoding AssetType: %w", err) } switch AssetType(u.Type) { case AssetTypeAssetTypeCreditAlphanum4: u.AssetCode4 = new(AssetCode4) - nTmp, err = (*u.AssetCode4).DecodeFrom(d) + nTmp, err = (*u.AssetCode4).DecodeFrom(d, maxDepth) n += nTmp if err != nil { - return n, fmt.Errorf("decoding AssetCode4: %s", err) + return n, fmt.Errorf("decoding AssetCode4: %w", err) } return n, nil case AssetTypeAssetTypeCreditAlphanum12: u.AssetCode12 = new(AssetCode12) - nTmp, err = (*u.AssetCode12).DecodeFrom(d) + nTmp, err = (*u.AssetCode12).DecodeFrom(d, maxDepth) n += nTmp if err != nil { - return n, fmt.Errorf("decoding AssetCode12: %s", err) + return n, fmt.Errorf("decoding AssetCode12: %w", err) } return n, nil } @@ -2059,7 +2146,7 @@ func (s AssetCode) MarshalBinary() ([]byte, error) { func (s *AssetCode) UnmarshalBinary(inp []byte) error { r := bytes.NewReader(inp) d := xdr.NewDecoder(r) - _, err := s.DecodeFrom(d) + _, err := s.DecodeFrom(d, xdr.DecodeDefaultMaxDepth) return err } @@ -2101,18 +2188,22 @@ func (s *AlphaNum4) EncodeTo(e *xdr.Encoder) error { var _ decoderFrom = (*AlphaNum4)(nil) // DecodeFrom decodes this value using the Decoder. -func (s *AlphaNum4) DecodeFrom(d *xdr.Decoder) (int, error) { +func (s *AlphaNum4) DecodeFrom(d *xdr.Decoder, maxDepth uint) (int, error) { + if maxDepth == 0 { + return 0, fmt.Errorf("decoding AlphaNum4: %w", ErrMaxDecodingDepthReached) + } + maxDepth -= 1 var err error var n, nTmp int - nTmp, err = s.AssetCode.DecodeFrom(d) + nTmp, err = s.AssetCode.DecodeFrom(d, maxDepth) n += nTmp if err != nil { - return n, fmt.Errorf("decoding AssetCode4: %s", err) + return n, fmt.Errorf("decoding AssetCode4: %w", err) } - nTmp, err = s.Issuer.DecodeFrom(d) + nTmp, err = s.Issuer.DecodeFrom(d, maxDepth) n += nTmp if err != nil { - return n, fmt.Errorf("decoding AccountId: %s", err) + return n, fmt.Errorf("decoding AccountId: %w", err) } return n, nil } @@ -2129,7 +2220,7 @@ func (s AlphaNum4) MarshalBinary() ([]byte, error) { func (s *AlphaNum4) UnmarshalBinary(inp []byte) error { r := bytes.NewReader(inp) d := xdr.NewDecoder(r) - _, err := s.DecodeFrom(d) + _, err := s.DecodeFrom(d, xdr.DecodeDefaultMaxDepth) return err } @@ -2171,18 +2262,22 @@ func (s *AlphaNum12) EncodeTo(e *xdr.Encoder) error { var _ decoderFrom = (*AlphaNum12)(nil) // DecodeFrom decodes this value using the Decoder. -func (s *AlphaNum12) DecodeFrom(d *xdr.Decoder) (int, error) { +func (s *AlphaNum12) DecodeFrom(d *xdr.Decoder, maxDepth uint) (int, error) { + if maxDepth == 0 { + return 0, fmt.Errorf("decoding AlphaNum12: %w", ErrMaxDecodingDepthReached) + } + maxDepth -= 1 var err error var n, nTmp int - nTmp, err = s.AssetCode.DecodeFrom(d) + nTmp, err = s.AssetCode.DecodeFrom(d, maxDepth) n += nTmp if err != nil { - return n, fmt.Errorf("decoding AssetCode12: %s", err) + return n, fmt.Errorf("decoding AssetCode12: %w", err) } - nTmp, err = s.Issuer.DecodeFrom(d) + nTmp, err = s.Issuer.DecodeFrom(d, maxDepth) n += nTmp if err != nil { - return n, fmt.Errorf("decoding AccountId: %s", err) + return n, fmt.Errorf("decoding AccountId: %w", err) } return n, nil } @@ -2199,7 +2294,7 @@ func (s AlphaNum12) MarshalBinary() ([]byte, error) { func (s *AlphaNum12) UnmarshalBinary(inp []byte) error { r := bytes.NewReader(inp) d := xdr.NewDecoder(r) - _, err := s.DecodeFrom(d) + _, err := s.DecodeFrom(d, xdr.DecodeDefaultMaxDepth) return err } @@ -2264,14 +2359,14 @@ func NewAsset(aType AssetType, value interface{}) (result Asset, err error) { case AssetTypeAssetTypeCreditAlphanum4: tv, ok := value.(AlphaNum4) if !ok { - err = fmt.Errorf("invalid value, must be AlphaNum4") + err = errors.New("invalid value, must be AlphaNum4") return } result.AlphaNum4 = &tv case AssetTypeAssetTypeCreditAlphanum12: tv, ok := value.(AlphaNum12) if !ok { - err = fmt.Errorf("invalid value, must be AlphaNum12") + err = errors.New("invalid value, must be AlphaNum12") return } result.AlphaNum12 = &tv @@ -2356,13 +2451,17 @@ func (u Asset) EncodeTo(e *xdr.Encoder) error { var _ decoderFrom = (*Asset)(nil) // DecodeFrom decodes this value using the Decoder. -func (u *Asset) DecodeFrom(d *xdr.Decoder) (int, error) { +func (u *Asset) DecodeFrom(d *xdr.Decoder, maxDepth uint) (int, error) { + if maxDepth == 0 { + return 0, fmt.Errorf("decoding Asset: %w", ErrMaxDecodingDepthReached) + } + maxDepth -= 1 var err error var n, nTmp int - nTmp, err = u.Type.DecodeFrom(d) + nTmp, err = u.Type.DecodeFrom(d, maxDepth) n += nTmp if err != nil { - return n, fmt.Errorf("decoding AssetType: %s", err) + return n, fmt.Errorf("decoding AssetType: %w", err) } switch AssetType(u.Type) { case AssetTypeAssetTypeNative: @@ -2370,18 +2469,18 @@ func (u *Asset) DecodeFrom(d *xdr.Decoder) (int, error) { return n, nil case AssetTypeAssetTypeCreditAlphanum4: u.AlphaNum4 = new(AlphaNum4) - nTmp, err = (*u.AlphaNum4).DecodeFrom(d) + nTmp, err = (*u.AlphaNum4).DecodeFrom(d, maxDepth) n += nTmp if err != nil { - return n, fmt.Errorf("decoding AlphaNum4: %s", err) + return n, fmt.Errorf("decoding AlphaNum4: %w", err) } return n, nil case AssetTypeAssetTypeCreditAlphanum12: u.AlphaNum12 = new(AlphaNum12) - nTmp, err = (*u.AlphaNum12).DecodeFrom(d) + nTmp, err = (*u.AlphaNum12).DecodeFrom(d, maxDepth) n += nTmp if err != nil { - return n, fmt.Errorf("decoding AlphaNum12: %s", err) + return n, fmt.Errorf("decoding AlphaNum12: %w", err) } return n, nil } @@ -2400,7 +2499,7 @@ func (s Asset) MarshalBinary() ([]byte, error) { func (s *Asset) UnmarshalBinary(inp []byte) error { r := bytes.NewReader(inp) d := xdr.NewDecoder(r) - _, err := s.DecodeFrom(d) + _, err := s.DecodeFrom(d, xdr.DecodeDefaultMaxDepth) return err } @@ -2442,18 +2541,22 @@ func (s *Price) EncodeTo(e *xdr.Encoder) error { var _ decoderFrom = (*Price)(nil) // DecodeFrom decodes this value using the Decoder. -func (s *Price) DecodeFrom(d *xdr.Decoder) (int, error) { +func (s *Price) DecodeFrom(d *xdr.Decoder, maxDepth uint) (int, error) { + if maxDepth == 0 { + return 0, fmt.Errorf("decoding Price: %w", ErrMaxDecodingDepthReached) + } + maxDepth -= 1 var err error var n, nTmp int - nTmp, err = s.N.DecodeFrom(d) + nTmp, err = s.N.DecodeFrom(d, maxDepth) n += nTmp if err != nil { - return n, fmt.Errorf("decoding Int32: %s", err) + return n, fmt.Errorf("decoding Int32: %w", err) } - nTmp, err = s.D.DecodeFrom(d) + nTmp, err = s.D.DecodeFrom(d, maxDepth) n += nTmp if err != nil { - return n, fmt.Errorf("decoding Int32: %s", err) + return n, fmt.Errorf("decoding Int32: %w", err) } return n, nil } @@ -2470,7 +2573,7 @@ func (s Price) MarshalBinary() ([]byte, error) { func (s *Price) UnmarshalBinary(inp []byte) error { r := bytes.NewReader(inp) d := xdr.NewDecoder(r) - _, err := s.DecodeFrom(d) + _, err := s.DecodeFrom(d, xdr.DecodeDefaultMaxDepth) return err } @@ -2512,18 +2615,22 @@ func (s *Liabilities) EncodeTo(e *xdr.Encoder) error { var _ decoderFrom = (*Liabilities)(nil) // DecodeFrom decodes this value using the Decoder. -func (s *Liabilities) DecodeFrom(d *xdr.Decoder) (int, error) { +func (s *Liabilities) DecodeFrom(d *xdr.Decoder, maxDepth uint) (int, error) { + if maxDepth == 0 { + return 0, fmt.Errorf("decoding Liabilities: %w", ErrMaxDecodingDepthReached) + } + maxDepth -= 1 var err error var n, nTmp int - nTmp, err = s.Buying.DecodeFrom(d) + nTmp, err = s.Buying.DecodeFrom(d, maxDepth) n += nTmp if err != nil { - return n, fmt.Errorf("decoding Int64: %s", err) + return n, fmt.Errorf("decoding Int64: %w", err) } - nTmp, err = s.Selling.DecodeFrom(d) + nTmp, err = s.Selling.DecodeFrom(d, maxDepth) n += nTmp if err != nil { - return n, fmt.Errorf("decoding Int64: %s", err) + return n, fmt.Errorf("decoding Int64: %w", err) } return n, nil } @@ -2540,7 +2647,7 @@ func (s Liabilities) MarshalBinary() ([]byte, error) { func (s *Liabilities) UnmarshalBinary(inp []byte) error { r := bytes.NewReader(inp) d := xdr.NewDecoder(r) - _, err := s.DecodeFrom(d) + _, err := s.DecodeFrom(d, xdr.DecodeDefaultMaxDepth) return err } @@ -2605,10 +2712,14 @@ func (e ThresholdIndexes) EncodeTo(enc *xdr.Encoder) error { var _ decoderFrom = (*ThresholdIndexes)(nil) // DecodeFrom decodes this value using the Decoder. -func (e *ThresholdIndexes) DecodeFrom(d *xdr.Decoder) (int, error) { +func (e *ThresholdIndexes) DecodeFrom(d *xdr.Decoder, maxDepth uint) (int, error) { + if maxDepth == 0 { + return 0, fmt.Errorf("decoding ThresholdIndexes: %w", ErrMaxDecodingDepthReached) + } + maxDepth -= 1 v, n, err := d.DecodeInt() if err != nil { - return n, fmt.Errorf("decoding ThresholdIndexes: %s", err) + return n, fmt.Errorf("decoding ThresholdIndexes: %w", err) } if _, ok := thresholdIndexesMap[v]; !ok { return n, fmt.Errorf("'%d' is not a valid ThresholdIndexes enum value", v) @@ -2629,7 +2740,7 @@ func (s ThresholdIndexes) MarshalBinary() ([]byte, error) { func (s *ThresholdIndexes) UnmarshalBinary(inp []byte) error { r := bytes.NewReader(inp) d := xdr.NewDecoder(r) - _, err := s.DecodeFrom(d) + _, err := s.DecodeFrom(d, xdr.DecodeDefaultMaxDepth) return err } @@ -2657,7 +2768,7 @@ var _ xdrType = (*ThresholdIndexes)(nil) // CONTRACT_DATA = 6, // CONTRACT_CODE = 7, // CONFIG_SETTING = 8, -// EXPIRATION = 9 +// TTL = 9 // }; type LedgerEntryType int32 @@ -2671,7 +2782,7 @@ const ( LedgerEntryTypeContractData LedgerEntryType = 6 LedgerEntryTypeContractCode LedgerEntryType = 7 LedgerEntryTypeConfigSetting LedgerEntryType = 8 - LedgerEntryTypeExpiration LedgerEntryType = 9 + LedgerEntryTypeTtl LedgerEntryType = 9 ) var ledgerEntryTypeMap = map[int32]string{ @@ -2684,7 +2795,7 @@ var ledgerEntryTypeMap = map[int32]string{ 6: "LedgerEntryTypeContractData", 7: "LedgerEntryTypeContractCode", 8: "LedgerEntryTypeConfigSetting", - 9: "LedgerEntryTypeExpiration", + 9: "LedgerEntryTypeTtl", } // ValidEnum validates a proposed value for this enum. Implements @@ -2712,10 +2823,14 @@ func (e LedgerEntryType) EncodeTo(enc *xdr.Encoder) error { var _ decoderFrom = (*LedgerEntryType)(nil) // DecodeFrom decodes this value using the Decoder. -func (e *LedgerEntryType) DecodeFrom(d *xdr.Decoder) (int, error) { +func (e *LedgerEntryType) DecodeFrom(d *xdr.Decoder, maxDepth uint) (int, error) { + if maxDepth == 0 { + return 0, fmt.Errorf("decoding LedgerEntryType: %w", ErrMaxDecodingDepthReached) + } + maxDepth -= 1 v, n, err := d.DecodeInt() if err != nil { - return n, fmt.Errorf("decoding LedgerEntryType: %s", err) + return n, fmt.Errorf("decoding LedgerEntryType: %w", err) } if _, ok := ledgerEntryTypeMap[v]; !ok { return n, fmt.Errorf("'%d' is not a valid LedgerEntryType enum value", v) @@ -2736,7 +2851,7 @@ func (s LedgerEntryType) MarshalBinary() ([]byte, error) { func (s *LedgerEntryType) UnmarshalBinary(inp []byte) error { r := bytes.NewReader(inp) d := xdr.NewDecoder(r) - _, err := s.DecodeFrom(d) + _, err := s.DecodeFrom(d, xdr.DecodeDefaultMaxDepth) return err } @@ -2778,18 +2893,22 @@ func (s *Signer) EncodeTo(e *xdr.Encoder) error { var _ decoderFrom = (*Signer)(nil) // DecodeFrom decodes this value using the Decoder. -func (s *Signer) DecodeFrom(d *xdr.Decoder) (int, error) { +func (s *Signer) DecodeFrom(d *xdr.Decoder, maxDepth uint) (int, error) { + if maxDepth == 0 { + return 0, fmt.Errorf("decoding Signer: %w", ErrMaxDecodingDepthReached) + } + maxDepth -= 1 var err error var n, nTmp int - nTmp, err = s.Key.DecodeFrom(d) + nTmp, err = s.Key.DecodeFrom(d, maxDepth) n += nTmp if err != nil { - return n, fmt.Errorf("decoding SignerKey: %s", err) + return n, fmt.Errorf("decoding SignerKey: %w", err) } - nTmp, err = s.Weight.DecodeFrom(d) + nTmp, err = s.Weight.DecodeFrom(d, maxDepth) n += nTmp if err != nil { - return n, fmt.Errorf("decoding Uint32: %s", err) + return n, fmt.Errorf("decoding Uint32: %w", err) } return n, nil } @@ -2806,7 +2925,7 @@ func (s Signer) MarshalBinary() ([]byte, error) { func (s *Signer) UnmarshalBinary(inp []byte) error { r := bytes.NewReader(inp) d := xdr.NewDecoder(r) - _, err := s.DecodeFrom(d) + _, err := s.DecodeFrom(d, xdr.DecodeDefaultMaxDepth) return err } @@ -2881,10 +3000,14 @@ func (e AccountFlags) EncodeTo(enc *xdr.Encoder) error { var _ decoderFrom = (*AccountFlags)(nil) // DecodeFrom decodes this value using the Decoder. -func (e *AccountFlags) DecodeFrom(d *xdr.Decoder) (int, error) { +func (e *AccountFlags) DecodeFrom(d *xdr.Decoder, maxDepth uint) (int, error) { + if maxDepth == 0 { + return 0, fmt.Errorf("decoding AccountFlags: %w", ErrMaxDecodingDepthReached) + } + maxDepth -= 1 v, n, err := d.DecodeInt() if err != nil { - return n, fmt.Errorf("decoding AccountFlags: %s", err) + return n, fmt.Errorf("decoding AccountFlags: %w", err) } if _, ok := accountFlagsMap[v]; !ok { return n, fmt.Errorf("'%d' is not a valid AccountFlags enum value", v) @@ -2905,7 +3028,7 @@ func (s AccountFlags) MarshalBinary() ([]byte, error) { func (s *AccountFlags) UnmarshalBinary(inp []byte) error { r := bytes.NewReader(inp) d := xdr.NewDecoder(r) - _, err := s.DecodeFrom(d) + _, err := s.DecodeFrom(d, xdr.DecodeDefaultMaxDepth) return err } @@ -2978,23 +3101,27 @@ func (s *AccountEntryExtensionV3) EncodeTo(e *xdr.Encoder) error { var _ decoderFrom = (*AccountEntryExtensionV3)(nil) // DecodeFrom decodes this value using the Decoder. -func (s *AccountEntryExtensionV3) DecodeFrom(d *xdr.Decoder) (int, error) { +func (s *AccountEntryExtensionV3) DecodeFrom(d *xdr.Decoder, maxDepth uint) (int, error) { + if maxDepth == 0 { + return 0, fmt.Errorf("decoding AccountEntryExtensionV3: %w", ErrMaxDecodingDepthReached) + } + maxDepth -= 1 var err error var n, nTmp int - nTmp, err = s.Ext.DecodeFrom(d) + nTmp, err = s.Ext.DecodeFrom(d, maxDepth) n += nTmp if err != nil { - return n, fmt.Errorf("decoding ExtensionPoint: %s", err) + return n, fmt.Errorf("decoding ExtensionPoint: %w", err) } - nTmp, err = s.SeqLedger.DecodeFrom(d) + nTmp, err = s.SeqLedger.DecodeFrom(d, maxDepth) n += nTmp if err != nil { - return n, fmt.Errorf("decoding Uint32: %s", err) + return n, fmt.Errorf("decoding Uint32: %w", err) } - nTmp, err = s.SeqTime.DecodeFrom(d) + nTmp, err = s.SeqTime.DecodeFrom(d, maxDepth) n += nTmp if err != nil { - return n, fmt.Errorf("decoding TimePoint: %s", err) + return n, fmt.Errorf("decoding TimePoint: %w", err) } return n, nil } @@ -3011,7 +3138,7 @@ func (s AccountEntryExtensionV3) MarshalBinary() ([]byte, error) { func (s *AccountEntryExtensionV3) UnmarshalBinary(inp []byte) error { r := bytes.NewReader(inp) d := xdr.NewDecoder(r) - _, err := s.DecodeFrom(d) + _, err := s.DecodeFrom(d, xdr.DecodeDefaultMaxDepth) return err } @@ -3067,7 +3194,7 @@ func NewAccountEntryExtensionV2Ext(v int32, value interface{}) (result AccountEn case 3: tv, ok := value.(AccountEntryExtensionV3) if !ok { - err = fmt.Errorf("invalid value, must be AccountEntryExtensionV3") + err = errors.New("invalid value, must be AccountEntryExtensionV3") return } result.V3 = &tv @@ -3122,13 +3249,17 @@ func (u AccountEntryExtensionV2Ext) EncodeTo(e *xdr.Encoder) error { var _ decoderFrom = (*AccountEntryExtensionV2Ext)(nil) // DecodeFrom decodes this value using the Decoder. -func (u *AccountEntryExtensionV2Ext) DecodeFrom(d *xdr.Decoder) (int, error) { +func (u *AccountEntryExtensionV2Ext) DecodeFrom(d *xdr.Decoder, maxDepth uint) (int, error) { + if maxDepth == 0 { + return 0, fmt.Errorf("decoding AccountEntryExtensionV2Ext: %w", ErrMaxDecodingDepthReached) + } + maxDepth -= 1 var err error var n, nTmp int u.V, nTmp, err = d.DecodeInt() n += nTmp if err != nil { - return n, fmt.Errorf("decoding Int: %s", err) + return n, fmt.Errorf("decoding Int: %w", err) } switch int32(u.V) { case 0: @@ -3136,10 +3267,10 @@ func (u *AccountEntryExtensionV2Ext) DecodeFrom(d *xdr.Decoder) (int, error) { return n, nil case 3: u.V3 = new(AccountEntryExtensionV3) - nTmp, err = (*u.V3).DecodeFrom(d) + nTmp, err = (*u.V3).DecodeFrom(d, maxDepth) n += nTmp if err != nil { - return n, fmt.Errorf("decoding AccountEntryExtensionV3: %s", err) + return n, fmt.Errorf("decoding AccountEntryExtensionV3: %w", err) } return n, nil } @@ -3158,7 +3289,7 @@ func (s AccountEntryExtensionV2Ext) MarshalBinary() ([]byte, error) { func (s *AccountEntryExtensionV2Ext) UnmarshalBinary(inp []byte) error { r := bytes.NewReader(inp) d := xdr.NewDecoder(r) - _, err := s.DecodeFrom(d) + _, err := s.DecodeFrom(d, xdr.DecodeDefaultMaxDepth) return err } @@ -3228,24 +3359,28 @@ func (s *AccountEntryExtensionV2) EncodeTo(e *xdr.Encoder) error { var _ decoderFrom = (*AccountEntryExtensionV2)(nil) // DecodeFrom decodes this value using the Decoder. -func (s *AccountEntryExtensionV2) DecodeFrom(d *xdr.Decoder) (int, error) { +func (s *AccountEntryExtensionV2) DecodeFrom(d *xdr.Decoder, maxDepth uint) (int, error) { + if maxDepth == 0 { + return 0, fmt.Errorf("decoding AccountEntryExtensionV2: %w", ErrMaxDecodingDepthReached) + } + maxDepth -= 1 var err error var n, nTmp int - nTmp, err = s.NumSponsored.DecodeFrom(d) + nTmp, err = s.NumSponsored.DecodeFrom(d, maxDepth) n += nTmp if err != nil { - return n, fmt.Errorf("decoding Uint32: %s", err) + return n, fmt.Errorf("decoding Uint32: %w", err) } - nTmp, err = s.NumSponsoring.DecodeFrom(d) + nTmp, err = s.NumSponsoring.DecodeFrom(d, maxDepth) n += nTmp if err != nil { - return n, fmt.Errorf("decoding Uint32: %s", err) + return n, fmt.Errorf("decoding Uint32: %w", err) } var l uint32 l, nTmp, err = d.DecodeUint() n += nTmp if err != nil { - return n, fmt.Errorf("decoding SponsorshipDescriptor: %s", err) + return n, fmt.Errorf("decoding SponsorshipDescriptor: %w", err) } if l > 20 { return n, fmt.Errorf("decoding SponsorshipDescriptor: data size (%d) exceeds size limit (20)", l) @@ -3258,23 +3393,23 @@ func (s *AccountEntryExtensionV2) DecodeFrom(d *xdr.Decoder) (int, error) { eb, nTmp, err = d.DecodeBool() n += nTmp if err != nil { - return n, fmt.Errorf("decoding SponsorshipDescriptor: %s", err) + return n, fmt.Errorf("decoding SponsorshipDescriptor: %w", err) } s.SignerSponsoringIDs[i] = nil if eb { s.SignerSponsoringIDs[i] = new(AccountId) - nTmp, err = s.SignerSponsoringIDs[i].DecodeFrom(d) + nTmp, err = s.SignerSponsoringIDs[i].DecodeFrom(d, maxDepth) n += nTmp if err != nil { - return n, fmt.Errorf("decoding SponsorshipDescriptor: %s", err) + return n, fmt.Errorf("decoding SponsorshipDescriptor: %w", err) } } } } - nTmp, err = s.Ext.DecodeFrom(d) + nTmp, err = s.Ext.DecodeFrom(d, maxDepth) n += nTmp if err != nil { - return n, fmt.Errorf("decoding AccountEntryExtensionV2Ext: %s", err) + return n, fmt.Errorf("decoding AccountEntryExtensionV2Ext: %w", err) } return n, nil } @@ -3291,7 +3426,7 @@ func (s AccountEntryExtensionV2) MarshalBinary() ([]byte, error) { func (s *AccountEntryExtensionV2) UnmarshalBinary(inp []byte) error { r := bytes.NewReader(inp) d := xdr.NewDecoder(r) - _, err := s.DecodeFrom(d) + _, err := s.DecodeFrom(d, xdr.DecodeDefaultMaxDepth) return err } @@ -3347,7 +3482,7 @@ func NewAccountEntryExtensionV1Ext(v int32, value interface{}) (result AccountEn case 2: tv, ok := value.(AccountEntryExtensionV2) if !ok { - err = fmt.Errorf("invalid value, must be AccountEntryExtensionV2") + err = errors.New("invalid value, must be AccountEntryExtensionV2") return } result.V2 = &tv @@ -3402,13 +3537,17 @@ func (u AccountEntryExtensionV1Ext) EncodeTo(e *xdr.Encoder) error { var _ decoderFrom = (*AccountEntryExtensionV1Ext)(nil) // DecodeFrom decodes this value using the Decoder. -func (u *AccountEntryExtensionV1Ext) DecodeFrom(d *xdr.Decoder) (int, error) { +func (u *AccountEntryExtensionV1Ext) DecodeFrom(d *xdr.Decoder, maxDepth uint) (int, error) { + if maxDepth == 0 { + return 0, fmt.Errorf("decoding AccountEntryExtensionV1Ext: %w", ErrMaxDecodingDepthReached) + } + maxDepth -= 1 var err error var n, nTmp int u.V, nTmp, err = d.DecodeInt() n += nTmp if err != nil { - return n, fmt.Errorf("decoding Int: %s", err) + return n, fmt.Errorf("decoding Int: %w", err) } switch int32(u.V) { case 0: @@ -3416,10 +3555,10 @@ func (u *AccountEntryExtensionV1Ext) DecodeFrom(d *xdr.Decoder) (int, error) { return n, nil case 2: u.V2 = new(AccountEntryExtensionV2) - nTmp, err = (*u.V2).DecodeFrom(d) + nTmp, err = (*u.V2).DecodeFrom(d, maxDepth) n += nTmp if err != nil { - return n, fmt.Errorf("decoding AccountEntryExtensionV2: %s", err) + return n, fmt.Errorf("decoding AccountEntryExtensionV2: %w", err) } return n, nil } @@ -3438,7 +3577,7 @@ func (s AccountEntryExtensionV1Ext) MarshalBinary() ([]byte, error) { func (s *AccountEntryExtensionV1Ext) UnmarshalBinary(inp []byte) error { r := bytes.NewReader(inp) d := xdr.NewDecoder(r) - _, err := s.DecodeFrom(d) + _, err := s.DecodeFrom(d, xdr.DecodeDefaultMaxDepth) return err } @@ -3488,18 +3627,22 @@ func (s *AccountEntryExtensionV1) EncodeTo(e *xdr.Encoder) error { var _ decoderFrom = (*AccountEntryExtensionV1)(nil) // DecodeFrom decodes this value using the Decoder. -func (s *AccountEntryExtensionV1) DecodeFrom(d *xdr.Decoder) (int, error) { +func (s *AccountEntryExtensionV1) DecodeFrom(d *xdr.Decoder, maxDepth uint) (int, error) { + if maxDepth == 0 { + return 0, fmt.Errorf("decoding AccountEntryExtensionV1: %w", ErrMaxDecodingDepthReached) + } + maxDepth -= 1 var err error var n, nTmp int - nTmp, err = s.Liabilities.DecodeFrom(d) + nTmp, err = s.Liabilities.DecodeFrom(d, maxDepth) n += nTmp if err != nil { - return n, fmt.Errorf("decoding Liabilities: %s", err) + return n, fmt.Errorf("decoding Liabilities: %w", err) } - nTmp, err = s.Ext.DecodeFrom(d) + nTmp, err = s.Ext.DecodeFrom(d, maxDepth) n += nTmp if err != nil { - return n, fmt.Errorf("decoding AccountEntryExtensionV1Ext: %s", err) + return n, fmt.Errorf("decoding AccountEntryExtensionV1Ext: %w", err) } return n, nil } @@ -3516,7 +3659,7 @@ func (s AccountEntryExtensionV1) MarshalBinary() ([]byte, error) { func (s *AccountEntryExtensionV1) UnmarshalBinary(inp []byte) error { r := bytes.NewReader(inp) d := xdr.NewDecoder(r) - _, err := s.DecodeFrom(d) + _, err := s.DecodeFrom(d, xdr.DecodeDefaultMaxDepth) return err } @@ -3572,7 +3715,7 @@ func NewAccountEntryExt(v int32, value interface{}) (result AccountEntryExt, err case 1: tv, ok := value.(AccountEntryExtensionV1) if !ok { - err = fmt.Errorf("invalid value, must be AccountEntryExtensionV1") + err = errors.New("invalid value, must be AccountEntryExtensionV1") return } result.V1 = &tv @@ -3627,13 +3770,17 @@ func (u AccountEntryExt) EncodeTo(e *xdr.Encoder) error { var _ decoderFrom = (*AccountEntryExt)(nil) // DecodeFrom decodes this value using the Decoder. -func (u *AccountEntryExt) DecodeFrom(d *xdr.Decoder) (int, error) { +func (u *AccountEntryExt) DecodeFrom(d *xdr.Decoder, maxDepth uint) (int, error) { + if maxDepth == 0 { + return 0, fmt.Errorf("decoding AccountEntryExt: %w", ErrMaxDecodingDepthReached) + } + maxDepth -= 1 var err error var n, nTmp int u.V, nTmp, err = d.DecodeInt() n += nTmp if err != nil { - return n, fmt.Errorf("decoding Int: %s", err) + return n, fmt.Errorf("decoding Int: %w", err) } switch int32(u.V) { case 0: @@ -3641,10 +3788,10 @@ func (u *AccountEntryExt) DecodeFrom(d *xdr.Decoder) (int, error) { return n, nil case 1: u.V1 = new(AccountEntryExtensionV1) - nTmp, err = (*u.V1).DecodeFrom(d) + nTmp, err = (*u.V1).DecodeFrom(d, maxDepth) n += nTmp if err != nil { - return n, fmt.Errorf("decoding AccountEntryExtensionV1: %s", err) + return n, fmt.Errorf("decoding AccountEntryExtensionV1: %w", err) } return n, nil } @@ -3663,7 +3810,7 @@ func (s AccountEntryExt) MarshalBinary() ([]byte, error) { func (s *AccountEntryExt) UnmarshalBinary(inp []byte) error { r := bytes.NewReader(inp) d := xdr.NewDecoder(r) - _, err := s.DecodeFrom(d) + _, err := s.DecodeFrom(d, xdr.DecodeDefaultMaxDepth) return err } @@ -3770,64 +3917,68 @@ func (s *AccountEntry) EncodeTo(e *xdr.Encoder) error { var _ decoderFrom = (*AccountEntry)(nil) // DecodeFrom decodes this value using the Decoder. -func (s *AccountEntry) DecodeFrom(d *xdr.Decoder) (int, error) { +func (s *AccountEntry) DecodeFrom(d *xdr.Decoder, maxDepth uint) (int, error) { + if maxDepth == 0 { + return 0, fmt.Errorf("decoding AccountEntry: %w", ErrMaxDecodingDepthReached) + } + maxDepth -= 1 var err error var n, nTmp int - nTmp, err = s.AccountId.DecodeFrom(d) + nTmp, err = s.AccountId.DecodeFrom(d, maxDepth) n += nTmp if err != nil { - return n, fmt.Errorf("decoding AccountId: %s", err) + return n, fmt.Errorf("decoding AccountId: %w", err) } - nTmp, err = s.Balance.DecodeFrom(d) + nTmp, err = s.Balance.DecodeFrom(d, maxDepth) n += nTmp if err != nil { - return n, fmt.Errorf("decoding Int64: %s", err) + return n, fmt.Errorf("decoding Int64: %w", err) } - nTmp, err = s.SeqNum.DecodeFrom(d) + nTmp, err = s.SeqNum.DecodeFrom(d, maxDepth) n += nTmp if err != nil { - return n, fmt.Errorf("decoding SequenceNumber: %s", err) + return n, fmt.Errorf("decoding SequenceNumber: %w", err) } - nTmp, err = s.NumSubEntries.DecodeFrom(d) + nTmp, err = s.NumSubEntries.DecodeFrom(d, maxDepth) n += nTmp if err != nil { - return n, fmt.Errorf("decoding Uint32: %s", err) + return n, fmt.Errorf("decoding Uint32: %w", err) } var b bool b, nTmp, err = d.DecodeBool() n += nTmp if err != nil { - return n, fmt.Errorf("decoding AccountId: %s", err) + return n, fmt.Errorf("decoding AccountId: %w", err) } s.InflationDest = nil if b { s.InflationDest = new(AccountId) - nTmp, err = s.InflationDest.DecodeFrom(d) + nTmp, err = s.InflationDest.DecodeFrom(d, maxDepth) n += nTmp if err != nil { - return n, fmt.Errorf("decoding AccountId: %s", err) + return n, fmt.Errorf("decoding AccountId: %w", err) } } - nTmp, err = s.Flags.DecodeFrom(d) + nTmp, err = s.Flags.DecodeFrom(d, maxDepth) n += nTmp if err != nil { - return n, fmt.Errorf("decoding Uint32: %s", err) + return n, fmt.Errorf("decoding Uint32: %w", err) } - nTmp, err = s.HomeDomain.DecodeFrom(d) + nTmp, err = s.HomeDomain.DecodeFrom(d, maxDepth) n += nTmp if err != nil { - return n, fmt.Errorf("decoding String32: %s", err) + return n, fmt.Errorf("decoding String32: %w", err) } - nTmp, err = s.Thresholds.DecodeFrom(d) + nTmp, err = s.Thresholds.DecodeFrom(d, maxDepth) n += nTmp if err != nil { - return n, fmt.Errorf("decoding Thresholds: %s", err) + return n, fmt.Errorf("decoding Thresholds: %w", err) } var l uint32 l, nTmp, err = d.DecodeUint() n += nTmp if err != nil { - return n, fmt.Errorf("decoding Signer: %s", err) + return n, fmt.Errorf("decoding Signer: %w", err) } if l > 20 { return n, fmt.Errorf("decoding Signer: data size (%d) exceeds size limit (20)", l) @@ -3836,17 +3987,17 @@ func (s *AccountEntry) DecodeFrom(d *xdr.Decoder) (int, error) { if l > 0 { s.Signers = make([]Signer, l) for i := uint32(0); i < l; i++ { - nTmp, err = s.Signers[i].DecodeFrom(d) + nTmp, err = s.Signers[i].DecodeFrom(d, maxDepth) n += nTmp if err != nil { - return n, fmt.Errorf("decoding Signer: %s", err) + return n, fmt.Errorf("decoding Signer: %w", err) } } } - nTmp, err = s.Ext.DecodeFrom(d) + nTmp, err = s.Ext.DecodeFrom(d, maxDepth) n += nTmp if err != nil { - return n, fmt.Errorf("decoding AccountEntryExt: %s", err) + return n, fmt.Errorf("decoding AccountEntryExt: %w", err) } return n, nil } @@ -3863,7 +4014,7 @@ func (s AccountEntry) MarshalBinary() ([]byte, error) { func (s *AccountEntry) UnmarshalBinary(inp []byte) error { r := bytes.NewReader(inp) d := xdr.NewDecoder(r) - _, err := s.DecodeFrom(d) + _, err := s.DecodeFrom(d, xdr.DecodeDefaultMaxDepth) return err } @@ -3930,10 +4081,14 @@ func (e TrustLineFlags) EncodeTo(enc *xdr.Encoder) error { var _ decoderFrom = (*TrustLineFlags)(nil) // DecodeFrom decodes this value using the Decoder. -func (e *TrustLineFlags) DecodeFrom(d *xdr.Decoder) (int, error) { +func (e *TrustLineFlags) DecodeFrom(d *xdr.Decoder, maxDepth uint) (int, error) { + if maxDepth == 0 { + return 0, fmt.Errorf("decoding TrustLineFlags: %w", ErrMaxDecodingDepthReached) + } + maxDepth -= 1 v, n, err := d.DecodeInt() if err != nil { - return n, fmt.Errorf("decoding TrustLineFlags: %s", err) + return n, fmt.Errorf("decoding TrustLineFlags: %w", err) } if _, ok := trustLineFlagsMap[v]; !ok { return n, fmt.Errorf("'%d' is not a valid TrustLineFlags enum value", v) @@ -3954,7 +4109,7 @@ func (s TrustLineFlags) MarshalBinary() ([]byte, error) { func (s *TrustLineFlags) UnmarshalBinary(inp []byte) error { r := bytes.NewReader(inp) d := xdr.NewDecoder(r) - _, err := s.DecodeFrom(d) + _, err := s.DecodeFrom(d, xdr.DecodeDefaultMaxDepth) return err } @@ -4025,10 +4180,14 @@ func (e LiquidityPoolType) EncodeTo(enc *xdr.Encoder) error { var _ decoderFrom = (*LiquidityPoolType)(nil) // DecodeFrom decodes this value using the Decoder. -func (e *LiquidityPoolType) DecodeFrom(d *xdr.Decoder) (int, error) { +func (e *LiquidityPoolType) DecodeFrom(d *xdr.Decoder, maxDepth uint) (int, error) { + if maxDepth == 0 { + return 0, fmt.Errorf("decoding LiquidityPoolType: %w", ErrMaxDecodingDepthReached) + } + maxDepth -= 1 v, n, err := d.DecodeInt() if err != nil { - return n, fmt.Errorf("decoding LiquidityPoolType: %s", err) + return n, fmt.Errorf("decoding LiquidityPoolType: %w", err) } if _, ok := liquidityPoolTypeMap[v]; !ok { return n, fmt.Errorf("'%d' is not a valid LiquidityPoolType enum value", v) @@ -4049,7 +4208,7 @@ func (s LiquidityPoolType) MarshalBinary() ([]byte, error) { func (s *LiquidityPoolType) UnmarshalBinary(inp []byte) error { r := bytes.NewReader(inp) d := xdr.NewDecoder(r) - _, err := s.DecodeFrom(d) + _, err := s.DecodeFrom(d, xdr.DecodeDefaultMaxDepth) return err } @@ -4120,21 +4279,21 @@ func NewTrustLineAsset(aType AssetType, value interface{}) (result TrustLineAsse case AssetTypeAssetTypeCreditAlphanum4: tv, ok := value.(AlphaNum4) if !ok { - err = fmt.Errorf("invalid value, must be AlphaNum4") + err = errors.New("invalid value, must be AlphaNum4") return } result.AlphaNum4 = &tv case AssetTypeAssetTypeCreditAlphanum12: tv, ok := value.(AlphaNum12) if !ok { - err = fmt.Errorf("invalid value, must be AlphaNum12") + err = errors.New("invalid value, must be AlphaNum12") return } result.AlphaNum12 = &tv case AssetTypeAssetTypePoolShare: tv, ok := value.(PoolId) if !ok { - err = fmt.Errorf("invalid value, must be PoolId") + err = errors.New("invalid value, must be PoolId") return } result.LiquidityPoolId = &tv @@ -4249,13 +4408,17 @@ func (u TrustLineAsset) EncodeTo(e *xdr.Encoder) error { var _ decoderFrom = (*TrustLineAsset)(nil) // DecodeFrom decodes this value using the Decoder. -func (u *TrustLineAsset) DecodeFrom(d *xdr.Decoder) (int, error) { +func (u *TrustLineAsset) DecodeFrom(d *xdr.Decoder, maxDepth uint) (int, error) { + if maxDepth == 0 { + return 0, fmt.Errorf("decoding TrustLineAsset: %w", ErrMaxDecodingDepthReached) + } + maxDepth -= 1 var err error var n, nTmp int - nTmp, err = u.Type.DecodeFrom(d) + nTmp, err = u.Type.DecodeFrom(d, maxDepth) n += nTmp if err != nil { - return n, fmt.Errorf("decoding AssetType: %s", err) + return n, fmt.Errorf("decoding AssetType: %w", err) } switch AssetType(u.Type) { case AssetTypeAssetTypeNative: @@ -4263,26 +4426,26 @@ func (u *TrustLineAsset) DecodeFrom(d *xdr.Decoder) (int, error) { return n, nil case AssetTypeAssetTypeCreditAlphanum4: u.AlphaNum4 = new(AlphaNum4) - nTmp, err = (*u.AlphaNum4).DecodeFrom(d) + nTmp, err = (*u.AlphaNum4).DecodeFrom(d, maxDepth) n += nTmp if err != nil { - return n, fmt.Errorf("decoding AlphaNum4: %s", err) + return n, fmt.Errorf("decoding AlphaNum4: %w", err) } return n, nil case AssetTypeAssetTypeCreditAlphanum12: u.AlphaNum12 = new(AlphaNum12) - nTmp, err = (*u.AlphaNum12).DecodeFrom(d) + nTmp, err = (*u.AlphaNum12).DecodeFrom(d, maxDepth) n += nTmp if err != nil { - return n, fmt.Errorf("decoding AlphaNum12: %s", err) + return n, fmt.Errorf("decoding AlphaNum12: %w", err) } return n, nil case AssetTypeAssetTypePoolShare: u.LiquidityPoolId = new(PoolId) - nTmp, err = (*u.LiquidityPoolId).DecodeFrom(d) + nTmp, err = (*u.LiquidityPoolId).DecodeFrom(d, maxDepth) n += nTmp if err != nil { - return n, fmt.Errorf("decoding PoolId: %s", err) + return n, fmt.Errorf("decoding PoolId: %w", err) } return n, nil } @@ -4301,7 +4464,7 @@ func (s TrustLineAsset) MarshalBinary() ([]byte, error) { func (s *TrustLineAsset) UnmarshalBinary(inp []byte) error { r := bytes.NewReader(inp) d := xdr.NewDecoder(r) - _, err := s.DecodeFrom(d) + _, err := s.DecodeFrom(d, xdr.DecodeDefaultMaxDepth) return err } @@ -4370,13 +4533,17 @@ func (u TrustLineEntryExtensionV2Ext) EncodeTo(e *xdr.Encoder) error { var _ decoderFrom = (*TrustLineEntryExtensionV2Ext)(nil) // DecodeFrom decodes this value using the Decoder. -func (u *TrustLineEntryExtensionV2Ext) DecodeFrom(d *xdr.Decoder) (int, error) { +func (u *TrustLineEntryExtensionV2Ext) DecodeFrom(d *xdr.Decoder, maxDepth uint) (int, error) { + if maxDepth == 0 { + return 0, fmt.Errorf("decoding TrustLineEntryExtensionV2Ext: %w", ErrMaxDecodingDepthReached) + } + maxDepth -= 1 var err error var n, nTmp int u.V, nTmp, err = d.DecodeInt() n += nTmp if err != nil { - return n, fmt.Errorf("decoding Int: %s", err) + return n, fmt.Errorf("decoding Int: %w", err) } switch int32(u.V) { case 0: @@ -4398,7 +4565,7 @@ func (s TrustLineEntryExtensionV2Ext) MarshalBinary() ([]byte, error) { func (s *TrustLineEntryExtensionV2Ext) UnmarshalBinary(inp []byte) error { r := bytes.NewReader(inp) d := xdr.NewDecoder(r) - _, err := s.DecodeFrom(d) + _, err := s.DecodeFrom(d, xdr.DecodeDefaultMaxDepth) return err } @@ -4446,18 +4613,22 @@ func (s *TrustLineEntryExtensionV2) EncodeTo(e *xdr.Encoder) error { var _ decoderFrom = (*TrustLineEntryExtensionV2)(nil) // DecodeFrom decodes this value using the Decoder. -func (s *TrustLineEntryExtensionV2) DecodeFrom(d *xdr.Decoder) (int, error) { +func (s *TrustLineEntryExtensionV2) DecodeFrom(d *xdr.Decoder, maxDepth uint) (int, error) { + if maxDepth == 0 { + return 0, fmt.Errorf("decoding TrustLineEntryExtensionV2: %w", ErrMaxDecodingDepthReached) + } + maxDepth -= 1 var err error var n, nTmp int - nTmp, err = s.LiquidityPoolUseCount.DecodeFrom(d) + nTmp, err = s.LiquidityPoolUseCount.DecodeFrom(d, maxDepth) n += nTmp if err != nil { - return n, fmt.Errorf("decoding Int32: %s", err) + return n, fmt.Errorf("decoding Int32: %w", err) } - nTmp, err = s.Ext.DecodeFrom(d) + nTmp, err = s.Ext.DecodeFrom(d, maxDepth) n += nTmp if err != nil { - return n, fmt.Errorf("decoding TrustLineEntryExtensionV2Ext: %s", err) + return n, fmt.Errorf("decoding TrustLineEntryExtensionV2Ext: %w", err) } return n, nil } @@ -4474,7 +4645,7 @@ func (s TrustLineEntryExtensionV2) MarshalBinary() ([]byte, error) { func (s *TrustLineEntryExtensionV2) UnmarshalBinary(inp []byte) error { r := bytes.NewReader(inp) d := xdr.NewDecoder(r) - _, err := s.DecodeFrom(d) + _, err := s.DecodeFrom(d, xdr.DecodeDefaultMaxDepth) return err } @@ -4530,7 +4701,7 @@ func NewTrustLineEntryV1Ext(v int32, value interface{}) (result TrustLineEntryV1 case 2: tv, ok := value.(TrustLineEntryExtensionV2) if !ok { - err = fmt.Errorf("invalid value, must be TrustLineEntryExtensionV2") + err = errors.New("invalid value, must be TrustLineEntryExtensionV2") return } result.V2 = &tv @@ -4585,13 +4756,17 @@ func (u TrustLineEntryV1Ext) EncodeTo(e *xdr.Encoder) error { var _ decoderFrom = (*TrustLineEntryV1Ext)(nil) // DecodeFrom decodes this value using the Decoder. -func (u *TrustLineEntryV1Ext) DecodeFrom(d *xdr.Decoder) (int, error) { +func (u *TrustLineEntryV1Ext) DecodeFrom(d *xdr.Decoder, maxDepth uint) (int, error) { + if maxDepth == 0 { + return 0, fmt.Errorf("decoding TrustLineEntryV1Ext: %w", ErrMaxDecodingDepthReached) + } + maxDepth -= 1 var err error var n, nTmp int u.V, nTmp, err = d.DecodeInt() n += nTmp if err != nil { - return n, fmt.Errorf("decoding Int: %s", err) + return n, fmt.Errorf("decoding Int: %w", err) } switch int32(u.V) { case 0: @@ -4599,10 +4774,10 @@ func (u *TrustLineEntryV1Ext) DecodeFrom(d *xdr.Decoder) (int, error) { return n, nil case 2: u.V2 = new(TrustLineEntryExtensionV2) - nTmp, err = (*u.V2).DecodeFrom(d) + nTmp, err = (*u.V2).DecodeFrom(d, maxDepth) n += nTmp if err != nil { - return n, fmt.Errorf("decoding TrustLineEntryExtensionV2: %s", err) + return n, fmt.Errorf("decoding TrustLineEntryExtensionV2: %w", err) } return n, nil } @@ -4621,7 +4796,7 @@ func (s TrustLineEntryV1Ext) MarshalBinary() ([]byte, error) { func (s *TrustLineEntryV1Ext) UnmarshalBinary(inp []byte) error { r := bytes.NewReader(inp) d := xdr.NewDecoder(r) - _, err := s.DecodeFrom(d) + _, err := s.DecodeFrom(d, xdr.DecodeDefaultMaxDepth) return err } @@ -4671,18 +4846,22 @@ func (s *TrustLineEntryV1) EncodeTo(e *xdr.Encoder) error { var _ decoderFrom = (*TrustLineEntryV1)(nil) // DecodeFrom decodes this value using the Decoder. -func (s *TrustLineEntryV1) DecodeFrom(d *xdr.Decoder) (int, error) { +func (s *TrustLineEntryV1) DecodeFrom(d *xdr.Decoder, maxDepth uint) (int, error) { + if maxDepth == 0 { + return 0, fmt.Errorf("decoding TrustLineEntryV1: %w", ErrMaxDecodingDepthReached) + } + maxDepth -= 1 var err error var n, nTmp int - nTmp, err = s.Liabilities.DecodeFrom(d) + nTmp, err = s.Liabilities.DecodeFrom(d, maxDepth) n += nTmp if err != nil { - return n, fmt.Errorf("decoding Liabilities: %s", err) + return n, fmt.Errorf("decoding Liabilities: %w", err) } - nTmp, err = s.Ext.DecodeFrom(d) + nTmp, err = s.Ext.DecodeFrom(d, maxDepth) n += nTmp if err != nil { - return n, fmt.Errorf("decoding TrustLineEntryV1Ext: %s", err) + return n, fmt.Errorf("decoding TrustLineEntryV1Ext: %w", err) } return n, nil } @@ -4699,7 +4878,7 @@ func (s TrustLineEntryV1) MarshalBinary() ([]byte, error) { func (s *TrustLineEntryV1) UnmarshalBinary(inp []byte) error { r := bytes.NewReader(inp) d := xdr.NewDecoder(r) - _, err := s.DecodeFrom(d) + _, err := s.DecodeFrom(d, xdr.DecodeDefaultMaxDepth) return err } @@ -4767,7 +4946,7 @@ func NewTrustLineEntryExt(v int32, value interface{}) (result TrustLineEntryExt, case 1: tv, ok := value.(TrustLineEntryV1) if !ok { - err = fmt.Errorf("invalid value, must be TrustLineEntryV1") + err = errors.New("invalid value, must be TrustLineEntryV1") return } result.V1 = &tv @@ -4822,13 +5001,17 @@ func (u TrustLineEntryExt) EncodeTo(e *xdr.Encoder) error { var _ decoderFrom = (*TrustLineEntryExt)(nil) // DecodeFrom decodes this value using the Decoder. -func (u *TrustLineEntryExt) DecodeFrom(d *xdr.Decoder) (int, error) { +func (u *TrustLineEntryExt) DecodeFrom(d *xdr.Decoder, maxDepth uint) (int, error) { + if maxDepth == 0 { + return 0, fmt.Errorf("decoding TrustLineEntryExt: %w", ErrMaxDecodingDepthReached) + } + maxDepth -= 1 var err error var n, nTmp int u.V, nTmp, err = d.DecodeInt() n += nTmp if err != nil { - return n, fmt.Errorf("decoding Int: %s", err) + return n, fmt.Errorf("decoding Int: %w", err) } switch int32(u.V) { case 0: @@ -4836,10 +5019,10 @@ func (u *TrustLineEntryExt) DecodeFrom(d *xdr.Decoder) (int, error) { return n, nil case 1: u.V1 = new(TrustLineEntryV1) - nTmp, err = (*u.V1).DecodeFrom(d) + nTmp, err = (*u.V1).DecodeFrom(d, maxDepth) n += nTmp if err != nil { - return n, fmt.Errorf("decoding TrustLineEntryV1: %s", err) + return n, fmt.Errorf("decoding TrustLineEntryV1: %w", err) } return n, nil } @@ -4858,7 +5041,7 @@ func (s TrustLineEntryExt) MarshalBinary() ([]byte, error) { func (s *TrustLineEntryExt) UnmarshalBinary(inp []byte) error { r := bytes.NewReader(inp) d := xdr.NewDecoder(r) - _, err := s.DecodeFrom(d) + _, err := s.DecodeFrom(d, xdr.DecodeDefaultMaxDepth) return err } @@ -4943,38 +5126,42 @@ func (s *TrustLineEntry) EncodeTo(e *xdr.Encoder) error { var _ decoderFrom = (*TrustLineEntry)(nil) // DecodeFrom decodes this value using the Decoder. -func (s *TrustLineEntry) DecodeFrom(d *xdr.Decoder) (int, error) { +func (s *TrustLineEntry) DecodeFrom(d *xdr.Decoder, maxDepth uint) (int, error) { + if maxDepth == 0 { + return 0, fmt.Errorf("decoding TrustLineEntry: %w", ErrMaxDecodingDepthReached) + } + maxDepth -= 1 var err error var n, nTmp int - nTmp, err = s.AccountId.DecodeFrom(d) + nTmp, err = s.AccountId.DecodeFrom(d, maxDepth) n += nTmp if err != nil { - return n, fmt.Errorf("decoding AccountId: %s", err) + return n, fmt.Errorf("decoding AccountId: %w", err) } - nTmp, err = s.Asset.DecodeFrom(d) + nTmp, err = s.Asset.DecodeFrom(d, maxDepth) n += nTmp if err != nil { - return n, fmt.Errorf("decoding TrustLineAsset: %s", err) + return n, fmt.Errorf("decoding TrustLineAsset: %w", err) } - nTmp, err = s.Balance.DecodeFrom(d) + nTmp, err = s.Balance.DecodeFrom(d, maxDepth) n += nTmp if err != nil { - return n, fmt.Errorf("decoding Int64: %s", err) + return n, fmt.Errorf("decoding Int64: %w", err) } - nTmp, err = s.Limit.DecodeFrom(d) + nTmp, err = s.Limit.DecodeFrom(d, maxDepth) n += nTmp if err != nil { - return n, fmt.Errorf("decoding Int64: %s", err) + return n, fmt.Errorf("decoding Int64: %w", err) } - nTmp, err = s.Flags.DecodeFrom(d) + nTmp, err = s.Flags.DecodeFrom(d, maxDepth) n += nTmp if err != nil { - return n, fmt.Errorf("decoding Uint32: %s", err) + return n, fmt.Errorf("decoding Uint32: %w", err) } - nTmp, err = s.Ext.DecodeFrom(d) + nTmp, err = s.Ext.DecodeFrom(d, maxDepth) n += nTmp if err != nil { - return n, fmt.Errorf("decoding TrustLineEntryExt: %s", err) + return n, fmt.Errorf("decoding TrustLineEntryExt: %w", err) } return n, nil } @@ -4991,7 +5178,7 @@ func (s TrustLineEntry) MarshalBinary() ([]byte, error) { func (s *TrustLineEntry) UnmarshalBinary(inp []byte) error { r := bytes.NewReader(inp) d := xdr.NewDecoder(r) - _, err := s.DecodeFrom(d) + _, err := s.DecodeFrom(d, xdr.DecodeDefaultMaxDepth) return err } @@ -5049,10 +5236,14 @@ func (e OfferEntryFlags) EncodeTo(enc *xdr.Encoder) error { var _ decoderFrom = (*OfferEntryFlags)(nil) // DecodeFrom decodes this value using the Decoder. -func (e *OfferEntryFlags) DecodeFrom(d *xdr.Decoder) (int, error) { +func (e *OfferEntryFlags) DecodeFrom(d *xdr.Decoder, maxDepth uint) (int, error) { + if maxDepth == 0 { + return 0, fmt.Errorf("decoding OfferEntryFlags: %w", ErrMaxDecodingDepthReached) + } + maxDepth -= 1 v, n, err := d.DecodeInt() if err != nil { - return n, fmt.Errorf("decoding OfferEntryFlags: %s", err) + return n, fmt.Errorf("decoding OfferEntryFlags: %w", err) } if _, ok := offerEntryFlagsMap[v]; !ok { return n, fmt.Errorf("'%d' is not a valid OfferEntryFlags enum value", v) @@ -5073,7 +5264,7 @@ func (s OfferEntryFlags) MarshalBinary() ([]byte, error) { func (s *OfferEntryFlags) UnmarshalBinary(inp []byte) error { r := bytes.NewReader(inp) d := xdr.NewDecoder(r) - _, err := s.DecodeFrom(d) + _, err := s.DecodeFrom(d, xdr.DecodeDefaultMaxDepth) return err } @@ -5147,13 +5338,17 @@ func (u OfferEntryExt) EncodeTo(e *xdr.Encoder) error { var _ decoderFrom = (*OfferEntryExt)(nil) // DecodeFrom decodes this value using the Decoder. -func (u *OfferEntryExt) DecodeFrom(d *xdr.Decoder) (int, error) { +func (u *OfferEntryExt) DecodeFrom(d *xdr.Decoder, maxDepth uint) (int, error) { + if maxDepth == 0 { + return 0, fmt.Errorf("decoding OfferEntryExt: %w", ErrMaxDecodingDepthReached) + } + maxDepth -= 1 var err error var n, nTmp int u.V, nTmp, err = d.DecodeInt() n += nTmp if err != nil { - return n, fmt.Errorf("decoding Int: %s", err) + return n, fmt.Errorf("decoding Int: %w", err) } switch int32(u.V) { case 0: @@ -5175,7 +5370,7 @@ func (s OfferEntryExt) MarshalBinary() ([]byte, error) { func (s *OfferEntryExt) UnmarshalBinary(inp []byte) error { r := bytes.NewReader(inp) d := xdr.NewDecoder(r) - _, err := s.DecodeFrom(d) + _, err := s.DecodeFrom(d, xdr.DecodeDefaultMaxDepth) return err } @@ -5260,48 +5455,52 @@ func (s *OfferEntry) EncodeTo(e *xdr.Encoder) error { var _ decoderFrom = (*OfferEntry)(nil) // DecodeFrom decodes this value using the Decoder. -func (s *OfferEntry) DecodeFrom(d *xdr.Decoder) (int, error) { +func (s *OfferEntry) DecodeFrom(d *xdr.Decoder, maxDepth uint) (int, error) { + if maxDepth == 0 { + return 0, fmt.Errorf("decoding OfferEntry: %w", ErrMaxDecodingDepthReached) + } + maxDepth -= 1 var err error var n, nTmp int - nTmp, err = s.SellerId.DecodeFrom(d) + nTmp, err = s.SellerId.DecodeFrom(d, maxDepth) n += nTmp if err != nil { - return n, fmt.Errorf("decoding AccountId: %s", err) + return n, fmt.Errorf("decoding AccountId: %w", err) } - nTmp, err = s.OfferId.DecodeFrom(d) + nTmp, err = s.OfferId.DecodeFrom(d, maxDepth) n += nTmp if err != nil { - return n, fmt.Errorf("decoding Int64: %s", err) + return n, fmt.Errorf("decoding Int64: %w", err) } - nTmp, err = s.Selling.DecodeFrom(d) + nTmp, err = s.Selling.DecodeFrom(d, maxDepth) n += nTmp if err != nil { - return n, fmt.Errorf("decoding Asset: %s", err) + return n, fmt.Errorf("decoding Asset: %w", err) } - nTmp, err = s.Buying.DecodeFrom(d) + nTmp, err = s.Buying.DecodeFrom(d, maxDepth) n += nTmp if err != nil { - return n, fmt.Errorf("decoding Asset: %s", err) + return n, fmt.Errorf("decoding Asset: %w", err) } - nTmp, err = s.Amount.DecodeFrom(d) + nTmp, err = s.Amount.DecodeFrom(d, maxDepth) n += nTmp if err != nil { - return n, fmt.Errorf("decoding Int64: %s", err) + return n, fmt.Errorf("decoding Int64: %w", err) } - nTmp, err = s.Price.DecodeFrom(d) + nTmp, err = s.Price.DecodeFrom(d, maxDepth) n += nTmp if err != nil { - return n, fmt.Errorf("decoding Price: %s", err) + return n, fmt.Errorf("decoding Price: %w", err) } - nTmp, err = s.Flags.DecodeFrom(d) + nTmp, err = s.Flags.DecodeFrom(d, maxDepth) n += nTmp if err != nil { - return n, fmt.Errorf("decoding Uint32: %s", err) + return n, fmt.Errorf("decoding Uint32: %w", err) } - nTmp, err = s.Ext.DecodeFrom(d) + nTmp, err = s.Ext.DecodeFrom(d, maxDepth) n += nTmp if err != nil { - return n, fmt.Errorf("decoding OfferEntryExt: %s", err) + return n, fmt.Errorf("decoding OfferEntryExt: %w", err) } return n, nil } @@ -5318,7 +5517,7 @@ func (s OfferEntry) MarshalBinary() ([]byte, error) { func (s *OfferEntry) UnmarshalBinary(inp []byte) error { r := bytes.NewReader(inp) d := xdr.NewDecoder(r) - _, err := s.DecodeFrom(d) + _, err := s.DecodeFrom(d, xdr.DecodeDefaultMaxDepth) return err } @@ -5387,13 +5586,17 @@ func (u DataEntryExt) EncodeTo(e *xdr.Encoder) error { var _ decoderFrom = (*DataEntryExt)(nil) // DecodeFrom decodes this value using the Decoder. -func (u *DataEntryExt) DecodeFrom(d *xdr.Decoder) (int, error) { +func (u *DataEntryExt) DecodeFrom(d *xdr.Decoder, maxDepth uint) (int, error) { + if maxDepth == 0 { + return 0, fmt.Errorf("decoding DataEntryExt: %w", ErrMaxDecodingDepthReached) + } + maxDepth -= 1 var err error var n, nTmp int u.V, nTmp, err = d.DecodeInt() n += nTmp if err != nil { - return n, fmt.Errorf("decoding Int: %s", err) + return n, fmt.Errorf("decoding Int: %w", err) } switch int32(u.V) { case 0: @@ -5415,7 +5618,7 @@ func (s DataEntryExt) MarshalBinary() ([]byte, error) { func (s *DataEntryExt) UnmarshalBinary(inp []byte) error { r := bytes.NewReader(inp) d := xdr.NewDecoder(r) - _, err := s.DecodeFrom(d) + _, err := s.DecodeFrom(d, xdr.DecodeDefaultMaxDepth) return err } @@ -5474,28 +5677,32 @@ func (s *DataEntry) EncodeTo(e *xdr.Encoder) error { var _ decoderFrom = (*DataEntry)(nil) // DecodeFrom decodes this value using the Decoder. -func (s *DataEntry) DecodeFrom(d *xdr.Decoder) (int, error) { +func (s *DataEntry) DecodeFrom(d *xdr.Decoder, maxDepth uint) (int, error) { + if maxDepth == 0 { + return 0, fmt.Errorf("decoding DataEntry: %w", ErrMaxDecodingDepthReached) + } + maxDepth -= 1 var err error var n, nTmp int - nTmp, err = s.AccountId.DecodeFrom(d) + nTmp, err = s.AccountId.DecodeFrom(d, maxDepth) n += nTmp if err != nil { - return n, fmt.Errorf("decoding AccountId: %s", err) + return n, fmt.Errorf("decoding AccountId: %w", err) } - nTmp, err = s.DataName.DecodeFrom(d) + nTmp, err = s.DataName.DecodeFrom(d, maxDepth) n += nTmp if err != nil { - return n, fmt.Errorf("decoding String64: %s", err) + return n, fmt.Errorf("decoding String64: %w", err) } - nTmp, err = s.DataValue.DecodeFrom(d) + nTmp, err = s.DataValue.DecodeFrom(d, maxDepth) n += nTmp if err != nil { - return n, fmt.Errorf("decoding DataValue: %s", err) + return n, fmt.Errorf("decoding DataValue: %w", err) } - nTmp, err = s.Ext.DecodeFrom(d) + nTmp, err = s.Ext.DecodeFrom(d, maxDepth) n += nTmp if err != nil { - return n, fmt.Errorf("decoding DataEntryExt: %s", err) + return n, fmt.Errorf("decoding DataEntryExt: %w", err) } return n, nil } @@ -5512,7 +5719,7 @@ func (s DataEntry) MarshalBinary() ([]byte, error) { func (s *DataEntry) UnmarshalBinary(inp []byte) error { r := bytes.NewReader(inp) d := xdr.NewDecoder(r) - _, err := s.DecodeFrom(d) + _, err := s.DecodeFrom(d, xdr.DecodeDefaultMaxDepth) return err } @@ -5583,10 +5790,14 @@ func (e ClaimPredicateType) EncodeTo(enc *xdr.Encoder) error { var _ decoderFrom = (*ClaimPredicateType)(nil) // DecodeFrom decodes this value using the Decoder. -func (e *ClaimPredicateType) DecodeFrom(d *xdr.Decoder) (int, error) { +func (e *ClaimPredicateType) DecodeFrom(d *xdr.Decoder, maxDepth uint) (int, error) { + if maxDepth == 0 { + return 0, fmt.Errorf("decoding ClaimPredicateType: %w", ErrMaxDecodingDepthReached) + } + maxDepth -= 1 v, n, err := d.DecodeInt() if err != nil { - return n, fmt.Errorf("decoding ClaimPredicateType: %s", err) + return n, fmt.Errorf("decoding ClaimPredicateType: %w", err) } if _, ok := claimPredicateTypeMap[v]; !ok { return n, fmt.Errorf("'%d' is not a valid ClaimPredicateType enum value", v) @@ -5607,7 +5818,7 @@ func (s ClaimPredicateType) MarshalBinary() ([]byte, error) { func (s *ClaimPredicateType) UnmarshalBinary(inp []byte) error { r := bytes.NewReader(inp) d := xdr.NewDecoder(r) - _, err := s.DecodeFrom(d) + _, err := s.DecodeFrom(d, xdr.DecodeDefaultMaxDepth) return err } @@ -5684,35 +5895,35 @@ func NewClaimPredicate(aType ClaimPredicateType, value interface{}) (result Clai case ClaimPredicateTypeClaimPredicateAnd: tv, ok := value.([]ClaimPredicate) if !ok { - err = fmt.Errorf("invalid value, must be []ClaimPredicate") + err = errors.New("invalid value, must be []ClaimPredicate") return } result.AndPredicates = &tv case ClaimPredicateTypeClaimPredicateOr: tv, ok := value.([]ClaimPredicate) if !ok { - err = fmt.Errorf("invalid value, must be []ClaimPredicate") + err = errors.New("invalid value, must be []ClaimPredicate") return } result.OrPredicates = &tv case ClaimPredicateTypeClaimPredicateNot: tv, ok := value.(*ClaimPredicate) if !ok { - err = fmt.Errorf("invalid value, must be *ClaimPredicate") + err = errors.New("invalid value, must be *ClaimPredicate") return } result.NotPredicate = &tv case ClaimPredicateTypeClaimPredicateBeforeAbsoluteTime: tv, ok := value.(Int64) if !ok { - err = fmt.Errorf("invalid value, must be Int64") + err = errors.New("invalid value, must be Int64") return } result.AbsBefore = &tv case ClaimPredicateTypeClaimPredicateBeforeRelativeTime: tv, ok := value.(Int64) if !ok { - err = fmt.Errorf("invalid value, must be Int64") + err = errors.New("invalid value, must be Int64") return } result.RelBefore = &tv @@ -5902,13 +6113,17 @@ func (u ClaimPredicate) EncodeTo(e *xdr.Encoder) error { var _ decoderFrom = (*ClaimPredicate)(nil) // DecodeFrom decodes this value using the Decoder. -func (u *ClaimPredicate) DecodeFrom(d *xdr.Decoder) (int, error) { +func (u *ClaimPredicate) DecodeFrom(d *xdr.Decoder, maxDepth uint) (int, error) { + if maxDepth == 0 { + return 0, fmt.Errorf("decoding ClaimPredicate: %w", ErrMaxDecodingDepthReached) + } + maxDepth -= 1 var err error var n, nTmp int - nTmp, err = u.Type.DecodeFrom(d) + nTmp, err = u.Type.DecodeFrom(d, maxDepth) n += nTmp if err != nil { - return n, fmt.Errorf("decoding ClaimPredicateType: %s", err) + return n, fmt.Errorf("decoding ClaimPredicateType: %w", err) } switch ClaimPredicateType(u.Type) { case ClaimPredicateTypeClaimPredicateUnconditional: @@ -5920,7 +6135,7 @@ func (u *ClaimPredicate) DecodeFrom(d *xdr.Decoder) (int, error) { l, nTmp, err = d.DecodeUint() n += nTmp if err != nil { - return n, fmt.Errorf("decoding ClaimPredicate: %s", err) + return n, fmt.Errorf("decoding ClaimPredicate: %w", err) } if l > 2 { return n, fmt.Errorf("decoding ClaimPredicate: data size (%d) exceeds size limit (2)", l) @@ -5929,10 +6144,10 @@ func (u *ClaimPredicate) DecodeFrom(d *xdr.Decoder) (int, error) { if l > 0 { (*u.AndPredicates) = make([]ClaimPredicate, l) for i := uint32(0); i < l; i++ { - nTmp, err = (*u.AndPredicates)[i].DecodeFrom(d) + nTmp, err = (*u.AndPredicates)[i].DecodeFrom(d, maxDepth) n += nTmp if err != nil { - return n, fmt.Errorf("decoding ClaimPredicate: %s", err) + return n, fmt.Errorf("decoding ClaimPredicate: %w", err) } } } @@ -5943,7 +6158,7 @@ func (u *ClaimPredicate) DecodeFrom(d *xdr.Decoder) (int, error) { l, nTmp, err = d.DecodeUint() n += nTmp if err != nil { - return n, fmt.Errorf("decoding ClaimPredicate: %s", err) + return n, fmt.Errorf("decoding ClaimPredicate: %w", err) } if l > 2 { return n, fmt.Errorf("decoding ClaimPredicate: data size (%d) exceeds size limit (2)", l) @@ -5952,10 +6167,10 @@ func (u *ClaimPredicate) DecodeFrom(d *xdr.Decoder) (int, error) { if l > 0 { (*u.OrPredicates) = make([]ClaimPredicate, l) for i := uint32(0); i < l; i++ { - nTmp, err = (*u.OrPredicates)[i].DecodeFrom(d) + nTmp, err = (*u.OrPredicates)[i].DecodeFrom(d, maxDepth) n += nTmp if err != nil { - return n, fmt.Errorf("decoding ClaimPredicate: %s", err) + return n, fmt.Errorf("decoding ClaimPredicate: %w", err) } } } @@ -5966,32 +6181,32 @@ func (u *ClaimPredicate) DecodeFrom(d *xdr.Decoder) (int, error) { b, nTmp, err = d.DecodeBool() n += nTmp if err != nil { - return n, fmt.Errorf("decoding ClaimPredicate: %s", err) + return n, fmt.Errorf("decoding ClaimPredicate: %w", err) } (*u.NotPredicate) = nil if b { (*u.NotPredicate) = new(ClaimPredicate) - nTmp, err = (*u.NotPredicate).DecodeFrom(d) + nTmp, err = (*u.NotPredicate).DecodeFrom(d, maxDepth) n += nTmp if err != nil { - return n, fmt.Errorf("decoding ClaimPredicate: %s", err) + return n, fmt.Errorf("decoding ClaimPredicate: %w", err) } } return n, nil case ClaimPredicateTypeClaimPredicateBeforeAbsoluteTime: u.AbsBefore = new(Int64) - nTmp, err = (*u.AbsBefore).DecodeFrom(d) + nTmp, err = (*u.AbsBefore).DecodeFrom(d, maxDepth) n += nTmp if err != nil { - return n, fmt.Errorf("decoding Int64: %s", err) + return n, fmt.Errorf("decoding Int64: %w", err) } return n, nil case ClaimPredicateTypeClaimPredicateBeforeRelativeTime: u.RelBefore = new(Int64) - nTmp, err = (*u.RelBefore).DecodeFrom(d) + nTmp, err = (*u.RelBefore).DecodeFrom(d, maxDepth) n += nTmp if err != nil { - return n, fmt.Errorf("decoding Int64: %s", err) + return n, fmt.Errorf("decoding Int64: %w", err) } return n, nil } @@ -6010,7 +6225,7 @@ func (s ClaimPredicate) MarshalBinary() ([]byte, error) { func (s *ClaimPredicate) UnmarshalBinary(inp []byte) error { r := bytes.NewReader(inp) d := xdr.NewDecoder(r) - _, err := s.DecodeFrom(d) + _, err := s.DecodeFrom(d, xdr.DecodeDefaultMaxDepth) return err } @@ -6066,10 +6281,14 @@ func (e ClaimantType) EncodeTo(enc *xdr.Encoder) error { var _ decoderFrom = (*ClaimantType)(nil) // DecodeFrom decodes this value using the Decoder. -func (e *ClaimantType) DecodeFrom(d *xdr.Decoder) (int, error) { +func (e *ClaimantType) DecodeFrom(d *xdr.Decoder, maxDepth uint) (int, error) { + if maxDepth == 0 { + return 0, fmt.Errorf("decoding ClaimantType: %w", ErrMaxDecodingDepthReached) + } + maxDepth -= 1 v, n, err := d.DecodeInt() if err != nil { - return n, fmt.Errorf("decoding ClaimantType: %s", err) + return n, fmt.Errorf("decoding ClaimantType: %w", err) } if _, ok := claimantTypeMap[v]; !ok { return n, fmt.Errorf("'%d' is not a valid ClaimantType enum value", v) @@ -6090,7 +6309,7 @@ func (s ClaimantType) MarshalBinary() ([]byte, error) { func (s *ClaimantType) UnmarshalBinary(inp []byte) error { r := bytes.NewReader(inp) d := xdr.NewDecoder(r) - _, err := s.DecodeFrom(d) + _, err := s.DecodeFrom(d, xdr.DecodeDefaultMaxDepth) return err } @@ -6132,18 +6351,22 @@ func (s *ClaimantV0) EncodeTo(e *xdr.Encoder) error { var _ decoderFrom = (*ClaimantV0)(nil) // DecodeFrom decodes this value using the Decoder. -func (s *ClaimantV0) DecodeFrom(d *xdr.Decoder) (int, error) { +func (s *ClaimantV0) DecodeFrom(d *xdr.Decoder, maxDepth uint) (int, error) { + if maxDepth == 0 { + return 0, fmt.Errorf("decoding ClaimantV0: %w", ErrMaxDecodingDepthReached) + } + maxDepth -= 1 var err error var n, nTmp int - nTmp, err = s.Destination.DecodeFrom(d) + nTmp, err = s.Destination.DecodeFrom(d, maxDepth) n += nTmp if err != nil { - return n, fmt.Errorf("decoding AccountId: %s", err) + return n, fmt.Errorf("decoding AccountId: %w", err) } - nTmp, err = s.Predicate.DecodeFrom(d) + nTmp, err = s.Predicate.DecodeFrom(d, maxDepth) n += nTmp if err != nil { - return n, fmt.Errorf("decoding ClaimPredicate: %s", err) + return n, fmt.Errorf("decoding ClaimPredicate: %w", err) } return n, nil } @@ -6160,7 +6383,7 @@ func (s ClaimantV0) MarshalBinary() ([]byte, error) { func (s *ClaimantV0) UnmarshalBinary(inp []byte) error { r := bytes.NewReader(inp) d := xdr.NewDecoder(r) - _, err := s.DecodeFrom(d) + _, err := s.DecodeFrom(d, xdr.DecodeDefaultMaxDepth) return err } @@ -6214,7 +6437,7 @@ func NewClaimant(aType ClaimantType, value interface{}) (result Claimant, err er case ClaimantTypeClaimantTypeV0: tv, ok := value.(ClaimantV0) if !ok { - err = fmt.Errorf("invalid value, must be ClaimantV0") + err = errors.New("invalid value, must be ClaimantV0") return } result.V0 = &tv @@ -6266,21 +6489,25 @@ func (u Claimant) EncodeTo(e *xdr.Encoder) error { var _ decoderFrom = (*Claimant)(nil) // DecodeFrom decodes this value using the Decoder. -func (u *Claimant) DecodeFrom(d *xdr.Decoder) (int, error) { +func (u *Claimant) DecodeFrom(d *xdr.Decoder, maxDepth uint) (int, error) { + if maxDepth == 0 { + return 0, fmt.Errorf("decoding Claimant: %w", ErrMaxDecodingDepthReached) + } + maxDepth -= 1 var err error var n, nTmp int - nTmp, err = u.Type.DecodeFrom(d) + nTmp, err = u.Type.DecodeFrom(d, maxDepth) n += nTmp if err != nil { - return n, fmt.Errorf("decoding ClaimantType: %s", err) + return n, fmt.Errorf("decoding ClaimantType: %w", err) } switch ClaimantType(u.Type) { case ClaimantTypeClaimantTypeV0: u.V0 = new(ClaimantV0) - nTmp, err = (*u.V0).DecodeFrom(d) + nTmp, err = (*u.V0).DecodeFrom(d, maxDepth) n += nTmp if err != nil { - return n, fmt.Errorf("decoding ClaimantV0: %s", err) + return n, fmt.Errorf("decoding ClaimantV0: %w", err) } return n, nil } @@ -6299,7 +6526,7 @@ func (s Claimant) MarshalBinary() ([]byte, error) { func (s *Claimant) UnmarshalBinary(inp []byte) error { r := bytes.NewReader(inp) d := xdr.NewDecoder(r) - _, err := s.DecodeFrom(d) + _, err := s.DecodeFrom(d, xdr.DecodeDefaultMaxDepth) return err } @@ -6355,10 +6582,14 @@ func (e ClaimableBalanceIdType) EncodeTo(enc *xdr.Encoder) error { var _ decoderFrom = (*ClaimableBalanceIdType)(nil) // DecodeFrom decodes this value using the Decoder. -func (e *ClaimableBalanceIdType) DecodeFrom(d *xdr.Decoder) (int, error) { +func (e *ClaimableBalanceIdType) DecodeFrom(d *xdr.Decoder, maxDepth uint) (int, error) { + if maxDepth == 0 { + return 0, fmt.Errorf("decoding ClaimableBalanceIdType: %w", ErrMaxDecodingDepthReached) + } + maxDepth -= 1 v, n, err := d.DecodeInt() if err != nil { - return n, fmt.Errorf("decoding ClaimableBalanceIdType: %s", err) + return n, fmt.Errorf("decoding ClaimableBalanceIdType: %w", err) } if _, ok := claimableBalanceIdTypeMap[v]; !ok { return n, fmt.Errorf("'%d' is not a valid ClaimableBalanceIdType enum value", v) @@ -6379,7 +6610,7 @@ func (s ClaimableBalanceIdType) MarshalBinary() ([]byte, error) { func (s *ClaimableBalanceIdType) UnmarshalBinary(inp []byte) error { r := bytes.NewReader(inp) d := xdr.NewDecoder(r) - _, err := s.DecodeFrom(d) + _, err := s.DecodeFrom(d, xdr.DecodeDefaultMaxDepth) return err } @@ -6429,7 +6660,7 @@ func NewClaimableBalanceId(aType ClaimableBalanceIdType, value interface{}) (res case ClaimableBalanceIdTypeClaimableBalanceIdTypeV0: tv, ok := value.(Hash) if !ok { - err = fmt.Errorf("invalid value, must be Hash") + err = errors.New("invalid value, must be Hash") return } result.V0 = &tv @@ -6481,21 +6712,25 @@ func (u ClaimableBalanceId) EncodeTo(e *xdr.Encoder) error { var _ decoderFrom = (*ClaimableBalanceId)(nil) // DecodeFrom decodes this value using the Decoder. -func (u *ClaimableBalanceId) DecodeFrom(d *xdr.Decoder) (int, error) { +func (u *ClaimableBalanceId) DecodeFrom(d *xdr.Decoder, maxDepth uint) (int, error) { + if maxDepth == 0 { + return 0, fmt.Errorf("decoding ClaimableBalanceId: %w", ErrMaxDecodingDepthReached) + } + maxDepth -= 1 var err error var n, nTmp int - nTmp, err = u.Type.DecodeFrom(d) + nTmp, err = u.Type.DecodeFrom(d, maxDepth) n += nTmp if err != nil { - return n, fmt.Errorf("decoding ClaimableBalanceIdType: %s", err) + return n, fmt.Errorf("decoding ClaimableBalanceIdType: %w", err) } switch ClaimableBalanceIdType(u.Type) { case ClaimableBalanceIdTypeClaimableBalanceIdTypeV0: u.V0 = new(Hash) - nTmp, err = (*u.V0).DecodeFrom(d) + nTmp, err = (*u.V0).DecodeFrom(d, maxDepth) n += nTmp if err != nil { - return n, fmt.Errorf("decoding Hash: %s", err) + return n, fmt.Errorf("decoding Hash: %w", err) } return n, nil } @@ -6514,7 +6749,7 @@ func (s ClaimableBalanceId) MarshalBinary() ([]byte, error) { func (s *ClaimableBalanceId) UnmarshalBinary(inp []byte) error { r := bytes.NewReader(inp) d := xdr.NewDecoder(r) - _, err := s.DecodeFrom(d) + _, err := s.DecodeFrom(d, xdr.DecodeDefaultMaxDepth) return err } @@ -6572,10 +6807,14 @@ func (e ClaimableBalanceFlags) EncodeTo(enc *xdr.Encoder) error { var _ decoderFrom = (*ClaimableBalanceFlags)(nil) // DecodeFrom decodes this value using the Decoder. -func (e *ClaimableBalanceFlags) DecodeFrom(d *xdr.Decoder) (int, error) { +func (e *ClaimableBalanceFlags) DecodeFrom(d *xdr.Decoder, maxDepth uint) (int, error) { + if maxDepth == 0 { + return 0, fmt.Errorf("decoding ClaimableBalanceFlags: %w", ErrMaxDecodingDepthReached) + } + maxDepth -= 1 v, n, err := d.DecodeInt() if err != nil { - return n, fmt.Errorf("decoding ClaimableBalanceFlags: %s", err) + return n, fmt.Errorf("decoding ClaimableBalanceFlags: %w", err) } if _, ok := claimableBalanceFlagsMap[v]; !ok { return n, fmt.Errorf("'%d' is not a valid ClaimableBalanceFlags enum value", v) @@ -6596,7 +6835,7 @@ func (s ClaimableBalanceFlags) MarshalBinary() ([]byte, error) { func (s *ClaimableBalanceFlags) UnmarshalBinary(inp []byte) error { r := bytes.NewReader(inp) d := xdr.NewDecoder(r) - _, err := s.DecodeFrom(d) + _, err := s.DecodeFrom(d, xdr.DecodeDefaultMaxDepth) return err } @@ -6670,13 +6909,17 @@ func (u ClaimableBalanceEntryExtensionV1Ext) EncodeTo(e *xdr.Encoder) error { var _ decoderFrom = (*ClaimableBalanceEntryExtensionV1Ext)(nil) // DecodeFrom decodes this value using the Decoder. -func (u *ClaimableBalanceEntryExtensionV1Ext) DecodeFrom(d *xdr.Decoder) (int, error) { +func (u *ClaimableBalanceEntryExtensionV1Ext) DecodeFrom(d *xdr.Decoder, maxDepth uint) (int, error) { + if maxDepth == 0 { + return 0, fmt.Errorf("decoding ClaimableBalanceEntryExtensionV1Ext: %w", ErrMaxDecodingDepthReached) + } + maxDepth -= 1 var err error var n, nTmp int u.V, nTmp, err = d.DecodeInt() n += nTmp if err != nil { - return n, fmt.Errorf("decoding Int: %s", err) + return n, fmt.Errorf("decoding Int: %w", err) } switch int32(u.V) { case 0: @@ -6698,7 +6941,7 @@ func (s ClaimableBalanceEntryExtensionV1Ext) MarshalBinary() ([]byte, error) { func (s *ClaimableBalanceEntryExtensionV1Ext) UnmarshalBinary(inp []byte) error { r := bytes.NewReader(inp) d := xdr.NewDecoder(r) - _, err := s.DecodeFrom(d) + _, err := s.DecodeFrom(d, xdr.DecodeDefaultMaxDepth) return err } @@ -6746,18 +6989,22 @@ func (s *ClaimableBalanceEntryExtensionV1) EncodeTo(e *xdr.Encoder) error { var _ decoderFrom = (*ClaimableBalanceEntryExtensionV1)(nil) // DecodeFrom decodes this value using the Decoder. -func (s *ClaimableBalanceEntryExtensionV1) DecodeFrom(d *xdr.Decoder) (int, error) { +func (s *ClaimableBalanceEntryExtensionV1) DecodeFrom(d *xdr.Decoder, maxDepth uint) (int, error) { + if maxDepth == 0 { + return 0, fmt.Errorf("decoding ClaimableBalanceEntryExtensionV1: %w", ErrMaxDecodingDepthReached) + } + maxDepth -= 1 var err error var n, nTmp int - nTmp, err = s.Ext.DecodeFrom(d) + nTmp, err = s.Ext.DecodeFrom(d, maxDepth) n += nTmp if err != nil { - return n, fmt.Errorf("decoding ClaimableBalanceEntryExtensionV1Ext: %s", err) + return n, fmt.Errorf("decoding ClaimableBalanceEntryExtensionV1Ext: %w", err) } - nTmp, err = s.Flags.DecodeFrom(d) + nTmp, err = s.Flags.DecodeFrom(d, maxDepth) n += nTmp if err != nil { - return n, fmt.Errorf("decoding Uint32: %s", err) + return n, fmt.Errorf("decoding Uint32: %w", err) } return n, nil } @@ -6774,7 +7021,7 @@ func (s ClaimableBalanceEntryExtensionV1) MarshalBinary() ([]byte, error) { func (s *ClaimableBalanceEntryExtensionV1) UnmarshalBinary(inp []byte) error { r := bytes.NewReader(inp) d := xdr.NewDecoder(r) - _, err := s.DecodeFrom(d) + _, err := s.DecodeFrom(d, xdr.DecodeDefaultMaxDepth) return err } @@ -6830,7 +7077,7 @@ func NewClaimableBalanceEntryExt(v int32, value interface{}) (result ClaimableBa case 1: tv, ok := value.(ClaimableBalanceEntryExtensionV1) if !ok { - err = fmt.Errorf("invalid value, must be ClaimableBalanceEntryExtensionV1") + err = errors.New("invalid value, must be ClaimableBalanceEntryExtensionV1") return } result.V1 = &tv @@ -6885,13 +7132,17 @@ func (u ClaimableBalanceEntryExt) EncodeTo(e *xdr.Encoder) error { var _ decoderFrom = (*ClaimableBalanceEntryExt)(nil) // DecodeFrom decodes this value using the Decoder. -func (u *ClaimableBalanceEntryExt) DecodeFrom(d *xdr.Decoder) (int, error) { +func (u *ClaimableBalanceEntryExt) DecodeFrom(d *xdr.Decoder, maxDepth uint) (int, error) { + if maxDepth == 0 { + return 0, fmt.Errorf("decoding ClaimableBalanceEntryExt: %w", ErrMaxDecodingDepthReached) + } + maxDepth -= 1 var err error var n, nTmp int u.V, nTmp, err = d.DecodeInt() n += nTmp if err != nil { - return n, fmt.Errorf("decoding Int: %s", err) + return n, fmt.Errorf("decoding Int: %w", err) } switch int32(u.V) { case 0: @@ -6899,10 +7150,10 @@ func (u *ClaimableBalanceEntryExt) DecodeFrom(d *xdr.Decoder) (int, error) { return n, nil case 1: u.V1 = new(ClaimableBalanceEntryExtensionV1) - nTmp, err = (*u.V1).DecodeFrom(d) + nTmp, err = (*u.V1).DecodeFrom(d, maxDepth) n += nTmp if err != nil { - return n, fmt.Errorf("decoding ClaimableBalanceEntryExtensionV1: %s", err) + return n, fmt.Errorf("decoding ClaimableBalanceEntryExtensionV1: %w", err) } return n, nil } @@ -6921,7 +7172,7 @@ func (s ClaimableBalanceEntryExt) MarshalBinary() ([]byte, error) { func (s *ClaimableBalanceEntryExt) UnmarshalBinary(inp []byte) error { r := bytes.NewReader(inp) d := xdr.NewDecoder(r) - _, err := s.DecodeFrom(d) + _, err := s.DecodeFrom(d, xdr.DecodeDefaultMaxDepth) return err } @@ -6999,19 +7250,23 @@ func (s *ClaimableBalanceEntry) EncodeTo(e *xdr.Encoder) error { var _ decoderFrom = (*ClaimableBalanceEntry)(nil) // DecodeFrom decodes this value using the Decoder. -func (s *ClaimableBalanceEntry) DecodeFrom(d *xdr.Decoder) (int, error) { +func (s *ClaimableBalanceEntry) DecodeFrom(d *xdr.Decoder, maxDepth uint) (int, error) { + if maxDepth == 0 { + return 0, fmt.Errorf("decoding ClaimableBalanceEntry: %w", ErrMaxDecodingDepthReached) + } + maxDepth -= 1 var err error var n, nTmp int - nTmp, err = s.BalanceId.DecodeFrom(d) + nTmp, err = s.BalanceId.DecodeFrom(d, maxDepth) n += nTmp if err != nil { - return n, fmt.Errorf("decoding ClaimableBalanceId: %s", err) + return n, fmt.Errorf("decoding ClaimableBalanceId: %w", err) } var l uint32 l, nTmp, err = d.DecodeUint() n += nTmp if err != nil { - return n, fmt.Errorf("decoding Claimant: %s", err) + return n, fmt.Errorf("decoding Claimant: %w", err) } if l > 10 { return n, fmt.Errorf("decoding Claimant: data size (%d) exceeds size limit (10)", l) @@ -7020,27 +7275,27 @@ func (s *ClaimableBalanceEntry) DecodeFrom(d *xdr.Decoder) (int, error) { if l > 0 { s.Claimants = make([]Claimant, l) for i := uint32(0); i < l; i++ { - nTmp, err = s.Claimants[i].DecodeFrom(d) + nTmp, err = s.Claimants[i].DecodeFrom(d, maxDepth) n += nTmp if err != nil { - return n, fmt.Errorf("decoding Claimant: %s", err) + return n, fmt.Errorf("decoding Claimant: %w", err) } } } - nTmp, err = s.Asset.DecodeFrom(d) + nTmp, err = s.Asset.DecodeFrom(d, maxDepth) n += nTmp if err != nil { - return n, fmt.Errorf("decoding Asset: %s", err) + return n, fmt.Errorf("decoding Asset: %w", err) } - nTmp, err = s.Amount.DecodeFrom(d) + nTmp, err = s.Amount.DecodeFrom(d, maxDepth) n += nTmp if err != nil { - return n, fmt.Errorf("decoding Int64: %s", err) + return n, fmt.Errorf("decoding Int64: %w", err) } - nTmp, err = s.Ext.DecodeFrom(d) + nTmp, err = s.Ext.DecodeFrom(d, maxDepth) n += nTmp if err != nil { - return n, fmt.Errorf("decoding ClaimableBalanceEntryExt: %s", err) + return n, fmt.Errorf("decoding ClaimableBalanceEntryExt: %w", err) } return n, nil } @@ -7057,7 +7312,7 @@ func (s ClaimableBalanceEntry) MarshalBinary() ([]byte, error) { func (s *ClaimableBalanceEntry) UnmarshalBinary(inp []byte) error { r := bytes.NewReader(inp) d := xdr.NewDecoder(r) - _, err := s.DecodeFrom(d) + _, err := s.DecodeFrom(d, xdr.DecodeDefaultMaxDepth) return err } @@ -7104,23 +7359,27 @@ func (s *LiquidityPoolConstantProductParameters) EncodeTo(e *xdr.Encoder) error var _ decoderFrom = (*LiquidityPoolConstantProductParameters)(nil) // DecodeFrom decodes this value using the Decoder. -func (s *LiquidityPoolConstantProductParameters) DecodeFrom(d *xdr.Decoder) (int, error) { +func (s *LiquidityPoolConstantProductParameters) DecodeFrom(d *xdr.Decoder, maxDepth uint) (int, error) { + if maxDepth == 0 { + return 0, fmt.Errorf("decoding LiquidityPoolConstantProductParameters: %w", ErrMaxDecodingDepthReached) + } + maxDepth -= 1 var err error var n, nTmp int - nTmp, err = s.AssetA.DecodeFrom(d) + nTmp, err = s.AssetA.DecodeFrom(d, maxDepth) n += nTmp if err != nil { - return n, fmt.Errorf("decoding Asset: %s", err) + return n, fmt.Errorf("decoding Asset: %w", err) } - nTmp, err = s.AssetB.DecodeFrom(d) + nTmp, err = s.AssetB.DecodeFrom(d, maxDepth) n += nTmp if err != nil { - return n, fmt.Errorf("decoding Asset: %s", err) + return n, fmt.Errorf("decoding Asset: %w", err) } - nTmp, err = s.Fee.DecodeFrom(d) + nTmp, err = s.Fee.DecodeFrom(d, maxDepth) n += nTmp if err != nil { - return n, fmt.Errorf("decoding Int32: %s", err) + return n, fmt.Errorf("decoding Int32: %w", err) } return n, nil } @@ -7137,7 +7396,7 @@ func (s LiquidityPoolConstantProductParameters) MarshalBinary() ([]byte, error) func (s *LiquidityPoolConstantProductParameters) UnmarshalBinary(inp []byte) error { r := bytes.NewReader(inp) d := xdr.NewDecoder(r) - _, err := s.DecodeFrom(d) + _, err := s.DecodeFrom(d, xdr.DecodeDefaultMaxDepth) return err } @@ -7196,33 +7455,37 @@ func (s *LiquidityPoolEntryConstantProduct) EncodeTo(e *xdr.Encoder) error { var _ decoderFrom = (*LiquidityPoolEntryConstantProduct)(nil) // DecodeFrom decodes this value using the Decoder. -func (s *LiquidityPoolEntryConstantProduct) DecodeFrom(d *xdr.Decoder) (int, error) { +func (s *LiquidityPoolEntryConstantProduct) DecodeFrom(d *xdr.Decoder, maxDepth uint) (int, error) { + if maxDepth == 0 { + return 0, fmt.Errorf("decoding LiquidityPoolEntryConstantProduct: %w", ErrMaxDecodingDepthReached) + } + maxDepth -= 1 var err error var n, nTmp int - nTmp, err = s.Params.DecodeFrom(d) + nTmp, err = s.Params.DecodeFrom(d, maxDepth) n += nTmp if err != nil { - return n, fmt.Errorf("decoding LiquidityPoolConstantProductParameters: %s", err) + return n, fmt.Errorf("decoding LiquidityPoolConstantProductParameters: %w", err) } - nTmp, err = s.ReserveA.DecodeFrom(d) + nTmp, err = s.ReserveA.DecodeFrom(d, maxDepth) n += nTmp if err != nil { - return n, fmt.Errorf("decoding Int64: %s", err) + return n, fmt.Errorf("decoding Int64: %w", err) } - nTmp, err = s.ReserveB.DecodeFrom(d) + nTmp, err = s.ReserveB.DecodeFrom(d, maxDepth) n += nTmp if err != nil { - return n, fmt.Errorf("decoding Int64: %s", err) + return n, fmt.Errorf("decoding Int64: %w", err) } - nTmp, err = s.TotalPoolShares.DecodeFrom(d) + nTmp, err = s.TotalPoolShares.DecodeFrom(d, maxDepth) n += nTmp if err != nil { - return n, fmt.Errorf("decoding Int64: %s", err) + return n, fmt.Errorf("decoding Int64: %w", err) } - nTmp, err = s.PoolSharesTrustLineCount.DecodeFrom(d) + nTmp, err = s.PoolSharesTrustLineCount.DecodeFrom(d, maxDepth) n += nTmp if err != nil { - return n, fmt.Errorf("decoding Int64: %s", err) + return n, fmt.Errorf("decoding Int64: %w", err) } return n, nil } @@ -7239,7 +7502,7 @@ func (s LiquidityPoolEntryConstantProduct) MarshalBinary() ([]byte, error) { func (s *LiquidityPoolEntryConstantProduct) UnmarshalBinary(inp []byte) error { r := bytes.NewReader(inp) d := xdr.NewDecoder(r) - _, err := s.DecodeFrom(d) + _, err := s.DecodeFrom(d, xdr.DecodeDefaultMaxDepth) return err } @@ -7298,7 +7561,7 @@ func NewLiquidityPoolEntryBody(aType LiquidityPoolType, value interface{}) (resu case LiquidityPoolTypeLiquidityPoolConstantProduct: tv, ok := value.(LiquidityPoolEntryConstantProduct) if !ok { - err = fmt.Errorf("invalid value, must be LiquidityPoolEntryConstantProduct") + err = errors.New("invalid value, must be LiquidityPoolEntryConstantProduct") return } result.ConstantProduct = &tv @@ -7350,21 +7613,25 @@ func (u LiquidityPoolEntryBody) EncodeTo(e *xdr.Encoder) error { var _ decoderFrom = (*LiquidityPoolEntryBody)(nil) // DecodeFrom decodes this value using the Decoder. -func (u *LiquidityPoolEntryBody) DecodeFrom(d *xdr.Decoder) (int, error) { +func (u *LiquidityPoolEntryBody) DecodeFrom(d *xdr.Decoder, maxDepth uint) (int, error) { + if maxDepth == 0 { + return 0, fmt.Errorf("decoding LiquidityPoolEntryBody: %w", ErrMaxDecodingDepthReached) + } + maxDepth -= 1 var err error var n, nTmp int - nTmp, err = u.Type.DecodeFrom(d) + nTmp, err = u.Type.DecodeFrom(d, maxDepth) n += nTmp if err != nil { - return n, fmt.Errorf("decoding LiquidityPoolType: %s", err) + return n, fmt.Errorf("decoding LiquidityPoolType: %w", err) } switch LiquidityPoolType(u.Type) { case LiquidityPoolTypeLiquidityPoolConstantProduct: u.ConstantProduct = new(LiquidityPoolEntryConstantProduct) - nTmp, err = (*u.ConstantProduct).DecodeFrom(d) + nTmp, err = (*u.ConstantProduct).DecodeFrom(d, maxDepth) n += nTmp if err != nil { - return n, fmt.Errorf("decoding LiquidityPoolEntryConstantProduct: %s", err) + return n, fmt.Errorf("decoding LiquidityPoolEntryConstantProduct: %w", err) } return n, nil } @@ -7383,7 +7650,7 @@ func (s LiquidityPoolEntryBody) MarshalBinary() ([]byte, error) { func (s *LiquidityPoolEntryBody) UnmarshalBinary(inp []byte) error { r := bytes.NewReader(inp) d := xdr.NewDecoder(r) - _, err := s.DecodeFrom(d) + _, err := s.DecodeFrom(d, xdr.DecodeDefaultMaxDepth) return err } @@ -7440,18 +7707,22 @@ func (s *LiquidityPoolEntry) EncodeTo(e *xdr.Encoder) error { var _ decoderFrom = (*LiquidityPoolEntry)(nil) // DecodeFrom decodes this value using the Decoder. -func (s *LiquidityPoolEntry) DecodeFrom(d *xdr.Decoder) (int, error) { +func (s *LiquidityPoolEntry) DecodeFrom(d *xdr.Decoder, maxDepth uint) (int, error) { + if maxDepth == 0 { + return 0, fmt.Errorf("decoding LiquidityPoolEntry: %w", ErrMaxDecodingDepthReached) + } + maxDepth -= 1 var err error var n, nTmp int - nTmp, err = s.LiquidityPoolId.DecodeFrom(d) + nTmp, err = s.LiquidityPoolId.DecodeFrom(d, maxDepth) n += nTmp if err != nil { - return n, fmt.Errorf("decoding PoolId: %s", err) + return n, fmt.Errorf("decoding PoolId: %w", err) } - nTmp, err = s.Body.DecodeFrom(d) + nTmp, err = s.Body.DecodeFrom(d, maxDepth) n += nTmp if err != nil { - return n, fmt.Errorf("decoding LiquidityPoolEntryBody: %s", err) + return n, fmt.Errorf("decoding LiquidityPoolEntryBody: %w", err) } return n, nil } @@ -7468,7 +7739,7 @@ func (s LiquidityPoolEntry) MarshalBinary() ([]byte, error) { func (s *LiquidityPoolEntry) UnmarshalBinary(inp []byte) error { r := bytes.NewReader(inp) d := xdr.NewDecoder(r) - _, err := s.DecodeFrom(d) + _, err := s.DecodeFrom(d, xdr.DecodeDefaultMaxDepth) return err } @@ -7526,10 +7797,14 @@ func (e ContractDataDurability) EncodeTo(enc *xdr.Encoder) error { var _ decoderFrom = (*ContractDataDurability)(nil) // DecodeFrom decodes this value using the Decoder. -func (e *ContractDataDurability) DecodeFrom(d *xdr.Decoder) (int, error) { +func (e *ContractDataDurability) DecodeFrom(d *xdr.Decoder, maxDepth uint) (int, error) { + if maxDepth == 0 { + return 0, fmt.Errorf("decoding ContractDataDurability: %w", ErrMaxDecodingDepthReached) + } + maxDepth -= 1 v, n, err := d.DecodeInt() if err != nil { - return n, fmt.Errorf("decoding ContractDataDurability: %s", err) + return n, fmt.Errorf("decoding ContractDataDurability: %w", err) } if _, ok := contractDataDurabilityMap[v]; !ok { return n, fmt.Errorf("'%d' is not a valid ContractDataDurability enum value", v) @@ -7550,7 +7825,7 @@ func (s ContractDataDurability) MarshalBinary() ([]byte, error) { func (s *ContractDataDurability) UnmarshalBinary(inp []byte) error { r := bytes.NewReader(inp) d := xdr.NewDecoder(r) - _, err := s.DecodeFrom(d) + _, err := s.DecodeFrom(d, xdr.DecodeDefaultMaxDepth) return err } @@ -7607,33 +7882,37 @@ func (s *ContractDataEntry) EncodeTo(e *xdr.Encoder) error { var _ decoderFrom = (*ContractDataEntry)(nil) // DecodeFrom decodes this value using the Decoder. -func (s *ContractDataEntry) DecodeFrom(d *xdr.Decoder) (int, error) { +func (s *ContractDataEntry) DecodeFrom(d *xdr.Decoder, maxDepth uint) (int, error) { + if maxDepth == 0 { + return 0, fmt.Errorf("decoding ContractDataEntry: %w", ErrMaxDecodingDepthReached) + } + maxDepth -= 1 var err error var n, nTmp int - nTmp, err = s.Ext.DecodeFrom(d) + nTmp, err = s.Ext.DecodeFrom(d, maxDepth) n += nTmp if err != nil { - return n, fmt.Errorf("decoding ExtensionPoint: %s", err) + return n, fmt.Errorf("decoding ExtensionPoint: %w", err) } - nTmp, err = s.Contract.DecodeFrom(d) + nTmp, err = s.Contract.DecodeFrom(d, maxDepth) n += nTmp if err != nil { - return n, fmt.Errorf("decoding ScAddress: %s", err) + return n, fmt.Errorf("decoding ScAddress: %w", err) } - nTmp, err = s.Key.DecodeFrom(d) + nTmp, err = s.Key.DecodeFrom(d, maxDepth) n += nTmp if err != nil { - return n, fmt.Errorf("decoding ScVal: %s", err) + return n, fmt.Errorf("decoding ScVal: %w", err) } - nTmp, err = s.Durability.DecodeFrom(d) + nTmp, err = s.Durability.DecodeFrom(d, maxDepth) n += nTmp if err != nil { - return n, fmt.Errorf("decoding ContractDataDurability: %s", err) + return n, fmt.Errorf("decoding ContractDataDurability: %w", err) } - nTmp, err = s.Val.DecodeFrom(d) + nTmp, err = s.Val.DecodeFrom(d, maxDepth) n += nTmp if err != nil { - return n, fmt.Errorf("decoding ScVal: %s", err) + return n, fmt.Errorf("decoding ScVal: %w", err) } return n, nil } @@ -7650,7 +7929,7 @@ func (s ContractDataEntry) MarshalBinary() ([]byte, error) { func (s *ContractDataEntry) UnmarshalBinary(inp []byte) error { r := bytes.NewReader(inp) d := xdr.NewDecoder(r) - _, err := s.DecodeFrom(d) + _, err := s.DecodeFrom(d, xdr.DecodeDefaultMaxDepth) return err } @@ -7697,23 +7976,27 @@ func (s *ContractCodeEntry) EncodeTo(e *xdr.Encoder) error { var _ decoderFrom = (*ContractCodeEntry)(nil) // DecodeFrom decodes this value using the Decoder. -func (s *ContractCodeEntry) DecodeFrom(d *xdr.Decoder) (int, error) { +func (s *ContractCodeEntry) DecodeFrom(d *xdr.Decoder, maxDepth uint) (int, error) { + if maxDepth == 0 { + return 0, fmt.Errorf("decoding ContractCodeEntry: %w", ErrMaxDecodingDepthReached) + } + maxDepth -= 1 var err error var n, nTmp int - nTmp, err = s.Ext.DecodeFrom(d) + nTmp, err = s.Ext.DecodeFrom(d, maxDepth) n += nTmp if err != nil { - return n, fmt.Errorf("decoding ExtensionPoint: %s", err) + return n, fmt.Errorf("decoding ExtensionPoint: %w", err) } - nTmp, err = s.Hash.DecodeFrom(d) + nTmp, err = s.Hash.DecodeFrom(d, maxDepth) n += nTmp if err != nil { - return n, fmt.Errorf("decoding Hash: %s", err) + return n, fmt.Errorf("decoding Hash: %w", err) } s.Code, nTmp, err = d.DecodeOpaque(0) n += nTmp if err != nil { - return n, fmt.Errorf("decoding Code: %s", err) + return n, fmt.Errorf("decoding Code: %w", err) } return n, nil } @@ -7730,7 +8013,7 @@ func (s ContractCodeEntry) MarshalBinary() ([]byte, error) { func (s *ContractCodeEntry) UnmarshalBinary(inp []byte) error { r := bytes.NewReader(inp) d := xdr.NewDecoder(r) - _, err := s.DecodeFrom(d) + _, err := s.DecodeFrom(d, xdr.DecodeDefaultMaxDepth) return err } @@ -7745,51 +8028,55 @@ func (s ContractCodeEntry) xdrType() {} var _ xdrType = (*ContractCodeEntry)(nil) -// ExpirationEntry is an XDR Struct defines as: +// TtlEntry is an XDR Struct defines as: // -// struct ExpirationEntry { -// // Hash of the LedgerKey that is associated with this ExpirationEntry +// struct TTLEntry { +// // Hash of the LedgerKey that is associated with this TTLEntry // Hash keyHash; -// uint32 expirationLedgerSeq; +// uint32 liveUntilLedgerSeq; // }; -type ExpirationEntry struct { - KeyHash Hash - ExpirationLedgerSeq Uint32 +type TtlEntry struct { + KeyHash Hash + LiveUntilLedgerSeq Uint32 } // EncodeTo encodes this value using the Encoder. -func (s *ExpirationEntry) EncodeTo(e *xdr.Encoder) error { +func (s *TtlEntry) EncodeTo(e *xdr.Encoder) error { var err error if err = s.KeyHash.EncodeTo(e); err != nil { return err } - if err = s.ExpirationLedgerSeq.EncodeTo(e); err != nil { + if err = s.LiveUntilLedgerSeq.EncodeTo(e); err != nil { return err } return nil } -var _ decoderFrom = (*ExpirationEntry)(nil) +var _ decoderFrom = (*TtlEntry)(nil) // DecodeFrom decodes this value using the Decoder. -func (s *ExpirationEntry) DecodeFrom(d *xdr.Decoder) (int, error) { +func (s *TtlEntry) DecodeFrom(d *xdr.Decoder, maxDepth uint) (int, error) { + if maxDepth == 0 { + return 0, fmt.Errorf("decoding TtlEntry: %w", ErrMaxDecodingDepthReached) + } + maxDepth -= 1 var err error var n, nTmp int - nTmp, err = s.KeyHash.DecodeFrom(d) + nTmp, err = s.KeyHash.DecodeFrom(d, maxDepth) n += nTmp if err != nil { - return n, fmt.Errorf("decoding Hash: %s", err) + return n, fmt.Errorf("decoding Hash: %w", err) } - nTmp, err = s.ExpirationLedgerSeq.DecodeFrom(d) + nTmp, err = s.LiveUntilLedgerSeq.DecodeFrom(d, maxDepth) n += nTmp if err != nil { - return n, fmt.Errorf("decoding Uint32: %s", err) + return n, fmt.Errorf("decoding Uint32: %w", err) } return n, nil } // MarshalBinary implements encoding.BinaryMarshaler. -func (s ExpirationEntry) MarshalBinary() ([]byte, error) { +func (s TtlEntry) MarshalBinary() ([]byte, error) { b := bytes.Buffer{} e := xdr.NewEncoder(&b) err := s.EncodeTo(e) @@ -7797,23 +8084,23 @@ func (s ExpirationEntry) MarshalBinary() ([]byte, error) { } // UnmarshalBinary implements encoding.BinaryUnmarshaler. -func (s *ExpirationEntry) UnmarshalBinary(inp []byte) error { +func (s *TtlEntry) UnmarshalBinary(inp []byte) error { r := bytes.NewReader(inp) d := xdr.NewDecoder(r) - _, err := s.DecodeFrom(d) + _, err := s.DecodeFrom(d, xdr.DecodeDefaultMaxDepth) return err } var ( - _ encoding.BinaryMarshaler = (*ExpirationEntry)(nil) - _ encoding.BinaryUnmarshaler = (*ExpirationEntry)(nil) + _ encoding.BinaryMarshaler = (*TtlEntry)(nil) + _ encoding.BinaryUnmarshaler = (*TtlEntry)(nil) ) // xdrType signals that this type is an type representing // representing XDR values defined by this package. -func (s ExpirationEntry) xdrType() {} +func (s TtlEntry) xdrType() {} -var _ xdrType = (*ExpirationEntry)(nil) +var _ xdrType = (*TtlEntry)(nil) // LedgerEntryExtensionV1Ext is an XDR NestedUnion defines as: // @@ -7869,13 +8156,17 @@ func (u LedgerEntryExtensionV1Ext) EncodeTo(e *xdr.Encoder) error { var _ decoderFrom = (*LedgerEntryExtensionV1Ext)(nil) // DecodeFrom decodes this value using the Decoder. -func (u *LedgerEntryExtensionV1Ext) DecodeFrom(d *xdr.Decoder) (int, error) { +func (u *LedgerEntryExtensionV1Ext) DecodeFrom(d *xdr.Decoder, maxDepth uint) (int, error) { + if maxDepth == 0 { + return 0, fmt.Errorf("decoding LedgerEntryExtensionV1Ext: %w", ErrMaxDecodingDepthReached) + } + maxDepth -= 1 var err error var n, nTmp int u.V, nTmp, err = d.DecodeInt() n += nTmp if err != nil { - return n, fmt.Errorf("decoding Int: %s", err) + return n, fmt.Errorf("decoding Int: %w", err) } switch int32(u.V) { case 0: @@ -7897,7 +8188,7 @@ func (s LedgerEntryExtensionV1Ext) MarshalBinary() ([]byte, error) { func (s *LedgerEntryExtensionV1Ext) UnmarshalBinary(inp []byte) error { r := bytes.NewReader(inp) d := xdr.NewDecoder(r) - _, err := s.DecodeFrom(d) + _, err := s.DecodeFrom(d, xdr.DecodeDefaultMaxDepth) return err } @@ -7950,28 +8241,32 @@ func (s *LedgerEntryExtensionV1) EncodeTo(e *xdr.Encoder) error { var _ decoderFrom = (*LedgerEntryExtensionV1)(nil) // DecodeFrom decodes this value using the Decoder. -func (s *LedgerEntryExtensionV1) DecodeFrom(d *xdr.Decoder) (int, error) { +func (s *LedgerEntryExtensionV1) DecodeFrom(d *xdr.Decoder, maxDepth uint) (int, error) { + if maxDepth == 0 { + return 0, fmt.Errorf("decoding LedgerEntryExtensionV1: %w", ErrMaxDecodingDepthReached) + } + maxDepth -= 1 var err error var n, nTmp int var b bool b, nTmp, err = d.DecodeBool() n += nTmp if err != nil { - return n, fmt.Errorf("decoding SponsorshipDescriptor: %s", err) + return n, fmt.Errorf("decoding SponsorshipDescriptor: %w", err) } s.SponsoringId = nil if b { s.SponsoringId = new(AccountId) - nTmp, err = s.SponsoringId.DecodeFrom(d) + nTmp, err = s.SponsoringId.DecodeFrom(d, maxDepth) n += nTmp if err != nil { - return n, fmt.Errorf("decoding SponsorshipDescriptor: %s", err) + return n, fmt.Errorf("decoding SponsorshipDescriptor: %w", err) } } - nTmp, err = s.Ext.DecodeFrom(d) + nTmp, err = s.Ext.DecodeFrom(d, maxDepth) n += nTmp if err != nil { - return n, fmt.Errorf("decoding LedgerEntryExtensionV1Ext: %s", err) + return n, fmt.Errorf("decoding LedgerEntryExtensionV1Ext: %w", err) } return n, nil } @@ -7988,7 +8283,7 @@ func (s LedgerEntryExtensionV1) MarshalBinary() ([]byte, error) { func (s *LedgerEntryExtensionV1) UnmarshalBinary(inp []byte) error { r := bytes.NewReader(inp) d := xdr.NewDecoder(r) - _, err := s.DecodeFrom(d) + _, err := s.DecodeFrom(d, xdr.DecodeDefaultMaxDepth) return err } @@ -8025,8 +8320,8 @@ var _ xdrType = (*LedgerEntryExtensionV1)(nil) // ContractCodeEntry contractCode; // case CONFIG_SETTING: // ConfigSettingEntry configSetting; -// case EXPIRATION: -// ExpirationEntry expiration; +// case TTL: +// TTLEntry ttl; // } type LedgerEntryData struct { Type LedgerEntryType @@ -8039,7 +8334,7 @@ type LedgerEntryData struct { ContractData *ContractDataEntry ContractCode *ContractCodeEntry ConfigSetting *ConfigSettingEntry - Expiration *ExpirationEntry + Ttl *TtlEntry } // SwitchFieldName returns the field name in which this union's @@ -8070,8 +8365,8 @@ func (u LedgerEntryData) ArmForSwitch(sw int32) (string, bool) { return "ContractCode", true case LedgerEntryTypeConfigSetting: return "ConfigSetting", true - case LedgerEntryTypeExpiration: - return "Expiration", true + case LedgerEntryTypeTtl: + return "Ttl", true } return "-", false } @@ -8083,73 +8378,73 @@ func NewLedgerEntryData(aType LedgerEntryType, value interface{}) (result Ledger case LedgerEntryTypeAccount: tv, ok := value.(AccountEntry) if !ok { - err = fmt.Errorf("invalid value, must be AccountEntry") + err = errors.New("invalid value, must be AccountEntry") return } result.Account = &tv case LedgerEntryTypeTrustline: tv, ok := value.(TrustLineEntry) if !ok { - err = fmt.Errorf("invalid value, must be TrustLineEntry") + err = errors.New("invalid value, must be TrustLineEntry") return } result.TrustLine = &tv case LedgerEntryTypeOffer: tv, ok := value.(OfferEntry) if !ok { - err = fmt.Errorf("invalid value, must be OfferEntry") + err = errors.New("invalid value, must be OfferEntry") return } result.Offer = &tv case LedgerEntryTypeData: tv, ok := value.(DataEntry) if !ok { - err = fmt.Errorf("invalid value, must be DataEntry") + err = errors.New("invalid value, must be DataEntry") return } result.Data = &tv case LedgerEntryTypeClaimableBalance: tv, ok := value.(ClaimableBalanceEntry) if !ok { - err = fmt.Errorf("invalid value, must be ClaimableBalanceEntry") + err = errors.New("invalid value, must be ClaimableBalanceEntry") return } result.ClaimableBalance = &tv case LedgerEntryTypeLiquidityPool: tv, ok := value.(LiquidityPoolEntry) if !ok { - err = fmt.Errorf("invalid value, must be LiquidityPoolEntry") + err = errors.New("invalid value, must be LiquidityPoolEntry") return } result.LiquidityPool = &tv case LedgerEntryTypeContractData: tv, ok := value.(ContractDataEntry) if !ok { - err = fmt.Errorf("invalid value, must be ContractDataEntry") + err = errors.New("invalid value, must be ContractDataEntry") return } result.ContractData = &tv case LedgerEntryTypeContractCode: tv, ok := value.(ContractCodeEntry) if !ok { - err = fmt.Errorf("invalid value, must be ContractCodeEntry") + err = errors.New("invalid value, must be ContractCodeEntry") return } result.ContractCode = &tv case LedgerEntryTypeConfigSetting: tv, ok := value.(ConfigSettingEntry) if !ok { - err = fmt.Errorf("invalid value, must be ConfigSettingEntry") + err = errors.New("invalid value, must be ConfigSettingEntry") return } result.ConfigSetting = &tv - case LedgerEntryTypeExpiration: - tv, ok := value.(ExpirationEntry) + case LedgerEntryTypeTtl: + tv, ok := value.(TtlEntry) if !ok { - err = fmt.Errorf("invalid value, must be ExpirationEntry") + err = errors.New("invalid value, must be TtlEntry") return } - result.Expiration = &tv + result.Ttl = &tv } return } @@ -8379,25 +8674,25 @@ func (u LedgerEntryData) GetConfigSetting() (result ConfigSettingEntry, ok bool) return } -// MustExpiration retrieves the Expiration value from the union, +// MustTtl retrieves the Ttl value from the union, // panicing if the value is not set. -func (u LedgerEntryData) MustExpiration() ExpirationEntry { - val, ok := u.GetExpiration() +func (u LedgerEntryData) MustTtl() TtlEntry { + val, ok := u.GetTtl() if !ok { - panic("arm Expiration is not set") + panic("arm Ttl is not set") } return val } -// GetExpiration retrieves the Expiration value from the union, +// GetTtl retrieves the Ttl value from the union, // returning ok if the union's switch indicated the value is valid. -func (u LedgerEntryData) GetExpiration() (result ExpirationEntry, ok bool) { +func (u LedgerEntryData) GetTtl() (result TtlEntry, ok bool) { armName, _ := u.ArmForSwitch(int32(u.Type)) - if armName == "Expiration" { - result = *u.Expiration + if armName == "Ttl" { + result = *u.Ttl ok = true } @@ -8456,8 +8751,8 @@ func (u LedgerEntryData) EncodeTo(e *xdr.Encoder) error { return err } return nil - case LedgerEntryTypeExpiration: - if err = (*u.Expiration).EncodeTo(e); err != nil { + case LedgerEntryTypeTtl: + if err = (*u.Ttl).EncodeTo(e); err != nil { return err } return nil @@ -8468,93 +8763,97 @@ func (u LedgerEntryData) EncodeTo(e *xdr.Encoder) error { var _ decoderFrom = (*LedgerEntryData)(nil) // DecodeFrom decodes this value using the Decoder. -func (u *LedgerEntryData) DecodeFrom(d *xdr.Decoder) (int, error) { +func (u *LedgerEntryData) DecodeFrom(d *xdr.Decoder, maxDepth uint) (int, error) { + if maxDepth == 0 { + return 0, fmt.Errorf("decoding LedgerEntryData: %w", ErrMaxDecodingDepthReached) + } + maxDepth -= 1 var err error var n, nTmp int - nTmp, err = u.Type.DecodeFrom(d) + nTmp, err = u.Type.DecodeFrom(d, maxDepth) n += nTmp if err != nil { - return n, fmt.Errorf("decoding LedgerEntryType: %s", err) + return n, fmt.Errorf("decoding LedgerEntryType: %w", err) } switch LedgerEntryType(u.Type) { case LedgerEntryTypeAccount: u.Account = new(AccountEntry) - nTmp, err = (*u.Account).DecodeFrom(d) + nTmp, err = (*u.Account).DecodeFrom(d, maxDepth) n += nTmp if err != nil { - return n, fmt.Errorf("decoding AccountEntry: %s", err) + return n, fmt.Errorf("decoding AccountEntry: %w", err) } return n, nil case LedgerEntryTypeTrustline: u.TrustLine = new(TrustLineEntry) - nTmp, err = (*u.TrustLine).DecodeFrom(d) + nTmp, err = (*u.TrustLine).DecodeFrom(d, maxDepth) n += nTmp if err != nil { - return n, fmt.Errorf("decoding TrustLineEntry: %s", err) + return n, fmt.Errorf("decoding TrustLineEntry: %w", err) } return n, nil case LedgerEntryTypeOffer: u.Offer = new(OfferEntry) - nTmp, err = (*u.Offer).DecodeFrom(d) + nTmp, err = (*u.Offer).DecodeFrom(d, maxDepth) n += nTmp if err != nil { - return n, fmt.Errorf("decoding OfferEntry: %s", err) + return n, fmt.Errorf("decoding OfferEntry: %w", err) } return n, nil case LedgerEntryTypeData: u.Data = new(DataEntry) - nTmp, err = (*u.Data).DecodeFrom(d) + nTmp, err = (*u.Data).DecodeFrom(d, maxDepth) n += nTmp if err != nil { - return n, fmt.Errorf("decoding DataEntry: %s", err) + return n, fmt.Errorf("decoding DataEntry: %w", err) } return n, nil case LedgerEntryTypeClaimableBalance: u.ClaimableBalance = new(ClaimableBalanceEntry) - nTmp, err = (*u.ClaimableBalance).DecodeFrom(d) + nTmp, err = (*u.ClaimableBalance).DecodeFrom(d, maxDepth) n += nTmp if err != nil { - return n, fmt.Errorf("decoding ClaimableBalanceEntry: %s", err) + return n, fmt.Errorf("decoding ClaimableBalanceEntry: %w", err) } return n, nil case LedgerEntryTypeLiquidityPool: u.LiquidityPool = new(LiquidityPoolEntry) - nTmp, err = (*u.LiquidityPool).DecodeFrom(d) + nTmp, err = (*u.LiquidityPool).DecodeFrom(d, maxDepth) n += nTmp if err != nil { - return n, fmt.Errorf("decoding LiquidityPoolEntry: %s", err) + return n, fmt.Errorf("decoding LiquidityPoolEntry: %w", err) } return n, nil case LedgerEntryTypeContractData: u.ContractData = new(ContractDataEntry) - nTmp, err = (*u.ContractData).DecodeFrom(d) + nTmp, err = (*u.ContractData).DecodeFrom(d, maxDepth) n += nTmp if err != nil { - return n, fmt.Errorf("decoding ContractDataEntry: %s", err) + return n, fmt.Errorf("decoding ContractDataEntry: %w", err) } return n, nil case LedgerEntryTypeContractCode: u.ContractCode = new(ContractCodeEntry) - nTmp, err = (*u.ContractCode).DecodeFrom(d) + nTmp, err = (*u.ContractCode).DecodeFrom(d, maxDepth) n += nTmp if err != nil { - return n, fmt.Errorf("decoding ContractCodeEntry: %s", err) + return n, fmt.Errorf("decoding ContractCodeEntry: %w", err) } return n, nil case LedgerEntryTypeConfigSetting: u.ConfigSetting = new(ConfigSettingEntry) - nTmp, err = (*u.ConfigSetting).DecodeFrom(d) + nTmp, err = (*u.ConfigSetting).DecodeFrom(d, maxDepth) n += nTmp if err != nil { - return n, fmt.Errorf("decoding ConfigSettingEntry: %s", err) + return n, fmt.Errorf("decoding ConfigSettingEntry: %w", err) } return n, nil - case LedgerEntryTypeExpiration: - u.Expiration = new(ExpirationEntry) - nTmp, err = (*u.Expiration).DecodeFrom(d) + case LedgerEntryTypeTtl: + u.Ttl = new(TtlEntry) + nTmp, err = (*u.Ttl).DecodeFrom(d, maxDepth) n += nTmp if err != nil { - return n, fmt.Errorf("decoding ExpirationEntry: %s", err) + return n, fmt.Errorf("decoding TtlEntry: %w", err) } return n, nil } @@ -8573,7 +8872,7 @@ func (s LedgerEntryData) MarshalBinary() ([]byte, error) { func (s *LedgerEntryData) UnmarshalBinary(inp []byte) error { r := bytes.NewReader(inp) d := xdr.NewDecoder(r) - _, err := s.DecodeFrom(d) + _, err := s.DecodeFrom(d, xdr.DecodeDefaultMaxDepth) return err } @@ -8629,7 +8928,7 @@ func NewLedgerEntryExt(v int32, value interface{}) (result LedgerEntryExt, err e case 1: tv, ok := value.(LedgerEntryExtensionV1) if !ok { - err = fmt.Errorf("invalid value, must be LedgerEntryExtensionV1") + err = errors.New("invalid value, must be LedgerEntryExtensionV1") return } result.V1 = &tv @@ -8684,13 +8983,17 @@ func (u LedgerEntryExt) EncodeTo(e *xdr.Encoder) error { var _ decoderFrom = (*LedgerEntryExt)(nil) // DecodeFrom decodes this value using the Decoder. -func (u *LedgerEntryExt) DecodeFrom(d *xdr.Decoder) (int, error) { +func (u *LedgerEntryExt) DecodeFrom(d *xdr.Decoder, maxDepth uint) (int, error) { + if maxDepth == 0 { + return 0, fmt.Errorf("decoding LedgerEntryExt: %w", ErrMaxDecodingDepthReached) + } + maxDepth -= 1 var err error var n, nTmp int u.V, nTmp, err = d.DecodeInt() n += nTmp if err != nil { - return n, fmt.Errorf("decoding Int: %s", err) + return n, fmt.Errorf("decoding Int: %w", err) } switch int32(u.V) { case 0: @@ -8698,10 +9001,10 @@ func (u *LedgerEntryExt) DecodeFrom(d *xdr.Decoder) (int, error) { return n, nil case 1: u.V1 = new(LedgerEntryExtensionV1) - nTmp, err = (*u.V1).DecodeFrom(d) + nTmp, err = (*u.V1).DecodeFrom(d, maxDepth) n += nTmp if err != nil { - return n, fmt.Errorf("decoding LedgerEntryExtensionV1: %s", err) + return n, fmt.Errorf("decoding LedgerEntryExtensionV1: %w", err) } return n, nil } @@ -8720,7 +9023,7 @@ func (s LedgerEntryExt) MarshalBinary() ([]byte, error) { func (s *LedgerEntryExt) UnmarshalBinary(inp []byte) error { r := bytes.NewReader(inp) d := xdr.NewDecoder(r) - _, err := s.DecodeFrom(d) + _, err := s.DecodeFrom(d, xdr.DecodeDefaultMaxDepth) return err } @@ -8761,8 +9064,8 @@ var _ xdrType = (*LedgerEntryExt)(nil) // ContractCodeEntry contractCode; // case CONFIG_SETTING: // ConfigSettingEntry configSetting; -// case EXPIRATION: -// ExpirationEntry expiration; +// case TTL: +// TTLEntry ttl; // } // data; // @@ -8800,23 +9103,27 @@ func (s *LedgerEntry) EncodeTo(e *xdr.Encoder) error { var _ decoderFrom = (*LedgerEntry)(nil) // DecodeFrom decodes this value using the Decoder. -func (s *LedgerEntry) DecodeFrom(d *xdr.Decoder) (int, error) { +func (s *LedgerEntry) DecodeFrom(d *xdr.Decoder, maxDepth uint) (int, error) { + if maxDepth == 0 { + return 0, fmt.Errorf("decoding LedgerEntry: %w", ErrMaxDecodingDepthReached) + } + maxDepth -= 1 var err error var n, nTmp int - nTmp, err = s.LastModifiedLedgerSeq.DecodeFrom(d) + nTmp, err = s.LastModifiedLedgerSeq.DecodeFrom(d, maxDepth) n += nTmp if err != nil { - return n, fmt.Errorf("decoding Uint32: %s", err) + return n, fmt.Errorf("decoding Uint32: %w", err) } - nTmp, err = s.Data.DecodeFrom(d) + nTmp, err = s.Data.DecodeFrom(d, maxDepth) n += nTmp if err != nil { - return n, fmt.Errorf("decoding LedgerEntryData: %s", err) + return n, fmt.Errorf("decoding LedgerEntryData: %w", err) } - nTmp, err = s.Ext.DecodeFrom(d) + nTmp, err = s.Ext.DecodeFrom(d, maxDepth) n += nTmp if err != nil { - return n, fmt.Errorf("decoding LedgerEntryExt: %s", err) + return n, fmt.Errorf("decoding LedgerEntryExt: %w", err) } return n, nil } @@ -8833,7 +9140,7 @@ func (s LedgerEntry) MarshalBinary() ([]byte, error) { func (s *LedgerEntry) UnmarshalBinary(inp []byte) error { r := bytes.NewReader(inp) d := xdr.NewDecoder(r) - _, err := s.DecodeFrom(d) + _, err := s.DecodeFrom(d, xdr.DecodeDefaultMaxDepth) return err } @@ -8870,13 +9177,17 @@ func (s *LedgerKeyAccount) EncodeTo(e *xdr.Encoder) error { var _ decoderFrom = (*LedgerKeyAccount)(nil) // DecodeFrom decodes this value using the Decoder. -func (s *LedgerKeyAccount) DecodeFrom(d *xdr.Decoder) (int, error) { +func (s *LedgerKeyAccount) DecodeFrom(d *xdr.Decoder, maxDepth uint) (int, error) { + if maxDepth == 0 { + return 0, fmt.Errorf("decoding LedgerKeyAccount: %w", ErrMaxDecodingDepthReached) + } + maxDepth -= 1 var err error var n, nTmp int - nTmp, err = s.AccountId.DecodeFrom(d) + nTmp, err = s.AccountId.DecodeFrom(d, maxDepth) n += nTmp if err != nil { - return n, fmt.Errorf("decoding AccountId: %s", err) + return n, fmt.Errorf("decoding AccountId: %w", err) } return n, nil } @@ -8893,7 +9204,7 @@ func (s LedgerKeyAccount) MarshalBinary() ([]byte, error) { func (s *LedgerKeyAccount) UnmarshalBinary(inp []byte) error { r := bytes.NewReader(inp) d := xdr.NewDecoder(r) - _, err := s.DecodeFrom(d) + _, err := s.DecodeFrom(d, xdr.DecodeDefaultMaxDepth) return err } @@ -8935,18 +9246,22 @@ func (s *LedgerKeyTrustLine) EncodeTo(e *xdr.Encoder) error { var _ decoderFrom = (*LedgerKeyTrustLine)(nil) // DecodeFrom decodes this value using the Decoder. -func (s *LedgerKeyTrustLine) DecodeFrom(d *xdr.Decoder) (int, error) { +func (s *LedgerKeyTrustLine) DecodeFrom(d *xdr.Decoder, maxDepth uint) (int, error) { + if maxDepth == 0 { + return 0, fmt.Errorf("decoding LedgerKeyTrustLine: %w", ErrMaxDecodingDepthReached) + } + maxDepth -= 1 var err error var n, nTmp int - nTmp, err = s.AccountId.DecodeFrom(d) + nTmp, err = s.AccountId.DecodeFrom(d, maxDepth) n += nTmp if err != nil { - return n, fmt.Errorf("decoding AccountId: %s", err) + return n, fmt.Errorf("decoding AccountId: %w", err) } - nTmp, err = s.Asset.DecodeFrom(d) + nTmp, err = s.Asset.DecodeFrom(d, maxDepth) n += nTmp if err != nil { - return n, fmt.Errorf("decoding TrustLineAsset: %s", err) + return n, fmt.Errorf("decoding TrustLineAsset: %w", err) } return n, nil } @@ -8963,7 +9278,7 @@ func (s LedgerKeyTrustLine) MarshalBinary() ([]byte, error) { func (s *LedgerKeyTrustLine) UnmarshalBinary(inp []byte) error { r := bytes.NewReader(inp) d := xdr.NewDecoder(r) - _, err := s.DecodeFrom(d) + _, err := s.DecodeFrom(d, xdr.DecodeDefaultMaxDepth) return err } @@ -9005,18 +9320,22 @@ func (s *LedgerKeyOffer) EncodeTo(e *xdr.Encoder) error { var _ decoderFrom = (*LedgerKeyOffer)(nil) // DecodeFrom decodes this value using the Decoder. -func (s *LedgerKeyOffer) DecodeFrom(d *xdr.Decoder) (int, error) { +func (s *LedgerKeyOffer) DecodeFrom(d *xdr.Decoder, maxDepth uint) (int, error) { + if maxDepth == 0 { + return 0, fmt.Errorf("decoding LedgerKeyOffer: %w", ErrMaxDecodingDepthReached) + } + maxDepth -= 1 var err error var n, nTmp int - nTmp, err = s.SellerId.DecodeFrom(d) + nTmp, err = s.SellerId.DecodeFrom(d, maxDepth) n += nTmp if err != nil { - return n, fmt.Errorf("decoding AccountId: %s", err) + return n, fmt.Errorf("decoding AccountId: %w", err) } - nTmp, err = s.OfferId.DecodeFrom(d) + nTmp, err = s.OfferId.DecodeFrom(d, maxDepth) n += nTmp if err != nil { - return n, fmt.Errorf("decoding Int64: %s", err) + return n, fmt.Errorf("decoding Int64: %w", err) } return n, nil } @@ -9033,7 +9352,7 @@ func (s LedgerKeyOffer) MarshalBinary() ([]byte, error) { func (s *LedgerKeyOffer) UnmarshalBinary(inp []byte) error { r := bytes.NewReader(inp) d := xdr.NewDecoder(r) - _, err := s.DecodeFrom(d) + _, err := s.DecodeFrom(d, xdr.DecodeDefaultMaxDepth) return err } @@ -9075,18 +9394,22 @@ func (s *LedgerKeyData) EncodeTo(e *xdr.Encoder) error { var _ decoderFrom = (*LedgerKeyData)(nil) // DecodeFrom decodes this value using the Decoder. -func (s *LedgerKeyData) DecodeFrom(d *xdr.Decoder) (int, error) { +func (s *LedgerKeyData) DecodeFrom(d *xdr.Decoder, maxDepth uint) (int, error) { + if maxDepth == 0 { + return 0, fmt.Errorf("decoding LedgerKeyData: %w", ErrMaxDecodingDepthReached) + } + maxDepth -= 1 var err error var n, nTmp int - nTmp, err = s.AccountId.DecodeFrom(d) + nTmp, err = s.AccountId.DecodeFrom(d, maxDepth) n += nTmp if err != nil { - return n, fmt.Errorf("decoding AccountId: %s", err) + return n, fmt.Errorf("decoding AccountId: %w", err) } - nTmp, err = s.DataName.DecodeFrom(d) + nTmp, err = s.DataName.DecodeFrom(d, maxDepth) n += nTmp if err != nil { - return n, fmt.Errorf("decoding String64: %s", err) + return n, fmt.Errorf("decoding String64: %w", err) } return n, nil } @@ -9103,7 +9426,7 @@ func (s LedgerKeyData) MarshalBinary() ([]byte, error) { func (s *LedgerKeyData) UnmarshalBinary(inp []byte) error { r := bytes.NewReader(inp) d := xdr.NewDecoder(r) - _, err := s.DecodeFrom(d) + _, err := s.DecodeFrom(d, xdr.DecodeDefaultMaxDepth) return err } @@ -9140,13 +9463,17 @@ func (s *LedgerKeyClaimableBalance) EncodeTo(e *xdr.Encoder) error { var _ decoderFrom = (*LedgerKeyClaimableBalance)(nil) // DecodeFrom decodes this value using the Decoder. -func (s *LedgerKeyClaimableBalance) DecodeFrom(d *xdr.Decoder) (int, error) { +func (s *LedgerKeyClaimableBalance) DecodeFrom(d *xdr.Decoder, maxDepth uint) (int, error) { + if maxDepth == 0 { + return 0, fmt.Errorf("decoding LedgerKeyClaimableBalance: %w", ErrMaxDecodingDepthReached) + } + maxDepth -= 1 var err error var n, nTmp int - nTmp, err = s.BalanceId.DecodeFrom(d) + nTmp, err = s.BalanceId.DecodeFrom(d, maxDepth) n += nTmp if err != nil { - return n, fmt.Errorf("decoding ClaimableBalanceId: %s", err) + return n, fmt.Errorf("decoding ClaimableBalanceId: %w", err) } return n, nil } @@ -9163,7 +9490,7 @@ func (s LedgerKeyClaimableBalance) MarshalBinary() ([]byte, error) { func (s *LedgerKeyClaimableBalance) UnmarshalBinary(inp []byte) error { r := bytes.NewReader(inp) d := xdr.NewDecoder(r) - _, err := s.DecodeFrom(d) + _, err := s.DecodeFrom(d, xdr.DecodeDefaultMaxDepth) return err } @@ -9200,13 +9527,17 @@ func (s *LedgerKeyLiquidityPool) EncodeTo(e *xdr.Encoder) error { var _ decoderFrom = (*LedgerKeyLiquidityPool)(nil) // DecodeFrom decodes this value using the Decoder. -func (s *LedgerKeyLiquidityPool) DecodeFrom(d *xdr.Decoder) (int, error) { +func (s *LedgerKeyLiquidityPool) DecodeFrom(d *xdr.Decoder, maxDepth uint) (int, error) { + if maxDepth == 0 { + return 0, fmt.Errorf("decoding LedgerKeyLiquidityPool: %w", ErrMaxDecodingDepthReached) + } + maxDepth -= 1 var err error var n, nTmp int - nTmp, err = s.LiquidityPoolId.DecodeFrom(d) + nTmp, err = s.LiquidityPoolId.DecodeFrom(d, maxDepth) n += nTmp if err != nil { - return n, fmt.Errorf("decoding PoolId: %s", err) + return n, fmt.Errorf("decoding PoolId: %w", err) } return n, nil } @@ -9223,7 +9554,7 @@ func (s LedgerKeyLiquidityPool) MarshalBinary() ([]byte, error) { func (s *LedgerKeyLiquidityPool) UnmarshalBinary(inp []byte) error { r := bytes.NewReader(inp) d := xdr.NewDecoder(r) - _, err := s.DecodeFrom(d) + _, err := s.DecodeFrom(d, xdr.DecodeDefaultMaxDepth) return err } @@ -9270,23 +9601,27 @@ func (s *LedgerKeyContractData) EncodeTo(e *xdr.Encoder) error { var _ decoderFrom = (*LedgerKeyContractData)(nil) // DecodeFrom decodes this value using the Decoder. -func (s *LedgerKeyContractData) DecodeFrom(d *xdr.Decoder) (int, error) { +func (s *LedgerKeyContractData) DecodeFrom(d *xdr.Decoder, maxDepth uint) (int, error) { + if maxDepth == 0 { + return 0, fmt.Errorf("decoding LedgerKeyContractData: %w", ErrMaxDecodingDepthReached) + } + maxDepth -= 1 var err error var n, nTmp int - nTmp, err = s.Contract.DecodeFrom(d) + nTmp, err = s.Contract.DecodeFrom(d, maxDepth) n += nTmp if err != nil { - return n, fmt.Errorf("decoding ScAddress: %s", err) + return n, fmt.Errorf("decoding ScAddress: %w", err) } - nTmp, err = s.Key.DecodeFrom(d) + nTmp, err = s.Key.DecodeFrom(d, maxDepth) n += nTmp if err != nil { - return n, fmt.Errorf("decoding ScVal: %s", err) + return n, fmt.Errorf("decoding ScVal: %w", err) } - nTmp, err = s.Durability.DecodeFrom(d) + nTmp, err = s.Durability.DecodeFrom(d, maxDepth) n += nTmp if err != nil { - return n, fmt.Errorf("decoding ContractDataDurability: %s", err) + return n, fmt.Errorf("decoding ContractDataDurability: %w", err) } return n, nil } @@ -9303,7 +9638,7 @@ func (s LedgerKeyContractData) MarshalBinary() ([]byte, error) { func (s *LedgerKeyContractData) UnmarshalBinary(inp []byte) error { r := bytes.NewReader(inp) d := xdr.NewDecoder(r) - _, err := s.DecodeFrom(d) + _, err := s.DecodeFrom(d, xdr.DecodeDefaultMaxDepth) return err } @@ -9340,13 +9675,17 @@ func (s *LedgerKeyContractCode) EncodeTo(e *xdr.Encoder) error { var _ decoderFrom = (*LedgerKeyContractCode)(nil) // DecodeFrom decodes this value using the Decoder. -func (s *LedgerKeyContractCode) DecodeFrom(d *xdr.Decoder) (int, error) { +func (s *LedgerKeyContractCode) DecodeFrom(d *xdr.Decoder, maxDepth uint) (int, error) { + if maxDepth == 0 { + return 0, fmt.Errorf("decoding LedgerKeyContractCode: %w", ErrMaxDecodingDepthReached) + } + maxDepth -= 1 var err error var n, nTmp int - nTmp, err = s.Hash.DecodeFrom(d) + nTmp, err = s.Hash.DecodeFrom(d, maxDepth) n += nTmp if err != nil { - return n, fmt.Errorf("decoding Hash: %s", err) + return n, fmt.Errorf("decoding Hash: %w", err) } return n, nil } @@ -9363,7 +9702,7 @@ func (s LedgerKeyContractCode) MarshalBinary() ([]byte, error) { func (s *LedgerKeyContractCode) UnmarshalBinary(inp []byte) error { r := bytes.NewReader(inp) d := xdr.NewDecoder(r) - _, err := s.DecodeFrom(d) + _, err := s.DecodeFrom(d, xdr.DecodeDefaultMaxDepth) return err } @@ -9400,13 +9739,17 @@ func (s *LedgerKeyConfigSetting) EncodeTo(e *xdr.Encoder) error { var _ decoderFrom = (*LedgerKeyConfigSetting)(nil) // DecodeFrom decodes this value using the Decoder. -func (s *LedgerKeyConfigSetting) DecodeFrom(d *xdr.Decoder) (int, error) { +func (s *LedgerKeyConfigSetting) DecodeFrom(d *xdr.Decoder, maxDepth uint) (int, error) { + if maxDepth == 0 { + return 0, fmt.Errorf("decoding LedgerKeyConfigSetting: %w", ErrMaxDecodingDepthReached) + } + maxDepth -= 1 var err error var n, nTmp int - nTmp, err = s.ConfigSettingId.DecodeFrom(d) + nTmp, err = s.ConfigSettingId.DecodeFrom(d, maxDepth) n += nTmp if err != nil { - return n, fmt.Errorf("decoding ConfigSettingId: %s", err) + return n, fmt.Errorf("decoding ConfigSettingId: %w", err) } return n, nil } @@ -9423,7 +9766,7 @@ func (s LedgerKeyConfigSetting) MarshalBinary() ([]byte, error) { func (s *LedgerKeyConfigSetting) UnmarshalBinary(inp []byte) error { r := bytes.NewReader(inp) d := xdr.NewDecoder(r) - _, err := s.DecodeFrom(d) + _, err := s.DecodeFrom(d, xdr.DecodeDefaultMaxDepth) return err } @@ -9438,19 +9781,19 @@ func (s LedgerKeyConfigSetting) xdrType() {} var _ xdrType = (*LedgerKeyConfigSetting)(nil) -// LedgerKeyExpiration is an XDR NestedStruct defines as: +// LedgerKeyTtl is an XDR NestedStruct defines as: // // struct // { -// // Hash of the LedgerKey that is associated with this ExpirationEntry +// // Hash of the LedgerKey that is associated with this TTLEntry // Hash keyHash; // } -type LedgerKeyExpiration struct { +type LedgerKeyTtl struct { KeyHash Hash } // EncodeTo encodes this value using the Encoder. -func (s *LedgerKeyExpiration) EncodeTo(e *xdr.Encoder) error { +func (s *LedgerKeyTtl) EncodeTo(e *xdr.Encoder) error { var err error if err = s.KeyHash.EncodeTo(e); err != nil { return err @@ -9458,22 +9801,26 @@ func (s *LedgerKeyExpiration) EncodeTo(e *xdr.Encoder) error { return nil } -var _ decoderFrom = (*LedgerKeyExpiration)(nil) +var _ decoderFrom = (*LedgerKeyTtl)(nil) // DecodeFrom decodes this value using the Decoder. -func (s *LedgerKeyExpiration) DecodeFrom(d *xdr.Decoder) (int, error) { +func (s *LedgerKeyTtl) DecodeFrom(d *xdr.Decoder, maxDepth uint) (int, error) { + if maxDepth == 0 { + return 0, fmt.Errorf("decoding LedgerKeyTtl: %w", ErrMaxDecodingDepthReached) + } + maxDepth -= 1 var err error var n, nTmp int - nTmp, err = s.KeyHash.DecodeFrom(d) + nTmp, err = s.KeyHash.DecodeFrom(d, maxDepth) n += nTmp if err != nil { - return n, fmt.Errorf("decoding Hash: %s", err) + return n, fmt.Errorf("decoding Hash: %w", err) } return n, nil } // MarshalBinary implements encoding.BinaryMarshaler. -func (s LedgerKeyExpiration) MarshalBinary() ([]byte, error) { +func (s LedgerKeyTtl) MarshalBinary() ([]byte, error) { b := bytes.Buffer{} e := xdr.NewEncoder(&b) err := s.EncodeTo(e) @@ -9481,23 +9828,23 @@ func (s LedgerKeyExpiration) MarshalBinary() ([]byte, error) { } // UnmarshalBinary implements encoding.BinaryUnmarshaler. -func (s *LedgerKeyExpiration) UnmarshalBinary(inp []byte) error { +func (s *LedgerKeyTtl) UnmarshalBinary(inp []byte) error { r := bytes.NewReader(inp) d := xdr.NewDecoder(r) - _, err := s.DecodeFrom(d) + _, err := s.DecodeFrom(d, xdr.DecodeDefaultMaxDepth) return err } var ( - _ encoding.BinaryMarshaler = (*LedgerKeyExpiration)(nil) - _ encoding.BinaryUnmarshaler = (*LedgerKeyExpiration)(nil) + _ encoding.BinaryMarshaler = (*LedgerKeyTtl)(nil) + _ encoding.BinaryUnmarshaler = (*LedgerKeyTtl)(nil) ) // xdrType signals that this type is an type representing // representing XDR values defined by this package. -func (s LedgerKeyExpiration) xdrType() {} +func (s LedgerKeyTtl) xdrType() {} -var _ xdrType = (*LedgerKeyExpiration)(nil) +var _ xdrType = (*LedgerKeyTtl)(nil) // LedgerKey is an XDR Union defines as: // @@ -9558,12 +9905,12 @@ var _ xdrType = (*LedgerKeyExpiration)(nil) // { // ConfigSettingID configSettingID; // } configSetting; -// case EXPIRATION: +// case TTL: // struct // { -// // Hash of the LedgerKey that is associated with this ExpirationEntry +// // Hash of the LedgerKey that is associated with this TTLEntry // Hash keyHash; -// } expiration; +// } ttl; // }; type LedgerKey struct { Type LedgerEntryType @@ -9576,7 +9923,7 @@ type LedgerKey struct { ContractData *LedgerKeyContractData ContractCode *LedgerKeyContractCode ConfigSetting *LedgerKeyConfigSetting - Expiration *LedgerKeyExpiration + Ttl *LedgerKeyTtl } // SwitchFieldName returns the field name in which this union's @@ -9607,8 +9954,8 @@ func (u LedgerKey) ArmForSwitch(sw int32) (string, bool) { return "ContractCode", true case LedgerEntryTypeConfigSetting: return "ConfigSetting", true - case LedgerEntryTypeExpiration: - return "Expiration", true + case LedgerEntryTypeTtl: + return "Ttl", true } return "-", false } @@ -9620,73 +9967,73 @@ func NewLedgerKey(aType LedgerEntryType, value interface{}) (result LedgerKey, e case LedgerEntryTypeAccount: tv, ok := value.(LedgerKeyAccount) if !ok { - err = fmt.Errorf("invalid value, must be LedgerKeyAccount") + err = errors.New("invalid value, must be LedgerKeyAccount") return } result.Account = &tv case LedgerEntryTypeTrustline: tv, ok := value.(LedgerKeyTrustLine) if !ok { - err = fmt.Errorf("invalid value, must be LedgerKeyTrustLine") + err = errors.New("invalid value, must be LedgerKeyTrustLine") return } result.TrustLine = &tv case LedgerEntryTypeOffer: tv, ok := value.(LedgerKeyOffer) if !ok { - err = fmt.Errorf("invalid value, must be LedgerKeyOffer") + err = errors.New("invalid value, must be LedgerKeyOffer") return } result.Offer = &tv case LedgerEntryTypeData: tv, ok := value.(LedgerKeyData) if !ok { - err = fmt.Errorf("invalid value, must be LedgerKeyData") + err = errors.New("invalid value, must be LedgerKeyData") return } result.Data = &tv case LedgerEntryTypeClaimableBalance: tv, ok := value.(LedgerKeyClaimableBalance) if !ok { - err = fmt.Errorf("invalid value, must be LedgerKeyClaimableBalance") + err = errors.New("invalid value, must be LedgerKeyClaimableBalance") return } result.ClaimableBalance = &tv case LedgerEntryTypeLiquidityPool: tv, ok := value.(LedgerKeyLiquidityPool) if !ok { - err = fmt.Errorf("invalid value, must be LedgerKeyLiquidityPool") + err = errors.New("invalid value, must be LedgerKeyLiquidityPool") return } result.LiquidityPool = &tv case LedgerEntryTypeContractData: tv, ok := value.(LedgerKeyContractData) if !ok { - err = fmt.Errorf("invalid value, must be LedgerKeyContractData") + err = errors.New("invalid value, must be LedgerKeyContractData") return } result.ContractData = &tv case LedgerEntryTypeContractCode: tv, ok := value.(LedgerKeyContractCode) if !ok { - err = fmt.Errorf("invalid value, must be LedgerKeyContractCode") + err = errors.New("invalid value, must be LedgerKeyContractCode") return } result.ContractCode = &tv case LedgerEntryTypeConfigSetting: tv, ok := value.(LedgerKeyConfigSetting) if !ok { - err = fmt.Errorf("invalid value, must be LedgerKeyConfigSetting") + err = errors.New("invalid value, must be LedgerKeyConfigSetting") return } result.ConfigSetting = &tv - case LedgerEntryTypeExpiration: - tv, ok := value.(LedgerKeyExpiration) + case LedgerEntryTypeTtl: + tv, ok := value.(LedgerKeyTtl) if !ok { - err = fmt.Errorf("invalid value, must be LedgerKeyExpiration") + err = errors.New("invalid value, must be LedgerKeyTtl") return } - result.Expiration = &tv + result.Ttl = &tv } return } @@ -9916,25 +10263,25 @@ func (u LedgerKey) GetConfigSetting() (result LedgerKeyConfigSetting, ok bool) { return } -// MustExpiration retrieves the Expiration value from the union, +// MustTtl retrieves the Ttl value from the union, // panicing if the value is not set. -func (u LedgerKey) MustExpiration() LedgerKeyExpiration { - val, ok := u.GetExpiration() +func (u LedgerKey) MustTtl() LedgerKeyTtl { + val, ok := u.GetTtl() if !ok { - panic("arm Expiration is not set") + panic("arm Ttl is not set") } return val } -// GetExpiration retrieves the Expiration value from the union, +// GetTtl retrieves the Ttl value from the union, // returning ok if the union's switch indicated the value is valid. -func (u LedgerKey) GetExpiration() (result LedgerKeyExpiration, ok bool) { +func (u LedgerKey) GetTtl() (result LedgerKeyTtl, ok bool) { armName, _ := u.ArmForSwitch(int32(u.Type)) - if armName == "Expiration" { - result = *u.Expiration + if armName == "Ttl" { + result = *u.Ttl ok = true } @@ -9993,8 +10340,8 @@ func (u LedgerKey) EncodeTo(e *xdr.Encoder) error { return err } return nil - case LedgerEntryTypeExpiration: - if err = (*u.Expiration).EncodeTo(e); err != nil { + case LedgerEntryTypeTtl: + if err = (*u.Ttl).EncodeTo(e); err != nil { return err } return nil @@ -10005,93 +10352,97 @@ func (u LedgerKey) EncodeTo(e *xdr.Encoder) error { var _ decoderFrom = (*LedgerKey)(nil) // DecodeFrom decodes this value using the Decoder. -func (u *LedgerKey) DecodeFrom(d *xdr.Decoder) (int, error) { +func (u *LedgerKey) DecodeFrom(d *xdr.Decoder, maxDepth uint) (int, error) { + if maxDepth == 0 { + return 0, fmt.Errorf("decoding LedgerKey: %w", ErrMaxDecodingDepthReached) + } + maxDepth -= 1 var err error var n, nTmp int - nTmp, err = u.Type.DecodeFrom(d) + nTmp, err = u.Type.DecodeFrom(d, maxDepth) n += nTmp if err != nil { - return n, fmt.Errorf("decoding LedgerEntryType: %s", err) + return n, fmt.Errorf("decoding LedgerEntryType: %w", err) } switch LedgerEntryType(u.Type) { case LedgerEntryTypeAccount: u.Account = new(LedgerKeyAccount) - nTmp, err = (*u.Account).DecodeFrom(d) + nTmp, err = (*u.Account).DecodeFrom(d, maxDepth) n += nTmp if err != nil { - return n, fmt.Errorf("decoding LedgerKeyAccount: %s", err) + return n, fmt.Errorf("decoding LedgerKeyAccount: %w", err) } return n, nil case LedgerEntryTypeTrustline: u.TrustLine = new(LedgerKeyTrustLine) - nTmp, err = (*u.TrustLine).DecodeFrom(d) + nTmp, err = (*u.TrustLine).DecodeFrom(d, maxDepth) n += nTmp if err != nil { - return n, fmt.Errorf("decoding LedgerKeyTrustLine: %s", err) + return n, fmt.Errorf("decoding LedgerKeyTrustLine: %w", err) } return n, nil case LedgerEntryTypeOffer: u.Offer = new(LedgerKeyOffer) - nTmp, err = (*u.Offer).DecodeFrom(d) + nTmp, err = (*u.Offer).DecodeFrom(d, maxDepth) n += nTmp if err != nil { - return n, fmt.Errorf("decoding LedgerKeyOffer: %s", err) + return n, fmt.Errorf("decoding LedgerKeyOffer: %w", err) } return n, nil case LedgerEntryTypeData: u.Data = new(LedgerKeyData) - nTmp, err = (*u.Data).DecodeFrom(d) + nTmp, err = (*u.Data).DecodeFrom(d, maxDepth) n += nTmp if err != nil { - return n, fmt.Errorf("decoding LedgerKeyData: %s", err) + return n, fmt.Errorf("decoding LedgerKeyData: %w", err) } return n, nil case LedgerEntryTypeClaimableBalance: u.ClaimableBalance = new(LedgerKeyClaimableBalance) - nTmp, err = (*u.ClaimableBalance).DecodeFrom(d) + nTmp, err = (*u.ClaimableBalance).DecodeFrom(d, maxDepth) n += nTmp if err != nil { - return n, fmt.Errorf("decoding LedgerKeyClaimableBalance: %s", err) + return n, fmt.Errorf("decoding LedgerKeyClaimableBalance: %w", err) } return n, nil case LedgerEntryTypeLiquidityPool: u.LiquidityPool = new(LedgerKeyLiquidityPool) - nTmp, err = (*u.LiquidityPool).DecodeFrom(d) + nTmp, err = (*u.LiquidityPool).DecodeFrom(d, maxDepth) n += nTmp if err != nil { - return n, fmt.Errorf("decoding LedgerKeyLiquidityPool: %s", err) + return n, fmt.Errorf("decoding LedgerKeyLiquidityPool: %w", err) } return n, nil case LedgerEntryTypeContractData: u.ContractData = new(LedgerKeyContractData) - nTmp, err = (*u.ContractData).DecodeFrom(d) + nTmp, err = (*u.ContractData).DecodeFrom(d, maxDepth) n += nTmp if err != nil { - return n, fmt.Errorf("decoding LedgerKeyContractData: %s", err) + return n, fmt.Errorf("decoding LedgerKeyContractData: %w", err) } return n, nil case LedgerEntryTypeContractCode: u.ContractCode = new(LedgerKeyContractCode) - nTmp, err = (*u.ContractCode).DecodeFrom(d) + nTmp, err = (*u.ContractCode).DecodeFrom(d, maxDepth) n += nTmp if err != nil { - return n, fmt.Errorf("decoding LedgerKeyContractCode: %s", err) + return n, fmt.Errorf("decoding LedgerKeyContractCode: %w", err) } return n, nil case LedgerEntryTypeConfigSetting: u.ConfigSetting = new(LedgerKeyConfigSetting) - nTmp, err = (*u.ConfigSetting).DecodeFrom(d) + nTmp, err = (*u.ConfigSetting).DecodeFrom(d, maxDepth) n += nTmp if err != nil { - return n, fmt.Errorf("decoding LedgerKeyConfigSetting: %s", err) + return n, fmt.Errorf("decoding LedgerKeyConfigSetting: %w", err) } return n, nil - case LedgerEntryTypeExpiration: - u.Expiration = new(LedgerKeyExpiration) - nTmp, err = (*u.Expiration).DecodeFrom(d) + case LedgerEntryTypeTtl: + u.Ttl = new(LedgerKeyTtl) + nTmp, err = (*u.Ttl).DecodeFrom(d, maxDepth) n += nTmp if err != nil { - return n, fmt.Errorf("decoding LedgerKeyExpiration: %s", err) + return n, fmt.Errorf("decoding LedgerKeyTtl: %w", err) } return n, nil } @@ -10110,7 +10461,7 @@ func (s LedgerKey) MarshalBinary() ([]byte, error) { func (s *LedgerKey) UnmarshalBinary(inp []byte) error { r := bytes.NewReader(inp) d := xdr.NewDecoder(r) - _, err := s.DecodeFrom(d) + _, err := s.DecodeFrom(d, xdr.DecodeDefaultMaxDepth) return err } @@ -10193,10 +10544,14 @@ func (e EnvelopeType) EncodeTo(enc *xdr.Encoder) error { var _ decoderFrom = (*EnvelopeType)(nil) // DecodeFrom decodes this value using the Decoder. -func (e *EnvelopeType) DecodeFrom(d *xdr.Decoder) (int, error) { +func (e *EnvelopeType) DecodeFrom(d *xdr.Decoder, maxDepth uint) (int, error) { + if maxDepth == 0 { + return 0, fmt.Errorf("decoding EnvelopeType: %w", ErrMaxDecodingDepthReached) + } + maxDepth -= 1 v, n, err := d.DecodeInt() if err != nil { - return n, fmt.Errorf("decoding EnvelopeType: %s", err) + return n, fmt.Errorf("decoding EnvelopeType: %w", err) } if _, ok := envelopeTypeMap[v]; !ok { return n, fmt.Errorf("'%d' is not a valid EnvelopeType enum value", v) @@ -10217,7 +10572,7 @@ func (s EnvelopeType) MarshalBinary() ([]byte, error) { func (s *EnvelopeType) UnmarshalBinary(inp []byte) error { r := bytes.NewReader(inp) d := xdr.NewDecoder(r) - _, err := s.DecodeFrom(d) + _, err := s.DecodeFrom(d, xdr.DecodeDefaultMaxDepth) return err } @@ -10254,13 +10609,17 @@ func (s UpgradeType) EncodeTo(e *xdr.Encoder) error { var _ decoderFrom = (*UpgradeType)(nil) // DecodeFrom decodes this value using the Decoder. -func (s *UpgradeType) DecodeFrom(d *xdr.Decoder) (int, error) { +func (s *UpgradeType) DecodeFrom(d *xdr.Decoder, maxDepth uint) (int, error) { + if maxDepth == 0 { + return 0, fmt.Errorf("decoding UpgradeType: %w", ErrMaxDecodingDepthReached) + } + maxDepth -= 1 var err error var n, nTmp int (*s), nTmp, err = d.DecodeOpaque(128) n += nTmp if err != nil { - return n, fmt.Errorf("decoding UpgradeType: %s", err) + return n, fmt.Errorf("decoding UpgradeType: %w", err) } return n, nil } @@ -10277,7 +10636,7 @@ func (s UpgradeType) MarshalBinary() ([]byte, error) { func (s *UpgradeType) UnmarshalBinary(inp []byte) error { r := bytes.NewReader(inp) d := xdr.NewDecoder(r) - _, err := s.DecodeFrom(d) + _, err := s.DecodeFrom(d, xdr.DecodeDefaultMaxDepth) return err } @@ -10336,10 +10695,14 @@ func (e StellarValueType) EncodeTo(enc *xdr.Encoder) error { var _ decoderFrom = (*StellarValueType)(nil) // DecodeFrom decodes this value using the Decoder. -func (e *StellarValueType) DecodeFrom(d *xdr.Decoder) (int, error) { +func (e *StellarValueType) DecodeFrom(d *xdr.Decoder, maxDepth uint) (int, error) { + if maxDepth == 0 { + return 0, fmt.Errorf("decoding StellarValueType: %w", ErrMaxDecodingDepthReached) + } + maxDepth -= 1 v, n, err := d.DecodeInt() if err != nil { - return n, fmt.Errorf("decoding StellarValueType: %s", err) + return n, fmt.Errorf("decoding StellarValueType: %w", err) } if _, ok := stellarValueTypeMap[v]; !ok { return n, fmt.Errorf("'%d' is not a valid StellarValueType enum value", v) @@ -10360,7 +10723,7 @@ func (s StellarValueType) MarshalBinary() ([]byte, error) { func (s *StellarValueType) UnmarshalBinary(inp []byte) error { r := bytes.NewReader(inp) d := xdr.NewDecoder(r) - _, err := s.DecodeFrom(d) + _, err := s.DecodeFrom(d, xdr.DecodeDefaultMaxDepth) return err } @@ -10402,18 +10765,22 @@ func (s *LedgerCloseValueSignature) EncodeTo(e *xdr.Encoder) error { var _ decoderFrom = (*LedgerCloseValueSignature)(nil) // DecodeFrom decodes this value using the Decoder. -func (s *LedgerCloseValueSignature) DecodeFrom(d *xdr.Decoder) (int, error) { +func (s *LedgerCloseValueSignature) DecodeFrom(d *xdr.Decoder, maxDepth uint) (int, error) { + if maxDepth == 0 { + return 0, fmt.Errorf("decoding LedgerCloseValueSignature: %w", ErrMaxDecodingDepthReached) + } + maxDepth -= 1 var err error var n, nTmp int - nTmp, err = s.NodeId.DecodeFrom(d) + nTmp, err = s.NodeId.DecodeFrom(d, maxDepth) n += nTmp if err != nil { - return n, fmt.Errorf("decoding NodeId: %s", err) + return n, fmt.Errorf("decoding NodeId: %w", err) } - nTmp, err = s.Signature.DecodeFrom(d) + nTmp, err = s.Signature.DecodeFrom(d, maxDepth) n += nTmp if err != nil { - return n, fmt.Errorf("decoding Signature: %s", err) + return n, fmt.Errorf("decoding Signature: %w", err) } return n, nil } @@ -10430,7 +10797,7 @@ func (s LedgerCloseValueSignature) MarshalBinary() ([]byte, error) { func (s *LedgerCloseValueSignature) UnmarshalBinary(inp []byte) error { r := bytes.NewReader(inp) d := xdr.NewDecoder(r) - _, err := s.DecodeFrom(d) + _, err := s.DecodeFrom(d, xdr.DecodeDefaultMaxDepth) return err } @@ -10486,7 +10853,7 @@ func NewStellarValueExt(v StellarValueType, value interface{}) (result StellarVa case StellarValueTypeStellarValueSigned: tv, ok := value.(LedgerCloseValueSignature) if !ok { - err = fmt.Errorf("invalid value, must be LedgerCloseValueSignature") + err = errors.New("invalid value, must be LedgerCloseValueSignature") return } result.LcValueSignature = &tv @@ -10541,13 +10908,17 @@ func (u StellarValueExt) EncodeTo(e *xdr.Encoder) error { var _ decoderFrom = (*StellarValueExt)(nil) // DecodeFrom decodes this value using the Decoder. -func (u *StellarValueExt) DecodeFrom(d *xdr.Decoder) (int, error) { +func (u *StellarValueExt) DecodeFrom(d *xdr.Decoder, maxDepth uint) (int, error) { + if maxDepth == 0 { + return 0, fmt.Errorf("decoding StellarValueExt: %w", ErrMaxDecodingDepthReached) + } + maxDepth -= 1 var err error var n, nTmp int - nTmp, err = u.V.DecodeFrom(d) + nTmp, err = u.V.DecodeFrom(d, maxDepth) n += nTmp if err != nil { - return n, fmt.Errorf("decoding StellarValueType: %s", err) + return n, fmt.Errorf("decoding StellarValueType: %w", err) } switch StellarValueType(u.V) { case StellarValueTypeStellarValueBasic: @@ -10555,10 +10926,10 @@ func (u *StellarValueExt) DecodeFrom(d *xdr.Decoder) (int, error) { return n, nil case StellarValueTypeStellarValueSigned: u.LcValueSignature = new(LedgerCloseValueSignature) - nTmp, err = (*u.LcValueSignature).DecodeFrom(d) + nTmp, err = (*u.LcValueSignature).DecodeFrom(d, maxDepth) n += nTmp if err != nil { - return n, fmt.Errorf("decoding LedgerCloseValueSignature: %s", err) + return n, fmt.Errorf("decoding LedgerCloseValueSignature: %w", err) } return n, nil } @@ -10577,7 +10948,7 @@ func (s StellarValueExt) MarshalBinary() ([]byte, error) { func (s *StellarValueExt) UnmarshalBinary(inp []byte) error { r := bytes.NewReader(inp) d := xdr.NewDecoder(r) - _, err := s.DecodeFrom(d) + _, err := s.DecodeFrom(d, xdr.DecodeDefaultMaxDepth) return err } @@ -10649,24 +11020,28 @@ func (s *StellarValue) EncodeTo(e *xdr.Encoder) error { var _ decoderFrom = (*StellarValue)(nil) // DecodeFrom decodes this value using the Decoder. -func (s *StellarValue) DecodeFrom(d *xdr.Decoder) (int, error) { +func (s *StellarValue) DecodeFrom(d *xdr.Decoder, maxDepth uint) (int, error) { + if maxDepth == 0 { + return 0, fmt.Errorf("decoding StellarValue: %w", ErrMaxDecodingDepthReached) + } + maxDepth -= 1 var err error var n, nTmp int - nTmp, err = s.TxSetHash.DecodeFrom(d) + nTmp, err = s.TxSetHash.DecodeFrom(d, maxDepth) n += nTmp if err != nil { - return n, fmt.Errorf("decoding Hash: %s", err) + return n, fmt.Errorf("decoding Hash: %w", err) } - nTmp, err = s.CloseTime.DecodeFrom(d) + nTmp, err = s.CloseTime.DecodeFrom(d, maxDepth) n += nTmp if err != nil { - return n, fmt.Errorf("decoding TimePoint: %s", err) + return n, fmt.Errorf("decoding TimePoint: %w", err) } var l uint32 l, nTmp, err = d.DecodeUint() n += nTmp if err != nil { - return n, fmt.Errorf("decoding UpgradeType: %s", err) + return n, fmt.Errorf("decoding UpgradeType: %w", err) } if l > 6 { return n, fmt.Errorf("decoding UpgradeType: data size (%d) exceeds size limit (6)", l) @@ -10675,17 +11050,17 @@ func (s *StellarValue) DecodeFrom(d *xdr.Decoder) (int, error) { if l > 0 { s.Upgrades = make([]UpgradeType, l) for i := uint32(0); i < l; i++ { - nTmp, err = s.Upgrades[i].DecodeFrom(d) + nTmp, err = s.Upgrades[i].DecodeFrom(d, maxDepth) n += nTmp if err != nil { - return n, fmt.Errorf("decoding UpgradeType: %s", err) + return n, fmt.Errorf("decoding UpgradeType: %w", err) } } } - nTmp, err = s.Ext.DecodeFrom(d) + nTmp, err = s.Ext.DecodeFrom(d, maxDepth) n += nTmp if err != nil { - return n, fmt.Errorf("decoding StellarValueExt: %s", err) + return n, fmt.Errorf("decoding StellarValueExt: %w", err) } return n, nil } @@ -10702,7 +11077,7 @@ func (s StellarValue) MarshalBinary() ([]byte, error) { func (s *StellarValue) UnmarshalBinary(inp []byte) error { r := bytes.NewReader(inp) d := xdr.NewDecoder(r) - _, err := s.DecodeFrom(d) + _, err := s.DecodeFrom(d, xdr.DecodeDefaultMaxDepth) return err } @@ -10769,10 +11144,14 @@ func (e LedgerHeaderFlags) EncodeTo(enc *xdr.Encoder) error { var _ decoderFrom = (*LedgerHeaderFlags)(nil) // DecodeFrom decodes this value using the Decoder. -func (e *LedgerHeaderFlags) DecodeFrom(d *xdr.Decoder) (int, error) { +func (e *LedgerHeaderFlags) DecodeFrom(d *xdr.Decoder, maxDepth uint) (int, error) { + if maxDepth == 0 { + return 0, fmt.Errorf("decoding LedgerHeaderFlags: %w", ErrMaxDecodingDepthReached) + } + maxDepth -= 1 v, n, err := d.DecodeInt() if err != nil { - return n, fmt.Errorf("decoding LedgerHeaderFlags: %s", err) + return n, fmt.Errorf("decoding LedgerHeaderFlags: %w", err) } if _, ok := ledgerHeaderFlagsMap[v]; !ok { return n, fmt.Errorf("'%d' is not a valid LedgerHeaderFlags enum value", v) @@ -10793,7 +11172,7 @@ func (s LedgerHeaderFlags) MarshalBinary() ([]byte, error) { func (s *LedgerHeaderFlags) UnmarshalBinary(inp []byte) error { r := bytes.NewReader(inp) d := xdr.NewDecoder(r) - _, err := s.DecodeFrom(d) + _, err := s.DecodeFrom(d, xdr.DecodeDefaultMaxDepth) return err } @@ -10862,13 +11241,17 @@ func (u LedgerHeaderExtensionV1Ext) EncodeTo(e *xdr.Encoder) error { var _ decoderFrom = (*LedgerHeaderExtensionV1Ext)(nil) // DecodeFrom decodes this value using the Decoder. -func (u *LedgerHeaderExtensionV1Ext) DecodeFrom(d *xdr.Decoder) (int, error) { +func (u *LedgerHeaderExtensionV1Ext) DecodeFrom(d *xdr.Decoder, maxDepth uint) (int, error) { + if maxDepth == 0 { + return 0, fmt.Errorf("decoding LedgerHeaderExtensionV1Ext: %w", ErrMaxDecodingDepthReached) + } + maxDepth -= 1 var err error var n, nTmp int u.V, nTmp, err = d.DecodeInt() n += nTmp if err != nil { - return n, fmt.Errorf("decoding Int: %s", err) + return n, fmt.Errorf("decoding Int: %w", err) } switch int32(u.V) { case 0: @@ -10890,7 +11273,7 @@ func (s LedgerHeaderExtensionV1Ext) MarshalBinary() ([]byte, error) { func (s *LedgerHeaderExtensionV1Ext) UnmarshalBinary(inp []byte) error { r := bytes.NewReader(inp) d := xdr.NewDecoder(r) - _, err := s.DecodeFrom(d) + _, err := s.DecodeFrom(d, xdr.DecodeDefaultMaxDepth) return err } @@ -10938,18 +11321,22 @@ func (s *LedgerHeaderExtensionV1) EncodeTo(e *xdr.Encoder) error { var _ decoderFrom = (*LedgerHeaderExtensionV1)(nil) // DecodeFrom decodes this value using the Decoder. -func (s *LedgerHeaderExtensionV1) DecodeFrom(d *xdr.Decoder) (int, error) { +func (s *LedgerHeaderExtensionV1) DecodeFrom(d *xdr.Decoder, maxDepth uint) (int, error) { + if maxDepth == 0 { + return 0, fmt.Errorf("decoding LedgerHeaderExtensionV1: %w", ErrMaxDecodingDepthReached) + } + maxDepth -= 1 var err error var n, nTmp int - nTmp, err = s.Flags.DecodeFrom(d) + nTmp, err = s.Flags.DecodeFrom(d, maxDepth) n += nTmp if err != nil { - return n, fmt.Errorf("decoding Uint32: %s", err) + return n, fmt.Errorf("decoding Uint32: %w", err) } - nTmp, err = s.Ext.DecodeFrom(d) + nTmp, err = s.Ext.DecodeFrom(d, maxDepth) n += nTmp if err != nil { - return n, fmt.Errorf("decoding LedgerHeaderExtensionV1Ext: %s", err) + return n, fmt.Errorf("decoding LedgerHeaderExtensionV1Ext: %w", err) } return n, nil } @@ -10966,7 +11353,7 @@ func (s LedgerHeaderExtensionV1) MarshalBinary() ([]byte, error) { func (s *LedgerHeaderExtensionV1) UnmarshalBinary(inp []byte) error { r := bytes.NewReader(inp) d := xdr.NewDecoder(r) - _, err := s.DecodeFrom(d) + _, err := s.DecodeFrom(d, xdr.DecodeDefaultMaxDepth) return err } @@ -11022,7 +11409,7 @@ func NewLedgerHeaderExt(v int32, value interface{}) (result LedgerHeaderExt, err case 1: tv, ok := value.(LedgerHeaderExtensionV1) if !ok { - err = fmt.Errorf("invalid value, must be LedgerHeaderExtensionV1") + err = errors.New("invalid value, must be LedgerHeaderExtensionV1") return } result.V1 = &tv @@ -11077,13 +11464,17 @@ func (u LedgerHeaderExt) EncodeTo(e *xdr.Encoder) error { var _ decoderFrom = (*LedgerHeaderExt)(nil) // DecodeFrom decodes this value using the Decoder. -func (u *LedgerHeaderExt) DecodeFrom(d *xdr.Decoder) (int, error) { +func (u *LedgerHeaderExt) DecodeFrom(d *xdr.Decoder, maxDepth uint) (int, error) { + if maxDepth == 0 { + return 0, fmt.Errorf("decoding LedgerHeaderExt: %w", ErrMaxDecodingDepthReached) + } + maxDepth -= 1 var err error var n, nTmp int u.V, nTmp, err = d.DecodeInt() n += nTmp if err != nil { - return n, fmt.Errorf("decoding Int: %s", err) + return n, fmt.Errorf("decoding Int: %w", err) } switch int32(u.V) { case 0: @@ -11091,10 +11482,10 @@ func (u *LedgerHeaderExt) DecodeFrom(d *xdr.Decoder) (int, error) { return n, nil case 1: u.V1 = new(LedgerHeaderExtensionV1) - nTmp, err = (*u.V1).DecodeFrom(d) + nTmp, err = (*u.V1).DecodeFrom(d, maxDepth) n += nTmp if err != nil { - return n, fmt.Errorf("decoding LedgerHeaderExtensionV1: %s", err) + return n, fmt.Errorf("decoding LedgerHeaderExtensionV1: %w", err) } return n, nil } @@ -11113,7 +11504,7 @@ func (s LedgerHeaderExt) MarshalBinary() ([]byte, error) { func (s *LedgerHeaderExt) UnmarshalBinary(inp []byte) error { r := bytes.NewReader(inp) d := xdr.NewDecoder(r) - _, err := s.DecodeFrom(d) + _, err := s.DecodeFrom(d, xdr.DecodeDefaultMaxDepth) return err } @@ -11243,85 +11634,89 @@ func (s *LedgerHeader) EncodeTo(e *xdr.Encoder) error { var _ decoderFrom = (*LedgerHeader)(nil) // DecodeFrom decodes this value using the Decoder. -func (s *LedgerHeader) DecodeFrom(d *xdr.Decoder) (int, error) { +func (s *LedgerHeader) DecodeFrom(d *xdr.Decoder, maxDepth uint) (int, error) { + if maxDepth == 0 { + return 0, fmt.Errorf("decoding LedgerHeader: %w", ErrMaxDecodingDepthReached) + } + maxDepth -= 1 var err error var n, nTmp int - nTmp, err = s.LedgerVersion.DecodeFrom(d) + nTmp, err = s.LedgerVersion.DecodeFrom(d, maxDepth) n += nTmp if err != nil { - return n, fmt.Errorf("decoding Uint32: %s", err) + return n, fmt.Errorf("decoding Uint32: %w", err) } - nTmp, err = s.PreviousLedgerHash.DecodeFrom(d) + nTmp, err = s.PreviousLedgerHash.DecodeFrom(d, maxDepth) n += nTmp if err != nil { - return n, fmt.Errorf("decoding Hash: %s", err) + return n, fmt.Errorf("decoding Hash: %w", err) } - nTmp, err = s.ScpValue.DecodeFrom(d) + nTmp, err = s.ScpValue.DecodeFrom(d, maxDepth) n += nTmp if err != nil { - return n, fmt.Errorf("decoding StellarValue: %s", err) + return n, fmt.Errorf("decoding StellarValue: %w", err) } - nTmp, err = s.TxSetResultHash.DecodeFrom(d) + nTmp, err = s.TxSetResultHash.DecodeFrom(d, maxDepth) n += nTmp if err != nil { - return n, fmt.Errorf("decoding Hash: %s", err) + return n, fmt.Errorf("decoding Hash: %w", err) } - nTmp, err = s.BucketListHash.DecodeFrom(d) + nTmp, err = s.BucketListHash.DecodeFrom(d, maxDepth) n += nTmp if err != nil { - return n, fmt.Errorf("decoding Hash: %s", err) + return n, fmt.Errorf("decoding Hash: %w", err) } - nTmp, err = s.LedgerSeq.DecodeFrom(d) + nTmp, err = s.LedgerSeq.DecodeFrom(d, maxDepth) n += nTmp if err != nil { - return n, fmt.Errorf("decoding Uint32: %s", err) + return n, fmt.Errorf("decoding Uint32: %w", err) } - nTmp, err = s.TotalCoins.DecodeFrom(d) + nTmp, err = s.TotalCoins.DecodeFrom(d, maxDepth) n += nTmp if err != nil { - return n, fmt.Errorf("decoding Int64: %s", err) + return n, fmt.Errorf("decoding Int64: %w", err) } - nTmp, err = s.FeePool.DecodeFrom(d) + nTmp, err = s.FeePool.DecodeFrom(d, maxDepth) n += nTmp if err != nil { - return n, fmt.Errorf("decoding Int64: %s", err) + return n, fmt.Errorf("decoding Int64: %w", err) } - nTmp, err = s.InflationSeq.DecodeFrom(d) + nTmp, err = s.InflationSeq.DecodeFrom(d, maxDepth) n += nTmp if err != nil { - return n, fmt.Errorf("decoding Uint32: %s", err) + return n, fmt.Errorf("decoding Uint32: %w", err) } - nTmp, err = s.IdPool.DecodeFrom(d) + nTmp, err = s.IdPool.DecodeFrom(d, maxDepth) n += nTmp if err != nil { - return n, fmt.Errorf("decoding Uint64: %s", err) + return n, fmt.Errorf("decoding Uint64: %w", err) } - nTmp, err = s.BaseFee.DecodeFrom(d) + nTmp, err = s.BaseFee.DecodeFrom(d, maxDepth) n += nTmp if err != nil { - return n, fmt.Errorf("decoding Uint32: %s", err) + return n, fmt.Errorf("decoding Uint32: %w", err) } - nTmp, err = s.BaseReserve.DecodeFrom(d) + nTmp, err = s.BaseReserve.DecodeFrom(d, maxDepth) n += nTmp if err != nil { - return n, fmt.Errorf("decoding Uint32: %s", err) + return n, fmt.Errorf("decoding Uint32: %w", err) } - nTmp, err = s.MaxTxSetSize.DecodeFrom(d) + nTmp, err = s.MaxTxSetSize.DecodeFrom(d, maxDepth) n += nTmp if err != nil { - return n, fmt.Errorf("decoding Uint32: %s", err) + return n, fmt.Errorf("decoding Uint32: %w", err) } for i := 0; i < len(s.SkipList); i++ { - nTmp, err = s.SkipList[i].DecodeFrom(d) + nTmp, err = s.SkipList[i].DecodeFrom(d, maxDepth) n += nTmp if err != nil { - return n, fmt.Errorf("decoding Hash: %s", err) + return n, fmt.Errorf("decoding Hash: %w", err) } } - nTmp, err = s.Ext.DecodeFrom(d) + nTmp, err = s.Ext.DecodeFrom(d, maxDepth) n += nTmp if err != nil { - return n, fmt.Errorf("decoding LedgerHeaderExt: %s", err) + return n, fmt.Errorf("decoding LedgerHeaderExt: %w", err) } return n, nil } @@ -11338,7 +11733,7 @@ func (s LedgerHeader) MarshalBinary() ([]byte, error) { func (s *LedgerHeader) UnmarshalBinary(inp []byte) error { r := bytes.NewReader(inp) d := xdr.NewDecoder(r) - _, err := s.DecodeFrom(d) + _, err := s.DecodeFrom(d, xdr.DecodeDefaultMaxDepth) return err } @@ -11412,10 +11807,14 @@ func (e LedgerUpgradeType) EncodeTo(enc *xdr.Encoder) error { var _ decoderFrom = (*LedgerUpgradeType)(nil) // DecodeFrom decodes this value using the Decoder. -func (e *LedgerUpgradeType) DecodeFrom(d *xdr.Decoder) (int, error) { +func (e *LedgerUpgradeType) DecodeFrom(d *xdr.Decoder, maxDepth uint) (int, error) { + if maxDepth == 0 { + return 0, fmt.Errorf("decoding LedgerUpgradeType: %w", ErrMaxDecodingDepthReached) + } + maxDepth -= 1 v, n, err := d.DecodeInt() if err != nil { - return n, fmt.Errorf("decoding LedgerUpgradeType: %s", err) + return n, fmt.Errorf("decoding LedgerUpgradeType: %w", err) } if _, ok := ledgerUpgradeTypeMap[v]; !ok { return n, fmt.Errorf("'%d' is not a valid LedgerUpgradeType enum value", v) @@ -11436,7 +11835,7 @@ func (s LedgerUpgradeType) MarshalBinary() ([]byte, error) { func (s *LedgerUpgradeType) UnmarshalBinary(inp []byte) error { r := bytes.NewReader(inp) d := xdr.NewDecoder(r) - _, err := s.DecodeFrom(d) + _, err := s.DecodeFrom(d, xdr.DecodeDefaultMaxDepth) return err } @@ -11477,18 +11876,22 @@ func (s *ConfigUpgradeSetKey) EncodeTo(e *xdr.Encoder) error { var _ decoderFrom = (*ConfigUpgradeSetKey)(nil) // DecodeFrom decodes this value using the Decoder. -func (s *ConfigUpgradeSetKey) DecodeFrom(d *xdr.Decoder) (int, error) { +func (s *ConfigUpgradeSetKey) DecodeFrom(d *xdr.Decoder, maxDepth uint) (int, error) { + if maxDepth == 0 { + return 0, fmt.Errorf("decoding ConfigUpgradeSetKey: %w", ErrMaxDecodingDepthReached) + } + maxDepth -= 1 var err error var n, nTmp int - nTmp, err = s.ContractId.DecodeFrom(d) + nTmp, err = s.ContractId.DecodeFrom(d, maxDepth) n += nTmp if err != nil { - return n, fmt.Errorf("decoding Hash: %s", err) + return n, fmt.Errorf("decoding Hash: %w", err) } - nTmp, err = s.ContentHash.DecodeFrom(d) + nTmp, err = s.ContentHash.DecodeFrom(d, maxDepth) n += nTmp if err != nil { - return n, fmt.Errorf("decoding Hash: %s", err) + return n, fmt.Errorf("decoding Hash: %w", err) } return n, nil } @@ -11505,7 +11908,7 @@ func (s ConfigUpgradeSetKey) MarshalBinary() ([]byte, error) { func (s *ConfigUpgradeSetKey) UnmarshalBinary(inp []byte) error { r := bytes.NewReader(inp) d := xdr.NewDecoder(r) - _, err := s.DecodeFrom(d) + _, err := s.DecodeFrom(d, xdr.DecodeDefaultMaxDepth) return err } @@ -11588,49 +11991,49 @@ func NewLedgerUpgrade(aType LedgerUpgradeType, value interface{}) (result Ledger case LedgerUpgradeTypeLedgerUpgradeVersion: tv, ok := value.(Uint32) if !ok { - err = fmt.Errorf("invalid value, must be Uint32") + err = errors.New("invalid value, must be Uint32") return } result.NewLedgerVersion = &tv case LedgerUpgradeTypeLedgerUpgradeBaseFee: tv, ok := value.(Uint32) if !ok { - err = fmt.Errorf("invalid value, must be Uint32") + err = errors.New("invalid value, must be Uint32") return } result.NewBaseFee = &tv case LedgerUpgradeTypeLedgerUpgradeMaxTxSetSize: tv, ok := value.(Uint32) if !ok { - err = fmt.Errorf("invalid value, must be Uint32") + err = errors.New("invalid value, must be Uint32") return } result.NewMaxTxSetSize = &tv case LedgerUpgradeTypeLedgerUpgradeBaseReserve: tv, ok := value.(Uint32) if !ok { - err = fmt.Errorf("invalid value, must be Uint32") + err = errors.New("invalid value, must be Uint32") return } result.NewBaseReserve = &tv case LedgerUpgradeTypeLedgerUpgradeFlags: tv, ok := value.(Uint32) if !ok { - err = fmt.Errorf("invalid value, must be Uint32") + err = errors.New("invalid value, must be Uint32") return } result.NewFlags = &tv case LedgerUpgradeTypeLedgerUpgradeConfig: tv, ok := value.(ConfigUpgradeSetKey) if !ok { - err = fmt.Errorf("invalid value, must be ConfigUpgradeSetKey") + err = errors.New("invalid value, must be ConfigUpgradeSetKey") return } result.NewConfig = &tv case LedgerUpgradeTypeLedgerUpgradeMaxSorobanTxSetSize: tv, ok := value.(Uint32) if !ok { - err = fmt.Errorf("invalid value, must be Uint32") + err = errors.New("invalid value, must be Uint32") return } result.NewMaxSorobanTxSetSize = &tv @@ -11862,69 +12265,73 @@ func (u LedgerUpgrade) EncodeTo(e *xdr.Encoder) error { var _ decoderFrom = (*LedgerUpgrade)(nil) // DecodeFrom decodes this value using the Decoder. -func (u *LedgerUpgrade) DecodeFrom(d *xdr.Decoder) (int, error) { +func (u *LedgerUpgrade) DecodeFrom(d *xdr.Decoder, maxDepth uint) (int, error) { + if maxDepth == 0 { + return 0, fmt.Errorf("decoding LedgerUpgrade: %w", ErrMaxDecodingDepthReached) + } + maxDepth -= 1 var err error var n, nTmp int - nTmp, err = u.Type.DecodeFrom(d) + nTmp, err = u.Type.DecodeFrom(d, maxDepth) n += nTmp if err != nil { - return n, fmt.Errorf("decoding LedgerUpgradeType: %s", err) + return n, fmt.Errorf("decoding LedgerUpgradeType: %w", err) } switch LedgerUpgradeType(u.Type) { case LedgerUpgradeTypeLedgerUpgradeVersion: u.NewLedgerVersion = new(Uint32) - nTmp, err = (*u.NewLedgerVersion).DecodeFrom(d) + nTmp, err = (*u.NewLedgerVersion).DecodeFrom(d, maxDepth) n += nTmp if err != nil { - return n, fmt.Errorf("decoding Uint32: %s", err) + return n, fmt.Errorf("decoding Uint32: %w", err) } return n, nil case LedgerUpgradeTypeLedgerUpgradeBaseFee: u.NewBaseFee = new(Uint32) - nTmp, err = (*u.NewBaseFee).DecodeFrom(d) + nTmp, err = (*u.NewBaseFee).DecodeFrom(d, maxDepth) n += nTmp if err != nil { - return n, fmt.Errorf("decoding Uint32: %s", err) + return n, fmt.Errorf("decoding Uint32: %w", err) } return n, nil case LedgerUpgradeTypeLedgerUpgradeMaxTxSetSize: u.NewMaxTxSetSize = new(Uint32) - nTmp, err = (*u.NewMaxTxSetSize).DecodeFrom(d) + nTmp, err = (*u.NewMaxTxSetSize).DecodeFrom(d, maxDepth) n += nTmp if err != nil { - return n, fmt.Errorf("decoding Uint32: %s", err) + return n, fmt.Errorf("decoding Uint32: %w", err) } return n, nil case LedgerUpgradeTypeLedgerUpgradeBaseReserve: u.NewBaseReserve = new(Uint32) - nTmp, err = (*u.NewBaseReserve).DecodeFrom(d) + nTmp, err = (*u.NewBaseReserve).DecodeFrom(d, maxDepth) n += nTmp if err != nil { - return n, fmt.Errorf("decoding Uint32: %s", err) + return n, fmt.Errorf("decoding Uint32: %w", err) } return n, nil case LedgerUpgradeTypeLedgerUpgradeFlags: u.NewFlags = new(Uint32) - nTmp, err = (*u.NewFlags).DecodeFrom(d) + nTmp, err = (*u.NewFlags).DecodeFrom(d, maxDepth) n += nTmp if err != nil { - return n, fmt.Errorf("decoding Uint32: %s", err) + return n, fmt.Errorf("decoding Uint32: %w", err) } return n, nil case LedgerUpgradeTypeLedgerUpgradeConfig: u.NewConfig = new(ConfigUpgradeSetKey) - nTmp, err = (*u.NewConfig).DecodeFrom(d) + nTmp, err = (*u.NewConfig).DecodeFrom(d, maxDepth) n += nTmp if err != nil { - return n, fmt.Errorf("decoding ConfigUpgradeSetKey: %s", err) + return n, fmt.Errorf("decoding ConfigUpgradeSetKey: %w", err) } return n, nil case LedgerUpgradeTypeLedgerUpgradeMaxSorobanTxSetSize: u.NewMaxSorobanTxSetSize = new(Uint32) - nTmp, err = (*u.NewMaxSorobanTxSetSize).DecodeFrom(d) + nTmp, err = (*u.NewMaxSorobanTxSetSize).DecodeFrom(d, maxDepth) n += nTmp if err != nil { - return n, fmt.Errorf("decoding Uint32: %s", err) + return n, fmt.Errorf("decoding Uint32: %w", err) } return n, nil } @@ -11943,7 +12350,7 @@ func (s LedgerUpgrade) MarshalBinary() ([]byte, error) { func (s *LedgerUpgrade) UnmarshalBinary(inp []byte) error { r := bytes.NewReader(inp) d := xdr.NewDecoder(r) - _, err := s.DecodeFrom(d) + _, err := s.DecodeFrom(d, xdr.DecodeDefaultMaxDepth) return err } @@ -11984,23 +12391,27 @@ func (s *ConfigUpgradeSet) EncodeTo(e *xdr.Encoder) error { var _ decoderFrom = (*ConfigUpgradeSet)(nil) // DecodeFrom decodes this value using the Decoder. -func (s *ConfigUpgradeSet) DecodeFrom(d *xdr.Decoder) (int, error) { +func (s *ConfigUpgradeSet) DecodeFrom(d *xdr.Decoder, maxDepth uint) (int, error) { + if maxDepth == 0 { + return 0, fmt.Errorf("decoding ConfigUpgradeSet: %w", ErrMaxDecodingDepthReached) + } + maxDepth -= 1 var err error var n, nTmp int var l uint32 l, nTmp, err = d.DecodeUint() n += nTmp if err != nil { - return n, fmt.Errorf("decoding ConfigSettingEntry: %s", err) + return n, fmt.Errorf("decoding ConfigSettingEntry: %w", err) } s.UpdatedEntry = nil if l > 0 { s.UpdatedEntry = make([]ConfigSettingEntry, l) for i := uint32(0); i < l; i++ { - nTmp, err = s.UpdatedEntry[i].DecodeFrom(d) + nTmp, err = s.UpdatedEntry[i].DecodeFrom(d, maxDepth) n += nTmp if err != nil { - return n, fmt.Errorf("decoding ConfigSettingEntry: %s", err) + return n, fmt.Errorf("decoding ConfigSettingEntry: %w", err) } } } @@ -12019,7 +12430,7 @@ func (s ConfigUpgradeSet) MarshalBinary() ([]byte, error) { func (s *ConfigUpgradeSet) UnmarshalBinary(inp []byte) error { r := bytes.NewReader(inp) d := xdr.NewDecoder(r) - _, err := s.DecodeFrom(d) + _, err := s.DecodeFrom(d, xdr.DecodeDefaultMaxDepth) return err } @@ -12086,10 +12497,14 @@ func (e BucketEntryType) EncodeTo(enc *xdr.Encoder) error { var _ decoderFrom = (*BucketEntryType)(nil) // DecodeFrom decodes this value using the Decoder. -func (e *BucketEntryType) DecodeFrom(d *xdr.Decoder) (int, error) { +func (e *BucketEntryType) DecodeFrom(d *xdr.Decoder, maxDepth uint) (int, error) { + if maxDepth == 0 { + return 0, fmt.Errorf("decoding BucketEntryType: %w", ErrMaxDecodingDepthReached) + } + maxDepth -= 1 v, n, err := d.DecodeInt() if err != nil { - return n, fmt.Errorf("decoding BucketEntryType: %s", err) + return n, fmt.Errorf("decoding BucketEntryType: %w", err) } if _, ok := bucketEntryTypeMap[v]; !ok { return n, fmt.Errorf("'%d' is not a valid BucketEntryType enum value", v) @@ -12110,7 +12525,7 @@ func (s BucketEntryType) MarshalBinary() ([]byte, error) { func (s *BucketEntryType) UnmarshalBinary(inp []byte) error { r := bytes.NewReader(inp) d := xdr.NewDecoder(r) - _, err := s.DecodeFrom(d) + _, err := s.DecodeFrom(d, xdr.DecodeDefaultMaxDepth) return err } @@ -12179,13 +12594,17 @@ func (u BucketMetadataExt) EncodeTo(e *xdr.Encoder) error { var _ decoderFrom = (*BucketMetadataExt)(nil) // DecodeFrom decodes this value using the Decoder. -func (u *BucketMetadataExt) DecodeFrom(d *xdr.Decoder) (int, error) { +func (u *BucketMetadataExt) DecodeFrom(d *xdr.Decoder, maxDepth uint) (int, error) { + if maxDepth == 0 { + return 0, fmt.Errorf("decoding BucketMetadataExt: %w", ErrMaxDecodingDepthReached) + } + maxDepth -= 1 var err error var n, nTmp int u.V, nTmp, err = d.DecodeInt() n += nTmp if err != nil { - return n, fmt.Errorf("decoding Int: %s", err) + return n, fmt.Errorf("decoding Int: %w", err) } switch int32(u.V) { case 0: @@ -12207,7 +12626,7 @@ func (s BucketMetadataExt) MarshalBinary() ([]byte, error) { func (s *BucketMetadataExt) UnmarshalBinary(inp []byte) error { r := bytes.NewReader(inp) d := xdr.NewDecoder(r) - _, err := s.DecodeFrom(d) + _, err := s.DecodeFrom(d, xdr.DecodeDefaultMaxDepth) return err } @@ -12257,18 +12676,22 @@ func (s *BucketMetadata) EncodeTo(e *xdr.Encoder) error { var _ decoderFrom = (*BucketMetadata)(nil) // DecodeFrom decodes this value using the Decoder. -func (s *BucketMetadata) DecodeFrom(d *xdr.Decoder) (int, error) { +func (s *BucketMetadata) DecodeFrom(d *xdr.Decoder, maxDepth uint) (int, error) { + if maxDepth == 0 { + return 0, fmt.Errorf("decoding BucketMetadata: %w", ErrMaxDecodingDepthReached) + } + maxDepth -= 1 var err error var n, nTmp int - nTmp, err = s.LedgerVersion.DecodeFrom(d) + nTmp, err = s.LedgerVersion.DecodeFrom(d, maxDepth) n += nTmp if err != nil { - return n, fmt.Errorf("decoding Uint32: %s", err) + return n, fmt.Errorf("decoding Uint32: %w", err) } - nTmp, err = s.Ext.DecodeFrom(d) + nTmp, err = s.Ext.DecodeFrom(d, maxDepth) n += nTmp if err != nil { - return n, fmt.Errorf("decoding BucketMetadataExt: %s", err) + return n, fmt.Errorf("decoding BucketMetadataExt: %w", err) } return n, nil } @@ -12285,7 +12708,7 @@ func (s BucketMetadata) MarshalBinary() ([]byte, error) { func (s *BucketMetadata) UnmarshalBinary(inp []byte) error { r := bytes.NewReader(inp) d := xdr.NewDecoder(r) - _, err := s.DecodeFrom(d) + _, err := s.DecodeFrom(d, xdr.DecodeDefaultMaxDepth) return err } @@ -12349,28 +12772,28 @@ func NewBucketEntry(aType BucketEntryType, value interface{}) (result BucketEntr case BucketEntryTypeLiveentry: tv, ok := value.(LedgerEntry) if !ok { - err = fmt.Errorf("invalid value, must be LedgerEntry") + err = errors.New("invalid value, must be LedgerEntry") return } result.LiveEntry = &tv case BucketEntryTypeInitentry: tv, ok := value.(LedgerEntry) if !ok { - err = fmt.Errorf("invalid value, must be LedgerEntry") + err = errors.New("invalid value, must be LedgerEntry") return } result.LiveEntry = &tv case BucketEntryTypeDeadentry: tv, ok := value.(LedgerKey) if !ok { - err = fmt.Errorf("invalid value, must be LedgerKey") + err = errors.New("invalid value, must be LedgerKey") return } result.DeadEntry = &tv case BucketEntryTypeMetaentry: tv, ok := value.(BucketMetadata) if !ok { - err = fmt.Errorf("invalid value, must be BucketMetadata") + err = errors.New("invalid value, must be BucketMetadata") return } result.MetaEntry = &tv @@ -12487,45 +12910,49 @@ func (u BucketEntry) EncodeTo(e *xdr.Encoder) error { var _ decoderFrom = (*BucketEntry)(nil) // DecodeFrom decodes this value using the Decoder. -func (u *BucketEntry) DecodeFrom(d *xdr.Decoder) (int, error) { +func (u *BucketEntry) DecodeFrom(d *xdr.Decoder, maxDepth uint) (int, error) { + if maxDepth == 0 { + return 0, fmt.Errorf("decoding BucketEntry: %w", ErrMaxDecodingDepthReached) + } + maxDepth -= 1 var err error var n, nTmp int - nTmp, err = u.Type.DecodeFrom(d) + nTmp, err = u.Type.DecodeFrom(d, maxDepth) n += nTmp if err != nil { - return n, fmt.Errorf("decoding BucketEntryType: %s", err) + return n, fmt.Errorf("decoding BucketEntryType: %w", err) } switch BucketEntryType(u.Type) { case BucketEntryTypeLiveentry: u.LiveEntry = new(LedgerEntry) - nTmp, err = (*u.LiveEntry).DecodeFrom(d) + nTmp, err = (*u.LiveEntry).DecodeFrom(d, maxDepth) n += nTmp if err != nil { - return n, fmt.Errorf("decoding LedgerEntry: %s", err) + return n, fmt.Errorf("decoding LedgerEntry: %w", err) } return n, nil case BucketEntryTypeInitentry: u.LiveEntry = new(LedgerEntry) - nTmp, err = (*u.LiveEntry).DecodeFrom(d) + nTmp, err = (*u.LiveEntry).DecodeFrom(d, maxDepth) n += nTmp if err != nil { - return n, fmt.Errorf("decoding LedgerEntry: %s", err) + return n, fmt.Errorf("decoding LedgerEntry: %w", err) } return n, nil case BucketEntryTypeDeadentry: u.DeadEntry = new(LedgerKey) - nTmp, err = (*u.DeadEntry).DecodeFrom(d) + nTmp, err = (*u.DeadEntry).DecodeFrom(d, maxDepth) n += nTmp if err != nil { - return n, fmt.Errorf("decoding LedgerKey: %s", err) + return n, fmt.Errorf("decoding LedgerKey: %w", err) } return n, nil case BucketEntryTypeMetaentry: u.MetaEntry = new(BucketMetadata) - nTmp, err = (*u.MetaEntry).DecodeFrom(d) + nTmp, err = (*u.MetaEntry).DecodeFrom(d, maxDepth) n += nTmp if err != nil { - return n, fmt.Errorf("decoding BucketMetadata: %s", err) + return n, fmt.Errorf("decoding BucketMetadata: %w", err) } return n, nil } @@ -12544,7 +12971,7 @@ func (s BucketEntry) MarshalBinary() ([]byte, error) { func (s *BucketEntry) UnmarshalBinary(inp []byte) error { r := bytes.NewReader(inp) d := xdr.NewDecoder(r) - _, err := s.DecodeFrom(d) + _, err := s.DecodeFrom(d, xdr.DecodeDefaultMaxDepth) return err } @@ -12602,10 +13029,14 @@ func (e TxSetComponentType) EncodeTo(enc *xdr.Encoder) error { var _ decoderFrom = (*TxSetComponentType)(nil) // DecodeFrom decodes this value using the Decoder. -func (e *TxSetComponentType) DecodeFrom(d *xdr.Decoder) (int, error) { +func (e *TxSetComponentType) DecodeFrom(d *xdr.Decoder, maxDepth uint) (int, error) { + if maxDepth == 0 { + return 0, fmt.Errorf("decoding TxSetComponentType: %w", ErrMaxDecodingDepthReached) + } + maxDepth -= 1 v, n, err := d.DecodeInt() if err != nil { - return n, fmt.Errorf("decoding TxSetComponentType: %s", err) + return n, fmt.Errorf("decoding TxSetComponentType: %w", err) } if _, ok := txSetComponentTypeMap[v]; !ok { return n, fmt.Errorf("'%d' is not a valid TxSetComponentType enum value", v) @@ -12626,7 +13057,7 @@ func (s TxSetComponentType) MarshalBinary() ([]byte, error) { func (s *TxSetComponentType) UnmarshalBinary(inp []byte) error { r := bytes.NewReader(inp) d := xdr.NewDecoder(r) - _, err := s.DecodeFrom(d) + _, err := s.DecodeFrom(d, xdr.DecodeDefaultMaxDepth) return err } @@ -12678,38 +13109,42 @@ func (s *TxSetComponentTxsMaybeDiscountedFee) EncodeTo(e *xdr.Encoder) error { var _ decoderFrom = (*TxSetComponentTxsMaybeDiscountedFee)(nil) // DecodeFrom decodes this value using the Decoder. -func (s *TxSetComponentTxsMaybeDiscountedFee) DecodeFrom(d *xdr.Decoder) (int, error) { +func (s *TxSetComponentTxsMaybeDiscountedFee) DecodeFrom(d *xdr.Decoder, maxDepth uint) (int, error) { + if maxDepth == 0 { + return 0, fmt.Errorf("decoding TxSetComponentTxsMaybeDiscountedFee: %w", ErrMaxDecodingDepthReached) + } + maxDepth -= 1 var err error var n, nTmp int var b bool b, nTmp, err = d.DecodeBool() n += nTmp if err != nil { - return n, fmt.Errorf("decoding Int64: %s", err) + return n, fmt.Errorf("decoding Int64: %w", err) } s.BaseFee = nil if b { s.BaseFee = new(Int64) - nTmp, err = s.BaseFee.DecodeFrom(d) + nTmp, err = s.BaseFee.DecodeFrom(d, maxDepth) n += nTmp if err != nil { - return n, fmt.Errorf("decoding Int64: %s", err) + return n, fmt.Errorf("decoding Int64: %w", err) } } var l uint32 l, nTmp, err = d.DecodeUint() n += nTmp if err != nil { - return n, fmt.Errorf("decoding TransactionEnvelope: %s", err) + return n, fmt.Errorf("decoding TransactionEnvelope: %w", err) } s.Txs = nil if l > 0 { s.Txs = make([]TransactionEnvelope, l) for i := uint32(0); i < l; i++ { - nTmp, err = s.Txs[i].DecodeFrom(d) + nTmp, err = s.Txs[i].DecodeFrom(d, maxDepth) n += nTmp if err != nil { - return n, fmt.Errorf("decoding TransactionEnvelope: %s", err) + return n, fmt.Errorf("decoding TransactionEnvelope: %w", err) } } } @@ -12728,7 +13163,7 @@ func (s TxSetComponentTxsMaybeDiscountedFee) MarshalBinary() ([]byte, error) { func (s *TxSetComponentTxsMaybeDiscountedFee) UnmarshalBinary(inp []byte) error { r := bytes.NewReader(inp) d := xdr.NewDecoder(r) - _, err := s.DecodeFrom(d) + _, err := s.DecodeFrom(d, xdr.DecodeDefaultMaxDepth) return err } @@ -12782,7 +13217,7 @@ func NewTxSetComponent(aType TxSetComponentType, value interface{}) (result TxSe case TxSetComponentTypeTxsetCompTxsMaybeDiscountedFee: tv, ok := value.(TxSetComponentTxsMaybeDiscountedFee) if !ok { - err = fmt.Errorf("invalid value, must be TxSetComponentTxsMaybeDiscountedFee") + err = errors.New("invalid value, must be TxSetComponentTxsMaybeDiscountedFee") return } result.TxsMaybeDiscountedFee = &tv @@ -12834,21 +13269,25 @@ func (u TxSetComponent) EncodeTo(e *xdr.Encoder) error { var _ decoderFrom = (*TxSetComponent)(nil) // DecodeFrom decodes this value using the Decoder. -func (u *TxSetComponent) DecodeFrom(d *xdr.Decoder) (int, error) { +func (u *TxSetComponent) DecodeFrom(d *xdr.Decoder, maxDepth uint) (int, error) { + if maxDepth == 0 { + return 0, fmt.Errorf("decoding TxSetComponent: %w", ErrMaxDecodingDepthReached) + } + maxDepth -= 1 var err error var n, nTmp int - nTmp, err = u.Type.DecodeFrom(d) + nTmp, err = u.Type.DecodeFrom(d, maxDepth) n += nTmp if err != nil { - return n, fmt.Errorf("decoding TxSetComponentType: %s", err) + return n, fmt.Errorf("decoding TxSetComponentType: %w", err) } switch TxSetComponentType(u.Type) { case TxSetComponentTypeTxsetCompTxsMaybeDiscountedFee: u.TxsMaybeDiscountedFee = new(TxSetComponentTxsMaybeDiscountedFee) - nTmp, err = (*u.TxsMaybeDiscountedFee).DecodeFrom(d) + nTmp, err = (*u.TxsMaybeDiscountedFee).DecodeFrom(d, maxDepth) n += nTmp if err != nil { - return n, fmt.Errorf("decoding TxSetComponentTxsMaybeDiscountedFee: %s", err) + return n, fmt.Errorf("decoding TxSetComponentTxsMaybeDiscountedFee: %w", err) } return n, nil } @@ -12867,7 +13306,7 @@ func (s TxSetComponent) MarshalBinary() ([]byte, error) { func (s *TxSetComponent) UnmarshalBinary(inp []byte) error { r := bytes.NewReader(inp) d := xdr.NewDecoder(r) - _, err := s.DecodeFrom(d) + _, err := s.DecodeFrom(d, xdr.DecodeDefaultMaxDepth) return err } @@ -12917,7 +13356,7 @@ func NewTransactionPhase(v int32, value interface{}) (result TransactionPhase, e case 0: tv, ok := value.([]TxSetComponent) if !ok { - err = fmt.Errorf("invalid value, must be []TxSetComponent") + err = errors.New("invalid value, must be []TxSetComponent") return } result.V0Components = &tv @@ -12974,13 +13413,17 @@ func (u TransactionPhase) EncodeTo(e *xdr.Encoder) error { var _ decoderFrom = (*TransactionPhase)(nil) // DecodeFrom decodes this value using the Decoder. -func (u *TransactionPhase) DecodeFrom(d *xdr.Decoder) (int, error) { +func (u *TransactionPhase) DecodeFrom(d *xdr.Decoder, maxDepth uint) (int, error) { + if maxDepth == 0 { + return 0, fmt.Errorf("decoding TransactionPhase: %w", ErrMaxDecodingDepthReached) + } + maxDepth -= 1 var err error var n, nTmp int u.V, nTmp, err = d.DecodeInt() n += nTmp if err != nil { - return n, fmt.Errorf("decoding Int: %s", err) + return n, fmt.Errorf("decoding Int: %w", err) } switch int32(u.V) { case 0: @@ -12989,16 +13432,16 @@ func (u *TransactionPhase) DecodeFrom(d *xdr.Decoder) (int, error) { l, nTmp, err = d.DecodeUint() n += nTmp if err != nil { - return n, fmt.Errorf("decoding TxSetComponent: %s", err) + return n, fmt.Errorf("decoding TxSetComponent: %w", err) } (*u.V0Components) = nil if l > 0 { (*u.V0Components) = make([]TxSetComponent, l) for i := uint32(0); i < l; i++ { - nTmp, err = (*u.V0Components)[i].DecodeFrom(d) + nTmp, err = (*u.V0Components)[i].DecodeFrom(d, maxDepth) n += nTmp if err != nil { - return n, fmt.Errorf("decoding TxSetComponent: %s", err) + return n, fmt.Errorf("decoding TxSetComponent: %w", err) } } } @@ -13019,7 +13462,7 @@ func (s TransactionPhase) MarshalBinary() ([]byte, error) { func (s *TransactionPhase) UnmarshalBinary(inp []byte) error { r := bytes.NewReader(inp) d := xdr.NewDecoder(r) - _, err := s.DecodeFrom(d) + _, err := s.DecodeFrom(d, xdr.DecodeDefaultMaxDepth) return err } @@ -13066,28 +13509,32 @@ func (s *TransactionSet) EncodeTo(e *xdr.Encoder) error { var _ decoderFrom = (*TransactionSet)(nil) // DecodeFrom decodes this value using the Decoder. -func (s *TransactionSet) DecodeFrom(d *xdr.Decoder) (int, error) { +func (s *TransactionSet) DecodeFrom(d *xdr.Decoder, maxDepth uint) (int, error) { + if maxDepth == 0 { + return 0, fmt.Errorf("decoding TransactionSet: %w", ErrMaxDecodingDepthReached) + } + maxDepth -= 1 var err error var n, nTmp int - nTmp, err = s.PreviousLedgerHash.DecodeFrom(d) + nTmp, err = s.PreviousLedgerHash.DecodeFrom(d, maxDepth) n += nTmp if err != nil { - return n, fmt.Errorf("decoding Hash: %s", err) + return n, fmt.Errorf("decoding Hash: %w", err) } var l uint32 l, nTmp, err = d.DecodeUint() n += nTmp if err != nil { - return n, fmt.Errorf("decoding TransactionEnvelope: %s", err) + return n, fmt.Errorf("decoding TransactionEnvelope: %w", err) } s.Txs = nil if l > 0 { s.Txs = make([]TransactionEnvelope, l) for i := uint32(0); i < l; i++ { - nTmp, err = s.Txs[i].DecodeFrom(d) + nTmp, err = s.Txs[i].DecodeFrom(d, maxDepth) n += nTmp if err != nil { - return n, fmt.Errorf("decoding TransactionEnvelope: %s", err) + return n, fmt.Errorf("decoding TransactionEnvelope: %w", err) } } } @@ -13106,7 +13553,7 @@ func (s TransactionSet) MarshalBinary() ([]byte, error) { func (s *TransactionSet) UnmarshalBinary(inp []byte) error { r := bytes.NewReader(inp) d := xdr.NewDecoder(r) - _, err := s.DecodeFrom(d) + _, err := s.DecodeFrom(d, xdr.DecodeDefaultMaxDepth) return err } @@ -13153,28 +13600,32 @@ func (s *TransactionSetV1) EncodeTo(e *xdr.Encoder) error { var _ decoderFrom = (*TransactionSetV1)(nil) // DecodeFrom decodes this value using the Decoder. -func (s *TransactionSetV1) DecodeFrom(d *xdr.Decoder) (int, error) { +func (s *TransactionSetV1) DecodeFrom(d *xdr.Decoder, maxDepth uint) (int, error) { + if maxDepth == 0 { + return 0, fmt.Errorf("decoding TransactionSetV1: %w", ErrMaxDecodingDepthReached) + } + maxDepth -= 1 var err error var n, nTmp int - nTmp, err = s.PreviousLedgerHash.DecodeFrom(d) + nTmp, err = s.PreviousLedgerHash.DecodeFrom(d, maxDepth) n += nTmp if err != nil { - return n, fmt.Errorf("decoding Hash: %s", err) + return n, fmt.Errorf("decoding Hash: %w", err) } var l uint32 l, nTmp, err = d.DecodeUint() n += nTmp if err != nil { - return n, fmt.Errorf("decoding TransactionPhase: %s", err) + return n, fmt.Errorf("decoding TransactionPhase: %w", err) } s.Phases = nil if l > 0 { s.Phases = make([]TransactionPhase, l) for i := uint32(0); i < l; i++ { - nTmp, err = s.Phases[i].DecodeFrom(d) + nTmp, err = s.Phases[i].DecodeFrom(d, maxDepth) n += nTmp if err != nil { - return n, fmt.Errorf("decoding TransactionPhase: %s", err) + return n, fmt.Errorf("decoding TransactionPhase: %w", err) } } } @@ -13193,7 +13644,7 @@ func (s TransactionSetV1) MarshalBinary() ([]byte, error) { func (s *TransactionSetV1) UnmarshalBinary(inp []byte) error { r := bytes.NewReader(inp) d := xdr.NewDecoder(r) - _, err := s.DecodeFrom(d) + _, err := s.DecodeFrom(d, xdr.DecodeDefaultMaxDepth) return err } @@ -13244,7 +13695,7 @@ func NewGeneralizedTransactionSet(v int32, value interface{}) (result Generalize case 1: tv, ok := value.(TransactionSetV1) if !ok { - err = fmt.Errorf("invalid value, must be TransactionSetV1") + err = errors.New("invalid value, must be TransactionSetV1") return } result.V1TxSet = &tv @@ -13296,21 +13747,25 @@ func (u GeneralizedTransactionSet) EncodeTo(e *xdr.Encoder) error { var _ decoderFrom = (*GeneralizedTransactionSet)(nil) // DecodeFrom decodes this value using the Decoder. -func (u *GeneralizedTransactionSet) DecodeFrom(d *xdr.Decoder) (int, error) { +func (u *GeneralizedTransactionSet) DecodeFrom(d *xdr.Decoder, maxDepth uint) (int, error) { + if maxDepth == 0 { + return 0, fmt.Errorf("decoding GeneralizedTransactionSet: %w", ErrMaxDecodingDepthReached) + } + maxDepth -= 1 var err error var n, nTmp int u.V, nTmp, err = d.DecodeInt() n += nTmp if err != nil { - return n, fmt.Errorf("decoding Int: %s", err) + return n, fmt.Errorf("decoding Int: %w", err) } switch int32(u.V) { case 1: u.V1TxSet = new(TransactionSetV1) - nTmp, err = (*u.V1TxSet).DecodeFrom(d) + nTmp, err = (*u.V1TxSet).DecodeFrom(d, maxDepth) n += nTmp if err != nil { - return n, fmt.Errorf("decoding TransactionSetV1: %s", err) + return n, fmt.Errorf("decoding TransactionSetV1: %w", err) } return n, nil } @@ -13329,7 +13784,7 @@ func (s GeneralizedTransactionSet) MarshalBinary() ([]byte, error) { func (s *GeneralizedTransactionSet) UnmarshalBinary(inp []byte) error { r := bytes.NewReader(inp) d := xdr.NewDecoder(r) - _, err := s.DecodeFrom(d) + _, err := s.DecodeFrom(d, xdr.DecodeDefaultMaxDepth) return err } @@ -13371,18 +13826,22 @@ func (s *TransactionResultPair) EncodeTo(e *xdr.Encoder) error { var _ decoderFrom = (*TransactionResultPair)(nil) // DecodeFrom decodes this value using the Decoder. -func (s *TransactionResultPair) DecodeFrom(d *xdr.Decoder) (int, error) { +func (s *TransactionResultPair) DecodeFrom(d *xdr.Decoder, maxDepth uint) (int, error) { + if maxDepth == 0 { + return 0, fmt.Errorf("decoding TransactionResultPair: %w", ErrMaxDecodingDepthReached) + } + maxDepth -= 1 var err error var n, nTmp int - nTmp, err = s.TransactionHash.DecodeFrom(d) + nTmp, err = s.TransactionHash.DecodeFrom(d, maxDepth) n += nTmp if err != nil { - return n, fmt.Errorf("decoding Hash: %s", err) + return n, fmt.Errorf("decoding Hash: %w", err) } - nTmp, err = s.Result.DecodeFrom(d) + nTmp, err = s.Result.DecodeFrom(d, maxDepth) n += nTmp if err != nil { - return n, fmt.Errorf("decoding TransactionResult: %s", err) + return n, fmt.Errorf("decoding TransactionResult: %w", err) } return n, nil } @@ -13399,7 +13858,7 @@ func (s TransactionResultPair) MarshalBinary() ([]byte, error) { func (s *TransactionResultPair) UnmarshalBinary(inp []byte) error { r := bytes.NewReader(inp) d := xdr.NewDecoder(r) - _, err := s.DecodeFrom(d) + _, err := s.DecodeFrom(d, xdr.DecodeDefaultMaxDepth) return err } @@ -13441,23 +13900,27 @@ func (s *TransactionResultSet) EncodeTo(e *xdr.Encoder) error { var _ decoderFrom = (*TransactionResultSet)(nil) // DecodeFrom decodes this value using the Decoder. -func (s *TransactionResultSet) DecodeFrom(d *xdr.Decoder) (int, error) { +func (s *TransactionResultSet) DecodeFrom(d *xdr.Decoder, maxDepth uint) (int, error) { + if maxDepth == 0 { + return 0, fmt.Errorf("decoding TransactionResultSet: %w", ErrMaxDecodingDepthReached) + } + maxDepth -= 1 var err error var n, nTmp int var l uint32 l, nTmp, err = d.DecodeUint() n += nTmp if err != nil { - return n, fmt.Errorf("decoding TransactionResultPair: %s", err) + return n, fmt.Errorf("decoding TransactionResultPair: %w", err) } s.Results = nil if l > 0 { s.Results = make([]TransactionResultPair, l) for i := uint32(0); i < l; i++ { - nTmp, err = s.Results[i].DecodeFrom(d) + nTmp, err = s.Results[i].DecodeFrom(d, maxDepth) n += nTmp if err != nil { - return n, fmt.Errorf("decoding TransactionResultPair: %s", err) + return n, fmt.Errorf("decoding TransactionResultPair: %w", err) } } } @@ -13476,7 +13939,7 @@ func (s TransactionResultSet) MarshalBinary() ([]byte, error) { func (s *TransactionResultSet) UnmarshalBinary(inp []byte) error { r := bytes.NewReader(inp) d := xdr.NewDecoder(r) - _, err := s.DecodeFrom(d) + _, err := s.DecodeFrom(d, xdr.DecodeDefaultMaxDepth) return err } @@ -13532,7 +13995,7 @@ func NewTransactionHistoryEntryExt(v int32, value interface{}) (result Transacti case 1: tv, ok := value.(GeneralizedTransactionSet) if !ok { - err = fmt.Errorf("invalid value, must be GeneralizedTransactionSet") + err = errors.New("invalid value, must be GeneralizedTransactionSet") return } result.GeneralizedTxSet = &tv @@ -13587,13 +14050,17 @@ func (u TransactionHistoryEntryExt) EncodeTo(e *xdr.Encoder) error { var _ decoderFrom = (*TransactionHistoryEntryExt)(nil) // DecodeFrom decodes this value using the Decoder. -func (u *TransactionHistoryEntryExt) DecodeFrom(d *xdr.Decoder) (int, error) { +func (u *TransactionHistoryEntryExt) DecodeFrom(d *xdr.Decoder, maxDepth uint) (int, error) { + if maxDepth == 0 { + return 0, fmt.Errorf("decoding TransactionHistoryEntryExt: %w", ErrMaxDecodingDepthReached) + } + maxDepth -= 1 var err error var n, nTmp int u.V, nTmp, err = d.DecodeInt() n += nTmp if err != nil { - return n, fmt.Errorf("decoding Int: %s", err) + return n, fmt.Errorf("decoding Int: %w", err) } switch int32(u.V) { case 0: @@ -13601,10 +14068,10 @@ func (u *TransactionHistoryEntryExt) DecodeFrom(d *xdr.Decoder) (int, error) { return n, nil case 1: u.GeneralizedTxSet = new(GeneralizedTransactionSet) - nTmp, err = (*u.GeneralizedTxSet).DecodeFrom(d) + nTmp, err = (*u.GeneralizedTxSet).DecodeFrom(d, maxDepth) n += nTmp if err != nil { - return n, fmt.Errorf("decoding GeneralizedTransactionSet: %s", err) + return n, fmt.Errorf("decoding GeneralizedTransactionSet: %w", err) } return n, nil } @@ -13623,7 +14090,7 @@ func (s TransactionHistoryEntryExt) MarshalBinary() ([]byte, error) { func (s *TransactionHistoryEntryExt) UnmarshalBinary(inp []byte) error { r := bytes.NewReader(inp) d := xdr.NewDecoder(r) - _, err := s.DecodeFrom(d) + _, err := s.DecodeFrom(d, xdr.DecodeDefaultMaxDepth) return err } @@ -13679,23 +14146,27 @@ func (s *TransactionHistoryEntry) EncodeTo(e *xdr.Encoder) error { var _ decoderFrom = (*TransactionHistoryEntry)(nil) // DecodeFrom decodes this value using the Decoder. -func (s *TransactionHistoryEntry) DecodeFrom(d *xdr.Decoder) (int, error) { +func (s *TransactionHistoryEntry) DecodeFrom(d *xdr.Decoder, maxDepth uint) (int, error) { + if maxDepth == 0 { + return 0, fmt.Errorf("decoding TransactionHistoryEntry: %w", ErrMaxDecodingDepthReached) + } + maxDepth -= 1 var err error var n, nTmp int - nTmp, err = s.LedgerSeq.DecodeFrom(d) + nTmp, err = s.LedgerSeq.DecodeFrom(d, maxDepth) n += nTmp if err != nil { - return n, fmt.Errorf("decoding Uint32: %s", err) + return n, fmt.Errorf("decoding Uint32: %w", err) } - nTmp, err = s.TxSet.DecodeFrom(d) + nTmp, err = s.TxSet.DecodeFrom(d, maxDepth) n += nTmp if err != nil { - return n, fmt.Errorf("decoding TransactionSet: %s", err) + return n, fmt.Errorf("decoding TransactionSet: %w", err) } - nTmp, err = s.Ext.DecodeFrom(d) + nTmp, err = s.Ext.DecodeFrom(d, maxDepth) n += nTmp if err != nil { - return n, fmt.Errorf("decoding TransactionHistoryEntryExt: %s", err) + return n, fmt.Errorf("decoding TransactionHistoryEntryExt: %w", err) } return n, nil } @@ -13712,7 +14183,7 @@ func (s TransactionHistoryEntry) MarshalBinary() ([]byte, error) { func (s *TransactionHistoryEntry) UnmarshalBinary(inp []byte) error { r := bytes.NewReader(inp) d := xdr.NewDecoder(r) - _, err := s.DecodeFrom(d) + _, err := s.DecodeFrom(d, xdr.DecodeDefaultMaxDepth) return err } @@ -13781,13 +14252,17 @@ func (u TransactionHistoryResultEntryExt) EncodeTo(e *xdr.Encoder) error { var _ decoderFrom = (*TransactionHistoryResultEntryExt)(nil) // DecodeFrom decodes this value using the Decoder. -func (u *TransactionHistoryResultEntryExt) DecodeFrom(d *xdr.Decoder) (int, error) { +func (u *TransactionHistoryResultEntryExt) DecodeFrom(d *xdr.Decoder, maxDepth uint) (int, error) { + if maxDepth == 0 { + return 0, fmt.Errorf("decoding TransactionHistoryResultEntryExt: %w", ErrMaxDecodingDepthReached) + } + maxDepth -= 1 var err error var n, nTmp int u.V, nTmp, err = d.DecodeInt() n += nTmp if err != nil { - return n, fmt.Errorf("decoding Int: %s", err) + return n, fmt.Errorf("decoding Int: %w", err) } switch int32(u.V) { case 0: @@ -13809,7 +14284,7 @@ func (s TransactionHistoryResultEntryExt) MarshalBinary() ([]byte, error) { func (s *TransactionHistoryResultEntryExt) UnmarshalBinary(inp []byte) error { r := bytes.NewReader(inp) d := xdr.NewDecoder(r) - _, err := s.DecodeFrom(d) + _, err := s.DecodeFrom(d, xdr.DecodeDefaultMaxDepth) return err } @@ -13863,23 +14338,27 @@ func (s *TransactionHistoryResultEntry) EncodeTo(e *xdr.Encoder) error { var _ decoderFrom = (*TransactionHistoryResultEntry)(nil) // DecodeFrom decodes this value using the Decoder. -func (s *TransactionHistoryResultEntry) DecodeFrom(d *xdr.Decoder) (int, error) { +func (s *TransactionHistoryResultEntry) DecodeFrom(d *xdr.Decoder, maxDepth uint) (int, error) { + if maxDepth == 0 { + return 0, fmt.Errorf("decoding TransactionHistoryResultEntry: %w", ErrMaxDecodingDepthReached) + } + maxDepth -= 1 var err error var n, nTmp int - nTmp, err = s.LedgerSeq.DecodeFrom(d) + nTmp, err = s.LedgerSeq.DecodeFrom(d, maxDepth) n += nTmp if err != nil { - return n, fmt.Errorf("decoding Uint32: %s", err) + return n, fmt.Errorf("decoding Uint32: %w", err) } - nTmp, err = s.TxResultSet.DecodeFrom(d) + nTmp, err = s.TxResultSet.DecodeFrom(d, maxDepth) n += nTmp if err != nil { - return n, fmt.Errorf("decoding TransactionResultSet: %s", err) + return n, fmt.Errorf("decoding TransactionResultSet: %w", err) } - nTmp, err = s.Ext.DecodeFrom(d) + nTmp, err = s.Ext.DecodeFrom(d, maxDepth) n += nTmp if err != nil { - return n, fmt.Errorf("decoding TransactionHistoryResultEntryExt: %s", err) + return n, fmt.Errorf("decoding TransactionHistoryResultEntryExt: %w", err) } return n, nil } @@ -13896,7 +14375,7 @@ func (s TransactionHistoryResultEntry) MarshalBinary() ([]byte, error) { func (s *TransactionHistoryResultEntry) UnmarshalBinary(inp []byte) error { r := bytes.NewReader(inp) d := xdr.NewDecoder(r) - _, err := s.DecodeFrom(d) + _, err := s.DecodeFrom(d, xdr.DecodeDefaultMaxDepth) return err } @@ -13965,13 +14444,17 @@ func (u LedgerHeaderHistoryEntryExt) EncodeTo(e *xdr.Encoder) error { var _ decoderFrom = (*LedgerHeaderHistoryEntryExt)(nil) // DecodeFrom decodes this value using the Decoder. -func (u *LedgerHeaderHistoryEntryExt) DecodeFrom(d *xdr.Decoder) (int, error) { +func (u *LedgerHeaderHistoryEntryExt) DecodeFrom(d *xdr.Decoder, maxDepth uint) (int, error) { + if maxDepth == 0 { + return 0, fmt.Errorf("decoding LedgerHeaderHistoryEntryExt: %w", ErrMaxDecodingDepthReached) + } + maxDepth -= 1 var err error var n, nTmp int u.V, nTmp, err = d.DecodeInt() n += nTmp if err != nil { - return n, fmt.Errorf("decoding Int: %s", err) + return n, fmt.Errorf("decoding Int: %w", err) } switch int32(u.V) { case 0: @@ -13993,7 +14476,7 @@ func (s LedgerHeaderHistoryEntryExt) MarshalBinary() ([]byte, error) { func (s *LedgerHeaderHistoryEntryExt) UnmarshalBinary(inp []byte) error { r := bytes.NewReader(inp) d := xdr.NewDecoder(r) - _, err := s.DecodeFrom(d) + _, err := s.DecodeFrom(d, xdr.DecodeDefaultMaxDepth) return err } @@ -14047,23 +14530,27 @@ func (s *LedgerHeaderHistoryEntry) EncodeTo(e *xdr.Encoder) error { var _ decoderFrom = (*LedgerHeaderHistoryEntry)(nil) // DecodeFrom decodes this value using the Decoder. -func (s *LedgerHeaderHistoryEntry) DecodeFrom(d *xdr.Decoder) (int, error) { +func (s *LedgerHeaderHistoryEntry) DecodeFrom(d *xdr.Decoder, maxDepth uint) (int, error) { + if maxDepth == 0 { + return 0, fmt.Errorf("decoding LedgerHeaderHistoryEntry: %w", ErrMaxDecodingDepthReached) + } + maxDepth -= 1 var err error var n, nTmp int - nTmp, err = s.Hash.DecodeFrom(d) + nTmp, err = s.Hash.DecodeFrom(d, maxDepth) n += nTmp if err != nil { - return n, fmt.Errorf("decoding Hash: %s", err) + return n, fmt.Errorf("decoding Hash: %w", err) } - nTmp, err = s.Header.DecodeFrom(d) + nTmp, err = s.Header.DecodeFrom(d, maxDepth) n += nTmp if err != nil { - return n, fmt.Errorf("decoding LedgerHeader: %s", err) + return n, fmt.Errorf("decoding LedgerHeader: %w", err) } - nTmp, err = s.Ext.DecodeFrom(d) + nTmp, err = s.Ext.DecodeFrom(d, maxDepth) n += nTmp if err != nil { - return n, fmt.Errorf("decoding LedgerHeaderHistoryEntryExt: %s", err) + return n, fmt.Errorf("decoding LedgerHeaderHistoryEntryExt: %w", err) } return n, nil } @@ -14080,7 +14567,7 @@ func (s LedgerHeaderHistoryEntry) MarshalBinary() ([]byte, error) { func (s *LedgerHeaderHistoryEntry) UnmarshalBinary(inp []byte) error { r := bytes.NewReader(inp) d := xdr.NewDecoder(r) - _, err := s.DecodeFrom(d) + _, err := s.DecodeFrom(d, xdr.DecodeDefaultMaxDepth) return err } @@ -14127,28 +14614,32 @@ func (s *LedgerScpMessages) EncodeTo(e *xdr.Encoder) error { var _ decoderFrom = (*LedgerScpMessages)(nil) // DecodeFrom decodes this value using the Decoder. -func (s *LedgerScpMessages) DecodeFrom(d *xdr.Decoder) (int, error) { +func (s *LedgerScpMessages) DecodeFrom(d *xdr.Decoder, maxDepth uint) (int, error) { + if maxDepth == 0 { + return 0, fmt.Errorf("decoding LedgerScpMessages: %w", ErrMaxDecodingDepthReached) + } + maxDepth -= 1 var err error var n, nTmp int - nTmp, err = s.LedgerSeq.DecodeFrom(d) + nTmp, err = s.LedgerSeq.DecodeFrom(d, maxDepth) n += nTmp if err != nil { - return n, fmt.Errorf("decoding Uint32: %s", err) + return n, fmt.Errorf("decoding Uint32: %w", err) } var l uint32 l, nTmp, err = d.DecodeUint() n += nTmp if err != nil { - return n, fmt.Errorf("decoding ScpEnvelope: %s", err) + return n, fmt.Errorf("decoding ScpEnvelope: %w", err) } s.Messages = nil if l > 0 { s.Messages = make([]ScpEnvelope, l) for i := uint32(0); i < l; i++ { - nTmp, err = s.Messages[i].DecodeFrom(d) + nTmp, err = s.Messages[i].DecodeFrom(d, maxDepth) n += nTmp if err != nil { - return n, fmt.Errorf("decoding ScpEnvelope: %s", err) + return n, fmt.Errorf("decoding ScpEnvelope: %w", err) } } } @@ -14167,7 +14658,7 @@ func (s LedgerScpMessages) MarshalBinary() ([]byte, error) { func (s *LedgerScpMessages) UnmarshalBinary(inp []byte) error { r := bytes.NewReader(inp) d := xdr.NewDecoder(r) - _, err := s.DecodeFrom(d) + _, err := s.DecodeFrom(d, xdr.DecodeDefaultMaxDepth) return err } @@ -14214,30 +14705,34 @@ func (s *ScpHistoryEntryV0) EncodeTo(e *xdr.Encoder) error { var _ decoderFrom = (*ScpHistoryEntryV0)(nil) // DecodeFrom decodes this value using the Decoder. -func (s *ScpHistoryEntryV0) DecodeFrom(d *xdr.Decoder) (int, error) { +func (s *ScpHistoryEntryV0) DecodeFrom(d *xdr.Decoder, maxDepth uint) (int, error) { + if maxDepth == 0 { + return 0, fmt.Errorf("decoding ScpHistoryEntryV0: %w", ErrMaxDecodingDepthReached) + } + maxDepth -= 1 var err error var n, nTmp int var l uint32 l, nTmp, err = d.DecodeUint() n += nTmp if err != nil { - return n, fmt.Errorf("decoding ScpQuorumSet: %s", err) + return n, fmt.Errorf("decoding ScpQuorumSet: %w", err) } s.QuorumSets = nil if l > 0 { s.QuorumSets = make([]ScpQuorumSet, l) for i := uint32(0); i < l; i++ { - nTmp, err = s.QuorumSets[i].DecodeFrom(d) + nTmp, err = s.QuorumSets[i].DecodeFrom(d, maxDepth) n += nTmp if err != nil { - return n, fmt.Errorf("decoding ScpQuorumSet: %s", err) + return n, fmt.Errorf("decoding ScpQuorumSet: %w", err) } } } - nTmp, err = s.LedgerMessages.DecodeFrom(d) + nTmp, err = s.LedgerMessages.DecodeFrom(d, maxDepth) n += nTmp if err != nil { - return n, fmt.Errorf("decoding LedgerScpMessages: %s", err) + return n, fmt.Errorf("decoding LedgerScpMessages: %w", err) } return n, nil } @@ -14254,7 +14749,7 @@ func (s ScpHistoryEntryV0) MarshalBinary() ([]byte, error) { func (s *ScpHistoryEntryV0) UnmarshalBinary(inp []byte) error { r := bytes.NewReader(inp) d := xdr.NewDecoder(r) - _, err := s.DecodeFrom(d) + _, err := s.DecodeFrom(d, xdr.DecodeDefaultMaxDepth) return err } @@ -14304,7 +14799,7 @@ func NewScpHistoryEntry(v int32, value interface{}) (result ScpHistoryEntry, err case 0: tv, ok := value.(ScpHistoryEntryV0) if !ok { - err = fmt.Errorf("invalid value, must be ScpHistoryEntryV0") + err = errors.New("invalid value, must be ScpHistoryEntryV0") return } result.V0 = &tv @@ -14356,21 +14851,25 @@ func (u ScpHistoryEntry) EncodeTo(e *xdr.Encoder) error { var _ decoderFrom = (*ScpHistoryEntry)(nil) // DecodeFrom decodes this value using the Decoder. -func (u *ScpHistoryEntry) DecodeFrom(d *xdr.Decoder) (int, error) { +func (u *ScpHistoryEntry) DecodeFrom(d *xdr.Decoder, maxDepth uint) (int, error) { + if maxDepth == 0 { + return 0, fmt.Errorf("decoding ScpHistoryEntry: %w", ErrMaxDecodingDepthReached) + } + maxDepth -= 1 var err error var n, nTmp int u.V, nTmp, err = d.DecodeInt() n += nTmp if err != nil { - return n, fmt.Errorf("decoding Int: %s", err) + return n, fmt.Errorf("decoding Int: %w", err) } switch int32(u.V) { case 0: u.V0 = new(ScpHistoryEntryV0) - nTmp, err = (*u.V0).DecodeFrom(d) + nTmp, err = (*u.V0).DecodeFrom(d, maxDepth) n += nTmp if err != nil { - return n, fmt.Errorf("decoding ScpHistoryEntryV0: %s", err) + return n, fmt.Errorf("decoding ScpHistoryEntryV0: %w", err) } return n, nil } @@ -14389,7 +14888,7 @@ func (s ScpHistoryEntry) MarshalBinary() ([]byte, error) { func (s *ScpHistoryEntry) UnmarshalBinary(inp []byte) error { r := bytes.NewReader(inp) d := xdr.NewDecoder(r) - _, err := s.DecodeFrom(d) + _, err := s.DecodeFrom(d, xdr.DecodeDefaultMaxDepth) return err } @@ -14454,10 +14953,14 @@ func (e LedgerEntryChangeType) EncodeTo(enc *xdr.Encoder) error { var _ decoderFrom = (*LedgerEntryChangeType)(nil) // DecodeFrom decodes this value using the Decoder. -func (e *LedgerEntryChangeType) DecodeFrom(d *xdr.Decoder) (int, error) { +func (e *LedgerEntryChangeType) DecodeFrom(d *xdr.Decoder, maxDepth uint) (int, error) { + if maxDepth == 0 { + return 0, fmt.Errorf("decoding LedgerEntryChangeType: %w", ErrMaxDecodingDepthReached) + } + maxDepth -= 1 v, n, err := d.DecodeInt() if err != nil { - return n, fmt.Errorf("decoding LedgerEntryChangeType: %s", err) + return n, fmt.Errorf("decoding LedgerEntryChangeType: %w", err) } if _, ok := ledgerEntryChangeTypeMap[v]; !ok { return n, fmt.Errorf("'%d' is not a valid LedgerEntryChangeType enum value", v) @@ -14478,7 +14981,7 @@ func (s LedgerEntryChangeType) MarshalBinary() ([]byte, error) { func (s *LedgerEntryChangeType) UnmarshalBinary(inp []byte) error { r := bytes.NewReader(inp) d := xdr.NewDecoder(r) - _, err := s.DecodeFrom(d) + _, err := s.DecodeFrom(d, xdr.DecodeDefaultMaxDepth) return err } @@ -14543,28 +15046,28 @@ func NewLedgerEntryChange(aType LedgerEntryChangeType, value interface{}) (resul case LedgerEntryChangeTypeLedgerEntryCreated: tv, ok := value.(LedgerEntry) if !ok { - err = fmt.Errorf("invalid value, must be LedgerEntry") + err = errors.New("invalid value, must be LedgerEntry") return } result.Created = &tv case LedgerEntryChangeTypeLedgerEntryUpdated: tv, ok := value.(LedgerEntry) if !ok { - err = fmt.Errorf("invalid value, must be LedgerEntry") + err = errors.New("invalid value, must be LedgerEntry") return } result.Updated = &tv case LedgerEntryChangeTypeLedgerEntryRemoved: tv, ok := value.(LedgerKey) if !ok { - err = fmt.Errorf("invalid value, must be LedgerKey") + err = errors.New("invalid value, must be LedgerKey") return } result.Removed = &tv case LedgerEntryChangeTypeLedgerEntryState: tv, ok := value.(LedgerEntry) if !ok { - err = fmt.Errorf("invalid value, must be LedgerEntry") + err = errors.New("invalid value, must be LedgerEntry") return } result.State = &tv @@ -14706,45 +15209,49 @@ func (u LedgerEntryChange) EncodeTo(e *xdr.Encoder) error { var _ decoderFrom = (*LedgerEntryChange)(nil) // DecodeFrom decodes this value using the Decoder. -func (u *LedgerEntryChange) DecodeFrom(d *xdr.Decoder) (int, error) { +func (u *LedgerEntryChange) DecodeFrom(d *xdr.Decoder, maxDepth uint) (int, error) { + if maxDepth == 0 { + return 0, fmt.Errorf("decoding LedgerEntryChange: %w", ErrMaxDecodingDepthReached) + } + maxDepth -= 1 var err error var n, nTmp int - nTmp, err = u.Type.DecodeFrom(d) + nTmp, err = u.Type.DecodeFrom(d, maxDepth) n += nTmp if err != nil { - return n, fmt.Errorf("decoding LedgerEntryChangeType: %s", err) + return n, fmt.Errorf("decoding LedgerEntryChangeType: %w", err) } switch LedgerEntryChangeType(u.Type) { case LedgerEntryChangeTypeLedgerEntryCreated: u.Created = new(LedgerEntry) - nTmp, err = (*u.Created).DecodeFrom(d) + nTmp, err = (*u.Created).DecodeFrom(d, maxDepth) n += nTmp if err != nil { - return n, fmt.Errorf("decoding LedgerEntry: %s", err) + return n, fmt.Errorf("decoding LedgerEntry: %w", err) } return n, nil case LedgerEntryChangeTypeLedgerEntryUpdated: u.Updated = new(LedgerEntry) - nTmp, err = (*u.Updated).DecodeFrom(d) + nTmp, err = (*u.Updated).DecodeFrom(d, maxDepth) n += nTmp if err != nil { - return n, fmt.Errorf("decoding LedgerEntry: %s", err) + return n, fmt.Errorf("decoding LedgerEntry: %w", err) } return n, nil case LedgerEntryChangeTypeLedgerEntryRemoved: u.Removed = new(LedgerKey) - nTmp, err = (*u.Removed).DecodeFrom(d) + nTmp, err = (*u.Removed).DecodeFrom(d, maxDepth) n += nTmp if err != nil { - return n, fmt.Errorf("decoding LedgerKey: %s", err) + return n, fmt.Errorf("decoding LedgerKey: %w", err) } return n, nil case LedgerEntryChangeTypeLedgerEntryState: u.State = new(LedgerEntry) - nTmp, err = (*u.State).DecodeFrom(d) + nTmp, err = (*u.State).DecodeFrom(d, maxDepth) n += nTmp if err != nil { - return n, fmt.Errorf("decoding LedgerEntry: %s", err) + return n, fmt.Errorf("decoding LedgerEntry: %w", err) } return n, nil } @@ -14763,7 +15270,7 @@ func (s LedgerEntryChange) MarshalBinary() ([]byte, error) { func (s *LedgerEntryChange) UnmarshalBinary(inp []byte) error { r := bytes.NewReader(inp) d := xdr.NewDecoder(r) - _, err := s.DecodeFrom(d) + _, err := s.DecodeFrom(d, xdr.DecodeDefaultMaxDepth) return err } @@ -14800,23 +15307,27 @@ func (s LedgerEntryChanges) EncodeTo(e *xdr.Encoder) error { var _ decoderFrom = (*LedgerEntryChanges)(nil) // DecodeFrom decodes this value using the Decoder. -func (s *LedgerEntryChanges) DecodeFrom(d *xdr.Decoder) (int, error) { +func (s *LedgerEntryChanges) DecodeFrom(d *xdr.Decoder, maxDepth uint) (int, error) { + if maxDepth == 0 { + return 0, fmt.Errorf("decoding LedgerEntryChanges: %w", ErrMaxDecodingDepthReached) + } + maxDepth -= 1 var err error var n, nTmp int var l uint32 l, nTmp, err = d.DecodeUint() n += nTmp if err != nil { - return n, fmt.Errorf("decoding LedgerEntryChange: %s", err) + return n, fmt.Errorf("decoding LedgerEntryChange: %w", err) } (*s) = nil if l > 0 { (*s) = make([]LedgerEntryChange, l) for i := uint32(0); i < l; i++ { - nTmp, err = (*s)[i].DecodeFrom(d) + nTmp, err = (*s)[i].DecodeFrom(d, maxDepth) n += nTmp if err != nil { - return n, fmt.Errorf("decoding LedgerEntryChange: %s", err) + return n, fmt.Errorf("decoding LedgerEntryChange: %w", err) } } } @@ -14835,7 +15346,7 @@ func (s LedgerEntryChanges) MarshalBinary() ([]byte, error) { func (s *LedgerEntryChanges) UnmarshalBinary(inp []byte) error { r := bytes.NewReader(inp) d := xdr.NewDecoder(r) - _, err := s.DecodeFrom(d) + _, err := s.DecodeFrom(d, xdr.DecodeDefaultMaxDepth) return err } @@ -14872,13 +15383,17 @@ func (s *OperationMeta) EncodeTo(e *xdr.Encoder) error { var _ decoderFrom = (*OperationMeta)(nil) // DecodeFrom decodes this value using the Decoder. -func (s *OperationMeta) DecodeFrom(d *xdr.Decoder) (int, error) { +func (s *OperationMeta) DecodeFrom(d *xdr.Decoder, maxDepth uint) (int, error) { + if maxDepth == 0 { + return 0, fmt.Errorf("decoding OperationMeta: %w", ErrMaxDecodingDepthReached) + } + maxDepth -= 1 var err error var n, nTmp int - nTmp, err = s.Changes.DecodeFrom(d) + nTmp, err = s.Changes.DecodeFrom(d, maxDepth) n += nTmp if err != nil { - return n, fmt.Errorf("decoding LedgerEntryChanges: %s", err) + return n, fmt.Errorf("decoding LedgerEntryChanges: %w", err) } return n, nil } @@ -14895,7 +15410,7 @@ func (s OperationMeta) MarshalBinary() ([]byte, error) { func (s *OperationMeta) UnmarshalBinary(inp []byte) error { r := bytes.NewReader(inp) d := xdr.NewDecoder(r) - _, err := s.DecodeFrom(d) + _, err := s.DecodeFrom(d, xdr.DecodeDefaultMaxDepth) return err } @@ -14942,28 +15457,32 @@ func (s *TransactionMetaV1) EncodeTo(e *xdr.Encoder) error { var _ decoderFrom = (*TransactionMetaV1)(nil) // DecodeFrom decodes this value using the Decoder. -func (s *TransactionMetaV1) DecodeFrom(d *xdr.Decoder) (int, error) { +func (s *TransactionMetaV1) DecodeFrom(d *xdr.Decoder, maxDepth uint) (int, error) { + if maxDepth == 0 { + return 0, fmt.Errorf("decoding TransactionMetaV1: %w", ErrMaxDecodingDepthReached) + } + maxDepth -= 1 var err error var n, nTmp int - nTmp, err = s.TxChanges.DecodeFrom(d) + nTmp, err = s.TxChanges.DecodeFrom(d, maxDepth) n += nTmp if err != nil { - return n, fmt.Errorf("decoding LedgerEntryChanges: %s", err) + return n, fmt.Errorf("decoding LedgerEntryChanges: %w", err) } var l uint32 l, nTmp, err = d.DecodeUint() n += nTmp if err != nil { - return n, fmt.Errorf("decoding OperationMeta: %s", err) + return n, fmt.Errorf("decoding OperationMeta: %w", err) } s.Operations = nil if l > 0 { s.Operations = make([]OperationMeta, l) for i := uint32(0); i < l; i++ { - nTmp, err = s.Operations[i].DecodeFrom(d) + nTmp, err = s.Operations[i].DecodeFrom(d, maxDepth) n += nTmp if err != nil { - return n, fmt.Errorf("decoding OperationMeta: %s", err) + return n, fmt.Errorf("decoding OperationMeta: %w", err) } } } @@ -14982,7 +15501,7 @@ func (s TransactionMetaV1) MarshalBinary() ([]byte, error) { func (s *TransactionMetaV1) UnmarshalBinary(inp []byte) error { r := bytes.NewReader(inp) d := xdr.NewDecoder(r) - _, err := s.DecodeFrom(d) + _, err := s.DecodeFrom(d, xdr.DecodeDefaultMaxDepth) return err } @@ -15036,35 +15555,39 @@ func (s *TransactionMetaV2) EncodeTo(e *xdr.Encoder) error { var _ decoderFrom = (*TransactionMetaV2)(nil) // DecodeFrom decodes this value using the Decoder. -func (s *TransactionMetaV2) DecodeFrom(d *xdr.Decoder) (int, error) { +func (s *TransactionMetaV2) DecodeFrom(d *xdr.Decoder, maxDepth uint) (int, error) { + if maxDepth == 0 { + return 0, fmt.Errorf("decoding TransactionMetaV2: %w", ErrMaxDecodingDepthReached) + } + maxDepth -= 1 var err error var n, nTmp int - nTmp, err = s.TxChangesBefore.DecodeFrom(d) + nTmp, err = s.TxChangesBefore.DecodeFrom(d, maxDepth) n += nTmp if err != nil { - return n, fmt.Errorf("decoding LedgerEntryChanges: %s", err) + return n, fmt.Errorf("decoding LedgerEntryChanges: %w", err) } var l uint32 l, nTmp, err = d.DecodeUint() n += nTmp if err != nil { - return n, fmt.Errorf("decoding OperationMeta: %s", err) + return n, fmt.Errorf("decoding OperationMeta: %w", err) } s.Operations = nil if l > 0 { s.Operations = make([]OperationMeta, l) for i := uint32(0); i < l; i++ { - nTmp, err = s.Operations[i].DecodeFrom(d) + nTmp, err = s.Operations[i].DecodeFrom(d, maxDepth) n += nTmp if err != nil { - return n, fmt.Errorf("decoding OperationMeta: %s", err) + return n, fmt.Errorf("decoding OperationMeta: %w", err) } } } - nTmp, err = s.TxChangesAfter.DecodeFrom(d) + nTmp, err = s.TxChangesAfter.DecodeFrom(d, maxDepth) n += nTmp if err != nil { - return n, fmt.Errorf("decoding LedgerEntryChanges: %s", err) + return n, fmt.Errorf("decoding LedgerEntryChanges: %w", err) } return n, nil } @@ -15081,7 +15604,7 @@ func (s TransactionMetaV2) MarshalBinary() ([]byte, error) { func (s *TransactionMetaV2) UnmarshalBinary(inp []byte) error { r := bytes.NewReader(inp) d := xdr.NewDecoder(r) - _, err := s.DecodeFrom(d) + _, err := s.DecodeFrom(d, xdr.DecodeDefaultMaxDepth) return err } @@ -15143,10 +15666,14 @@ func (e ContractEventType) EncodeTo(enc *xdr.Encoder) error { var _ decoderFrom = (*ContractEventType)(nil) // DecodeFrom decodes this value using the Decoder. -func (e *ContractEventType) DecodeFrom(d *xdr.Decoder) (int, error) { +func (e *ContractEventType) DecodeFrom(d *xdr.Decoder, maxDepth uint) (int, error) { + if maxDepth == 0 { + return 0, fmt.Errorf("decoding ContractEventType: %w", ErrMaxDecodingDepthReached) + } + maxDepth -= 1 v, n, err := d.DecodeInt() if err != nil { - return n, fmt.Errorf("decoding ContractEventType: %s", err) + return n, fmt.Errorf("decoding ContractEventType: %w", err) } if _, ok := contractEventTypeMap[v]; !ok { return n, fmt.Errorf("'%d' is not a valid ContractEventType enum value", v) @@ -15167,7 +15694,7 @@ func (s ContractEventType) MarshalBinary() ([]byte, error) { func (s *ContractEventType) UnmarshalBinary(inp []byte) error { r := bytes.NewReader(inp) d := xdr.NewDecoder(r) - _, err := s.DecodeFrom(d) + _, err := s.DecodeFrom(d, xdr.DecodeDefaultMaxDepth) return err } @@ -15214,30 +15741,34 @@ func (s *ContractEventV0) EncodeTo(e *xdr.Encoder) error { var _ decoderFrom = (*ContractEventV0)(nil) // DecodeFrom decodes this value using the Decoder. -func (s *ContractEventV0) DecodeFrom(d *xdr.Decoder) (int, error) { +func (s *ContractEventV0) DecodeFrom(d *xdr.Decoder, maxDepth uint) (int, error) { + if maxDepth == 0 { + return 0, fmt.Errorf("decoding ContractEventV0: %w", ErrMaxDecodingDepthReached) + } + maxDepth -= 1 var err error var n, nTmp int var l uint32 l, nTmp, err = d.DecodeUint() n += nTmp if err != nil { - return n, fmt.Errorf("decoding ScVal: %s", err) + return n, fmt.Errorf("decoding ScVal: %w", err) } s.Topics = nil if l > 0 { s.Topics = make([]ScVal, l) for i := uint32(0); i < l; i++ { - nTmp, err = s.Topics[i].DecodeFrom(d) + nTmp, err = s.Topics[i].DecodeFrom(d, maxDepth) n += nTmp if err != nil { - return n, fmt.Errorf("decoding ScVal: %s", err) + return n, fmt.Errorf("decoding ScVal: %w", err) } } } - nTmp, err = s.Data.DecodeFrom(d) + nTmp, err = s.Data.DecodeFrom(d, maxDepth) n += nTmp if err != nil { - return n, fmt.Errorf("decoding ScVal: %s", err) + return n, fmt.Errorf("decoding ScVal: %w", err) } return n, nil } @@ -15254,7 +15785,7 @@ func (s ContractEventV0) MarshalBinary() ([]byte, error) { func (s *ContractEventV0) UnmarshalBinary(inp []byte) error { r := bytes.NewReader(inp) d := xdr.NewDecoder(r) - _, err := s.DecodeFrom(d) + _, err := s.DecodeFrom(d, xdr.DecodeDefaultMaxDepth) return err } @@ -15308,7 +15839,7 @@ func NewContractEventBody(v int32, value interface{}) (result ContractEventBody, case 0: tv, ok := value.(ContractEventV0) if !ok { - err = fmt.Errorf("invalid value, must be ContractEventV0") + err = errors.New("invalid value, must be ContractEventV0") return } result.V0 = &tv @@ -15360,21 +15891,25 @@ func (u ContractEventBody) EncodeTo(e *xdr.Encoder) error { var _ decoderFrom = (*ContractEventBody)(nil) // DecodeFrom decodes this value using the Decoder. -func (u *ContractEventBody) DecodeFrom(d *xdr.Decoder) (int, error) { +func (u *ContractEventBody) DecodeFrom(d *xdr.Decoder, maxDepth uint) (int, error) { + if maxDepth == 0 { + return 0, fmt.Errorf("decoding ContractEventBody: %w", ErrMaxDecodingDepthReached) + } + maxDepth -= 1 var err error var n, nTmp int u.V, nTmp, err = d.DecodeInt() n += nTmp if err != nil { - return n, fmt.Errorf("decoding Int: %s", err) + return n, fmt.Errorf("decoding Int: %w", err) } switch int32(u.V) { case 0: u.V0 = new(ContractEventV0) - nTmp, err = (*u.V0).DecodeFrom(d) + nTmp, err = (*u.V0).DecodeFrom(d, maxDepth) n += nTmp if err != nil { - return n, fmt.Errorf("decoding ContractEventV0: %s", err) + return n, fmt.Errorf("decoding ContractEventV0: %w", err) } return n, nil } @@ -15393,7 +15928,7 @@ func (s ContractEventBody) MarshalBinary() ([]byte, error) { func (s *ContractEventBody) UnmarshalBinary(inp []byte) error { r := bytes.NewReader(inp) d := xdr.NewDecoder(r) - _, err := s.DecodeFrom(d) + _, err := s.DecodeFrom(d, xdr.DecodeDefaultMaxDepth) return err } @@ -15463,38 +15998,42 @@ func (s *ContractEvent) EncodeTo(e *xdr.Encoder) error { var _ decoderFrom = (*ContractEvent)(nil) // DecodeFrom decodes this value using the Decoder. -func (s *ContractEvent) DecodeFrom(d *xdr.Decoder) (int, error) { +func (s *ContractEvent) DecodeFrom(d *xdr.Decoder, maxDepth uint) (int, error) { + if maxDepth == 0 { + return 0, fmt.Errorf("decoding ContractEvent: %w", ErrMaxDecodingDepthReached) + } + maxDepth -= 1 var err error var n, nTmp int - nTmp, err = s.Ext.DecodeFrom(d) + nTmp, err = s.Ext.DecodeFrom(d, maxDepth) n += nTmp if err != nil { - return n, fmt.Errorf("decoding ExtensionPoint: %s", err) + return n, fmt.Errorf("decoding ExtensionPoint: %w", err) } var b bool b, nTmp, err = d.DecodeBool() n += nTmp if err != nil { - return n, fmt.Errorf("decoding Hash: %s", err) + return n, fmt.Errorf("decoding Hash: %w", err) } s.ContractId = nil if b { s.ContractId = new(Hash) - nTmp, err = s.ContractId.DecodeFrom(d) + nTmp, err = s.ContractId.DecodeFrom(d, maxDepth) n += nTmp if err != nil { - return n, fmt.Errorf("decoding Hash: %s", err) + return n, fmt.Errorf("decoding Hash: %w", err) } } - nTmp, err = s.Type.DecodeFrom(d) + nTmp, err = s.Type.DecodeFrom(d, maxDepth) n += nTmp if err != nil { - return n, fmt.Errorf("decoding ContractEventType: %s", err) + return n, fmt.Errorf("decoding ContractEventType: %w", err) } - nTmp, err = s.Body.DecodeFrom(d) + nTmp, err = s.Body.DecodeFrom(d, maxDepth) n += nTmp if err != nil { - return n, fmt.Errorf("decoding ContractEventBody: %s", err) + return n, fmt.Errorf("decoding ContractEventBody: %w", err) } return n, nil } @@ -15511,7 +16050,7 @@ func (s ContractEvent) MarshalBinary() ([]byte, error) { func (s *ContractEvent) UnmarshalBinary(inp []byte) error { r := bytes.NewReader(inp) d := xdr.NewDecoder(r) - _, err := s.DecodeFrom(d) + _, err := s.DecodeFrom(d, xdr.DecodeDefaultMaxDepth) return err } @@ -15553,18 +16092,22 @@ func (s *DiagnosticEvent) EncodeTo(e *xdr.Encoder) error { var _ decoderFrom = (*DiagnosticEvent)(nil) // DecodeFrom decodes this value using the Decoder. -func (s *DiagnosticEvent) DecodeFrom(d *xdr.Decoder) (int, error) { +func (s *DiagnosticEvent) DecodeFrom(d *xdr.Decoder, maxDepth uint) (int, error) { + if maxDepth == 0 { + return 0, fmt.Errorf("decoding DiagnosticEvent: %w", ErrMaxDecodingDepthReached) + } + maxDepth -= 1 var err error var n, nTmp int s.InSuccessfulContractCall, nTmp, err = d.DecodeBool() n += nTmp if err != nil { - return n, fmt.Errorf("decoding Bool: %s", err) + return n, fmt.Errorf("decoding Bool: %w", err) } - nTmp, err = s.Event.DecodeFrom(d) + nTmp, err = s.Event.DecodeFrom(d, maxDepth) n += nTmp if err != nil { - return n, fmt.Errorf("decoding ContractEvent: %s", err) + return n, fmt.Errorf("decoding ContractEvent: %w", err) } return n, nil } @@ -15581,7 +16124,7 @@ func (s DiagnosticEvent) MarshalBinary() ([]byte, error) { func (s *DiagnosticEvent) UnmarshalBinary(inp []byte) error { r := bytes.NewReader(inp) d := xdr.NewDecoder(r) - _, err := s.DecodeFrom(d) + _, err := s.DecodeFrom(d, xdr.DecodeDefaultMaxDepth) return err } @@ -15649,49 +16192,53 @@ func (s *SorobanTransactionMeta) EncodeTo(e *xdr.Encoder) error { var _ decoderFrom = (*SorobanTransactionMeta)(nil) // DecodeFrom decodes this value using the Decoder. -func (s *SorobanTransactionMeta) DecodeFrom(d *xdr.Decoder) (int, error) { +func (s *SorobanTransactionMeta) DecodeFrom(d *xdr.Decoder, maxDepth uint) (int, error) { + if maxDepth == 0 { + return 0, fmt.Errorf("decoding SorobanTransactionMeta: %w", ErrMaxDecodingDepthReached) + } + maxDepth -= 1 var err error var n, nTmp int - nTmp, err = s.Ext.DecodeFrom(d) + nTmp, err = s.Ext.DecodeFrom(d, maxDepth) n += nTmp if err != nil { - return n, fmt.Errorf("decoding ExtensionPoint: %s", err) + return n, fmt.Errorf("decoding ExtensionPoint: %w", err) } var l uint32 l, nTmp, err = d.DecodeUint() n += nTmp if err != nil { - return n, fmt.Errorf("decoding ContractEvent: %s", err) + return n, fmt.Errorf("decoding ContractEvent: %w", err) } s.Events = nil if l > 0 { s.Events = make([]ContractEvent, l) for i := uint32(0); i < l; i++ { - nTmp, err = s.Events[i].DecodeFrom(d) + nTmp, err = s.Events[i].DecodeFrom(d, maxDepth) n += nTmp if err != nil { - return n, fmt.Errorf("decoding ContractEvent: %s", err) + return n, fmt.Errorf("decoding ContractEvent: %w", err) } } } - nTmp, err = s.ReturnValue.DecodeFrom(d) + nTmp, err = s.ReturnValue.DecodeFrom(d, maxDepth) n += nTmp if err != nil { - return n, fmt.Errorf("decoding ScVal: %s", err) + return n, fmt.Errorf("decoding ScVal: %w", err) } l, nTmp, err = d.DecodeUint() n += nTmp if err != nil { - return n, fmt.Errorf("decoding DiagnosticEvent: %s", err) + return n, fmt.Errorf("decoding DiagnosticEvent: %w", err) } s.DiagnosticEvents = nil if l > 0 { s.DiagnosticEvents = make([]DiagnosticEvent, l) for i := uint32(0); i < l; i++ { - nTmp, err = s.DiagnosticEvents[i].DecodeFrom(d) + nTmp, err = s.DiagnosticEvents[i].DecodeFrom(d, maxDepth) n += nTmp if err != nil { - return n, fmt.Errorf("decoding DiagnosticEvent: %s", err) + return n, fmt.Errorf("decoding DiagnosticEvent: %w", err) } } } @@ -15710,7 +16257,7 @@ func (s SorobanTransactionMeta) MarshalBinary() ([]byte, error) { func (s *SorobanTransactionMeta) UnmarshalBinary(inp []byte) error { r := bytes.NewReader(inp) d := xdr.NewDecoder(r) - _, err := s.DecodeFrom(d) + _, err := s.DecodeFrom(d, xdr.DecodeDefaultMaxDepth) return err } @@ -15781,54 +16328,58 @@ func (s *TransactionMetaV3) EncodeTo(e *xdr.Encoder) error { var _ decoderFrom = (*TransactionMetaV3)(nil) // DecodeFrom decodes this value using the Decoder. -func (s *TransactionMetaV3) DecodeFrom(d *xdr.Decoder) (int, error) { +func (s *TransactionMetaV3) DecodeFrom(d *xdr.Decoder, maxDepth uint) (int, error) { + if maxDepth == 0 { + return 0, fmt.Errorf("decoding TransactionMetaV3: %w", ErrMaxDecodingDepthReached) + } + maxDepth -= 1 var err error var n, nTmp int - nTmp, err = s.Ext.DecodeFrom(d) + nTmp, err = s.Ext.DecodeFrom(d, maxDepth) n += nTmp if err != nil { - return n, fmt.Errorf("decoding ExtensionPoint: %s", err) + return n, fmt.Errorf("decoding ExtensionPoint: %w", err) } - nTmp, err = s.TxChangesBefore.DecodeFrom(d) + nTmp, err = s.TxChangesBefore.DecodeFrom(d, maxDepth) n += nTmp if err != nil { - return n, fmt.Errorf("decoding LedgerEntryChanges: %s", err) + return n, fmt.Errorf("decoding LedgerEntryChanges: %w", err) } var l uint32 l, nTmp, err = d.DecodeUint() n += nTmp if err != nil { - return n, fmt.Errorf("decoding OperationMeta: %s", err) + return n, fmt.Errorf("decoding OperationMeta: %w", err) } s.Operations = nil if l > 0 { s.Operations = make([]OperationMeta, l) for i := uint32(0); i < l; i++ { - nTmp, err = s.Operations[i].DecodeFrom(d) + nTmp, err = s.Operations[i].DecodeFrom(d, maxDepth) n += nTmp if err != nil { - return n, fmt.Errorf("decoding OperationMeta: %s", err) + return n, fmt.Errorf("decoding OperationMeta: %w", err) } } } - nTmp, err = s.TxChangesAfter.DecodeFrom(d) + nTmp, err = s.TxChangesAfter.DecodeFrom(d, maxDepth) n += nTmp if err != nil { - return n, fmt.Errorf("decoding LedgerEntryChanges: %s", err) + return n, fmt.Errorf("decoding LedgerEntryChanges: %w", err) } var b bool b, nTmp, err = d.DecodeBool() n += nTmp if err != nil { - return n, fmt.Errorf("decoding SorobanTransactionMeta: %s", err) + return n, fmt.Errorf("decoding SorobanTransactionMeta: %w", err) } s.SorobanMeta = nil if b { s.SorobanMeta = new(SorobanTransactionMeta) - nTmp, err = s.SorobanMeta.DecodeFrom(d) + nTmp, err = s.SorobanMeta.DecodeFrom(d, maxDepth) n += nTmp if err != nil { - return n, fmt.Errorf("decoding SorobanTransactionMeta: %s", err) + return n, fmt.Errorf("decoding SorobanTransactionMeta: %w", err) } } return n, nil @@ -15846,7 +16397,7 @@ func (s TransactionMetaV3) MarshalBinary() ([]byte, error) { func (s *TransactionMetaV3) UnmarshalBinary(inp []byte) error { r := bytes.NewReader(inp) d := xdr.NewDecoder(r) - _, err := s.DecodeFrom(d) + _, err := s.DecodeFrom(d, xdr.DecodeDefaultMaxDepth) return err } @@ -15893,28 +16444,32 @@ func (s *InvokeHostFunctionSuccessPreImage) EncodeTo(e *xdr.Encoder) error { var _ decoderFrom = (*InvokeHostFunctionSuccessPreImage)(nil) // DecodeFrom decodes this value using the Decoder. -func (s *InvokeHostFunctionSuccessPreImage) DecodeFrom(d *xdr.Decoder) (int, error) { +func (s *InvokeHostFunctionSuccessPreImage) DecodeFrom(d *xdr.Decoder, maxDepth uint) (int, error) { + if maxDepth == 0 { + return 0, fmt.Errorf("decoding InvokeHostFunctionSuccessPreImage: %w", ErrMaxDecodingDepthReached) + } + maxDepth -= 1 var err error var n, nTmp int - nTmp, err = s.ReturnValue.DecodeFrom(d) + nTmp, err = s.ReturnValue.DecodeFrom(d, maxDepth) n += nTmp if err != nil { - return n, fmt.Errorf("decoding ScVal: %s", err) + return n, fmt.Errorf("decoding ScVal: %w", err) } var l uint32 l, nTmp, err = d.DecodeUint() n += nTmp if err != nil { - return n, fmt.Errorf("decoding ContractEvent: %s", err) + return n, fmt.Errorf("decoding ContractEvent: %w", err) } s.Events = nil if l > 0 { s.Events = make([]ContractEvent, l) for i := uint32(0); i < l; i++ { - nTmp, err = s.Events[i].DecodeFrom(d) + nTmp, err = s.Events[i].DecodeFrom(d, maxDepth) n += nTmp if err != nil { - return n, fmt.Errorf("decoding ContractEvent: %s", err) + return n, fmt.Errorf("decoding ContractEvent: %w", err) } } } @@ -15933,7 +16488,7 @@ func (s InvokeHostFunctionSuccessPreImage) MarshalBinary() ([]byte, error) { func (s *InvokeHostFunctionSuccessPreImage) UnmarshalBinary(inp []byte) error { r := bytes.NewReader(inp) d := xdr.NewDecoder(r) - _, err := s.DecodeFrom(d) + _, err := s.DecodeFrom(d, xdr.DecodeDefaultMaxDepth) return err } @@ -15998,28 +16553,28 @@ func NewTransactionMeta(v int32, value interface{}) (result TransactionMeta, err case 0: tv, ok := value.([]OperationMeta) if !ok { - err = fmt.Errorf("invalid value, must be []OperationMeta") + err = errors.New("invalid value, must be []OperationMeta") return } result.Operations = &tv case 1: tv, ok := value.(TransactionMetaV1) if !ok { - err = fmt.Errorf("invalid value, must be TransactionMetaV1") + err = errors.New("invalid value, must be TransactionMetaV1") return } result.V1 = &tv case 2: tv, ok := value.(TransactionMetaV2) if !ok { - err = fmt.Errorf("invalid value, must be TransactionMetaV2") + err = errors.New("invalid value, must be TransactionMetaV2") return } result.V2 = &tv case 3: tv, ok := value.(TransactionMetaV3) if !ok { - err = fmt.Errorf("invalid value, must be TransactionMetaV3") + err = errors.New("invalid value, must be TransactionMetaV3") return } result.V3 = &tv @@ -16166,13 +16721,17 @@ func (u TransactionMeta) EncodeTo(e *xdr.Encoder) error { var _ decoderFrom = (*TransactionMeta)(nil) // DecodeFrom decodes this value using the Decoder. -func (u *TransactionMeta) DecodeFrom(d *xdr.Decoder) (int, error) { +func (u *TransactionMeta) DecodeFrom(d *xdr.Decoder, maxDepth uint) (int, error) { + if maxDepth == 0 { + return 0, fmt.Errorf("decoding TransactionMeta: %w", ErrMaxDecodingDepthReached) + } + maxDepth -= 1 var err error var n, nTmp int u.V, nTmp, err = d.DecodeInt() n += nTmp if err != nil { - return n, fmt.Errorf("decoding Int: %s", err) + return n, fmt.Errorf("decoding Int: %w", err) } switch int32(u.V) { case 0: @@ -16181,42 +16740,42 @@ func (u *TransactionMeta) DecodeFrom(d *xdr.Decoder) (int, error) { l, nTmp, err = d.DecodeUint() n += nTmp if err != nil { - return n, fmt.Errorf("decoding OperationMeta: %s", err) + return n, fmt.Errorf("decoding OperationMeta: %w", err) } (*u.Operations) = nil if l > 0 { (*u.Operations) = make([]OperationMeta, l) for i := uint32(0); i < l; i++ { - nTmp, err = (*u.Operations)[i].DecodeFrom(d) + nTmp, err = (*u.Operations)[i].DecodeFrom(d, maxDepth) n += nTmp if err != nil { - return n, fmt.Errorf("decoding OperationMeta: %s", err) + return n, fmt.Errorf("decoding OperationMeta: %w", err) } } } return n, nil case 1: u.V1 = new(TransactionMetaV1) - nTmp, err = (*u.V1).DecodeFrom(d) + nTmp, err = (*u.V1).DecodeFrom(d, maxDepth) n += nTmp if err != nil { - return n, fmt.Errorf("decoding TransactionMetaV1: %s", err) + return n, fmt.Errorf("decoding TransactionMetaV1: %w", err) } return n, nil case 2: u.V2 = new(TransactionMetaV2) - nTmp, err = (*u.V2).DecodeFrom(d) + nTmp, err = (*u.V2).DecodeFrom(d, maxDepth) n += nTmp if err != nil { - return n, fmt.Errorf("decoding TransactionMetaV2: %s", err) + return n, fmt.Errorf("decoding TransactionMetaV2: %w", err) } return n, nil case 3: u.V3 = new(TransactionMetaV3) - nTmp, err = (*u.V3).DecodeFrom(d) + nTmp, err = (*u.V3).DecodeFrom(d, maxDepth) n += nTmp if err != nil { - return n, fmt.Errorf("decoding TransactionMetaV3: %s", err) + return n, fmt.Errorf("decoding TransactionMetaV3: %w", err) } return n, nil } @@ -16235,7 +16794,7 @@ func (s TransactionMeta) MarshalBinary() ([]byte, error) { func (s *TransactionMeta) UnmarshalBinary(inp []byte) error { r := bytes.NewReader(inp) d := xdr.NewDecoder(r) - _, err := s.DecodeFrom(d) + _, err := s.DecodeFrom(d, xdr.DecodeDefaultMaxDepth) return err } @@ -16282,23 +16841,27 @@ func (s *TransactionResultMeta) EncodeTo(e *xdr.Encoder) error { var _ decoderFrom = (*TransactionResultMeta)(nil) // DecodeFrom decodes this value using the Decoder. -func (s *TransactionResultMeta) DecodeFrom(d *xdr.Decoder) (int, error) { +func (s *TransactionResultMeta) DecodeFrom(d *xdr.Decoder, maxDepth uint) (int, error) { + if maxDepth == 0 { + return 0, fmt.Errorf("decoding TransactionResultMeta: %w", ErrMaxDecodingDepthReached) + } + maxDepth -= 1 var err error var n, nTmp int - nTmp, err = s.Result.DecodeFrom(d) + nTmp, err = s.Result.DecodeFrom(d, maxDepth) n += nTmp if err != nil { - return n, fmt.Errorf("decoding TransactionResultPair: %s", err) + return n, fmt.Errorf("decoding TransactionResultPair: %w", err) } - nTmp, err = s.FeeProcessing.DecodeFrom(d) + nTmp, err = s.FeeProcessing.DecodeFrom(d, maxDepth) n += nTmp if err != nil { - return n, fmt.Errorf("decoding LedgerEntryChanges: %s", err) + return n, fmt.Errorf("decoding LedgerEntryChanges: %w", err) } - nTmp, err = s.TxApplyProcessing.DecodeFrom(d) + nTmp, err = s.TxApplyProcessing.DecodeFrom(d, maxDepth) n += nTmp if err != nil { - return n, fmt.Errorf("decoding TransactionMeta: %s", err) + return n, fmt.Errorf("decoding TransactionMeta: %w", err) } return n, nil } @@ -16315,7 +16878,7 @@ func (s TransactionResultMeta) MarshalBinary() ([]byte, error) { func (s *TransactionResultMeta) UnmarshalBinary(inp []byte) error { r := bytes.NewReader(inp) d := xdr.NewDecoder(r) - _, err := s.DecodeFrom(d) + _, err := s.DecodeFrom(d, xdr.DecodeDefaultMaxDepth) return err } @@ -16357,18 +16920,22 @@ func (s *UpgradeEntryMeta) EncodeTo(e *xdr.Encoder) error { var _ decoderFrom = (*UpgradeEntryMeta)(nil) // DecodeFrom decodes this value using the Decoder. -func (s *UpgradeEntryMeta) DecodeFrom(d *xdr.Decoder) (int, error) { +func (s *UpgradeEntryMeta) DecodeFrom(d *xdr.Decoder, maxDepth uint) (int, error) { + if maxDepth == 0 { + return 0, fmt.Errorf("decoding UpgradeEntryMeta: %w", ErrMaxDecodingDepthReached) + } + maxDepth -= 1 var err error var n, nTmp int - nTmp, err = s.Upgrade.DecodeFrom(d) + nTmp, err = s.Upgrade.DecodeFrom(d, maxDepth) n += nTmp if err != nil { - return n, fmt.Errorf("decoding LedgerUpgrade: %s", err) + return n, fmt.Errorf("decoding LedgerUpgrade: %w", err) } - nTmp, err = s.Changes.DecodeFrom(d) + nTmp, err = s.Changes.DecodeFrom(d, maxDepth) n += nTmp if err != nil { - return n, fmt.Errorf("decoding LedgerEntryChanges: %s", err) + return n, fmt.Errorf("decoding LedgerEntryChanges: %w", err) } return n, nil } @@ -16385,7 +16952,7 @@ func (s UpgradeEntryMeta) MarshalBinary() ([]byte, error) { func (s *UpgradeEntryMeta) UnmarshalBinary(inp []byte) error { r := bytes.NewReader(inp) d := xdr.NewDecoder(r) - _, err := s.DecodeFrom(d) + _, err := s.DecodeFrom(d, xdr.DecodeDefaultMaxDepth) return err } @@ -16466,65 +17033,69 @@ func (s *LedgerCloseMetaV0) EncodeTo(e *xdr.Encoder) error { var _ decoderFrom = (*LedgerCloseMetaV0)(nil) // DecodeFrom decodes this value using the Decoder. -func (s *LedgerCloseMetaV0) DecodeFrom(d *xdr.Decoder) (int, error) { +func (s *LedgerCloseMetaV0) DecodeFrom(d *xdr.Decoder, maxDepth uint) (int, error) { + if maxDepth == 0 { + return 0, fmt.Errorf("decoding LedgerCloseMetaV0: %w", ErrMaxDecodingDepthReached) + } + maxDepth -= 1 var err error var n, nTmp int - nTmp, err = s.LedgerHeader.DecodeFrom(d) + nTmp, err = s.LedgerHeader.DecodeFrom(d, maxDepth) n += nTmp if err != nil { - return n, fmt.Errorf("decoding LedgerHeaderHistoryEntry: %s", err) + return n, fmt.Errorf("decoding LedgerHeaderHistoryEntry: %w", err) } - nTmp, err = s.TxSet.DecodeFrom(d) + nTmp, err = s.TxSet.DecodeFrom(d, maxDepth) n += nTmp if err != nil { - return n, fmt.Errorf("decoding TransactionSet: %s", err) + return n, fmt.Errorf("decoding TransactionSet: %w", err) } var l uint32 l, nTmp, err = d.DecodeUint() n += nTmp if err != nil { - return n, fmt.Errorf("decoding TransactionResultMeta: %s", err) + return n, fmt.Errorf("decoding TransactionResultMeta: %w", err) } s.TxProcessing = nil if l > 0 { s.TxProcessing = make([]TransactionResultMeta, l) for i := uint32(0); i < l; i++ { - nTmp, err = s.TxProcessing[i].DecodeFrom(d) + nTmp, err = s.TxProcessing[i].DecodeFrom(d, maxDepth) n += nTmp if err != nil { - return n, fmt.Errorf("decoding TransactionResultMeta: %s", err) + return n, fmt.Errorf("decoding TransactionResultMeta: %w", err) } } } l, nTmp, err = d.DecodeUint() n += nTmp if err != nil { - return n, fmt.Errorf("decoding UpgradeEntryMeta: %s", err) + return n, fmt.Errorf("decoding UpgradeEntryMeta: %w", err) } s.UpgradesProcessing = nil if l > 0 { s.UpgradesProcessing = make([]UpgradeEntryMeta, l) for i := uint32(0); i < l; i++ { - nTmp, err = s.UpgradesProcessing[i].DecodeFrom(d) + nTmp, err = s.UpgradesProcessing[i].DecodeFrom(d, maxDepth) n += nTmp if err != nil { - return n, fmt.Errorf("decoding UpgradeEntryMeta: %s", err) + return n, fmt.Errorf("decoding UpgradeEntryMeta: %w", err) } } } l, nTmp, err = d.DecodeUint() n += nTmp if err != nil { - return n, fmt.Errorf("decoding ScpHistoryEntry: %s", err) + return n, fmt.Errorf("decoding ScpHistoryEntry: %w", err) } s.ScpInfo = nil if l > 0 { s.ScpInfo = make([]ScpHistoryEntry, l) for i := uint32(0); i < l; i++ { - nTmp, err = s.ScpInfo[i].DecodeFrom(d) + nTmp, err = s.ScpInfo[i].DecodeFrom(d, maxDepth) n += nTmp if err != nil { - return n, fmt.Errorf("decoding ScpHistoryEntry: %s", err) + return n, fmt.Errorf("decoding ScpHistoryEntry: %w", err) } } } @@ -16543,7 +17114,7 @@ func (s LedgerCloseMetaV0) MarshalBinary() ([]byte, error) { func (s *LedgerCloseMetaV0) UnmarshalBinary(inp []byte) error { r := bytes.NewReader(inp) d := xdr.NewDecoder(r) - _, err := s.DecodeFrom(d) + _, err := s.DecodeFrom(d, xdr.DecodeDefaultMaxDepth) return err } @@ -16562,166 +17133,8 @@ var _ xdrType = (*LedgerCloseMetaV0)(nil) // // struct LedgerCloseMetaV1 // { -// LedgerHeaderHistoryEntry ledgerHeader; -// -// GeneralizedTransactionSet txSet; -// -// // NB: transactions are sorted in apply order here -// // fees for all transactions are processed first -// // followed by applying transactions -// TransactionResultMeta txProcessing<>; -// -// // upgrades are applied last -// UpgradeEntryMeta upgradesProcessing<>; -// -// // other misc information attached to the ledger close -// SCPHistoryEntry scpInfo<>; -// }; -type LedgerCloseMetaV1 struct { - LedgerHeader LedgerHeaderHistoryEntry - TxSet GeneralizedTransactionSet - TxProcessing []TransactionResultMeta - UpgradesProcessing []UpgradeEntryMeta - ScpInfo []ScpHistoryEntry -} - -// EncodeTo encodes this value using the Encoder. -func (s *LedgerCloseMetaV1) EncodeTo(e *xdr.Encoder) error { - var err error - if err = s.LedgerHeader.EncodeTo(e); err != nil { - return err - } - if err = s.TxSet.EncodeTo(e); err != nil { - return err - } - if _, err = e.EncodeUint(uint32(len(s.TxProcessing))); err != nil { - return err - } - for i := 0; i < len(s.TxProcessing); i++ { - if err = s.TxProcessing[i].EncodeTo(e); err != nil { - return err - } - } - if _, err = e.EncodeUint(uint32(len(s.UpgradesProcessing))); err != nil { - return err - } - for i := 0; i < len(s.UpgradesProcessing); i++ { - if err = s.UpgradesProcessing[i].EncodeTo(e); err != nil { - return err - } - } - if _, err = e.EncodeUint(uint32(len(s.ScpInfo))); err != nil { - return err - } - for i := 0; i < len(s.ScpInfo); i++ { - if err = s.ScpInfo[i].EncodeTo(e); err != nil { - return err - } - } - return nil -} - -var _ decoderFrom = (*LedgerCloseMetaV1)(nil) - -// DecodeFrom decodes this value using the Decoder. -func (s *LedgerCloseMetaV1) DecodeFrom(d *xdr.Decoder) (int, error) { - var err error - var n, nTmp int - nTmp, err = s.LedgerHeader.DecodeFrom(d) - n += nTmp - if err != nil { - return n, fmt.Errorf("decoding LedgerHeaderHistoryEntry: %s", err) - } - nTmp, err = s.TxSet.DecodeFrom(d) - n += nTmp - if err != nil { - return n, fmt.Errorf("decoding GeneralizedTransactionSet: %s", err) - } - var l uint32 - l, nTmp, err = d.DecodeUint() - n += nTmp - if err != nil { - return n, fmt.Errorf("decoding TransactionResultMeta: %s", err) - } - s.TxProcessing = nil - if l > 0 { - s.TxProcessing = make([]TransactionResultMeta, l) - for i := uint32(0); i < l; i++ { - nTmp, err = s.TxProcessing[i].DecodeFrom(d) - n += nTmp - if err != nil { - return n, fmt.Errorf("decoding TransactionResultMeta: %s", err) - } - } - } - l, nTmp, err = d.DecodeUint() - n += nTmp - if err != nil { - return n, fmt.Errorf("decoding UpgradeEntryMeta: %s", err) - } - s.UpgradesProcessing = nil - if l > 0 { - s.UpgradesProcessing = make([]UpgradeEntryMeta, l) - for i := uint32(0); i < l; i++ { - nTmp, err = s.UpgradesProcessing[i].DecodeFrom(d) - n += nTmp - if err != nil { - return n, fmt.Errorf("decoding UpgradeEntryMeta: %s", err) - } - } - } - l, nTmp, err = d.DecodeUint() - n += nTmp - if err != nil { - return n, fmt.Errorf("decoding ScpHistoryEntry: %s", err) - } - s.ScpInfo = nil - if l > 0 { - s.ScpInfo = make([]ScpHistoryEntry, l) - for i := uint32(0); i < l; i++ { - nTmp, err = s.ScpInfo[i].DecodeFrom(d) - n += nTmp - if err != nil { - return n, fmt.Errorf("decoding ScpHistoryEntry: %s", err) - } - } - } - return n, nil -} - -// MarshalBinary implements encoding.BinaryMarshaler. -func (s LedgerCloseMetaV1) MarshalBinary() ([]byte, error) { - b := bytes.Buffer{} - e := xdr.NewEncoder(&b) - err := s.EncodeTo(e) - return b.Bytes(), err -} - -// UnmarshalBinary implements encoding.BinaryUnmarshaler. -func (s *LedgerCloseMetaV1) UnmarshalBinary(inp []byte) error { - r := bytes.NewReader(inp) - d := xdr.NewDecoder(r) - _, err := s.DecodeFrom(d) - return err -} - -var ( - _ encoding.BinaryMarshaler = (*LedgerCloseMetaV1)(nil) - _ encoding.BinaryUnmarshaler = (*LedgerCloseMetaV1)(nil) -) - -// xdrType signals that this type is an type representing -// representing XDR values defined by this package. -func (s LedgerCloseMetaV1) xdrType() {} - -var _ xdrType = (*LedgerCloseMetaV1)(nil) - -// LedgerCloseMetaV2 is an XDR Struct defines as: -// -// struct LedgerCloseMetaV2 -// { -// // We forgot to add an ExtensionPoint in v1 but at least -// // we can add one now in v2. +// // We forgot to add an ExtensionPoint in v0 but at least +// // we can add one now in v1. // ExtensionPoint ext; // // LedgerHeaderHistoryEntry ledgerHeader; @@ -16743,14 +17156,14 @@ var _ xdrType = (*LedgerCloseMetaV1)(nil) // // systems calculating storage fees correctly. // uint64 totalByteSizeOfBucketList; // -// // Expired temp keys that are being evicted at this ledger. +// // Temp keys that are being evicted at this ledger. // LedgerKey evictedTemporaryLedgerKeys<>; // -// // Expired restorable ledger entries that are being +// // Archived restorable ledger entries that are being // // evicted at this ledger. // LedgerEntry evictedPersistentLedgerEntries<>; // }; -type LedgerCloseMetaV2 struct { +type LedgerCloseMetaV1 struct { Ext ExtensionPoint LedgerHeader LedgerHeaderHistoryEntry TxSet GeneralizedTransactionSet @@ -16763,7 +17176,7 @@ type LedgerCloseMetaV2 struct { } // EncodeTo encodes this value using the Encoder. -func (s *LedgerCloseMetaV2) EncodeTo(e *xdr.Encoder) error { +func (s *LedgerCloseMetaV1) EncodeTo(e *xdr.Encoder) error { var err error if err = s.Ext.EncodeTo(e); err != nil { return err @@ -16820,110 +17233,114 @@ func (s *LedgerCloseMetaV2) EncodeTo(e *xdr.Encoder) error { return nil } -var _ decoderFrom = (*LedgerCloseMetaV2)(nil) +var _ decoderFrom = (*LedgerCloseMetaV1)(nil) // DecodeFrom decodes this value using the Decoder. -func (s *LedgerCloseMetaV2) DecodeFrom(d *xdr.Decoder) (int, error) { +func (s *LedgerCloseMetaV1) DecodeFrom(d *xdr.Decoder, maxDepth uint) (int, error) { + if maxDepth == 0 { + return 0, fmt.Errorf("decoding LedgerCloseMetaV1: %w", ErrMaxDecodingDepthReached) + } + maxDepth -= 1 var err error var n, nTmp int - nTmp, err = s.Ext.DecodeFrom(d) + nTmp, err = s.Ext.DecodeFrom(d, maxDepth) n += nTmp if err != nil { - return n, fmt.Errorf("decoding ExtensionPoint: %s", err) + return n, fmt.Errorf("decoding ExtensionPoint: %w", err) } - nTmp, err = s.LedgerHeader.DecodeFrom(d) + nTmp, err = s.LedgerHeader.DecodeFrom(d, maxDepth) n += nTmp if err != nil { - return n, fmt.Errorf("decoding LedgerHeaderHistoryEntry: %s", err) + return n, fmt.Errorf("decoding LedgerHeaderHistoryEntry: %w", err) } - nTmp, err = s.TxSet.DecodeFrom(d) + nTmp, err = s.TxSet.DecodeFrom(d, maxDepth) n += nTmp if err != nil { - return n, fmt.Errorf("decoding GeneralizedTransactionSet: %s", err) + return n, fmt.Errorf("decoding GeneralizedTransactionSet: %w", err) } var l uint32 l, nTmp, err = d.DecodeUint() n += nTmp if err != nil { - return n, fmt.Errorf("decoding TransactionResultMeta: %s", err) + return n, fmt.Errorf("decoding TransactionResultMeta: %w", err) } s.TxProcessing = nil if l > 0 { s.TxProcessing = make([]TransactionResultMeta, l) for i := uint32(0); i < l; i++ { - nTmp, err = s.TxProcessing[i].DecodeFrom(d) + nTmp, err = s.TxProcessing[i].DecodeFrom(d, maxDepth) n += nTmp if err != nil { - return n, fmt.Errorf("decoding TransactionResultMeta: %s", err) + return n, fmt.Errorf("decoding TransactionResultMeta: %w", err) } } } l, nTmp, err = d.DecodeUint() n += nTmp if err != nil { - return n, fmt.Errorf("decoding UpgradeEntryMeta: %s", err) + return n, fmt.Errorf("decoding UpgradeEntryMeta: %w", err) } s.UpgradesProcessing = nil if l > 0 { s.UpgradesProcessing = make([]UpgradeEntryMeta, l) for i := uint32(0); i < l; i++ { - nTmp, err = s.UpgradesProcessing[i].DecodeFrom(d) + nTmp, err = s.UpgradesProcessing[i].DecodeFrom(d, maxDepth) n += nTmp if err != nil { - return n, fmt.Errorf("decoding UpgradeEntryMeta: %s", err) + return n, fmt.Errorf("decoding UpgradeEntryMeta: %w", err) } } } l, nTmp, err = d.DecodeUint() n += nTmp if err != nil { - return n, fmt.Errorf("decoding ScpHistoryEntry: %s", err) + return n, fmt.Errorf("decoding ScpHistoryEntry: %w", err) } s.ScpInfo = nil if l > 0 { s.ScpInfo = make([]ScpHistoryEntry, l) for i := uint32(0); i < l; i++ { - nTmp, err = s.ScpInfo[i].DecodeFrom(d) + nTmp, err = s.ScpInfo[i].DecodeFrom(d, maxDepth) n += nTmp if err != nil { - return n, fmt.Errorf("decoding ScpHistoryEntry: %s", err) + return n, fmt.Errorf("decoding ScpHistoryEntry: %w", err) } } } - nTmp, err = s.TotalByteSizeOfBucketList.DecodeFrom(d) + nTmp, err = s.TotalByteSizeOfBucketList.DecodeFrom(d, maxDepth) n += nTmp if err != nil { - return n, fmt.Errorf("decoding Uint64: %s", err) + return n, fmt.Errorf("decoding Uint64: %w", err) } l, nTmp, err = d.DecodeUint() n += nTmp if err != nil { - return n, fmt.Errorf("decoding LedgerKey: %s", err) + return n, fmt.Errorf("decoding LedgerKey: %w", err) } s.EvictedTemporaryLedgerKeys = nil if l > 0 { s.EvictedTemporaryLedgerKeys = make([]LedgerKey, l) for i := uint32(0); i < l; i++ { - nTmp, err = s.EvictedTemporaryLedgerKeys[i].DecodeFrom(d) + nTmp, err = s.EvictedTemporaryLedgerKeys[i].DecodeFrom(d, maxDepth) n += nTmp if err != nil { - return n, fmt.Errorf("decoding LedgerKey: %s", err) + return n, fmt.Errorf("decoding LedgerKey: %w", err) } } } l, nTmp, err = d.DecodeUint() n += nTmp if err != nil { - return n, fmt.Errorf("decoding LedgerEntry: %s", err) + return n, fmt.Errorf("decoding LedgerEntry: %w", err) } s.EvictedPersistentLedgerEntries = nil if l > 0 { s.EvictedPersistentLedgerEntries = make([]LedgerEntry, l) for i := uint32(0); i < l; i++ { - nTmp, err = s.EvictedPersistentLedgerEntries[i].DecodeFrom(d) + nTmp, err = s.EvictedPersistentLedgerEntries[i].DecodeFrom(d, maxDepth) n += nTmp if err != nil { - return n, fmt.Errorf("decoding LedgerEntry: %s", err) + return n, fmt.Errorf("decoding LedgerEntry: %w", err) } } } @@ -16931,7 +17348,7 @@ func (s *LedgerCloseMetaV2) DecodeFrom(d *xdr.Decoder) (int, error) { } // MarshalBinary implements encoding.BinaryMarshaler. -func (s LedgerCloseMetaV2) MarshalBinary() ([]byte, error) { +func (s LedgerCloseMetaV1) MarshalBinary() ([]byte, error) { b := bytes.Buffer{} e := xdr.NewEncoder(&b) err := s.EncodeTo(e) @@ -16939,23 +17356,23 @@ func (s LedgerCloseMetaV2) MarshalBinary() ([]byte, error) { } // UnmarshalBinary implements encoding.BinaryUnmarshaler. -func (s *LedgerCloseMetaV2) UnmarshalBinary(inp []byte) error { +func (s *LedgerCloseMetaV1) UnmarshalBinary(inp []byte) error { r := bytes.NewReader(inp) d := xdr.NewDecoder(r) - _, err := s.DecodeFrom(d) + _, err := s.DecodeFrom(d, xdr.DecodeDefaultMaxDepth) return err } var ( - _ encoding.BinaryMarshaler = (*LedgerCloseMetaV2)(nil) - _ encoding.BinaryUnmarshaler = (*LedgerCloseMetaV2)(nil) + _ encoding.BinaryMarshaler = (*LedgerCloseMetaV1)(nil) + _ encoding.BinaryUnmarshaler = (*LedgerCloseMetaV1)(nil) ) // xdrType signals that this type is an type representing // representing XDR values defined by this package. -func (s LedgerCloseMetaV2) xdrType() {} +func (s LedgerCloseMetaV1) xdrType() {} -var _ xdrType = (*LedgerCloseMetaV2)(nil) +var _ xdrType = (*LedgerCloseMetaV1)(nil) // LedgerCloseMeta is an XDR Union defines as: // @@ -16965,14 +17382,11 @@ var _ xdrType = (*LedgerCloseMetaV2)(nil) // LedgerCloseMetaV0 v0; // case 1: // LedgerCloseMetaV1 v1; -// case 2: -// LedgerCloseMetaV2 v2; // }; type LedgerCloseMeta struct { V int32 V0 *LedgerCloseMetaV0 V1 *LedgerCloseMetaV1 - V2 *LedgerCloseMetaV2 } // SwitchFieldName returns the field name in which this union's @@ -16989,8 +17403,6 @@ func (u LedgerCloseMeta) ArmForSwitch(sw int32) (string, bool) { return "V0", true case 1: return "V1", true - case 2: - return "V2", true } return "-", false } @@ -17002,24 +17414,17 @@ func NewLedgerCloseMeta(v int32, value interface{}) (result LedgerCloseMeta, err case 0: tv, ok := value.(LedgerCloseMetaV0) if !ok { - err = fmt.Errorf("invalid value, must be LedgerCloseMetaV0") + err = errors.New("invalid value, must be LedgerCloseMetaV0") return } result.V0 = &tv case 1: tv, ok := value.(LedgerCloseMetaV1) if !ok { - err = fmt.Errorf("invalid value, must be LedgerCloseMetaV1") + err = errors.New("invalid value, must be LedgerCloseMetaV1") return } result.V1 = &tv - case 2: - tv, ok := value.(LedgerCloseMetaV2) - if !ok { - err = fmt.Errorf("invalid value, must be LedgerCloseMetaV2") - return - } - result.V2 = &tv } return } @@ -17074,31 +17479,6 @@ func (u LedgerCloseMeta) GetV1() (result LedgerCloseMetaV1, ok bool) { return } -// MustV2 retrieves the V2 value from the union, -// panicing if the value is not set. -func (u LedgerCloseMeta) MustV2() LedgerCloseMetaV2 { - val, ok := u.GetV2() - - if !ok { - panic("arm V2 is not set") - } - - return val -} - -// GetV2 retrieves the V2 value from the union, -// returning ok if the union's switch indicated the value is valid. -func (u LedgerCloseMeta) GetV2() (result LedgerCloseMetaV2, ok bool) { - armName, _ := u.ArmForSwitch(int32(u.V)) - - if armName == "V2" { - result = *u.V2 - ok = true - } - - return -} - // EncodeTo encodes this value using the Encoder. func (u LedgerCloseMeta) EncodeTo(e *xdr.Encoder) error { var err error @@ -17116,11 +17496,6 @@ func (u LedgerCloseMeta) EncodeTo(e *xdr.Encoder) error { return err } return nil - case 2: - if err = (*u.V2).EncodeTo(e); err != nil { - return err - } - return nil } return fmt.Errorf("V (int32) switch value '%d' is not valid for union LedgerCloseMeta", u.V) } @@ -17128,37 +17503,33 @@ func (u LedgerCloseMeta) EncodeTo(e *xdr.Encoder) error { var _ decoderFrom = (*LedgerCloseMeta)(nil) // DecodeFrom decodes this value using the Decoder. -func (u *LedgerCloseMeta) DecodeFrom(d *xdr.Decoder) (int, error) { +func (u *LedgerCloseMeta) DecodeFrom(d *xdr.Decoder, maxDepth uint) (int, error) { + if maxDepth == 0 { + return 0, fmt.Errorf("decoding LedgerCloseMeta: %w", ErrMaxDecodingDepthReached) + } + maxDepth -= 1 var err error var n, nTmp int u.V, nTmp, err = d.DecodeInt() n += nTmp if err != nil { - return n, fmt.Errorf("decoding Int: %s", err) + return n, fmt.Errorf("decoding Int: %w", err) } switch int32(u.V) { case 0: u.V0 = new(LedgerCloseMetaV0) - nTmp, err = (*u.V0).DecodeFrom(d) + nTmp, err = (*u.V0).DecodeFrom(d, maxDepth) n += nTmp if err != nil { - return n, fmt.Errorf("decoding LedgerCloseMetaV0: %s", err) + return n, fmt.Errorf("decoding LedgerCloseMetaV0: %w", err) } return n, nil case 1: u.V1 = new(LedgerCloseMetaV1) - nTmp, err = (*u.V1).DecodeFrom(d) + nTmp, err = (*u.V1).DecodeFrom(d, maxDepth) n += nTmp if err != nil { - return n, fmt.Errorf("decoding LedgerCloseMetaV1: %s", err) - } - return n, nil - case 2: - u.V2 = new(LedgerCloseMetaV2) - nTmp, err = (*u.V2).DecodeFrom(d) - n += nTmp - if err != nil { - return n, fmt.Errorf("decoding LedgerCloseMetaV2: %s", err) + return n, fmt.Errorf("decoding LedgerCloseMetaV1: %w", err) } return n, nil } @@ -17177,7 +17548,7 @@ func (s LedgerCloseMeta) MarshalBinary() ([]byte, error) { func (s *LedgerCloseMeta) UnmarshalBinary(inp []byte) error { r := bytes.NewReader(inp) d := xdr.NewDecoder(r) - _, err := s.DecodeFrom(d) + _, err := s.DecodeFrom(d, xdr.DecodeDefaultMaxDepth) return err } @@ -17245,10 +17616,14 @@ func (e ErrorCode) EncodeTo(enc *xdr.Encoder) error { var _ decoderFrom = (*ErrorCode)(nil) // DecodeFrom decodes this value using the Decoder. -func (e *ErrorCode) DecodeFrom(d *xdr.Decoder) (int, error) { +func (e *ErrorCode) DecodeFrom(d *xdr.Decoder, maxDepth uint) (int, error) { + if maxDepth == 0 { + return 0, fmt.Errorf("decoding ErrorCode: %w", ErrMaxDecodingDepthReached) + } + maxDepth -= 1 v, n, err := d.DecodeInt() if err != nil { - return n, fmt.Errorf("decoding ErrorCode: %s", err) + return n, fmt.Errorf("decoding ErrorCode: %w", err) } if _, ok := errorCodeMap[v]; !ok { return n, fmt.Errorf("'%d' is not a valid ErrorCode enum value", v) @@ -17269,7 +17644,7 @@ func (s ErrorCode) MarshalBinary() ([]byte, error) { func (s *ErrorCode) UnmarshalBinary(inp []byte) error { r := bytes.NewReader(inp) d := xdr.NewDecoder(r) - _, err := s.DecodeFrom(d) + _, err := s.DecodeFrom(d, xdr.DecodeDefaultMaxDepth) return err } @@ -17311,18 +17686,22 @@ func (s *Error) EncodeTo(e *xdr.Encoder) error { var _ decoderFrom = (*Error)(nil) // DecodeFrom decodes this value using the Decoder. -func (s *Error) DecodeFrom(d *xdr.Decoder) (int, error) { +func (s *Error) DecodeFrom(d *xdr.Decoder, maxDepth uint) (int, error) { + if maxDepth == 0 { + return 0, fmt.Errorf("decoding Error: %w", ErrMaxDecodingDepthReached) + } + maxDepth -= 1 var err error var n, nTmp int - nTmp, err = s.Code.DecodeFrom(d) + nTmp, err = s.Code.DecodeFrom(d, maxDepth) n += nTmp if err != nil { - return n, fmt.Errorf("decoding ErrorCode: %s", err) + return n, fmt.Errorf("decoding ErrorCode: %w", err) } s.Msg, nTmp, err = d.DecodeString(100) n += nTmp if err != nil { - return n, fmt.Errorf("decoding Msg: %s", err) + return n, fmt.Errorf("decoding Msg: %w", err) } return n, nil } @@ -17339,7 +17718,7 @@ func (s Error) MarshalBinary() ([]byte, error) { func (s *Error) UnmarshalBinary(inp []byte) error { r := bytes.NewReader(inp) d := xdr.NewDecoder(r) - _, err := s.DecodeFrom(d) + _, err := s.DecodeFrom(d, xdr.DecodeDefaultMaxDepth) return err } @@ -17376,13 +17755,17 @@ func (s *SendMore) EncodeTo(e *xdr.Encoder) error { var _ decoderFrom = (*SendMore)(nil) // DecodeFrom decodes this value using the Decoder. -func (s *SendMore) DecodeFrom(d *xdr.Decoder) (int, error) { +func (s *SendMore) DecodeFrom(d *xdr.Decoder, maxDepth uint) (int, error) { + if maxDepth == 0 { + return 0, fmt.Errorf("decoding SendMore: %w", ErrMaxDecodingDepthReached) + } + maxDepth -= 1 var err error var n, nTmp int - nTmp, err = s.NumMessages.DecodeFrom(d) + nTmp, err = s.NumMessages.DecodeFrom(d, maxDepth) n += nTmp if err != nil { - return n, fmt.Errorf("decoding Uint32: %s", err) + return n, fmt.Errorf("decoding Uint32: %w", err) } return n, nil } @@ -17399,7 +17782,7 @@ func (s SendMore) MarshalBinary() ([]byte, error) { func (s *SendMore) UnmarshalBinary(inp []byte) error { r := bytes.NewReader(inp) d := xdr.NewDecoder(r) - _, err := s.DecodeFrom(d) + _, err := s.DecodeFrom(d, xdr.DecodeDefaultMaxDepth) return err } @@ -17441,18 +17824,22 @@ func (s *SendMoreExtended) EncodeTo(e *xdr.Encoder) error { var _ decoderFrom = (*SendMoreExtended)(nil) // DecodeFrom decodes this value using the Decoder. -func (s *SendMoreExtended) DecodeFrom(d *xdr.Decoder) (int, error) { +func (s *SendMoreExtended) DecodeFrom(d *xdr.Decoder, maxDepth uint) (int, error) { + if maxDepth == 0 { + return 0, fmt.Errorf("decoding SendMoreExtended: %w", ErrMaxDecodingDepthReached) + } + maxDepth -= 1 var err error var n, nTmp int - nTmp, err = s.NumMessages.DecodeFrom(d) + nTmp, err = s.NumMessages.DecodeFrom(d, maxDepth) n += nTmp if err != nil { - return n, fmt.Errorf("decoding Uint32: %s", err) + return n, fmt.Errorf("decoding Uint32: %w", err) } - nTmp, err = s.NumBytes.DecodeFrom(d) + nTmp, err = s.NumBytes.DecodeFrom(d, maxDepth) n += nTmp if err != nil { - return n, fmt.Errorf("decoding Uint32: %s", err) + return n, fmt.Errorf("decoding Uint32: %w", err) } return n, nil } @@ -17469,7 +17856,7 @@ func (s SendMoreExtended) MarshalBinary() ([]byte, error) { func (s *SendMoreExtended) UnmarshalBinary(inp []byte) error { r := bytes.NewReader(inp) d := xdr.NewDecoder(r) - _, err := s.DecodeFrom(d) + _, err := s.DecodeFrom(d, xdr.DecodeDefaultMaxDepth) return err } @@ -17516,23 +17903,27 @@ func (s *AuthCert) EncodeTo(e *xdr.Encoder) error { var _ decoderFrom = (*AuthCert)(nil) // DecodeFrom decodes this value using the Decoder. -func (s *AuthCert) DecodeFrom(d *xdr.Decoder) (int, error) { +func (s *AuthCert) DecodeFrom(d *xdr.Decoder, maxDepth uint) (int, error) { + if maxDepth == 0 { + return 0, fmt.Errorf("decoding AuthCert: %w", ErrMaxDecodingDepthReached) + } + maxDepth -= 1 var err error var n, nTmp int - nTmp, err = s.Pubkey.DecodeFrom(d) + nTmp, err = s.Pubkey.DecodeFrom(d, maxDepth) n += nTmp if err != nil { - return n, fmt.Errorf("decoding Curve25519Public: %s", err) + return n, fmt.Errorf("decoding Curve25519Public: %w", err) } - nTmp, err = s.Expiration.DecodeFrom(d) + nTmp, err = s.Expiration.DecodeFrom(d, maxDepth) n += nTmp if err != nil { - return n, fmt.Errorf("decoding Uint64: %s", err) + return n, fmt.Errorf("decoding Uint64: %w", err) } - nTmp, err = s.Sig.DecodeFrom(d) + nTmp, err = s.Sig.DecodeFrom(d, maxDepth) n += nTmp if err != nil { - return n, fmt.Errorf("decoding Signature: %s", err) + return n, fmt.Errorf("decoding Signature: %w", err) } return n, nil } @@ -17549,7 +17940,7 @@ func (s AuthCert) MarshalBinary() ([]byte, error) { func (s *AuthCert) UnmarshalBinary(inp []byte) error { r := bytes.NewReader(inp) d := xdr.NewDecoder(r) - _, err := s.DecodeFrom(d) + _, err := s.DecodeFrom(d, xdr.DecodeDefaultMaxDepth) return err } @@ -17626,53 +18017,57 @@ func (s *Hello) EncodeTo(e *xdr.Encoder) error { var _ decoderFrom = (*Hello)(nil) // DecodeFrom decodes this value using the Decoder. -func (s *Hello) DecodeFrom(d *xdr.Decoder) (int, error) { +func (s *Hello) DecodeFrom(d *xdr.Decoder, maxDepth uint) (int, error) { + if maxDepth == 0 { + return 0, fmt.Errorf("decoding Hello: %w", ErrMaxDecodingDepthReached) + } + maxDepth -= 1 var err error var n, nTmp int - nTmp, err = s.LedgerVersion.DecodeFrom(d) + nTmp, err = s.LedgerVersion.DecodeFrom(d, maxDepth) n += nTmp if err != nil { - return n, fmt.Errorf("decoding Uint32: %s", err) + return n, fmt.Errorf("decoding Uint32: %w", err) } - nTmp, err = s.OverlayVersion.DecodeFrom(d) + nTmp, err = s.OverlayVersion.DecodeFrom(d, maxDepth) n += nTmp if err != nil { - return n, fmt.Errorf("decoding Uint32: %s", err) + return n, fmt.Errorf("decoding Uint32: %w", err) } - nTmp, err = s.OverlayMinVersion.DecodeFrom(d) + nTmp, err = s.OverlayMinVersion.DecodeFrom(d, maxDepth) n += nTmp if err != nil { - return n, fmt.Errorf("decoding Uint32: %s", err) + return n, fmt.Errorf("decoding Uint32: %w", err) } - nTmp, err = s.NetworkId.DecodeFrom(d) + nTmp, err = s.NetworkId.DecodeFrom(d, maxDepth) n += nTmp if err != nil { - return n, fmt.Errorf("decoding Hash: %s", err) + return n, fmt.Errorf("decoding Hash: %w", err) } s.VersionStr, nTmp, err = d.DecodeString(100) n += nTmp if err != nil { - return n, fmt.Errorf("decoding VersionStr: %s", err) + return n, fmt.Errorf("decoding VersionStr: %w", err) } s.ListeningPort, nTmp, err = d.DecodeInt() n += nTmp if err != nil { - return n, fmt.Errorf("decoding Int: %s", err) + return n, fmt.Errorf("decoding Int: %w", err) } - nTmp, err = s.PeerId.DecodeFrom(d) + nTmp, err = s.PeerId.DecodeFrom(d, maxDepth) n += nTmp if err != nil { - return n, fmt.Errorf("decoding NodeId: %s", err) + return n, fmt.Errorf("decoding NodeId: %w", err) } - nTmp, err = s.Cert.DecodeFrom(d) + nTmp, err = s.Cert.DecodeFrom(d, maxDepth) n += nTmp if err != nil { - return n, fmt.Errorf("decoding AuthCert: %s", err) + return n, fmt.Errorf("decoding AuthCert: %w", err) } - nTmp, err = s.Nonce.DecodeFrom(d) + nTmp, err = s.Nonce.DecodeFrom(d, maxDepth) n += nTmp if err != nil { - return n, fmt.Errorf("decoding Uint256: %s", err) + return n, fmt.Errorf("decoding Uint256: %w", err) } return n, nil } @@ -17689,7 +18084,7 @@ func (s Hello) MarshalBinary() ([]byte, error) { func (s *Hello) UnmarshalBinary(inp []byte) error { r := bytes.NewReader(inp) d := xdr.NewDecoder(r) - _, err := s.DecodeFrom(d) + _, err := s.DecodeFrom(d, xdr.DecodeDefaultMaxDepth) return err } @@ -17731,13 +18126,17 @@ func (s *Auth) EncodeTo(e *xdr.Encoder) error { var _ decoderFrom = (*Auth)(nil) // DecodeFrom decodes this value using the Decoder. -func (s *Auth) DecodeFrom(d *xdr.Decoder) (int, error) { +func (s *Auth) DecodeFrom(d *xdr.Decoder, maxDepth uint) (int, error) { + if maxDepth == 0 { + return 0, fmt.Errorf("decoding Auth: %w", ErrMaxDecodingDepthReached) + } + maxDepth -= 1 var err error var n, nTmp int s.Flags, nTmp, err = d.DecodeInt() n += nTmp if err != nil { - return n, fmt.Errorf("decoding Int: %s", err) + return n, fmt.Errorf("decoding Int: %w", err) } return n, nil } @@ -17754,7 +18153,7 @@ func (s Auth) MarshalBinary() ([]byte, error) { func (s *Auth) UnmarshalBinary(inp []byte) error { r := bytes.NewReader(inp) d := xdr.NewDecoder(r) - _, err := s.DecodeFrom(d) + _, err := s.DecodeFrom(d, xdr.DecodeDefaultMaxDepth) return err } @@ -17813,10 +18212,14 @@ func (e IpAddrType) EncodeTo(enc *xdr.Encoder) error { var _ decoderFrom = (*IpAddrType)(nil) // DecodeFrom decodes this value using the Decoder. -func (e *IpAddrType) DecodeFrom(d *xdr.Decoder) (int, error) { +func (e *IpAddrType) DecodeFrom(d *xdr.Decoder, maxDepth uint) (int, error) { + if maxDepth == 0 { + return 0, fmt.Errorf("decoding IpAddrType: %w", ErrMaxDecodingDepthReached) + } + maxDepth -= 1 v, n, err := d.DecodeInt() if err != nil { - return n, fmt.Errorf("decoding IpAddrType: %s", err) + return n, fmt.Errorf("decoding IpAddrType: %w", err) } if _, ok := ipAddrTypeMap[v]; !ok { return n, fmt.Errorf("'%d' is not a valid IpAddrType enum value", v) @@ -17837,7 +18240,7 @@ func (s IpAddrType) MarshalBinary() ([]byte, error) { func (s *IpAddrType) UnmarshalBinary(inp []byte) error { r := bytes.NewReader(inp) d := xdr.NewDecoder(r) - _, err := s.DecodeFrom(d) + _, err := s.DecodeFrom(d, xdr.DecodeDefaultMaxDepth) return err } @@ -17892,14 +18295,14 @@ func NewPeerAddressIp(aType IpAddrType, value interface{}) (result PeerAddressIp case IpAddrTypeIPv4: tv, ok := value.([4]byte) if !ok { - err = fmt.Errorf("invalid value, must be [4]byte") + err = errors.New("invalid value, must be [4]byte") return } result.Ipv4 = &tv case IpAddrTypeIPv6: tv, ok := value.([16]byte) if !ok { - err = fmt.Errorf("invalid value, must be [16]byte") + err = errors.New("invalid value, must be [16]byte") return } result.Ipv6 = &tv @@ -17981,13 +18384,17 @@ func (u PeerAddressIp) EncodeTo(e *xdr.Encoder) error { var _ decoderFrom = (*PeerAddressIp)(nil) // DecodeFrom decodes this value using the Decoder. -func (u *PeerAddressIp) DecodeFrom(d *xdr.Decoder) (int, error) { +func (u *PeerAddressIp) DecodeFrom(d *xdr.Decoder, maxDepth uint) (int, error) { + if maxDepth == 0 { + return 0, fmt.Errorf("decoding PeerAddressIp: %w", ErrMaxDecodingDepthReached) + } + maxDepth -= 1 var err error var n, nTmp int - nTmp, err = u.Type.DecodeFrom(d) + nTmp, err = u.Type.DecodeFrom(d, maxDepth) n += nTmp if err != nil { - return n, fmt.Errorf("decoding IpAddrType: %s", err) + return n, fmt.Errorf("decoding IpAddrType: %w", err) } switch IpAddrType(u.Type) { case IpAddrTypeIPv4: @@ -17995,7 +18402,7 @@ func (u *PeerAddressIp) DecodeFrom(d *xdr.Decoder) (int, error) { nTmp, err = d.DecodeFixedOpaqueInplace((*u.Ipv4)[:]) n += nTmp if err != nil { - return n, fmt.Errorf("decoding Ipv4: %s", err) + return n, fmt.Errorf("decoding Ipv4: %w", err) } return n, nil case IpAddrTypeIPv6: @@ -18003,7 +18410,7 @@ func (u *PeerAddressIp) DecodeFrom(d *xdr.Decoder) (int, error) { nTmp, err = d.DecodeFixedOpaqueInplace((*u.Ipv6)[:]) n += nTmp if err != nil { - return n, fmt.Errorf("decoding Ipv6: %s", err) + return n, fmt.Errorf("decoding Ipv6: %w", err) } return n, nil } @@ -18022,7 +18429,7 @@ func (s PeerAddressIp) MarshalBinary() ([]byte, error) { func (s *PeerAddressIp) UnmarshalBinary(inp []byte) error { r := bytes.NewReader(inp) d := xdr.NewDecoder(r) - _, err := s.DecodeFrom(d) + _, err := s.DecodeFrom(d, xdr.DecodeDefaultMaxDepth) return err } @@ -18076,23 +18483,27 @@ func (s *PeerAddress) EncodeTo(e *xdr.Encoder) error { var _ decoderFrom = (*PeerAddress)(nil) // DecodeFrom decodes this value using the Decoder. -func (s *PeerAddress) DecodeFrom(d *xdr.Decoder) (int, error) { +func (s *PeerAddress) DecodeFrom(d *xdr.Decoder, maxDepth uint) (int, error) { + if maxDepth == 0 { + return 0, fmt.Errorf("decoding PeerAddress: %w", ErrMaxDecodingDepthReached) + } + maxDepth -= 1 var err error var n, nTmp int - nTmp, err = s.Ip.DecodeFrom(d) + nTmp, err = s.Ip.DecodeFrom(d, maxDepth) n += nTmp if err != nil { - return n, fmt.Errorf("decoding PeerAddressIp: %s", err) + return n, fmt.Errorf("decoding PeerAddressIp: %w", err) } - nTmp, err = s.Port.DecodeFrom(d) + nTmp, err = s.Port.DecodeFrom(d, maxDepth) n += nTmp if err != nil { - return n, fmt.Errorf("decoding Uint32: %s", err) + return n, fmt.Errorf("decoding Uint32: %w", err) } - nTmp, err = s.NumFailures.DecodeFrom(d) + nTmp, err = s.NumFailures.DecodeFrom(d, maxDepth) n += nTmp if err != nil { - return n, fmt.Errorf("decoding Uint32: %s", err) + return n, fmt.Errorf("decoding Uint32: %w", err) } return n, nil } @@ -18109,7 +18520,7 @@ func (s PeerAddress) MarshalBinary() ([]byte, error) { func (s *PeerAddress) UnmarshalBinary(inp []byte) error { r := bytes.NewReader(inp) d := xdr.NewDecoder(r) - _, err := s.DecodeFrom(d) + _, err := s.DecodeFrom(d, xdr.DecodeDefaultMaxDepth) return err } @@ -18232,10 +18643,14 @@ func (e MessageType) EncodeTo(enc *xdr.Encoder) error { var _ decoderFrom = (*MessageType)(nil) // DecodeFrom decodes this value using the Decoder. -func (e *MessageType) DecodeFrom(d *xdr.Decoder) (int, error) { +func (e *MessageType) DecodeFrom(d *xdr.Decoder, maxDepth uint) (int, error) { + if maxDepth == 0 { + return 0, fmt.Errorf("decoding MessageType: %w", ErrMaxDecodingDepthReached) + } + maxDepth -= 1 v, n, err := d.DecodeInt() if err != nil { - return n, fmt.Errorf("decoding MessageType: %s", err) + return n, fmt.Errorf("decoding MessageType: %w", err) } if _, ok := messageTypeMap[v]; !ok { return n, fmt.Errorf("'%d' is not a valid MessageType enum value", v) @@ -18256,7 +18671,7 @@ func (s MessageType) MarshalBinary() ([]byte, error) { func (s *MessageType) UnmarshalBinary(inp []byte) error { r := bytes.NewReader(inp) d := xdr.NewDecoder(r) - _, err := s.DecodeFrom(d) + _, err := s.DecodeFrom(d, xdr.DecodeDefaultMaxDepth) return err } @@ -18298,18 +18713,22 @@ func (s *DontHave) EncodeTo(e *xdr.Encoder) error { var _ decoderFrom = (*DontHave)(nil) // DecodeFrom decodes this value using the Decoder. -func (s *DontHave) DecodeFrom(d *xdr.Decoder) (int, error) { +func (s *DontHave) DecodeFrom(d *xdr.Decoder, maxDepth uint) (int, error) { + if maxDepth == 0 { + return 0, fmt.Errorf("decoding DontHave: %w", ErrMaxDecodingDepthReached) + } + maxDepth -= 1 var err error var n, nTmp int - nTmp, err = s.Type.DecodeFrom(d) + nTmp, err = s.Type.DecodeFrom(d, maxDepth) n += nTmp if err != nil { - return n, fmt.Errorf("decoding MessageType: %s", err) + return n, fmt.Errorf("decoding MessageType: %w", err) } - nTmp, err = s.ReqHash.DecodeFrom(d) + nTmp, err = s.ReqHash.DecodeFrom(d, maxDepth) n += nTmp if err != nil { - return n, fmt.Errorf("decoding Uint256: %s", err) + return n, fmt.Errorf("decoding Uint256: %w", err) } return n, nil } @@ -18326,7 +18745,7 @@ func (s DontHave) MarshalBinary() ([]byte, error) { func (s *DontHave) UnmarshalBinary(inp []byte) error { r := bytes.NewReader(inp) d := xdr.NewDecoder(r) - _, err := s.DecodeFrom(d) + _, err := s.DecodeFrom(d, xdr.DecodeDefaultMaxDepth) return err } @@ -18382,10 +18801,14 @@ func (e SurveyMessageCommandType) EncodeTo(enc *xdr.Encoder) error { var _ decoderFrom = (*SurveyMessageCommandType)(nil) // DecodeFrom decodes this value using the Decoder. -func (e *SurveyMessageCommandType) DecodeFrom(d *xdr.Decoder) (int, error) { +func (e *SurveyMessageCommandType) DecodeFrom(d *xdr.Decoder, maxDepth uint) (int, error) { + if maxDepth == 0 { + return 0, fmt.Errorf("decoding SurveyMessageCommandType: %w", ErrMaxDecodingDepthReached) + } + maxDepth -= 1 v, n, err := d.DecodeInt() if err != nil { - return n, fmt.Errorf("decoding SurveyMessageCommandType: %s", err) + return n, fmt.Errorf("decoding SurveyMessageCommandType: %w", err) } if _, ok := surveyMessageCommandTypeMap[v]; !ok { return n, fmt.Errorf("'%d' is not a valid SurveyMessageCommandType enum value", v) @@ -18406,7 +18829,7 @@ func (s SurveyMessageCommandType) MarshalBinary() ([]byte, error) { func (s *SurveyMessageCommandType) UnmarshalBinary(inp []byte) error { r := bytes.NewReader(inp) d := xdr.NewDecoder(r) - _, err := s.DecodeFrom(d) + _, err := s.DecodeFrom(d, xdr.DecodeDefaultMaxDepth) return err } @@ -18465,10 +18888,14 @@ func (e SurveyMessageResponseType) EncodeTo(enc *xdr.Encoder) error { var _ decoderFrom = (*SurveyMessageResponseType)(nil) // DecodeFrom decodes this value using the Decoder. -func (e *SurveyMessageResponseType) DecodeFrom(d *xdr.Decoder) (int, error) { +func (e *SurveyMessageResponseType) DecodeFrom(d *xdr.Decoder, maxDepth uint) (int, error) { + if maxDepth == 0 { + return 0, fmt.Errorf("decoding SurveyMessageResponseType: %w", ErrMaxDecodingDepthReached) + } + maxDepth -= 1 v, n, err := d.DecodeInt() if err != nil { - return n, fmt.Errorf("decoding SurveyMessageResponseType: %s", err) + return n, fmt.Errorf("decoding SurveyMessageResponseType: %w", err) } if _, ok := surveyMessageResponseTypeMap[v]; !ok { return n, fmt.Errorf("'%d' is not a valid SurveyMessageResponseType enum value", v) @@ -18489,7 +18916,7 @@ func (s SurveyMessageResponseType) MarshalBinary() ([]byte, error) { func (s *SurveyMessageResponseType) UnmarshalBinary(inp []byte) error { r := bytes.NewReader(inp) d := xdr.NewDecoder(r) - _, err := s.DecodeFrom(d) + _, err := s.DecodeFrom(d, xdr.DecodeDefaultMaxDepth) return err } @@ -18546,33 +18973,37 @@ func (s *SurveyRequestMessage) EncodeTo(e *xdr.Encoder) error { var _ decoderFrom = (*SurveyRequestMessage)(nil) // DecodeFrom decodes this value using the Decoder. -func (s *SurveyRequestMessage) DecodeFrom(d *xdr.Decoder) (int, error) { +func (s *SurveyRequestMessage) DecodeFrom(d *xdr.Decoder, maxDepth uint) (int, error) { + if maxDepth == 0 { + return 0, fmt.Errorf("decoding SurveyRequestMessage: %w", ErrMaxDecodingDepthReached) + } + maxDepth -= 1 var err error var n, nTmp int - nTmp, err = s.SurveyorPeerId.DecodeFrom(d) + nTmp, err = s.SurveyorPeerId.DecodeFrom(d, maxDepth) n += nTmp if err != nil { - return n, fmt.Errorf("decoding NodeId: %s", err) + return n, fmt.Errorf("decoding NodeId: %w", err) } - nTmp, err = s.SurveyedPeerId.DecodeFrom(d) + nTmp, err = s.SurveyedPeerId.DecodeFrom(d, maxDepth) n += nTmp if err != nil { - return n, fmt.Errorf("decoding NodeId: %s", err) + return n, fmt.Errorf("decoding NodeId: %w", err) } - nTmp, err = s.LedgerNum.DecodeFrom(d) + nTmp, err = s.LedgerNum.DecodeFrom(d, maxDepth) n += nTmp if err != nil { - return n, fmt.Errorf("decoding Uint32: %s", err) + return n, fmt.Errorf("decoding Uint32: %w", err) } - nTmp, err = s.EncryptionKey.DecodeFrom(d) + nTmp, err = s.EncryptionKey.DecodeFrom(d, maxDepth) n += nTmp if err != nil { - return n, fmt.Errorf("decoding Curve25519Public: %s", err) + return n, fmt.Errorf("decoding Curve25519Public: %w", err) } - nTmp, err = s.CommandType.DecodeFrom(d) + nTmp, err = s.CommandType.DecodeFrom(d, maxDepth) n += nTmp if err != nil { - return n, fmt.Errorf("decoding SurveyMessageCommandType: %s", err) + return n, fmt.Errorf("decoding SurveyMessageCommandType: %w", err) } return n, nil } @@ -18589,7 +19020,7 @@ func (s SurveyRequestMessage) MarshalBinary() ([]byte, error) { func (s *SurveyRequestMessage) UnmarshalBinary(inp []byte) error { r := bytes.NewReader(inp) d := xdr.NewDecoder(r) - _, err := s.DecodeFrom(d) + _, err := s.DecodeFrom(d, xdr.DecodeDefaultMaxDepth) return err } @@ -18631,18 +19062,22 @@ func (s *SignedSurveyRequestMessage) EncodeTo(e *xdr.Encoder) error { var _ decoderFrom = (*SignedSurveyRequestMessage)(nil) // DecodeFrom decodes this value using the Decoder. -func (s *SignedSurveyRequestMessage) DecodeFrom(d *xdr.Decoder) (int, error) { +func (s *SignedSurveyRequestMessage) DecodeFrom(d *xdr.Decoder, maxDepth uint) (int, error) { + if maxDepth == 0 { + return 0, fmt.Errorf("decoding SignedSurveyRequestMessage: %w", ErrMaxDecodingDepthReached) + } + maxDepth -= 1 var err error var n, nTmp int - nTmp, err = s.RequestSignature.DecodeFrom(d) + nTmp, err = s.RequestSignature.DecodeFrom(d, maxDepth) n += nTmp if err != nil { - return n, fmt.Errorf("decoding Signature: %s", err) + return n, fmt.Errorf("decoding Signature: %w", err) } - nTmp, err = s.Request.DecodeFrom(d) + nTmp, err = s.Request.DecodeFrom(d, maxDepth) n += nTmp if err != nil { - return n, fmt.Errorf("decoding SurveyRequestMessage: %s", err) + return n, fmt.Errorf("decoding SurveyRequestMessage: %w", err) } return n, nil } @@ -18659,7 +19094,7 @@ func (s SignedSurveyRequestMessage) MarshalBinary() ([]byte, error) { func (s *SignedSurveyRequestMessage) UnmarshalBinary(inp []byte) error { r := bytes.NewReader(inp) d := xdr.NewDecoder(r) - _, err := s.DecodeFrom(d) + _, err := s.DecodeFrom(d, xdr.DecodeDefaultMaxDepth) return err } @@ -18696,13 +19131,17 @@ func (s EncryptedBody) EncodeTo(e *xdr.Encoder) error { var _ decoderFrom = (*EncryptedBody)(nil) // DecodeFrom decodes this value using the Decoder. -func (s *EncryptedBody) DecodeFrom(d *xdr.Decoder) (int, error) { +func (s *EncryptedBody) DecodeFrom(d *xdr.Decoder, maxDepth uint) (int, error) { + if maxDepth == 0 { + return 0, fmt.Errorf("decoding EncryptedBody: %w", ErrMaxDecodingDepthReached) + } + maxDepth -= 1 var err error var n, nTmp int (*s), nTmp, err = d.DecodeOpaque(64000) n += nTmp if err != nil { - return n, fmt.Errorf("decoding EncryptedBody: %s", err) + return n, fmt.Errorf("decoding EncryptedBody: %w", err) } return n, nil } @@ -18719,7 +19158,7 @@ func (s EncryptedBody) MarshalBinary() ([]byte, error) { func (s *EncryptedBody) UnmarshalBinary(inp []byte) error { r := bytes.NewReader(inp) d := xdr.NewDecoder(r) - _, err := s.DecodeFrom(d) + _, err := s.DecodeFrom(d, xdr.DecodeDefaultMaxDepth) return err } @@ -18776,33 +19215,37 @@ func (s *SurveyResponseMessage) EncodeTo(e *xdr.Encoder) error { var _ decoderFrom = (*SurveyResponseMessage)(nil) // DecodeFrom decodes this value using the Decoder. -func (s *SurveyResponseMessage) DecodeFrom(d *xdr.Decoder) (int, error) { +func (s *SurveyResponseMessage) DecodeFrom(d *xdr.Decoder, maxDepth uint) (int, error) { + if maxDepth == 0 { + return 0, fmt.Errorf("decoding SurveyResponseMessage: %w", ErrMaxDecodingDepthReached) + } + maxDepth -= 1 var err error var n, nTmp int - nTmp, err = s.SurveyorPeerId.DecodeFrom(d) + nTmp, err = s.SurveyorPeerId.DecodeFrom(d, maxDepth) n += nTmp if err != nil { - return n, fmt.Errorf("decoding NodeId: %s", err) + return n, fmt.Errorf("decoding NodeId: %w", err) } - nTmp, err = s.SurveyedPeerId.DecodeFrom(d) + nTmp, err = s.SurveyedPeerId.DecodeFrom(d, maxDepth) n += nTmp if err != nil { - return n, fmt.Errorf("decoding NodeId: %s", err) + return n, fmt.Errorf("decoding NodeId: %w", err) } - nTmp, err = s.LedgerNum.DecodeFrom(d) + nTmp, err = s.LedgerNum.DecodeFrom(d, maxDepth) n += nTmp if err != nil { - return n, fmt.Errorf("decoding Uint32: %s", err) + return n, fmt.Errorf("decoding Uint32: %w", err) } - nTmp, err = s.CommandType.DecodeFrom(d) + nTmp, err = s.CommandType.DecodeFrom(d, maxDepth) n += nTmp if err != nil { - return n, fmt.Errorf("decoding SurveyMessageCommandType: %s", err) + return n, fmt.Errorf("decoding SurveyMessageCommandType: %w", err) } - nTmp, err = s.EncryptedBody.DecodeFrom(d) + nTmp, err = s.EncryptedBody.DecodeFrom(d, maxDepth) n += nTmp if err != nil { - return n, fmt.Errorf("decoding EncryptedBody: %s", err) + return n, fmt.Errorf("decoding EncryptedBody: %w", err) } return n, nil } @@ -18819,7 +19262,7 @@ func (s SurveyResponseMessage) MarshalBinary() ([]byte, error) { func (s *SurveyResponseMessage) UnmarshalBinary(inp []byte) error { r := bytes.NewReader(inp) d := xdr.NewDecoder(r) - _, err := s.DecodeFrom(d) + _, err := s.DecodeFrom(d, xdr.DecodeDefaultMaxDepth) return err } @@ -18861,18 +19304,22 @@ func (s *SignedSurveyResponseMessage) EncodeTo(e *xdr.Encoder) error { var _ decoderFrom = (*SignedSurveyResponseMessage)(nil) // DecodeFrom decodes this value using the Decoder. -func (s *SignedSurveyResponseMessage) DecodeFrom(d *xdr.Decoder) (int, error) { +func (s *SignedSurveyResponseMessage) DecodeFrom(d *xdr.Decoder, maxDepth uint) (int, error) { + if maxDepth == 0 { + return 0, fmt.Errorf("decoding SignedSurveyResponseMessage: %w", ErrMaxDecodingDepthReached) + } + maxDepth -= 1 var err error var n, nTmp int - nTmp, err = s.ResponseSignature.DecodeFrom(d) + nTmp, err = s.ResponseSignature.DecodeFrom(d, maxDepth) n += nTmp if err != nil { - return n, fmt.Errorf("decoding Signature: %s", err) + return n, fmt.Errorf("decoding Signature: %w", err) } - nTmp, err = s.Response.DecodeFrom(d) + nTmp, err = s.Response.DecodeFrom(d, maxDepth) n += nTmp if err != nil { - return n, fmt.Errorf("decoding SurveyResponseMessage: %s", err) + return n, fmt.Errorf("decoding SurveyResponseMessage: %w", err) } return n, nil } @@ -18889,7 +19336,7 @@ func (s SignedSurveyResponseMessage) MarshalBinary() ([]byte, error) { func (s *SignedSurveyResponseMessage) UnmarshalBinary(inp []byte) error { r := bytes.NewReader(inp) d := xdr.NewDecoder(r) - _, err := s.DecodeFrom(d) + _, err := s.DecodeFrom(d, xdr.DecodeDefaultMaxDepth) return err } @@ -18998,83 +19445,87 @@ func (s *PeerStats) EncodeTo(e *xdr.Encoder) error { var _ decoderFrom = (*PeerStats)(nil) // DecodeFrom decodes this value using the Decoder. -func (s *PeerStats) DecodeFrom(d *xdr.Decoder) (int, error) { +func (s *PeerStats) DecodeFrom(d *xdr.Decoder, maxDepth uint) (int, error) { + if maxDepth == 0 { + return 0, fmt.Errorf("decoding PeerStats: %w", ErrMaxDecodingDepthReached) + } + maxDepth -= 1 var err error var n, nTmp int - nTmp, err = s.Id.DecodeFrom(d) + nTmp, err = s.Id.DecodeFrom(d, maxDepth) n += nTmp if err != nil { - return n, fmt.Errorf("decoding NodeId: %s", err) + return n, fmt.Errorf("decoding NodeId: %w", err) } s.VersionStr, nTmp, err = d.DecodeString(100) n += nTmp if err != nil { - return n, fmt.Errorf("decoding VersionStr: %s", err) + return n, fmt.Errorf("decoding VersionStr: %w", err) } - nTmp, err = s.MessagesRead.DecodeFrom(d) + nTmp, err = s.MessagesRead.DecodeFrom(d, maxDepth) n += nTmp if err != nil { - return n, fmt.Errorf("decoding Uint64: %s", err) + return n, fmt.Errorf("decoding Uint64: %w", err) } - nTmp, err = s.MessagesWritten.DecodeFrom(d) + nTmp, err = s.MessagesWritten.DecodeFrom(d, maxDepth) n += nTmp if err != nil { - return n, fmt.Errorf("decoding Uint64: %s", err) + return n, fmt.Errorf("decoding Uint64: %w", err) } - nTmp, err = s.BytesRead.DecodeFrom(d) + nTmp, err = s.BytesRead.DecodeFrom(d, maxDepth) n += nTmp if err != nil { - return n, fmt.Errorf("decoding Uint64: %s", err) + return n, fmt.Errorf("decoding Uint64: %w", err) } - nTmp, err = s.BytesWritten.DecodeFrom(d) + nTmp, err = s.BytesWritten.DecodeFrom(d, maxDepth) n += nTmp if err != nil { - return n, fmt.Errorf("decoding Uint64: %s", err) + return n, fmt.Errorf("decoding Uint64: %w", err) } - nTmp, err = s.SecondsConnected.DecodeFrom(d) + nTmp, err = s.SecondsConnected.DecodeFrom(d, maxDepth) n += nTmp if err != nil { - return n, fmt.Errorf("decoding Uint64: %s", err) + return n, fmt.Errorf("decoding Uint64: %w", err) } - nTmp, err = s.UniqueFloodBytesRecv.DecodeFrom(d) + nTmp, err = s.UniqueFloodBytesRecv.DecodeFrom(d, maxDepth) n += nTmp if err != nil { - return n, fmt.Errorf("decoding Uint64: %s", err) + return n, fmt.Errorf("decoding Uint64: %w", err) } - nTmp, err = s.DuplicateFloodBytesRecv.DecodeFrom(d) + nTmp, err = s.DuplicateFloodBytesRecv.DecodeFrom(d, maxDepth) n += nTmp if err != nil { - return n, fmt.Errorf("decoding Uint64: %s", err) + return n, fmt.Errorf("decoding Uint64: %w", err) } - nTmp, err = s.UniqueFetchBytesRecv.DecodeFrom(d) + nTmp, err = s.UniqueFetchBytesRecv.DecodeFrom(d, maxDepth) n += nTmp if err != nil { - return n, fmt.Errorf("decoding Uint64: %s", err) + return n, fmt.Errorf("decoding Uint64: %w", err) } - nTmp, err = s.DuplicateFetchBytesRecv.DecodeFrom(d) + nTmp, err = s.DuplicateFetchBytesRecv.DecodeFrom(d, maxDepth) n += nTmp if err != nil { - return n, fmt.Errorf("decoding Uint64: %s", err) + return n, fmt.Errorf("decoding Uint64: %w", err) } - nTmp, err = s.UniqueFloodMessageRecv.DecodeFrom(d) + nTmp, err = s.UniqueFloodMessageRecv.DecodeFrom(d, maxDepth) n += nTmp if err != nil { - return n, fmt.Errorf("decoding Uint64: %s", err) + return n, fmt.Errorf("decoding Uint64: %w", err) } - nTmp, err = s.DuplicateFloodMessageRecv.DecodeFrom(d) + nTmp, err = s.DuplicateFloodMessageRecv.DecodeFrom(d, maxDepth) n += nTmp if err != nil { - return n, fmt.Errorf("decoding Uint64: %s", err) + return n, fmt.Errorf("decoding Uint64: %w", err) } - nTmp, err = s.UniqueFetchMessageRecv.DecodeFrom(d) + nTmp, err = s.UniqueFetchMessageRecv.DecodeFrom(d, maxDepth) n += nTmp if err != nil { - return n, fmt.Errorf("decoding Uint64: %s", err) + return n, fmt.Errorf("decoding Uint64: %w", err) } - nTmp, err = s.DuplicateFetchMessageRecv.DecodeFrom(d) + nTmp, err = s.DuplicateFetchMessageRecv.DecodeFrom(d, maxDepth) n += nTmp if err != nil { - return n, fmt.Errorf("decoding Uint64: %s", err) + return n, fmt.Errorf("decoding Uint64: %w", err) } return n, nil } @@ -19091,7 +19542,7 @@ func (s PeerStats) MarshalBinary() ([]byte, error) { func (s *PeerStats) UnmarshalBinary(inp []byte) error { r := bytes.NewReader(inp) d := xdr.NewDecoder(r) - _, err := s.DecodeFrom(d) + _, err := s.DecodeFrom(d, xdr.DecodeDefaultMaxDepth) return err } @@ -19133,14 +19584,18 @@ func (s PeerStatList) EncodeTo(e *xdr.Encoder) error { var _ decoderFrom = (*PeerStatList)(nil) // DecodeFrom decodes this value using the Decoder. -func (s *PeerStatList) DecodeFrom(d *xdr.Decoder) (int, error) { +func (s *PeerStatList) DecodeFrom(d *xdr.Decoder, maxDepth uint) (int, error) { + if maxDepth == 0 { + return 0, fmt.Errorf("decoding PeerStatList: %w", ErrMaxDecodingDepthReached) + } + maxDepth -= 1 var err error var n, nTmp int var l uint32 l, nTmp, err = d.DecodeUint() n += nTmp if err != nil { - return n, fmt.Errorf("decoding PeerStats: %s", err) + return n, fmt.Errorf("decoding PeerStats: %w", err) } if l > 25 { return n, fmt.Errorf("decoding PeerStats: data size (%d) exceeds size limit (25)", l) @@ -19149,10 +19604,10 @@ func (s *PeerStatList) DecodeFrom(d *xdr.Decoder) (int, error) { if l > 0 { (*s) = make([]PeerStats, l) for i := uint32(0); i < l; i++ { - nTmp, err = (*s)[i].DecodeFrom(d) + nTmp, err = (*s)[i].DecodeFrom(d, maxDepth) n += nTmp if err != nil { - return n, fmt.Errorf("decoding PeerStats: %s", err) + return n, fmt.Errorf("decoding PeerStats: %w", err) } } } @@ -19171,7 +19626,7 @@ func (s PeerStatList) MarshalBinary() ([]byte, error) { func (s *PeerStatList) UnmarshalBinary(inp []byte) error { r := bytes.NewReader(inp) d := xdr.NewDecoder(r) - _, err := s.DecodeFrom(d) + _, err := s.DecodeFrom(d, xdr.DecodeDefaultMaxDepth) return err } @@ -19224,28 +19679,32 @@ func (s *TopologyResponseBodyV0) EncodeTo(e *xdr.Encoder) error { var _ decoderFrom = (*TopologyResponseBodyV0)(nil) // DecodeFrom decodes this value using the Decoder. -func (s *TopologyResponseBodyV0) DecodeFrom(d *xdr.Decoder) (int, error) { +func (s *TopologyResponseBodyV0) DecodeFrom(d *xdr.Decoder, maxDepth uint) (int, error) { + if maxDepth == 0 { + return 0, fmt.Errorf("decoding TopologyResponseBodyV0: %w", ErrMaxDecodingDepthReached) + } + maxDepth -= 1 var err error var n, nTmp int - nTmp, err = s.InboundPeers.DecodeFrom(d) + nTmp, err = s.InboundPeers.DecodeFrom(d, maxDepth) n += nTmp if err != nil { - return n, fmt.Errorf("decoding PeerStatList: %s", err) + return n, fmt.Errorf("decoding PeerStatList: %w", err) } - nTmp, err = s.OutboundPeers.DecodeFrom(d) + nTmp, err = s.OutboundPeers.DecodeFrom(d, maxDepth) n += nTmp if err != nil { - return n, fmt.Errorf("decoding PeerStatList: %s", err) + return n, fmt.Errorf("decoding PeerStatList: %w", err) } - nTmp, err = s.TotalInboundPeerCount.DecodeFrom(d) + nTmp, err = s.TotalInboundPeerCount.DecodeFrom(d, maxDepth) n += nTmp if err != nil { - return n, fmt.Errorf("decoding Uint32: %s", err) + return n, fmt.Errorf("decoding Uint32: %w", err) } - nTmp, err = s.TotalOutboundPeerCount.DecodeFrom(d) + nTmp, err = s.TotalOutboundPeerCount.DecodeFrom(d, maxDepth) n += nTmp if err != nil { - return n, fmt.Errorf("decoding Uint32: %s", err) + return n, fmt.Errorf("decoding Uint32: %w", err) } return n, nil } @@ -19262,7 +19721,7 @@ func (s TopologyResponseBodyV0) MarshalBinary() ([]byte, error) { func (s *TopologyResponseBodyV0) UnmarshalBinary(inp []byte) error { r := bytes.NewReader(inp) d := xdr.NewDecoder(r) - _, err := s.DecodeFrom(d) + _, err := s.DecodeFrom(d, xdr.DecodeDefaultMaxDepth) return err } @@ -19326,38 +19785,42 @@ func (s *TopologyResponseBodyV1) EncodeTo(e *xdr.Encoder) error { var _ decoderFrom = (*TopologyResponseBodyV1)(nil) // DecodeFrom decodes this value using the Decoder. -func (s *TopologyResponseBodyV1) DecodeFrom(d *xdr.Decoder) (int, error) { +func (s *TopologyResponseBodyV1) DecodeFrom(d *xdr.Decoder, maxDepth uint) (int, error) { + if maxDepth == 0 { + return 0, fmt.Errorf("decoding TopologyResponseBodyV1: %w", ErrMaxDecodingDepthReached) + } + maxDepth -= 1 var err error var n, nTmp int - nTmp, err = s.InboundPeers.DecodeFrom(d) + nTmp, err = s.InboundPeers.DecodeFrom(d, maxDepth) n += nTmp if err != nil { - return n, fmt.Errorf("decoding PeerStatList: %s", err) + return n, fmt.Errorf("decoding PeerStatList: %w", err) } - nTmp, err = s.OutboundPeers.DecodeFrom(d) + nTmp, err = s.OutboundPeers.DecodeFrom(d, maxDepth) n += nTmp if err != nil { - return n, fmt.Errorf("decoding PeerStatList: %s", err) + return n, fmt.Errorf("decoding PeerStatList: %w", err) } - nTmp, err = s.TotalInboundPeerCount.DecodeFrom(d) + nTmp, err = s.TotalInboundPeerCount.DecodeFrom(d, maxDepth) n += nTmp if err != nil { - return n, fmt.Errorf("decoding Uint32: %s", err) + return n, fmt.Errorf("decoding Uint32: %w", err) } - nTmp, err = s.TotalOutboundPeerCount.DecodeFrom(d) + nTmp, err = s.TotalOutboundPeerCount.DecodeFrom(d, maxDepth) n += nTmp if err != nil { - return n, fmt.Errorf("decoding Uint32: %s", err) + return n, fmt.Errorf("decoding Uint32: %w", err) } - nTmp, err = s.MaxInboundPeerCount.DecodeFrom(d) + nTmp, err = s.MaxInboundPeerCount.DecodeFrom(d, maxDepth) n += nTmp if err != nil { - return n, fmt.Errorf("decoding Uint32: %s", err) + return n, fmt.Errorf("decoding Uint32: %w", err) } - nTmp, err = s.MaxOutboundPeerCount.DecodeFrom(d) + nTmp, err = s.MaxOutboundPeerCount.DecodeFrom(d, maxDepth) n += nTmp if err != nil { - return n, fmt.Errorf("decoding Uint32: %s", err) + return n, fmt.Errorf("decoding Uint32: %w", err) } return n, nil } @@ -19374,7 +19837,7 @@ func (s TopologyResponseBodyV1) MarshalBinary() ([]byte, error) { func (s *TopologyResponseBodyV1) UnmarshalBinary(inp []byte) error { r := bytes.NewReader(inp) d := xdr.NewDecoder(r) - _, err := s.DecodeFrom(d) + _, err := s.DecodeFrom(d, xdr.DecodeDefaultMaxDepth) return err } @@ -19429,14 +19892,14 @@ func NewSurveyResponseBody(aType SurveyMessageResponseType, value interface{}) ( case SurveyMessageResponseTypeSurveyTopologyResponseV0: tv, ok := value.(TopologyResponseBodyV0) if !ok { - err = fmt.Errorf("invalid value, must be TopologyResponseBodyV0") + err = errors.New("invalid value, must be TopologyResponseBodyV0") return } result.TopologyResponseBodyV0 = &tv case SurveyMessageResponseTypeSurveyTopologyResponseV1: tv, ok := value.(TopologyResponseBodyV1) if !ok { - err = fmt.Errorf("invalid value, must be TopologyResponseBodyV1") + err = errors.New("invalid value, must be TopologyResponseBodyV1") return } result.TopologyResponseBodyV1 = &tv @@ -19518,29 +19981,33 @@ func (u SurveyResponseBody) EncodeTo(e *xdr.Encoder) error { var _ decoderFrom = (*SurveyResponseBody)(nil) // DecodeFrom decodes this value using the Decoder. -func (u *SurveyResponseBody) DecodeFrom(d *xdr.Decoder) (int, error) { +func (u *SurveyResponseBody) DecodeFrom(d *xdr.Decoder, maxDepth uint) (int, error) { + if maxDepth == 0 { + return 0, fmt.Errorf("decoding SurveyResponseBody: %w", ErrMaxDecodingDepthReached) + } + maxDepth -= 1 var err error var n, nTmp int - nTmp, err = u.Type.DecodeFrom(d) + nTmp, err = u.Type.DecodeFrom(d, maxDepth) n += nTmp if err != nil { - return n, fmt.Errorf("decoding SurveyMessageResponseType: %s", err) + return n, fmt.Errorf("decoding SurveyMessageResponseType: %w", err) } switch SurveyMessageResponseType(u.Type) { case SurveyMessageResponseTypeSurveyTopologyResponseV0: u.TopologyResponseBodyV0 = new(TopologyResponseBodyV0) - nTmp, err = (*u.TopologyResponseBodyV0).DecodeFrom(d) + nTmp, err = (*u.TopologyResponseBodyV0).DecodeFrom(d, maxDepth) n += nTmp if err != nil { - return n, fmt.Errorf("decoding TopologyResponseBodyV0: %s", err) + return n, fmt.Errorf("decoding TopologyResponseBodyV0: %w", err) } return n, nil case SurveyMessageResponseTypeSurveyTopologyResponseV1: u.TopologyResponseBodyV1 = new(TopologyResponseBodyV1) - nTmp, err = (*u.TopologyResponseBodyV1).DecodeFrom(d) + nTmp, err = (*u.TopologyResponseBodyV1).DecodeFrom(d, maxDepth) n += nTmp if err != nil { - return n, fmt.Errorf("decoding TopologyResponseBodyV1: %s", err) + return n, fmt.Errorf("decoding TopologyResponseBodyV1: %w", err) } return n, nil } @@ -19559,7 +20026,7 @@ func (s SurveyResponseBody) MarshalBinary() ([]byte, error) { func (s *SurveyResponseBody) UnmarshalBinary(inp []byte) error { r := bytes.NewReader(inp) d := xdr.NewDecoder(r) - _, err := s.DecodeFrom(d) + _, err := s.DecodeFrom(d, xdr.DecodeDefaultMaxDepth) return err } @@ -19606,14 +20073,18 @@ func (s TxAdvertVector) EncodeTo(e *xdr.Encoder) error { var _ decoderFrom = (*TxAdvertVector)(nil) // DecodeFrom decodes this value using the Decoder. -func (s *TxAdvertVector) DecodeFrom(d *xdr.Decoder) (int, error) { +func (s *TxAdvertVector) DecodeFrom(d *xdr.Decoder, maxDepth uint) (int, error) { + if maxDepth == 0 { + return 0, fmt.Errorf("decoding TxAdvertVector: %w", ErrMaxDecodingDepthReached) + } + maxDepth -= 1 var err error var n, nTmp int var l uint32 l, nTmp, err = d.DecodeUint() n += nTmp if err != nil { - return n, fmt.Errorf("decoding Hash: %s", err) + return n, fmt.Errorf("decoding Hash: %w", err) } if l > 1000 { return n, fmt.Errorf("decoding Hash: data size (%d) exceeds size limit (1000)", l) @@ -19622,10 +20093,10 @@ func (s *TxAdvertVector) DecodeFrom(d *xdr.Decoder) (int, error) { if l > 0 { (*s) = make([]Hash, l) for i := uint32(0); i < l; i++ { - nTmp, err = (*s)[i].DecodeFrom(d) + nTmp, err = (*s)[i].DecodeFrom(d, maxDepth) n += nTmp if err != nil { - return n, fmt.Errorf("decoding Hash: %s", err) + return n, fmt.Errorf("decoding Hash: %w", err) } } } @@ -19644,7 +20115,7 @@ func (s TxAdvertVector) MarshalBinary() ([]byte, error) { func (s *TxAdvertVector) UnmarshalBinary(inp []byte) error { r := bytes.NewReader(inp) d := xdr.NewDecoder(r) - _, err := s.DecodeFrom(d) + _, err := s.DecodeFrom(d, xdr.DecodeDefaultMaxDepth) return err } @@ -19681,13 +20152,17 @@ func (s *FloodAdvert) EncodeTo(e *xdr.Encoder) error { var _ decoderFrom = (*FloodAdvert)(nil) // DecodeFrom decodes this value using the Decoder. -func (s *FloodAdvert) DecodeFrom(d *xdr.Decoder) (int, error) { +func (s *FloodAdvert) DecodeFrom(d *xdr.Decoder, maxDepth uint) (int, error) { + if maxDepth == 0 { + return 0, fmt.Errorf("decoding FloodAdvert: %w", ErrMaxDecodingDepthReached) + } + maxDepth -= 1 var err error var n, nTmp int - nTmp, err = s.TxHashes.DecodeFrom(d) + nTmp, err = s.TxHashes.DecodeFrom(d, maxDepth) n += nTmp if err != nil { - return n, fmt.Errorf("decoding TxAdvertVector: %s", err) + return n, fmt.Errorf("decoding TxAdvertVector: %w", err) } return n, nil } @@ -19704,7 +20179,7 @@ func (s FloodAdvert) MarshalBinary() ([]byte, error) { func (s *FloodAdvert) UnmarshalBinary(inp []byte) error { r := bytes.NewReader(inp) d := xdr.NewDecoder(r) - _, err := s.DecodeFrom(d) + _, err := s.DecodeFrom(d, xdr.DecodeDefaultMaxDepth) return err } @@ -19751,14 +20226,18 @@ func (s TxDemandVector) EncodeTo(e *xdr.Encoder) error { var _ decoderFrom = (*TxDemandVector)(nil) // DecodeFrom decodes this value using the Decoder. -func (s *TxDemandVector) DecodeFrom(d *xdr.Decoder) (int, error) { +func (s *TxDemandVector) DecodeFrom(d *xdr.Decoder, maxDepth uint) (int, error) { + if maxDepth == 0 { + return 0, fmt.Errorf("decoding TxDemandVector: %w", ErrMaxDecodingDepthReached) + } + maxDepth -= 1 var err error var n, nTmp int var l uint32 l, nTmp, err = d.DecodeUint() n += nTmp if err != nil { - return n, fmt.Errorf("decoding Hash: %s", err) + return n, fmt.Errorf("decoding Hash: %w", err) } if l > 1000 { return n, fmt.Errorf("decoding Hash: data size (%d) exceeds size limit (1000)", l) @@ -19767,10 +20246,10 @@ func (s *TxDemandVector) DecodeFrom(d *xdr.Decoder) (int, error) { if l > 0 { (*s) = make([]Hash, l) for i := uint32(0); i < l; i++ { - nTmp, err = (*s)[i].DecodeFrom(d) + nTmp, err = (*s)[i].DecodeFrom(d, maxDepth) n += nTmp if err != nil { - return n, fmt.Errorf("decoding Hash: %s", err) + return n, fmt.Errorf("decoding Hash: %w", err) } } } @@ -19789,7 +20268,7 @@ func (s TxDemandVector) MarshalBinary() ([]byte, error) { func (s *TxDemandVector) UnmarshalBinary(inp []byte) error { r := bytes.NewReader(inp) d := xdr.NewDecoder(r) - _, err := s.DecodeFrom(d) + _, err := s.DecodeFrom(d, xdr.DecodeDefaultMaxDepth) return err } @@ -19826,13 +20305,17 @@ func (s *FloodDemand) EncodeTo(e *xdr.Encoder) error { var _ decoderFrom = (*FloodDemand)(nil) // DecodeFrom decodes this value using the Decoder. -func (s *FloodDemand) DecodeFrom(d *xdr.Decoder) (int, error) { +func (s *FloodDemand) DecodeFrom(d *xdr.Decoder, maxDepth uint) (int, error) { + if maxDepth == 0 { + return 0, fmt.Errorf("decoding FloodDemand: %w", ErrMaxDecodingDepthReached) + } + maxDepth -= 1 var err error var n, nTmp int - nTmp, err = s.TxHashes.DecodeFrom(d) + nTmp, err = s.TxHashes.DecodeFrom(d, maxDepth) n += nTmp if err != nil { - return n, fmt.Errorf("decoding TxDemandVector: %s", err) + return n, fmt.Errorf("decoding TxDemandVector: %w", err) } return n, nil } @@ -19849,7 +20332,7 @@ func (s FloodDemand) MarshalBinary() ([]byte, error) { func (s *FloodDemand) UnmarshalBinary(inp []byte) error { r := bytes.NewReader(inp) d := xdr.NewDecoder(r) - _, err := s.DecodeFrom(d) + _, err := s.DecodeFrom(d, xdr.DecodeDefaultMaxDepth) return err } @@ -20000,28 +20483,28 @@ func NewStellarMessage(aType MessageType, value interface{}) (result StellarMess case MessageTypeErrorMsg: tv, ok := value.(Error) if !ok { - err = fmt.Errorf("invalid value, must be Error") + err = errors.New("invalid value, must be Error") return } result.Error = &tv case MessageTypeHello: tv, ok := value.(Hello) if !ok { - err = fmt.Errorf("invalid value, must be Hello") + err = errors.New("invalid value, must be Hello") return } result.Hello = &tv case MessageTypeAuth: tv, ok := value.(Auth) if !ok { - err = fmt.Errorf("invalid value, must be Auth") + err = errors.New("invalid value, must be Auth") return } result.Auth = &tv case MessageTypeDontHave: tv, ok := value.(DontHave) if !ok { - err = fmt.Errorf("invalid value, must be DontHave") + err = errors.New("invalid value, must be DontHave") return } result.DontHave = &tv @@ -20030,105 +20513,105 @@ func NewStellarMessage(aType MessageType, value interface{}) (result StellarMess case MessageTypePeers: tv, ok := value.([]PeerAddress) if !ok { - err = fmt.Errorf("invalid value, must be []PeerAddress") + err = errors.New("invalid value, must be []PeerAddress") return } result.Peers = &tv case MessageTypeGetTxSet: tv, ok := value.(Uint256) if !ok { - err = fmt.Errorf("invalid value, must be Uint256") + err = errors.New("invalid value, must be Uint256") return } result.TxSetHash = &tv case MessageTypeTxSet: tv, ok := value.(TransactionSet) if !ok { - err = fmt.Errorf("invalid value, must be TransactionSet") + err = errors.New("invalid value, must be TransactionSet") return } result.TxSet = &tv case MessageTypeGeneralizedTxSet: tv, ok := value.(GeneralizedTransactionSet) if !ok { - err = fmt.Errorf("invalid value, must be GeneralizedTransactionSet") + err = errors.New("invalid value, must be GeneralizedTransactionSet") return } result.GeneralizedTxSet = &tv case MessageTypeTransaction: tv, ok := value.(TransactionEnvelope) if !ok { - err = fmt.Errorf("invalid value, must be TransactionEnvelope") + err = errors.New("invalid value, must be TransactionEnvelope") return } result.Transaction = &tv case MessageTypeSurveyRequest: tv, ok := value.(SignedSurveyRequestMessage) if !ok { - err = fmt.Errorf("invalid value, must be SignedSurveyRequestMessage") + err = errors.New("invalid value, must be SignedSurveyRequestMessage") return } result.SignedSurveyRequestMessage = &tv case MessageTypeSurveyResponse: tv, ok := value.(SignedSurveyResponseMessage) if !ok { - err = fmt.Errorf("invalid value, must be SignedSurveyResponseMessage") + err = errors.New("invalid value, must be SignedSurveyResponseMessage") return } result.SignedSurveyResponseMessage = &tv case MessageTypeGetScpQuorumset: tv, ok := value.(Uint256) if !ok { - err = fmt.Errorf("invalid value, must be Uint256") + err = errors.New("invalid value, must be Uint256") return } result.QSetHash = &tv case MessageTypeScpQuorumset: tv, ok := value.(ScpQuorumSet) if !ok { - err = fmt.Errorf("invalid value, must be ScpQuorumSet") + err = errors.New("invalid value, must be ScpQuorumSet") return } result.QSet = &tv case MessageTypeScpMessage: tv, ok := value.(ScpEnvelope) if !ok { - err = fmt.Errorf("invalid value, must be ScpEnvelope") + err = errors.New("invalid value, must be ScpEnvelope") return } result.Envelope = &tv case MessageTypeGetScpState: tv, ok := value.(Uint32) if !ok { - err = fmt.Errorf("invalid value, must be Uint32") + err = errors.New("invalid value, must be Uint32") return } result.GetScpLedgerSeq = &tv case MessageTypeSendMore: tv, ok := value.(SendMore) if !ok { - err = fmt.Errorf("invalid value, must be SendMore") + err = errors.New("invalid value, must be SendMore") return } result.SendMoreMessage = &tv case MessageTypeSendMoreExtended: tv, ok := value.(SendMoreExtended) if !ok { - err = fmt.Errorf("invalid value, must be SendMoreExtended") + err = errors.New("invalid value, must be SendMoreExtended") return } result.SendMoreExtendedMessage = &tv case MessageTypeFloodAdvert: tv, ok := value.(FloodAdvert) if !ok { - err = fmt.Errorf("invalid value, must be FloodAdvert") + err = errors.New("invalid value, must be FloodAdvert") return } result.FloodAdvert = &tv case MessageTypeFloodDemand: tv, ok := value.(FloodDemand) if !ok { - err = fmt.Errorf("invalid value, must be FloodDemand") + err = errors.New("invalid value, must be FloodDemand") return } result.FloodDemand = &tv @@ -20728,45 +21211,49 @@ func (u StellarMessage) EncodeTo(e *xdr.Encoder) error { var _ decoderFrom = (*StellarMessage)(nil) // DecodeFrom decodes this value using the Decoder. -func (u *StellarMessage) DecodeFrom(d *xdr.Decoder) (int, error) { +func (u *StellarMessage) DecodeFrom(d *xdr.Decoder, maxDepth uint) (int, error) { + if maxDepth == 0 { + return 0, fmt.Errorf("decoding StellarMessage: %w", ErrMaxDecodingDepthReached) + } + maxDepth -= 1 var err error var n, nTmp int - nTmp, err = u.Type.DecodeFrom(d) + nTmp, err = u.Type.DecodeFrom(d, maxDepth) n += nTmp if err != nil { - return n, fmt.Errorf("decoding MessageType: %s", err) + return n, fmt.Errorf("decoding MessageType: %w", err) } switch MessageType(u.Type) { case MessageTypeErrorMsg: u.Error = new(Error) - nTmp, err = (*u.Error).DecodeFrom(d) + nTmp, err = (*u.Error).DecodeFrom(d, maxDepth) n += nTmp if err != nil { - return n, fmt.Errorf("decoding Error: %s", err) + return n, fmt.Errorf("decoding Error: %w", err) } return n, nil case MessageTypeHello: u.Hello = new(Hello) - nTmp, err = (*u.Hello).DecodeFrom(d) + nTmp, err = (*u.Hello).DecodeFrom(d, maxDepth) n += nTmp if err != nil { - return n, fmt.Errorf("decoding Hello: %s", err) + return n, fmt.Errorf("decoding Hello: %w", err) } return n, nil case MessageTypeAuth: u.Auth = new(Auth) - nTmp, err = (*u.Auth).DecodeFrom(d) + nTmp, err = (*u.Auth).DecodeFrom(d, maxDepth) n += nTmp if err != nil { - return n, fmt.Errorf("decoding Auth: %s", err) + return n, fmt.Errorf("decoding Auth: %w", err) } return n, nil case MessageTypeDontHave: u.DontHave = new(DontHave) - nTmp, err = (*u.DontHave).DecodeFrom(d) + nTmp, err = (*u.DontHave).DecodeFrom(d, maxDepth) n += nTmp if err != nil { - return n, fmt.Errorf("decoding DontHave: %s", err) + return n, fmt.Errorf("decoding DontHave: %w", err) } return n, nil case MessageTypeGetPeers: @@ -20778,7 +21265,7 @@ func (u *StellarMessage) DecodeFrom(d *xdr.Decoder) (int, error) { l, nTmp, err = d.DecodeUint() n += nTmp if err != nil { - return n, fmt.Errorf("decoding PeerAddress: %s", err) + return n, fmt.Errorf("decoding PeerAddress: %w", err) } if l > 100 { return n, fmt.Errorf("decoding PeerAddress: data size (%d) exceeds size limit (100)", l) @@ -20787,124 +21274,124 @@ func (u *StellarMessage) DecodeFrom(d *xdr.Decoder) (int, error) { if l > 0 { (*u.Peers) = make([]PeerAddress, l) for i := uint32(0); i < l; i++ { - nTmp, err = (*u.Peers)[i].DecodeFrom(d) + nTmp, err = (*u.Peers)[i].DecodeFrom(d, maxDepth) n += nTmp if err != nil { - return n, fmt.Errorf("decoding PeerAddress: %s", err) + return n, fmt.Errorf("decoding PeerAddress: %w", err) } } } return n, nil case MessageTypeGetTxSet: u.TxSetHash = new(Uint256) - nTmp, err = (*u.TxSetHash).DecodeFrom(d) + nTmp, err = (*u.TxSetHash).DecodeFrom(d, maxDepth) n += nTmp if err != nil { - return n, fmt.Errorf("decoding Uint256: %s", err) + return n, fmt.Errorf("decoding Uint256: %w", err) } return n, nil case MessageTypeTxSet: u.TxSet = new(TransactionSet) - nTmp, err = (*u.TxSet).DecodeFrom(d) + nTmp, err = (*u.TxSet).DecodeFrom(d, maxDepth) n += nTmp if err != nil { - return n, fmt.Errorf("decoding TransactionSet: %s", err) + return n, fmt.Errorf("decoding TransactionSet: %w", err) } return n, nil case MessageTypeGeneralizedTxSet: u.GeneralizedTxSet = new(GeneralizedTransactionSet) - nTmp, err = (*u.GeneralizedTxSet).DecodeFrom(d) + nTmp, err = (*u.GeneralizedTxSet).DecodeFrom(d, maxDepth) n += nTmp if err != nil { - return n, fmt.Errorf("decoding GeneralizedTransactionSet: %s", err) + return n, fmt.Errorf("decoding GeneralizedTransactionSet: %w", err) } return n, nil case MessageTypeTransaction: u.Transaction = new(TransactionEnvelope) - nTmp, err = (*u.Transaction).DecodeFrom(d) + nTmp, err = (*u.Transaction).DecodeFrom(d, maxDepth) n += nTmp if err != nil { - return n, fmt.Errorf("decoding TransactionEnvelope: %s", err) + return n, fmt.Errorf("decoding TransactionEnvelope: %w", err) } return n, nil case MessageTypeSurveyRequest: u.SignedSurveyRequestMessage = new(SignedSurveyRequestMessage) - nTmp, err = (*u.SignedSurveyRequestMessage).DecodeFrom(d) + nTmp, err = (*u.SignedSurveyRequestMessage).DecodeFrom(d, maxDepth) n += nTmp if err != nil { - return n, fmt.Errorf("decoding SignedSurveyRequestMessage: %s", err) + return n, fmt.Errorf("decoding SignedSurveyRequestMessage: %w", err) } return n, nil case MessageTypeSurveyResponse: u.SignedSurveyResponseMessage = new(SignedSurveyResponseMessage) - nTmp, err = (*u.SignedSurveyResponseMessage).DecodeFrom(d) + nTmp, err = (*u.SignedSurveyResponseMessage).DecodeFrom(d, maxDepth) n += nTmp if err != nil { - return n, fmt.Errorf("decoding SignedSurveyResponseMessage: %s", err) + return n, fmt.Errorf("decoding SignedSurveyResponseMessage: %w", err) } return n, nil case MessageTypeGetScpQuorumset: u.QSetHash = new(Uint256) - nTmp, err = (*u.QSetHash).DecodeFrom(d) + nTmp, err = (*u.QSetHash).DecodeFrom(d, maxDepth) n += nTmp if err != nil { - return n, fmt.Errorf("decoding Uint256: %s", err) + return n, fmt.Errorf("decoding Uint256: %w", err) } return n, nil case MessageTypeScpQuorumset: u.QSet = new(ScpQuorumSet) - nTmp, err = (*u.QSet).DecodeFrom(d) + nTmp, err = (*u.QSet).DecodeFrom(d, maxDepth) n += nTmp if err != nil { - return n, fmt.Errorf("decoding ScpQuorumSet: %s", err) + return n, fmt.Errorf("decoding ScpQuorumSet: %w", err) } return n, nil case MessageTypeScpMessage: u.Envelope = new(ScpEnvelope) - nTmp, err = (*u.Envelope).DecodeFrom(d) + nTmp, err = (*u.Envelope).DecodeFrom(d, maxDepth) n += nTmp if err != nil { - return n, fmt.Errorf("decoding ScpEnvelope: %s", err) + return n, fmt.Errorf("decoding ScpEnvelope: %w", err) } return n, nil case MessageTypeGetScpState: u.GetScpLedgerSeq = new(Uint32) - nTmp, err = (*u.GetScpLedgerSeq).DecodeFrom(d) + nTmp, err = (*u.GetScpLedgerSeq).DecodeFrom(d, maxDepth) n += nTmp if err != nil { - return n, fmt.Errorf("decoding Uint32: %s", err) + return n, fmt.Errorf("decoding Uint32: %w", err) } return n, nil case MessageTypeSendMore: u.SendMoreMessage = new(SendMore) - nTmp, err = (*u.SendMoreMessage).DecodeFrom(d) + nTmp, err = (*u.SendMoreMessage).DecodeFrom(d, maxDepth) n += nTmp if err != nil { - return n, fmt.Errorf("decoding SendMore: %s", err) + return n, fmt.Errorf("decoding SendMore: %w", err) } return n, nil case MessageTypeSendMoreExtended: u.SendMoreExtendedMessage = new(SendMoreExtended) - nTmp, err = (*u.SendMoreExtendedMessage).DecodeFrom(d) + nTmp, err = (*u.SendMoreExtendedMessage).DecodeFrom(d, maxDepth) n += nTmp if err != nil { - return n, fmt.Errorf("decoding SendMoreExtended: %s", err) + return n, fmt.Errorf("decoding SendMoreExtended: %w", err) } return n, nil case MessageTypeFloodAdvert: u.FloodAdvert = new(FloodAdvert) - nTmp, err = (*u.FloodAdvert).DecodeFrom(d) + nTmp, err = (*u.FloodAdvert).DecodeFrom(d, maxDepth) n += nTmp if err != nil { - return n, fmt.Errorf("decoding FloodAdvert: %s", err) + return n, fmt.Errorf("decoding FloodAdvert: %w", err) } return n, nil case MessageTypeFloodDemand: u.FloodDemand = new(FloodDemand) - nTmp, err = (*u.FloodDemand).DecodeFrom(d) + nTmp, err = (*u.FloodDemand).DecodeFrom(d, maxDepth) n += nTmp if err != nil { - return n, fmt.Errorf("decoding FloodDemand: %s", err) + return n, fmt.Errorf("decoding FloodDemand: %w", err) } return n, nil } @@ -20923,7 +21410,7 @@ func (s StellarMessage) MarshalBinary() ([]byte, error) { func (s *StellarMessage) UnmarshalBinary(inp []byte) error { r := bytes.NewReader(inp) d := xdr.NewDecoder(r) - _, err := s.DecodeFrom(d) + _, err := s.DecodeFrom(d, xdr.DecodeDefaultMaxDepth) return err } @@ -20970,23 +21457,27 @@ func (s *AuthenticatedMessageV0) EncodeTo(e *xdr.Encoder) error { var _ decoderFrom = (*AuthenticatedMessageV0)(nil) // DecodeFrom decodes this value using the Decoder. -func (s *AuthenticatedMessageV0) DecodeFrom(d *xdr.Decoder) (int, error) { +func (s *AuthenticatedMessageV0) DecodeFrom(d *xdr.Decoder, maxDepth uint) (int, error) { + if maxDepth == 0 { + return 0, fmt.Errorf("decoding AuthenticatedMessageV0: %w", ErrMaxDecodingDepthReached) + } + maxDepth -= 1 var err error var n, nTmp int - nTmp, err = s.Sequence.DecodeFrom(d) + nTmp, err = s.Sequence.DecodeFrom(d, maxDepth) n += nTmp if err != nil { - return n, fmt.Errorf("decoding Uint64: %s", err) + return n, fmt.Errorf("decoding Uint64: %w", err) } - nTmp, err = s.Message.DecodeFrom(d) + nTmp, err = s.Message.DecodeFrom(d, maxDepth) n += nTmp if err != nil { - return n, fmt.Errorf("decoding StellarMessage: %s", err) + return n, fmt.Errorf("decoding StellarMessage: %w", err) } - nTmp, err = s.Mac.DecodeFrom(d) + nTmp, err = s.Mac.DecodeFrom(d, maxDepth) n += nTmp if err != nil { - return n, fmt.Errorf("decoding HmacSha256Mac: %s", err) + return n, fmt.Errorf("decoding HmacSha256Mac: %w", err) } return n, nil } @@ -21003,7 +21494,7 @@ func (s AuthenticatedMessageV0) MarshalBinary() ([]byte, error) { func (s *AuthenticatedMessageV0) UnmarshalBinary(inp []byte) error { r := bytes.NewReader(inp) d := xdr.NewDecoder(r) - _, err := s.DecodeFrom(d) + _, err := s.DecodeFrom(d, xdr.DecodeDefaultMaxDepth) return err } @@ -21058,7 +21549,7 @@ func NewAuthenticatedMessage(v Uint32, value interface{}) (result AuthenticatedM case 0: tv, ok := value.(AuthenticatedMessageV0) if !ok { - err = fmt.Errorf("invalid value, must be AuthenticatedMessageV0") + err = errors.New("invalid value, must be AuthenticatedMessageV0") return } result.V0 = &tv @@ -21110,21 +21601,25 @@ func (u AuthenticatedMessage) EncodeTo(e *xdr.Encoder) error { var _ decoderFrom = (*AuthenticatedMessage)(nil) // DecodeFrom decodes this value using the Decoder. -func (u *AuthenticatedMessage) DecodeFrom(d *xdr.Decoder) (int, error) { +func (u *AuthenticatedMessage) DecodeFrom(d *xdr.Decoder, maxDepth uint) (int, error) { + if maxDepth == 0 { + return 0, fmt.Errorf("decoding AuthenticatedMessage: %w", ErrMaxDecodingDepthReached) + } + maxDepth -= 1 var err error var n, nTmp int - nTmp, err = u.V.DecodeFrom(d) + nTmp, err = u.V.DecodeFrom(d, maxDepth) n += nTmp if err != nil { - return n, fmt.Errorf("decoding Uint32: %s", err) + return n, fmt.Errorf("decoding Uint32: %w", err) } switch Uint32(u.V) { case 0: u.V0 = new(AuthenticatedMessageV0) - nTmp, err = (*u.V0).DecodeFrom(d) + nTmp, err = (*u.V0).DecodeFrom(d, maxDepth) n += nTmp if err != nil { - return n, fmt.Errorf("decoding AuthenticatedMessageV0: %s", err) + return n, fmt.Errorf("decoding AuthenticatedMessageV0: %w", err) } return n, nil } @@ -21143,7 +21638,7 @@ func (s AuthenticatedMessage) MarshalBinary() ([]byte, error) { func (s *AuthenticatedMessage) UnmarshalBinary(inp []byte) error { r := bytes.NewReader(inp) d := xdr.NewDecoder(r) - _, err := s.DecodeFrom(d) + _, err := s.DecodeFrom(d, xdr.DecodeDefaultMaxDepth) return err } @@ -21198,7 +21693,7 @@ func NewLiquidityPoolParameters(aType LiquidityPoolType, value interface{}) (res case LiquidityPoolTypeLiquidityPoolConstantProduct: tv, ok := value.(LiquidityPoolConstantProductParameters) if !ok { - err = fmt.Errorf("invalid value, must be LiquidityPoolConstantProductParameters") + err = errors.New("invalid value, must be LiquidityPoolConstantProductParameters") return } result.ConstantProduct = &tv @@ -21250,21 +21745,25 @@ func (u LiquidityPoolParameters) EncodeTo(e *xdr.Encoder) error { var _ decoderFrom = (*LiquidityPoolParameters)(nil) // DecodeFrom decodes this value using the Decoder. -func (u *LiquidityPoolParameters) DecodeFrom(d *xdr.Decoder) (int, error) { +func (u *LiquidityPoolParameters) DecodeFrom(d *xdr.Decoder, maxDepth uint) (int, error) { + if maxDepth == 0 { + return 0, fmt.Errorf("decoding LiquidityPoolParameters: %w", ErrMaxDecodingDepthReached) + } + maxDepth -= 1 var err error var n, nTmp int - nTmp, err = u.Type.DecodeFrom(d) + nTmp, err = u.Type.DecodeFrom(d, maxDepth) n += nTmp if err != nil { - return n, fmt.Errorf("decoding LiquidityPoolType: %s", err) + return n, fmt.Errorf("decoding LiquidityPoolType: %w", err) } switch LiquidityPoolType(u.Type) { case LiquidityPoolTypeLiquidityPoolConstantProduct: u.ConstantProduct = new(LiquidityPoolConstantProductParameters) - nTmp, err = (*u.ConstantProduct).DecodeFrom(d) + nTmp, err = (*u.ConstantProduct).DecodeFrom(d, maxDepth) n += nTmp if err != nil { - return n, fmt.Errorf("decoding LiquidityPoolConstantProductParameters: %s", err) + return n, fmt.Errorf("decoding LiquidityPoolConstantProductParameters: %w", err) } return n, nil } @@ -21283,7 +21782,7 @@ func (s LiquidityPoolParameters) MarshalBinary() ([]byte, error) { func (s *LiquidityPoolParameters) UnmarshalBinary(inp []byte) error { r := bytes.NewReader(inp) d := xdr.NewDecoder(r) - _, err := s.DecodeFrom(d) + _, err := s.DecodeFrom(d, xdr.DecodeDefaultMaxDepth) return err } @@ -21325,18 +21824,22 @@ func (s *MuxedAccountMed25519) EncodeTo(e *xdr.Encoder) error { var _ decoderFrom = (*MuxedAccountMed25519)(nil) // DecodeFrom decodes this value using the Decoder. -func (s *MuxedAccountMed25519) DecodeFrom(d *xdr.Decoder) (int, error) { +func (s *MuxedAccountMed25519) DecodeFrom(d *xdr.Decoder, maxDepth uint) (int, error) { + if maxDepth == 0 { + return 0, fmt.Errorf("decoding MuxedAccountMed25519: %w", ErrMaxDecodingDepthReached) + } + maxDepth -= 1 var err error var n, nTmp int - nTmp, err = s.Id.DecodeFrom(d) + nTmp, err = s.Id.DecodeFrom(d, maxDepth) n += nTmp if err != nil { - return n, fmt.Errorf("decoding Uint64: %s", err) + return n, fmt.Errorf("decoding Uint64: %w", err) } - nTmp, err = s.Ed25519.DecodeFrom(d) + nTmp, err = s.Ed25519.DecodeFrom(d, maxDepth) n += nTmp if err != nil { - return n, fmt.Errorf("decoding Uint256: %s", err) + return n, fmt.Errorf("decoding Uint256: %w", err) } return n, nil } @@ -21353,7 +21856,7 @@ func (s MuxedAccountMed25519) MarshalBinary() ([]byte, error) { func (s *MuxedAccountMed25519) UnmarshalBinary(inp []byte) error { r := bytes.NewReader(inp) d := xdr.NewDecoder(r) - _, err := s.DecodeFrom(d) + _, err := s.DecodeFrom(d, xdr.DecodeDefaultMaxDepth) return err } @@ -21412,14 +21915,14 @@ func NewMuxedAccount(aType CryptoKeyType, value interface{}) (result MuxedAccoun case CryptoKeyTypeKeyTypeEd25519: tv, ok := value.(Uint256) if !ok { - err = fmt.Errorf("invalid value, must be Uint256") + err = errors.New("invalid value, must be Uint256") return } result.Ed25519 = &tv case CryptoKeyTypeKeyTypeMuxedEd25519: tv, ok := value.(MuxedAccountMed25519) if !ok { - err = fmt.Errorf("invalid value, must be MuxedAccountMed25519") + err = errors.New("invalid value, must be MuxedAccountMed25519") return } result.Med25519 = &tv @@ -21501,29 +22004,33 @@ func (u MuxedAccount) EncodeTo(e *xdr.Encoder) error { var _ decoderFrom = (*MuxedAccount)(nil) // DecodeFrom decodes this value using the Decoder. -func (u *MuxedAccount) DecodeFrom(d *xdr.Decoder) (int, error) { +func (u *MuxedAccount) DecodeFrom(d *xdr.Decoder, maxDepth uint) (int, error) { + if maxDepth == 0 { + return 0, fmt.Errorf("decoding MuxedAccount: %w", ErrMaxDecodingDepthReached) + } + maxDepth -= 1 var err error var n, nTmp int - nTmp, err = u.Type.DecodeFrom(d) + nTmp, err = u.Type.DecodeFrom(d, maxDepth) n += nTmp if err != nil { - return n, fmt.Errorf("decoding CryptoKeyType: %s", err) + return n, fmt.Errorf("decoding CryptoKeyType: %w", err) } switch CryptoKeyType(u.Type) { case CryptoKeyTypeKeyTypeEd25519: u.Ed25519 = new(Uint256) - nTmp, err = (*u.Ed25519).DecodeFrom(d) + nTmp, err = (*u.Ed25519).DecodeFrom(d, maxDepth) n += nTmp if err != nil { - return n, fmt.Errorf("decoding Uint256: %s", err) + return n, fmt.Errorf("decoding Uint256: %w", err) } return n, nil case CryptoKeyTypeKeyTypeMuxedEd25519: u.Med25519 = new(MuxedAccountMed25519) - nTmp, err = (*u.Med25519).DecodeFrom(d) + nTmp, err = (*u.Med25519).DecodeFrom(d, maxDepth) n += nTmp if err != nil { - return n, fmt.Errorf("decoding MuxedAccountMed25519: %s", err) + return n, fmt.Errorf("decoding MuxedAccountMed25519: %w", err) } return n, nil } @@ -21542,7 +22049,7 @@ func (s MuxedAccount) MarshalBinary() ([]byte, error) { func (s *MuxedAccount) UnmarshalBinary(inp []byte) error { r := bytes.NewReader(inp) d := xdr.NewDecoder(r) - _, err := s.DecodeFrom(d) + _, err := s.DecodeFrom(d, xdr.DecodeDefaultMaxDepth) return err } @@ -21584,18 +22091,22 @@ func (s *DecoratedSignature) EncodeTo(e *xdr.Encoder) error { var _ decoderFrom = (*DecoratedSignature)(nil) // DecodeFrom decodes this value using the Decoder. -func (s *DecoratedSignature) DecodeFrom(d *xdr.Decoder) (int, error) { +func (s *DecoratedSignature) DecodeFrom(d *xdr.Decoder, maxDepth uint) (int, error) { + if maxDepth == 0 { + return 0, fmt.Errorf("decoding DecoratedSignature: %w", ErrMaxDecodingDepthReached) + } + maxDepth -= 1 var err error var n, nTmp int - nTmp, err = s.Hint.DecodeFrom(d) + nTmp, err = s.Hint.DecodeFrom(d, maxDepth) n += nTmp if err != nil { - return n, fmt.Errorf("decoding SignatureHint: %s", err) + return n, fmt.Errorf("decoding SignatureHint: %w", err) } - nTmp, err = s.Signature.DecodeFrom(d) + nTmp, err = s.Signature.DecodeFrom(d, maxDepth) n += nTmp if err != nil { - return n, fmt.Errorf("decoding Signature: %s", err) + return n, fmt.Errorf("decoding Signature: %w", err) } return n, nil } @@ -21612,7 +22123,7 @@ func (s DecoratedSignature) MarshalBinary() ([]byte, error) { func (s *DecoratedSignature) UnmarshalBinary(inp []byte) error { r := bytes.NewReader(inp) d := xdr.NewDecoder(r) - _, err := s.DecodeFrom(d) + _, err := s.DecodeFrom(d, xdr.DecodeDefaultMaxDepth) return err } @@ -21656,7 +22167,7 @@ var _ xdrType = (*DecoratedSignature)(nil) // LIQUIDITY_POOL_DEPOSIT = 22, // LIQUIDITY_POOL_WITHDRAW = 23, // INVOKE_HOST_FUNCTION = 24, -// BUMP_FOOTPRINT_EXPIRATION = 25, +// EXTEND_FOOTPRINT_TTL = 25, // RESTORE_FOOTPRINT = 26 // }; type OperationType int32 @@ -21687,7 +22198,7 @@ const ( OperationTypeLiquidityPoolDeposit OperationType = 22 OperationTypeLiquidityPoolWithdraw OperationType = 23 OperationTypeInvokeHostFunction OperationType = 24 - OperationTypeBumpFootprintExpiration OperationType = 25 + OperationTypeExtendFootprintTtl OperationType = 25 OperationTypeRestoreFootprint OperationType = 26 ) @@ -21717,7 +22228,7 @@ var operationTypeMap = map[int32]string{ 22: "OperationTypeLiquidityPoolDeposit", 23: "OperationTypeLiquidityPoolWithdraw", 24: "OperationTypeInvokeHostFunction", - 25: "OperationTypeBumpFootprintExpiration", + 25: "OperationTypeExtendFootprintTtl", 26: "OperationTypeRestoreFootprint", } @@ -21746,10 +22257,14 @@ func (e OperationType) EncodeTo(enc *xdr.Encoder) error { var _ decoderFrom = (*OperationType)(nil) // DecodeFrom decodes this value using the Decoder. -func (e *OperationType) DecodeFrom(d *xdr.Decoder) (int, error) { +func (e *OperationType) DecodeFrom(d *xdr.Decoder, maxDepth uint) (int, error) { + if maxDepth == 0 { + return 0, fmt.Errorf("decoding OperationType: %w", ErrMaxDecodingDepthReached) + } + maxDepth -= 1 v, n, err := d.DecodeInt() if err != nil { - return n, fmt.Errorf("decoding OperationType: %s", err) + return n, fmt.Errorf("decoding OperationType: %w", err) } if _, ok := operationTypeMap[v]; !ok { return n, fmt.Errorf("'%d' is not a valid OperationType enum value", v) @@ -21770,7 +22285,7 @@ func (s OperationType) MarshalBinary() ([]byte, error) { func (s *OperationType) UnmarshalBinary(inp []byte) error { r := bytes.NewReader(inp) d := xdr.NewDecoder(r) - _, err := s.DecodeFrom(d) + _, err := s.DecodeFrom(d, xdr.DecodeDefaultMaxDepth) return err } @@ -21812,18 +22327,22 @@ func (s *CreateAccountOp) EncodeTo(e *xdr.Encoder) error { var _ decoderFrom = (*CreateAccountOp)(nil) // DecodeFrom decodes this value using the Decoder. -func (s *CreateAccountOp) DecodeFrom(d *xdr.Decoder) (int, error) { +func (s *CreateAccountOp) DecodeFrom(d *xdr.Decoder, maxDepth uint) (int, error) { + if maxDepth == 0 { + return 0, fmt.Errorf("decoding CreateAccountOp: %w", ErrMaxDecodingDepthReached) + } + maxDepth -= 1 var err error var n, nTmp int - nTmp, err = s.Destination.DecodeFrom(d) + nTmp, err = s.Destination.DecodeFrom(d, maxDepth) n += nTmp if err != nil { - return n, fmt.Errorf("decoding AccountId: %s", err) + return n, fmt.Errorf("decoding AccountId: %w", err) } - nTmp, err = s.StartingBalance.DecodeFrom(d) + nTmp, err = s.StartingBalance.DecodeFrom(d, maxDepth) n += nTmp if err != nil { - return n, fmt.Errorf("decoding Int64: %s", err) + return n, fmt.Errorf("decoding Int64: %w", err) } return n, nil } @@ -21840,7 +22359,7 @@ func (s CreateAccountOp) MarshalBinary() ([]byte, error) { func (s *CreateAccountOp) UnmarshalBinary(inp []byte) error { r := bytes.NewReader(inp) d := xdr.NewDecoder(r) - _, err := s.DecodeFrom(d) + _, err := s.DecodeFrom(d, xdr.DecodeDefaultMaxDepth) return err } @@ -21887,23 +22406,27 @@ func (s *PaymentOp) EncodeTo(e *xdr.Encoder) error { var _ decoderFrom = (*PaymentOp)(nil) // DecodeFrom decodes this value using the Decoder. -func (s *PaymentOp) DecodeFrom(d *xdr.Decoder) (int, error) { +func (s *PaymentOp) DecodeFrom(d *xdr.Decoder, maxDepth uint) (int, error) { + if maxDepth == 0 { + return 0, fmt.Errorf("decoding PaymentOp: %w", ErrMaxDecodingDepthReached) + } + maxDepth -= 1 var err error var n, nTmp int - nTmp, err = s.Destination.DecodeFrom(d) + nTmp, err = s.Destination.DecodeFrom(d, maxDepth) n += nTmp if err != nil { - return n, fmt.Errorf("decoding MuxedAccount: %s", err) + return n, fmt.Errorf("decoding MuxedAccount: %w", err) } - nTmp, err = s.Asset.DecodeFrom(d) + nTmp, err = s.Asset.DecodeFrom(d, maxDepth) n += nTmp if err != nil { - return n, fmt.Errorf("decoding Asset: %s", err) + return n, fmt.Errorf("decoding Asset: %w", err) } - nTmp, err = s.Amount.DecodeFrom(d) + nTmp, err = s.Amount.DecodeFrom(d, maxDepth) n += nTmp if err != nil { - return n, fmt.Errorf("decoding Int64: %s", err) + return n, fmt.Errorf("decoding Int64: %w", err) } return n, nil } @@ -21920,7 +22443,7 @@ func (s PaymentOp) MarshalBinary() ([]byte, error) { func (s *PaymentOp) UnmarshalBinary(inp []byte) error { r := bytes.NewReader(inp) d := xdr.NewDecoder(r) - _, err := s.DecodeFrom(d) + _, err := s.DecodeFrom(d, xdr.DecodeDefaultMaxDepth) return err } @@ -21991,39 +22514,43 @@ func (s *PathPaymentStrictReceiveOp) EncodeTo(e *xdr.Encoder) error { var _ decoderFrom = (*PathPaymentStrictReceiveOp)(nil) // DecodeFrom decodes this value using the Decoder. -func (s *PathPaymentStrictReceiveOp) DecodeFrom(d *xdr.Decoder) (int, error) { +func (s *PathPaymentStrictReceiveOp) DecodeFrom(d *xdr.Decoder, maxDepth uint) (int, error) { + if maxDepth == 0 { + return 0, fmt.Errorf("decoding PathPaymentStrictReceiveOp: %w", ErrMaxDecodingDepthReached) + } + maxDepth -= 1 var err error var n, nTmp int - nTmp, err = s.SendAsset.DecodeFrom(d) + nTmp, err = s.SendAsset.DecodeFrom(d, maxDepth) n += nTmp if err != nil { - return n, fmt.Errorf("decoding Asset: %s", err) + return n, fmt.Errorf("decoding Asset: %w", err) } - nTmp, err = s.SendMax.DecodeFrom(d) + nTmp, err = s.SendMax.DecodeFrom(d, maxDepth) n += nTmp if err != nil { - return n, fmt.Errorf("decoding Int64: %s", err) + return n, fmt.Errorf("decoding Int64: %w", err) } - nTmp, err = s.Destination.DecodeFrom(d) + nTmp, err = s.Destination.DecodeFrom(d, maxDepth) n += nTmp if err != nil { - return n, fmt.Errorf("decoding MuxedAccount: %s", err) + return n, fmt.Errorf("decoding MuxedAccount: %w", err) } - nTmp, err = s.DestAsset.DecodeFrom(d) + nTmp, err = s.DestAsset.DecodeFrom(d, maxDepth) n += nTmp if err != nil { - return n, fmt.Errorf("decoding Asset: %s", err) + return n, fmt.Errorf("decoding Asset: %w", err) } - nTmp, err = s.DestAmount.DecodeFrom(d) + nTmp, err = s.DestAmount.DecodeFrom(d, maxDepth) n += nTmp if err != nil { - return n, fmt.Errorf("decoding Int64: %s", err) + return n, fmt.Errorf("decoding Int64: %w", err) } var l uint32 l, nTmp, err = d.DecodeUint() n += nTmp if err != nil { - return n, fmt.Errorf("decoding Asset: %s", err) + return n, fmt.Errorf("decoding Asset: %w", err) } if l > 5 { return n, fmt.Errorf("decoding Asset: data size (%d) exceeds size limit (5)", l) @@ -22032,10 +22559,10 @@ func (s *PathPaymentStrictReceiveOp) DecodeFrom(d *xdr.Decoder) (int, error) { if l > 0 { s.Path = make([]Asset, l) for i := uint32(0); i < l; i++ { - nTmp, err = s.Path[i].DecodeFrom(d) + nTmp, err = s.Path[i].DecodeFrom(d, maxDepth) n += nTmp if err != nil { - return n, fmt.Errorf("decoding Asset: %s", err) + return n, fmt.Errorf("decoding Asset: %w", err) } } } @@ -22054,7 +22581,7 @@ func (s PathPaymentStrictReceiveOp) MarshalBinary() ([]byte, error) { func (s *PathPaymentStrictReceiveOp) UnmarshalBinary(inp []byte) error { r := bytes.NewReader(inp) d := xdr.NewDecoder(r) - _, err := s.DecodeFrom(d) + _, err := s.DecodeFrom(d, xdr.DecodeDefaultMaxDepth) return err } @@ -22125,39 +22652,43 @@ func (s *PathPaymentStrictSendOp) EncodeTo(e *xdr.Encoder) error { var _ decoderFrom = (*PathPaymentStrictSendOp)(nil) // DecodeFrom decodes this value using the Decoder. -func (s *PathPaymentStrictSendOp) DecodeFrom(d *xdr.Decoder) (int, error) { +func (s *PathPaymentStrictSendOp) DecodeFrom(d *xdr.Decoder, maxDepth uint) (int, error) { + if maxDepth == 0 { + return 0, fmt.Errorf("decoding PathPaymentStrictSendOp: %w", ErrMaxDecodingDepthReached) + } + maxDepth -= 1 var err error var n, nTmp int - nTmp, err = s.SendAsset.DecodeFrom(d) + nTmp, err = s.SendAsset.DecodeFrom(d, maxDepth) n += nTmp if err != nil { - return n, fmt.Errorf("decoding Asset: %s", err) + return n, fmt.Errorf("decoding Asset: %w", err) } - nTmp, err = s.SendAmount.DecodeFrom(d) + nTmp, err = s.SendAmount.DecodeFrom(d, maxDepth) n += nTmp if err != nil { - return n, fmt.Errorf("decoding Int64: %s", err) + return n, fmt.Errorf("decoding Int64: %w", err) } - nTmp, err = s.Destination.DecodeFrom(d) + nTmp, err = s.Destination.DecodeFrom(d, maxDepth) n += nTmp if err != nil { - return n, fmt.Errorf("decoding MuxedAccount: %s", err) + return n, fmt.Errorf("decoding MuxedAccount: %w", err) } - nTmp, err = s.DestAsset.DecodeFrom(d) + nTmp, err = s.DestAsset.DecodeFrom(d, maxDepth) n += nTmp if err != nil { - return n, fmt.Errorf("decoding Asset: %s", err) + return n, fmt.Errorf("decoding Asset: %w", err) } - nTmp, err = s.DestMin.DecodeFrom(d) + nTmp, err = s.DestMin.DecodeFrom(d, maxDepth) n += nTmp if err != nil { - return n, fmt.Errorf("decoding Int64: %s", err) + return n, fmt.Errorf("decoding Int64: %w", err) } var l uint32 l, nTmp, err = d.DecodeUint() n += nTmp if err != nil { - return n, fmt.Errorf("decoding Asset: %s", err) + return n, fmt.Errorf("decoding Asset: %w", err) } if l > 5 { return n, fmt.Errorf("decoding Asset: data size (%d) exceeds size limit (5)", l) @@ -22166,10 +22697,10 @@ func (s *PathPaymentStrictSendOp) DecodeFrom(d *xdr.Decoder) (int, error) { if l > 0 { s.Path = make([]Asset, l) for i := uint32(0); i < l; i++ { - nTmp, err = s.Path[i].DecodeFrom(d) + nTmp, err = s.Path[i].DecodeFrom(d, maxDepth) n += nTmp if err != nil { - return n, fmt.Errorf("decoding Asset: %s", err) + return n, fmt.Errorf("decoding Asset: %w", err) } } } @@ -22188,7 +22719,7 @@ func (s PathPaymentStrictSendOp) MarshalBinary() ([]byte, error) { func (s *PathPaymentStrictSendOp) UnmarshalBinary(inp []byte) error { r := bytes.NewReader(inp) d := xdr.NewDecoder(r) - _, err := s.DecodeFrom(d) + _, err := s.DecodeFrom(d, xdr.DecodeDefaultMaxDepth) return err } @@ -22247,33 +22778,37 @@ func (s *ManageSellOfferOp) EncodeTo(e *xdr.Encoder) error { var _ decoderFrom = (*ManageSellOfferOp)(nil) // DecodeFrom decodes this value using the Decoder. -func (s *ManageSellOfferOp) DecodeFrom(d *xdr.Decoder) (int, error) { +func (s *ManageSellOfferOp) DecodeFrom(d *xdr.Decoder, maxDepth uint) (int, error) { + if maxDepth == 0 { + return 0, fmt.Errorf("decoding ManageSellOfferOp: %w", ErrMaxDecodingDepthReached) + } + maxDepth -= 1 var err error var n, nTmp int - nTmp, err = s.Selling.DecodeFrom(d) + nTmp, err = s.Selling.DecodeFrom(d, maxDepth) n += nTmp if err != nil { - return n, fmt.Errorf("decoding Asset: %s", err) + return n, fmt.Errorf("decoding Asset: %w", err) } - nTmp, err = s.Buying.DecodeFrom(d) + nTmp, err = s.Buying.DecodeFrom(d, maxDepth) n += nTmp if err != nil { - return n, fmt.Errorf("decoding Asset: %s", err) + return n, fmt.Errorf("decoding Asset: %w", err) } - nTmp, err = s.Amount.DecodeFrom(d) + nTmp, err = s.Amount.DecodeFrom(d, maxDepth) n += nTmp if err != nil { - return n, fmt.Errorf("decoding Int64: %s", err) + return n, fmt.Errorf("decoding Int64: %w", err) } - nTmp, err = s.Price.DecodeFrom(d) + nTmp, err = s.Price.DecodeFrom(d, maxDepth) n += nTmp if err != nil { - return n, fmt.Errorf("decoding Price: %s", err) + return n, fmt.Errorf("decoding Price: %w", err) } - nTmp, err = s.OfferId.DecodeFrom(d) + nTmp, err = s.OfferId.DecodeFrom(d, maxDepth) n += nTmp if err != nil { - return n, fmt.Errorf("decoding Int64: %s", err) + return n, fmt.Errorf("decoding Int64: %w", err) } return n, nil } @@ -22290,7 +22825,7 @@ func (s ManageSellOfferOp) MarshalBinary() ([]byte, error) { func (s *ManageSellOfferOp) UnmarshalBinary(inp []byte) error { r := bytes.NewReader(inp) d := xdr.NewDecoder(r) - _, err := s.DecodeFrom(d) + _, err := s.DecodeFrom(d, xdr.DecodeDefaultMaxDepth) return err } @@ -22350,33 +22885,37 @@ func (s *ManageBuyOfferOp) EncodeTo(e *xdr.Encoder) error { var _ decoderFrom = (*ManageBuyOfferOp)(nil) // DecodeFrom decodes this value using the Decoder. -func (s *ManageBuyOfferOp) DecodeFrom(d *xdr.Decoder) (int, error) { +func (s *ManageBuyOfferOp) DecodeFrom(d *xdr.Decoder, maxDepth uint) (int, error) { + if maxDepth == 0 { + return 0, fmt.Errorf("decoding ManageBuyOfferOp: %w", ErrMaxDecodingDepthReached) + } + maxDepth -= 1 var err error var n, nTmp int - nTmp, err = s.Selling.DecodeFrom(d) + nTmp, err = s.Selling.DecodeFrom(d, maxDepth) n += nTmp if err != nil { - return n, fmt.Errorf("decoding Asset: %s", err) + return n, fmt.Errorf("decoding Asset: %w", err) } - nTmp, err = s.Buying.DecodeFrom(d) + nTmp, err = s.Buying.DecodeFrom(d, maxDepth) n += nTmp if err != nil { - return n, fmt.Errorf("decoding Asset: %s", err) + return n, fmt.Errorf("decoding Asset: %w", err) } - nTmp, err = s.BuyAmount.DecodeFrom(d) + nTmp, err = s.BuyAmount.DecodeFrom(d, maxDepth) n += nTmp if err != nil { - return n, fmt.Errorf("decoding Int64: %s", err) + return n, fmt.Errorf("decoding Int64: %w", err) } - nTmp, err = s.Price.DecodeFrom(d) + nTmp, err = s.Price.DecodeFrom(d, maxDepth) n += nTmp if err != nil { - return n, fmt.Errorf("decoding Price: %s", err) + return n, fmt.Errorf("decoding Price: %w", err) } - nTmp, err = s.OfferId.DecodeFrom(d) + nTmp, err = s.OfferId.DecodeFrom(d, maxDepth) n += nTmp if err != nil { - return n, fmt.Errorf("decoding Int64: %s", err) + return n, fmt.Errorf("decoding Int64: %w", err) } return n, nil } @@ -22393,7 +22932,7 @@ func (s ManageBuyOfferOp) MarshalBinary() ([]byte, error) { func (s *ManageBuyOfferOp) UnmarshalBinary(inp []byte) error { r := bytes.NewReader(inp) d := xdr.NewDecoder(r) - _, err := s.DecodeFrom(d) + _, err := s.DecodeFrom(d, xdr.DecodeDefaultMaxDepth) return err } @@ -22445,28 +22984,32 @@ func (s *CreatePassiveSellOfferOp) EncodeTo(e *xdr.Encoder) error { var _ decoderFrom = (*CreatePassiveSellOfferOp)(nil) // DecodeFrom decodes this value using the Decoder. -func (s *CreatePassiveSellOfferOp) DecodeFrom(d *xdr.Decoder) (int, error) { +func (s *CreatePassiveSellOfferOp) DecodeFrom(d *xdr.Decoder, maxDepth uint) (int, error) { + if maxDepth == 0 { + return 0, fmt.Errorf("decoding CreatePassiveSellOfferOp: %w", ErrMaxDecodingDepthReached) + } + maxDepth -= 1 var err error var n, nTmp int - nTmp, err = s.Selling.DecodeFrom(d) + nTmp, err = s.Selling.DecodeFrom(d, maxDepth) n += nTmp if err != nil { - return n, fmt.Errorf("decoding Asset: %s", err) + return n, fmt.Errorf("decoding Asset: %w", err) } - nTmp, err = s.Buying.DecodeFrom(d) + nTmp, err = s.Buying.DecodeFrom(d, maxDepth) n += nTmp if err != nil { - return n, fmt.Errorf("decoding Asset: %s", err) + return n, fmt.Errorf("decoding Asset: %w", err) } - nTmp, err = s.Amount.DecodeFrom(d) + nTmp, err = s.Amount.DecodeFrom(d, maxDepth) n += nTmp if err != nil { - return n, fmt.Errorf("decoding Int64: %s", err) + return n, fmt.Errorf("decoding Int64: %w", err) } - nTmp, err = s.Price.DecodeFrom(d) + nTmp, err = s.Price.DecodeFrom(d, maxDepth) n += nTmp if err != nil { - return n, fmt.Errorf("decoding Price: %s", err) + return n, fmt.Errorf("decoding Price: %w", err) } return n, nil } @@ -22483,7 +23026,7 @@ func (s CreatePassiveSellOfferOp) MarshalBinary() ([]byte, error) { func (s *CreatePassiveSellOfferOp) UnmarshalBinary(inp []byte) error { r := bytes.NewReader(inp) d := xdr.NewDecoder(r) - _, err := s.DecodeFrom(d) + _, err := s.DecodeFrom(d, xdr.DecodeDefaultMaxDepth) return err } @@ -22612,134 +23155,138 @@ func (s *SetOptionsOp) EncodeTo(e *xdr.Encoder) error { var _ decoderFrom = (*SetOptionsOp)(nil) // DecodeFrom decodes this value using the Decoder. -func (s *SetOptionsOp) DecodeFrom(d *xdr.Decoder) (int, error) { +func (s *SetOptionsOp) DecodeFrom(d *xdr.Decoder, maxDepth uint) (int, error) { + if maxDepth == 0 { + return 0, fmt.Errorf("decoding SetOptionsOp: %w", ErrMaxDecodingDepthReached) + } + maxDepth -= 1 var err error var n, nTmp int var b bool b, nTmp, err = d.DecodeBool() n += nTmp if err != nil { - return n, fmt.Errorf("decoding AccountId: %s", err) + return n, fmt.Errorf("decoding AccountId: %w", err) } s.InflationDest = nil if b { s.InflationDest = new(AccountId) - nTmp, err = s.InflationDest.DecodeFrom(d) + nTmp, err = s.InflationDest.DecodeFrom(d, maxDepth) n += nTmp if err != nil { - return n, fmt.Errorf("decoding AccountId: %s", err) + return n, fmt.Errorf("decoding AccountId: %w", err) } } b, nTmp, err = d.DecodeBool() n += nTmp if err != nil { - return n, fmt.Errorf("decoding Uint32: %s", err) + return n, fmt.Errorf("decoding Uint32: %w", err) } s.ClearFlags = nil if b { s.ClearFlags = new(Uint32) - nTmp, err = s.ClearFlags.DecodeFrom(d) + nTmp, err = s.ClearFlags.DecodeFrom(d, maxDepth) n += nTmp if err != nil { - return n, fmt.Errorf("decoding Uint32: %s", err) + return n, fmt.Errorf("decoding Uint32: %w", err) } } b, nTmp, err = d.DecodeBool() n += nTmp if err != nil { - return n, fmt.Errorf("decoding Uint32: %s", err) + return n, fmt.Errorf("decoding Uint32: %w", err) } s.SetFlags = nil if b { s.SetFlags = new(Uint32) - nTmp, err = s.SetFlags.DecodeFrom(d) + nTmp, err = s.SetFlags.DecodeFrom(d, maxDepth) n += nTmp if err != nil { - return n, fmt.Errorf("decoding Uint32: %s", err) + return n, fmt.Errorf("decoding Uint32: %w", err) } } b, nTmp, err = d.DecodeBool() n += nTmp if err != nil { - return n, fmt.Errorf("decoding Uint32: %s", err) + return n, fmt.Errorf("decoding Uint32: %w", err) } s.MasterWeight = nil if b { s.MasterWeight = new(Uint32) - nTmp, err = s.MasterWeight.DecodeFrom(d) + nTmp, err = s.MasterWeight.DecodeFrom(d, maxDepth) n += nTmp if err != nil { - return n, fmt.Errorf("decoding Uint32: %s", err) + return n, fmt.Errorf("decoding Uint32: %w", err) } } b, nTmp, err = d.DecodeBool() n += nTmp if err != nil { - return n, fmt.Errorf("decoding Uint32: %s", err) + return n, fmt.Errorf("decoding Uint32: %w", err) } s.LowThreshold = nil if b { s.LowThreshold = new(Uint32) - nTmp, err = s.LowThreshold.DecodeFrom(d) + nTmp, err = s.LowThreshold.DecodeFrom(d, maxDepth) n += nTmp if err != nil { - return n, fmt.Errorf("decoding Uint32: %s", err) + return n, fmt.Errorf("decoding Uint32: %w", err) } } b, nTmp, err = d.DecodeBool() n += nTmp if err != nil { - return n, fmt.Errorf("decoding Uint32: %s", err) + return n, fmt.Errorf("decoding Uint32: %w", err) } s.MedThreshold = nil if b { s.MedThreshold = new(Uint32) - nTmp, err = s.MedThreshold.DecodeFrom(d) + nTmp, err = s.MedThreshold.DecodeFrom(d, maxDepth) n += nTmp if err != nil { - return n, fmt.Errorf("decoding Uint32: %s", err) + return n, fmt.Errorf("decoding Uint32: %w", err) } } b, nTmp, err = d.DecodeBool() n += nTmp if err != nil { - return n, fmt.Errorf("decoding Uint32: %s", err) + return n, fmt.Errorf("decoding Uint32: %w", err) } s.HighThreshold = nil if b { s.HighThreshold = new(Uint32) - nTmp, err = s.HighThreshold.DecodeFrom(d) + nTmp, err = s.HighThreshold.DecodeFrom(d, maxDepth) n += nTmp if err != nil { - return n, fmt.Errorf("decoding Uint32: %s", err) + return n, fmt.Errorf("decoding Uint32: %w", err) } } b, nTmp, err = d.DecodeBool() n += nTmp if err != nil { - return n, fmt.Errorf("decoding String32: %s", err) + return n, fmt.Errorf("decoding String32: %w", err) } s.HomeDomain = nil if b { s.HomeDomain = new(String32) - nTmp, err = s.HomeDomain.DecodeFrom(d) + nTmp, err = s.HomeDomain.DecodeFrom(d, maxDepth) n += nTmp if err != nil { - return n, fmt.Errorf("decoding String32: %s", err) + return n, fmt.Errorf("decoding String32: %w", err) } } b, nTmp, err = d.DecodeBool() n += nTmp if err != nil { - return n, fmt.Errorf("decoding Signer: %s", err) + return n, fmt.Errorf("decoding Signer: %w", err) } s.Signer = nil if b { s.Signer = new(Signer) - nTmp, err = s.Signer.DecodeFrom(d) + nTmp, err = s.Signer.DecodeFrom(d, maxDepth) n += nTmp if err != nil { - return n, fmt.Errorf("decoding Signer: %s", err) + return n, fmt.Errorf("decoding Signer: %w", err) } } return n, nil @@ -22757,7 +23304,7 @@ func (s SetOptionsOp) MarshalBinary() ([]byte, error) { func (s *SetOptionsOp) UnmarshalBinary(inp []byte) error { r := bytes.NewReader(inp) d := xdr.NewDecoder(r) - _, err := s.DecodeFrom(d) + _, err := s.DecodeFrom(d, xdr.DecodeDefaultMaxDepth) return err } @@ -22828,21 +23375,21 @@ func NewChangeTrustAsset(aType AssetType, value interface{}) (result ChangeTrust case AssetTypeAssetTypeCreditAlphanum4: tv, ok := value.(AlphaNum4) if !ok { - err = fmt.Errorf("invalid value, must be AlphaNum4") + err = errors.New("invalid value, must be AlphaNum4") return } result.AlphaNum4 = &tv case AssetTypeAssetTypeCreditAlphanum12: tv, ok := value.(AlphaNum12) if !ok { - err = fmt.Errorf("invalid value, must be AlphaNum12") + err = errors.New("invalid value, must be AlphaNum12") return } result.AlphaNum12 = &tv case AssetTypeAssetTypePoolShare: tv, ok := value.(LiquidityPoolParameters) if !ok { - err = fmt.Errorf("invalid value, must be LiquidityPoolParameters") + err = errors.New("invalid value, must be LiquidityPoolParameters") return } result.LiquidityPool = &tv @@ -22957,13 +23504,17 @@ func (u ChangeTrustAsset) EncodeTo(e *xdr.Encoder) error { var _ decoderFrom = (*ChangeTrustAsset)(nil) // DecodeFrom decodes this value using the Decoder. -func (u *ChangeTrustAsset) DecodeFrom(d *xdr.Decoder) (int, error) { +func (u *ChangeTrustAsset) DecodeFrom(d *xdr.Decoder, maxDepth uint) (int, error) { + if maxDepth == 0 { + return 0, fmt.Errorf("decoding ChangeTrustAsset: %w", ErrMaxDecodingDepthReached) + } + maxDepth -= 1 var err error var n, nTmp int - nTmp, err = u.Type.DecodeFrom(d) + nTmp, err = u.Type.DecodeFrom(d, maxDepth) n += nTmp if err != nil { - return n, fmt.Errorf("decoding AssetType: %s", err) + return n, fmt.Errorf("decoding AssetType: %w", err) } switch AssetType(u.Type) { case AssetTypeAssetTypeNative: @@ -22971,26 +23522,26 @@ func (u *ChangeTrustAsset) DecodeFrom(d *xdr.Decoder) (int, error) { return n, nil case AssetTypeAssetTypeCreditAlphanum4: u.AlphaNum4 = new(AlphaNum4) - nTmp, err = (*u.AlphaNum4).DecodeFrom(d) + nTmp, err = (*u.AlphaNum4).DecodeFrom(d, maxDepth) n += nTmp if err != nil { - return n, fmt.Errorf("decoding AlphaNum4: %s", err) + return n, fmt.Errorf("decoding AlphaNum4: %w", err) } return n, nil case AssetTypeAssetTypeCreditAlphanum12: u.AlphaNum12 = new(AlphaNum12) - nTmp, err = (*u.AlphaNum12).DecodeFrom(d) + nTmp, err = (*u.AlphaNum12).DecodeFrom(d, maxDepth) n += nTmp if err != nil { - return n, fmt.Errorf("decoding AlphaNum12: %s", err) + return n, fmt.Errorf("decoding AlphaNum12: %w", err) } return n, nil case AssetTypeAssetTypePoolShare: u.LiquidityPool = new(LiquidityPoolParameters) - nTmp, err = (*u.LiquidityPool).DecodeFrom(d) + nTmp, err = (*u.LiquidityPool).DecodeFrom(d, maxDepth) n += nTmp if err != nil { - return n, fmt.Errorf("decoding LiquidityPoolParameters: %s", err) + return n, fmt.Errorf("decoding LiquidityPoolParameters: %w", err) } return n, nil } @@ -23009,7 +23560,7 @@ func (s ChangeTrustAsset) MarshalBinary() ([]byte, error) { func (s *ChangeTrustAsset) UnmarshalBinary(inp []byte) error { r := bytes.NewReader(inp) d := xdr.NewDecoder(r) - _, err := s.DecodeFrom(d) + _, err := s.DecodeFrom(d, xdr.DecodeDefaultMaxDepth) return err } @@ -23053,18 +23604,22 @@ func (s *ChangeTrustOp) EncodeTo(e *xdr.Encoder) error { var _ decoderFrom = (*ChangeTrustOp)(nil) // DecodeFrom decodes this value using the Decoder. -func (s *ChangeTrustOp) DecodeFrom(d *xdr.Decoder) (int, error) { +func (s *ChangeTrustOp) DecodeFrom(d *xdr.Decoder, maxDepth uint) (int, error) { + if maxDepth == 0 { + return 0, fmt.Errorf("decoding ChangeTrustOp: %w", ErrMaxDecodingDepthReached) + } + maxDepth -= 1 var err error var n, nTmp int - nTmp, err = s.Line.DecodeFrom(d) + nTmp, err = s.Line.DecodeFrom(d, maxDepth) n += nTmp if err != nil { - return n, fmt.Errorf("decoding ChangeTrustAsset: %s", err) + return n, fmt.Errorf("decoding ChangeTrustAsset: %w", err) } - nTmp, err = s.Limit.DecodeFrom(d) + nTmp, err = s.Limit.DecodeFrom(d, maxDepth) n += nTmp if err != nil { - return n, fmt.Errorf("decoding Int64: %s", err) + return n, fmt.Errorf("decoding Int64: %w", err) } return n, nil } @@ -23081,7 +23636,7 @@ func (s ChangeTrustOp) MarshalBinary() ([]byte, error) { func (s *ChangeTrustOp) UnmarshalBinary(inp []byte) error { r := bytes.NewReader(inp) d := xdr.NewDecoder(r) - _, err := s.DecodeFrom(d) + _, err := s.DecodeFrom(d, xdr.DecodeDefaultMaxDepth) return err } @@ -23130,23 +23685,27 @@ func (s *AllowTrustOp) EncodeTo(e *xdr.Encoder) error { var _ decoderFrom = (*AllowTrustOp)(nil) // DecodeFrom decodes this value using the Decoder. -func (s *AllowTrustOp) DecodeFrom(d *xdr.Decoder) (int, error) { +func (s *AllowTrustOp) DecodeFrom(d *xdr.Decoder, maxDepth uint) (int, error) { + if maxDepth == 0 { + return 0, fmt.Errorf("decoding AllowTrustOp: %w", ErrMaxDecodingDepthReached) + } + maxDepth -= 1 var err error var n, nTmp int - nTmp, err = s.Trustor.DecodeFrom(d) + nTmp, err = s.Trustor.DecodeFrom(d, maxDepth) n += nTmp if err != nil { - return n, fmt.Errorf("decoding AccountId: %s", err) + return n, fmt.Errorf("decoding AccountId: %w", err) } - nTmp, err = s.Asset.DecodeFrom(d) + nTmp, err = s.Asset.DecodeFrom(d, maxDepth) n += nTmp if err != nil { - return n, fmt.Errorf("decoding AssetCode: %s", err) + return n, fmt.Errorf("decoding AssetCode: %w", err) } - nTmp, err = s.Authorize.DecodeFrom(d) + nTmp, err = s.Authorize.DecodeFrom(d, maxDepth) n += nTmp if err != nil { - return n, fmt.Errorf("decoding Uint32: %s", err) + return n, fmt.Errorf("decoding Uint32: %w", err) } return n, nil } @@ -23163,7 +23722,7 @@ func (s AllowTrustOp) MarshalBinary() ([]byte, error) { func (s *AllowTrustOp) UnmarshalBinary(inp []byte) error { r := bytes.NewReader(inp) d := xdr.NewDecoder(r) - _, err := s.DecodeFrom(d) + _, err := s.DecodeFrom(d, xdr.DecodeDefaultMaxDepth) return err } @@ -23210,27 +23769,31 @@ func (s *ManageDataOp) EncodeTo(e *xdr.Encoder) error { var _ decoderFrom = (*ManageDataOp)(nil) // DecodeFrom decodes this value using the Decoder. -func (s *ManageDataOp) DecodeFrom(d *xdr.Decoder) (int, error) { +func (s *ManageDataOp) DecodeFrom(d *xdr.Decoder, maxDepth uint) (int, error) { + if maxDepth == 0 { + return 0, fmt.Errorf("decoding ManageDataOp: %w", ErrMaxDecodingDepthReached) + } + maxDepth -= 1 var err error var n, nTmp int - nTmp, err = s.DataName.DecodeFrom(d) + nTmp, err = s.DataName.DecodeFrom(d, maxDepth) n += nTmp if err != nil { - return n, fmt.Errorf("decoding String64: %s", err) + return n, fmt.Errorf("decoding String64: %w", err) } var b bool b, nTmp, err = d.DecodeBool() n += nTmp if err != nil { - return n, fmt.Errorf("decoding DataValue: %s", err) + return n, fmt.Errorf("decoding DataValue: %w", err) } s.DataValue = nil if b { s.DataValue = new(DataValue) - nTmp, err = s.DataValue.DecodeFrom(d) + nTmp, err = s.DataValue.DecodeFrom(d, maxDepth) n += nTmp if err != nil { - return n, fmt.Errorf("decoding DataValue: %s", err) + return n, fmt.Errorf("decoding DataValue: %w", err) } } return n, nil @@ -23248,7 +23811,7 @@ func (s ManageDataOp) MarshalBinary() ([]byte, error) { func (s *ManageDataOp) UnmarshalBinary(inp []byte) error { r := bytes.NewReader(inp) d := xdr.NewDecoder(r) - _, err := s.DecodeFrom(d) + _, err := s.DecodeFrom(d, xdr.DecodeDefaultMaxDepth) return err } @@ -23285,13 +23848,17 @@ func (s *BumpSequenceOp) EncodeTo(e *xdr.Encoder) error { var _ decoderFrom = (*BumpSequenceOp)(nil) // DecodeFrom decodes this value using the Decoder. -func (s *BumpSequenceOp) DecodeFrom(d *xdr.Decoder) (int, error) { +func (s *BumpSequenceOp) DecodeFrom(d *xdr.Decoder, maxDepth uint) (int, error) { + if maxDepth == 0 { + return 0, fmt.Errorf("decoding BumpSequenceOp: %w", ErrMaxDecodingDepthReached) + } + maxDepth -= 1 var err error var n, nTmp int - nTmp, err = s.BumpTo.DecodeFrom(d) + nTmp, err = s.BumpTo.DecodeFrom(d, maxDepth) n += nTmp if err != nil { - return n, fmt.Errorf("decoding SequenceNumber: %s", err) + return n, fmt.Errorf("decoding SequenceNumber: %w", err) } return n, nil } @@ -23308,7 +23875,7 @@ func (s BumpSequenceOp) MarshalBinary() ([]byte, error) { func (s *BumpSequenceOp) UnmarshalBinary(inp []byte) error { r := bytes.NewReader(inp) d := xdr.NewDecoder(r) - _, err := s.DecodeFrom(d) + _, err := s.DecodeFrom(d, xdr.DecodeDefaultMaxDepth) return err } @@ -23360,24 +23927,28 @@ func (s *CreateClaimableBalanceOp) EncodeTo(e *xdr.Encoder) error { var _ decoderFrom = (*CreateClaimableBalanceOp)(nil) // DecodeFrom decodes this value using the Decoder. -func (s *CreateClaimableBalanceOp) DecodeFrom(d *xdr.Decoder) (int, error) { +func (s *CreateClaimableBalanceOp) DecodeFrom(d *xdr.Decoder, maxDepth uint) (int, error) { + if maxDepth == 0 { + return 0, fmt.Errorf("decoding CreateClaimableBalanceOp: %w", ErrMaxDecodingDepthReached) + } + maxDepth -= 1 var err error var n, nTmp int - nTmp, err = s.Asset.DecodeFrom(d) + nTmp, err = s.Asset.DecodeFrom(d, maxDepth) n += nTmp if err != nil { - return n, fmt.Errorf("decoding Asset: %s", err) + return n, fmt.Errorf("decoding Asset: %w", err) } - nTmp, err = s.Amount.DecodeFrom(d) + nTmp, err = s.Amount.DecodeFrom(d, maxDepth) n += nTmp if err != nil { - return n, fmt.Errorf("decoding Int64: %s", err) + return n, fmt.Errorf("decoding Int64: %w", err) } var l uint32 l, nTmp, err = d.DecodeUint() n += nTmp if err != nil { - return n, fmt.Errorf("decoding Claimant: %s", err) + return n, fmt.Errorf("decoding Claimant: %w", err) } if l > 10 { return n, fmt.Errorf("decoding Claimant: data size (%d) exceeds size limit (10)", l) @@ -23386,10 +23957,10 @@ func (s *CreateClaimableBalanceOp) DecodeFrom(d *xdr.Decoder) (int, error) { if l > 0 { s.Claimants = make([]Claimant, l) for i := uint32(0); i < l; i++ { - nTmp, err = s.Claimants[i].DecodeFrom(d) + nTmp, err = s.Claimants[i].DecodeFrom(d, maxDepth) n += nTmp if err != nil { - return n, fmt.Errorf("decoding Claimant: %s", err) + return n, fmt.Errorf("decoding Claimant: %w", err) } } } @@ -23408,7 +23979,7 @@ func (s CreateClaimableBalanceOp) MarshalBinary() ([]byte, error) { func (s *CreateClaimableBalanceOp) UnmarshalBinary(inp []byte) error { r := bytes.NewReader(inp) d := xdr.NewDecoder(r) - _, err := s.DecodeFrom(d) + _, err := s.DecodeFrom(d, xdr.DecodeDefaultMaxDepth) return err } @@ -23445,13 +24016,17 @@ func (s *ClaimClaimableBalanceOp) EncodeTo(e *xdr.Encoder) error { var _ decoderFrom = (*ClaimClaimableBalanceOp)(nil) // DecodeFrom decodes this value using the Decoder. -func (s *ClaimClaimableBalanceOp) DecodeFrom(d *xdr.Decoder) (int, error) { +func (s *ClaimClaimableBalanceOp) DecodeFrom(d *xdr.Decoder, maxDepth uint) (int, error) { + if maxDepth == 0 { + return 0, fmt.Errorf("decoding ClaimClaimableBalanceOp: %w", ErrMaxDecodingDepthReached) + } + maxDepth -= 1 var err error var n, nTmp int - nTmp, err = s.BalanceId.DecodeFrom(d) + nTmp, err = s.BalanceId.DecodeFrom(d, maxDepth) n += nTmp if err != nil { - return n, fmt.Errorf("decoding ClaimableBalanceId: %s", err) + return n, fmt.Errorf("decoding ClaimableBalanceId: %w", err) } return n, nil } @@ -23468,7 +24043,7 @@ func (s ClaimClaimableBalanceOp) MarshalBinary() ([]byte, error) { func (s *ClaimClaimableBalanceOp) UnmarshalBinary(inp []byte) error { r := bytes.NewReader(inp) d := xdr.NewDecoder(r) - _, err := s.DecodeFrom(d) + _, err := s.DecodeFrom(d, xdr.DecodeDefaultMaxDepth) return err } @@ -23505,13 +24080,17 @@ func (s *BeginSponsoringFutureReservesOp) EncodeTo(e *xdr.Encoder) error { var _ decoderFrom = (*BeginSponsoringFutureReservesOp)(nil) // DecodeFrom decodes this value using the Decoder. -func (s *BeginSponsoringFutureReservesOp) DecodeFrom(d *xdr.Decoder) (int, error) { +func (s *BeginSponsoringFutureReservesOp) DecodeFrom(d *xdr.Decoder, maxDepth uint) (int, error) { + if maxDepth == 0 { + return 0, fmt.Errorf("decoding BeginSponsoringFutureReservesOp: %w", ErrMaxDecodingDepthReached) + } + maxDepth -= 1 var err error var n, nTmp int - nTmp, err = s.SponsoredId.DecodeFrom(d) + nTmp, err = s.SponsoredId.DecodeFrom(d, maxDepth) n += nTmp if err != nil { - return n, fmt.Errorf("decoding AccountId: %s", err) + return n, fmt.Errorf("decoding AccountId: %w", err) } return n, nil } @@ -23528,7 +24107,7 @@ func (s BeginSponsoringFutureReservesOp) MarshalBinary() ([]byte, error) { func (s *BeginSponsoringFutureReservesOp) UnmarshalBinary(inp []byte) error { r := bytes.NewReader(inp) d := xdr.NewDecoder(r) - _, err := s.DecodeFrom(d) + _, err := s.DecodeFrom(d, xdr.DecodeDefaultMaxDepth) return err } @@ -23587,10 +24166,14 @@ func (e RevokeSponsorshipType) EncodeTo(enc *xdr.Encoder) error { var _ decoderFrom = (*RevokeSponsorshipType)(nil) // DecodeFrom decodes this value using the Decoder. -func (e *RevokeSponsorshipType) DecodeFrom(d *xdr.Decoder) (int, error) { +func (e *RevokeSponsorshipType) DecodeFrom(d *xdr.Decoder, maxDepth uint) (int, error) { + if maxDepth == 0 { + return 0, fmt.Errorf("decoding RevokeSponsorshipType: %w", ErrMaxDecodingDepthReached) + } + maxDepth -= 1 v, n, err := d.DecodeInt() if err != nil { - return n, fmt.Errorf("decoding RevokeSponsorshipType: %s", err) + return n, fmt.Errorf("decoding RevokeSponsorshipType: %w", err) } if _, ok := revokeSponsorshipTypeMap[v]; !ok { return n, fmt.Errorf("'%d' is not a valid RevokeSponsorshipType enum value", v) @@ -23611,7 +24194,7 @@ func (s RevokeSponsorshipType) MarshalBinary() ([]byte, error) { func (s *RevokeSponsorshipType) UnmarshalBinary(inp []byte) error { r := bytes.NewReader(inp) d := xdr.NewDecoder(r) - _, err := s.DecodeFrom(d) + _, err := s.DecodeFrom(d, xdr.DecodeDefaultMaxDepth) return err } @@ -23653,18 +24236,22 @@ func (s *RevokeSponsorshipOpSigner) EncodeTo(e *xdr.Encoder) error { var _ decoderFrom = (*RevokeSponsorshipOpSigner)(nil) // DecodeFrom decodes this value using the Decoder. -func (s *RevokeSponsorshipOpSigner) DecodeFrom(d *xdr.Decoder) (int, error) { +func (s *RevokeSponsorshipOpSigner) DecodeFrom(d *xdr.Decoder, maxDepth uint) (int, error) { + if maxDepth == 0 { + return 0, fmt.Errorf("decoding RevokeSponsorshipOpSigner: %w", ErrMaxDecodingDepthReached) + } + maxDepth -= 1 var err error var n, nTmp int - nTmp, err = s.AccountId.DecodeFrom(d) + nTmp, err = s.AccountId.DecodeFrom(d, maxDepth) n += nTmp if err != nil { - return n, fmt.Errorf("decoding AccountId: %s", err) + return n, fmt.Errorf("decoding AccountId: %w", err) } - nTmp, err = s.SignerKey.DecodeFrom(d) + nTmp, err = s.SignerKey.DecodeFrom(d, maxDepth) n += nTmp if err != nil { - return n, fmt.Errorf("decoding SignerKey: %s", err) + return n, fmt.Errorf("decoding SignerKey: %w", err) } return n, nil } @@ -23681,7 +24268,7 @@ func (s RevokeSponsorshipOpSigner) MarshalBinary() ([]byte, error) { func (s *RevokeSponsorshipOpSigner) UnmarshalBinary(inp []byte) error { r := bytes.NewReader(inp) d := xdr.NewDecoder(r) - _, err := s.DecodeFrom(d) + _, err := s.DecodeFrom(d, xdr.DecodeDefaultMaxDepth) return err } @@ -23740,14 +24327,14 @@ func NewRevokeSponsorshipOp(aType RevokeSponsorshipType, value interface{}) (res case RevokeSponsorshipTypeRevokeSponsorshipLedgerEntry: tv, ok := value.(LedgerKey) if !ok { - err = fmt.Errorf("invalid value, must be LedgerKey") + err = errors.New("invalid value, must be LedgerKey") return } result.LedgerKey = &tv case RevokeSponsorshipTypeRevokeSponsorshipSigner: tv, ok := value.(RevokeSponsorshipOpSigner) if !ok { - err = fmt.Errorf("invalid value, must be RevokeSponsorshipOpSigner") + err = errors.New("invalid value, must be RevokeSponsorshipOpSigner") return } result.Signer = &tv @@ -23829,29 +24416,33 @@ func (u RevokeSponsorshipOp) EncodeTo(e *xdr.Encoder) error { var _ decoderFrom = (*RevokeSponsorshipOp)(nil) // DecodeFrom decodes this value using the Decoder. -func (u *RevokeSponsorshipOp) DecodeFrom(d *xdr.Decoder) (int, error) { +func (u *RevokeSponsorshipOp) DecodeFrom(d *xdr.Decoder, maxDepth uint) (int, error) { + if maxDepth == 0 { + return 0, fmt.Errorf("decoding RevokeSponsorshipOp: %w", ErrMaxDecodingDepthReached) + } + maxDepth -= 1 var err error var n, nTmp int - nTmp, err = u.Type.DecodeFrom(d) + nTmp, err = u.Type.DecodeFrom(d, maxDepth) n += nTmp if err != nil { - return n, fmt.Errorf("decoding RevokeSponsorshipType: %s", err) + return n, fmt.Errorf("decoding RevokeSponsorshipType: %w", err) } switch RevokeSponsorshipType(u.Type) { case RevokeSponsorshipTypeRevokeSponsorshipLedgerEntry: u.LedgerKey = new(LedgerKey) - nTmp, err = (*u.LedgerKey).DecodeFrom(d) + nTmp, err = (*u.LedgerKey).DecodeFrom(d, maxDepth) n += nTmp if err != nil { - return n, fmt.Errorf("decoding LedgerKey: %s", err) + return n, fmt.Errorf("decoding LedgerKey: %w", err) } return n, nil case RevokeSponsorshipTypeRevokeSponsorshipSigner: u.Signer = new(RevokeSponsorshipOpSigner) - nTmp, err = (*u.Signer).DecodeFrom(d) + nTmp, err = (*u.Signer).DecodeFrom(d, maxDepth) n += nTmp if err != nil { - return n, fmt.Errorf("decoding RevokeSponsorshipOpSigner: %s", err) + return n, fmt.Errorf("decoding RevokeSponsorshipOpSigner: %w", err) } return n, nil } @@ -23870,7 +24461,7 @@ func (s RevokeSponsorshipOp) MarshalBinary() ([]byte, error) { func (s *RevokeSponsorshipOp) UnmarshalBinary(inp []byte) error { r := bytes.NewReader(inp) d := xdr.NewDecoder(r) - _, err := s.DecodeFrom(d) + _, err := s.DecodeFrom(d, xdr.DecodeDefaultMaxDepth) return err } @@ -23917,23 +24508,27 @@ func (s *ClawbackOp) EncodeTo(e *xdr.Encoder) error { var _ decoderFrom = (*ClawbackOp)(nil) // DecodeFrom decodes this value using the Decoder. -func (s *ClawbackOp) DecodeFrom(d *xdr.Decoder) (int, error) { +func (s *ClawbackOp) DecodeFrom(d *xdr.Decoder, maxDepth uint) (int, error) { + if maxDepth == 0 { + return 0, fmt.Errorf("decoding ClawbackOp: %w", ErrMaxDecodingDepthReached) + } + maxDepth -= 1 var err error var n, nTmp int - nTmp, err = s.Asset.DecodeFrom(d) + nTmp, err = s.Asset.DecodeFrom(d, maxDepth) n += nTmp if err != nil { - return n, fmt.Errorf("decoding Asset: %s", err) + return n, fmt.Errorf("decoding Asset: %w", err) } - nTmp, err = s.From.DecodeFrom(d) + nTmp, err = s.From.DecodeFrom(d, maxDepth) n += nTmp if err != nil { - return n, fmt.Errorf("decoding MuxedAccount: %s", err) + return n, fmt.Errorf("decoding MuxedAccount: %w", err) } - nTmp, err = s.Amount.DecodeFrom(d) + nTmp, err = s.Amount.DecodeFrom(d, maxDepth) n += nTmp if err != nil { - return n, fmt.Errorf("decoding Int64: %s", err) + return n, fmt.Errorf("decoding Int64: %w", err) } return n, nil } @@ -23950,7 +24545,7 @@ func (s ClawbackOp) MarshalBinary() ([]byte, error) { func (s *ClawbackOp) UnmarshalBinary(inp []byte) error { r := bytes.NewReader(inp) d := xdr.NewDecoder(r) - _, err := s.DecodeFrom(d) + _, err := s.DecodeFrom(d, xdr.DecodeDefaultMaxDepth) return err } @@ -23987,13 +24582,17 @@ func (s *ClawbackClaimableBalanceOp) EncodeTo(e *xdr.Encoder) error { var _ decoderFrom = (*ClawbackClaimableBalanceOp)(nil) // DecodeFrom decodes this value using the Decoder. -func (s *ClawbackClaimableBalanceOp) DecodeFrom(d *xdr.Decoder) (int, error) { +func (s *ClawbackClaimableBalanceOp) DecodeFrom(d *xdr.Decoder, maxDepth uint) (int, error) { + if maxDepth == 0 { + return 0, fmt.Errorf("decoding ClawbackClaimableBalanceOp: %w", ErrMaxDecodingDepthReached) + } + maxDepth -= 1 var err error var n, nTmp int - nTmp, err = s.BalanceId.DecodeFrom(d) + nTmp, err = s.BalanceId.DecodeFrom(d, maxDepth) n += nTmp if err != nil { - return n, fmt.Errorf("decoding ClaimableBalanceId: %s", err) + return n, fmt.Errorf("decoding ClaimableBalanceId: %w", err) } return n, nil } @@ -24010,7 +24609,7 @@ func (s ClawbackClaimableBalanceOp) MarshalBinary() ([]byte, error) { func (s *ClawbackClaimableBalanceOp) UnmarshalBinary(inp []byte) error { r := bytes.NewReader(inp) d := xdr.NewDecoder(r) - _, err := s.DecodeFrom(d) + _, err := s.DecodeFrom(d, xdr.DecodeDefaultMaxDepth) return err } @@ -24063,28 +24662,32 @@ func (s *SetTrustLineFlagsOp) EncodeTo(e *xdr.Encoder) error { var _ decoderFrom = (*SetTrustLineFlagsOp)(nil) // DecodeFrom decodes this value using the Decoder. -func (s *SetTrustLineFlagsOp) DecodeFrom(d *xdr.Decoder) (int, error) { +func (s *SetTrustLineFlagsOp) DecodeFrom(d *xdr.Decoder, maxDepth uint) (int, error) { + if maxDepth == 0 { + return 0, fmt.Errorf("decoding SetTrustLineFlagsOp: %w", ErrMaxDecodingDepthReached) + } + maxDepth -= 1 var err error var n, nTmp int - nTmp, err = s.Trustor.DecodeFrom(d) + nTmp, err = s.Trustor.DecodeFrom(d, maxDepth) n += nTmp if err != nil { - return n, fmt.Errorf("decoding AccountId: %s", err) + return n, fmt.Errorf("decoding AccountId: %w", err) } - nTmp, err = s.Asset.DecodeFrom(d) + nTmp, err = s.Asset.DecodeFrom(d, maxDepth) n += nTmp if err != nil { - return n, fmt.Errorf("decoding Asset: %s", err) + return n, fmt.Errorf("decoding Asset: %w", err) } - nTmp, err = s.ClearFlags.DecodeFrom(d) + nTmp, err = s.ClearFlags.DecodeFrom(d, maxDepth) n += nTmp if err != nil { - return n, fmt.Errorf("decoding Uint32: %s", err) + return n, fmt.Errorf("decoding Uint32: %w", err) } - nTmp, err = s.SetFlags.DecodeFrom(d) + nTmp, err = s.SetFlags.DecodeFrom(d, maxDepth) n += nTmp if err != nil { - return n, fmt.Errorf("decoding Uint32: %s", err) + return n, fmt.Errorf("decoding Uint32: %w", err) } return n, nil } @@ -24101,7 +24704,7 @@ func (s SetTrustLineFlagsOp) MarshalBinary() ([]byte, error) { func (s *SetTrustLineFlagsOp) UnmarshalBinary(inp []byte) error { r := bytes.NewReader(inp) d := xdr.NewDecoder(r) - _, err := s.DecodeFrom(d) + _, err := s.DecodeFrom(d, xdr.DecodeDefaultMaxDepth) return err } @@ -24163,33 +24766,37 @@ func (s *LiquidityPoolDepositOp) EncodeTo(e *xdr.Encoder) error { var _ decoderFrom = (*LiquidityPoolDepositOp)(nil) // DecodeFrom decodes this value using the Decoder. -func (s *LiquidityPoolDepositOp) DecodeFrom(d *xdr.Decoder) (int, error) { +func (s *LiquidityPoolDepositOp) DecodeFrom(d *xdr.Decoder, maxDepth uint) (int, error) { + if maxDepth == 0 { + return 0, fmt.Errorf("decoding LiquidityPoolDepositOp: %w", ErrMaxDecodingDepthReached) + } + maxDepth -= 1 var err error var n, nTmp int - nTmp, err = s.LiquidityPoolId.DecodeFrom(d) + nTmp, err = s.LiquidityPoolId.DecodeFrom(d, maxDepth) n += nTmp if err != nil { - return n, fmt.Errorf("decoding PoolId: %s", err) + return n, fmt.Errorf("decoding PoolId: %w", err) } - nTmp, err = s.MaxAmountA.DecodeFrom(d) + nTmp, err = s.MaxAmountA.DecodeFrom(d, maxDepth) n += nTmp if err != nil { - return n, fmt.Errorf("decoding Int64: %s", err) + return n, fmt.Errorf("decoding Int64: %w", err) } - nTmp, err = s.MaxAmountB.DecodeFrom(d) + nTmp, err = s.MaxAmountB.DecodeFrom(d, maxDepth) n += nTmp if err != nil { - return n, fmt.Errorf("decoding Int64: %s", err) + return n, fmt.Errorf("decoding Int64: %w", err) } - nTmp, err = s.MinPrice.DecodeFrom(d) + nTmp, err = s.MinPrice.DecodeFrom(d, maxDepth) n += nTmp if err != nil { - return n, fmt.Errorf("decoding Price: %s", err) + return n, fmt.Errorf("decoding Price: %w", err) } - nTmp, err = s.MaxPrice.DecodeFrom(d) + nTmp, err = s.MaxPrice.DecodeFrom(d, maxDepth) n += nTmp if err != nil { - return n, fmt.Errorf("decoding Price: %s", err) + return n, fmt.Errorf("decoding Price: %w", err) } return n, nil } @@ -24206,7 +24813,7 @@ func (s LiquidityPoolDepositOp) MarshalBinary() ([]byte, error) { func (s *LiquidityPoolDepositOp) UnmarshalBinary(inp []byte) error { r := bytes.NewReader(inp) d := xdr.NewDecoder(r) - _, err := s.DecodeFrom(d) + _, err := s.DecodeFrom(d, xdr.DecodeDefaultMaxDepth) return err } @@ -24258,28 +24865,32 @@ func (s *LiquidityPoolWithdrawOp) EncodeTo(e *xdr.Encoder) error { var _ decoderFrom = (*LiquidityPoolWithdrawOp)(nil) // DecodeFrom decodes this value using the Decoder. -func (s *LiquidityPoolWithdrawOp) DecodeFrom(d *xdr.Decoder) (int, error) { +func (s *LiquidityPoolWithdrawOp) DecodeFrom(d *xdr.Decoder, maxDepth uint) (int, error) { + if maxDepth == 0 { + return 0, fmt.Errorf("decoding LiquidityPoolWithdrawOp: %w", ErrMaxDecodingDepthReached) + } + maxDepth -= 1 var err error var n, nTmp int - nTmp, err = s.LiquidityPoolId.DecodeFrom(d) + nTmp, err = s.LiquidityPoolId.DecodeFrom(d, maxDepth) n += nTmp if err != nil { - return n, fmt.Errorf("decoding PoolId: %s", err) + return n, fmt.Errorf("decoding PoolId: %w", err) } - nTmp, err = s.Amount.DecodeFrom(d) + nTmp, err = s.Amount.DecodeFrom(d, maxDepth) n += nTmp if err != nil { - return n, fmt.Errorf("decoding Int64: %s", err) + return n, fmt.Errorf("decoding Int64: %w", err) } - nTmp, err = s.MinAmountA.DecodeFrom(d) + nTmp, err = s.MinAmountA.DecodeFrom(d, maxDepth) n += nTmp if err != nil { - return n, fmt.Errorf("decoding Int64: %s", err) + return n, fmt.Errorf("decoding Int64: %w", err) } - nTmp, err = s.MinAmountB.DecodeFrom(d) + nTmp, err = s.MinAmountB.DecodeFrom(d, maxDepth) n += nTmp if err != nil { - return n, fmt.Errorf("decoding Int64: %s", err) + return n, fmt.Errorf("decoding Int64: %w", err) } return n, nil } @@ -24296,7 +24907,7 @@ func (s LiquidityPoolWithdrawOp) MarshalBinary() ([]byte, error) { func (s *LiquidityPoolWithdrawOp) UnmarshalBinary(inp []byte) error { r := bytes.NewReader(inp) d := xdr.NewDecoder(r) - _, err := s.DecodeFrom(d) + _, err := s.DecodeFrom(d, xdr.DecodeDefaultMaxDepth) return err } @@ -24358,10 +24969,14 @@ func (e HostFunctionType) EncodeTo(enc *xdr.Encoder) error { var _ decoderFrom = (*HostFunctionType)(nil) // DecodeFrom decodes this value using the Decoder. -func (e *HostFunctionType) DecodeFrom(d *xdr.Decoder) (int, error) { +func (e *HostFunctionType) DecodeFrom(d *xdr.Decoder, maxDepth uint) (int, error) { + if maxDepth == 0 { + return 0, fmt.Errorf("decoding HostFunctionType: %w", ErrMaxDecodingDepthReached) + } + maxDepth -= 1 v, n, err := d.DecodeInt() if err != nil { - return n, fmt.Errorf("decoding HostFunctionType: %s", err) + return n, fmt.Errorf("decoding HostFunctionType: %w", err) } if _, ok := hostFunctionTypeMap[v]; !ok { return n, fmt.Errorf("'%d' is not a valid HostFunctionType enum value", v) @@ -24382,7 +24997,7 @@ func (s HostFunctionType) MarshalBinary() ([]byte, error) { func (s *HostFunctionType) UnmarshalBinary(inp []byte) error { r := bytes.NewReader(inp) d := xdr.NewDecoder(r) - _, err := s.DecodeFrom(d) + _, err := s.DecodeFrom(d, xdr.DecodeDefaultMaxDepth) return err } @@ -24441,10 +25056,14 @@ func (e ContractIdPreimageType) EncodeTo(enc *xdr.Encoder) error { var _ decoderFrom = (*ContractIdPreimageType)(nil) // DecodeFrom decodes this value using the Decoder. -func (e *ContractIdPreimageType) DecodeFrom(d *xdr.Decoder) (int, error) { +func (e *ContractIdPreimageType) DecodeFrom(d *xdr.Decoder, maxDepth uint) (int, error) { + if maxDepth == 0 { + return 0, fmt.Errorf("decoding ContractIdPreimageType: %w", ErrMaxDecodingDepthReached) + } + maxDepth -= 1 v, n, err := d.DecodeInt() if err != nil { - return n, fmt.Errorf("decoding ContractIdPreimageType: %s", err) + return n, fmt.Errorf("decoding ContractIdPreimageType: %w", err) } if _, ok := contractIdPreimageTypeMap[v]; !ok { return n, fmt.Errorf("'%d' is not a valid ContractIdPreimageType enum value", v) @@ -24465,7 +25084,7 @@ func (s ContractIdPreimageType) MarshalBinary() ([]byte, error) { func (s *ContractIdPreimageType) UnmarshalBinary(inp []byte) error { r := bytes.NewReader(inp) d := xdr.NewDecoder(r) - _, err := s.DecodeFrom(d) + _, err := s.DecodeFrom(d, xdr.DecodeDefaultMaxDepth) return err } @@ -24507,18 +25126,22 @@ func (s *ContractIdPreimageFromAddress) EncodeTo(e *xdr.Encoder) error { var _ decoderFrom = (*ContractIdPreimageFromAddress)(nil) // DecodeFrom decodes this value using the Decoder. -func (s *ContractIdPreimageFromAddress) DecodeFrom(d *xdr.Decoder) (int, error) { +func (s *ContractIdPreimageFromAddress) DecodeFrom(d *xdr.Decoder, maxDepth uint) (int, error) { + if maxDepth == 0 { + return 0, fmt.Errorf("decoding ContractIdPreimageFromAddress: %w", ErrMaxDecodingDepthReached) + } + maxDepth -= 1 var err error var n, nTmp int - nTmp, err = s.Address.DecodeFrom(d) + nTmp, err = s.Address.DecodeFrom(d, maxDepth) n += nTmp if err != nil { - return n, fmt.Errorf("decoding ScAddress: %s", err) + return n, fmt.Errorf("decoding ScAddress: %w", err) } - nTmp, err = s.Salt.DecodeFrom(d) + nTmp, err = s.Salt.DecodeFrom(d, maxDepth) n += nTmp if err != nil { - return n, fmt.Errorf("decoding Uint256: %s", err) + return n, fmt.Errorf("decoding Uint256: %w", err) } return n, nil } @@ -24535,7 +25158,7 @@ func (s ContractIdPreimageFromAddress) MarshalBinary() ([]byte, error) { func (s *ContractIdPreimageFromAddress) UnmarshalBinary(inp []byte) error { r := bytes.NewReader(inp) d := xdr.NewDecoder(r) - _, err := s.DecodeFrom(d) + _, err := s.DecodeFrom(d, xdr.DecodeDefaultMaxDepth) return err } @@ -24594,14 +25217,14 @@ func NewContractIdPreimage(aType ContractIdPreimageType, value interface{}) (res case ContractIdPreimageTypeContractIdPreimageFromAddress: tv, ok := value.(ContractIdPreimageFromAddress) if !ok { - err = fmt.Errorf("invalid value, must be ContractIdPreimageFromAddress") + err = errors.New("invalid value, must be ContractIdPreimageFromAddress") return } result.FromAddress = &tv case ContractIdPreimageTypeContractIdPreimageFromAsset: tv, ok := value.(Asset) if !ok { - err = fmt.Errorf("invalid value, must be Asset") + err = errors.New("invalid value, must be Asset") return } result.FromAsset = &tv @@ -24683,29 +25306,33 @@ func (u ContractIdPreimage) EncodeTo(e *xdr.Encoder) error { var _ decoderFrom = (*ContractIdPreimage)(nil) // DecodeFrom decodes this value using the Decoder. -func (u *ContractIdPreimage) DecodeFrom(d *xdr.Decoder) (int, error) { +func (u *ContractIdPreimage) DecodeFrom(d *xdr.Decoder, maxDepth uint) (int, error) { + if maxDepth == 0 { + return 0, fmt.Errorf("decoding ContractIdPreimage: %w", ErrMaxDecodingDepthReached) + } + maxDepth -= 1 var err error var n, nTmp int - nTmp, err = u.Type.DecodeFrom(d) + nTmp, err = u.Type.DecodeFrom(d, maxDepth) n += nTmp if err != nil { - return n, fmt.Errorf("decoding ContractIdPreimageType: %s", err) + return n, fmt.Errorf("decoding ContractIdPreimageType: %w", err) } switch ContractIdPreimageType(u.Type) { case ContractIdPreimageTypeContractIdPreimageFromAddress: u.FromAddress = new(ContractIdPreimageFromAddress) - nTmp, err = (*u.FromAddress).DecodeFrom(d) + nTmp, err = (*u.FromAddress).DecodeFrom(d, maxDepth) n += nTmp if err != nil { - return n, fmt.Errorf("decoding ContractIdPreimageFromAddress: %s", err) + return n, fmt.Errorf("decoding ContractIdPreimageFromAddress: %w", err) } return n, nil case ContractIdPreimageTypeContractIdPreimageFromAsset: u.FromAsset = new(Asset) - nTmp, err = (*u.FromAsset).DecodeFrom(d) + nTmp, err = (*u.FromAsset).DecodeFrom(d, maxDepth) n += nTmp if err != nil { - return n, fmt.Errorf("decoding Asset: %s", err) + return n, fmt.Errorf("decoding Asset: %w", err) } return n, nil } @@ -24724,7 +25351,7 @@ func (s ContractIdPreimage) MarshalBinary() ([]byte, error) { func (s *ContractIdPreimage) UnmarshalBinary(inp []byte) error { r := bytes.NewReader(inp) d := xdr.NewDecoder(r) - _, err := s.DecodeFrom(d) + _, err := s.DecodeFrom(d, xdr.DecodeDefaultMaxDepth) return err } @@ -24766,18 +25393,22 @@ func (s *CreateContractArgs) EncodeTo(e *xdr.Encoder) error { var _ decoderFrom = (*CreateContractArgs)(nil) // DecodeFrom decodes this value using the Decoder. -func (s *CreateContractArgs) DecodeFrom(d *xdr.Decoder) (int, error) { +func (s *CreateContractArgs) DecodeFrom(d *xdr.Decoder, maxDepth uint) (int, error) { + if maxDepth == 0 { + return 0, fmt.Errorf("decoding CreateContractArgs: %w", ErrMaxDecodingDepthReached) + } + maxDepth -= 1 var err error var n, nTmp int - nTmp, err = s.ContractIdPreimage.DecodeFrom(d) + nTmp, err = s.ContractIdPreimage.DecodeFrom(d, maxDepth) n += nTmp if err != nil { - return n, fmt.Errorf("decoding ContractIdPreimage: %s", err) + return n, fmt.Errorf("decoding ContractIdPreimage: %w", err) } - nTmp, err = s.Executable.DecodeFrom(d) + nTmp, err = s.Executable.DecodeFrom(d, maxDepth) n += nTmp if err != nil { - return n, fmt.Errorf("decoding ContractExecutable: %s", err) + return n, fmt.Errorf("decoding ContractExecutable: %w", err) } return n, nil } @@ -24794,7 +25425,7 @@ func (s CreateContractArgs) MarshalBinary() ([]byte, error) { func (s *CreateContractArgs) UnmarshalBinary(inp []byte) error { r := bytes.NewReader(inp) d := xdr.NewDecoder(r) - _, err := s.DecodeFrom(d) + _, err := s.DecodeFrom(d, xdr.DecodeDefaultMaxDepth) return err } @@ -24845,33 +25476,37 @@ func (s *InvokeContractArgs) EncodeTo(e *xdr.Encoder) error { var _ decoderFrom = (*InvokeContractArgs)(nil) // DecodeFrom decodes this value using the Decoder. -func (s *InvokeContractArgs) DecodeFrom(d *xdr.Decoder) (int, error) { +func (s *InvokeContractArgs) DecodeFrom(d *xdr.Decoder, maxDepth uint) (int, error) { + if maxDepth == 0 { + return 0, fmt.Errorf("decoding InvokeContractArgs: %w", ErrMaxDecodingDepthReached) + } + maxDepth -= 1 var err error var n, nTmp int - nTmp, err = s.ContractAddress.DecodeFrom(d) + nTmp, err = s.ContractAddress.DecodeFrom(d, maxDepth) n += nTmp if err != nil { - return n, fmt.Errorf("decoding ScAddress: %s", err) + return n, fmt.Errorf("decoding ScAddress: %w", err) } - nTmp, err = s.FunctionName.DecodeFrom(d) + nTmp, err = s.FunctionName.DecodeFrom(d, maxDepth) n += nTmp if err != nil { - return n, fmt.Errorf("decoding ScSymbol: %s", err) + return n, fmt.Errorf("decoding ScSymbol: %w", err) } var l uint32 l, nTmp, err = d.DecodeUint() n += nTmp if err != nil { - return n, fmt.Errorf("decoding ScVal: %s", err) + return n, fmt.Errorf("decoding ScVal: %w", err) } s.Args = nil if l > 0 { s.Args = make([]ScVal, l) for i := uint32(0); i < l; i++ { - nTmp, err = s.Args[i].DecodeFrom(d) + nTmp, err = s.Args[i].DecodeFrom(d, maxDepth) n += nTmp if err != nil { - return n, fmt.Errorf("decoding ScVal: %s", err) + return n, fmt.Errorf("decoding ScVal: %w", err) } } } @@ -24890,7 +25525,7 @@ func (s InvokeContractArgs) MarshalBinary() ([]byte, error) { func (s *InvokeContractArgs) UnmarshalBinary(inp []byte) error { r := bytes.NewReader(inp) d := xdr.NewDecoder(r) - _, err := s.DecodeFrom(d) + _, err := s.DecodeFrom(d, xdr.DecodeDefaultMaxDepth) return err } @@ -24950,21 +25585,21 @@ func NewHostFunction(aType HostFunctionType, value interface{}) (result HostFunc case HostFunctionTypeHostFunctionTypeInvokeContract: tv, ok := value.(InvokeContractArgs) if !ok { - err = fmt.Errorf("invalid value, must be InvokeContractArgs") + err = errors.New("invalid value, must be InvokeContractArgs") return } result.InvokeContract = &tv case HostFunctionTypeHostFunctionTypeCreateContract: tv, ok := value.(CreateContractArgs) if !ok { - err = fmt.Errorf("invalid value, must be CreateContractArgs") + err = errors.New("invalid value, must be CreateContractArgs") return } result.CreateContract = &tv case HostFunctionTypeHostFunctionTypeUploadContractWasm: tv, ok := value.([]byte) if !ok { - err = fmt.Errorf("invalid value, must be []byte") + err = errors.New("invalid value, must be []byte") return } result.Wasm = &tv @@ -25076,29 +25711,33 @@ func (u HostFunction) EncodeTo(e *xdr.Encoder) error { var _ decoderFrom = (*HostFunction)(nil) // DecodeFrom decodes this value using the Decoder. -func (u *HostFunction) DecodeFrom(d *xdr.Decoder) (int, error) { +func (u *HostFunction) DecodeFrom(d *xdr.Decoder, maxDepth uint) (int, error) { + if maxDepth == 0 { + return 0, fmt.Errorf("decoding HostFunction: %w", ErrMaxDecodingDepthReached) + } + maxDepth -= 1 var err error var n, nTmp int - nTmp, err = u.Type.DecodeFrom(d) + nTmp, err = u.Type.DecodeFrom(d, maxDepth) n += nTmp if err != nil { - return n, fmt.Errorf("decoding HostFunctionType: %s", err) + return n, fmt.Errorf("decoding HostFunctionType: %w", err) } switch HostFunctionType(u.Type) { case HostFunctionTypeHostFunctionTypeInvokeContract: u.InvokeContract = new(InvokeContractArgs) - nTmp, err = (*u.InvokeContract).DecodeFrom(d) + nTmp, err = (*u.InvokeContract).DecodeFrom(d, maxDepth) n += nTmp if err != nil { - return n, fmt.Errorf("decoding InvokeContractArgs: %s", err) + return n, fmt.Errorf("decoding InvokeContractArgs: %w", err) } return n, nil case HostFunctionTypeHostFunctionTypeCreateContract: u.CreateContract = new(CreateContractArgs) - nTmp, err = (*u.CreateContract).DecodeFrom(d) + nTmp, err = (*u.CreateContract).DecodeFrom(d, maxDepth) n += nTmp if err != nil { - return n, fmt.Errorf("decoding CreateContractArgs: %s", err) + return n, fmt.Errorf("decoding CreateContractArgs: %w", err) } return n, nil case HostFunctionTypeHostFunctionTypeUploadContractWasm: @@ -25106,7 +25745,7 @@ func (u *HostFunction) DecodeFrom(d *xdr.Decoder) (int, error) { (*u.Wasm), nTmp, err = d.DecodeOpaque(0) n += nTmp if err != nil { - return n, fmt.Errorf("decoding Wasm: %s", err) + return n, fmt.Errorf("decoding Wasm: %w", err) } return n, nil } @@ -25125,7 +25764,7 @@ func (s HostFunction) MarshalBinary() ([]byte, error) { func (s *HostFunction) UnmarshalBinary(inp []byte) error { r := bytes.NewReader(inp) d := xdr.NewDecoder(r) - _, err := s.DecodeFrom(d) + _, err := s.DecodeFrom(d, xdr.DecodeDefaultMaxDepth) return err } @@ -25184,10 +25823,14 @@ func (e SorobanAuthorizedFunctionType) EncodeTo(enc *xdr.Encoder) error { var _ decoderFrom = (*SorobanAuthorizedFunctionType)(nil) // DecodeFrom decodes this value using the Decoder. -func (e *SorobanAuthorizedFunctionType) DecodeFrom(d *xdr.Decoder) (int, error) { +func (e *SorobanAuthorizedFunctionType) DecodeFrom(d *xdr.Decoder, maxDepth uint) (int, error) { + if maxDepth == 0 { + return 0, fmt.Errorf("decoding SorobanAuthorizedFunctionType: %w", ErrMaxDecodingDepthReached) + } + maxDepth -= 1 v, n, err := d.DecodeInt() if err != nil { - return n, fmt.Errorf("decoding SorobanAuthorizedFunctionType: %s", err) + return n, fmt.Errorf("decoding SorobanAuthorizedFunctionType: %w", err) } if _, ok := sorobanAuthorizedFunctionTypeMap[v]; !ok { return n, fmt.Errorf("'%d' is not a valid SorobanAuthorizedFunctionType enum value", v) @@ -25208,7 +25851,7 @@ func (s SorobanAuthorizedFunctionType) MarshalBinary() ([]byte, error) { func (s *SorobanAuthorizedFunctionType) UnmarshalBinary(inp []byte) error { r := bytes.NewReader(inp) d := xdr.NewDecoder(r) - _, err := s.DecodeFrom(d) + _, err := s.DecodeFrom(d, xdr.DecodeDefaultMaxDepth) return err } @@ -25263,14 +25906,14 @@ func NewSorobanAuthorizedFunction(aType SorobanAuthorizedFunctionType, value int case SorobanAuthorizedFunctionTypeSorobanAuthorizedFunctionTypeContractFn: tv, ok := value.(InvokeContractArgs) if !ok { - err = fmt.Errorf("invalid value, must be InvokeContractArgs") + err = errors.New("invalid value, must be InvokeContractArgs") return } result.ContractFn = &tv case SorobanAuthorizedFunctionTypeSorobanAuthorizedFunctionTypeCreateContractHostFn: tv, ok := value.(CreateContractArgs) if !ok { - err = fmt.Errorf("invalid value, must be CreateContractArgs") + err = errors.New("invalid value, must be CreateContractArgs") return } result.CreateContractHostFn = &tv @@ -25352,29 +25995,33 @@ func (u SorobanAuthorizedFunction) EncodeTo(e *xdr.Encoder) error { var _ decoderFrom = (*SorobanAuthorizedFunction)(nil) // DecodeFrom decodes this value using the Decoder. -func (u *SorobanAuthorizedFunction) DecodeFrom(d *xdr.Decoder) (int, error) { +func (u *SorobanAuthorizedFunction) DecodeFrom(d *xdr.Decoder, maxDepth uint) (int, error) { + if maxDepth == 0 { + return 0, fmt.Errorf("decoding SorobanAuthorizedFunction: %w", ErrMaxDecodingDepthReached) + } + maxDepth -= 1 var err error var n, nTmp int - nTmp, err = u.Type.DecodeFrom(d) + nTmp, err = u.Type.DecodeFrom(d, maxDepth) n += nTmp if err != nil { - return n, fmt.Errorf("decoding SorobanAuthorizedFunctionType: %s", err) + return n, fmt.Errorf("decoding SorobanAuthorizedFunctionType: %w", err) } switch SorobanAuthorizedFunctionType(u.Type) { case SorobanAuthorizedFunctionTypeSorobanAuthorizedFunctionTypeContractFn: u.ContractFn = new(InvokeContractArgs) - nTmp, err = (*u.ContractFn).DecodeFrom(d) + nTmp, err = (*u.ContractFn).DecodeFrom(d, maxDepth) n += nTmp if err != nil { - return n, fmt.Errorf("decoding InvokeContractArgs: %s", err) + return n, fmt.Errorf("decoding InvokeContractArgs: %w", err) } return n, nil case SorobanAuthorizedFunctionTypeSorobanAuthorizedFunctionTypeCreateContractHostFn: u.CreateContractHostFn = new(CreateContractArgs) - nTmp, err = (*u.CreateContractHostFn).DecodeFrom(d) + nTmp, err = (*u.CreateContractHostFn).DecodeFrom(d, maxDepth) n += nTmp if err != nil { - return n, fmt.Errorf("decoding CreateContractArgs: %s", err) + return n, fmt.Errorf("decoding CreateContractArgs: %w", err) } return n, nil } @@ -25393,7 +26040,7 @@ func (s SorobanAuthorizedFunction) MarshalBinary() ([]byte, error) { func (s *SorobanAuthorizedFunction) UnmarshalBinary(inp []byte) error { r := bytes.NewReader(inp) d := xdr.NewDecoder(r) - _, err := s.DecodeFrom(d) + _, err := s.DecodeFrom(d, xdr.DecodeDefaultMaxDepth) return err } @@ -25440,28 +26087,32 @@ func (s *SorobanAuthorizedInvocation) EncodeTo(e *xdr.Encoder) error { var _ decoderFrom = (*SorobanAuthorizedInvocation)(nil) // DecodeFrom decodes this value using the Decoder. -func (s *SorobanAuthorizedInvocation) DecodeFrom(d *xdr.Decoder) (int, error) { +func (s *SorobanAuthorizedInvocation) DecodeFrom(d *xdr.Decoder, maxDepth uint) (int, error) { + if maxDepth == 0 { + return 0, fmt.Errorf("decoding SorobanAuthorizedInvocation: %w", ErrMaxDecodingDepthReached) + } + maxDepth -= 1 var err error var n, nTmp int - nTmp, err = s.Function.DecodeFrom(d) + nTmp, err = s.Function.DecodeFrom(d, maxDepth) n += nTmp if err != nil { - return n, fmt.Errorf("decoding SorobanAuthorizedFunction: %s", err) + return n, fmt.Errorf("decoding SorobanAuthorizedFunction: %w", err) } var l uint32 l, nTmp, err = d.DecodeUint() n += nTmp if err != nil { - return n, fmt.Errorf("decoding SorobanAuthorizedInvocation: %s", err) + return n, fmt.Errorf("decoding SorobanAuthorizedInvocation: %w", err) } s.SubInvocations = nil if l > 0 { s.SubInvocations = make([]SorobanAuthorizedInvocation, l) for i := uint32(0); i < l; i++ { - nTmp, err = s.SubInvocations[i].DecodeFrom(d) + nTmp, err = s.SubInvocations[i].DecodeFrom(d, maxDepth) n += nTmp if err != nil { - return n, fmt.Errorf("decoding SorobanAuthorizedInvocation: %s", err) + return n, fmt.Errorf("decoding SorobanAuthorizedInvocation: %w", err) } } } @@ -25480,7 +26131,7 @@ func (s SorobanAuthorizedInvocation) MarshalBinary() ([]byte, error) { func (s *SorobanAuthorizedInvocation) UnmarshalBinary(inp []byte) error { r := bytes.NewReader(inp) d := xdr.NewDecoder(r) - _, err := s.DecodeFrom(d) + _, err := s.DecodeFrom(d, xdr.DecodeDefaultMaxDepth) return err } @@ -25532,28 +26183,32 @@ func (s *SorobanAddressCredentials) EncodeTo(e *xdr.Encoder) error { var _ decoderFrom = (*SorobanAddressCredentials)(nil) // DecodeFrom decodes this value using the Decoder. -func (s *SorobanAddressCredentials) DecodeFrom(d *xdr.Decoder) (int, error) { +func (s *SorobanAddressCredentials) DecodeFrom(d *xdr.Decoder, maxDepth uint) (int, error) { + if maxDepth == 0 { + return 0, fmt.Errorf("decoding SorobanAddressCredentials: %w", ErrMaxDecodingDepthReached) + } + maxDepth -= 1 var err error var n, nTmp int - nTmp, err = s.Address.DecodeFrom(d) + nTmp, err = s.Address.DecodeFrom(d, maxDepth) n += nTmp if err != nil { - return n, fmt.Errorf("decoding ScAddress: %s", err) + return n, fmt.Errorf("decoding ScAddress: %w", err) } - nTmp, err = s.Nonce.DecodeFrom(d) + nTmp, err = s.Nonce.DecodeFrom(d, maxDepth) n += nTmp if err != nil { - return n, fmt.Errorf("decoding Int64: %s", err) + return n, fmt.Errorf("decoding Int64: %w", err) } - nTmp, err = s.SignatureExpirationLedger.DecodeFrom(d) + nTmp, err = s.SignatureExpirationLedger.DecodeFrom(d, maxDepth) n += nTmp if err != nil { - return n, fmt.Errorf("decoding Uint32: %s", err) + return n, fmt.Errorf("decoding Uint32: %w", err) } - nTmp, err = s.Signature.DecodeFrom(d) + nTmp, err = s.Signature.DecodeFrom(d, maxDepth) n += nTmp if err != nil { - return n, fmt.Errorf("decoding ScVal: %s", err) + return n, fmt.Errorf("decoding ScVal: %w", err) } return n, nil } @@ -25570,7 +26225,7 @@ func (s SorobanAddressCredentials) MarshalBinary() ([]byte, error) { func (s *SorobanAddressCredentials) UnmarshalBinary(inp []byte) error { r := bytes.NewReader(inp) d := xdr.NewDecoder(r) - _, err := s.DecodeFrom(d) + _, err := s.DecodeFrom(d, xdr.DecodeDefaultMaxDepth) return err } @@ -25629,10 +26284,14 @@ func (e SorobanCredentialsType) EncodeTo(enc *xdr.Encoder) error { var _ decoderFrom = (*SorobanCredentialsType)(nil) // DecodeFrom decodes this value using the Decoder. -func (e *SorobanCredentialsType) DecodeFrom(d *xdr.Decoder) (int, error) { +func (e *SorobanCredentialsType) DecodeFrom(d *xdr.Decoder, maxDepth uint) (int, error) { + if maxDepth == 0 { + return 0, fmt.Errorf("decoding SorobanCredentialsType: %w", ErrMaxDecodingDepthReached) + } + maxDepth -= 1 v, n, err := d.DecodeInt() if err != nil { - return n, fmt.Errorf("decoding SorobanCredentialsType: %s", err) + return n, fmt.Errorf("decoding SorobanCredentialsType: %w", err) } if _, ok := sorobanCredentialsTypeMap[v]; !ok { return n, fmt.Errorf("'%d' is not a valid SorobanCredentialsType enum value", v) @@ -25653,7 +26312,7 @@ func (s SorobanCredentialsType) MarshalBinary() ([]byte, error) { func (s *SorobanCredentialsType) UnmarshalBinary(inp []byte) error { r := bytes.NewReader(inp) d := xdr.NewDecoder(r) - _, err := s.DecodeFrom(d) + _, err := s.DecodeFrom(d, xdr.DecodeDefaultMaxDepth) return err } @@ -25709,7 +26368,7 @@ func NewSorobanCredentials(aType SorobanCredentialsType, value interface{}) (res case SorobanCredentialsTypeSorobanCredentialsAddress: tv, ok := value.(SorobanAddressCredentials) if !ok { - err = fmt.Errorf("invalid value, must be SorobanAddressCredentials") + err = errors.New("invalid value, must be SorobanAddressCredentials") return } result.Address = &tv @@ -25764,13 +26423,17 @@ func (u SorobanCredentials) EncodeTo(e *xdr.Encoder) error { var _ decoderFrom = (*SorobanCredentials)(nil) // DecodeFrom decodes this value using the Decoder. -func (u *SorobanCredentials) DecodeFrom(d *xdr.Decoder) (int, error) { +func (u *SorobanCredentials) DecodeFrom(d *xdr.Decoder, maxDepth uint) (int, error) { + if maxDepth == 0 { + return 0, fmt.Errorf("decoding SorobanCredentials: %w", ErrMaxDecodingDepthReached) + } + maxDepth -= 1 var err error var n, nTmp int - nTmp, err = u.Type.DecodeFrom(d) + nTmp, err = u.Type.DecodeFrom(d, maxDepth) n += nTmp if err != nil { - return n, fmt.Errorf("decoding SorobanCredentialsType: %s", err) + return n, fmt.Errorf("decoding SorobanCredentialsType: %w", err) } switch SorobanCredentialsType(u.Type) { case SorobanCredentialsTypeSorobanCredentialsSourceAccount: @@ -25778,10 +26441,10 @@ func (u *SorobanCredentials) DecodeFrom(d *xdr.Decoder) (int, error) { return n, nil case SorobanCredentialsTypeSorobanCredentialsAddress: u.Address = new(SorobanAddressCredentials) - nTmp, err = (*u.Address).DecodeFrom(d) + nTmp, err = (*u.Address).DecodeFrom(d, maxDepth) n += nTmp if err != nil { - return n, fmt.Errorf("decoding SorobanAddressCredentials: %s", err) + return n, fmt.Errorf("decoding SorobanAddressCredentials: %w", err) } return n, nil } @@ -25800,7 +26463,7 @@ func (s SorobanCredentials) MarshalBinary() ([]byte, error) { func (s *SorobanCredentials) UnmarshalBinary(inp []byte) error { r := bytes.NewReader(inp) d := xdr.NewDecoder(r) - _, err := s.DecodeFrom(d) + _, err := s.DecodeFrom(d, xdr.DecodeDefaultMaxDepth) return err } @@ -25842,18 +26505,22 @@ func (s *SorobanAuthorizationEntry) EncodeTo(e *xdr.Encoder) error { var _ decoderFrom = (*SorobanAuthorizationEntry)(nil) // DecodeFrom decodes this value using the Decoder. -func (s *SorobanAuthorizationEntry) DecodeFrom(d *xdr.Decoder) (int, error) { +func (s *SorobanAuthorizationEntry) DecodeFrom(d *xdr.Decoder, maxDepth uint) (int, error) { + if maxDepth == 0 { + return 0, fmt.Errorf("decoding SorobanAuthorizationEntry: %w", ErrMaxDecodingDepthReached) + } + maxDepth -= 1 var err error var n, nTmp int - nTmp, err = s.Credentials.DecodeFrom(d) + nTmp, err = s.Credentials.DecodeFrom(d, maxDepth) n += nTmp if err != nil { - return n, fmt.Errorf("decoding SorobanCredentials: %s", err) + return n, fmt.Errorf("decoding SorobanCredentials: %w", err) } - nTmp, err = s.RootInvocation.DecodeFrom(d) + nTmp, err = s.RootInvocation.DecodeFrom(d, maxDepth) n += nTmp if err != nil { - return n, fmt.Errorf("decoding SorobanAuthorizedInvocation: %s", err) + return n, fmt.Errorf("decoding SorobanAuthorizedInvocation: %w", err) } return n, nil } @@ -25870,7 +26537,7 @@ func (s SorobanAuthorizationEntry) MarshalBinary() ([]byte, error) { func (s *SorobanAuthorizationEntry) UnmarshalBinary(inp []byte) error { r := bytes.NewReader(inp) d := xdr.NewDecoder(r) - _, err := s.DecodeFrom(d) + _, err := s.DecodeFrom(d, xdr.DecodeDefaultMaxDepth) return err } @@ -25919,28 +26586,32 @@ func (s *InvokeHostFunctionOp) EncodeTo(e *xdr.Encoder) error { var _ decoderFrom = (*InvokeHostFunctionOp)(nil) // DecodeFrom decodes this value using the Decoder. -func (s *InvokeHostFunctionOp) DecodeFrom(d *xdr.Decoder) (int, error) { +func (s *InvokeHostFunctionOp) DecodeFrom(d *xdr.Decoder, maxDepth uint) (int, error) { + if maxDepth == 0 { + return 0, fmt.Errorf("decoding InvokeHostFunctionOp: %w", ErrMaxDecodingDepthReached) + } + maxDepth -= 1 var err error var n, nTmp int - nTmp, err = s.HostFunction.DecodeFrom(d) + nTmp, err = s.HostFunction.DecodeFrom(d, maxDepth) n += nTmp if err != nil { - return n, fmt.Errorf("decoding HostFunction: %s", err) + return n, fmt.Errorf("decoding HostFunction: %w", err) } var l uint32 l, nTmp, err = d.DecodeUint() n += nTmp if err != nil { - return n, fmt.Errorf("decoding SorobanAuthorizationEntry: %s", err) + return n, fmt.Errorf("decoding SorobanAuthorizationEntry: %w", err) } s.Auth = nil if l > 0 { s.Auth = make([]SorobanAuthorizationEntry, l) for i := uint32(0); i < l; i++ { - nTmp, err = s.Auth[i].DecodeFrom(d) + nTmp, err = s.Auth[i].DecodeFrom(d, maxDepth) n += nTmp if err != nil { - return n, fmt.Errorf("decoding SorobanAuthorizationEntry: %s", err) + return n, fmt.Errorf("decoding SorobanAuthorizationEntry: %w", err) } } } @@ -25959,7 +26630,7 @@ func (s InvokeHostFunctionOp) MarshalBinary() ([]byte, error) { func (s *InvokeHostFunctionOp) UnmarshalBinary(inp []byte) error { r := bytes.NewReader(inp) d := xdr.NewDecoder(r) - _, err := s.DecodeFrom(d) + _, err := s.DecodeFrom(d, xdr.DecodeDefaultMaxDepth) return err } @@ -25974,51 +26645,55 @@ func (s InvokeHostFunctionOp) xdrType() {} var _ xdrType = (*InvokeHostFunctionOp)(nil) -// BumpFootprintExpirationOp is an XDR Struct defines as: +// ExtendFootprintTtlOp is an XDR Struct defines as: // -// struct BumpFootprintExpirationOp +// struct ExtendFootprintTTLOp // { // ExtensionPoint ext; -// uint32 ledgersToExpire; +// uint32 extendTo; // }; -type BumpFootprintExpirationOp struct { - Ext ExtensionPoint - LedgersToExpire Uint32 +type ExtendFootprintTtlOp struct { + Ext ExtensionPoint + ExtendTo Uint32 } // EncodeTo encodes this value using the Encoder. -func (s *BumpFootprintExpirationOp) EncodeTo(e *xdr.Encoder) error { +func (s *ExtendFootprintTtlOp) EncodeTo(e *xdr.Encoder) error { var err error if err = s.Ext.EncodeTo(e); err != nil { return err } - if err = s.LedgersToExpire.EncodeTo(e); err != nil { + if err = s.ExtendTo.EncodeTo(e); err != nil { return err } return nil } -var _ decoderFrom = (*BumpFootprintExpirationOp)(nil) +var _ decoderFrom = (*ExtendFootprintTtlOp)(nil) // DecodeFrom decodes this value using the Decoder. -func (s *BumpFootprintExpirationOp) DecodeFrom(d *xdr.Decoder) (int, error) { +func (s *ExtendFootprintTtlOp) DecodeFrom(d *xdr.Decoder, maxDepth uint) (int, error) { + if maxDepth == 0 { + return 0, fmt.Errorf("decoding ExtendFootprintTtlOp: %w", ErrMaxDecodingDepthReached) + } + maxDepth -= 1 var err error var n, nTmp int - nTmp, err = s.Ext.DecodeFrom(d) + nTmp, err = s.Ext.DecodeFrom(d, maxDepth) n += nTmp if err != nil { - return n, fmt.Errorf("decoding ExtensionPoint: %s", err) + return n, fmt.Errorf("decoding ExtensionPoint: %w", err) } - nTmp, err = s.LedgersToExpire.DecodeFrom(d) + nTmp, err = s.ExtendTo.DecodeFrom(d, maxDepth) n += nTmp if err != nil { - return n, fmt.Errorf("decoding Uint32: %s", err) + return n, fmt.Errorf("decoding Uint32: %w", err) } return n, nil } // MarshalBinary implements encoding.BinaryMarshaler. -func (s BumpFootprintExpirationOp) MarshalBinary() ([]byte, error) { +func (s ExtendFootprintTtlOp) MarshalBinary() ([]byte, error) { b := bytes.Buffer{} e := xdr.NewEncoder(&b) err := s.EncodeTo(e) @@ -26026,23 +26701,23 @@ func (s BumpFootprintExpirationOp) MarshalBinary() ([]byte, error) { } // UnmarshalBinary implements encoding.BinaryUnmarshaler. -func (s *BumpFootprintExpirationOp) UnmarshalBinary(inp []byte) error { +func (s *ExtendFootprintTtlOp) UnmarshalBinary(inp []byte) error { r := bytes.NewReader(inp) d := xdr.NewDecoder(r) - _, err := s.DecodeFrom(d) + _, err := s.DecodeFrom(d, xdr.DecodeDefaultMaxDepth) return err } var ( - _ encoding.BinaryMarshaler = (*BumpFootprintExpirationOp)(nil) - _ encoding.BinaryUnmarshaler = (*BumpFootprintExpirationOp)(nil) + _ encoding.BinaryMarshaler = (*ExtendFootprintTtlOp)(nil) + _ encoding.BinaryUnmarshaler = (*ExtendFootprintTtlOp)(nil) ) // xdrType signals that this type is an type representing // representing XDR values defined by this package. -func (s BumpFootprintExpirationOp) xdrType() {} +func (s ExtendFootprintTtlOp) xdrType() {} -var _ xdrType = (*BumpFootprintExpirationOp)(nil) +var _ xdrType = (*ExtendFootprintTtlOp)(nil) // RestoreFootprintOp is an XDR Struct defines as: // @@ -26066,13 +26741,17 @@ func (s *RestoreFootprintOp) EncodeTo(e *xdr.Encoder) error { var _ decoderFrom = (*RestoreFootprintOp)(nil) // DecodeFrom decodes this value using the Decoder. -func (s *RestoreFootprintOp) DecodeFrom(d *xdr.Decoder) (int, error) { +func (s *RestoreFootprintOp) DecodeFrom(d *xdr.Decoder, maxDepth uint) (int, error) { + if maxDepth == 0 { + return 0, fmt.Errorf("decoding RestoreFootprintOp: %w", ErrMaxDecodingDepthReached) + } + maxDepth -= 1 var err error var n, nTmp int - nTmp, err = s.Ext.DecodeFrom(d) + nTmp, err = s.Ext.DecodeFrom(d, maxDepth) n += nTmp if err != nil { - return n, fmt.Errorf("decoding ExtensionPoint: %s", err) + return n, fmt.Errorf("decoding ExtensionPoint: %w", err) } return n, nil } @@ -26089,7 +26768,7 @@ func (s RestoreFootprintOp) MarshalBinary() ([]byte, error) { func (s *RestoreFootprintOp) UnmarshalBinary(inp []byte) error { r := bytes.NewReader(inp) d := xdr.NewDecoder(r) - _, err := s.DecodeFrom(d) + _, err := s.DecodeFrom(d, xdr.DecodeDefaultMaxDepth) return err } @@ -26158,8 +26837,8 @@ var _ xdrType = (*RestoreFootprintOp)(nil) // LiquidityPoolWithdrawOp liquidityPoolWithdrawOp; // case INVOKE_HOST_FUNCTION: // InvokeHostFunctionOp invokeHostFunctionOp; -// case BUMP_FOOTPRINT_EXPIRATION: -// BumpFootprintExpirationOp bumpFootprintExpirationOp; +// case EXTEND_FOOTPRINT_TTL: +// ExtendFootprintTTLOp extendFootprintTTLOp; // case RESTORE_FOOTPRINT: // RestoreFootprintOp restoreFootprintOp; // } @@ -26188,7 +26867,7 @@ type OperationBody struct { LiquidityPoolDepositOp *LiquidityPoolDepositOp LiquidityPoolWithdrawOp *LiquidityPoolWithdrawOp InvokeHostFunctionOp *InvokeHostFunctionOp - BumpFootprintExpirationOp *BumpFootprintExpirationOp + ExtendFootprintTtlOp *ExtendFootprintTtlOp RestoreFootprintOp *RestoreFootprintOp } @@ -26252,8 +26931,8 @@ func (u OperationBody) ArmForSwitch(sw int32) (string, bool) { return "LiquidityPoolWithdrawOp", true case OperationTypeInvokeHostFunction: return "InvokeHostFunctionOp", true - case OperationTypeBumpFootprintExpiration: - return "BumpFootprintExpirationOp", true + case OperationTypeExtendFootprintTtl: + return "ExtendFootprintTtlOp", true case OperationTypeRestoreFootprint: return "RestoreFootprintOp", true } @@ -26267,63 +26946,63 @@ func NewOperationBody(aType OperationType, value interface{}) (result OperationB case OperationTypeCreateAccount: tv, ok := value.(CreateAccountOp) if !ok { - err = fmt.Errorf("invalid value, must be CreateAccountOp") + err = errors.New("invalid value, must be CreateAccountOp") return } result.CreateAccountOp = &tv case OperationTypePayment: tv, ok := value.(PaymentOp) if !ok { - err = fmt.Errorf("invalid value, must be PaymentOp") + err = errors.New("invalid value, must be PaymentOp") return } result.PaymentOp = &tv case OperationTypePathPaymentStrictReceive: tv, ok := value.(PathPaymentStrictReceiveOp) if !ok { - err = fmt.Errorf("invalid value, must be PathPaymentStrictReceiveOp") + err = errors.New("invalid value, must be PathPaymentStrictReceiveOp") return } result.PathPaymentStrictReceiveOp = &tv case OperationTypeManageSellOffer: tv, ok := value.(ManageSellOfferOp) if !ok { - err = fmt.Errorf("invalid value, must be ManageSellOfferOp") + err = errors.New("invalid value, must be ManageSellOfferOp") return } result.ManageSellOfferOp = &tv case OperationTypeCreatePassiveSellOffer: tv, ok := value.(CreatePassiveSellOfferOp) if !ok { - err = fmt.Errorf("invalid value, must be CreatePassiveSellOfferOp") + err = errors.New("invalid value, must be CreatePassiveSellOfferOp") return } result.CreatePassiveSellOfferOp = &tv case OperationTypeSetOptions: tv, ok := value.(SetOptionsOp) if !ok { - err = fmt.Errorf("invalid value, must be SetOptionsOp") + err = errors.New("invalid value, must be SetOptionsOp") return } result.SetOptionsOp = &tv case OperationTypeChangeTrust: tv, ok := value.(ChangeTrustOp) if !ok { - err = fmt.Errorf("invalid value, must be ChangeTrustOp") + err = errors.New("invalid value, must be ChangeTrustOp") return } result.ChangeTrustOp = &tv case OperationTypeAllowTrust: tv, ok := value.(AllowTrustOp) if !ok { - err = fmt.Errorf("invalid value, must be AllowTrustOp") + err = errors.New("invalid value, must be AllowTrustOp") return } result.AllowTrustOp = &tv case OperationTypeAccountMerge: tv, ok := value.(MuxedAccount) if !ok { - err = fmt.Errorf("invalid value, must be MuxedAccount") + err = errors.New("invalid value, must be MuxedAccount") return } result.Destination = &tv @@ -26332,49 +27011,49 @@ func NewOperationBody(aType OperationType, value interface{}) (result OperationB case OperationTypeManageData: tv, ok := value.(ManageDataOp) if !ok { - err = fmt.Errorf("invalid value, must be ManageDataOp") + err = errors.New("invalid value, must be ManageDataOp") return } result.ManageDataOp = &tv case OperationTypeBumpSequence: tv, ok := value.(BumpSequenceOp) if !ok { - err = fmt.Errorf("invalid value, must be BumpSequenceOp") + err = errors.New("invalid value, must be BumpSequenceOp") return } result.BumpSequenceOp = &tv case OperationTypeManageBuyOffer: tv, ok := value.(ManageBuyOfferOp) if !ok { - err = fmt.Errorf("invalid value, must be ManageBuyOfferOp") + err = errors.New("invalid value, must be ManageBuyOfferOp") return } result.ManageBuyOfferOp = &tv case OperationTypePathPaymentStrictSend: tv, ok := value.(PathPaymentStrictSendOp) if !ok { - err = fmt.Errorf("invalid value, must be PathPaymentStrictSendOp") + err = errors.New("invalid value, must be PathPaymentStrictSendOp") return } result.PathPaymentStrictSendOp = &tv case OperationTypeCreateClaimableBalance: tv, ok := value.(CreateClaimableBalanceOp) if !ok { - err = fmt.Errorf("invalid value, must be CreateClaimableBalanceOp") + err = errors.New("invalid value, must be CreateClaimableBalanceOp") return } result.CreateClaimableBalanceOp = &tv case OperationTypeClaimClaimableBalance: tv, ok := value.(ClaimClaimableBalanceOp) if !ok { - err = fmt.Errorf("invalid value, must be ClaimClaimableBalanceOp") + err = errors.New("invalid value, must be ClaimClaimableBalanceOp") return } result.ClaimClaimableBalanceOp = &tv case OperationTypeBeginSponsoringFutureReserves: tv, ok := value.(BeginSponsoringFutureReservesOp) if !ok { - err = fmt.Errorf("invalid value, must be BeginSponsoringFutureReservesOp") + err = errors.New("invalid value, must be BeginSponsoringFutureReservesOp") return } result.BeginSponsoringFutureReservesOp = &tv @@ -26383,63 +27062,63 @@ func NewOperationBody(aType OperationType, value interface{}) (result OperationB case OperationTypeRevokeSponsorship: tv, ok := value.(RevokeSponsorshipOp) if !ok { - err = fmt.Errorf("invalid value, must be RevokeSponsorshipOp") + err = errors.New("invalid value, must be RevokeSponsorshipOp") return } result.RevokeSponsorshipOp = &tv case OperationTypeClawback: tv, ok := value.(ClawbackOp) if !ok { - err = fmt.Errorf("invalid value, must be ClawbackOp") + err = errors.New("invalid value, must be ClawbackOp") return } result.ClawbackOp = &tv case OperationTypeClawbackClaimableBalance: tv, ok := value.(ClawbackClaimableBalanceOp) if !ok { - err = fmt.Errorf("invalid value, must be ClawbackClaimableBalanceOp") + err = errors.New("invalid value, must be ClawbackClaimableBalanceOp") return } result.ClawbackClaimableBalanceOp = &tv case OperationTypeSetTrustLineFlags: tv, ok := value.(SetTrustLineFlagsOp) if !ok { - err = fmt.Errorf("invalid value, must be SetTrustLineFlagsOp") + err = errors.New("invalid value, must be SetTrustLineFlagsOp") return } result.SetTrustLineFlagsOp = &tv case OperationTypeLiquidityPoolDeposit: tv, ok := value.(LiquidityPoolDepositOp) if !ok { - err = fmt.Errorf("invalid value, must be LiquidityPoolDepositOp") + err = errors.New("invalid value, must be LiquidityPoolDepositOp") return } result.LiquidityPoolDepositOp = &tv case OperationTypeLiquidityPoolWithdraw: tv, ok := value.(LiquidityPoolWithdrawOp) if !ok { - err = fmt.Errorf("invalid value, must be LiquidityPoolWithdrawOp") + err = errors.New("invalid value, must be LiquidityPoolWithdrawOp") return } result.LiquidityPoolWithdrawOp = &tv case OperationTypeInvokeHostFunction: tv, ok := value.(InvokeHostFunctionOp) if !ok { - err = fmt.Errorf("invalid value, must be InvokeHostFunctionOp") + err = errors.New("invalid value, must be InvokeHostFunctionOp") return } result.InvokeHostFunctionOp = &tv - case OperationTypeBumpFootprintExpiration: - tv, ok := value.(BumpFootprintExpirationOp) + case OperationTypeExtendFootprintTtl: + tv, ok := value.(ExtendFootprintTtlOp) if !ok { - err = fmt.Errorf("invalid value, must be BumpFootprintExpirationOp") + err = errors.New("invalid value, must be ExtendFootprintTtlOp") return } - result.BumpFootprintExpirationOp = &tv + result.ExtendFootprintTtlOp = &tv case OperationTypeRestoreFootprint: tv, ok := value.(RestoreFootprintOp) if !ok { - err = fmt.Errorf("invalid value, must be RestoreFootprintOp") + err = errors.New("invalid value, must be RestoreFootprintOp") return } result.RestoreFootprintOp = &tv @@ -27022,25 +27701,25 @@ func (u OperationBody) GetInvokeHostFunctionOp() (result InvokeHostFunctionOp, o return } -// MustBumpFootprintExpirationOp retrieves the BumpFootprintExpirationOp value from the union, +// MustExtendFootprintTtlOp retrieves the ExtendFootprintTtlOp value from the union, // panicing if the value is not set. -func (u OperationBody) MustBumpFootprintExpirationOp() BumpFootprintExpirationOp { - val, ok := u.GetBumpFootprintExpirationOp() +func (u OperationBody) MustExtendFootprintTtlOp() ExtendFootprintTtlOp { + val, ok := u.GetExtendFootprintTtlOp() if !ok { - panic("arm BumpFootprintExpirationOp is not set") + panic("arm ExtendFootprintTtlOp is not set") } return val } -// GetBumpFootprintExpirationOp retrieves the BumpFootprintExpirationOp value from the union, +// GetExtendFootprintTtlOp retrieves the ExtendFootprintTtlOp value from the union, // returning ok if the union's switch indicated the value is valid. -func (u OperationBody) GetBumpFootprintExpirationOp() (result BumpFootprintExpirationOp, ok bool) { +func (u OperationBody) GetExtendFootprintTtlOp() (result ExtendFootprintTtlOp, ok bool) { armName, _ := u.ArmForSwitch(int32(u.Type)) - if armName == "BumpFootprintExpirationOp" { - result = *u.BumpFootprintExpirationOp + if armName == "ExtendFootprintTtlOp" { + result = *u.ExtendFootprintTtlOp ok = true } @@ -27200,8 +27879,8 @@ func (u OperationBody) EncodeTo(e *xdr.Encoder) error { return err } return nil - case OperationTypeBumpFootprintExpiration: - if err = (*u.BumpFootprintExpirationOp).EncodeTo(e); err != nil { + case OperationTypeExtendFootprintTtl: + if err = (*u.ExtendFootprintTtlOp).EncodeTo(e); err != nil { return err } return nil @@ -27217,85 +27896,89 @@ func (u OperationBody) EncodeTo(e *xdr.Encoder) error { var _ decoderFrom = (*OperationBody)(nil) // DecodeFrom decodes this value using the Decoder. -func (u *OperationBody) DecodeFrom(d *xdr.Decoder) (int, error) { +func (u *OperationBody) DecodeFrom(d *xdr.Decoder, maxDepth uint) (int, error) { + if maxDepth == 0 { + return 0, fmt.Errorf("decoding OperationBody: %w", ErrMaxDecodingDepthReached) + } + maxDepth -= 1 var err error var n, nTmp int - nTmp, err = u.Type.DecodeFrom(d) + nTmp, err = u.Type.DecodeFrom(d, maxDepth) n += nTmp if err != nil { - return n, fmt.Errorf("decoding OperationType: %s", err) + return n, fmt.Errorf("decoding OperationType: %w", err) } switch OperationType(u.Type) { case OperationTypeCreateAccount: u.CreateAccountOp = new(CreateAccountOp) - nTmp, err = (*u.CreateAccountOp).DecodeFrom(d) + nTmp, err = (*u.CreateAccountOp).DecodeFrom(d, maxDepth) n += nTmp if err != nil { - return n, fmt.Errorf("decoding CreateAccountOp: %s", err) + return n, fmt.Errorf("decoding CreateAccountOp: %w", err) } return n, nil case OperationTypePayment: u.PaymentOp = new(PaymentOp) - nTmp, err = (*u.PaymentOp).DecodeFrom(d) + nTmp, err = (*u.PaymentOp).DecodeFrom(d, maxDepth) n += nTmp if err != nil { - return n, fmt.Errorf("decoding PaymentOp: %s", err) + return n, fmt.Errorf("decoding PaymentOp: %w", err) } return n, nil case OperationTypePathPaymentStrictReceive: u.PathPaymentStrictReceiveOp = new(PathPaymentStrictReceiveOp) - nTmp, err = (*u.PathPaymentStrictReceiveOp).DecodeFrom(d) + nTmp, err = (*u.PathPaymentStrictReceiveOp).DecodeFrom(d, maxDepth) n += nTmp if err != nil { - return n, fmt.Errorf("decoding PathPaymentStrictReceiveOp: %s", err) + return n, fmt.Errorf("decoding PathPaymentStrictReceiveOp: %w", err) } return n, nil case OperationTypeManageSellOffer: u.ManageSellOfferOp = new(ManageSellOfferOp) - nTmp, err = (*u.ManageSellOfferOp).DecodeFrom(d) + nTmp, err = (*u.ManageSellOfferOp).DecodeFrom(d, maxDepth) n += nTmp if err != nil { - return n, fmt.Errorf("decoding ManageSellOfferOp: %s", err) + return n, fmt.Errorf("decoding ManageSellOfferOp: %w", err) } return n, nil case OperationTypeCreatePassiveSellOffer: u.CreatePassiveSellOfferOp = new(CreatePassiveSellOfferOp) - nTmp, err = (*u.CreatePassiveSellOfferOp).DecodeFrom(d) + nTmp, err = (*u.CreatePassiveSellOfferOp).DecodeFrom(d, maxDepth) n += nTmp if err != nil { - return n, fmt.Errorf("decoding CreatePassiveSellOfferOp: %s", err) + return n, fmt.Errorf("decoding CreatePassiveSellOfferOp: %w", err) } return n, nil case OperationTypeSetOptions: u.SetOptionsOp = new(SetOptionsOp) - nTmp, err = (*u.SetOptionsOp).DecodeFrom(d) + nTmp, err = (*u.SetOptionsOp).DecodeFrom(d, maxDepth) n += nTmp if err != nil { - return n, fmt.Errorf("decoding SetOptionsOp: %s", err) + return n, fmt.Errorf("decoding SetOptionsOp: %w", err) } return n, nil case OperationTypeChangeTrust: u.ChangeTrustOp = new(ChangeTrustOp) - nTmp, err = (*u.ChangeTrustOp).DecodeFrom(d) + nTmp, err = (*u.ChangeTrustOp).DecodeFrom(d, maxDepth) n += nTmp if err != nil { - return n, fmt.Errorf("decoding ChangeTrustOp: %s", err) + return n, fmt.Errorf("decoding ChangeTrustOp: %w", err) } return n, nil case OperationTypeAllowTrust: u.AllowTrustOp = new(AllowTrustOp) - nTmp, err = (*u.AllowTrustOp).DecodeFrom(d) + nTmp, err = (*u.AllowTrustOp).DecodeFrom(d, maxDepth) n += nTmp if err != nil { - return n, fmt.Errorf("decoding AllowTrustOp: %s", err) + return n, fmt.Errorf("decoding AllowTrustOp: %w", err) } return n, nil case OperationTypeAccountMerge: u.Destination = new(MuxedAccount) - nTmp, err = (*u.Destination).DecodeFrom(d) + nTmp, err = (*u.Destination).DecodeFrom(d, maxDepth) n += nTmp if err != nil { - return n, fmt.Errorf("decoding MuxedAccount: %s", err) + return n, fmt.Errorf("decoding MuxedAccount: %w", err) } return n, nil case OperationTypeInflation: @@ -27303,58 +27986,58 @@ func (u *OperationBody) DecodeFrom(d *xdr.Decoder) (int, error) { return n, nil case OperationTypeManageData: u.ManageDataOp = new(ManageDataOp) - nTmp, err = (*u.ManageDataOp).DecodeFrom(d) + nTmp, err = (*u.ManageDataOp).DecodeFrom(d, maxDepth) n += nTmp if err != nil { - return n, fmt.Errorf("decoding ManageDataOp: %s", err) + return n, fmt.Errorf("decoding ManageDataOp: %w", err) } return n, nil case OperationTypeBumpSequence: u.BumpSequenceOp = new(BumpSequenceOp) - nTmp, err = (*u.BumpSequenceOp).DecodeFrom(d) + nTmp, err = (*u.BumpSequenceOp).DecodeFrom(d, maxDepth) n += nTmp if err != nil { - return n, fmt.Errorf("decoding BumpSequenceOp: %s", err) + return n, fmt.Errorf("decoding BumpSequenceOp: %w", err) } return n, nil case OperationTypeManageBuyOffer: u.ManageBuyOfferOp = new(ManageBuyOfferOp) - nTmp, err = (*u.ManageBuyOfferOp).DecodeFrom(d) + nTmp, err = (*u.ManageBuyOfferOp).DecodeFrom(d, maxDepth) n += nTmp if err != nil { - return n, fmt.Errorf("decoding ManageBuyOfferOp: %s", err) + return n, fmt.Errorf("decoding ManageBuyOfferOp: %w", err) } return n, nil case OperationTypePathPaymentStrictSend: u.PathPaymentStrictSendOp = new(PathPaymentStrictSendOp) - nTmp, err = (*u.PathPaymentStrictSendOp).DecodeFrom(d) + nTmp, err = (*u.PathPaymentStrictSendOp).DecodeFrom(d, maxDepth) n += nTmp if err != nil { - return n, fmt.Errorf("decoding PathPaymentStrictSendOp: %s", err) + return n, fmt.Errorf("decoding PathPaymentStrictSendOp: %w", err) } return n, nil case OperationTypeCreateClaimableBalance: u.CreateClaimableBalanceOp = new(CreateClaimableBalanceOp) - nTmp, err = (*u.CreateClaimableBalanceOp).DecodeFrom(d) + nTmp, err = (*u.CreateClaimableBalanceOp).DecodeFrom(d, maxDepth) n += nTmp if err != nil { - return n, fmt.Errorf("decoding CreateClaimableBalanceOp: %s", err) + return n, fmt.Errorf("decoding CreateClaimableBalanceOp: %w", err) } return n, nil case OperationTypeClaimClaimableBalance: u.ClaimClaimableBalanceOp = new(ClaimClaimableBalanceOp) - nTmp, err = (*u.ClaimClaimableBalanceOp).DecodeFrom(d) + nTmp, err = (*u.ClaimClaimableBalanceOp).DecodeFrom(d, maxDepth) n += nTmp if err != nil { - return n, fmt.Errorf("decoding ClaimClaimableBalanceOp: %s", err) + return n, fmt.Errorf("decoding ClaimClaimableBalanceOp: %w", err) } return n, nil case OperationTypeBeginSponsoringFutureReserves: u.BeginSponsoringFutureReservesOp = new(BeginSponsoringFutureReservesOp) - nTmp, err = (*u.BeginSponsoringFutureReservesOp).DecodeFrom(d) + nTmp, err = (*u.BeginSponsoringFutureReservesOp).DecodeFrom(d, maxDepth) n += nTmp if err != nil { - return n, fmt.Errorf("decoding BeginSponsoringFutureReservesOp: %s", err) + return n, fmt.Errorf("decoding BeginSponsoringFutureReservesOp: %w", err) } return n, nil case OperationTypeEndSponsoringFutureReserves: @@ -27362,74 +28045,74 @@ func (u *OperationBody) DecodeFrom(d *xdr.Decoder) (int, error) { return n, nil case OperationTypeRevokeSponsorship: u.RevokeSponsorshipOp = new(RevokeSponsorshipOp) - nTmp, err = (*u.RevokeSponsorshipOp).DecodeFrom(d) + nTmp, err = (*u.RevokeSponsorshipOp).DecodeFrom(d, maxDepth) n += nTmp if err != nil { - return n, fmt.Errorf("decoding RevokeSponsorshipOp: %s", err) + return n, fmt.Errorf("decoding RevokeSponsorshipOp: %w", err) } return n, nil case OperationTypeClawback: u.ClawbackOp = new(ClawbackOp) - nTmp, err = (*u.ClawbackOp).DecodeFrom(d) + nTmp, err = (*u.ClawbackOp).DecodeFrom(d, maxDepth) n += nTmp if err != nil { - return n, fmt.Errorf("decoding ClawbackOp: %s", err) + return n, fmt.Errorf("decoding ClawbackOp: %w", err) } return n, nil case OperationTypeClawbackClaimableBalance: u.ClawbackClaimableBalanceOp = new(ClawbackClaimableBalanceOp) - nTmp, err = (*u.ClawbackClaimableBalanceOp).DecodeFrom(d) + nTmp, err = (*u.ClawbackClaimableBalanceOp).DecodeFrom(d, maxDepth) n += nTmp if err != nil { - return n, fmt.Errorf("decoding ClawbackClaimableBalanceOp: %s", err) + return n, fmt.Errorf("decoding ClawbackClaimableBalanceOp: %w", err) } return n, nil case OperationTypeSetTrustLineFlags: u.SetTrustLineFlagsOp = new(SetTrustLineFlagsOp) - nTmp, err = (*u.SetTrustLineFlagsOp).DecodeFrom(d) + nTmp, err = (*u.SetTrustLineFlagsOp).DecodeFrom(d, maxDepth) n += nTmp if err != nil { - return n, fmt.Errorf("decoding SetTrustLineFlagsOp: %s", err) + return n, fmt.Errorf("decoding SetTrustLineFlagsOp: %w", err) } return n, nil case OperationTypeLiquidityPoolDeposit: u.LiquidityPoolDepositOp = new(LiquidityPoolDepositOp) - nTmp, err = (*u.LiquidityPoolDepositOp).DecodeFrom(d) + nTmp, err = (*u.LiquidityPoolDepositOp).DecodeFrom(d, maxDepth) n += nTmp if err != nil { - return n, fmt.Errorf("decoding LiquidityPoolDepositOp: %s", err) + return n, fmt.Errorf("decoding LiquidityPoolDepositOp: %w", err) } return n, nil case OperationTypeLiquidityPoolWithdraw: u.LiquidityPoolWithdrawOp = new(LiquidityPoolWithdrawOp) - nTmp, err = (*u.LiquidityPoolWithdrawOp).DecodeFrom(d) + nTmp, err = (*u.LiquidityPoolWithdrawOp).DecodeFrom(d, maxDepth) n += nTmp if err != nil { - return n, fmt.Errorf("decoding LiquidityPoolWithdrawOp: %s", err) + return n, fmt.Errorf("decoding LiquidityPoolWithdrawOp: %w", err) } return n, nil case OperationTypeInvokeHostFunction: u.InvokeHostFunctionOp = new(InvokeHostFunctionOp) - nTmp, err = (*u.InvokeHostFunctionOp).DecodeFrom(d) + nTmp, err = (*u.InvokeHostFunctionOp).DecodeFrom(d, maxDepth) n += nTmp if err != nil { - return n, fmt.Errorf("decoding InvokeHostFunctionOp: %s", err) + return n, fmt.Errorf("decoding InvokeHostFunctionOp: %w", err) } return n, nil - case OperationTypeBumpFootprintExpiration: - u.BumpFootprintExpirationOp = new(BumpFootprintExpirationOp) - nTmp, err = (*u.BumpFootprintExpirationOp).DecodeFrom(d) + case OperationTypeExtendFootprintTtl: + u.ExtendFootprintTtlOp = new(ExtendFootprintTtlOp) + nTmp, err = (*u.ExtendFootprintTtlOp).DecodeFrom(d, maxDepth) n += nTmp if err != nil { - return n, fmt.Errorf("decoding BumpFootprintExpirationOp: %s", err) + return n, fmt.Errorf("decoding ExtendFootprintTtlOp: %w", err) } return n, nil case OperationTypeRestoreFootprint: u.RestoreFootprintOp = new(RestoreFootprintOp) - nTmp, err = (*u.RestoreFootprintOp).DecodeFrom(d) + nTmp, err = (*u.RestoreFootprintOp).DecodeFrom(d, maxDepth) n += nTmp if err != nil { - return n, fmt.Errorf("decoding RestoreFootprintOp: %s", err) + return n, fmt.Errorf("decoding RestoreFootprintOp: %w", err) } return n, nil } @@ -27448,7 +28131,7 @@ func (s OperationBody) MarshalBinary() ([]byte, error) { func (s *OperationBody) UnmarshalBinary(inp []byte) error { r := bytes.NewReader(inp) d := xdr.NewDecoder(r) - _, err := s.DecodeFrom(d) + _, err := s.DecodeFrom(d, xdr.DecodeDefaultMaxDepth) return err } @@ -27524,8 +28207,8 @@ var _ xdrType = (*OperationBody)(nil) // LiquidityPoolWithdrawOp liquidityPoolWithdrawOp; // case INVOKE_HOST_FUNCTION: // InvokeHostFunctionOp invokeHostFunctionOp; -// case BUMP_FOOTPRINT_EXPIRATION: -// BumpFootprintExpirationOp bumpFootprintExpirationOp; +// case EXTEND_FOOTPRINT_TTL: +// ExtendFootprintTTLOp extendFootprintTTLOp; // case RESTORE_FOOTPRINT: // RestoreFootprintOp restoreFootprintOp; // } @@ -27556,28 +28239,32 @@ func (s *Operation) EncodeTo(e *xdr.Encoder) error { var _ decoderFrom = (*Operation)(nil) // DecodeFrom decodes this value using the Decoder. -func (s *Operation) DecodeFrom(d *xdr.Decoder) (int, error) { +func (s *Operation) DecodeFrom(d *xdr.Decoder, maxDepth uint) (int, error) { + if maxDepth == 0 { + return 0, fmt.Errorf("decoding Operation: %w", ErrMaxDecodingDepthReached) + } + maxDepth -= 1 var err error var n, nTmp int var b bool b, nTmp, err = d.DecodeBool() n += nTmp if err != nil { - return n, fmt.Errorf("decoding MuxedAccount: %s", err) + return n, fmt.Errorf("decoding MuxedAccount: %w", err) } s.SourceAccount = nil if b { s.SourceAccount = new(MuxedAccount) - nTmp, err = s.SourceAccount.DecodeFrom(d) + nTmp, err = s.SourceAccount.DecodeFrom(d, maxDepth) n += nTmp if err != nil { - return n, fmt.Errorf("decoding MuxedAccount: %s", err) + return n, fmt.Errorf("decoding MuxedAccount: %w", err) } } - nTmp, err = s.Body.DecodeFrom(d) + nTmp, err = s.Body.DecodeFrom(d, maxDepth) n += nTmp if err != nil { - return n, fmt.Errorf("decoding OperationBody: %s", err) + return n, fmt.Errorf("decoding OperationBody: %w", err) } return n, nil } @@ -27594,7 +28281,7 @@ func (s Operation) MarshalBinary() ([]byte, error) { func (s *Operation) UnmarshalBinary(inp []byte) error { r := bytes.NewReader(inp) d := xdr.NewDecoder(r) - _, err := s.DecodeFrom(d) + _, err := s.DecodeFrom(d, xdr.DecodeDefaultMaxDepth) return err } @@ -27641,23 +28328,27 @@ func (s *HashIdPreimageOperationId) EncodeTo(e *xdr.Encoder) error { var _ decoderFrom = (*HashIdPreimageOperationId)(nil) // DecodeFrom decodes this value using the Decoder. -func (s *HashIdPreimageOperationId) DecodeFrom(d *xdr.Decoder) (int, error) { +func (s *HashIdPreimageOperationId) DecodeFrom(d *xdr.Decoder, maxDepth uint) (int, error) { + if maxDepth == 0 { + return 0, fmt.Errorf("decoding HashIdPreimageOperationId: %w", ErrMaxDecodingDepthReached) + } + maxDepth -= 1 var err error var n, nTmp int - nTmp, err = s.SourceAccount.DecodeFrom(d) + nTmp, err = s.SourceAccount.DecodeFrom(d, maxDepth) n += nTmp if err != nil { - return n, fmt.Errorf("decoding AccountId: %s", err) + return n, fmt.Errorf("decoding AccountId: %w", err) } - nTmp, err = s.SeqNum.DecodeFrom(d) + nTmp, err = s.SeqNum.DecodeFrom(d, maxDepth) n += nTmp if err != nil { - return n, fmt.Errorf("decoding SequenceNumber: %s", err) + return n, fmt.Errorf("decoding SequenceNumber: %w", err) } - nTmp, err = s.OpNum.DecodeFrom(d) + nTmp, err = s.OpNum.DecodeFrom(d, maxDepth) n += nTmp if err != nil { - return n, fmt.Errorf("decoding Uint32: %s", err) + return n, fmt.Errorf("decoding Uint32: %w", err) } return n, nil } @@ -27674,7 +28365,7 @@ func (s HashIdPreimageOperationId) MarshalBinary() ([]byte, error) { func (s *HashIdPreimageOperationId) UnmarshalBinary(inp []byte) error { r := bytes.NewReader(inp) d := xdr.NewDecoder(r) - _, err := s.DecodeFrom(d) + _, err := s.DecodeFrom(d, xdr.DecodeDefaultMaxDepth) return err } @@ -27731,33 +28422,37 @@ func (s *HashIdPreimageRevokeId) EncodeTo(e *xdr.Encoder) error { var _ decoderFrom = (*HashIdPreimageRevokeId)(nil) // DecodeFrom decodes this value using the Decoder. -func (s *HashIdPreimageRevokeId) DecodeFrom(d *xdr.Decoder) (int, error) { +func (s *HashIdPreimageRevokeId) DecodeFrom(d *xdr.Decoder, maxDepth uint) (int, error) { + if maxDepth == 0 { + return 0, fmt.Errorf("decoding HashIdPreimageRevokeId: %w", ErrMaxDecodingDepthReached) + } + maxDepth -= 1 var err error var n, nTmp int - nTmp, err = s.SourceAccount.DecodeFrom(d) + nTmp, err = s.SourceAccount.DecodeFrom(d, maxDepth) n += nTmp if err != nil { - return n, fmt.Errorf("decoding AccountId: %s", err) + return n, fmt.Errorf("decoding AccountId: %w", err) } - nTmp, err = s.SeqNum.DecodeFrom(d) + nTmp, err = s.SeqNum.DecodeFrom(d, maxDepth) n += nTmp if err != nil { - return n, fmt.Errorf("decoding SequenceNumber: %s", err) + return n, fmt.Errorf("decoding SequenceNumber: %w", err) } - nTmp, err = s.OpNum.DecodeFrom(d) + nTmp, err = s.OpNum.DecodeFrom(d, maxDepth) n += nTmp if err != nil { - return n, fmt.Errorf("decoding Uint32: %s", err) + return n, fmt.Errorf("decoding Uint32: %w", err) } - nTmp, err = s.LiquidityPoolId.DecodeFrom(d) + nTmp, err = s.LiquidityPoolId.DecodeFrom(d, maxDepth) n += nTmp if err != nil { - return n, fmt.Errorf("decoding PoolId: %s", err) + return n, fmt.Errorf("decoding PoolId: %w", err) } - nTmp, err = s.Asset.DecodeFrom(d) + nTmp, err = s.Asset.DecodeFrom(d, maxDepth) n += nTmp if err != nil { - return n, fmt.Errorf("decoding Asset: %s", err) + return n, fmt.Errorf("decoding Asset: %w", err) } return n, nil } @@ -27774,7 +28469,7 @@ func (s HashIdPreimageRevokeId) MarshalBinary() ([]byte, error) { func (s *HashIdPreimageRevokeId) UnmarshalBinary(inp []byte) error { r := bytes.NewReader(inp) d := xdr.NewDecoder(r) - _, err := s.DecodeFrom(d) + _, err := s.DecodeFrom(d, xdr.DecodeDefaultMaxDepth) return err } @@ -27816,18 +28511,22 @@ func (s *HashIdPreimageContractId) EncodeTo(e *xdr.Encoder) error { var _ decoderFrom = (*HashIdPreimageContractId)(nil) // DecodeFrom decodes this value using the Decoder. -func (s *HashIdPreimageContractId) DecodeFrom(d *xdr.Decoder) (int, error) { +func (s *HashIdPreimageContractId) DecodeFrom(d *xdr.Decoder, maxDepth uint) (int, error) { + if maxDepth == 0 { + return 0, fmt.Errorf("decoding HashIdPreimageContractId: %w", ErrMaxDecodingDepthReached) + } + maxDepth -= 1 var err error var n, nTmp int - nTmp, err = s.NetworkId.DecodeFrom(d) + nTmp, err = s.NetworkId.DecodeFrom(d, maxDepth) n += nTmp if err != nil { - return n, fmt.Errorf("decoding Hash: %s", err) + return n, fmt.Errorf("decoding Hash: %w", err) } - nTmp, err = s.ContractIdPreimage.DecodeFrom(d) + nTmp, err = s.ContractIdPreimage.DecodeFrom(d, maxDepth) n += nTmp if err != nil { - return n, fmt.Errorf("decoding ContractIdPreimage: %s", err) + return n, fmt.Errorf("decoding ContractIdPreimage: %w", err) } return n, nil } @@ -27844,7 +28543,7 @@ func (s HashIdPreimageContractId) MarshalBinary() ([]byte, error) { func (s *HashIdPreimageContractId) UnmarshalBinary(inp []byte) error { r := bytes.NewReader(inp) d := xdr.NewDecoder(r) - _, err := s.DecodeFrom(d) + _, err := s.DecodeFrom(d, xdr.DecodeDefaultMaxDepth) return err } @@ -27896,28 +28595,32 @@ func (s *HashIdPreimageSorobanAuthorization) EncodeTo(e *xdr.Encoder) error { var _ decoderFrom = (*HashIdPreimageSorobanAuthorization)(nil) // DecodeFrom decodes this value using the Decoder. -func (s *HashIdPreimageSorobanAuthorization) DecodeFrom(d *xdr.Decoder) (int, error) { +func (s *HashIdPreimageSorobanAuthorization) DecodeFrom(d *xdr.Decoder, maxDepth uint) (int, error) { + if maxDepth == 0 { + return 0, fmt.Errorf("decoding HashIdPreimageSorobanAuthorization: %w", ErrMaxDecodingDepthReached) + } + maxDepth -= 1 var err error var n, nTmp int - nTmp, err = s.NetworkId.DecodeFrom(d) + nTmp, err = s.NetworkId.DecodeFrom(d, maxDepth) n += nTmp if err != nil { - return n, fmt.Errorf("decoding Hash: %s", err) + return n, fmt.Errorf("decoding Hash: %w", err) } - nTmp, err = s.Nonce.DecodeFrom(d) + nTmp, err = s.Nonce.DecodeFrom(d, maxDepth) n += nTmp if err != nil { - return n, fmt.Errorf("decoding Int64: %s", err) + return n, fmt.Errorf("decoding Int64: %w", err) } - nTmp, err = s.SignatureExpirationLedger.DecodeFrom(d) + nTmp, err = s.SignatureExpirationLedger.DecodeFrom(d, maxDepth) n += nTmp if err != nil { - return n, fmt.Errorf("decoding Uint32: %s", err) + return n, fmt.Errorf("decoding Uint32: %w", err) } - nTmp, err = s.Invocation.DecodeFrom(d) + nTmp, err = s.Invocation.DecodeFrom(d, maxDepth) n += nTmp if err != nil { - return n, fmt.Errorf("decoding SorobanAuthorizedInvocation: %s", err) + return n, fmt.Errorf("decoding SorobanAuthorizedInvocation: %w", err) } return n, nil } @@ -27934,7 +28637,7 @@ func (s HashIdPreimageSorobanAuthorization) MarshalBinary() ([]byte, error) { func (s *HashIdPreimageSorobanAuthorization) UnmarshalBinary(inp []byte) error { r := bytes.NewReader(inp) d := xdr.NewDecoder(r) - _, err := s.DecodeFrom(d) + _, err := s.DecodeFrom(d, xdr.DecodeDefaultMaxDepth) return err } @@ -28021,28 +28724,28 @@ func NewHashIdPreimage(aType EnvelopeType, value interface{}) (result HashIdPrei case EnvelopeTypeEnvelopeTypeOpId: tv, ok := value.(HashIdPreimageOperationId) if !ok { - err = fmt.Errorf("invalid value, must be HashIdPreimageOperationId") + err = errors.New("invalid value, must be HashIdPreimageOperationId") return } result.OperationId = &tv case EnvelopeTypeEnvelopeTypePoolRevokeOpId: tv, ok := value.(HashIdPreimageRevokeId) if !ok { - err = fmt.Errorf("invalid value, must be HashIdPreimageRevokeId") + err = errors.New("invalid value, must be HashIdPreimageRevokeId") return } result.RevokeId = &tv case EnvelopeTypeEnvelopeTypeContractId: tv, ok := value.(HashIdPreimageContractId) if !ok { - err = fmt.Errorf("invalid value, must be HashIdPreimageContractId") + err = errors.New("invalid value, must be HashIdPreimageContractId") return } result.ContractId = &tv case EnvelopeTypeEnvelopeTypeSorobanAuthorization: tv, ok := value.(HashIdPreimageSorobanAuthorization) if !ok { - err = fmt.Errorf("invalid value, must be HashIdPreimageSorobanAuthorization") + err = errors.New("invalid value, must be HashIdPreimageSorobanAuthorization") return } result.SorobanAuthorization = &tv @@ -28184,45 +28887,49 @@ func (u HashIdPreimage) EncodeTo(e *xdr.Encoder) error { var _ decoderFrom = (*HashIdPreimage)(nil) // DecodeFrom decodes this value using the Decoder. -func (u *HashIdPreimage) DecodeFrom(d *xdr.Decoder) (int, error) { +func (u *HashIdPreimage) DecodeFrom(d *xdr.Decoder, maxDepth uint) (int, error) { + if maxDepth == 0 { + return 0, fmt.Errorf("decoding HashIdPreimage: %w", ErrMaxDecodingDepthReached) + } + maxDepth -= 1 var err error var n, nTmp int - nTmp, err = u.Type.DecodeFrom(d) + nTmp, err = u.Type.DecodeFrom(d, maxDepth) n += nTmp if err != nil { - return n, fmt.Errorf("decoding EnvelopeType: %s", err) + return n, fmt.Errorf("decoding EnvelopeType: %w", err) } switch EnvelopeType(u.Type) { case EnvelopeTypeEnvelopeTypeOpId: u.OperationId = new(HashIdPreimageOperationId) - nTmp, err = (*u.OperationId).DecodeFrom(d) + nTmp, err = (*u.OperationId).DecodeFrom(d, maxDepth) n += nTmp if err != nil { - return n, fmt.Errorf("decoding HashIdPreimageOperationId: %s", err) + return n, fmt.Errorf("decoding HashIdPreimageOperationId: %w", err) } return n, nil case EnvelopeTypeEnvelopeTypePoolRevokeOpId: u.RevokeId = new(HashIdPreimageRevokeId) - nTmp, err = (*u.RevokeId).DecodeFrom(d) + nTmp, err = (*u.RevokeId).DecodeFrom(d, maxDepth) n += nTmp if err != nil { - return n, fmt.Errorf("decoding HashIdPreimageRevokeId: %s", err) + return n, fmt.Errorf("decoding HashIdPreimageRevokeId: %w", err) } return n, nil case EnvelopeTypeEnvelopeTypeContractId: u.ContractId = new(HashIdPreimageContractId) - nTmp, err = (*u.ContractId).DecodeFrom(d) + nTmp, err = (*u.ContractId).DecodeFrom(d, maxDepth) n += nTmp if err != nil { - return n, fmt.Errorf("decoding HashIdPreimageContractId: %s", err) + return n, fmt.Errorf("decoding HashIdPreimageContractId: %w", err) } return n, nil case EnvelopeTypeEnvelopeTypeSorobanAuthorization: u.SorobanAuthorization = new(HashIdPreimageSorobanAuthorization) - nTmp, err = (*u.SorobanAuthorization).DecodeFrom(d) + nTmp, err = (*u.SorobanAuthorization).DecodeFrom(d, maxDepth) n += nTmp if err != nil { - return n, fmt.Errorf("decoding HashIdPreimageSorobanAuthorization: %s", err) + return n, fmt.Errorf("decoding HashIdPreimageSorobanAuthorization: %w", err) } return n, nil } @@ -28241,7 +28948,7 @@ func (s HashIdPreimage) MarshalBinary() ([]byte, error) { func (s *HashIdPreimage) UnmarshalBinary(inp []byte) error { r := bytes.NewReader(inp) d := xdr.NewDecoder(r) - _, err := s.DecodeFrom(d) + _, err := s.DecodeFrom(d, xdr.DecodeDefaultMaxDepth) return err } @@ -28309,10 +29016,14 @@ func (e MemoType) EncodeTo(enc *xdr.Encoder) error { var _ decoderFrom = (*MemoType)(nil) // DecodeFrom decodes this value using the Decoder. -func (e *MemoType) DecodeFrom(d *xdr.Decoder) (int, error) { +func (e *MemoType) DecodeFrom(d *xdr.Decoder, maxDepth uint) (int, error) { + if maxDepth == 0 { + return 0, fmt.Errorf("decoding MemoType: %w", ErrMaxDecodingDepthReached) + } + maxDepth -= 1 v, n, err := d.DecodeInt() if err != nil { - return n, fmt.Errorf("decoding MemoType: %s", err) + return n, fmt.Errorf("decoding MemoType: %w", err) } if _, ok := memoTypeMap[v]; !ok { return n, fmt.Errorf("'%d' is not a valid MemoType enum value", v) @@ -28333,7 +29044,7 @@ func (s MemoType) MarshalBinary() ([]byte, error) { func (s *MemoType) UnmarshalBinary(inp []byte) error { r := bytes.NewReader(inp) d := xdr.NewDecoder(r) - _, err := s.DecodeFrom(d) + _, err := s.DecodeFrom(d, xdr.DecodeDefaultMaxDepth) return err } @@ -28404,28 +29115,28 @@ func NewMemo(aType MemoType, value interface{}) (result Memo, err error) { case MemoTypeMemoText: tv, ok := value.(string) if !ok { - err = fmt.Errorf("invalid value, must be string") + err = errors.New("invalid value, must be string") return } result.Text = &tv case MemoTypeMemoId: tv, ok := value.(Uint64) if !ok { - err = fmt.Errorf("invalid value, must be Uint64") + err = errors.New("invalid value, must be Uint64") return } result.Id = &tv case MemoTypeMemoHash: tv, ok := value.(Hash) if !ok { - err = fmt.Errorf("invalid value, must be Hash") + err = errors.New("invalid value, must be Hash") return } result.Hash = &tv case MemoTypeMemoReturn: tv, ok := value.(Hash) if !ok { - err = fmt.Errorf("invalid value, must be Hash") + err = errors.New("invalid value, must be Hash") return } result.RetHash = &tv @@ -28570,13 +29281,17 @@ func (u Memo) EncodeTo(e *xdr.Encoder) error { var _ decoderFrom = (*Memo)(nil) // DecodeFrom decodes this value using the Decoder. -func (u *Memo) DecodeFrom(d *xdr.Decoder) (int, error) { +func (u *Memo) DecodeFrom(d *xdr.Decoder, maxDepth uint) (int, error) { + if maxDepth == 0 { + return 0, fmt.Errorf("decoding Memo: %w", ErrMaxDecodingDepthReached) + } + maxDepth -= 1 var err error var n, nTmp int - nTmp, err = u.Type.DecodeFrom(d) + nTmp, err = u.Type.DecodeFrom(d, maxDepth) n += nTmp if err != nil { - return n, fmt.Errorf("decoding MemoType: %s", err) + return n, fmt.Errorf("decoding MemoType: %w", err) } switch MemoType(u.Type) { case MemoTypeMemoNone: @@ -28587,31 +29302,31 @@ func (u *Memo) DecodeFrom(d *xdr.Decoder) (int, error) { (*u.Text), nTmp, err = d.DecodeString(28) n += nTmp if err != nil { - return n, fmt.Errorf("decoding Text: %s", err) + return n, fmt.Errorf("decoding Text: %w", err) } return n, nil case MemoTypeMemoId: u.Id = new(Uint64) - nTmp, err = (*u.Id).DecodeFrom(d) + nTmp, err = (*u.Id).DecodeFrom(d, maxDepth) n += nTmp if err != nil { - return n, fmt.Errorf("decoding Uint64: %s", err) + return n, fmt.Errorf("decoding Uint64: %w", err) } return n, nil case MemoTypeMemoHash: u.Hash = new(Hash) - nTmp, err = (*u.Hash).DecodeFrom(d) + nTmp, err = (*u.Hash).DecodeFrom(d, maxDepth) n += nTmp if err != nil { - return n, fmt.Errorf("decoding Hash: %s", err) + return n, fmt.Errorf("decoding Hash: %w", err) } return n, nil case MemoTypeMemoReturn: u.RetHash = new(Hash) - nTmp, err = (*u.RetHash).DecodeFrom(d) + nTmp, err = (*u.RetHash).DecodeFrom(d, maxDepth) n += nTmp if err != nil { - return n, fmt.Errorf("decoding Hash: %s", err) + return n, fmt.Errorf("decoding Hash: %w", err) } return n, nil } @@ -28630,7 +29345,7 @@ func (s Memo) MarshalBinary() ([]byte, error) { func (s *Memo) UnmarshalBinary(inp []byte) error { r := bytes.NewReader(inp) d := xdr.NewDecoder(r) - _, err := s.DecodeFrom(d) + _, err := s.DecodeFrom(d, xdr.DecodeDefaultMaxDepth) return err } @@ -28672,18 +29387,22 @@ func (s *TimeBounds) EncodeTo(e *xdr.Encoder) error { var _ decoderFrom = (*TimeBounds)(nil) // DecodeFrom decodes this value using the Decoder. -func (s *TimeBounds) DecodeFrom(d *xdr.Decoder) (int, error) { +func (s *TimeBounds) DecodeFrom(d *xdr.Decoder, maxDepth uint) (int, error) { + if maxDepth == 0 { + return 0, fmt.Errorf("decoding TimeBounds: %w", ErrMaxDecodingDepthReached) + } + maxDepth -= 1 var err error var n, nTmp int - nTmp, err = s.MinTime.DecodeFrom(d) + nTmp, err = s.MinTime.DecodeFrom(d, maxDepth) n += nTmp if err != nil { - return n, fmt.Errorf("decoding TimePoint: %s", err) + return n, fmt.Errorf("decoding TimePoint: %w", err) } - nTmp, err = s.MaxTime.DecodeFrom(d) + nTmp, err = s.MaxTime.DecodeFrom(d, maxDepth) n += nTmp if err != nil { - return n, fmt.Errorf("decoding TimePoint: %s", err) + return n, fmt.Errorf("decoding TimePoint: %w", err) } return n, nil } @@ -28700,7 +29419,7 @@ func (s TimeBounds) MarshalBinary() ([]byte, error) { func (s *TimeBounds) UnmarshalBinary(inp []byte) error { r := bytes.NewReader(inp) d := xdr.NewDecoder(r) - _, err := s.DecodeFrom(d) + _, err := s.DecodeFrom(d, xdr.DecodeDefaultMaxDepth) return err } @@ -28742,18 +29461,22 @@ func (s *LedgerBounds) EncodeTo(e *xdr.Encoder) error { var _ decoderFrom = (*LedgerBounds)(nil) // DecodeFrom decodes this value using the Decoder. -func (s *LedgerBounds) DecodeFrom(d *xdr.Decoder) (int, error) { +func (s *LedgerBounds) DecodeFrom(d *xdr.Decoder, maxDepth uint) (int, error) { + if maxDepth == 0 { + return 0, fmt.Errorf("decoding LedgerBounds: %w", ErrMaxDecodingDepthReached) + } + maxDepth -= 1 var err error var n, nTmp int - nTmp, err = s.MinLedger.DecodeFrom(d) + nTmp, err = s.MinLedger.DecodeFrom(d, maxDepth) n += nTmp if err != nil { - return n, fmt.Errorf("decoding Uint32: %s", err) + return n, fmt.Errorf("decoding Uint32: %w", err) } - nTmp, err = s.MaxLedger.DecodeFrom(d) + nTmp, err = s.MaxLedger.DecodeFrom(d, maxDepth) n += nTmp if err != nil { - return n, fmt.Errorf("decoding Uint32: %s", err) + return n, fmt.Errorf("decoding Uint32: %w", err) } return n, nil } @@ -28770,7 +29493,7 @@ func (s LedgerBounds) MarshalBinary() ([]byte, error) { func (s *LedgerBounds) UnmarshalBinary(inp []byte) error { r := bytes.NewReader(inp) d := xdr.NewDecoder(r) - _, err := s.DecodeFrom(d) + _, err := s.DecodeFrom(d, xdr.DecodeDefaultMaxDepth) return err } @@ -28875,67 +29598,71 @@ func (s *PreconditionsV2) EncodeTo(e *xdr.Encoder) error { var _ decoderFrom = (*PreconditionsV2)(nil) // DecodeFrom decodes this value using the Decoder. -func (s *PreconditionsV2) DecodeFrom(d *xdr.Decoder) (int, error) { +func (s *PreconditionsV2) DecodeFrom(d *xdr.Decoder, maxDepth uint) (int, error) { + if maxDepth == 0 { + return 0, fmt.Errorf("decoding PreconditionsV2: %w", ErrMaxDecodingDepthReached) + } + maxDepth -= 1 var err error var n, nTmp int var b bool b, nTmp, err = d.DecodeBool() n += nTmp if err != nil { - return n, fmt.Errorf("decoding TimeBounds: %s", err) + return n, fmt.Errorf("decoding TimeBounds: %w", err) } s.TimeBounds = nil if b { s.TimeBounds = new(TimeBounds) - nTmp, err = s.TimeBounds.DecodeFrom(d) + nTmp, err = s.TimeBounds.DecodeFrom(d, maxDepth) n += nTmp if err != nil { - return n, fmt.Errorf("decoding TimeBounds: %s", err) + return n, fmt.Errorf("decoding TimeBounds: %w", err) } } b, nTmp, err = d.DecodeBool() n += nTmp if err != nil { - return n, fmt.Errorf("decoding LedgerBounds: %s", err) + return n, fmt.Errorf("decoding LedgerBounds: %w", err) } s.LedgerBounds = nil if b { s.LedgerBounds = new(LedgerBounds) - nTmp, err = s.LedgerBounds.DecodeFrom(d) + nTmp, err = s.LedgerBounds.DecodeFrom(d, maxDepth) n += nTmp if err != nil { - return n, fmt.Errorf("decoding LedgerBounds: %s", err) + return n, fmt.Errorf("decoding LedgerBounds: %w", err) } } b, nTmp, err = d.DecodeBool() n += nTmp if err != nil { - return n, fmt.Errorf("decoding SequenceNumber: %s", err) + return n, fmt.Errorf("decoding SequenceNumber: %w", err) } s.MinSeqNum = nil if b { s.MinSeqNum = new(SequenceNumber) - nTmp, err = s.MinSeqNum.DecodeFrom(d) + nTmp, err = s.MinSeqNum.DecodeFrom(d, maxDepth) n += nTmp if err != nil { - return n, fmt.Errorf("decoding SequenceNumber: %s", err) + return n, fmt.Errorf("decoding SequenceNumber: %w", err) } } - nTmp, err = s.MinSeqAge.DecodeFrom(d) + nTmp, err = s.MinSeqAge.DecodeFrom(d, maxDepth) n += nTmp if err != nil { - return n, fmt.Errorf("decoding Duration: %s", err) + return n, fmt.Errorf("decoding Duration: %w", err) } - nTmp, err = s.MinSeqLedgerGap.DecodeFrom(d) + nTmp, err = s.MinSeqLedgerGap.DecodeFrom(d, maxDepth) n += nTmp if err != nil { - return n, fmt.Errorf("decoding Uint32: %s", err) + return n, fmt.Errorf("decoding Uint32: %w", err) } var l uint32 l, nTmp, err = d.DecodeUint() n += nTmp if err != nil { - return n, fmt.Errorf("decoding SignerKey: %s", err) + return n, fmt.Errorf("decoding SignerKey: %w", err) } if l > 2 { return n, fmt.Errorf("decoding SignerKey: data size (%d) exceeds size limit (2)", l) @@ -28944,10 +29671,10 @@ func (s *PreconditionsV2) DecodeFrom(d *xdr.Decoder) (int, error) { if l > 0 { s.ExtraSigners = make([]SignerKey, l) for i := uint32(0); i < l; i++ { - nTmp, err = s.ExtraSigners[i].DecodeFrom(d) + nTmp, err = s.ExtraSigners[i].DecodeFrom(d, maxDepth) n += nTmp if err != nil { - return n, fmt.Errorf("decoding SignerKey: %s", err) + return n, fmt.Errorf("decoding SignerKey: %w", err) } } } @@ -28966,7 +29693,7 @@ func (s PreconditionsV2) MarshalBinary() ([]byte, error) { func (s *PreconditionsV2) UnmarshalBinary(inp []byte) error { r := bytes.NewReader(inp) d := xdr.NewDecoder(r) - _, err := s.DecodeFrom(d) + _, err := s.DecodeFrom(d, xdr.DecodeDefaultMaxDepth) return err } @@ -29028,10 +29755,14 @@ func (e PreconditionType) EncodeTo(enc *xdr.Encoder) error { var _ decoderFrom = (*PreconditionType)(nil) // DecodeFrom decodes this value using the Decoder. -func (e *PreconditionType) DecodeFrom(d *xdr.Decoder) (int, error) { +func (e *PreconditionType) DecodeFrom(d *xdr.Decoder, maxDepth uint) (int, error) { + if maxDepth == 0 { + return 0, fmt.Errorf("decoding PreconditionType: %w", ErrMaxDecodingDepthReached) + } + maxDepth -= 1 v, n, err := d.DecodeInt() if err != nil { - return n, fmt.Errorf("decoding PreconditionType: %s", err) + return n, fmt.Errorf("decoding PreconditionType: %w", err) } if _, ok := preconditionTypeMap[v]; !ok { return n, fmt.Errorf("'%d' is not a valid PreconditionType enum value", v) @@ -29052,7 +29783,7 @@ func (s PreconditionType) MarshalBinary() ([]byte, error) { func (s *PreconditionType) UnmarshalBinary(inp []byte) error { r := bytes.NewReader(inp) d := xdr.NewDecoder(r) - _, err := s.DecodeFrom(d) + _, err := s.DecodeFrom(d, xdr.DecodeDefaultMaxDepth) return err } @@ -29113,14 +29844,14 @@ func NewPreconditions(aType PreconditionType, value interface{}) (result Precond case PreconditionTypePrecondTime: tv, ok := value.(TimeBounds) if !ok { - err = fmt.Errorf("invalid value, must be TimeBounds") + err = errors.New("invalid value, must be TimeBounds") return } result.TimeBounds = &tv case PreconditionTypePrecondV2: tv, ok := value.(PreconditionsV2) if !ok { - err = fmt.Errorf("invalid value, must be PreconditionsV2") + err = errors.New("invalid value, must be PreconditionsV2") return } result.V2 = &tv @@ -29205,13 +29936,17 @@ func (u Preconditions) EncodeTo(e *xdr.Encoder) error { var _ decoderFrom = (*Preconditions)(nil) // DecodeFrom decodes this value using the Decoder. -func (u *Preconditions) DecodeFrom(d *xdr.Decoder) (int, error) { +func (u *Preconditions) DecodeFrom(d *xdr.Decoder, maxDepth uint) (int, error) { + if maxDepth == 0 { + return 0, fmt.Errorf("decoding Preconditions: %w", ErrMaxDecodingDepthReached) + } + maxDepth -= 1 var err error var n, nTmp int - nTmp, err = u.Type.DecodeFrom(d) + nTmp, err = u.Type.DecodeFrom(d, maxDepth) n += nTmp if err != nil { - return n, fmt.Errorf("decoding PreconditionType: %s", err) + return n, fmt.Errorf("decoding PreconditionType: %w", err) } switch PreconditionType(u.Type) { case PreconditionTypePrecondNone: @@ -29219,18 +29954,18 @@ func (u *Preconditions) DecodeFrom(d *xdr.Decoder) (int, error) { return n, nil case PreconditionTypePrecondTime: u.TimeBounds = new(TimeBounds) - nTmp, err = (*u.TimeBounds).DecodeFrom(d) + nTmp, err = (*u.TimeBounds).DecodeFrom(d, maxDepth) n += nTmp if err != nil { - return n, fmt.Errorf("decoding TimeBounds: %s", err) + return n, fmt.Errorf("decoding TimeBounds: %w", err) } return n, nil case PreconditionTypePrecondV2: u.V2 = new(PreconditionsV2) - nTmp, err = (*u.V2).DecodeFrom(d) + nTmp, err = (*u.V2).DecodeFrom(d, maxDepth) n += nTmp if err != nil { - return n, fmt.Errorf("decoding PreconditionsV2: %s", err) + return n, fmt.Errorf("decoding PreconditionsV2: %w", err) } return n, nil } @@ -29249,7 +29984,7 @@ func (s Preconditions) MarshalBinary() ([]byte, error) { func (s *Preconditions) UnmarshalBinary(inp []byte) error { r := bytes.NewReader(inp) d := xdr.NewDecoder(r) - _, err := s.DecodeFrom(d) + _, err := s.DecodeFrom(d, xdr.DecodeDefaultMaxDepth) return err } @@ -29301,39 +30036,43 @@ func (s *LedgerFootprint) EncodeTo(e *xdr.Encoder) error { var _ decoderFrom = (*LedgerFootprint)(nil) // DecodeFrom decodes this value using the Decoder. -func (s *LedgerFootprint) DecodeFrom(d *xdr.Decoder) (int, error) { +func (s *LedgerFootprint) DecodeFrom(d *xdr.Decoder, maxDepth uint) (int, error) { + if maxDepth == 0 { + return 0, fmt.Errorf("decoding LedgerFootprint: %w", ErrMaxDecodingDepthReached) + } + maxDepth -= 1 var err error var n, nTmp int var l uint32 l, nTmp, err = d.DecodeUint() n += nTmp if err != nil { - return n, fmt.Errorf("decoding LedgerKey: %s", err) + return n, fmt.Errorf("decoding LedgerKey: %w", err) } s.ReadOnly = nil if l > 0 { s.ReadOnly = make([]LedgerKey, l) for i := uint32(0); i < l; i++ { - nTmp, err = s.ReadOnly[i].DecodeFrom(d) + nTmp, err = s.ReadOnly[i].DecodeFrom(d, maxDepth) n += nTmp if err != nil { - return n, fmt.Errorf("decoding LedgerKey: %s", err) + return n, fmt.Errorf("decoding LedgerKey: %w", err) } } } l, nTmp, err = d.DecodeUint() n += nTmp if err != nil { - return n, fmt.Errorf("decoding LedgerKey: %s", err) + return n, fmt.Errorf("decoding LedgerKey: %w", err) } s.ReadWrite = nil if l > 0 { s.ReadWrite = make([]LedgerKey, l) for i := uint32(0); i < l; i++ { - nTmp, err = s.ReadWrite[i].DecodeFrom(d) + nTmp, err = s.ReadWrite[i].DecodeFrom(d, maxDepth) n += nTmp if err != nil { - return n, fmt.Errorf("decoding LedgerKey: %s", err) + return n, fmt.Errorf("decoding LedgerKey: %w", err) } } } @@ -29352,7 +30091,7 @@ func (s LedgerFootprint) MarshalBinary() ([]byte, error) { func (s *LedgerFootprint) UnmarshalBinary(inp []byte) error { r := bytes.NewReader(inp) d := xdr.NewDecoder(r) - _, err := s.DecodeFrom(d) + _, err := s.DecodeFrom(d, xdr.DecodeDefaultMaxDepth) return err } @@ -29409,28 +30148,32 @@ func (s *SorobanResources) EncodeTo(e *xdr.Encoder) error { var _ decoderFrom = (*SorobanResources)(nil) // DecodeFrom decodes this value using the Decoder. -func (s *SorobanResources) DecodeFrom(d *xdr.Decoder) (int, error) { +func (s *SorobanResources) DecodeFrom(d *xdr.Decoder, maxDepth uint) (int, error) { + if maxDepth == 0 { + return 0, fmt.Errorf("decoding SorobanResources: %w", ErrMaxDecodingDepthReached) + } + maxDepth -= 1 var err error var n, nTmp int - nTmp, err = s.Footprint.DecodeFrom(d) + nTmp, err = s.Footprint.DecodeFrom(d, maxDepth) n += nTmp if err != nil { - return n, fmt.Errorf("decoding LedgerFootprint: %s", err) + return n, fmt.Errorf("decoding LedgerFootprint: %w", err) } - nTmp, err = s.Instructions.DecodeFrom(d) + nTmp, err = s.Instructions.DecodeFrom(d, maxDepth) n += nTmp if err != nil { - return n, fmt.Errorf("decoding Uint32: %s", err) + return n, fmt.Errorf("decoding Uint32: %w", err) } - nTmp, err = s.ReadBytes.DecodeFrom(d) + nTmp, err = s.ReadBytes.DecodeFrom(d, maxDepth) n += nTmp if err != nil { - return n, fmt.Errorf("decoding Uint32: %s", err) + return n, fmt.Errorf("decoding Uint32: %w", err) } - nTmp, err = s.WriteBytes.DecodeFrom(d) + nTmp, err = s.WriteBytes.DecodeFrom(d, maxDepth) n += nTmp if err != nil { - return n, fmt.Errorf("decoding Uint32: %s", err) + return n, fmt.Errorf("decoding Uint32: %w", err) } return n, nil } @@ -29447,7 +30190,7 @@ func (s SorobanResources) MarshalBinary() ([]byte, error) { func (s *SorobanResources) UnmarshalBinary(inp []byte) error { r := bytes.NewReader(inp) d := xdr.NewDecoder(r) - _, err := s.DecodeFrom(d) + _, err := s.DecodeFrom(d, xdr.DecodeDefaultMaxDepth) return err } @@ -29468,13 +30211,21 @@ var _ xdrType = (*SorobanResources)(nil) // { // ExtensionPoint ext; // SorobanResources resources; -// // Portion of transaction `fee` allocated to refundable fees. -// int64 refundableFee; +// // Amount of the transaction `fee` allocated to the Soroban resource fees. +// // The fraction of `resourceFee` corresponding to `resources` specified +// // above is *not* refundable (i.e. fees for instructions, ledger I/O), as +// // well as fees for the transaction size. +// // The remaining part of the fee is refundable and the charged value is +// // based on the actual consumption of refundable resources (events, ledger +// // rent bumps). +// // The `inclusionFee` used for prioritization of the transaction is defined +// // as `tx.fee - resourceFee`. +// int64 resourceFee; // }; type SorobanTransactionData struct { - Ext ExtensionPoint - Resources SorobanResources - RefundableFee Int64 + Ext ExtensionPoint + Resources SorobanResources + ResourceFee Int64 } // EncodeTo encodes this value using the Encoder. @@ -29486,7 +30237,7 @@ func (s *SorobanTransactionData) EncodeTo(e *xdr.Encoder) error { if err = s.Resources.EncodeTo(e); err != nil { return err } - if err = s.RefundableFee.EncodeTo(e); err != nil { + if err = s.ResourceFee.EncodeTo(e); err != nil { return err } return nil @@ -29495,23 +30246,27 @@ func (s *SorobanTransactionData) EncodeTo(e *xdr.Encoder) error { var _ decoderFrom = (*SorobanTransactionData)(nil) // DecodeFrom decodes this value using the Decoder. -func (s *SorobanTransactionData) DecodeFrom(d *xdr.Decoder) (int, error) { +func (s *SorobanTransactionData) DecodeFrom(d *xdr.Decoder, maxDepth uint) (int, error) { + if maxDepth == 0 { + return 0, fmt.Errorf("decoding SorobanTransactionData: %w", ErrMaxDecodingDepthReached) + } + maxDepth -= 1 var err error var n, nTmp int - nTmp, err = s.Ext.DecodeFrom(d) + nTmp, err = s.Ext.DecodeFrom(d, maxDepth) n += nTmp if err != nil { - return n, fmt.Errorf("decoding ExtensionPoint: %s", err) + return n, fmt.Errorf("decoding ExtensionPoint: %w", err) } - nTmp, err = s.Resources.DecodeFrom(d) + nTmp, err = s.Resources.DecodeFrom(d, maxDepth) n += nTmp if err != nil { - return n, fmt.Errorf("decoding SorobanResources: %s", err) + return n, fmt.Errorf("decoding SorobanResources: %w", err) } - nTmp, err = s.RefundableFee.DecodeFrom(d) + nTmp, err = s.ResourceFee.DecodeFrom(d, maxDepth) n += nTmp if err != nil { - return n, fmt.Errorf("decoding Int64: %s", err) + return n, fmt.Errorf("decoding Int64: %w", err) } return n, nil } @@ -29528,7 +30283,7 @@ func (s SorobanTransactionData) MarshalBinary() ([]byte, error) { func (s *SorobanTransactionData) UnmarshalBinary(inp []byte) error { r := bytes.NewReader(inp) d := xdr.NewDecoder(r) - _, err := s.DecodeFrom(d) + _, err := s.DecodeFrom(d, xdr.DecodeDefaultMaxDepth) return err } @@ -29597,13 +30352,17 @@ func (u TransactionV0Ext) EncodeTo(e *xdr.Encoder) error { var _ decoderFrom = (*TransactionV0Ext)(nil) // DecodeFrom decodes this value using the Decoder. -func (u *TransactionV0Ext) DecodeFrom(d *xdr.Decoder) (int, error) { +func (u *TransactionV0Ext) DecodeFrom(d *xdr.Decoder, maxDepth uint) (int, error) { + if maxDepth == 0 { + return 0, fmt.Errorf("decoding TransactionV0Ext: %w", ErrMaxDecodingDepthReached) + } + maxDepth -= 1 var err error var n, nTmp int u.V, nTmp, err = d.DecodeInt() n += nTmp if err != nil { - return n, fmt.Errorf("decoding Int: %s", err) + return n, fmt.Errorf("decoding Int: %w", err) } switch int32(u.V) { case 0: @@ -29625,7 +30384,7 @@ func (s TransactionV0Ext) MarshalBinary() ([]byte, error) { func (s *TransactionV0Ext) UnmarshalBinary(inp []byte) error { r := bytes.NewReader(inp) d := xdr.NewDecoder(r) - _, err := s.DecodeFrom(d) + _, err := s.DecodeFrom(d, xdr.DecodeDefaultMaxDepth) return err } @@ -29707,49 +30466,53 @@ func (s *TransactionV0) EncodeTo(e *xdr.Encoder) error { var _ decoderFrom = (*TransactionV0)(nil) // DecodeFrom decodes this value using the Decoder. -func (s *TransactionV0) DecodeFrom(d *xdr.Decoder) (int, error) { +func (s *TransactionV0) DecodeFrom(d *xdr.Decoder, maxDepth uint) (int, error) { + if maxDepth == 0 { + return 0, fmt.Errorf("decoding TransactionV0: %w", ErrMaxDecodingDepthReached) + } + maxDepth -= 1 var err error var n, nTmp int - nTmp, err = s.SourceAccountEd25519.DecodeFrom(d) + nTmp, err = s.SourceAccountEd25519.DecodeFrom(d, maxDepth) n += nTmp if err != nil { - return n, fmt.Errorf("decoding Uint256: %s", err) + return n, fmt.Errorf("decoding Uint256: %w", err) } - nTmp, err = s.Fee.DecodeFrom(d) + nTmp, err = s.Fee.DecodeFrom(d, maxDepth) n += nTmp if err != nil { - return n, fmt.Errorf("decoding Uint32: %s", err) + return n, fmt.Errorf("decoding Uint32: %w", err) } - nTmp, err = s.SeqNum.DecodeFrom(d) + nTmp, err = s.SeqNum.DecodeFrom(d, maxDepth) n += nTmp if err != nil { - return n, fmt.Errorf("decoding SequenceNumber: %s", err) + return n, fmt.Errorf("decoding SequenceNumber: %w", err) } var b bool b, nTmp, err = d.DecodeBool() n += nTmp if err != nil { - return n, fmt.Errorf("decoding TimeBounds: %s", err) + return n, fmt.Errorf("decoding TimeBounds: %w", err) } s.TimeBounds = nil if b { s.TimeBounds = new(TimeBounds) - nTmp, err = s.TimeBounds.DecodeFrom(d) + nTmp, err = s.TimeBounds.DecodeFrom(d, maxDepth) n += nTmp if err != nil { - return n, fmt.Errorf("decoding TimeBounds: %s", err) + return n, fmt.Errorf("decoding TimeBounds: %w", err) } } - nTmp, err = s.Memo.DecodeFrom(d) + nTmp, err = s.Memo.DecodeFrom(d, maxDepth) n += nTmp if err != nil { - return n, fmt.Errorf("decoding Memo: %s", err) + return n, fmt.Errorf("decoding Memo: %w", err) } var l uint32 l, nTmp, err = d.DecodeUint() n += nTmp if err != nil { - return n, fmt.Errorf("decoding Operation: %s", err) + return n, fmt.Errorf("decoding Operation: %w", err) } if l > 100 { return n, fmt.Errorf("decoding Operation: data size (%d) exceeds size limit (100)", l) @@ -29758,17 +30521,17 @@ func (s *TransactionV0) DecodeFrom(d *xdr.Decoder) (int, error) { if l > 0 { s.Operations = make([]Operation, l) for i := uint32(0); i < l; i++ { - nTmp, err = s.Operations[i].DecodeFrom(d) + nTmp, err = s.Operations[i].DecodeFrom(d, maxDepth) n += nTmp if err != nil { - return n, fmt.Errorf("decoding Operation: %s", err) + return n, fmt.Errorf("decoding Operation: %w", err) } } } - nTmp, err = s.Ext.DecodeFrom(d) + nTmp, err = s.Ext.DecodeFrom(d, maxDepth) n += nTmp if err != nil { - return n, fmt.Errorf("decoding TransactionV0Ext: %s", err) + return n, fmt.Errorf("decoding TransactionV0Ext: %w", err) } return n, nil } @@ -29785,7 +30548,7 @@ func (s TransactionV0) MarshalBinary() ([]byte, error) { func (s *TransactionV0) UnmarshalBinary(inp []byte) error { r := bytes.NewReader(inp) d := xdr.NewDecoder(r) - _, err := s.DecodeFrom(d) + _, err := s.DecodeFrom(d, xdr.DecodeDefaultMaxDepth) return err } @@ -29834,19 +30597,23 @@ func (s *TransactionV0Envelope) EncodeTo(e *xdr.Encoder) error { var _ decoderFrom = (*TransactionV0Envelope)(nil) // DecodeFrom decodes this value using the Decoder. -func (s *TransactionV0Envelope) DecodeFrom(d *xdr.Decoder) (int, error) { +func (s *TransactionV0Envelope) DecodeFrom(d *xdr.Decoder, maxDepth uint) (int, error) { + if maxDepth == 0 { + return 0, fmt.Errorf("decoding TransactionV0Envelope: %w", ErrMaxDecodingDepthReached) + } + maxDepth -= 1 var err error var n, nTmp int - nTmp, err = s.Tx.DecodeFrom(d) + nTmp, err = s.Tx.DecodeFrom(d, maxDepth) n += nTmp if err != nil { - return n, fmt.Errorf("decoding TransactionV0: %s", err) + return n, fmt.Errorf("decoding TransactionV0: %w", err) } var l uint32 l, nTmp, err = d.DecodeUint() n += nTmp if err != nil { - return n, fmt.Errorf("decoding DecoratedSignature: %s", err) + return n, fmt.Errorf("decoding DecoratedSignature: %w", err) } if l > 20 { return n, fmt.Errorf("decoding DecoratedSignature: data size (%d) exceeds size limit (20)", l) @@ -29855,10 +30622,10 @@ func (s *TransactionV0Envelope) DecodeFrom(d *xdr.Decoder) (int, error) { if l > 0 { s.Signatures = make([]DecoratedSignature, l) for i := uint32(0); i < l; i++ { - nTmp, err = s.Signatures[i].DecodeFrom(d) + nTmp, err = s.Signatures[i].DecodeFrom(d, maxDepth) n += nTmp if err != nil { - return n, fmt.Errorf("decoding DecoratedSignature: %s", err) + return n, fmt.Errorf("decoding DecoratedSignature: %w", err) } } } @@ -29877,7 +30644,7 @@ func (s TransactionV0Envelope) MarshalBinary() ([]byte, error) { func (s *TransactionV0Envelope) UnmarshalBinary(inp []byte) error { r := bytes.NewReader(inp) d := xdr.NewDecoder(r) - _, err := s.DecodeFrom(d) + _, err := s.DecodeFrom(d, xdr.DecodeDefaultMaxDepth) return err } @@ -29933,7 +30700,7 @@ func NewTransactionExt(v int32, value interface{}) (result TransactionExt, err e case 1: tv, ok := value.(SorobanTransactionData) if !ok { - err = fmt.Errorf("invalid value, must be SorobanTransactionData") + err = errors.New("invalid value, must be SorobanTransactionData") return } result.SorobanData = &tv @@ -29988,13 +30755,17 @@ func (u TransactionExt) EncodeTo(e *xdr.Encoder) error { var _ decoderFrom = (*TransactionExt)(nil) // DecodeFrom decodes this value using the Decoder. -func (u *TransactionExt) DecodeFrom(d *xdr.Decoder) (int, error) { +func (u *TransactionExt) DecodeFrom(d *xdr.Decoder, maxDepth uint) (int, error) { + if maxDepth == 0 { + return 0, fmt.Errorf("decoding TransactionExt: %w", ErrMaxDecodingDepthReached) + } + maxDepth -= 1 var err error var n, nTmp int u.V, nTmp, err = d.DecodeInt() n += nTmp if err != nil { - return n, fmt.Errorf("decoding Int: %s", err) + return n, fmt.Errorf("decoding Int: %w", err) } switch int32(u.V) { case 0: @@ -30002,10 +30773,10 @@ func (u *TransactionExt) DecodeFrom(d *xdr.Decoder) (int, error) { return n, nil case 1: u.SorobanData = new(SorobanTransactionData) - nTmp, err = (*u.SorobanData).DecodeFrom(d) + nTmp, err = (*u.SorobanData).DecodeFrom(d, maxDepth) n += nTmp if err != nil { - return n, fmt.Errorf("decoding SorobanTransactionData: %s", err) + return n, fmt.Errorf("decoding SorobanTransactionData: %w", err) } return n, nil } @@ -30024,7 +30795,7 @@ func (s TransactionExt) MarshalBinary() ([]byte, error) { func (s *TransactionExt) UnmarshalBinary(inp []byte) error { r := bytes.NewReader(inp) d := xdr.NewDecoder(r) - _, err := s.DecodeFrom(d) + _, err := s.DecodeFrom(d, xdr.DecodeDefaultMaxDepth) return err } @@ -30114,39 +30885,43 @@ func (s *Transaction) EncodeTo(e *xdr.Encoder) error { var _ decoderFrom = (*Transaction)(nil) // DecodeFrom decodes this value using the Decoder. -func (s *Transaction) DecodeFrom(d *xdr.Decoder) (int, error) { +func (s *Transaction) DecodeFrom(d *xdr.Decoder, maxDepth uint) (int, error) { + if maxDepth == 0 { + return 0, fmt.Errorf("decoding Transaction: %w", ErrMaxDecodingDepthReached) + } + maxDepth -= 1 var err error var n, nTmp int - nTmp, err = s.SourceAccount.DecodeFrom(d) + nTmp, err = s.SourceAccount.DecodeFrom(d, maxDepth) n += nTmp if err != nil { - return n, fmt.Errorf("decoding MuxedAccount: %s", err) + return n, fmt.Errorf("decoding MuxedAccount: %w", err) } - nTmp, err = s.Fee.DecodeFrom(d) + nTmp, err = s.Fee.DecodeFrom(d, maxDepth) n += nTmp if err != nil { - return n, fmt.Errorf("decoding Uint32: %s", err) + return n, fmt.Errorf("decoding Uint32: %w", err) } - nTmp, err = s.SeqNum.DecodeFrom(d) + nTmp, err = s.SeqNum.DecodeFrom(d, maxDepth) n += nTmp if err != nil { - return n, fmt.Errorf("decoding SequenceNumber: %s", err) + return n, fmt.Errorf("decoding SequenceNumber: %w", err) } - nTmp, err = s.Cond.DecodeFrom(d) + nTmp, err = s.Cond.DecodeFrom(d, maxDepth) n += nTmp if err != nil { - return n, fmt.Errorf("decoding Preconditions: %s", err) + return n, fmt.Errorf("decoding Preconditions: %w", err) } - nTmp, err = s.Memo.DecodeFrom(d) + nTmp, err = s.Memo.DecodeFrom(d, maxDepth) n += nTmp if err != nil { - return n, fmt.Errorf("decoding Memo: %s", err) + return n, fmt.Errorf("decoding Memo: %w", err) } var l uint32 l, nTmp, err = d.DecodeUint() n += nTmp if err != nil { - return n, fmt.Errorf("decoding Operation: %s", err) + return n, fmt.Errorf("decoding Operation: %w", err) } if l > 100 { return n, fmt.Errorf("decoding Operation: data size (%d) exceeds size limit (100)", l) @@ -30155,17 +30930,17 @@ func (s *Transaction) DecodeFrom(d *xdr.Decoder) (int, error) { if l > 0 { s.Operations = make([]Operation, l) for i := uint32(0); i < l; i++ { - nTmp, err = s.Operations[i].DecodeFrom(d) + nTmp, err = s.Operations[i].DecodeFrom(d, maxDepth) n += nTmp if err != nil { - return n, fmt.Errorf("decoding Operation: %s", err) + return n, fmt.Errorf("decoding Operation: %w", err) } } } - nTmp, err = s.Ext.DecodeFrom(d) + nTmp, err = s.Ext.DecodeFrom(d, maxDepth) n += nTmp if err != nil { - return n, fmt.Errorf("decoding TransactionExt: %s", err) + return n, fmt.Errorf("decoding TransactionExt: %w", err) } return n, nil } @@ -30182,7 +30957,7 @@ func (s Transaction) MarshalBinary() ([]byte, error) { func (s *Transaction) UnmarshalBinary(inp []byte) error { r := bytes.NewReader(inp) d := xdr.NewDecoder(r) - _, err := s.DecodeFrom(d) + _, err := s.DecodeFrom(d, xdr.DecodeDefaultMaxDepth) return err } @@ -30231,19 +31006,23 @@ func (s *TransactionV1Envelope) EncodeTo(e *xdr.Encoder) error { var _ decoderFrom = (*TransactionV1Envelope)(nil) // DecodeFrom decodes this value using the Decoder. -func (s *TransactionV1Envelope) DecodeFrom(d *xdr.Decoder) (int, error) { +func (s *TransactionV1Envelope) DecodeFrom(d *xdr.Decoder, maxDepth uint) (int, error) { + if maxDepth == 0 { + return 0, fmt.Errorf("decoding TransactionV1Envelope: %w", ErrMaxDecodingDepthReached) + } + maxDepth -= 1 var err error var n, nTmp int - nTmp, err = s.Tx.DecodeFrom(d) + nTmp, err = s.Tx.DecodeFrom(d, maxDepth) n += nTmp if err != nil { - return n, fmt.Errorf("decoding Transaction: %s", err) + return n, fmt.Errorf("decoding Transaction: %w", err) } var l uint32 l, nTmp, err = d.DecodeUint() n += nTmp if err != nil { - return n, fmt.Errorf("decoding DecoratedSignature: %s", err) + return n, fmt.Errorf("decoding DecoratedSignature: %w", err) } if l > 20 { return n, fmt.Errorf("decoding DecoratedSignature: data size (%d) exceeds size limit (20)", l) @@ -30252,10 +31031,10 @@ func (s *TransactionV1Envelope) DecodeFrom(d *xdr.Decoder) (int, error) { if l > 0 { s.Signatures = make([]DecoratedSignature, l) for i := uint32(0); i < l; i++ { - nTmp, err = s.Signatures[i].DecodeFrom(d) + nTmp, err = s.Signatures[i].DecodeFrom(d, maxDepth) n += nTmp if err != nil { - return n, fmt.Errorf("decoding DecoratedSignature: %s", err) + return n, fmt.Errorf("decoding DecoratedSignature: %w", err) } } } @@ -30274,7 +31053,7 @@ func (s TransactionV1Envelope) MarshalBinary() ([]byte, error) { func (s *TransactionV1Envelope) UnmarshalBinary(inp []byte) error { r := bytes.NewReader(inp) d := xdr.NewDecoder(r) - _, err := s.DecodeFrom(d) + _, err := s.DecodeFrom(d, xdr.DecodeDefaultMaxDepth) return err } @@ -30324,7 +31103,7 @@ func NewFeeBumpTransactionInnerTx(aType EnvelopeType, value interface{}) (result case EnvelopeTypeEnvelopeTypeTx: tv, ok := value.(TransactionV1Envelope) if !ok { - err = fmt.Errorf("invalid value, must be TransactionV1Envelope") + err = errors.New("invalid value, must be TransactionV1Envelope") return } result.V1 = &tv @@ -30376,21 +31155,25 @@ func (u FeeBumpTransactionInnerTx) EncodeTo(e *xdr.Encoder) error { var _ decoderFrom = (*FeeBumpTransactionInnerTx)(nil) // DecodeFrom decodes this value using the Decoder. -func (u *FeeBumpTransactionInnerTx) DecodeFrom(d *xdr.Decoder) (int, error) { +func (u *FeeBumpTransactionInnerTx) DecodeFrom(d *xdr.Decoder, maxDepth uint) (int, error) { + if maxDepth == 0 { + return 0, fmt.Errorf("decoding FeeBumpTransactionInnerTx: %w", ErrMaxDecodingDepthReached) + } + maxDepth -= 1 var err error var n, nTmp int - nTmp, err = u.Type.DecodeFrom(d) + nTmp, err = u.Type.DecodeFrom(d, maxDepth) n += nTmp if err != nil { - return n, fmt.Errorf("decoding EnvelopeType: %s", err) + return n, fmt.Errorf("decoding EnvelopeType: %w", err) } switch EnvelopeType(u.Type) { case EnvelopeTypeEnvelopeTypeTx: u.V1 = new(TransactionV1Envelope) - nTmp, err = (*u.V1).DecodeFrom(d) + nTmp, err = (*u.V1).DecodeFrom(d, maxDepth) n += nTmp if err != nil { - return n, fmt.Errorf("decoding TransactionV1Envelope: %s", err) + return n, fmt.Errorf("decoding TransactionV1Envelope: %w", err) } return n, nil } @@ -30409,7 +31192,7 @@ func (s FeeBumpTransactionInnerTx) MarshalBinary() ([]byte, error) { func (s *FeeBumpTransactionInnerTx) UnmarshalBinary(inp []byte) error { r := bytes.NewReader(inp) d := xdr.NewDecoder(r) - _, err := s.DecodeFrom(d) + _, err := s.DecodeFrom(d, xdr.DecodeDefaultMaxDepth) return err } @@ -30478,13 +31261,17 @@ func (u FeeBumpTransactionExt) EncodeTo(e *xdr.Encoder) error { var _ decoderFrom = (*FeeBumpTransactionExt)(nil) // DecodeFrom decodes this value using the Decoder. -func (u *FeeBumpTransactionExt) DecodeFrom(d *xdr.Decoder) (int, error) { +func (u *FeeBumpTransactionExt) DecodeFrom(d *xdr.Decoder, maxDepth uint) (int, error) { + if maxDepth == 0 { + return 0, fmt.Errorf("decoding FeeBumpTransactionExt: %w", ErrMaxDecodingDepthReached) + } + maxDepth -= 1 var err error var n, nTmp int u.V, nTmp, err = d.DecodeInt() n += nTmp if err != nil { - return n, fmt.Errorf("decoding Int: %s", err) + return n, fmt.Errorf("decoding Int: %w", err) } switch int32(u.V) { case 0: @@ -30506,7 +31293,7 @@ func (s FeeBumpTransactionExt) MarshalBinary() ([]byte, error) { func (s *FeeBumpTransactionExt) UnmarshalBinary(inp []byte) error { r := bytes.NewReader(inp) d := xdr.NewDecoder(r) - _, err := s.DecodeFrom(d) + _, err := s.DecodeFrom(d, xdr.DecodeDefaultMaxDepth) return err } @@ -30568,28 +31355,32 @@ func (s *FeeBumpTransaction) EncodeTo(e *xdr.Encoder) error { var _ decoderFrom = (*FeeBumpTransaction)(nil) // DecodeFrom decodes this value using the Decoder. -func (s *FeeBumpTransaction) DecodeFrom(d *xdr.Decoder) (int, error) { +func (s *FeeBumpTransaction) DecodeFrom(d *xdr.Decoder, maxDepth uint) (int, error) { + if maxDepth == 0 { + return 0, fmt.Errorf("decoding FeeBumpTransaction: %w", ErrMaxDecodingDepthReached) + } + maxDepth -= 1 var err error var n, nTmp int - nTmp, err = s.FeeSource.DecodeFrom(d) + nTmp, err = s.FeeSource.DecodeFrom(d, maxDepth) n += nTmp if err != nil { - return n, fmt.Errorf("decoding MuxedAccount: %s", err) + return n, fmt.Errorf("decoding MuxedAccount: %w", err) } - nTmp, err = s.Fee.DecodeFrom(d) + nTmp, err = s.Fee.DecodeFrom(d, maxDepth) n += nTmp if err != nil { - return n, fmt.Errorf("decoding Int64: %s", err) + return n, fmt.Errorf("decoding Int64: %w", err) } - nTmp, err = s.InnerTx.DecodeFrom(d) + nTmp, err = s.InnerTx.DecodeFrom(d, maxDepth) n += nTmp if err != nil { - return n, fmt.Errorf("decoding FeeBumpTransactionInnerTx: %s", err) + return n, fmt.Errorf("decoding FeeBumpTransactionInnerTx: %w", err) } - nTmp, err = s.Ext.DecodeFrom(d) + nTmp, err = s.Ext.DecodeFrom(d, maxDepth) n += nTmp if err != nil { - return n, fmt.Errorf("decoding FeeBumpTransactionExt: %s", err) + return n, fmt.Errorf("decoding FeeBumpTransactionExt: %w", err) } return n, nil } @@ -30606,7 +31397,7 @@ func (s FeeBumpTransaction) MarshalBinary() ([]byte, error) { func (s *FeeBumpTransaction) UnmarshalBinary(inp []byte) error { r := bytes.NewReader(inp) d := xdr.NewDecoder(r) - _, err := s.DecodeFrom(d) + _, err := s.DecodeFrom(d, xdr.DecodeDefaultMaxDepth) return err } @@ -30655,19 +31446,23 @@ func (s *FeeBumpTransactionEnvelope) EncodeTo(e *xdr.Encoder) error { var _ decoderFrom = (*FeeBumpTransactionEnvelope)(nil) // DecodeFrom decodes this value using the Decoder. -func (s *FeeBumpTransactionEnvelope) DecodeFrom(d *xdr.Decoder) (int, error) { +func (s *FeeBumpTransactionEnvelope) DecodeFrom(d *xdr.Decoder, maxDepth uint) (int, error) { + if maxDepth == 0 { + return 0, fmt.Errorf("decoding FeeBumpTransactionEnvelope: %w", ErrMaxDecodingDepthReached) + } + maxDepth -= 1 var err error var n, nTmp int - nTmp, err = s.Tx.DecodeFrom(d) + nTmp, err = s.Tx.DecodeFrom(d, maxDepth) n += nTmp if err != nil { - return n, fmt.Errorf("decoding FeeBumpTransaction: %s", err) + return n, fmt.Errorf("decoding FeeBumpTransaction: %w", err) } var l uint32 l, nTmp, err = d.DecodeUint() n += nTmp if err != nil { - return n, fmt.Errorf("decoding DecoratedSignature: %s", err) + return n, fmt.Errorf("decoding DecoratedSignature: %w", err) } if l > 20 { return n, fmt.Errorf("decoding DecoratedSignature: data size (%d) exceeds size limit (20)", l) @@ -30676,10 +31471,10 @@ func (s *FeeBumpTransactionEnvelope) DecodeFrom(d *xdr.Decoder) (int, error) { if l > 0 { s.Signatures = make([]DecoratedSignature, l) for i := uint32(0); i < l; i++ { - nTmp, err = s.Signatures[i].DecodeFrom(d) + nTmp, err = s.Signatures[i].DecodeFrom(d, maxDepth) n += nTmp if err != nil { - return n, fmt.Errorf("decoding DecoratedSignature: %s", err) + return n, fmt.Errorf("decoding DecoratedSignature: %w", err) } } } @@ -30698,7 +31493,7 @@ func (s FeeBumpTransactionEnvelope) MarshalBinary() ([]byte, error) { func (s *FeeBumpTransactionEnvelope) UnmarshalBinary(inp []byte) error { r := bytes.NewReader(inp) d := xdr.NewDecoder(r) - _, err := s.DecodeFrom(d) + _, err := s.DecodeFrom(d, xdr.DecodeDefaultMaxDepth) return err } @@ -30758,21 +31553,21 @@ func NewTransactionEnvelope(aType EnvelopeType, value interface{}) (result Trans case EnvelopeTypeEnvelopeTypeTxV0: tv, ok := value.(TransactionV0Envelope) if !ok { - err = fmt.Errorf("invalid value, must be TransactionV0Envelope") + err = errors.New("invalid value, must be TransactionV0Envelope") return } result.V0 = &tv case EnvelopeTypeEnvelopeTypeTx: tv, ok := value.(TransactionV1Envelope) if !ok { - err = fmt.Errorf("invalid value, must be TransactionV1Envelope") + err = errors.New("invalid value, must be TransactionV1Envelope") return } result.V1 = &tv case EnvelopeTypeEnvelopeTypeTxFeeBump: tv, ok := value.(FeeBumpTransactionEnvelope) if !ok { - err = fmt.Errorf("invalid value, must be FeeBumpTransactionEnvelope") + err = errors.New("invalid value, must be FeeBumpTransactionEnvelope") return } result.FeeBump = &tv @@ -30884,37 +31679,41 @@ func (u TransactionEnvelope) EncodeTo(e *xdr.Encoder) error { var _ decoderFrom = (*TransactionEnvelope)(nil) // DecodeFrom decodes this value using the Decoder. -func (u *TransactionEnvelope) DecodeFrom(d *xdr.Decoder) (int, error) { +func (u *TransactionEnvelope) DecodeFrom(d *xdr.Decoder, maxDepth uint) (int, error) { + if maxDepth == 0 { + return 0, fmt.Errorf("decoding TransactionEnvelope: %w", ErrMaxDecodingDepthReached) + } + maxDepth -= 1 var err error var n, nTmp int - nTmp, err = u.Type.DecodeFrom(d) + nTmp, err = u.Type.DecodeFrom(d, maxDepth) n += nTmp if err != nil { - return n, fmt.Errorf("decoding EnvelopeType: %s", err) + return n, fmt.Errorf("decoding EnvelopeType: %w", err) } switch EnvelopeType(u.Type) { case EnvelopeTypeEnvelopeTypeTxV0: u.V0 = new(TransactionV0Envelope) - nTmp, err = (*u.V0).DecodeFrom(d) + nTmp, err = (*u.V0).DecodeFrom(d, maxDepth) n += nTmp if err != nil { - return n, fmt.Errorf("decoding TransactionV0Envelope: %s", err) + return n, fmt.Errorf("decoding TransactionV0Envelope: %w", err) } return n, nil case EnvelopeTypeEnvelopeTypeTx: u.V1 = new(TransactionV1Envelope) - nTmp, err = (*u.V1).DecodeFrom(d) + nTmp, err = (*u.V1).DecodeFrom(d, maxDepth) n += nTmp if err != nil { - return n, fmt.Errorf("decoding TransactionV1Envelope: %s", err) + return n, fmt.Errorf("decoding TransactionV1Envelope: %w", err) } return n, nil case EnvelopeTypeEnvelopeTypeTxFeeBump: u.FeeBump = new(FeeBumpTransactionEnvelope) - nTmp, err = (*u.FeeBump).DecodeFrom(d) + nTmp, err = (*u.FeeBump).DecodeFrom(d, maxDepth) n += nTmp if err != nil { - return n, fmt.Errorf("decoding FeeBumpTransactionEnvelope: %s", err) + return n, fmt.Errorf("decoding FeeBumpTransactionEnvelope: %w", err) } return n, nil } @@ -30933,7 +31732,7 @@ func (s TransactionEnvelope) MarshalBinary() ([]byte, error) { func (s *TransactionEnvelope) UnmarshalBinary(inp []byte) error { r := bytes.NewReader(inp) d := xdr.NewDecoder(r) - _, err := s.DecodeFrom(d) + _, err := s.DecodeFrom(d, xdr.DecodeDefaultMaxDepth) return err } @@ -30989,14 +31788,14 @@ func NewTransactionSignaturePayloadTaggedTransaction(aType EnvelopeType, value i case EnvelopeTypeEnvelopeTypeTx: tv, ok := value.(Transaction) if !ok { - err = fmt.Errorf("invalid value, must be Transaction") + err = errors.New("invalid value, must be Transaction") return } result.Tx = &tv case EnvelopeTypeEnvelopeTypeTxFeeBump: tv, ok := value.(FeeBumpTransaction) if !ok { - err = fmt.Errorf("invalid value, must be FeeBumpTransaction") + err = errors.New("invalid value, must be FeeBumpTransaction") return } result.FeeBump = &tv @@ -31078,29 +31877,33 @@ func (u TransactionSignaturePayloadTaggedTransaction) EncodeTo(e *xdr.Encoder) e var _ decoderFrom = (*TransactionSignaturePayloadTaggedTransaction)(nil) // DecodeFrom decodes this value using the Decoder. -func (u *TransactionSignaturePayloadTaggedTransaction) DecodeFrom(d *xdr.Decoder) (int, error) { +func (u *TransactionSignaturePayloadTaggedTransaction) DecodeFrom(d *xdr.Decoder, maxDepth uint) (int, error) { + if maxDepth == 0 { + return 0, fmt.Errorf("decoding TransactionSignaturePayloadTaggedTransaction: %w", ErrMaxDecodingDepthReached) + } + maxDepth -= 1 var err error var n, nTmp int - nTmp, err = u.Type.DecodeFrom(d) + nTmp, err = u.Type.DecodeFrom(d, maxDepth) n += nTmp if err != nil { - return n, fmt.Errorf("decoding EnvelopeType: %s", err) + return n, fmt.Errorf("decoding EnvelopeType: %w", err) } switch EnvelopeType(u.Type) { case EnvelopeTypeEnvelopeTypeTx: u.Tx = new(Transaction) - nTmp, err = (*u.Tx).DecodeFrom(d) + nTmp, err = (*u.Tx).DecodeFrom(d, maxDepth) n += nTmp if err != nil { - return n, fmt.Errorf("decoding Transaction: %s", err) + return n, fmt.Errorf("decoding Transaction: %w", err) } return n, nil case EnvelopeTypeEnvelopeTypeTxFeeBump: u.FeeBump = new(FeeBumpTransaction) - nTmp, err = (*u.FeeBump).DecodeFrom(d) + nTmp, err = (*u.FeeBump).DecodeFrom(d, maxDepth) n += nTmp if err != nil { - return n, fmt.Errorf("decoding FeeBumpTransaction: %s", err) + return n, fmt.Errorf("decoding FeeBumpTransaction: %w", err) } return n, nil } @@ -31119,7 +31922,7 @@ func (s TransactionSignaturePayloadTaggedTransaction) MarshalBinary() ([]byte, e func (s *TransactionSignaturePayloadTaggedTransaction) UnmarshalBinary(inp []byte) error { r := bytes.NewReader(inp) d := xdr.NewDecoder(r) - _, err := s.DecodeFrom(d) + _, err := s.DecodeFrom(d, xdr.DecodeDefaultMaxDepth) return err } @@ -31169,18 +31972,22 @@ func (s *TransactionSignaturePayload) EncodeTo(e *xdr.Encoder) error { var _ decoderFrom = (*TransactionSignaturePayload)(nil) // DecodeFrom decodes this value using the Decoder. -func (s *TransactionSignaturePayload) DecodeFrom(d *xdr.Decoder) (int, error) { +func (s *TransactionSignaturePayload) DecodeFrom(d *xdr.Decoder, maxDepth uint) (int, error) { + if maxDepth == 0 { + return 0, fmt.Errorf("decoding TransactionSignaturePayload: %w", ErrMaxDecodingDepthReached) + } + maxDepth -= 1 var err error var n, nTmp int - nTmp, err = s.NetworkId.DecodeFrom(d) + nTmp, err = s.NetworkId.DecodeFrom(d, maxDepth) n += nTmp if err != nil { - return n, fmt.Errorf("decoding Hash: %s", err) + return n, fmt.Errorf("decoding Hash: %w", err) } - nTmp, err = s.TaggedTransaction.DecodeFrom(d) + nTmp, err = s.TaggedTransaction.DecodeFrom(d, maxDepth) n += nTmp if err != nil { - return n, fmt.Errorf("decoding TransactionSignaturePayloadTaggedTransaction: %s", err) + return n, fmt.Errorf("decoding TransactionSignaturePayloadTaggedTransaction: %w", err) } return n, nil } @@ -31197,7 +32004,7 @@ func (s TransactionSignaturePayload) MarshalBinary() ([]byte, error) { func (s *TransactionSignaturePayload) UnmarshalBinary(inp []byte) error { r := bytes.NewReader(inp) d := xdr.NewDecoder(r) - _, err := s.DecodeFrom(d) + _, err := s.DecodeFrom(d, xdr.DecodeDefaultMaxDepth) return err } @@ -31259,10 +32066,14 @@ func (e ClaimAtomType) EncodeTo(enc *xdr.Encoder) error { var _ decoderFrom = (*ClaimAtomType)(nil) // DecodeFrom decodes this value using the Decoder. -func (e *ClaimAtomType) DecodeFrom(d *xdr.Decoder) (int, error) { +func (e *ClaimAtomType) DecodeFrom(d *xdr.Decoder, maxDepth uint) (int, error) { + if maxDepth == 0 { + return 0, fmt.Errorf("decoding ClaimAtomType: %w", ErrMaxDecodingDepthReached) + } + maxDepth -= 1 v, n, err := d.DecodeInt() if err != nil { - return n, fmt.Errorf("decoding ClaimAtomType: %s", err) + return n, fmt.Errorf("decoding ClaimAtomType: %w", err) } if _, ok := claimAtomTypeMap[v]; !ok { return n, fmt.Errorf("'%d' is not a valid ClaimAtomType enum value", v) @@ -31283,7 +32094,7 @@ func (s ClaimAtomType) MarshalBinary() ([]byte, error) { func (s *ClaimAtomType) UnmarshalBinary(inp []byte) error { r := bytes.NewReader(inp) d := xdr.NewDecoder(r) - _, err := s.DecodeFrom(d) + _, err := s.DecodeFrom(d, xdr.DecodeDefaultMaxDepth) return err } @@ -31350,38 +32161,42 @@ func (s *ClaimOfferAtomV0) EncodeTo(e *xdr.Encoder) error { var _ decoderFrom = (*ClaimOfferAtomV0)(nil) // DecodeFrom decodes this value using the Decoder. -func (s *ClaimOfferAtomV0) DecodeFrom(d *xdr.Decoder) (int, error) { +func (s *ClaimOfferAtomV0) DecodeFrom(d *xdr.Decoder, maxDepth uint) (int, error) { + if maxDepth == 0 { + return 0, fmt.Errorf("decoding ClaimOfferAtomV0: %w", ErrMaxDecodingDepthReached) + } + maxDepth -= 1 var err error var n, nTmp int - nTmp, err = s.SellerEd25519.DecodeFrom(d) + nTmp, err = s.SellerEd25519.DecodeFrom(d, maxDepth) n += nTmp if err != nil { - return n, fmt.Errorf("decoding Uint256: %s", err) + return n, fmt.Errorf("decoding Uint256: %w", err) } - nTmp, err = s.OfferId.DecodeFrom(d) + nTmp, err = s.OfferId.DecodeFrom(d, maxDepth) n += nTmp if err != nil { - return n, fmt.Errorf("decoding Int64: %s", err) + return n, fmt.Errorf("decoding Int64: %w", err) } - nTmp, err = s.AssetSold.DecodeFrom(d) + nTmp, err = s.AssetSold.DecodeFrom(d, maxDepth) n += nTmp if err != nil { - return n, fmt.Errorf("decoding Asset: %s", err) + return n, fmt.Errorf("decoding Asset: %w", err) } - nTmp, err = s.AmountSold.DecodeFrom(d) + nTmp, err = s.AmountSold.DecodeFrom(d, maxDepth) n += nTmp if err != nil { - return n, fmt.Errorf("decoding Int64: %s", err) + return n, fmt.Errorf("decoding Int64: %w", err) } - nTmp, err = s.AssetBought.DecodeFrom(d) + nTmp, err = s.AssetBought.DecodeFrom(d, maxDepth) n += nTmp if err != nil { - return n, fmt.Errorf("decoding Asset: %s", err) + return n, fmt.Errorf("decoding Asset: %w", err) } - nTmp, err = s.AmountBought.DecodeFrom(d) + nTmp, err = s.AmountBought.DecodeFrom(d, maxDepth) n += nTmp if err != nil { - return n, fmt.Errorf("decoding Int64: %s", err) + return n, fmt.Errorf("decoding Int64: %w", err) } return n, nil } @@ -31398,7 +32213,7 @@ func (s ClaimOfferAtomV0) MarshalBinary() ([]byte, error) { func (s *ClaimOfferAtomV0) UnmarshalBinary(inp []byte) error { r := bytes.NewReader(inp) d := xdr.NewDecoder(r) - _, err := s.DecodeFrom(d) + _, err := s.DecodeFrom(d, xdr.DecodeDefaultMaxDepth) return err } @@ -31465,38 +32280,42 @@ func (s *ClaimOfferAtom) EncodeTo(e *xdr.Encoder) error { var _ decoderFrom = (*ClaimOfferAtom)(nil) // DecodeFrom decodes this value using the Decoder. -func (s *ClaimOfferAtom) DecodeFrom(d *xdr.Decoder) (int, error) { +func (s *ClaimOfferAtom) DecodeFrom(d *xdr.Decoder, maxDepth uint) (int, error) { + if maxDepth == 0 { + return 0, fmt.Errorf("decoding ClaimOfferAtom: %w", ErrMaxDecodingDepthReached) + } + maxDepth -= 1 var err error var n, nTmp int - nTmp, err = s.SellerId.DecodeFrom(d) + nTmp, err = s.SellerId.DecodeFrom(d, maxDepth) n += nTmp if err != nil { - return n, fmt.Errorf("decoding AccountId: %s", err) + return n, fmt.Errorf("decoding AccountId: %w", err) } - nTmp, err = s.OfferId.DecodeFrom(d) + nTmp, err = s.OfferId.DecodeFrom(d, maxDepth) n += nTmp if err != nil { - return n, fmt.Errorf("decoding Int64: %s", err) + return n, fmt.Errorf("decoding Int64: %w", err) } - nTmp, err = s.AssetSold.DecodeFrom(d) + nTmp, err = s.AssetSold.DecodeFrom(d, maxDepth) n += nTmp if err != nil { - return n, fmt.Errorf("decoding Asset: %s", err) + return n, fmt.Errorf("decoding Asset: %w", err) } - nTmp, err = s.AmountSold.DecodeFrom(d) + nTmp, err = s.AmountSold.DecodeFrom(d, maxDepth) n += nTmp if err != nil { - return n, fmt.Errorf("decoding Int64: %s", err) + return n, fmt.Errorf("decoding Int64: %w", err) } - nTmp, err = s.AssetBought.DecodeFrom(d) + nTmp, err = s.AssetBought.DecodeFrom(d, maxDepth) n += nTmp if err != nil { - return n, fmt.Errorf("decoding Asset: %s", err) + return n, fmt.Errorf("decoding Asset: %w", err) } - nTmp, err = s.AmountBought.DecodeFrom(d) + nTmp, err = s.AmountBought.DecodeFrom(d, maxDepth) n += nTmp if err != nil { - return n, fmt.Errorf("decoding Int64: %s", err) + return n, fmt.Errorf("decoding Int64: %w", err) } return n, nil } @@ -31513,7 +32332,7 @@ func (s ClaimOfferAtom) MarshalBinary() ([]byte, error) { func (s *ClaimOfferAtom) UnmarshalBinary(inp []byte) error { r := bytes.NewReader(inp) d := xdr.NewDecoder(r) - _, err := s.DecodeFrom(d) + _, err := s.DecodeFrom(d, xdr.DecodeDefaultMaxDepth) return err } @@ -31574,33 +32393,37 @@ func (s *ClaimLiquidityAtom) EncodeTo(e *xdr.Encoder) error { var _ decoderFrom = (*ClaimLiquidityAtom)(nil) // DecodeFrom decodes this value using the Decoder. -func (s *ClaimLiquidityAtom) DecodeFrom(d *xdr.Decoder) (int, error) { +func (s *ClaimLiquidityAtom) DecodeFrom(d *xdr.Decoder, maxDepth uint) (int, error) { + if maxDepth == 0 { + return 0, fmt.Errorf("decoding ClaimLiquidityAtom: %w", ErrMaxDecodingDepthReached) + } + maxDepth -= 1 var err error var n, nTmp int - nTmp, err = s.LiquidityPoolId.DecodeFrom(d) + nTmp, err = s.LiquidityPoolId.DecodeFrom(d, maxDepth) n += nTmp if err != nil { - return n, fmt.Errorf("decoding PoolId: %s", err) + return n, fmt.Errorf("decoding PoolId: %w", err) } - nTmp, err = s.AssetSold.DecodeFrom(d) + nTmp, err = s.AssetSold.DecodeFrom(d, maxDepth) n += nTmp if err != nil { - return n, fmt.Errorf("decoding Asset: %s", err) + return n, fmt.Errorf("decoding Asset: %w", err) } - nTmp, err = s.AmountSold.DecodeFrom(d) + nTmp, err = s.AmountSold.DecodeFrom(d, maxDepth) n += nTmp if err != nil { - return n, fmt.Errorf("decoding Int64: %s", err) + return n, fmt.Errorf("decoding Int64: %w", err) } - nTmp, err = s.AssetBought.DecodeFrom(d) + nTmp, err = s.AssetBought.DecodeFrom(d, maxDepth) n += nTmp if err != nil { - return n, fmt.Errorf("decoding Asset: %s", err) + return n, fmt.Errorf("decoding Asset: %w", err) } - nTmp, err = s.AmountBought.DecodeFrom(d) + nTmp, err = s.AmountBought.DecodeFrom(d, maxDepth) n += nTmp if err != nil { - return n, fmt.Errorf("decoding Int64: %s", err) + return n, fmt.Errorf("decoding Int64: %w", err) } return n, nil } @@ -31617,7 +32440,7 @@ func (s ClaimLiquidityAtom) MarshalBinary() ([]byte, error) { func (s *ClaimLiquidityAtom) UnmarshalBinary(inp []byte) error { r := bytes.NewReader(inp) d := xdr.NewDecoder(r) - _, err := s.DecodeFrom(d) + _, err := s.DecodeFrom(d, xdr.DecodeDefaultMaxDepth) return err } @@ -31677,21 +32500,21 @@ func NewClaimAtom(aType ClaimAtomType, value interface{}) (result ClaimAtom, err case ClaimAtomTypeClaimAtomTypeV0: tv, ok := value.(ClaimOfferAtomV0) if !ok { - err = fmt.Errorf("invalid value, must be ClaimOfferAtomV0") + err = errors.New("invalid value, must be ClaimOfferAtomV0") return } result.V0 = &tv case ClaimAtomTypeClaimAtomTypeOrderBook: tv, ok := value.(ClaimOfferAtom) if !ok { - err = fmt.Errorf("invalid value, must be ClaimOfferAtom") + err = errors.New("invalid value, must be ClaimOfferAtom") return } result.OrderBook = &tv case ClaimAtomTypeClaimAtomTypeLiquidityPool: tv, ok := value.(ClaimLiquidityAtom) if !ok { - err = fmt.Errorf("invalid value, must be ClaimLiquidityAtom") + err = errors.New("invalid value, must be ClaimLiquidityAtom") return } result.LiquidityPool = &tv @@ -31803,37 +32626,41 @@ func (u ClaimAtom) EncodeTo(e *xdr.Encoder) error { var _ decoderFrom = (*ClaimAtom)(nil) // DecodeFrom decodes this value using the Decoder. -func (u *ClaimAtom) DecodeFrom(d *xdr.Decoder) (int, error) { +func (u *ClaimAtom) DecodeFrom(d *xdr.Decoder, maxDepth uint) (int, error) { + if maxDepth == 0 { + return 0, fmt.Errorf("decoding ClaimAtom: %w", ErrMaxDecodingDepthReached) + } + maxDepth -= 1 var err error var n, nTmp int - nTmp, err = u.Type.DecodeFrom(d) + nTmp, err = u.Type.DecodeFrom(d, maxDepth) n += nTmp if err != nil { - return n, fmt.Errorf("decoding ClaimAtomType: %s", err) + return n, fmt.Errorf("decoding ClaimAtomType: %w", err) } switch ClaimAtomType(u.Type) { case ClaimAtomTypeClaimAtomTypeV0: u.V0 = new(ClaimOfferAtomV0) - nTmp, err = (*u.V0).DecodeFrom(d) + nTmp, err = (*u.V0).DecodeFrom(d, maxDepth) n += nTmp if err != nil { - return n, fmt.Errorf("decoding ClaimOfferAtomV0: %s", err) + return n, fmt.Errorf("decoding ClaimOfferAtomV0: %w", err) } return n, nil case ClaimAtomTypeClaimAtomTypeOrderBook: u.OrderBook = new(ClaimOfferAtom) - nTmp, err = (*u.OrderBook).DecodeFrom(d) + nTmp, err = (*u.OrderBook).DecodeFrom(d, maxDepth) n += nTmp if err != nil { - return n, fmt.Errorf("decoding ClaimOfferAtom: %s", err) + return n, fmt.Errorf("decoding ClaimOfferAtom: %w", err) } return n, nil case ClaimAtomTypeClaimAtomTypeLiquidityPool: u.LiquidityPool = new(ClaimLiquidityAtom) - nTmp, err = (*u.LiquidityPool).DecodeFrom(d) + nTmp, err = (*u.LiquidityPool).DecodeFrom(d, maxDepth) n += nTmp if err != nil { - return n, fmt.Errorf("decoding ClaimLiquidityAtom: %s", err) + return n, fmt.Errorf("decoding ClaimLiquidityAtom: %w", err) } return n, nil } @@ -31852,7 +32679,7 @@ func (s ClaimAtom) MarshalBinary() ([]byte, error) { func (s *ClaimAtom) UnmarshalBinary(inp []byte) error { r := bytes.NewReader(inp) d := xdr.NewDecoder(r) - _, err := s.DecodeFrom(d) + _, err := s.DecodeFrom(d, xdr.DecodeDefaultMaxDepth) return err } @@ -31924,10 +32751,14 @@ func (e CreateAccountResultCode) EncodeTo(enc *xdr.Encoder) error { var _ decoderFrom = (*CreateAccountResultCode)(nil) // DecodeFrom decodes this value using the Decoder. -func (e *CreateAccountResultCode) DecodeFrom(d *xdr.Decoder) (int, error) { +func (e *CreateAccountResultCode) DecodeFrom(d *xdr.Decoder, maxDepth uint) (int, error) { + if maxDepth == 0 { + return 0, fmt.Errorf("decoding CreateAccountResultCode: %w", ErrMaxDecodingDepthReached) + } + maxDepth -= 1 v, n, err := d.DecodeInt() if err != nil { - return n, fmt.Errorf("decoding CreateAccountResultCode: %s", err) + return n, fmt.Errorf("decoding CreateAccountResultCode: %w", err) } if _, ok := createAccountResultCodeMap[v]; !ok { return n, fmt.Errorf("'%d' is not a valid CreateAccountResultCode enum value", v) @@ -31948,7 +32779,7 @@ func (s CreateAccountResultCode) MarshalBinary() ([]byte, error) { func (s *CreateAccountResultCode) UnmarshalBinary(inp []byte) error { r := bytes.NewReader(inp) d := xdr.NewDecoder(r) - _, err := s.DecodeFrom(d) + _, err := s.DecodeFrom(d, xdr.DecodeDefaultMaxDepth) return err } @@ -32050,13 +32881,17 @@ func (u CreateAccountResult) EncodeTo(e *xdr.Encoder) error { var _ decoderFrom = (*CreateAccountResult)(nil) // DecodeFrom decodes this value using the Decoder. -func (u *CreateAccountResult) DecodeFrom(d *xdr.Decoder) (int, error) { +func (u *CreateAccountResult) DecodeFrom(d *xdr.Decoder, maxDepth uint) (int, error) { + if maxDepth == 0 { + return 0, fmt.Errorf("decoding CreateAccountResult: %w", ErrMaxDecodingDepthReached) + } + maxDepth -= 1 var err error var n, nTmp int - nTmp, err = u.Code.DecodeFrom(d) + nTmp, err = u.Code.DecodeFrom(d, maxDepth) n += nTmp if err != nil { - return n, fmt.Errorf("decoding CreateAccountResultCode: %s", err) + return n, fmt.Errorf("decoding CreateAccountResultCode: %w", err) } switch CreateAccountResultCode(u.Code) { case CreateAccountResultCodeCreateAccountSuccess: @@ -32090,7 +32925,7 @@ func (s CreateAccountResult) MarshalBinary() ([]byte, error) { func (s *CreateAccountResult) UnmarshalBinary(inp []byte) error { r := bytes.NewReader(inp) d := xdr.NewDecoder(r) - _, err := s.DecodeFrom(d) + _, err := s.DecodeFrom(d, xdr.DecodeDefaultMaxDepth) return err } @@ -32176,10 +33011,14 @@ func (e PaymentResultCode) EncodeTo(enc *xdr.Encoder) error { var _ decoderFrom = (*PaymentResultCode)(nil) // DecodeFrom decodes this value using the Decoder. -func (e *PaymentResultCode) DecodeFrom(d *xdr.Decoder) (int, error) { +func (e *PaymentResultCode) DecodeFrom(d *xdr.Decoder, maxDepth uint) (int, error) { + if maxDepth == 0 { + return 0, fmt.Errorf("decoding PaymentResultCode: %w", ErrMaxDecodingDepthReached) + } + maxDepth -= 1 v, n, err := d.DecodeInt() if err != nil { - return n, fmt.Errorf("decoding PaymentResultCode: %s", err) + return n, fmt.Errorf("decoding PaymentResultCode: %w", err) } if _, ok := paymentResultCodeMap[v]; !ok { return n, fmt.Errorf("'%d' is not a valid PaymentResultCode enum value", v) @@ -32200,7 +33039,7 @@ func (s PaymentResultCode) MarshalBinary() ([]byte, error) { func (s *PaymentResultCode) UnmarshalBinary(inp []byte) error { r := bytes.NewReader(inp) d := xdr.NewDecoder(r) - _, err := s.DecodeFrom(d) + _, err := s.DecodeFrom(d, xdr.DecodeDefaultMaxDepth) return err } @@ -32342,13 +33181,17 @@ func (u PaymentResult) EncodeTo(e *xdr.Encoder) error { var _ decoderFrom = (*PaymentResult)(nil) // DecodeFrom decodes this value using the Decoder. -func (u *PaymentResult) DecodeFrom(d *xdr.Decoder) (int, error) { +func (u *PaymentResult) DecodeFrom(d *xdr.Decoder, maxDepth uint) (int, error) { + if maxDepth == 0 { + return 0, fmt.Errorf("decoding PaymentResult: %w", ErrMaxDecodingDepthReached) + } + maxDepth -= 1 var err error var n, nTmp int - nTmp, err = u.Code.DecodeFrom(d) + nTmp, err = u.Code.DecodeFrom(d, maxDepth) n += nTmp if err != nil { - return n, fmt.Errorf("decoding PaymentResultCode: %s", err) + return n, fmt.Errorf("decoding PaymentResultCode: %w", err) } switch PaymentResultCode(u.Code) { case PaymentResultCodePaymentSuccess: @@ -32397,7 +33240,7 @@ func (s PaymentResult) MarshalBinary() ([]byte, error) { func (s *PaymentResult) UnmarshalBinary(inp []byte) error { r := bytes.NewReader(inp) d := xdr.NewDecoder(r) - _, err := s.DecodeFrom(d) + _, err := s.DecodeFrom(d, xdr.DecodeDefaultMaxDepth) return err } @@ -32501,10 +33344,14 @@ func (e PathPaymentStrictReceiveResultCode) EncodeTo(enc *xdr.Encoder) error { var _ decoderFrom = (*PathPaymentStrictReceiveResultCode)(nil) // DecodeFrom decodes this value using the Decoder. -func (e *PathPaymentStrictReceiveResultCode) DecodeFrom(d *xdr.Decoder) (int, error) { +func (e *PathPaymentStrictReceiveResultCode) DecodeFrom(d *xdr.Decoder, maxDepth uint) (int, error) { + if maxDepth == 0 { + return 0, fmt.Errorf("decoding PathPaymentStrictReceiveResultCode: %w", ErrMaxDecodingDepthReached) + } + maxDepth -= 1 v, n, err := d.DecodeInt() if err != nil { - return n, fmt.Errorf("decoding PathPaymentStrictReceiveResultCode: %s", err) + return n, fmt.Errorf("decoding PathPaymentStrictReceiveResultCode: %w", err) } if _, ok := pathPaymentStrictReceiveResultCodeMap[v]; !ok { return n, fmt.Errorf("'%d' is not a valid PathPaymentStrictReceiveResultCode enum value", v) @@ -32525,7 +33372,7 @@ func (s PathPaymentStrictReceiveResultCode) MarshalBinary() ([]byte, error) { func (s *PathPaymentStrictReceiveResultCode) UnmarshalBinary(inp []byte) error { r := bytes.NewReader(inp) d := xdr.NewDecoder(r) - _, err := s.DecodeFrom(d) + _, err := s.DecodeFrom(d, xdr.DecodeDefaultMaxDepth) return err } @@ -32572,23 +33419,27 @@ func (s *SimplePaymentResult) EncodeTo(e *xdr.Encoder) error { var _ decoderFrom = (*SimplePaymentResult)(nil) // DecodeFrom decodes this value using the Decoder. -func (s *SimplePaymentResult) DecodeFrom(d *xdr.Decoder) (int, error) { +func (s *SimplePaymentResult) DecodeFrom(d *xdr.Decoder, maxDepth uint) (int, error) { + if maxDepth == 0 { + return 0, fmt.Errorf("decoding SimplePaymentResult: %w", ErrMaxDecodingDepthReached) + } + maxDepth -= 1 var err error var n, nTmp int - nTmp, err = s.Destination.DecodeFrom(d) + nTmp, err = s.Destination.DecodeFrom(d, maxDepth) n += nTmp if err != nil { - return n, fmt.Errorf("decoding AccountId: %s", err) + return n, fmt.Errorf("decoding AccountId: %w", err) } - nTmp, err = s.Asset.DecodeFrom(d) + nTmp, err = s.Asset.DecodeFrom(d, maxDepth) n += nTmp if err != nil { - return n, fmt.Errorf("decoding Asset: %s", err) + return n, fmt.Errorf("decoding Asset: %w", err) } - nTmp, err = s.Amount.DecodeFrom(d) + nTmp, err = s.Amount.DecodeFrom(d, maxDepth) n += nTmp if err != nil { - return n, fmt.Errorf("decoding Int64: %s", err) + return n, fmt.Errorf("decoding Int64: %w", err) } return n, nil } @@ -32605,7 +33456,7 @@ func (s SimplePaymentResult) MarshalBinary() ([]byte, error) { func (s *SimplePaymentResult) UnmarshalBinary(inp []byte) error { r := bytes.NewReader(inp) d := xdr.NewDecoder(r) - _, err := s.DecodeFrom(d) + _, err := s.DecodeFrom(d, xdr.DecodeDefaultMaxDepth) return err } @@ -32652,30 +33503,34 @@ func (s *PathPaymentStrictReceiveResultSuccess) EncodeTo(e *xdr.Encoder) error { var _ decoderFrom = (*PathPaymentStrictReceiveResultSuccess)(nil) // DecodeFrom decodes this value using the Decoder. -func (s *PathPaymentStrictReceiveResultSuccess) DecodeFrom(d *xdr.Decoder) (int, error) { +func (s *PathPaymentStrictReceiveResultSuccess) DecodeFrom(d *xdr.Decoder, maxDepth uint) (int, error) { + if maxDepth == 0 { + return 0, fmt.Errorf("decoding PathPaymentStrictReceiveResultSuccess: %w", ErrMaxDecodingDepthReached) + } + maxDepth -= 1 var err error var n, nTmp int var l uint32 l, nTmp, err = d.DecodeUint() n += nTmp if err != nil { - return n, fmt.Errorf("decoding ClaimAtom: %s", err) + return n, fmt.Errorf("decoding ClaimAtom: %w", err) } s.Offers = nil if l > 0 { s.Offers = make([]ClaimAtom, l) for i := uint32(0); i < l; i++ { - nTmp, err = s.Offers[i].DecodeFrom(d) + nTmp, err = s.Offers[i].DecodeFrom(d, maxDepth) n += nTmp if err != nil { - return n, fmt.Errorf("decoding ClaimAtom: %s", err) + return n, fmt.Errorf("decoding ClaimAtom: %w", err) } } } - nTmp, err = s.Last.DecodeFrom(d) + nTmp, err = s.Last.DecodeFrom(d, maxDepth) n += nTmp if err != nil { - return n, fmt.Errorf("decoding SimplePaymentResult: %s", err) + return n, fmt.Errorf("decoding SimplePaymentResult: %w", err) } return n, nil } @@ -32692,7 +33547,7 @@ func (s PathPaymentStrictReceiveResultSuccess) MarshalBinary() ([]byte, error) { func (s *PathPaymentStrictReceiveResultSuccess) UnmarshalBinary(inp []byte) error { r := bytes.NewReader(inp) d := xdr.NewDecoder(r) - _, err := s.DecodeFrom(d) + _, err := s.DecodeFrom(d, xdr.DecodeDefaultMaxDepth) return err } @@ -32787,7 +33642,7 @@ func NewPathPaymentStrictReceiveResult(code PathPaymentStrictReceiveResultCode, case PathPaymentStrictReceiveResultCodePathPaymentStrictReceiveSuccess: tv, ok := value.(PathPaymentStrictReceiveResultSuccess) if !ok { - err = fmt.Errorf("invalid value, must be PathPaymentStrictReceiveResultSuccess") + err = errors.New("invalid value, must be PathPaymentStrictReceiveResultSuccess") return } result.Success = &tv @@ -32810,7 +33665,7 @@ func NewPathPaymentStrictReceiveResult(code PathPaymentStrictReceiveResultCode, case PathPaymentStrictReceiveResultCodePathPaymentStrictReceiveNoIssuer: tv, ok := value.(Asset) if !ok { - err = fmt.Errorf("invalid value, must be Asset") + err = errors.New("invalid value, must be Asset") return } result.NoIssuer = &tv @@ -32931,21 +33786,25 @@ func (u PathPaymentStrictReceiveResult) EncodeTo(e *xdr.Encoder) error { var _ decoderFrom = (*PathPaymentStrictReceiveResult)(nil) // DecodeFrom decodes this value using the Decoder. -func (u *PathPaymentStrictReceiveResult) DecodeFrom(d *xdr.Decoder) (int, error) { +func (u *PathPaymentStrictReceiveResult) DecodeFrom(d *xdr.Decoder, maxDepth uint) (int, error) { + if maxDepth == 0 { + return 0, fmt.Errorf("decoding PathPaymentStrictReceiveResult: %w", ErrMaxDecodingDepthReached) + } + maxDepth -= 1 var err error var n, nTmp int - nTmp, err = u.Code.DecodeFrom(d) + nTmp, err = u.Code.DecodeFrom(d, maxDepth) n += nTmp if err != nil { - return n, fmt.Errorf("decoding PathPaymentStrictReceiveResultCode: %s", err) + return n, fmt.Errorf("decoding PathPaymentStrictReceiveResultCode: %w", err) } switch PathPaymentStrictReceiveResultCode(u.Code) { case PathPaymentStrictReceiveResultCodePathPaymentStrictReceiveSuccess: u.Success = new(PathPaymentStrictReceiveResultSuccess) - nTmp, err = (*u.Success).DecodeFrom(d) + nTmp, err = (*u.Success).DecodeFrom(d, maxDepth) n += nTmp if err != nil { - return n, fmt.Errorf("decoding PathPaymentStrictReceiveResultSuccess: %s", err) + return n, fmt.Errorf("decoding PathPaymentStrictReceiveResultSuccess: %w", err) } return n, nil case PathPaymentStrictReceiveResultCodePathPaymentStrictReceiveMalformed: @@ -32974,10 +33833,10 @@ func (u *PathPaymentStrictReceiveResult) DecodeFrom(d *xdr.Decoder) (int, error) return n, nil case PathPaymentStrictReceiveResultCodePathPaymentStrictReceiveNoIssuer: u.NoIssuer = new(Asset) - nTmp, err = (*u.NoIssuer).DecodeFrom(d) + nTmp, err = (*u.NoIssuer).DecodeFrom(d, maxDepth) n += nTmp if err != nil { - return n, fmt.Errorf("decoding Asset: %s", err) + return n, fmt.Errorf("decoding Asset: %w", err) } return n, nil case PathPaymentStrictReceiveResultCodePathPaymentStrictReceiveTooFewOffers: @@ -33005,7 +33864,7 @@ func (s PathPaymentStrictReceiveResult) MarshalBinary() ([]byte, error) { func (s *PathPaymentStrictReceiveResult) UnmarshalBinary(inp []byte) error { r := bytes.NewReader(inp) d := xdr.NewDecoder(r) - _, err := s.DecodeFrom(d) + _, err := s.DecodeFrom(d, xdr.DecodeDefaultMaxDepth) return err } @@ -33108,10 +33967,14 @@ func (e PathPaymentStrictSendResultCode) EncodeTo(enc *xdr.Encoder) error { var _ decoderFrom = (*PathPaymentStrictSendResultCode)(nil) // DecodeFrom decodes this value using the Decoder. -func (e *PathPaymentStrictSendResultCode) DecodeFrom(d *xdr.Decoder) (int, error) { +func (e *PathPaymentStrictSendResultCode) DecodeFrom(d *xdr.Decoder, maxDepth uint) (int, error) { + if maxDepth == 0 { + return 0, fmt.Errorf("decoding PathPaymentStrictSendResultCode: %w", ErrMaxDecodingDepthReached) + } + maxDepth -= 1 v, n, err := d.DecodeInt() if err != nil { - return n, fmt.Errorf("decoding PathPaymentStrictSendResultCode: %s", err) + return n, fmt.Errorf("decoding PathPaymentStrictSendResultCode: %w", err) } if _, ok := pathPaymentStrictSendResultCodeMap[v]; !ok { return n, fmt.Errorf("'%d' is not a valid PathPaymentStrictSendResultCode enum value", v) @@ -33132,7 +33995,7 @@ func (s PathPaymentStrictSendResultCode) MarshalBinary() ([]byte, error) { func (s *PathPaymentStrictSendResultCode) UnmarshalBinary(inp []byte) error { r := bytes.NewReader(inp) d := xdr.NewDecoder(r) - _, err := s.DecodeFrom(d) + _, err := s.DecodeFrom(d, xdr.DecodeDefaultMaxDepth) return err } @@ -33179,30 +34042,34 @@ func (s *PathPaymentStrictSendResultSuccess) EncodeTo(e *xdr.Encoder) error { var _ decoderFrom = (*PathPaymentStrictSendResultSuccess)(nil) // DecodeFrom decodes this value using the Decoder. -func (s *PathPaymentStrictSendResultSuccess) DecodeFrom(d *xdr.Decoder) (int, error) { +func (s *PathPaymentStrictSendResultSuccess) DecodeFrom(d *xdr.Decoder, maxDepth uint) (int, error) { + if maxDepth == 0 { + return 0, fmt.Errorf("decoding PathPaymentStrictSendResultSuccess: %w", ErrMaxDecodingDepthReached) + } + maxDepth -= 1 var err error var n, nTmp int var l uint32 l, nTmp, err = d.DecodeUint() n += nTmp if err != nil { - return n, fmt.Errorf("decoding ClaimAtom: %s", err) + return n, fmt.Errorf("decoding ClaimAtom: %w", err) } s.Offers = nil if l > 0 { s.Offers = make([]ClaimAtom, l) for i := uint32(0); i < l; i++ { - nTmp, err = s.Offers[i].DecodeFrom(d) + nTmp, err = s.Offers[i].DecodeFrom(d, maxDepth) n += nTmp if err != nil { - return n, fmt.Errorf("decoding ClaimAtom: %s", err) + return n, fmt.Errorf("decoding ClaimAtom: %w", err) } } } - nTmp, err = s.Last.DecodeFrom(d) + nTmp, err = s.Last.DecodeFrom(d, maxDepth) n += nTmp if err != nil { - return n, fmt.Errorf("decoding SimplePaymentResult: %s", err) + return n, fmt.Errorf("decoding SimplePaymentResult: %w", err) } return n, nil } @@ -33219,7 +34086,7 @@ func (s PathPaymentStrictSendResultSuccess) MarshalBinary() ([]byte, error) { func (s *PathPaymentStrictSendResultSuccess) UnmarshalBinary(inp []byte) error { r := bytes.NewReader(inp) d := xdr.NewDecoder(r) - _, err := s.DecodeFrom(d) + _, err := s.DecodeFrom(d, xdr.DecodeDefaultMaxDepth) return err } @@ -33313,7 +34180,7 @@ func NewPathPaymentStrictSendResult(code PathPaymentStrictSendResultCode, value case PathPaymentStrictSendResultCodePathPaymentStrictSendSuccess: tv, ok := value.(PathPaymentStrictSendResultSuccess) if !ok { - err = fmt.Errorf("invalid value, must be PathPaymentStrictSendResultSuccess") + err = errors.New("invalid value, must be PathPaymentStrictSendResultSuccess") return } result.Success = &tv @@ -33336,7 +34203,7 @@ func NewPathPaymentStrictSendResult(code PathPaymentStrictSendResultCode, value case PathPaymentStrictSendResultCodePathPaymentStrictSendNoIssuer: tv, ok := value.(Asset) if !ok { - err = fmt.Errorf("invalid value, must be Asset") + err = errors.New("invalid value, must be Asset") return } result.NoIssuer = &tv @@ -33457,21 +34324,25 @@ func (u PathPaymentStrictSendResult) EncodeTo(e *xdr.Encoder) error { var _ decoderFrom = (*PathPaymentStrictSendResult)(nil) // DecodeFrom decodes this value using the Decoder. -func (u *PathPaymentStrictSendResult) DecodeFrom(d *xdr.Decoder) (int, error) { +func (u *PathPaymentStrictSendResult) DecodeFrom(d *xdr.Decoder, maxDepth uint) (int, error) { + if maxDepth == 0 { + return 0, fmt.Errorf("decoding PathPaymentStrictSendResult: %w", ErrMaxDecodingDepthReached) + } + maxDepth -= 1 var err error var n, nTmp int - nTmp, err = u.Code.DecodeFrom(d) + nTmp, err = u.Code.DecodeFrom(d, maxDepth) n += nTmp if err != nil { - return n, fmt.Errorf("decoding PathPaymentStrictSendResultCode: %s", err) + return n, fmt.Errorf("decoding PathPaymentStrictSendResultCode: %w", err) } switch PathPaymentStrictSendResultCode(u.Code) { case PathPaymentStrictSendResultCodePathPaymentStrictSendSuccess: u.Success = new(PathPaymentStrictSendResultSuccess) - nTmp, err = (*u.Success).DecodeFrom(d) + nTmp, err = (*u.Success).DecodeFrom(d, maxDepth) n += nTmp if err != nil { - return n, fmt.Errorf("decoding PathPaymentStrictSendResultSuccess: %s", err) + return n, fmt.Errorf("decoding PathPaymentStrictSendResultSuccess: %w", err) } return n, nil case PathPaymentStrictSendResultCodePathPaymentStrictSendMalformed: @@ -33500,10 +34371,10 @@ func (u *PathPaymentStrictSendResult) DecodeFrom(d *xdr.Decoder) (int, error) { return n, nil case PathPaymentStrictSendResultCodePathPaymentStrictSendNoIssuer: u.NoIssuer = new(Asset) - nTmp, err = (*u.NoIssuer).DecodeFrom(d) + nTmp, err = (*u.NoIssuer).DecodeFrom(d, maxDepth) n += nTmp if err != nil { - return n, fmt.Errorf("decoding Asset: %s", err) + return n, fmt.Errorf("decoding Asset: %w", err) } return n, nil case PathPaymentStrictSendResultCodePathPaymentStrictSendTooFewOffers: @@ -33531,7 +34402,7 @@ func (s PathPaymentStrictSendResult) MarshalBinary() ([]byte, error) { func (s *PathPaymentStrictSendResult) UnmarshalBinary(inp []byte) error { r := bytes.NewReader(inp) d := xdr.NewDecoder(r) - _, err := s.DecodeFrom(d) + _, err := s.DecodeFrom(d, xdr.DecodeDefaultMaxDepth) return err } @@ -33633,10 +34504,14 @@ func (e ManageSellOfferResultCode) EncodeTo(enc *xdr.Encoder) error { var _ decoderFrom = (*ManageSellOfferResultCode)(nil) // DecodeFrom decodes this value using the Decoder. -func (e *ManageSellOfferResultCode) DecodeFrom(d *xdr.Decoder) (int, error) { +func (e *ManageSellOfferResultCode) DecodeFrom(d *xdr.Decoder, maxDepth uint) (int, error) { + if maxDepth == 0 { + return 0, fmt.Errorf("decoding ManageSellOfferResultCode: %w", ErrMaxDecodingDepthReached) + } + maxDepth -= 1 v, n, err := d.DecodeInt() if err != nil { - return n, fmt.Errorf("decoding ManageSellOfferResultCode: %s", err) + return n, fmt.Errorf("decoding ManageSellOfferResultCode: %w", err) } if _, ok := manageSellOfferResultCodeMap[v]; !ok { return n, fmt.Errorf("'%d' is not a valid ManageSellOfferResultCode enum value", v) @@ -33657,7 +34532,7 @@ func (s ManageSellOfferResultCode) MarshalBinary() ([]byte, error) { func (s *ManageSellOfferResultCode) UnmarshalBinary(inp []byte) error { r := bytes.NewReader(inp) d := xdr.NewDecoder(r) - _, err := s.DecodeFrom(d) + _, err := s.DecodeFrom(d, xdr.DecodeDefaultMaxDepth) return err } @@ -33719,10 +34594,14 @@ func (e ManageOfferEffect) EncodeTo(enc *xdr.Encoder) error { var _ decoderFrom = (*ManageOfferEffect)(nil) // DecodeFrom decodes this value using the Decoder. -func (e *ManageOfferEffect) DecodeFrom(d *xdr.Decoder) (int, error) { +func (e *ManageOfferEffect) DecodeFrom(d *xdr.Decoder, maxDepth uint) (int, error) { + if maxDepth == 0 { + return 0, fmt.Errorf("decoding ManageOfferEffect: %w", ErrMaxDecodingDepthReached) + } + maxDepth -= 1 v, n, err := d.DecodeInt() if err != nil { - return n, fmt.Errorf("decoding ManageOfferEffect: %s", err) + return n, fmt.Errorf("decoding ManageOfferEffect: %w", err) } if _, ok := manageOfferEffectMap[v]; !ok { return n, fmt.Errorf("'%d' is not a valid ManageOfferEffect enum value", v) @@ -33743,7 +34622,7 @@ func (s ManageOfferEffect) MarshalBinary() ([]byte, error) { func (s *ManageOfferEffect) UnmarshalBinary(inp []byte) error { r := bytes.NewReader(inp) d := xdr.NewDecoder(r) - _, err := s.DecodeFrom(d) + _, err := s.DecodeFrom(d, xdr.DecodeDefaultMaxDepth) return err } @@ -33800,14 +34679,14 @@ func NewManageOfferSuccessResultOffer(effect ManageOfferEffect, value interface{ case ManageOfferEffectManageOfferCreated: tv, ok := value.(OfferEntry) if !ok { - err = fmt.Errorf("invalid value, must be OfferEntry") + err = errors.New("invalid value, must be OfferEntry") return } result.Offer = &tv case ManageOfferEffectManageOfferUpdated: tv, ok := value.(OfferEntry) if !ok { - err = fmt.Errorf("invalid value, must be OfferEntry") + err = errors.New("invalid value, must be OfferEntry") return } result.Offer = &tv @@ -33869,29 +34748,33 @@ func (u ManageOfferSuccessResultOffer) EncodeTo(e *xdr.Encoder) error { var _ decoderFrom = (*ManageOfferSuccessResultOffer)(nil) // DecodeFrom decodes this value using the Decoder. -func (u *ManageOfferSuccessResultOffer) DecodeFrom(d *xdr.Decoder) (int, error) { +func (u *ManageOfferSuccessResultOffer) DecodeFrom(d *xdr.Decoder, maxDepth uint) (int, error) { + if maxDepth == 0 { + return 0, fmt.Errorf("decoding ManageOfferSuccessResultOffer: %w", ErrMaxDecodingDepthReached) + } + maxDepth -= 1 var err error var n, nTmp int - nTmp, err = u.Effect.DecodeFrom(d) + nTmp, err = u.Effect.DecodeFrom(d, maxDepth) n += nTmp if err != nil { - return n, fmt.Errorf("decoding ManageOfferEffect: %s", err) + return n, fmt.Errorf("decoding ManageOfferEffect: %w", err) } switch ManageOfferEffect(u.Effect) { case ManageOfferEffectManageOfferCreated: u.Offer = new(OfferEntry) - nTmp, err = (*u.Offer).DecodeFrom(d) + nTmp, err = (*u.Offer).DecodeFrom(d, maxDepth) n += nTmp if err != nil { - return n, fmt.Errorf("decoding OfferEntry: %s", err) + return n, fmt.Errorf("decoding OfferEntry: %w", err) } return n, nil case ManageOfferEffectManageOfferUpdated: u.Offer = new(OfferEntry) - nTmp, err = (*u.Offer).DecodeFrom(d) + nTmp, err = (*u.Offer).DecodeFrom(d, maxDepth) n += nTmp if err != nil { - return n, fmt.Errorf("decoding OfferEntry: %s", err) + return n, fmt.Errorf("decoding OfferEntry: %w", err) } return n, nil case ManageOfferEffectManageOfferDeleted: @@ -33913,7 +34796,7 @@ func (s ManageOfferSuccessResultOffer) MarshalBinary() ([]byte, error) { func (s *ManageOfferSuccessResultOffer) UnmarshalBinary(inp []byte) error { r := bytes.NewReader(inp) d := xdr.NewDecoder(r) - _, err := s.DecodeFrom(d) + _, err := s.DecodeFrom(d, xdr.DecodeDefaultMaxDepth) return err } @@ -33970,30 +34853,34 @@ func (s *ManageOfferSuccessResult) EncodeTo(e *xdr.Encoder) error { var _ decoderFrom = (*ManageOfferSuccessResult)(nil) // DecodeFrom decodes this value using the Decoder. -func (s *ManageOfferSuccessResult) DecodeFrom(d *xdr.Decoder) (int, error) { +func (s *ManageOfferSuccessResult) DecodeFrom(d *xdr.Decoder, maxDepth uint) (int, error) { + if maxDepth == 0 { + return 0, fmt.Errorf("decoding ManageOfferSuccessResult: %w", ErrMaxDecodingDepthReached) + } + maxDepth -= 1 var err error var n, nTmp int var l uint32 l, nTmp, err = d.DecodeUint() n += nTmp if err != nil { - return n, fmt.Errorf("decoding ClaimAtom: %s", err) + return n, fmt.Errorf("decoding ClaimAtom: %w", err) } s.OffersClaimed = nil if l > 0 { s.OffersClaimed = make([]ClaimAtom, l) for i := uint32(0); i < l; i++ { - nTmp, err = s.OffersClaimed[i].DecodeFrom(d) + nTmp, err = s.OffersClaimed[i].DecodeFrom(d, maxDepth) n += nTmp if err != nil { - return n, fmt.Errorf("decoding ClaimAtom: %s", err) + return n, fmt.Errorf("decoding ClaimAtom: %w", err) } } } - nTmp, err = s.Offer.DecodeFrom(d) + nTmp, err = s.Offer.DecodeFrom(d, maxDepth) n += nTmp if err != nil { - return n, fmt.Errorf("decoding ManageOfferSuccessResultOffer: %s", err) + return n, fmt.Errorf("decoding ManageOfferSuccessResultOffer: %w", err) } return n, nil } @@ -34010,7 +34897,7 @@ func (s ManageOfferSuccessResult) MarshalBinary() ([]byte, error) { func (s *ManageOfferSuccessResult) UnmarshalBinary(inp []byte) error { r := bytes.NewReader(inp) d := xdr.NewDecoder(r) - _, err := s.DecodeFrom(d) + _, err := s.DecodeFrom(d, xdr.DecodeDefaultMaxDepth) return err } @@ -34097,7 +34984,7 @@ func NewManageSellOfferResult(code ManageSellOfferResultCode, value interface{}) case ManageSellOfferResultCodeManageSellOfferSuccess: tv, ok := value.(ManageOfferSuccessResult) if !ok { - err = fmt.Errorf("invalid value, must be ManageOfferSuccessResult") + err = errors.New("invalid value, must be ManageOfferSuccessResult") return } result.Success = &tv @@ -34209,21 +35096,25 @@ func (u ManageSellOfferResult) EncodeTo(e *xdr.Encoder) error { var _ decoderFrom = (*ManageSellOfferResult)(nil) // DecodeFrom decodes this value using the Decoder. -func (u *ManageSellOfferResult) DecodeFrom(d *xdr.Decoder) (int, error) { +func (u *ManageSellOfferResult) DecodeFrom(d *xdr.Decoder, maxDepth uint) (int, error) { + if maxDepth == 0 { + return 0, fmt.Errorf("decoding ManageSellOfferResult: %w", ErrMaxDecodingDepthReached) + } + maxDepth -= 1 var err error var n, nTmp int - nTmp, err = u.Code.DecodeFrom(d) + nTmp, err = u.Code.DecodeFrom(d, maxDepth) n += nTmp if err != nil { - return n, fmt.Errorf("decoding ManageSellOfferResultCode: %s", err) + return n, fmt.Errorf("decoding ManageSellOfferResultCode: %w", err) } switch ManageSellOfferResultCode(u.Code) { case ManageSellOfferResultCodeManageSellOfferSuccess: u.Success = new(ManageOfferSuccessResult) - nTmp, err = (*u.Success).DecodeFrom(d) + nTmp, err = (*u.Success).DecodeFrom(d, maxDepth) n += nTmp if err != nil { - return n, fmt.Errorf("decoding ManageOfferSuccessResult: %s", err) + return n, fmt.Errorf("decoding ManageOfferSuccessResult: %w", err) } return n, nil case ManageSellOfferResultCodeManageSellOfferMalformed: @@ -34278,7 +35169,7 @@ func (s ManageSellOfferResult) MarshalBinary() ([]byte, error) { func (s *ManageSellOfferResult) UnmarshalBinary(inp []byte) error { r := bytes.NewReader(inp) d := xdr.NewDecoder(r) - _, err := s.DecodeFrom(d) + _, err := s.DecodeFrom(d, xdr.DecodeDefaultMaxDepth) return err } @@ -34377,10 +35268,14 @@ func (e ManageBuyOfferResultCode) EncodeTo(enc *xdr.Encoder) error { var _ decoderFrom = (*ManageBuyOfferResultCode)(nil) // DecodeFrom decodes this value using the Decoder. -func (e *ManageBuyOfferResultCode) DecodeFrom(d *xdr.Decoder) (int, error) { +func (e *ManageBuyOfferResultCode) DecodeFrom(d *xdr.Decoder, maxDepth uint) (int, error) { + if maxDepth == 0 { + return 0, fmt.Errorf("decoding ManageBuyOfferResultCode: %w", ErrMaxDecodingDepthReached) + } + maxDepth -= 1 v, n, err := d.DecodeInt() if err != nil { - return n, fmt.Errorf("decoding ManageBuyOfferResultCode: %s", err) + return n, fmt.Errorf("decoding ManageBuyOfferResultCode: %w", err) } if _, ok := manageBuyOfferResultCodeMap[v]; !ok { return n, fmt.Errorf("'%d' is not a valid ManageBuyOfferResultCode enum value", v) @@ -34401,7 +35296,7 @@ func (s ManageBuyOfferResultCode) MarshalBinary() ([]byte, error) { func (s *ManageBuyOfferResultCode) UnmarshalBinary(inp []byte) error { r := bytes.NewReader(inp) d := xdr.NewDecoder(r) - _, err := s.DecodeFrom(d) + _, err := s.DecodeFrom(d, xdr.DecodeDefaultMaxDepth) return err } @@ -34488,7 +35383,7 @@ func NewManageBuyOfferResult(code ManageBuyOfferResultCode, value interface{}) ( case ManageBuyOfferResultCodeManageBuyOfferSuccess: tv, ok := value.(ManageOfferSuccessResult) if !ok { - err = fmt.Errorf("invalid value, must be ManageOfferSuccessResult") + err = errors.New("invalid value, must be ManageOfferSuccessResult") return } result.Success = &tv @@ -34600,21 +35495,25 @@ func (u ManageBuyOfferResult) EncodeTo(e *xdr.Encoder) error { var _ decoderFrom = (*ManageBuyOfferResult)(nil) // DecodeFrom decodes this value using the Decoder. -func (u *ManageBuyOfferResult) DecodeFrom(d *xdr.Decoder) (int, error) { +func (u *ManageBuyOfferResult) DecodeFrom(d *xdr.Decoder, maxDepth uint) (int, error) { + if maxDepth == 0 { + return 0, fmt.Errorf("decoding ManageBuyOfferResult: %w", ErrMaxDecodingDepthReached) + } + maxDepth -= 1 var err error var n, nTmp int - nTmp, err = u.Code.DecodeFrom(d) + nTmp, err = u.Code.DecodeFrom(d, maxDepth) n += nTmp if err != nil { - return n, fmt.Errorf("decoding ManageBuyOfferResultCode: %s", err) + return n, fmt.Errorf("decoding ManageBuyOfferResultCode: %w", err) } switch ManageBuyOfferResultCode(u.Code) { case ManageBuyOfferResultCodeManageBuyOfferSuccess: u.Success = new(ManageOfferSuccessResult) - nTmp, err = (*u.Success).DecodeFrom(d) + nTmp, err = (*u.Success).DecodeFrom(d, maxDepth) n += nTmp if err != nil { - return n, fmt.Errorf("decoding ManageOfferSuccessResult: %s", err) + return n, fmt.Errorf("decoding ManageOfferSuccessResult: %w", err) } return n, nil case ManageBuyOfferResultCodeManageBuyOfferMalformed: @@ -34669,7 +35568,7 @@ func (s ManageBuyOfferResult) MarshalBinary() ([]byte, error) { func (s *ManageBuyOfferResult) UnmarshalBinary(inp []byte) error { r := bytes.NewReader(inp) d := xdr.NewDecoder(r) - _, err := s.DecodeFrom(d) + _, err := s.DecodeFrom(d, xdr.DecodeDefaultMaxDepth) return err } @@ -34758,10 +35657,14 @@ func (e SetOptionsResultCode) EncodeTo(enc *xdr.Encoder) error { var _ decoderFrom = (*SetOptionsResultCode)(nil) // DecodeFrom decodes this value using the Decoder. -func (e *SetOptionsResultCode) DecodeFrom(d *xdr.Decoder) (int, error) { +func (e *SetOptionsResultCode) DecodeFrom(d *xdr.Decoder, maxDepth uint) (int, error) { + if maxDepth == 0 { + return 0, fmt.Errorf("decoding SetOptionsResultCode: %w", ErrMaxDecodingDepthReached) + } + maxDepth -= 1 v, n, err := d.DecodeInt() if err != nil { - return n, fmt.Errorf("decoding SetOptionsResultCode: %s", err) + return n, fmt.Errorf("decoding SetOptionsResultCode: %w", err) } if _, ok := setOptionsResultCodeMap[v]; !ok { return n, fmt.Errorf("'%d' is not a valid SetOptionsResultCode enum value", v) @@ -34782,7 +35685,7 @@ func (s SetOptionsResultCode) MarshalBinary() ([]byte, error) { func (s *SetOptionsResultCode) UnmarshalBinary(inp []byte) error { r := bytes.NewReader(inp) d := xdr.NewDecoder(r) - _, err := s.DecodeFrom(d) + _, err := s.DecodeFrom(d, xdr.DecodeDefaultMaxDepth) return err } @@ -34932,13 +35835,17 @@ func (u SetOptionsResult) EncodeTo(e *xdr.Encoder) error { var _ decoderFrom = (*SetOptionsResult)(nil) // DecodeFrom decodes this value using the Decoder. -func (u *SetOptionsResult) DecodeFrom(d *xdr.Decoder) (int, error) { +func (u *SetOptionsResult) DecodeFrom(d *xdr.Decoder, maxDepth uint) (int, error) { + if maxDepth == 0 { + return 0, fmt.Errorf("decoding SetOptionsResult: %w", ErrMaxDecodingDepthReached) + } + maxDepth -= 1 var err error var n, nTmp int - nTmp, err = u.Code.DecodeFrom(d) + nTmp, err = u.Code.DecodeFrom(d, maxDepth) n += nTmp if err != nil { - return n, fmt.Errorf("decoding SetOptionsResultCode: %s", err) + return n, fmt.Errorf("decoding SetOptionsResultCode: %w", err) } switch SetOptionsResultCode(u.Code) { case SetOptionsResultCodeSetOptionsSuccess: @@ -34990,7 +35897,7 @@ func (s SetOptionsResult) MarshalBinary() ([]byte, error) { func (s *SetOptionsResult) UnmarshalBinary(inp []byte) error { r := bytes.NewReader(inp) d := xdr.NewDecoder(r) - _, err := s.DecodeFrom(d) + _, err := s.DecodeFrom(d, xdr.DecodeDefaultMaxDepth) return err } @@ -35076,10 +35983,14 @@ func (e ChangeTrustResultCode) EncodeTo(enc *xdr.Encoder) error { var _ decoderFrom = (*ChangeTrustResultCode)(nil) // DecodeFrom decodes this value using the Decoder. -func (e *ChangeTrustResultCode) DecodeFrom(d *xdr.Decoder) (int, error) { +func (e *ChangeTrustResultCode) DecodeFrom(d *xdr.Decoder, maxDepth uint) (int, error) { + if maxDepth == 0 { + return 0, fmt.Errorf("decoding ChangeTrustResultCode: %w", ErrMaxDecodingDepthReached) + } + maxDepth -= 1 v, n, err := d.DecodeInt() if err != nil { - return n, fmt.Errorf("decoding ChangeTrustResultCode: %s", err) + return n, fmt.Errorf("decoding ChangeTrustResultCode: %w", err) } if _, ok := changeTrustResultCodeMap[v]; !ok { return n, fmt.Errorf("'%d' is not a valid ChangeTrustResultCode enum value", v) @@ -35100,7 +36011,7 @@ func (s ChangeTrustResultCode) MarshalBinary() ([]byte, error) { func (s *ChangeTrustResultCode) UnmarshalBinary(inp []byte) error { r := bytes.NewReader(inp) d := xdr.NewDecoder(r) - _, err := s.DecodeFrom(d) + _, err := s.DecodeFrom(d, xdr.DecodeDefaultMaxDepth) return err } @@ -35234,13 +36145,17 @@ func (u ChangeTrustResult) EncodeTo(e *xdr.Encoder) error { var _ decoderFrom = (*ChangeTrustResult)(nil) // DecodeFrom decodes this value using the Decoder. -func (u *ChangeTrustResult) DecodeFrom(d *xdr.Decoder) (int, error) { +func (u *ChangeTrustResult) DecodeFrom(d *xdr.Decoder, maxDepth uint) (int, error) { + if maxDepth == 0 { + return 0, fmt.Errorf("decoding ChangeTrustResult: %w", ErrMaxDecodingDepthReached) + } + maxDepth -= 1 var err error var n, nTmp int - nTmp, err = u.Code.DecodeFrom(d) + nTmp, err = u.Code.DecodeFrom(d, maxDepth) n += nTmp if err != nil { - return n, fmt.Errorf("decoding ChangeTrustResultCode: %s", err) + return n, fmt.Errorf("decoding ChangeTrustResultCode: %w", err) } switch ChangeTrustResultCode(u.Code) { case ChangeTrustResultCodeChangeTrustSuccess: @@ -35286,7 +36201,7 @@ func (s ChangeTrustResult) MarshalBinary() ([]byte, error) { func (s *ChangeTrustResult) UnmarshalBinary(inp []byte) error { r := bytes.NewReader(inp) d := xdr.NewDecoder(r) - _, err := s.DecodeFrom(d) + _, err := s.DecodeFrom(d, xdr.DecodeDefaultMaxDepth) return err } @@ -35364,10 +36279,14 @@ func (e AllowTrustResultCode) EncodeTo(enc *xdr.Encoder) error { var _ decoderFrom = (*AllowTrustResultCode)(nil) // DecodeFrom decodes this value using the Decoder. -func (e *AllowTrustResultCode) DecodeFrom(d *xdr.Decoder) (int, error) { +func (e *AllowTrustResultCode) DecodeFrom(d *xdr.Decoder, maxDepth uint) (int, error) { + if maxDepth == 0 { + return 0, fmt.Errorf("decoding AllowTrustResultCode: %w", ErrMaxDecodingDepthReached) + } + maxDepth -= 1 v, n, err := d.DecodeInt() if err != nil { - return n, fmt.Errorf("decoding AllowTrustResultCode: %s", err) + return n, fmt.Errorf("decoding AllowTrustResultCode: %w", err) } if _, ok := allowTrustResultCodeMap[v]; !ok { return n, fmt.Errorf("'%d' is not a valid AllowTrustResultCode enum value", v) @@ -35388,7 +36307,7 @@ func (s AllowTrustResultCode) MarshalBinary() ([]byte, error) { func (s *AllowTrustResultCode) UnmarshalBinary(inp []byte) error { r := bytes.NewReader(inp) d := xdr.NewDecoder(r) - _, err := s.DecodeFrom(d) + _, err := s.DecodeFrom(d, xdr.DecodeDefaultMaxDepth) return err } @@ -35506,13 +36425,17 @@ func (u AllowTrustResult) EncodeTo(e *xdr.Encoder) error { var _ decoderFrom = (*AllowTrustResult)(nil) // DecodeFrom decodes this value using the Decoder. -func (u *AllowTrustResult) DecodeFrom(d *xdr.Decoder) (int, error) { +func (u *AllowTrustResult) DecodeFrom(d *xdr.Decoder, maxDepth uint) (int, error) { + if maxDepth == 0 { + return 0, fmt.Errorf("decoding AllowTrustResult: %w", ErrMaxDecodingDepthReached) + } + maxDepth -= 1 var err error var n, nTmp int - nTmp, err = u.Code.DecodeFrom(d) + nTmp, err = u.Code.DecodeFrom(d, maxDepth) n += nTmp if err != nil { - return n, fmt.Errorf("decoding AllowTrustResultCode: %s", err) + return n, fmt.Errorf("decoding AllowTrustResultCode: %w", err) } switch AllowTrustResultCode(u.Code) { case AllowTrustResultCodeAllowTrustSuccess: @@ -35552,7 +36475,7 @@ func (s AllowTrustResult) MarshalBinary() ([]byte, error) { func (s *AllowTrustResult) UnmarshalBinary(inp []byte) error { r := bytes.NewReader(inp) d := xdr.NewDecoder(r) - _, err := s.DecodeFrom(d) + _, err := s.DecodeFrom(d, xdr.DecodeDefaultMaxDepth) return err } @@ -35632,10 +36555,14 @@ func (e AccountMergeResultCode) EncodeTo(enc *xdr.Encoder) error { var _ decoderFrom = (*AccountMergeResultCode)(nil) // DecodeFrom decodes this value using the Decoder. -func (e *AccountMergeResultCode) DecodeFrom(d *xdr.Decoder) (int, error) { +func (e *AccountMergeResultCode) DecodeFrom(d *xdr.Decoder, maxDepth uint) (int, error) { + if maxDepth == 0 { + return 0, fmt.Errorf("decoding AccountMergeResultCode: %w", ErrMaxDecodingDepthReached) + } + maxDepth -= 1 v, n, err := d.DecodeInt() if err != nil { - return n, fmt.Errorf("decoding AccountMergeResultCode: %s", err) + return n, fmt.Errorf("decoding AccountMergeResultCode: %w", err) } if _, ok := accountMergeResultCodeMap[v]; !ok { return n, fmt.Errorf("'%d' is not a valid AccountMergeResultCode enum value", v) @@ -35656,7 +36583,7 @@ func (s AccountMergeResultCode) MarshalBinary() ([]byte, error) { func (s *AccountMergeResultCode) UnmarshalBinary(inp []byte) error { r := bytes.NewReader(inp) d := xdr.NewDecoder(r) - _, err := s.DecodeFrom(d) + _, err := s.DecodeFrom(d, xdr.DecodeDefaultMaxDepth) return err } @@ -35728,7 +36655,7 @@ func NewAccountMergeResult(code AccountMergeResultCode, value interface{}) (resu case AccountMergeResultCodeAccountMergeSuccess: tv, ok := value.(Int64) if !ok { - err = fmt.Errorf("invalid value, must be Int64") + err = errors.New("invalid value, must be Int64") return } result.SourceAccountBalance = &tv @@ -35815,21 +36742,25 @@ func (u AccountMergeResult) EncodeTo(e *xdr.Encoder) error { var _ decoderFrom = (*AccountMergeResult)(nil) // DecodeFrom decodes this value using the Decoder. -func (u *AccountMergeResult) DecodeFrom(d *xdr.Decoder) (int, error) { +func (u *AccountMergeResult) DecodeFrom(d *xdr.Decoder, maxDepth uint) (int, error) { + if maxDepth == 0 { + return 0, fmt.Errorf("decoding AccountMergeResult: %w", ErrMaxDecodingDepthReached) + } + maxDepth -= 1 var err error var n, nTmp int - nTmp, err = u.Code.DecodeFrom(d) + nTmp, err = u.Code.DecodeFrom(d, maxDepth) n += nTmp if err != nil { - return n, fmt.Errorf("decoding AccountMergeResultCode: %s", err) + return n, fmt.Errorf("decoding AccountMergeResultCode: %w", err) } switch AccountMergeResultCode(u.Code) { case AccountMergeResultCodeAccountMergeSuccess: u.SourceAccountBalance = new(Int64) - nTmp, err = (*u.SourceAccountBalance).DecodeFrom(d) + nTmp, err = (*u.SourceAccountBalance).DecodeFrom(d, maxDepth) n += nTmp if err != nil { - return n, fmt.Errorf("decoding Int64: %s", err) + return n, fmt.Errorf("decoding Int64: %w", err) } return n, nil case AccountMergeResultCodeAccountMergeMalformed: @@ -35869,7 +36800,7 @@ func (s AccountMergeResult) MarshalBinary() ([]byte, error) { func (s *AccountMergeResult) UnmarshalBinary(inp []byte) error { r := bytes.NewReader(inp) d := xdr.NewDecoder(r) - _, err := s.DecodeFrom(d) + _, err := s.DecodeFrom(d, xdr.DecodeDefaultMaxDepth) return err } @@ -35930,10 +36861,14 @@ func (e InflationResultCode) EncodeTo(enc *xdr.Encoder) error { var _ decoderFrom = (*InflationResultCode)(nil) // DecodeFrom decodes this value using the Decoder. -func (e *InflationResultCode) DecodeFrom(d *xdr.Decoder) (int, error) { +func (e *InflationResultCode) DecodeFrom(d *xdr.Decoder, maxDepth uint) (int, error) { + if maxDepth == 0 { + return 0, fmt.Errorf("decoding InflationResultCode: %w", ErrMaxDecodingDepthReached) + } + maxDepth -= 1 v, n, err := d.DecodeInt() if err != nil { - return n, fmt.Errorf("decoding InflationResultCode: %s", err) + return n, fmt.Errorf("decoding InflationResultCode: %w", err) } if _, ok := inflationResultCodeMap[v]; !ok { return n, fmt.Errorf("'%d' is not a valid InflationResultCode enum value", v) @@ -35954,7 +36889,7 @@ func (s InflationResultCode) MarshalBinary() ([]byte, error) { func (s *InflationResultCode) UnmarshalBinary(inp []byte) error { r := bytes.NewReader(inp) d := xdr.NewDecoder(r) - _, err := s.DecodeFrom(d) + _, err := s.DecodeFrom(d, xdr.DecodeDefaultMaxDepth) return err } @@ -35996,18 +36931,22 @@ func (s *InflationPayout) EncodeTo(e *xdr.Encoder) error { var _ decoderFrom = (*InflationPayout)(nil) // DecodeFrom decodes this value using the Decoder. -func (s *InflationPayout) DecodeFrom(d *xdr.Decoder) (int, error) { +func (s *InflationPayout) DecodeFrom(d *xdr.Decoder, maxDepth uint) (int, error) { + if maxDepth == 0 { + return 0, fmt.Errorf("decoding InflationPayout: %w", ErrMaxDecodingDepthReached) + } + maxDepth -= 1 var err error var n, nTmp int - nTmp, err = s.Destination.DecodeFrom(d) + nTmp, err = s.Destination.DecodeFrom(d, maxDepth) n += nTmp if err != nil { - return n, fmt.Errorf("decoding AccountId: %s", err) + return n, fmt.Errorf("decoding AccountId: %w", err) } - nTmp, err = s.Amount.DecodeFrom(d) + nTmp, err = s.Amount.DecodeFrom(d, maxDepth) n += nTmp if err != nil { - return n, fmt.Errorf("decoding Int64: %s", err) + return n, fmt.Errorf("decoding Int64: %w", err) } return n, nil } @@ -36024,7 +36963,7 @@ func (s InflationPayout) MarshalBinary() ([]byte, error) { func (s *InflationPayout) UnmarshalBinary(inp []byte) error { r := bytes.NewReader(inp) d := xdr.NewDecoder(r) - _, err := s.DecodeFrom(d) + _, err := s.DecodeFrom(d, xdr.DecodeDefaultMaxDepth) return err } @@ -36078,7 +37017,7 @@ func NewInflationResult(code InflationResultCode, value interface{}) (result Inf case InflationResultCodeInflationSuccess: tv, ok := value.([]InflationPayout) if !ok { - err = fmt.Errorf("invalid value, must be []InflationPayout") + err = errors.New("invalid value, must be []InflationPayout") return } result.Payouts = &tv @@ -36140,13 +37079,17 @@ func (u InflationResult) EncodeTo(e *xdr.Encoder) error { var _ decoderFrom = (*InflationResult)(nil) // DecodeFrom decodes this value using the Decoder. -func (u *InflationResult) DecodeFrom(d *xdr.Decoder) (int, error) { +func (u *InflationResult) DecodeFrom(d *xdr.Decoder, maxDepth uint) (int, error) { + if maxDepth == 0 { + return 0, fmt.Errorf("decoding InflationResult: %w", ErrMaxDecodingDepthReached) + } + maxDepth -= 1 var err error var n, nTmp int - nTmp, err = u.Code.DecodeFrom(d) + nTmp, err = u.Code.DecodeFrom(d, maxDepth) n += nTmp if err != nil { - return n, fmt.Errorf("decoding InflationResultCode: %s", err) + return n, fmt.Errorf("decoding InflationResultCode: %w", err) } switch InflationResultCode(u.Code) { case InflationResultCodeInflationSuccess: @@ -36155,16 +37098,16 @@ func (u *InflationResult) DecodeFrom(d *xdr.Decoder) (int, error) { l, nTmp, err = d.DecodeUint() n += nTmp if err != nil { - return n, fmt.Errorf("decoding InflationPayout: %s", err) + return n, fmt.Errorf("decoding InflationPayout: %w", err) } (*u.Payouts) = nil if l > 0 { (*u.Payouts) = make([]InflationPayout, l) for i := uint32(0); i < l; i++ { - nTmp, err = (*u.Payouts)[i].DecodeFrom(d) + nTmp, err = (*u.Payouts)[i].DecodeFrom(d, maxDepth) n += nTmp if err != nil { - return n, fmt.Errorf("decoding InflationPayout: %s", err) + return n, fmt.Errorf("decoding InflationPayout: %w", err) } } } @@ -36188,7 +37131,7 @@ func (s InflationResult) MarshalBinary() ([]byte, error) { func (s *InflationResult) UnmarshalBinary(inp []byte) error { r := bytes.NewReader(inp) d := xdr.NewDecoder(r) - _, err := s.DecodeFrom(d) + _, err := s.DecodeFrom(d, xdr.DecodeDefaultMaxDepth) return err } @@ -36260,10 +37203,14 @@ func (e ManageDataResultCode) EncodeTo(enc *xdr.Encoder) error { var _ decoderFrom = (*ManageDataResultCode)(nil) // DecodeFrom decodes this value using the Decoder. -func (e *ManageDataResultCode) DecodeFrom(d *xdr.Decoder) (int, error) { +func (e *ManageDataResultCode) DecodeFrom(d *xdr.Decoder, maxDepth uint) (int, error) { + if maxDepth == 0 { + return 0, fmt.Errorf("decoding ManageDataResultCode: %w", ErrMaxDecodingDepthReached) + } + maxDepth -= 1 v, n, err := d.DecodeInt() if err != nil { - return n, fmt.Errorf("decoding ManageDataResultCode: %s", err) + return n, fmt.Errorf("decoding ManageDataResultCode: %w", err) } if _, ok := manageDataResultCodeMap[v]; !ok { return n, fmt.Errorf("'%d' is not a valid ManageDataResultCode enum value", v) @@ -36284,7 +37231,7 @@ func (s ManageDataResultCode) MarshalBinary() ([]byte, error) { func (s *ManageDataResultCode) UnmarshalBinary(inp []byte) error { r := bytes.NewReader(inp) d := xdr.NewDecoder(r) - _, err := s.DecodeFrom(d) + _, err := s.DecodeFrom(d, xdr.DecodeDefaultMaxDepth) return err } @@ -36386,13 +37333,17 @@ func (u ManageDataResult) EncodeTo(e *xdr.Encoder) error { var _ decoderFrom = (*ManageDataResult)(nil) // DecodeFrom decodes this value using the Decoder. -func (u *ManageDataResult) DecodeFrom(d *xdr.Decoder) (int, error) { +func (u *ManageDataResult) DecodeFrom(d *xdr.Decoder, maxDepth uint) (int, error) { + if maxDepth == 0 { + return 0, fmt.Errorf("decoding ManageDataResult: %w", ErrMaxDecodingDepthReached) + } + maxDepth -= 1 var err error var n, nTmp int - nTmp, err = u.Code.DecodeFrom(d) + nTmp, err = u.Code.DecodeFrom(d, maxDepth) n += nTmp if err != nil { - return n, fmt.Errorf("decoding ManageDataResultCode: %s", err) + return n, fmt.Errorf("decoding ManageDataResultCode: %w", err) } switch ManageDataResultCode(u.Code) { case ManageDataResultCodeManageDataSuccess: @@ -36426,7 +37377,7 @@ func (s ManageDataResult) MarshalBinary() ([]byte, error) { func (s *ManageDataResult) UnmarshalBinary(inp []byte) error { r := bytes.NewReader(inp) d := xdr.NewDecoder(r) - _, err := s.DecodeFrom(d) + _, err := s.DecodeFrom(d, xdr.DecodeDefaultMaxDepth) return err } @@ -36487,10 +37438,14 @@ func (e BumpSequenceResultCode) EncodeTo(enc *xdr.Encoder) error { var _ decoderFrom = (*BumpSequenceResultCode)(nil) // DecodeFrom decodes this value using the Decoder. -func (e *BumpSequenceResultCode) DecodeFrom(d *xdr.Decoder) (int, error) { +func (e *BumpSequenceResultCode) DecodeFrom(d *xdr.Decoder, maxDepth uint) (int, error) { + if maxDepth == 0 { + return 0, fmt.Errorf("decoding BumpSequenceResultCode: %w", ErrMaxDecodingDepthReached) + } + maxDepth -= 1 v, n, err := d.DecodeInt() if err != nil { - return n, fmt.Errorf("decoding BumpSequenceResultCode: %s", err) + return n, fmt.Errorf("decoding BumpSequenceResultCode: %w", err) } if _, ok := bumpSequenceResultCodeMap[v]; !ok { return n, fmt.Errorf("'%d' is not a valid BumpSequenceResultCode enum value", v) @@ -36511,7 +37466,7 @@ func (s BumpSequenceResultCode) MarshalBinary() ([]byte, error) { func (s *BumpSequenceResultCode) UnmarshalBinary(inp []byte) error { r := bytes.NewReader(inp) d := xdr.NewDecoder(r) - _, err := s.DecodeFrom(d) + _, err := s.DecodeFrom(d, xdr.DecodeDefaultMaxDepth) return err } @@ -36589,13 +37544,17 @@ func (u BumpSequenceResult) EncodeTo(e *xdr.Encoder) error { var _ decoderFrom = (*BumpSequenceResult)(nil) // DecodeFrom decodes this value using the Decoder. -func (u *BumpSequenceResult) DecodeFrom(d *xdr.Decoder) (int, error) { +func (u *BumpSequenceResult) DecodeFrom(d *xdr.Decoder, maxDepth uint) (int, error) { + if maxDepth == 0 { + return 0, fmt.Errorf("decoding BumpSequenceResult: %w", ErrMaxDecodingDepthReached) + } + maxDepth -= 1 var err error var n, nTmp int - nTmp, err = u.Code.DecodeFrom(d) + nTmp, err = u.Code.DecodeFrom(d, maxDepth) n += nTmp if err != nil { - return n, fmt.Errorf("decoding BumpSequenceResultCode: %s", err) + return n, fmt.Errorf("decoding BumpSequenceResultCode: %w", err) } switch BumpSequenceResultCode(u.Code) { case BumpSequenceResultCodeBumpSequenceSuccess: @@ -36620,7 +37579,7 @@ func (s BumpSequenceResult) MarshalBinary() ([]byte, error) { func (s *BumpSequenceResult) UnmarshalBinary(inp []byte) error { r := bytes.NewReader(inp) d := xdr.NewDecoder(r) - _, err := s.DecodeFrom(d) + _, err := s.DecodeFrom(d, xdr.DecodeDefaultMaxDepth) return err } @@ -36691,10 +37650,14 @@ func (e CreateClaimableBalanceResultCode) EncodeTo(enc *xdr.Encoder) error { var _ decoderFrom = (*CreateClaimableBalanceResultCode)(nil) // DecodeFrom decodes this value using the Decoder. -func (e *CreateClaimableBalanceResultCode) DecodeFrom(d *xdr.Decoder) (int, error) { +func (e *CreateClaimableBalanceResultCode) DecodeFrom(d *xdr.Decoder, maxDepth uint) (int, error) { + if maxDepth == 0 { + return 0, fmt.Errorf("decoding CreateClaimableBalanceResultCode: %w", ErrMaxDecodingDepthReached) + } + maxDepth -= 1 v, n, err := d.DecodeInt() if err != nil { - return n, fmt.Errorf("decoding CreateClaimableBalanceResultCode: %s", err) + return n, fmt.Errorf("decoding CreateClaimableBalanceResultCode: %w", err) } if _, ok := createClaimableBalanceResultCodeMap[v]; !ok { return n, fmt.Errorf("'%d' is not a valid CreateClaimableBalanceResultCode enum value", v) @@ -36715,7 +37678,7 @@ func (s CreateClaimableBalanceResultCode) MarshalBinary() ([]byte, error) { func (s *CreateClaimableBalanceResultCode) UnmarshalBinary(inp []byte) error { r := bytes.NewReader(inp) d := xdr.NewDecoder(r) - _, err := s.DecodeFrom(d) + _, err := s.DecodeFrom(d, xdr.DecodeDefaultMaxDepth) return err } @@ -36782,7 +37745,7 @@ func NewCreateClaimableBalanceResult(code CreateClaimableBalanceResultCode, valu case CreateClaimableBalanceResultCodeCreateClaimableBalanceSuccess: tv, ok := value.(ClaimableBalanceId) if !ok { - err = fmt.Errorf("invalid value, must be ClaimableBalanceId") + err = errors.New("invalid value, must be ClaimableBalanceId") return } result.BalanceId = &tv @@ -36859,21 +37822,25 @@ func (u CreateClaimableBalanceResult) EncodeTo(e *xdr.Encoder) error { var _ decoderFrom = (*CreateClaimableBalanceResult)(nil) // DecodeFrom decodes this value using the Decoder. -func (u *CreateClaimableBalanceResult) DecodeFrom(d *xdr.Decoder) (int, error) { +func (u *CreateClaimableBalanceResult) DecodeFrom(d *xdr.Decoder, maxDepth uint) (int, error) { + if maxDepth == 0 { + return 0, fmt.Errorf("decoding CreateClaimableBalanceResult: %w", ErrMaxDecodingDepthReached) + } + maxDepth -= 1 var err error var n, nTmp int - nTmp, err = u.Code.DecodeFrom(d) + nTmp, err = u.Code.DecodeFrom(d, maxDepth) n += nTmp if err != nil { - return n, fmt.Errorf("decoding CreateClaimableBalanceResultCode: %s", err) + return n, fmt.Errorf("decoding CreateClaimableBalanceResultCode: %w", err) } switch CreateClaimableBalanceResultCode(u.Code) { case CreateClaimableBalanceResultCodeCreateClaimableBalanceSuccess: u.BalanceId = new(ClaimableBalanceId) - nTmp, err = (*u.BalanceId).DecodeFrom(d) + nTmp, err = (*u.BalanceId).DecodeFrom(d, maxDepth) n += nTmp if err != nil { - return n, fmt.Errorf("decoding ClaimableBalanceId: %s", err) + return n, fmt.Errorf("decoding ClaimableBalanceId: %w", err) } return n, nil case CreateClaimableBalanceResultCodeCreateClaimableBalanceMalformed: @@ -36907,7 +37874,7 @@ func (s CreateClaimableBalanceResult) MarshalBinary() ([]byte, error) { func (s *CreateClaimableBalanceResult) UnmarshalBinary(inp []byte) error { r := bytes.NewReader(inp) d := xdr.NewDecoder(r) - _, err := s.DecodeFrom(d) + _, err := s.DecodeFrom(d, xdr.DecodeDefaultMaxDepth) return err } @@ -36978,10 +37945,14 @@ func (e ClaimClaimableBalanceResultCode) EncodeTo(enc *xdr.Encoder) error { var _ decoderFrom = (*ClaimClaimableBalanceResultCode)(nil) // DecodeFrom decodes this value using the Decoder. -func (e *ClaimClaimableBalanceResultCode) DecodeFrom(d *xdr.Decoder) (int, error) { +func (e *ClaimClaimableBalanceResultCode) DecodeFrom(d *xdr.Decoder, maxDepth uint) (int, error) { + if maxDepth == 0 { + return 0, fmt.Errorf("decoding ClaimClaimableBalanceResultCode: %w", ErrMaxDecodingDepthReached) + } + maxDepth -= 1 v, n, err := d.DecodeInt() if err != nil { - return n, fmt.Errorf("decoding ClaimClaimableBalanceResultCode: %s", err) + return n, fmt.Errorf("decoding ClaimClaimableBalanceResultCode: %w", err) } if _, ok := claimClaimableBalanceResultCodeMap[v]; !ok { return n, fmt.Errorf("'%d' is not a valid ClaimClaimableBalanceResultCode enum value", v) @@ -37002,7 +37973,7 @@ func (s ClaimClaimableBalanceResultCode) MarshalBinary() ([]byte, error) { func (s *ClaimClaimableBalanceResultCode) UnmarshalBinary(inp []byte) error { r := bytes.NewReader(inp) d := xdr.NewDecoder(r) - _, err := s.DecodeFrom(d) + _, err := s.DecodeFrom(d, xdr.DecodeDefaultMaxDepth) return err } @@ -37112,13 +38083,17 @@ func (u ClaimClaimableBalanceResult) EncodeTo(e *xdr.Encoder) error { var _ decoderFrom = (*ClaimClaimableBalanceResult)(nil) // DecodeFrom decodes this value using the Decoder. -func (u *ClaimClaimableBalanceResult) DecodeFrom(d *xdr.Decoder) (int, error) { +func (u *ClaimClaimableBalanceResult) DecodeFrom(d *xdr.Decoder, maxDepth uint) (int, error) { + if maxDepth == 0 { + return 0, fmt.Errorf("decoding ClaimClaimableBalanceResult: %w", ErrMaxDecodingDepthReached) + } + maxDepth -= 1 var err error var n, nTmp int - nTmp, err = u.Code.DecodeFrom(d) + nTmp, err = u.Code.DecodeFrom(d, maxDepth) n += nTmp if err != nil { - return n, fmt.Errorf("decoding ClaimClaimableBalanceResultCode: %s", err) + return n, fmt.Errorf("decoding ClaimClaimableBalanceResultCode: %w", err) } switch ClaimClaimableBalanceResultCode(u.Code) { case ClaimClaimableBalanceResultCodeClaimClaimableBalanceSuccess: @@ -37155,7 +38130,7 @@ func (s ClaimClaimableBalanceResult) MarshalBinary() ([]byte, error) { func (s *ClaimClaimableBalanceResult) UnmarshalBinary(inp []byte) error { r := bytes.NewReader(inp) d := xdr.NewDecoder(r) - _, err := s.DecodeFrom(d) + _, err := s.DecodeFrom(d, xdr.DecodeDefaultMaxDepth) return err } @@ -37223,10 +38198,14 @@ func (e BeginSponsoringFutureReservesResultCode) EncodeTo(enc *xdr.Encoder) erro var _ decoderFrom = (*BeginSponsoringFutureReservesResultCode)(nil) // DecodeFrom decodes this value using the Decoder. -func (e *BeginSponsoringFutureReservesResultCode) DecodeFrom(d *xdr.Decoder) (int, error) { +func (e *BeginSponsoringFutureReservesResultCode) DecodeFrom(d *xdr.Decoder, maxDepth uint) (int, error) { + if maxDepth == 0 { + return 0, fmt.Errorf("decoding BeginSponsoringFutureReservesResultCode: %w", ErrMaxDecodingDepthReached) + } + maxDepth -= 1 v, n, err := d.DecodeInt() if err != nil { - return n, fmt.Errorf("decoding BeginSponsoringFutureReservesResultCode: %s", err) + return n, fmt.Errorf("decoding BeginSponsoringFutureReservesResultCode: %w", err) } if _, ok := beginSponsoringFutureReservesResultCodeMap[v]; !ok { return n, fmt.Errorf("'%d' is not a valid BeginSponsoringFutureReservesResultCode enum value", v) @@ -37247,7 +38226,7 @@ func (s BeginSponsoringFutureReservesResultCode) MarshalBinary() ([]byte, error) func (s *BeginSponsoringFutureReservesResultCode) UnmarshalBinary(inp []byte) error { r := bytes.NewReader(inp) d := xdr.NewDecoder(r) - _, err := s.DecodeFrom(d) + _, err := s.DecodeFrom(d, xdr.DecodeDefaultMaxDepth) return err } @@ -37342,13 +38321,17 @@ func (u BeginSponsoringFutureReservesResult) EncodeTo(e *xdr.Encoder) error { var _ decoderFrom = (*BeginSponsoringFutureReservesResult)(nil) // DecodeFrom decodes this value using the Decoder. -func (u *BeginSponsoringFutureReservesResult) DecodeFrom(d *xdr.Decoder) (int, error) { +func (u *BeginSponsoringFutureReservesResult) DecodeFrom(d *xdr.Decoder, maxDepth uint) (int, error) { + if maxDepth == 0 { + return 0, fmt.Errorf("decoding BeginSponsoringFutureReservesResult: %w", ErrMaxDecodingDepthReached) + } + maxDepth -= 1 var err error var n, nTmp int - nTmp, err = u.Code.DecodeFrom(d) + nTmp, err = u.Code.DecodeFrom(d, maxDepth) n += nTmp if err != nil { - return n, fmt.Errorf("decoding BeginSponsoringFutureReservesResultCode: %s", err) + return n, fmt.Errorf("decoding BeginSponsoringFutureReservesResultCode: %w", err) } switch BeginSponsoringFutureReservesResultCode(u.Code) { case BeginSponsoringFutureReservesResultCodeBeginSponsoringFutureReservesSuccess: @@ -37379,7 +38362,7 @@ func (s BeginSponsoringFutureReservesResult) MarshalBinary() ([]byte, error) { func (s *BeginSponsoringFutureReservesResult) UnmarshalBinary(inp []byte) error { r := bytes.NewReader(inp) d := xdr.NewDecoder(r) - _, err := s.DecodeFrom(d) + _, err := s.DecodeFrom(d, xdr.DecodeDefaultMaxDepth) return err } @@ -37441,10 +38424,14 @@ func (e EndSponsoringFutureReservesResultCode) EncodeTo(enc *xdr.Encoder) error var _ decoderFrom = (*EndSponsoringFutureReservesResultCode)(nil) // DecodeFrom decodes this value using the Decoder. -func (e *EndSponsoringFutureReservesResultCode) DecodeFrom(d *xdr.Decoder) (int, error) { +func (e *EndSponsoringFutureReservesResultCode) DecodeFrom(d *xdr.Decoder, maxDepth uint) (int, error) { + if maxDepth == 0 { + return 0, fmt.Errorf("decoding EndSponsoringFutureReservesResultCode: %w", ErrMaxDecodingDepthReached) + } + maxDepth -= 1 v, n, err := d.DecodeInt() if err != nil { - return n, fmt.Errorf("decoding EndSponsoringFutureReservesResultCode: %s", err) + return n, fmt.Errorf("decoding EndSponsoringFutureReservesResultCode: %w", err) } if _, ok := endSponsoringFutureReservesResultCodeMap[v]; !ok { return n, fmt.Errorf("'%d' is not a valid EndSponsoringFutureReservesResultCode enum value", v) @@ -37465,7 +38452,7 @@ func (s EndSponsoringFutureReservesResultCode) MarshalBinary() ([]byte, error) { func (s *EndSponsoringFutureReservesResultCode) UnmarshalBinary(inp []byte) error { r := bytes.NewReader(inp) d := xdr.NewDecoder(r) - _, err := s.DecodeFrom(d) + _, err := s.DecodeFrom(d, xdr.DecodeDefaultMaxDepth) return err } @@ -37544,13 +38531,17 @@ func (u EndSponsoringFutureReservesResult) EncodeTo(e *xdr.Encoder) error { var _ decoderFrom = (*EndSponsoringFutureReservesResult)(nil) // DecodeFrom decodes this value using the Decoder. -func (u *EndSponsoringFutureReservesResult) DecodeFrom(d *xdr.Decoder) (int, error) { +func (u *EndSponsoringFutureReservesResult) DecodeFrom(d *xdr.Decoder, maxDepth uint) (int, error) { + if maxDepth == 0 { + return 0, fmt.Errorf("decoding EndSponsoringFutureReservesResult: %w", ErrMaxDecodingDepthReached) + } + maxDepth -= 1 var err error var n, nTmp int - nTmp, err = u.Code.DecodeFrom(d) + nTmp, err = u.Code.DecodeFrom(d, maxDepth) n += nTmp if err != nil { - return n, fmt.Errorf("decoding EndSponsoringFutureReservesResultCode: %s", err) + return n, fmt.Errorf("decoding EndSponsoringFutureReservesResultCode: %w", err) } switch EndSponsoringFutureReservesResultCode(u.Code) { case EndSponsoringFutureReservesResultCodeEndSponsoringFutureReservesSuccess: @@ -37575,7 +38566,7 @@ func (s EndSponsoringFutureReservesResult) MarshalBinary() ([]byte, error) { func (s *EndSponsoringFutureReservesResult) UnmarshalBinary(inp []byte) error { r := bytes.NewReader(inp) d := xdr.NewDecoder(r) - _, err := s.DecodeFrom(d) + _, err := s.DecodeFrom(d, xdr.DecodeDefaultMaxDepth) return err } @@ -37649,10 +38640,14 @@ func (e RevokeSponsorshipResultCode) EncodeTo(enc *xdr.Encoder) error { var _ decoderFrom = (*RevokeSponsorshipResultCode)(nil) // DecodeFrom decodes this value using the Decoder. -func (e *RevokeSponsorshipResultCode) DecodeFrom(d *xdr.Decoder) (int, error) { +func (e *RevokeSponsorshipResultCode) DecodeFrom(d *xdr.Decoder, maxDepth uint) (int, error) { + if maxDepth == 0 { + return 0, fmt.Errorf("decoding RevokeSponsorshipResultCode: %w", ErrMaxDecodingDepthReached) + } + maxDepth -= 1 v, n, err := d.DecodeInt() if err != nil { - return n, fmt.Errorf("decoding RevokeSponsorshipResultCode: %s", err) + return n, fmt.Errorf("decoding RevokeSponsorshipResultCode: %w", err) } if _, ok := revokeSponsorshipResultCodeMap[v]; !ok { return n, fmt.Errorf("'%d' is not a valid RevokeSponsorshipResultCode enum value", v) @@ -37673,7 +38668,7 @@ func (s RevokeSponsorshipResultCode) MarshalBinary() ([]byte, error) { func (s *RevokeSponsorshipResultCode) UnmarshalBinary(inp []byte) error { r := bytes.NewReader(inp) d := xdr.NewDecoder(r) - _, err := s.DecodeFrom(d) + _, err := s.DecodeFrom(d, xdr.DecodeDefaultMaxDepth) return err } @@ -37783,13 +38778,17 @@ func (u RevokeSponsorshipResult) EncodeTo(e *xdr.Encoder) error { var _ decoderFrom = (*RevokeSponsorshipResult)(nil) // DecodeFrom decodes this value using the Decoder. -func (u *RevokeSponsorshipResult) DecodeFrom(d *xdr.Decoder) (int, error) { +func (u *RevokeSponsorshipResult) DecodeFrom(d *xdr.Decoder, maxDepth uint) (int, error) { + if maxDepth == 0 { + return 0, fmt.Errorf("decoding RevokeSponsorshipResult: %w", ErrMaxDecodingDepthReached) + } + maxDepth -= 1 var err error var n, nTmp int - nTmp, err = u.Code.DecodeFrom(d) + nTmp, err = u.Code.DecodeFrom(d, maxDepth) n += nTmp if err != nil { - return n, fmt.Errorf("decoding RevokeSponsorshipResultCode: %s", err) + return n, fmt.Errorf("decoding RevokeSponsorshipResultCode: %w", err) } switch RevokeSponsorshipResultCode(u.Code) { case RevokeSponsorshipResultCodeRevokeSponsorshipSuccess: @@ -37826,7 +38825,7 @@ func (s RevokeSponsorshipResult) MarshalBinary() ([]byte, error) { func (s *RevokeSponsorshipResult) UnmarshalBinary(inp []byte) error { r := bytes.NewReader(inp) d := xdr.NewDecoder(r) - _, err := s.DecodeFrom(d) + _, err := s.DecodeFrom(d, xdr.DecodeDefaultMaxDepth) return err } @@ -37897,10 +38896,14 @@ func (e ClawbackResultCode) EncodeTo(enc *xdr.Encoder) error { var _ decoderFrom = (*ClawbackResultCode)(nil) // DecodeFrom decodes this value using the Decoder. -func (e *ClawbackResultCode) DecodeFrom(d *xdr.Decoder) (int, error) { +func (e *ClawbackResultCode) DecodeFrom(d *xdr.Decoder, maxDepth uint) (int, error) { + if maxDepth == 0 { + return 0, fmt.Errorf("decoding ClawbackResultCode: %w", ErrMaxDecodingDepthReached) + } + maxDepth -= 1 v, n, err := d.DecodeInt() if err != nil { - return n, fmt.Errorf("decoding ClawbackResultCode: %s", err) + return n, fmt.Errorf("decoding ClawbackResultCode: %w", err) } if _, ok := clawbackResultCodeMap[v]; !ok { return n, fmt.Errorf("'%d' is not a valid ClawbackResultCode enum value", v) @@ -37921,7 +38924,7 @@ func (s ClawbackResultCode) MarshalBinary() ([]byte, error) { func (s *ClawbackResultCode) UnmarshalBinary(inp []byte) error { r := bytes.NewReader(inp) d := xdr.NewDecoder(r) - _, err := s.DecodeFrom(d) + _, err := s.DecodeFrom(d, xdr.DecodeDefaultMaxDepth) return err } @@ -38023,13 +39026,17 @@ func (u ClawbackResult) EncodeTo(e *xdr.Encoder) error { var _ decoderFrom = (*ClawbackResult)(nil) // DecodeFrom decodes this value using the Decoder. -func (u *ClawbackResult) DecodeFrom(d *xdr.Decoder) (int, error) { +func (u *ClawbackResult) DecodeFrom(d *xdr.Decoder, maxDepth uint) (int, error) { + if maxDepth == 0 { + return 0, fmt.Errorf("decoding ClawbackResult: %w", ErrMaxDecodingDepthReached) + } + maxDepth -= 1 var err error var n, nTmp int - nTmp, err = u.Code.DecodeFrom(d) + nTmp, err = u.Code.DecodeFrom(d, maxDepth) n += nTmp if err != nil { - return n, fmt.Errorf("decoding ClawbackResultCode: %s", err) + return n, fmt.Errorf("decoding ClawbackResultCode: %w", err) } switch ClawbackResultCode(u.Code) { case ClawbackResultCodeClawbackSuccess: @@ -38063,7 +39070,7 @@ func (s ClawbackResult) MarshalBinary() ([]byte, error) { func (s *ClawbackResult) UnmarshalBinary(inp []byte) error { r := bytes.NewReader(inp) d := xdr.NewDecoder(r) - _, err := s.DecodeFrom(d) + _, err := s.DecodeFrom(d, xdr.DecodeDefaultMaxDepth) return err } @@ -38131,10 +39138,14 @@ func (e ClawbackClaimableBalanceResultCode) EncodeTo(enc *xdr.Encoder) error { var _ decoderFrom = (*ClawbackClaimableBalanceResultCode)(nil) // DecodeFrom decodes this value using the Decoder. -func (e *ClawbackClaimableBalanceResultCode) DecodeFrom(d *xdr.Decoder) (int, error) { +func (e *ClawbackClaimableBalanceResultCode) DecodeFrom(d *xdr.Decoder, maxDepth uint) (int, error) { + if maxDepth == 0 { + return 0, fmt.Errorf("decoding ClawbackClaimableBalanceResultCode: %w", ErrMaxDecodingDepthReached) + } + maxDepth -= 1 v, n, err := d.DecodeInt() if err != nil { - return n, fmt.Errorf("decoding ClawbackClaimableBalanceResultCode: %s", err) + return n, fmt.Errorf("decoding ClawbackClaimableBalanceResultCode: %w", err) } if _, ok := clawbackClaimableBalanceResultCodeMap[v]; !ok { return n, fmt.Errorf("'%d' is not a valid ClawbackClaimableBalanceResultCode enum value", v) @@ -38155,7 +39166,7 @@ func (s ClawbackClaimableBalanceResultCode) MarshalBinary() ([]byte, error) { func (s *ClawbackClaimableBalanceResultCode) UnmarshalBinary(inp []byte) error { r := bytes.NewReader(inp) d := xdr.NewDecoder(r) - _, err := s.DecodeFrom(d) + _, err := s.DecodeFrom(d, xdr.DecodeDefaultMaxDepth) return err } @@ -38250,13 +39261,17 @@ func (u ClawbackClaimableBalanceResult) EncodeTo(e *xdr.Encoder) error { var _ decoderFrom = (*ClawbackClaimableBalanceResult)(nil) // DecodeFrom decodes this value using the Decoder. -func (u *ClawbackClaimableBalanceResult) DecodeFrom(d *xdr.Decoder) (int, error) { +func (u *ClawbackClaimableBalanceResult) DecodeFrom(d *xdr.Decoder, maxDepth uint) (int, error) { + if maxDepth == 0 { + return 0, fmt.Errorf("decoding ClawbackClaimableBalanceResult: %w", ErrMaxDecodingDepthReached) + } + maxDepth -= 1 var err error var n, nTmp int - nTmp, err = u.Code.DecodeFrom(d) + nTmp, err = u.Code.DecodeFrom(d, maxDepth) n += nTmp if err != nil { - return n, fmt.Errorf("decoding ClawbackClaimableBalanceResultCode: %s", err) + return n, fmt.Errorf("decoding ClawbackClaimableBalanceResultCode: %w", err) } switch ClawbackClaimableBalanceResultCode(u.Code) { case ClawbackClaimableBalanceResultCodeClawbackClaimableBalanceSuccess: @@ -38287,7 +39302,7 @@ func (s ClawbackClaimableBalanceResult) MarshalBinary() ([]byte, error) { func (s *ClawbackClaimableBalanceResult) UnmarshalBinary(inp []byte) error { r := bytes.NewReader(inp) d := xdr.NewDecoder(r) - _, err := s.DecodeFrom(d) + _, err := s.DecodeFrom(d, xdr.DecodeDefaultMaxDepth) return err } @@ -38362,10 +39377,14 @@ func (e SetTrustLineFlagsResultCode) EncodeTo(enc *xdr.Encoder) error { var _ decoderFrom = (*SetTrustLineFlagsResultCode)(nil) // DecodeFrom decodes this value using the Decoder. -func (e *SetTrustLineFlagsResultCode) DecodeFrom(d *xdr.Decoder) (int, error) { +func (e *SetTrustLineFlagsResultCode) DecodeFrom(d *xdr.Decoder, maxDepth uint) (int, error) { + if maxDepth == 0 { + return 0, fmt.Errorf("decoding SetTrustLineFlagsResultCode: %w", ErrMaxDecodingDepthReached) + } + maxDepth -= 1 v, n, err := d.DecodeInt() if err != nil { - return n, fmt.Errorf("decoding SetTrustLineFlagsResultCode: %s", err) + return n, fmt.Errorf("decoding SetTrustLineFlagsResultCode: %w", err) } if _, ok := setTrustLineFlagsResultCodeMap[v]; !ok { return n, fmt.Errorf("'%d' is not a valid SetTrustLineFlagsResultCode enum value", v) @@ -38386,7 +39405,7 @@ func (s SetTrustLineFlagsResultCode) MarshalBinary() ([]byte, error) { func (s *SetTrustLineFlagsResultCode) UnmarshalBinary(inp []byte) error { r := bytes.NewReader(inp) d := xdr.NewDecoder(r) - _, err := s.DecodeFrom(d) + _, err := s.DecodeFrom(d, xdr.DecodeDefaultMaxDepth) return err } @@ -38496,13 +39515,17 @@ func (u SetTrustLineFlagsResult) EncodeTo(e *xdr.Encoder) error { var _ decoderFrom = (*SetTrustLineFlagsResult)(nil) // DecodeFrom decodes this value using the Decoder. -func (u *SetTrustLineFlagsResult) DecodeFrom(d *xdr.Decoder) (int, error) { +func (u *SetTrustLineFlagsResult) DecodeFrom(d *xdr.Decoder, maxDepth uint) (int, error) { + if maxDepth == 0 { + return 0, fmt.Errorf("decoding SetTrustLineFlagsResult: %w", ErrMaxDecodingDepthReached) + } + maxDepth -= 1 var err error var n, nTmp int - nTmp, err = u.Code.DecodeFrom(d) + nTmp, err = u.Code.DecodeFrom(d, maxDepth) n += nTmp if err != nil { - return n, fmt.Errorf("decoding SetTrustLineFlagsResultCode: %s", err) + return n, fmt.Errorf("decoding SetTrustLineFlagsResultCode: %w", err) } switch SetTrustLineFlagsResultCode(u.Code) { case SetTrustLineFlagsResultCodeSetTrustLineFlagsSuccess: @@ -38539,7 +39562,7 @@ func (s SetTrustLineFlagsResult) MarshalBinary() ([]byte, error) { func (s *SetTrustLineFlagsResult) UnmarshalBinary(inp []byte) error { r := bytes.NewReader(inp) d := xdr.NewDecoder(r) - _, err := s.DecodeFrom(d) + _, err := s.DecodeFrom(d, xdr.DecodeDefaultMaxDepth) return err } @@ -38623,10 +39646,14 @@ func (e LiquidityPoolDepositResultCode) EncodeTo(enc *xdr.Encoder) error { var _ decoderFrom = (*LiquidityPoolDepositResultCode)(nil) // DecodeFrom decodes this value using the Decoder. -func (e *LiquidityPoolDepositResultCode) DecodeFrom(d *xdr.Decoder) (int, error) { +func (e *LiquidityPoolDepositResultCode) DecodeFrom(d *xdr.Decoder, maxDepth uint) (int, error) { + if maxDepth == 0 { + return 0, fmt.Errorf("decoding LiquidityPoolDepositResultCode: %w", ErrMaxDecodingDepthReached) + } + maxDepth -= 1 v, n, err := d.DecodeInt() if err != nil { - return n, fmt.Errorf("decoding LiquidityPoolDepositResultCode: %s", err) + return n, fmt.Errorf("decoding LiquidityPoolDepositResultCode: %w", err) } if _, ok := liquidityPoolDepositResultCodeMap[v]; !ok { return n, fmt.Errorf("'%d' is not a valid LiquidityPoolDepositResultCode enum value", v) @@ -38647,7 +39674,7 @@ func (s LiquidityPoolDepositResultCode) MarshalBinary() ([]byte, error) { func (s *LiquidityPoolDepositResultCode) UnmarshalBinary(inp []byte) error { r := bytes.NewReader(inp) d := xdr.NewDecoder(r) - _, err := s.DecodeFrom(d) + _, err := s.DecodeFrom(d, xdr.DecodeDefaultMaxDepth) return err } @@ -38773,13 +39800,17 @@ func (u LiquidityPoolDepositResult) EncodeTo(e *xdr.Encoder) error { var _ decoderFrom = (*LiquidityPoolDepositResult)(nil) // DecodeFrom decodes this value using the Decoder. -func (u *LiquidityPoolDepositResult) DecodeFrom(d *xdr.Decoder) (int, error) { +func (u *LiquidityPoolDepositResult) DecodeFrom(d *xdr.Decoder, maxDepth uint) (int, error) { + if maxDepth == 0 { + return 0, fmt.Errorf("decoding LiquidityPoolDepositResult: %w", ErrMaxDecodingDepthReached) + } + maxDepth -= 1 var err error var n, nTmp int - nTmp, err = u.Code.DecodeFrom(d) + nTmp, err = u.Code.DecodeFrom(d, maxDepth) n += nTmp if err != nil { - return n, fmt.Errorf("decoding LiquidityPoolDepositResultCode: %s", err) + return n, fmt.Errorf("decoding LiquidityPoolDepositResultCode: %w", err) } switch LiquidityPoolDepositResultCode(u.Code) { case LiquidityPoolDepositResultCodeLiquidityPoolDepositSuccess: @@ -38822,7 +39853,7 @@ func (s LiquidityPoolDepositResult) MarshalBinary() ([]byte, error) { func (s *LiquidityPoolDepositResult) UnmarshalBinary(inp []byte) error { r := bytes.NewReader(inp) d := xdr.NewDecoder(r) - _, err := s.DecodeFrom(d) + _, err := s.DecodeFrom(d, xdr.DecodeDefaultMaxDepth) return err } @@ -38899,10 +39930,14 @@ func (e LiquidityPoolWithdrawResultCode) EncodeTo(enc *xdr.Encoder) error { var _ decoderFrom = (*LiquidityPoolWithdrawResultCode)(nil) // DecodeFrom decodes this value using the Decoder. -func (e *LiquidityPoolWithdrawResultCode) DecodeFrom(d *xdr.Decoder) (int, error) { +func (e *LiquidityPoolWithdrawResultCode) DecodeFrom(d *xdr.Decoder, maxDepth uint) (int, error) { + if maxDepth == 0 { + return 0, fmt.Errorf("decoding LiquidityPoolWithdrawResultCode: %w", ErrMaxDecodingDepthReached) + } + maxDepth -= 1 v, n, err := d.DecodeInt() if err != nil { - return n, fmt.Errorf("decoding LiquidityPoolWithdrawResultCode: %s", err) + return n, fmt.Errorf("decoding LiquidityPoolWithdrawResultCode: %w", err) } if _, ok := liquidityPoolWithdrawResultCodeMap[v]; !ok { return n, fmt.Errorf("'%d' is not a valid LiquidityPoolWithdrawResultCode enum value", v) @@ -38923,7 +39958,7 @@ func (s LiquidityPoolWithdrawResultCode) MarshalBinary() ([]byte, error) { func (s *LiquidityPoolWithdrawResultCode) UnmarshalBinary(inp []byte) error { r := bytes.NewReader(inp) d := xdr.NewDecoder(r) - _, err := s.DecodeFrom(d) + _, err := s.DecodeFrom(d, xdr.DecodeDefaultMaxDepth) return err } @@ -39033,13 +40068,17 @@ func (u LiquidityPoolWithdrawResult) EncodeTo(e *xdr.Encoder) error { var _ decoderFrom = (*LiquidityPoolWithdrawResult)(nil) // DecodeFrom decodes this value using the Decoder. -func (u *LiquidityPoolWithdrawResult) DecodeFrom(d *xdr.Decoder) (int, error) { +func (u *LiquidityPoolWithdrawResult) DecodeFrom(d *xdr.Decoder, maxDepth uint) (int, error) { + if maxDepth == 0 { + return 0, fmt.Errorf("decoding LiquidityPoolWithdrawResult: %w", ErrMaxDecodingDepthReached) + } + maxDepth -= 1 var err error var n, nTmp int - nTmp, err = u.Code.DecodeFrom(d) + nTmp, err = u.Code.DecodeFrom(d, maxDepth) n += nTmp if err != nil { - return n, fmt.Errorf("decoding LiquidityPoolWithdrawResultCode: %s", err) + return n, fmt.Errorf("decoding LiquidityPoolWithdrawResultCode: %w", err) } switch LiquidityPoolWithdrawResultCode(u.Code) { case LiquidityPoolWithdrawResultCodeLiquidityPoolWithdrawSuccess: @@ -39076,7 +40115,7 @@ func (s LiquidityPoolWithdrawResult) MarshalBinary() ([]byte, error) { func (s *LiquidityPoolWithdrawResult) UnmarshalBinary(inp []byte) error { r := bytes.NewReader(inp) d := xdr.NewDecoder(r) - _, err := s.DecodeFrom(d) + _, err := s.DecodeFrom(d, xdr.DecodeDefaultMaxDepth) return err } @@ -39102,7 +40141,7 @@ var _ xdrType = (*LiquidityPoolWithdrawResult)(nil) // INVOKE_HOST_FUNCTION_MALFORMED = -1, // INVOKE_HOST_FUNCTION_TRAPPED = -2, // INVOKE_HOST_FUNCTION_RESOURCE_LIMIT_EXCEEDED = -3, -// INVOKE_HOST_FUNCTION_ENTRY_EXPIRED = -4, +// INVOKE_HOST_FUNCTION_ENTRY_ARCHIVED = -4, // INVOKE_HOST_FUNCTION_INSUFFICIENT_REFUNDABLE_FEE = -5 // }; type InvokeHostFunctionResultCode int32 @@ -39112,7 +40151,7 @@ const ( InvokeHostFunctionResultCodeInvokeHostFunctionMalformed InvokeHostFunctionResultCode = -1 InvokeHostFunctionResultCodeInvokeHostFunctionTrapped InvokeHostFunctionResultCode = -2 InvokeHostFunctionResultCodeInvokeHostFunctionResourceLimitExceeded InvokeHostFunctionResultCode = -3 - InvokeHostFunctionResultCodeInvokeHostFunctionEntryExpired InvokeHostFunctionResultCode = -4 + InvokeHostFunctionResultCodeInvokeHostFunctionEntryArchived InvokeHostFunctionResultCode = -4 InvokeHostFunctionResultCodeInvokeHostFunctionInsufficientRefundableFee InvokeHostFunctionResultCode = -5 ) @@ -39121,7 +40160,7 @@ var invokeHostFunctionResultCodeMap = map[int32]string{ -1: "InvokeHostFunctionResultCodeInvokeHostFunctionMalformed", -2: "InvokeHostFunctionResultCodeInvokeHostFunctionTrapped", -3: "InvokeHostFunctionResultCodeInvokeHostFunctionResourceLimitExceeded", - -4: "InvokeHostFunctionResultCodeInvokeHostFunctionEntryExpired", + -4: "InvokeHostFunctionResultCodeInvokeHostFunctionEntryArchived", -5: "InvokeHostFunctionResultCodeInvokeHostFunctionInsufficientRefundableFee", } @@ -39150,10 +40189,14 @@ func (e InvokeHostFunctionResultCode) EncodeTo(enc *xdr.Encoder) error { var _ decoderFrom = (*InvokeHostFunctionResultCode)(nil) // DecodeFrom decodes this value using the Decoder. -func (e *InvokeHostFunctionResultCode) DecodeFrom(d *xdr.Decoder) (int, error) { +func (e *InvokeHostFunctionResultCode) DecodeFrom(d *xdr.Decoder, maxDepth uint) (int, error) { + if maxDepth == 0 { + return 0, fmt.Errorf("decoding InvokeHostFunctionResultCode: %w", ErrMaxDecodingDepthReached) + } + maxDepth -= 1 v, n, err := d.DecodeInt() if err != nil { - return n, fmt.Errorf("decoding InvokeHostFunctionResultCode: %s", err) + return n, fmt.Errorf("decoding InvokeHostFunctionResultCode: %w", err) } if _, ok := invokeHostFunctionResultCodeMap[v]; !ok { return n, fmt.Errorf("'%d' is not a valid InvokeHostFunctionResultCode enum value", v) @@ -39174,7 +40217,7 @@ func (s InvokeHostFunctionResultCode) MarshalBinary() ([]byte, error) { func (s *InvokeHostFunctionResultCode) UnmarshalBinary(inp []byte) error { r := bytes.NewReader(inp) d := xdr.NewDecoder(r) - _, err := s.DecodeFrom(d) + _, err := s.DecodeFrom(d, xdr.DecodeDefaultMaxDepth) return err } @@ -39198,7 +40241,7 @@ var _ xdrType = (*InvokeHostFunctionResultCode)(nil) // case INVOKE_HOST_FUNCTION_MALFORMED: // case INVOKE_HOST_FUNCTION_TRAPPED: // case INVOKE_HOST_FUNCTION_RESOURCE_LIMIT_EXCEEDED: -// case INVOKE_HOST_FUNCTION_ENTRY_EXPIRED: +// case INVOKE_HOST_FUNCTION_ENTRY_ARCHIVED: // case INVOKE_HOST_FUNCTION_INSUFFICIENT_REFUNDABLE_FEE: // void; // }; @@ -39225,7 +40268,7 @@ func (u InvokeHostFunctionResult) ArmForSwitch(sw int32) (string, bool) { return "", true case InvokeHostFunctionResultCodeInvokeHostFunctionResourceLimitExceeded: return "", true - case InvokeHostFunctionResultCodeInvokeHostFunctionEntryExpired: + case InvokeHostFunctionResultCodeInvokeHostFunctionEntryArchived: return "", true case InvokeHostFunctionResultCodeInvokeHostFunctionInsufficientRefundableFee: return "", true @@ -39240,7 +40283,7 @@ func NewInvokeHostFunctionResult(code InvokeHostFunctionResultCode, value interf case InvokeHostFunctionResultCodeInvokeHostFunctionSuccess: tv, ok := value.(Hash) if !ok { - err = fmt.Errorf("invalid value, must be Hash") + err = errors.New("invalid value, must be Hash") return } result.Success = &tv @@ -39250,7 +40293,7 @@ func NewInvokeHostFunctionResult(code InvokeHostFunctionResultCode, value interf // void case InvokeHostFunctionResultCodeInvokeHostFunctionResourceLimitExceeded: // void - case InvokeHostFunctionResultCodeInvokeHostFunctionEntryExpired: + case InvokeHostFunctionResultCodeInvokeHostFunctionEntryArchived: // void case InvokeHostFunctionResultCodeInvokeHostFunctionInsufficientRefundableFee: // void @@ -39304,7 +40347,7 @@ func (u InvokeHostFunctionResult) EncodeTo(e *xdr.Encoder) error { case InvokeHostFunctionResultCodeInvokeHostFunctionResourceLimitExceeded: // Void return nil - case InvokeHostFunctionResultCodeInvokeHostFunctionEntryExpired: + case InvokeHostFunctionResultCodeInvokeHostFunctionEntryArchived: // Void return nil case InvokeHostFunctionResultCodeInvokeHostFunctionInsufficientRefundableFee: @@ -39317,21 +40360,25 @@ func (u InvokeHostFunctionResult) EncodeTo(e *xdr.Encoder) error { var _ decoderFrom = (*InvokeHostFunctionResult)(nil) // DecodeFrom decodes this value using the Decoder. -func (u *InvokeHostFunctionResult) DecodeFrom(d *xdr.Decoder) (int, error) { +func (u *InvokeHostFunctionResult) DecodeFrom(d *xdr.Decoder, maxDepth uint) (int, error) { + if maxDepth == 0 { + return 0, fmt.Errorf("decoding InvokeHostFunctionResult: %w", ErrMaxDecodingDepthReached) + } + maxDepth -= 1 var err error var n, nTmp int - nTmp, err = u.Code.DecodeFrom(d) + nTmp, err = u.Code.DecodeFrom(d, maxDepth) n += nTmp if err != nil { - return n, fmt.Errorf("decoding InvokeHostFunctionResultCode: %s", err) + return n, fmt.Errorf("decoding InvokeHostFunctionResultCode: %w", err) } switch InvokeHostFunctionResultCode(u.Code) { case InvokeHostFunctionResultCodeInvokeHostFunctionSuccess: u.Success = new(Hash) - nTmp, err = (*u.Success).DecodeFrom(d) + nTmp, err = (*u.Success).DecodeFrom(d, maxDepth) n += nTmp if err != nil { - return n, fmt.Errorf("decoding Hash: %s", err) + return n, fmt.Errorf("decoding Hash: %w", err) } return n, nil case InvokeHostFunctionResultCodeInvokeHostFunctionMalformed: @@ -39343,7 +40390,7 @@ func (u *InvokeHostFunctionResult) DecodeFrom(d *xdr.Decoder) (int, error) { case InvokeHostFunctionResultCodeInvokeHostFunctionResourceLimitExceeded: // Void return n, nil - case InvokeHostFunctionResultCodeInvokeHostFunctionEntryExpired: + case InvokeHostFunctionResultCodeInvokeHostFunctionEntryArchived: // Void return n, nil case InvokeHostFunctionResultCodeInvokeHostFunctionInsufficientRefundableFee: @@ -39365,7 +40412,7 @@ func (s InvokeHostFunctionResult) MarshalBinary() ([]byte, error) { func (s *InvokeHostFunctionResult) UnmarshalBinary(inp []byte) error { r := bytes.NewReader(inp) d := xdr.NewDecoder(r) - _, err := s.DecodeFrom(d) + _, err := s.DecodeFrom(d, xdr.DecodeDefaultMaxDepth) return err } @@ -39380,73 +40427,77 @@ func (s InvokeHostFunctionResult) xdrType() {} var _ xdrType = (*InvokeHostFunctionResult)(nil) -// BumpFootprintExpirationResultCode is an XDR Enum defines as: +// ExtendFootprintTtlResultCode is an XDR Enum defines as: // -// enum BumpFootprintExpirationResultCode +// enum ExtendFootprintTTLResultCode // { // // codes considered as "success" for the operation -// BUMP_FOOTPRINT_EXPIRATION_SUCCESS = 0, +// EXTEND_FOOTPRINT_TTL_SUCCESS = 0, // // // codes considered as "failure" for the operation -// BUMP_FOOTPRINT_EXPIRATION_MALFORMED = -1, -// BUMP_FOOTPRINT_EXPIRATION_RESOURCE_LIMIT_EXCEEDED = -2, -// BUMP_FOOTPRINT_EXPIRATION_INSUFFICIENT_REFUNDABLE_FEE = -3 +// EXTEND_FOOTPRINT_TTL_MALFORMED = -1, +// EXTEND_FOOTPRINT_TTL_RESOURCE_LIMIT_EXCEEDED = -2, +// EXTEND_FOOTPRINT_TTL_INSUFFICIENT_REFUNDABLE_FEE = -3 // }; -type BumpFootprintExpirationResultCode int32 +type ExtendFootprintTtlResultCode int32 const ( - BumpFootprintExpirationResultCodeBumpFootprintExpirationSuccess BumpFootprintExpirationResultCode = 0 - BumpFootprintExpirationResultCodeBumpFootprintExpirationMalformed BumpFootprintExpirationResultCode = -1 - BumpFootprintExpirationResultCodeBumpFootprintExpirationResourceLimitExceeded BumpFootprintExpirationResultCode = -2 - BumpFootprintExpirationResultCodeBumpFootprintExpirationInsufficientRefundableFee BumpFootprintExpirationResultCode = -3 + ExtendFootprintTtlResultCodeExtendFootprintTtlSuccess ExtendFootprintTtlResultCode = 0 + ExtendFootprintTtlResultCodeExtendFootprintTtlMalformed ExtendFootprintTtlResultCode = -1 + ExtendFootprintTtlResultCodeExtendFootprintTtlResourceLimitExceeded ExtendFootprintTtlResultCode = -2 + ExtendFootprintTtlResultCodeExtendFootprintTtlInsufficientRefundableFee ExtendFootprintTtlResultCode = -3 ) -var bumpFootprintExpirationResultCodeMap = map[int32]string{ - 0: "BumpFootprintExpirationResultCodeBumpFootprintExpirationSuccess", - -1: "BumpFootprintExpirationResultCodeBumpFootprintExpirationMalformed", - -2: "BumpFootprintExpirationResultCodeBumpFootprintExpirationResourceLimitExceeded", - -3: "BumpFootprintExpirationResultCodeBumpFootprintExpirationInsufficientRefundableFee", +var extendFootprintTtlResultCodeMap = map[int32]string{ + 0: "ExtendFootprintTtlResultCodeExtendFootprintTtlSuccess", + -1: "ExtendFootprintTtlResultCodeExtendFootprintTtlMalformed", + -2: "ExtendFootprintTtlResultCodeExtendFootprintTtlResourceLimitExceeded", + -3: "ExtendFootprintTtlResultCodeExtendFootprintTtlInsufficientRefundableFee", } // ValidEnum validates a proposed value for this enum. Implements -// the Enum interface for BumpFootprintExpirationResultCode -func (e BumpFootprintExpirationResultCode) ValidEnum(v int32) bool { - _, ok := bumpFootprintExpirationResultCodeMap[v] +// the Enum interface for ExtendFootprintTtlResultCode +func (e ExtendFootprintTtlResultCode) ValidEnum(v int32) bool { + _, ok := extendFootprintTtlResultCodeMap[v] return ok } // String returns the name of `e` -func (e BumpFootprintExpirationResultCode) String() string { - name, _ := bumpFootprintExpirationResultCodeMap[int32(e)] +func (e ExtendFootprintTtlResultCode) String() string { + name, _ := extendFootprintTtlResultCodeMap[int32(e)] return name } // EncodeTo encodes this value using the Encoder. -func (e BumpFootprintExpirationResultCode) EncodeTo(enc *xdr.Encoder) error { - if _, ok := bumpFootprintExpirationResultCodeMap[int32(e)]; !ok { - return fmt.Errorf("'%d' is not a valid BumpFootprintExpirationResultCode enum value", e) +func (e ExtendFootprintTtlResultCode) EncodeTo(enc *xdr.Encoder) error { + if _, ok := extendFootprintTtlResultCodeMap[int32(e)]; !ok { + return fmt.Errorf("'%d' is not a valid ExtendFootprintTtlResultCode enum value", e) } _, err := enc.EncodeInt(int32(e)) return err } -var _ decoderFrom = (*BumpFootprintExpirationResultCode)(nil) +var _ decoderFrom = (*ExtendFootprintTtlResultCode)(nil) // DecodeFrom decodes this value using the Decoder. -func (e *BumpFootprintExpirationResultCode) DecodeFrom(d *xdr.Decoder) (int, error) { +func (e *ExtendFootprintTtlResultCode) DecodeFrom(d *xdr.Decoder, maxDepth uint) (int, error) { + if maxDepth == 0 { + return 0, fmt.Errorf("decoding ExtendFootprintTtlResultCode: %w", ErrMaxDecodingDepthReached) + } + maxDepth -= 1 v, n, err := d.DecodeInt() if err != nil { - return n, fmt.Errorf("decoding BumpFootprintExpirationResultCode: %s", err) + return n, fmt.Errorf("decoding ExtendFootprintTtlResultCode: %w", err) } - if _, ok := bumpFootprintExpirationResultCodeMap[v]; !ok { - return n, fmt.Errorf("'%d' is not a valid BumpFootprintExpirationResultCode enum value", v) + if _, ok := extendFootprintTtlResultCodeMap[v]; !ok { + return n, fmt.Errorf("'%d' is not a valid ExtendFootprintTtlResultCode enum value", v) } - *e = BumpFootprintExpirationResultCode(v) + *e = ExtendFootprintTtlResultCode(v) return n, nil } // MarshalBinary implements encoding.BinaryMarshaler. -func (s BumpFootprintExpirationResultCode) MarshalBinary() ([]byte, error) { +func (s ExtendFootprintTtlResultCode) MarshalBinary() ([]byte, error) { b := bytes.Buffer{} e := xdr.NewEncoder(&b) err := s.EncodeTo(e) @@ -39454,130 +40505,134 @@ func (s BumpFootprintExpirationResultCode) MarshalBinary() ([]byte, error) { } // UnmarshalBinary implements encoding.BinaryUnmarshaler. -func (s *BumpFootprintExpirationResultCode) UnmarshalBinary(inp []byte) error { +func (s *ExtendFootprintTtlResultCode) UnmarshalBinary(inp []byte) error { r := bytes.NewReader(inp) d := xdr.NewDecoder(r) - _, err := s.DecodeFrom(d) + _, err := s.DecodeFrom(d, xdr.DecodeDefaultMaxDepth) return err } var ( - _ encoding.BinaryMarshaler = (*BumpFootprintExpirationResultCode)(nil) - _ encoding.BinaryUnmarshaler = (*BumpFootprintExpirationResultCode)(nil) + _ encoding.BinaryMarshaler = (*ExtendFootprintTtlResultCode)(nil) + _ encoding.BinaryUnmarshaler = (*ExtendFootprintTtlResultCode)(nil) ) // xdrType signals that this type is an type representing // representing XDR values defined by this package. -func (s BumpFootprintExpirationResultCode) xdrType() {} +func (s ExtendFootprintTtlResultCode) xdrType() {} -var _ xdrType = (*BumpFootprintExpirationResultCode)(nil) +var _ xdrType = (*ExtendFootprintTtlResultCode)(nil) -// BumpFootprintExpirationResult is an XDR Union defines as: +// ExtendFootprintTtlResult is an XDR Union defines as: // -// union BumpFootprintExpirationResult switch (BumpFootprintExpirationResultCode code) +// union ExtendFootprintTTLResult switch (ExtendFootprintTTLResultCode code) // { -// case BUMP_FOOTPRINT_EXPIRATION_SUCCESS: +// case EXTEND_FOOTPRINT_TTL_SUCCESS: // void; -// case BUMP_FOOTPRINT_EXPIRATION_MALFORMED: -// case BUMP_FOOTPRINT_EXPIRATION_RESOURCE_LIMIT_EXCEEDED: -// case BUMP_FOOTPRINT_EXPIRATION_INSUFFICIENT_REFUNDABLE_FEE: +// case EXTEND_FOOTPRINT_TTL_MALFORMED: +// case EXTEND_FOOTPRINT_TTL_RESOURCE_LIMIT_EXCEEDED: +// case EXTEND_FOOTPRINT_TTL_INSUFFICIENT_REFUNDABLE_FEE: // void; // }; -type BumpFootprintExpirationResult struct { - Code BumpFootprintExpirationResultCode +type ExtendFootprintTtlResult struct { + Code ExtendFootprintTtlResultCode } // SwitchFieldName returns the field name in which this union's // discriminant is stored -func (u BumpFootprintExpirationResult) SwitchFieldName() string { +func (u ExtendFootprintTtlResult) SwitchFieldName() string { return "Code" } // ArmForSwitch returns which field name should be used for storing -// the value for an instance of BumpFootprintExpirationResult -func (u BumpFootprintExpirationResult) ArmForSwitch(sw int32) (string, bool) { - switch BumpFootprintExpirationResultCode(sw) { - case BumpFootprintExpirationResultCodeBumpFootprintExpirationSuccess: +// the value for an instance of ExtendFootprintTtlResult +func (u ExtendFootprintTtlResult) ArmForSwitch(sw int32) (string, bool) { + switch ExtendFootprintTtlResultCode(sw) { + case ExtendFootprintTtlResultCodeExtendFootprintTtlSuccess: return "", true - case BumpFootprintExpirationResultCodeBumpFootprintExpirationMalformed: + case ExtendFootprintTtlResultCodeExtendFootprintTtlMalformed: return "", true - case BumpFootprintExpirationResultCodeBumpFootprintExpirationResourceLimitExceeded: + case ExtendFootprintTtlResultCodeExtendFootprintTtlResourceLimitExceeded: return "", true - case BumpFootprintExpirationResultCodeBumpFootprintExpirationInsufficientRefundableFee: + case ExtendFootprintTtlResultCodeExtendFootprintTtlInsufficientRefundableFee: return "", true } return "-", false } -// NewBumpFootprintExpirationResult creates a new BumpFootprintExpirationResult. -func NewBumpFootprintExpirationResult(code BumpFootprintExpirationResultCode, value interface{}) (result BumpFootprintExpirationResult, err error) { +// NewExtendFootprintTtlResult creates a new ExtendFootprintTtlResult. +func NewExtendFootprintTtlResult(code ExtendFootprintTtlResultCode, value interface{}) (result ExtendFootprintTtlResult, err error) { result.Code = code - switch BumpFootprintExpirationResultCode(code) { - case BumpFootprintExpirationResultCodeBumpFootprintExpirationSuccess: + switch ExtendFootprintTtlResultCode(code) { + case ExtendFootprintTtlResultCodeExtendFootprintTtlSuccess: // void - case BumpFootprintExpirationResultCodeBumpFootprintExpirationMalformed: + case ExtendFootprintTtlResultCodeExtendFootprintTtlMalformed: // void - case BumpFootprintExpirationResultCodeBumpFootprintExpirationResourceLimitExceeded: + case ExtendFootprintTtlResultCodeExtendFootprintTtlResourceLimitExceeded: // void - case BumpFootprintExpirationResultCodeBumpFootprintExpirationInsufficientRefundableFee: + case ExtendFootprintTtlResultCodeExtendFootprintTtlInsufficientRefundableFee: // void } return } // EncodeTo encodes this value using the Encoder. -func (u BumpFootprintExpirationResult) EncodeTo(e *xdr.Encoder) error { +func (u ExtendFootprintTtlResult) EncodeTo(e *xdr.Encoder) error { var err error if err = u.Code.EncodeTo(e); err != nil { return err } - switch BumpFootprintExpirationResultCode(u.Code) { - case BumpFootprintExpirationResultCodeBumpFootprintExpirationSuccess: + switch ExtendFootprintTtlResultCode(u.Code) { + case ExtendFootprintTtlResultCodeExtendFootprintTtlSuccess: // Void return nil - case BumpFootprintExpirationResultCodeBumpFootprintExpirationMalformed: + case ExtendFootprintTtlResultCodeExtendFootprintTtlMalformed: // Void return nil - case BumpFootprintExpirationResultCodeBumpFootprintExpirationResourceLimitExceeded: + case ExtendFootprintTtlResultCodeExtendFootprintTtlResourceLimitExceeded: // Void return nil - case BumpFootprintExpirationResultCodeBumpFootprintExpirationInsufficientRefundableFee: + case ExtendFootprintTtlResultCodeExtendFootprintTtlInsufficientRefundableFee: // Void return nil } - return fmt.Errorf("Code (BumpFootprintExpirationResultCode) switch value '%d' is not valid for union BumpFootprintExpirationResult", u.Code) + return fmt.Errorf("Code (ExtendFootprintTtlResultCode) switch value '%d' is not valid for union ExtendFootprintTtlResult", u.Code) } -var _ decoderFrom = (*BumpFootprintExpirationResult)(nil) +var _ decoderFrom = (*ExtendFootprintTtlResult)(nil) // DecodeFrom decodes this value using the Decoder. -func (u *BumpFootprintExpirationResult) DecodeFrom(d *xdr.Decoder) (int, error) { +func (u *ExtendFootprintTtlResult) DecodeFrom(d *xdr.Decoder, maxDepth uint) (int, error) { + if maxDepth == 0 { + return 0, fmt.Errorf("decoding ExtendFootprintTtlResult: %w", ErrMaxDecodingDepthReached) + } + maxDepth -= 1 var err error var n, nTmp int - nTmp, err = u.Code.DecodeFrom(d) + nTmp, err = u.Code.DecodeFrom(d, maxDepth) n += nTmp if err != nil { - return n, fmt.Errorf("decoding BumpFootprintExpirationResultCode: %s", err) + return n, fmt.Errorf("decoding ExtendFootprintTtlResultCode: %w", err) } - switch BumpFootprintExpirationResultCode(u.Code) { - case BumpFootprintExpirationResultCodeBumpFootprintExpirationSuccess: + switch ExtendFootprintTtlResultCode(u.Code) { + case ExtendFootprintTtlResultCodeExtendFootprintTtlSuccess: // Void return n, nil - case BumpFootprintExpirationResultCodeBumpFootprintExpirationMalformed: + case ExtendFootprintTtlResultCodeExtendFootprintTtlMalformed: // Void return n, nil - case BumpFootprintExpirationResultCodeBumpFootprintExpirationResourceLimitExceeded: + case ExtendFootprintTtlResultCodeExtendFootprintTtlResourceLimitExceeded: // Void return n, nil - case BumpFootprintExpirationResultCodeBumpFootprintExpirationInsufficientRefundableFee: + case ExtendFootprintTtlResultCodeExtendFootprintTtlInsufficientRefundableFee: // Void return n, nil } - return n, fmt.Errorf("union BumpFootprintExpirationResult has invalid Code (BumpFootprintExpirationResultCode) switch value '%d'", u.Code) + return n, fmt.Errorf("union ExtendFootprintTtlResult has invalid Code (ExtendFootprintTtlResultCode) switch value '%d'", u.Code) } // MarshalBinary implements encoding.BinaryMarshaler. -func (s BumpFootprintExpirationResult) MarshalBinary() ([]byte, error) { +func (s ExtendFootprintTtlResult) MarshalBinary() ([]byte, error) { b := bytes.Buffer{} e := xdr.NewEncoder(&b) err := s.EncodeTo(e) @@ -39585,23 +40640,23 @@ func (s BumpFootprintExpirationResult) MarshalBinary() ([]byte, error) { } // UnmarshalBinary implements encoding.BinaryUnmarshaler. -func (s *BumpFootprintExpirationResult) UnmarshalBinary(inp []byte) error { +func (s *ExtendFootprintTtlResult) UnmarshalBinary(inp []byte) error { r := bytes.NewReader(inp) d := xdr.NewDecoder(r) - _, err := s.DecodeFrom(d) + _, err := s.DecodeFrom(d, xdr.DecodeDefaultMaxDepth) return err } var ( - _ encoding.BinaryMarshaler = (*BumpFootprintExpirationResult)(nil) - _ encoding.BinaryUnmarshaler = (*BumpFootprintExpirationResult)(nil) + _ encoding.BinaryMarshaler = (*ExtendFootprintTtlResult)(nil) + _ encoding.BinaryUnmarshaler = (*ExtendFootprintTtlResult)(nil) ) // xdrType signals that this type is an type representing // representing XDR values defined by this package. -func (s BumpFootprintExpirationResult) xdrType() {} +func (s ExtendFootprintTtlResult) xdrType() {} -var _ xdrType = (*BumpFootprintExpirationResult)(nil) +var _ xdrType = (*ExtendFootprintTtlResult)(nil) // RestoreFootprintResultCode is an XDR Enum defines as: // @@ -39656,10 +40711,14 @@ func (e RestoreFootprintResultCode) EncodeTo(enc *xdr.Encoder) error { var _ decoderFrom = (*RestoreFootprintResultCode)(nil) // DecodeFrom decodes this value using the Decoder. -func (e *RestoreFootprintResultCode) DecodeFrom(d *xdr.Decoder) (int, error) { +func (e *RestoreFootprintResultCode) DecodeFrom(d *xdr.Decoder, maxDepth uint) (int, error) { + if maxDepth == 0 { + return 0, fmt.Errorf("decoding RestoreFootprintResultCode: %w", ErrMaxDecodingDepthReached) + } + maxDepth -= 1 v, n, err := d.DecodeInt() if err != nil { - return n, fmt.Errorf("decoding RestoreFootprintResultCode: %s", err) + return n, fmt.Errorf("decoding RestoreFootprintResultCode: %w", err) } if _, ok := restoreFootprintResultCodeMap[v]; !ok { return n, fmt.Errorf("'%d' is not a valid RestoreFootprintResultCode enum value", v) @@ -39680,7 +40739,7 @@ func (s RestoreFootprintResultCode) MarshalBinary() ([]byte, error) { func (s *RestoreFootprintResultCode) UnmarshalBinary(inp []byte) error { r := bytes.NewReader(inp) d := xdr.NewDecoder(r) - _, err := s.DecodeFrom(d) + _, err := s.DecodeFrom(d, xdr.DecodeDefaultMaxDepth) return err } @@ -39774,13 +40833,17 @@ func (u RestoreFootprintResult) EncodeTo(e *xdr.Encoder) error { var _ decoderFrom = (*RestoreFootprintResult)(nil) // DecodeFrom decodes this value using the Decoder. -func (u *RestoreFootprintResult) DecodeFrom(d *xdr.Decoder) (int, error) { +func (u *RestoreFootprintResult) DecodeFrom(d *xdr.Decoder, maxDepth uint) (int, error) { + if maxDepth == 0 { + return 0, fmt.Errorf("decoding RestoreFootprintResult: %w", ErrMaxDecodingDepthReached) + } + maxDepth -= 1 var err error var n, nTmp int - nTmp, err = u.Code.DecodeFrom(d) + nTmp, err = u.Code.DecodeFrom(d, maxDepth) n += nTmp if err != nil { - return n, fmt.Errorf("decoding RestoreFootprintResultCode: %s", err) + return n, fmt.Errorf("decoding RestoreFootprintResultCode: %w", err) } switch RestoreFootprintResultCode(u.Code) { case RestoreFootprintResultCodeRestoreFootprintSuccess: @@ -39811,7 +40874,7 @@ func (s RestoreFootprintResult) MarshalBinary() ([]byte, error) { func (s *RestoreFootprintResult) UnmarshalBinary(inp []byte) error { r := bytes.NewReader(inp) d := xdr.NewDecoder(r) - _, err := s.DecodeFrom(d) + _, err := s.DecodeFrom(d, xdr.DecodeDefaultMaxDepth) return err } @@ -39886,10 +40949,14 @@ func (e OperationResultCode) EncodeTo(enc *xdr.Encoder) error { var _ decoderFrom = (*OperationResultCode)(nil) // DecodeFrom decodes this value using the Decoder. -func (e *OperationResultCode) DecodeFrom(d *xdr.Decoder) (int, error) { +func (e *OperationResultCode) DecodeFrom(d *xdr.Decoder, maxDepth uint) (int, error) { + if maxDepth == 0 { + return 0, fmt.Errorf("decoding OperationResultCode: %w", ErrMaxDecodingDepthReached) + } + maxDepth -= 1 v, n, err := d.DecodeInt() if err != nil { - return n, fmt.Errorf("decoding OperationResultCode: %s", err) + return n, fmt.Errorf("decoding OperationResultCode: %w", err) } if _, ok := operationResultCodeMap[v]; !ok { return n, fmt.Errorf("'%d' is not a valid OperationResultCode enum value", v) @@ -39910,7 +40977,7 @@ func (s OperationResultCode) MarshalBinary() ([]byte, error) { func (s *OperationResultCode) UnmarshalBinary(inp []byte) error { r := bytes.NewReader(inp) d := xdr.NewDecoder(r) - _, err := s.DecodeFrom(d) + _, err := s.DecodeFrom(d, xdr.DecodeDefaultMaxDepth) return err } @@ -39979,8 +41046,8 @@ var _ xdrType = (*OperationResultCode)(nil) // LiquidityPoolWithdrawResult liquidityPoolWithdrawResult; // case INVOKE_HOST_FUNCTION: // InvokeHostFunctionResult invokeHostFunctionResult; -// case BUMP_FOOTPRINT_EXPIRATION: -// BumpFootprintExpirationResult bumpFootprintExpirationResult; +// case EXTEND_FOOTPRINT_TTL: +// ExtendFootprintTTLResult extendFootprintTTLResult; // case RESTORE_FOOTPRINT: // RestoreFootprintResult restoreFootprintResult; // } @@ -40011,7 +41078,7 @@ type OperationResultTr struct { LiquidityPoolDepositResult *LiquidityPoolDepositResult LiquidityPoolWithdrawResult *LiquidityPoolWithdrawResult InvokeHostFunctionResult *InvokeHostFunctionResult - BumpFootprintExpirationResult *BumpFootprintExpirationResult + ExtendFootprintTtlResult *ExtendFootprintTtlResult RestoreFootprintResult *RestoreFootprintResult } @@ -40075,8 +41142,8 @@ func (u OperationResultTr) ArmForSwitch(sw int32) (string, bool) { return "LiquidityPoolWithdrawResult", true case OperationTypeInvokeHostFunction: return "InvokeHostFunctionResult", true - case OperationTypeBumpFootprintExpiration: - return "BumpFootprintExpirationResult", true + case OperationTypeExtendFootprintTtl: + return "ExtendFootprintTtlResult", true case OperationTypeRestoreFootprint: return "RestoreFootprintResult", true } @@ -40090,189 +41157,189 @@ func NewOperationResultTr(aType OperationType, value interface{}) (result Operat case OperationTypeCreateAccount: tv, ok := value.(CreateAccountResult) if !ok { - err = fmt.Errorf("invalid value, must be CreateAccountResult") + err = errors.New("invalid value, must be CreateAccountResult") return } result.CreateAccountResult = &tv case OperationTypePayment: tv, ok := value.(PaymentResult) if !ok { - err = fmt.Errorf("invalid value, must be PaymentResult") + err = errors.New("invalid value, must be PaymentResult") return } result.PaymentResult = &tv case OperationTypePathPaymentStrictReceive: tv, ok := value.(PathPaymentStrictReceiveResult) if !ok { - err = fmt.Errorf("invalid value, must be PathPaymentStrictReceiveResult") + err = errors.New("invalid value, must be PathPaymentStrictReceiveResult") return } result.PathPaymentStrictReceiveResult = &tv case OperationTypeManageSellOffer: tv, ok := value.(ManageSellOfferResult) if !ok { - err = fmt.Errorf("invalid value, must be ManageSellOfferResult") + err = errors.New("invalid value, must be ManageSellOfferResult") return } result.ManageSellOfferResult = &tv case OperationTypeCreatePassiveSellOffer: tv, ok := value.(ManageSellOfferResult) if !ok { - err = fmt.Errorf("invalid value, must be ManageSellOfferResult") + err = errors.New("invalid value, must be ManageSellOfferResult") return } result.CreatePassiveSellOfferResult = &tv case OperationTypeSetOptions: tv, ok := value.(SetOptionsResult) if !ok { - err = fmt.Errorf("invalid value, must be SetOptionsResult") + err = errors.New("invalid value, must be SetOptionsResult") return } result.SetOptionsResult = &tv case OperationTypeChangeTrust: tv, ok := value.(ChangeTrustResult) if !ok { - err = fmt.Errorf("invalid value, must be ChangeTrustResult") + err = errors.New("invalid value, must be ChangeTrustResult") return } result.ChangeTrustResult = &tv case OperationTypeAllowTrust: tv, ok := value.(AllowTrustResult) if !ok { - err = fmt.Errorf("invalid value, must be AllowTrustResult") + err = errors.New("invalid value, must be AllowTrustResult") return } result.AllowTrustResult = &tv case OperationTypeAccountMerge: tv, ok := value.(AccountMergeResult) if !ok { - err = fmt.Errorf("invalid value, must be AccountMergeResult") + err = errors.New("invalid value, must be AccountMergeResult") return } result.AccountMergeResult = &tv case OperationTypeInflation: tv, ok := value.(InflationResult) if !ok { - err = fmt.Errorf("invalid value, must be InflationResult") + err = errors.New("invalid value, must be InflationResult") return } result.InflationResult = &tv case OperationTypeManageData: tv, ok := value.(ManageDataResult) if !ok { - err = fmt.Errorf("invalid value, must be ManageDataResult") + err = errors.New("invalid value, must be ManageDataResult") return } result.ManageDataResult = &tv case OperationTypeBumpSequence: tv, ok := value.(BumpSequenceResult) if !ok { - err = fmt.Errorf("invalid value, must be BumpSequenceResult") + err = errors.New("invalid value, must be BumpSequenceResult") return } result.BumpSeqResult = &tv case OperationTypeManageBuyOffer: tv, ok := value.(ManageBuyOfferResult) if !ok { - err = fmt.Errorf("invalid value, must be ManageBuyOfferResult") + err = errors.New("invalid value, must be ManageBuyOfferResult") return } result.ManageBuyOfferResult = &tv case OperationTypePathPaymentStrictSend: tv, ok := value.(PathPaymentStrictSendResult) if !ok { - err = fmt.Errorf("invalid value, must be PathPaymentStrictSendResult") + err = errors.New("invalid value, must be PathPaymentStrictSendResult") return } result.PathPaymentStrictSendResult = &tv case OperationTypeCreateClaimableBalance: tv, ok := value.(CreateClaimableBalanceResult) if !ok { - err = fmt.Errorf("invalid value, must be CreateClaimableBalanceResult") + err = errors.New("invalid value, must be CreateClaimableBalanceResult") return } result.CreateClaimableBalanceResult = &tv case OperationTypeClaimClaimableBalance: tv, ok := value.(ClaimClaimableBalanceResult) if !ok { - err = fmt.Errorf("invalid value, must be ClaimClaimableBalanceResult") + err = errors.New("invalid value, must be ClaimClaimableBalanceResult") return } result.ClaimClaimableBalanceResult = &tv case OperationTypeBeginSponsoringFutureReserves: tv, ok := value.(BeginSponsoringFutureReservesResult) if !ok { - err = fmt.Errorf("invalid value, must be BeginSponsoringFutureReservesResult") + err = errors.New("invalid value, must be BeginSponsoringFutureReservesResult") return } result.BeginSponsoringFutureReservesResult = &tv case OperationTypeEndSponsoringFutureReserves: tv, ok := value.(EndSponsoringFutureReservesResult) if !ok { - err = fmt.Errorf("invalid value, must be EndSponsoringFutureReservesResult") + err = errors.New("invalid value, must be EndSponsoringFutureReservesResult") return } result.EndSponsoringFutureReservesResult = &tv case OperationTypeRevokeSponsorship: tv, ok := value.(RevokeSponsorshipResult) if !ok { - err = fmt.Errorf("invalid value, must be RevokeSponsorshipResult") + err = errors.New("invalid value, must be RevokeSponsorshipResult") return } result.RevokeSponsorshipResult = &tv case OperationTypeClawback: tv, ok := value.(ClawbackResult) if !ok { - err = fmt.Errorf("invalid value, must be ClawbackResult") + err = errors.New("invalid value, must be ClawbackResult") return } result.ClawbackResult = &tv case OperationTypeClawbackClaimableBalance: tv, ok := value.(ClawbackClaimableBalanceResult) if !ok { - err = fmt.Errorf("invalid value, must be ClawbackClaimableBalanceResult") + err = errors.New("invalid value, must be ClawbackClaimableBalanceResult") return } result.ClawbackClaimableBalanceResult = &tv case OperationTypeSetTrustLineFlags: tv, ok := value.(SetTrustLineFlagsResult) if !ok { - err = fmt.Errorf("invalid value, must be SetTrustLineFlagsResult") + err = errors.New("invalid value, must be SetTrustLineFlagsResult") return } result.SetTrustLineFlagsResult = &tv case OperationTypeLiquidityPoolDeposit: tv, ok := value.(LiquidityPoolDepositResult) if !ok { - err = fmt.Errorf("invalid value, must be LiquidityPoolDepositResult") + err = errors.New("invalid value, must be LiquidityPoolDepositResult") return } result.LiquidityPoolDepositResult = &tv case OperationTypeLiquidityPoolWithdraw: tv, ok := value.(LiquidityPoolWithdrawResult) if !ok { - err = fmt.Errorf("invalid value, must be LiquidityPoolWithdrawResult") + err = errors.New("invalid value, must be LiquidityPoolWithdrawResult") return } result.LiquidityPoolWithdrawResult = &tv case OperationTypeInvokeHostFunction: tv, ok := value.(InvokeHostFunctionResult) if !ok { - err = fmt.Errorf("invalid value, must be InvokeHostFunctionResult") + err = errors.New("invalid value, must be InvokeHostFunctionResult") return } result.InvokeHostFunctionResult = &tv - case OperationTypeBumpFootprintExpiration: - tv, ok := value.(BumpFootprintExpirationResult) + case OperationTypeExtendFootprintTtl: + tv, ok := value.(ExtendFootprintTtlResult) if !ok { - err = fmt.Errorf("invalid value, must be BumpFootprintExpirationResult") + err = errors.New("invalid value, must be ExtendFootprintTtlResult") return } - result.BumpFootprintExpirationResult = &tv + result.ExtendFootprintTtlResult = &tv case OperationTypeRestoreFootprint: tv, ok := value.(RestoreFootprintResult) if !ok { - err = fmt.Errorf("invalid value, must be RestoreFootprintResult") + err = errors.New("invalid value, must be RestoreFootprintResult") return } result.RestoreFootprintResult = &tv @@ -40905,25 +41972,25 @@ func (u OperationResultTr) GetInvokeHostFunctionResult() (result InvokeHostFunct return } -// MustBumpFootprintExpirationResult retrieves the BumpFootprintExpirationResult value from the union, +// MustExtendFootprintTtlResult retrieves the ExtendFootprintTtlResult value from the union, // panicing if the value is not set. -func (u OperationResultTr) MustBumpFootprintExpirationResult() BumpFootprintExpirationResult { - val, ok := u.GetBumpFootprintExpirationResult() +func (u OperationResultTr) MustExtendFootprintTtlResult() ExtendFootprintTtlResult { + val, ok := u.GetExtendFootprintTtlResult() if !ok { - panic("arm BumpFootprintExpirationResult is not set") + panic("arm ExtendFootprintTtlResult is not set") } return val } -// GetBumpFootprintExpirationResult retrieves the BumpFootprintExpirationResult value from the union, +// GetExtendFootprintTtlResult retrieves the ExtendFootprintTtlResult value from the union, // returning ok if the union's switch indicated the value is valid. -func (u OperationResultTr) GetBumpFootprintExpirationResult() (result BumpFootprintExpirationResult, ok bool) { +func (u OperationResultTr) GetExtendFootprintTtlResult() (result ExtendFootprintTtlResult, ok bool) { armName, _ := u.ArmForSwitch(int32(u.Type)) - if armName == "BumpFootprintExpirationResult" { - result = *u.BumpFootprintExpirationResult + if armName == "ExtendFootprintTtlResult" { + result = *u.ExtendFootprintTtlResult ok = true } @@ -41087,8 +42154,8 @@ func (u OperationResultTr) EncodeTo(e *xdr.Encoder) error { return err } return nil - case OperationTypeBumpFootprintExpiration: - if err = (*u.BumpFootprintExpirationResult).EncodeTo(e); err != nil { + case OperationTypeExtendFootprintTtl: + if err = (*u.ExtendFootprintTtlResult).EncodeTo(e); err != nil { return err } return nil @@ -41104,229 +42171,233 @@ func (u OperationResultTr) EncodeTo(e *xdr.Encoder) error { var _ decoderFrom = (*OperationResultTr)(nil) // DecodeFrom decodes this value using the Decoder. -func (u *OperationResultTr) DecodeFrom(d *xdr.Decoder) (int, error) { +func (u *OperationResultTr) DecodeFrom(d *xdr.Decoder, maxDepth uint) (int, error) { + if maxDepth == 0 { + return 0, fmt.Errorf("decoding OperationResultTr: %w", ErrMaxDecodingDepthReached) + } + maxDepth -= 1 var err error var n, nTmp int - nTmp, err = u.Type.DecodeFrom(d) + nTmp, err = u.Type.DecodeFrom(d, maxDepth) n += nTmp if err != nil { - return n, fmt.Errorf("decoding OperationType: %s", err) + return n, fmt.Errorf("decoding OperationType: %w", err) } switch OperationType(u.Type) { case OperationTypeCreateAccount: u.CreateAccountResult = new(CreateAccountResult) - nTmp, err = (*u.CreateAccountResult).DecodeFrom(d) + nTmp, err = (*u.CreateAccountResult).DecodeFrom(d, maxDepth) n += nTmp if err != nil { - return n, fmt.Errorf("decoding CreateAccountResult: %s", err) + return n, fmt.Errorf("decoding CreateAccountResult: %w", err) } return n, nil case OperationTypePayment: u.PaymentResult = new(PaymentResult) - nTmp, err = (*u.PaymentResult).DecodeFrom(d) + nTmp, err = (*u.PaymentResult).DecodeFrom(d, maxDepth) n += nTmp if err != nil { - return n, fmt.Errorf("decoding PaymentResult: %s", err) + return n, fmt.Errorf("decoding PaymentResult: %w", err) } return n, nil case OperationTypePathPaymentStrictReceive: u.PathPaymentStrictReceiveResult = new(PathPaymentStrictReceiveResult) - nTmp, err = (*u.PathPaymentStrictReceiveResult).DecodeFrom(d) + nTmp, err = (*u.PathPaymentStrictReceiveResult).DecodeFrom(d, maxDepth) n += nTmp if err != nil { - return n, fmt.Errorf("decoding PathPaymentStrictReceiveResult: %s", err) + return n, fmt.Errorf("decoding PathPaymentStrictReceiveResult: %w", err) } return n, nil case OperationTypeManageSellOffer: u.ManageSellOfferResult = new(ManageSellOfferResult) - nTmp, err = (*u.ManageSellOfferResult).DecodeFrom(d) + nTmp, err = (*u.ManageSellOfferResult).DecodeFrom(d, maxDepth) n += nTmp if err != nil { - return n, fmt.Errorf("decoding ManageSellOfferResult: %s", err) + return n, fmt.Errorf("decoding ManageSellOfferResult: %w", err) } return n, nil case OperationTypeCreatePassiveSellOffer: u.CreatePassiveSellOfferResult = new(ManageSellOfferResult) - nTmp, err = (*u.CreatePassiveSellOfferResult).DecodeFrom(d) + nTmp, err = (*u.CreatePassiveSellOfferResult).DecodeFrom(d, maxDepth) n += nTmp if err != nil { - return n, fmt.Errorf("decoding ManageSellOfferResult: %s", err) + return n, fmt.Errorf("decoding ManageSellOfferResult: %w", err) } return n, nil case OperationTypeSetOptions: u.SetOptionsResult = new(SetOptionsResult) - nTmp, err = (*u.SetOptionsResult).DecodeFrom(d) + nTmp, err = (*u.SetOptionsResult).DecodeFrom(d, maxDepth) n += nTmp if err != nil { - return n, fmt.Errorf("decoding SetOptionsResult: %s", err) + return n, fmt.Errorf("decoding SetOptionsResult: %w", err) } return n, nil case OperationTypeChangeTrust: u.ChangeTrustResult = new(ChangeTrustResult) - nTmp, err = (*u.ChangeTrustResult).DecodeFrom(d) + nTmp, err = (*u.ChangeTrustResult).DecodeFrom(d, maxDepth) n += nTmp if err != nil { - return n, fmt.Errorf("decoding ChangeTrustResult: %s", err) + return n, fmt.Errorf("decoding ChangeTrustResult: %w", err) } return n, nil case OperationTypeAllowTrust: u.AllowTrustResult = new(AllowTrustResult) - nTmp, err = (*u.AllowTrustResult).DecodeFrom(d) + nTmp, err = (*u.AllowTrustResult).DecodeFrom(d, maxDepth) n += nTmp if err != nil { - return n, fmt.Errorf("decoding AllowTrustResult: %s", err) + return n, fmt.Errorf("decoding AllowTrustResult: %w", err) } return n, nil case OperationTypeAccountMerge: u.AccountMergeResult = new(AccountMergeResult) - nTmp, err = (*u.AccountMergeResult).DecodeFrom(d) + nTmp, err = (*u.AccountMergeResult).DecodeFrom(d, maxDepth) n += nTmp if err != nil { - return n, fmt.Errorf("decoding AccountMergeResult: %s", err) + return n, fmt.Errorf("decoding AccountMergeResult: %w", err) } return n, nil case OperationTypeInflation: u.InflationResult = new(InflationResult) - nTmp, err = (*u.InflationResult).DecodeFrom(d) + nTmp, err = (*u.InflationResult).DecodeFrom(d, maxDepth) n += nTmp if err != nil { - return n, fmt.Errorf("decoding InflationResult: %s", err) + return n, fmt.Errorf("decoding InflationResult: %w", err) } return n, nil case OperationTypeManageData: u.ManageDataResult = new(ManageDataResult) - nTmp, err = (*u.ManageDataResult).DecodeFrom(d) + nTmp, err = (*u.ManageDataResult).DecodeFrom(d, maxDepth) n += nTmp if err != nil { - return n, fmt.Errorf("decoding ManageDataResult: %s", err) + return n, fmt.Errorf("decoding ManageDataResult: %w", err) } return n, nil case OperationTypeBumpSequence: u.BumpSeqResult = new(BumpSequenceResult) - nTmp, err = (*u.BumpSeqResult).DecodeFrom(d) + nTmp, err = (*u.BumpSeqResult).DecodeFrom(d, maxDepth) n += nTmp if err != nil { - return n, fmt.Errorf("decoding BumpSequenceResult: %s", err) + return n, fmt.Errorf("decoding BumpSequenceResult: %w", err) } return n, nil case OperationTypeManageBuyOffer: u.ManageBuyOfferResult = new(ManageBuyOfferResult) - nTmp, err = (*u.ManageBuyOfferResult).DecodeFrom(d) + nTmp, err = (*u.ManageBuyOfferResult).DecodeFrom(d, maxDepth) n += nTmp if err != nil { - return n, fmt.Errorf("decoding ManageBuyOfferResult: %s", err) + return n, fmt.Errorf("decoding ManageBuyOfferResult: %w", err) } return n, nil case OperationTypePathPaymentStrictSend: u.PathPaymentStrictSendResult = new(PathPaymentStrictSendResult) - nTmp, err = (*u.PathPaymentStrictSendResult).DecodeFrom(d) + nTmp, err = (*u.PathPaymentStrictSendResult).DecodeFrom(d, maxDepth) n += nTmp if err != nil { - return n, fmt.Errorf("decoding PathPaymentStrictSendResult: %s", err) + return n, fmt.Errorf("decoding PathPaymentStrictSendResult: %w", err) } return n, nil case OperationTypeCreateClaimableBalance: u.CreateClaimableBalanceResult = new(CreateClaimableBalanceResult) - nTmp, err = (*u.CreateClaimableBalanceResult).DecodeFrom(d) + nTmp, err = (*u.CreateClaimableBalanceResult).DecodeFrom(d, maxDepth) n += nTmp if err != nil { - return n, fmt.Errorf("decoding CreateClaimableBalanceResult: %s", err) + return n, fmt.Errorf("decoding CreateClaimableBalanceResult: %w", err) } return n, nil case OperationTypeClaimClaimableBalance: u.ClaimClaimableBalanceResult = new(ClaimClaimableBalanceResult) - nTmp, err = (*u.ClaimClaimableBalanceResult).DecodeFrom(d) + nTmp, err = (*u.ClaimClaimableBalanceResult).DecodeFrom(d, maxDepth) n += nTmp if err != nil { - return n, fmt.Errorf("decoding ClaimClaimableBalanceResult: %s", err) + return n, fmt.Errorf("decoding ClaimClaimableBalanceResult: %w", err) } return n, nil case OperationTypeBeginSponsoringFutureReserves: u.BeginSponsoringFutureReservesResult = new(BeginSponsoringFutureReservesResult) - nTmp, err = (*u.BeginSponsoringFutureReservesResult).DecodeFrom(d) + nTmp, err = (*u.BeginSponsoringFutureReservesResult).DecodeFrom(d, maxDepth) n += nTmp if err != nil { - return n, fmt.Errorf("decoding BeginSponsoringFutureReservesResult: %s", err) + return n, fmt.Errorf("decoding BeginSponsoringFutureReservesResult: %w", err) } return n, nil case OperationTypeEndSponsoringFutureReserves: u.EndSponsoringFutureReservesResult = new(EndSponsoringFutureReservesResult) - nTmp, err = (*u.EndSponsoringFutureReservesResult).DecodeFrom(d) + nTmp, err = (*u.EndSponsoringFutureReservesResult).DecodeFrom(d, maxDepth) n += nTmp if err != nil { - return n, fmt.Errorf("decoding EndSponsoringFutureReservesResult: %s", err) + return n, fmt.Errorf("decoding EndSponsoringFutureReservesResult: %w", err) } return n, nil case OperationTypeRevokeSponsorship: u.RevokeSponsorshipResult = new(RevokeSponsorshipResult) - nTmp, err = (*u.RevokeSponsorshipResult).DecodeFrom(d) + nTmp, err = (*u.RevokeSponsorshipResult).DecodeFrom(d, maxDepth) n += nTmp if err != nil { - return n, fmt.Errorf("decoding RevokeSponsorshipResult: %s", err) + return n, fmt.Errorf("decoding RevokeSponsorshipResult: %w", err) } return n, nil case OperationTypeClawback: u.ClawbackResult = new(ClawbackResult) - nTmp, err = (*u.ClawbackResult).DecodeFrom(d) + nTmp, err = (*u.ClawbackResult).DecodeFrom(d, maxDepth) n += nTmp if err != nil { - return n, fmt.Errorf("decoding ClawbackResult: %s", err) + return n, fmt.Errorf("decoding ClawbackResult: %w", err) } return n, nil case OperationTypeClawbackClaimableBalance: u.ClawbackClaimableBalanceResult = new(ClawbackClaimableBalanceResult) - nTmp, err = (*u.ClawbackClaimableBalanceResult).DecodeFrom(d) + nTmp, err = (*u.ClawbackClaimableBalanceResult).DecodeFrom(d, maxDepth) n += nTmp if err != nil { - return n, fmt.Errorf("decoding ClawbackClaimableBalanceResult: %s", err) + return n, fmt.Errorf("decoding ClawbackClaimableBalanceResult: %w", err) } return n, nil case OperationTypeSetTrustLineFlags: u.SetTrustLineFlagsResult = new(SetTrustLineFlagsResult) - nTmp, err = (*u.SetTrustLineFlagsResult).DecodeFrom(d) + nTmp, err = (*u.SetTrustLineFlagsResult).DecodeFrom(d, maxDepth) n += nTmp if err != nil { - return n, fmt.Errorf("decoding SetTrustLineFlagsResult: %s", err) + return n, fmt.Errorf("decoding SetTrustLineFlagsResult: %w", err) } return n, nil case OperationTypeLiquidityPoolDeposit: u.LiquidityPoolDepositResult = new(LiquidityPoolDepositResult) - nTmp, err = (*u.LiquidityPoolDepositResult).DecodeFrom(d) + nTmp, err = (*u.LiquidityPoolDepositResult).DecodeFrom(d, maxDepth) n += nTmp if err != nil { - return n, fmt.Errorf("decoding LiquidityPoolDepositResult: %s", err) + return n, fmt.Errorf("decoding LiquidityPoolDepositResult: %w", err) } return n, nil case OperationTypeLiquidityPoolWithdraw: u.LiquidityPoolWithdrawResult = new(LiquidityPoolWithdrawResult) - nTmp, err = (*u.LiquidityPoolWithdrawResult).DecodeFrom(d) + nTmp, err = (*u.LiquidityPoolWithdrawResult).DecodeFrom(d, maxDepth) n += nTmp if err != nil { - return n, fmt.Errorf("decoding LiquidityPoolWithdrawResult: %s", err) + return n, fmt.Errorf("decoding LiquidityPoolWithdrawResult: %w", err) } return n, nil case OperationTypeInvokeHostFunction: u.InvokeHostFunctionResult = new(InvokeHostFunctionResult) - nTmp, err = (*u.InvokeHostFunctionResult).DecodeFrom(d) + nTmp, err = (*u.InvokeHostFunctionResult).DecodeFrom(d, maxDepth) n += nTmp if err != nil { - return n, fmt.Errorf("decoding InvokeHostFunctionResult: %s", err) + return n, fmt.Errorf("decoding InvokeHostFunctionResult: %w", err) } return n, nil - case OperationTypeBumpFootprintExpiration: - u.BumpFootprintExpirationResult = new(BumpFootprintExpirationResult) - nTmp, err = (*u.BumpFootprintExpirationResult).DecodeFrom(d) + case OperationTypeExtendFootprintTtl: + u.ExtendFootprintTtlResult = new(ExtendFootprintTtlResult) + nTmp, err = (*u.ExtendFootprintTtlResult).DecodeFrom(d, maxDepth) n += nTmp if err != nil { - return n, fmt.Errorf("decoding BumpFootprintExpirationResult: %s", err) + return n, fmt.Errorf("decoding ExtendFootprintTtlResult: %w", err) } return n, nil case OperationTypeRestoreFootprint: u.RestoreFootprintResult = new(RestoreFootprintResult) - nTmp, err = (*u.RestoreFootprintResult).DecodeFrom(d) + nTmp, err = (*u.RestoreFootprintResult).DecodeFrom(d, maxDepth) n += nTmp if err != nil { - return n, fmt.Errorf("decoding RestoreFootprintResult: %s", err) + return n, fmt.Errorf("decoding RestoreFootprintResult: %w", err) } return n, nil } @@ -41345,7 +42416,7 @@ func (s OperationResultTr) MarshalBinary() ([]byte, error) { func (s *OperationResultTr) UnmarshalBinary(inp []byte) error { r := bytes.NewReader(inp) d := xdr.NewDecoder(r) - _, err := s.DecodeFrom(d) + _, err := s.DecodeFrom(d, xdr.DecodeDefaultMaxDepth) return err } @@ -41417,8 +42488,8 @@ var _ xdrType = (*OperationResultTr)(nil) // LiquidityPoolWithdrawResult liquidityPoolWithdrawResult; // case INVOKE_HOST_FUNCTION: // InvokeHostFunctionResult invokeHostFunctionResult; -// case BUMP_FOOTPRINT_EXPIRATION: -// BumpFootprintExpirationResult bumpFootprintExpirationResult; +// case EXTEND_FOOTPRINT_TTL: +// ExtendFootprintTTLResult extendFootprintTTLResult; // case RESTORE_FOOTPRINT: // RestoreFootprintResult restoreFootprintResult; // } @@ -41471,7 +42542,7 @@ func NewOperationResult(code OperationResultCode, value interface{}) (result Ope case OperationResultCodeOpInner: tv, ok := value.(OperationResultTr) if !ok { - err = fmt.Errorf("invalid value, must be OperationResultTr") + err = errors.New("invalid value, must be OperationResultTr") return } result.Tr = &tv @@ -41553,21 +42624,25 @@ func (u OperationResult) EncodeTo(e *xdr.Encoder) error { var _ decoderFrom = (*OperationResult)(nil) // DecodeFrom decodes this value using the Decoder. -func (u *OperationResult) DecodeFrom(d *xdr.Decoder) (int, error) { +func (u *OperationResult) DecodeFrom(d *xdr.Decoder, maxDepth uint) (int, error) { + if maxDepth == 0 { + return 0, fmt.Errorf("decoding OperationResult: %w", ErrMaxDecodingDepthReached) + } + maxDepth -= 1 var err error var n, nTmp int - nTmp, err = u.Code.DecodeFrom(d) + nTmp, err = u.Code.DecodeFrom(d, maxDepth) n += nTmp if err != nil { - return n, fmt.Errorf("decoding OperationResultCode: %s", err) + return n, fmt.Errorf("decoding OperationResultCode: %w", err) } switch OperationResultCode(u.Code) { case OperationResultCodeOpInner: u.Tr = new(OperationResultTr) - nTmp, err = (*u.Tr).DecodeFrom(d) + nTmp, err = (*u.Tr).DecodeFrom(d, maxDepth) n += nTmp if err != nil { - return n, fmt.Errorf("decoding OperationResultTr: %s", err) + return n, fmt.Errorf("decoding OperationResultTr: %w", err) } return n, nil case OperationResultCodeOpBadAuth: @@ -41604,7 +42679,7 @@ func (s OperationResult) MarshalBinary() ([]byte, error) { func (s *OperationResult) UnmarshalBinary(inp []byte) error { r := bytes.NewReader(inp) d := xdr.NewDecoder(r) - _, err := s.DecodeFrom(d) + _, err := s.DecodeFrom(d, xdr.DecodeDefaultMaxDepth) return err } @@ -41718,10 +42793,14 @@ func (e TransactionResultCode) EncodeTo(enc *xdr.Encoder) error { var _ decoderFrom = (*TransactionResultCode)(nil) // DecodeFrom decodes this value using the Decoder. -func (e *TransactionResultCode) DecodeFrom(d *xdr.Decoder) (int, error) { +func (e *TransactionResultCode) DecodeFrom(d *xdr.Decoder, maxDepth uint) (int, error) { + if maxDepth == 0 { + return 0, fmt.Errorf("decoding TransactionResultCode: %w", ErrMaxDecodingDepthReached) + } + maxDepth -= 1 v, n, err := d.DecodeInt() if err != nil { - return n, fmt.Errorf("decoding TransactionResultCode: %s", err) + return n, fmt.Errorf("decoding TransactionResultCode: %w", err) } if _, ok := transactionResultCodeMap[v]; !ok { return n, fmt.Errorf("'%d' is not a valid TransactionResultCode enum value", v) @@ -41742,7 +42821,7 @@ func (s TransactionResultCode) MarshalBinary() ([]byte, error) { func (s *TransactionResultCode) UnmarshalBinary(inp []byte) error { r := bytes.NewReader(inp) d := xdr.NewDecoder(r) - _, err := s.DecodeFrom(d) + _, err := s.DecodeFrom(d, xdr.DecodeDefaultMaxDepth) return err } @@ -41843,14 +42922,14 @@ func NewInnerTransactionResultResult(code TransactionResultCode, value interface case TransactionResultCodeTxSuccess: tv, ok := value.([]OperationResult) if !ok { - err = fmt.Errorf("invalid value, must be []OperationResult") + err = errors.New("invalid value, must be []OperationResult") return } result.Results = &tv case TransactionResultCodeTxFailed: tv, ok := value.([]OperationResult) if !ok { - err = fmt.Errorf("invalid value, must be []OperationResult") + err = errors.New("invalid value, must be []OperationResult") return } result.Results = &tv @@ -41992,13 +43071,17 @@ func (u InnerTransactionResultResult) EncodeTo(e *xdr.Encoder) error { var _ decoderFrom = (*InnerTransactionResultResult)(nil) // DecodeFrom decodes this value using the Decoder. -func (u *InnerTransactionResultResult) DecodeFrom(d *xdr.Decoder) (int, error) { +func (u *InnerTransactionResultResult) DecodeFrom(d *xdr.Decoder, maxDepth uint) (int, error) { + if maxDepth == 0 { + return 0, fmt.Errorf("decoding InnerTransactionResultResult: %w", ErrMaxDecodingDepthReached) + } + maxDepth -= 1 var err error var n, nTmp int - nTmp, err = u.Code.DecodeFrom(d) + nTmp, err = u.Code.DecodeFrom(d, maxDepth) n += nTmp if err != nil { - return n, fmt.Errorf("decoding TransactionResultCode: %s", err) + return n, fmt.Errorf("decoding TransactionResultCode: %w", err) } switch TransactionResultCode(u.Code) { case TransactionResultCodeTxSuccess: @@ -42007,16 +43090,16 @@ func (u *InnerTransactionResultResult) DecodeFrom(d *xdr.Decoder) (int, error) { l, nTmp, err = d.DecodeUint() n += nTmp if err != nil { - return n, fmt.Errorf("decoding OperationResult: %s", err) + return n, fmt.Errorf("decoding OperationResult: %w", err) } (*u.Results) = nil if l > 0 { (*u.Results) = make([]OperationResult, l) for i := uint32(0); i < l; i++ { - nTmp, err = (*u.Results)[i].DecodeFrom(d) + nTmp, err = (*u.Results)[i].DecodeFrom(d, maxDepth) n += nTmp if err != nil { - return n, fmt.Errorf("decoding OperationResult: %s", err) + return n, fmt.Errorf("decoding OperationResult: %w", err) } } } @@ -42027,16 +43110,16 @@ func (u *InnerTransactionResultResult) DecodeFrom(d *xdr.Decoder) (int, error) { l, nTmp, err = d.DecodeUint() n += nTmp if err != nil { - return n, fmt.Errorf("decoding OperationResult: %s", err) + return n, fmt.Errorf("decoding OperationResult: %w", err) } (*u.Results) = nil if l > 0 { (*u.Results) = make([]OperationResult, l) for i := uint32(0); i < l; i++ { - nTmp, err = (*u.Results)[i].DecodeFrom(d) + nTmp, err = (*u.Results)[i].DecodeFrom(d, maxDepth) n += nTmp if err != nil { - return n, fmt.Errorf("decoding OperationResult: %s", err) + return n, fmt.Errorf("decoding OperationResult: %w", err) } } } @@ -42102,7 +43185,7 @@ func (s InnerTransactionResultResult) MarshalBinary() ([]byte, error) { func (s *InnerTransactionResultResult) UnmarshalBinary(inp []byte) error { r := bytes.NewReader(inp) d := xdr.NewDecoder(r) - _, err := s.DecodeFrom(d) + _, err := s.DecodeFrom(d, xdr.DecodeDefaultMaxDepth) return err } @@ -42171,13 +43254,17 @@ func (u InnerTransactionResultExt) EncodeTo(e *xdr.Encoder) error { var _ decoderFrom = (*InnerTransactionResultExt)(nil) // DecodeFrom decodes this value using the Decoder. -func (u *InnerTransactionResultExt) DecodeFrom(d *xdr.Decoder) (int, error) { +func (u *InnerTransactionResultExt) DecodeFrom(d *xdr.Decoder, maxDepth uint) (int, error) { + if maxDepth == 0 { + return 0, fmt.Errorf("decoding InnerTransactionResultExt: %w", ErrMaxDecodingDepthReached) + } + maxDepth -= 1 var err error var n, nTmp int u.V, nTmp, err = d.DecodeInt() n += nTmp if err != nil { - return n, fmt.Errorf("decoding Int: %s", err) + return n, fmt.Errorf("decoding Int: %w", err) } switch int32(u.V) { case 0: @@ -42199,7 +43286,7 @@ func (s InnerTransactionResultExt) MarshalBinary() ([]byte, error) { func (s *InnerTransactionResultExt) UnmarshalBinary(inp []byte) error { r := bytes.NewReader(inp) d := xdr.NewDecoder(r) - _, err := s.DecodeFrom(d) + _, err := s.DecodeFrom(d, xdr.DecodeDefaultMaxDepth) return err } @@ -42279,23 +43366,27 @@ func (s *InnerTransactionResult) EncodeTo(e *xdr.Encoder) error { var _ decoderFrom = (*InnerTransactionResult)(nil) // DecodeFrom decodes this value using the Decoder. -func (s *InnerTransactionResult) DecodeFrom(d *xdr.Decoder) (int, error) { +func (s *InnerTransactionResult) DecodeFrom(d *xdr.Decoder, maxDepth uint) (int, error) { + if maxDepth == 0 { + return 0, fmt.Errorf("decoding InnerTransactionResult: %w", ErrMaxDecodingDepthReached) + } + maxDepth -= 1 var err error var n, nTmp int - nTmp, err = s.FeeCharged.DecodeFrom(d) + nTmp, err = s.FeeCharged.DecodeFrom(d, maxDepth) n += nTmp if err != nil { - return n, fmt.Errorf("decoding Int64: %s", err) + return n, fmt.Errorf("decoding Int64: %w", err) } - nTmp, err = s.Result.DecodeFrom(d) + nTmp, err = s.Result.DecodeFrom(d, maxDepth) n += nTmp if err != nil { - return n, fmt.Errorf("decoding InnerTransactionResultResult: %s", err) + return n, fmt.Errorf("decoding InnerTransactionResultResult: %w", err) } - nTmp, err = s.Ext.DecodeFrom(d) + nTmp, err = s.Ext.DecodeFrom(d, maxDepth) n += nTmp if err != nil { - return n, fmt.Errorf("decoding InnerTransactionResultExt: %s", err) + return n, fmt.Errorf("decoding InnerTransactionResultExt: %w", err) } return n, nil } @@ -42312,7 +43403,7 @@ func (s InnerTransactionResult) MarshalBinary() ([]byte, error) { func (s *InnerTransactionResult) UnmarshalBinary(inp []byte) error { r := bytes.NewReader(inp) d := xdr.NewDecoder(r) - _, err := s.DecodeFrom(d) + _, err := s.DecodeFrom(d, xdr.DecodeDefaultMaxDepth) return err } @@ -42354,18 +43445,22 @@ func (s *InnerTransactionResultPair) EncodeTo(e *xdr.Encoder) error { var _ decoderFrom = (*InnerTransactionResultPair)(nil) // DecodeFrom decodes this value using the Decoder. -func (s *InnerTransactionResultPair) DecodeFrom(d *xdr.Decoder) (int, error) { +func (s *InnerTransactionResultPair) DecodeFrom(d *xdr.Decoder, maxDepth uint) (int, error) { + if maxDepth == 0 { + return 0, fmt.Errorf("decoding InnerTransactionResultPair: %w", ErrMaxDecodingDepthReached) + } + maxDepth -= 1 var err error var n, nTmp int - nTmp, err = s.TransactionHash.DecodeFrom(d) + nTmp, err = s.TransactionHash.DecodeFrom(d, maxDepth) n += nTmp if err != nil { - return n, fmt.Errorf("decoding Hash: %s", err) + return n, fmt.Errorf("decoding Hash: %w", err) } - nTmp, err = s.Result.DecodeFrom(d) + nTmp, err = s.Result.DecodeFrom(d, maxDepth) n += nTmp if err != nil { - return n, fmt.Errorf("decoding InnerTransactionResult: %s", err) + return n, fmt.Errorf("decoding InnerTransactionResult: %w", err) } return n, nil } @@ -42382,7 +43477,7 @@ func (s InnerTransactionResultPair) MarshalBinary() ([]byte, error) { func (s *InnerTransactionResultPair) UnmarshalBinary(inp []byte) error { r := bytes.NewReader(inp) d := xdr.NewDecoder(r) - _, err := s.DecodeFrom(d) + _, err := s.DecodeFrom(d, xdr.DecodeDefaultMaxDepth) return err } @@ -42490,28 +43585,28 @@ func NewTransactionResultResult(code TransactionResultCode, value interface{}) ( case TransactionResultCodeTxFeeBumpInnerSuccess: tv, ok := value.(InnerTransactionResultPair) if !ok { - err = fmt.Errorf("invalid value, must be InnerTransactionResultPair") + err = errors.New("invalid value, must be InnerTransactionResultPair") return } result.InnerResultPair = &tv case TransactionResultCodeTxFeeBumpInnerFailed: tv, ok := value.(InnerTransactionResultPair) if !ok { - err = fmt.Errorf("invalid value, must be InnerTransactionResultPair") + err = errors.New("invalid value, must be InnerTransactionResultPair") return } result.InnerResultPair = &tv case TransactionResultCodeTxSuccess: tv, ok := value.([]OperationResult) if !ok { - err = fmt.Errorf("invalid value, must be []OperationResult") + err = errors.New("invalid value, must be []OperationResult") return } result.Results = &tv case TransactionResultCodeTxFailed: tv, ok := value.([]OperationResult) if !ok { - err = fmt.Errorf("invalid value, must be []OperationResult") + err = errors.New("invalid value, must be []OperationResult") return } result.Results = &tv @@ -42688,29 +43783,33 @@ func (u TransactionResultResult) EncodeTo(e *xdr.Encoder) error { var _ decoderFrom = (*TransactionResultResult)(nil) // DecodeFrom decodes this value using the Decoder. -func (u *TransactionResultResult) DecodeFrom(d *xdr.Decoder) (int, error) { +func (u *TransactionResultResult) DecodeFrom(d *xdr.Decoder, maxDepth uint) (int, error) { + if maxDepth == 0 { + return 0, fmt.Errorf("decoding TransactionResultResult: %w", ErrMaxDecodingDepthReached) + } + maxDepth -= 1 var err error var n, nTmp int - nTmp, err = u.Code.DecodeFrom(d) + nTmp, err = u.Code.DecodeFrom(d, maxDepth) n += nTmp if err != nil { - return n, fmt.Errorf("decoding TransactionResultCode: %s", err) + return n, fmt.Errorf("decoding TransactionResultCode: %w", err) } switch TransactionResultCode(u.Code) { case TransactionResultCodeTxFeeBumpInnerSuccess: u.InnerResultPair = new(InnerTransactionResultPair) - nTmp, err = (*u.InnerResultPair).DecodeFrom(d) + nTmp, err = (*u.InnerResultPair).DecodeFrom(d, maxDepth) n += nTmp if err != nil { - return n, fmt.Errorf("decoding InnerTransactionResultPair: %s", err) + return n, fmt.Errorf("decoding InnerTransactionResultPair: %w", err) } return n, nil case TransactionResultCodeTxFeeBumpInnerFailed: u.InnerResultPair = new(InnerTransactionResultPair) - nTmp, err = (*u.InnerResultPair).DecodeFrom(d) + nTmp, err = (*u.InnerResultPair).DecodeFrom(d, maxDepth) n += nTmp if err != nil { - return n, fmt.Errorf("decoding InnerTransactionResultPair: %s", err) + return n, fmt.Errorf("decoding InnerTransactionResultPair: %w", err) } return n, nil case TransactionResultCodeTxSuccess: @@ -42719,16 +43818,16 @@ func (u *TransactionResultResult) DecodeFrom(d *xdr.Decoder) (int, error) { l, nTmp, err = d.DecodeUint() n += nTmp if err != nil { - return n, fmt.Errorf("decoding OperationResult: %s", err) + return n, fmt.Errorf("decoding OperationResult: %w", err) } (*u.Results) = nil if l > 0 { (*u.Results) = make([]OperationResult, l) for i := uint32(0); i < l; i++ { - nTmp, err = (*u.Results)[i].DecodeFrom(d) + nTmp, err = (*u.Results)[i].DecodeFrom(d, maxDepth) n += nTmp if err != nil { - return n, fmt.Errorf("decoding OperationResult: %s", err) + return n, fmt.Errorf("decoding OperationResult: %w", err) } } } @@ -42739,16 +43838,16 @@ func (u *TransactionResultResult) DecodeFrom(d *xdr.Decoder) (int, error) { l, nTmp, err = d.DecodeUint() n += nTmp if err != nil { - return n, fmt.Errorf("decoding OperationResult: %s", err) + return n, fmt.Errorf("decoding OperationResult: %w", err) } (*u.Results) = nil if l > 0 { (*u.Results) = make([]OperationResult, l) for i := uint32(0); i < l; i++ { - nTmp, err = (*u.Results)[i].DecodeFrom(d) + nTmp, err = (*u.Results)[i].DecodeFrom(d, maxDepth) n += nTmp if err != nil { - return n, fmt.Errorf("decoding OperationResult: %s", err) + return n, fmt.Errorf("decoding OperationResult: %w", err) } } } @@ -42814,7 +43913,7 @@ func (s TransactionResultResult) MarshalBinary() ([]byte, error) { func (s *TransactionResultResult) UnmarshalBinary(inp []byte) error { r := bytes.NewReader(inp) d := xdr.NewDecoder(r) - _, err := s.DecodeFrom(d) + _, err := s.DecodeFrom(d, xdr.DecodeDefaultMaxDepth) return err } @@ -42883,13 +43982,17 @@ func (u TransactionResultExt) EncodeTo(e *xdr.Encoder) error { var _ decoderFrom = (*TransactionResultExt)(nil) // DecodeFrom decodes this value using the Decoder. -func (u *TransactionResultExt) DecodeFrom(d *xdr.Decoder) (int, error) { +func (u *TransactionResultExt) DecodeFrom(d *xdr.Decoder, maxDepth uint) (int, error) { + if maxDepth == 0 { + return 0, fmt.Errorf("decoding TransactionResultExt: %w", ErrMaxDecodingDepthReached) + } + maxDepth -= 1 var err error var n, nTmp int u.V, nTmp, err = d.DecodeInt() n += nTmp if err != nil { - return n, fmt.Errorf("decoding Int: %s", err) + return n, fmt.Errorf("decoding Int: %w", err) } switch int32(u.V) { case 0: @@ -42911,7 +44014,7 @@ func (s TransactionResultExt) MarshalBinary() ([]byte, error) { func (s *TransactionResultExt) UnmarshalBinary(inp []byte) error { r := bytes.NewReader(inp) d := xdr.NewDecoder(r) - _, err := s.DecodeFrom(d) + _, err := s.DecodeFrom(d, xdr.DecodeDefaultMaxDepth) return err } @@ -42992,23 +44095,27 @@ func (s *TransactionResult) EncodeTo(e *xdr.Encoder) error { var _ decoderFrom = (*TransactionResult)(nil) // DecodeFrom decodes this value using the Decoder. -func (s *TransactionResult) DecodeFrom(d *xdr.Decoder) (int, error) { +func (s *TransactionResult) DecodeFrom(d *xdr.Decoder, maxDepth uint) (int, error) { + if maxDepth == 0 { + return 0, fmt.Errorf("decoding TransactionResult: %w", ErrMaxDecodingDepthReached) + } + maxDepth -= 1 var err error var n, nTmp int - nTmp, err = s.FeeCharged.DecodeFrom(d) + nTmp, err = s.FeeCharged.DecodeFrom(d, maxDepth) n += nTmp if err != nil { - return n, fmt.Errorf("decoding Int64: %s", err) + return n, fmt.Errorf("decoding Int64: %w", err) } - nTmp, err = s.Result.DecodeFrom(d) + nTmp, err = s.Result.DecodeFrom(d, maxDepth) n += nTmp if err != nil { - return n, fmt.Errorf("decoding TransactionResultResult: %s", err) + return n, fmt.Errorf("decoding TransactionResultResult: %w", err) } - nTmp, err = s.Ext.DecodeFrom(d) + nTmp, err = s.Ext.DecodeFrom(d, maxDepth) n += nTmp if err != nil { - return n, fmt.Errorf("decoding TransactionResultExt: %s", err) + return n, fmt.Errorf("decoding TransactionResultExt: %w", err) } return n, nil } @@ -43025,7 +44132,7 @@ func (s TransactionResult) MarshalBinary() ([]byte, error) { func (s *TransactionResult) UnmarshalBinary(inp []byte) error { r := bytes.NewReader(inp) d := xdr.NewDecoder(r) - _, err := s.DecodeFrom(d) + _, err := s.DecodeFrom(d, xdr.DecodeDefaultMaxDepth) return err } @@ -43062,13 +44169,17 @@ func (s *Hash) EncodeTo(e *xdr.Encoder) error { var _ decoderFrom = (*Hash)(nil) // DecodeFrom decodes this value using the Decoder. -func (s *Hash) DecodeFrom(d *xdr.Decoder) (int, error) { +func (s *Hash) DecodeFrom(d *xdr.Decoder, maxDepth uint) (int, error) { + if maxDepth == 0 { + return 0, fmt.Errorf("decoding Hash: %w", ErrMaxDecodingDepthReached) + } + maxDepth -= 1 var err error var n, nTmp int nTmp, err = d.DecodeFixedOpaqueInplace(s[:]) n += nTmp if err != nil { - return n, fmt.Errorf("decoding Hash: %s", err) + return n, fmt.Errorf("decoding Hash: %w", err) } return n, nil } @@ -43085,7 +44196,7 @@ func (s Hash) MarshalBinary() ([]byte, error) { func (s *Hash) UnmarshalBinary(inp []byte) error { r := bytes.NewReader(inp) d := xdr.NewDecoder(r) - _, err := s.DecodeFrom(d) + _, err := s.DecodeFrom(d, xdr.DecodeDefaultMaxDepth) return err } @@ -43122,13 +44233,17 @@ func (s *Uint256) EncodeTo(e *xdr.Encoder) error { var _ decoderFrom = (*Uint256)(nil) // DecodeFrom decodes this value using the Decoder. -func (s *Uint256) DecodeFrom(d *xdr.Decoder) (int, error) { +func (s *Uint256) DecodeFrom(d *xdr.Decoder, maxDepth uint) (int, error) { + if maxDepth == 0 { + return 0, fmt.Errorf("decoding Uint256: %w", ErrMaxDecodingDepthReached) + } + maxDepth -= 1 var err error var n, nTmp int nTmp, err = d.DecodeFixedOpaqueInplace(s[:]) n += nTmp if err != nil { - return n, fmt.Errorf("decoding Uint256: %s", err) + return n, fmt.Errorf("decoding Uint256: %w", err) } return n, nil } @@ -43145,7 +44260,7 @@ func (s Uint256) MarshalBinary() ([]byte, error) { func (s *Uint256) UnmarshalBinary(inp []byte) error { r := bytes.NewReader(inp) d := xdr.NewDecoder(r) - _, err := s.DecodeFrom(d) + _, err := s.DecodeFrom(d, xdr.DecodeDefaultMaxDepth) return err } @@ -43177,14 +44292,18 @@ func (s Uint32) EncodeTo(e *xdr.Encoder) error { var _ decoderFrom = (*Uint32)(nil) // DecodeFrom decodes this value using the Decoder. -func (s *Uint32) DecodeFrom(d *xdr.Decoder) (int, error) { +func (s *Uint32) DecodeFrom(d *xdr.Decoder, maxDepth uint) (int, error) { + if maxDepth == 0 { + return 0, fmt.Errorf("decoding Uint32: %w", ErrMaxDecodingDepthReached) + } + maxDepth -= 1 var err error var n, nTmp int var v uint32 v, nTmp, err = d.DecodeUint() n += nTmp if err != nil { - return n, fmt.Errorf("decoding Unsigned int: %s", err) + return n, fmt.Errorf("decoding Unsigned int: %w", err) } *s = Uint32(v) return n, nil @@ -43202,7 +44321,7 @@ func (s Uint32) MarshalBinary() ([]byte, error) { func (s *Uint32) UnmarshalBinary(inp []byte) error { r := bytes.NewReader(inp) d := xdr.NewDecoder(r) - _, err := s.DecodeFrom(d) + _, err := s.DecodeFrom(d, xdr.DecodeDefaultMaxDepth) return err } @@ -43234,14 +44353,18 @@ func (s Int32) EncodeTo(e *xdr.Encoder) error { var _ decoderFrom = (*Int32)(nil) // DecodeFrom decodes this value using the Decoder. -func (s *Int32) DecodeFrom(d *xdr.Decoder) (int, error) { +func (s *Int32) DecodeFrom(d *xdr.Decoder, maxDepth uint) (int, error) { + if maxDepth == 0 { + return 0, fmt.Errorf("decoding Int32: %w", ErrMaxDecodingDepthReached) + } + maxDepth -= 1 var err error var n, nTmp int var v int32 v, nTmp, err = d.DecodeInt() n += nTmp if err != nil { - return n, fmt.Errorf("decoding Int: %s", err) + return n, fmt.Errorf("decoding Int: %w", err) } *s = Int32(v) return n, nil @@ -43259,7 +44382,7 @@ func (s Int32) MarshalBinary() ([]byte, error) { func (s *Int32) UnmarshalBinary(inp []byte) error { r := bytes.NewReader(inp) d := xdr.NewDecoder(r) - _, err := s.DecodeFrom(d) + _, err := s.DecodeFrom(d, xdr.DecodeDefaultMaxDepth) return err } @@ -43291,14 +44414,18 @@ func (s Uint64) EncodeTo(e *xdr.Encoder) error { var _ decoderFrom = (*Uint64)(nil) // DecodeFrom decodes this value using the Decoder. -func (s *Uint64) DecodeFrom(d *xdr.Decoder) (int, error) { +func (s *Uint64) DecodeFrom(d *xdr.Decoder, maxDepth uint) (int, error) { + if maxDepth == 0 { + return 0, fmt.Errorf("decoding Uint64: %w", ErrMaxDecodingDepthReached) + } + maxDepth -= 1 var err error var n, nTmp int var v uint64 v, nTmp, err = d.DecodeUhyper() n += nTmp if err != nil { - return n, fmt.Errorf("decoding Unsigned hyper: %s", err) + return n, fmt.Errorf("decoding Unsigned hyper: %w", err) } *s = Uint64(v) return n, nil @@ -43316,7 +44443,7 @@ func (s Uint64) MarshalBinary() ([]byte, error) { func (s *Uint64) UnmarshalBinary(inp []byte) error { r := bytes.NewReader(inp) d := xdr.NewDecoder(r) - _, err := s.DecodeFrom(d) + _, err := s.DecodeFrom(d, xdr.DecodeDefaultMaxDepth) return err } @@ -43348,14 +44475,18 @@ func (s Int64) EncodeTo(e *xdr.Encoder) error { var _ decoderFrom = (*Int64)(nil) // DecodeFrom decodes this value using the Decoder. -func (s *Int64) DecodeFrom(d *xdr.Decoder) (int, error) { +func (s *Int64) DecodeFrom(d *xdr.Decoder, maxDepth uint) (int, error) { + if maxDepth == 0 { + return 0, fmt.Errorf("decoding Int64: %w", ErrMaxDecodingDepthReached) + } + maxDepth -= 1 var err error var n, nTmp int var v int64 v, nTmp, err = d.DecodeHyper() n += nTmp if err != nil { - return n, fmt.Errorf("decoding Hyper: %s", err) + return n, fmt.Errorf("decoding Hyper: %w", err) } *s = Int64(v) return n, nil @@ -43373,7 +44504,7 @@ func (s Int64) MarshalBinary() ([]byte, error) { func (s *Int64) UnmarshalBinary(inp []byte) error { r := bytes.NewReader(inp) d := xdr.NewDecoder(r) - _, err := s.DecodeFrom(d) + _, err := s.DecodeFrom(d, xdr.DecodeDefaultMaxDepth) return err } @@ -43405,13 +44536,17 @@ func (s TimePoint) EncodeTo(e *xdr.Encoder) error { var _ decoderFrom = (*TimePoint)(nil) // DecodeFrom decodes this value using the Decoder. -func (s *TimePoint) DecodeFrom(d *xdr.Decoder) (int, error) { +func (s *TimePoint) DecodeFrom(d *xdr.Decoder, maxDepth uint) (int, error) { + if maxDepth == 0 { + return 0, fmt.Errorf("decoding TimePoint: %w", ErrMaxDecodingDepthReached) + } + maxDepth -= 1 var err error var n, nTmp int - nTmp, err = (*Uint64)(s).DecodeFrom(d) + nTmp, err = (*Uint64)(s).DecodeFrom(d, maxDepth) n += nTmp if err != nil { - return n, fmt.Errorf("decoding Uint64: %s", err) + return n, fmt.Errorf("decoding Uint64: %w", err) } return n, nil } @@ -43428,7 +44563,7 @@ func (s TimePoint) MarshalBinary() ([]byte, error) { func (s *TimePoint) UnmarshalBinary(inp []byte) error { r := bytes.NewReader(inp) d := xdr.NewDecoder(r) - _, err := s.DecodeFrom(d) + _, err := s.DecodeFrom(d, xdr.DecodeDefaultMaxDepth) return err } @@ -43460,13 +44595,17 @@ func (s Duration) EncodeTo(e *xdr.Encoder) error { var _ decoderFrom = (*Duration)(nil) // DecodeFrom decodes this value using the Decoder. -func (s *Duration) DecodeFrom(d *xdr.Decoder) (int, error) { +func (s *Duration) DecodeFrom(d *xdr.Decoder, maxDepth uint) (int, error) { + if maxDepth == 0 { + return 0, fmt.Errorf("decoding Duration: %w", ErrMaxDecodingDepthReached) + } + maxDepth -= 1 var err error var n, nTmp int - nTmp, err = (*Uint64)(s).DecodeFrom(d) + nTmp, err = (*Uint64)(s).DecodeFrom(d, maxDepth) n += nTmp if err != nil { - return n, fmt.Errorf("decoding Uint64: %s", err) + return n, fmt.Errorf("decoding Uint64: %w", err) } return n, nil } @@ -43483,7 +44622,7 @@ func (s Duration) MarshalBinary() ([]byte, error) { func (s *Duration) UnmarshalBinary(inp []byte) error { r := bytes.NewReader(inp) d := xdr.NewDecoder(r) - _, err := s.DecodeFrom(d) + _, err := s.DecodeFrom(d, xdr.DecodeDefaultMaxDepth) return err } @@ -43552,13 +44691,17 @@ func (u ExtensionPoint) EncodeTo(e *xdr.Encoder) error { var _ decoderFrom = (*ExtensionPoint)(nil) // DecodeFrom decodes this value using the Decoder. -func (u *ExtensionPoint) DecodeFrom(d *xdr.Decoder) (int, error) { +func (u *ExtensionPoint) DecodeFrom(d *xdr.Decoder, maxDepth uint) (int, error) { + if maxDepth == 0 { + return 0, fmt.Errorf("decoding ExtensionPoint: %w", ErrMaxDecodingDepthReached) + } + maxDepth -= 1 var err error var n, nTmp int u.V, nTmp, err = d.DecodeInt() n += nTmp if err != nil { - return n, fmt.Errorf("decoding Int: %s", err) + return n, fmt.Errorf("decoding Int: %w", err) } switch int32(u.V) { case 0: @@ -43580,7 +44723,7 @@ func (s ExtensionPoint) MarshalBinary() ([]byte, error) { func (s *ExtensionPoint) UnmarshalBinary(inp []byte) error { r := bytes.NewReader(inp) d := xdr.NewDecoder(r) - _, err := s.DecodeFrom(d) + _, err := s.DecodeFrom(d, xdr.DecodeDefaultMaxDepth) return err } @@ -43650,10 +44793,14 @@ func (e CryptoKeyType) EncodeTo(enc *xdr.Encoder) error { var _ decoderFrom = (*CryptoKeyType)(nil) // DecodeFrom decodes this value using the Decoder. -func (e *CryptoKeyType) DecodeFrom(d *xdr.Decoder) (int, error) { +func (e *CryptoKeyType) DecodeFrom(d *xdr.Decoder, maxDepth uint) (int, error) { + if maxDepth == 0 { + return 0, fmt.Errorf("decoding CryptoKeyType: %w", ErrMaxDecodingDepthReached) + } + maxDepth -= 1 v, n, err := d.DecodeInt() if err != nil { - return n, fmt.Errorf("decoding CryptoKeyType: %s", err) + return n, fmt.Errorf("decoding CryptoKeyType: %w", err) } if _, ok := cryptoKeyTypeMap[v]; !ok { return n, fmt.Errorf("'%d' is not a valid CryptoKeyType enum value", v) @@ -43674,7 +44821,7 @@ func (s CryptoKeyType) MarshalBinary() ([]byte, error) { func (s *CryptoKeyType) UnmarshalBinary(inp []byte) error { r := bytes.NewReader(inp) d := xdr.NewDecoder(r) - _, err := s.DecodeFrom(d) + _, err := s.DecodeFrom(d, xdr.DecodeDefaultMaxDepth) return err } @@ -43730,10 +44877,14 @@ func (e PublicKeyType) EncodeTo(enc *xdr.Encoder) error { var _ decoderFrom = (*PublicKeyType)(nil) // DecodeFrom decodes this value using the Decoder. -func (e *PublicKeyType) DecodeFrom(d *xdr.Decoder) (int, error) { +func (e *PublicKeyType) DecodeFrom(d *xdr.Decoder, maxDepth uint) (int, error) { + if maxDepth == 0 { + return 0, fmt.Errorf("decoding PublicKeyType: %w", ErrMaxDecodingDepthReached) + } + maxDepth -= 1 v, n, err := d.DecodeInt() if err != nil { - return n, fmt.Errorf("decoding PublicKeyType: %s", err) + return n, fmt.Errorf("decoding PublicKeyType: %w", err) } if _, ok := publicKeyTypeMap[v]; !ok { return n, fmt.Errorf("'%d' is not a valid PublicKeyType enum value", v) @@ -43754,7 +44905,7 @@ func (s PublicKeyType) MarshalBinary() ([]byte, error) { func (s *PublicKeyType) UnmarshalBinary(inp []byte) error { r := bytes.NewReader(inp) d := xdr.NewDecoder(r) - _, err := s.DecodeFrom(d) + _, err := s.DecodeFrom(d, xdr.DecodeDefaultMaxDepth) return err } @@ -43819,10 +44970,14 @@ func (e SignerKeyType) EncodeTo(enc *xdr.Encoder) error { var _ decoderFrom = (*SignerKeyType)(nil) // DecodeFrom decodes this value using the Decoder. -func (e *SignerKeyType) DecodeFrom(d *xdr.Decoder) (int, error) { +func (e *SignerKeyType) DecodeFrom(d *xdr.Decoder, maxDepth uint) (int, error) { + if maxDepth == 0 { + return 0, fmt.Errorf("decoding SignerKeyType: %w", ErrMaxDecodingDepthReached) + } + maxDepth -= 1 v, n, err := d.DecodeInt() if err != nil { - return n, fmt.Errorf("decoding SignerKeyType: %s", err) + return n, fmt.Errorf("decoding SignerKeyType: %w", err) } if _, ok := signerKeyTypeMap[v]; !ok { return n, fmt.Errorf("'%d' is not a valid SignerKeyType enum value", v) @@ -43843,7 +44998,7 @@ func (s SignerKeyType) MarshalBinary() ([]byte, error) { func (s *SignerKeyType) UnmarshalBinary(inp []byte) error { r := bytes.NewReader(inp) d := xdr.NewDecoder(r) - _, err := s.DecodeFrom(d) + _, err := s.DecodeFrom(d, xdr.DecodeDefaultMaxDepth) return err } @@ -43893,7 +45048,7 @@ func NewPublicKey(aType PublicKeyType, value interface{}) (result PublicKey, err case PublicKeyTypePublicKeyTypeEd25519: tv, ok := value.(Uint256) if !ok { - err = fmt.Errorf("invalid value, must be Uint256") + err = errors.New("invalid value, must be Uint256") return } result.Ed25519 = &tv @@ -43945,21 +45100,25 @@ func (u PublicKey) EncodeTo(e *xdr.Encoder) error { var _ decoderFrom = (*PublicKey)(nil) // DecodeFrom decodes this value using the Decoder. -func (u *PublicKey) DecodeFrom(d *xdr.Decoder) (int, error) { +func (u *PublicKey) DecodeFrom(d *xdr.Decoder, maxDepth uint) (int, error) { + if maxDepth == 0 { + return 0, fmt.Errorf("decoding PublicKey: %w", ErrMaxDecodingDepthReached) + } + maxDepth -= 1 var err error var n, nTmp int - nTmp, err = u.Type.DecodeFrom(d) + nTmp, err = u.Type.DecodeFrom(d, maxDepth) n += nTmp if err != nil { - return n, fmt.Errorf("decoding PublicKeyType: %s", err) + return n, fmt.Errorf("decoding PublicKeyType: %w", err) } switch PublicKeyType(u.Type) { case PublicKeyTypePublicKeyTypeEd25519: u.Ed25519 = new(Uint256) - nTmp, err = (*u.Ed25519).DecodeFrom(d) + nTmp, err = (*u.Ed25519).DecodeFrom(d, maxDepth) n += nTmp if err != nil { - return n, fmt.Errorf("decoding Uint256: %s", err) + return n, fmt.Errorf("decoding Uint256: %w", err) } return n, nil } @@ -43978,7 +45137,7 @@ func (s PublicKey) MarshalBinary() ([]byte, error) { func (s *PublicKey) UnmarshalBinary(inp []byte) error { r := bytes.NewReader(inp) d := xdr.NewDecoder(r) - _, err := s.DecodeFrom(d) + _, err := s.DecodeFrom(d, xdr.DecodeDefaultMaxDepth) return err } @@ -44022,18 +45181,22 @@ func (s *SignerKeyEd25519SignedPayload) EncodeTo(e *xdr.Encoder) error { var _ decoderFrom = (*SignerKeyEd25519SignedPayload)(nil) // DecodeFrom decodes this value using the Decoder. -func (s *SignerKeyEd25519SignedPayload) DecodeFrom(d *xdr.Decoder) (int, error) { +func (s *SignerKeyEd25519SignedPayload) DecodeFrom(d *xdr.Decoder, maxDepth uint) (int, error) { + if maxDepth == 0 { + return 0, fmt.Errorf("decoding SignerKeyEd25519SignedPayload: %w", ErrMaxDecodingDepthReached) + } + maxDepth -= 1 var err error var n, nTmp int - nTmp, err = s.Ed25519.DecodeFrom(d) + nTmp, err = s.Ed25519.DecodeFrom(d, maxDepth) n += nTmp if err != nil { - return n, fmt.Errorf("decoding Uint256: %s", err) + return n, fmt.Errorf("decoding Uint256: %w", err) } s.Payload, nTmp, err = d.DecodeOpaque(64) n += nTmp if err != nil { - return n, fmt.Errorf("decoding Payload: %s", err) + return n, fmt.Errorf("decoding Payload: %w", err) } return n, nil } @@ -44050,7 +45213,7 @@ func (s SignerKeyEd25519SignedPayload) MarshalBinary() ([]byte, error) { func (s *SignerKeyEd25519SignedPayload) UnmarshalBinary(inp []byte) error { r := bytes.NewReader(inp) d := xdr.NewDecoder(r) - _, err := s.DecodeFrom(d) + _, err := s.DecodeFrom(d, xdr.DecodeDefaultMaxDepth) return err } @@ -44123,28 +45286,28 @@ func NewSignerKey(aType SignerKeyType, value interface{}) (result SignerKey, err case SignerKeyTypeSignerKeyTypeEd25519: tv, ok := value.(Uint256) if !ok { - err = fmt.Errorf("invalid value, must be Uint256") + err = errors.New("invalid value, must be Uint256") return } result.Ed25519 = &tv case SignerKeyTypeSignerKeyTypePreAuthTx: tv, ok := value.(Uint256) if !ok { - err = fmt.Errorf("invalid value, must be Uint256") + err = errors.New("invalid value, must be Uint256") return } result.PreAuthTx = &tv case SignerKeyTypeSignerKeyTypeHashX: tv, ok := value.(Uint256) if !ok { - err = fmt.Errorf("invalid value, must be Uint256") + err = errors.New("invalid value, must be Uint256") return } result.HashX = &tv case SignerKeyTypeSignerKeyTypeEd25519SignedPayload: tv, ok := value.(SignerKeyEd25519SignedPayload) if !ok { - err = fmt.Errorf("invalid value, must be SignerKeyEd25519SignedPayload") + err = errors.New("invalid value, must be SignerKeyEd25519SignedPayload") return } result.Ed25519SignedPayload = &tv @@ -44286,45 +45449,49 @@ func (u SignerKey) EncodeTo(e *xdr.Encoder) error { var _ decoderFrom = (*SignerKey)(nil) // DecodeFrom decodes this value using the Decoder. -func (u *SignerKey) DecodeFrom(d *xdr.Decoder) (int, error) { +func (u *SignerKey) DecodeFrom(d *xdr.Decoder, maxDepth uint) (int, error) { + if maxDepth == 0 { + return 0, fmt.Errorf("decoding SignerKey: %w", ErrMaxDecodingDepthReached) + } + maxDepth -= 1 var err error var n, nTmp int - nTmp, err = u.Type.DecodeFrom(d) + nTmp, err = u.Type.DecodeFrom(d, maxDepth) n += nTmp if err != nil { - return n, fmt.Errorf("decoding SignerKeyType: %s", err) + return n, fmt.Errorf("decoding SignerKeyType: %w", err) } switch SignerKeyType(u.Type) { case SignerKeyTypeSignerKeyTypeEd25519: u.Ed25519 = new(Uint256) - nTmp, err = (*u.Ed25519).DecodeFrom(d) + nTmp, err = (*u.Ed25519).DecodeFrom(d, maxDepth) n += nTmp if err != nil { - return n, fmt.Errorf("decoding Uint256: %s", err) + return n, fmt.Errorf("decoding Uint256: %w", err) } return n, nil case SignerKeyTypeSignerKeyTypePreAuthTx: u.PreAuthTx = new(Uint256) - nTmp, err = (*u.PreAuthTx).DecodeFrom(d) + nTmp, err = (*u.PreAuthTx).DecodeFrom(d, maxDepth) n += nTmp if err != nil { - return n, fmt.Errorf("decoding Uint256: %s", err) + return n, fmt.Errorf("decoding Uint256: %w", err) } return n, nil case SignerKeyTypeSignerKeyTypeHashX: u.HashX = new(Uint256) - nTmp, err = (*u.HashX).DecodeFrom(d) + nTmp, err = (*u.HashX).DecodeFrom(d, maxDepth) n += nTmp if err != nil { - return n, fmt.Errorf("decoding Uint256: %s", err) + return n, fmt.Errorf("decoding Uint256: %w", err) } return n, nil case SignerKeyTypeSignerKeyTypeEd25519SignedPayload: u.Ed25519SignedPayload = new(SignerKeyEd25519SignedPayload) - nTmp, err = (*u.Ed25519SignedPayload).DecodeFrom(d) + nTmp, err = (*u.Ed25519SignedPayload).DecodeFrom(d, maxDepth) n += nTmp if err != nil { - return n, fmt.Errorf("decoding SignerKeyEd25519SignedPayload: %s", err) + return n, fmt.Errorf("decoding SignerKeyEd25519SignedPayload: %w", err) } return n, nil } @@ -44343,7 +45510,7 @@ func (s SignerKey) MarshalBinary() ([]byte, error) { func (s *SignerKey) UnmarshalBinary(inp []byte) error { r := bytes.NewReader(inp) d := xdr.NewDecoder(r) - _, err := s.DecodeFrom(d) + _, err := s.DecodeFrom(d, xdr.DecodeDefaultMaxDepth) return err } @@ -44380,13 +45547,17 @@ func (s Signature) EncodeTo(e *xdr.Encoder) error { var _ decoderFrom = (*Signature)(nil) // DecodeFrom decodes this value using the Decoder. -func (s *Signature) DecodeFrom(d *xdr.Decoder) (int, error) { +func (s *Signature) DecodeFrom(d *xdr.Decoder, maxDepth uint) (int, error) { + if maxDepth == 0 { + return 0, fmt.Errorf("decoding Signature: %w", ErrMaxDecodingDepthReached) + } + maxDepth -= 1 var err error var n, nTmp int (*s), nTmp, err = d.DecodeOpaque(64) n += nTmp if err != nil { - return n, fmt.Errorf("decoding Signature: %s", err) + return n, fmt.Errorf("decoding Signature: %w", err) } return n, nil } @@ -44403,7 +45574,7 @@ func (s Signature) MarshalBinary() ([]byte, error) { func (s *Signature) UnmarshalBinary(inp []byte) error { r := bytes.NewReader(inp) d := xdr.NewDecoder(r) - _, err := s.DecodeFrom(d) + _, err := s.DecodeFrom(d, xdr.DecodeDefaultMaxDepth) return err } @@ -44440,13 +45611,17 @@ func (s *SignatureHint) EncodeTo(e *xdr.Encoder) error { var _ decoderFrom = (*SignatureHint)(nil) // DecodeFrom decodes this value using the Decoder. -func (s *SignatureHint) DecodeFrom(d *xdr.Decoder) (int, error) { +func (s *SignatureHint) DecodeFrom(d *xdr.Decoder, maxDepth uint) (int, error) { + if maxDepth == 0 { + return 0, fmt.Errorf("decoding SignatureHint: %w", ErrMaxDecodingDepthReached) + } + maxDepth -= 1 var err error var n, nTmp int nTmp, err = d.DecodeFixedOpaqueInplace(s[:]) n += nTmp if err != nil { - return n, fmt.Errorf("decoding SignatureHint: %s", err) + return n, fmt.Errorf("decoding SignatureHint: %w", err) } return n, nil } @@ -44463,7 +45638,7 @@ func (s SignatureHint) MarshalBinary() ([]byte, error) { func (s *SignatureHint) UnmarshalBinary(inp []byte) error { r := bytes.NewReader(inp) d := xdr.NewDecoder(r) - _, err := s.DecodeFrom(d) + _, err := s.DecodeFrom(d, xdr.DecodeDefaultMaxDepth) return err } @@ -44526,13 +45701,17 @@ func (s NodeId) EncodeTo(e *xdr.Encoder) error { var _ decoderFrom = (*NodeId)(nil) // DecodeFrom decodes this value using the Decoder. -func (s *NodeId) DecodeFrom(d *xdr.Decoder) (int, error) { +func (s *NodeId) DecodeFrom(d *xdr.Decoder, maxDepth uint) (int, error) { + if maxDepth == 0 { + return 0, fmt.Errorf("decoding NodeId: %w", ErrMaxDecodingDepthReached) + } + maxDepth -= 1 var err error var n, nTmp int - nTmp, err = (*PublicKey)(s).DecodeFrom(d) + nTmp, err = (*PublicKey)(s).DecodeFrom(d, maxDepth) n += nTmp if err != nil { - return n, fmt.Errorf("decoding PublicKey: %s", err) + return n, fmt.Errorf("decoding PublicKey: %w", err) } return n, nil } @@ -44549,7 +45728,7 @@ func (s NodeId) MarshalBinary() ([]byte, error) { func (s *NodeId) UnmarshalBinary(inp []byte) error { r := bytes.NewReader(inp) d := xdr.NewDecoder(r) - _, err := s.DecodeFrom(d) + _, err := s.DecodeFrom(d, xdr.DecodeDefaultMaxDepth) return err } @@ -44612,13 +45791,17 @@ func (s AccountId) EncodeTo(e *xdr.Encoder) error { var _ decoderFrom = (*AccountId)(nil) // DecodeFrom decodes this value using the Decoder. -func (s *AccountId) DecodeFrom(d *xdr.Decoder) (int, error) { +func (s *AccountId) DecodeFrom(d *xdr.Decoder, maxDepth uint) (int, error) { + if maxDepth == 0 { + return 0, fmt.Errorf("decoding AccountId: %w", ErrMaxDecodingDepthReached) + } + maxDepth -= 1 var err error var n, nTmp int - nTmp, err = (*PublicKey)(s).DecodeFrom(d) + nTmp, err = (*PublicKey)(s).DecodeFrom(d, maxDepth) n += nTmp if err != nil { - return n, fmt.Errorf("decoding PublicKey: %s", err) + return n, fmt.Errorf("decoding PublicKey: %w", err) } return n, nil } @@ -44635,7 +45818,7 @@ func (s AccountId) MarshalBinary() ([]byte, error) { func (s *AccountId) UnmarshalBinary(inp []byte) error { r := bytes.NewReader(inp) d := xdr.NewDecoder(r) - _, err := s.DecodeFrom(d) + _, err := s.DecodeFrom(d, xdr.DecodeDefaultMaxDepth) return err } @@ -44672,13 +45855,17 @@ func (s *Curve25519Secret) EncodeTo(e *xdr.Encoder) error { var _ decoderFrom = (*Curve25519Secret)(nil) // DecodeFrom decodes this value using the Decoder. -func (s *Curve25519Secret) DecodeFrom(d *xdr.Decoder) (int, error) { +func (s *Curve25519Secret) DecodeFrom(d *xdr.Decoder, maxDepth uint) (int, error) { + if maxDepth == 0 { + return 0, fmt.Errorf("decoding Curve25519Secret: %w", ErrMaxDecodingDepthReached) + } + maxDepth -= 1 var err error var n, nTmp int nTmp, err = d.DecodeFixedOpaqueInplace(s.Key[:]) n += nTmp if err != nil { - return n, fmt.Errorf("decoding Key: %s", err) + return n, fmt.Errorf("decoding Key: %w", err) } return n, nil } @@ -44695,7 +45882,7 @@ func (s Curve25519Secret) MarshalBinary() ([]byte, error) { func (s *Curve25519Secret) UnmarshalBinary(inp []byte) error { r := bytes.NewReader(inp) d := xdr.NewDecoder(r) - _, err := s.DecodeFrom(d) + _, err := s.DecodeFrom(d, xdr.DecodeDefaultMaxDepth) return err } @@ -44732,13 +45919,17 @@ func (s *Curve25519Public) EncodeTo(e *xdr.Encoder) error { var _ decoderFrom = (*Curve25519Public)(nil) // DecodeFrom decodes this value using the Decoder. -func (s *Curve25519Public) DecodeFrom(d *xdr.Decoder) (int, error) { +func (s *Curve25519Public) DecodeFrom(d *xdr.Decoder, maxDepth uint) (int, error) { + if maxDepth == 0 { + return 0, fmt.Errorf("decoding Curve25519Public: %w", ErrMaxDecodingDepthReached) + } + maxDepth -= 1 var err error var n, nTmp int nTmp, err = d.DecodeFixedOpaqueInplace(s.Key[:]) n += nTmp if err != nil { - return n, fmt.Errorf("decoding Key: %s", err) + return n, fmt.Errorf("decoding Key: %w", err) } return n, nil } @@ -44755,7 +45946,7 @@ func (s Curve25519Public) MarshalBinary() ([]byte, error) { func (s *Curve25519Public) UnmarshalBinary(inp []byte) error { r := bytes.NewReader(inp) d := xdr.NewDecoder(r) - _, err := s.DecodeFrom(d) + _, err := s.DecodeFrom(d, xdr.DecodeDefaultMaxDepth) return err } @@ -44792,13 +45983,17 @@ func (s *HmacSha256Key) EncodeTo(e *xdr.Encoder) error { var _ decoderFrom = (*HmacSha256Key)(nil) // DecodeFrom decodes this value using the Decoder. -func (s *HmacSha256Key) DecodeFrom(d *xdr.Decoder) (int, error) { +func (s *HmacSha256Key) DecodeFrom(d *xdr.Decoder, maxDepth uint) (int, error) { + if maxDepth == 0 { + return 0, fmt.Errorf("decoding HmacSha256Key: %w", ErrMaxDecodingDepthReached) + } + maxDepth -= 1 var err error var n, nTmp int nTmp, err = d.DecodeFixedOpaqueInplace(s.Key[:]) n += nTmp if err != nil { - return n, fmt.Errorf("decoding Key: %s", err) + return n, fmt.Errorf("decoding Key: %w", err) } return n, nil } @@ -44815,7 +46010,7 @@ func (s HmacSha256Key) MarshalBinary() ([]byte, error) { func (s *HmacSha256Key) UnmarshalBinary(inp []byte) error { r := bytes.NewReader(inp) d := xdr.NewDecoder(r) - _, err := s.DecodeFrom(d) + _, err := s.DecodeFrom(d, xdr.DecodeDefaultMaxDepth) return err } @@ -44852,13 +46047,17 @@ func (s *HmacSha256Mac) EncodeTo(e *xdr.Encoder) error { var _ decoderFrom = (*HmacSha256Mac)(nil) // DecodeFrom decodes this value using the Decoder. -func (s *HmacSha256Mac) DecodeFrom(d *xdr.Decoder) (int, error) { +func (s *HmacSha256Mac) DecodeFrom(d *xdr.Decoder, maxDepth uint) (int, error) { + if maxDepth == 0 { + return 0, fmt.Errorf("decoding HmacSha256Mac: %w", ErrMaxDecodingDepthReached) + } + maxDepth -= 1 var err error var n, nTmp int nTmp, err = d.DecodeFixedOpaqueInplace(s.Mac[:]) n += nTmp if err != nil { - return n, fmt.Errorf("decoding Mac: %s", err) + return n, fmt.Errorf("decoding Mac: %w", err) } return n, nil } @@ -44875,7 +46074,7 @@ func (s HmacSha256Mac) MarshalBinary() ([]byte, error) { func (s *HmacSha256Mac) UnmarshalBinary(inp []byte) error { r := bytes.NewReader(inp) d := xdr.NewDecoder(r) - _, err := s.DecodeFrom(d) + _, err := s.DecodeFrom(d, xdr.DecodeDefaultMaxDepth) return err } @@ -44931,10 +46130,14 @@ func (e ScEnvMetaKind) EncodeTo(enc *xdr.Encoder) error { var _ decoderFrom = (*ScEnvMetaKind)(nil) // DecodeFrom decodes this value using the Decoder. -func (e *ScEnvMetaKind) DecodeFrom(d *xdr.Decoder) (int, error) { +func (e *ScEnvMetaKind) DecodeFrom(d *xdr.Decoder, maxDepth uint) (int, error) { + if maxDepth == 0 { + return 0, fmt.Errorf("decoding ScEnvMetaKind: %w", ErrMaxDecodingDepthReached) + } + maxDepth -= 1 v, n, err := d.DecodeInt() if err != nil { - return n, fmt.Errorf("decoding ScEnvMetaKind: %s", err) + return n, fmt.Errorf("decoding ScEnvMetaKind: %w", err) } if _, ok := scEnvMetaKindMap[v]; !ok { return n, fmt.Errorf("'%d' is not a valid ScEnvMetaKind enum value", v) @@ -44955,7 +46158,7 @@ func (s ScEnvMetaKind) MarshalBinary() ([]byte, error) { func (s *ScEnvMetaKind) UnmarshalBinary(inp []byte) error { r := bytes.NewReader(inp) d := xdr.NewDecoder(r) - _, err := s.DecodeFrom(d) + _, err := s.DecodeFrom(d, xdr.DecodeDefaultMaxDepth) return err } @@ -45005,7 +46208,7 @@ func NewScEnvMetaEntry(kind ScEnvMetaKind, value interface{}) (result ScEnvMetaE case ScEnvMetaKindScEnvMetaKindInterfaceVersion: tv, ok := value.(Uint64) if !ok { - err = fmt.Errorf("invalid value, must be Uint64") + err = errors.New("invalid value, must be Uint64") return } result.InterfaceVersion = &tv @@ -45057,21 +46260,25 @@ func (u ScEnvMetaEntry) EncodeTo(e *xdr.Encoder) error { var _ decoderFrom = (*ScEnvMetaEntry)(nil) // DecodeFrom decodes this value using the Decoder. -func (u *ScEnvMetaEntry) DecodeFrom(d *xdr.Decoder) (int, error) { +func (u *ScEnvMetaEntry) DecodeFrom(d *xdr.Decoder, maxDepth uint) (int, error) { + if maxDepth == 0 { + return 0, fmt.Errorf("decoding ScEnvMetaEntry: %w", ErrMaxDecodingDepthReached) + } + maxDepth -= 1 var err error var n, nTmp int - nTmp, err = u.Kind.DecodeFrom(d) + nTmp, err = u.Kind.DecodeFrom(d, maxDepth) n += nTmp if err != nil { - return n, fmt.Errorf("decoding ScEnvMetaKind: %s", err) + return n, fmt.Errorf("decoding ScEnvMetaKind: %w", err) } switch ScEnvMetaKind(u.Kind) { case ScEnvMetaKindScEnvMetaKindInterfaceVersion: u.InterfaceVersion = new(Uint64) - nTmp, err = (*u.InterfaceVersion).DecodeFrom(d) + nTmp, err = (*u.InterfaceVersion).DecodeFrom(d, maxDepth) n += nTmp if err != nil { - return n, fmt.Errorf("decoding Uint64: %s", err) + return n, fmt.Errorf("decoding Uint64: %w", err) } return n, nil } @@ -45090,7 +46297,7 @@ func (s ScEnvMetaEntry) MarshalBinary() ([]byte, error) { func (s *ScEnvMetaEntry) UnmarshalBinary(inp []byte) error { r := bytes.NewReader(inp) d := xdr.NewDecoder(r) - _, err := s.DecodeFrom(d) + _, err := s.DecodeFrom(d, xdr.DecodeDefaultMaxDepth) return err } @@ -45132,18 +46339,22 @@ func (s *ScMetaV0) EncodeTo(e *xdr.Encoder) error { var _ decoderFrom = (*ScMetaV0)(nil) // DecodeFrom decodes this value using the Decoder. -func (s *ScMetaV0) DecodeFrom(d *xdr.Decoder) (int, error) { +func (s *ScMetaV0) DecodeFrom(d *xdr.Decoder, maxDepth uint) (int, error) { + if maxDepth == 0 { + return 0, fmt.Errorf("decoding ScMetaV0: %w", ErrMaxDecodingDepthReached) + } + maxDepth -= 1 var err error var n, nTmp int s.Key, nTmp, err = d.DecodeString(0) n += nTmp if err != nil { - return n, fmt.Errorf("decoding Key: %s", err) + return n, fmt.Errorf("decoding Key: %w", err) } s.Val, nTmp, err = d.DecodeString(0) n += nTmp if err != nil { - return n, fmt.Errorf("decoding Val: %s", err) + return n, fmt.Errorf("decoding Val: %w", err) } return n, nil } @@ -45160,7 +46371,7 @@ func (s ScMetaV0) MarshalBinary() ([]byte, error) { func (s *ScMetaV0) UnmarshalBinary(inp []byte) error { r := bytes.NewReader(inp) d := xdr.NewDecoder(r) - _, err := s.DecodeFrom(d) + _, err := s.DecodeFrom(d, xdr.DecodeDefaultMaxDepth) return err } @@ -45216,10 +46427,14 @@ func (e ScMetaKind) EncodeTo(enc *xdr.Encoder) error { var _ decoderFrom = (*ScMetaKind)(nil) // DecodeFrom decodes this value using the Decoder. -func (e *ScMetaKind) DecodeFrom(d *xdr.Decoder) (int, error) { +func (e *ScMetaKind) DecodeFrom(d *xdr.Decoder, maxDepth uint) (int, error) { + if maxDepth == 0 { + return 0, fmt.Errorf("decoding ScMetaKind: %w", ErrMaxDecodingDepthReached) + } + maxDepth -= 1 v, n, err := d.DecodeInt() if err != nil { - return n, fmt.Errorf("decoding ScMetaKind: %s", err) + return n, fmt.Errorf("decoding ScMetaKind: %w", err) } if _, ok := scMetaKindMap[v]; !ok { return n, fmt.Errorf("'%d' is not a valid ScMetaKind enum value", v) @@ -45240,7 +46455,7 @@ func (s ScMetaKind) MarshalBinary() ([]byte, error) { func (s *ScMetaKind) UnmarshalBinary(inp []byte) error { r := bytes.NewReader(inp) d := xdr.NewDecoder(r) - _, err := s.DecodeFrom(d) + _, err := s.DecodeFrom(d, xdr.DecodeDefaultMaxDepth) return err } @@ -45290,7 +46505,7 @@ func NewScMetaEntry(kind ScMetaKind, value interface{}) (result ScMetaEntry, err case ScMetaKindScMetaV0: tv, ok := value.(ScMetaV0) if !ok { - err = fmt.Errorf("invalid value, must be ScMetaV0") + err = errors.New("invalid value, must be ScMetaV0") return } result.V0 = &tv @@ -45342,21 +46557,25 @@ func (u ScMetaEntry) EncodeTo(e *xdr.Encoder) error { var _ decoderFrom = (*ScMetaEntry)(nil) // DecodeFrom decodes this value using the Decoder. -func (u *ScMetaEntry) DecodeFrom(d *xdr.Decoder) (int, error) { +func (u *ScMetaEntry) DecodeFrom(d *xdr.Decoder, maxDepth uint) (int, error) { + if maxDepth == 0 { + return 0, fmt.Errorf("decoding ScMetaEntry: %w", ErrMaxDecodingDepthReached) + } + maxDepth -= 1 var err error var n, nTmp int - nTmp, err = u.Kind.DecodeFrom(d) + nTmp, err = u.Kind.DecodeFrom(d, maxDepth) n += nTmp if err != nil { - return n, fmt.Errorf("decoding ScMetaKind: %s", err) + return n, fmt.Errorf("decoding ScMetaKind: %w", err) } switch ScMetaKind(u.Kind) { case ScMetaKindScMetaV0: u.V0 = new(ScMetaV0) - nTmp, err = (*u.V0).DecodeFrom(d) + nTmp, err = (*u.V0).DecodeFrom(d, maxDepth) n += nTmp if err != nil { - return n, fmt.Errorf("decoding ScMetaV0: %s", err) + return n, fmt.Errorf("decoding ScMetaV0: %w", err) } return n, nil } @@ -45375,7 +46594,7 @@ func (s ScMetaEntry) MarshalBinary() ([]byte, error) { func (s *ScMetaEntry) UnmarshalBinary(inp []byte) error { r := bytes.NewReader(inp) d := xdr.NewDecoder(r) - _, err := s.DecodeFrom(d) + _, err := s.DecodeFrom(d, xdr.DecodeDefaultMaxDepth) return err } @@ -45514,10 +46733,14 @@ func (e ScSpecType) EncodeTo(enc *xdr.Encoder) error { var _ decoderFrom = (*ScSpecType)(nil) // DecodeFrom decodes this value using the Decoder. -func (e *ScSpecType) DecodeFrom(d *xdr.Decoder) (int, error) { +func (e *ScSpecType) DecodeFrom(d *xdr.Decoder, maxDepth uint) (int, error) { + if maxDepth == 0 { + return 0, fmt.Errorf("decoding ScSpecType: %w", ErrMaxDecodingDepthReached) + } + maxDepth -= 1 v, n, err := d.DecodeInt() if err != nil { - return n, fmt.Errorf("decoding ScSpecType: %s", err) + return n, fmt.Errorf("decoding ScSpecType: %w", err) } if _, ok := scSpecTypeMap[v]; !ok { return n, fmt.Errorf("'%d' is not a valid ScSpecType enum value", v) @@ -45538,7 +46761,7 @@ func (s ScSpecType) MarshalBinary() ([]byte, error) { func (s *ScSpecType) UnmarshalBinary(inp []byte) error { r := bytes.NewReader(inp) d := xdr.NewDecoder(r) - _, err := s.DecodeFrom(d) + _, err := s.DecodeFrom(d, xdr.DecodeDefaultMaxDepth) return err } @@ -45575,13 +46798,17 @@ func (s *ScSpecTypeOption) EncodeTo(e *xdr.Encoder) error { var _ decoderFrom = (*ScSpecTypeOption)(nil) // DecodeFrom decodes this value using the Decoder. -func (s *ScSpecTypeOption) DecodeFrom(d *xdr.Decoder) (int, error) { +func (s *ScSpecTypeOption) DecodeFrom(d *xdr.Decoder, maxDepth uint) (int, error) { + if maxDepth == 0 { + return 0, fmt.Errorf("decoding ScSpecTypeOption: %w", ErrMaxDecodingDepthReached) + } + maxDepth -= 1 var err error var n, nTmp int - nTmp, err = s.ValueType.DecodeFrom(d) + nTmp, err = s.ValueType.DecodeFrom(d, maxDepth) n += nTmp if err != nil { - return n, fmt.Errorf("decoding ScSpecTypeDef: %s", err) + return n, fmt.Errorf("decoding ScSpecTypeDef: %w", err) } return n, nil } @@ -45598,7 +46825,7 @@ func (s ScSpecTypeOption) MarshalBinary() ([]byte, error) { func (s *ScSpecTypeOption) UnmarshalBinary(inp []byte) error { r := bytes.NewReader(inp) d := xdr.NewDecoder(r) - _, err := s.DecodeFrom(d) + _, err := s.DecodeFrom(d, xdr.DecodeDefaultMaxDepth) return err } @@ -45640,18 +46867,22 @@ func (s *ScSpecTypeResult) EncodeTo(e *xdr.Encoder) error { var _ decoderFrom = (*ScSpecTypeResult)(nil) // DecodeFrom decodes this value using the Decoder. -func (s *ScSpecTypeResult) DecodeFrom(d *xdr.Decoder) (int, error) { +func (s *ScSpecTypeResult) DecodeFrom(d *xdr.Decoder, maxDepth uint) (int, error) { + if maxDepth == 0 { + return 0, fmt.Errorf("decoding ScSpecTypeResult: %w", ErrMaxDecodingDepthReached) + } + maxDepth -= 1 var err error var n, nTmp int - nTmp, err = s.OkType.DecodeFrom(d) + nTmp, err = s.OkType.DecodeFrom(d, maxDepth) n += nTmp if err != nil { - return n, fmt.Errorf("decoding ScSpecTypeDef: %s", err) + return n, fmt.Errorf("decoding ScSpecTypeDef: %w", err) } - nTmp, err = s.ErrorType.DecodeFrom(d) + nTmp, err = s.ErrorType.DecodeFrom(d, maxDepth) n += nTmp if err != nil { - return n, fmt.Errorf("decoding ScSpecTypeDef: %s", err) + return n, fmt.Errorf("decoding ScSpecTypeDef: %w", err) } return n, nil } @@ -45668,7 +46899,7 @@ func (s ScSpecTypeResult) MarshalBinary() ([]byte, error) { func (s *ScSpecTypeResult) UnmarshalBinary(inp []byte) error { r := bytes.NewReader(inp) d := xdr.NewDecoder(r) - _, err := s.DecodeFrom(d) + _, err := s.DecodeFrom(d, xdr.DecodeDefaultMaxDepth) return err } @@ -45705,13 +46936,17 @@ func (s *ScSpecTypeVec) EncodeTo(e *xdr.Encoder) error { var _ decoderFrom = (*ScSpecTypeVec)(nil) // DecodeFrom decodes this value using the Decoder. -func (s *ScSpecTypeVec) DecodeFrom(d *xdr.Decoder) (int, error) { +func (s *ScSpecTypeVec) DecodeFrom(d *xdr.Decoder, maxDepth uint) (int, error) { + if maxDepth == 0 { + return 0, fmt.Errorf("decoding ScSpecTypeVec: %w", ErrMaxDecodingDepthReached) + } + maxDepth -= 1 var err error var n, nTmp int - nTmp, err = s.ElementType.DecodeFrom(d) + nTmp, err = s.ElementType.DecodeFrom(d, maxDepth) n += nTmp if err != nil { - return n, fmt.Errorf("decoding ScSpecTypeDef: %s", err) + return n, fmt.Errorf("decoding ScSpecTypeDef: %w", err) } return n, nil } @@ -45728,7 +46963,7 @@ func (s ScSpecTypeVec) MarshalBinary() ([]byte, error) { func (s *ScSpecTypeVec) UnmarshalBinary(inp []byte) error { r := bytes.NewReader(inp) d := xdr.NewDecoder(r) - _, err := s.DecodeFrom(d) + _, err := s.DecodeFrom(d, xdr.DecodeDefaultMaxDepth) return err } @@ -45770,18 +47005,22 @@ func (s *ScSpecTypeMap) EncodeTo(e *xdr.Encoder) error { var _ decoderFrom = (*ScSpecTypeMap)(nil) // DecodeFrom decodes this value using the Decoder. -func (s *ScSpecTypeMap) DecodeFrom(d *xdr.Decoder) (int, error) { +func (s *ScSpecTypeMap) DecodeFrom(d *xdr.Decoder, maxDepth uint) (int, error) { + if maxDepth == 0 { + return 0, fmt.Errorf("decoding ScSpecTypeMap: %w", ErrMaxDecodingDepthReached) + } + maxDepth -= 1 var err error var n, nTmp int - nTmp, err = s.KeyType.DecodeFrom(d) + nTmp, err = s.KeyType.DecodeFrom(d, maxDepth) n += nTmp if err != nil { - return n, fmt.Errorf("decoding ScSpecTypeDef: %s", err) + return n, fmt.Errorf("decoding ScSpecTypeDef: %w", err) } - nTmp, err = s.ValueType.DecodeFrom(d) + nTmp, err = s.ValueType.DecodeFrom(d, maxDepth) n += nTmp if err != nil { - return n, fmt.Errorf("decoding ScSpecTypeDef: %s", err) + return n, fmt.Errorf("decoding ScSpecTypeDef: %w", err) } return n, nil } @@ -45798,7 +47037,7 @@ func (s ScSpecTypeMap) MarshalBinary() ([]byte, error) { func (s *ScSpecTypeMap) UnmarshalBinary(inp []byte) error { r := bytes.NewReader(inp) d := xdr.NewDecoder(r) - _, err := s.DecodeFrom(d) + _, err := s.DecodeFrom(d, xdr.DecodeDefaultMaxDepth) return err } @@ -45840,14 +47079,18 @@ func (s *ScSpecTypeTuple) EncodeTo(e *xdr.Encoder) error { var _ decoderFrom = (*ScSpecTypeTuple)(nil) // DecodeFrom decodes this value using the Decoder. -func (s *ScSpecTypeTuple) DecodeFrom(d *xdr.Decoder) (int, error) { +func (s *ScSpecTypeTuple) DecodeFrom(d *xdr.Decoder, maxDepth uint) (int, error) { + if maxDepth == 0 { + return 0, fmt.Errorf("decoding ScSpecTypeTuple: %w", ErrMaxDecodingDepthReached) + } + maxDepth -= 1 var err error var n, nTmp int var l uint32 l, nTmp, err = d.DecodeUint() n += nTmp if err != nil { - return n, fmt.Errorf("decoding ScSpecTypeDef: %s", err) + return n, fmt.Errorf("decoding ScSpecTypeDef: %w", err) } if l > 12 { return n, fmt.Errorf("decoding ScSpecTypeDef: data size (%d) exceeds size limit (12)", l) @@ -45856,10 +47099,10 @@ func (s *ScSpecTypeTuple) DecodeFrom(d *xdr.Decoder) (int, error) { if l > 0 { s.ValueTypes = make([]ScSpecTypeDef, l) for i := uint32(0); i < l; i++ { - nTmp, err = s.ValueTypes[i].DecodeFrom(d) + nTmp, err = s.ValueTypes[i].DecodeFrom(d, maxDepth) n += nTmp if err != nil { - return n, fmt.Errorf("decoding ScSpecTypeDef: %s", err) + return n, fmt.Errorf("decoding ScSpecTypeDef: %w", err) } } } @@ -45878,7 +47121,7 @@ func (s ScSpecTypeTuple) MarshalBinary() ([]byte, error) { func (s *ScSpecTypeTuple) UnmarshalBinary(inp []byte) error { r := bytes.NewReader(inp) d := xdr.NewDecoder(r) - _, err := s.DecodeFrom(d) + _, err := s.DecodeFrom(d, xdr.DecodeDefaultMaxDepth) return err } @@ -45915,13 +47158,17 @@ func (s *ScSpecTypeBytesN) EncodeTo(e *xdr.Encoder) error { var _ decoderFrom = (*ScSpecTypeBytesN)(nil) // DecodeFrom decodes this value using the Decoder. -func (s *ScSpecTypeBytesN) DecodeFrom(d *xdr.Decoder) (int, error) { +func (s *ScSpecTypeBytesN) DecodeFrom(d *xdr.Decoder, maxDepth uint) (int, error) { + if maxDepth == 0 { + return 0, fmt.Errorf("decoding ScSpecTypeBytesN: %w", ErrMaxDecodingDepthReached) + } + maxDepth -= 1 var err error var n, nTmp int - nTmp, err = s.N.DecodeFrom(d) + nTmp, err = s.N.DecodeFrom(d, maxDepth) n += nTmp if err != nil { - return n, fmt.Errorf("decoding Uint32: %s", err) + return n, fmt.Errorf("decoding Uint32: %w", err) } return n, nil } @@ -45938,7 +47185,7 @@ func (s ScSpecTypeBytesN) MarshalBinary() ([]byte, error) { func (s *ScSpecTypeBytesN) UnmarshalBinary(inp []byte) error { r := bytes.NewReader(inp) d := xdr.NewDecoder(r) - _, err := s.DecodeFrom(d) + _, err := s.DecodeFrom(d, xdr.DecodeDefaultMaxDepth) return err } @@ -45975,13 +47222,17 @@ func (s *ScSpecTypeUdt) EncodeTo(e *xdr.Encoder) error { var _ decoderFrom = (*ScSpecTypeUdt)(nil) // DecodeFrom decodes this value using the Decoder. -func (s *ScSpecTypeUdt) DecodeFrom(d *xdr.Decoder) (int, error) { +func (s *ScSpecTypeUdt) DecodeFrom(d *xdr.Decoder, maxDepth uint) (int, error) { + if maxDepth == 0 { + return 0, fmt.Errorf("decoding ScSpecTypeUdt: %w", ErrMaxDecodingDepthReached) + } + maxDepth -= 1 var err error var n, nTmp int s.Name, nTmp, err = d.DecodeString(60) n += nTmp if err != nil { - return n, fmt.Errorf("decoding Name: %s", err) + return n, fmt.Errorf("decoding Name: %w", err) } return n, nil } @@ -45998,7 +47249,7 @@ func (s ScSpecTypeUdt) MarshalBinary() ([]byte, error) { func (s *ScSpecTypeUdt) UnmarshalBinary(inp []byte) error { r := bytes.NewReader(inp) d := xdr.NewDecoder(r) - _, err := s.DecodeFrom(d) + _, err := s.DecodeFrom(d, xdr.DecodeDefaultMaxDepth) return err } @@ -46169,49 +47420,49 @@ func NewScSpecTypeDef(aType ScSpecType, value interface{}) (result ScSpecTypeDef case ScSpecTypeScSpecTypeOption: tv, ok := value.(ScSpecTypeOption) if !ok { - err = fmt.Errorf("invalid value, must be ScSpecTypeOption") + err = errors.New("invalid value, must be ScSpecTypeOption") return } result.Option = &tv case ScSpecTypeScSpecTypeResult: tv, ok := value.(ScSpecTypeResult) if !ok { - err = fmt.Errorf("invalid value, must be ScSpecTypeResult") + err = errors.New("invalid value, must be ScSpecTypeResult") return } result.Result = &tv case ScSpecTypeScSpecTypeVec: tv, ok := value.(ScSpecTypeVec) if !ok { - err = fmt.Errorf("invalid value, must be ScSpecTypeVec") + err = errors.New("invalid value, must be ScSpecTypeVec") return } result.Vec = &tv case ScSpecTypeScSpecTypeMap: tv, ok := value.(ScSpecTypeMap) if !ok { - err = fmt.Errorf("invalid value, must be ScSpecTypeMap") + err = errors.New("invalid value, must be ScSpecTypeMap") return } result.Map = &tv case ScSpecTypeScSpecTypeTuple: tv, ok := value.(ScSpecTypeTuple) if !ok { - err = fmt.Errorf("invalid value, must be ScSpecTypeTuple") + err = errors.New("invalid value, must be ScSpecTypeTuple") return } result.Tuple = &tv case ScSpecTypeScSpecTypeBytesN: tv, ok := value.(ScSpecTypeBytesN) if !ok { - err = fmt.Errorf("invalid value, must be ScSpecTypeBytesN") + err = errors.New("invalid value, must be ScSpecTypeBytesN") return } result.BytesN = &tv case ScSpecTypeScSpecTypeUdt: tv, ok := value.(ScSpecTypeUdt) if !ok { - err = fmt.Errorf("invalid value, must be ScSpecTypeUdt") + err = errors.New("invalid value, must be ScSpecTypeUdt") return } result.Udt = &tv @@ -46497,13 +47748,17 @@ func (u ScSpecTypeDef) EncodeTo(e *xdr.Encoder) error { var _ decoderFrom = (*ScSpecTypeDef)(nil) // DecodeFrom decodes this value using the Decoder. -func (u *ScSpecTypeDef) DecodeFrom(d *xdr.Decoder) (int, error) { +func (u *ScSpecTypeDef) DecodeFrom(d *xdr.Decoder, maxDepth uint) (int, error) { + if maxDepth == 0 { + return 0, fmt.Errorf("decoding ScSpecTypeDef: %w", ErrMaxDecodingDepthReached) + } + maxDepth -= 1 var err error var n, nTmp int - nTmp, err = u.Type.DecodeFrom(d) + nTmp, err = u.Type.DecodeFrom(d, maxDepth) n += nTmp if err != nil { - return n, fmt.Errorf("decoding ScSpecType: %s", err) + return n, fmt.Errorf("decoding ScSpecType: %w", err) } switch ScSpecType(u.Type) { case ScSpecTypeScSpecTypeVal: @@ -46562,58 +47817,58 @@ func (u *ScSpecTypeDef) DecodeFrom(d *xdr.Decoder) (int, error) { return n, nil case ScSpecTypeScSpecTypeOption: u.Option = new(ScSpecTypeOption) - nTmp, err = (*u.Option).DecodeFrom(d) + nTmp, err = (*u.Option).DecodeFrom(d, maxDepth) n += nTmp if err != nil { - return n, fmt.Errorf("decoding ScSpecTypeOption: %s", err) + return n, fmt.Errorf("decoding ScSpecTypeOption: %w", err) } return n, nil case ScSpecTypeScSpecTypeResult: u.Result = new(ScSpecTypeResult) - nTmp, err = (*u.Result).DecodeFrom(d) + nTmp, err = (*u.Result).DecodeFrom(d, maxDepth) n += nTmp if err != nil { - return n, fmt.Errorf("decoding ScSpecTypeResult: %s", err) + return n, fmt.Errorf("decoding ScSpecTypeResult: %w", err) } return n, nil case ScSpecTypeScSpecTypeVec: u.Vec = new(ScSpecTypeVec) - nTmp, err = (*u.Vec).DecodeFrom(d) + nTmp, err = (*u.Vec).DecodeFrom(d, maxDepth) n += nTmp if err != nil { - return n, fmt.Errorf("decoding ScSpecTypeVec: %s", err) + return n, fmt.Errorf("decoding ScSpecTypeVec: %w", err) } return n, nil case ScSpecTypeScSpecTypeMap: u.Map = new(ScSpecTypeMap) - nTmp, err = (*u.Map).DecodeFrom(d) + nTmp, err = (*u.Map).DecodeFrom(d, maxDepth) n += nTmp if err != nil { - return n, fmt.Errorf("decoding ScSpecTypeMap: %s", err) + return n, fmt.Errorf("decoding ScSpecTypeMap: %w", err) } return n, nil case ScSpecTypeScSpecTypeTuple: u.Tuple = new(ScSpecTypeTuple) - nTmp, err = (*u.Tuple).DecodeFrom(d) + nTmp, err = (*u.Tuple).DecodeFrom(d, maxDepth) n += nTmp if err != nil { - return n, fmt.Errorf("decoding ScSpecTypeTuple: %s", err) + return n, fmt.Errorf("decoding ScSpecTypeTuple: %w", err) } return n, nil case ScSpecTypeScSpecTypeBytesN: u.BytesN = new(ScSpecTypeBytesN) - nTmp, err = (*u.BytesN).DecodeFrom(d) + nTmp, err = (*u.BytesN).DecodeFrom(d, maxDepth) n += nTmp if err != nil { - return n, fmt.Errorf("decoding ScSpecTypeBytesN: %s", err) + return n, fmt.Errorf("decoding ScSpecTypeBytesN: %w", err) } return n, nil case ScSpecTypeScSpecTypeUdt: u.Udt = new(ScSpecTypeUdt) - nTmp, err = (*u.Udt).DecodeFrom(d) + nTmp, err = (*u.Udt).DecodeFrom(d, maxDepth) n += nTmp if err != nil { - return n, fmt.Errorf("decoding ScSpecTypeUdt: %s", err) + return n, fmt.Errorf("decoding ScSpecTypeUdt: %w", err) } return n, nil } @@ -46632,7 +47887,7 @@ func (s ScSpecTypeDef) MarshalBinary() ([]byte, error) { func (s *ScSpecTypeDef) UnmarshalBinary(inp []byte) error { r := bytes.NewReader(inp) d := xdr.NewDecoder(r) - _, err := s.DecodeFrom(d) + _, err := s.DecodeFrom(d, xdr.DecodeDefaultMaxDepth) return err } @@ -46679,23 +47934,27 @@ func (s *ScSpecUdtStructFieldV0) EncodeTo(e *xdr.Encoder) error { var _ decoderFrom = (*ScSpecUdtStructFieldV0)(nil) // DecodeFrom decodes this value using the Decoder. -func (s *ScSpecUdtStructFieldV0) DecodeFrom(d *xdr.Decoder) (int, error) { +func (s *ScSpecUdtStructFieldV0) DecodeFrom(d *xdr.Decoder, maxDepth uint) (int, error) { + if maxDepth == 0 { + return 0, fmt.Errorf("decoding ScSpecUdtStructFieldV0: %w", ErrMaxDecodingDepthReached) + } + maxDepth -= 1 var err error var n, nTmp int s.Doc, nTmp, err = d.DecodeString(1024) n += nTmp if err != nil { - return n, fmt.Errorf("decoding Doc: %s", err) + return n, fmt.Errorf("decoding Doc: %w", err) } s.Name, nTmp, err = d.DecodeString(30) n += nTmp if err != nil { - return n, fmt.Errorf("decoding Name: %s", err) + return n, fmt.Errorf("decoding Name: %w", err) } - nTmp, err = s.Type.DecodeFrom(d) + nTmp, err = s.Type.DecodeFrom(d, maxDepth) n += nTmp if err != nil { - return n, fmt.Errorf("decoding ScSpecTypeDef: %s", err) + return n, fmt.Errorf("decoding ScSpecTypeDef: %w", err) } return n, nil } @@ -46712,7 +47971,7 @@ func (s ScSpecUdtStructFieldV0) MarshalBinary() ([]byte, error) { func (s *ScSpecUdtStructFieldV0) UnmarshalBinary(inp []byte) error { r := bytes.NewReader(inp) d := xdr.NewDecoder(r) - _, err := s.DecodeFrom(d) + _, err := s.DecodeFrom(d, xdr.DecodeDefaultMaxDepth) return err } @@ -46769,29 +48028,33 @@ func (s *ScSpecUdtStructV0) EncodeTo(e *xdr.Encoder) error { var _ decoderFrom = (*ScSpecUdtStructV0)(nil) // DecodeFrom decodes this value using the Decoder. -func (s *ScSpecUdtStructV0) DecodeFrom(d *xdr.Decoder) (int, error) { +func (s *ScSpecUdtStructV0) DecodeFrom(d *xdr.Decoder, maxDepth uint) (int, error) { + if maxDepth == 0 { + return 0, fmt.Errorf("decoding ScSpecUdtStructV0: %w", ErrMaxDecodingDepthReached) + } + maxDepth -= 1 var err error var n, nTmp int s.Doc, nTmp, err = d.DecodeString(1024) n += nTmp if err != nil { - return n, fmt.Errorf("decoding Doc: %s", err) + return n, fmt.Errorf("decoding Doc: %w", err) } s.Lib, nTmp, err = d.DecodeString(80) n += nTmp if err != nil { - return n, fmt.Errorf("decoding Lib: %s", err) + return n, fmt.Errorf("decoding Lib: %w", err) } s.Name, nTmp, err = d.DecodeString(60) n += nTmp if err != nil { - return n, fmt.Errorf("decoding Name: %s", err) + return n, fmt.Errorf("decoding Name: %w", err) } var l uint32 l, nTmp, err = d.DecodeUint() n += nTmp if err != nil { - return n, fmt.Errorf("decoding ScSpecUdtStructFieldV0: %s", err) + return n, fmt.Errorf("decoding ScSpecUdtStructFieldV0: %w", err) } if l > 40 { return n, fmt.Errorf("decoding ScSpecUdtStructFieldV0: data size (%d) exceeds size limit (40)", l) @@ -46800,10 +48063,10 @@ func (s *ScSpecUdtStructV0) DecodeFrom(d *xdr.Decoder) (int, error) { if l > 0 { s.Fields = make([]ScSpecUdtStructFieldV0, l) for i := uint32(0); i < l; i++ { - nTmp, err = s.Fields[i].DecodeFrom(d) + nTmp, err = s.Fields[i].DecodeFrom(d, maxDepth) n += nTmp if err != nil { - return n, fmt.Errorf("decoding ScSpecUdtStructFieldV0: %s", err) + return n, fmt.Errorf("decoding ScSpecUdtStructFieldV0: %w", err) } } } @@ -46822,7 +48085,7 @@ func (s ScSpecUdtStructV0) MarshalBinary() ([]byte, error) { func (s *ScSpecUdtStructV0) UnmarshalBinary(inp []byte) error { r := bytes.NewReader(inp) d := xdr.NewDecoder(r) - _, err := s.DecodeFrom(d) + _, err := s.DecodeFrom(d, xdr.DecodeDefaultMaxDepth) return err } @@ -46864,18 +48127,22 @@ func (s *ScSpecUdtUnionCaseVoidV0) EncodeTo(e *xdr.Encoder) error { var _ decoderFrom = (*ScSpecUdtUnionCaseVoidV0)(nil) // DecodeFrom decodes this value using the Decoder. -func (s *ScSpecUdtUnionCaseVoidV0) DecodeFrom(d *xdr.Decoder) (int, error) { +func (s *ScSpecUdtUnionCaseVoidV0) DecodeFrom(d *xdr.Decoder, maxDepth uint) (int, error) { + if maxDepth == 0 { + return 0, fmt.Errorf("decoding ScSpecUdtUnionCaseVoidV0: %w", ErrMaxDecodingDepthReached) + } + maxDepth -= 1 var err error var n, nTmp int s.Doc, nTmp, err = d.DecodeString(1024) n += nTmp if err != nil { - return n, fmt.Errorf("decoding Doc: %s", err) + return n, fmt.Errorf("decoding Doc: %w", err) } s.Name, nTmp, err = d.DecodeString(60) n += nTmp if err != nil { - return n, fmt.Errorf("decoding Name: %s", err) + return n, fmt.Errorf("decoding Name: %w", err) } return n, nil } @@ -46892,7 +48159,7 @@ func (s ScSpecUdtUnionCaseVoidV0) MarshalBinary() ([]byte, error) { func (s *ScSpecUdtUnionCaseVoidV0) UnmarshalBinary(inp []byte) error { r := bytes.NewReader(inp) d := xdr.NewDecoder(r) - _, err := s.DecodeFrom(d) + _, err := s.DecodeFrom(d, xdr.DecodeDefaultMaxDepth) return err } @@ -46944,24 +48211,28 @@ func (s *ScSpecUdtUnionCaseTupleV0) EncodeTo(e *xdr.Encoder) error { var _ decoderFrom = (*ScSpecUdtUnionCaseTupleV0)(nil) // DecodeFrom decodes this value using the Decoder. -func (s *ScSpecUdtUnionCaseTupleV0) DecodeFrom(d *xdr.Decoder) (int, error) { +func (s *ScSpecUdtUnionCaseTupleV0) DecodeFrom(d *xdr.Decoder, maxDepth uint) (int, error) { + if maxDepth == 0 { + return 0, fmt.Errorf("decoding ScSpecUdtUnionCaseTupleV0: %w", ErrMaxDecodingDepthReached) + } + maxDepth -= 1 var err error var n, nTmp int s.Doc, nTmp, err = d.DecodeString(1024) n += nTmp if err != nil { - return n, fmt.Errorf("decoding Doc: %s", err) + return n, fmt.Errorf("decoding Doc: %w", err) } s.Name, nTmp, err = d.DecodeString(60) n += nTmp if err != nil { - return n, fmt.Errorf("decoding Name: %s", err) + return n, fmt.Errorf("decoding Name: %w", err) } var l uint32 l, nTmp, err = d.DecodeUint() n += nTmp if err != nil { - return n, fmt.Errorf("decoding ScSpecTypeDef: %s", err) + return n, fmt.Errorf("decoding ScSpecTypeDef: %w", err) } if l > 12 { return n, fmt.Errorf("decoding ScSpecTypeDef: data size (%d) exceeds size limit (12)", l) @@ -46970,10 +48241,10 @@ func (s *ScSpecUdtUnionCaseTupleV0) DecodeFrom(d *xdr.Decoder) (int, error) { if l > 0 { s.Type = make([]ScSpecTypeDef, l) for i := uint32(0); i < l; i++ { - nTmp, err = s.Type[i].DecodeFrom(d) + nTmp, err = s.Type[i].DecodeFrom(d, maxDepth) n += nTmp if err != nil { - return n, fmt.Errorf("decoding ScSpecTypeDef: %s", err) + return n, fmt.Errorf("decoding ScSpecTypeDef: %w", err) } } } @@ -46992,7 +48263,7 @@ func (s ScSpecUdtUnionCaseTupleV0) MarshalBinary() ([]byte, error) { func (s *ScSpecUdtUnionCaseTupleV0) UnmarshalBinary(inp []byte) error { r := bytes.NewReader(inp) d := xdr.NewDecoder(r) - _, err := s.DecodeFrom(d) + _, err := s.DecodeFrom(d, xdr.DecodeDefaultMaxDepth) return err } @@ -47051,10 +48322,14 @@ func (e ScSpecUdtUnionCaseV0Kind) EncodeTo(enc *xdr.Encoder) error { var _ decoderFrom = (*ScSpecUdtUnionCaseV0Kind)(nil) // DecodeFrom decodes this value using the Decoder. -func (e *ScSpecUdtUnionCaseV0Kind) DecodeFrom(d *xdr.Decoder) (int, error) { +func (e *ScSpecUdtUnionCaseV0Kind) DecodeFrom(d *xdr.Decoder, maxDepth uint) (int, error) { + if maxDepth == 0 { + return 0, fmt.Errorf("decoding ScSpecUdtUnionCaseV0Kind: %w", ErrMaxDecodingDepthReached) + } + maxDepth -= 1 v, n, err := d.DecodeInt() if err != nil { - return n, fmt.Errorf("decoding ScSpecUdtUnionCaseV0Kind: %s", err) + return n, fmt.Errorf("decoding ScSpecUdtUnionCaseV0Kind: %w", err) } if _, ok := scSpecUdtUnionCaseV0KindMap[v]; !ok { return n, fmt.Errorf("'%d' is not a valid ScSpecUdtUnionCaseV0Kind enum value", v) @@ -47075,7 +48350,7 @@ func (s ScSpecUdtUnionCaseV0Kind) MarshalBinary() ([]byte, error) { func (s *ScSpecUdtUnionCaseV0Kind) UnmarshalBinary(inp []byte) error { r := bytes.NewReader(inp) d := xdr.NewDecoder(r) - _, err := s.DecodeFrom(d) + _, err := s.DecodeFrom(d, xdr.DecodeDefaultMaxDepth) return err } @@ -47130,14 +48405,14 @@ func NewScSpecUdtUnionCaseV0(kind ScSpecUdtUnionCaseV0Kind, value interface{}) ( case ScSpecUdtUnionCaseV0KindScSpecUdtUnionCaseVoidV0: tv, ok := value.(ScSpecUdtUnionCaseVoidV0) if !ok { - err = fmt.Errorf("invalid value, must be ScSpecUdtUnionCaseVoidV0") + err = errors.New("invalid value, must be ScSpecUdtUnionCaseVoidV0") return } result.VoidCase = &tv case ScSpecUdtUnionCaseV0KindScSpecUdtUnionCaseTupleV0: tv, ok := value.(ScSpecUdtUnionCaseTupleV0) if !ok { - err = fmt.Errorf("invalid value, must be ScSpecUdtUnionCaseTupleV0") + err = errors.New("invalid value, must be ScSpecUdtUnionCaseTupleV0") return } result.TupleCase = &tv @@ -47219,29 +48494,33 @@ func (u ScSpecUdtUnionCaseV0) EncodeTo(e *xdr.Encoder) error { var _ decoderFrom = (*ScSpecUdtUnionCaseV0)(nil) // DecodeFrom decodes this value using the Decoder. -func (u *ScSpecUdtUnionCaseV0) DecodeFrom(d *xdr.Decoder) (int, error) { +func (u *ScSpecUdtUnionCaseV0) DecodeFrom(d *xdr.Decoder, maxDepth uint) (int, error) { + if maxDepth == 0 { + return 0, fmt.Errorf("decoding ScSpecUdtUnionCaseV0: %w", ErrMaxDecodingDepthReached) + } + maxDepth -= 1 var err error var n, nTmp int - nTmp, err = u.Kind.DecodeFrom(d) + nTmp, err = u.Kind.DecodeFrom(d, maxDepth) n += nTmp if err != nil { - return n, fmt.Errorf("decoding ScSpecUdtUnionCaseV0Kind: %s", err) + return n, fmt.Errorf("decoding ScSpecUdtUnionCaseV0Kind: %w", err) } switch ScSpecUdtUnionCaseV0Kind(u.Kind) { case ScSpecUdtUnionCaseV0KindScSpecUdtUnionCaseVoidV0: u.VoidCase = new(ScSpecUdtUnionCaseVoidV0) - nTmp, err = (*u.VoidCase).DecodeFrom(d) + nTmp, err = (*u.VoidCase).DecodeFrom(d, maxDepth) n += nTmp if err != nil { - return n, fmt.Errorf("decoding ScSpecUdtUnionCaseVoidV0: %s", err) + return n, fmt.Errorf("decoding ScSpecUdtUnionCaseVoidV0: %w", err) } return n, nil case ScSpecUdtUnionCaseV0KindScSpecUdtUnionCaseTupleV0: u.TupleCase = new(ScSpecUdtUnionCaseTupleV0) - nTmp, err = (*u.TupleCase).DecodeFrom(d) + nTmp, err = (*u.TupleCase).DecodeFrom(d, maxDepth) n += nTmp if err != nil { - return n, fmt.Errorf("decoding ScSpecUdtUnionCaseTupleV0: %s", err) + return n, fmt.Errorf("decoding ScSpecUdtUnionCaseTupleV0: %w", err) } return n, nil } @@ -47260,7 +48539,7 @@ func (s ScSpecUdtUnionCaseV0) MarshalBinary() ([]byte, error) { func (s *ScSpecUdtUnionCaseV0) UnmarshalBinary(inp []byte) error { r := bytes.NewReader(inp) d := xdr.NewDecoder(r) - _, err := s.DecodeFrom(d) + _, err := s.DecodeFrom(d, xdr.DecodeDefaultMaxDepth) return err } @@ -47317,29 +48596,33 @@ func (s *ScSpecUdtUnionV0) EncodeTo(e *xdr.Encoder) error { var _ decoderFrom = (*ScSpecUdtUnionV0)(nil) // DecodeFrom decodes this value using the Decoder. -func (s *ScSpecUdtUnionV0) DecodeFrom(d *xdr.Decoder) (int, error) { +func (s *ScSpecUdtUnionV0) DecodeFrom(d *xdr.Decoder, maxDepth uint) (int, error) { + if maxDepth == 0 { + return 0, fmt.Errorf("decoding ScSpecUdtUnionV0: %w", ErrMaxDecodingDepthReached) + } + maxDepth -= 1 var err error var n, nTmp int s.Doc, nTmp, err = d.DecodeString(1024) n += nTmp if err != nil { - return n, fmt.Errorf("decoding Doc: %s", err) + return n, fmt.Errorf("decoding Doc: %w", err) } s.Lib, nTmp, err = d.DecodeString(80) n += nTmp if err != nil { - return n, fmt.Errorf("decoding Lib: %s", err) + return n, fmt.Errorf("decoding Lib: %w", err) } s.Name, nTmp, err = d.DecodeString(60) n += nTmp if err != nil { - return n, fmt.Errorf("decoding Name: %s", err) + return n, fmt.Errorf("decoding Name: %w", err) } var l uint32 l, nTmp, err = d.DecodeUint() n += nTmp if err != nil { - return n, fmt.Errorf("decoding ScSpecUdtUnionCaseV0: %s", err) + return n, fmt.Errorf("decoding ScSpecUdtUnionCaseV0: %w", err) } if l > 50 { return n, fmt.Errorf("decoding ScSpecUdtUnionCaseV0: data size (%d) exceeds size limit (50)", l) @@ -47348,10 +48631,10 @@ func (s *ScSpecUdtUnionV0) DecodeFrom(d *xdr.Decoder) (int, error) { if l > 0 { s.Cases = make([]ScSpecUdtUnionCaseV0, l) for i := uint32(0); i < l; i++ { - nTmp, err = s.Cases[i].DecodeFrom(d) + nTmp, err = s.Cases[i].DecodeFrom(d, maxDepth) n += nTmp if err != nil { - return n, fmt.Errorf("decoding ScSpecUdtUnionCaseV0: %s", err) + return n, fmt.Errorf("decoding ScSpecUdtUnionCaseV0: %w", err) } } } @@ -47370,7 +48653,7 @@ func (s ScSpecUdtUnionV0) MarshalBinary() ([]byte, error) { func (s *ScSpecUdtUnionV0) UnmarshalBinary(inp []byte) error { r := bytes.NewReader(inp) d := xdr.NewDecoder(r) - _, err := s.DecodeFrom(d) + _, err := s.DecodeFrom(d, xdr.DecodeDefaultMaxDepth) return err } @@ -47417,23 +48700,27 @@ func (s *ScSpecUdtEnumCaseV0) EncodeTo(e *xdr.Encoder) error { var _ decoderFrom = (*ScSpecUdtEnumCaseV0)(nil) // DecodeFrom decodes this value using the Decoder. -func (s *ScSpecUdtEnumCaseV0) DecodeFrom(d *xdr.Decoder) (int, error) { +func (s *ScSpecUdtEnumCaseV0) DecodeFrom(d *xdr.Decoder, maxDepth uint) (int, error) { + if maxDepth == 0 { + return 0, fmt.Errorf("decoding ScSpecUdtEnumCaseV0: %w", ErrMaxDecodingDepthReached) + } + maxDepth -= 1 var err error var n, nTmp int s.Doc, nTmp, err = d.DecodeString(1024) n += nTmp if err != nil { - return n, fmt.Errorf("decoding Doc: %s", err) + return n, fmt.Errorf("decoding Doc: %w", err) } s.Name, nTmp, err = d.DecodeString(60) n += nTmp if err != nil { - return n, fmt.Errorf("decoding Name: %s", err) + return n, fmt.Errorf("decoding Name: %w", err) } - nTmp, err = s.Value.DecodeFrom(d) + nTmp, err = s.Value.DecodeFrom(d, maxDepth) n += nTmp if err != nil { - return n, fmt.Errorf("decoding Uint32: %s", err) + return n, fmt.Errorf("decoding Uint32: %w", err) } return n, nil } @@ -47450,7 +48737,7 @@ func (s ScSpecUdtEnumCaseV0) MarshalBinary() ([]byte, error) { func (s *ScSpecUdtEnumCaseV0) UnmarshalBinary(inp []byte) error { r := bytes.NewReader(inp) d := xdr.NewDecoder(r) - _, err := s.DecodeFrom(d) + _, err := s.DecodeFrom(d, xdr.DecodeDefaultMaxDepth) return err } @@ -47507,29 +48794,33 @@ func (s *ScSpecUdtEnumV0) EncodeTo(e *xdr.Encoder) error { var _ decoderFrom = (*ScSpecUdtEnumV0)(nil) // DecodeFrom decodes this value using the Decoder. -func (s *ScSpecUdtEnumV0) DecodeFrom(d *xdr.Decoder) (int, error) { +func (s *ScSpecUdtEnumV0) DecodeFrom(d *xdr.Decoder, maxDepth uint) (int, error) { + if maxDepth == 0 { + return 0, fmt.Errorf("decoding ScSpecUdtEnumV0: %w", ErrMaxDecodingDepthReached) + } + maxDepth -= 1 var err error var n, nTmp int s.Doc, nTmp, err = d.DecodeString(1024) n += nTmp if err != nil { - return n, fmt.Errorf("decoding Doc: %s", err) + return n, fmt.Errorf("decoding Doc: %w", err) } s.Lib, nTmp, err = d.DecodeString(80) n += nTmp if err != nil { - return n, fmt.Errorf("decoding Lib: %s", err) + return n, fmt.Errorf("decoding Lib: %w", err) } s.Name, nTmp, err = d.DecodeString(60) n += nTmp if err != nil { - return n, fmt.Errorf("decoding Name: %s", err) + return n, fmt.Errorf("decoding Name: %w", err) } var l uint32 l, nTmp, err = d.DecodeUint() n += nTmp if err != nil { - return n, fmt.Errorf("decoding ScSpecUdtEnumCaseV0: %s", err) + return n, fmt.Errorf("decoding ScSpecUdtEnumCaseV0: %w", err) } if l > 50 { return n, fmt.Errorf("decoding ScSpecUdtEnumCaseV0: data size (%d) exceeds size limit (50)", l) @@ -47538,10 +48829,10 @@ func (s *ScSpecUdtEnumV0) DecodeFrom(d *xdr.Decoder) (int, error) { if l > 0 { s.Cases = make([]ScSpecUdtEnumCaseV0, l) for i := uint32(0); i < l; i++ { - nTmp, err = s.Cases[i].DecodeFrom(d) + nTmp, err = s.Cases[i].DecodeFrom(d, maxDepth) n += nTmp if err != nil { - return n, fmt.Errorf("decoding ScSpecUdtEnumCaseV0: %s", err) + return n, fmt.Errorf("decoding ScSpecUdtEnumCaseV0: %w", err) } } } @@ -47560,7 +48851,7 @@ func (s ScSpecUdtEnumV0) MarshalBinary() ([]byte, error) { func (s *ScSpecUdtEnumV0) UnmarshalBinary(inp []byte) error { r := bytes.NewReader(inp) d := xdr.NewDecoder(r) - _, err := s.DecodeFrom(d) + _, err := s.DecodeFrom(d, xdr.DecodeDefaultMaxDepth) return err } @@ -47607,23 +48898,27 @@ func (s *ScSpecUdtErrorEnumCaseV0) EncodeTo(e *xdr.Encoder) error { var _ decoderFrom = (*ScSpecUdtErrorEnumCaseV0)(nil) // DecodeFrom decodes this value using the Decoder. -func (s *ScSpecUdtErrorEnumCaseV0) DecodeFrom(d *xdr.Decoder) (int, error) { +func (s *ScSpecUdtErrorEnumCaseV0) DecodeFrom(d *xdr.Decoder, maxDepth uint) (int, error) { + if maxDepth == 0 { + return 0, fmt.Errorf("decoding ScSpecUdtErrorEnumCaseV0: %w", ErrMaxDecodingDepthReached) + } + maxDepth -= 1 var err error var n, nTmp int s.Doc, nTmp, err = d.DecodeString(1024) n += nTmp if err != nil { - return n, fmt.Errorf("decoding Doc: %s", err) + return n, fmt.Errorf("decoding Doc: %w", err) } s.Name, nTmp, err = d.DecodeString(60) n += nTmp if err != nil { - return n, fmt.Errorf("decoding Name: %s", err) + return n, fmt.Errorf("decoding Name: %w", err) } - nTmp, err = s.Value.DecodeFrom(d) + nTmp, err = s.Value.DecodeFrom(d, maxDepth) n += nTmp if err != nil { - return n, fmt.Errorf("decoding Uint32: %s", err) + return n, fmt.Errorf("decoding Uint32: %w", err) } return n, nil } @@ -47640,7 +48935,7 @@ func (s ScSpecUdtErrorEnumCaseV0) MarshalBinary() ([]byte, error) { func (s *ScSpecUdtErrorEnumCaseV0) UnmarshalBinary(inp []byte) error { r := bytes.NewReader(inp) d := xdr.NewDecoder(r) - _, err := s.DecodeFrom(d) + _, err := s.DecodeFrom(d, xdr.DecodeDefaultMaxDepth) return err } @@ -47697,29 +48992,33 @@ func (s *ScSpecUdtErrorEnumV0) EncodeTo(e *xdr.Encoder) error { var _ decoderFrom = (*ScSpecUdtErrorEnumV0)(nil) // DecodeFrom decodes this value using the Decoder. -func (s *ScSpecUdtErrorEnumV0) DecodeFrom(d *xdr.Decoder) (int, error) { +func (s *ScSpecUdtErrorEnumV0) DecodeFrom(d *xdr.Decoder, maxDepth uint) (int, error) { + if maxDepth == 0 { + return 0, fmt.Errorf("decoding ScSpecUdtErrorEnumV0: %w", ErrMaxDecodingDepthReached) + } + maxDepth -= 1 var err error var n, nTmp int s.Doc, nTmp, err = d.DecodeString(1024) n += nTmp if err != nil { - return n, fmt.Errorf("decoding Doc: %s", err) + return n, fmt.Errorf("decoding Doc: %w", err) } s.Lib, nTmp, err = d.DecodeString(80) n += nTmp if err != nil { - return n, fmt.Errorf("decoding Lib: %s", err) + return n, fmt.Errorf("decoding Lib: %w", err) } s.Name, nTmp, err = d.DecodeString(60) n += nTmp if err != nil { - return n, fmt.Errorf("decoding Name: %s", err) + return n, fmt.Errorf("decoding Name: %w", err) } var l uint32 l, nTmp, err = d.DecodeUint() n += nTmp if err != nil { - return n, fmt.Errorf("decoding ScSpecUdtErrorEnumCaseV0: %s", err) + return n, fmt.Errorf("decoding ScSpecUdtErrorEnumCaseV0: %w", err) } if l > 50 { return n, fmt.Errorf("decoding ScSpecUdtErrorEnumCaseV0: data size (%d) exceeds size limit (50)", l) @@ -47728,10 +49027,10 @@ func (s *ScSpecUdtErrorEnumV0) DecodeFrom(d *xdr.Decoder) (int, error) { if l > 0 { s.Cases = make([]ScSpecUdtErrorEnumCaseV0, l) for i := uint32(0); i < l; i++ { - nTmp, err = s.Cases[i].DecodeFrom(d) + nTmp, err = s.Cases[i].DecodeFrom(d, maxDepth) n += nTmp if err != nil { - return n, fmt.Errorf("decoding ScSpecUdtErrorEnumCaseV0: %s", err) + return n, fmt.Errorf("decoding ScSpecUdtErrorEnumCaseV0: %w", err) } } } @@ -47750,7 +49049,7 @@ func (s ScSpecUdtErrorEnumV0) MarshalBinary() ([]byte, error) { func (s *ScSpecUdtErrorEnumV0) UnmarshalBinary(inp []byte) error { r := bytes.NewReader(inp) d := xdr.NewDecoder(r) - _, err := s.DecodeFrom(d) + _, err := s.DecodeFrom(d, xdr.DecodeDefaultMaxDepth) return err } @@ -47797,23 +49096,27 @@ func (s *ScSpecFunctionInputV0) EncodeTo(e *xdr.Encoder) error { var _ decoderFrom = (*ScSpecFunctionInputV0)(nil) // DecodeFrom decodes this value using the Decoder. -func (s *ScSpecFunctionInputV0) DecodeFrom(d *xdr.Decoder) (int, error) { +func (s *ScSpecFunctionInputV0) DecodeFrom(d *xdr.Decoder, maxDepth uint) (int, error) { + if maxDepth == 0 { + return 0, fmt.Errorf("decoding ScSpecFunctionInputV0: %w", ErrMaxDecodingDepthReached) + } + maxDepth -= 1 var err error var n, nTmp int s.Doc, nTmp, err = d.DecodeString(1024) n += nTmp if err != nil { - return n, fmt.Errorf("decoding Doc: %s", err) + return n, fmt.Errorf("decoding Doc: %w", err) } s.Name, nTmp, err = d.DecodeString(30) n += nTmp if err != nil { - return n, fmt.Errorf("decoding Name: %s", err) + return n, fmt.Errorf("decoding Name: %w", err) } - nTmp, err = s.Type.DecodeFrom(d) + nTmp, err = s.Type.DecodeFrom(d, maxDepth) n += nTmp if err != nil { - return n, fmt.Errorf("decoding ScSpecTypeDef: %s", err) + return n, fmt.Errorf("decoding ScSpecTypeDef: %w", err) } return n, nil } @@ -47830,7 +49133,7 @@ func (s ScSpecFunctionInputV0) MarshalBinary() ([]byte, error) { func (s *ScSpecFunctionInputV0) UnmarshalBinary(inp []byte) error { r := bytes.NewReader(inp) d := xdr.NewDecoder(r) - _, err := s.DecodeFrom(d) + _, err := s.DecodeFrom(d, xdr.DecodeDefaultMaxDepth) return err } @@ -47892,24 +49195,28 @@ func (s *ScSpecFunctionV0) EncodeTo(e *xdr.Encoder) error { var _ decoderFrom = (*ScSpecFunctionV0)(nil) // DecodeFrom decodes this value using the Decoder. -func (s *ScSpecFunctionV0) DecodeFrom(d *xdr.Decoder) (int, error) { +func (s *ScSpecFunctionV0) DecodeFrom(d *xdr.Decoder, maxDepth uint) (int, error) { + if maxDepth == 0 { + return 0, fmt.Errorf("decoding ScSpecFunctionV0: %w", ErrMaxDecodingDepthReached) + } + maxDepth -= 1 var err error var n, nTmp int s.Doc, nTmp, err = d.DecodeString(1024) n += nTmp if err != nil { - return n, fmt.Errorf("decoding Doc: %s", err) + return n, fmt.Errorf("decoding Doc: %w", err) } - nTmp, err = s.Name.DecodeFrom(d) + nTmp, err = s.Name.DecodeFrom(d, maxDepth) n += nTmp if err != nil { - return n, fmt.Errorf("decoding ScSymbol: %s", err) + return n, fmt.Errorf("decoding ScSymbol: %w", err) } var l uint32 l, nTmp, err = d.DecodeUint() n += nTmp if err != nil { - return n, fmt.Errorf("decoding ScSpecFunctionInputV0: %s", err) + return n, fmt.Errorf("decoding ScSpecFunctionInputV0: %w", err) } if l > 10 { return n, fmt.Errorf("decoding ScSpecFunctionInputV0: data size (%d) exceeds size limit (10)", l) @@ -47918,17 +49225,17 @@ func (s *ScSpecFunctionV0) DecodeFrom(d *xdr.Decoder) (int, error) { if l > 0 { s.Inputs = make([]ScSpecFunctionInputV0, l) for i := uint32(0); i < l; i++ { - nTmp, err = s.Inputs[i].DecodeFrom(d) + nTmp, err = s.Inputs[i].DecodeFrom(d, maxDepth) n += nTmp if err != nil { - return n, fmt.Errorf("decoding ScSpecFunctionInputV0: %s", err) + return n, fmt.Errorf("decoding ScSpecFunctionInputV0: %w", err) } } } l, nTmp, err = d.DecodeUint() n += nTmp if err != nil { - return n, fmt.Errorf("decoding ScSpecTypeDef: %s", err) + return n, fmt.Errorf("decoding ScSpecTypeDef: %w", err) } if l > 1 { return n, fmt.Errorf("decoding ScSpecTypeDef: data size (%d) exceeds size limit (1)", l) @@ -47937,10 +49244,10 @@ func (s *ScSpecFunctionV0) DecodeFrom(d *xdr.Decoder) (int, error) { if l > 0 { s.Outputs = make([]ScSpecTypeDef, l) for i := uint32(0); i < l; i++ { - nTmp, err = s.Outputs[i].DecodeFrom(d) + nTmp, err = s.Outputs[i].DecodeFrom(d, maxDepth) n += nTmp if err != nil { - return n, fmt.Errorf("decoding ScSpecTypeDef: %s", err) + return n, fmt.Errorf("decoding ScSpecTypeDef: %w", err) } } } @@ -47959,7 +49266,7 @@ func (s ScSpecFunctionV0) MarshalBinary() ([]byte, error) { func (s *ScSpecFunctionV0) UnmarshalBinary(inp []byte) error { r := bytes.NewReader(inp) d := xdr.NewDecoder(r) - _, err := s.DecodeFrom(d) + _, err := s.DecodeFrom(d, xdr.DecodeDefaultMaxDepth) return err } @@ -48027,10 +49334,14 @@ func (e ScSpecEntryKind) EncodeTo(enc *xdr.Encoder) error { var _ decoderFrom = (*ScSpecEntryKind)(nil) // DecodeFrom decodes this value using the Decoder. -func (e *ScSpecEntryKind) DecodeFrom(d *xdr.Decoder) (int, error) { +func (e *ScSpecEntryKind) DecodeFrom(d *xdr.Decoder, maxDepth uint) (int, error) { + if maxDepth == 0 { + return 0, fmt.Errorf("decoding ScSpecEntryKind: %w", ErrMaxDecodingDepthReached) + } + maxDepth -= 1 v, n, err := d.DecodeInt() if err != nil { - return n, fmt.Errorf("decoding ScSpecEntryKind: %s", err) + return n, fmt.Errorf("decoding ScSpecEntryKind: %w", err) } if _, ok := scSpecEntryKindMap[v]; !ok { return n, fmt.Errorf("'%d' is not a valid ScSpecEntryKind enum value", v) @@ -48051,7 +49362,7 @@ func (s ScSpecEntryKind) MarshalBinary() ([]byte, error) { func (s *ScSpecEntryKind) UnmarshalBinary(inp []byte) error { r := bytes.NewReader(inp) d := xdr.NewDecoder(r) - _, err := s.DecodeFrom(d) + _, err := s.DecodeFrom(d, xdr.DecodeDefaultMaxDepth) return err } @@ -48121,35 +49432,35 @@ func NewScSpecEntry(kind ScSpecEntryKind, value interface{}) (result ScSpecEntry case ScSpecEntryKindScSpecEntryFunctionV0: tv, ok := value.(ScSpecFunctionV0) if !ok { - err = fmt.Errorf("invalid value, must be ScSpecFunctionV0") + err = errors.New("invalid value, must be ScSpecFunctionV0") return } result.FunctionV0 = &tv case ScSpecEntryKindScSpecEntryUdtStructV0: tv, ok := value.(ScSpecUdtStructV0) if !ok { - err = fmt.Errorf("invalid value, must be ScSpecUdtStructV0") + err = errors.New("invalid value, must be ScSpecUdtStructV0") return } result.UdtStructV0 = &tv case ScSpecEntryKindScSpecEntryUdtUnionV0: tv, ok := value.(ScSpecUdtUnionV0) if !ok { - err = fmt.Errorf("invalid value, must be ScSpecUdtUnionV0") + err = errors.New("invalid value, must be ScSpecUdtUnionV0") return } result.UdtUnionV0 = &tv case ScSpecEntryKindScSpecEntryUdtEnumV0: tv, ok := value.(ScSpecUdtEnumV0) if !ok { - err = fmt.Errorf("invalid value, must be ScSpecUdtEnumV0") + err = errors.New("invalid value, must be ScSpecUdtEnumV0") return } result.UdtEnumV0 = &tv case ScSpecEntryKindScSpecEntryUdtErrorEnumV0: tv, ok := value.(ScSpecUdtErrorEnumV0) if !ok { - err = fmt.Errorf("invalid value, must be ScSpecUdtErrorEnumV0") + err = errors.New("invalid value, must be ScSpecUdtErrorEnumV0") return } result.UdtErrorEnumV0 = &tv @@ -48321,53 +49632,57 @@ func (u ScSpecEntry) EncodeTo(e *xdr.Encoder) error { var _ decoderFrom = (*ScSpecEntry)(nil) // DecodeFrom decodes this value using the Decoder. -func (u *ScSpecEntry) DecodeFrom(d *xdr.Decoder) (int, error) { +func (u *ScSpecEntry) DecodeFrom(d *xdr.Decoder, maxDepth uint) (int, error) { + if maxDepth == 0 { + return 0, fmt.Errorf("decoding ScSpecEntry: %w", ErrMaxDecodingDepthReached) + } + maxDepth -= 1 var err error var n, nTmp int - nTmp, err = u.Kind.DecodeFrom(d) + nTmp, err = u.Kind.DecodeFrom(d, maxDepth) n += nTmp if err != nil { - return n, fmt.Errorf("decoding ScSpecEntryKind: %s", err) + return n, fmt.Errorf("decoding ScSpecEntryKind: %w", err) } switch ScSpecEntryKind(u.Kind) { case ScSpecEntryKindScSpecEntryFunctionV0: u.FunctionV0 = new(ScSpecFunctionV0) - nTmp, err = (*u.FunctionV0).DecodeFrom(d) + nTmp, err = (*u.FunctionV0).DecodeFrom(d, maxDepth) n += nTmp if err != nil { - return n, fmt.Errorf("decoding ScSpecFunctionV0: %s", err) + return n, fmt.Errorf("decoding ScSpecFunctionV0: %w", err) } return n, nil case ScSpecEntryKindScSpecEntryUdtStructV0: u.UdtStructV0 = new(ScSpecUdtStructV0) - nTmp, err = (*u.UdtStructV0).DecodeFrom(d) + nTmp, err = (*u.UdtStructV0).DecodeFrom(d, maxDepth) n += nTmp if err != nil { - return n, fmt.Errorf("decoding ScSpecUdtStructV0: %s", err) + return n, fmt.Errorf("decoding ScSpecUdtStructV0: %w", err) } return n, nil case ScSpecEntryKindScSpecEntryUdtUnionV0: u.UdtUnionV0 = new(ScSpecUdtUnionV0) - nTmp, err = (*u.UdtUnionV0).DecodeFrom(d) + nTmp, err = (*u.UdtUnionV0).DecodeFrom(d, maxDepth) n += nTmp if err != nil { - return n, fmt.Errorf("decoding ScSpecUdtUnionV0: %s", err) + return n, fmt.Errorf("decoding ScSpecUdtUnionV0: %w", err) } return n, nil case ScSpecEntryKindScSpecEntryUdtEnumV0: u.UdtEnumV0 = new(ScSpecUdtEnumV0) - nTmp, err = (*u.UdtEnumV0).DecodeFrom(d) + nTmp, err = (*u.UdtEnumV0).DecodeFrom(d, maxDepth) n += nTmp if err != nil { - return n, fmt.Errorf("decoding ScSpecUdtEnumV0: %s", err) + return n, fmt.Errorf("decoding ScSpecUdtEnumV0: %w", err) } return n, nil case ScSpecEntryKindScSpecEntryUdtErrorEnumV0: u.UdtErrorEnumV0 = new(ScSpecUdtErrorEnumV0) - nTmp, err = (*u.UdtErrorEnumV0).DecodeFrom(d) + nTmp, err = (*u.UdtErrorEnumV0).DecodeFrom(d, maxDepth) n += nTmp if err != nil { - return n, fmt.Errorf("decoding ScSpecUdtErrorEnumV0: %s", err) + return n, fmt.Errorf("decoding ScSpecUdtErrorEnumV0: %w", err) } return n, nil } @@ -48386,7 +49701,7 @@ func (s ScSpecEntry) MarshalBinary() ([]byte, error) { func (s *ScSpecEntry) UnmarshalBinary(inp []byte) error { r := bytes.NewReader(inp) d := xdr.NewDecoder(r) - _, err := s.DecodeFrom(d) + _, err := s.DecodeFrom(d, xdr.DecodeDefaultMaxDepth) return err } @@ -48534,10 +49849,14 @@ func (e ScValType) EncodeTo(enc *xdr.Encoder) error { var _ decoderFrom = (*ScValType)(nil) // DecodeFrom decodes this value using the Decoder. -func (e *ScValType) DecodeFrom(d *xdr.Decoder) (int, error) { +func (e *ScValType) DecodeFrom(d *xdr.Decoder, maxDepth uint) (int, error) { + if maxDepth == 0 { + return 0, fmt.Errorf("decoding ScValType: %w", ErrMaxDecodingDepthReached) + } + maxDepth -= 1 v, n, err := d.DecodeInt() if err != nil { - return n, fmt.Errorf("decoding ScValType: %s", err) + return n, fmt.Errorf("decoding ScValType: %w", err) } if _, ok := scValTypeMap[v]; !ok { return n, fmt.Errorf("'%d' is not a valid ScValType enum value", v) @@ -48558,7 +49877,7 @@ func (s ScValType) MarshalBinary() ([]byte, error) { func (s *ScValType) UnmarshalBinary(inp []byte) error { r := bytes.NewReader(inp) d := xdr.NewDecoder(r) - _, err := s.DecodeFrom(d) + _, err := s.DecodeFrom(d, xdr.DecodeDefaultMaxDepth) return err } @@ -48641,10 +49960,14 @@ func (e ScErrorType) EncodeTo(enc *xdr.Encoder) error { var _ decoderFrom = (*ScErrorType)(nil) // DecodeFrom decodes this value using the Decoder. -func (e *ScErrorType) DecodeFrom(d *xdr.Decoder) (int, error) { +func (e *ScErrorType) DecodeFrom(d *xdr.Decoder, maxDepth uint) (int, error) { + if maxDepth == 0 { + return 0, fmt.Errorf("decoding ScErrorType: %w", ErrMaxDecodingDepthReached) + } + maxDepth -= 1 v, n, err := d.DecodeInt() if err != nil { - return n, fmt.Errorf("decoding ScErrorType: %s", err) + return n, fmt.Errorf("decoding ScErrorType: %w", err) } if _, ok := scErrorTypeMap[v]; !ok { return n, fmt.Errorf("'%d' is not a valid ScErrorType enum value", v) @@ -48665,7 +49988,7 @@ func (s ScErrorType) MarshalBinary() ([]byte, error) { func (s *ScErrorType) UnmarshalBinary(inp []byte) error { r := bytes.NewReader(inp) d := xdr.NewDecoder(r) - _, err := s.DecodeFrom(d) + _, err := s.DecodeFrom(d, xdr.DecodeDefaultMaxDepth) return err } @@ -48748,10 +50071,14 @@ func (e ScErrorCode) EncodeTo(enc *xdr.Encoder) error { var _ decoderFrom = (*ScErrorCode)(nil) // DecodeFrom decodes this value using the Decoder. -func (e *ScErrorCode) DecodeFrom(d *xdr.Decoder) (int, error) { +func (e *ScErrorCode) DecodeFrom(d *xdr.Decoder, maxDepth uint) (int, error) { + if maxDepth == 0 { + return 0, fmt.Errorf("decoding ScErrorCode: %w", ErrMaxDecodingDepthReached) + } + maxDepth -= 1 v, n, err := d.DecodeInt() if err != nil { - return n, fmt.Errorf("decoding ScErrorCode: %s", err) + return n, fmt.Errorf("decoding ScErrorCode: %w", err) } if _, ok := scErrorCodeMap[v]; !ok { return n, fmt.Errorf("'%d' is not a valid ScErrorCode enum value", v) @@ -48772,7 +50099,7 @@ func (s ScErrorCode) MarshalBinary() ([]byte, error) { func (s *ScErrorCode) UnmarshalBinary(inp []byte) error { r := bytes.NewReader(inp) d := xdr.NewDecoder(r) - _, err := s.DecodeFrom(d) + _, err := s.DecodeFrom(d, xdr.DecodeDefaultMaxDepth) return err } @@ -48851,70 +50178,70 @@ func NewScError(aType ScErrorType, value interface{}) (result ScError, err error case ScErrorTypeSceContract: tv, ok := value.(Uint32) if !ok { - err = fmt.Errorf("invalid value, must be Uint32") + err = errors.New("invalid value, must be Uint32") return } result.ContractCode = &tv case ScErrorTypeSceWasmVm: tv, ok := value.(ScErrorCode) if !ok { - err = fmt.Errorf("invalid value, must be ScErrorCode") + err = errors.New("invalid value, must be ScErrorCode") return } result.Code = &tv case ScErrorTypeSceContext: tv, ok := value.(ScErrorCode) if !ok { - err = fmt.Errorf("invalid value, must be ScErrorCode") + err = errors.New("invalid value, must be ScErrorCode") return } result.Code = &tv case ScErrorTypeSceStorage: tv, ok := value.(ScErrorCode) if !ok { - err = fmt.Errorf("invalid value, must be ScErrorCode") + err = errors.New("invalid value, must be ScErrorCode") return } result.Code = &tv case ScErrorTypeSceObject: tv, ok := value.(ScErrorCode) if !ok { - err = fmt.Errorf("invalid value, must be ScErrorCode") + err = errors.New("invalid value, must be ScErrorCode") return } result.Code = &tv case ScErrorTypeSceCrypto: tv, ok := value.(ScErrorCode) if !ok { - err = fmt.Errorf("invalid value, must be ScErrorCode") + err = errors.New("invalid value, must be ScErrorCode") return } result.Code = &tv case ScErrorTypeSceEvents: tv, ok := value.(ScErrorCode) if !ok { - err = fmt.Errorf("invalid value, must be ScErrorCode") + err = errors.New("invalid value, must be ScErrorCode") return } result.Code = &tv case ScErrorTypeSceBudget: tv, ok := value.(ScErrorCode) if !ok { - err = fmt.Errorf("invalid value, must be ScErrorCode") + err = errors.New("invalid value, must be ScErrorCode") return } result.Code = &tv case ScErrorTypeSceValue: tv, ok := value.(ScErrorCode) if !ok { - err = fmt.Errorf("invalid value, must be ScErrorCode") + err = errors.New("invalid value, must be ScErrorCode") return } result.Code = &tv case ScErrorTypeSceAuth: tv, ok := value.(ScErrorCode) if !ok { - err = fmt.Errorf("invalid value, must be ScErrorCode") + err = errors.New("invalid value, must be ScErrorCode") return } result.Code = &tv @@ -49036,93 +50363,97 @@ func (u ScError) EncodeTo(e *xdr.Encoder) error { var _ decoderFrom = (*ScError)(nil) // DecodeFrom decodes this value using the Decoder. -func (u *ScError) DecodeFrom(d *xdr.Decoder) (int, error) { +func (u *ScError) DecodeFrom(d *xdr.Decoder, maxDepth uint) (int, error) { + if maxDepth == 0 { + return 0, fmt.Errorf("decoding ScError: %w", ErrMaxDecodingDepthReached) + } + maxDepth -= 1 var err error var n, nTmp int - nTmp, err = u.Type.DecodeFrom(d) + nTmp, err = u.Type.DecodeFrom(d, maxDepth) n += nTmp if err != nil { - return n, fmt.Errorf("decoding ScErrorType: %s", err) + return n, fmt.Errorf("decoding ScErrorType: %w", err) } switch ScErrorType(u.Type) { case ScErrorTypeSceContract: u.ContractCode = new(Uint32) - nTmp, err = (*u.ContractCode).DecodeFrom(d) + nTmp, err = (*u.ContractCode).DecodeFrom(d, maxDepth) n += nTmp if err != nil { - return n, fmt.Errorf("decoding Uint32: %s", err) + return n, fmt.Errorf("decoding Uint32: %w", err) } return n, nil case ScErrorTypeSceWasmVm: u.Code = new(ScErrorCode) - nTmp, err = (*u.Code).DecodeFrom(d) + nTmp, err = (*u.Code).DecodeFrom(d, maxDepth) n += nTmp if err != nil { - return n, fmt.Errorf("decoding ScErrorCode: %s", err) + return n, fmt.Errorf("decoding ScErrorCode: %w", err) } return n, nil case ScErrorTypeSceContext: u.Code = new(ScErrorCode) - nTmp, err = (*u.Code).DecodeFrom(d) + nTmp, err = (*u.Code).DecodeFrom(d, maxDepth) n += nTmp if err != nil { - return n, fmt.Errorf("decoding ScErrorCode: %s", err) + return n, fmt.Errorf("decoding ScErrorCode: %w", err) } return n, nil case ScErrorTypeSceStorage: u.Code = new(ScErrorCode) - nTmp, err = (*u.Code).DecodeFrom(d) + nTmp, err = (*u.Code).DecodeFrom(d, maxDepth) n += nTmp if err != nil { - return n, fmt.Errorf("decoding ScErrorCode: %s", err) + return n, fmt.Errorf("decoding ScErrorCode: %w", err) } return n, nil case ScErrorTypeSceObject: u.Code = new(ScErrorCode) - nTmp, err = (*u.Code).DecodeFrom(d) + nTmp, err = (*u.Code).DecodeFrom(d, maxDepth) n += nTmp if err != nil { - return n, fmt.Errorf("decoding ScErrorCode: %s", err) + return n, fmt.Errorf("decoding ScErrorCode: %w", err) } return n, nil case ScErrorTypeSceCrypto: u.Code = new(ScErrorCode) - nTmp, err = (*u.Code).DecodeFrom(d) + nTmp, err = (*u.Code).DecodeFrom(d, maxDepth) n += nTmp if err != nil { - return n, fmt.Errorf("decoding ScErrorCode: %s", err) + return n, fmt.Errorf("decoding ScErrorCode: %w", err) } return n, nil case ScErrorTypeSceEvents: u.Code = new(ScErrorCode) - nTmp, err = (*u.Code).DecodeFrom(d) + nTmp, err = (*u.Code).DecodeFrom(d, maxDepth) n += nTmp if err != nil { - return n, fmt.Errorf("decoding ScErrorCode: %s", err) + return n, fmt.Errorf("decoding ScErrorCode: %w", err) } return n, nil case ScErrorTypeSceBudget: u.Code = new(ScErrorCode) - nTmp, err = (*u.Code).DecodeFrom(d) + nTmp, err = (*u.Code).DecodeFrom(d, maxDepth) n += nTmp if err != nil { - return n, fmt.Errorf("decoding ScErrorCode: %s", err) + return n, fmt.Errorf("decoding ScErrorCode: %w", err) } return n, nil case ScErrorTypeSceValue: u.Code = new(ScErrorCode) - nTmp, err = (*u.Code).DecodeFrom(d) + nTmp, err = (*u.Code).DecodeFrom(d, maxDepth) n += nTmp if err != nil { - return n, fmt.Errorf("decoding ScErrorCode: %s", err) + return n, fmt.Errorf("decoding ScErrorCode: %w", err) } return n, nil case ScErrorTypeSceAuth: u.Code = new(ScErrorCode) - nTmp, err = (*u.Code).DecodeFrom(d) + nTmp, err = (*u.Code).DecodeFrom(d, maxDepth) n += nTmp if err != nil { - return n, fmt.Errorf("decoding ScErrorCode: %s", err) + return n, fmt.Errorf("decoding ScErrorCode: %w", err) } return n, nil } @@ -49141,7 +50472,7 @@ func (s ScError) MarshalBinary() ([]byte, error) { func (s *ScError) UnmarshalBinary(inp []byte) error { r := bytes.NewReader(inp) d := xdr.NewDecoder(r) - _, err := s.DecodeFrom(d) + _, err := s.DecodeFrom(d, xdr.DecodeDefaultMaxDepth) return err } @@ -49182,18 +50513,22 @@ func (s *UInt128Parts) EncodeTo(e *xdr.Encoder) error { var _ decoderFrom = (*UInt128Parts)(nil) // DecodeFrom decodes this value using the Decoder. -func (s *UInt128Parts) DecodeFrom(d *xdr.Decoder) (int, error) { +func (s *UInt128Parts) DecodeFrom(d *xdr.Decoder, maxDepth uint) (int, error) { + if maxDepth == 0 { + return 0, fmt.Errorf("decoding UInt128Parts: %w", ErrMaxDecodingDepthReached) + } + maxDepth -= 1 var err error var n, nTmp int - nTmp, err = s.Hi.DecodeFrom(d) + nTmp, err = s.Hi.DecodeFrom(d, maxDepth) n += nTmp if err != nil { - return n, fmt.Errorf("decoding Uint64: %s", err) + return n, fmt.Errorf("decoding Uint64: %w", err) } - nTmp, err = s.Lo.DecodeFrom(d) + nTmp, err = s.Lo.DecodeFrom(d, maxDepth) n += nTmp if err != nil { - return n, fmt.Errorf("decoding Uint64: %s", err) + return n, fmt.Errorf("decoding Uint64: %w", err) } return n, nil } @@ -49210,7 +50545,7 @@ func (s UInt128Parts) MarshalBinary() ([]byte, error) { func (s *UInt128Parts) UnmarshalBinary(inp []byte) error { r := bytes.NewReader(inp) d := xdr.NewDecoder(r) - _, err := s.DecodeFrom(d) + _, err := s.DecodeFrom(d, xdr.DecodeDefaultMaxDepth) return err } @@ -49251,18 +50586,22 @@ func (s *Int128Parts) EncodeTo(e *xdr.Encoder) error { var _ decoderFrom = (*Int128Parts)(nil) // DecodeFrom decodes this value using the Decoder. -func (s *Int128Parts) DecodeFrom(d *xdr.Decoder) (int, error) { +func (s *Int128Parts) DecodeFrom(d *xdr.Decoder, maxDepth uint) (int, error) { + if maxDepth == 0 { + return 0, fmt.Errorf("decoding Int128Parts: %w", ErrMaxDecodingDepthReached) + } + maxDepth -= 1 var err error var n, nTmp int - nTmp, err = s.Hi.DecodeFrom(d) + nTmp, err = s.Hi.DecodeFrom(d, maxDepth) n += nTmp if err != nil { - return n, fmt.Errorf("decoding Int64: %s", err) + return n, fmt.Errorf("decoding Int64: %w", err) } - nTmp, err = s.Lo.DecodeFrom(d) + nTmp, err = s.Lo.DecodeFrom(d, maxDepth) n += nTmp if err != nil { - return n, fmt.Errorf("decoding Uint64: %s", err) + return n, fmt.Errorf("decoding Uint64: %w", err) } return n, nil } @@ -49279,7 +50618,7 @@ func (s Int128Parts) MarshalBinary() ([]byte, error) { func (s *Int128Parts) UnmarshalBinary(inp []byte) error { r := bytes.NewReader(inp) d := xdr.NewDecoder(r) - _, err := s.DecodeFrom(d) + _, err := s.DecodeFrom(d, xdr.DecodeDefaultMaxDepth) return err } @@ -49330,28 +50669,32 @@ func (s *UInt256Parts) EncodeTo(e *xdr.Encoder) error { var _ decoderFrom = (*UInt256Parts)(nil) // DecodeFrom decodes this value using the Decoder. -func (s *UInt256Parts) DecodeFrom(d *xdr.Decoder) (int, error) { +func (s *UInt256Parts) DecodeFrom(d *xdr.Decoder, maxDepth uint) (int, error) { + if maxDepth == 0 { + return 0, fmt.Errorf("decoding UInt256Parts: %w", ErrMaxDecodingDepthReached) + } + maxDepth -= 1 var err error var n, nTmp int - nTmp, err = s.HiHi.DecodeFrom(d) + nTmp, err = s.HiHi.DecodeFrom(d, maxDepth) n += nTmp if err != nil { - return n, fmt.Errorf("decoding Uint64: %s", err) + return n, fmt.Errorf("decoding Uint64: %w", err) } - nTmp, err = s.HiLo.DecodeFrom(d) + nTmp, err = s.HiLo.DecodeFrom(d, maxDepth) n += nTmp if err != nil { - return n, fmt.Errorf("decoding Uint64: %s", err) + return n, fmt.Errorf("decoding Uint64: %w", err) } - nTmp, err = s.LoHi.DecodeFrom(d) + nTmp, err = s.LoHi.DecodeFrom(d, maxDepth) n += nTmp if err != nil { - return n, fmt.Errorf("decoding Uint64: %s", err) + return n, fmt.Errorf("decoding Uint64: %w", err) } - nTmp, err = s.LoLo.DecodeFrom(d) + nTmp, err = s.LoLo.DecodeFrom(d, maxDepth) n += nTmp if err != nil { - return n, fmt.Errorf("decoding Uint64: %s", err) + return n, fmt.Errorf("decoding Uint64: %w", err) } return n, nil } @@ -49368,7 +50711,7 @@ func (s UInt256Parts) MarshalBinary() ([]byte, error) { func (s *UInt256Parts) UnmarshalBinary(inp []byte) error { r := bytes.NewReader(inp) d := xdr.NewDecoder(r) - _, err := s.DecodeFrom(d) + _, err := s.DecodeFrom(d, xdr.DecodeDefaultMaxDepth) return err } @@ -49419,28 +50762,32 @@ func (s *Int256Parts) EncodeTo(e *xdr.Encoder) error { var _ decoderFrom = (*Int256Parts)(nil) // DecodeFrom decodes this value using the Decoder. -func (s *Int256Parts) DecodeFrom(d *xdr.Decoder) (int, error) { +func (s *Int256Parts) DecodeFrom(d *xdr.Decoder, maxDepth uint) (int, error) { + if maxDepth == 0 { + return 0, fmt.Errorf("decoding Int256Parts: %w", ErrMaxDecodingDepthReached) + } + maxDepth -= 1 var err error var n, nTmp int - nTmp, err = s.HiHi.DecodeFrom(d) + nTmp, err = s.HiHi.DecodeFrom(d, maxDepth) n += nTmp if err != nil { - return n, fmt.Errorf("decoding Int64: %s", err) + return n, fmt.Errorf("decoding Int64: %w", err) } - nTmp, err = s.HiLo.DecodeFrom(d) + nTmp, err = s.HiLo.DecodeFrom(d, maxDepth) n += nTmp if err != nil { - return n, fmt.Errorf("decoding Uint64: %s", err) + return n, fmt.Errorf("decoding Uint64: %w", err) } - nTmp, err = s.LoHi.DecodeFrom(d) + nTmp, err = s.LoHi.DecodeFrom(d, maxDepth) n += nTmp if err != nil { - return n, fmt.Errorf("decoding Uint64: %s", err) + return n, fmt.Errorf("decoding Uint64: %w", err) } - nTmp, err = s.LoLo.DecodeFrom(d) + nTmp, err = s.LoLo.DecodeFrom(d, maxDepth) n += nTmp if err != nil { - return n, fmt.Errorf("decoding Uint64: %s", err) + return n, fmt.Errorf("decoding Uint64: %w", err) } return n, nil } @@ -49457,7 +50804,7 @@ func (s Int256Parts) MarshalBinary() ([]byte, error) { func (s *Int256Parts) UnmarshalBinary(inp []byte) error { r := bytes.NewReader(inp) d := xdr.NewDecoder(r) - _, err := s.DecodeFrom(d) + _, err := s.DecodeFrom(d, xdr.DecodeDefaultMaxDepth) return err } @@ -49477,18 +50824,18 @@ var _ xdrType = (*Int256Parts)(nil) // enum ContractExecutableType // { // CONTRACT_EXECUTABLE_WASM = 0, -// CONTRACT_EXECUTABLE_TOKEN = 1 +// CONTRACT_EXECUTABLE_STELLAR_ASSET = 1 // }; type ContractExecutableType int32 const ( - ContractExecutableTypeContractExecutableWasm ContractExecutableType = 0 - ContractExecutableTypeContractExecutableToken ContractExecutableType = 1 + ContractExecutableTypeContractExecutableWasm ContractExecutableType = 0 + ContractExecutableTypeContractExecutableStellarAsset ContractExecutableType = 1 ) var contractExecutableTypeMap = map[int32]string{ 0: "ContractExecutableTypeContractExecutableWasm", - 1: "ContractExecutableTypeContractExecutableToken", + 1: "ContractExecutableTypeContractExecutableStellarAsset", } // ValidEnum validates a proposed value for this enum. Implements @@ -49516,10 +50863,14 @@ func (e ContractExecutableType) EncodeTo(enc *xdr.Encoder) error { var _ decoderFrom = (*ContractExecutableType)(nil) // DecodeFrom decodes this value using the Decoder. -func (e *ContractExecutableType) DecodeFrom(d *xdr.Decoder) (int, error) { +func (e *ContractExecutableType) DecodeFrom(d *xdr.Decoder, maxDepth uint) (int, error) { + if maxDepth == 0 { + return 0, fmt.Errorf("decoding ContractExecutableType: %w", ErrMaxDecodingDepthReached) + } + maxDepth -= 1 v, n, err := d.DecodeInt() if err != nil { - return n, fmt.Errorf("decoding ContractExecutableType: %s", err) + return n, fmt.Errorf("decoding ContractExecutableType: %w", err) } if _, ok := contractExecutableTypeMap[v]; !ok { return n, fmt.Errorf("'%d' is not a valid ContractExecutableType enum value", v) @@ -49540,7 +50891,7 @@ func (s ContractExecutableType) MarshalBinary() ([]byte, error) { func (s *ContractExecutableType) UnmarshalBinary(inp []byte) error { r := bytes.NewReader(inp) d := xdr.NewDecoder(r) - _, err := s.DecodeFrom(d) + _, err := s.DecodeFrom(d, xdr.DecodeDefaultMaxDepth) return err } @@ -49561,7 +50912,7 @@ var _ xdrType = (*ContractExecutableType)(nil) // { // case CONTRACT_EXECUTABLE_WASM: // Hash wasm_hash; -// case CONTRACT_EXECUTABLE_TOKEN: +// case CONTRACT_EXECUTABLE_STELLAR_ASSET: // void; // }; type ContractExecutable struct { @@ -49581,7 +50932,7 @@ func (u ContractExecutable) ArmForSwitch(sw int32) (string, bool) { switch ContractExecutableType(sw) { case ContractExecutableTypeContractExecutableWasm: return "WasmHash", true - case ContractExecutableTypeContractExecutableToken: + case ContractExecutableTypeContractExecutableStellarAsset: return "", true } return "-", false @@ -49594,11 +50945,11 @@ func NewContractExecutable(aType ContractExecutableType, value interface{}) (res case ContractExecutableTypeContractExecutableWasm: tv, ok := value.(Hash) if !ok { - err = fmt.Errorf("invalid value, must be Hash") + err = errors.New("invalid value, must be Hash") return } result.WasmHash = &tv - case ContractExecutableTypeContractExecutableToken: + case ContractExecutableTypeContractExecutableStellarAsset: // void } return @@ -49641,7 +50992,7 @@ func (u ContractExecutable) EncodeTo(e *xdr.Encoder) error { return err } return nil - case ContractExecutableTypeContractExecutableToken: + case ContractExecutableTypeContractExecutableStellarAsset: // Void return nil } @@ -49651,24 +51002,28 @@ func (u ContractExecutable) EncodeTo(e *xdr.Encoder) error { var _ decoderFrom = (*ContractExecutable)(nil) // DecodeFrom decodes this value using the Decoder. -func (u *ContractExecutable) DecodeFrom(d *xdr.Decoder) (int, error) { +func (u *ContractExecutable) DecodeFrom(d *xdr.Decoder, maxDepth uint) (int, error) { + if maxDepth == 0 { + return 0, fmt.Errorf("decoding ContractExecutable: %w", ErrMaxDecodingDepthReached) + } + maxDepth -= 1 var err error var n, nTmp int - nTmp, err = u.Type.DecodeFrom(d) + nTmp, err = u.Type.DecodeFrom(d, maxDepth) n += nTmp if err != nil { - return n, fmt.Errorf("decoding ContractExecutableType: %s", err) + return n, fmt.Errorf("decoding ContractExecutableType: %w", err) } switch ContractExecutableType(u.Type) { case ContractExecutableTypeContractExecutableWasm: u.WasmHash = new(Hash) - nTmp, err = (*u.WasmHash).DecodeFrom(d) + nTmp, err = (*u.WasmHash).DecodeFrom(d, maxDepth) n += nTmp if err != nil { - return n, fmt.Errorf("decoding Hash: %s", err) + return n, fmt.Errorf("decoding Hash: %w", err) } return n, nil - case ContractExecutableTypeContractExecutableToken: + case ContractExecutableTypeContractExecutableStellarAsset: // Void return n, nil } @@ -49687,7 +51042,7 @@ func (s ContractExecutable) MarshalBinary() ([]byte, error) { func (s *ContractExecutable) UnmarshalBinary(inp []byte) error { r := bytes.NewReader(inp) d := xdr.NewDecoder(r) - _, err := s.DecodeFrom(d) + _, err := s.DecodeFrom(d, xdr.DecodeDefaultMaxDepth) return err } @@ -49746,10 +51101,14 @@ func (e ScAddressType) EncodeTo(enc *xdr.Encoder) error { var _ decoderFrom = (*ScAddressType)(nil) // DecodeFrom decodes this value using the Decoder. -func (e *ScAddressType) DecodeFrom(d *xdr.Decoder) (int, error) { +func (e *ScAddressType) DecodeFrom(d *xdr.Decoder, maxDepth uint) (int, error) { + if maxDepth == 0 { + return 0, fmt.Errorf("decoding ScAddressType: %w", ErrMaxDecodingDepthReached) + } + maxDepth -= 1 v, n, err := d.DecodeInt() if err != nil { - return n, fmt.Errorf("decoding ScAddressType: %s", err) + return n, fmt.Errorf("decoding ScAddressType: %w", err) } if _, ok := scAddressTypeMap[v]; !ok { return n, fmt.Errorf("'%d' is not a valid ScAddressType enum value", v) @@ -49770,7 +51129,7 @@ func (s ScAddressType) MarshalBinary() ([]byte, error) { func (s *ScAddressType) UnmarshalBinary(inp []byte) error { r := bytes.NewReader(inp) d := xdr.NewDecoder(r) - _, err := s.DecodeFrom(d) + _, err := s.DecodeFrom(d, xdr.DecodeDefaultMaxDepth) return err } @@ -49825,14 +51184,14 @@ func NewScAddress(aType ScAddressType, value interface{}) (result ScAddress, err case ScAddressTypeScAddressTypeAccount: tv, ok := value.(AccountId) if !ok { - err = fmt.Errorf("invalid value, must be AccountId") + err = errors.New("invalid value, must be AccountId") return } result.AccountId = &tv case ScAddressTypeScAddressTypeContract: tv, ok := value.(Hash) if !ok { - err = fmt.Errorf("invalid value, must be Hash") + err = errors.New("invalid value, must be Hash") return } result.ContractId = &tv @@ -49914,29 +51273,33 @@ func (u ScAddress) EncodeTo(e *xdr.Encoder) error { var _ decoderFrom = (*ScAddress)(nil) // DecodeFrom decodes this value using the Decoder. -func (u *ScAddress) DecodeFrom(d *xdr.Decoder) (int, error) { +func (u *ScAddress) DecodeFrom(d *xdr.Decoder, maxDepth uint) (int, error) { + if maxDepth == 0 { + return 0, fmt.Errorf("decoding ScAddress: %w", ErrMaxDecodingDepthReached) + } + maxDepth -= 1 var err error var n, nTmp int - nTmp, err = u.Type.DecodeFrom(d) + nTmp, err = u.Type.DecodeFrom(d, maxDepth) n += nTmp if err != nil { - return n, fmt.Errorf("decoding ScAddressType: %s", err) + return n, fmt.Errorf("decoding ScAddressType: %w", err) } switch ScAddressType(u.Type) { case ScAddressTypeScAddressTypeAccount: u.AccountId = new(AccountId) - nTmp, err = (*u.AccountId).DecodeFrom(d) + nTmp, err = (*u.AccountId).DecodeFrom(d, maxDepth) n += nTmp if err != nil { - return n, fmt.Errorf("decoding AccountId: %s", err) + return n, fmt.Errorf("decoding AccountId: %w", err) } return n, nil case ScAddressTypeScAddressTypeContract: u.ContractId = new(Hash) - nTmp, err = (*u.ContractId).DecodeFrom(d) + nTmp, err = (*u.ContractId).DecodeFrom(d, maxDepth) n += nTmp if err != nil { - return n, fmt.Errorf("decoding Hash: %s", err) + return n, fmt.Errorf("decoding Hash: %w", err) } return n, nil } @@ -49955,7 +51318,7 @@ func (s ScAddress) MarshalBinary() ([]byte, error) { func (s *ScAddress) UnmarshalBinary(inp []byte) error { r := bytes.NewReader(inp) d := xdr.NewDecoder(r) - _, err := s.DecodeFrom(d) + _, err := s.DecodeFrom(d, xdr.DecodeDefaultMaxDepth) return err } @@ -49997,23 +51360,27 @@ func (s ScVec) EncodeTo(e *xdr.Encoder) error { var _ decoderFrom = (*ScVec)(nil) // DecodeFrom decodes this value using the Decoder. -func (s *ScVec) DecodeFrom(d *xdr.Decoder) (int, error) { +func (s *ScVec) DecodeFrom(d *xdr.Decoder, maxDepth uint) (int, error) { + if maxDepth == 0 { + return 0, fmt.Errorf("decoding ScVec: %w", ErrMaxDecodingDepthReached) + } + maxDepth -= 1 var err error var n, nTmp int var l uint32 l, nTmp, err = d.DecodeUint() n += nTmp if err != nil { - return n, fmt.Errorf("decoding ScVal: %s", err) + return n, fmt.Errorf("decoding ScVal: %w", err) } (*s) = nil if l > 0 { (*s) = make([]ScVal, l) for i := uint32(0); i < l; i++ { - nTmp, err = (*s)[i].DecodeFrom(d) + nTmp, err = (*s)[i].DecodeFrom(d, maxDepth) n += nTmp if err != nil { - return n, fmt.Errorf("decoding ScVal: %s", err) + return n, fmt.Errorf("decoding ScVal: %w", err) } } } @@ -50032,7 +51399,7 @@ func (s ScVec) MarshalBinary() ([]byte, error) { func (s *ScVec) UnmarshalBinary(inp []byte) error { r := bytes.NewReader(inp) d := xdr.NewDecoder(r) - _, err := s.DecodeFrom(d) + _, err := s.DecodeFrom(d, xdr.DecodeDefaultMaxDepth) return err } @@ -50069,23 +51436,27 @@ func (s ScMap) EncodeTo(e *xdr.Encoder) error { var _ decoderFrom = (*ScMap)(nil) // DecodeFrom decodes this value using the Decoder. -func (s *ScMap) DecodeFrom(d *xdr.Decoder) (int, error) { +func (s *ScMap) DecodeFrom(d *xdr.Decoder, maxDepth uint) (int, error) { + if maxDepth == 0 { + return 0, fmt.Errorf("decoding ScMap: %w", ErrMaxDecodingDepthReached) + } + maxDepth -= 1 var err error var n, nTmp int var l uint32 l, nTmp, err = d.DecodeUint() n += nTmp if err != nil { - return n, fmt.Errorf("decoding ScMapEntry: %s", err) + return n, fmt.Errorf("decoding ScMapEntry: %w", err) } (*s) = nil if l > 0 { (*s) = make([]ScMapEntry, l) for i := uint32(0); i < l; i++ { - nTmp, err = (*s)[i].DecodeFrom(d) + nTmp, err = (*s)[i].DecodeFrom(d, maxDepth) n += nTmp if err != nil { - return n, fmt.Errorf("decoding ScMapEntry: %s", err) + return n, fmt.Errorf("decoding ScMapEntry: %w", err) } } } @@ -50104,7 +51475,7 @@ func (s ScMap) MarshalBinary() ([]byte, error) { func (s *ScMap) UnmarshalBinary(inp []byte) error { r := bytes.NewReader(inp) d := xdr.NewDecoder(r) - _, err := s.DecodeFrom(d) + _, err := s.DecodeFrom(d, xdr.DecodeDefaultMaxDepth) return err } @@ -50136,13 +51507,17 @@ func (s ScBytes) EncodeTo(e *xdr.Encoder) error { var _ decoderFrom = (*ScBytes)(nil) // DecodeFrom decodes this value using the Decoder. -func (s *ScBytes) DecodeFrom(d *xdr.Decoder) (int, error) { +func (s *ScBytes) DecodeFrom(d *xdr.Decoder, maxDepth uint) (int, error) { + if maxDepth == 0 { + return 0, fmt.Errorf("decoding ScBytes: %w", ErrMaxDecodingDepthReached) + } + maxDepth -= 1 var err error var n, nTmp int (*s), nTmp, err = d.DecodeOpaque(0) n += nTmp if err != nil { - return n, fmt.Errorf("decoding ScBytes: %s", err) + return n, fmt.Errorf("decoding ScBytes: %w", err) } return n, nil } @@ -50159,7 +51534,7 @@ func (s ScBytes) MarshalBinary() ([]byte, error) { func (s *ScBytes) UnmarshalBinary(inp []byte) error { r := bytes.NewReader(inp) d := xdr.NewDecoder(r) - _, err := s.DecodeFrom(d) + _, err := s.DecodeFrom(d, xdr.DecodeDefaultMaxDepth) return err } @@ -50191,14 +51566,18 @@ func (s ScString) EncodeTo(e *xdr.Encoder) error { var _ decoderFrom = (*ScString)(nil) // DecodeFrom decodes this value using the Decoder. -func (s *ScString) DecodeFrom(d *xdr.Decoder) (int, error) { +func (s *ScString) DecodeFrom(d *xdr.Decoder, maxDepth uint) (int, error) { + if maxDepth == 0 { + return 0, fmt.Errorf("decoding ScString: %w", ErrMaxDecodingDepthReached) + } + maxDepth -= 1 var err error var n, nTmp int var v string v, nTmp, err = d.DecodeString(0) n += nTmp if err != nil { - return n, fmt.Errorf("decoding ScString: %s", err) + return n, fmt.Errorf("decoding ScString: %w", err) } *s = ScString(v) return n, nil @@ -50216,7 +51595,7 @@ func (s ScString) MarshalBinary() ([]byte, error) { func (s *ScString) UnmarshalBinary(inp []byte) error { r := bytes.NewReader(inp) d := xdr.NewDecoder(r) - _, err := s.DecodeFrom(d) + _, err := s.DecodeFrom(d, xdr.DecodeDefaultMaxDepth) return err } @@ -50253,14 +51632,18 @@ func (s ScSymbol) EncodeTo(e *xdr.Encoder) error { var _ decoderFrom = (*ScSymbol)(nil) // DecodeFrom decodes this value using the Decoder. -func (s *ScSymbol) DecodeFrom(d *xdr.Decoder) (int, error) { +func (s *ScSymbol) DecodeFrom(d *xdr.Decoder, maxDepth uint) (int, error) { + if maxDepth == 0 { + return 0, fmt.Errorf("decoding ScSymbol: %w", ErrMaxDecodingDepthReached) + } + maxDepth -= 1 var err error var n, nTmp int var v string v, nTmp, err = d.DecodeString(32) n += nTmp if err != nil { - return n, fmt.Errorf("decoding ScSymbol: %s", err) + return n, fmt.Errorf("decoding ScSymbol: %w", err) } *s = ScSymbol(v) return n, nil @@ -50278,7 +51661,7 @@ func (s ScSymbol) MarshalBinary() ([]byte, error) { func (s *ScSymbol) UnmarshalBinary(inp []byte) error { r := bytes.NewReader(inp) d := xdr.NewDecoder(r) - _, err := s.DecodeFrom(d) + _, err := s.DecodeFrom(d, xdr.DecodeDefaultMaxDepth) return err } @@ -50314,13 +51697,17 @@ func (s *ScNonceKey) EncodeTo(e *xdr.Encoder) error { var _ decoderFrom = (*ScNonceKey)(nil) // DecodeFrom decodes this value using the Decoder. -func (s *ScNonceKey) DecodeFrom(d *xdr.Decoder) (int, error) { +func (s *ScNonceKey) DecodeFrom(d *xdr.Decoder, maxDepth uint) (int, error) { + if maxDepth == 0 { + return 0, fmt.Errorf("decoding ScNonceKey: %w", ErrMaxDecodingDepthReached) + } + maxDepth -= 1 var err error var n, nTmp int - nTmp, err = s.Nonce.DecodeFrom(d) + nTmp, err = s.Nonce.DecodeFrom(d, maxDepth) n += nTmp if err != nil { - return n, fmt.Errorf("decoding Int64: %s", err) + return n, fmt.Errorf("decoding Int64: %w", err) } return n, nil } @@ -50337,7 +51724,7 @@ func (s ScNonceKey) MarshalBinary() ([]byte, error) { func (s *ScNonceKey) UnmarshalBinary(inp []byte) error { r := bytes.NewReader(inp) d := xdr.NewDecoder(r) - _, err := s.DecodeFrom(d) + _, err := s.DecodeFrom(d, xdr.DecodeDefaultMaxDepth) return err } @@ -50383,27 +51770,31 @@ func (s *ScContractInstance) EncodeTo(e *xdr.Encoder) error { var _ decoderFrom = (*ScContractInstance)(nil) // DecodeFrom decodes this value using the Decoder. -func (s *ScContractInstance) DecodeFrom(d *xdr.Decoder) (int, error) { +func (s *ScContractInstance) DecodeFrom(d *xdr.Decoder, maxDepth uint) (int, error) { + if maxDepth == 0 { + return 0, fmt.Errorf("decoding ScContractInstance: %w", ErrMaxDecodingDepthReached) + } + maxDepth -= 1 var err error var n, nTmp int - nTmp, err = s.Executable.DecodeFrom(d) + nTmp, err = s.Executable.DecodeFrom(d, maxDepth) n += nTmp if err != nil { - return n, fmt.Errorf("decoding ContractExecutable: %s", err) + return n, fmt.Errorf("decoding ContractExecutable: %w", err) } var b bool b, nTmp, err = d.DecodeBool() n += nTmp if err != nil { - return n, fmt.Errorf("decoding ScMap: %s", err) + return n, fmt.Errorf("decoding ScMap: %w", err) } s.Storage = nil if b { s.Storage = new(ScMap) - nTmp, err = s.Storage.DecodeFrom(d) + nTmp, err = s.Storage.DecodeFrom(d, maxDepth) n += nTmp if err != nil { - return n, fmt.Errorf("decoding ScMap: %s", err) + return n, fmt.Errorf("decoding ScMap: %w", err) } } return n, nil @@ -50421,7 +51812,7 @@ func (s ScContractInstance) MarshalBinary() ([]byte, error) { func (s *ScContractInstance) UnmarshalBinary(inp []byte) error { r := bytes.NewReader(inp) d := xdr.NewDecoder(r) - _, err := s.DecodeFrom(d) + _, err := s.DecodeFrom(d, xdr.DecodeDefaultMaxDepth) return err } @@ -50588,7 +51979,7 @@ func NewScVal(aType ScValType, value interface{}) (result ScVal, err error) { case ScValTypeScvBool: tv, ok := value.(bool) if !ok { - err = fmt.Errorf("invalid value, must be bool") + err = errors.New("invalid value, must be bool") return } result.B = &tv @@ -50597,119 +51988,119 @@ func NewScVal(aType ScValType, value interface{}) (result ScVal, err error) { case ScValTypeScvError: tv, ok := value.(ScError) if !ok { - err = fmt.Errorf("invalid value, must be ScError") + err = errors.New("invalid value, must be ScError") return } result.Error = &tv case ScValTypeScvU32: tv, ok := value.(Uint32) if !ok { - err = fmt.Errorf("invalid value, must be Uint32") + err = errors.New("invalid value, must be Uint32") return } result.U32 = &tv case ScValTypeScvI32: tv, ok := value.(Int32) if !ok { - err = fmt.Errorf("invalid value, must be Int32") + err = errors.New("invalid value, must be Int32") return } result.I32 = &tv case ScValTypeScvU64: tv, ok := value.(Uint64) if !ok { - err = fmt.Errorf("invalid value, must be Uint64") + err = errors.New("invalid value, must be Uint64") return } result.U64 = &tv case ScValTypeScvI64: tv, ok := value.(Int64) if !ok { - err = fmt.Errorf("invalid value, must be Int64") + err = errors.New("invalid value, must be Int64") return } result.I64 = &tv case ScValTypeScvTimepoint: tv, ok := value.(TimePoint) if !ok { - err = fmt.Errorf("invalid value, must be TimePoint") + err = errors.New("invalid value, must be TimePoint") return } result.Timepoint = &tv case ScValTypeScvDuration: tv, ok := value.(Duration) if !ok { - err = fmt.Errorf("invalid value, must be Duration") + err = errors.New("invalid value, must be Duration") return } result.Duration = &tv case ScValTypeScvU128: tv, ok := value.(UInt128Parts) if !ok { - err = fmt.Errorf("invalid value, must be UInt128Parts") + err = errors.New("invalid value, must be UInt128Parts") return } result.U128 = &tv case ScValTypeScvI128: tv, ok := value.(Int128Parts) if !ok { - err = fmt.Errorf("invalid value, must be Int128Parts") + err = errors.New("invalid value, must be Int128Parts") return } result.I128 = &tv case ScValTypeScvU256: tv, ok := value.(UInt256Parts) if !ok { - err = fmt.Errorf("invalid value, must be UInt256Parts") + err = errors.New("invalid value, must be UInt256Parts") return } result.U256 = &tv case ScValTypeScvI256: tv, ok := value.(Int256Parts) if !ok { - err = fmt.Errorf("invalid value, must be Int256Parts") + err = errors.New("invalid value, must be Int256Parts") return } result.I256 = &tv case ScValTypeScvBytes: tv, ok := value.(ScBytes) if !ok { - err = fmt.Errorf("invalid value, must be ScBytes") + err = errors.New("invalid value, must be ScBytes") return } result.Bytes = &tv case ScValTypeScvString: tv, ok := value.(ScString) if !ok { - err = fmt.Errorf("invalid value, must be ScString") + err = errors.New("invalid value, must be ScString") return } result.Str = &tv case ScValTypeScvSymbol: tv, ok := value.(ScSymbol) if !ok { - err = fmt.Errorf("invalid value, must be ScSymbol") + err = errors.New("invalid value, must be ScSymbol") return } result.Sym = &tv case ScValTypeScvVec: tv, ok := value.(*ScVec) if !ok { - err = fmt.Errorf("invalid value, must be *ScVec") + err = errors.New("invalid value, must be *ScVec") return } result.Vec = &tv case ScValTypeScvMap: tv, ok := value.(*ScMap) if !ok { - err = fmt.Errorf("invalid value, must be *ScMap") + err = errors.New("invalid value, must be *ScMap") return } result.Map = &tv case ScValTypeScvAddress: tv, ok := value.(ScAddress) if !ok { - err = fmt.Errorf("invalid value, must be ScAddress") + err = errors.New("invalid value, must be ScAddress") return } result.Address = &tv @@ -50718,14 +52109,14 @@ func NewScVal(aType ScValType, value interface{}) (result ScVal, err error) { case ScValTypeScvLedgerKeyNonce: tv, ok := value.(ScNonceKey) if !ok { - err = fmt.Errorf("invalid value, must be ScNonceKey") + err = errors.New("invalid value, must be ScNonceKey") return } result.NonceKey = &tv case ScValTypeScvContractInstance: tv, ok := value.(ScContractInstance) if !ok { - err = fmt.Errorf("invalid value, must be ScContractInstance") + err = errors.New("invalid value, must be ScContractInstance") return } result.Instance = &tv @@ -51363,13 +52754,17 @@ func (u ScVal) EncodeTo(e *xdr.Encoder) error { var _ decoderFrom = (*ScVal)(nil) // DecodeFrom decodes this value using the Decoder. -func (u *ScVal) DecodeFrom(d *xdr.Decoder) (int, error) { +func (u *ScVal) DecodeFrom(d *xdr.Decoder, maxDepth uint) (int, error) { + if maxDepth == 0 { + return 0, fmt.Errorf("decoding ScVal: %w", ErrMaxDecodingDepthReached) + } + maxDepth -= 1 var err error var n, nTmp int - nTmp, err = u.Type.DecodeFrom(d) + nTmp, err = u.Type.DecodeFrom(d, maxDepth) n += nTmp if err != nil { - return n, fmt.Errorf("decoding ScValType: %s", err) + return n, fmt.Errorf("decoding ScValType: %w", err) } switch ScValType(u.Type) { case ScValTypeScvBool: @@ -51377,7 +52772,7 @@ func (u *ScVal) DecodeFrom(d *xdr.Decoder) (int, error) { (*u.B), nTmp, err = d.DecodeBool() n += nTmp if err != nil { - return n, fmt.Errorf("decoding Bool: %s", err) + return n, fmt.Errorf("decoding Bool: %w", err) } return n, nil case ScValTypeScvVoid: @@ -51385,114 +52780,114 @@ func (u *ScVal) DecodeFrom(d *xdr.Decoder) (int, error) { return n, nil case ScValTypeScvError: u.Error = new(ScError) - nTmp, err = (*u.Error).DecodeFrom(d) + nTmp, err = (*u.Error).DecodeFrom(d, maxDepth) n += nTmp if err != nil { - return n, fmt.Errorf("decoding ScError: %s", err) + return n, fmt.Errorf("decoding ScError: %w", err) } return n, nil case ScValTypeScvU32: u.U32 = new(Uint32) - nTmp, err = (*u.U32).DecodeFrom(d) + nTmp, err = (*u.U32).DecodeFrom(d, maxDepth) n += nTmp if err != nil { - return n, fmt.Errorf("decoding Uint32: %s", err) + return n, fmt.Errorf("decoding Uint32: %w", err) } return n, nil case ScValTypeScvI32: u.I32 = new(Int32) - nTmp, err = (*u.I32).DecodeFrom(d) + nTmp, err = (*u.I32).DecodeFrom(d, maxDepth) n += nTmp if err != nil { - return n, fmt.Errorf("decoding Int32: %s", err) + return n, fmt.Errorf("decoding Int32: %w", err) } return n, nil case ScValTypeScvU64: u.U64 = new(Uint64) - nTmp, err = (*u.U64).DecodeFrom(d) + nTmp, err = (*u.U64).DecodeFrom(d, maxDepth) n += nTmp if err != nil { - return n, fmt.Errorf("decoding Uint64: %s", err) + return n, fmt.Errorf("decoding Uint64: %w", err) } return n, nil case ScValTypeScvI64: u.I64 = new(Int64) - nTmp, err = (*u.I64).DecodeFrom(d) + nTmp, err = (*u.I64).DecodeFrom(d, maxDepth) n += nTmp if err != nil { - return n, fmt.Errorf("decoding Int64: %s", err) + return n, fmt.Errorf("decoding Int64: %w", err) } return n, nil case ScValTypeScvTimepoint: u.Timepoint = new(TimePoint) - nTmp, err = (*u.Timepoint).DecodeFrom(d) + nTmp, err = (*u.Timepoint).DecodeFrom(d, maxDepth) n += nTmp if err != nil { - return n, fmt.Errorf("decoding TimePoint: %s", err) + return n, fmt.Errorf("decoding TimePoint: %w", err) } return n, nil case ScValTypeScvDuration: u.Duration = new(Duration) - nTmp, err = (*u.Duration).DecodeFrom(d) + nTmp, err = (*u.Duration).DecodeFrom(d, maxDepth) n += nTmp if err != nil { - return n, fmt.Errorf("decoding Duration: %s", err) + return n, fmt.Errorf("decoding Duration: %w", err) } return n, nil case ScValTypeScvU128: u.U128 = new(UInt128Parts) - nTmp, err = (*u.U128).DecodeFrom(d) + nTmp, err = (*u.U128).DecodeFrom(d, maxDepth) n += nTmp if err != nil { - return n, fmt.Errorf("decoding UInt128Parts: %s", err) + return n, fmt.Errorf("decoding UInt128Parts: %w", err) } return n, nil case ScValTypeScvI128: u.I128 = new(Int128Parts) - nTmp, err = (*u.I128).DecodeFrom(d) + nTmp, err = (*u.I128).DecodeFrom(d, maxDepth) n += nTmp if err != nil { - return n, fmt.Errorf("decoding Int128Parts: %s", err) + return n, fmt.Errorf("decoding Int128Parts: %w", err) } return n, nil case ScValTypeScvU256: u.U256 = new(UInt256Parts) - nTmp, err = (*u.U256).DecodeFrom(d) + nTmp, err = (*u.U256).DecodeFrom(d, maxDepth) n += nTmp if err != nil { - return n, fmt.Errorf("decoding UInt256Parts: %s", err) + return n, fmt.Errorf("decoding UInt256Parts: %w", err) } return n, nil case ScValTypeScvI256: u.I256 = new(Int256Parts) - nTmp, err = (*u.I256).DecodeFrom(d) + nTmp, err = (*u.I256).DecodeFrom(d, maxDepth) n += nTmp if err != nil { - return n, fmt.Errorf("decoding Int256Parts: %s", err) + return n, fmt.Errorf("decoding Int256Parts: %w", err) } return n, nil case ScValTypeScvBytes: u.Bytes = new(ScBytes) - nTmp, err = (*u.Bytes).DecodeFrom(d) + nTmp, err = (*u.Bytes).DecodeFrom(d, maxDepth) n += nTmp if err != nil { - return n, fmt.Errorf("decoding ScBytes: %s", err) + return n, fmt.Errorf("decoding ScBytes: %w", err) } return n, nil case ScValTypeScvString: u.Str = new(ScString) - nTmp, err = (*u.Str).DecodeFrom(d) + nTmp, err = (*u.Str).DecodeFrom(d, maxDepth) n += nTmp if err != nil { - return n, fmt.Errorf("decoding ScString: %s", err) + return n, fmt.Errorf("decoding ScString: %w", err) } return n, nil case ScValTypeScvSymbol: u.Sym = new(ScSymbol) - nTmp, err = (*u.Sym).DecodeFrom(d) + nTmp, err = (*u.Sym).DecodeFrom(d, maxDepth) n += nTmp if err != nil { - return n, fmt.Errorf("decoding ScSymbol: %s", err) + return n, fmt.Errorf("decoding ScSymbol: %w", err) } return n, nil case ScValTypeScvVec: @@ -51501,15 +52896,15 @@ func (u *ScVal) DecodeFrom(d *xdr.Decoder) (int, error) { b, nTmp, err = d.DecodeBool() n += nTmp if err != nil { - return n, fmt.Errorf("decoding ScVec: %s", err) + return n, fmt.Errorf("decoding ScVec: %w", err) } (*u.Vec) = nil if b { (*u.Vec) = new(ScVec) - nTmp, err = (*u.Vec).DecodeFrom(d) + nTmp, err = (*u.Vec).DecodeFrom(d, maxDepth) n += nTmp if err != nil { - return n, fmt.Errorf("decoding ScVec: %s", err) + return n, fmt.Errorf("decoding ScVec: %w", err) } } return n, nil @@ -51519,24 +52914,24 @@ func (u *ScVal) DecodeFrom(d *xdr.Decoder) (int, error) { b, nTmp, err = d.DecodeBool() n += nTmp if err != nil { - return n, fmt.Errorf("decoding ScMap: %s", err) + return n, fmt.Errorf("decoding ScMap: %w", err) } (*u.Map) = nil if b { (*u.Map) = new(ScMap) - nTmp, err = (*u.Map).DecodeFrom(d) + nTmp, err = (*u.Map).DecodeFrom(d, maxDepth) n += nTmp if err != nil { - return n, fmt.Errorf("decoding ScMap: %s", err) + return n, fmt.Errorf("decoding ScMap: %w", err) } } return n, nil case ScValTypeScvAddress: u.Address = new(ScAddress) - nTmp, err = (*u.Address).DecodeFrom(d) + nTmp, err = (*u.Address).DecodeFrom(d, maxDepth) n += nTmp if err != nil { - return n, fmt.Errorf("decoding ScAddress: %s", err) + return n, fmt.Errorf("decoding ScAddress: %w", err) } return n, nil case ScValTypeScvLedgerKeyContractInstance: @@ -51544,18 +52939,18 @@ func (u *ScVal) DecodeFrom(d *xdr.Decoder) (int, error) { return n, nil case ScValTypeScvLedgerKeyNonce: u.NonceKey = new(ScNonceKey) - nTmp, err = (*u.NonceKey).DecodeFrom(d) + nTmp, err = (*u.NonceKey).DecodeFrom(d, maxDepth) n += nTmp if err != nil { - return n, fmt.Errorf("decoding ScNonceKey: %s", err) + return n, fmt.Errorf("decoding ScNonceKey: %w", err) } return n, nil case ScValTypeScvContractInstance: u.Instance = new(ScContractInstance) - nTmp, err = (*u.Instance).DecodeFrom(d) + nTmp, err = (*u.Instance).DecodeFrom(d, maxDepth) n += nTmp if err != nil { - return n, fmt.Errorf("decoding ScContractInstance: %s", err) + return n, fmt.Errorf("decoding ScContractInstance: %w", err) } return n, nil } @@ -51574,7 +52969,7 @@ func (s ScVal) MarshalBinary() ([]byte, error) { func (s *ScVal) UnmarshalBinary(inp []byte) error { r := bytes.NewReader(inp) d := xdr.NewDecoder(r) - _, err := s.DecodeFrom(d) + _, err := s.DecodeFrom(d, xdr.DecodeDefaultMaxDepth) return err } @@ -51616,18 +53011,22 @@ func (s *ScMapEntry) EncodeTo(e *xdr.Encoder) error { var _ decoderFrom = (*ScMapEntry)(nil) // DecodeFrom decodes this value using the Decoder. -func (s *ScMapEntry) DecodeFrom(d *xdr.Decoder) (int, error) { +func (s *ScMapEntry) DecodeFrom(d *xdr.Decoder, maxDepth uint) (int, error) { + if maxDepth == 0 { + return 0, fmt.Errorf("decoding ScMapEntry: %w", ErrMaxDecodingDepthReached) + } + maxDepth -= 1 var err error var n, nTmp int - nTmp, err = s.Key.DecodeFrom(d) + nTmp, err = s.Key.DecodeFrom(d, maxDepth) n += nTmp if err != nil { - return n, fmt.Errorf("decoding ScVal: %s", err) + return n, fmt.Errorf("decoding ScVal: %w", err) } - nTmp, err = s.Val.DecodeFrom(d) + nTmp, err = s.Val.DecodeFrom(d, maxDepth) n += nTmp if err != nil { - return n, fmt.Errorf("decoding ScVal: %s", err) + return n, fmt.Errorf("decoding ScVal: %w", err) } return n, nil } @@ -51644,7 +53043,7 @@ func (s ScMapEntry) MarshalBinary() ([]byte, error) { func (s *ScMapEntry) UnmarshalBinary(inp []byte) error { r := bytes.NewReader(inp) d := xdr.NewDecoder(r) - _, err := s.DecodeFrom(d) + _, err := s.DecodeFrom(d, xdr.DecodeDefaultMaxDepth) return err } @@ -51699,14 +53098,14 @@ func NewStoredTransactionSet(v int32, value interface{}) (result StoredTransacti case 0: tv, ok := value.(TransactionSet) if !ok { - err = fmt.Errorf("invalid value, must be TransactionSet") + err = errors.New("invalid value, must be TransactionSet") return } result.TxSet = &tv case 1: tv, ok := value.(GeneralizedTransactionSet) if !ok { - err = fmt.Errorf("invalid value, must be GeneralizedTransactionSet") + err = errors.New("invalid value, must be GeneralizedTransactionSet") return } result.GeneralizedTxSet = &tv @@ -51788,29 +53187,33 @@ func (u StoredTransactionSet) EncodeTo(e *xdr.Encoder) error { var _ decoderFrom = (*StoredTransactionSet)(nil) // DecodeFrom decodes this value using the Decoder. -func (u *StoredTransactionSet) DecodeFrom(d *xdr.Decoder) (int, error) { +func (u *StoredTransactionSet) DecodeFrom(d *xdr.Decoder, maxDepth uint) (int, error) { + if maxDepth == 0 { + return 0, fmt.Errorf("decoding StoredTransactionSet: %w", ErrMaxDecodingDepthReached) + } + maxDepth -= 1 var err error var n, nTmp int u.V, nTmp, err = d.DecodeInt() n += nTmp if err != nil { - return n, fmt.Errorf("decoding Int: %s", err) + return n, fmt.Errorf("decoding Int: %w", err) } switch int32(u.V) { case 0: u.TxSet = new(TransactionSet) - nTmp, err = (*u.TxSet).DecodeFrom(d) + nTmp, err = (*u.TxSet).DecodeFrom(d, maxDepth) n += nTmp if err != nil { - return n, fmt.Errorf("decoding TransactionSet: %s", err) + return n, fmt.Errorf("decoding TransactionSet: %w", err) } return n, nil case 1: u.GeneralizedTxSet = new(GeneralizedTransactionSet) - nTmp, err = (*u.GeneralizedTxSet).DecodeFrom(d) + nTmp, err = (*u.GeneralizedTxSet).DecodeFrom(d, maxDepth) n += nTmp if err != nil { - return n, fmt.Errorf("decoding GeneralizedTransactionSet: %s", err) + return n, fmt.Errorf("decoding GeneralizedTransactionSet: %w", err) } return n, nil } @@ -51829,7 +53232,7 @@ func (s StoredTransactionSet) MarshalBinary() ([]byte, error) { func (s *StoredTransactionSet) UnmarshalBinary(inp []byte) error { r := bytes.NewReader(inp) d := xdr.NewDecoder(r) - _, err := s.DecodeFrom(d) + _, err := s.DecodeFrom(d, xdr.DecodeDefaultMaxDepth) return err } @@ -51844,6 +53247,90 @@ func (s StoredTransactionSet) xdrType() {} var _ xdrType = (*StoredTransactionSet)(nil) +// StoredDebugTransactionSet is an XDR Struct defines as: +// +// struct StoredDebugTransactionSet +// { +// StoredTransactionSet txSet; +// uint32 ledgerSeq; +// StellarValue scpValue; +// }; +type StoredDebugTransactionSet struct { + TxSet StoredTransactionSet + LedgerSeq Uint32 + ScpValue StellarValue +} + +// EncodeTo encodes this value using the Encoder. +func (s *StoredDebugTransactionSet) EncodeTo(e *xdr.Encoder) error { + var err error + if err = s.TxSet.EncodeTo(e); err != nil { + return err + } + if err = s.LedgerSeq.EncodeTo(e); err != nil { + return err + } + if err = s.ScpValue.EncodeTo(e); err != nil { + return err + } + return nil +} + +var _ decoderFrom = (*StoredDebugTransactionSet)(nil) + +// DecodeFrom decodes this value using the Decoder. +func (s *StoredDebugTransactionSet) DecodeFrom(d *xdr.Decoder, maxDepth uint) (int, error) { + if maxDepth == 0 { + return 0, fmt.Errorf("decoding StoredDebugTransactionSet: %w", ErrMaxDecodingDepthReached) + } + maxDepth -= 1 + var err error + var n, nTmp int + nTmp, err = s.TxSet.DecodeFrom(d, maxDepth) + n += nTmp + if err != nil { + return n, fmt.Errorf("decoding StoredTransactionSet: %w", err) + } + nTmp, err = s.LedgerSeq.DecodeFrom(d, maxDepth) + n += nTmp + if err != nil { + return n, fmt.Errorf("decoding Uint32: %w", err) + } + nTmp, err = s.ScpValue.DecodeFrom(d, maxDepth) + n += nTmp + if err != nil { + return n, fmt.Errorf("decoding StellarValue: %w", err) + } + return n, nil +} + +// MarshalBinary implements encoding.BinaryMarshaler. +func (s StoredDebugTransactionSet) MarshalBinary() ([]byte, error) { + b := bytes.Buffer{} + e := xdr.NewEncoder(&b) + err := s.EncodeTo(e) + return b.Bytes(), err +} + +// UnmarshalBinary implements encoding.BinaryUnmarshaler. +func (s *StoredDebugTransactionSet) UnmarshalBinary(inp []byte) error { + r := bytes.NewReader(inp) + d := xdr.NewDecoder(r) + _, err := s.DecodeFrom(d, xdr.DecodeDefaultMaxDepth) + return err +} + +var ( + _ encoding.BinaryMarshaler = (*StoredDebugTransactionSet)(nil) + _ encoding.BinaryUnmarshaler = (*StoredDebugTransactionSet)(nil) +) + +// xdrType signals that this type is an type representing +// representing XDR values defined by this package. +func (s StoredDebugTransactionSet) xdrType() {} + +var _ xdrType = (*StoredDebugTransactionSet)(nil) + // PersistedScpStateV0 is an XDR Struct defines as: // // struct PersistedSCPStateV0 @@ -51891,55 +53378,59 @@ func (s *PersistedScpStateV0) EncodeTo(e *xdr.Encoder) error { var _ decoderFrom = (*PersistedScpStateV0)(nil) // DecodeFrom decodes this value using the Decoder. -func (s *PersistedScpStateV0) DecodeFrom(d *xdr.Decoder) (int, error) { +func (s *PersistedScpStateV0) DecodeFrom(d *xdr.Decoder, maxDepth uint) (int, error) { + if maxDepth == 0 { + return 0, fmt.Errorf("decoding PersistedScpStateV0: %w", ErrMaxDecodingDepthReached) + } + maxDepth -= 1 var err error var n, nTmp int var l uint32 l, nTmp, err = d.DecodeUint() n += nTmp if err != nil { - return n, fmt.Errorf("decoding ScpEnvelope: %s", err) + return n, fmt.Errorf("decoding ScpEnvelope: %w", err) } s.ScpEnvelopes = nil if l > 0 { s.ScpEnvelopes = make([]ScpEnvelope, l) for i := uint32(0); i < l; i++ { - nTmp, err = s.ScpEnvelopes[i].DecodeFrom(d) + nTmp, err = s.ScpEnvelopes[i].DecodeFrom(d, maxDepth) n += nTmp if err != nil { - return n, fmt.Errorf("decoding ScpEnvelope: %s", err) + return n, fmt.Errorf("decoding ScpEnvelope: %w", err) } } } l, nTmp, err = d.DecodeUint() n += nTmp if err != nil { - return n, fmt.Errorf("decoding ScpQuorumSet: %s", err) + return n, fmt.Errorf("decoding ScpQuorumSet: %w", err) } s.QuorumSets = nil if l > 0 { s.QuorumSets = make([]ScpQuorumSet, l) for i := uint32(0); i < l; i++ { - nTmp, err = s.QuorumSets[i].DecodeFrom(d) + nTmp, err = s.QuorumSets[i].DecodeFrom(d, maxDepth) n += nTmp if err != nil { - return n, fmt.Errorf("decoding ScpQuorumSet: %s", err) + return n, fmt.Errorf("decoding ScpQuorumSet: %w", err) } } } l, nTmp, err = d.DecodeUint() n += nTmp if err != nil { - return n, fmt.Errorf("decoding StoredTransactionSet: %s", err) + return n, fmt.Errorf("decoding StoredTransactionSet: %w", err) } s.TxSets = nil if l > 0 { s.TxSets = make([]StoredTransactionSet, l) for i := uint32(0); i < l; i++ { - nTmp, err = s.TxSets[i].DecodeFrom(d) + nTmp, err = s.TxSets[i].DecodeFrom(d, maxDepth) n += nTmp if err != nil { - return n, fmt.Errorf("decoding StoredTransactionSet: %s", err) + return n, fmt.Errorf("decoding StoredTransactionSet: %w", err) } } } @@ -51958,7 +53449,7 @@ func (s PersistedScpStateV0) MarshalBinary() ([]byte, error) { func (s *PersistedScpStateV0) UnmarshalBinary(inp []byte) error { r := bytes.NewReader(inp) d := xdr.NewDecoder(r) - _, err := s.DecodeFrom(d) + _, err := s.DecodeFrom(d, xdr.DecodeDefaultMaxDepth) return err } @@ -52011,39 +53502,43 @@ func (s *PersistedScpStateV1) EncodeTo(e *xdr.Encoder) error { var _ decoderFrom = (*PersistedScpStateV1)(nil) // DecodeFrom decodes this value using the Decoder. -func (s *PersistedScpStateV1) DecodeFrom(d *xdr.Decoder) (int, error) { +func (s *PersistedScpStateV1) DecodeFrom(d *xdr.Decoder, maxDepth uint) (int, error) { + if maxDepth == 0 { + return 0, fmt.Errorf("decoding PersistedScpStateV1: %w", ErrMaxDecodingDepthReached) + } + maxDepth -= 1 var err error var n, nTmp int var l uint32 l, nTmp, err = d.DecodeUint() n += nTmp if err != nil { - return n, fmt.Errorf("decoding ScpEnvelope: %s", err) + return n, fmt.Errorf("decoding ScpEnvelope: %w", err) } s.ScpEnvelopes = nil if l > 0 { s.ScpEnvelopes = make([]ScpEnvelope, l) for i := uint32(0); i < l; i++ { - nTmp, err = s.ScpEnvelopes[i].DecodeFrom(d) + nTmp, err = s.ScpEnvelopes[i].DecodeFrom(d, maxDepth) n += nTmp if err != nil { - return n, fmt.Errorf("decoding ScpEnvelope: %s", err) + return n, fmt.Errorf("decoding ScpEnvelope: %w", err) } } } l, nTmp, err = d.DecodeUint() n += nTmp if err != nil { - return n, fmt.Errorf("decoding ScpQuorumSet: %s", err) + return n, fmt.Errorf("decoding ScpQuorumSet: %w", err) } s.QuorumSets = nil if l > 0 { s.QuorumSets = make([]ScpQuorumSet, l) for i := uint32(0); i < l; i++ { - nTmp, err = s.QuorumSets[i].DecodeFrom(d) + nTmp, err = s.QuorumSets[i].DecodeFrom(d, maxDepth) n += nTmp if err != nil { - return n, fmt.Errorf("decoding ScpQuorumSet: %s", err) + return n, fmt.Errorf("decoding ScpQuorumSet: %w", err) } } } @@ -52062,7 +53557,7 @@ func (s PersistedScpStateV1) MarshalBinary() ([]byte, error) { func (s *PersistedScpStateV1) UnmarshalBinary(inp []byte) error { r := bytes.NewReader(inp) d := xdr.NewDecoder(r) - _, err := s.DecodeFrom(d) + _, err := s.DecodeFrom(d, xdr.DecodeDefaultMaxDepth) return err } @@ -52117,14 +53612,14 @@ func NewPersistedScpState(v int32, value interface{}) (result PersistedScpState, case 0: tv, ok := value.(PersistedScpStateV0) if !ok { - err = fmt.Errorf("invalid value, must be PersistedScpStateV0") + err = errors.New("invalid value, must be PersistedScpStateV0") return } result.V0 = &tv case 1: tv, ok := value.(PersistedScpStateV1) if !ok { - err = fmt.Errorf("invalid value, must be PersistedScpStateV1") + err = errors.New("invalid value, must be PersistedScpStateV1") return } result.V1 = &tv @@ -52206,29 +53701,33 @@ func (u PersistedScpState) EncodeTo(e *xdr.Encoder) error { var _ decoderFrom = (*PersistedScpState)(nil) // DecodeFrom decodes this value using the Decoder. -func (u *PersistedScpState) DecodeFrom(d *xdr.Decoder) (int, error) { +func (u *PersistedScpState) DecodeFrom(d *xdr.Decoder, maxDepth uint) (int, error) { + if maxDepth == 0 { + return 0, fmt.Errorf("decoding PersistedScpState: %w", ErrMaxDecodingDepthReached) + } + maxDepth -= 1 var err error var n, nTmp int u.V, nTmp, err = d.DecodeInt() n += nTmp if err != nil { - return n, fmt.Errorf("decoding Int: %s", err) + return n, fmt.Errorf("decoding Int: %w", err) } switch int32(u.V) { case 0: u.V0 = new(PersistedScpStateV0) - nTmp, err = (*u.V0).DecodeFrom(d) + nTmp, err = (*u.V0).DecodeFrom(d, maxDepth) n += nTmp if err != nil { - return n, fmt.Errorf("decoding PersistedScpStateV0: %s", err) + return n, fmt.Errorf("decoding PersistedScpStateV0: %w", err) } return n, nil case 1: u.V1 = new(PersistedScpStateV1) - nTmp, err = (*u.V1).DecodeFrom(d) + nTmp, err = (*u.V1).DecodeFrom(d, maxDepth) n += nTmp if err != nil { - return n, fmt.Errorf("decoding PersistedScpStateV1: %s", err) + return n, fmt.Errorf("decoding PersistedScpStateV1: %w", err) } return n, nil } @@ -52247,7 +53746,7 @@ func (s PersistedScpState) MarshalBinary() ([]byte, error) { func (s *PersistedScpState) UnmarshalBinary(inp []byte) error { r := bytes.NewReader(inp) d := xdr.NewDecoder(r) - _, err := s.DecodeFrom(d) + _, err := s.DecodeFrom(d, xdr.DecodeDefaultMaxDepth) return err } @@ -52285,13 +53784,17 @@ func (s *ConfigSettingContractExecutionLanesV0) EncodeTo(e *xdr.Encoder) error { var _ decoderFrom = (*ConfigSettingContractExecutionLanesV0)(nil) // DecodeFrom decodes this value using the Decoder. -func (s *ConfigSettingContractExecutionLanesV0) DecodeFrom(d *xdr.Decoder) (int, error) { +func (s *ConfigSettingContractExecutionLanesV0) DecodeFrom(d *xdr.Decoder, maxDepth uint) (int, error) { + if maxDepth == 0 { + return 0, fmt.Errorf("decoding ConfigSettingContractExecutionLanesV0: %w", ErrMaxDecodingDepthReached) + } + maxDepth -= 1 var err error var n, nTmp int - nTmp, err = s.LedgerMaxTxCount.DecodeFrom(d) + nTmp, err = s.LedgerMaxTxCount.DecodeFrom(d, maxDepth) n += nTmp if err != nil { - return n, fmt.Errorf("decoding Uint32: %s", err) + return n, fmt.Errorf("decoding Uint32: %w", err) } return n, nil } @@ -52308,7 +53811,7 @@ func (s ConfigSettingContractExecutionLanesV0) MarshalBinary() ([]byte, error) { func (s *ConfigSettingContractExecutionLanesV0) UnmarshalBinary(inp []byte) error { r := bytes.NewReader(inp) d := xdr.NewDecoder(r) - _, err := s.DecodeFrom(d) + _, err := s.DecodeFrom(d, xdr.DecodeDefaultMaxDepth) return err } @@ -52366,28 +53869,32 @@ func (s *ConfigSettingContractComputeV0) EncodeTo(e *xdr.Encoder) error { var _ decoderFrom = (*ConfigSettingContractComputeV0)(nil) // DecodeFrom decodes this value using the Decoder. -func (s *ConfigSettingContractComputeV0) DecodeFrom(d *xdr.Decoder) (int, error) { +func (s *ConfigSettingContractComputeV0) DecodeFrom(d *xdr.Decoder, maxDepth uint) (int, error) { + if maxDepth == 0 { + return 0, fmt.Errorf("decoding ConfigSettingContractComputeV0: %w", ErrMaxDecodingDepthReached) + } + maxDepth -= 1 var err error var n, nTmp int - nTmp, err = s.LedgerMaxInstructions.DecodeFrom(d) + nTmp, err = s.LedgerMaxInstructions.DecodeFrom(d, maxDepth) n += nTmp if err != nil { - return n, fmt.Errorf("decoding Int64: %s", err) + return n, fmt.Errorf("decoding Int64: %w", err) } - nTmp, err = s.TxMaxInstructions.DecodeFrom(d) + nTmp, err = s.TxMaxInstructions.DecodeFrom(d, maxDepth) n += nTmp if err != nil { - return n, fmt.Errorf("decoding Int64: %s", err) + return n, fmt.Errorf("decoding Int64: %w", err) } - nTmp, err = s.FeeRatePerInstructionsIncrement.DecodeFrom(d) + nTmp, err = s.FeeRatePerInstructionsIncrement.DecodeFrom(d, maxDepth) n += nTmp if err != nil { - return n, fmt.Errorf("decoding Int64: %s", err) + return n, fmt.Errorf("decoding Int64: %w", err) } - nTmp, err = s.TxMemoryLimit.DecodeFrom(d) + nTmp, err = s.TxMemoryLimit.DecodeFrom(d, maxDepth) n += nTmp if err != nil { - return n, fmt.Errorf("decoding Uint32: %s", err) + return n, fmt.Errorf("decoding Uint32: %w", err) } return n, nil } @@ -52404,7 +53911,7 @@ func (s ConfigSettingContractComputeV0) MarshalBinary() ([]byte, error) { func (s *ConfigSettingContractComputeV0) UnmarshalBinary(inp []byte) error { r := bytes.NewReader(inp) d := xdr.NewDecoder(r) - _, err := s.DecodeFrom(d) + _, err := s.DecodeFrom(d, xdr.DecodeDefaultMaxDepth) return err } @@ -52528,83 +54035,87 @@ func (s *ConfigSettingContractLedgerCostV0) EncodeTo(e *xdr.Encoder) error { var _ decoderFrom = (*ConfigSettingContractLedgerCostV0)(nil) // DecodeFrom decodes this value using the Decoder. -func (s *ConfigSettingContractLedgerCostV0) DecodeFrom(d *xdr.Decoder) (int, error) { +func (s *ConfigSettingContractLedgerCostV0) DecodeFrom(d *xdr.Decoder, maxDepth uint) (int, error) { + if maxDepth == 0 { + return 0, fmt.Errorf("decoding ConfigSettingContractLedgerCostV0: %w", ErrMaxDecodingDepthReached) + } + maxDepth -= 1 var err error var n, nTmp int - nTmp, err = s.LedgerMaxReadLedgerEntries.DecodeFrom(d) + nTmp, err = s.LedgerMaxReadLedgerEntries.DecodeFrom(d, maxDepth) n += nTmp if err != nil { - return n, fmt.Errorf("decoding Uint32: %s", err) + return n, fmt.Errorf("decoding Uint32: %w", err) } - nTmp, err = s.LedgerMaxReadBytes.DecodeFrom(d) + nTmp, err = s.LedgerMaxReadBytes.DecodeFrom(d, maxDepth) n += nTmp if err != nil { - return n, fmt.Errorf("decoding Uint32: %s", err) + return n, fmt.Errorf("decoding Uint32: %w", err) } - nTmp, err = s.LedgerMaxWriteLedgerEntries.DecodeFrom(d) + nTmp, err = s.LedgerMaxWriteLedgerEntries.DecodeFrom(d, maxDepth) n += nTmp if err != nil { - return n, fmt.Errorf("decoding Uint32: %s", err) + return n, fmt.Errorf("decoding Uint32: %w", err) } - nTmp, err = s.LedgerMaxWriteBytes.DecodeFrom(d) + nTmp, err = s.LedgerMaxWriteBytes.DecodeFrom(d, maxDepth) n += nTmp if err != nil { - return n, fmt.Errorf("decoding Uint32: %s", err) + return n, fmt.Errorf("decoding Uint32: %w", err) } - nTmp, err = s.TxMaxReadLedgerEntries.DecodeFrom(d) + nTmp, err = s.TxMaxReadLedgerEntries.DecodeFrom(d, maxDepth) n += nTmp if err != nil { - return n, fmt.Errorf("decoding Uint32: %s", err) + return n, fmt.Errorf("decoding Uint32: %w", err) } - nTmp, err = s.TxMaxReadBytes.DecodeFrom(d) + nTmp, err = s.TxMaxReadBytes.DecodeFrom(d, maxDepth) n += nTmp if err != nil { - return n, fmt.Errorf("decoding Uint32: %s", err) + return n, fmt.Errorf("decoding Uint32: %w", err) } - nTmp, err = s.TxMaxWriteLedgerEntries.DecodeFrom(d) + nTmp, err = s.TxMaxWriteLedgerEntries.DecodeFrom(d, maxDepth) n += nTmp if err != nil { - return n, fmt.Errorf("decoding Uint32: %s", err) + return n, fmt.Errorf("decoding Uint32: %w", err) } - nTmp, err = s.TxMaxWriteBytes.DecodeFrom(d) + nTmp, err = s.TxMaxWriteBytes.DecodeFrom(d, maxDepth) n += nTmp if err != nil { - return n, fmt.Errorf("decoding Uint32: %s", err) + return n, fmt.Errorf("decoding Uint32: %w", err) } - nTmp, err = s.FeeReadLedgerEntry.DecodeFrom(d) + nTmp, err = s.FeeReadLedgerEntry.DecodeFrom(d, maxDepth) n += nTmp if err != nil { - return n, fmt.Errorf("decoding Int64: %s", err) + return n, fmt.Errorf("decoding Int64: %w", err) } - nTmp, err = s.FeeWriteLedgerEntry.DecodeFrom(d) + nTmp, err = s.FeeWriteLedgerEntry.DecodeFrom(d, maxDepth) n += nTmp if err != nil { - return n, fmt.Errorf("decoding Int64: %s", err) + return n, fmt.Errorf("decoding Int64: %w", err) } - nTmp, err = s.FeeRead1Kb.DecodeFrom(d) + nTmp, err = s.FeeRead1Kb.DecodeFrom(d, maxDepth) n += nTmp if err != nil { - return n, fmt.Errorf("decoding Int64: %s", err) + return n, fmt.Errorf("decoding Int64: %w", err) } - nTmp, err = s.BucketListTargetSizeBytes.DecodeFrom(d) + nTmp, err = s.BucketListTargetSizeBytes.DecodeFrom(d, maxDepth) n += nTmp if err != nil { - return n, fmt.Errorf("decoding Int64: %s", err) + return n, fmt.Errorf("decoding Int64: %w", err) } - nTmp, err = s.WriteFee1KbBucketListLow.DecodeFrom(d) + nTmp, err = s.WriteFee1KbBucketListLow.DecodeFrom(d, maxDepth) n += nTmp if err != nil { - return n, fmt.Errorf("decoding Int64: %s", err) + return n, fmt.Errorf("decoding Int64: %w", err) } - nTmp, err = s.WriteFee1KbBucketListHigh.DecodeFrom(d) + nTmp, err = s.WriteFee1KbBucketListHigh.DecodeFrom(d, maxDepth) n += nTmp if err != nil { - return n, fmt.Errorf("decoding Int64: %s", err) + return n, fmt.Errorf("decoding Int64: %w", err) } - nTmp, err = s.BucketListWriteFeeGrowthFactor.DecodeFrom(d) + nTmp, err = s.BucketListWriteFeeGrowthFactor.DecodeFrom(d, maxDepth) n += nTmp if err != nil { - return n, fmt.Errorf("decoding Uint32: %s", err) + return n, fmt.Errorf("decoding Uint32: %w", err) } return n, nil } @@ -52621,7 +54132,7 @@ func (s ConfigSettingContractLedgerCostV0) MarshalBinary() ([]byte, error) { func (s *ConfigSettingContractLedgerCostV0) UnmarshalBinary(inp []byte) error { r := bytes.NewReader(inp) d := xdr.NewDecoder(r) - _, err := s.DecodeFrom(d) + _, err := s.DecodeFrom(d, xdr.DecodeDefaultMaxDepth) return err } @@ -52658,13 +54169,17 @@ func (s *ConfigSettingContractHistoricalDataV0) EncodeTo(e *xdr.Encoder) error { var _ decoderFrom = (*ConfigSettingContractHistoricalDataV0)(nil) // DecodeFrom decodes this value using the Decoder. -func (s *ConfigSettingContractHistoricalDataV0) DecodeFrom(d *xdr.Decoder) (int, error) { +func (s *ConfigSettingContractHistoricalDataV0) DecodeFrom(d *xdr.Decoder, maxDepth uint) (int, error) { + if maxDepth == 0 { + return 0, fmt.Errorf("decoding ConfigSettingContractHistoricalDataV0: %w", ErrMaxDecodingDepthReached) + } + maxDepth -= 1 var err error var n, nTmp int - nTmp, err = s.FeeHistorical1Kb.DecodeFrom(d) + nTmp, err = s.FeeHistorical1Kb.DecodeFrom(d, maxDepth) n += nTmp if err != nil { - return n, fmt.Errorf("decoding Int64: %s", err) + return n, fmt.Errorf("decoding Int64: %w", err) } return n, nil } @@ -52681,7 +54196,7 @@ func (s ConfigSettingContractHistoricalDataV0) MarshalBinary() ([]byte, error) { func (s *ConfigSettingContractHistoricalDataV0) UnmarshalBinary(inp []byte) error { r := bytes.NewReader(inp) d := xdr.NewDecoder(r) - _, err := s.DecodeFrom(d) + _, err := s.DecodeFrom(d, xdr.DecodeDefaultMaxDepth) return err } @@ -52725,18 +54240,22 @@ func (s *ConfigSettingContractEventsV0) EncodeTo(e *xdr.Encoder) error { var _ decoderFrom = (*ConfigSettingContractEventsV0)(nil) // DecodeFrom decodes this value using the Decoder. -func (s *ConfigSettingContractEventsV0) DecodeFrom(d *xdr.Decoder) (int, error) { +func (s *ConfigSettingContractEventsV0) DecodeFrom(d *xdr.Decoder, maxDepth uint) (int, error) { + if maxDepth == 0 { + return 0, fmt.Errorf("decoding ConfigSettingContractEventsV0: %w", ErrMaxDecodingDepthReached) + } + maxDepth -= 1 var err error var n, nTmp int - nTmp, err = s.TxMaxContractEventsSizeBytes.DecodeFrom(d) + nTmp, err = s.TxMaxContractEventsSizeBytes.DecodeFrom(d, maxDepth) n += nTmp if err != nil { - return n, fmt.Errorf("decoding Uint32: %s", err) + return n, fmt.Errorf("decoding Uint32: %w", err) } - nTmp, err = s.FeeContractEvents1Kb.DecodeFrom(d) + nTmp, err = s.FeeContractEvents1Kb.DecodeFrom(d, maxDepth) n += nTmp if err != nil { - return n, fmt.Errorf("decoding Int64: %s", err) + return n, fmt.Errorf("decoding Int64: %w", err) } return n, nil } @@ -52753,7 +54272,7 @@ func (s ConfigSettingContractEventsV0) MarshalBinary() ([]byte, error) { func (s *ConfigSettingContractEventsV0) UnmarshalBinary(inp []byte) error { r := bytes.NewReader(inp) d := xdr.NewDecoder(r) - _, err := s.DecodeFrom(d) + _, err := s.DecodeFrom(d, xdr.DecodeDefaultMaxDepth) return err } @@ -52804,23 +54323,27 @@ func (s *ConfigSettingContractBandwidthV0) EncodeTo(e *xdr.Encoder) error { var _ decoderFrom = (*ConfigSettingContractBandwidthV0)(nil) // DecodeFrom decodes this value using the Decoder. -func (s *ConfigSettingContractBandwidthV0) DecodeFrom(d *xdr.Decoder) (int, error) { +func (s *ConfigSettingContractBandwidthV0) DecodeFrom(d *xdr.Decoder, maxDepth uint) (int, error) { + if maxDepth == 0 { + return 0, fmt.Errorf("decoding ConfigSettingContractBandwidthV0: %w", ErrMaxDecodingDepthReached) + } + maxDepth -= 1 var err error var n, nTmp int - nTmp, err = s.LedgerMaxTxsSizeBytes.DecodeFrom(d) + nTmp, err = s.LedgerMaxTxsSizeBytes.DecodeFrom(d, maxDepth) n += nTmp if err != nil { - return n, fmt.Errorf("decoding Uint32: %s", err) + return n, fmt.Errorf("decoding Uint32: %w", err) } - nTmp, err = s.TxMaxSizeBytes.DecodeFrom(d) + nTmp, err = s.TxMaxSizeBytes.DecodeFrom(d, maxDepth) n += nTmp if err != nil { - return n, fmt.Errorf("decoding Uint32: %s", err) + return n, fmt.Errorf("decoding Uint32: %w", err) } - nTmp, err = s.FeeTxSize1Kb.DecodeFrom(d) + nTmp, err = s.FeeTxSize1Kb.DecodeFrom(d, maxDepth) n += nTmp if err != nil { - return n, fmt.Errorf("decoding Int64: %s", err) + return n, fmt.Errorf("decoding Int64: %w", err) } return n, nil } @@ -52837,7 +54360,7 @@ func (s ConfigSettingContractBandwidthV0) MarshalBinary() ([]byte, error) { func (s *ConfigSettingContractBandwidthV0) UnmarshalBinary(inp []byte) error { r := bytes.NewReader(inp) d := xdr.NewDecoder(r) - _, err := s.DecodeFrom(d) + _, err := s.DecodeFrom(d, xdr.DecodeDefaultMaxDepth) return err } @@ -52857,127 +54380,107 @@ var _ xdrType = (*ConfigSettingContractBandwidthV0)(nil) // enum ContractCostType { // // Cost of running 1 wasm instruction // WasmInsnExec = 0, -// // Cost of growing wasm linear memory by 1 page -// WasmMemAlloc = 1, -// // Cost of allocating a chuck of host memory (in bytes) -// HostMemAlloc = 2, -// // Cost of copying a chuck of bytes into a pre-allocated host memory -// HostMemCpy = 3, -// // Cost of comparing two slices of host memory -// HostMemCmp = 4, +// // Cost of allocating a slice of memory (in bytes) +// MemAlloc = 1, +// // Cost of copying a slice of bytes into a pre-allocated memory +// MemCpy = 2, +// // Cost of comparing two slices of memory +// MemCmp = 3, // // Cost of a host function dispatch, not including the actual work done by // // the function nor the cost of VM invocation machinary -// DispatchHostFunction = 5, +// DispatchHostFunction = 4, // // Cost of visiting a host object from the host object storage. Exists to // // make sure some baseline cost coverage, i.e. repeatly visiting objects // // by the guest will always incur some charges. -// VisitObject = 6, +// VisitObject = 5, // // Cost of serializing an xdr object to bytes -// ValSer = 7, +// ValSer = 6, // // Cost of deserializing an xdr object from bytes -// ValDeser = 8, +// ValDeser = 7, // // Cost of computing the sha256 hash from bytes -// ComputeSha256Hash = 9, +// ComputeSha256Hash = 8, // // Cost of computing the ed25519 pubkey from bytes -// ComputeEd25519PubKey = 10, -// // Cost of accessing an entry in a Map. -// MapEntry = 11, -// // Cost of accessing an entry in a Vec -// VecEntry = 12, +// ComputeEd25519PubKey = 9, // // Cost of verifying ed25519 signature of a payload. -// VerifyEd25519Sig = 13, -// // Cost of reading a slice of vm linear memory -// VmMemRead = 14, -// // Cost of writing to a slice of vm linear memory -// VmMemWrite = 15, +// VerifyEd25519Sig = 10, // // Cost of instantiation a VM from wasm bytes code. -// VmInstantiation = 16, +// VmInstantiation = 11, // // Cost of instantiation a VM from a cached state. -// VmCachedInstantiation = 17, +// VmCachedInstantiation = 12, // // Cost of invoking a function on the VM. If the function is a host function, // // additional cost will be covered by `DispatchHostFunction`. -// InvokeVmFunction = 18, +// InvokeVmFunction = 13, // // Cost of computing a keccak256 hash from bytes. -// ComputeKeccak256Hash = 19, -// // Cost of computing an ECDSA secp256k1 pubkey from bytes. -// ComputeEcdsaSecp256k1Key = 20, +// ComputeKeccak256Hash = 14, // // Cost of computing an ECDSA secp256k1 signature from bytes. -// ComputeEcdsaSecp256k1Sig = 21, +// ComputeEcdsaSecp256k1Sig = 15, // // Cost of recovering an ECDSA secp256k1 key from a signature. -// RecoverEcdsaSecp256k1Key = 22, +// RecoverEcdsaSecp256k1Key = 16, // // Cost of int256 addition (`+`) and subtraction (`-`) operations -// Int256AddSub = 23, +// Int256AddSub = 17, // // Cost of int256 multiplication (`*`) operation -// Int256Mul = 24, +// Int256Mul = 18, // // Cost of int256 division (`/`) operation -// Int256Div = 25, +// Int256Div = 19, // // Cost of int256 power (`exp`) operation -// Int256Pow = 26, +// Int256Pow = 20, // // Cost of int256 shift (`shl`, `shr`) operation -// Int256Shift = 27 +// Int256Shift = 21, +// // Cost of drawing random bytes using a ChaCha20 PRNG +// ChaCha20DrawBytes = 22 // }; type ContractCostType int32 const ( ContractCostTypeWasmInsnExec ContractCostType = 0 - ContractCostTypeWasmMemAlloc ContractCostType = 1 - ContractCostTypeHostMemAlloc ContractCostType = 2 - ContractCostTypeHostMemCpy ContractCostType = 3 - ContractCostTypeHostMemCmp ContractCostType = 4 - ContractCostTypeDispatchHostFunction ContractCostType = 5 - ContractCostTypeVisitObject ContractCostType = 6 - ContractCostTypeValSer ContractCostType = 7 - ContractCostTypeValDeser ContractCostType = 8 - ContractCostTypeComputeSha256Hash ContractCostType = 9 - ContractCostTypeComputeEd25519PubKey ContractCostType = 10 - ContractCostTypeMapEntry ContractCostType = 11 - ContractCostTypeVecEntry ContractCostType = 12 - ContractCostTypeVerifyEd25519Sig ContractCostType = 13 - ContractCostTypeVmMemRead ContractCostType = 14 - ContractCostTypeVmMemWrite ContractCostType = 15 - ContractCostTypeVmInstantiation ContractCostType = 16 - ContractCostTypeVmCachedInstantiation ContractCostType = 17 - ContractCostTypeInvokeVmFunction ContractCostType = 18 - ContractCostTypeComputeKeccak256Hash ContractCostType = 19 - ContractCostTypeComputeEcdsaSecp256k1Key ContractCostType = 20 - ContractCostTypeComputeEcdsaSecp256k1Sig ContractCostType = 21 - ContractCostTypeRecoverEcdsaSecp256k1Key ContractCostType = 22 - ContractCostTypeInt256AddSub ContractCostType = 23 - ContractCostTypeInt256Mul ContractCostType = 24 - ContractCostTypeInt256Div ContractCostType = 25 - ContractCostTypeInt256Pow ContractCostType = 26 - ContractCostTypeInt256Shift ContractCostType = 27 + ContractCostTypeMemAlloc ContractCostType = 1 + ContractCostTypeMemCpy ContractCostType = 2 + ContractCostTypeMemCmp ContractCostType = 3 + ContractCostTypeDispatchHostFunction ContractCostType = 4 + ContractCostTypeVisitObject ContractCostType = 5 + ContractCostTypeValSer ContractCostType = 6 + ContractCostTypeValDeser ContractCostType = 7 + ContractCostTypeComputeSha256Hash ContractCostType = 8 + ContractCostTypeComputeEd25519PubKey ContractCostType = 9 + ContractCostTypeVerifyEd25519Sig ContractCostType = 10 + ContractCostTypeVmInstantiation ContractCostType = 11 + ContractCostTypeVmCachedInstantiation ContractCostType = 12 + ContractCostTypeInvokeVmFunction ContractCostType = 13 + ContractCostTypeComputeKeccak256Hash ContractCostType = 14 + ContractCostTypeComputeEcdsaSecp256k1Sig ContractCostType = 15 + ContractCostTypeRecoverEcdsaSecp256k1Key ContractCostType = 16 + ContractCostTypeInt256AddSub ContractCostType = 17 + ContractCostTypeInt256Mul ContractCostType = 18 + ContractCostTypeInt256Div ContractCostType = 19 + ContractCostTypeInt256Pow ContractCostType = 20 + ContractCostTypeInt256Shift ContractCostType = 21 + ContractCostTypeChaCha20DrawBytes ContractCostType = 22 ) var contractCostTypeMap = map[int32]string{ 0: "ContractCostTypeWasmInsnExec", - 1: "ContractCostTypeWasmMemAlloc", - 2: "ContractCostTypeHostMemAlloc", - 3: "ContractCostTypeHostMemCpy", - 4: "ContractCostTypeHostMemCmp", - 5: "ContractCostTypeDispatchHostFunction", - 6: "ContractCostTypeVisitObject", - 7: "ContractCostTypeValSer", - 8: "ContractCostTypeValDeser", - 9: "ContractCostTypeComputeSha256Hash", - 10: "ContractCostTypeComputeEd25519PubKey", - 11: "ContractCostTypeMapEntry", - 12: "ContractCostTypeVecEntry", - 13: "ContractCostTypeVerifyEd25519Sig", - 14: "ContractCostTypeVmMemRead", - 15: "ContractCostTypeVmMemWrite", - 16: "ContractCostTypeVmInstantiation", - 17: "ContractCostTypeVmCachedInstantiation", - 18: "ContractCostTypeInvokeVmFunction", - 19: "ContractCostTypeComputeKeccak256Hash", - 20: "ContractCostTypeComputeEcdsaSecp256k1Key", - 21: "ContractCostTypeComputeEcdsaSecp256k1Sig", - 22: "ContractCostTypeRecoverEcdsaSecp256k1Key", - 23: "ContractCostTypeInt256AddSub", - 24: "ContractCostTypeInt256Mul", - 25: "ContractCostTypeInt256Div", - 26: "ContractCostTypeInt256Pow", - 27: "ContractCostTypeInt256Shift", + 1: "ContractCostTypeMemAlloc", + 2: "ContractCostTypeMemCpy", + 3: "ContractCostTypeMemCmp", + 4: "ContractCostTypeDispatchHostFunction", + 5: "ContractCostTypeVisitObject", + 6: "ContractCostTypeValSer", + 7: "ContractCostTypeValDeser", + 8: "ContractCostTypeComputeSha256Hash", + 9: "ContractCostTypeComputeEd25519PubKey", + 10: "ContractCostTypeVerifyEd25519Sig", + 11: "ContractCostTypeVmInstantiation", + 12: "ContractCostTypeVmCachedInstantiation", + 13: "ContractCostTypeInvokeVmFunction", + 14: "ContractCostTypeComputeKeccak256Hash", + 15: "ContractCostTypeComputeEcdsaSecp256k1Sig", + 16: "ContractCostTypeRecoverEcdsaSecp256k1Key", + 17: "ContractCostTypeInt256AddSub", + 18: "ContractCostTypeInt256Mul", + 19: "ContractCostTypeInt256Div", + 20: "ContractCostTypeInt256Pow", + 21: "ContractCostTypeInt256Shift", + 22: "ContractCostTypeChaCha20DrawBytes", } // ValidEnum validates a proposed value for this enum. Implements @@ -53005,10 +54508,14 @@ func (e ContractCostType) EncodeTo(enc *xdr.Encoder) error { var _ decoderFrom = (*ContractCostType)(nil) // DecodeFrom decodes this value using the Decoder. -func (e *ContractCostType) DecodeFrom(d *xdr.Decoder) (int, error) { +func (e *ContractCostType) DecodeFrom(d *xdr.Decoder, maxDepth uint) (int, error) { + if maxDepth == 0 { + return 0, fmt.Errorf("decoding ContractCostType: %w", ErrMaxDecodingDepthReached) + } + maxDepth -= 1 v, n, err := d.DecodeInt() if err != nil { - return n, fmt.Errorf("decoding ContractCostType: %s", err) + return n, fmt.Errorf("decoding ContractCostType: %w", err) } if _, ok := contractCostTypeMap[v]; !ok { return n, fmt.Errorf("'%d' is not a valid ContractCostType enum value", v) @@ -53029,7 +54536,7 @@ func (s ContractCostType) MarshalBinary() ([]byte, error) { func (s *ContractCostType) UnmarshalBinary(inp []byte) error { r := bytes.NewReader(inp) d := xdr.NewDecoder(r) - _, err := s.DecodeFrom(d) + _, err := s.DecodeFrom(d, xdr.DecodeDefaultMaxDepth) return err } @@ -53077,23 +54584,27 @@ func (s *ContractCostParamEntry) EncodeTo(e *xdr.Encoder) error { var _ decoderFrom = (*ContractCostParamEntry)(nil) // DecodeFrom decodes this value using the Decoder. -func (s *ContractCostParamEntry) DecodeFrom(d *xdr.Decoder) (int, error) { +func (s *ContractCostParamEntry) DecodeFrom(d *xdr.Decoder, maxDepth uint) (int, error) { + if maxDepth == 0 { + return 0, fmt.Errorf("decoding ContractCostParamEntry: %w", ErrMaxDecodingDepthReached) + } + maxDepth -= 1 var err error var n, nTmp int - nTmp, err = s.Ext.DecodeFrom(d) + nTmp, err = s.Ext.DecodeFrom(d, maxDepth) n += nTmp if err != nil { - return n, fmt.Errorf("decoding ExtensionPoint: %s", err) + return n, fmt.Errorf("decoding ExtensionPoint: %w", err) } - nTmp, err = s.ConstTerm.DecodeFrom(d) + nTmp, err = s.ConstTerm.DecodeFrom(d, maxDepth) n += nTmp if err != nil { - return n, fmt.Errorf("decoding Int64: %s", err) + return n, fmt.Errorf("decoding Int64: %w", err) } - nTmp, err = s.LinearTerm.DecodeFrom(d) + nTmp, err = s.LinearTerm.DecodeFrom(d, maxDepth) n += nTmp if err != nil { - return n, fmt.Errorf("decoding Int64: %s", err) + return n, fmt.Errorf("decoding Int64: %w", err) } return n, nil } @@ -53110,7 +54621,7 @@ func (s ContractCostParamEntry) MarshalBinary() ([]byte, error) { func (s *ContractCostParamEntry) UnmarshalBinary(inp []byte) error { r := bytes.NewReader(inp) d := xdr.NewDecoder(r) - _, err := s.DecodeFrom(d) + _, err := s.DecodeFrom(d, xdr.DecodeDefaultMaxDepth) return err } @@ -53125,19 +54636,19 @@ func (s ContractCostParamEntry) xdrType() {} var _ xdrType = (*ContractCostParamEntry)(nil) -// StateExpirationSettings is an XDR Struct defines as: +// StateArchivalSettings is an XDR Struct defines as: // -// struct StateExpirationSettings { -// uint32 maxEntryExpiration; -// uint32 minTempEntryExpiration; -// uint32 minPersistentEntryExpiration; +// struct StateArchivalSettings { +// uint32 maxEntryTTL; +// uint32 minTemporaryTTL; +// uint32 minPersistentTTL; // // // rent_fee = wfee_rate_average / rent_rate_denominator_for_type // int64 persistentRentRateDenominator; // int64 tempRentRateDenominator; // -// // max number of entries that emit expiration meta in a single ledger -// uint32 maxEntriesToExpire; +// // max number of entries that emit archival meta in a single ledger +// uint32 maxEntriesToArchive; // // // Number of snapshots to use when calculating average BucketList size // uint32 bucketListSizeWindowSampleSize; @@ -53148,28 +54659,28 @@ var _ xdrType = (*ContractCostParamEntry)(nil) // // Lowest BucketList level to be scanned to evict entries // uint32 startingEvictionScanLevel; // }; -type StateExpirationSettings struct { - MaxEntryExpiration Uint32 - MinTempEntryExpiration Uint32 - MinPersistentEntryExpiration Uint32 +type StateArchivalSettings struct { + MaxEntryTtl Uint32 + MinTemporaryTtl Uint32 + MinPersistentTtl Uint32 PersistentRentRateDenominator Int64 TempRentRateDenominator Int64 - MaxEntriesToExpire Uint32 + MaxEntriesToArchive Uint32 BucketListSizeWindowSampleSize Uint32 EvictionScanSize Uint64 StartingEvictionScanLevel Uint32 } // EncodeTo encodes this value using the Encoder. -func (s *StateExpirationSettings) EncodeTo(e *xdr.Encoder) error { +func (s *StateArchivalSettings) EncodeTo(e *xdr.Encoder) error { var err error - if err = s.MaxEntryExpiration.EncodeTo(e); err != nil { + if err = s.MaxEntryTtl.EncodeTo(e); err != nil { return err } - if err = s.MinTempEntryExpiration.EncodeTo(e); err != nil { + if err = s.MinTemporaryTtl.EncodeTo(e); err != nil { return err } - if err = s.MinPersistentEntryExpiration.EncodeTo(e); err != nil { + if err = s.MinPersistentTtl.EncodeTo(e); err != nil { return err } if err = s.PersistentRentRateDenominator.EncodeTo(e); err != nil { @@ -53178,7 +54689,7 @@ func (s *StateExpirationSettings) EncodeTo(e *xdr.Encoder) error { if err = s.TempRentRateDenominator.EncodeTo(e); err != nil { return err } - if err = s.MaxEntriesToExpire.EncodeTo(e); err != nil { + if err = s.MaxEntriesToArchive.EncodeTo(e); err != nil { return err } if err = s.BucketListSizeWindowSampleSize.EncodeTo(e); err != nil { @@ -53193,62 +54704,66 @@ func (s *StateExpirationSettings) EncodeTo(e *xdr.Encoder) error { return nil } -var _ decoderFrom = (*StateExpirationSettings)(nil) +var _ decoderFrom = (*StateArchivalSettings)(nil) // DecodeFrom decodes this value using the Decoder. -func (s *StateExpirationSettings) DecodeFrom(d *xdr.Decoder) (int, error) { +func (s *StateArchivalSettings) DecodeFrom(d *xdr.Decoder, maxDepth uint) (int, error) { + if maxDepth == 0 { + return 0, fmt.Errorf("decoding StateArchivalSettings: %w", ErrMaxDecodingDepthReached) + } + maxDepth -= 1 var err error var n, nTmp int - nTmp, err = s.MaxEntryExpiration.DecodeFrom(d) + nTmp, err = s.MaxEntryTtl.DecodeFrom(d, maxDepth) n += nTmp if err != nil { - return n, fmt.Errorf("decoding Uint32: %s", err) + return n, fmt.Errorf("decoding Uint32: %w", err) } - nTmp, err = s.MinTempEntryExpiration.DecodeFrom(d) + nTmp, err = s.MinTemporaryTtl.DecodeFrom(d, maxDepth) n += nTmp if err != nil { - return n, fmt.Errorf("decoding Uint32: %s", err) + return n, fmt.Errorf("decoding Uint32: %w", err) } - nTmp, err = s.MinPersistentEntryExpiration.DecodeFrom(d) + nTmp, err = s.MinPersistentTtl.DecodeFrom(d, maxDepth) n += nTmp if err != nil { - return n, fmt.Errorf("decoding Uint32: %s", err) + return n, fmt.Errorf("decoding Uint32: %w", err) } - nTmp, err = s.PersistentRentRateDenominator.DecodeFrom(d) + nTmp, err = s.PersistentRentRateDenominator.DecodeFrom(d, maxDepth) n += nTmp if err != nil { - return n, fmt.Errorf("decoding Int64: %s", err) + return n, fmt.Errorf("decoding Int64: %w", err) } - nTmp, err = s.TempRentRateDenominator.DecodeFrom(d) + nTmp, err = s.TempRentRateDenominator.DecodeFrom(d, maxDepth) n += nTmp if err != nil { - return n, fmt.Errorf("decoding Int64: %s", err) + return n, fmt.Errorf("decoding Int64: %w", err) } - nTmp, err = s.MaxEntriesToExpire.DecodeFrom(d) + nTmp, err = s.MaxEntriesToArchive.DecodeFrom(d, maxDepth) n += nTmp if err != nil { - return n, fmt.Errorf("decoding Uint32: %s", err) + return n, fmt.Errorf("decoding Uint32: %w", err) } - nTmp, err = s.BucketListSizeWindowSampleSize.DecodeFrom(d) + nTmp, err = s.BucketListSizeWindowSampleSize.DecodeFrom(d, maxDepth) n += nTmp if err != nil { - return n, fmt.Errorf("decoding Uint32: %s", err) + return n, fmt.Errorf("decoding Uint32: %w", err) } - nTmp, err = s.EvictionScanSize.DecodeFrom(d) + nTmp, err = s.EvictionScanSize.DecodeFrom(d, maxDepth) n += nTmp if err != nil { - return n, fmt.Errorf("decoding Uint64: %s", err) + return n, fmt.Errorf("decoding Uint64: %w", err) } - nTmp, err = s.StartingEvictionScanLevel.DecodeFrom(d) + nTmp, err = s.StartingEvictionScanLevel.DecodeFrom(d, maxDepth) n += nTmp if err != nil { - return n, fmt.Errorf("decoding Uint32: %s", err) + return n, fmt.Errorf("decoding Uint32: %w", err) } return n, nil } // MarshalBinary implements encoding.BinaryMarshaler. -func (s StateExpirationSettings) MarshalBinary() ([]byte, error) { +func (s StateArchivalSettings) MarshalBinary() ([]byte, error) { b := bytes.Buffer{} e := xdr.NewEncoder(&b) err := s.EncodeTo(e) @@ -53256,23 +54771,23 @@ func (s StateExpirationSettings) MarshalBinary() ([]byte, error) { } // UnmarshalBinary implements encoding.BinaryUnmarshaler. -func (s *StateExpirationSettings) UnmarshalBinary(inp []byte) error { +func (s *StateArchivalSettings) UnmarshalBinary(inp []byte) error { r := bytes.NewReader(inp) d := xdr.NewDecoder(r) - _, err := s.DecodeFrom(d) + _, err := s.DecodeFrom(d, xdr.DecodeDefaultMaxDepth) return err } var ( - _ encoding.BinaryMarshaler = (*StateExpirationSettings)(nil) - _ encoding.BinaryUnmarshaler = (*StateExpirationSettings)(nil) + _ encoding.BinaryMarshaler = (*StateArchivalSettings)(nil) + _ encoding.BinaryUnmarshaler = (*StateArchivalSettings)(nil) ) // xdrType signals that this type is an type representing // representing XDR values defined by this package. -func (s StateExpirationSettings) xdrType() {} +func (s StateArchivalSettings) xdrType() {} -var _ xdrType = (*StateExpirationSettings)(nil) +var _ xdrType = (*StateArchivalSettings)(nil) // EvictionIterator is an XDR Struct defines as: // @@ -53305,23 +54820,27 @@ func (s *EvictionIterator) EncodeTo(e *xdr.Encoder) error { var _ decoderFrom = (*EvictionIterator)(nil) // DecodeFrom decodes this value using the Decoder. -func (s *EvictionIterator) DecodeFrom(d *xdr.Decoder) (int, error) { +func (s *EvictionIterator) DecodeFrom(d *xdr.Decoder, maxDepth uint) (int, error) { + if maxDepth == 0 { + return 0, fmt.Errorf("decoding EvictionIterator: %w", ErrMaxDecodingDepthReached) + } + maxDepth -= 1 var err error var n, nTmp int - nTmp, err = s.BucketListLevel.DecodeFrom(d) + nTmp, err = s.BucketListLevel.DecodeFrom(d, maxDepth) n += nTmp if err != nil { - return n, fmt.Errorf("decoding Uint32: %s", err) + return n, fmt.Errorf("decoding Uint32: %w", err) } s.IsCurrBucket, nTmp, err = d.DecodeBool() n += nTmp if err != nil { - return n, fmt.Errorf("decoding Bool: %s", err) + return n, fmt.Errorf("decoding Bool: %w", err) } - nTmp, err = s.BucketFileOffset.DecodeFrom(d) + nTmp, err = s.BucketFileOffset.DecodeFrom(d, maxDepth) n += nTmp if err != nil { - return n, fmt.Errorf("decoding Uint64: %s", err) + return n, fmt.Errorf("decoding Uint64: %w", err) } return n, nil } @@ -53338,7 +54857,7 @@ func (s EvictionIterator) MarshalBinary() ([]byte, error) { func (s *EvictionIterator) UnmarshalBinary(inp []byte) error { r := bytes.NewReader(inp) d := xdr.NewDecoder(r) - _, err := s.DecodeFrom(d) + _, err := s.DecodeFrom(d, xdr.DecodeDefaultMaxDepth) return err } @@ -53385,14 +54904,18 @@ func (s ContractCostParams) EncodeTo(e *xdr.Encoder) error { var _ decoderFrom = (*ContractCostParams)(nil) // DecodeFrom decodes this value using the Decoder. -func (s *ContractCostParams) DecodeFrom(d *xdr.Decoder) (int, error) { +func (s *ContractCostParams) DecodeFrom(d *xdr.Decoder, maxDepth uint) (int, error) { + if maxDepth == 0 { + return 0, fmt.Errorf("decoding ContractCostParams: %w", ErrMaxDecodingDepthReached) + } + maxDepth -= 1 var err error var n, nTmp int var l uint32 l, nTmp, err = d.DecodeUint() n += nTmp if err != nil { - return n, fmt.Errorf("decoding ContractCostParamEntry: %s", err) + return n, fmt.Errorf("decoding ContractCostParamEntry: %w", err) } if l > 1024 { return n, fmt.Errorf("decoding ContractCostParamEntry: data size (%d) exceeds size limit (1024)", l) @@ -53401,10 +54924,10 @@ func (s *ContractCostParams) DecodeFrom(d *xdr.Decoder) (int, error) { if l > 0 { (*s) = make([]ContractCostParamEntry, l) for i := uint32(0); i < l; i++ { - nTmp, err = (*s)[i].DecodeFrom(d) + nTmp, err = (*s)[i].DecodeFrom(d, maxDepth) n += nTmp if err != nil { - return n, fmt.Errorf("decoding ContractCostParamEntry: %s", err) + return n, fmt.Errorf("decoding ContractCostParamEntry: %w", err) } } } @@ -53423,7 +54946,7 @@ func (s ContractCostParams) MarshalBinary() ([]byte, error) { func (s *ContractCostParams) UnmarshalBinary(inp []byte) error { r := bytes.NewReader(inp) d := xdr.NewDecoder(r) - _, err := s.DecodeFrom(d) + _, err := s.DecodeFrom(d, xdr.DecodeDefaultMaxDepth) return err } @@ -53452,7 +54975,7 @@ var _ xdrType = (*ContractCostParams)(nil) // CONFIG_SETTING_CONTRACT_COST_PARAMS_MEMORY_BYTES = 7, // CONFIG_SETTING_CONTRACT_DATA_KEY_SIZE_BYTES = 8, // CONFIG_SETTING_CONTRACT_DATA_ENTRY_SIZE_BYTES = 9, -// CONFIG_SETTING_STATE_EXPIRATION = 10, +// CONFIG_SETTING_STATE_ARCHIVAL = 10, // CONFIG_SETTING_CONTRACT_EXECUTION_LANES = 11, // CONFIG_SETTING_BUCKETLIST_SIZE_WINDOW = 12, // CONFIG_SETTING_EVICTION_ITERATOR = 13 @@ -53470,7 +54993,7 @@ const ( ConfigSettingIdConfigSettingContractCostParamsMemoryBytes ConfigSettingId = 7 ConfigSettingIdConfigSettingContractDataKeySizeBytes ConfigSettingId = 8 ConfigSettingIdConfigSettingContractDataEntrySizeBytes ConfigSettingId = 9 - ConfigSettingIdConfigSettingStateExpiration ConfigSettingId = 10 + ConfigSettingIdConfigSettingStateArchival ConfigSettingId = 10 ConfigSettingIdConfigSettingContractExecutionLanes ConfigSettingId = 11 ConfigSettingIdConfigSettingBucketlistSizeWindow ConfigSettingId = 12 ConfigSettingIdConfigSettingEvictionIterator ConfigSettingId = 13 @@ -53487,7 +55010,7 @@ var configSettingIdMap = map[int32]string{ 7: "ConfigSettingIdConfigSettingContractCostParamsMemoryBytes", 8: "ConfigSettingIdConfigSettingContractDataKeySizeBytes", 9: "ConfigSettingIdConfigSettingContractDataEntrySizeBytes", - 10: "ConfigSettingIdConfigSettingStateExpiration", + 10: "ConfigSettingIdConfigSettingStateArchival", 11: "ConfigSettingIdConfigSettingContractExecutionLanes", 12: "ConfigSettingIdConfigSettingBucketlistSizeWindow", 13: "ConfigSettingIdConfigSettingEvictionIterator", @@ -53518,10 +55041,14 @@ func (e ConfigSettingId) EncodeTo(enc *xdr.Encoder) error { var _ decoderFrom = (*ConfigSettingId)(nil) // DecodeFrom decodes this value using the Decoder. -func (e *ConfigSettingId) DecodeFrom(d *xdr.Decoder) (int, error) { +func (e *ConfigSettingId) DecodeFrom(d *xdr.Decoder, maxDepth uint) (int, error) { + if maxDepth == 0 { + return 0, fmt.Errorf("decoding ConfigSettingId: %w", ErrMaxDecodingDepthReached) + } + maxDepth -= 1 v, n, err := d.DecodeInt() if err != nil { - return n, fmt.Errorf("decoding ConfigSettingId: %s", err) + return n, fmt.Errorf("decoding ConfigSettingId: %w", err) } if _, ok := configSettingIdMap[v]; !ok { return n, fmt.Errorf("'%d' is not a valid ConfigSettingId enum value", v) @@ -53542,7 +55069,7 @@ func (s ConfigSettingId) MarshalBinary() ([]byte, error) { func (s *ConfigSettingId) UnmarshalBinary(inp []byte) error { r := bytes.NewReader(inp) d := xdr.NewDecoder(r) - _, err := s.DecodeFrom(d) + _, err := s.DecodeFrom(d, xdr.DecodeDefaultMaxDepth) return err } @@ -53581,8 +55108,8 @@ var _ xdrType = (*ConfigSettingId)(nil) // uint32 contractDataKeySizeBytes; // case CONFIG_SETTING_CONTRACT_DATA_ENTRY_SIZE_BYTES: // uint32 contractDataEntrySizeBytes; -// case CONFIG_SETTING_STATE_EXPIRATION: -// StateExpirationSettings stateExpirationSettings; +// case CONFIG_SETTING_STATE_ARCHIVAL: +// StateArchivalSettings stateArchivalSettings; // case CONFIG_SETTING_CONTRACT_EXECUTION_LANES: // ConfigSettingContractExecutionLanesV0 contractExecutionLanes; // case CONFIG_SETTING_BUCKETLIST_SIZE_WINDOW: @@ -53602,7 +55129,7 @@ type ConfigSettingEntry struct { ContractCostParamsMemBytes *ContractCostParams ContractDataKeySizeBytes *Uint32 ContractDataEntrySizeBytes *Uint32 - StateExpirationSettings *StateExpirationSettings + StateArchivalSettings *StateArchivalSettings ContractExecutionLanes *ConfigSettingContractExecutionLanesV0 BucketListSizeWindow *[]Uint64 EvictionIterator *EvictionIterator @@ -53638,8 +55165,8 @@ func (u ConfigSettingEntry) ArmForSwitch(sw int32) (string, bool) { return "ContractDataKeySizeBytes", true case ConfigSettingIdConfigSettingContractDataEntrySizeBytes: return "ContractDataEntrySizeBytes", true - case ConfigSettingIdConfigSettingStateExpiration: - return "StateExpirationSettings", true + case ConfigSettingIdConfigSettingStateArchival: + return "StateArchivalSettings", true case ConfigSettingIdConfigSettingContractExecutionLanes: return "ContractExecutionLanes", true case ConfigSettingIdConfigSettingBucketlistSizeWindow: @@ -53657,98 +55184,98 @@ func NewConfigSettingEntry(configSettingId ConfigSettingId, value interface{}) ( case ConfigSettingIdConfigSettingContractMaxSizeBytes: tv, ok := value.(Uint32) if !ok { - err = fmt.Errorf("invalid value, must be Uint32") + err = errors.New("invalid value, must be Uint32") return } result.ContractMaxSizeBytes = &tv case ConfigSettingIdConfigSettingContractComputeV0: tv, ok := value.(ConfigSettingContractComputeV0) if !ok { - err = fmt.Errorf("invalid value, must be ConfigSettingContractComputeV0") + err = errors.New("invalid value, must be ConfigSettingContractComputeV0") return } result.ContractCompute = &tv case ConfigSettingIdConfigSettingContractLedgerCostV0: tv, ok := value.(ConfigSettingContractLedgerCostV0) if !ok { - err = fmt.Errorf("invalid value, must be ConfigSettingContractLedgerCostV0") + err = errors.New("invalid value, must be ConfigSettingContractLedgerCostV0") return } result.ContractLedgerCost = &tv case ConfigSettingIdConfigSettingContractHistoricalDataV0: tv, ok := value.(ConfigSettingContractHistoricalDataV0) if !ok { - err = fmt.Errorf("invalid value, must be ConfigSettingContractHistoricalDataV0") + err = errors.New("invalid value, must be ConfigSettingContractHistoricalDataV0") return } result.ContractHistoricalData = &tv case ConfigSettingIdConfigSettingContractEventsV0: tv, ok := value.(ConfigSettingContractEventsV0) if !ok { - err = fmt.Errorf("invalid value, must be ConfigSettingContractEventsV0") + err = errors.New("invalid value, must be ConfigSettingContractEventsV0") return } result.ContractEvents = &tv case ConfigSettingIdConfigSettingContractBandwidthV0: tv, ok := value.(ConfigSettingContractBandwidthV0) if !ok { - err = fmt.Errorf("invalid value, must be ConfigSettingContractBandwidthV0") + err = errors.New("invalid value, must be ConfigSettingContractBandwidthV0") return } result.ContractBandwidth = &tv case ConfigSettingIdConfigSettingContractCostParamsCpuInstructions: tv, ok := value.(ContractCostParams) if !ok { - err = fmt.Errorf("invalid value, must be ContractCostParams") + err = errors.New("invalid value, must be ContractCostParams") return } result.ContractCostParamsCpuInsns = &tv case ConfigSettingIdConfigSettingContractCostParamsMemoryBytes: tv, ok := value.(ContractCostParams) if !ok { - err = fmt.Errorf("invalid value, must be ContractCostParams") + err = errors.New("invalid value, must be ContractCostParams") return } result.ContractCostParamsMemBytes = &tv case ConfigSettingIdConfigSettingContractDataKeySizeBytes: tv, ok := value.(Uint32) if !ok { - err = fmt.Errorf("invalid value, must be Uint32") + err = errors.New("invalid value, must be Uint32") return } result.ContractDataKeySizeBytes = &tv case ConfigSettingIdConfigSettingContractDataEntrySizeBytes: tv, ok := value.(Uint32) if !ok { - err = fmt.Errorf("invalid value, must be Uint32") + err = errors.New("invalid value, must be Uint32") return } result.ContractDataEntrySizeBytes = &tv - case ConfigSettingIdConfigSettingStateExpiration: - tv, ok := value.(StateExpirationSettings) + case ConfigSettingIdConfigSettingStateArchival: + tv, ok := value.(StateArchivalSettings) if !ok { - err = fmt.Errorf("invalid value, must be StateExpirationSettings") + err = errors.New("invalid value, must be StateArchivalSettings") return } - result.StateExpirationSettings = &tv + result.StateArchivalSettings = &tv case ConfigSettingIdConfigSettingContractExecutionLanes: tv, ok := value.(ConfigSettingContractExecutionLanesV0) if !ok { - err = fmt.Errorf("invalid value, must be ConfigSettingContractExecutionLanesV0") + err = errors.New("invalid value, must be ConfigSettingContractExecutionLanesV0") return } result.ContractExecutionLanes = &tv case ConfigSettingIdConfigSettingBucketlistSizeWindow: tv, ok := value.([]Uint64) if !ok { - err = fmt.Errorf("invalid value, must be []Uint64") + err = errors.New("invalid value, must be []Uint64") return } result.BucketListSizeWindow = &tv case ConfigSettingIdConfigSettingEvictionIterator: tv, ok := value.(EvictionIterator) if !ok { - err = fmt.Errorf("invalid value, must be EvictionIterator") + err = errors.New("invalid value, must be EvictionIterator") return } result.EvictionIterator = &tv @@ -54006,25 +55533,25 @@ func (u ConfigSettingEntry) GetContractDataEntrySizeBytes() (result Uint32, ok b return } -// MustStateExpirationSettings retrieves the StateExpirationSettings value from the union, +// MustStateArchivalSettings retrieves the StateArchivalSettings value from the union, // panicing if the value is not set. -func (u ConfigSettingEntry) MustStateExpirationSettings() StateExpirationSettings { - val, ok := u.GetStateExpirationSettings() +func (u ConfigSettingEntry) MustStateArchivalSettings() StateArchivalSettings { + val, ok := u.GetStateArchivalSettings() if !ok { - panic("arm StateExpirationSettings is not set") + panic("arm StateArchivalSettings is not set") } return val } -// GetStateExpirationSettings retrieves the StateExpirationSettings value from the union, +// GetStateArchivalSettings retrieves the StateArchivalSettings value from the union, // returning ok if the union's switch indicated the value is valid. -func (u ConfigSettingEntry) GetStateExpirationSettings() (result StateExpirationSettings, ok bool) { +func (u ConfigSettingEntry) GetStateArchivalSettings() (result StateArchivalSettings, ok bool) { armName, _ := u.ArmForSwitch(int32(u.ConfigSettingId)) - if armName == "StateExpirationSettings" { - result = *u.StateExpirationSettings + if armName == "StateArchivalSettings" { + result = *u.StateArchivalSettings ok = true } @@ -54163,8 +55690,8 @@ func (u ConfigSettingEntry) EncodeTo(e *xdr.Encoder) error { return err } return nil - case ConfigSettingIdConfigSettingStateExpiration: - if err = (*u.StateExpirationSettings).EncodeTo(e); err != nil { + case ConfigSettingIdConfigSettingStateArchival: + if err = (*u.StateArchivalSettings).EncodeTo(e); err != nil { return err } return nil @@ -54195,109 +55722,113 @@ func (u ConfigSettingEntry) EncodeTo(e *xdr.Encoder) error { var _ decoderFrom = (*ConfigSettingEntry)(nil) // DecodeFrom decodes this value using the Decoder. -func (u *ConfigSettingEntry) DecodeFrom(d *xdr.Decoder) (int, error) { +func (u *ConfigSettingEntry) DecodeFrom(d *xdr.Decoder, maxDepth uint) (int, error) { + if maxDepth == 0 { + return 0, fmt.Errorf("decoding ConfigSettingEntry: %w", ErrMaxDecodingDepthReached) + } + maxDepth -= 1 var err error var n, nTmp int - nTmp, err = u.ConfigSettingId.DecodeFrom(d) + nTmp, err = u.ConfigSettingId.DecodeFrom(d, maxDepth) n += nTmp if err != nil { - return n, fmt.Errorf("decoding ConfigSettingId: %s", err) + return n, fmt.Errorf("decoding ConfigSettingId: %w", err) } switch ConfigSettingId(u.ConfigSettingId) { case ConfigSettingIdConfigSettingContractMaxSizeBytes: u.ContractMaxSizeBytes = new(Uint32) - nTmp, err = (*u.ContractMaxSizeBytes).DecodeFrom(d) + nTmp, err = (*u.ContractMaxSizeBytes).DecodeFrom(d, maxDepth) n += nTmp if err != nil { - return n, fmt.Errorf("decoding Uint32: %s", err) + return n, fmt.Errorf("decoding Uint32: %w", err) } return n, nil case ConfigSettingIdConfigSettingContractComputeV0: u.ContractCompute = new(ConfigSettingContractComputeV0) - nTmp, err = (*u.ContractCompute).DecodeFrom(d) + nTmp, err = (*u.ContractCompute).DecodeFrom(d, maxDepth) n += nTmp if err != nil { - return n, fmt.Errorf("decoding ConfigSettingContractComputeV0: %s", err) + return n, fmt.Errorf("decoding ConfigSettingContractComputeV0: %w", err) } return n, nil case ConfigSettingIdConfigSettingContractLedgerCostV0: u.ContractLedgerCost = new(ConfigSettingContractLedgerCostV0) - nTmp, err = (*u.ContractLedgerCost).DecodeFrom(d) + nTmp, err = (*u.ContractLedgerCost).DecodeFrom(d, maxDepth) n += nTmp if err != nil { - return n, fmt.Errorf("decoding ConfigSettingContractLedgerCostV0: %s", err) + return n, fmt.Errorf("decoding ConfigSettingContractLedgerCostV0: %w", err) } return n, nil case ConfigSettingIdConfigSettingContractHistoricalDataV0: u.ContractHistoricalData = new(ConfigSettingContractHistoricalDataV0) - nTmp, err = (*u.ContractHistoricalData).DecodeFrom(d) + nTmp, err = (*u.ContractHistoricalData).DecodeFrom(d, maxDepth) n += nTmp if err != nil { - return n, fmt.Errorf("decoding ConfigSettingContractHistoricalDataV0: %s", err) + return n, fmt.Errorf("decoding ConfigSettingContractHistoricalDataV0: %w", err) } return n, nil case ConfigSettingIdConfigSettingContractEventsV0: u.ContractEvents = new(ConfigSettingContractEventsV0) - nTmp, err = (*u.ContractEvents).DecodeFrom(d) + nTmp, err = (*u.ContractEvents).DecodeFrom(d, maxDepth) n += nTmp if err != nil { - return n, fmt.Errorf("decoding ConfigSettingContractEventsV0: %s", err) + return n, fmt.Errorf("decoding ConfigSettingContractEventsV0: %w", err) } return n, nil case ConfigSettingIdConfigSettingContractBandwidthV0: u.ContractBandwidth = new(ConfigSettingContractBandwidthV0) - nTmp, err = (*u.ContractBandwidth).DecodeFrom(d) + nTmp, err = (*u.ContractBandwidth).DecodeFrom(d, maxDepth) n += nTmp if err != nil { - return n, fmt.Errorf("decoding ConfigSettingContractBandwidthV0: %s", err) + return n, fmt.Errorf("decoding ConfigSettingContractBandwidthV0: %w", err) } return n, nil case ConfigSettingIdConfigSettingContractCostParamsCpuInstructions: u.ContractCostParamsCpuInsns = new(ContractCostParams) - nTmp, err = (*u.ContractCostParamsCpuInsns).DecodeFrom(d) + nTmp, err = (*u.ContractCostParamsCpuInsns).DecodeFrom(d, maxDepth) n += nTmp if err != nil { - return n, fmt.Errorf("decoding ContractCostParams: %s", err) + return n, fmt.Errorf("decoding ContractCostParams: %w", err) } return n, nil case ConfigSettingIdConfigSettingContractCostParamsMemoryBytes: u.ContractCostParamsMemBytes = new(ContractCostParams) - nTmp, err = (*u.ContractCostParamsMemBytes).DecodeFrom(d) + nTmp, err = (*u.ContractCostParamsMemBytes).DecodeFrom(d, maxDepth) n += nTmp if err != nil { - return n, fmt.Errorf("decoding ContractCostParams: %s", err) + return n, fmt.Errorf("decoding ContractCostParams: %w", err) } return n, nil case ConfigSettingIdConfigSettingContractDataKeySizeBytes: u.ContractDataKeySizeBytes = new(Uint32) - nTmp, err = (*u.ContractDataKeySizeBytes).DecodeFrom(d) + nTmp, err = (*u.ContractDataKeySizeBytes).DecodeFrom(d, maxDepth) n += nTmp if err != nil { - return n, fmt.Errorf("decoding Uint32: %s", err) + return n, fmt.Errorf("decoding Uint32: %w", err) } return n, nil case ConfigSettingIdConfigSettingContractDataEntrySizeBytes: u.ContractDataEntrySizeBytes = new(Uint32) - nTmp, err = (*u.ContractDataEntrySizeBytes).DecodeFrom(d) + nTmp, err = (*u.ContractDataEntrySizeBytes).DecodeFrom(d, maxDepth) n += nTmp if err != nil { - return n, fmt.Errorf("decoding Uint32: %s", err) + return n, fmt.Errorf("decoding Uint32: %w", err) } return n, nil - case ConfigSettingIdConfigSettingStateExpiration: - u.StateExpirationSettings = new(StateExpirationSettings) - nTmp, err = (*u.StateExpirationSettings).DecodeFrom(d) + case ConfigSettingIdConfigSettingStateArchival: + u.StateArchivalSettings = new(StateArchivalSettings) + nTmp, err = (*u.StateArchivalSettings).DecodeFrom(d, maxDepth) n += nTmp if err != nil { - return n, fmt.Errorf("decoding StateExpirationSettings: %s", err) + return n, fmt.Errorf("decoding StateArchivalSettings: %w", err) } return n, nil case ConfigSettingIdConfigSettingContractExecutionLanes: u.ContractExecutionLanes = new(ConfigSettingContractExecutionLanesV0) - nTmp, err = (*u.ContractExecutionLanes).DecodeFrom(d) + nTmp, err = (*u.ContractExecutionLanes).DecodeFrom(d, maxDepth) n += nTmp if err != nil { - return n, fmt.Errorf("decoding ConfigSettingContractExecutionLanesV0: %s", err) + return n, fmt.Errorf("decoding ConfigSettingContractExecutionLanesV0: %w", err) } return n, nil case ConfigSettingIdConfigSettingBucketlistSizeWindow: @@ -54306,26 +55837,26 @@ func (u *ConfigSettingEntry) DecodeFrom(d *xdr.Decoder) (int, error) { l, nTmp, err = d.DecodeUint() n += nTmp if err != nil { - return n, fmt.Errorf("decoding Uint64: %s", err) + return n, fmt.Errorf("decoding Uint64: %w", err) } (*u.BucketListSizeWindow) = nil if l > 0 { (*u.BucketListSizeWindow) = make([]Uint64, l) for i := uint32(0); i < l; i++ { - nTmp, err = (*u.BucketListSizeWindow)[i].DecodeFrom(d) + nTmp, err = (*u.BucketListSizeWindow)[i].DecodeFrom(d, maxDepth) n += nTmp if err != nil { - return n, fmt.Errorf("decoding Uint64: %s", err) + return n, fmt.Errorf("decoding Uint64: %w", err) } } } return n, nil case ConfigSettingIdConfigSettingEvictionIterator: u.EvictionIterator = new(EvictionIterator) - nTmp, err = (*u.EvictionIterator).DecodeFrom(d) + nTmp, err = (*u.EvictionIterator).DecodeFrom(d, maxDepth) n += nTmp if err != nil { - return n, fmt.Errorf("decoding EvictionIterator: %s", err) + return n, fmt.Errorf("decoding EvictionIterator: %w", err) } return n, nil } @@ -54344,7 +55875,7 @@ func (s ConfigSettingEntry) MarshalBinary() ([]byte, error) { func (s *ConfigSettingEntry) UnmarshalBinary(inp []byte) error { r := bytes.NewReader(inp) d := xdr.NewDecoder(r) - _, err := s.DecodeFrom(d) + _, err := s.DecodeFrom(d, xdr.DecodeDefaultMaxDepth) return err } From ac1958cdb93c24f4924434d2c74ec9d1e7675607 Mon Sep 17 00:00:00 2001 From: Tsachi Herman <24438559+tsachiherman@users.noreply.github.com> Date: Wed, 25 Oct 2023 09:08:51 -0400 Subject: [PATCH 07/16] fix comment (#5090) --- services/horizon/internal/ingest/processors/contract_data.go | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/services/horizon/internal/ingest/processors/contract_data.go b/services/horizon/internal/ingest/processors/contract_data.go index dec9199747..bce4ac6b25 100644 --- a/services/horizon/internal/ingest/processors/contract_data.go +++ b/services/horizon/internal/ingest/processors/contract_data.go @@ -413,7 +413,7 @@ func metadataObjFromAsset(isNative bool, code, issuer string) (*xdr.ScMap, error // ledger entry containing the asset info entry written to contract storage by the // Stellar Asset Contract. // -// Warning: Only for use in tests. This does not set a realistic expirationLedgerSeq +// Warning: Only for use in tests. This does not create the accompanied TTLEntry which would typically be created by core. func AssetToContractData(isNative bool, code, issuer string, contractID [32]byte) (xdr.LedgerEntryData, error) { storageMap, err := metadataObjFromAsset(isNative, code, issuer) if err != nil { @@ -450,7 +450,7 @@ func AssetToContractData(isNative bool, code, issuer string, contractID [32]byte // creates a ledger entry containing the asset balance of a contract holder // written to contract storage by the Stellar Asset Contract. // -// Warning: Only for use in tests. This does not set a realistic expirationLedgerSeq +// Warning: Only for use in tests. This does not create the accompanied TTLEntry which would typically be created by core. func BalanceToContractData(assetContractId, holderID [32]byte, amt uint64) xdr.LedgerEntryData { return balanceToContractData(assetContractId, holderID, xdr.Int128Parts{ Lo: xdr.Uint64(amt), From 7bdbc7b61d153dd6c40b6fa4e2cc7814ac019bd0 Mon Sep 17 00:00:00 2001 From: Tsachi Herman <24438559+tsachiherman@users.noreply.github.com> Date: Tue, 31 Oct 2023 15:54:16 -0400 Subject: [PATCH 08/16] update (#5097) --- ingest/checkpoint_change_reader.go | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/ingest/checkpoint_change_reader.go b/ingest/checkpoint_change_reader.go index 7fbc74e294..37e5e994e1 100644 --- a/ingest/checkpoint_change_reader.go +++ b/ingest/checkpoint_change_reader.go @@ -325,6 +325,8 @@ func (r *CheckpointChangeReader) streamBucketContents(hash historyarchive.Hash, var batch []xdr.BucketEntry lastBatch := false + preloadKeys := make([]string, 0, preloadedEntries) + LoopBucketEntry: for { // Preload entries for faster retrieve from temp store. @@ -332,8 +334,10 @@ LoopBucketEntry: if lastBatch { return true } + batch = make([]xdr.BucketEntry, 0, preloadedEntries) - preloadKeys := []string{} + // reset the content of the preloadKeys + preloadKeys = preloadKeys[:0] for i := 0; i < preloadedEntries; i++ { var entry xdr.BucketEntry From d0c8a9138634ee0b67f080b937689ce686c2fe00 Mon Sep 17 00:00:00 2001 From: Alfonso Acosta Date: Wed, 15 Nov 2023 18:34:01 +0100 Subject: [PATCH 09/16] xdr: Add String() method to ScVal (#5112) * xdr: Add String() method to ScVal * Also add String() method for contract events --- xdr/event.go | 23 +++++++++++ xdr/scval.go | 100 ++++++++++++++++++++++++++++++++++++++++++++++ xdr/scval_test.go | 28 +++++++++++-- 3 files changed, 147 insertions(+), 4 deletions(-) create mode 100644 xdr/event.go diff --git a/xdr/event.go b/xdr/event.go new file mode 100644 index 0000000000..2ae97a0d2c --- /dev/null +++ b/xdr/event.go @@ -0,0 +1,23 @@ +package xdr + +import ( + "encoding/hex" + "fmt" +) + +func (ce ContractEvent) String() string { + result := ce.Type.String() + "(" + if ce.ContractId != nil { + result += hex.EncodeToString(ce.ContractId[:]) + "," + } + result += ce.Body.String() + ")" + return result +} + +func (eb ContractEventBody) String() string { + return fmt.Sprintf("%+v", *eb.V0) +} + +func (de DiagnosticEvent) String() string { + return fmt.Sprintf("%s, successful call: %t", de.Event, de.InSuccessfulContractCall) +} diff --git a/xdr/scval.go b/xdr/scval.go index 4648a6ab82..003efe885f 100644 --- a/xdr/scval.go +++ b/xdr/scval.go @@ -2,7 +2,10 @@ package xdr import ( "bytes" + "encoding/hex" "fmt" + "math/big" + "time" "github.com/stellar/go/strkey" ) @@ -182,3 +185,100 @@ func (s ScMapEntry) Equals(o ScMapEntry) bool { func (s ScNonceKey) Equals(o ScNonceKey) bool { return s.Nonce == o.Nonce } + +func bigIntFromParts(hi Int64, lowerParts ...Uint64) *big.Int { + result := new(big.Int).SetInt64(int64(hi)) + secondary := new(big.Int) + for _, part := range lowerParts { + result.Lsh(result, 64) + result.Or(result, secondary.SetUint64(uint64(part))) + } + return result +} + +func bigUIntFromParts(hi Uint64, lowerParts ...Uint64) *big.Int { + result := new(big.Int).SetUint64(uint64(hi)) + secondary := new(big.Int) + for _, part := range lowerParts { + result.Lsh(result, 64) + result.Or(result, secondary.SetUint64(uint64(part))) + } + return result +} + +func (s ScVal) String() string { + switch s.Type { + case ScValTypeScvBool: + return fmt.Sprintf("%t", *s.B) + case ScValTypeScvVoid: + return "(void)" + case ScValTypeScvError: + switch s.Error.Type { + case ScErrorTypeSceContract: + return fmt.Sprintf("%s(%d)", s.Error.Type, *s.Error.ContractCode) + case ScErrorTypeSceWasmVm, ScErrorTypeSceContext, ScErrorTypeSceStorage, ScErrorTypeSceObject, + ScErrorTypeSceCrypto, ScErrorTypeSceEvents, ScErrorTypeSceBudget, ScErrorTypeSceValue, ScErrorTypeSceAuth: + return fmt.Sprintf("%s(%s)", s.Error.Type, *s.Error.Code) + } + case ScValTypeScvU32: + return fmt.Sprintf("%d", *s.U32) + case ScValTypeScvI32: + return fmt.Sprintf("%d", *s.I32) + case ScValTypeScvU64: + return fmt.Sprintf("%d", *s.U64) + case ScValTypeScvI64: + return fmt.Sprintf("%d", *s.I64) + case ScValTypeScvTimepoint: + return time.Unix(int64(*s.Timepoint), 0).String() + case ScValTypeScvDuration: + return fmt.Sprintf("%d", *s.Duration) + case ScValTypeScvU128: + return bigUIntFromParts(s.U128.Hi, s.U128.Lo).String() + case ScValTypeScvI128: + return bigIntFromParts(s.I128.Hi, s.I128.Lo).String() + case ScValTypeScvU256: + return bigUIntFromParts(s.U256.HiHi, s.U256.HiLo, s.U256.LoHi, s.U256.LoLo).String() + case ScValTypeScvI256: + return bigIntFromParts(s.I256.HiHi, s.I256.HiLo, s.I256.LoHi, s.I256.LoLo).String() + case ScValTypeScvBytes: + return hex.EncodeToString(*s.Bytes) + case ScValTypeScvString: + return string(*s.Str) + case ScValTypeScvSymbol: + return string(*s.Sym) + case ScValTypeScvVec: + if *s.Vec == nil { + return "nil" + } + return fmt.Sprintf("%s", **s.Vec) + case ScValTypeScvMap: + if *s.Map == nil { + return "nil" + } + return fmt.Sprintf("%v", **s.Map) + case ScValTypeScvAddress: + str, err := s.Address.String() + if err != nil { + return err.Error() + } + return str + case ScValTypeScvContractInstance: + result := "" + switch s.Instance.Executable.Type { + case ContractExecutableTypeContractExecutableStellarAsset: + result = "(StellarAssetContract)" + case ContractExecutableTypeContractExecutableWasm: + result = hex.EncodeToString(s.Instance.Executable.WasmHash[:]) + } + if s.Instance.Storage != nil && len(*s.Instance.Storage) > 0 { + result += fmt.Sprintf(": %v", *s.Instance.Storage) + } + return result + case ScValTypeScvLedgerKeyContractInstance: + return "(LedgerKeyContractInstance)" + case ScValTypeScvLedgerKeyNonce: + return fmt.Sprintf("%X", *s.NonceKey) + } + + return "unknown" +} diff --git a/xdr/scval_test.go b/xdr/scval_test.go index 812a12942b..8bfa97deb3 100644 --- a/xdr/scval_test.go +++ b/xdr/scval_test.go @@ -3,7 +3,7 @@ package xdr import ( "testing" - "github.com/stretchr/testify/assert" + "github.com/stretchr/testify/require" "github.com/stellar/go/gxdr" "github.com/stellar/go/randxdr" @@ -19,10 +19,30 @@ func TestScValEqualsCoverage(t *testing.T) { shape, []randxdr.Preset{}, ) - assert.NoError(t, gxdr.Convert(shape, &scVal)) + require.NoError(t, gxdr.Convert(shape, &scVal)) clonedScVal := ScVal{} - assert.NoError(t, gxdr.Convert(shape, &clonedScVal)) - assert.True(t, scVal.Equals(clonedScVal), "scVal: %#v, clonedScVal: %#v", scVal, clonedScVal) + require.NoError(t, gxdr.Convert(shape, &clonedScVal)) + require.True(t, scVal.Equals(clonedScVal), "scVal: %#v, clonedScVal: %#v", scVal, clonedScVal) + } +} + +func TestScValStringCoverage(t *testing.T) { + gen := randxdr.NewGenerator() + for i := 0; i < 30000; i++ { + scVal := ScVal{} + + shape := &gxdr.SCVal{} + gen.Next( + shape, + []randxdr.Preset{}, + ) + require.NoError(t, gxdr.Convert(shape, &scVal)) + + var str string + require.NotPanics(t, func() { + str = scVal.String() + }) + require.NotEqual(t, str, "unknown") } } From 11e5322c60cc489d45f547d4aa662f4c38223422 Mon Sep 17 00:00:00 2001 From: tamirms Date: Fri, 17 Nov 2023 14:38:34 +0000 Subject: [PATCH 10/16] services/horizon/internal/ingest/processors: Accommodate eviction of soroban ledger entries in asset stats endpoint (#5033) --- protocols/horizon/main.go | 2 + .../docker/captive-core-integration-tests.cfg | 5 +- .../docker/stellar-core-integration-tests.cfg | 5 +- services/horizon/internal/actions/asset.go | 2 +- .../horizon/internal/actions/asset_test.go | 5 + .../horizon/internal/db2/assets/asset_stat.go | 60 -- .../internal/db2/assets/asset_stat_test.go | 107 --- .../internal/db2/history/asset_stats.go | 259 ++++++- .../internal/db2/history/asset_stats_test.go | 567 +++++++++++----- services/horizon/internal/db2/history/main.go | 69 +- .../db2/history/mock_q_asset_stats.go | 67 +- .../horizon/internal/db2/schema/bindata.go | 23 + .../migrations/66_contract_asset_stats.sql | 18 + services/horizon/internal/ingest/main.go | 4 +- .../internal/ingest/processor_runner.go | 2 +- .../internal/ingest/processor_runner_test.go | 32 +- .../processors/asset_stats_processor.go | 453 +++++++++---- .../processors/asset_stats_processor_test.go | 637 +++++++++++++++--- .../ingest/processors/asset_stats_set.go | 251 +------ .../ingest/processors/asset_stats_set_test.go | 436 +----------- .../ingest/processors/contract_asset_stats.go | 412 +++++++++++ .../processors/contract_asset_stats_test.go | 636 +++++++++++++++++ .../ingest/processors/contract_data.go | 38 +- services/horizon/internal/ingest/verify.go | 214 +++++- .../ingest/verify_range_state_test.go | 85 ++- .../horizon/internal/ingest/verify_test.go | 27 +- .../integration/extend_footprint_ttl_test.go | 4 +- .../horizon/internal/integration/sac_test.go | 297 ++++---- .../internal/resourceadapter/asset_stat.go | 40 +- .../resourceadapter/asset_stat_test.go | 49 +- 30 files changed, 3296 insertions(+), 1510 deletions(-) delete mode 100644 services/horizon/internal/db2/assets/asset_stat.go delete mode 100644 services/horizon/internal/db2/assets/asset_stat_test.go create mode 100644 services/horizon/internal/db2/schema/migrations/66_contract_asset_stats.sql create mode 100644 services/horizon/internal/ingest/processors/contract_asset_stats.go create mode 100644 services/horizon/internal/ingest/processors/contract_asset_stats_test.go diff --git a/protocols/horizon/main.go b/protocols/horizon/main.go index 1cfc10bf9b..08da47b7b4 100644 --- a/protocols/horizon/main.go +++ b/protocols/horizon/main.go @@ -173,12 +173,14 @@ type AssetStat struct { NumClaimableBalances int32 `json:"num_claimable_balances"` NumLiquidityPools int32 `json:"num_liquidity_pools"` NumContracts int32 `json:"num_contracts"` + NumArchivedContracts int32 `json:"num_archived_contracts"` // Action needed in release: horizon-v3.0.0: deprecated field Amount string `json:"amount"` Accounts AssetStatAccounts `json:"accounts"` ClaimableBalancesAmount string `json:"claimable_balances_amount"` LiquidityPoolsAmount string `json:"liquidity_pools_amount"` ContractsAmount string `json:"contracts_amount"` + ArchivedContractsAmount string `json:"archived_contracts_amount"` Balances AssetStatBalances `json:"balances"` Flags AccountFlags `json:"flags"` } diff --git a/services/horizon/docker/captive-core-integration-tests.cfg b/services/horizon/docker/captive-core-integration-tests.cfg index 2215cb9fd0..abea8c8ede 100644 --- a/services/horizon/docker/captive-core-integration-tests.cfg +++ b/services/horizon/docker/captive-core-integration-tests.cfg @@ -1,11 +1,12 @@ PEER_PORT=11725 ARTIFICIALLY_ACCELERATE_TIME_FOR_TESTING=true -ENABLE_SOROBAN_DIAGNOSTIC_EVENTS=true -TESTING_SOROBAN_HIGH_LIMIT_OVERRIDE=true UNSAFE_QUORUM=true FAILURE_SAFETY=0 +ENABLE_SOROBAN_DIAGNOSTIC_EVENTS=true +TESTING_SOROBAN_HIGH_LIMIT_OVERRIDE=true + [[VALIDATORS]] NAME="local_core" HOME_DOMAIN="core.local" diff --git a/services/horizon/docker/stellar-core-integration-tests.cfg b/services/horizon/docker/stellar-core-integration-tests.cfg index 53d5a9816b..27adf63f4b 100644 --- a/services/horizon/docker/stellar-core-integration-tests.cfg +++ b/services/horizon/docker/stellar-core-integration-tests.cfg @@ -1,5 +1,4 @@ ARTIFICIALLY_ACCELERATE_TIME_FOR_TESTING=true -TESTING_SOROBAN_HIGH_LIMIT_OVERRIDE=true NETWORK_PASSPHRASE="Standalone Network ; February 2017" @@ -15,6 +14,8 @@ FAILURE_SAFETY=0 DATABASE="postgresql://user=postgres password=mysecretpassword host=core-postgres port=5641 dbname=stellar" +TESTING_SOROBAN_HIGH_LIMIT_OVERRIDE=true + [QUORUM_SET] THRESHOLD_PERCENT=100 VALIDATORS=["GD5KD2KEZJIGTC63IGW6UMUSMVUVG5IHG64HUTFWCHVZH2N2IBOQN7PS"] @@ -22,4 +23,4 @@ VALIDATORS=["GD5KD2KEZJIGTC63IGW6UMUSMVUVG5IHG64HUTFWCHVZH2N2IBOQN7PS"] [HISTORY.vs] get="cp history/vs/{0} {1}" put="cp {0} history/vs/{1}" -mkdir="mkdir -p history/vs/{0}" \ No newline at end of file +mkdir="mkdir -p history/vs/{0}" diff --git a/services/horizon/internal/actions/asset.go b/services/horizon/internal/actions/asset.go index 27235fb5eb..7236b482ff 100644 --- a/services/horizon/internal/actions/asset.go +++ b/services/horizon/internal/actions/asset.go @@ -81,7 +81,7 @@ func (handler AssetStatsHandler) validateAssetParams(code, issuer string, pq db2 func (handler AssetStatsHandler) findIssuersForAssets( ctx context.Context, historyQ *history.Q, - assetStats []history.ExpAssetStat, + assetStats []history.AssetAndContractStat, ) (map[string]history.AccountEntry, error) { issuerSet := map[string]bool{} issuers := []string{} diff --git a/services/horizon/internal/actions/asset_test.go b/services/horizon/internal/actions/asset_test.go index eb1a1df07d..0e4995d93c 100644 --- a/services/horizon/internal/actions/asset_test.go +++ b/services/horizon/internal/actions/asset_test.go @@ -160,6 +160,7 @@ func TestAssetStats(t *testing.T) { Amount: "0.0000001", NumAccounts: usdAssetStat.NumAccounts, ContractsAmount: "0.0000000", + ArchivedContractsAmount: "0.0000000", Asset: base.Asset{ Type: "credit_alphanum4", Code: usdAssetStat.AssetCode, @@ -204,6 +205,7 @@ func TestAssetStats(t *testing.T) { ClaimableBalancesAmount: "0.0000000", LiquidityPoolsAmount: "0.0000000", ContractsAmount: "0.0000000", + ArchivedContractsAmount: "0.0000000", Amount: "0.0000023", NumAccounts: etherAssetStat.NumAccounts, Asset: base.Asset{ @@ -251,6 +253,7 @@ func TestAssetStats(t *testing.T) { LiquidityPoolsAmount: "0.0000000", Amount: "0.0000001", ContractsAmount: "0.0000000", + ArchivedContractsAmount: "0.0000000", NumAccounts: otherUSDAssetStat.NumAccounts, Asset: base.Asset{ Type: "credit_alphanum4", @@ -299,6 +302,7 @@ func TestAssetStats(t *testing.T) { LiquidityPoolsAmount: "0.0000000", Amount: "0.0000111", ContractsAmount: "0.0000000", + ArchivedContractsAmount: "0.0000000", NumAccounts: eurAssetStat.NumAccounts, Asset: base.Asset{ Type: "credit_alphanum4", @@ -476,6 +480,7 @@ func TestAssetStatsIssuerDoesNotExist(t *testing.T) { LiquidityPoolsAmount: "0.0000000", Amount: "0.0000001", ContractsAmount: "0.0000000", + ArchivedContractsAmount: "0.0000000", NumAccounts: usdAssetStat.NumAccounts, Asset: base.Asset{ Type: "credit_alphanum4", diff --git a/services/horizon/internal/db2/assets/asset_stat.go b/services/horizon/internal/db2/assets/asset_stat.go deleted file mode 100644 index c7a5e69eec..0000000000 --- a/services/horizon/internal/db2/assets/asset_stat.go +++ /dev/null @@ -1,60 +0,0 @@ -package assets - -import ( - sq "github.com/Masterminds/squirrel" - "github.com/stellar/go/services/horizon/internal/db2" -) - -// PagingToken implementation for hal.Pageable -//func (res AssetStat) PagingToken() string { -// return res.PT -//} - -// AssetStatsQ is the query to fetch all assets in the system -type AssetStatsQ struct { - AssetCode *string - AssetIssuer *string - PageQuery *db2.PageQuery -} - -// GetSQL allows this query to be executed by the caller -func (q AssetStatsQ) GetSQL() (sq.SelectBuilder, error) { - sql := selectQuery - if q.AssetCode != nil && *q.AssetCode != "" { - sql = sql.Where("hist.asset_code = ?", *q.AssetCode) - } - if q.AssetIssuer != nil && *q.AssetIssuer != "" { - sql = sql.Where("hist.asset_issuer = ?", *q.AssetIssuer) - } - - var err error - if q.PageQuery != nil { - // cursor needs to work for descending case as well - cursor := q.PageQuery.Cursor - if q.PageQuery.Order == "desc" && cursor == "" { - cursor = "zzzzzzzzzzzzz" // 12 + 1 "z"s so it will always be greater than the _ delimiter since code is max 12 chars - } - - sql, err = q.PageQuery.ApplyToUsingCursor(sql, "concat(hist.asset_code, '_', hist.asset_issuer, '_', hist.asset_type)", cursor) - if err != nil { - return sql, err - } - } else { - sql = sql.OrderBy("sort_key ASC") - } - return sql, nil -} - -var selectQuery = sq. - Select( - "concat(hist.asset_code, '_', hist.asset_issuer, '_', hist.asset_type) as sort_key", - "hist.asset_type", - "hist.asset_code", - "hist.asset_issuer", - "stats.amount", - "stats.num_accounts", - "stats.flags", - "stats.toml", - ). - From("history_assets hist"). - Join("asset_stats stats ON hist.id = stats.id") diff --git a/services/horizon/internal/db2/assets/asset_stat_test.go b/services/horizon/internal/db2/assets/asset_stat_test.go deleted file mode 100644 index c87edc19cb..0000000000 --- a/services/horizon/internal/db2/assets/asset_stat_test.go +++ /dev/null @@ -1,107 +0,0 @@ -package assets - -import ( - "context" - "strconv" - "testing" - - "github.com/stellar/go/services/horizon/internal/db2" - "github.com/stellar/go/services/horizon/internal/db2/history" - "github.com/stellar/go/services/horizon/internal/test" -) - -// AssetStatsR is the result from the AssetStatsQ query -type AssetStatsR struct { - SortKey string `db:"sort_key"` - Type string `db:"asset_type"` - Code string `db:"asset_code"` - Issuer string `db:"asset_issuer"` - Amount string `db:"amount"` - NumAccounts int32 `db:"num_accounts"` - Flags int8 `db:"flags"` - Toml string `db:"toml"` -} - -func TestAssetsStatsQExec(t *testing.T) { - item0 := AssetStatsR{ - SortKey: "BTC_GC23QF2HUE52AMXUFUH3AYJAXXGXXV2VHXYYR6EYXETPKDXZSAW67XO4_credit_alphanum4", - Type: "credit_alphanum4", - Code: "BTC", - Issuer: "GC23QF2HUE52AMXUFUH3AYJAXXGXXV2VHXYYR6EYXETPKDXZSAW67XO4", - Amount: "1009876000", - NumAccounts: 1, - Flags: 1, - Toml: "https://test.com/.well-known/stellar.toml", - } - - item1 := AssetStatsR{ - SortKey: "SCOT_GCXKG6RN4ONIEPCMNFB732A436Z5PNDSRLGWK7GBLCMQLIFO4S7EYWVU_credit_alphanum4", - Type: "credit_alphanum4", - Code: "SCOT", - Issuer: "GCXKG6RN4ONIEPCMNFB732A436Z5PNDSRLGWK7GBLCMQLIFO4S7EYWVU", - Amount: "10000000000", - NumAccounts: 1, - Flags: 2, - Toml: "", - } - - item2 := AssetStatsR{ - SortKey: "USD_GC23QF2HUE52AMXUFUH3AYJAXXGXXV2VHXYYR6EYXETPKDXZSAW67XO4_credit_alphanum4", - Type: "credit_alphanum4", - Code: "USD", - Issuer: "GC23QF2HUE52AMXUFUH3AYJAXXGXXV2VHXYYR6EYXETPKDXZSAW67XO4", - Amount: "3000010434000", - NumAccounts: 2, - Flags: 1, - Toml: "https://test.com/.well-known/stellar.toml", - } - - testCases := []struct { - query AssetStatsQ - want []AssetStatsR - }{ - { - AssetStatsQ{}, - []AssetStatsR{item0, item1, item2}, - }, { - AssetStatsQ{ - PageQuery: &db2.PageQuery{ - Order: "asc", - Limit: 10, - }, - }, - []AssetStatsR{item0, item1, item2}, - }, { - AssetStatsQ{ - PageQuery: &db2.PageQuery{ - Order: "desc", - Limit: 10, - }, - }, - []AssetStatsR{item2, item1, item0}, - }, - } - - for i, kase := range testCases { - t.Run(strconv.Itoa(i), func(t *testing.T) { - tt := test.Start(t) - tt.Scenario("ingest_asset_stats") - defer tt.Finish() - - sql, err := kase.query.GetSQL() - tt.Require.NoError(err) - - var results []AssetStatsR - err = history.Q{SessionInterface: tt.HorizonSession()}.Select(context.Background(), &results, sql) - tt.Require.NoError(err) - if !tt.Assert.Equal(3, len(results)) { - return - } - - tt.Assert.Equal(len(kase.want), len(results)) - for i := range kase.want { - tt.Assert.Equal(kase.want[i], results[i]) - } - }) - } -} diff --git a/services/horizon/internal/db2/history/asset_stats.go b/services/horizon/internal/db2/history/asset_stats.go index b13d913141..94f0d61e00 100644 --- a/services/horizon/internal/db2/history/asset_stats.go +++ b/services/horizon/internal/db2/history/asset_stats.go @@ -6,6 +6,7 @@ import ( "strings" sq "github.com/Masterminds/squirrel" + "github.com/stellar/go/services/horizon/internal/db2" "github.com/stellar/go/support/db" "github.com/stellar/go/support/errors" @@ -33,11 +34,23 @@ func assetStatToPrimaryKeyMap(assetStat ExpAssetStat) map[string]interface{} { } } +// ContractAssetStatRow represents a row in the contract_asset_stats table +type ContractAssetStatRow struct { + // ContractID is the contract id of the stellar asset contract + ContractID []byte `db:"contract_id"` + // Stat is a json blob containing statistics on the contract holders + // this asset + Stat ContractStat `db:"stat"` +} + // InsertAssetStats a set of asset stats into the exp_asset_stats -func (q *Q) InsertAssetStats(ctx context.Context, assetStats []ExpAssetStat, batchSize int) error { +func (q *Q) InsertAssetStats(ctx context.Context, assetStats []ExpAssetStat) error { + if len(assetStats) == 0 { + return nil + } + builder := &db.BatchInsertBuilder{ - Table: q.GetTable("exp_asset_stats"), - MaxBatchSize: batchSize, + Table: q.GetTable("exp_asset_stats"), } for _, assetStat := range assetStats { @@ -53,6 +66,175 @@ func (q *Q) InsertAssetStats(ctx context.Context, assetStats []ExpAssetStat, bat return nil } +// InsertContractAssetStats inserts the given list of rows into the contract_asset_stats table +func (q *Q) InsertContractAssetStats(ctx context.Context, rows []ContractAssetStatRow) error { + if len(rows) == 0 { + return nil + } + builder := &db.BatchInsertBuilder{ + Table: q.GetTable("contract_asset_stats"), + } + + for _, row := range rows { + if err := builder.RowStruct(ctx, row); err != nil { + return errors.Wrap(err, "could not insert asset assetStat row") + } + } + + if err := builder.Exec(ctx); err != nil { + return errors.Wrap(err, "could not exec asset assetStats insert builder") + } + + return nil +} + +// ContractAssetBalance represents a row in the contract_asset_balances table +type ContractAssetBalance struct { + // KeyHash is a hash of the contract balance's ledger entry key + KeyHash []byte `db:"key_hash"` + // ContractID is the contract id of the stellar asset contract + ContractID []byte `db:"asset_contract_id"` + // Amount is the amount held by the contract + Amount string `db:"amount"` + // ExpirationLedger is the latest ledger for which this contract balance + // ledger entry is active + ExpirationLedger uint32 `db:"expiration_ledger"` +} + +// InsertContractAssetBalances will insert the given list of rows into the contract_asset_balances table +func (q *Q) InsertContractAssetBalances(ctx context.Context, rows []ContractAssetBalance) error { + if len(rows) == 0 { + return nil + } + builder := &db.BatchInsertBuilder{ + Table: q.GetTable("contract_asset_balances"), + } + + for _, row := range rows { + if err := builder.RowStruct(ctx, row); err != nil { + return errors.Wrap(err, "could not insert asset assetStat row") + } + } + + if err := builder.Exec(ctx); err != nil { + return errors.Wrap(err, "could not exec asset assetStats insert builder") + } + + return nil +} + +const maxUpdateBatchSize = 30000 + +// UpdateContractAssetBalanceAmounts will update the expiration ledgers for the given list of keys +// (if they exist in the db). +func (q *Q) UpdateContractAssetBalanceAmounts(ctx context.Context, keys []xdr.Hash, amounts []string) error { + for len(keys) > 0 { + var args []interface{} + var values []string + + for i := 0; len(keys) > 0 && i < maxUpdateBatchSize; i++ { + args = append(args, keys[0][:], amounts[0]) + values = append(values, "(cast(? as bytea), cast(? as numeric))") + keys = keys[1:] + amounts = amounts[1:] + } + + sql := fmt.Sprintf(` + UPDATE contract_asset_balances + SET + amount = myvalues.amount + FROM ( + VALUES + %s + ) AS myvalues (key_hash, amount) + WHERE contract_asset_balances.key_hash = myvalues.key_hash`, + strings.Join(values, ","), + ) + + _, err := q.ExecRaw(ctx, sql, args...) + if err != nil { + return err + } + } + return nil +} + +// UpdateContractAssetBalanceExpirations will update the expiration ledgers for the given list of keys +// (if they exist in the db). +func (q *Q) UpdateContractAssetBalanceExpirations(ctx context.Context, keys []xdr.Hash, expirationLedgers []uint32) error { + for len(keys) > 0 { + var args []interface{} + var values []string + + for i := 0; len(keys) > 0 && i < maxUpdateBatchSize; i++ { + args = append(args, keys[0][:], expirationLedgers[0]) + values = append(values, "(cast(? as bytea), cast(? as integer))") + keys = keys[1:] + expirationLedgers = expirationLedgers[1:] + } + + sql := fmt.Sprintf(` + UPDATE contract_asset_balances + SET + expiration_ledger = myvalues.expiration + FROM ( + VALUES + %s + ) AS myvalues (key_hash, expiration) + WHERE contract_asset_balances.key_hash = myvalues.key_hash`, + strings.Join(values, ","), + ) + + _, err := q.ExecRaw(ctx, sql, args...) + if err != nil { + return err + } + } + + return nil +} + +// GetContractAssetBalancesExpiringAt returns all contract asset balances which are active +// at `ledger` and expired at `ledger+1` +func (q *Q) GetContractAssetBalancesExpiringAt(ctx context.Context, ledger uint32) ([]ContractAssetBalance, error) { + sql := sq.Select("contract_asset_balances.*").From("contract_asset_balances"). + Where(map[string]interface{}{"expiration_ledger": ledger}) + var balances []ContractAssetBalance + err := q.Select(ctx, &balances, sql) + return balances, err +} + +// GetContractAssetBalances fetches all contract_asset_balances rows for the +// given list of key hashes. +func (q *Q) GetContractAssetBalances(ctx context.Context, keys []xdr.Hash) ([]ContractAssetBalance, error) { + keyBytes := make([][]byte, len(keys)) + for i := range keys { + keyBytes[i] = keys[i][:] + } + sql := sq.Select("contract_asset_balances.*").From("contract_asset_balances"). + Where(map[string]interface{}{"key_hash": keyBytes}) + var balances []ContractAssetBalance + err := q.Select(ctx, &balances, sql) + return balances, err +} + +// RemoveContractAssetBalances removes rows from the contract_asset_balances table +func (q *Q) RemoveContractAssetBalances(ctx context.Context, keys []xdr.Hash) error { + if len(keys) == 0 { + return nil + } + keyBytes := make([][]byte, len(keys)) + for i := range keys { + keyBytes[i] = keys[i][:] + } + + _, err := q.Exec(ctx, sq.Delete("contract_asset_balances"). + Where(map[string]interface{}{ + "key_hash": keyBytes, + })) + return err +} + // InsertAssetStat a single asset assetStat row into the exp_asset_stats // Returns number of rows affected and error. func (q *Q) InsertAssetStat(ctx context.Context, assetStat ExpAssetStat) (int64, error) { @@ -65,6 +247,20 @@ func (q *Q) InsertAssetStat(ctx context.Context, assetStat ExpAssetStat) (int64, return result.RowsAffected() } +// InsertContractAssetStat inserts a row into the contract_asset_stats table +func (q *Q) InsertContractAssetStat(ctx context.Context, row ContractAssetStatRow) (int64, error) { + sql := sq.Insert("contract_asset_stats").SetMap(map[string]interface{}{ + "contract_id": row.ContractID, + "stat": row.Stat, + }) + result, err := q.Exec(ctx, sql) + if err != nil { + return 0, err + } + + return result.RowsAffected() +} + // UpdateAssetStat updates a row in the exp_asset_stats table. // Returns number of rows affected and error. func (q *Q) UpdateAssetStat(ctx context.Context, assetStat ExpAssetStat) (int64, error) { @@ -79,6 +275,19 @@ func (q *Q) UpdateAssetStat(ctx context.Context, assetStat ExpAssetStat) (int64, return result.RowsAffected() } +// UpdateContractAssetStat updates a row in the contract_asset_stats table. +// Returns number of rows afected and error. +func (q *Q) UpdateContractAssetStat(ctx context.Context, row ContractAssetStatRow) (int64, error) { + sql := sq.Update("contract_asset_stats").Set("stat", row.Stat). + Where("contract_id = ?", row.ContractID) + result, err := q.Exec(ctx, sql) + if err != nil { + return 0, err + } + + return result.RowsAffected() +} + // RemoveAssetStat removes a row in the exp_asset_stats table. func (q *Q) RemoveAssetStat(ctx context.Context, assetType xdr.AssetType, assetCode, assetIssuer string) (int64, error) { sql := sq.Delete("exp_asset_stats"). @@ -95,6 +304,18 @@ func (q *Q) RemoveAssetStat(ctx context.Context, assetType xdr.AssetType, assetC return result.RowsAffected() } +// RemoveAssetContractStat removes a row in the contract_asset_stats table. +func (q *Q) RemoveAssetContractStat(ctx context.Context, contractID []byte) (int64, error) { + sql := sq.Delete("contract_asset_stats"). + Where("contract_id = ?", contractID) + result, err := q.Exec(ctx, sql) + if err != nil { + return 0, err + } + + return result.RowsAffected() +} + // GetAssetStat returns a row in the exp_asset_stats table. func (q *Q) GetAssetStat(ctx context.Context, assetType xdr.AssetType, assetCode, assetIssuer string) (ExpAssetStat, error) { sql := selectAssetStats.Where(map[string]interface{}{ @@ -107,23 +328,21 @@ func (q *Q) GetAssetStat(ctx context.Context, assetType xdr.AssetType, assetCode return assetStat, err } -func (q *Q) GetAssetStatByContract(ctx context.Context, contractID [32]byte) (ExpAssetStat, error) { - sql := selectAssetStats.Where("contract_id = ?", contractID[:]) - var assetStat ExpAssetStat +// GetContractAssetStat returns a row in the contract_asset_stats table. +func (q *Q) GetContractAssetStat(ctx context.Context, contractID []byte) (ContractAssetStatRow, error) { + sql := sq.Select("*").From("contract_asset_stats").Where("contract_id = ?", contractID) + var assetStat ContractAssetStatRow err := q.Get(ctx, &assetStat, sql) return assetStat, err } -func (q *Q) GetAssetStatByContracts(ctx context.Context, contractIDs [][32]byte) ([]ExpAssetStat, error) { - contractIDBytes := make([][]byte, len(contractIDs)) - for i := range contractIDs { - contractIDBytes[i] = contractIDs[i][:] - } - sql := selectAssetStats.Where(map[string]interface{}{"contract_id": contractIDBytes}) - - var assetStats []ExpAssetStat - err := q.Select(ctx, &assetStats, sql) - return assetStats, err +// GetAssetStatByContract returns the row in the exp_asset_stats table corresponding +// to the given contract id +func (q *Q) GetAssetStatByContract(ctx context.Context, contractID xdr.Hash) (ExpAssetStat, error) { + sql := selectAssetStats.Where("contract_id = ?", contractID[:]) + var assetStat ExpAssetStat + err := q.Get(ctx, &assetStat, sql) + return assetStat, err } func parseAssetStatsCursor(cursor string) (string, string, error) { @@ -158,8 +377,10 @@ func parseAssetStatsCursor(cursor string) (string, string, error) { } // GetAssetStats returns a page of exp_asset_stats rows. -func (q *Q) GetAssetStats(ctx context.Context, assetCode, assetIssuer string, page db2.PageQuery) ([]ExpAssetStat, error) { - sql := selectAssetStats +func (q *Q) GetAssetStats(ctx context.Context, assetCode, assetIssuer string, page db2.PageQuery) ([]AssetAndContractStat, error) { + sql := sq.Select("exp_asset_stats.*, contract_asset_stats.stat as contracts"). + From("exp_asset_stats"). + LeftJoin("contract_asset_stats ON exp_asset_stats.contract_id = contract_asset_stats.contract_id") filters := map[string]interface{}{} if assetCode != "" { filters["asset_code"] = assetCode @@ -193,7 +414,7 @@ func (q *Q) GetAssetStats(ctx context.Context, assetCode, assetIssuer string, pa sql = sql.OrderBy("(asset_code, asset_issuer) " + orderBy).Limit(page.Limit) - var results []ExpAssetStat + var results []AssetAndContractStat if err := q.Select(ctx, &results, sql); err != nil { return nil, errors.Wrap(err, "could not run select query") } diff --git a/services/horizon/internal/db2/history/asset_stats_test.go b/services/horizon/internal/db2/history/asset_stats_test.go index ceeb962a05..6485aec02b 100644 --- a/services/horizon/internal/db2/history/asset_stats_test.go +++ b/services/horizon/internal/db2/history/asset_stats_test.go @@ -1,10 +1,15 @@ package history import ( + "bytes" + "context" "database/sql" "sort" "testing" + "github.com/stretchr/testify/assert" + "golang.org/x/exp/slices" + "github.com/stellar/go/services/horizon/internal/db2" "github.com/stellar/go/services/horizon/internal/test" "github.com/stellar/go/xdr" @@ -25,7 +30,6 @@ func TestAssetStatContracts(t *testing.T) { ClaimableBalances: 0, LiquidityPools: 0, Unauthorized: 0, - Contracts: 0, }, Balances: ExpAssetStatBalances{ Authorized: "0", @@ -33,7 +37,6 @@ func TestAssetStatContracts(t *testing.T) { ClaimableBalances: "0", LiquidityPools: "0", Unauthorized: "0", - Contracts: "0", }, Amount: "0", NumAccounts: 0, @@ -46,7 +49,6 @@ func TestAssetStatContracts(t *testing.T) { Authorized: 1, AuthorizedToMaintainLiabilities: 3, Unauthorized: 4, - Contracts: 7, }, Balances: ExpAssetStatBalances{ Authorized: "23", @@ -54,7 +56,6 @@ func TestAssetStatContracts(t *testing.T) { Unauthorized: "3", ClaimableBalances: "4", LiquidityPools: "5", - Contracts: "60", }, Amount: "23", NumAccounts: 1, @@ -67,7 +68,6 @@ func TestAssetStatContracts(t *testing.T) { Authorized: 2, AuthorizedToMaintainLiabilities: 3, Unauthorized: 4, - Contracts: 8, }, Balances: ExpAssetStatBalances{ Authorized: "1", @@ -75,7 +75,6 @@ func TestAssetStatContracts(t *testing.T) { Unauthorized: "3", ClaimableBalances: "4", LiquidityPools: "5", - Contracts: "90", }, Amount: "1", NumAccounts: 2, @@ -86,7 +85,7 @@ func TestAssetStatContracts(t *testing.T) { assetStats[i].SetContractID(contractID) contractID[0]++ } - tt.Assert.NoError(q.InsertAssetStats(tt.Ctx, assetStats, 1)) + tt.Assert.NoError(q.InsertAssetStats(tt.Ctx, assetStats)) contractID[0] = 0 for i := 0; i < 2; i++ { @@ -97,22 +96,9 @@ func TestAssetStatContracts(t *testing.T) { contractID[0]++ } - contractIDs := make([][32]byte, 2) - contractIDs[1][0]++ - rows, err := q.GetAssetStatByContracts(tt.Ctx, contractIDs) - tt.Assert.NoError(err) - tt.Assert.Len(rows, 2) - sort.Slice(rows, func(i, j int) bool { - return rows[i].AssetCode < rows[j].AssetCode - }) - - for i, row := range rows { - tt.Assert.True(row.Equals(assetStats[i])) - } - usd := assetStats[2] usd.SetContractID([32]byte{}) - _, err = q.UpdateAssetStat(tt.Ctx, usd) + _, err := q.UpdateAssetStat(tt.Ctx, usd) tt.Assert.EqualError(err, "exec failed: pq: duplicate key value violates unique constraint \"exp_asset_stats_contract_id_key\"") usd.SetContractID([32]byte{2}) @@ -129,17 +115,73 @@ func TestAssetStatContracts(t *testing.T) { tt.Assert.True(assetStat.Equals(assetStats[i])) contractID[0]++ } +} - contractIDs = [][32]byte{{}, {1}, {2}} - rows, err = q.GetAssetStatByContracts(tt.Ctx, contractIDs) +func TestAssetContractStats(t *testing.T) { + tt := test.Start(t) + defer tt.Finish() + test.ResetHorizonDB(t, tt.HorizonDB) + q := &Q{tt.HorizonSession()} + + c1 := ContractAssetStatRow{ + ContractID: []byte{1}, + Stat: ContractStat{ + ActiveBalance: "100", + ActiveHolders: 2, + ArchivedBalance: "0", + ArchivedHolders: 0, + }, + } + c2 := ContractAssetStatRow{ + ContractID: []byte{2}, + Stat: ContractStat{ + ActiveBalance: "40", + ActiveHolders: 1, + ArchivedBalance: "0", + ArchivedHolders: 0, + }, + } + c3 := ContractAssetStatRow{ + ContractID: []byte{3}, + Stat: ContractStat{ + ActiveBalance: "900", + ActiveHolders: 12, + ArchivedBalance: "23", + ArchivedHolders: 3, + }, + } + + rows := []ContractAssetStatRow{c1, c2, c3} + tt.Assert.NoError(q.InsertContractAssetStats(tt.Ctx, rows)) + + for _, row := range rows { + result, err := q.GetContractAssetStat(tt.Ctx, row.ContractID) + tt.Assert.NoError(err) + tt.Assert.Equal(result, row) + } + + c2.Stat.ActiveHolders = 3 + c2.Stat.ActiveBalance = "20" + c3.Stat.ArchivedBalance = "900" + c2.Stat.ActiveHolders = 5 + numRows, err := q.UpdateContractAssetStat(tt.Ctx, c2) tt.Assert.NoError(err) - tt.Assert.Len(rows, 3) - sort.Slice(rows, func(i, j int) bool { - return rows[i].AssetCode < rows[j].AssetCode - }) + tt.Assert.Equal(int64(1), numRows) + row, err := q.GetContractAssetStat(tt.Ctx, c2.ContractID) + tt.Assert.NoError(err) + tt.Assert.Equal(c2, row) - for i, row := range rows { - tt.Assert.True(row.Equals(assetStats[i])) + numRows, err = q.RemoveAssetContractStat(tt.Ctx, c3.ContractID) + tt.Assert.NoError(err) + tt.Assert.Equal(int64(1), numRows) + + _, err = q.GetContractAssetStat(tt.Ctx, c3.ContractID) + tt.Assert.Equal(sql.ErrNoRows, err) + + for _, row := range []ContractAssetStatRow{c1, c2} { + result, err := q.GetContractAssetStat(tt.Ctx, row.ContractID) + tt.Assert.NoError(err) + tt.Assert.Equal(result, row) } } @@ -148,7 +190,7 @@ func TestInsertAssetStats(t *testing.T) { defer tt.Finish() test.ResetHorizonDB(t, tt.HorizonDB) q := &Q{tt.HorizonSession()} - tt.Assert.NoError(q.InsertAssetStats(tt.Ctx, []ExpAssetStat{}, 1)) + tt.Assert.NoError(q.InsertAssetStats(tt.Ctx, []ExpAssetStat{})) assetStats := []ExpAssetStat{ { @@ -159,7 +201,6 @@ func TestInsertAssetStats(t *testing.T) { Authorized: 2, AuthorizedToMaintainLiabilities: 3, Unauthorized: 4, - Contracts: 0, }, Balances: ExpAssetStatBalances{ Authorized: "1", @@ -167,7 +208,6 @@ func TestInsertAssetStats(t *testing.T) { Unauthorized: "3", ClaimableBalances: "4", LiquidityPools: "5", - Contracts: "0", }, Amount: "1", NumAccounts: 2, @@ -180,7 +220,6 @@ func TestInsertAssetStats(t *testing.T) { Authorized: 1, AuthorizedToMaintainLiabilities: 3, Unauthorized: 4, - Contracts: 0, }, Balances: ExpAssetStatBalances{ Authorized: "23", @@ -188,13 +227,12 @@ func TestInsertAssetStats(t *testing.T) { Unauthorized: "3", ClaimableBalances: "4", LiquidityPools: "5", - Contracts: "0", }, Amount: "23", NumAccounts: 1, }, } - tt.Assert.NoError(q.InsertAssetStats(tt.Ctx, assetStats, 1)) + tt.Assert.NoError(q.InsertAssetStats(tt.Ctx, assetStats)) for _, assetStat := range assetStats { got, err := q.GetAssetStat(tt.Ctx, assetStat.AssetType, assetStat.AssetCode, assetStat.AssetIssuer) @@ -218,7 +256,6 @@ func TestInsertAssetStat(t *testing.T) { Authorized: 2, AuthorizedToMaintainLiabilities: 3, Unauthorized: 4, - Contracts: 0, }, Balances: ExpAssetStatBalances{ Authorized: "1", @@ -226,7 +263,6 @@ func TestInsertAssetStat(t *testing.T) { Unauthorized: "3", ClaimableBalances: "4", LiquidityPools: "5", - Contracts: "0", }, Amount: "1", NumAccounts: 2, @@ -239,7 +275,6 @@ func TestInsertAssetStat(t *testing.T) { Authorized: 1, AuthorizedToMaintainLiabilities: 3, Unauthorized: 4, - Contracts: 0, }, Balances: ExpAssetStatBalances{ Authorized: "23", @@ -247,7 +282,6 @@ func TestInsertAssetStat(t *testing.T) { Unauthorized: "3", ClaimableBalances: "4", LiquidityPools: "5", - Contracts: "0", }, Amount: "23", NumAccounts: 1, @@ -279,7 +313,6 @@ func TestInsertAssetStatAlreadyExistsError(t *testing.T) { Authorized: 2, AuthorizedToMaintainLiabilities: 3, Unauthorized: 4, - Contracts: 0, }, Balances: ExpAssetStatBalances{ Authorized: "1", @@ -287,7 +320,6 @@ func TestInsertAssetStatAlreadyExistsError(t *testing.T) { Unauthorized: "3", ClaimableBalances: "4", LiquidityPools: "5", - Contracts: "0", }, Amount: "1", NumAccounts: 2, @@ -328,7 +360,6 @@ func TestUpdateAssetStatDoesNotExistsError(t *testing.T) { Authorized: 2, AuthorizedToMaintainLiabilities: 3, Unauthorized: 4, - Contracts: 0, }, Balances: ExpAssetStatBalances{ Authorized: "1", @@ -336,7 +367,6 @@ func TestUpdateAssetStatDoesNotExistsError(t *testing.T) { Unauthorized: "3", ClaimableBalances: "4", LiquidityPools: "5", - Contracts: "0", }, Amount: "1", NumAccounts: 2, @@ -365,7 +395,6 @@ func TestUpdateStat(t *testing.T) { Authorized: 2, AuthorizedToMaintainLiabilities: 3, Unauthorized: 4, - Contracts: 0, }, Balances: ExpAssetStatBalances{ Authorized: "1", @@ -373,7 +402,6 @@ func TestUpdateStat(t *testing.T) { Unauthorized: "3", ClaimableBalances: "4", LiquidityPools: "5", - Contracts: "0", }, Amount: "1", NumAccounts: 2, @@ -388,9 +416,7 @@ func TestUpdateStat(t *testing.T) { tt.Assert.Equal(got, assetStat) assetStat.NumAccounts = 50 - assetStat.Accounts.Contracts = 4 assetStat.Amount = "23" - assetStat.Balances.Contracts = "56" assetStat.SetContractID([32]byte{23}) numChanged, err = q.UpdateAssetStat(tt.Ctx, assetStat) @@ -416,7 +442,6 @@ func TestGetAssetStatDoesNotExist(t *testing.T) { Authorized: 2, AuthorizedToMaintainLiabilities: 3, Unauthorized: 4, - Contracts: 0, }, Balances: ExpAssetStatBalances{ Authorized: "1", @@ -424,7 +449,6 @@ func TestGetAssetStatDoesNotExist(t *testing.T) { Unauthorized: "3", ClaimableBalances: "4", LiquidityPools: "5", - Contracts: "0", }, Amount: "1", NumAccounts: 2, @@ -449,7 +473,6 @@ func TestRemoveAssetStat(t *testing.T) { Authorized: 2, AuthorizedToMaintainLiabilities: 3, Unauthorized: 4, - Contracts: 0, }, Balances: ExpAssetStatBalances{ Authorized: "1", @@ -457,7 +480,6 @@ func TestRemoveAssetStat(t *testing.T) { Unauthorized: "3", ClaimableBalances: "4", LiquidityPools: "5", - Contracts: "0", }, Amount: "1", NumAccounts: 2, @@ -565,123 +587,153 @@ func TestGetAssetStatsOrderValidation(t *testing.T) { tt.Assert.Contains(err.Error(), "invalid page order") } -func reverseAssetStats(a []ExpAssetStat) { - for i := len(a)/2 - 1; i >= 0; i-- { - opp := len(a) - 1 - i - a[i], a[opp] = a[opp], a[i] - } -} - func TestGetAssetStatsFiltersAndCursor(t *testing.T) { tt := test.Start(t) defer tt.Finish() test.ResetHorizonDB(t, tt.HorizonDB) q := &Q{tt.HorizonSession()} - - usdAssetStat := ExpAssetStat{ - AssetType: xdr.AssetTypeAssetTypeCreditAlphanum4, - AssetIssuer: "GBRPYHIL2CI3FNQ4BXLFMNDLFJUNPU2HY3ZMFSHONUCEOASW7QC7OX2H", - AssetCode: "USD", - Accounts: ExpAssetStatAccounts{ - Authorized: 2, - AuthorizedToMaintainLiabilities: 3, - Unauthorized: 4, - Contracts: 0, - }, - Balances: ExpAssetStatBalances{ - Authorized: "1", - AuthorizedToMaintainLiabilities: "2", - Unauthorized: "3", - ClaimableBalances: "0", - LiquidityPools: "0", - Contracts: "0", - }, - Amount: "1", - NumAccounts: 2, + zero := ContractStat{ + ActiveBalance: "0", + ActiveHolders: 0, + ArchivedBalance: "0", + ArchivedHolders: 0, } - etherAssetStat := ExpAssetStat{ - AssetType: xdr.AssetTypeAssetTypeCreditAlphanum12, - AssetIssuer: "GBRPYHIL2CI3FNQ4BXLFMNDLFJUNPU2HY3ZMFSHONUCEOASW7QC7OX2H", - AssetCode: "ETHER", - Accounts: ExpAssetStatAccounts{ - Authorized: 1, - AuthorizedToMaintainLiabilities: 3, - Unauthorized: 4, - Contracts: 0, - }, - Balances: ExpAssetStatBalances{ - Authorized: "23", - AuthorizedToMaintainLiabilities: "2", - Unauthorized: "3", - ClaimableBalances: "0", - LiquidityPools: "0", - Contracts: "0", + usdAssetStat := AssetAndContractStat{ + ExpAssetStat: ExpAssetStat{ + AssetType: xdr.AssetTypeAssetTypeCreditAlphanum4, + AssetIssuer: "GBRPYHIL2CI3FNQ4BXLFMNDLFJUNPU2HY3ZMFSHONUCEOASW7QC7OX2H", + AssetCode: "USD", + Accounts: ExpAssetStatAccounts{ + Authorized: 2, + AuthorizedToMaintainLiabilities: 3, + Unauthorized: 4, + }, + Balances: ExpAssetStatBalances{ + Authorized: "1", + AuthorizedToMaintainLiabilities: "2", + Unauthorized: "3", + ClaimableBalances: "0", + LiquidityPools: "0", + }, + Amount: "1", + NumAccounts: 2, }, - Amount: "23", - NumAccounts: 1, + Contracts: zero, } - otherUSDAssetStat := ExpAssetStat{ - AssetType: xdr.AssetTypeAssetTypeCreditAlphanum4, - AssetIssuer: "GA5WBPYA5Y4WAEHXWR2UKO2UO4BUGHUQ74EUPKON2QHV4WRHOIRNKKH2", - AssetCode: "USD", - Accounts: ExpAssetStatAccounts{ - Authorized: 2, - AuthorizedToMaintainLiabilities: 3, - Unauthorized: 4, - Contracts: 0, + etherAssetStat := AssetAndContractStat{ + ExpAssetStat: ExpAssetStat{ + AssetType: xdr.AssetTypeAssetTypeCreditAlphanum12, + AssetIssuer: "GBRPYHIL2CI3FNQ4BXLFMNDLFJUNPU2HY3ZMFSHONUCEOASW7QC7OX2H", + AssetCode: "ETHER", + Accounts: ExpAssetStatAccounts{ + Authorized: 1, + AuthorizedToMaintainLiabilities: 3, + Unauthorized: 4, + }, + Balances: ExpAssetStatBalances{ + Authorized: "23", + AuthorizedToMaintainLiabilities: "2", + Unauthorized: "3", + ClaimableBalances: "0", + LiquidityPools: "0", + }, + Amount: "23", + NumAccounts: 1, }, - Balances: ExpAssetStatBalances{ - Authorized: "1", - AuthorizedToMaintainLiabilities: "2", - Unauthorized: "3", - ClaimableBalances: "0", - LiquidityPools: "0", - Contracts: "0", + Contracts: zero, + } + otherUSDAssetStat := AssetAndContractStat{ + ExpAssetStat: ExpAssetStat{ + AssetType: xdr.AssetTypeAssetTypeCreditAlphanum4, + AssetIssuer: "GA5WBPYA5Y4WAEHXWR2UKO2UO4BUGHUQ74EUPKON2QHV4WRHOIRNKKH2", + AssetCode: "USD", + Accounts: ExpAssetStatAccounts{ + Authorized: 2, + AuthorizedToMaintainLiabilities: 3, + Unauthorized: 4, + }, + Balances: ExpAssetStatBalances{ + Authorized: "1", + AuthorizedToMaintainLiabilities: "2", + Unauthorized: "3", + ClaimableBalances: "0", + LiquidityPools: "0", + }, + Amount: "1", + NumAccounts: 2, }, - Amount: "1", - NumAccounts: 2, + Contracts: zero, } - eurAssetStat := ExpAssetStat{ - AssetType: xdr.AssetTypeAssetTypeCreditAlphanum4, - AssetIssuer: "GA5WBPYA5Y4WAEHXWR2UKO2UO4BUGHUQ74EUPKON2QHV4WRHOIRNKKH2", - AssetCode: "EUR", - Accounts: ExpAssetStatAccounts{ - Authorized: 3, - AuthorizedToMaintainLiabilities: 2, - Unauthorized: 4, - Contracts: 0, + eurAssetStat := AssetAndContractStat{ + ExpAssetStat: ExpAssetStat{ + AssetType: xdr.AssetTypeAssetTypeCreditAlphanum4, + AssetIssuer: "GA5WBPYA5Y4WAEHXWR2UKO2UO4BUGHUQ74EUPKON2QHV4WRHOIRNKKH2", + AssetCode: "EUR", + Accounts: ExpAssetStatAccounts{ + Authorized: 3, + AuthorizedToMaintainLiabilities: 2, + Unauthorized: 4, + }, + Balances: ExpAssetStatBalances{ + Authorized: "111", + AuthorizedToMaintainLiabilities: "2", + Unauthorized: "3", + ClaimableBalances: "1", + LiquidityPools: "2", + }, + Amount: "111", + NumAccounts: 3, }, - Balances: ExpAssetStatBalances{ - Authorized: "111", - AuthorizedToMaintainLiabilities: "2", - Unauthorized: "3", - ClaimableBalances: "1", - LiquidityPools: "2", - Contracts: "0", + Contracts: ContractStat{ + ActiveBalance: "120", + ActiveHolders: 3, + ArchivedBalance: "90", + ArchivedHolders: 1, }, - Amount: "111", - NumAccounts: 3, } - assetStats := []ExpAssetStat{ + eurAssetStat.SetContractID([32]byte{}) + assetStats := []AssetAndContractStat{ etherAssetStat, eurAssetStat, otherUSDAssetStat, usdAssetStat, } for _, assetStat := range assetStats { - numChanged, err := q.InsertAssetStat(tt.Ctx, assetStat) + numChanged, err := q.InsertAssetStat(tt.Ctx, assetStat.ExpAssetStat) tt.Assert.NoError(err) tt.Assert.Equal(numChanged, int64(1)) + if assetStat.Contracts != zero { + numChanged, err = q.InsertContractAssetStat(tt.Ctx, ContractAssetStatRow{ + ContractID: *assetStat.ContractID, + Stat: assetStat.Contracts, + }) + tt.Assert.NoError(err) + tt.Assert.Equal(numChanged, int64(1)) + } } + // insert contract stat which has no corresponding asset stat row + // to test that it isn't included in the results + numChanged, err := q.InsertContractAssetStat(tt.Ctx, ContractAssetStatRow{ + ContractID: []byte{1}, + Stat: ContractStat{ + ActiveBalance: "400", + ActiveHolders: 30, + ArchivedBalance: "0", + ArchivedHolders: 0, + }, + }) + tt.Assert.NoError(err) + tt.Assert.Equal(numChanged, int64(1)) + for _, testCase := range []struct { name string assetCode string assetIssuer string cursor string order string - expected []ExpAssetStat + expected []AssetAndContractStat }{ { "no filter without cursor", @@ -689,7 +741,7 @@ func TestGetAssetStatsFiltersAndCursor(t *testing.T) { "", "", "asc", - []ExpAssetStat{ + []AssetAndContractStat{ etherAssetStat, eurAssetStat, otherUSDAssetStat, @@ -702,7 +754,7 @@ func TestGetAssetStatsFiltersAndCursor(t *testing.T) { "", "ABC_GA5WBPYA5Y4WAEHXWR2UKO2UO4BUGHUQ74EUPKON2QHV4WRHOIRNKKH2_credit_alphanum4", "asc", - []ExpAssetStat{ + []AssetAndContractStat{ etherAssetStat, eurAssetStat, otherUSDAssetStat, @@ -715,7 +767,7 @@ func TestGetAssetStatsFiltersAndCursor(t *testing.T) { "", "ZZZ_GBRPYHIL2CI3FNQ4BXLFMNDLFJUNPU2HY3ZMFSHONUCEOASW7QC7OX2H_credit_alphanum4", "desc", - []ExpAssetStat{ + []AssetAndContractStat{ usdAssetStat, otherUSDAssetStat, eurAssetStat, @@ -728,7 +780,7 @@ func TestGetAssetStatsFiltersAndCursor(t *testing.T) { "", "ETHER_GBRPYHIL2CI3FNQ4BXLFMNDLFJUNPU2HY3ZMFSHONUCEOASW7QC7OX2H_credit_alphanum12", "asc", - []ExpAssetStat{ + []AssetAndContractStat{ eurAssetStat, otherUSDAssetStat, usdAssetStat, @@ -740,7 +792,7 @@ func TestGetAssetStatsFiltersAndCursor(t *testing.T) { "", "EUR_GA5WBPYA5Y4WAEHXWR2UKO2UO4BUGHUQ74EUPKON2QHV4WRHOIRNKKH2_credit_alphanum4", "desc", - []ExpAssetStat{ + []AssetAndContractStat{ etherAssetStat, }, }, @@ -750,7 +802,7 @@ func TestGetAssetStatsFiltersAndCursor(t *testing.T) { "", "EUR_GBRPYHIL2CI3FNQ4BXLFMNDLFJUNPU2HY3ZMFSHONUCEOASW7QC7OX2H_credit_alphanum4", "desc", - []ExpAssetStat{ + []AssetAndContractStat{ eurAssetStat, etherAssetStat, }, @@ -761,7 +813,7 @@ func TestGetAssetStatsFiltersAndCursor(t *testing.T) { "", "", "asc", - []ExpAssetStat{ + []AssetAndContractStat{ otherUSDAssetStat, usdAssetStat, }, @@ -772,7 +824,7 @@ func TestGetAssetStatsFiltersAndCursor(t *testing.T) { "", "USD_GA5WBPYA5Y4WAEHXWR2UKO2UO4BUGHUQ74EUPKON2QHV4WRHOIRNKKH2_credit_alphanum4", "asc", - []ExpAssetStat{ + []AssetAndContractStat{ usdAssetStat, }, }, @@ -782,7 +834,7 @@ func TestGetAssetStatsFiltersAndCursor(t *testing.T) { "", "USD_GBRPYHIL2CI3FNQ4BXLFMNDLFJUNPU2HY3ZMFSHONUCEOASW7QC7OX2H_credit_alphanum4", "desc", - []ExpAssetStat{ + []AssetAndContractStat{ otherUSDAssetStat, }, }, @@ -792,7 +844,7 @@ func TestGetAssetStatsFiltersAndCursor(t *testing.T) { "GA5WBPYA5Y4WAEHXWR2UKO2UO4BUGHUQ74EUPKON2QHV4WRHOIRNKKH2", "", "asc", - []ExpAssetStat{ + []AssetAndContractStat{ eurAssetStat, otherUSDAssetStat, }, @@ -803,7 +855,7 @@ func TestGetAssetStatsFiltersAndCursor(t *testing.T) { "GA5WBPYA5Y4WAEHXWR2UKO2UO4BUGHUQ74EUPKON2QHV4WRHOIRNKKH2", "EUR_GA5WBPYA5Y4WAEHXWR2UKO2UO4BUGHUQ74EUPKON2QHV4WRHOIRNKKH2_credit_alphanum4", "asc", - []ExpAssetStat{ + []AssetAndContractStat{ otherUSDAssetStat, }, }, @@ -813,7 +865,7 @@ func TestGetAssetStatsFiltersAndCursor(t *testing.T) { "GA5WBPYA5Y4WAEHXWR2UKO2UO4BUGHUQ74EUPKON2QHV4WRHOIRNKKH2", "USD_GA5WBPYA5Y4WAEHXWR2UKO2UO4BUGHUQ74EUPKON2QHV4WRHOIRNKKH2_credit_alphanum4", "desc", - []ExpAssetStat{ + []AssetAndContractStat{ eurAssetStat, }, }, @@ -871,7 +923,7 @@ func TestGetAssetStatsFiltersAndCursor(t *testing.T) { "GA5WBPYA5Y4WAEHXWR2UKO2UO4BUGHUQ74EUPKON2QHV4WRHOIRNKKH2", "", "asc", - []ExpAssetStat{ + []AssetAndContractStat{ otherUSDAssetStat, }, }, @@ -881,7 +933,7 @@ func TestGetAssetStatsFiltersAndCursor(t *testing.T) { "GA5WBPYA5Y4WAEHXWR2UKO2UO4BUGHUQ74EUPKON2QHV4WRHOIRNKKH2", "USC_GA5WBPYA5Y4WAEHXWR2UKO2UO4BUGHUQ74EUPKON2QHV4WRHOIRNKKH2_credit_alphanum4", "asc", - []ExpAssetStat{ + []AssetAndContractStat{ otherUSDAssetStat, }, }, @@ -891,7 +943,7 @@ func TestGetAssetStatsFiltersAndCursor(t *testing.T) { "GA5WBPYA5Y4WAEHXWR2UKO2UO4BUGHUQ74EUPKON2QHV4WRHOIRNKKH2", "USE_GA5WBPYA5Y4WAEHXWR2UKO2UO4BUGHUQ74EUPKON2QHV4WRHOIRNKKH2_credit_alphanum4", "desc", - []ExpAssetStat{ + []AssetAndContractStat{ otherUSDAssetStat, }, }, @@ -929,9 +981,218 @@ func TestGetAssetStatsFiltersAndCursor(t *testing.T) { results, err = q.GetAssetStats(tt.Ctx, testCase.assetCode, testCase.assetIssuer, page) tt.Assert.NoError(err) - reverseAssetStats(results) + slices.Reverse(results) tt.Assert.Equal(testCase.expected, results) } }) } } + +func assertContractAssetBalancesEqual(t *testing.T, balances, otherBalances []ContractAssetBalance) { + assert.Equal(t, len(balances), len(otherBalances)) + + sort.Slice(balances, func(i, j int) bool { + return bytes.Compare(balances[i].KeyHash, balances[j].KeyHash) < 0 + }) + sort.Slice(otherBalances, func(i, j int) bool { + return bytes.Compare(otherBalances[i].KeyHash, otherBalances[j].KeyHash) < 0 + }) + + for i, balance := range balances { + other := otherBalances[i] + assert.Equal(t, balance, other) + } +} + +func TestInsertContractAssetBalances(t *testing.T) { + tt := test.Start(t) + defer tt.Finish() + test.ResetHorizonDB(t, tt.HorizonDB) + + q := &Q{tt.HorizonSession()} + + keyHash := [32]byte{} + contractID := [32]byte{1} + balance := ContractAssetBalance{ + KeyHash: keyHash[:], + ContractID: contractID[:], + Amount: "100", + ExpirationLedger: 10, + } + + otherKeyHash := [32]byte{2} + otherContractID := [32]byte{3} + otherBalance := ContractAssetBalance{ + KeyHash: otherKeyHash[:], + ContractID: otherContractID[:], + Amount: "101", + ExpirationLedger: 11, + } + + tt.Assert.NoError( + q.InsertContractAssetBalances(context.Background(), []ContractAssetBalance{balance, otherBalance}), + ) + + nonExistantKeyHash := [32]byte{4} + balances, err := q.GetContractAssetBalances(context.Background(), []xdr.Hash{keyHash, otherKeyHash, nonExistantKeyHash}) + tt.Assert.NoError(err) + + assertContractAssetBalancesEqual(t, balances, []ContractAssetBalance{balance, otherBalance}) +} + +func TestRemoveContractAssetBalances(t *testing.T) { + tt := test.Start(t) + defer tt.Finish() + test.ResetHorizonDB(t, tt.HorizonDB) + + q := &Q{tt.HorizonSession()} + + keyHash := [32]byte{} + contractID := [32]byte{1} + balance := ContractAssetBalance{ + KeyHash: keyHash[:], + ContractID: contractID[:], + Amount: "100", + ExpirationLedger: 10, + } + + otherKeyHash := [32]byte{2} + otherContractID := [32]byte{3} + otherBalance := ContractAssetBalance{ + KeyHash: otherKeyHash[:], + ContractID: otherContractID[:], + Amount: "101", + ExpirationLedger: 11, + } + + tt.Assert.NoError( + q.InsertContractAssetBalances(context.Background(), []ContractAssetBalance{balance, otherBalance}), + ) + nonExistantKeyHash := xdr.Hash{4} + + tt.Assert.NoError( + q.RemoveContractAssetBalances(context.Background(), []xdr.Hash{nonExistantKeyHash}), + ) + balances, err := q.GetContractAssetBalances(context.Background(), []xdr.Hash{keyHash, otherKeyHash, nonExistantKeyHash}) + tt.Assert.NoError(err) + + assertContractAssetBalancesEqual(t, balances, []ContractAssetBalance{balance, otherBalance}) + + tt.Assert.NoError( + q.RemoveContractAssetBalances(context.Background(), []xdr.Hash{nonExistantKeyHash, otherKeyHash}), + ) + + balances, err = q.GetContractAssetBalances(context.Background(), []xdr.Hash{keyHash, otherKeyHash, nonExistantKeyHash}) + tt.Assert.NoError(err) + + assertContractAssetBalancesEqual(t, balances, []ContractAssetBalance{balance}) +} + +func TestUpdateContractAssetBalanceAmounts(t *testing.T) { + tt := test.Start(t) + defer tt.Finish() + test.ResetHorizonDB(t, tt.HorizonDB) + + q := &Q{tt.HorizonSession()} + + keyHash := [32]byte{} + contractID := [32]byte{1} + balance := ContractAssetBalance{ + KeyHash: keyHash[:], + ContractID: contractID[:], + Amount: "100", + ExpirationLedger: 10, + } + + otherKeyHash := [32]byte{2} + otherContractID := [32]byte{3} + otherBalance := ContractAssetBalance{ + KeyHash: otherKeyHash[:], + ContractID: otherContractID[:], + Amount: "101", + ExpirationLedger: 11, + } + + tt.Assert.NoError( + q.InsertContractAssetBalances(context.Background(), []ContractAssetBalance{balance, otherBalance}), + ) + + nonExistantKeyHash := xdr.Hash{4} + + tt.Assert.NoError( + q.UpdateContractAssetBalanceAmounts( + context.Background(), + []xdr.Hash{otherKeyHash, keyHash, nonExistantKeyHash}, + []string{"1", "2", "3"}, + ), + ) + + balances, err := q.GetContractAssetBalances(context.Background(), []xdr.Hash{keyHash, otherKeyHash}) + tt.Assert.NoError(err) + + balance.Amount = "2" + otherBalance.Amount = "1" + assertContractAssetBalancesEqual(t, balances, []ContractAssetBalance{balance, otherBalance}) +} + +func TestUpdateContractAssetBalanceExpirations(t *testing.T) { + tt := test.Start(t) + defer tt.Finish() + test.ResetHorizonDB(t, tt.HorizonDB) + + q := &Q{tt.HorizonSession()} + + keyHash := [32]byte{} + contractID := [32]byte{1} + balance := ContractAssetBalance{ + KeyHash: keyHash[:], + ContractID: contractID[:], + Amount: "100", + ExpirationLedger: 10, + } + + otherKeyHash := [32]byte{2} + otherContractID := [32]byte{3} + otherBalance := ContractAssetBalance{ + KeyHash: otherKeyHash[:], + ContractID: otherContractID[:], + Amount: "101", + ExpirationLedger: 11, + } + + tt.Assert.NoError( + q.InsertContractAssetBalances(context.Background(), []ContractAssetBalance{balance, otherBalance}), + ) + + balances, err := q.GetContractAssetBalancesExpiringAt(context.Background(), 10) + tt.Assert.NoError(err) + assertContractAssetBalancesEqual(t, balances, []ContractAssetBalance{balance}) + + balances, err = q.GetContractAssetBalancesExpiringAt(context.Background(), 11) + tt.Assert.NoError(err) + assertContractAssetBalancesEqual(t, balances, []ContractAssetBalance{otherBalance}) + + nonExistantKeyHash := xdr.Hash{4} + + tt.Assert.NoError( + q.UpdateContractAssetBalanceExpirations( + context.Background(), + []xdr.Hash{otherKeyHash, keyHash, nonExistantKeyHash}, + []uint32{200, 200, 500}, + ), + ) + + balances, err = q.GetContractAssetBalances(context.Background(), []xdr.Hash{keyHash, otherKeyHash}) + tt.Assert.NoError(err) + balance.ExpirationLedger = 200 + otherBalance.ExpirationLedger = 200 + assertContractAssetBalancesEqual(t, balances, []ContractAssetBalance{balance, otherBalance}) + + balances, err = q.GetContractAssetBalancesExpiringAt(context.Background(), 10) + tt.Assert.NoError(err) + assert.Empty(t, balances) + + balances, err = q.GetContractAssetBalancesExpiringAt(context.Background(), 200) + tt.Assert.NoError(err) + assertContractAssetBalancesEqual(t, balances, []ContractAssetBalance{balance, otherBalance}) +} diff --git a/services/horizon/internal/db2/history/main.go b/services/horizon/internal/db2/history/main.go index c91c7c3a7d..992c1fcaaf 100644 --- a/services/horizon/internal/db2/history/main.go +++ b/services/horizon/internal/db2/history/main.go @@ -364,6 +364,50 @@ type Asset struct { Issuer string `db:"asset_issuer"` } +type ContractStat struct { + ActiveBalance string `json:"balance"` + ActiveHolders int32 `json:"holders"` + ArchivedBalance string `json:"archived_balance"` + ArchivedHolders int32 `json:"archived_holders"` +} + +func (c ContractStat) Value() (driver.Value, error) { + return json.Marshal(c) +} + +func (c *ContractStat) Scan(src interface{}) error { + if src == nil { + c.ActiveBalance = "0" + c.ArchivedBalance = "0" + return nil + } + + source, ok := src.([]byte) + if !ok { + return errors.New("Type assertion .([]byte) failed.") + } + + err := json.Unmarshal(source, &c) + if err != nil { + return err + } + + // Sets zero values for empty balances + if c.ActiveBalance == "" { + c.ActiveBalance = "0" + } + if c.ArchivedBalance == "" { + c.ArchivedBalance = "0" + } + + return nil +} + +type AssetAndContractStat struct { + ExpAssetStat + Contracts ContractStat `db:"contracts"` +} + // ExpAssetStat is a row in the exp_asset_stats table representing the stats per Asset type ExpAssetStat struct { AssetType xdr.AssetType `db:"asset_type"` @@ -393,7 +437,6 @@ type ExpAssetStatAccounts struct { AuthorizedToMaintainLiabilities int32 `json:"authorized_to_maintain_liabilities"` ClaimableBalances int32 `json:"claimable_balances"` LiquidityPools int32 `json:"liquidity_pools"` - Contracts int32 `json:"contracts"` Unauthorized int32 `json:"unauthorized"` } @@ -450,7 +493,6 @@ func (a ExpAssetStatAccounts) Add(b ExpAssetStatAccounts) ExpAssetStatAccounts { ClaimableBalances: a.ClaimableBalances + b.ClaimableBalances, LiquidityPools: a.LiquidityPools + b.LiquidityPools, Unauthorized: a.Unauthorized + b.Unauthorized, - Contracts: a.Contracts + b.Contracts, } } @@ -465,7 +507,6 @@ type ExpAssetStatBalances struct { AuthorizedToMaintainLiabilities string `json:"authorized_to_maintain_liabilities"` ClaimableBalances string `json:"claimable_balances"` LiquidityPools string `json:"liquidity_pools"` - Contracts string `json:"contracts"` Unauthorized string `json:"unauthorized"` } @@ -475,7 +516,6 @@ func (e ExpAssetStatBalances) IsZero() bool { AuthorizedToMaintainLiabilities: "0", ClaimableBalances: "0", LiquidityPools: "0", - Contracts: "0", Unauthorized: "0", } } @@ -511,23 +551,30 @@ func (e *ExpAssetStatBalances) Scan(src interface{}) error { if e.Unauthorized == "" { e.Unauthorized = "0" } - if e.Contracts == "" { - e.Contracts = "0" - } return nil } // QAssetStats defines exp_asset_stats related queries. type QAssetStats interface { - InsertAssetStats(ctx context.Context, stats []ExpAssetStat, batchSize int) error + InsertContractAssetBalances(ctx context.Context, rows []ContractAssetBalance) error + RemoveContractAssetBalances(ctx context.Context, keys []xdr.Hash) error + UpdateContractAssetBalanceAmounts(ctx context.Context, keys []xdr.Hash, amounts []string) error + UpdateContractAssetBalanceExpirations(ctx context.Context, keys []xdr.Hash, expirationLedgers []uint32) error + GetContractAssetBalances(ctx context.Context, keys []xdr.Hash) ([]ContractAssetBalance, error) + GetContractAssetBalancesExpiringAt(ctx context.Context, ledger uint32) ([]ContractAssetBalance, error) + InsertAssetStats(ctx context.Context, stats []ExpAssetStat) error + InsertContractAssetStats(ctx context.Context, rows []ContractAssetStatRow) error InsertAssetStat(ctx context.Context, stat ExpAssetStat) (int64, error) + InsertContractAssetStat(ctx context.Context, row ContractAssetStatRow) (int64, error) UpdateAssetStat(ctx context.Context, stat ExpAssetStat) (int64, error) + UpdateContractAssetStat(ctx context.Context, row ContractAssetStatRow) (int64, error) GetAssetStat(ctx context.Context, assetType xdr.AssetType, assetCode, assetIssuer string) (ExpAssetStat, error) - GetAssetStatByContract(ctx context.Context, contractID [32]byte) (ExpAssetStat, error) - GetAssetStatByContracts(ctx context.Context, contractIDs [][32]byte) ([]ExpAssetStat, error) + GetAssetStatByContract(ctx context.Context, contractID xdr.Hash) (ExpAssetStat, error) + GetContractAssetStat(ctx context.Context, contractID []byte) (ContractAssetStatRow, error) RemoveAssetStat(ctx context.Context, assetType xdr.AssetType, assetCode, assetIssuer string) (int64, error) - GetAssetStats(ctx context.Context, assetCode, assetIssuer string, page db2.PageQuery) ([]ExpAssetStat, error) + RemoveAssetContractStat(ctx context.Context, contractID []byte) (int64, error) + GetAssetStats(ctx context.Context, assetCode, assetIssuer string, page db2.PageQuery) ([]AssetAndContractStat, error) CountTrustLines(ctx context.Context) (int, error) } diff --git a/services/horizon/internal/db2/history/mock_q_asset_stats.go b/services/horizon/internal/db2/history/mock_q_asset_stats.go index 6b4563181c..84927b53ee 100644 --- a/services/horizon/internal/db2/history/mock_q_asset_stats.go +++ b/services/horizon/internal/db2/history/mock_q_asset_stats.go @@ -14,8 +14,63 @@ type MockQAssetStats struct { mock.Mock } -func (m *MockQAssetStats) InsertAssetStats(ctx context.Context, assetStats []ExpAssetStat, batchSize int) error { - a := m.Called(ctx, assetStats, batchSize) +func (m *MockQAssetStats) InsertContractAssetBalances(ctx context.Context, rows []ContractAssetBalance) error { + a := m.Called(ctx, rows) + return a.Error(0) +} + +func (m *MockQAssetStats) RemoveContractAssetBalances(ctx context.Context, keys []xdr.Hash) error { + a := m.Called(ctx, keys) + return a.Error(0) +} + +func (m *MockQAssetStats) UpdateContractAssetBalanceAmounts(ctx context.Context, keys []xdr.Hash, amounts []string) error { + a := m.Called(ctx, keys, amounts) + return a.Error(0) +} + +func (m *MockQAssetStats) UpdateContractAssetBalanceExpirations(ctx context.Context, keys []xdr.Hash, expirationLedgers []uint32) error { + a := m.Called(ctx, keys, expirationLedgers) + return a.Error(0) +} + +func (m *MockQAssetStats) GetContractAssetBalances(ctx context.Context, keys []xdr.Hash) ([]ContractAssetBalance, error) { + a := m.Called(ctx, keys) + return a.Get(0).([]ContractAssetBalance), a.Error(1) +} + +func (m *MockQAssetStats) GetContractAssetBalancesExpiringAt(ctx context.Context, ledger uint32) ([]ContractAssetBalance, error) { + a := m.Called(ctx, ledger) + return a.Get(0).([]ContractAssetBalance), a.Error(1) +} + +func (m *MockQAssetStats) InsertContractAssetStats(ctx context.Context, rows []ContractAssetStatRow) error { + a := m.Called(ctx, rows) + return a.Error(0) +} + +func (m *MockQAssetStats) InsertContractAssetStat(ctx context.Context, row ContractAssetStatRow) (int64, error) { + a := m.Called(ctx, row) + return a.Get(0).(int64), a.Error(1) +} + +func (m *MockQAssetStats) UpdateContractAssetStat(ctx context.Context, row ContractAssetStatRow) (int64, error) { + a := m.Called(ctx, row) + return a.Get(0).(int64), a.Error(1) +} + +func (m *MockQAssetStats) GetContractAssetStat(ctx context.Context, contractID []byte) (ContractAssetStatRow, error) { + a := m.Called(ctx, contractID) + return a.Get(0).(ContractAssetStatRow), a.Error(1) +} + +func (m *MockQAssetStats) RemoveAssetContractStat(ctx context.Context, contractID []byte) (int64, error) { + a := m.Called(ctx, contractID) + return a.Get(0).(int64), a.Error(1) +} + +func (m *MockQAssetStats) InsertAssetStats(ctx context.Context, assetStats []ExpAssetStat) error { + a := m.Called(ctx, assetStats) return a.Error(0) } @@ -34,7 +89,7 @@ func (m *MockQAssetStats) GetAssetStat(ctx context.Context, assetType xdr.AssetT return a.Get(0).(ExpAssetStat), a.Error(1) } -func (m *MockQAssetStats) GetAssetStatByContract(ctx context.Context, contractID [32]byte) (ExpAssetStat, error) { +func (m *MockQAssetStats) GetAssetStatByContract(ctx context.Context, contractID xdr.Hash) (ExpAssetStat, error) { a := m.Called(ctx, contractID) return a.Get(0).(ExpAssetStat), a.Error(1) } @@ -44,12 +99,12 @@ func (m *MockQAssetStats) RemoveAssetStat(ctx context.Context, assetType xdr.Ass return a.Get(0).(int64), a.Error(1) } -func (m *MockQAssetStats) GetAssetStats(ctx context.Context, assetCode, assetIssuer string, page db2.PageQuery) ([]ExpAssetStat, error) { +func (m *MockQAssetStats) GetAssetStats(ctx context.Context, assetCode, assetIssuer string, page db2.PageQuery) ([]AssetAndContractStat, error) { a := m.Called(ctx, assetCode, assetIssuer, page) - return a.Get(0).([]ExpAssetStat), a.Error(1) + return a.Get(0).([]AssetAndContractStat), a.Error(1) } -func (m *MockQAssetStats) GetAssetStatByContracts(ctx context.Context, contractIDs [][32]byte) ([]ExpAssetStat, error) { +func (m *MockQAssetStats) GetAssetStatByContracts(ctx context.Context, contractIDs []xdr.Hash) ([]ExpAssetStat, error) { a := m.Called(ctx, contractIDs) return a.Get(0).([]ExpAssetStat), a.Error(1) } diff --git a/services/horizon/internal/db2/schema/bindata.go b/services/horizon/internal/db2/schema/bindata.go index bf2121170b..4883858ef5 100644 --- a/services/horizon/internal/db2/schema/bindata.go +++ b/services/horizon/internal/db2/schema/bindata.go @@ -62,6 +62,7 @@ // migrations/63_add_contract_id_to_asset_stats.sql (153B) // migrations/64_add_payment_flag_history_ops.sql (145B) // migrations/65_drop_payment_index.sql (260B) +// migrations/66_contract_asset_stats.sql (583B) // migrations/6_create_assets_table.sql (366B) // migrations/7_modify_trades_table.sql (2.303kB) // migrations/8_add_aggregators.sql (907B) @@ -1375,6 +1376,26 @@ func migrations65_drop_payment_indexSql() (*asset, error) { return a, nil } +var _migrations66_contract_asset_statsSql = []byte("\x1f\x8b\x08\x00\x00\x00\x00\x00\x00\xff\x7c\x91\x41\x6b\xf2\x40\x10\x86\xef\xf9\x15\x2f\x9e\x94\xcf\xc0\xd7\x7a\xa9\x78\x8a\x35\x14\x5b\x9b\x48\x8c\x50\x4f\xcb\x66\x33\xc6\xa1\xba\x91\xdd\x91\xd6\x7f\x5f\x24\x44\x0b\x56\xf7\x3a\xcf\xcc\xf3\xce\x4e\x18\xe2\xdf\x8e\x2b\xa7\x85\xb0\xdc\x07\xcf\x59\x1c\xe5\x31\xf2\x68\x3c\x8b\x61\x6a\x2b\x4e\x1b\x51\xda\x7b\x12\xe5\x45\x8b\x47\x37\xc0\xe9\x9d\x6b\x5c\x62\xbc\xca\xe3\x08\xf3\x6c\xfa\x1e\x65\x2b\xbc\xc5\xab\x7e\xc3\x9c\x1a\xd0\xbc\xd7\x45\x9a\x8c\x91\xa4\x39\x92\xe5\x6c\x16\xf4\x46\xc1\x5d\x55\xa1\xb7\xda\x1a\x3a\xdb\x3e\xe9\xa8\x36\xda\x6f\x6e\xaa\x9a\xb6\xeb\x50\xad\xb1\xc5\x76\xf5\xc1\xb6\x99\xec\x61\x47\x8e\x4d\x77\x30\xec\xff\xef\x5d\x48\x84\x21\x06\x43\x94\x5c\xb1\x78\xb0\x87\x3f\xac\xd7\x6c\x98\xac\x60\x5d\x3b\x68\x3c\x3c\x3e\xa1\x60\x01\x5b\xa1\x8a\x5c\x33\x9a\xbe\xf7\xec\xb4\x70\x6d\xd5\x96\xca\x8a\x5c\x5b\xfe\x73\xeb\x69\x32\x89\x3f\xd0\xb9\xb1\xb6\x2a\x8e\xea\x32\xaf\x83\x34\xb9\xf9\x41\xcb\xc5\x34\x79\x41\x21\x8e\x08\xdd\xab\x0c\x27\xe3\xef\x0b\x4f\xea\x2f\x1b\x4c\xb2\x74\x7e\xef\xc2\x46\x7b\xa3\x4b\x1a\xdd\x01\xcf\xfa\x96\xfd\x09\x00\x00\xff\xff\x78\xde\xe2\x11\x47\x02\x00\x00") + +func migrations66_contract_asset_statsSqlBytes() ([]byte, error) { + return bindataRead( + _migrations66_contract_asset_statsSql, + "migrations/66_contract_asset_stats.sql", + ) +} + +func migrations66_contract_asset_statsSql() (*asset, error) { + bytes, err := migrations66_contract_asset_statsSqlBytes() + if err != nil { + return nil, err + } + + info := bindataFileInfo{name: "migrations/66_contract_asset_stats.sql", size: 0, mode: os.FileMode(0), modTime: time.Unix(0, 0)} + a := &asset{bytes: bytes, info: info, digest: [32]uint8{0x2a, 0x9a, 0xab, 0xd3, 0x1d, 0x20, 0x82, 0x82, 0x64, 0xb1, 0x7e, 0x9f, 0xcb, 0xb5, 0xe6, 0x2b, 0xc2, 0x72, 0x8e, 0x1e, 0x58, 0x23, 0xc, 0xfd, 0x25, 0xb3, 0xe7, 0x9, 0x89, 0x43, 0x3e, 0x15}} + return a, nil +} + var _migrations6_create_assets_tableSql = []byte("\x1f\x8b\x08\x00\x00\x00\x00\x00\x00\xff\x6c\x90\x3d\x4f\xc3\x30\x18\x84\x77\xff\x8a\x1b\x1d\x91\x0e\x20\xe8\x92\xc9\x34\x16\x58\x18\xa7\xb8\x31\xa2\x53\xe5\x26\x16\x78\x80\x54\xb6\x11\xca\xbf\x47\xaa\x28\xf9\x50\xe6\x7b\xf4\xbc\xef\xdd\x6a\x85\xab\x4f\xff\x1e\x6c\x72\x30\x27\xb2\xd1\x9c\xd5\x1c\x35\xbb\x97\x1c\x1f\x3e\xa6\x2e\xf4\x07\x1b\xa3\x4b\x11\x94\x00\x80\x6f\xb1\xe3\x5a\x30\x89\xad\x16\xcf\x4c\xef\xf1\xc4\xf7\xc8\xcf\xd9\x19\x3c\xa4\xfe\xe4\xf0\xca\xf4\xe6\x91\x69\xba\xbe\xcd\xa0\xaa\x1a\xca\x48\x39\x86\x9a\xae\x1d\xa0\xeb\x9b\x65\xc8\xc7\xf8\xed\xc2\x3f\x76\xb7\x9e\x63\x46\x89\x17\xc3\xe9\xa0\xcc\x47\x3f\xe4\x13\x4b\x46\xb2\x82\x5c\xfa\x09\x55\xf2\xb7\xbf\xf8\xd8\x5f\xee\x54\x6a\x5e\xd9\xec\x84\x7a\xc0\x31\x05\xe7\x40\x27\xb6\x82\x90\xf1\x74\x65\xf7\xf3\x45\x4a\x5d\x6d\x97\xa7\x6b\x6c\x6c\x6c\xeb\x8a\xdf\x00\x00\x00\xff\xff\xfb\x53\x3e\x81\x6e\x01\x00\x00") func migrations6_create_assets_tableSqlBytes() ([]byte, error) { @@ -1628,6 +1649,7 @@ var _bindata = map[string]func() (*asset, error){ "migrations/63_add_contract_id_to_asset_stats.sql": migrations63_add_contract_id_to_asset_statsSql, "migrations/64_add_payment_flag_history_ops.sql": migrations64_add_payment_flag_history_opsSql, "migrations/65_drop_payment_index.sql": migrations65_drop_payment_indexSql, + "migrations/66_contract_asset_stats.sql": migrations66_contract_asset_statsSql, "migrations/6_create_assets_table.sql": migrations6_create_assets_tableSql, "migrations/7_modify_trades_table.sql": migrations7_modify_trades_tableSql, "migrations/8_add_aggregators.sql": migrations8_add_aggregatorsSql, @@ -1741,6 +1763,7 @@ var _bintree = &bintree{nil, map[string]*bintree{ "63_add_contract_id_to_asset_stats.sql": {migrations63_add_contract_id_to_asset_statsSql, map[string]*bintree{}}, "64_add_payment_flag_history_ops.sql": {migrations64_add_payment_flag_history_opsSql, map[string]*bintree{}}, "65_drop_payment_index.sql": {migrations65_drop_payment_indexSql, map[string]*bintree{}}, + "66_contract_asset_stats.sql": {migrations66_contract_asset_statsSql, map[string]*bintree{}}, "6_create_assets_table.sql": {migrations6_create_assets_tableSql, map[string]*bintree{}}, "7_modify_trades_table.sql": {migrations7_modify_trades_tableSql, map[string]*bintree{}}, "8_add_aggregators.sql": {migrations8_add_aggregatorsSql, map[string]*bintree{}}, diff --git a/services/horizon/internal/db2/schema/migrations/66_contract_asset_stats.sql b/services/horizon/internal/db2/schema/migrations/66_contract_asset_stats.sql new file mode 100644 index 0000000000..c36b88dc71 --- /dev/null +++ b/services/horizon/internal/db2/schema/migrations/66_contract_asset_stats.sql @@ -0,0 +1,18 @@ +-- +migrate Up +CREATE TABLE contract_asset_stats ( + contract_id BYTEA PRIMARY KEY, + stat JSONB NOT NULL +); + +CREATE TABLE contract_asset_balances ( + key_hash BYTEA PRIMARY KEY, + asset_contract_id BYTEA NOT NULL, + amount numeric(39,0) NOT NULL, -- 39 digits is sufficient for a 128 bit integer + expiration_ledger integer NOT NULL +); + +CREATE INDEX "contract_asset_balances_by_expiration" ON contract_asset_balances USING btree (expiration_ledger); + +-- +migrate Down +DROP TABLE contract_asset_stats cascade; +DROP TABLE contract_asset_balances cascade; \ No newline at end of file diff --git a/services/horizon/internal/ingest/main.go b/services/horizon/internal/ingest/main.go index dbc586e8ff..aeb137d82a 100644 --- a/services/horizon/internal/ingest/main.go +++ b/services/horizon/internal/ingest/main.go @@ -58,7 +58,9 @@ const ( // claimable balances for claimant queries. // - 17: Add contract_id column to exp_asset_stats table which is derived by ingesting // contract data ledger entries. - CurrentVersion = 17 + // - 18: Ingest contract asset balances so we can keep track of expired / restore asset + // balances for asset stats. + CurrentVersion = 18 // MaxDBConnections is the size of the postgres connection pool dedicated to Horizon ingestion: // * Ledger ingestion, diff --git a/services/horizon/internal/ingest/processor_runner.go b/services/horizon/internal/ingest/processor_runner.go index 41264ad262..48e1fe0216 100644 --- a/services/horizon/internal/ingest/processor_runner.go +++ b/services/horizon/internal/ingest/processor_runner.go @@ -123,7 +123,7 @@ func buildChangeProcessor( processors.NewAccountDataProcessor(historyQ), processors.NewAccountsProcessor(historyQ), processors.NewOffersProcessor(historyQ, ledgerSequence), - processors.NewAssetStatsProcessor(historyQ, networkPassphrase, useLedgerCache), + processors.NewAssetStatsProcessor(historyQ, networkPassphrase, source == historyArchiveSource, ledgerSequence), processors.NewSignersProcessor(historyQ, useLedgerCache), processors.NewTrustLinesProcessor(historyQ), processors.NewClaimableBalancesChangeProcessor(historyQ), diff --git a/services/horizon/internal/ingest/processor_runner_test.go b/services/horizon/internal/ingest/processor_runner_test.go index 507ba64da7..d48257a88f 100644 --- a/services/horizon/internal/ingest/processor_runner_test.go +++ b/services/horizon/internal/ingest/processor_runner_test.go @@ -202,8 +202,8 @@ func TestProcessorRunnerBuildChangeProcessor(t *testing.T) { assert.IsType(t, &processors.AccountsProcessor{}, processor.processors[2]) assert.IsType(t, &processors.OffersProcessor{}, processor.processors[3]) assert.IsType(t, &processors.AssetStatsProcessor{}, processor.processors[4]) - assert.True(t, reflect.ValueOf(processor.processors[4]). - Elem().FieldByName("useLedgerEntryCache").Bool()) + assert.False(t, reflect.ValueOf(processor.processors[4]). + Elem().FieldByName("ingestFromHistoryArchive").Bool()) assert.IsType(t, &processors.SignersProcessor{}, processor.processors[5]) assert.True(t, reflect.ValueOf(processor.processors[5]). Elem().FieldByName("useLedgerEntryCache").Bool()) @@ -223,8 +223,8 @@ func TestProcessorRunnerBuildChangeProcessor(t *testing.T) { assert.IsType(t, &processors.AccountsProcessor{}, processor.processors[2]) assert.IsType(t, &processors.OffersProcessor{}, processor.processors[3]) assert.IsType(t, &processors.AssetStatsProcessor{}, processor.processors[4]) - assert.False(t, reflect.ValueOf(processor.processors[4]). - Elem().FieldByName("useLedgerEntryCache").Bool()) + assert.True(t, reflect.ValueOf(processor.processors[4]). + Elem().FieldByName("ingestFromHistoryArchive").Bool()) assert.IsType(t, &processors.SignersProcessor{}, processor.processors[5]) assert.False(t, reflect.ValueOf(processor.processors[5]). Elem().FieldByName("useLedgerEntryCache").Bool()) @@ -283,6 +283,7 @@ func TestProcessorRunnerWithFilterEnabled(t *testing.T) { LedgerHeader: xdr.LedgerHeaderHistoryEntry{ Header: xdr.LedgerHeader{ BucketListHash: xdr.Hash([32]byte{0, 1, 2}), + LedgerSeq: 23, }, }, }, @@ -319,6 +320,17 @@ func TestProcessorRunnerWithFilterEnabled(t *testing.T) { q.MockQLedgers.On("InsertLedger", ctx, ledger.V0.LedgerHeader, 0, 0, 0, 0, CurrentVersion). Return(int64(1), nil).Once() + q.MockQAssetStats.On("RemoveContractAssetBalances", ctx, []xdr.Hash(nil)). + Return(nil).Once() + q.MockQAssetStats.On("UpdateContractAssetBalanceAmounts", ctx, []xdr.Hash{}, []string{}). + Return(nil).Once() + q.MockQAssetStats.On("InsertContractAssetBalances", ctx, []history.ContractAssetBalance(nil)). + Return(nil).Once() + q.MockQAssetStats.On("UpdateContractAssetBalanceExpirations", ctx, []xdr.Hash{}, []uint32{}). + Return(nil).Once() + q.MockQAssetStats.On("GetContractAssetBalancesExpiringAt", ctx, uint32(22)). + Return([]history.ContractAssetBalance{}, nil).Once() + runner := ProcessorRunner{ ctx: ctx, config: config, @@ -346,6 +358,7 @@ func TestProcessorRunnerRunAllProcessorsOnLedger(t *testing.T) { LedgerHeader: xdr.LedgerHeaderHistoryEntry{ Header: xdr.LedgerHeader{ BucketListHash: xdr.Hash([32]byte{0, 1, 2}), + LedgerSeq: 23, }, }, }, @@ -375,6 +388,17 @@ func TestProcessorRunnerRunAllProcessorsOnLedger(t *testing.T) { q.MockQLedgers.On("InsertLedger", ctx, ledger.V0.LedgerHeader, 0, 0, 0, 0, CurrentVersion). Return(int64(1), nil).Once() + q.MockQAssetStats.On("RemoveContractAssetBalances", ctx, []xdr.Hash(nil)). + Return(nil).Once() + q.MockQAssetStats.On("UpdateContractAssetBalanceAmounts", ctx, []xdr.Hash{}, []string{}). + Return(nil).Once() + q.MockQAssetStats.On("InsertContractAssetBalances", ctx, []history.ContractAssetBalance(nil)). + Return(nil).Once() + q.MockQAssetStats.On("UpdateContractAssetBalanceExpirations", ctx, []xdr.Hash{}, []uint32{}). + Return(nil).Once() + q.MockQAssetStats.On("GetContractAssetBalancesExpiringAt", ctx, uint32(22)). + Return([]history.ContractAssetBalance{}, nil).Once() + runner := ProcessorRunner{ ctx: ctx, config: config, diff --git a/services/horizon/internal/ingest/processors/asset_stats_processor.go b/services/horizon/internal/ingest/processors/asset_stats_processor.go index 32c9733b1c..c3da42b730 100644 --- a/services/horizon/internal/ingest/processors/asset_stats_processor.go +++ b/services/horizon/internal/ingest/processors/asset_stats_processor.go @@ -4,6 +4,7 @@ import ( "context" "database/sql" "encoding/hex" + "fmt" "math/big" "github.com/stellar/go/ingest" @@ -13,116 +14,319 @@ import ( ) type AssetStatsProcessor struct { - assetStatsQ history.QAssetStats - cache *ingest.ChangeCompactor - assetStatSet AssetStatSet - useLedgerEntryCache bool - networkPassphrase string + assetStatsQ history.QAssetStats + cache *ingest.ChangeCompactor + currentLedger uint32 + removedExpirationEntries map[xdr.Hash]uint32 + createdExpirationEntries map[xdr.Hash]uint32 + updatedExpirationEntries map[xdr.Hash][2]uint32 + ingestFromHistoryArchive bool + networkPassphrase string } // NewAssetStatsProcessor constructs a new AssetStatsProcessor instance. -// If useLedgerEntryCache is false we don't use ledger cache and we just -// add trust lines to assetStatSet, then we insert all the stats in one -// insert query. This is done to make history buckets processing faster -// (batch inserting). func NewAssetStatsProcessor( assetStatsQ history.QAssetStats, networkPassphrase string, - useLedgerEntryCache bool, + ingestFromHistoryArchive bool, + currentLedger uint32, ) *AssetStatsProcessor { p := &AssetStatsProcessor{ - assetStatsQ: assetStatsQ, - useLedgerEntryCache: useLedgerEntryCache, - networkPassphrase: networkPassphrase, + currentLedger: currentLedger, + assetStatsQ: assetStatsQ, + ingestFromHistoryArchive: ingestFromHistoryArchive, + networkPassphrase: networkPassphrase, + cache: ingest.NewChangeCompactor(), + removedExpirationEntries: map[xdr.Hash]uint32{}, + createdExpirationEntries: map[xdr.Hash]uint32{}, + updatedExpirationEntries: map[xdr.Hash][2]uint32{}, } - p.reset() return p } -func (p *AssetStatsProcessor) reset() { - p.cache = ingest.NewChangeCompactor() - p.assetStatSet = NewAssetStatSet(p.networkPassphrase) -} - func (p *AssetStatsProcessor) ProcessChange(ctx context.Context, change ingest.Change) error { if change.Type != xdr.LedgerEntryTypeLiquidityPool && change.Type != xdr.LedgerEntryTypeClaimableBalance && change.Type != xdr.LedgerEntryTypeTrustline && - change.Type != xdr.LedgerEntryTypeContractData { + change.Type != xdr.LedgerEntryTypeContractData && + change.Type != xdr.LedgerEntryTypeTtl { return nil } - if p.useLedgerEntryCache { - return p.addToCache(ctx, change) - } - if change.Pre != nil || change.Post == nil { - return errors.New("AssetStatsProcessor is in insert only mode") - } - - switch change.Type { - case xdr.LedgerEntryTypeLiquidityPool: - return p.assetStatSet.AddLiquidityPool(change) - case xdr.LedgerEntryTypeClaimableBalance: - return p.assetStatSet.AddClaimableBalance(change) - case xdr.LedgerEntryTypeTrustline: - return p.assetStatSet.AddTrustline(change) - case xdr.LedgerEntryTypeContractData: - return p.assetStatSet.AddContractData(change) - default: - return nil + // only ingest contract data entries which could be relevant to + // asset stats + if change.Type == xdr.LedgerEntryTypeContractData { + ledgerEntry := change.Post + if ledgerEntry == nil { + ledgerEntry = change.Pre + } + asset := AssetFromContractData(*ledgerEntry, p.networkPassphrase) + _, _, balanceFound := ContractBalanceFromContractData(*ledgerEntry, p.networkPassphrase) + if asset == nil && !balanceFound { + return nil + } } -} - -func (p *AssetStatsProcessor) addToCache(ctx context.Context, change ingest.Change) error { - err := p.cache.AddChange(change) - if err != nil { + if err := p.cache.AddChange(change); err != nil { return errors.Wrap(err, "error adding to ledgerCache") } + return nil +} - if p.cache.Size() > maxBatchSize { - err = p.Commit(ctx) - if err != nil { - return errors.Wrap(err, "error in Commit") +func (p *AssetStatsProcessor) addExpirationChange(change ingest.Change) error { + switch { + case change.Pre == nil && change.Post != nil: // created + post := change.Post.Data.MustTtl() + p.createdExpirationEntries[post.KeyHash] = uint32(post.LiveUntilLedgerSeq) + case change.Pre != nil && change.Post == nil: // removed + pre := change.Pre.Data.MustTtl() + p.removedExpirationEntries[pre.KeyHash] = uint32(pre.LiveUntilLedgerSeq) + case change.Pre != nil && change.Post != nil: // updated + pre := change.Pre.Data.MustTtl() + post := change.Post.Data.MustTtl() + // it's unclear if core could emit a ledger entry change where the + // expiration ledger remains the same + if pre.LiveUntilLedgerSeq == post.LiveUntilLedgerSeq { + return nil + } + // but we expect that the expiration ledger will never decrease + if pre.LiveUntilLedgerSeq > post.LiveUntilLedgerSeq { + return errors.Errorf( + "unexpected change in expiration ledger Pre: %v Post: %v", + pre.LiveUntilLedgerSeq, + post.LiveUntilLedgerSeq, + ) } - p.reset() + // also the new expiration ledger must always be greater than or equal + // to the current ledger + if uint32(post.LiveUntilLedgerSeq) < p.currentLedger { + return errors.Errorf( + "post expiration ledger is less than current ledger."+ + " Pre: %v Post: %v current ledger: %v", + pre.LiveUntilLedgerSeq, + post.LiveUntilLedgerSeq, + p.currentLedger, + ) + } + p.updatedExpirationEntries[pre.KeyHash] = [2]uint32{ + uint32(pre.LiveUntilLedgerSeq), + uint32(post.LiveUntilLedgerSeq), + } + default: + return errors.Errorf("unexpected change Pre: %v Post: %v", change.Pre, change.Post) } return nil } func (p *AssetStatsProcessor) Commit(ctx context.Context) error { - if !p.useLedgerEntryCache { - assetStatsDeltas, err := p.assetStatSet.AllFromSnapshot() - if err != nil { - return err - } - if len(assetStatsDeltas) == 0 { - return nil - } - - return p.assetStatsQ.InsertAssetStats(ctx, assetStatsDeltas, maxBatchSize) - } + assetStatSet := NewAssetStatSet() changes := p.cache.GetChanges() + var contractDataChanges []ingest.Change for _, change := range changes { var err error switch change.Type { case xdr.LedgerEntryTypeLiquidityPool: - err = p.assetStatSet.AddLiquidityPool(change) + err = assetStatSet.AddLiquidityPool(change) case xdr.LedgerEntryTypeClaimableBalance: - err = p.assetStatSet.AddClaimableBalance(change) + err = assetStatSet.AddClaimableBalance(change) case xdr.LedgerEntryTypeTrustline: - err = p.assetStatSet.AddTrustline(change) + err = assetStatSet.AddTrustline(change) case xdr.LedgerEntryTypeContractData: - err = p.assetStatSet.AddContractData(change) + contractDataChanges = append(contractDataChanges, change) + case xdr.LedgerEntryTypeTtl: + err = p.addExpirationChange(change) default: return errors.Errorf("Change type %v is unexpected", change.Type) } - if err != nil { return errors.Wrap(err, "Error adjusting asset stat") } } - assetStatsDeltas, contractToAsset, contractAssetStats := p.assetStatSet.All() + contractAssetStatSet := NewContractAssetStatSet( + p.assetStatsQ, + p.networkPassphrase, + p.removedExpirationEntries, + p.createdExpirationEntries, + p.updatedExpirationEntries, + p.currentLedger, + ) + for _, change := range contractDataChanges { + if err := contractAssetStatSet.AddContractData(ctx, change); err != nil { + return errors.Wrap(err, "Error ingesting contract data") + } + } + + return p.updateDB(ctx, assetStatSet, contractAssetStatSet) +} + +func (p *AssetStatsProcessor) updateDB( + ctx context.Context, + assetStatSet AssetStatSet, + contractAssetStatSet *ContractAssetStatSet, +) error { + if p.ingestFromHistoryArchive { + // When ingesting from the history archives we can take advantage of the fact + // that there are only created ledger entries. We don't need to execute any + // updates or removals on the asset stats tables. And we can also skip + // ingesting restored contract balances and expired contract balances. + assetStatsDeltas := assetStatSet.All() + if len(assetStatsDeltas) > 0 { + var err error + assetStatsDeltas, err = IncludeContractIDsInAssetStats( + p.networkPassphrase, + assetStatsDeltas, + contractAssetStatSet.contractToAsset, + ) + if err != nil { + return errors.Wrap(err, "Error extracting asset stat rows") + } + if err := p.assetStatsQ.InsertAssetStats(ctx, assetStatsDeltas); err != nil { + return errors.Wrap(err, "Error inserting asset stats") + } + } + + if rows := contractAssetStatSet.GetContractStats(); len(rows) > 0 { + if err := p.assetStatsQ.InsertContractAssetStats(ctx, rows); err != nil { + return errors.Wrap(err, "Error inserting asset contract stats") + } + } + + if len(contractAssetStatSet.createdBalances) > 0 { + if err := p.assetStatsQ.InsertContractAssetBalances(ctx, contractAssetStatSet.createdBalances); err != nil { + return errors.Wrap(err, "Error inserting asset contract stats") + } + } + return nil + } + + assetStatsDeltas := assetStatSet.All() + + if err := p.updateAssetStats(ctx, assetStatsDeltas, contractAssetStatSet.contractToAsset); err != nil { + return err + } + if err := p.updateContractIDs(ctx, contractAssetStatSet.contractToAsset); err != nil { + return err + } + + if err := p.assetStatsQ.RemoveContractAssetBalances(ctx, contractAssetStatSet.removedBalances); err != nil { + return errors.Wrap(err, "Error removing contract asset balances") + } + + if err := p.updateContractAssetBalanceAmounts(ctx, contractAssetStatSet.updatedBalances); err != nil { + return err + } + + if err := p.assetStatsQ.InsertContractAssetBalances(ctx, contractAssetStatSet.createdBalances); err != nil { + return errors.Wrap(err, "Error inserting contract asset balances") + } + + if err := contractAssetStatSet.ingestRestoredBalances(ctx); err != nil { + return err + } + + if err := p.updateContractAssetBalanceExpirations(ctx); err != nil { + return err + } + + if err := contractAssetStatSet.ingestExpiredBalances(ctx); err != nil { + return err + } + + return p.updateContractAssetStats(ctx, contractAssetStatSet.contractAssetStats) +} + +func (p *AssetStatsProcessor) updateContractAssetBalanceAmounts(ctx context.Context, updatedBalances map[xdr.Hash]*big.Int) error { + keys := make([]xdr.Hash, 0, len(updatedBalances)) + amounts := make([]string, 0, len(updatedBalances)) + for key, amount := range updatedBalances { + keys = append(keys, key) + amounts = append(amounts, amount.String()) + } + if err := p.assetStatsQ.UpdateContractAssetBalanceAmounts(ctx, keys, amounts); err != nil { + return errors.Wrap(err, "Error updating contract asset balance amounts") + } + return nil +} + +func (p *AssetStatsProcessor) updateContractAssetBalanceExpirations(ctx context.Context) error { + keys := make([]xdr.Hash, 0, len(p.updatedExpirationEntries)) + expirationLedgers := make([]uint32, 0, len(p.updatedExpirationEntries)) + for key, update := range p.updatedExpirationEntries { + keys = append(keys, key) + expirationLedgers = append(expirationLedgers, update[1]) + } + if err := p.assetStatsQ.UpdateContractAssetBalanceExpirations(ctx, keys, expirationLedgers); err != nil { + return errors.Wrap(err, "Error updating contract asset balance expirations") + } + return nil +} + +func IncludeContractIDsInAssetStats( + networkPassphrase string, + assetStatsDeltas []history.ExpAssetStat, + contractToAsset map[xdr.Hash]*xdr.Asset, +) ([]history.ExpAssetStat, error) { + included := map[xdr.Hash]bool{} + // modify the asset stat row to update the contract_id column whenever we encounter a + // contract data ledger entry with the Stellar asset metadata. + for i, assetStatDelta := range assetStatsDeltas { + // asset stats only supports non-native assets + asset := xdr.MustNewCreditAsset(assetStatDelta.AssetCode, assetStatDelta.AssetIssuer) + contractID, err := asset.ContractID(networkPassphrase) + if err != nil { + return nil, errors.Wrap(err, "cannot compute contract id for asset") + } + if asset, ok := contractToAsset[contractID]; ok && asset == nil { + return nil, ingest.NewStateError(fmt.Errorf( + "unexpected contract data removal in history archives: %s", + hex.EncodeToString(contractID[:]), + )) + } else if ok { + assetStatDelta.SetContractID(contractID) + included[contractID] = true + } + + assetStatsDeltas[i] = assetStatDelta + } + + // There is also a corner case where a Stellar Asset contract is initialized before there exists any + // trustlines / claimable balances for the Stellar Asset. In this case, when ingesting contract data + // ledger entries, there will be no existing asset stat row. We handle this case by inserting a row + // with zero stats just so we can populate the contract id. + for contractID, asset := range contractToAsset { + if included[contractID] { + continue + } + if asset == nil { + return nil, ingest.NewStateError(fmt.Errorf( + "unexpected contract data removal in history archives: %s", + hex.EncodeToString(contractID[:]), + )) + } + var assetType xdr.AssetType + var assetCode, assetIssuer string + asset.MustExtract(&assetType, &assetCode, &assetIssuer) + row := history.ExpAssetStat{ + AssetType: assetType, + AssetCode: assetCode, + AssetIssuer: assetIssuer, + Accounts: history.ExpAssetStatAccounts{}, + Balances: newAssetStatBalance().ConvertToHistoryObject(), + Amount: "0", + NumAccounts: 0, + } + row.SetContractID(contractID) + assetStatsDeltas = append(assetStatsDeltas, row) + } + + return assetStatsDeltas, nil +} + +func (p *AssetStatsProcessor) updateAssetStats( + ctx context.Context, + assetStatsDeltas []history.ExpAssetStat, + contractToAsset map[xdr.Hash]*xdr.Asset, +) error { for _, delta := range assetStatsDeltas { var rowsAffected int64 var stat history.ExpAssetStat @@ -134,12 +338,6 @@ func (p *AssetStatsProcessor) Commit(ctx context.Context) error { return errors.Wrap(err, "cannot compute contract id for asset") } - if contractAssetStat, ok := contractAssetStats[contractID]; ok { - delta.Balances.Contracts = contractAssetStat.balance.String() - delta.Accounts.Contracts = contractAssetStat.numHolders - delete(contractAssetStats, contractID) - } - stat, err = p.assetStatsQ.GetAssetStat(ctx, delta.AssetType, delta.AssetCode, @@ -225,12 +423,12 @@ func (p *AssetStatsProcessor) Commit(ctx context.Context) error { } } else { var statBalances assetStatBalances - if err = statBalances.Parse(&stat.Balances); err != nil { + if err = statBalances.Parse(stat.Balances); err != nil { return errors.Wrap(err, "Error parsing balances") } var deltaBalances assetStatBalances - if err = deltaBalances.Parse(&delta.Balances); err != nil { + if err = deltaBalances.Parse(delta.Balances); err != nil { return errors.Wrap(err, "Error parsing balances") } @@ -285,31 +483,26 @@ func (p *AssetStatsProcessor) Commit(ctx context.Context) error { )) } } - - if err := p.updateContractIDs(ctx, contractToAsset, contractAssetStats); err != nil { - return err - } - return p.updateContractAssetStats(ctx, contractAssetStats) + return nil } func (p *AssetStatsProcessor) updateContractIDs( ctx context.Context, - contractToAsset map[[32]byte]*xdr.Asset, - contractAssetStats map[[32]byte]contractAssetStatValue, + contractToAsset map[xdr.Hash]*xdr.Asset, ) error { for contractID, asset := range contractToAsset { - if err := p.updateContractID(ctx, contractAssetStats, contractID, asset); err != nil { + if err := p.updateContractID(ctx, contractID, asset); err != nil { return err } } return nil } -// updateContractID will update the asset stat row for the corresponding asset to either add or remove the given contract id +// updateContractID will update the asset stat row for the corresponding asset to either +// add or remove the given contract id func (p *AssetStatsProcessor) updateContractID( ctx context.Context, - contractAssetStats map[[32]byte]contractAssetStatValue, - contractID [32]byte, + contractID xdr.Hash, asset *xdr.Asset, ) error { var rowsAffected int64 @@ -326,10 +519,6 @@ func (p *AssetStatsProcessor) updateContractID( return errors.Wrap(err, "error querying asset by contract id") } - if err = p.maybeAddContractAssetStat(contractAssetStats, contractID, &stat); err != nil { - return errors.Wrapf(err, "could not update asset stat with contract id %v with contract delta", contractID) - } - if stat.Accounts.IsZero() { if !stat.Balances.IsZero() { return ingest.NewStateError(errors.Errorf( @@ -346,11 +535,6 @@ func (p *AssetStatsProcessor) updateContractID( if err != nil { return errors.Wrap(err, "could not remove asset stat") } - } else if stat.Accounts.Contracts != 0 || stat.Balances.Contracts != "0" { - return ingest.NewStateError(errors.Errorf( - "asset stat has contract holders but is attempting to remove contract id: %s", - hex.EncodeToString(contractID[:]), - )) } else { // update the row to set the contract_id column to NULL stat.ContractID = nil @@ -376,9 +560,6 @@ func (p *AssetStatsProcessor) updateContractID( NumAccounts: 0, } row.SetContractID(contractID) - if err = p.maybeAddContractAssetStat(contractAssetStats, contractID, &row); err != nil { - return errors.Wrapf(err, "could not update asset stat with contract id %v with contract delta", contractID) - } rowsAffected, err = p.assetStatsQ.InsertAssetStat(ctx, row) if err != nil { @@ -397,10 +578,6 @@ func (p *AssetStatsProcessor) updateContractID( } else { // update the column_id column stat.SetContractID(contractID) - if err = p.maybeAddContractAssetStat(contractAssetStats, contractID, &stat); err != nil { - return errors.Wrapf(err, "could not update asset stat with contract id %v with contract delta", contractID) - } - rowsAffected, err = p.assetStatsQ.UpdateAssetStat(ctx, stat) if err != nil { return errors.Wrap(err, "could not update asset stat") @@ -419,67 +596,77 @@ func (p *AssetStatsProcessor) updateContractID( return nil } -func (p *AssetStatsProcessor) addContractAssetStat(contractAssetStat contractAssetStatValue, stat *history.ExpAssetStat) error { - stat.Accounts.Contracts += contractAssetStat.numHolders - contracts, ok := new(big.Int).SetString(stat.Balances.Contracts, 10) +func (p *AssetStatsProcessor) addContractAssetStat(contractAssetStat assetContractStatValue, row *history.ContractAssetStatRow) error { + row.Stat.ActiveHolders += contractAssetStat.activeHolders + row.Stat.ArchivedHolders += contractAssetStat.archivedHolders + activeBalance, ok := new(big.Int).SetString(row.Stat.ActiveBalance, 10) if !ok { - return errors.New("Error parsing: " + stat.Balances.Contracts) + return errors.New("Error parsing: " + row.Stat.ActiveBalance) } - stat.Balances.Contracts = (new(big.Int).Add(contracts, contractAssetStat.balance)).String() - return nil -} - -func (p *AssetStatsProcessor) maybeAddContractAssetStat(contractAssetStats map[[32]byte]contractAssetStatValue, contractID [32]byte, stat *history.ExpAssetStat) error { - if contractAssetStat, ok := contractAssetStats[contractID]; ok { - if err := p.addContractAssetStat(contractAssetStat, stat); err != nil { - return err - } - delete(contractAssetStats, contractID) + row.Stat.ActiveBalance = activeBalance.Add(activeBalance, contractAssetStat.activeBalance).String() + archivedBalance, ok := new(big.Int).SetString(row.Stat.ArchivedBalance, 10) + if !ok { + return errors.New("Error parsing: " + row.Stat.ArchivedBalance) } + row.Stat.ArchivedBalance = archivedBalance.Add(archivedBalance, contractAssetStat.archivedBalance).String() return nil } func (p *AssetStatsProcessor) updateContractAssetStats( ctx context.Context, - contractAssetStats map[[32]byte]contractAssetStatValue, + contractAssetStats map[xdr.Hash]assetContractStatValue, ) error { for contractID, contractAssetStat := range contractAssetStats { - if err := p.updateContractAssetStat(ctx, contractID, contractAssetStat); err != nil { + if err := p.updateAssetContractStats(ctx, contractID, contractAssetStat); err != nil { return err } } return nil } -// updateContractAssetStat will look up an asset stat by contract id and, if it exists, -// it will adjust the contract balance and holders based on contractAssetStatValue -func (p *AssetStatsProcessor) updateContractAssetStat( +// updateAssetContractStats will look up an asset contract stat by contract id and +// it will adjust the contract balance and holders based on assetContractStat +func (p *AssetStatsProcessor) updateAssetContractStats( ctx context.Context, - contractID [32]byte, - contractAssetStat contractAssetStatValue, + contractID xdr.Hash, + assetContractStat assetContractStatValue, ) error { - stat, err := p.assetStatsQ.GetAssetStatByContract(ctx, contractID) + var rowsAffected int64 + row, err := p.assetStatsQ.GetContractAssetStat(ctx, contractID[:]) if err == sql.ErrNoRows { - return nil + rowsAffected, err = p.assetStatsQ.InsertContractAssetStat(ctx, assetContractStat.ConvertToHistoryObject()) + if err != nil { + return errors.Wrap(err, "error inserting asset contract stat") + } } else if err != nil { return errors.Wrap(err, "error querying asset by contract id") - } - if err = p.addContractAssetStat(contractAssetStat, &stat); err != nil { - return errors.Wrapf(err, "could not update asset stat with contract id %v with contract delta", contractID) - } + } else { + if err = p.addContractAssetStat(assetContractStat, &row); err != nil { + return errors.Wrapf(err, "could not update asset stat with contract id %v with contract delta", contractID) + } - var rowsAffected int64 - rowsAffected, err = p.assetStatsQ.UpdateAssetStat(ctx, stat) - if err != nil { - return errors.Wrap(err, "could not update asset stat") + if row.Stat == (history.ContractStat{ + ActiveBalance: "0", + ActiveHolders: 0, + ArchivedBalance: "0", + ArchivedHolders: 0, + }) { + rowsAffected, err = p.assetStatsQ.RemoveAssetContractStat(ctx, contractID[:]) + } else { + rowsAffected, err = p.assetStatsQ.UpdateContractAssetStat(ctx, row) + } + + if err != nil { + return errors.Wrap(err, "could not update asset stat") + } } if rowsAffected != 1 { // assert that we have updated exactly one row return ingest.NewStateError(errors.Errorf( - "%d rows affected (expected exactly 1) when adjusting asset stat for asset: %s", + "%d rows affected (expected exactly 1) when adjusting asset contract stat for contract: %s", rowsAffected, - stat.AssetCode+":"+stat.AssetIssuer, + contractID, )) } return nil diff --git a/services/horizon/internal/ingest/processors/asset_stats_processor_test.go b/services/horizon/internal/ingest/processors/asset_stats_processor_test.go index e95b9b3c44..a1fb68237c 100644 --- a/services/horizon/internal/ingest/processors/asset_stats_processor_test.go +++ b/services/horizon/internal/ingest/processors/asset_stats_processor_test.go @@ -3,10 +3,13 @@ package processors import ( + "bytes" "context" "database/sql" "testing" + "github.com/stretchr/testify/assert" + "github.com/stellar/go/ingest" "github.com/stellar/go/services/horizon/internal/db2/history" "github.com/stellar/go/xdr" @@ -29,7 +32,7 @@ type AssetStatsProcessorTestSuiteState struct { func (s *AssetStatsProcessorTestSuiteState) SetupTest() { s.ctx = context.Background() s.mockQ = &history.MockQAssetStats{} - s.processor = NewAssetStatsProcessor(s.mockQ, "", false) + s.processor = NewAssetStatsProcessor(s.mockQ, "", true, 123) } func (s *AssetStatsProcessorTestSuiteState) TearDownTest() { @@ -70,12 +73,11 @@ func (s *AssetStatsProcessorTestSuiteState) TestCreateTrustLine() { Unauthorized: "0", ClaimableBalances: "0", LiquidityPools: "0", - Contracts: "0", }, Amount: "0", NumAccounts: 1, }, - }, maxBatchSize).Return(nil).Once() + }).Return(nil).Once() } func (s *AssetStatsProcessorTestSuiteState) TestCreatePoolShareTrustLine() { @@ -138,12 +140,11 @@ func (s *AssetStatsProcessorTestSuiteState) TestCreateTrustLineWithClawback() { Unauthorized: "0", ClaimableBalances: "0", LiquidityPools: "0", - Contracts: "0", }, Amount: "0", NumAccounts: 1, }, - }, maxBatchSize).Return(nil).Once() + }).Return(nil).Once() } func (s *AssetStatsProcessorTestSuiteState) TestCreateTrustLineUnauthorized() { @@ -177,12 +178,11 @@ func (s *AssetStatsProcessorTestSuiteState) TestCreateTrustLineUnauthorized() { Unauthorized: "0", ClaimableBalances: "0", LiquidityPools: "0", - Contracts: "0", }, Amount: "0", NumAccounts: 0, }, - }, maxBatchSize).Return(nil).Once() + }).Return(nil).Once() } func TestAssetStatsProcessorTestSuiteLedger(t *testing.T) { @@ -200,7 +200,7 @@ func (s *AssetStatsProcessorTestSuiteLedger) SetupTest() { s.ctx = context.Background() s.mockQ = &history.MockQAssetStats{} - s.processor = NewAssetStatsProcessor(s.mockQ, "", true) + s.processor = NewAssetStatsProcessor(s.mockQ, "", false, 1235) } func (s *AssetStatsProcessorTestSuiteLedger) TearDownTest() { @@ -319,7 +319,6 @@ func (s *AssetStatsProcessorTestSuiteLedger) TestInsertClaimableBalance() { Unauthorized: "0", ClaimableBalances: "24", LiquidityPools: "0", - Contracts: "0", }, Amount: "0", NumAccounts: 0, @@ -343,12 +342,22 @@ func (s *AssetStatsProcessorTestSuiteLedger) TestInsertClaimableBalance() { Unauthorized: "0", ClaimableBalances: "46", LiquidityPools: "0", - Contracts: "0", }, Amount: "0", NumAccounts: 0, }).Return(int64(1), nil).Once() + s.mockQ.On("RemoveContractAssetBalances", s.ctx, []xdr.Hash(nil)). + Return(nil).Once() + s.mockQ.On("UpdateContractAssetBalanceAmounts", s.ctx, []xdr.Hash{}, []string{}). + Return(nil).Once() + s.mockQ.On("InsertContractAssetBalances", s.ctx, []history.ContractAssetBalance(nil)). + Return(nil).Once() + s.mockQ.On("UpdateContractAssetBalanceExpirations", s.ctx, []xdr.Hash{}, []uint32{}). + Return(nil).Once() + s.mockQ.On("GetContractAssetBalancesExpiringAt", s.ctx, uint32(1234)). + Return([]history.ContractAssetBalance{}, nil).Once() + s.Assert().NoError(s.processor.Commit(s.ctx)) } @@ -477,7 +486,6 @@ func (s *AssetStatsProcessorTestSuiteLedger) TestInsertTrustLine() { Unauthorized: "0", ClaimableBalances: "0", LiquidityPools: "0", - Contracts: "0", }, Amount: "10", NumAccounts: 1, @@ -501,12 +509,22 @@ func (s *AssetStatsProcessorTestSuiteLedger) TestInsertTrustLine() { Unauthorized: "10", ClaimableBalances: "0", LiquidityPools: "0", - Contracts: "0", }, Amount: "0", NumAccounts: 0, }).Return(int64(1), nil).Once() + s.mockQ.On("RemoveContractAssetBalances", s.ctx, []xdr.Hash(nil)). + Return(nil).Once() + s.mockQ.On("UpdateContractAssetBalanceAmounts", s.ctx, []xdr.Hash{}, []string{}). + Return(nil).Once() + s.mockQ.On("InsertContractAssetBalances", s.ctx, []history.ContractAssetBalance(nil)). + Return(nil).Once() + s.mockQ.On("UpdateContractAssetBalanceExpirations", s.ctx, []xdr.Hash{}, []uint32{}). + Return(nil).Once() + s.mockQ.On("GetContractAssetBalancesExpiringAt", s.ctx, uint32(1234)). + Return([]history.ContractAssetBalance{}, nil).Once() + s.Assert().NoError(s.processor.Commit(s.ctx)) } @@ -580,7 +598,6 @@ func (s *AssetStatsProcessorTestSuiteLedger) TestInsertContractID() { Unauthorized: "0", ClaimableBalances: "0", LiquidityPools: "0", - Contracts: "0", }, Amount: "0", NumAccounts: 1, @@ -607,7 +624,6 @@ func (s *AssetStatsProcessorTestSuiteLedger) TestInsertContractID() { Unauthorized: "0", ClaimableBalances: "0", LiquidityPools: "0", - Contracts: "0", }, Amount: "0", NumAccounts: 0, @@ -617,6 +633,17 @@ func (s *AssetStatsProcessorTestSuiteLedger) TestInsertContractID() { return usdAssetStat.Equals(assetStat) })).Return(int64(1), nil).Once() + s.mockQ.On("RemoveContractAssetBalances", s.ctx, []xdr.Hash(nil)). + Return(nil).Once() + s.mockQ.On("UpdateContractAssetBalanceAmounts", s.ctx, []xdr.Hash{}, []string{}). + Return(nil).Once() + s.mockQ.On("InsertContractAssetBalances", s.ctx, []history.ContractAssetBalance(nil)). + Return(nil).Once() + s.mockQ.On("UpdateContractAssetBalanceExpirations", s.ctx, []xdr.Hash{}, []uint32{}). + Return(nil).Once() + s.mockQ.On("GetContractAssetBalancesExpiringAt", s.ctx, uint32(1234)). + Return([]history.ContractAssetBalance{}, nil).Once() + s.Assert().NoError(s.processor.Commit(s.ctx)) } @@ -633,34 +660,115 @@ func (s *AssetStatsProcessorTestSuiteLedger) TestInsertContractBalance() { }, })) - usdAssetStat := history.ExpAssetStat{ - AssetType: xdr.AssetTypeAssetTypeCreditAlphanum4, - AssetIssuer: trustLineIssuer.Address(), - AssetCode: "USD", - Accounts: history.ExpAssetStatAccounts{ - Contracts: 1, + keyHash := getKeyHashForBalance(s.T(), usdID, [32]byte{1}) + s.Assert().NoError(s.processor.ProcessChange(s.ctx, ingest.Change{ + Type: xdr.LedgerEntryTypeTtl, + Post: &xdr.LedgerEntry{ + LastModifiedLedgerSeq: lastModifiedLedgerSeq, + Data: xdr.LedgerEntryData{ + Type: xdr.LedgerEntryTypeTtl, + Ttl: &xdr.TtlEntry{ + KeyHash: keyHash, + LiveUntilLedgerSeq: 2234, + }, + }, }, - Balances: history.ExpAssetStatBalances{ - Authorized: "0", - AuthorizedToMaintainLiabilities: "0", - Unauthorized: "0", - ClaimableBalances: "0", - LiquidityPools: "0", - Contracts: "150", + })) + + s.mockQ.On("GetContractAssetStat", s.ctx, usdID[:]). + Return(history.ContractAssetStatRow{}, sql.ErrNoRows).Once() + + usdAssetContractStat := history.ContractAssetStatRow{ + ContractID: usdID[:], + Stat: history.ContractStat{ + ActiveBalance: "200", + ActiveHolders: 1, + ArchivedBalance: "0", + ArchivedHolders: 0, }, - Amount: "0", - NumAccounts: 0, } - usdAssetStat.SetContractID(usdID) - s.mockQ.On("GetAssetStatByContract", s.ctx, usdID). - Return(usdAssetStat, nil).Once() + s.mockQ.On("InsertContractAssetStat", s.ctx, mock.MatchedBy(func(row history.ContractAssetStatRow) bool { + return bytes.Equal(usdID[:], row.ContractID) && + usdAssetContractStat.Stat == row.Stat + })).Return(int64(1), nil).Once() - usdAssetStat.Accounts.Contracts++ - usdAssetStat.Balances.Contracts = "350" - s.mockQ.On("UpdateAssetStat", s.ctx, mock.MatchedBy(func(assetStat history.ExpAssetStat) bool { - return usdAssetStat.Equals(assetStat) + s.mockQ.On("RemoveContractAssetBalances", s.ctx, []xdr.Hash(nil)). + Return(nil).Once() + s.mockQ.On("UpdateContractAssetBalanceAmounts", s.ctx, []xdr.Hash{}, []string{}). + Return(nil).Once() + s.mockQ.On("InsertContractAssetBalances", s.ctx, []history.ContractAssetBalance{ + { + KeyHash: keyHash[:], + ContractID: usdID[:], + Amount: "200", + ExpirationLedger: 2234, + }, + }).Return(nil).Once() + s.mockQ.On("UpdateContractAssetBalanceExpirations", s.ctx, []xdr.Hash{}, []uint32{}). + Return(nil).Once() + s.mockQ.On("GetContractAssetBalancesExpiringAt", s.ctx, uint32(1234)). + Return([]history.ContractAssetBalance{}, nil).Once() + + s.Assert().NoError(s.processor.Commit(s.ctx)) +} + +func (s *AssetStatsProcessorTestSuiteLedger) TestUpdateContractBalance() { + lastModifiedLedgerSeq := xdr.Uint32(1234) + usdID, err := xdr.MustNewCreditAsset("USD", trustLineIssuer.Address()).ContractID("") + s.Assert().NoError(err) + + keyHash := getKeyHashForBalance(s.T(), usdID, [32]byte{1}) + s.Assert().NoError(s.processor.ProcessChange(s.ctx, ingest.Change{ + Type: xdr.LedgerEntryTypeContractData, + Pre: &xdr.LedgerEntry{ + LastModifiedLedgerSeq: lastModifiedLedgerSeq, + Data: BalanceToContractData(usdID, [32]byte{1}, 100), + }, + Post: &xdr.LedgerEntry{ + LastModifiedLedgerSeq: lastModifiedLedgerSeq, + Data: BalanceToContractData(usdID, [32]byte{1}, 300), + }, + })) + + usdAssetContractStat := history.ContractAssetStatRow{ + ContractID: usdID[:], + Stat: history.ContractStat{ + ActiveBalance: "150", + ActiveHolders: 1, + ArchivedBalance: "20", + ArchivedHolders: 2, + }, + } + s.mockQ.On("GetContractAssetStat", s.ctx, usdID[:]). + Return(usdAssetContractStat, nil).Once() + + s.mockQ.On("GetContractAssetBalances", s.ctx, []xdr.Hash{keyHash}). + Return([]history.ContractAssetBalance{ + { + KeyHash: keyHash[:], + ContractID: usdID[:], + Amount: "100", + ExpirationLedger: 2234, + }, + }, nil).Once() + + usdAssetContractStat.Stat.ActiveBalance = "350" + s.mockQ.On("UpdateContractAssetStat", s.ctx, mock.MatchedBy(func(row history.ContractAssetStatRow) bool { + return bytes.Equal(usdID[:], row.ContractID) && + usdAssetContractStat.Stat == row.Stat })).Return(int64(1), nil).Once() + s.mockQ.On("InsertContractAssetBalances", s.ctx, []history.ContractAssetBalance(nil)). + Return(nil).Once() + s.mockQ.On("RemoveContractAssetBalances", s.ctx, []xdr.Hash(nil)). + Return(nil).Once() + s.mockQ.On("UpdateContractAssetBalanceAmounts", s.ctx, []xdr.Hash{keyHash}, []string{"300"}). + Return(nil).Once() + s.mockQ.On("UpdateContractAssetBalanceExpirations", s.ctx, []xdr.Hash{}, []uint32{}). + Return(nil).Once() + s.mockQ.On("GetContractAssetBalancesExpiringAt", s.ctx, uint32(1234)). + Return([]history.ContractAssetBalance{}, nil).Once() + s.Assert().NoError(s.processor.Commit(s.ctx)) } @@ -677,33 +785,46 @@ func (s *AssetStatsProcessorTestSuiteLedger) TestRemoveContractBalance() { }, })) - usdAssetStat := history.ExpAssetStat{ - AssetType: xdr.AssetTypeAssetTypeCreditAlphanum4, - AssetIssuer: trustLineIssuer.Address(), - AssetCode: "USD", - Accounts: history.ExpAssetStatAccounts{ - Contracts: 1, + keyHash := getKeyHashForBalance(s.T(), usdID, [32]byte{1}) + s.Assert().NoError(s.processor.ProcessChange(s.ctx, ingest.Change{ + Type: xdr.LedgerEntryTypeTtl, + Pre: &xdr.LedgerEntry{ + LastModifiedLedgerSeq: lastModifiedLedgerSeq, + Data: xdr.LedgerEntryData{ + Type: xdr.LedgerEntryTypeTtl, + Ttl: &xdr.TtlEntry{ + KeyHash: keyHash, + LiveUntilLedgerSeq: 2234, + }, + }, }, - Balances: history.ExpAssetStatBalances{ - Authorized: "0", - AuthorizedToMaintainLiabilities: "0", - Unauthorized: "0", - ClaimableBalances: "0", - LiquidityPools: "0", - Contracts: "200", + })) + + usdAssetContractStat := history.ContractAssetStatRow{ + ContractID: usdID[:], + Stat: history.ContractStat{ + ActiveBalance: "200", + ActiveHolders: 1, + ArchivedHolders: 0, + ArchivedBalance: "0", }, - Amount: "0", - NumAccounts: 0, } - usdAssetStat.SetContractID(usdID) - s.mockQ.On("GetAssetStatByContract", s.ctx, usdID). - Return(usdAssetStat, nil).Once() - - usdAssetStat.Accounts.Contracts = 0 - usdAssetStat.Balances.Contracts = "0" - s.mockQ.On("UpdateAssetStat", s.ctx, mock.MatchedBy(func(assetStat history.ExpAssetStat) bool { - return usdAssetStat.Equals(assetStat) - })).Return(int64(1), nil).Once() + s.mockQ.On("GetContractAssetStat", s.ctx, usdID[:]). + Return(usdAssetContractStat, nil).Once() + + usdAssetContractStat.Stat.ActiveHolders = 0 + usdAssetContractStat.Stat.ActiveBalance = "0" + s.mockQ.On("RemoveAssetContractStat", s.ctx, usdID[:]).Return(int64(1), nil).Once() + s.mockQ.On("RemoveContractAssetBalances", s.ctx, []xdr.Hash{keyHash}). + Return(nil).Once() + s.mockQ.On("UpdateContractAssetBalanceAmounts", s.ctx, []xdr.Hash{}, []string{}). + Return(nil).Once() + s.mockQ.On("InsertContractAssetBalances", s.ctx, []history.ContractAssetBalance(nil)). + Return(nil).Once() + s.mockQ.On("UpdateContractAssetBalanceExpirations", s.ctx, []xdr.Hash{}, []uint32{}). + Return(nil).Once() + s.mockQ.On("GetContractAssetBalancesExpiringAt", s.ctx, uint32(1234)). + Return([]history.ContractAssetBalance{}, nil).Once() s.Assert().NoError(s.processor.Commit(s.ctx)) } @@ -777,6 +898,21 @@ func (s *AssetStatsProcessorTestSuiteLedger) TestInsertContractIDWithBalance() { }, })) + keyHash := getKeyHashForBalance(s.T(), btcID, [32]byte{1}) + s.Assert().NoError(s.processor.ProcessChange(s.ctx, ingest.Change{ + Type: xdr.LedgerEntryTypeTtl, + Post: &xdr.LedgerEntry{ + LastModifiedLedgerSeq: lastModifiedLedgerSeq, + Data: xdr.LedgerEntryData{ + Type: xdr.LedgerEntryTypeTtl, + Ttl: &xdr.TtlEntry{ + KeyHash: keyHash, + LiveUntilLedgerSeq: 2234, + }, + }, + }, + })) + s.mockQ.On("GetAssetStat", s.ctx, xdr.AssetTypeAssetTypeCreditAlphanum4, "EUR", @@ -795,7 +931,6 @@ func (s *AssetStatsProcessorTestSuiteLedger) TestInsertContractIDWithBalance() { Unauthorized: "0", ClaimableBalances: "0", LiquidityPools: "0", - Contracts: "0", }, Amount: "0", NumAccounts: 1, @@ -811,23 +946,33 @@ func (s *AssetStatsProcessorTestSuiteLedger) TestInsertContractIDWithBalance() { trustLineIssuer.Address(), ).Return(history.ExpAssetStat{}, sql.ErrNoRows).Once() - s.mockQ.On("GetAssetStatByContract", s.ctx, btcID). - Return(history.ExpAssetStat{}, sql.ErrNoRows).Once() + s.mockQ.On("GetContractAssetStat", s.ctx, btcID[:]). + Return(history.ContractAssetStatRow{}, sql.ErrNoRows).Once() + btcAssetContractStat := history.ContractAssetStatRow{ + ContractID: btcID[:], + Stat: history.ContractStat{ + ActiveBalance: "20", + ActiveHolders: 1, + ArchivedBalance: "0", + ArchivedHolders: 0, + }, + } + s.mockQ.On("InsertContractAssetStat", s.ctx, mock.MatchedBy(func(row history.ContractAssetStatRow) bool { + return bytes.Equal(btcID[:], row.ContractID) && + btcAssetContractStat.Stat == row.Stat + })).Return(int64(1), nil).Once() usdAssetStat := history.ExpAssetStat{ AssetType: xdr.AssetTypeAssetTypeCreditAlphanum4, AssetIssuer: trustLineIssuer.Address(), AssetCode: "USD", - Accounts: history.ExpAssetStatAccounts{ - Contracts: 1, - }, + Accounts: history.ExpAssetStatAccounts{}, Balances: history.ExpAssetStatBalances{ Authorized: "0", AuthorizedToMaintainLiabilities: "0", Unauthorized: "0", ClaimableBalances: "0", LiquidityPools: "0", - Contracts: "150", }, Amount: "0", NumAccounts: 0, @@ -837,6 +982,23 @@ func (s *AssetStatsProcessorTestSuiteLedger) TestInsertContractIDWithBalance() { return usdAssetStat.Equals(assetStat) })).Return(int64(1), nil).Once() + s.mockQ.On("RemoveContractAssetBalances", s.ctx, []xdr.Hash(nil)). + Return(nil).Once() + s.mockQ.On("UpdateContractAssetBalanceAmounts", s.ctx, []xdr.Hash{}, []string{}). + Return(nil).Once() + s.mockQ.On("InsertContractAssetBalances", s.ctx, []history.ContractAssetBalance{ + { + KeyHash: keyHash[:], + ContractID: btcID[:], + Amount: "20", + ExpirationLedger: 2234, + }, + }).Return(nil).Once() + s.mockQ.On("UpdateContractAssetBalanceExpirations", s.ctx, []xdr.Hash{}, []uint32{}). + Return(nil).Once() + s.mockQ.On("GetContractAssetBalancesExpiringAt", s.ctx, uint32(1234)). + Return([]history.ContractAssetBalance{}, nil).Once() + s.Assert().NoError(s.processor.Commit(s.ctx)) } @@ -934,12 +1096,22 @@ func (s *AssetStatsProcessorTestSuiteLedger) TestInsertClaimableBalanceAndTrustl Unauthorized: "0", ClaimableBalances: "12", LiquidityPools: "100", - Contracts: "0", }, Amount: "9", NumAccounts: 1, }).Return(int64(1), nil).Once() + s.mockQ.On("RemoveContractAssetBalances", s.ctx, []xdr.Hash(nil)). + Return(nil).Once() + s.mockQ.On("UpdateContractAssetBalanceAmounts", s.ctx, []xdr.Hash{}, []string{}). + Return(nil).Once() + s.mockQ.On("InsertContractAssetBalances", s.ctx, []history.ContractAssetBalance(nil)). + Return(nil).Once() + s.mockQ.On("UpdateContractAssetBalanceExpirations", s.ctx, []xdr.Hash{}, []uint32{}). + Return(nil).Once() + s.mockQ.On("GetContractAssetBalancesExpiringAt", s.ctx, uint32(1234)). + Return([]history.ContractAssetBalance{}, nil).Once() + s.Assert().NoError(s.processor.Commit(s.ctx)) } @@ -975,7 +1147,6 @@ func (s *AssetStatsProcessorTestSuiteLedger) TestUpdateContractID() { Unauthorized: "0", ClaimableBalances: "0", LiquidityPools: "0", - Contracts: "0", }, Amount: "100", NumAccounts: 1, @@ -992,7 +1163,6 @@ func (s *AssetStatsProcessorTestSuiteLedger) TestUpdateContractID() { Unauthorized: "0", ClaimableBalances: "0", LiquidityPools: "0", - Contracts: "0", }, Amount: "100", NumAccounts: 1, @@ -1002,9 +1172,94 @@ func (s *AssetStatsProcessorTestSuiteLedger) TestUpdateContractID() { return eurAssetStat.Equals(assetStat) })).Return(int64(1), nil).Once() + s.mockQ.On("RemoveContractAssetBalances", s.ctx, []xdr.Hash(nil)). + Return(nil).Once() + s.mockQ.On("UpdateContractAssetBalanceAmounts", s.ctx, []xdr.Hash{}, []string{}). + Return(nil).Once() + s.mockQ.On("InsertContractAssetBalances", s.ctx, []history.ContractAssetBalance(nil)). + Return(nil).Once() + s.mockQ.On("UpdateContractAssetBalanceExpirations", s.ctx, []xdr.Hash{}, []uint32{}). + Return(nil).Once() + s.mockQ.On("GetContractAssetBalancesExpiringAt", s.ctx, uint32(1234)). + Return([]history.ContractAssetBalance{}, nil).Once() + s.Assert().NoError(s.processor.Commit(s.ctx)) } +func (s *AssetStatsProcessorTestSuiteLedger) TestExpirationLedgerCannotDecrease() { + lastModifiedLedgerSeq := xdr.Uint32(1234) + + eurID, err := xdr.MustNewCreditAsset("EUR", trustLineIssuer.Address()).ContractID("") + s.Assert().NoError(err) + + keyHash := getKeyHashForBalance(s.T(), eurID, [32]byte{1}) + s.Assert().NoError(s.processor.ProcessChange(s.ctx, ingest.Change{ + Type: xdr.LedgerEntryTypeTtl, + Pre: &xdr.LedgerEntry{ + LastModifiedLedgerSeq: lastModifiedLedgerSeq, + Data: xdr.LedgerEntryData{ + Type: xdr.LedgerEntryTypeTtl, + Ttl: &xdr.TtlEntry{ + KeyHash: keyHash, + LiveUntilLedgerSeq: 2235, + }, + }, + }, + Post: &xdr.LedgerEntry{ + LastModifiedLedgerSeq: lastModifiedLedgerSeq, + Data: xdr.LedgerEntryData{ + Type: xdr.LedgerEntryTypeTtl, + Ttl: &xdr.TtlEntry{ + KeyHash: keyHash, + LiveUntilLedgerSeq: 2234, + }, + }, + }, + })) + + s.Assert().EqualError( + s.processor.Commit(s.ctx), + "Error adjusting asset stat: unexpected change in expiration ledger Pre: 2235 Post: 2234", + ) +} + +func (s *AssetStatsProcessorTestSuiteLedger) TestExpirationLedgerCannotBeLessThanCurrentLedger() { + lastModifiedLedgerSeq := xdr.Uint32(1234) + + eurID, err := xdr.MustNewCreditAsset("EUR", trustLineIssuer.Address()).ContractID("") + s.Assert().NoError(err) + + keyHash := getKeyHashForBalance(s.T(), eurID, [32]byte{1}) + s.Assert().NoError(s.processor.ProcessChange(s.ctx, ingest.Change{ + Type: xdr.LedgerEntryTypeTtl, + Pre: &xdr.LedgerEntry{ + LastModifiedLedgerSeq: lastModifiedLedgerSeq, + Data: xdr.LedgerEntryData{ + Type: xdr.LedgerEntryTypeTtl, + Ttl: &xdr.TtlEntry{ + KeyHash: keyHash, + LiveUntilLedgerSeq: 1230, + }, + }, + }, + Post: &xdr.LedgerEntry{ + LastModifiedLedgerSeq: lastModifiedLedgerSeq, + Data: xdr.LedgerEntryData{ + Type: xdr.LedgerEntryTypeTtl, + Ttl: &xdr.TtlEntry{ + KeyHash: keyHash, + LiveUntilLedgerSeq: 1234, + }, + }, + }, + })) + + s.Assert().EqualError( + s.processor.Commit(s.ctx), + "Error adjusting asset stat: post expiration ledger is less than current ledger. Pre: 1230 Post: 1234 current ledger: 1235", + ) +} + func (s *AssetStatsProcessorTestSuiteLedger) TestUpdateContractIDWithBalance() { lastModifiedLedgerSeq := xdr.Uint32(1234) @@ -1029,6 +1284,20 @@ func (s *AssetStatsProcessorTestSuiteLedger) TestUpdateContractIDWithBalance() { Data: BalanceToContractData(eurID, [32]byte{1}, 150), }, })) + keyHash := getKeyHashForBalance(s.T(), eurID, [32]byte{1}) + s.Assert().NoError(s.processor.ProcessChange(s.ctx, ingest.Change{ + Type: xdr.LedgerEntryTypeTtl, + Post: &xdr.LedgerEntry{ + LastModifiedLedgerSeq: lastModifiedLedgerSeq, + Data: xdr.LedgerEntryData{ + Type: xdr.LedgerEntryTypeTtl, + Ttl: &xdr.TtlEntry{ + KeyHash: keyHash, + LiveUntilLedgerSeq: 2234, + }, + }, + }, + })) s.mockQ.On("GetAssetStat", s.ctx, xdr.AssetTypeAssetTypeCreditAlphanum4, @@ -1045,7 +1314,6 @@ func (s *AssetStatsProcessorTestSuiteLedger) TestUpdateContractIDWithBalance() { Unauthorized: "0", ClaimableBalances: "0", LiquidityPools: "0", - Contracts: "0", }, Amount: "100", NumAccounts: 1, @@ -1057,7 +1325,6 @@ func (s *AssetStatsProcessorTestSuiteLedger) TestUpdateContractIDWithBalance() { AssetCode: "EUR", Accounts: history.ExpAssetStatAccounts{ Authorized: 1, - Contracts: 1, }, Balances: history.ExpAssetStatBalances{ Authorized: "100", @@ -1065,7 +1332,6 @@ func (s *AssetStatsProcessorTestSuiteLedger) TestUpdateContractIDWithBalance() { Unauthorized: "0", ClaimableBalances: "0", LiquidityPools: "0", - Contracts: "150", }, Amount: "100", NumAccounts: 1, @@ -1075,6 +1341,43 @@ func (s *AssetStatsProcessorTestSuiteLedger) TestUpdateContractIDWithBalance() { return eurAssetStat.Equals(assetStat) })).Return(int64(1), nil).Once() + eurAssetContractStat := history.ContractAssetStatRow{ + ContractID: eurID[:], + Stat: history.ContractStat{ + ActiveBalance: "10", + ActiveHolders: 2, + ArchivedBalance: "0", + ArchivedHolders: 0, + }, + } + s.mockQ.On("GetContractAssetStat", s.ctx, eurID[:]). + Return(eurAssetContractStat, nil).Once() + + eurAssetContractStat.Stat.ActiveHolders++ + eurAssetContractStat.Stat.ActiveBalance = "160" + s.mockQ.On("UpdateContractAssetStat", s.ctx, mock.MatchedBy(func(row history.ContractAssetStatRow) bool { + return bytes.Equal(eurID[:], row.ContractID) && + eurAssetContractStat.Stat == row.Stat + })).Return(int64(1), nil).Once() + + s.mockQ.On("RemoveContractAssetBalances", s.ctx, []xdr.Hash(nil)). + Return(nil).Once() + s.mockQ.On("UpdateContractAssetBalanceAmounts", s.ctx, []xdr.Hash{}, []string{}). + Return(nil).Once() + s.mockQ.On("InsertContractAssetBalances", s.ctx, []history.ContractAssetBalance{ + { + KeyHash: keyHash[:], + ContractID: eurID[:], + Amount: "150", + ExpirationLedger: 2234, + }, + }). + Return(nil).Once() + s.mockQ.On("UpdateContractAssetBalanceExpirations", s.ctx, []xdr.Hash{}, []uint32{}). + Return(nil).Once() + s.mockQ.On("GetContractAssetBalancesExpiringAt", s.ctx, uint32(1234)). + Return([]history.ContractAssetBalance{}, nil).Once() + s.Assert().NoError(s.processor.Commit(s.ctx)) } @@ -1108,7 +1411,6 @@ func (s *AssetStatsProcessorTestSuiteLedger) TestUpdateContractIDError() { Unauthorized: "0", ClaimableBalances: "0", LiquidityPools: "0", - Contracts: "0", }, Amount: "100", NumAccounts: 1, @@ -1188,7 +1490,6 @@ func (s *AssetStatsProcessorTestSuiteLedger) TestUpdateTrustlineAndContractIDErr Unauthorized: "0", ClaimableBalances: "0", LiquidityPools: "0", - Contracts: "0", }, Amount: "100", NumAccounts: 1, @@ -1223,7 +1524,7 @@ func (s *AssetStatsProcessorTestSuiteLedger) TestRemoveContractIDError() { }) s.Assert().NoError(err) - s.mockQ.On("GetAssetStatByContract", s.ctx, eurID). + s.mockQ.On("GetAssetStatByContract", s.ctx, xdr.Hash(eurID)). Return(history.ExpAssetStat{}, sql.ErrNoRows).Once() s.Assert().EqualError( @@ -1292,7 +1593,6 @@ func (s *AssetStatsProcessorTestSuiteLedger) TestUpdateTrustlineAndRemoveContrac Unauthorized: "0", ClaimableBalances: "0", LiquidityPools: "0", - Contracts: "0", }, Amount: "100", NumAccounts: 1, @@ -1359,7 +1659,6 @@ func (s *AssetStatsProcessorTestSuiteLedger) TestUpdateTrustLine() { Unauthorized: "0", ClaimableBalances: "0", LiquidityPools: "0", - Contracts: "0", }, Amount: "100", NumAccounts: 1, @@ -1375,12 +1674,22 @@ func (s *AssetStatsProcessorTestSuiteLedger) TestUpdateTrustLine() { Unauthorized: "0", ClaimableBalances: "0", LiquidityPools: "0", - Contracts: "0", }, Amount: "110", NumAccounts: 1, }).Return(int64(1), nil).Once() + s.mockQ.On("RemoveContractAssetBalances", s.ctx, []xdr.Hash(nil)). + Return(nil).Once() + s.mockQ.On("UpdateContractAssetBalanceAmounts", s.ctx, []xdr.Hash{}, []string{}). + Return(nil).Once() + s.mockQ.On("InsertContractAssetBalances", s.ctx, []history.ContractAssetBalance(nil)). + Return(nil).Once() + s.mockQ.On("UpdateContractAssetBalanceExpirations", s.ctx, []xdr.Hash{}, []uint32{}). + Return(nil).Once() + s.mockQ.On("GetContractAssetBalancesExpiringAt", s.ctx, uint32(1234)). + Return([]history.ContractAssetBalance{}, nil).Once() + s.Assert().NoError(s.processor.Commit(s.ctx)) } @@ -1501,7 +1810,6 @@ func (s *AssetStatsProcessorTestSuiteLedger) TestUpdateTrustLineAuthorization() Unauthorized: "100", ClaimableBalances: "0", LiquidityPools: "0", - Contracts: "0", }, Amount: "0", NumAccounts: 0, @@ -1519,7 +1827,6 @@ func (s *AssetStatsProcessorTestSuiteLedger) TestUpdateTrustLineAuthorization() Unauthorized: "0", ClaimableBalances: "0", LiquidityPools: "0", - Contracts: "0", }, Amount: "10", NumAccounts: 1, @@ -1542,7 +1849,6 @@ func (s *AssetStatsProcessorTestSuiteLedger) TestUpdateTrustLineAuthorization() Unauthorized: "0", ClaimableBalances: "0", LiquidityPools: "0", - Contracts: "0", }, Amount: "100", NumAccounts: 1, @@ -1560,7 +1866,6 @@ func (s *AssetStatsProcessorTestSuiteLedger) TestUpdateTrustLineAuthorization() Unauthorized: "10", ClaimableBalances: "0", LiquidityPools: "0", - Contracts: "0", }, Amount: "0", NumAccounts: 0, @@ -1583,7 +1888,6 @@ func (s *AssetStatsProcessorTestSuiteLedger) TestUpdateTrustLineAuthorization() Unauthorized: "0", ClaimableBalances: "0", LiquidityPools: "0", - Contracts: "0", }, Amount: "100", NumAccounts: 1, @@ -1601,12 +1905,22 @@ func (s *AssetStatsProcessorTestSuiteLedger) TestUpdateTrustLineAuthorization() Unauthorized: "0", ClaimableBalances: "0", LiquidityPools: "0", - Contracts: "0", }, Amount: "0", NumAccounts: 0, }).Return(int64(1), nil).Once() + s.mockQ.On("RemoveContractAssetBalances", s.ctx, []xdr.Hash(nil)). + Return(nil).Once() + s.mockQ.On("UpdateContractAssetBalanceAmounts", s.ctx, []xdr.Hash{}, []string{}). + Return(nil).Once() + s.mockQ.On("InsertContractAssetBalances", s.ctx, []history.ContractAssetBalance(nil)). + Return(nil).Once() + s.mockQ.On("UpdateContractAssetBalanceExpirations", s.ctx, []xdr.Hash{}, []uint32{}). + Return(nil).Once() + s.mockQ.On("GetContractAssetBalancesExpiringAt", s.ctx, uint32(1234)). + Return([]history.ContractAssetBalance{}, nil).Once() + s.Assert().NoError(s.processor.Commit(s.ctx)) } @@ -1669,7 +1983,6 @@ func (s *AssetStatsProcessorTestSuiteLedger) TestRemoveClaimableBalance() { Unauthorized: "0", ClaimableBalances: "12", LiquidityPools: "0", - Contracts: "0", }, Amount: "0", NumAccounts: 0, @@ -1698,7 +2011,6 @@ func (s *AssetStatsProcessorTestSuiteLedger) TestRemoveClaimableBalance() { Unauthorized: "0", ClaimableBalances: "21", LiquidityPools: "0", - Contracts: "0", }, Amount: "0", NumAccounts: 0, @@ -1714,12 +2026,22 @@ func (s *AssetStatsProcessorTestSuiteLedger) TestRemoveClaimableBalance() { Unauthorized: "0", ClaimableBalances: "0", LiquidityPools: "0", - Contracts: "0", }, Amount: "0", NumAccounts: 0, }).Return(int64(1), nil).Once() + s.mockQ.On("RemoveContractAssetBalances", s.ctx, []xdr.Hash(nil)). + Return(nil).Once() + s.mockQ.On("UpdateContractAssetBalanceAmounts", s.ctx, []xdr.Hash{}, []string{}). + Return(nil).Once() + s.mockQ.On("InsertContractAssetBalances", s.ctx, []history.ContractAssetBalance(nil)). + Return(nil).Once() + s.mockQ.On("UpdateContractAssetBalanceExpirations", s.ctx, []xdr.Hash{}, []uint32{}). + Return(nil).Once() + s.mockQ.On("GetContractAssetBalancesExpiringAt", s.ctx, uint32(1234)). + Return([]history.ContractAssetBalance{}, nil).Once() + s.Assert().NoError(s.processor.Commit(s.ctx)) } @@ -1777,7 +2099,6 @@ func (s *AssetStatsProcessorTestSuiteLedger) TestRemoveTrustLine() { Unauthorized: "0", ClaimableBalances: "0", LiquidityPools: "0", - Contracts: "0", }, Amount: "0", NumAccounts: 1, @@ -1805,7 +2126,6 @@ func (s *AssetStatsProcessorTestSuiteLedger) TestRemoveTrustLine() { Unauthorized: "0", ClaimableBalances: "0", LiquidityPools: "0", - Contracts: "0", }, Amount: "0", NumAccounts: 0, @@ -1816,6 +2136,17 @@ func (s *AssetStatsProcessorTestSuiteLedger) TestRemoveTrustLine() { trustLineIssuer.Address(), ).Return(int64(1), nil).Once() + s.mockQ.On("RemoveContractAssetBalances", s.ctx, []xdr.Hash(nil)). + Return(nil).Once() + s.mockQ.On("UpdateContractAssetBalanceAmounts", s.ctx, []xdr.Hash{}, []string{}). + Return(nil).Once() + s.mockQ.On("InsertContractAssetBalances", s.ctx, []history.ContractAssetBalance(nil)). + Return(nil).Once() + s.mockQ.On("UpdateContractAssetBalanceExpirations", s.ctx, []xdr.Hash{}, []uint32{}). + Return(nil).Once() + s.mockQ.On("GetContractAssetBalancesExpiringAt", s.ctx, uint32(1234)). + Return([]history.ContractAssetBalance{}, nil).Once() + s.Assert().NoError(s.processor.Commit(s.ctx)) } @@ -1847,13 +2178,12 @@ func (s *AssetStatsProcessorTestSuiteLedger) TestRemoveContractID() { Unauthorized: "0", ClaimableBalances: "0", LiquidityPools: "0", - Contracts: "0", }, Amount: "100", NumAccounts: 1, } eurAssetStat.SetContractID(eurID) - s.mockQ.On("GetAssetStatByContract", s.ctx, eurID). + s.mockQ.On("GetAssetStatByContract", s.ctx, xdr.Hash(eurID)). Return(eurAssetStat, nil).Once() eurAssetStat.ContractID = nil @@ -1861,6 +2191,17 @@ func (s *AssetStatsProcessorTestSuiteLedger) TestRemoveContractID() { return eurAssetStat.Equals(assetStat) })).Return(int64(1), nil).Once() + s.mockQ.On("RemoveContractAssetBalances", s.ctx, []xdr.Hash(nil)). + Return(nil).Once() + s.mockQ.On("UpdateContractAssetBalanceAmounts", s.ctx, []xdr.Hash{}, []string{}). + Return(nil).Once() + s.mockQ.On("InsertContractAssetBalances", s.ctx, []history.ContractAssetBalance(nil)). + Return(nil).Once() + s.mockQ.On("UpdateContractAssetBalanceExpirations", s.ctx, []xdr.Hash{}, []uint32{}). + Return(nil).Once() + s.mockQ.On("GetContractAssetBalancesExpiringAt", s.ctx, uint32(1234)). + Return([]history.ContractAssetBalance{}, nil).Once() + s.Assert().NoError(s.processor.Commit(s.ctx)) } @@ -1924,7 +2265,6 @@ func (s *AssetStatsProcessorTestSuiteLedger) TestUpdateTrustlineAndRemoveContrac Unauthorized: "0", ClaimableBalances: "0", LiquidityPools: "0", - Contracts: "0", }, Amount: "100", NumAccounts: 1, @@ -1947,7 +2287,6 @@ func (s *AssetStatsProcessorTestSuiteLedger) TestUpdateTrustlineAndRemoveContrac Unauthorized: "0", ClaimableBalances: "0", LiquidityPools: "0", - Contracts: "0", }, Amount: "110", NumAccounts: 1, @@ -1956,6 +2295,17 @@ func (s *AssetStatsProcessorTestSuiteLedger) TestUpdateTrustlineAndRemoveContrac return eurAssetStat.Equals(assetStat) })).Return(int64(1), nil).Once() + s.mockQ.On("RemoveContractAssetBalances", s.ctx, []xdr.Hash(nil)). + Return(nil).Once() + s.mockQ.On("UpdateContractAssetBalanceAmounts", s.ctx, []xdr.Hash{}, []string{}). + Return(nil).Once() + s.mockQ.On("InsertContractAssetBalances", s.ctx, []history.ContractAssetBalance(nil)). + Return(nil).Once() + s.mockQ.On("UpdateContractAssetBalanceExpirations", s.ctx, []xdr.Hash{}, []uint32{}). + Return(nil).Once() + s.mockQ.On("GetContractAssetBalancesExpiringAt", s.ctx, uint32(1234)). + Return([]history.ContractAssetBalance{}, nil).Once() + s.Assert().NoError(s.processor.Commit(s.ctx)) } @@ -1987,13 +2337,12 @@ func (s *AssetStatsProcessorTestSuiteLedger) TestRemoveContractIDFromZeroRow() { Unauthorized: "0", ClaimableBalances: "0", LiquidityPools: "0", - Contracts: "0", }, Amount: "0", NumAccounts: 0, } eurAssetStat.SetContractID(eurID) - s.mockQ.On("GetAssetStatByContract", s.ctx, eurID). + s.mockQ.On("GetAssetStatByContract", s.ctx, xdr.Hash(eurID)). Return(eurAssetStat, nil).Once() s.mockQ.On("RemoveAssetStat", s.ctx, @@ -2002,6 +2351,17 @@ func (s *AssetStatsProcessorTestSuiteLedger) TestRemoveContractIDFromZeroRow() { trustLineIssuer.Address(), ).Return(int64(1), nil).Once() + s.mockQ.On("RemoveContractAssetBalances", s.ctx, []xdr.Hash(nil)). + Return(nil).Once() + s.mockQ.On("UpdateContractAssetBalanceAmounts", s.ctx, []xdr.Hash{}, []string{}). + Return(nil).Once() + s.mockQ.On("InsertContractAssetBalances", s.ctx, []history.ContractAssetBalance(nil)). + Return(nil).Once() + s.mockQ.On("UpdateContractAssetBalanceExpirations", s.ctx, []xdr.Hash{}, []uint32{}). + Return(nil).Once() + s.mockQ.On("GetContractAssetBalancesExpiringAt", s.ctx, uint32(1234)). + Return([]history.ContractAssetBalance{}, nil).Once() + s.Assert().NoError(s.processor.Commit(s.ctx)) } @@ -2029,6 +2389,20 @@ func (s *AssetStatsProcessorTestSuiteLedger) TestRemoveContractIDAndBalanceZeroR Data: BalanceToContractData(eurID, [32]byte{1}, 9), }, })) + keyHash := getKeyHashForBalance(s.T(), eurID, [32]byte{1}) + s.Assert().NoError(s.processor.ProcessChange(s.ctx, ingest.Change{ + Type: xdr.LedgerEntryTypeTtl, + Pre: &xdr.LedgerEntry{ + LastModifiedLedgerSeq: lastModifiedLedgerSeq, + Data: xdr.LedgerEntryData{ + Type: xdr.LedgerEntryTypeTtl, + Ttl: &xdr.TtlEntry{ + KeyHash: keyHash, + LiveUntilLedgerSeq: 2234, + }, + }, + }, + })) s.Assert().NoError(s.processor.ProcessChange(s.ctx, ingest.Change{ Type: xdr.LedgerEntryTypeContractData, @@ -2037,25 +2411,38 @@ func (s *AssetStatsProcessorTestSuiteLedger) TestRemoveContractIDAndBalanceZeroR Data: BalanceToContractData(eurID, [32]byte{2}, 1), }, })) + otherKeyHash := getKeyHashForBalance(s.T(), eurID, [32]byte{2}) + s.Assert().NoError(s.processor.ProcessChange(s.ctx, ingest.Change{ + Type: xdr.LedgerEntryTypeTtl, + Pre: &xdr.LedgerEntry{ + LastModifiedLedgerSeq: lastModifiedLedgerSeq, + Data: xdr.LedgerEntryData{ + Type: xdr.LedgerEntryTypeTtl, + Ttl: &xdr.TtlEntry{ + KeyHash: otherKeyHash, + LiveUntilLedgerSeq: 2234, + }, + }, + }, + })) eurAssetStat := history.ExpAssetStat{ AssetType: xdr.AssetTypeAssetTypeCreditAlphanum4, AssetIssuer: trustLineIssuer.Address(), AssetCode: "EUR", - Accounts: history.ExpAssetStatAccounts{Contracts: 2}, + Accounts: history.ExpAssetStatAccounts{}, Balances: history.ExpAssetStatBalances{ Authorized: "0", AuthorizedToMaintainLiabilities: "0", Unauthorized: "0", ClaimableBalances: "0", LiquidityPools: "0", - Contracts: "10", }, Amount: "0", NumAccounts: 0, } eurAssetStat.SetContractID(eurID) - s.mockQ.On("GetAssetStatByContract", s.ctx, eurID). + s.mockQ.On("GetAssetStatByContract", s.ctx, xdr.Hash(eurID)). Return(eurAssetStat, nil).Once() s.mockQ.On("RemoveAssetStat", s.ctx, @@ -2064,6 +2451,33 @@ func (s *AssetStatsProcessorTestSuiteLedger) TestRemoveContractIDAndBalanceZeroR trustLineIssuer.Address(), ).Return(int64(1), nil).Once() + eurAssetContractStat := history.ContractAssetStatRow{ + ContractID: eurID[:], + Stat: history.ContractStat{ + ActiveBalance: "10", + ActiveHolders: 2, + ArchivedBalance: "0", + ArchivedHolders: 0, + }, + } + s.mockQ.On("GetContractAssetStat", s.ctx, eurID[:]). + Return(eurAssetContractStat, nil).Once() + s.mockQ.On("RemoveAssetContractStat", s.ctx, eurID[:]). + Return(int64(1), nil).Once() + + s.mockQ.On("RemoveContractAssetBalances", s.ctx, mock.MatchedBy(func(keys []xdr.Hash) bool { + return assert.ElementsMatch(s.T(), []xdr.Hash{keyHash, otherKeyHash}, keys) + })). + Return(nil).Once() + s.mockQ.On("UpdateContractAssetBalanceAmounts", s.ctx, []xdr.Hash{}, []string{}). + Return(nil).Once() + s.mockQ.On("InsertContractAssetBalances", s.ctx, []history.ContractAssetBalance(nil)). + Return(nil).Once() + s.mockQ.On("UpdateContractAssetBalanceExpirations", s.ctx, []xdr.Hash{}, []uint32{}). + Return(nil).Once() + s.mockQ.On("GetContractAssetBalancesExpiringAt", s.ctx, uint32(1234)). + Return([]history.ContractAssetBalance{}, nil).Once() + s.Assert().NoError(s.processor.Commit(s.ctx)) } @@ -2115,7 +2529,6 @@ func (s *AssetStatsProcessorTestSuiteLedger) TestRemoveContractIDAndRow() { Unauthorized: "0", ClaimableBalances: "0", LiquidityPools: "0", - Contracts: "0", }, Amount: "0", NumAccounts: 1, @@ -2133,6 +2546,17 @@ func (s *AssetStatsProcessorTestSuiteLedger) TestRemoveContractIDAndRow() { trustLineIssuer.Address(), ).Return(int64(1), nil).Once() + s.mockQ.On("RemoveContractAssetBalances", s.ctx, []xdr.Hash(nil)). + Return(nil).Once() + s.mockQ.On("UpdateContractAssetBalanceAmounts", s.ctx, []xdr.Hash{}, []string{}). + Return(nil).Once() + s.mockQ.On("InsertContractAssetBalances", s.ctx, []history.ContractAssetBalance(nil)). + Return(nil).Once() + s.mockQ.On("UpdateContractAssetBalanceExpirations", s.ctx, []xdr.Hash{}, []uint32{}). + Return(nil).Once() + s.mockQ.On("GetContractAssetBalancesExpiringAt", s.ctx, uint32(1234)). + Return([]history.ContractAssetBalance{}, nil).Once() + s.Assert().NoError(s.processor.Commit(s.ctx)) } @@ -2202,10 +2626,21 @@ func (s *AssetStatsProcessorTestSuiteLedger) TestProcessUpgradeChange() { Unauthorized: "0", ClaimableBalances: "0", LiquidityPools: "0", - Contracts: "0", }, Amount: "10", NumAccounts: 1, }).Return(int64(1), nil).Once() + + s.mockQ.On("RemoveContractAssetBalances", s.ctx, []xdr.Hash(nil)). + Return(nil).Once() + s.mockQ.On("UpdateContractAssetBalanceAmounts", s.ctx, []xdr.Hash{}, []string{}). + Return(nil).Once() + s.mockQ.On("InsertContractAssetBalances", s.ctx, []history.ContractAssetBalance(nil)). + Return(nil).Once() + s.mockQ.On("UpdateContractAssetBalanceExpirations", s.ctx, []xdr.Hash{}, []uint32{}). + Return(nil).Once() + s.mockQ.On("GetContractAssetBalancesExpiringAt", s.ctx, uint32(1234)). + Return([]history.ContractAssetBalance{}, nil).Once() + s.Assert().NoError(s.processor.Commit(s.ctx)) } diff --git a/services/horizon/internal/ingest/processors/asset_stats_set.go b/services/horizon/internal/ingest/processors/asset_stats_set.go index 5beffd1af7..bc27c2a4ef 100644 --- a/services/horizon/internal/ingest/processors/asset_stats_set.go +++ b/services/horizon/internal/ingest/processors/asset_stats_set.go @@ -1,8 +1,6 @@ package processors import ( - "encoding/hex" - "fmt" "math/big" "github.com/stellar/go/ingest" @@ -29,7 +27,6 @@ type assetStatBalances struct { ClaimableBalances *big.Int LiquidityPools *big.Int Unauthorized *big.Int - Contracts *big.Int } func newAssetStatBalance() assetStatBalances { @@ -39,11 +36,10 @@ func newAssetStatBalance() assetStatBalances { ClaimableBalances: big.NewInt(0), LiquidityPools: big.NewInt(0), Unauthorized: big.NewInt(0), - Contracts: big.NewInt(0), } } -func (a *assetStatBalances) Parse(b *history.ExpAssetStatBalances) error { +func (a *assetStatBalances) Parse(b history.ExpAssetStatBalances) error { authorized, ok := new(big.Int).SetString(b.Authorized, 10) if !ok { return errors.New("Error parsing: " + b.Authorized) @@ -74,12 +70,6 @@ func (a *assetStatBalances) Parse(b *history.ExpAssetStatBalances) error { } a.Unauthorized = unauthorized - contracts, ok := new(big.Int).SetString(b.Contracts, 10) - if !ok { - return errors.New("Error parsing: " + b.Contracts) - } - a.Contracts = contracts - return nil } @@ -90,7 +80,6 @@ func (a assetStatBalances) Add(b assetStatBalances) assetStatBalances { ClaimableBalances: big.NewInt(0).Add(a.ClaimableBalances, b.ClaimableBalances), LiquidityPools: big.NewInt(0).Add(a.LiquidityPools, b.LiquidityPools), Unauthorized: big.NewInt(0).Add(a.Unauthorized, b.Unauthorized), - Contracts: big.NewInt(0).Add(a.Contracts, b.Contracts), } } @@ -99,8 +88,7 @@ func (a assetStatBalances) IsZero() bool { a.AuthorizedToMaintainLiabilities.Cmp(big.NewInt(0)) == 0 && a.ClaimableBalances.Cmp(big.NewInt(0)) == 0 && a.LiquidityPools.Cmp(big.NewInt(0)) == 0 && - a.Unauthorized.Cmp(big.NewInt(0)) == 0 && - a.Contracts.Cmp(big.NewInt(0)) == 0 + a.Unauthorized.Cmp(big.NewInt(0)) == 0 } func (a assetStatBalances) ConvertToHistoryObject() history.ExpAssetStatBalances { @@ -110,7 +98,6 @@ func (a assetStatBalances) ConvertToHistoryObject() history.ExpAssetStatBalances ClaimableBalances: a.ClaimableBalances.String(), LiquidityPools: a.LiquidityPools.String(), Unauthorized: a.Unauthorized.String(), - Contracts: a.Contracts.String(), } } @@ -127,28 +114,17 @@ func (value assetStatValue) ConvertToHistoryObject() history.ExpAssetStat { } } -type contractAssetStatValue struct { - balance *big.Int - numHolders int32 -} - // AssetStatSet represents a collection of asset stats and a mapping // of Soroban contract IDs to classic assets (which is unique to each // network). type AssetStatSet struct { - classicAssetStats map[assetStatKey]*assetStatValue - contractToAsset map[[32]byte]*xdr.Asset - contractAssetStats map[[32]byte]contractAssetStatValue - networkPassphrase string + classicAssetStats map[assetStatKey]*assetStatValue } // NewAssetStatSet constructs a new AssetStatSet instance -func NewAssetStatSet(networkPassphrase string) AssetStatSet { +func NewAssetStatSet() AssetStatSet { return AssetStatSet{ - classicAssetStats: map[assetStatKey]*assetStatValue{}, - contractToAsset: map[[32]byte]*xdr.Asset{}, - contractAssetStats: map[[32]byte]contractAssetStatValue{}, - networkPassphrase: networkPassphrase, + classicAssetStats: map[assetStatKey]*assetStatValue{}, } } @@ -363,225 +339,12 @@ func (s AssetStatSet) AddClaimableBalance(change ingest.Change) error { return nil } -// AddContractData updates the set to account for how a given contract data entry has changed. -// change must be a xdr.LedgerEntryTypeContractData type. -func (s AssetStatSet) AddContractData(change ingest.Change) error { - if err := s.ingestAssetContractMetadata(change); err != nil { - return err - } - s.ingestAssetContractBalance(change) - return nil -} - -func (s AssetStatSet) ingestAssetContractMetadata(change ingest.Change) error { - if change.Pre != nil { - asset := AssetFromContractData(*change.Pre, s.networkPassphrase) - if asset == nil { - return nil - } - pContractID := change.Pre.Data.MustContractData().Contract.ContractId - if pContractID == nil { - return nil - } - contractID := *pContractID - if change.Post == nil { - s.contractToAsset[contractID] = nil - return nil - } - // The contract id for a stellar asset should never change and - // therefore we return a fatal ingestion error if we encounter - // a stellar asset changing contract ids. - postAsset := AssetFromContractData(*change.Post, s.networkPassphrase) - if postAsset == nil || !(*postAsset).Equals(*asset) { - return ingest.NewStateError(fmt.Errorf("asset contract changed asset")) - } - } else if change.Post != nil { - asset := AssetFromContractData(*change.Post, s.networkPassphrase) - if asset == nil { - return nil - } - if pContactID := change.Post.Data.MustContractData().Contract.ContractId; pContactID != nil { - s.contractToAsset[*pContactID] = asset - } - } - return nil -} - -func (s AssetStatSet) ingestAssetContractBalance(change ingest.Change) { - if change.Pre != nil { - pContractID := change.Pre.Data.MustContractData().Contract.ContractId - if pContractID == nil { - return - } - holder, amt, ok := ContractBalanceFromContractData(*change.Pre, s.networkPassphrase) - if !ok { - return - } - stats, ok := s.contractAssetStats[*pContractID] - if !ok { - stats = contractAssetStatValue{ - balance: big.NewInt(0), - numHolders: 0, - } - } - - if change.Post == nil { - // the balance was removed so we need to deduct from - // contract holders and contract balance amount - stats.balance = new(big.Int).Sub(stats.balance, amt) - // only decrement holders if the removed balance - // contained a positive amount of the asset. - if amt.Cmp(big.NewInt(0)) > 0 { - stats.numHolders-- - } - s.maybeAddContractAssetStat(*pContractID, stats) - return - } - // if the updated ledger entry is not in the expected format then this - // cannot be emitted by the stellar asset contract, so ignore it - postHolder, postAmt, postOk := ContractBalanceFromContractData(*change.Post, s.networkPassphrase) - if !postOk || postHolder != holder { - return - } - - delta := new(big.Int).Sub(postAmt, amt) - stats.balance.Add(stats.balance, delta) - if postAmt.Cmp(big.NewInt(0)) == 0 && amt.Cmp(big.NewInt(0)) > 0 { - // if the pre amount is equal to the post amount it means the balance was wiped out so - // we can decrement the number of contract holders - stats.numHolders-- - } else if amt.Cmp(big.NewInt(0)) == 0 && postAmt.Cmp(big.NewInt(0)) > 0 { - // if the pre amount was zero and the post amount is positive the number of - // contract holders increased - stats.numHolders++ - } - s.maybeAddContractAssetStat(*pContractID, stats) - return - } - // in this case there was no balance before the change - pContractID := change.Post.Data.MustContractData().Contract.ContractId - if pContractID == nil { - return - } - - _, amt, ok := ContractBalanceFromContractData(*change.Post, s.networkPassphrase) - if !ok { - return - } - - // ignore zero balance amounts - if amt.Cmp(big.NewInt(0)) == 0 { - return - } - - // increase the number of contract holders because previously - // there was no balance - stats, ok := s.contractAssetStats[*pContractID] - if !ok { - stats = contractAssetStatValue{ - balance: amt, - numHolders: 1, - } - } else { - stats.balance = new(big.Int).Add(stats.balance, amt) - stats.numHolders++ - } - - s.maybeAddContractAssetStat(*pContractID, stats) -} - -func (s AssetStatSet) maybeAddContractAssetStat(contractID [32]byte, stat contractAssetStatValue) { - if stat.numHolders == 0 && stat.balance.Cmp(big.NewInt(0)) == 0 { - delete(s.contractAssetStats, contractID) - } else { - s.contractAssetStats[contractID] = stat - } -} - // All returns a list of all `history.ExpAssetStat` contained within the set // along with all contract id attribution changes in the set. -func (s AssetStatSet) All() ([]history.ExpAssetStat, map[[32]byte]*xdr.Asset, map[[32]byte]contractAssetStatValue) { +func (s AssetStatSet) All() []history.ExpAssetStat { assetStats := make([]history.ExpAssetStat, 0, len(s.classicAssetStats)) for _, value := range s.classicAssetStats { assetStats = append(assetStats, value.ConvertToHistoryObject()) } - contractToAsset := make(map[[32]byte]*xdr.Asset, len(s.contractToAsset)) - for key, val := range s.contractToAsset { - contractToAsset[key] = val - } - contractAssetStats := make(map[[32]byte]contractAssetStatValue, len(s.contractAssetStats)) - for key, val := range s.contractAssetStats { - contractAssetStats[key] = val - } - return assetStats, contractToAsset, contractAssetStats -} - -// AllFromSnapshot returns a list of all `history.ExpAssetStat` contained within the set. -// AllFromSnapshot should only be invoked when the AssetStatSet has been derived from ledger -// entry changes consisting of only inserts (no updates) reflecting the current state of -// the ledger without any missing entries (e.g. history archives). -func (s AssetStatSet) AllFromSnapshot() ([]history.ExpAssetStat, error) { - // merge assetStatsDeltas and contractToAsset into one list of history.ExpAssetStat. - assetStatsDeltas, contractToAsset, contractAssetStats := s.All() - - // modify the asset stat row to update the contract_id column whenever we encounter a - // contract data ledger entry with the Stellar asset metadata. - for i, assetStatDelta := range assetStatsDeltas { - // asset stats only supports non-native assets - asset := xdr.MustNewCreditAsset(assetStatDelta.AssetCode, assetStatDelta.AssetIssuer) - contractID, err := asset.ContractID(s.networkPassphrase) - if err != nil { - return nil, errors.Wrap(err, "cannot compute contract id for asset") - } - if asset, ok := contractToAsset[contractID]; ok && asset == nil { - return nil, ingest.NewStateError(fmt.Errorf( - "unexpected contract data removal in history archives: %s", - hex.EncodeToString(contractID[:]), - )) - } else if ok { - assetStatDelta.SetContractID(contractID) - delete(contractToAsset, contractID) - } - - if stats, ok := contractAssetStats[contractID]; ok { - assetStatDelta.Accounts.Contracts = stats.numHolders - assetStatDelta.Balances.Contracts = stats.balance.String() - } - assetStatsDeltas[i] = assetStatDelta - } - - // There is also a corner case where a Stellar Asset contract is initialized before there exists any - // trustlines / claimable balances for the Stellar Asset. In this case, when ingesting contract data - // ledger entries, there will be no existing asset stat row. We handle this case by inserting a row - // with zero stats just so we can populate the contract id. - for contractID, asset := range contractToAsset { - if asset == nil { - return nil, ingest.NewStateError(fmt.Errorf( - "unexpected contract data removal in history archives: %s", - hex.EncodeToString(contractID[:]), - )) - } - var assetType xdr.AssetType - var assetCode, assetIssuer string - asset.MustExtract(&assetType, &assetCode, &assetIssuer) - row := history.ExpAssetStat{ - AssetType: assetType, - AssetCode: assetCode, - AssetIssuer: assetIssuer, - Accounts: history.ExpAssetStatAccounts{}, - Balances: newAssetStatBalance().ConvertToHistoryObject(), - Amount: "0", - NumAccounts: 0, - } - if stats, ok := contractAssetStats[contractID]; ok { - row.Accounts.Contracts = stats.numHolders - row.Balances.Contracts = stats.balance.String() - } - row.SetContractID(contractID) - assetStatsDeltas = append(assetStatsDeltas, row) - } - // all balances remaining in contractAssetStats do not belong to - // stellar asset contracts (because all stellar asset contracts must - // be in contractToAsset) so we can ignore them - return assetStatsDeltas, nil + return assetStats } diff --git a/services/horizon/internal/ingest/processors/asset_stats_set_test.go b/services/horizon/internal/ingest/processors/asset_stats_set_test.go index 016eda2bbb..f9989fdc9e 100644 --- a/services/horizon/internal/ingest/processors/asset_stats_set_test.go +++ b/services/horizon/internal/ingest/processors/asset_stats_set_test.go @@ -2,12 +2,9 @@ package processors import ( "math" - "math/big" "sort" "testing" - "github.com/stellar/go/keypair" - "github.com/stretchr/testify/assert" "github.com/stellar/go/ingest" @@ -16,21 +13,13 @@ import ( ) func TestEmptyAssetStatSet(t *testing.T) { - set := NewAssetStatSet("") - all, m, cs := set.All() - assert.Empty(t, all) - assert.Empty(t, cs) - assert.Empty(t, m) - - all, err := set.AllFromSnapshot() + set := NewAssetStatSet() + all := set.All() assert.Empty(t, all) - assert.NoError(t, err) } func assertAllEquals(t *testing.T, set AssetStatSet, expected []history.ExpAssetStat) { - all, m, cs := set.All() - assert.Empty(t, m) - assert.Empty(t, cs) + all := set.All() assertAssetStatsAreEqual(t, all, expected) } @@ -44,398 +33,8 @@ func assertAssetStatsAreEqual(t *testing.T, all []history.ExpAssetStat, expected } } -func assertAllFromSnapshotEquals(t *testing.T, set AssetStatSet, expected []history.ExpAssetStat) { - all, err := set.AllFromSnapshot() - assert.NoError(t, err) - assertAssetStatsAreEqual(t, all, expected) -} - -func TestAddContractData(t *testing.T) { - xlmID, err := xdr.MustNewNativeAsset().ContractID("passphrase") - assert.NoError(t, err) - usdcIssuer := keypair.MustRandom().Address() - usdcAsset := xdr.MustNewCreditAsset("USDC", usdcIssuer) - usdcID, err := usdcAsset.ContractID("passphrase") - assert.NoError(t, err) - etherIssuer := keypair.MustRandom().Address() - etherAsset := xdr.MustNewCreditAsset("ETHER", etherIssuer) - etherID, err := etherAsset.ContractID("passphrase") - assert.NoError(t, err) - uniAsset := xdr.MustNewCreditAsset("UNI", etherIssuer) - uniID, err := uniAsset.ContractID("passphrase") - assert.NoError(t, err) - - set := NewAssetStatSet("passphrase") - - xlmContractData, err := AssetToContractData(true, "", "", xlmID) - assert.NoError(t, err) - err = set.AddContractData(ingest.Change{ - Type: xdr.LedgerEntryTypeContractData, - Post: &xdr.LedgerEntry{ - Data: xlmContractData, - }, - }) - assert.NoError(t, err) - - err = set.AddContractData(ingest.Change{ - Type: xdr.LedgerEntryTypeContractData, - Post: &xdr.LedgerEntry{ - Data: BalanceToContractData(xlmID, [32]byte{}, 100), - }, - }) - assert.NoError(t, err) - - err = set.AddContractData(ingest.Change{ - Type: xdr.LedgerEntryTypeContractData, - Post: &xdr.LedgerEntry{ - Data: BalanceToContractData(uniID, [32]byte{}, 0), - }, - }) - assert.NoError(t, err) - - usdcContractData, err := AssetToContractData(false, "USDC", usdcIssuer, usdcID) - assert.NoError(t, err) - err = set.AddContractData(ingest.Change{ - Type: xdr.LedgerEntryTypeContractData, - Post: &xdr.LedgerEntry{ - Data: usdcContractData, - }, - }) - assert.NoError(t, err) - - etherContractData, err := AssetToContractData(false, "ETHER", etherIssuer, etherID) - assert.NoError(t, err) - err = set.AddContractData(ingest.Change{ - Type: xdr.LedgerEntryTypeContractData, - Post: &xdr.LedgerEntry{ - Data: etherContractData, - }, - }) - assert.NoError(t, err) - - err = set.AddContractData(ingest.Change{ - Type: xdr.LedgerEntryTypeContractData, - Post: &xdr.LedgerEntry{ - Data: BalanceToContractData(etherID, [32]byte{}, 50), - }, - }) - assert.NoError(t, err) - - err = set.AddContractData(ingest.Change{ - Type: xdr.LedgerEntryTypeContractData, - Post: &xdr.LedgerEntry{ - Data: BalanceToContractData(etherID, [32]byte{1}, 150), - }, - }) - assert.NoError(t, err) - - // negative balances will be ignored - err = set.AddContractData(ingest.Change{ - Type: xdr.LedgerEntryTypeContractData, - Post: &xdr.LedgerEntry{ - Data: balanceToContractData(etherID, [32]byte{1}, xdr.Int128Parts{Hi: -1, Lo: 0}), - }, - }) - assert.NoError(t, err) - - btcAsset := xdr.MustNewCreditAsset("BTC", etherIssuer) - btcID, err := btcAsset.ContractID("passphrase") - assert.NoError(t, err) - - err = set.AddContractData(ingest.Change{ - Type: xdr.LedgerEntryTypeContractData, - Post: &xdr.LedgerEntry{ - Data: BalanceToContractData(btcID, [32]byte{2}, 300), - }, - }) - assert.NoError(t, err) - - assert.NoError( - t, - set.AddTrustline(trustlineChange(nil, &xdr.TrustLineEntry{ - AccountId: xdr.MustAddress("GAOQJGUAB7NI7K7I62ORBXMN3J4SSWQUQ7FOEPSDJ322W2HMCNWPHXFB"), - Asset: xdr.MustNewCreditAsset("ETHER", etherIssuer).ToTrustLineAsset(), - Balance: 1, - Flags: xdr.Uint32(xdr.TrustLineFlagsAuthorizedFlag), - })), - ) - - all, m, cs := set.All() - assert.Len(t, all, 1) - etherAssetStat := history.ExpAssetStat{ - AssetType: xdr.AssetTypeAssetTypeCreditAlphanum12, - AssetCode: "ETHER", - AssetIssuer: etherIssuer, - Accounts: history.ExpAssetStatAccounts{ - Authorized: 1, - }, - Balances: history.ExpAssetStatBalances{ - Authorized: "1", - AuthorizedToMaintainLiabilities: "0", - Unauthorized: "0", - ClaimableBalances: "0", - LiquidityPools: "0", - Contracts: "0", - }, - Amount: "1", - NumAccounts: 1, - } - assert.True(t, all[0].Equals(etherAssetStat)) - assert.Len(t, m, 2) - assert.True(t, m[usdcID].Equals(usdcAsset)) - assert.True(t, m[etherID].Equals(etherAsset)) - assert.Len(t, cs, 2) - assert.Equal(t, cs[etherID].numHolders, int32(2)) - assert.Zero(t, cs[etherID].balance.Cmp(big.NewInt(200))) - assert.Equal(t, cs[btcID].numHolders, int32(1)) - assert.Zero(t, cs[btcID].balance.Cmp(big.NewInt(300))) - - usdcAssetStat := history.ExpAssetStat{ - AssetType: xdr.AssetTypeAssetTypeCreditAlphanum4, - AssetCode: "USDC", - AssetIssuer: usdcIssuer, - Accounts: history.ExpAssetStatAccounts{}, - Balances: newAssetStatBalance().ConvertToHistoryObject(), - Amount: "0", - NumAccounts: 0, - ContractID: nil, - } - - etherAssetStat.SetContractID(etherID) - etherAssetStat.Balances.Contracts = "200" - etherAssetStat.Accounts.Contracts = 2 - usdcAssetStat.SetContractID(usdcID) - - assertAllFromSnapshotEquals(t, set, []history.ExpAssetStat{ - etherAssetStat, - usdcAssetStat, - }) -} - -func TestUpdateContractBalance(t *testing.T) { - usdcIssuer := keypair.MustRandom().Address() - usdcAsset := xdr.MustNewCreditAsset("USDC", usdcIssuer) - usdcID, err := usdcAsset.ContractID("passphrase") - assert.NoError(t, err) - etherIssuer := keypair.MustRandom().Address() - etherAsset := xdr.MustNewCreditAsset("ETHER", etherIssuer) - etherID, err := etherAsset.ContractID("passphrase") - assert.NoError(t, err) - btcAsset := xdr.MustNewCreditAsset("BTC", etherIssuer) - btcID, err := btcAsset.ContractID("passphrase") - assert.NoError(t, err) - uniAsset := xdr.MustNewCreditAsset("UNI", etherIssuer) - uniID, err := uniAsset.ContractID("passphrase") - assert.NoError(t, err) - - set := NewAssetStatSet("passphrase") - - err = set.AddContractData(ingest.Change{ - Type: xdr.LedgerEntryTypeContractData, - Pre: &xdr.LedgerEntry{ - Data: BalanceToContractData(usdcID, [32]byte{}, 50), - }, - Post: &xdr.LedgerEntry{ - Data: BalanceToContractData(usdcID, [32]byte{}, 100), - }, - }) - assert.NoError(t, err) - - err = set.AddContractData(ingest.Change{ - Type: xdr.LedgerEntryTypeContractData, - Pre: &xdr.LedgerEntry{ - Data: BalanceToContractData(usdcID, [32]byte{2}, 30), - }, - Post: &xdr.LedgerEntry{ - Data: BalanceToContractData(usdcID, [32]byte{2}, 100), - }, - }) - assert.NoError(t, err) - - err = set.AddContractData(ingest.Change{ - Type: xdr.LedgerEntryTypeContractData, - Pre: &xdr.LedgerEntry{ - Data: BalanceToContractData(usdcID, [32]byte{4}, 0), - }, - Post: &xdr.LedgerEntry{ - Data: BalanceToContractData(usdcID, [32]byte{4}, 100), - }, - }) - assert.NoError(t, err) - - err = set.AddContractData(ingest.Change{ - Type: xdr.LedgerEntryTypeContractData, - Pre: &xdr.LedgerEntry{ - Data: BalanceToContractData(etherID, [32]byte{}, 200), - }, - Post: &xdr.LedgerEntry{ - Data: BalanceToContractData(etherID, [32]byte{}, 50), - }, - }) - assert.NoError(t, err) - - // negative balances will be ignored - err = set.AddContractData(ingest.Change{ - Type: xdr.LedgerEntryTypeContractData, - Pre: &xdr.LedgerEntry{ - Data: BalanceToContractData(etherID, [32]byte{}, 200), - }, - Post: &xdr.LedgerEntry{ - Data: balanceToContractData(etherID, [32]byte{1}, xdr.Int128Parts{Hi: -1, Lo: 0}), - }, - }) - assert.NoError(t, err) - - // negative balances will be ignored - err = set.AddContractData(ingest.Change{ - Type: xdr.LedgerEntryTypeContractData, - Pre: &xdr.LedgerEntry{ - Data: balanceToContractData(etherID, [32]byte{1}, xdr.Int128Parts{Hi: -1, Lo: 0}), - }, - Post: &xdr.LedgerEntry{ - Data: BalanceToContractData(etherID, [32]byte{}, 200), - }, - }) - assert.NoError(t, err) - - err = set.AddContractData(ingest.Change{ - Type: xdr.LedgerEntryTypeContractData, - Pre: &xdr.LedgerEntry{ - Data: BalanceToContractData(btcID, [32]byte{2}, 300), - }, - Post: &xdr.LedgerEntry{ - Data: BalanceToContractData(btcID, [32]byte{2}, 300), - }, - }) - assert.NoError(t, err) - - err = set.AddContractData(ingest.Change{ - Type: xdr.LedgerEntryTypeContractData, - Pre: &xdr.LedgerEntry{ - Data: BalanceToContractData(btcID, [32]byte{2}, 0), - }, - Post: &xdr.LedgerEntry{ - Data: BalanceToContractData(btcID, [32]byte{2}, 0), - }, - }) - assert.NoError(t, err) - - err = set.AddContractData(ingest.Change{ - Type: xdr.LedgerEntryTypeContractData, - Pre: &xdr.LedgerEntry{ - Data: BalanceToContractData(btcID, [32]byte{2}, 0), - }, - }) - assert.NoError(t, err) - - err = set.AddContractData(ingest.Change{ - Type: xdr.LedgerEntryTypeContractData, - Post: &xdr.LedgerEntry{ - Data: BalanceToContractData(btcID, [32]byte{2}, 0), - }, - }) - assert.NoError(t, err) - - err = set.AddContractData(ingest.Change{ - Type: xdr.LedgerEntryTypeContractData, - Pre: &xdr.LedgerEntry{ - Data: BalanceToContractData(uniID, [32]byte{2}, 300), - }, - }) - assert.NoError(t, err) - - err = set.AddContractData(ingest.Change{ - Type: xdr.LedgerEntryTypeContractData, - Pre: &xdr.LedgerEntry{ - Data: BalanceToContractData(uniID, [32]byte{3}, 100), - }, - Post: &xdr.LedgerEntry{ - Data: BalanceToContractData(uniID, [32]byte{3}, 0), - }, - }) - assert.NoError(t, err) - - err = set.AddContractData(ingest.Change{ - Type: xdr.LedgerEntryTypeContractData, - Pre: &xdr.LedgerEntry{ - Data: BalanceToContractData(uniID, [32]byte{4}, 100), - }, - Post: &xdr.LedgerEntry{ - Data: BalanceToContractData(uniID, [32]byte{4}, 50), - }, - }) - assert.NoError(t, err) - - all, m, cs := set.All() - assert.Empty(t, all) - assert.Empty(t, m) - - assert.Len(t, cs, 3) - assert.Equal(t, cs[usdcID].numHolders, int32(1)) - assert.Zero(t, cs[usdcID].balance.Cmp(big.NewInt(220))) - assert.Equal(t, cs[etherID].numHolders, int32(0)) - assert.Zero(t, cs[etherID].balance.Cmp(big.NewInt(-150))) - assert.Equal(t, cs[uniID].numHolders, int32(-2)) - assert.Zero(t, cs[uniID].balance.Cmp(big.NewInt(-450))) - - all, err = set.AllFromSnapshot() - assert.NoError(t, err) - assert.Empty(t, all) -} - -func TestRemoveContractData(t *testing.T) { - eurID, err := xdr.MustNewCreditAsset("EUR", trustLineIssuer.Address()).ContractID("passphrase") - assert.NoError(t, err) - set := NewAssetStatSet("passphrase") - - eurContractData, err := AssetToContractData(false, "EUR", trustLineIssuer.Address(), eurID) - assert.NoError(t, err) - err = set.AddContractData(ingest.Change{ - Type: xdr.LedgerEntryTypeContractData, - Pre: &xdr.LedgerEntry{ - Data: eurContractData, - }, - }) - assert.NoError(t, err) - - all, m, cs := set.All() - assert.Empty(t, all) - assert.Empty(t, cs) - assert.Len(t, m, 1) - asset, ok := m[eurID] - assert.True(t, ok) - assert.Nil(t, asset) -} - -func TestChangeContractData(t *testing.T) { - eurID, err := xdr.MustNewCreditAsset("EUR", trustLineIssuer.Address()).ContractID("passphrase") - assert.NoError(t, err) - - usdcIssuer := keypair.MustRandom().Address() - usdcID, err := xdr.MustNewCreditAsset("USDC", usdcIssuer).ContractID("passphrase") - assert.NoError(t, err) - - set := NewAssetStatSet("passphrase") - - eurContractData, err := AssetToContractData(false, "EUR", trustLineIssuer.Address(), eurID) - assert.NoError(t, err) - usdcContractData, err := AssetToContractData(false, "USDC", usdcIssuer, usdcID) - assert.NoError(t, err) - - err = set.AddContractData(ingest.Change{ - Type: xdr.LedgerEntryTypeContractData, - Pre: &xdr.LedgerEntry{ - Data: eurContractData, - }, - Post: &xdr.LedgerEntry{ - Data: usdcContractData, - }, - }) - assert.EqualError(t, err, "asset contract changed asset") -} - func TestAddNativeClaimableBalance(t *testing.T) { - set := NewAssetStatSet("") + set := NewAssetStatSet() claimableBalance := xdr.ClaimableBalanceEntry{ BalanceId: xdr.ClaimableBalanceId{}, Claimants: nil, @@ -451,10 +50,8 @@ func TestAddNativeClaimableBalance(t *testing.T) { }, }, )) - all, m, cs := set.All() + all := set.All() assert.Empty(t, all) - assert.Empty(t, m) - assert.Empty(t, cs) } func trustlineChange(pre, post *xdr.TrustLineEntry) ingest.Change { @@ -477,7 +74,7 @@ func trustlineChange(pre, post *xdr.TrustLineEntry) ingest.Change { } func TestAddPoolShareTrustline(t *testing.T) { - set := NewAssetStatSet("") + set := NewAssetStatSet() assert.NoError( t, set.AddTrustline(trustlineChange(nil, &xdr.TrustLineEntry{ @@ -491,14 +88,12 @@ func TestAddPoolShareTrustline(t *testing.T) { }, )), ) - all, m, cs := set.All() + all := set.All() assert.Empty(t, all) - assert.Empty(t, m) - assert.Empty(t, cs) } func TestAddAssetStats(t *testing.T) { - set := NewAssetStatSet("") + set := NewAssetStatSet() eur := "EUR" eurAssetStat := history.ExpAssetStat{ AssetType: xdr.AssetTypeAssetTypeCreditAlphanum4, @@ -513,7 +108,6 @@ func TestAddAssetStats(t *testing.T) { Unauthorized: "0", ClaimableBalances: "0", LiquidityPools: "0", - Contracts: "0", }, Amount: "1", NumAccounts: 1, @@ -619,7 +213,6 @@ func TestAddAssetStats(t *testing.T) { Unauthorized: "5", ClaimableBalances: "0", LiquidityPools: "0", - Contracts: "0", }, Amount: "3", NumAccounts: 1, @@ -638,7 +231,6 @@ func TestAddAssetStats(t *testing.T) { Unauthorized: "0", ClaimableBalances: "0", LiquidityPools: "0", - Contracts: "0", }, Amount: "10", NumAccounts: 1, @@ -648,7 +240,7 @@ func TestAddAssetStats(t *testing.T) { } func TestOverflowAssetStatSet(t *testing.T) { - set := NewAssetStatSet("") + set := NewAssetStatSet() eur := "EUR" err := set.AddTrustline(trustlineChange(nil, &xdr.TrustLineEntry{ AccountId: xdr.MustAddress("GAOQJGUAB7NI7K7I62ORBXMN3J4SSWQUQ7FOEPSDJ322W2HMCNWPHXFB"), @@ -659,12 +251,10 @@ func TestOverflowAssetStatSet(t *testing.T) { if err != nil { t.Fatalf("unexpected error %v", err) } - all, m, cs := set.All() + all := set.All() if len(all) != 1 { t.Fatalf("expected list of 1 asset stat but got %v", all) } - assert.Empty(t, m) - assert.Empty(t, cs) eurAssetStat := history.ExpAssetStat{ AssetType: xdr.AssetTypeAssetTypeCreditAlphanum4, @@ -679,7 +269,6 @@ func TestOverflowAssetStatSet(t *testing.T) { Unauthorized: "0", ClaimableBalances: "0", LiquidityPools: "0", - Contracts: "0", }, Amount: "9223372036854775807", NumAccounts: 1, @@ -697,12 +286,10 @@ func TestOverflowAssetStatSet(t *testing.T) { if err != nil { t.Fatalf("unexpected error %v", err) } - all, m, cs = set.All() + all = set.All() if len(all) != 1 { t.Fatalf("expected list of 1 asset stat but got %v", all) } - assert.Empty(t, m) - assert.Empty(t, cs) eurAssetStat = history.ExpAssetStat{ AssetType: xdr.AssetTypeAssetTypeCreditAlphanum4, @@ -717,7 +304,6 @@ func TestOverflowAssetStatSet(t *testing.T) { Unauthorized: "0", ClaimableBalances: "0", LiquidityPools: "0", - Contracts: "0", }, Amount: "18446744073709551614", NumAccounts: 2, diff --git a/services/horizon/internal/ingest/processors/contract_asset_stats.go b/services/horizon/internal/ingest/processors/contract_asset_stats.go new file mode 100644 index 0000000000..d39ceb6b6d --- /dev/null +++ b/services/horizon/internal/ingest/processors/contract_asset_stats.go @@ -0,0 +1,412 @@ +package processors + +import ( + "context" + "crypto/sha256" + "fmt" + "math/big" + + "github.com/stellar/go/ingest" + "github.com/stellar/go/services/horizon/internal/db2/history" + "github.com/stellar/go/support/errors" + "github.com/stellar/go/xdr" +) + +type assetContractStatValue struct { + contractID xdr.Hash + activeBalance *big.Int + activeHolders int32 + archivedBalance *big.Int + archivedHolders int32 +} + +func (v assetContractStatValue) ConvertToHistoryObject() history.ContractAssetStatRow { + return history.ContractAssetStatRow{ + ContractID: v.contractID[:], + Stat: history.ContractStat{ + ActiveBalance: v.activeBalance.String(), + ActiveHolders: v.activeHolders, + ArchivedBalance: v.archivedBalance.String(), + ArchivedHolders: v.archivedHolders, + }, + } +} + +type contractAssetBalancesQ interface { + GetContractAssetBalances(ctx context.Context, keys []xdr.Hash) ([]history.ContractAssetBalance, error) + GetContractAssetBalancesExpiringAt(ctx context.Context, ledger uint32) ([]history.ContractAssetBalance, error) +} + +// ContractAssetStatSet represents a collection of asset stats for +// contract asset holders +type ContractAssetStatSet struct { + contractToAsset map[xdr.Hash]*xdr.Asset + contractAssetStats map[xdr.Hash]assetContractStatValue + createdBalances []history.ContractAssetBalance + removedBalances []xdr.Hash + updatedBalances map[xdr.Hash]*big.Int + removedExpirationEntries map[xdr.Hash]uint32 + createdExpirationEntries map[xdr.Hash]uint32 + updatedExpirationEntries map[xdr.Hash][2]uint32 + networkPassphrase string + assetStatsQ contractAssetBalancesQ + currentLedger uint32 +} + +// NewContractAssetStatSet constructs a new ContractAssetStatSet instance +func NewContractAssetStatSet( + assetStatsQ contractAssetBalancesQ, + networkPassphrase string, + removedExpirationEntries map[xdr.Hash]uint32, + createdExpirationEntries map[xdr.Hash]uint32, + updatedExpirationEntries map[xdr.Hash][2]uint32, + currentLedger uint32, +) *ContractAssetStatSet { + return &ContractAssetStatSet{ + contractToAsset: map[xdr.Hash]*xdr.Asset{}, + contractAssetStats: map[xdr.Hash]assetContractStatValue{}, + networkPassphrase: networkPassphrase, + assetStatsQ: assetStatsQ, + removedExpirationEntries: removedExpirationEntries, + createdExpirationEntries: createdExpirationEntries, + updatedExpirationEntries: updatedExpirationEntries, + currentLedger: currentLedger, + updatedBalances: map[xdr.Hash]*big.Int{}, + } +} + +// AddContractData updates the set to account for how a given contract data entry has changed. +// change must be a xdr.LedgerEntryTypeContractData type. +func (s *ContractAssetStatSet) AddContractData(ctx context.Context, change ingest.Change) error { + // skip ingestion of contract asset balances if we find an asset contract metadata entry + // because a ledger entry cannot be both an asset contract metadata entry and a + // contract asset balance. + if found, err := s.ingestAssetContractMetadata(change); err != nil { + return err + } else if found { + return nil + } + return s.ingestContractAssetBalance(ctx, change) +} + +func (s *ContractAssetStatSet) GetContractStats() []history.ContractAssetStatRow { + var contractStats []history.ContractAssetStatRow + for _, contractStat := range s.contractAssetStats { + contractStats = append(contractStats, contractStat.ConvertToHistoryObject()) + } + return contractStats +} + +func (s *ContractAssetStatSet) GetCreatedBalances() []history.ContractAssetBalance { + return s.createdBalances +} + +func (s *ContractAssetStatSet) GetAssetToContractMap() map[xdr.Hash]*xdr.Asset { + return s.contractToAsset +} + +func (s *ContractAssetStatSet) ingestAssetContractMetadata(change ingest.Change) (bool, error) { + if change.Pre != nil { + asset := AssetFromContractData(*change.Pre, s.networkPassphrase) + if asset == nil { + return false, nil + } + pContractID := change.Pre.Data.MustContractData().Contract.ContractId + if pContractID == nil { + return false, nil + } + contractID := *pContractID + if change.Post == nil { + s.contractToAsset[contractID] = nil + return true, nil + } + // The contract id for any soroban contract should never change and + // therefore we return a fatal ingestion error if we encounter + // a stellar asset changing contract ids. + postAsset := AssetFromContractData(*change.Post, s.networkPassphrase) + if postAsset == nil || !(*postAsset).Equals(*asset) { + return false, ingest.NewStateError(fmt.Errorf("asset contract changed asset")) + } + return true, nil + } else if change.Post != nil { + asset := AssetFromContractData(*change.Post, s.networkPassphrase) + if asset == nil { + return false, nil + } + if pContactID := change.Post.Data.MustContractData().Contract.ContractId; pContactID != nil { + s.contractToAsset[*pContactID] = asset + return true, nil + } + } + return false, nil +} + +func getKeyHash(ledgerEntry xdr.LedgerEntry) (xdr.Hash, error) { + lk, err := ledgerEntry.LedgerKey() + if err != nil { + return xdr.Hash{}, errors.Wrap(err, "could not extract ledger key") + } + bin, err := lk.MarshalBinary() + if err != nil { + return xdr.Hash{}, errors.Wrap(err, "could not marshal key") + } + return sha256.Sum256(bin), nil +} + +func (s *ContractAssetStatSet) ingestContractAssetBalance(ctx context.Context, change ingest.Change) error { + switch { + case change.Pre == nil && change.Post != nil: // created + pContractID := change.Post.Data.MustContractData().Contract.ContractId + if pContractID == nil { + return nil + } + + _, postAmt, postOk := ContractBalanceFromContractData(*change.Post, s.networkPassphrase) + // we only ingest created ledger entries if we determine that they resemble the shape of + // a Stellar Asset Contract balance ledger entry + if !postOk { + return nil + } + + keyHash, err := getKeyHash(*change.Post) + if err != nil { + return err + } + expirationLedger, ok := s.createdExpirationEntries[keyHash] + if !ok { + return nil + } + s.createdBalances = append(s.createdBalances, history.ContractAssetBalance{ + KeyHash: keyHash[:], + ContractID: (*pContractID)[:], + Amount: postAmt.String(), + ExpirationLedger: expirationLedger, + }) + + stat := s.getContractAssetStat(*pContractID) + if expirationLedger >= s.currentLedger { + stat.activeHolders++ + stat.activeBalance.Add(stat.activeBalance, postAmt) + } else { + stat.archivedHolders++ + stat.archivedBalance.Add(stat.archivedBalance, postAmt) + } + s.maybeAddContractAssetStat(*pContractID, stat) + case change.Pre != nil && change.Post == nil: // removed + pContractID := change.Pre.Data.MustContractData().Contract.ContractId + if pContractID == nil { + return nil + } + + keyHash, err := getKeyHash(*change.Pre) + if err != nil { + return err + } + // We always include the key hash in s.removedBalances even + // if the ledger entry is not a valid balance ledger entry. + // It's possible that a contract is able to forge a created + // balance ledger entry which matches the Stellar Asset Contract + // and later on the ledger entry is updated to an invalid state. + // In such a scenario we still want to remove the balance ledger + // entry from our db when the entry is removed from the ledger. + s.removedBalances = append(s.removedBalances, keyHash) + + _, preAmt, ok := ContractBalanceFromContractData(*change.Pre, s.networkPassphrase) + if !ok { + return nil + } + + expirationLedger, ok := s.removedExpirationEntries[keyHash] + if !ok { + return nil + } + + stat := s.getContractAssetStat(*pContractID) + if expirationLedger >= s.currentLedger { + stat.activeHolders-- + stat.activeBalance = new(big.Int).Sub(stat.activeBalance, preAmt) + } else { + stat.archivedHolders-- + stat.archivedBalance = new(big.Int).Sub(stat.archivedBalance, preAmt) + } + s.maybeAddContractAssetStat(*pContractID, stat) + case change.Pre != nil && change.Post != nil: // updated + pContractID := change.Pre.Data.MustContractData().Contract.ContractId + if pContractID == nil { + return nil + } + + holder, amt, ok := ContractBalanceFromContractData(*change.Pre, s.networkPassphrase) + if !ok { + return nil + } + + // if the updated ledger entry is not in the expected format then this + // cannot be emitted by the stellar asset contract, so ignore it + postHolder, postAmt, postOk := ContractBalanceFromContractData(*change.Post, s.networkPassphrase) + if !postOk || postHolder != holder { + return nil + } + + amtDelta := new(big.Int).Sub(postAmt, amt) + if amtDelta.Cmp(big.NewInt(0)) == 0 { + return nil + } + + keyHash, err := getKeyHash(*change.Post) + if err != nil { + return err + } + + var preExpiration, postExpiration uint32 + if expirationUpdate, ok := s.updatedExpirationEntries[keyHash]; ok { + preExpiration, postExpiration = expirationUpdate[0], expirationUpdate[1] + } else { + rows, err := s.assetStatsQ.GetContractAssetBalances(ctx, []xdr.Hash{keyHash}) + if err != nil { + return errors.Wrapf(err, "could not query contract asset balance for %v", keyHash) + } + if len(rows) == 0 { + return nil + } + if len(rows) != 1 { + return errors.Wrapf( + err, + "expected 1 contract asset balance for %v but got %v", + keyHash, + len(rows), + ) + } + preExpiration = rows[0].ExpirationLedger + postExpiration = preExpiration + } + if postExpiration < s.currentLedger { + return errors.Errorf( + "contract balance has invalid expiration ledger keyhash %v expiration ledger %v", + keyHash, + postExpiration, + ) + } + + s.updatedBalances[keyHash] = postAmt + stat := s.getContractAssetStat(*pContractID) + if preExpiration+1 >= s.currentLedger { // active balance was updated + stat.activeBalance.Add(stat.activeBalance, amtDelta) + } else { // balance was restored + stat.activeHolders++ + stat.archivedHolders-- + stat.activeBalance.Add(stat.activeBalance, postAmt) + stat.archivedBalance.Sub(stat.archivedBalance, amt) + } + s.maybeAddContractAssetStat(*pContractID, stat) + default: + return errors.Errorf("unexpected change Pre: %v Post: %v", change.Pre, change.Post) + } + return nil +} + +func (s *ContractAssetStatSet) ingestRestoredBalances(ctx context.Context) error { + var keyHashes []xdr.Hash + for keyHash, expirationUpdate := range s.updatedExpirationEntries { + prevExpirationLedger := expirationUpdate[0] + // prevExpirationLedger+1 >= s.currentLedger indicates that this contract balance is still + // active in our DB and therefore don't need to restore it. + // s.updatedBalances[keyHash] != nil indicates that this contract balance was already ingested + // in ingestContractAssetBalance() so we don't need to ingest it again here. + if prevExpirationLedger+1 >= s.currentLedger || s.updatedBalances[keyHash] != nil { + continue + } + keyHashes = append(keyHashes, keyHash) + } + if len(keyHashes) == 0 { + return nil + } + + rows, err := s.assetStatsQ.GetContractAssetBalances(ctx, keyHashes) + if err != nil { + return errors.Wrap(err, "Error fetching contract asset balances") + } + + for _, row := range rows { + var contractID xdr.Hash + copy(contractID[:], row.ContractID) + stat := s.getContractAssetStat(contractID) + amt, ok := new(big.Int).SetString(row.Amount, 10) + if !ok { + return errors.Errorf( + "contract balance %v has invalid amount: %v", + row.KeyHash, + row.Amount, + ) + } + + stat.activeHolders++ + stat.activeBalance.Add(stat.activeBalance, amt) + stat.archivedHolders-- + stat.archivedBalance.Sub(stat.archivedBalance, amt) + s.maybeAddContractAssetStat(contractID, stat) + } + + return nil +} + +func (s *ContractAssetStatSet) ingestExpiredBalances(ctx context.Context) error { + rows, err := s.assetStatsQ.GetContractAssetBalancesExpiringAt(ctx, s.currentLedger-1) + if err != nil { + return errors.Wrap(err, "Error fetching contract asset balances") + } + + for _, row := range rows { + var keyHash, contractID xdr.Hash + copy(keyHash[:], row.KeyHash) + + if _, ok := s.updatedExpirationEntries[keyHash]; ok { + // the expiration of this contract balance was bumped, so we can + // skip this contract balance since it is still active + continue + } + + copy(contractID[:], row.ContractID) + stat := s.getContractAssetStat(contractID) + amt, ok := new(big.Int).SetString(row.Amount, 10) + if !ok { + return errors.Errorf( + "contract balance %v has invalid amount: %v", + row.KeyHash, + row.Amount, + ) + } + + stat.activeHolders-- + stat.activeBalance.Sub(stat.activeBalance, amt) + stat.archivedHolders++ + stat.archivedBalance.Add(stat.archivedBalance, amt) + s.maybeAddContractAssetStat(contractID, stat) + } + + return nil +} + +func (s *ContractAssetStatSet) maybeAddContractAssetStat(contractID xdr.Hash, stat assetContractStatValue) { + if stat.archivedHolders == 0 && stat.activeHolders == 0 && + stat.activeBalance.Cmp(big.NewInt(0)) == 0 && + stat.archivedBalance.Cmp(big.NewInt(0)) == 0 { + delete(s.contractAssetStats, contractID) + } else { + s.contractAssetStats[contractID] = stat + } +} + +func (s *ContractAssetStatSet) getContractAssetStat(contractID xdr.Hash) assetContractStatValue { + stat, ok := s.contractAssetStats[contractID] + if !ok { + stat = assetContractStatValue{ + contractID: contractID, + activeBalance: big.NewInt(0), + activeHolders: 0, + archivedBalance: big.NewInt(0), + archivedHolders: 0, + } + } + return stat +} diff --git a/services/horizon/internal/ingest/processors/contract_asset_stats_test.go b/services/horizon/internal/ingest/processors/contract_asset_stats_test.go new file mode 100644 index 0000000000..ce89920ecd --- /dev/null +++ b/services/horizon/internal/ingest/processors/contract_asset_stats_test.go @@ -0,0 +1,636 @@ +package processors + +import ( + "context" + "crypto/sha256" + "math/big" + "testing" + + "github.com/stretchr/testify/assert" + "github.com/stretchr/testify/mock" + + "github.com/stellar/go/ingest" + "github.com/stellar/go/keypair" + "github.com/stellar/go/services/horizon/internal/db2/history" + "github.com/stellar/go/xdr" +) + +func getKeyHashForBalance(t *testing.T, assetContractId, holderID [32]byte) xdr.Hash { + ledgerKey := ContractBalanceLedgerKey(assetContractId, holderID) + bin, err := ledgerKey.MarshalBinary() + assert.NoError(t, err) + return sha256.Sum256(bin) +} + +func TestAddContractData(t *testing.T) { + xlmID, err := xdr.MustNewNativeAsset().ContractID("passphrase") + assert.NoError(t, err) + usdcIssuer := keypair.MustRandom().Address() + usdcAsset := xdr.MustNewCreditAsset("USDC", usdcIssuer) + usdcID, err := usdcAsset.ContractID("passphrase") + assert.NoError(t, err) + etherIssuer := keypair.MustRandom().Address() + etherAsset := xdr.MustNewCreditAsset("ETHER", etherIssuer) + etherID, err := etherAsset.ContractID("passphrase") + assert.NoError(t, err) + uniAsset := xdr.MustNewCreditAsset("UNI", etherIssuer) + uniID, err := uniAsset.ContractID("passphrase") + assert.NoError(t, err) + + set := NewContractAssetStatSet( + &history.MockQAssetStats{}, + "passphrase", + map[xdr.Hash]uint32{}, + map[xdr.Hash]uint32{}, + map[xdr.Hash][2]uint32{}, + 150, + ) + + xlmContractData, err := AssetToContractData(true, "", "", xlmID) + assert.NoError(t, err) + err = set.AddContractData(context.Background(), ingest.Change{ + Type: xdr.LedgerEntryTypeContractData, + Post: &xdr.LedgerEntry{ + Data: xlmContractData, + }, + }) + assert.NoError(t, err) + + xlmBalanceKeyHash := getKeyHashForBalance(t, xlmID, [32]byte{}) + assert.NoError(t, err) + set.createdExpirationEntries[xlmBalanceKeyHash] = 150 + err = set.AddContractData(context.Background(), ingest.Change{ + Type: xdr.LedgerEntryTypeContractData, + Post: &xdr.LedgerEntry{ + Data: BalanceToContractData(xlmID, [32]byte{}, 100), + }, + }) + assert.NoError(t, err) + + uniBalanceKeyHash := getKeyHashForBalance(t, uniID, [32]byte{}) + set.createdExpirationEntries[uniBalanceKeyHash] = 150 + err = set.AddContractData(context.Background(), ingest.Change{ + Type: xdr.LedgerEntryTypeContractData, + Post: &xdr.LedgerEntry{ + Data: BalanceToContractData(uniID, [32]byte{}, 0), + }, + }) + assert.NoError(t, err) + + usdcContractData, err := AssetToContractData(false, "USDC", usdcIssuer, usdcID) + assert.NoError(t, err) + err = set.AddContractData(context.Background(), ingest.Change{ + Type: xdr.LedgerEntryTypeContractData, + Post: &xdr.LedgerEntry{ + Data: usdcContractData, + }, + }) + assert.NoError(t, err) + + etherContractData, err := AssetToContractData(false, "ETHER", etherIssuer, etherID) + assert.NoError(t, err) + err = set.AddContractData(context.Background(), ingest.Change{ + Type: xdr.LedgerEntryTypeContractData, + Post: &xdr.LedgerEntry{ + Data: etherContractData, + }, + }) + assert.NoError(t, err) + + etherBalanceKeyHash := getKeyHashForBalance(t, etherID, [32]byte{}) + set.createdExpirationEntries[etherBalanceKeyHash] = 100 + err = set.AddContractData(context.Background(), ingest.Change{ + Type: xdr.LedgerEntryTypeContractData, + Post: &xdr.LedgerEntry{ + Data: BalanceToContractData(etherID, [32]byte{}, 50), + }, + }) + assert.NoError(t, err) + + otherEtherBalanceKeyHash := getKeyHashForBalance(t, etherID, [32]byte{1}) + set.createdExpirationEntries[otherEtherBalanceKeyHash] = 150 + err = set.AddContractData(context.Background(), ingest.Change{ + Type: xdr.LedgerEntryTypeContractData, + Post: &xdr.LedgerEntry{ + Data: BalanceToContractData(etherID, [32]byte{1}, 150), + }, + }) + assert.NoError(t, err) + + // negative balances will be ignored + err = set.AddContractData(context.Background(), ingest.Change{ + Type: xdr.LedgerEntryTypeContractData, + Post: &xdr.LedgerEntry{ + Data: balanceToContractData(etherID, [32]byte{1}, xdr.Int128Parts{Hi: -1, Lo: 0}), + }, + }) + assert.NoError(t, err) + + btcAsset := xdr.MustNewCreditAsset("BTC", etherIssuer) + btcID, err := btcAsset.ContractID("passphrase") + assert.NoError(t, err) + + err = set.AddContractData(context.Background(), ingest.Change{ + Type: xdr.LedgerEntryTypeContractData, + Post: &xdr.LedgerEntry{ + Data: BalanceToContractData(btcID, [32]byte{2}, 300), + }, + }) + assert.NoError(t, err) + + assert.Empty(t, set.updatedBalances) + assert.Empty(t, set.removedBalances) + assert.Len(t, set.contractToAsset, 2) + assert.True(t, set.contractToAsset[usdcID].Equals(usdcAsset)) + assert.True(t, set.contractToAsset[etherID].Equals(etherAsset)) + assert.Equal(t, []history.ContractAssetBalance{ + { + KeyHash: uniBalanceKeyHash[:], + ContractID: uniID[:], + Amount: "0", + ExpirationLedger: 150, + }, + { + KeyHash: etherBalanceKeyHash[:], + ContractID: etherID[:], + Amount: "50", + ExpirationLedger: 100, + }, + { + KeyHash: otherEtherBalanceKeyHash[:], + ContractID: etherID[:], + Amount: "150", + ExpirationLedger: 150, + }, + }, set.createdBalances) + assert.ElementsMatch(t, set.GetContractStats(), []history.ContractAssetStatRow{ + { + ContractID: uniID[:], + Stat: history.ContractStat{ + ActiveBalance: "0", + ArchivedBalance: "0", + ActiveHolders: 1, + ArchivedHolders: 0, + }, + }, + { + ContractID: etherID[:], + Stat: history.ContractStat{ + ActiveBalance: "150", + ArchivedBalance: "50", + ActiveHolders: 1, + ArchivedHolders: 1, + }, + }, + }) +} + +func TestUpdateContractBalance(t *testing.T) { + usdcIssuer := keypair.MustRandom().Address() + usdcAsset := xdr.MustNewCreditAsset("USDC", usdcIssuer) + usdcID, err := usdcAsset.ContractID("passphrase") + assert.NoError(t, err) + etherIssuer := keypair.MustRandom().Address() + etherAsset := xdr.MustNewCreditAsset("ETHER", etherIssuer) + etherID, err := etherAsset.ContractID("passphrase") + assert.NoError(t, err) + btcAsset := xdr.MustNewCreditAsset("BTC", etherIssuer) + btcID, err := btcAsset.ContractID("passphrase") + assert.NoError(t, err) + uniAsset := xdr.MustNewCreditAsset("UNI", etherIssuer) + uniID, err := uniAsset.ContractID("passphrase") + assert.NoError(t, err) + + mockQ := &history.MockQAssetStats{} + set := NewContractAssetStatSet( + mockQ, + "passphrase", + map[xdr.Hash]uint32{}, + map[xdr.Hash]uint32{}, + map[xdr.Hash][2]uint32{}, + 150, + ) + expectedBalances := map[xdr.Hash]string{} + + keyHash := getKeyHashForBalance(t, usdcID, [32]byte{}) + set.updatedExpirationEntries[keyHash] = [2]uint32{160, 170} + expectedBalances[keyHash] = "100" + err = set.AddContractData(context.Background(), ingest.Change{ + Type: xdr.LedgerEntryTypeContractData, + Pre: &xdr.LedgerEntry{ + Data: BalanceToContractData(usdcID, [32]byte{}, 50), + }, + Post: &xdr.LedgerEntry{ + Data: BalanceToContractData(usdcID, [32]byte{}, 100), + }, + }) + assert.NoError(t, err) + + keyHash = getKeyHashForBalance(t, usdcID, [32]byte{2}) + ctx := context.Background() + mockQ.On("GetContractAssetBalances", ctx, []xdr.Hash{keyHash}). + Return([]history.ContractAssetBalance{ + { + KeyHash: keyHash[:], + ContractID: usdcID[:], + Amount: "30", + ExpirationLedger: 180, + }, + }, nil).Once() + expectedBalances[keyHash] = "100" + err = set.AddContractData(context.Background(), ingest.Change{ + Type: xdr.LedgerEntryTypeContractData, + Pre: &xdr.LedgerEntry{ + Data: BalanceToContractData(usdcID, [32]byte{2}, 30), + }, + Post: &xdr.LedgerEntry{ + Data: BalanceToContractData(usdcID, [32]byte{2}, 100), + }, + }) + assert.NoError(t, err) + + keyHash = getKeyHashForBalance(t, usdcID, [32]byte{4}) + // balances which don't exist in the db will be ignored + mockQ.On("GetContractAssetBalances", ctx, []xdr.Hash{keyHash}). + Return([]history.ContractAssetBalance{}, nil).Once() + err = set.AddContractData(context.Background(), ingest.Change{ + Type: xdr.LedgerEntryTypeContractData, + Pre: &xdr.LedgerEntry{ + Data: BalanceToContractData(usdcID, [32]byte{4}, 0), + }, + Post: &xdr.LedgerEntry{ + Data: BalanceToContractData(usdcID, [32]byte{4}, 100), + }, + }) + assert.NoError(t, err) + + keyHash = getKeyHashForBalance(t, etherID, [32]byte{}) + mockQ.On("GetContractAssetBalances", ctx, []xdr.Hash{keyHash}). + Return([]history.ContractAssetBalance{ + { + KeyHash: keyHash[:], + ContractID: etherID[:], + Amount: "200", + ExpirationLedger: 200, + }, + }, nil).Once() + expectedBalances[keyHash] = "50" + err = set.AddContractData(context.Background(), ingest.Change{ + Type: xdr.LedgerEntryTypeContractData, + Pre: &xdr.LedgerEntry{ + Data: BalanceToContractData(etherID, [32]byte{}, 200), + }, + Post: &xdr.LedgerEntry{ + Data: BalanceToContractData(etherID, [32]byte{}, 50), + }, + }) + assert.NoError(t, err) + + // negative balances will be ignored + err = set.AddContractData(context.Background(), ingest.Change{ + Type: xdr.LedgerEntryTypeContractData, + Pre: &xdr.LedgerEntry{ + Data: BalanceToContractData(etherID, [32]byte{}, 200), + }, + Post: &xdr.LedgerEntry{ + Data: balanceToContractData(etherID, [32]byte{1}, xdr.Int128Parts{Hi: -1, Lo: 0}), + }, + }) + assert.NoError(t, err) + + // negative balances will be ignored + err = set.AddContractData(context.Background(), ingest.Change{ + Type: xdr.LedgerEntryTypeContractData, + Pre: &xdr.LedgerEntry{ + Data: balanceToContractData(etherID, [32]byte{1}, xdr.Int128Parts{Hi: -1, Lo: 0}), + }, + Post: &xdr.LedgerEntry{ + Data: BalanceToContractData(etherID, [32]byte{}, 200), + }, + }) + assert.NoError(t, err) + + // balances where the amount doesn't change will be ignored + err = set.AddContractData(context.Background(), ingest.Change{ + Type: xdr.LedgerEntryTypeContractData, + Pre: &xdr.LedgerEntry{ + Data: BalanceToContractData(btcID, [32]byte{2}, 300), + }, + Post: &xdr.LedgerEntry{ + Data: BalanceToContractData(btcID, [32]byte{2}, 300), + }, + }) + assert.NoError(t, err) + + keyHash = getKeyHashForBalance(t, btcID, [32]byte{5}) + mockQ.On("GetContractAssetBalances", ctx, []xdr.Hash{keyHash}). + Return([]history.ContractAssetBalance{ + { + KeyHash: keyHash[:], + ContractID: btcID[:], + Amount: "10", + ExpirationLedger: 20, + }, + }, nil).Once() + err = set.AddContractData(context.Background(), ingest.Change{ + Type: xdr.LedgerEntryTypeContractData, + Pre: &xdr.LedgerEntry{ + Data: BalanceToContractData(btcID, [32]byte{5}, 10), + }, + Post: &xdr.LedgerEntry{ + Data: BalanceToContractData(btcID, [32]byte{5}, 15), + }, + }) + assert.ErrorContains(t, err, "contract balance has invalid expiration ledger keyhash") + + keyHash = getKeyHashForBalance(t, btcID, [32]byte{6}) + set.updatedExpirationEntries[keyHash] = [2]uint32{100, 110} + err = set.AddContractData(context.Background(), ingest.Change{ + Type: xdr.LedgerEntryTypeContractData, + Pre: &xdr.LedgerEntry{ + Data: BalanceToContractData(btcID, [32]byte{6}, 120), + }, + Post: &xdr.LedgerEntry{ + Data: BalanceToContractData(btcID, [32]byte{6}, 135), + }, + }) + assert.ErrorContains(t, err, "contract balance has invalid expiration ledger keyhash") + + keyHash = getKeyHashForBalance(t, uniID, [32]byte{4}) + set.updatedExpirationEntries[keyHash] = [2]uint32{100, 170} + expectedBalances[keyHash] = "75" + err = set.AddContractData(context.Background(), ingest.Change{ + Type: xdr.LedgerEntryTypeContractData, + Pre: &xdr.LedgerEntry{ + Data: BalanceToContractData(uniID, [32]byte{4}, 50), + }, + Post: &xdr.LedgerEntry{ + Data: BalanceToContractData(uniID, [32]byte{4}, 75), + }, + }) + assert.NoError(t, err) + + assert.Empty(t, set.contractToAsset) + assert.Empty(t, set.removedBalances) + assert.Empty(t, set.createdExpirationEntries) + for key, amt := range set.updatedBalances { + assert.Equal(t, expectedBalances[key], amt.String()) + delete(expectedBalances, key) + } + assert.Empty(t, expectedBalances) + + assert.ElementsMatch(t, set.GetContractStats(), []history.ContractAssetStatRow{ + { + ContractID: usdcID[:], + Stat: history.ContractStat{ + ActiveBalance: "120", + ActiveHolders: 0, + ArchivedBalance: "0", + ArchivedHolders: 0, + }, + }, + { + ContractID: etherID[:], + Stat: history.ContractStat{ + ActiveBalance: "-150", + ActiveHolders: 0, + ArchivedBalance: "0", + ArchivedHolders: 0, + }, + }, + { + ContractID: uniID[:], + Stat: history.ContractStat{ + ActiveBalance: "75", + ActiveHolders: 1, + ArchivedBalance: "-50", + ArchivedHolders: -1, + }, + }, + }) + + mockQ.AssertExpectations(t) +} + +func TestRemoveContractData(t *testing.T) { + usdcIssuer := keypair.MustRandom().Address() + usdcAsset := xdr.MustNewCreditAsset("USDC", usdcIssuer) + usdcID, err := usdcAsset.ContractID("passphrase") + assert.NoError(t, err) + + set := NewContractAssetStatSet( + &history.MockQAssetStats{}, + "passphrase", + map[xdr.Hash]uint32{}, + map[xdr.Hash]uint32{}, + map[xdr.Hash][2]uint32{}, + 150, + ) + + usdcContractData, err := AssetToContractData(false, "USDC", usdcIssuer, usdcID) + assert.NoError(t, err) + err = set.AddContractData(context.Background(), ingest.Change{ + Type: xdr.LedgerEntryTypeContractData, + Pre: &xdr.LedgerEntry{ + Data: usdcContractData, + }, + }) + assert.NoError(t, err) + + keyHash := getKeyHashForBalance(t, usdcID, [32]byte{}) + set.removedExpirationEntries[keyHash] = 170 + err = set.AddContractData(context.Background(), ingest.Change{ + Type: xdr.LedgerEntryTypeContractData, + Pre: &xdr.LedgerEntry{ + Data: BalanceToContractData(usdcID, [32]byte{}, 50), + }, + }) + assert.NoError(t, err) + + keyHash1 := getKeyHashForBalance(t, usdcID, [32]byte{1}) + set.removedExpirationEntries[keyHash1] = 100 + err = set.AddContractData(context.Background(), ingest.Change{ + Type: xdr.LedgerEntryTypeContractData, + Pre: &xdr.LedgerEntry{ + Data: BalanceToContractData(usdcID, [32]byte{1}, 20), + }, + }) + assert.NoError(t, err) + + keyHash2 := getKeyHashForBalance(t, usdcID, [32]byte{2}) + err = set.AddContractData(context.Background(), ingest.Change{ + Type: xdr.LedgerEntryTypeContractData, + Pre: &xdr.LedgerEntry{ + Data: BalanceToContractData(usdcID, [32]byte{2}, 34), + }, + }) + assert.NoError(t, err) + + assert.Equal(t, []xdr.Hash{keyHash, keyHash1, keyHash2}, set.removedBalances) + assert.Len(t, set.contractToAsset, 1) + asset, ok := set.contractToAsset[usdcID] + assert.Nil(t, asset) + assert.True(t, ok) + + assert.ElementsMatch(t, set.GetContractStats(), []history.ContractAssetStatRow{ + { + ContractID: usdcID[:], + Stat: history.ContractStat{ + ActiveBalance: "-50", + ActiveHolders: -1, + ArchivedBalance: "-20", + ArchivedHolders: -1, + }, + }, + }) +} + +func TestIngestRestoredBalances(t *testing.T) { + usdcIssuer := keypair.MustRandom().Address() + usdcAsset := xdr.MustNewCreditAsset("USDC", usdcIssuer) + usdcID, err := usdcAsset.ContractID("passphrase") + assert.NoError(t, err) + + mockQ := &history.MockQAssetStats{} + set := NewContractAssetStatSet( + mockQ, + "passphrase", + map[xdr.Hash]uint32{}, + map[xdr.Hash]uint32{}, + map[xdr.Hash][2]uint32{}, + 150, + ) + + usdcKeyHash := getKeyHashForBalance(t, usdcID, [32]byte{}) + set.updatedBalances[usdcKeyHash] = big.NewInt(190) + set.updatedExpirationEntries[usdcKeyHash] = [2]uint32{120, 170} + + usdcKeyHash1 := getKeyHashForBalance(t, usdcID, [32]byte{1}) + set.updatedExpirationEntries[usdcKeyHash1] = [2]uint32{149, 190} + + usdcKeyHash2 := getKeyHashForBalance(t, usdcID, [32]byte{2}) + set.updatedExpirationEntries[usdcKeyHash2] = [2]uint32{100, 200} + + usdcKeyHash3 := getKeyHashForBalance(t, usdcID, [32]byte{3}) + set.updatedExpirationEntries[usdcKeyHash3] = [2]uint32{150, 210} + + usdcKeyHash4 := getKeyHashForBalance(t, usdcID, [32]byte{4}) + set.updatedExpirationEntries[usdcKeyHash4] = [2]uint32{170, 900} + + usdcKeyHash5 := getKeyHashForBalance(t, usdcID, [32]byte{5}) + set.updatedExpirationEntries[usdcKeyHash5] = [2]uint32{120, 600} + + ctx := context.Background() + + mockQ.On("GetContractAssetBalances", ctx, mock.MatchedBy(func(keys []xdr.Hash) bool { + return assert.ElementsMatch(t, []xdr.Hash{usdcKeyHash2, usdcKeyHash5}, keys) + })). + Return([]history.ContractAssetBalance{ + { + KeyHash: usdcKeyHash2[:], + ContractID: usdcID[:], + Amount: "67", + ExpirationLedger: 100, + }, + { + KeyHash: usdcKeyHash5[:], + ContractID: usdcID[:], + Amount: "200", + ExpirationLedger: 120, + }, + }, nil).Once() + + assert.NoError(t, set.ingestRestoredBalances(ctx)) + assert.ElementsMatch(t, set.GetContractStats(), []history.ContractAssetStatRow{ + { + ContractID: usdcID[:], + Stat: history.ContractStat{ + ActiveBalance: "267", + ActiveHolders: 2, + ArchivedBalance: "-267", + ArchivedHolders: -2, + }, + }, + }) + + mockQ.AssertExpectations(t) +} + +func TestIngestExpiredBalances(t *testing.T) { + usdcIssuer := keypair.MustRandom().Address() + usdcAsset := xdr.MustNewCreditAsset("USDC", usdcIssuer) + usdcID, err := usdcAsset.ContractID("passphrase") + assert.NoError(t, err) + + etherIssuer := keypair.MustRandom().Address() + etherAsset := xdr.MustNewCreditAsset("ETHER", etherIssuer) + etherID, err := etherAsset.ContractID("passphrase") + assert.NoError(t, err) + + mockQ := &history.MockQAssetStats{} + set := NewContractAssetStatSet( + mockQ, + "passphrase", + map[xdr.Hash]uint32{}, + map[xdr.Hash]uint32{}, + map[xdr.Hash][2]uint32{}, + 150, + ) + + usdcKeyHash := getKeyHashForBalance(t, usdcID, [32]byte{}) + usdcKeyHash1 := getKeyHashForBalance(t, usdcID, [32]byte{1}) + ethKeyHash := getKeyHashForBalance(t, etherID, [32]byte{}) + ethKeyHash1 := getKeyHashForBalance(t, etherID, [32]byte{1}) + set.updatedExpirationEntries[ethKeyHash1] = [2]uint32{149, 180} + ctx := context.Background() + mockQ.On("GetContractAssetBalancesExpiringAt", ctx, set.currentLedger-1). + Return([]history.ContractAssetBalance{ + { + KeyHash: usdcKeyHash[:], + ContractID: usdcID[:], + Amount: "67", + ExpirationLedger: 149, + }, + { + KeyHash: usdcKeyHash1[:], + ContractID: usdcID[:], + Amount: "200", + ExpirationLedger: 149, + }, + { + KeyHash: ethKeyHash[:], + ContractID: etherID[:], + Amount: "8", + ExpirationLedger: 149, + }, + { + KeyHash: ethKeyHash1[:], + ContractID: etherID[:], + Amount: "67", + ExpirationLedger: 149, + }, + }, nil).Once() + + assert.NoError(t, set.ingestExpiredBalances(ctx)) + assert.ElementsMatch(t, set.GetContractStats(), []history.ContractAssetStatRow{ + { + ContractID: usdcID[:], + Stat: history.ContractStat{ + ActiveBalance: "-267", + ActiveHolders: -2, + ArchivedBalance: "267", + ArchivedHolders: 2, + }, + }, + { + ContractID: etherID[:], + Stat: history.ContractStat{ + ActiveBalance: "-8", + ActiveHolders: -1, + ArchivedBalance: "8", + ArchivedHolders: 1, + }, + }, + }) + mockQ.AssertExpectations(t) +} diff --git a/services/horizon/internal/ingest/processors/contract_data.go b/services/horizon/internal/ingest/processors/contract_data.go index bce4ac6b25..7b15bd9c5b 100644 --- a/services/horizon/internal/ingest/processors/contract_data.go +++ b/services/horizon/internal/ingest/processors/contract_data.go @@ -458,7 +458,10 @@ func BalanceToContractData(assetContractId, holderID [32]byte, amt uint64) xdr.L }) } -func balanceToContractData(assetContractId, holderID [32]byte, amt xdr.Int128Parts) xdr.LedgerEntryData { +// ContractBalanceLedgerKey constructs the ledger key corresponding to the +// asset balance of a contract holder written to contract storage by the +// Stellar Asset Contract. +func ContractBalanceLedgerKey(assetContractId, holderID [32]byte) xdr.LedgerKey { holder := xdr.Hash(holderID) scAddress := &xdr.ScAddress{ Type: xdr.ScAddressTypeScAddressTypeContract, @@ -468,6 +471,25 @@ func balanceToContractData(assetContractId, holderID [32]byte, amt xdr.Int128Par xdr.ScVal{Type: xdr.ScValTypeScvSymbol, Sym: &balanceMetadataSym}, xdr.ScVal{Type: xdr.ScValTypeScvAddress, Address: scAddress}, } + var contractIDHash xdr.Hash = assetContractId + return xdr.LedgerKey{ + Type: xdr.LedgerEntryTypeContractData, + ContractData: &xdr.LedgerKeyContractData{ + Contract: xdr.ScAddress{ + Type: xdr.ScAddressTypeScAddressTypeContract, + ContractId: &contractIDHash, + }, + Key: xdr.ScVal{ + Type: xdr.ScValTypeScvVec, + Vec: &keyVec, + }, + Durability: xdr.ContractDataDurabilityPersistent, + }, + } +} + +func balanceToContractData(assetContractId, holderID [32]byte, amt xdr.Int128Parts) xdr.LedgerEntryData { + ledgerKey := ContractBalanceLedgerKey(assetContractId, holderID) amountSym := xdr.ScSymbol("amount") authorizedSym := xdr.ScSymbol("authorized") @@ -506,19 +528,13 @@ func balanceToContractData(assetContractId, holderID [32]byte, amt xdr.Int128Par }, } - var contractIDHash xdr.Hash = assetContractId + contractData := ledgerKey.MustContractData() return xdr.LedgerEntryData{ Type: xdr.LedgerEntryTypeContractData, ContractData: &xdr.ContractDataEntry{ - Contract: xdr.ScAddress{ - Type: xdr.ScAddressTypeScAddressTypeContract, - ContractId: &contractIDHash, - }, - Key: xdr.ScVal{ - Type: xdr.ScValTypeScvVec, - Vec: &keyVec, - }, - Durability: xdr.ContractDataDurabilityPersistent, + Contract: contractData.Contract, + Key: contractData.Key, + Durability: contractData.Durability, Val: xdr.ScVal{ Type: xdr.ScValTypeScvMap, Map: &dataMap, diff --git a/services/horizon/internal/ingest/verify.go b/services/horizon/internal/ingest/verify.go index c7d6c8f0d6..bf1ddbe5b5 100644 --- a/services/horizon/internal/ingest/verify.go +++ b/services/horizon/internal/ingest/verify.go @@ -1,6 +1,7 @@ package ingest import ( + "bytes" "context" "database/sql" "encoding/hex" @@ -29,7 +30,7 @@ const assetStatsBatchSize = 500 // check them. // There is a test that checks it, to fix it: update the actual `verifyState` // method instead of just updating this value! -const stateVerifierExpectedIngestionVersion = 17 +const stateVerifierExpectedIngestionVersion = 18 // verifyState is called as a go routine from pipeline post hook every 64 // ledgers. It checks if the state is correct. If another go routine is already @@ -180,7 +181,9 @@ func (s *system) verifyState(verifyAgainstLatestCheckpoint bool) error { return false, entry }) - assetStats := processors.NewAssetStatSet(s.config.NetworkPassphrase) + assetStats := processors.NewAssetStatSet() + createdExpirationEntries := map[xdr.Hash]uint32{} + var contractDataEntries []xdr.LedgerEntry total := int64(0) for { var entries []xdr.LedgerEntry @@ -234,21 +237,18 @@ func (s *system) verifyState(verifyAgainstLatestCheckpoint bool) error { if err = verifier.Write(entry); err != nil { return err } - err = assetStats.AddContractData(ingest.Change{ - Type: xdr.LedgerEntryTypeContractData, - Post: &entry, - }) - if err != nil { - return errors.Wrap(err, "Error running assetStats.AddContractData") - } + contractDataEntries = append(contractDataEntries, entry) totalByType["contract_data"]++ case xdr.LedgerEntryTypeTtl: - // we don't store ttl entries in the db, - // so there is nothing to verify in that case. + // we don't store all expiration entries in the db, + // we will only verify expiration of contract balances in the horizon db. if err = verifier.Write(entry); err != nil { return err } totalByType["ttl"]++ + ttl := entry.Data.MustTtl() + createdExpirationEntries[ttl.KeyHash] = uint32(ttl.LiveUntilLedgerSeq) + totalByType["expiration"]++ default: return errors.New("GetLedgerEntries return unexpected type") } @@ -288,6 +288,24 @@ func (s *system) verifyState(verifyAgainstLatestCheckpoint bool) error { localLog.WithField("total", total).Info("Batch added to StateVerifier") } + contractAssetStatSet := processors.NewContractAssetStatSet( + historyQ, + s.config.NetworkPassphrase, + map[xdr.Hash]uint32{}, + createdExpirationEntries, + map[xdr.Hash][2]uint32{}, + ledgerSequence, + ) + for i := range contractDataEntries { + entry := contractDataEntries[i] + if err = contractAssetStatSet.AddContractData(ctx, ingest.Change{ + Type: xdr.LedgerEntryTypeContractData, + Post: &entry, + }); err != nil { + return errors.Wrap(err, "Error ingesting contract data") + } + } + localLog.WithField("total", total).Info("Finished writing to StateVerifier") countAccounts, err := historyQ.CountAccounts(ctx) @@ -328,7 +346,7 @@ func (s *system) verifyState(verifyAgainstLatestCheckpoint bool) error { return errors.Wrap(err, "verifier.Verify failed") } - err = checkAssetStats(ctx, assetStats, historyQ) + err = checkAssetStats(ctx, assetStats, contractAssetStatSet, historyQ, s.config.NetworkPassphrase) if err != nil { return errors.Wrap(err, "checkAssetStats failed") } @@ -338,16 +356,26 @@ func (s *system) verifyState(verifyAgainstLatestCheckpoint bool) error { return nil } -func checkAssetStats(ctx context.Context, set processors.AssetStatSet, q history.IngestionQ) error { +func checkAssetStats( + ctx context.Context, + set processors.AssetStatSet, + contractAssetStatSet *processors.ContractAssetStatSet, + q history.IngestionQ, + networkPassphrase string, +) error { page := db2.PageQuery{ Order: "asc", Limit: assetStatsBatchSize, } - assetStats, err := set.AllFromSnapshot() + contractToAsset := contractAssetStatSet.GetAssetToContractMap() + assetStats := set.All() + var err error + assetStats, err = processors.IncludeContractIDsInAssetStats(networkPassphrase, assetStats, contractToAsset) if err != nil { - return errors.Wrap(err, "could not fetch asset stats from asset stat set") + return err } + all := map[string]history.ExpAssetStat{} for _, assetStat := range assetStats { // no need to handle the native asset because asset stats only @@ -355,6 +383,24 @@ func checkAssetStats(ctx context.Context, set processors.AssetStatSet, q history all[assetStat.AssetCode+":"+assetStat.AssetIssuer] = assetStat } + contractToStats := map[xdr.Hash]history.ContractAssetStatRow{} + for _, row := range contractAssetStatSet.GetContractStats() { + var contractID xdr.Hash + copy(contractID[:], row.ContractID) + contractToStats[contractID] = row + } + + // only check contract asset balances which belong to stellar asset contracts + // because other balances may be forged. + var filteredBalances []history.ContractAssetBalance + for _, balance := range contractAssetStatSet.GetCreatedBalances() { + var contractID xdr.Hash + copy(contractID[:], balance.ContractID) + if _, ok := contractToAsset[contractID]; ok { + filteredBalances = append(filteredBalances, balance) + } + } + for { assetStats, err := q.GetAssetStats(ctx, "", "", page) if err != nil { @@ -377,7 +423,7 @@ func checkAssetStats(ctx context.Context, set processors.AssetStatSet, q history } delete(all, key) - if !fromSet.Equals(assetStat) { + if !fromSet.Equals(assetStat.ExpAssetStat) { return ingest.NewStateError( fmt.Errorf( "db asset stat with code %s issuer %s does not match asset stat from HAS: expected=%v actual=%v", @@ -385,6 +431,68 @@ func checkAssetStats(ctx context.Context, set processors.AssetStatSet, q history ), ) } + + if contractID, ok := assetStat.GetContractID(); ok { + asset := contractToAsset[contractID] + if asset == nil { + return ingest.NewStateError( + fmt.Errorf( + "asset %v has contract id %v in db but contract id is not in HAS", + key, + contractID, + ), + ) + } + + var assetType xdr.AssetType + var code, issuer string + if err := asset.Extract(&assetType, &code, &issuer); err != nil { + return ingest.NewStateError( + fmt.Errorf( + "could not parse asset %v", + asset, + ), + ) + } + + if assetType != assetStat.AssetType || + assetStat.AssetCode != code || + assetStat.AssetIssuer != issuer { + return ingest.NewStateError( + fmt.Errorf( + "contract id %v mapped to asset %v in db does not match HAS %v", + contractID, + key, + code+":"+issuer, + ), + ) + } + + entry, ok := contractToStats[contractID] + if !ok { + entry = history.ContractAssetStatRow{ + ContractID: contractID[:], + Stat: history.ContractStat{ + ActiveBalance: "0", + ActiveHolders: 0, + ArchivedBalance: "0", + ArchivedHolders: 0, + }, + } + } + if assetStat.Contracts != entry.Stat { + return ingest.NewStateError( + fmt.Errorf( + "contract stats for contract id %v in db %v does not match HAS %v", + contractID, + assetStat.Contracts, + entry.Stat, + ), + ) + } + + delete(contractToAsset, contractID) + } } page.Cursor = assetStats[len(assetStats)-1].PagingToken() @@ -398,6 +506,80 @@ func checkAssetStats(ctx context.Context, set processors.AssetStatSet, q history ), ) } + + if err := checkContractBalances(ctx, filteredBalances, q); err != nil { + return err + } + return nil +} + +func checkContractBalances( + ctx context.Context, + balances []history.ContractAssetBalance, + q history.IngestionQ, +) error { + for i := 0; i < len(balances); { + end := i + assetStatsBatchSize + if end > len(balances) { + end = len(balances) + } + + subset := balances[i:end] + var keys []xdr.Hash + byKey := map[xdr.Hash]history.ContractAssetBalance{} + for _, balance := range subset { + var key xdr.Hash + copy(key[:], balance.KeyHash) + keys = append(keys, key) + byKey[key] = balance + } + + rows, err := q.GetContractAssetBalances(ctx, keys) + if err != nil { + return err + } + + for _, row := range rows { + var key xdr.Hash + copy(key[:], row.KeyHash) + expected := byKey[key] + + if !bytes.Equal(row.ContractID, expected.ContractID) { + return ingest.NewStateError( + fmt.Errorf( + "contract balance %v has contract %v in HAS but is %v in db", + key, + expected.ContractID, + row.ContractID, + ), + ) + } + + if row.ExpirationLedger != expected.ExpirationLedger { + return ingest.NewStateError( + fmt.Errorf( + "contract balance %v has expiration %v in HAS but is %v in db", + key, + expected.ExpirationLedger, + row.ExpirationLedger, + ), + ) + } + + if row.Amount != expected.Amount { + return ingest.NewStateError( + fmt.Errorf( + "contract balance %v has amount %v in HAS but is %v in db", + key, + expected.Amount, + row.Amount, + ), + ) + } + } + + i = end + } return nil } diff --git a/services/horizon/internal/ingest/verify_range_state_test.go b/services/horizon/internal/ingest/verify_range_state_test.go index f71aeb11e7..7440f7dce0 100644 --- a/services/horizon/internal/ingest/verify_range_state_test.go +++ b/services/horizon/internal/ingest/verify_range_state_test.go @@ -12,6 +12,9 @@ import ( "github.com/guregu/null" "github.com/guregu/null/zero" + "github.com/stretchr/testify/mock" + "github.com/stretchr/testify/suite" + "github.com/stellar/go/ingest" "github.com/stellar/go/ingest/ledgerbackend" "github.com/stellar/go/keypair" @@ -20,8 +23,6 @@ import ( "github.com/stellar/go/services/horizon/internal/ingest/processors" "github.com/stellar/go/support/errors" "github.com/stellar/go/xdr" - "github.com/stretchr/testify/mock" - "github.com/stretchr/testify/suite" ) func TestVerifyRangeStateTestSuite(t *testing.T) { @@ -544,30 +545,32 @@ func (s *VerifyRangeStateTestSuite) TestSuccessWithVerify() { clonedQ.MockQAssetStats.On("GetAssetStats", s.ctx, "", "", db2.PageQuery{ Order: "asc", Limit: assetStatsBatchSize, - }).Return([]history.ExpAssetStat{ + }).Return([]history.AssetAndContractStat{ // Created by liquidity pool: { - AssetType: xdr.AssetTypeAssetTypeCreditAlphanum4, - AssetCode: "USD", - AssetIssuer: "GC3C4AKRBQLHOJ45U4XG35ESVWRDECWO5XLDGYADO6DPR3L7KIDVUMML", - Accounts: history.ExpAssetStatAccounts{ - LiquidityPools: 1, - }, - Balances: history.ExpAssetStatBalances{ - Authorized: "0", - AuthorizedToMaintainLiabilities: "0", - ClaimableBalances: "0", - LiquidityPools: "450", - Unauthorized: "0", - Contracts: "0", + ExpAssetStat: history.ExpAssetStat{ + AssetType: xdr.AssetTypeAssetTypeCreditAlphanum4, + AssetCode: "USD", + AssetIssuer: "GC3C4AKRBQLHOJ45U4XG35ESVWRDECWO5XLDGYADO6DPR3L7KIDVUMML", + Accounts: history.ExpAssetStatAccounts{ + LiquidityPools: 1, + }, + Balances: history.ExpAssetStatBalances{ + Authorized: "0", + AuthorizedToMaintainLiabilities: "0", + ClaimableBalances: "0", + LiquidityPools: "450", + Unauthorized: "0", + }, + Amount: "0", }, - Amount: "0", - }}, nil).Once() + }, + }, nil).Once() clonedQ.MockQAssetStats.On("GetAssetStats", s.ctx, "", "", db2.PageQuery{ Cursor: "USD_GC3C4AKRBQLHOJ45U4XG35ESVWRDECWO5XLDGYADO6DPR3L7KIDVUMML_credit_alphanum4", Order: "asc", Limit: assetStatsBatchSize, - }).Return([]history.ExpAssetStat{}, nil).Once() + }).Return([]history.AssetAndContractStat{}, nil).Once() clonedQ.MockQClaimableBalances.On("CountClaimableBalances", s.ctx).Return(1, nil).Once() clonedQ.MockQClaimableBalances. @@ -603,7 +606,15 @@ func (s *VerifyRangeStateTestSuite) TestSuccessWithVerify() { } func (s *VerifyRangeStateTestSuite) TestVerifyFailsWhenAssetStatsMismatch() { - set := processors.NewAssetStatSet(s.system.config.NetworkPassphrase) + set := processors.NewAssetStatSet() + contractAssetStatsSet := processors.NewContractAssetStatSet( + s.historyQ, + s.system.config.NetworkPassphrase, + map[xdr.Hash]uint32{}, + map[xdr.Hash]uint32{}, + map[xdr.Hash][2]uint32{}, + 100, + ) trustLineIssuer := xdr.MustAddress("GBRPYHIL2CI3FNQ4BXLFMNDLFJUNPU2HY3ZMFSHONUCEOASW7QC7OX2H") set.AddTrustline( @@ -621,33 +632,35 @@ func (s *VerifyRangeStateTestSuite) TestVerifyFailsWhenAssetStatsMismatch() { }, ) - stat := history.ExpAssetStat{ - AssetType: xdr.AssetTypeAssetTypeCreditAlphanum4, - AssetCode: "EUR", - AssetIssuer: trustLineIssuer.Address(), - Accounts: history.ExpAssetStatAccounts{ - Unauthorized: 1, - }, - Balances: history.ExpAssetStatBalances{ - Authorized: "0", - AuthorizedToMaintainLiabilities: "0", - Unauthorized: "123", + stat := history.AssetAndContractStat{ + ExpAssetStat: history.ExpAssetStat{ + AssetType: xdr.AssetTypeAssetTypeCreditAlphanum4, + AssetCode: "EUR", + AssetIssuer: trustLineIssuer.Address(), + Accounts: history.ExpAssetStatAccounts{ + Unauthorized: 1, + }, + Balances: history.ExpAssetStatBalances{ + Authorized: "0", + AuthorizedToMaintainLiabilities: "0", + Unauthorized: "123", + }, + Amount: "0", + NumAccounts: 0, }, - Amount: "0", - NumAccounts: 0, } s.historyQ.MockQAssetStats.On("GetAssetStats", s.ctx, "", "", db2.PageQuery{ Order: "asc", Limit: assetStatsBatchSize, - }).Return([]history.ExpAssetStat{stat}, nil).Once() + }).Return([]history.AssetAndContractStat{stat}, nil).Once() s.historyQ.MockQAssetStats.On("GetAssetStats", s.ctx, "", "", db2.PageQuery{ Cursor: stat.PagingToken(), Order: "asc", Limit: assetStatsBatchSize, - }).Return([]history.ExpAssetStat{}, nil).Once() + }).Return([]history.AssetAndContractStat{}, nil).Once() - err := checkAssetStats(s.ctx, set, s.historyQ) + err := checkAssetStats(s.ctx, set, contractAssetStatsSet, s.historyQ, s.system.config.NetworkPassphrase) s.Assert().Contains(err.Error(), fmt.Sprintf("db asset stat with code EUR issuer %s does not match asset stat from HAS", trustLineIssuer.Address())) // Satisfy the mock diff --git a/services/horizon/internal/ingest/verify_test.go b/services/horizon/internal/ingest/verify_test.go index 4acd944f49..7d56f1f4cb 100644 --- a/services/horizon/internal/ingest/verify_test.go +++ b/services/horizon/internal/ingest/verify_test.go @@ -1,6 +1,7 @@ package ingest import ( + "crypto/sha256" "database/sql" "io" "math/rand" @@ -167,7 +168,6 @@ func genContractCode(tt *test.T, gen randxdr.Generator) xdr.LedgerEntryChange { []randxdr.Preset{ {randxdr.FieldEquals("type"), randxdr.SetU32(gxdr.LEDGER_ENTRY_CREATED.GetU32())}, {randxdr.FieldEquals("created.data.type"), randxdr.SetU32(gxdr.CONTRACT_CODE.GetU32())}, - //{randxdr.FieldEquals("created.data.contractcode.body.bodytype"), randxdr.SetU32(xdr.Body)}, }, ) tt.Assert.NoError(gxdr.Convert(shape, &change)) @@ -182,6 +182,8 @@ func genTTL(tt *test.T, gen randxdr.Generator) xdr.LedgerEntryChange { []randxdr.Preset{ {randxdr.FieldEquals("type"), randxdr.SetU32(gxdr.LEDGER_ENTRY_CREATED.GetU32())}, {randxdr.FieldEquals("created.data.type"), randxdr.SetU32(gxdr.TTL.GetU32())}, + {randxdr.FieldEquals("created.lastModifiedLedgerSeq"), randxdr.SetPositiveNum32}, + {randxdr.FieldEquals("created.data.ttl.liveUntilLedgerSeq"), randxdr.SetPositiveNum32}, }, ) tt.Assert.NoError(gxdr.Convert(shape, &change)) @@ -216,12 +218,16 @@ func genAssetContractMetadata(tt *test.T, gen randxdr.Generator) []xdr.LedgerEnt otherTrustline := genTrustLine(tt, gen, assetPreset) otherAssetContractMetadata := assetContractMetadataFromTrustline(tt, otherTrustline) + balance := balanceContractDataFromTrustline(tt, trustline) + otherBalance := balanceContractDataFromTrustline(tt, otherTrustline) return []xdr.LedgerEntryChange{ assetContractMetadata, trustline, - balanceContractDataFromTrustline(tt, trustline), + balance, + ttlForContractData(tt, gen, balance), otherAssetContractMetadata, - balanceContractDataFromTrustline(tt, otherTrustline), + otherBalance, + ttlForContractData(tt, gen, otherBalance), balanceContractDataFromTrustline(tt, genTrustLine(tt, gen, assetPreset)), } } @@ -265,6 +271,18 @@ func balanceContractDataFromTrustline(tt *test.T, trustline xdr.LedgerEntryChang return assetContractMetadata } +func ttlForContractData(tt *test.T, gen randxdr.Generator, contractData xdr.LedgerEntryChange) xdr.LedgerEntryChange { + ledgerEntry := contractData.MustCreated() + lk, err := ledgerEntry.LedgerKey() + tt.Assert.NoError(err) + bin, err := lk.MarshalBinary() + tt.Assert.NoError(err) + keyHash := sha256.Sum256(bin) + ttl := genTTL(tt, gen) + ttl.Created.Data.Ttl.KeyHash = keyHash + return ttl +} + func TestStateVerifierLockBusy(t *testing.T) { tt := test.Start(t) defer tt.Finish() @@ -324,7 +342,8 @@ func TestStateVerifier(t *testing.T) { test.ResetHorizonDB(t, tt.HorizonDB) q := &history.Q{&db.Session{DB: tt.HorizonDB}} - checkpointLedger := uint32(63) + ledger := rand.Int31() + checkpointLedger := uint32(ledger - (ledger % 64) - 1) changeProcessor := buildChangeProcessor(q, &ingest.StatsChangeProcessor{}, ledgerSource, checkpointLedger, "") mockChangeReader := &ingest.MockChangeReader{} diff --git a/services/horizon/internal/integration/extend_footprint_ttl_test.go b/services/horizon/internal/integration/extend_footprint_ttl_test.go index a9de3b5f69..b0c9258827 100644 --- a/services/horizon/internal/integration/extend_footprint_ttl_test.go +++ b/services/horizon/internal/integration/extend_footprint_ttl_test.go @@ -3,13 +3,13 @@ package integration import ( "testing" + "github.com/stretchr/testify/require" + "github.com/stellar/go/clients/horizonclient" "github.com/stellar/go/protocols/horizon/operations" "github.com/stellar/go/services/horizon/internal/test/integration" "github.com/stellar/go/txnbuild" "github.com/stellar/go/xdr" - - "github.com/stretchr/testify/require" ) func TestExtendFootprintTtl(t *testing.T) { diff --git a/services/horizon/internal/integration/sac_test.go b/services/horizon/internal/integration/sac_test.go index 06bca5a86d..68236ca3fe 100644 --- a/services/horizon/internal/integration/sac_test.go +++ b/services/horizon/internal/integration/sac_test.go @@ -41,8 +41,7 @@ func TestContractMintToAccount(t *testing.T) { code := "USD" asset := xdr.MustNewCreditAsset(code, issuer) - // Create the contract - assertInvokeHostFnSucceeds(itest, itest.Master(), createSAC(itest, issuer, asset)) + assertInvokeHostFnSucceeds(itest, itest.Master(), createSAC(issuer, asset)) recipientKp, recipient := itest.CreateAccount("100") itest.MustEstablishTrustline(recipientKp, recipient, txnbuild.MustAssetFromXDR(asset)) @@ -55,13 +54,15 @@ func TestContractMintToAccount(t *testing.T) { assertContainsBalance(itest, recipientKp, issuer, code, amount.MustParse("20")) assertAssetStats(itest, assetStats{ - code: code, - issuer: issuer, - numAccounts: 1, - balanceAccounts: amount.MustParse("20"), - numContracts: 0, - balanceContracts: big.NewInt(0), - contractID: stellarAssetContractID(itest, asset), + code: code, + issuer: issuer, + numAccounts: 1, + balanceAccounts: amount.MustParse("20"), + balanceArchivedContracts: big.NewInt(0), + numArchivedContracts: 0, + numContracts: 0, + balanceContracts: big.NewInt(0), + contractID: stellarAssetContractID(itest, asset), }) fx := getTxEffects(itest, mintTx, asset) @@ -92,13 +93,15 @@ func TestContractMintToAccount(t *testing.T) { effects.EffectAccountCredited, effects.EffectAccountDebited) assertAssetStats(itest, assetStats{ - code: code, - issuer: issuer, - numAccounts: 2, - balanceAccounts: amount.MustParse("50"), - numContracts: 0, - balanceContracts: big.NewInt(0), - contractID: stellarAssetContractID(itest, asset), + code: code, + issuer: issuer, + numAccounts: 2, + balanceArchivedContracts: big.NewInt(0), + numArchivedContracts: 0, + balanceAccounts: amount.MustParse("50"), + numContracts: 0, + balanceContracts: big.NewInt(0), + contractID: stellarAssetContractID(itest, asset), }) } @@ -116,8 +119,7 @@ func TestContractMintToContract(t *testing.T) { code := "USD" asset := xdr.MustNewCreditAsset(code, issuer) - // Create the contract - assertInvokeHostFnSucceeds(itest, itest.Master(), createSAC(itest, issuer, asset)) + assertInvokeHostFnSucceeds(itest, itest.Master(), createSAC(issuer, asset)) // Create recipient contract recipientContractID, _ := mustCreateAndInstallContract(itest, itest.Master(), "a1", add_u64_contract) @@ -171,13 +173,15 @@ func TestContractMintToContract(t *testing.T) { balanceContracts := new(big.Int).Lsh(big.NewInt(1), 127) balanceContracts.Sub(balanceContracts, big.NewInt(1)) assertAssetStats(itest, assetStats{ - code: code, - issuer: issuer, - numAccounts: 0, - balanceAccounts: 0, - numContracts: 1, - balanceContracts: balanceContracts, - contractID: stellarAssetContractID(itest, asset), + code: code, + issuer: issuer, + numAccounts: 0, + balanceAccounts: 0, + balanceArchivedContracts: big.NewInt(0), + numArchivedContracts: 0, + numContracts: 1, + balanceContracts: balanceContracts, + contractID: stellarAssetContractID(itest, asset), }) } @@ -195,8 +199,7 @@ func TestContractTransferBetweenAccounts(t *testing.T) { code := "USD" asset := xdr.MustNewCreditAsset(code, issuer) - // Create the contract - assertInvokeHostFnSucceeds(itest, itest.Master(), createSAC(itest, issuer, asset)) + assertInvokeHostFnSucceeds(itest, itest.Master(), createSAC(issuer, asset)) recipientKp, recipient := itest.CreateAccount("100") itest.MustEstablishTrustline(recipientKp, recipient, txnbuild.MustAssetFromXDR(asset)) @@ -217,13 +220,15 @@ func TestContractTransferBetweenAccounts(t *testing.T) { assertContainsBalance(itest, recipientKp, issuer, code, amount.MustParse("1000")) assertAssetStats(itest, assetStats{ - code: code, - issuer: issuer, - numAccounts: 1, - balanceAccounts: amount.MustParse("1000"), - numContracts: 0, - balanceContracts: big.NewInt(0), - contractID: stellarAssetContractID(itest, asset), + code: code, + issuer: issuer, + numAccounts: 1, + balanceAccounts: amount.MustParse("1000"), + balanceArchivedContracts: big.NewInt(0), + numArchivedContracts: 0, + numContracts: 0, + balanceContracts: big.NewInt(0), + contractID: stellarAssetContractID(itest, asset), }) otherRecipientKp, otherRecipient := itest.CreateAccount("100") @@ -242,13 +247,15 @@ func TestContractTransferBetweenAccounts(t *testing.T) { assert.NotEmpty(t, fx) assertContainsEffect(t, fx, effects.EffectAccountCredited, effects.EffectAccountDebited) assertAssetStats(itest, assetStats{ - code: code, - issuer: issuer, - numAccounts: 2, - balanceAccounts: amount.MustParse("1000"), - numContracts: 0, - balanceContracts: big.NewInt(0), - contractID: stellarAssetContractID(itest, asset), + code: code, + issuer: issuer, + numAccounts: 2, + balanceAccounts: amount.MustParse("1000"), + balanceArchivedContracts: big.NewInt(0), + numArchivedContracts: 0, + numContracts: 0, + balanceContracts: big.NewInt(0), + contractID: stellarAssetContractID(itest, asset), }) assertEventPayments(itest, transferTx, asset, recipientKp.Address(), otherRecipient.GetAccountID(), "transfer", "30.0000000") } @@ -267,8 +274,7 @@ func TestContractTransferBetweenAccountAndContract(t *testing.T) { code := "USDLONG" asset := xdr.MustNewCreditAsset(code, issuer) - // Create the contract - assertInvokeHostFnSucceeds(itest, itest.Master(), createSAC(itest, issuer, asset)) + assertInvokeHostFnSucceeds(itest, itest.Master(), createSAC(issuer, asset)) recipientKp, recipient := itest.CreateAccount("100") itest.MustEstablishTrustline(recipientKp, recipient, txnbuild.MustAssetFromXDR(asset)) @@ -310,13 +316,15 @@ func TestContractTransferBetweenAccountAndContract(t *testing.T) { effects.EffectContractCredited) assertAssetStats(itest, assetStats{ - code: code, - issuer: issuer, - numAccounts: 1, - balanceAccounts: amount.MustParse("1000"), - numContracts: 1, - balanceContracts: big.NewInt(int64(amount.MustParse("1000"))), - contractID: stellarAssetContractID(itest, asset), + code: code, + issuer: issuer, + numAccounts: 1, + balanceAccounts: amount.MustParse("1000"), + balanceArchivedContracts: big.NewInt(0), + numArchivedContracts: 0, + numContracts: 1, + balanceContracts: big.NewInt(int64(amount.MustParse("1000"))), + contractID: stellarAssetContractID(itest, asset), }) // transfer from account to contract @@ -329,13 +337,15 @@ func TestContractTransferBetweenAccountAndContract(t *testing.T) { assertContainsEffect(t, getTxEffects(itest, transferTx, asset), effects.EffectAccountDebited, effects.EffectContractCredited) assertAssetStats(itest, assetStats{ - code: code, - issuer: issuer, - numAccounts: 1, - balanceAccounts: amount.MustParse("970"), - numContracts: 1, - balanceContracts: big.NewInt(int64(amount.MustParse("1030"))), - contractID: stellarAssetContractID(itest, asset), + code: code, + issuer: issuer, + numAccounts: 1, + balanceAccounts: amount.MustParse("970"), + balanceArchivedContracts: big.NewInt(0), + numArchivedContracts: 0, + numContracts: 1, + balanceContracts: big.NewInt(int64(amount.MustParse("1030"))), + contractID: stellarAssetContractID(itest, asset), }) assertEventPayments(itest, transferTx, asset, recipientKp.Address(), strkeyRecipientContractID, "transfer", "30.0000000") @@ -349,13 +359,15 @@ func TestContractTransferBetweenAccountAndContract(t *testing.T) { effects.EffectContractDebited, effects.EffectAccountCredited) assertContainsBalance(itest, recipientKp, issuer, code, amount.MustParse("1470")) assertAssetStats(itest, assetStats{ - code: code, - issuer: issuer, - numAccounts: 1, - balanceAccounts: amount.MustParse("1470"), - numContracts: 1, - balanceContracts: big.NewInt(int64(amount.MustParse("530"))), - contractID: stellarAssetContractID(itest, asset), + code: code, + issuer: issuer, + numAccounts: 1, + balanceAccounts: amount.MustParse("1470"), + balanceArchivedContracts: big.NewInt(0), + numArchivedContracts: 0, + numContracts: 1, + balanceContracts: big.NewInt(int64(amount.MustParse("530"))), + contractID: stellarAssetContractID(itest, asset), }) assertEventPayments(itest, transferTx, asset, strkeyRecipientContractID, recipientKp.Address(), "transfer", "500.0000000") @@ -383,8 +395,7 @@ func TestContractTransferBetweenContracts(t *testing.T) { code := "USD" asset := xdr.MustNewCreditAsset(code, issuer) - // Create the token contract - assertInvokeHostFnSucceeds(itest, itest.Master(), createSAC(itest, issuer, asset)) + assertInvokeHostFnSucceeds(itest, itest.Master(), createSAC(issuer, asset)) // Create recipient contract recipientContractID, _ := mustCreateAndInstallContract(itest, itest.Master(), "a1", sac_contract) @@ -439,13 +450,15 @@ func TestContractTransferBetweenContracts(t *testing.T) { assert.Equal(itest.CurrentTest(), xdr.Int64(0), (*recipientBalanceAmount.I128).Hi) assertAssetStats(itest, assetStats{ - code: code, - issuer: issuer, - numAccounts: 0, - balanceAccounts: 0, - numContracts: 2, - balanceContracts: big.NewInt(int64(amount.MustParse("1000"))), - contractID: stellarAssetContractID(itest, asset), + code: code, + issuer: issuer, + numAccounts: 0, + balanceAccounts: 0, + balanceArchivedContracts: big.NewInt(0), + numArchivedContracts: 0, + numContracts: 2, + balanceContracts: big.NewInt(int64(amount.MustParse("1000"))), + contractID: stellarAssetContractID(itest, asset), }) assertEventPayments(itest, transferTx, asset, strkeyEmitterContractID, strkeyRecipientContractID, "transfer", "10.0000000") } @@ -464,8 +477,7 @@ func TestContractBurnFromAccount(t *testing.T) { code := "USD" asset := xdr.MustNewCreditAsset(code, issuer) - // Create the contract - assertInvokeHostFnSucceeds(itest, itest.Master(), createSAC(itest, issuer, asset)) + assertInvokeHostFnSucceeds(itest, itest.Master(), createSAC(issuer, asset)) recipientKp, recipient := itest.CreateAccount("100") itest.MustEstablishTrustline(recipientKp, recipient, txnbuild.MustAssetFromXDR(asset)) @@ -486,13 +498,15 @@ func TestContractBurnFromAccount(t *testing.T) { assertContainsBalance(itest, recipientKp, issuer, code, amount.MustParse("1000")) assertAssetStats(itest, assetStats{ - code: code, - issuer: issuer, - numAccounts: 1, - balanceAccounts: amount.MustParse("1000"), - numContracts: 0, - balanceContracts: big.NewInt(0), - contractID: stellarAssetContractID(itest, asset), + code: code, + issuer: issuer, + numAccounts: 1, + balanceAccounts: amount.MustParse("1000"), + numContracts: 0, + balanceArchivedContracts: big.NewInt(0), + numArchivedContracts: 0, + balanceContracts: big.NewInt(0), + contractID: stellarAssetContractID(itest, asset), }) _, burnTx, _ := assertInvokeHostFnSucceeds( @@ -512,13 +526,15 @@ func TestContractBurnFromAccount(t *testing.T) { assert.Equal(t, "500.0000000", burnEffect.Amount) assert.Equal(t, recipientKp.Address(), burnEffect.Account) assertAssetStats(itest, assetStats{ - code: code, - issuer: issuer, - numAccounts: 1, - balanceAccounts: amount.MustParse("500"), - numContracts: 0, - balanceContracts: big.NewInt(0), - contractID: stellarAssetContractID(itest, asset), + code: code, + issuer: issuer, + numAccounts: 1, + balanceAccounts: amount.MustParse("500"), + numContracts: 0, + balanceArchivedContracts: big.NewInt(0), + numArchivedContracts: 0, + balanceContracts: big.NewInt(0), + contractID: stellarAssetContractID(itest, asset), }) assertEventPayments(itest, burnTx, asset, recipientKp.Address(), "", "burn", "500.0000000") } @@ -537,8 +553,7 @@ func TestContractBurnFromContract(t *testing.T) { code := "USD" asset := xdr.MustNewCreditAsset(code, issuer) - // Create the contract - assertInvokeHostFnSucceeds(itest, itest.Master(), createSAC(itest, issuer, asset)) + assertInvokeHostFnSucceeds(itest, itest.Master(), createSAC(issuer, asset)) // Create recipient contract recipientContractID, recipientContractHash := mustCreateAndInstallContract(itest, itest.Master(), "a1", sac_contract) @@ -579,13 +594,15 @@ func TestContractBurnFromContract(t *testing.T) { effects.EffectContractDebited) assertAssetStats(itest, assetStats{ - code: code, - issuer: issuer, - numAccounts: 0, - balanceAccounts: 0, - numContracts: 1, - balanceContracts: big.NewInt(int64(amount.MustParse("990"))), - contractID: stellarAssetContractID(itest, asset), + code: code, + issuer: issuer, + numAccounts: 0, + balanceAccounts: 0, + balanceArchivedContracts: big.NewInt(0), + numArchivedContracts: 0, + numContracts: 1, + balanceContracts: big.NewInt(int64(amount.MustParse("990"))), + contractID: stellarAssetContractID(itest, asset), }) assertEventPayments(itest, burnTx, asset, strkeyRecipientContractID, "", "burn", "10.0000000") } @@ -614,8 +631,7 @@ func TestContractClawbackFromAccount(t *testing.T) { code := "USD" asset := xdr.MustNewCreditAsset(code, issuer) - // Create the contract - assertInvokeHostFnSucceeds(itest, itest.Master(), createSAC(itest, issuer, asset)) + assertInvokeHostFnSucceeds(itest, itest.Master(), createSAC(issuer, asset)) recipientKp, recipient := itest.CreateAccount("100") itest.MustEstablishTrustline(recipientKp, recipient, txnbuild.MustAssetFromXDR(asset)) @@ -636,13 +652,15 @@ func TestContractClawbackFromAccount(t *testing.T) { assertContainsBalance(itest, recipientKp, issuer, code, amount.MustParse("1000")) assertAssetStats(itest, assetStats{ - code: code, - issuer: issuer, - numAccounts: 1, - balanceAccounts: amount.MustParse("1000"), - numContracts: 0, - balanceContracts: big.NewInt(0), - contractID: stellarAssetContractID(itest, asset), + code: code, + issuer: issuer, + numAccounts: 1, + balanceAccounts: amount.MustParse("1000"), + numContracts: 0, + balanceArchivedContracts: big.NewInt(0), + numArchivedContracts: 0, + balanceContracts: big.NewInt(0), + contractID: stellarAssetContractID(itest, asset), }) _, clawTx, _ := assertInvokeHostFnSucceeds( @@ -654,13 +672,15 @@ func TestContractClawbackFromAccount(t *testing.T) { assertContainsEffect(t, getTxEffects(itest, clawTx, asset), effects.EffectAccountDebited) assertContainsBalance(itest, recipientKp, issuer, code, 0) assertAssetStats(itest, assetStats{ - code: code, - issuer: issuer, - numAccounts: 1, - balanceAccounts: 0, - numContracts: 0, - balanceContracts: big.NewInt(0), - contractID: stellarAssetContractID(itest, asset), + code: code, + issuer: issuer, + numAccounts: 1, + balanceAccounts: 0, + balanceArchivedContracts: big.NewInt(0), + numArchivedContracts: 0, + numContracts: 0, + balanceContracts: big.NewInt(0), + contractID: stellarAssetContractID(itest, asset), }) assertEventPayments(itest, clawTx, asset, recipientKp.Address(), "", "clawback", "1000.0000000") } @@ -689,8 +709,7 @@ func TestContractClawbackFromContract(t *testing.T) { code := "USD" asset := xdr.MustNewCreditAsset(code, issuer) - // Create the contract - assertInvokeHostFnSucceeds(itest, itest.Master(), createSAC(itest, issuer, asset)) + assertInvokeHostFnSucceeds(itest, itest.Master(), createSAC(issuer, asset)) // Create recipient contract recipientContractID, _ := mustCreateAndInstallContract(itest, itest.Master(), "a2", sac_contract) @@ -724,13 +743,15 @@ func TestContractClawbackFromContract(t *testing.T) { effects.EffectContractDebited) assertAssetStats(itest, assetStats{ - code: code, - issuer: issuer, - numAccounts: 0, - balanceAccounts: 0, - numContracts: 1, - balanceContracts: big.NewInt(int64(amount.MustParse("990"))), - contractID: stellarAssetContractID(itest, asset), + code: code, + issuer: issuer, + numAccounts: 0, + balanceAccounts: 0, + balanceArchivedContracts: big.NewInt(0), + numArchivedContracts: 0, + numContracts: 1, + balanceContracts: big.NewInt(int64(amount.MustParse("990"))), + contractID: stellarAssetContractID(itest, asset), }) assertEventPayments(itest, clawTx, asset, strkeyRecipientContractID, "", "clawback", "10.0000000") } @@ -748,13 +769,15 @@ func assertContainsBalance(itest *integration.Test, acct *keypair.Full, issuer, } type assetStats struct { - code string - issuer string - numAccounts int32 - balanceAccounts xdr.Int64 - numContracts int32 - balanceContracts *big.Int - contractID [32]byte + code string + issuer string + numAccounts int32 + balanceAccounts xdr.Int64 + numContracts int32 + numArchivedContracts int32 + balanceContracts *big.Int + balanceArchivedContracts *big.Int + contractID [32]byte } func assertAssetStats(itest *integration.Test, expected assetStats) { @@ -779,12 +802,18 @@ func assertAssetStats(itest *integration.Test, expected assetStats) { assert.Equal(itest.CurrentTest(), expected.numAccounts, asset.Accounts.Authorized) assert.Equal(itest.CurrentTest(), expected.balanceAccounts, amount.MustParse(asset.Amount)) assert.Equal(itest.CurrentTest(), expected.numContracts, asset.NumContracts) - parts := strings.Split(asset.ContractsAmount, ".") + assert.Equal(itest.CurrentTest(), expected.numArchivedContracts, asset.NumArchivedContracts) + assert.Equal(itest.CurrentTest(), expected.balanceContracts.String(), parseBalance(itest, asset.ContractsAmount).String()) + assert.Equal(itest.CurrentTest(), expected.balanceArchivedContracts.String(), parseBalance(itest, asset.ArchivedContractsAmount).String()) + assert.Equal(itest.CurrentTest(), strkey.MustEncode(strkey.VersionByteContract, expected.contractID[:]), asset.ContractID) +} + +func parseBalance(itest *integration.Test, balance string) *big.Int { + parts := strings.Split(balance, ".") assert.Len(itest.CurrentTest(), parts, 2) contractsAmount, ok := new(big.Int).SetString(parts[0]+parts[1], 10) assert.True(itest.CurrentTest(), ok) - assert.Equal(itest.CurrentTest(), expected.balanceContracts.String(), contractsAmount.String()) - assert.Equal(itest.CurrentTest(), strkey.MustEncode(strkey.VersionByteContract, expected.contractID[:]), asset.ContractID) + return contractsAmount } // assertContainsEffect checks that the list of json effects contains the given @@ -884,7 +913,7 @@ func i128Param(hi int64, lo uint64) xdr.ScVal { } } -func createSAC(itest *integration.Test, sourceAccount string, asset xdr.Asset) *txnbuild.InvokeHostFunction { +func createSAC(sourceAccount string, asset xdr.Asset) *txnbuild.InvokeHostFunction { invokeHostFunction := &txnbuild.InvokeHostFunction{ HostFunction: xdr.HostFunction{ Type: xdr.HostFunctionTypeHostFunctionTypeCreateContract, diff --git a/services/horizon/internal/resourceadapter/asset_stat.go b/services/horizon/internal/resourceadapter/asset_stat.go index 89196e9c89..994cce99a0 100644 --- a/services/horizon/internal/resourceadapter/asset_stat.go +++ b/services/horizon/internal/resourceadapter/asset_stat.go @@ -18,7 +18,7 @@ import ( func PopulateAssetStat( ctx context.Context, res *protocol.AssetStat, - row history.ExpAssetStat, + row history.AssetAndContractStat, issuer history.AccountEntry, ) (err error) { if row.ContractID != nil { @@ -37,9 +37,10 @@ func PopulateAssetStat( } res.NumClaimableBalances = row.Accounts.ClaimableBalances res.NumLiquidityPools = row.Accounts.LiquidityPools - res.NumContracts = row.Accounts.Contracts + res.NumContracts = row.Contracts.ActiveHolders + res.NumArchivedContracts = row.Contracts.ArchivedHolders res.NumAccounts = row.NumAccounts - err = populateAssetStatBalances(res, row.Balances) + err = populateAssetStatBalances(res, row) if err != nil { return err } @@ -61,40 +62,45 @@ func PopulateAssetStat( return } -func populateAssetStatBalances(res *protocol.AssetStat, row history.ExpAssetStatBalances) (err error) { - res.Amount, err = amount.IntStringToAmount(row.Authorized) +func populateAssetStatBalances(res *protocol.AssetStat, row history.AssetAndContractStat) (err error) { + res.Amount, err = amount.IntStringToAmount(row.Balances.Authorized) if err != nil { return errors.Wrap(err, "Invalid amount in PopulateAssetStat") } - res.Balances.Authorized, err = amount.IntStringToAmount(row.Authorized) + res.Balances.Authorized, err = amount.IntStringToAmount(row.Balances.Authorized) if err != nil { - return errors.Wrapf(err, "Invalid amount in PopulateAssetStatBalances: %q", row.Authorized) + return errors.Wrapf(err, "Invalid amount in PopulateAssetStatBalances: %q", row.Balances.Authorized) } - res.Balances.AuthorizedToMaintainLiabilities, err = amount.IntStringToAmount(row.AuthorizedToMaintainLiabilities) + res.Balances.AuthorizedToMaintainLiabilities, err = amount.IntStringToAmount(row.Balances.AuthorizedToMaintainLiabilities) if err != nil { - return errors.Wrapf(err, "Invalid amount in PopulateAssetStatBalances: %q", row.AuthorizedToMaintainLiabilities) + return errors.Wrapf(err, "Invalid amount in PopulateAssetStatBalances: %q", row.Balances.AuthorizedToMaintainLiabilities) } - res.Balances.Unauthorized, err = amount.IntStringToAmount(row.Unauthorized) + res.Balances.Unauthorized, err = amount.IntStringToAmount(row.Balances.Unauthorized) if err != nil { - return errors.Wrapf(err, "Invalid amount in PopulateAssetStatBalances: %q", row.Unauthorized) + return errors.Wrapf(err, "Invalid amount in PopulateAssetStatBalances: %q", row.Balances.Unauthorized) } - res.ClaimableBalancesAmount, err = amount.IntStringToAmount(row.ClaimableBalances) + res.ClaimableBalancesAmount, err = amount.IntStringToAmount(row.Balances.ClaimableBalances) if err != nil { - return errors.Wrapf(err, "Invalid amount in PopulateAssetStatBalances: %q", row.ClaimableBalances) + return errors.Wrapf(err, "Invalid amount in PopulateAssetStatBalances: %q", row.Balances.ClaimableBalances) } - res.LiquidityPoolsAmount, err = amount.IntStringToAmount(row.LiquidityPools) + res.LiquidityPoolsAmount, err = amount.IntStringToAmount(row.Balances.LiquidityPools) if err != nil { - return errors.Wrapf(err, "Invalid amount in PopulateAssetStatBalances: %q", row.LiquidityPools) + return errors.Wrapf(err, "Invalid amount in PopulateAssetStatBalances: %q", row.Balances.LiquidityPools) } - res.ContractsAmount, err = amount.IntStringToAmount(row.Contracts) + res.ContractsAmount, err = amount.IntStringToAmount(row.Contracts.ActiveBalance) if err != nil { - return errors.Wrapf(err, "Invalid amount in PopulateAssetStatBalances: %q", row.Contracts) + return errors.Wrapf(err, "Invalid amount in PopulateAssetStatBalances: %q", row.Contracts.ActiveBalance) + } + + res.ArchivedContractsAmount, err = amount.IntStringToAmount(row.Contracts.ArchivedBalance) + if err != nil { + return errors.Wrapf(err, "Invalid amount in PopulateAssetStatBalances: %q", row.Contracts.ArchivedBalance) } return nil diff --git a/services/horizon/internal/resourceadapter/asset_stat_test.go b/services/horizon/internal/resourceadapter/asset_stat_test.go index b1530f88b6..d3b14d62e6 100644 --- a/services/horizon/internal/resourceadapter/asset_stat_test.go +++ b/services/horizon/internal/resourceadapter/asset_stat_test.go @@ -4,35 +4,42 @@ import ( "context" "testing" + "github.com/stretchr/testify/assert" + "github.com/stellar/go/protocols/horizon" protocol "github.com/stellar/go/protocols/horizon" "github.com/stellar/go/services/horizon/internal/db2/history" "github.com/stellar/go/xdr" - "github.com/stretchr/testify/assert" ) func TestPopulateExpAssetStat(t *testing.T) { - row := history.ExpAssetStat{ - AssetType: xdr.AssetTypeAssetTypeCreditAlphanum4, - AssetCode: "XIM", - AssetIssuer: "GBZ35ZJRIKJGYH5PBKLKOZ5L6EXCNTO7BKIL7DAVVDFQ2ODJEEHHJXIM", - Accounts: history.ExpAssetStatAccounts{ - Authorized: 429, - AuthorizedToMaintainLiabilities: 214, - Unauthorized: 107, - ClaimableBalances: 12, - Contracts: 6, + row := history.AssetAndContractStat{ + ExpAssetStat: history.ExpAssetStat{ + AssetType: xdr.AssetTypeAssetTypeCreditAlphanum4, + AssetCode: "XIM", + AssetIssuer: "GBZ35ZJRIKJGYH5PBKLKOZ5L6EXCNTO7BKIL7DAVVDFQ2ODJEEHHJXIM", + Accounts: history.ExpAssetStatAccounts{ + Authorized: 429, + AuthorizedToMaintainLiabilities: 214, + Unauthorized: 107, + ClaimableBalances: 12, + }, + Balances: history.ExpAssetStatBalances{ + Authorized: "100000000000000000000", + AuthorizedToMaintainLiabilities: "50000000000000000000", + Unauthorized: "2500000000000000000", + ClaimableBalances: "1200000000000000000", + LiquidityPools: "7700000000000000000", + }, + Amount: "100000000000000000000", // 10T + NumAccounts: 429, }, - Balances: history.ExpAssetStatBalances{ - Authorized: "100000000000000000000", - AuthorizedToMaintainLiabilities: "50000000000000000000", - Unauthorized: "2500000000000000000", - ClaimableBalances: "1200000000000000000", - LiquidityPools: "7700000000000000000", - Contracts: "900000000000000000", + Contracts: history.ContractStat{ + ActiveBalance: "900000000000000000", + ActiveHolders: 6, + ArchivedBalance: "700000000000000000", + ArchivedHolders: 3, }, - Amount: "100000000000000000000", // 10T - NumAccounts: 429, } issuer := history.AccountEntry{ AccountID: "GBZ35ZJRIKJGYH5PBKLKOZ5L6EXCNTO7BKIL7DAVVDFQ2ODJEEHHJXIM", @@ -52,12 +59,14 @@ func TestPopulateExpAssetStat(t *testing.T) { assert.Equal(t, int32(107), res.Accounts.Unauthorized) assert.Equal(t, int32(12), res.NumClaimableBalances) assert.Equal(t, int32(6), res.NumContracts) + assert.Equal(t, int32(3), res.NumArchivedContracts) assert.Equal(t, "10000000000000.0000000", res.Balances.Authorized) assert.Equal(t, "5000000000000.0000000", res.Balances.AuthorizedToMaintainLiabilities) assert.Equal(t, "250000000000.0000000", res.Balances.Unauthorized) assert.Equal(t, "120000000000.0000000", res.ClaimableBalancesAmount) assert.Equal(t, "770000000000.0000000", res.LiquidityPoolsAmount) assert.Equal(t, "90000000000.0000000", res.ContractsAmount) + assert.Equal(t, "70000000000.0000000", res.ArchivedContractsAmount) assert.Equal(t, "10000000000000.0000000", res.Amount) assert.Equal(t, int32(429), res.NumAccounts) assert.Equal(t, horizon.AccountFlags{}, res.Flags) From 1924ea7bc2672f80dd1d31dd6ec9f98ed760151a Mon Sep 17 00:00:00 2001 From: Alfonso Acosta Date: Thu, 23 Nov 2023 17:32:57 +0100 Subject: [PATCH 11/16] xdr: Sanity-check allocations when decoding (#5116) --- Makefile | 2 +- go.mod | 2 +- go.sum | 4 +- gxdr/validator.go | 70 - gxdr/validator_test.go | 99 - .../internal/actions/submit_transaction.go | 8 +- xdr/main.go | 17 +- xdr/xdr_generated.go | 4158 ++++++++++------- 8 files changed, 2429 insertions(+), 1931 deletions(-) delete mode 100644 gxdr/validator.go delete mode 100644 gxdr/validator_test.go diff --git a/Makefile b/Makefile index 4266730900..7b0cda6df6 100644 --- a/Makefile +++ b/Makefile @@ -14,7 +14,7 @@ xdr/Stellar-contract.x \ xdr/Stellar-internal.x \ xdr/Stellar-contract-config-setting.x -XDRGEN_COMMIT=a231a92475ac6154c0c2f46dc503809823985060 +XDRGEN_COMMIT=f9995ef529eb83db6b70206a0a857dc88e33c750 XDR_COMMIT=6a620d160aab22609c982d54578ff6a63bfcdc01 .PHONY: xdr xdr-clean xdr-update diff --git a/go.mod b/go.mod index ac3f078197..48b7ccbea8 100644 --- a/go.mod +++ b/go.mod @@ -42,7 +42,7 @@ require ( github.com/spf13/cobra v0.0.5 github.com/spf13/pflag v1.0.3 github.com/spf13/viper v1.3.2 - github.com/stellar/go-xdr v0.0.0-20230919160922-6c7b68458206 + github.com/stellar/go-xdr v0.0.0-20231122183749-b53fb00bcac2 github.com/stellar/throttled v2.2.3-0.20190823235211-89d75816f59d+incompatible github.com/stretchr/testify v1.8.1 github.com/tyler-smith/go-bip39 v0.0.0-20180618194314-52158e4697b8 diff --git a/go.sum b/go.sum index 4fbfb8b2c5..cd5a054a7b 100644 --- a/go.sum +++ b/go.sum @@ -325,8 +325,8 @@ github.com/spf13/pflag v1.0.3 h1:zPAT6CGy6wXeQ7NtTnaTerfKOsV6V6F8agHXFiazDkg= github.com/spf13/pflag v1.0.3/go.mod h1:DYY7MBk1bdzusC3SYhjObp+wFpr4gzcvqqNjLnInEg4= github.com/spf13/viper v1.3.2 h1:VUFqw5KcqRf7i70GOzW7N+Q7+gxVBkSSqiXB12+JQ4M= github.com/spf13/viper v1.3.2/go.mod h1:ZiWeW+zYFKm7srdB9IoDzzZXaJaI5eL9QjNiN/DMA2s= -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/stellar/go-xdr v0.0.0-20231122183749-b53fb00bcac2 h1:OzCVd0SV5qE3ZcDeSFCmOWLZfEWZ3Oe8KtmSOYKEVWE= +github.com/stellar/go-xdr v0.0.0-20231122183749-b53fb00bcac2/go.mod h1:yoxyU/M8nl9LKeWIoBrbDPQ7Cy+4jxRcWcOayZ4BMps= github.com/stellar/throttled v2.2.3-0.20190823235211-89d75816f59d+incompatible h1:jMXXAcz6xTarGDQ4VtVbtERogcmDQw4RaE85Cr9CgoQ= github.com/stellar/throttled v2.2.3-0.20190823235211-89d75816f59d+incompatible/go.mod h1:7CJ23pXirXBJq45DqvO6clzTEGM/l1SfKrgrzLry8b4= github.com/stretchr/objx v0.1.0/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+wExME= diff --git a/gxdr/validator.go b/gxdr/validator.go deleted file mode 100644 index 9362ce3fdd..0000000000 --- a/gxdr/validator.go +++ /dev/null @@ -1,70 +0,0 @@ -package gxdr - -import ( - "encoding/base64" - "strings" - - goxdr "github.com/xdrpp/goxdr/xdr" -) - -const DefaultMaxDepth = 500 - -type depthLimiter struct { - depth int - maxDepth int - decoder *goxdr.XdrIn -} - -func (*depthLimiter) Sprintf(f string, args ...interface{}) string { - return "" -} - -func (d *depthLimiter) Marshal(field string, i goxdr.XdrType) { - switch t := goxdr.XdrBaseType(i).(type) { - case goxdr.XdrAggregate: - if d.depth > d.maxDepth { - goxdr.XdrPanic("max depth of %d exceeded", d.maxDepth) - } - d.depth++ - t.XdrRecurse(d, field) - d.depth-- - default: - d.decoder.Marshal(field, t) - } -} - -// ValidateTransactionEnvelope validates the given transaction envelope -// to make sure that it does not contain malicious arrays or nested -// structures which are too deep -func ValidateTransactionEnvelope(b64Envelope string, maxDepth int) error { - return validate(b64Envelope, &TransactionEnvelope{}, maxDepth) -} - -// ValidateLedgerKey validates the given ledger key -// to make sure that it does not contain malicious arrays or nested -// structures which are too deep -func ValidateLedgerKey(b64Key string, maxDepth int) error { - return validate(b64Key, &LedgerKey{}, maxDepth) -} - -func validate(b64 string, val goxdr.XdrType, maxDepth int) (err error) { - d := &depthLimiter{ - depth: 0, - maxDepth: maxDepth, - decoder: &goxdr.XdrIn{ - In: base64.NewDecoder(base64.StdEncoding, strings.NewReader(b64)), - }, - } - - defer func() { - switch i := recover().(type) { - case nil: - case goxdr.XdrError: - err = i - default: - panic(i) - } - }() - val.XdrMarshal(d, "") - return nil -} diff --git a/gxdr/validator_test.go b/gxdr/validator_test.go deleted file mode 100644 index 7e42e9467d..0000000000 --- a/gxdr/validator_test.go +++ /dev/null @@ -1,99 +0,0 @@ -package gxdr - -import ( - "encoding/base64" - "testing" - - "github.com/stretchr/testify/assert" - goxdr "github.com/xdrpp/goxdr/xdr" -) - -func buildVec(depth int) SCVal { - if depth <= 0 { - symbol := SCSymbol("s") - return SCVal{ - Type: SCV_SYMBOL, - _u: &symbol, - } - } - vec := &SCVec{ - buildVec(depth - 1), - } - return SCVal{Type: SCV_VEC, _u: &vec} -} - -func buildMaliciousVec(t *testing.T) string { - vals := &SCVec{} - for i := 0; i < 0x0D; i++ { - symbol := SCSymbol("s") - *vals = append(*vals, SCVal{ - Type: SCV_SYMBOL, - _u: &symbol, - }) - } - vec := SCVal{Type: SCV_VEC, _u: &vals} - raw := Dump(&vec) - // raw[8-11] represents the part of the xdr that holds the - // length of the vector - for i, b := range raw { - if b == 0x0D { - assert.Equal(t, 11, i) - } - } - // here we override the most significant byte in the vector length - // so that the vector length in the xdr is 0xFA00000D which - // is equal to 4194304013 - raw[8] = 0xFA - return base64.StdEncoding.EncodeToString(raw) -} - -func TestValidator(t *testing.T) { - shallowVec := buildVec(2) - deepVec := buildVec(100) - for _, testCase := range []struct { - name string - input string - maxDepth int - val goxdr.XdrType - expectedError string - }{ - { - "invalid base 64 input", - "{}<>~!@$#", - 500, - &LedgerEntry{}, - "illegal base64 data at input byte 0", - }, - { - "valid depth", - base64.StdEncoding.EncodeToString(Dump(&shallowVec)), - 500, - &SCVal{}, - "", - }, - { - "invalid depth", - base64.StdEncoding.EncodeToString(Dump(&deepVec)), - 50, - &SCVal{}, - "max depth of 50 exceeded", - }, - { - "malicious length", - buildMaliciousVec(t), - 500, - &SCVal{}, - "EOF", - }, - } { - t.Run(testCase.name, func(t *testing.T) { - err := validate(testCase.input, testCase.val, testCase.maxDepth) - if testCase.expectedError == "" { - assert.NoError(t, err) - assert.Equal(t, testCase.input, base64.StdEncoding.EncodeToString(Dump(testCase.val))) - } else { - assert.EqualError(t, err, testCase.expectedError) - } - }) - } -} diff --git a/services/horizon/internal/actions/submit_transaction.go b/services/horizon/internal/actions/submit_transaction.go index e6a1f02b7f..4c8f2fd691 100644 --- a/services/horizon/internal/actions/submit_transaction.go +++ b/services/horizon/internal/actions/submit_transaction.go @@ -6,7 +6,6 @@ import ( "mime" "net/http" - "github.com/stellar/go/gxdr" "github.com/stellar/go/network" "github.com/stellar/go/protocols/horizon" hProblem "github.com/stellar/go/services/horizon/internal/render/problem" @@ -36,11 +35,8 @@ type envelopeInfo struct { parsed xdr.TransactionEnvelope } -func extractEnvelopeInfo(raw string, passphrase string) (envelopeInfo, error) { +func (handler SubmitTransactionHandler) extractEnvelopeInfo(raw string, passphrase string) (envelopeInfo, error) { result := envelopeInfo{raw: raw} - if err := gxdr.ValidateTransactionEnvelope(raw, gxdr.DefaultMaxDepth); err != nil { - return result, err - } err := xdr.SafeUnmarshalBase64(raw, &result.parsed) if err != nil { return result, err @@ -149,7 +145,7 @@ func (handler SubmitTransactionHandler) GetResource(w HeaderWriter, r *http.Requ return nil, err } - info, err := extractEnvelopeInfo(raw, handler.NetworkPassphrase) + info, err := handler.extractEnvelopeInfo(raw, handler.NetworkPassphrase) if err != nil { return nil, &problem.P{ Type: "transaction_malformed", diff --git a/xdr/main.go b/xdr/main.go index b0c31ad5d8..44e8ced3ea 100644 --- a/xdr/main.go +++ b/xdr/main.go @@ -36,11 +36,11 @@ var OperationTypeToStringMap = operationTypeMap var LedgerEntryTypeMap = ledgerEntryTypeMap -func safeUnmarshalString(decoder func(reader io.Reader) io.Reader, data string, dest interface{}) error { +func safeUnmarshalString(decoder func(reader io.Reader) io.Reader, options xdr.DecodeOptions, data string, dest interface{}) error { count := &countWriter{} l := len(data) - _, err := Unmarshal(decoder(io.TeeReader(strings.NewReader(data), count)), dest) + _, err := UnmarshalWithOptions(decoder(io.TeeReader(strings.NewReader(data), count)), dest, options) if err != nil { return err } @@ -52,14 +52,23 @@ func safeUnmarshalString(decoder func(reader io.Reader) io.Reader, data string, return nil } +func decodeOptionsWithMaxInputLen(maxInputLen int) xdr.DecodeOptions { + options := xdr.DefaultDecodeOptions + options.MaxInputLen = maxInputLen + return options +} + // SafeUnmarshalBase64 first decodes the provided reader from base64 before // decoding the xdr into the provided destination. Also ensures that the reader // is fully consumed. func SafeUnmarshalBase64(data string, dest interface{}) error { + decodedLen := base64.StdEncoding.DecodedLen(len(data)) + options := decodeOptionsWithMaxInputLen(decodedLen) return safeUnmarshalString( func(r io.Reader) io.Reader { return base64.NewDecoder(base64.StdEncoding, r) }, + options, data, dest, ) @@ -69,7 +78,9 @@ func SafeUnmarshalBase64(data string, dest interface{}) error { // decoding the xdr into the provided destination. Also ensures that the reader // is fully consumed. func SafeUnmarshalHex(data string, dest interface{}) error { - return safeUnmarshalString(hex.NewDecoder, data, dest) + decodedLen := hex.DecodedLen(len(data)) + options := decodeOptionsWithMaxInputLen(decodedLen) + return safeUnmarshalString(hex.NewDecoder, options, data, dest) } // SafeUnmarshal decodes the provided reader into the destination and verifies diff --git a/xdr/xdr_generated.go b/xdr/xdr_generated.go index f4f59553cc..d4d6b12107 100644 --- a/xdr/xdr_generated.go +++ b/xdr/xdr_generated.go @@ -25,10 +25,14 @@ import ( "errors" "fmt" "io" + "unsafe" "github.com/stellar/go-xdr/xdr3" ) +// Needed since unsafe is not used in all cases +var _ = unsafe.Sizeof(0) + // XdrFilesSHA256 is the SHA256 hashes of source files. var XdrFilesSHA256 = map[string]string{ "xdr/Stellar-SCP.x": "8f32b04d008f8bc33b8843d075e69837231a673691ee41d8b821ca229a6e802a", @@ -57,12 +61,17 @@ type decoderFrom interface { // Unmarshal reads an xdr element from `r` into `v`. func Unmarshal(r io.Reader, v interface{}) (int, error) { + return UnmarshalWithOptions(r, v, xdr.DefaultDecodeOptions) +} + +// UnmarshalWithOptions works like Unmarshal but uses decoding options. +func UnmarshalWithOptions(r io.Reader, v interface{}, options xdr.DecodeOptions) (int, error) { if decodable, ok := v.(decoderFrom); ok { - d := xdr.NewDecoder(r) - return decodable.DecodeFrom(d, xdr.DecodeDefaultMaxDepth) + d := xdr.NewDecoderWithOptions(r, options) + return decodable.DecodeFrom(d, options.MaxDepth) } // delegate to xdr package's Unmarshal - return xdr.Unmarshal(r, v) + return xdr.UnmarshalWithOptions(r, v, options) } // Marshal writes an xdr element `v` into `w`. @@ -123,8 +132,10 @@ func (s Value) MarshalBinary() ([]byte, error) { // UnmarshalBinary implements encoding.BinaryUnmarshaler. func (s *Value) UnmarshalBinary(inp []byte) error { r := bytes.NewReader(inp) - d := xdr.NewDecoder(r) - _, err := s.DecodeFrom(d, xdr.DecodeDefaultMaxDepth) + o := xdr.DefaultDecodeOptions + o.MaxInputLen = len(inp) + d := xdr.NewDecoderWithOptions(r, o) + _, err := s.DecodeFrom(d, o.MaxDepth) return err } @@ -133,8 +144,7 @@ var ( _ encoding.BinaryUnmarshaler = (*Value)(nil) ) -// xdrType signals that this type is an type representing -// representing XDR values defined by this package. +// xdrType signals that this type represents XDR values defined by this package. func (s Value) xdrType() {} var _ xdrType = (*Value)(nil) @@ -197,8 +207,10 @@ func (s ScpBallot) MarshalBinary() ([]byte, error) { // UnmarshalBinary implements encoding.BinaryUnmarshaler. func (s *ScpBallot) UnmarshalBinary(inp []byte) error { r := bytes.NewReader(inp) - d := xdr.NewDecoder(r) - _, err := s.DecodeFrom(d, xdr.DecodeDefaultMaxDepth) + o := xdr.DefaultDecodeOptions + o.MaxInputLen = len(inp) + d := xdr.NewDecoderWithOptions(r, o) + _, err := s.DecodeFrom(d, o.MaxDepth) return err } @@ -207,8 +219,7 @@ var ( _ encoding.BinaryUnmarshaler = (*ScpBallot)(nil) ) -// xdrType signals that this type is an type representing -// representing XDR values defined by this package. +// xdrType signals that this type represents XDR values defined by this package. func (s ScpBallot) xdrType() {} var _ xdrType = (*ScpBallot)(nil) @@ -290,8 +301,10 @@ func (s ScpStatementType) MarshalBinary() ([]byte, error) { // UnmarshalBinary implements encoding.BinaryUnmarshaler. func (s *ScpStatementType) UnmarshalBinary(inp []byte) error { r := bytes.NewReader(inp) - d := xdr.NewDecoder(r) - _, err := s.DecodeFrom(d, xdr.DecodeDefaultMaxDepth) + o := xdr.DefaultDecodeOptions + o.MaxInputLen = len(inp) + d := xdr.NewDecoderWithOptions(r, o) + _, err := s.DecodeFrom(d, o.MaxDepth) return err } @@ -300,8 +313,7 @@ var ( _ encoding.BinaryUnmarshaler = (*ScpStatementType)(nil) ) -// xdrType signals that this type is an type representing -// representing XDR values defined by this package. +// xdrType signals that this type represents XDR values defined by this package. func (s ScpStatementType) xdrType() {} var _ xdrType = (*ScpStatementType)(nil) @@ -368,8 +380,11 @@ func (s *ScpNomination) DecodeFrom(d *xdr.Decoder, maxDepth uint) (int, error) { } s.Votes = nil if l > 0 { + if il, ok := d.InputLen(); ok && uint(il) < uint(l) { + return n, fmt.Errorf("decoding Value: length (%d) exceeds remaining input length (%d)", l, il) + } s.Votes = make([]Value, l) - for i := uint32(0); i < l; i++ { + for i := uint32(0); uint(i) < uint(l); i++ { nTmp, err = s.Votes[i].DecodeFrom(d, maxDepth) n += nTmp if err != nil { @@ -384,8 +399,11 @@ func (s *ScpNomination) DecodeFrom(d *xdr.Decoder, maxDepth uint) (int, error) { } s.Accepted = nil if l > 0 { + if il, ok := d.InputLen(); ok && uint(il) < uint(l) { + return n, fmt.Errorf("decoding Value: length (%d) exceeds remaining input length (%d)", l, il) + } s.Accepted = make([]Value, l) - for i := uint32(0); i < l; i++ { + for i := uint32(0); uint(i) < uint(l); i++ { nTmp, err = s.Accepted[i].DecodeFrom(d, maxDepth) n += nTmp if err != nil { @@ -407,8 +425,10 @@ func (s ScpNomination) MarshalBinary() ([]byte, error) { // UnmarshalBinary implements encoding.BinaryUnmarshaler. func (s *ScpNomination) UnmarshalBinary(inp []byte) error { r := bytes.NewReader(inp) - d := xdr.NewDecoder(r) - _, err := s.DecodeFrom(d, xdr.DecodeDefaultMaxDepth) + o := xdr.DefaultDecodeOptions + o.MaxInputLen = len(inp) + d := xdr.NewDecoderWithOptions(r, o) + _, err := s.DecodeFrom(d, o.MaxDepth) return err } @@ -417,8 +437,7 @@ var ( _ encoding.BinaryUnmarshaler = (*ScpNomination)(nil) ) -// xdrType signals that this type is an type representing -// representing XDR values defined by this package. +// xdrType signals that this type represents XDR values defined by this package. func (s ScpNomination) xdrType() {} var _ xdrType = (*ScpNomination)(nil) @@ -550,8 +569,10 @@ func (s ScpStatementPrepare) MarshalBinary() ([]byte, error) { // UnmarshalBinary implements encoding.BinaryUnmarshaler. func (s *ScpStatementPrepare) UnmarshalBinary(inp []byte) error { r := bytes.NewReader(inp) - d := xdr.NewDecoder(r) - _, err := s.DecodeFrom(d, xdr.DecodeDefaultMaxDepth) + o := xdr.DefaultDecodeOptions + o.MaxInputLen = len(inp) + d := xdr.NewDecoderWithOptions(r, o) + _, err := s.DecodeFrom(d, o.MaxDepth) return err } @@ -560,8 +581,7 @@ var ( _ encoding.BinaryUnmarshaler = (*ScpStatementPrepare)(nil) ) -// xdrType signals that this type is an type representing -// representing XDR values defined by this package. +// xdrType signals that this type represents XDR values defined by this package. func (s ScpStatementPrepare) xdrType() {} var _ xdrType = (*ScpStatementPrepare)(nil) @@ -654,8 +674,10 @@ func (s ScpStatementConfirm) MarshalBinary() ([]byte, error) { // UnmarshalBinary implements encoding.BinaryUnmarshaler. func (s *ScpStatementConfirm) UnmarshalBinary(inp []byte) error { r := bytes.NewReader(inp) - d := xdr.NewDecoder(r) - _, err := s.DecodeFrom(d, xdr.DecodeDefaultMaxDepth) + o := xdr.DefaultDecodeOptions + o.MaxInputLen = len(inp) + d := xdr.NewDecoderWithOptions(r, o) + _, err := s.DecodeFrom(d, o.MaxDepth) return err } @@ -664,8 +686,7 @@ var ( _ encoding.BinaryUnmarshaler = (*ScpStatementConfirm)(nil) ) -// xdrType signals that this type is an type representing -// representing XDR values defined by this package. +// xdrType signals that this type represents XDR values defined by this package. func (s ScpStatementConfirm) xdrType() {} var _ xdrType = (*ScpStatementConfirm)(nil) @@ -738,8 +759,10 @@ func (s ScpStatementExternalize) MarshalBinary() ([]byte, error) { // UnmarshalBinary implements encoding.BinaryUnmarshaler. func (s *ScpStatementExternalize) UnmarshalBinary(inp []byte) error { r := bytes.NewReader(inp) - d := xdr.NewDecoder(r) - _, err := s.DecodeFrom(d, xdr.DecodeDefaultMaxDepth) + o := xdr.DefaultDecodeOptions + o.MaxInputLen = len(inp) + d := xdr.NewDecoderWithOptions(r, o) + _, err := s.DecodeFrom(d, o.MaxDepth) return err } @@ -748,8 +771,7 @@ var ( _ encoding.BinaryUnmarshaler = (*ScpStatementExternalize)(nil) ) -// xdrType signals that this type is an type representing -// representing XDR values defined by this package. +// xdrType signals that this type represents XDR values defined by this package. func (s ScpStatementExternalize) xdrType() {} var _ xdrType = (*ScpStatementExternalize)(nil) @@ -1047,8 +1069,10 @@ func (s ScpStatementPledges) MarshalBinary() ([]byte, error) { // UnmarshalBinary implements encoding.BinaryUnmarshaler. func (s *ScpStatementPledges) UnmarshalBinary(inp []byte) error { r := bytes.NewReader(inp) - d := xdr.NewDecoder(r) - _, err := s.DecodeFrom(d, xdr.DecodeDefaultMaxDepth) + o := xdr.DefaultDecodeOptions + o.MaxInputLen = len(inp) + d := xdr.NewDecoderWithOptions(r, o) + _, err := s.DecodeFrom(d, o.MaxDepth) return err } @@ -1057,8 +1081,7 @@ var ( _ encoding.BinaryUnmarshaler = (*ScpStatementPledges)(nil) ) -// xdrType signals that this type is an type representing -// representing XDR values defined by this package. +// xdrType signals that this type represents XDR values defined by this package. func (s ScpStatementPledges) xdrType() {} var _ xdrType = (*ScpStatementPledges)(nil) @@ -1163,8 +1186,10 @@ func (s ScpStatement) MarshalBinary() ([]byte, error) { // UnmarshalBinary implements encoding.BinaryUnmarshaler. func (s *ScpStatement) UnmarshalBinary(inp []byte) error { r := bytes.NewReader(inp) - d := xdr.NewDecoder(r) - _, err := s.DecodeFrom(d, xdr.DecodeDefaultMaxDepth) + o := xdr.DefaultDecodeOptions + o.MaxInputLen = len(inp) + d := xdr.NewDecoderWithOptions(r, o) + _, err := s.DecodeFrom(d, o.MaxDepth) return err } @@ -1173,8 +1198,7 @@ var ( _ encoding.BinaryUnmarshaler = (*ScpStatement)(nil) ) -// xdrType signals that this type is an type representing -// representing XDR values defined by this package. +// xdrType signals that this type represents XDR values defined by this package. func (s ScpStatement) xdrType() {} var _ xdrType = (*ScpStatement)(nil) @@ -1237,8 +1261,10 @@ func (s ScpEnvelope) MarshalBinary() ([]byte, error) { // UnmarshalBinary implements encoding.BinaryUnmarshaler. func (s *ScpEnvelope) UnmarshalBinary(inp []byte) error { r := bytes.NewReader(inp) - d := xdr.NewDecoder(r) - _, err := s.DecodeFrom(d, xdr.DecodeDefaultMaxDepth) + o := xdr.DefaultDecodeOptions + o.MaxInputLen = len(inp) + d := xdr.NewDecoderWithOptions(r, o) + _, err := s.DecodeFrom(d, o.MaxDepth) return err } @@ -1247,8 +1273,7 @@ var ( _ encoding.BinaryUnmarshaler = (*ScpEnvelope)(nil) ) -// xdrType signals that this type is an type representing -// representing XDR values defined by this package. +// xdrType signals that this type represents XDR values defined by this package. func (s ScpEnvelope) xdrType() {} var _ xdrType = (*ScpEnvelope)(nil) @@ -1315,8 +1340,11 @@ func (s *ScpQuorumSet) DecodeFrom(d *xdr.Decoder, maxDepth uint) (int, error) { } s.Validators = nil if l > 0 { + if il, ok := d.InputLen(); ok && uint(il) < uint(l) { + return n, fmt.Errorf("decoding NodeId: length (%d) exceeds remaining input length (%d)", l, il) + } s.Validators = make([]NodeId, l) - for i := uint32(0); i < l; i++ { + for i := uint32(0); uint(i) < uint(l); i++ { nTmp, err = s.Validators[i].DecodeFrom(d, maxDepth) n += nTmp if err != nil { @@ -1331,8 +1359,11 @@ func (s *ScpQuorumSet) DecodeFrom(d *xdr.Decoder, maxDepth uint) (int, error) { } s.InnerSets = nil if l > 0 { + if il, ok := d.InputLen(); ok && uint(il) < uint(l) { + return n, fmt.Errorf("decoding ScpQuorumSet: length (%d) exceeds remaining input length (%d)", l, il) + } s.InnerSets = make([]ScpQuorumSet, l) - for i := uint32(0); i < l; i++ { + for i := uint32(0); uint(i) < uint(l); i++ { nTmp, err = s.InnerSets[i].DecodeFrom(d, maxDepth) n += nTmp if err != nil { @@ -1354,8 +1385,10 @@ func (s ScpQuorumSet) MarshalBinary() ([]byte, error) { // UnmarshalBinary implements encoding.BinaryUnmarshaler. func (s *ScpQuorumSet) UnmarshalBinary(inp []byte) error { r := bytes.NewReader(inp) - d := xdr.NewDecoder(r) - _, err := s.DecodeFrom(d, xdr.DecodeDefaultMaxDepth) + o := xdr.DefaultDecodeOptions + o.MaxInputLen = len(inp) + d := xdr.NewDecoderWithOptions(r, o) + _, err := s.DecodeFrom(d, o.MaxDepth) return err } @@ -1364,8 +1397,7 @@ var ( _ encoding.BinaryUnmarshaler = (*ScpQuorumSet)(nil) ) -// xdrType signals that this type is an type representing -// representing XDR values defined by this package. +// xdrType signals that this type represents XDR values defined by this package. func (s ScpQuorumSet) xdrType() {} var _ xdrType = (*ScpQuorumSet)(nil) @@ -1418,8 +1450,10 @@ func (s Thresholds) MarshalBinary() ([]byte, error) { // UnmarshalBinary implements encoding.BinaryUnmarshaler. func (s *Thresholds) UnmarshalBinary(inp []byte) error { r := bytes.NewReader(inp) - d := xdr.NewDecoder(r) - _, err := s.DecodeFrom(d, xdr.DecodeDefaultMaxDepth) + o := xdr.DefaultDecodeOptions + o.MaxInputLen = len(inp) + d := xdr.NewDecoderWithOptions(r, o) + _, err := s.DecodeFrom(d, o.MaxDepth) return err } @@ -1428,8 +1462,7 @@ var ( _ encoding.BinaryUnmarshaler = (*Thresholds)(nil) ) -// xdrType signals that this type is an type representing -// representing XDR values defined by this package. +// xdrType signals that this type represents XDR values defined by this package. func (s Thresholds) xdrType() {} var _ xdrType = (*Thresholds)(nil) @@ -1484,8 +1517,10 @@ func (s String32) MarshalBinary() ([]byte, error) { // UnmarshalBinary implements encoding.BinaryUnmarshaler. func (s *String32) UnmarshalBinary(inp []byte) error { r := bytes.NewReader(inp) - d := xdr.NewDecoder(r) - _, err := s.DecodeFrom(d, xdr.DecodeDefaultMaxDepth) + o := xdr.DefaultDecodeOptions + o.MaxInputLen = len(inp) + d := xdr.NewDecoderWithOptions(r, o) + _, err := s.DecodeFrom(d, o.MaxDepth) return err } @@ -1494,8 +1529,7 @@ var ( _ encoding.BinaryUnmarshaler = (*String32)(nil) ) -// xdrType signals that this type is an type representing -// representing XDR values defined by this package. +// xdrType signals that this type represents XDR values defined by this package. func (s String32) xdrType() {} var _ xdrType = (*String32)(nil) @@ -1550,8 +1584,10 @@ func (s String64) MarshalBinary() ([]byte, error) { // UnmarshalBinary implements encoding.BinaryUnmarshaler. func (s *String64) UnmarshalBinary(inp []byte) error { r := bytes.NewReader(inp) - d := xdr.NewDecoder(r) - _, err := s.DecodeFrom(d, xdr.DecodeDefaultMaxDepth) + o := xdr.DefaultDecodeOptions + o.MaxInputLen = len(inp) + d := xdr.NewDecoderWithOptions(r, o) + _, err := s.DecodeFrom(d, o.MaxDepth) return err } @@ -1560,8 +1596,7 @@ var ( _ encoding.BinaryUnmarshaler = (*String64)(nil) ) -// xdrType signals that this type is an type representing -// representing XDR values defined by this package. +// xdrType signals that this type represents XDR values defined by this package. func (s String64) xdrType() {} var _ xdrType = (*String64)(nil) @@ -1609,8 +1644,10 @@ func (s SequenceNumber) MarshalBinary() ([]byte, error) { // UnmarshalBinary implements encoding.BinaryUnmarshaler. func (s *SequenceNumber) UnmarshalBinary(inp []byte) error { r := bytes.NewReader(inp) - d := xdr.NewDecoder(r) - _, err := s.DecodeFrom(d, xdr.DecodeDefaultMaxDepth) + o := xdr.DefaultDecodeOptions + o.MaxInputLen = len(inp) + d := xdr.NewDecoderWithOptions(r, o) + _, err := s.DecodeFrom(d, o.MaxDepth) return err } @@ -1619,8 +1656,7 @@ var ( _ encoding.BinaryUnmarshaler = (*SequenceNumber)(nil) ) -// xdrType signals that this type is an type representing -// representing XDR values defined by this package. +// xdrType signals that this type represents XDR values defined by this package. func (s SequenceNumber) xdrType() {} var _ xdrType = (*SequenceNumber)(nil) @@ -1673,8 +1709,10 @@ func (s DataValue) MarshalBinary() ([]byte, error) { // UnmarshalBinary implements encoding.BinaryUnmarshaler. func (s *DataValue) UnmarshalBinary(inp []byte) error { r := bytes.NewReader(inp) - d := xdr.NewDecoder(r) - _, err := s.DecodeFrom(d, xdr.DecodeDefaultMaxDepth) + o := xdr.DefaultDecodeOptions + o.MaxInputLen = len(inp) + d := xdr.NewDecoderWithOptions(r, o) + _, err := s.DecodeFrom(d, o.MaxDepth) return err } @@ -1683,8 +1721,7 @@ var ( _ encoding.BinaryUnmarshaler = (*DataValue)(nil) ) -// xdrType signals that this type is an type representing -// representing XDR values defined by this package. +// xdrType signals that this type represents XDR values defined by this package. func (s DataValue) xdrType() {} var _ xdrType = (*DataValue)(nil) @@ -1732,8 +1769,10 @@ func (s PoolId) MarshalBinary() ([]byte, error) { // UnmarshalBinary implements encoding.BinaryUnmarshaler. func (s *PoolId) UnmarshalBinary(inp []byte) error { r := bytes.NewReader(inp) - d := xdr.NewDecoder(r) - _, err := s.DecodeFrom(d, xdr.DecodeDefaultMaxDepth) + o := xdr.DefaultDecodeOptions + o.MaxInputLen = len(inp) + d := xdr.NewDecoderWithOptions(r, o) + _, err := s.DecodeFrom(d, o.MaxDepth) return err } @@ -1742,8 +1781,7 @@ var ( _ encoding.BinaryUnmarshaler = (*PoolId)(nil) ) -// xdrType signals that this type is an type representing -// representing XDR values defined by this package. +// xdrType signals that this type represents XDR values defined by this package. func (s PoolId) xdrType() {} var _ xdrType = (*PoolId)(nil) @@ -1796,8 +1834,10 @@ func (s AssetCode4) MarshalBinary() ([]byte, error) { // UnmarshalBinary implements encoding.BinaryUnmarshaler. func (s *AssetCode4) UnmarshalBinary(inp []byte) error { r := bytes.NewReader(inp) - d := xdr.NewDecoder(r) - _, err := s.DecodeFrom(d, xdr.DecodeDefaultMaxDepth) + o := xdr.DefaultDecodeOptions + o.MaxInputLen = len(inp) + d := xdr.NewDecoderWithOptions(r, o) + _, err := s.DecodeFrom(d, o.MaxDepth) return err } @@ -1806,8 +1846,7 @@ var ( _ encoding.BinaryUnmarshaler = (*AssetCode4)(nil) ) -// xdrType signals that this type is an type representing -// representing XDR values defined by this package. +// xdrType signals that this type represents XDR values defined by this package. func (s AssetCode4) xdrType() {} var _ xdrType = (*AssetCode4)(nil) @@ -1860,8 +1899,10 @@ func (s AssetCode12) MarshalBinary() ([]byte, error) { // UnmarshalBinary implements encoding.BinaryUnmarshaler. func (s *AssetCode12) UnmarshalBinary(inp []byte) error { r := bytes.NewReader(inp) - d := xdr.NewDecoder(r) - _, err := s.DecodeFrom(d, xdr.DecodeDefaultMaxDepth) + o := xdr.DefaultDecodeOptions + o.MaxInputLen = len(inp) + d := xdr.NewDecoderWithOptions(r, o) + _, err := s.DecodeFrom(d, o.MaxDepth) return err } @@ -1870,8 +1911,7 @@ var ( _ encoding.BinaryUnmarshaler = (*AssetCode12)(nil) ) -// xdrType signals that this type is an type representing -// representing XDR values defined by this package. +// xdrType signals that this type represents XDR values defined by this package. func (s AssetCode12) xdrType() {} var _ xdrType = (*AssetCode12)(nil) @@ -1953,8 +1993,10 @@ func (s AssetType) MarshalBinary() ([]byte, error) { // UnmarshalBinary implements encoding.BinaryUnmarshaler. func (s *AssetType) UnmarshalBinary(inp []byte) error { r := bytes.NewReader(inp) - d := xdr.NewDecoder(r) - _, err := s.DecodeFrom(d, xdr.DecodeDefaultMaxDepth) + o := xdr.DefaultDecodeOptions + o.MaxInputLen = len(inp) + d := xdr.NewDecoderWithOptions(r, o) + _, err := s.DecodeFrom(d, o.MaxDepth) return err } @@ -1963,8 +2005,7 @@ var ( _ encoding.BinaryUnmarshaler = (*AssetType)(nil) ) -// xdrType signals that this type is an type representing -// representing XDR values defined by this package. +// xdrType signals that this type represents XDR values defined by this package. func (s AssetType) xdrType() {} var _ xdrType = (*AssetType)(nil) @@ -2145,8 +2186,10 @@ func (s AssetCode) MarshalBinary() ([]byte, error) { // UnmarshalBinary implements encoding.BinaryUnmarshaler. func (s *AssetCode) UnmarshalBinary(inp []byte) error { r := bytes.NewReader(inp) - d := xdr.NewDecoder(r) - _, err := s.DecodeFrom(d, xdr.DecodeDefaultMaxDepth) + o := xdr.DefaultDecodeOptions + o.MaxInputLen = len(inp) + d := xdr.NewDecoderWithOptions(r, o) + _, err := s.DecodeFrom(d, o.MaxDepth) return err } @@ -2155,8 +2198,7 @@ var ( _ encoding.BinaryUnmarshaler = (*AssetCode)(nil) ) -// xdrType signals that this type is an type representing -// representing XDR values defined by this package. +// xdrType signals that this type represents XDR values defined by this package. func (s AssetCode) xdrType() {} var _ xdrType = (*AssetCode)(nil) @@ -2219,8 +2261,10 @@ func (s AlphaNum4) MarshalBinary() ([]byte, error) { // UnmarshalBinary implements encoding.BinaryUnmarshaler. func (s *AlphaNum4) UnmarshalBinary(inp []byte) error { r := bytes.NewReader(inp) - d := xdr.NewDecoder(r) - _, err := s.DecodeFrom(d, xdr.DecodeDefaultMaxDepth) + o := xdr.DefaultDecodeOptions + o.MaxInputLen = len(inp) + d := xdr.NewDecoderWithOptions(r, o) + _, err := s.DecodeFrom(d, o.MaxDepth) return err } @@ -2229,8 +2273,7 @@ var ( _ encoding.BinaryUnmarshaler = (*AlphaNum4)(nil) ) -// xdrType signals that this type is an type representing -// representing XDR values defined by this package. +// xdrType signals that this type represents XDR values defined by this package. func (s AlphaNum4) xdrType() {} var _ xdrType = (*AlphaNum4)(nil) @@ -2293,8 +2336,10 @@ func (s AlphaNum12) MarshalBinary() ([]byte, error) { // UnmarshalBinary implements encoding.BinaryUnmarshaler. func (s *AlphaNum12) UnmarshalBinary(inp []byte) error { r := bytes.NewReader(inp) - d := xdr.NewDecoder(r) - _, err := s.DecodeFrom(d, xdr.DecodeDefaultMaxDepth) + o := xdr.DefaultDecodeOptions + o.MaxInputLen = len(inp) + d := xdr.NewDecoderWithOptions(r, o) + _, err := s.DecodeFrom(d, o.MaxDepth) return err } @@ -2303,8 +2348,7 @@ var ( _ encoding.BinaryUnmarshaler = (*AlphaNum12)(nil) ) -// xdrType signals that this type is an type representing -// representing XDR values defined by this package. +// xdrType signals that this type represents XDR values defined by this package. func (s AlphaNum12) xdrType() {} var _ xdrType = (*AlphaNum12)(nil) @@ -2498,8 +2542,10 @@ func (s Asset) MarshalBinary() ([]byte, error) { // UnmarshalBinary implements encoding.BinaryUnmarshaler. func (s *Asset) UnmarshalBinary(inp []byte) error { r := bytes.NewReader(inp) - d := xdr.NewDecoder(r) - _, err := s.DecodeFrom(d, xdr.DecodeDefaultMaxDepth) + o := xdr.DefaultDecodeOptions + o.MaxInputLen = len(inp) + d := xdr.NewDecoderWithOptions(r, o) + _, err := s.DecodeFrom(d, o.MaxDepth) return err } @@ -2508,8 +2554,7 @@ var ( _ encoding.BinaryUnmarshaler = (*Asset)(nil) ) -// xdrType signals that this type is an type representing -// representing XDR values defined by this package. +// xdrType signals that this type represents XDR values defined by this package. func (s Asset) xdrType() {} var _ xdrType = (*Asset)(nil) @@ -2572,8 +2617,10 @@ func (s Price) MarshalBinary() ([]byte, error) { // UnmarshalBinary implements encoding.BinaryUnmarshaler. func (s *Price) UnmarshalBinary(inp []byte) error { r := bytes.NewReader(inp) - d := xdr.NewDecoder(r) - _, err := s.DecodeFrom(d, xdr.DecodeDefaultMaxDepth) + o := xdr.DefaultDecodeOptions + o.MaxInputLen = len(inp) + d := xdr.NewDecoderWithOptions(r, o) + _, err := s.DecodeFrom(d, o.MaxDepth) return err } @@ -2582,8 +2629,7 @@ var ( _ encoding.BinaryUnmarshaler = (*Price)(nil) ) -// xdrType signals that this type is an type representing -// representing XDR values defined by this package. +// xdrType signals that this type represents XDR values defined by this package. func (s Price) xdrType() {} var _ xdrType = (*Price)(nil) @@ -2646,8 +2692,10 @@ func (s Liabilities) MarshalBinary() ([]byte, error) { // UnmarshalBinary implements encoding.BinaryUnmarshaler. func (s *Liabilities) UnmarshalBinary(inp []byte) error { r := bytes.NewReader(inp) - d := xdr.NewDecoder(r) - _, err := s.DecodeFrom(d, xdr.DecodeDefaultMaxDepth) + o := xdr.DefaultDecodeOptions + o.MaxInputLen = len(inp) + d := xdr.NewDecoderWithOptions(r, o) + _, err := s.DecodeFrom(d, o.MaxDepth) return err } @@ -2656,8 +2704,7 @@ var ( _ encoding.BinaryUnmarshaler = (*Liabilities)(nil) ) -// xdrType signals that this type is an type representing -// representing XDR values defined by this package. +// xdrType signals that this type represents XDR values defined by this package. func (s Liabilities) xdrType() {} var _ xdrType = (*Liabilities)(nil) @@ -2739,8 +2786,10 @@ func (s ThresholdIndexes) MarshalBinary() ([]byte, error) { // UnmarshalBinary implements encoding.BinaryUnmarshaler. func (s *ThresholdIndexes) UnmarshalBinary(inp []byte) error { r := bytes.NewReader(inp) - d := xdr.NewDecoder(r) - _, err := s.DecodeFrom(d, xdr.DecodeDefaultMaxDepth) + o := xdr.DefaultDecodeOptions + o.MaxInputLen = len(inp) + d := xdr.NewDecoderWithOptions(r, o) + _, err := s.DecodeFrom(d, o.MaxDepth) return err } @@ -2749,8 +2798,7 @@ var ( _ encoding.BinaryUnmarshaler = (*ThresholdIndexes)(nil) ) -// xdrType signals that this type is an type representing -// representing XDR values defined by this package. +// xdrType signals that this type represents XDR values defined by this package. func (s ThresholdIndexes) xdrType() {} var _ xdrType = (*ThresholdIndexes)(nil) @@ -2850,8 +2898,10 @@ func (s LedgerEntryType) MarshalBinary() ([]byte, error) { // UnmarshalBinary implements encoding.BinaryUnmarshaler. func (s *LedgerEntryType) UnmarshalBinary(inp []byte) error { r := bytes.NewReader(inp) - d := xdr.NewDecoder(r) - _, err := s.DecodeFrom(d, xdr.DecodeDefaultMaxDepth) + o := xdr.DefaultDecodeOptions + o.MaxInputLen = len(inp) + d := xdr.NewDecoderWithOptions(r, o) + _, err := s.DecodeFrom(d, o.MaxDepth) return err } @@ -2860,8 +2910,7 @@ var ( _ encoding.BinaryUnmarshaler = (*LedgerEntryType)(nil) ) -// xdrType signals that this type is an type representing -// representing XDR values defined by this package. +// xdrType signals that this type represents XDR values defined by this package. func (s LedgerEntryType) xdrType() {} var _ xdrType = (*LedgerEntryType)(nil) @@ -2924,8 +2973,10 @@ func (s Signer) MarshalBinary() ([]byte, error) { // UnmarshalBinary implements encoding.BinaryUnmarshaler. func (s *Signer) UnmarshalBinary(inp []byte) error { r := bytes.NewReader(inp) - d := xdr.NewDecoder(r) - _, err := s.DecodeFrom(d, xdr.DecodeDefaultMaxDepth) + o := xdr.DefaultDecodeOptions + o.MaxInputLen = len(inp) + d := xdr.NewDecoderWithOptions(r, o) + _, err := s.DecodeFrom(d, o.MaxDepth) return err } @@ -2934,8 +2985,7 @@ var ( _ encoding.BinaryUnmarshaler = (*Signer)(nil) ) -// xdrType signals that this type is an type representing -// representing XDR values defined by this package. +// xdrType signals that this type represents XDR values defined by this package. func (s Signer) xdrType() {} var _ xdrType = (*Signer)(nil) @@ -3027,8 +3077,10 @@ func (s AccountFlags) MarshalBinary() ([]byte, error) { // UnmarshalBinary implements encoding.BinaryUnmarshaler. func (s *AccountFlags) UnmarshalBinary(inp []byte) error { r := bytes.NewReader(inp) - d := xdr.NewDecoder(r) - _, err := s.DecodeFrom(d, xdr.DecodeDefaultMaxDepth) + o := xdr.DefaultDecodeOptions + o.MaxInputLen = len(inp) + d := xdr.NewDecoderWithOptions(r, o) + _, err := s.DecodeFrom(d, o.MaxDepth) return err } @@ -3037,8 +3089,7 @@ var ( _ encoding.BinaryUnmarshaler = (*AccountFlags)(nil) ) -// xdrType signals that this type is an type representing -// representing XDR values defined by this package. +// xdrType signals that this type represents XDR values defined by this package. func (s AccountFlags) xdrType() {} var _ xdrType = (*AccountFlags)(nil) @@ -3137,8 +3188,10 @@ func (s AccountEntryExtensionV3) MarshalBinary() ([]byte, error) { // UnmarshalBinary implements encoding.BinaryUnmarshaler. func (s *AccountEntryExtensionV3) UnmarshalBinary(inp []byte) error { r := bytes.NewReader(inp) - d := xdr.NewDecoder(r) - _, err := s.DecodeFrom(d, xdr.DecodeDefaultMaxDepth) + o := xdr.DefaultDecodeOptions + o.MaxInputLen = len(inp) + d := xdr.NewDecoderWithOptions(r, o) + _, err := s.DecodeFrom(d, o.MaxDepth) return err } @@ -3147,8 +3200,7 @@ var ( _ encoding.BinaryUnmarshaler = (*AccountEntryExtensionV3)(nil) ) -// xdrType signals that this type is an type representing -// representing XDR values defined by this package. +// xdrType signals that this type represents XDR values defined by this package. func (s AccountEntryExtensionV3) xdrType() {} var _ xdrType = (*AccountEntryExtensionV3)(nil) @@ -3288,8 +3340,10 @@ func (s AccountEntryExtensionV2Ext) MarshalBinary() ([]byte, error) { // UnmarshalBinary implements encoding.BinaryUnmarshaler. func (s *AccountEntryExtensionV2Ext) UnmarshalBinary(inp []byte) error { r := bytes.NewReader(inp) - d := xdr.NewDecoder(r) - _, err := s.DecodeFrom(d, xdr.DecodeDefaultMaxDepth) + o := xdr.DefaultDecodeOptions + o.MaxInputLen = len(inp) + d := xdr.NewDecoderWithOptions(r, o) + _, err := s.DecodeFrom(d, o.MaxDepth) return err } @@ -3298,8 +3352,7 @@ var ( _ encoding.BinaryUnmarshaler = (*AccountEntryExtensionV2Ext)(nil) ) -// xdrType signals that this type is an type representing -// representing XDR values defined by this package. +// xdrType signals that this type represents XDR values defined by this package. func (s AccountEntryExtensionV2Ext) xdrType() {} var _ xdrType = (*AccountEntryExtensionV2Ext)(nil) @@ -3387,8 +3440,11 @@ func (s *AccountEntryExtensionV2) DecodeFrom(d *xdr.Decoder, maxDepth uint) (int } s.SignerSponsoringIDs = nil if l > 0 { + if il, ok := d.InputLen(); ok && uint(il) < uint(l) { + return n, fmt.Errorf("decoding SponsorshipDescriptor: length (%d) exceeds remaining input length (%d)", l, il) + } s.SignerSponsoringIDs = make([]SponsorshipDescriptor, l) - for i := uint32(0); i < l; i++ { + for i := uint32(0); uint(i) < uint(l); i++ { var eb bool eb, nTmp, err = d.DecodeBool() n += nTmp @@ -3425,8 +3481,10 @@ func (s AccountEntryExtensionV2) MarshalBinary() ([]byte, error) { // UnmarshalBinary implements encoding.BinaryUnmarshaler. func (s *AccountEntryExtensionV2) UnmarshalBinary(inp []byte) error { r := bytes.NewReader(inp) - d := xdr.NewDecoder(r) - _, err := s.DecodeFrom(d, xdr.DecodeDefaultMaxDepth) + o := xdr.DefaultDecodeOptions + o.MaxInputLen = len(inp) + d := xdr.NewDecoderWithOptions(r, o) + _, err := s.DecodeFrom(d, o.MaxDepth) return err } @@ -3435,8 +3493,7 @@ var ( _ encoding.BinaryUnmarshaler = (*AccountEntryExtensionV2)(nil) ) -// xdrType signals that this type is an type representing -// representing XDR values defined by this package. +// xdrType signals that this type represents XDR values defined by this package. func (s AccountEntryExtensionV2) xdrType() {} var _ xdrType = (*AccountEntryExtensionV2)(nil) @@ -3576,8 +3633,10 @@ func (s AccountEntryExtensionV1Ext) MarshalBinary() ([]byte, error) { // UnmarshalBinary implements encoding.BinaryUnmarshaler. func (s *AccountEntryExtensionV1Ext) UnmarshalBinary(inp []byte) error { r := bytes.NewReader(inp) - d := xdr.NewDecoder(r) - _, err := s.DecodeFrom(d, xdr.DecodeDefaultMaxDepth) + o := xdr.DefaultDecodeOptions + o.MaxInputLen = len(inp) + d := xdr.NewDecoderWithOptions(r, o) + _, err := s.DecodeFrom(d, o.MaxDepth) return err } @@ -3586,8 +3645,7 @@ var ( _ encoding.BinaryUnmarshaler = (*AccountEntryExtensionV1Ext)(nil) ) -// xdrType signals that this type is an type representing -// representing XDR values defined by this package. +// xdrType signals that this type represents XDR values defined by this package. func (s AccountEntryExtensionV1Ext) xdrType() {} var _ xdrType = (*AccountEntryExtensionV1Ext)(nil) @@ -3658,8 +3716,10 @@ func (s AccountEntryExtensionV1) MarshalBinary() ([]byte, error) { // UnmarshalBinary implements encoding.BinaryUnmarshaler. func (s *AccountEntryExtensionV1) UnmarshalBinary(inp []byte) error { r := bytes.NewReader(inp) - d := xdr.NewDecoder(r) - _, err := s.DecodeFrom(d, xdr.DecodeDefaultMaxDepth) + o := xdr.DefaultDecodeOptions + o.MaxInputLen = len(inp) + d := xdr.NewDecoderWithOptions(r, o) + _, err := s.DecodeFrom(d, o.MaxDepth) return err } @@ -3668,8 +3728,7 @@ var ( _ encoding.BinaryUnmarshaler = (*AccountEntryExtensionV1)(nil) ) -// xdrType signals that this type is an type representing -// representing XDR values defined by this package. +// xdrType signals that this type represents XDR values defined by this package. func (s AccountEntryExtensionV1) xdrType() {} var _ xdrType = (*AccountEntryExtensionV1)(nil) @@ -3809,8 +3868,10 @@ func (s AccountEntryExt) MarshalBinary() ([]byte, error) { // UnmarshalBinary implements encoding.BinaryUnmarshaler. func (s *AccountEntryExt) UnmarshalBinary(inp []byte) error { r := bytes.NewReader(inp) - d := xdr.NewDecoder(r) - _, err := s.DecodeFrom(d, xdr.DecodeDefaultMaxDepth) + o := xdr.DefaultDecodeOptions + o.MaxInputLen = len(inp) + d := xdr.NewDecoderWithOptions(r, o) + _, err := s.DecodeFrom(d, o.MaxDepth) return err } @@ -3819,8 +3880,7 @@ var ( _ encoding.BinaryUnmarshaler = (*AccountEntryExt)(nil) ) -// xdrType signals that this type is an type representing -// representing XDR values defined by this package. +// xdrType signals that this type represents XDR values defined by this package. func (s AccountEntryExt) xdrType() {} var _ xdrType = (*AccountEntryExt)(nil) @@ -3985,8 +4045,11 @@ func (s *AccountEntry) DecodeFrom(d *xdr.Decoder, maxDepth uint) (int, error) { } s.Signers = nil if l > 0 { + if il, ok := d.InputLen(); ok && uint(il) < uint(l) { + return n, fmt.Errorf("decoding Signer: length (%d) exceeds remaining input length (%d)", l, il) + } s.Signers = make([]Signer, l) - for i := uint32(0); i < l; i++ { + for i := uint32(0); uint(i) < uint(l); i++ { nTmp, err = s.Signers[i].DecodeFrom(d, maxDepth) n += nTmp if err != nil { @@ -4013,8 +4076,10 @@ func (s AccountEntry) MarshalBinary() ([]byte, error) { // UnmarshalBinary implements encoding.BinaryUnmarshaler. func (s *AccountEntry) UnmarshalBinary(inp []byte) error { r := bytes.NewReader(inp) - d := xdr.NewDecoder(r) - _, err := s.DecodeFrom(d, xdr.DecodeDefaultMaxDepth) + o := xdr.DefaultDecodeOptions + o.MaxInputLen = len(inp) + d := xdr.NewDecoderWithOptions(r, o) + _, err := s.DecodeFrom(d, o.MaxDepth) return err } @@ -4023,8 +4088,7 @@ var ( _ encoding.BinaryUnmarshaler = (*AccountEntry)(nil) ) -// xdrType signals that this type is an type representing -// representing XDR values defined by this package. +// xdrType signals that this type represents XDR values defined by this package. func (s AccountEntry) xdrType() {} var _ xdrType = (*AccountEntry)(nil) @@ -4108,8 +4172,10 @@ func (s TrustLineFlags) MarshalBinary() ([]byte, error) { // UnmarshalBinary implements encoding.BinaryUnmarshaler. func (s *TrustLineFlags) UnmarshalBinary(inp []byte) error { r := bytes.NewReader(inp) - d := xdr.NewDecoder(r) - _, err := s.DecodeFrom(d, xdr.DecodeDefaultMaxDepth) + o := xdr.DefaultDecodeOptions + o.MaxInputLen = len(inp) + d := xdr.NewDecoderWithOptions(r, o) + _, err := s.DecodeFrom(d, o.MaxDepth) return err } @@ -4118,8 +4184,7 @@ var ( _ encoding.BinaryUnmarshaler = (*TrustLineFlags)(nil) ) -// xdrType signals that this type is an type representing -// representing XDR values defined by this package. +// xdrType signals that this type represents XDR values defined by this package. func (s TrustLineFlags) xdrType() {} var _ xdrType = (*TrustLineFlags)(nil) @@ -4207,8 +4272,10 @@ func (s LiquidityPoolType) MarshalBinary() ([]byte, error) { // UnmarshalBinary implements encoding.BinaryUnmarshaler. func (s *LiquidityPoolType) UnmarshalBinary(inp []byte) error { r := bytes.NewReader(inp) - d := xdr.NewDecoder(r) - _, err := s.DecodeFrom(d, xdr.DecodeDefaultMaxDepth) + o := xdr.DefaultDecodeOptions + o.MaxInputLen = len(inp) + d := xdr.NewDecoderWithOptions(r, o) + _, err := s.DecodeFrom(d, o.MaxDepth) return err } @@ -4217,8 +4284,7 @@ var ( _ encoding.BinaryUnmarshaler = (*LiquidityPoolType)(nil) ) -// xdrType signals that this type is an type representing -// representing XDR values defined by this package. +// xdrType signals that this type represents XDR values defined by this package. func (s LiquidityPoolType) xdrType() {} var _ xdrType = (*LiquidityPoolType)(nil) @@ -4463,8 +4529,10 @@ func (s TrustLineAsset) MarshalBinary() ([]byte, error) { // UnmarshalBinary implements encoding.BinaryUnmarshaler. func (s *TrustLineAsset) UnmarshalBinary(inp []byte) error { r := bytes.NewReader(inp) - d := xdr.NewDecoder(r) - _, err := s.DecodeFrom(d, xdr.DecodeDefaultMaxDepth) + o := xdr.DefaultDecodeOptions + o.MaxInputLen = len(inp) + d := xdr.NewDecoderWithOptions(r, o) + _, err := s.DecodeFrom(d, o.MaxDepth) return err } @@ -4473,8 +4541,7 @@ var ( _ encoding.BinaryUnmarshaler = (*TrustLineAsset)(nil) ) -// xdrType signals that this type is an type representing -// representing XDR values defined by this package. +// xdrType signals that this type represents XDR values defined by this package. func (s TrustLineAsset) xdrType() {} var _ xdrType = (*TrustLineAsset)(nil) @@ -4564,8 +4631,10 @@ func (s TrustLineEntryExtensionV2Ext) MarshalBinary() ([]byte, error) { // UnmarshalBinary implements encoding.BinaryUnmarshaler. func (s *TrustLineEntryExtensionV2Ext) UnmarshalBinary(inp []byte) error { r := bytes.NewReader(inp) - d := xdr.NewDecoder(r) - _, err := s.DecodeFrom(d, xdr.DecodeDefaultMaxDepth) + o := xdr.DefaultDecodeOptions + o.MaxInputLen = len(inp) + d := xdr.NewDecoderWithOptions(r, o) + _, err := s.DecodeFrom(d, o.MaxDepth) return err } @@ -4574,8 +4643,7 @@ var ( _ encoding.BinaryUnmarshaler = (*TrustLineEntryExtensionV2Ext)(nil) ) -// xdrType signals that this type is an type representing -// representing XDR values defined by this package. +// xdrType signals that this type represents XDR values defined by this package. func (s TrustLineEntryExtensionV2Ext) xdrType() {} var _ xdrType = (*TrustLineEntryExtensionV2Ext)(nil) @@ -4644,8 +4712,10 @@ func (s TrustLineEntryExtensionV2) MarshalBinary() ([]byte, error) { // UnmarshalBinary implements encoding.BinaryUnmarshaler. func (s *TrustLineEntryExtensionV2) UnmarshalBinary(inp []byte) error { r := bytes.NewReader(inp) - d := xdr.NewDecoder(r) - _, err := s.DecodeFrom(d, xdr.DecodeDefaultMaxDepth) + o := xdr.DefaultDecodeOptions + o.MaxInputLen = len(inp) + d := xdr.NewDecoderWithOptions(r, o) + _, err := s.DecodeFrom(d, o.MaxDepth) return err } @@ -4654,8 +4724,7 @@ var ( _ encoding.BinaryUnmarshaler = (*TrustLineEntryExtensionV2)(nil) ) -// xdrType signals that this type is an type representing -// representing XDR values defined by this package. +// xdrType signals that this type represents XDR values defined by this package. func (s TrustLineEntryExtensionV2) xdrType() {} var _ xdrType = (*TrustLineEntryExtensionV2)(nil) @@ -4795,8 +4864,10 @@ func (s TrustLineEntryV1Ext) MarshalBinary() ([]byte, error) { // UnmarshalBinary implements encoding.BinaryUnmarshaler. func (s *TrustLineEntryV1Ext) UnmarshalBinary(inp []byte) error { r := bytes.NewReader(inp) - d := xdr.NewDecoder(r) - _, err := s.DecodeFrom(d, xdr.DecodeDefaultMaxDepth) + o := xdr.DefaultDecodeOptions + o.MaxInputLen = len(inp) + d := xdr.NewDecoderWithOptions(r, o) + _, err := s.DecodeFrom(d, o.MaxDepth) return err } @@ -4805,8 +4876,7 @@ var ( _ encoding.BinaryUnmarshaler = (*TrustLineEntryV1Ext)(nil) ) -// xdrType signals that this type is an type representing -// representing XDR values defined by this package. +// xdrType signals that this type represents XDR values defined by this package. func (s TrustLineEntryV1Ext) xdrType() {} var _ xdrType = (*TrustLineEntryV1Ext)(nil) @@ -4877,8 +4947,10 @@ func (s TrustLineEntryV1) MarshalBinary() ([]byte, error) { // UnmarshalBinary implements encoding.BinaryUnmarshaler. func (s *TrustLineEntryV1) UnmarshalBinary(inp []byte) error { r := bytes.NewReader(inp) - d := xdr.NewDecoder(r) - _, err := s.DecodeFrom(d, xdr.DecodeDefaultMaxDepth) + o := xdr.DefaultDecodeOptions + o.MaxInputLen = len(inp) + d := xdr.NewDecoderWithOptions(r, o) + _, err := s.DecodeFrom(d, o.MaxDepth) return err } @@ -4887,8 +4959,7 @@ var ( _ encoding.BinaryUnmarshaler = (*TrustLineEntryV1)(nil) ) -// xdrType signals that this type is an type representing -// representing XDR values defined by this package. +// xdrType signals that this type represents XDR values defined by this package. func (s TrustLineEntryV1) xdrType() {} var _ xdrType = (*TrustLineEntryV1)(nil) @@ -5040,8 +5111,10 @@ func (s TrustLineEntryExt) MarshalBinary() ([]byte, error) { // UnmarshalBinary implements encoding.BinaryUnmarshaler. func (s *TrustLineEntryExt) UnmarshalBinary(inp []byte) error { r := bytes.NewReader(inp) - d := xdr.NewDecoder(r) - _, err := s.DecodeFrom(d, xdr.DecodeDefaultMaxDepth) + o := xdr.DefaultDecodeOptions + o.MaxInputLen = len(inp) + d := xdr.NewDecoderWithOptions(r, o) + _, err := s.DecodeFrom(d, o.MaxDepth) return err } @@ -5050,8 +5123,7 @@ var ( _ encoding.BinaryUnmarshaler = (*TrustLineEntryExt)(nil) ) -// xdrType signals that this type is an type representing -// representing XDR values defined by this package. +// xdrType signals that this type represents XDR values defined by this package. func (s TrustLineEntryExt) xdrType() {} var _ xdrType = (*TrustLineEntryExt)(nil) @@ -5177,8 +5249,10 @@ func (s TrustLineEntry) MarshalBinary() ([]byte, error) { // UnmarshalBinary implements encoding.BinaryUnmarshaler. func (s *TrustLineEntry) UnmarshalBinary(inp []byte) error { r := bytes.NewReader(inp) - d := xdr.NewDecoder(r) - _, err := s.DecodeFrom(d, xdr.DecodeDefaultMaxDepth) + o := xdr.DefaultDecodeOptions + o.MaxInputLen = len(inp) + d := xdr.NewDecoderWithOptions(r, o) + _, err := s.DecodeFrom(d, o.MaxDepth) return err } @@ -5187,8 +5261,7 @@ var ( _ encoding.BinaryUnmarshaler = (*TrustLineEntry)(nil) ) -// xdrType signals that this type is an type representing -// representing XDR values defined by this package. +// xdrType signals that this type represents XDR values defined by this package. func (s TrustLineEntry) xdrType() {} var _ xdrType = (*TrustLineEntry)(nil) @@ -5263,8 +5336,10 @@ func (s OfferEntryFlags) MarshalBinary() ([]byte, error) { // UnmarshalBinary implements encoding.BinaryUnmarshaler. func (s *OfferEntryFlags) UnmarshalBinary(inp []byte) error { r := bytes.NewReader(inp) - d := xdr.NewDecoder(r) - _, err := s.DecodeFrom(d, xdr.DecodeDefaultMaxDepth) + o := xdr.DefaultDecodeOptions + o.MaxInputLen = len(inp) + d := xdr.NewDecoderWithOptions(r, o) + _, err := s.DecodeFrom(d, o.MaxDepth) return err } @@ -5273,8 +5348,7 @@ var ( _ encoding.BinaryUnmarshaler = (*OfferEntryFlags)(nil) ) -// xdrType signals that this type is an type representing -// representing XDR values defined by this package. +// xdrType signals that this type represents XDR values defined by this package. func (s OfferEntryFlags) xdrType() {} var _ xdrType = (*OfferEntryFlags)(nil) @@ -5369,8 +5443,10 @@ func (s OfferEntryExt) MarshalBinary() ([]byte, error) { // UnmarshalBinary implements encoding.BinaryUnmarshaler. func (s *OfferEntryExt) UnmarshalBinary(inp []byte) error { r := bytes.NewReader(inp) - d := xdr.NewDecoder(r) - _, err := s.DecodeFrom(d, xdr.DecodeDefaultMaxDepth) + o := xdr.DefaultDecodeOptions + o.MaxInputLen = len(inp) + d := xdr.NewDecoderWithOptions(r, o) + _, err := s.DecodeFrom(d, o.MaxDepth) return err } @@ -5379,8 +5455,7 @@ var ( _ encoding.BinaryUnmarshaler = (*OfferEntryExt)(nil) ) -// xdrType signals that this type is an type representing -// representing XDR values defined by this package. +// xdrType signals that this type represents XDR values defined by this package. func (s OfferEntryExt) xdrType() {} var _ xdrType = (*OfferEntryExt)(nil) @@ -5516,8 +5591,10 @@ func (s OfferEntry) MarshalBinary() ([]byte, error) { // UnmarshalBinary implements encoding.BinaryUnmarshaler. func (s *OfferEntry) UnmarshalBinary(inp []byte) error { r := bytes.NewReader(inp) - d := xdr.NewDecoder(r) - _, err := s.DecodeFrom(d, xdr.DecodeDefaultMaxDepth) + o := xdr.DefaultDecodeOptions + o.MaxInputLen = len(inp) + d := xdr.NewDecoderWithOptions(r, o) + _, err := s.DecodeFrom(d, o.MaxDepth) return err } @@ -5526,8 +5603,7 @@ var ( _ encoding.BinaryUnmarshaler = (*OfferEntry)(nil) ) -// xdrType signals that this type is an type representing -// representing XDR values defined by this package. +// xdrType signals that this type represents XDR values defined by this package. func (s OfferEntry) xdrType() {} var _ xdrType = (*OfferEntry)(nil) @@ -5617,8 +5693,10 @@ func (s DataEntryExt) MarshalBinary() ([]byte, error) { // UnmarshalBinary implements encoding.BinaryUnmarshaler. func (s *DataEntryExt) UnmarshalBinary(inp []byte) error { r := bytes.NewReader(inp) - d := xdr.NewDecoder(r) - _, err := s.DecodeFrom(d, xdr.DecodeDefaultMaxDepth) + o := xdr.DefaultDecodeOptions + o.MaxInputLen = len(inp) + d := xdr.NewDecoderWithOptions(r, o) + _, err := s.DecodeFrom(d, o.MaxDepth) return err } @@ -5627,8 +5705,7 @@ var ( _ encoding.BinaryUnmarshaler = (*DataEntryExt)(nil) ) -// xdrType signals that this type is an type representing -// representing XDR values defined by this package. +// xdrType signals that this type represents XDR values defined by this package. func (s DataEntryExt) xdrType() {} var _ xdrType = (*DataEntryExt)(nil) @@ -5718,8 +5795,10 @@ func (s DataEntry) MarshalBinary() ([]byte, error) { // UnmarshalBinary implements encoding.BinaryUnmarshaler. func (s *DataEntry) UnmarshalBinary(inp []byte) error { r := bytes.NewReader(inp) - d := xdr.NewDecoder(r) - _, err := s.DecodeFrom(d, xdr.DecodeDefaultMaxDepth) + o := xdr.DefaultDecodeOptions + o.MaxInputLen = len(inp) + d := xdr.NewDecoderWithOptions(r, o) + _, err := s.DecodeFrom(d, o.MaxDepth) return err } @@ -5728,8 +5807,7 @@ var ( _ encoding.BinaryUnmarshaler = (*DataEntry)(nil) ) -// xdrType signals that this type is an type representing -// representing XDR values defined by this package. +// xdrType signals that this type represents XDR values defined by this package. func (s DataEntry) xdrType() {} var _ xdrType = (*DataEntry)(nil) @@ -5817,8 +5895,10 @@ func (s ClaimPredicateType) MarshalBinary() ([]byte, error) { // UnmarshalBinary implements encoding.BinaryUnmarshaler. func (s *ClaimPredicateType) UnmarshalBinary(inp []byte) error { r := bytes.NewReader(inp) - d := xdr.NewDecoder(r) - _, err := s.DecodeFrom(d, xdr.DecodeDefaultMaxDepth) + o := xdr.DefaultDecodeOptions + o.MaxInputLen = len(inp) + d := xdr.NewDecoderWithOptions(r, o) + _, err := s.DecodeFrom(d, o.MaxDepth) return err } @@ -5827,8 +5907,7 @@ var ( _ encoding.BinaryUnmarshaler = (*ClaimPredicateType)(nil) ) -// xdrType signals that this type is an type representing -// representing XDR values defined by this package. +// xdrType signals that this type represents XDR values defined by this package. func (s ClaimPredicateType) xdrType() {} var _ xdrType = (*ClaimPredicateType)(nil) @@ -6142,8 +6221,11 @@ func (u *ClaimPredicate) DecodeFrom(d *xdr.Decoder, maxDepth uint) (int, error) } (*u.AndPredicates) = nil if l > 0 { + if il, ok := d.InputLen(); ok && uint(il) < uint(l) { + return n, fmt.Errorf("decoding ClaimPredicate: length (%d) exceeds remaining input length (%d)", l, il) + } (*u.AndPredicates) = make([]ClaimPredicate, l) - for i := uint32(0); i < l; i++ { + for i := uint32(0); uint(i) < uint(l); i++ { nTmp, err = (*u.AndPredicates)[i].DecodeFrom(d, maxDepth) n += nTmp if err != nil { @@ -6165,8 +6247,11 @@ func (u *ClaimPredicate) DecodeFrom(d *xdr.Decoder, maxDepth uint) (int, error) } (*u.OrPredicates) = nil if l > 0 { + if il, ok := d.InputLen(); ok && uint(il) < uint(l) { + return n, fmt.Errorf("decoding ClaimPredicate: length (%d) exceeds remaining input length (%d)", l, il) + } (*u.OrPredicates) = make([]ClaimPredicate, l) - for i := uint32(0); i < l; i++ { + for i := uint32(0); uint(i) < uint(l); i++ { nTmp, err = (*u.OrPredicates)[i].DecodeFrom(d, maxDepth) n += nTmp if err != nil { @@ -6224,8 +6309,10 @@ func (s ClaimPredicate) MarshalBinary() ([]byte, error) { // UnmarshalBinary implements encoding.BinaryUnmarshaler. func (s *ClaimPredicate) UnmarshalBinary(inp []byte) error { r := bytes.NewReader(inp) - d := xdr.NewDecoder(r) - _, err := s.DecodeFrom(d, xdr.DecodeDefaultMaxDepth) + o := xdr.DefaultDecodeOptions + o.MaxInputLen = len(inp) + d := xdr.NewDecoderWithOptions(r, o) + _, err := s.DecodeFrom(d, o.MaxDepth) return err } @@ -6234,8 +6321,7 @@ var ( _ encoding.BinaryUnmarshaler = (*ClaimPredicate)(nil) ) -// xdrType signals that this type is an type representing -// representing XDR values defined by this package. +// xdrType signals that this type represents XDR values defined by this package. func (s ClaimPredicate) xdrType() {} var _ xdrType = (*ClaimPredicate)(nil) @@ -6308,8 +6394,10 @@ func (s ClaimantType) MarshalBinary() ([]byte, error) { // UnmarshalBinary implements encoding.BinaryUnmarshaler. func (s *ClaimantType) UnmarshalBinary(inp []byte) error { r := bytes.NewReader(inp) - d := xdr.NewDecoder(r) - _, err := s.DecodeFrom(d, xdr.DecodeDefaultMaxDepth) + o := xdr.DefaultDecodeOptions + o.MaxInputLen = len(inp) + d := xdr.NewDecoderWithOptions(r, o) + _, err := s.DecodeFrom(d, o.MaxDepth) return err } @@ -6318,8 +6406,7 @@ var ( _ encoding.BinaryUnmarshaler = (*ClaimantType)(nil) ) -// xdrType signals that this type is an type representing -// representing XDR values defined by this package. +// xdrType signals that this type represents XDR values defined by this package. func (s ClaimantType) xdrType() {} var _ xdrType = (*ClaimantType)(nil) @@ -6382,8 +6469,10 @@ func (s ClaimantV0) MarshalBinary() ([]byte, error) { // UnmarshalBinary implements encoding.BinaryUnmarshaler. func (s *ClaimantV0) UnmarshalBinary(inp []byte) error { r := bytes.NewReader(inp) - d := xdr.NewDecoder(r) - _, err := s.DecodeFrom(d, xdr.DecodeDefaultMaxDepth) + o := xdr.DefaultDecodeOptions + o.MaxInputLen = len(inp) + d := xdr.NewDecoderWithOptions(r, o) + _, err := s.DecodeFrom(d, o.MaxDepth) return err } @@ -6392,8 +6481,7 @@ var ( _ encoding.BinaryUnmarshaler = (*ClaimantV0)(nil) ) -// xdrType signals that this type is an type representing -// representing XDR values defined by this package. +// xdrType signals that this type represents XDR values defined by this package. func (s ClaimantV0) xdrType() {} var _ xdrType = (*ClaimantV0)(nil) @@ -6525,8 +6613,10 @@ func (s Claimant) MarshalBinary() ([]byte, error) { // UnmarshalBinary implements encoding.BinaryUnmarshaler. func (s *Claimant) UnmarshalBinary(inp []byte) error { r := bytes.NewReader(inp) - d := xdr.NewDecoder(r) - _, err := s.DecodeFrom(d, xdr.DecodeDefaultMaxDepth) + o := xdr.DefaultDecodeOptions + o.MaxInputLen = len(inp) + d := xdr.NewDecoderWithOptions(r, o) + _, err := s.DecodeFrom(d, o.MaxDepth) return err } @@ -6535,8 +6625,7 @@ var ( _ encoding.BinaryUnmarshaler = (*Claimant)(nil) ) -// xdrType signals that this type is an type representing -// representing XDR values defined by this package. +// xdrType signals that this type represents XDR values defined by this package. func (s Claimant) xdrType() {} var _ xdrType = (*Claimant)(nil) @@ -6609,8 +6698,10 @@ func (s ClaimableBalanceIdType) MarshalBinary() ([]byte, error) { // UnmarshalBinary implements encoding.BinaryUnmarshaler. func (s *ClaimableBalanceIdType) UnmarshalBinary(inp []byte) error { r := bytes.NewReader(inp) - d := xdr.NewDecoder(r) - _, err := s.DecodeFrom(d, xdr.DecodeDefaultMaxDepth) + o := xdr.DefaultDecodeOptions + o.MaxInputLen = len(inp) + d := xdr.NewDecoderWithOptions(r, o) + _, err := s.DecodeFrom(d, o.MaxDepth) return err } @@ -6619,8 +6710,7 @@ var ( _ encoding.BinaryUnmarshaler = (*ClaimableBalanceIdType)(nil) ) -// xdrType signals that this type is an type representing -// representing XDR values defined by this package. +// xdrType signals that this type represents XDR values defined by this package. func (s ClaimableBalanceIdType) xdrType() {} var _ xdrType = (*ClaimableBalanceIdType)(nil) @@ -6748,8 +6838,10 @@ func (s ClaimableBalanceId) MarshalBinary() ([]byte, error) { // UnmarshalBinary implements encoding.BinaryUnmarshaler. func (s *ClaimableBalanceId) UnmarshalBinary(inp []byte) error { r := bytes.NewReader(inp) - d := xdr.NewDecoder(r) - _, err := s.DecodeFrom(d, xdr.DecodeDefaultMaxDepth) + o := xdr.DefaultDecodeOptions + o.MaxInputLen = len(inp) + d := xdr.NewDecoderWithOptions(r, o) + _, err := s.DecodeFrom(d, o.MaxDepth) return err } @@ -6758,8 +6850,7 @@ var ( _ encoding.BinaryUnmarshaler = (*ClaimableBalanceId)(nil) ) -// xdrType signals that this type is an type representing -// representing XDR values defined by this package. +// xdrType signals that this type represents XDR values defined by this package. func (s ClaimableBalanceId) xdrType() {} var _ xdrType = (*ClaimableBalanceId)(nil) @@ -6834,8 +6925,10 @@ func (s ClaimableBalanceFlags) MarshalBinary() ([]byte, error) { // UnmarshalBinary implements encoding.BinaryUnmarshaler. func (s *ClaimableBalanceFlags) UnmarshalBinary(inp []byte) error { r := bytes.NewReader(inp) - d := xdr.NewDecoder(r) - _, err := s.DecodeFrom(d, xdr.DecodeDefaultMaxDepth) + o := xdr.DefaultDecodeOptions + o.MaxInputLen = len(inp) + d := xdr.NewDecoderWithOptions(r, o) + _, err := s.DecodeFrom(d, o.MaxDepth) return err } @@ -6844,8 +6937,7 @@ var ( _ encoding.BinaryUnmarshaler = (*ClaimableBalanceFlags)(nil) ) -// xdrType signals that this type is an type representing -// representing XDR values defined by this package. +// xdrType signals that this type represents XDR values defined by this package. func (s ClaimableBalanceFlags) xdrType() {} var _ xdrType = (*ClaimableBalanceFlags)(nil) @@ -6940,8 +7032,10 @@ func (s ClaimableBalanceEntryExtensionV1Ext) MarshalBinary() ([]byte, error) { // UnmarshalBinary implements encoding.BinaryUnmarshaler. func (s *ClaimableBalanceEntryExtensionV1Ext) UnmarshalBinary(inp []byte) error { r := bytes.NewReader(inp) - d := xdr.NewDecoder(r) - _, err := s.DecodeFrom(d, xdr.DecodeDefaultMaxDepth) + o := xdr.DefaultDecodeOptions + o.MaxInputLen = len(inp) + d := xdr.NewDecoderWithOptions(r, o) + _, err := s.DecodeFrom(d, o.MaxDepth) return err } @@ -6950,8 +7044,7 @@ var ( _ encoding.BinaryUnmarshaler = (*ClaimableBalanceEntryExtensionV1Ext)(nil) ) -// xdrType signals that this type is an type representing -// representing XDR values defined by this package. +// xdrType signals that this type represents XDR values defined by this package. func (s ClaimableBalanceEntryExtensionV1Ext) xdrType() {} var _ xdrType = (*ClaimableBalanceEntryExtensionV1Ext)(nil) @@ -7020,8 +7113,10 @@ func (s ClaimableBalanceEntryExtensionV1) MarshalBinary() ([]byte, error) { // UnmarshalBinary implements encoding.BinaryUnmarshaler. func (s *ClaimableBalanceEntryExtensionV1) UnmarshalBinary(inp []byte) error { r := bytes.NewReader(inp) - d := xdr.NewDecoder(r) - _, err := s.DecodeFrom(d, xdr.DecodeDefaultMaxDepth) + o := xdr.DefaultDecodeOptions + o.MaxInputLen = len(inp) + d := xdr.NewDecoderWithOptions(r, o) + _, err := s.DecodeFrom(d, o.MaxDepth) return err } @@ -7030,8 +7125,7 @@ var ( _ encoding.BinaryUnmarshaler = (*ClaimableBalanceEntryExtensionV1)(nil) ) -// xdrType signals that this type is an type representing -// representing XDR values defined by this package. +// xdrType signals that this type represents XDR values defined by this package. func (s ClaimableBalanceEntryExtensionV1) xdrType() {} var _ xdrType = (*ClaimableBalanceEntryExtensionV1)(nil) @@ -7171,8 +7265,10 @@ func (s ClaimableBalanceEntryExt) MarshalBinary() ([]byte, error) { // UnmarshalBinary implements encoding.BinaryUnmarshaler. func (s *ClaimableBalanceEntryExt) UnmarshalBinary(inp []byte) error { r := bytes.NewReader(inp) - d := xdr.NewDecoder(r) - _, err := s.DecodeFrom(d, xdr.DecodeDefaultMaxDepth) + o := xdr.DefaultDecodeOptions + o.MaxInputLen = len(inp) + d := xdr.NewDecoderWithOptions(r, o) + _, err := s.DecodeFrom(d, o.MaxDepth) return err } @@ -7181,8 +7277,7 @@ var ( _ encoding.BinaryUnmarshaler = (*ClaimableBalanceEntryExt)(nil) ) -// xdrType signals that this type is an type representing -// representing XDR values defined by this package. +// xdrType signals that this type represents XDR values defined by this package. func (s ClaimableBalanceEntryExt) xdrType() {} var _ xdrType = (*ClaimableBalanceEntryExt)(nil) @@ -7273,8 +7368,11 @@ func (s *ClaimableBalanceEntry) DecodeFrom(d *xdr.Decoder, maxDepth uint) (int, } s.Claimants = nil if l > 0 { + if il, ok := d.InputLen(); ok && uint(il) < uint(l) { + return n, fmt.Errorf("decoding Claimant: length (%d) exceeds remaining input length (%d)", l, il) + } s.Claimants = make([]Claimant, l) - for i := uint32(0); i < l; i++ { + for i := uint32(0); uint(i) < uint(l); i++ { nTmp, err = s.Claimants[i].DecodeFrom(d, maxDepth) n += nTmp if err != nil { @@ -7311,8 +7409,10 @@ func (s ClaimableBalanceEntry) MarshalBinary() ([]byte, error) { // UnmarshalBinary implements encoding.BinaryUnmarshaler. func (s *ClaimableBalanceEntry) UnmarshalBinary(inp []byte) error { r := bytes.NewReader(inp) - d := xdr.NewDecoder(r) - _, err := s.DecodeFrom(d, xdr.DecodeDefaultMaxDepth) + o := xdr.DefaultDecodeOptions + o.MaxInputLen = len(inp) + d := xdr.NewDecoderWithOptions(r, o) + _, err := s.DecodeFrom(d, o.MaxDepth) return err } @@ -7321,8 +7421,7 @@ var ( _ encoding.BinaryUnmarshaler = (*ClaimableBalanceEntry)(nil) ) -// xdrType signals that this type is an type representing -// representing XDR values defined by this package. +// xdrType signals that this type represents XDR values defined by this package. func (s ClaimableBalanceEntry) xdrType() {} var _ xdrType = (*ClaimableBalanceEntry)(nil) @@ -7395,8 +7494,10 @@ func (s LiquidityPoolConstantProductParameters) MarshalBinary() ([]byte, error) // UnmarshalBinary implements encoding.BinaryUnmarshaler. func (s *LiquidityPoolConstantProductParameters) UnmarshalBinary(inp []byte) error { r := bytes.NewReader(inp) - d := xdr.NewDecoder(r) - _, err := s.DecodeFrom(d, xdr.DecodeDefaultMaxDepth) + o := xdr.DefaultDecodeOptions + o.MaxInputLen = len(inp) + d := xdr.NewDecoderWithOptions(r, o) + _, err := s.DecodeFrom(d, o.MaxDepth) return err } @@ -7405,8 +7506,7 @@ var ( _ encoding.BinaryUnmarshaler = (*LiquidityPoolConstantProductParameters)(nil) ) -// xdrType signals that this type is an type representing -// representing XDR values defined by this package. +// xdrType signals that this type represents XDR values defined by this package. func (s LiquidityPoolConstantProductParameters) xdrType() {} var _ xdrType = (*LiquidityPoolConstantProductParameters)(nil) @@ -7501,8 +7601,10 @@ func (s LiquidityPoolEntryConstantProduct) MarshalBinary() ([]byte, error) { // UnmarshalBinary implements encoding.BinaryUnmarshaler. func (s *LiquidityPoolEntryConstantProduct) UnmarshalBinary(inp []byte) error { r := bytes.NewReader(inp) - d := xdr.NewDecoder(r) - _, err := s.DecodeFrom(d, xdr.DecodeDefaultMaxDepth) + o := xdr.DefaultDecodeOptions + o.MaxInputLen = len(inp) + d := xdr.NewDecoderWithOptions(r, o) + _, err := s.DecodeFrom(d, o.MaxDepth) return err } @@ -7511,8 +7613,7 @@ var ( _ encoding.BinaryUnmarshaler = (*LiquidityPoolEntryConstantProduct)(nil) ) -// xdrType signals that this type is an type representing -// representing XDR values defined by this package. +// xdrType signals that this type represents XDR values defined by this package. func (s LiquidityPoolEntryConstantProduct) xdrType() {} var _ xdrType = (*LiquidityPoolEntryConstantProduct)(nil) @@ -7649,8 +7750,10 @@ func (s LiquidityPoolEntryBody) MarshalBinary() ([]byte, error) { // UnmarshalBinary implements encoding.BinaryUnmarshaler. func (s *LiquidityPoolEntryBody) UnmarshalBinary(inp []byte) error { r := bytes.NewReader(inp) - d := xdr.NewDecoder(r) - _, err := s.DecodeFrom(d, xdr.DecodeDefaultMaxDepth) + o := xdr.DefaultDecodeOptions + o.MaxInputLen = len(inp) + d := xdr.NewDecoderWithOptions(r, o) + _, err := s.DecodeFrom(d, o.MaxDepth) return err } @@ -7659,8 +7762,7 @@ var ( _ encoding.BinaryUnmarshaler = (*LiquidityPoolEntryBody)(nil) ) -// xdrType signals that this type is an type representing -// representing XDR values defined by this package. +// xdrType signals that this type represents XDR values defined by this package. func (s LiquidityPoolEntryBody) xdrType() {} var _ xdrType = (*LiquidityPoolEntryBody)(nil) @@ -7738,8 +7840,10 @@ func (s LiquidityPoolEntry) MarshalBinary() ([]byte, error) { // UnmarshalBinary implements encoding.BinaryUnmarshaler. func (s *LiquidityPoolEntry) UnmarshalBinary(inp []byte) error { r := bytes.NewReader(inp) - d := xdr.NewDecoder(r) - _, err := s.DecodeFrom(d, xdr.DecodeDefaultMaxDepth) + o := xdr.DefaultDecodeOptions + o.MaxInputLen = len(inp) + d := xdr.NewDecoderWithOptions(r, o) + _, err := s.DecodeFrom(d, o.MaxDepth) return err } @@ -7748,8 +7852,7 @@ var ( _ encoding.BinaryUnmarshaler = (*LiquidityPoolEntry)(nil) ) -// xdrType signals that this type is an type representing -// representing XDR values defined by this package. +// xdrType signals that this type represents XDR values defined by this package. func (s LiquidityPoolEntry) xdrType() {} var _ xdrType = (*LiquidityPoolEntry)(nil) @@ -7824,8 +7927,10 @@ func (s ContractDataDurability) MarshalBinary() ([]byte, error) { // UnmarshalBinary implements encoding.BinaryUnmarshaler. func (s *ContractDataDurability) UnmarshalBinary(inp []byte) error { r := bytes.NewReader(inp) - d := xdr.NewDecoder(r) - _, err := s.DecodeFrom(d, xdr.DecodeDefaultMaxDepth) + o := xdr.DefaultDecodeOptions + o.MaxInputLen = len(inp) + d := xdr.NewDecoderWithOptions(r, o) + _, err := s.DecodeFrom(d, o.MaxDepth) return err } @@ -7834,8 +7939,7 @@ var ( _ encoding.BinaryUnmarshaler = (*ContractDataDurability)(nil) ) -// xdrType signals that this type is an type representing -// representing XDR values defined by this package. +// xdrType signals that this type represents XDR values defined by this package. func (s ContractDataDurability) xdrType() {} var _ xdrType = (*ContractDataDurability)(nil) @@ -7928,8 +8032,10 @@ func (s ContractDataEntry) MarshalBinary() ([]byte, error) { // UnmarshalBinary implements encoding.BinaryUnmarshaler. func (s *ContractDataEntry) UnmarshalBinary(inp []byte) error { r := bytes.NewReader(inp) - d := xdr.NewDecoder(r) - _, err := s.DecodeFrom(d, xdr.DecodeDefaultMaxDepth) + o := xdr.DefaultDecodeOptions + o.MaxInputLen = len(inp) + d := xdr.NewDecoderWithOptions(r, o) + _, err := s.DecodeFrom(d, o.MaxDepth) return err } @@ -7938,8 +8044,7 @@ var ( _ encoding.BinaryUnmarshaler = (*ContractDataEntry)(nil) ) -// xdrType signals that this type is an type representing -// representing XDR values defined by this package. +// xdrType signals that this type represents XDR values defined by this package. func (s ContractDataEntry) xdrType() {} var _ xdrType = (*ContractDataEntry)(nil) @@ -8012,8 +8117,10 @@ func (s ContractCodeEntry) MarshalBinary() ([]byte, error) { // UnmarshalBinary implements encoding.BinaryUnmarshaler. func (s *ContractCodeEntry) UnmarshalBinary(inp []byte) error { r := bytes.NewReader(inp) - d := xdr.NewDecoder(r) - _, err := s.DecodeFrom(d, xdr.DecodeDefaultMaxDepth) + o := xdr.DefaultDecodeOptions + o.MaxInputLen = len(inp) + d := xdr.NewDecoderWithOptions(r, o) + _, err := s.DecodeFrom(d, o.MaxDepth) return err } @@ -8022,8 +8129,7 @@ var ( _ encoding.BinaryUnmarshaler = (*ContractCodeEntry)(nil) ) -// xdrType signals that this type is an type representing -// representing XDR values defined by this package. +// xdrType signals that this type represents XDR values defined by this package. func (s ContractCodeEntry) xdrType() {} var _ xdrType = (*ContractCodeEntry)(nil) @@ -8086,8 +8192,10 @@ func (s TtlEntry) MarshalBinary() ([]byte, error) { // UnmarshalBinary implements encoding.BinaryUnmarshaler. func (s *TtlEntry) UnmarshalBinary(inp []byte) error { r := bytes.NewReader(inp) - d := xdr.NewDecoder(r) - _, err := s.DecodeFrom(d, xdr.DecodeDefaultMaxDepth) + o := xdr.DefaultDecodeOptions + o.MaxInputLen = len(inp) + d := xdr.NewDecoderWithOptions(r, o) + _, err := s.DecodeFrom(d, o.MaxDepth) return err } @@ -8096,8 +8204,7 @@ var ( _ encoding.BinaryUnmarshaler = (*TtlEntry)(nil) ) -// xdrType signals that this type is an type representing -// representing XDR values defined by this package. +// xdrType signals that this type represents XDR values defined by this package. func (s TtlEntry) xdrType() {} var _ xdrType = (*TtlEntry)(nil) @@ -8187,8 +8294,10 @@ func (s LedgerEntryExtensionV1Ext) MarshalBinary() ([]byte, error) { // UnmarshalBinary implements encoding.BinaryUnmarshaler. func (s *LedgerEntryExtensionV1Ext) UnmarshalBinary(inp []byte) error { r := bytes.NewReader(inp) - d := xdr.NewDecoder(r) - _, err := s.DecodeFrom(d, xdr.DecodeDefaultMaxDepth) + o := xdr.DefaultDecodeOptions + o.MaxInputLen = len(inp) + d := xdr.NewDecoderWithOptions(r, o) + _, err := s.DecodeFrom(d, o.MaxDepth) return err } @@ -8197,8 +8306,7 @@ var ( _ encoding.BinaryUnmarshaler = (*LedgerEntryExtensionV1Ext)(nil) ) -// xdrType signals that this type is an type representing -// representing XDR values defined by this package. +// xdrType signals that this type represents XDR values defined by this package. func (s LedgerEntryExtensionV1Ext) xdrType() {} var _ xdrType = (*LedgerEntryExtensionV1Ext)(nil) @@ -8282,8 +8390,10 @@ func (s LedgerEntryExtensionV1) MarshalBinary() ([]byte, error) { // UnmarshalBinary implements encoding.BinaryUnmarshaler. func (s *LedgerEntryExtensionV1) UnmarshalBinary(inp []byte) error { r := bytes.NewReader(inp) - d := xdr.NewDecoder(r) - _, err := s.DecodeFrom(d, xdr.DecodeDefaultMaxDepth) + o := xdr.DefaultDecodeOptions + o.MaxInputLen = len(inp) + d := xdr.NewDecoderWithOptions(r, o) + _, err := s.DecodeFrom(d, o.MaxDepth) return err } @@ -8292,8 +8402,7 @@ var ( _ encoding.BinaryUnmarshaler = (*LedgerEntryExtensionV1)(nil) ) -// xdrType signals that this type is an type representing -// representing XDR values defined by this package. +// xdrType signals that this type represents XDR values defined by this package. func (s LedgerEntryExtensionV1) xdrType() {} var _ xdrType = (*LedgerEntryExtensionV1)(nil) @@ -8871,8 +8980,10 @@ func (s LedgerEntryData) MarshalBinary() ([]byte, error) { // UnmarshalBinary implements encoding.BinaryUnmarshaler. func (s *LedgerEntryData) UnmarshalBinary(inp []byte) error { r := bytes.NewReader(inp) - d := xdr.NewDecoder(r) - _, err := s.DecodeFrom(d, xdr.DecodeDefaultMaxDepth) + o := xdr.DefaultDecodeOptions + o.MaxInputLen = len(inp) + d := xdr.NewDecoderWithOptions(r, o) + _, err := s.DecodeFrom(d, o.MaxDepth) return err } @@ -8881,8 +8992,7 @@ var ( _ encoding.BinaryUnmarshaler = (*LedgerEntryData)(nil) ) -// xdrType signals that this type is an type representing -// representing XDR values defined by this package. +// xdrType signals that this type represents XDR values defined by this package. func (s LedgerEntryData) xdrType() {} var _ xdrType = (*LedgerEntryData)(nil) @@ -9022,8 +9132,10 @@ func (s LedgerEntryExt) MarshalBinary() ([]byte, error) { // UnmarshalBinary implements encoding.BinaryUnmarshaler. func (s *LedgerEntryExt) UnmarshalBinary(inp []byte) error { r := bytes.NewReader(inp) - d := xdr.NewDecoder(r) - _, err := s.DecodeFrom(d, xdr.DecodeDefaultMaxDepth) + o := xdr.DefaultDecodeOptions + o.MaxInputLen = len(inp) + d := xdr.NewDecoderWithOptions(r, o) + _, err := s.DecodeFrom(d, o.MaxDepth) return err } @@ -9032,8 +9144,7 @@ var ( _ encoding.BinaryUnmarshaler = (*LedgerEntryExt)(nil) ) -// xdrType signals that this type is an type representing -// representing XDR values defined by this package. +// xdrType signals that this type represents XDR values defined by this package. func (s LedgerEntryExt) xdrType() {} var _ xdrType = (*LedgerEntryExt)(nil) @@ -9139,8 +9250,10 @@ func (s LedgerEntry) MarshalBinary() ([]byte, error) { // UnmarshalBinary implements encoding.BinaryUnmarshaler. func (s *LedgerEntry) UnmarshalBinary(inp []byte) error { r := bytes.NewReader(inp) - d := xdr.NewDecoder(r) - _, err := s.DecodeFrom(d, xdr.DecodeDefaultMaxDepth) + o := xdr.DefaultDecodeOptions + o.MaxInputLen = len(inp) + d := xdr.NewDecoderWithOptions(r, o) + _, err := s.DecodeFrom(d, o.MaxDepth) return err } @@ -9149,8 +9262,7 @@ var ( _ encoding.BinaryUnmarshaler = (*LedgerEntry)(nil) ) -// xdrType signals that this type is an type representing -// representing XDR values defined by this package. +// xdrType signals that this type represents XDR values defined by this package. func (s LedgerEntry) xdrType() {} var _ xdrType = (*LedgerEntry)(nil) @@ -9203,8 +9315,10 @@ func (s LedgerKeyAccount) MarshalBinary() ([]byte, error) { // UnmarshalBinary implements encoding.BinaryUnmarshaler. func (s *LedgerKeyAccount) UnmarshalBinary(inp []byte) error { r := bytes.NewReader(inp) - d := xdr.NewDecoder(r) - _, err := s.DecodeFrom(d, xdr.DecodeDefaultMaxDepth) + o := xdr.DefaultDecodeOptions + o.MaxInputLen = len(inp) + d := xdr.NewDecoderWithOptions(r, o) + _, err := s.DecodeFrom(d, o.MaxDepth) return err } @@ -9213,8 +9327,7 @@ var ( _ encoding.BinaryUnmarshaler = (*LedgerKeyAccount)(nil) ) -// xdrType signals that this type is an type representing -// representing XDR values defined by this package. +// xdrType signals that this type represents XDR values defined by this package. func (s LedgerKeyAccount) xdrType() {} var _ xdrType = (*LedgerKeyAccount)(nil) @@ -9277,8 +9390,10 @@ func (s LedgerKeyTrustLine) MarshalBinary() ([]byte, error) { // UnmarshalBinary implements encoding.BinaryUnmarshaler. func (s *LedgerKeyTrustLine) UnmarshalBinary(inp []byte) error { r := bytes.NewReader(inp) - d := xdr.NewDecoder(r) - _, err := s.DecodeFrom(d, xdr.DecodeDefaultMaxDepth) + o := xdr.DefaultDecodeOptions + o.MaxInputLen = len(inp) + d := xdr.NewDecoderWithOptions(r, o) + _, err := s.DecodeFrom(d, o.MaxDepth) return err } @@ -9287,8 +9402,7 @@ var ( _ encoding.BinaryUnmarshaler = (*LedgerKeyTrustLine)(nil) ) -// xdrType signals that this type is an type representing -// representing XDR values defined by this package. +// xdrType signals that this type represents XDR values defined by this package. func (s LedgerKeyTrustLine) xdrType() {} var _ xdrType = (*LedgerKeyTrustLine)(nil) @@ -9351,8 +9465,10 @@ func (s LedgerKeyOffer) MarshalBinary() ([]byte, error) { // UnmarshalBinary implements encoding.BinaryUnmarshaler. func (s *LedgerKeyOffer) UnmarshalBinary(inp []byte) error { r := bytes.NewReader(inp) - d := xdr.NewDecoder(r) - _, err := s.DecodeFrom(d, xdr.DecodeDefaultMaxDepth) + o := xdr.DefaultDecodeOptions + o.MaxInputLen = len(inp) + d := xdr.NewDecoderWithOptions(r, o) + _, err := s.DecodeFrom(d, o.MaxDepth) return err } @@ -9361,8 +9477,7 @@ var ( _ encoding.BinaryUnmarshaler = (*LedgerKeyOffer)(nil) ) -// xdrType signals that this type is an type representing -// representing XDR values defined by this package. +// xdrType signals that this type represents XDR values defined by this package. func (s LedgerKeyOffer) xdrType() {} var _ xdrType = (*LedgerKeyOffer)(nil) @@ -9425,8 +9540,10 @@ func (s LedgerKeyData) MarshalBinary() ([]byte, error) { // UnmarshalBinary implements encoding.BinaryUnmarshaler. func (s *LedgerKeyData) UnmarshalBinary(inp []byte) error { r := bytes.NewReader(inp) - d := xdr.NewDecoder(r) - _, err := s.DecodeFrom(d, xdr.DecodeDefaultMaxDepth) + o := xdr.DefaultDecodeOptions + o.MaxInputLen = len(inp) + d := xdr.NewDecoderWithOptions(r, o) + _, err := s.DecodeFrom(d, o.MaxDepth) return err } @@ -9435,8 +9552,7 @@ var ( _ encoding.BinaryUnmarshaler = (*LedgerKeyData)(nil) ) -// xdrType signals that this type is an type representing -// representing XDR values defined by this package. +// xdrType signals that this type represents XDR values defined by this package. func (s LedgerKeyData) xdrType() {} var _ xdrType = (*LedgerKeyData)(nil) @@ -9489,8 +9605,10 @@ func (s LedgerKeyClaimableBalance) MarshalBinary() ([]byte, error) { // UnmarshalBinary implements encoding.BinaryUnmarshaler. func (s *LedgerKeyClaimableBalance) UnmarshalBinary(inp []byte) error { r := bytes.NewReader(inp) - d := xdr.NewDecoder(r) - _, err := s.DecodeFrom(d, xdr.DecodeDefaultMaxDepth) + o := xdr.DefaultDecodeOptions + o.MaxInputLen = len(inp) + d := xdr.NewDecoderWithOptions(r, o) + _, err := s.DecodeFrom(d, o.MaxDepth) return err } @@ -9499,8 +9617,7 @@ var ( _ encoding.BinaryUnmarshaler = (*LedgerKeyClaimableBalance)(nil) ) -// xdrType signals that this type is an type representing -// representing XDR values defined by this package. +// xdrType signals that this type represents XDR values defined by this package. func (s LedgerKeyClaimableBalance) xdrType() {} var _ xdrType = (*LedgerKeyClaimableBalance)(nil) @@ -9553,8 +9670,10 @@ func (s LedgerKeyLiquidityPool) MarshalBinary() ([]byte, error) { // UnmarshalBinary implements encoding.BinaryUnmarshaler. func (s *LedgerKeyLiquidityPool) UnmarshalBinary(inp []byte) error { r := bytes.NewReader(inp) - d := xdr.NewDecoder(r) - _, err := s.DecodeFrom(d, xdr.DecodeDefaultMaxDepth) + o := xdr.DefaultDecodeOptions + o.MaxInputLen = len(inp) + d := xdr.NewDecoderWithOptions(r, o) + _, err := s.DecodeFrom(d, o.MaxDepth) return err } @@ -9563,8 +9682,7 @@ var ( _ encoding.BinaryUnmarshaler = (*LedgerKeyLiquidityPool)(nil) ) -// xdrType signals that this type is an type representing -// representing XDR values defined by this package. +// xdrType signals that this type represents XDR values defined by this package. func (s LedgerKeyLiquidityPool) xdrType() {} var _ xdrType = (*LedgerKeyLiquidityPool)(nil) @@ -9637,8 +9755,10 @@ func (s LedgerKeyContractData) MarshalBinary() ([]byte, error) { // UnmarshalBinary implements encoding.BinaryUnmarshaler. func (s *LedgerKeyContractData) UnmarshalBinary(inp []byte) error { r := bytes.NewReader(inp) - d := xdr.NewDecoder(r) - _, err := s.DecodeFrom(d, xdr.DecodeDefaultMaxDepth) + o := xdr.DefaultDecodeOptions + o.MaxInputLen = len(inp) + d := xdr.NewDecoderWithOptions(r, o) + _, err := s.DecodeFrom(d, o.MaxDepth) return err } @@ -9647,8 +9767,7 @@ var ( _ encoding.BinaryUnmarshaler = (*LedgerKeyContractData)(nil) ) -// xdrType signals that this type is an type representing -// representing XDR values defined by this package. +// xdrType signals that this type represents XDR values defined by this package. func (s LedgerKeyContractData) xdrType() {} var _ xdrType = (*LedgerKeyContractData)(nil) @@ -9701,8 +9820,10 @@ func (s LedgerKeyContractCode) MarshalBinary() ([]byte, error) { // UnmarshalBinary implements encoding.BinaryUnmarshaler. func (s *LedgerKeyContractCode) UnmarshalBinary(inp []byte) error { r := bytes.NewReader(inp) - d := xdr.NewDecoder(r) - _, err := s.DecodeFrom(d, xdr.DecodeDefaultMaxDepth) + o := xdr.DefaultDecodeOptions + o.MaxInputLen = len(inp) + d := xdr.NewDecoderWithOptions(r, o) + _, err := s.DecodeFrom(d, o.MaxDepth) return err } @@ -9711,8 +9832,7 @@ var ( _ encoding.BinaryUnmarshaler = (*LedgerKeyContractCode)(nil) ) -// xdrType signals that this type is an type representing -// representing XDR values defined by this package. +// xdrType signals that this type represents XDR values defined by this package. func (s LedgerKeyContractCode) xdrType() {} var _ xdrType = (*LedgerKeyContractCode)(nil) @@ -9765,8 +9885,10 @@ func (s LedgerKeyConfigSetting) MarshalBinary() ([]byte, error) { // UnmarshalBinary implements encoding.BinaryUnmarshaler. func (s *LedgerKeyConfigSetting) UnmarshalBinary(inp []byte) error { r := bytes.NewReader(inp) - d := xdr.NewDecoder(r) - _, err := s.DecodeFrom(d, xdr.DecodeDefaultMaxDepth) + o := xdr.DefaultDecodeOptions + o.MaxInputLen = len(inp) + d := xdr.NewDecoderWithOptions(r, o) + _, err := s.DecodeFrom(d, o.MaxDepth) return err } @@ -9775,8 +9897,7 @@ var ( _ encoding.BinaryUnmarshaler = (*LedgerKeyConfigSetting)(nil) ) -// xdrType signals that this type is an type representing -// representing XDR values defined by this package. +// xdrType signals that this type represents XDR values defined by this package. func (s LedgerKeyConfigSetting) xdrType() {} var _ xdrType = (*LedgerKeyConfigSetting)(nil) @@ -9830,8 +9951,10 @@ func (s LedgerKeyTtl) MarshalBinary() ([]byte, error) { // UnmarshalBinary implements encoding.BinaryUnmarshaler. func (s *LedgerKeyTtl) UnmarshalBinary(inp []byte) error { r := bytes.NewReader(inp) - d := xdr.NewDecoder(r) - _, err := s.DecodeFrom(d, xdr.DecodeDefaultMaxDepth) + o := xdr.DefaultDecodeOptions + o.MaxInputLen = len(inp) + d := xdr.NewDecoderWithOptions(r, o) + _, err := s.DecodeFrom(d, o.MaxDepth) return err } @@ -9840,8 +9963,7 @@ var ( _ encoding.BinaryUnmarshaler = (*LedgerKeyTtl)(nil) ) -// xdrType signals that this type is an type representing -// representing XDR values defined by this package. +// xdrType signals that this type represents XDR values defined by this package. func (s LedgerKeyTtl) xdrType() {} var _ xdrType = (*LedgerKeyTtl)(nil) @@ -10460,8 +10582,10 @@ func (s LedgerKey) MarshalBinary() ([]byte, error) { // UnmarshalBinary implements encoding.BinaryUnmarshaler. func (s *LedgerKey) UnmarshalBinary(inp []byte) error { r := bytes.NewReader(inp) - d := xdr.NewDecoder(r) - _, err := s.DecodeFrom(d, xdr.DecodeDefaultMaxDepth) + o := xdr.DefaultDecodeOptions + o.MaxInputLen = len(inp) + d := xdr.NewDecoderWithOptions(r, o) + _, err := s.DecodeFrom(d, o.MaxDepth) return err } @@ -10470,8 +10594,7 @@ var ( _ encoding.BinaryUnmarshaler = (*LedgerKey)(nil) ) -// xdrType signals that this type is an type representing -// representing XDR values defined by this package. +// xdrType signals that this type represents XDR values defined by this package. func (s LedgerKey) xdrType() {} var _ xdrType = (*LedgerKey)(nil) @@ -10571,8 +10694,10 @@ func (s EnvelopeType) MarshalBinary() ([]byte, error) { // UnmarshalBinary implements encoding.BinaryUnmarshaler. func (s *EnvelopeType) UnmarshalBinary(inp []byte) error { r := bytes.NewReader(inp) - d := xdr.NewDecoder(r) - _, err := s.DecodeFrom(d, xdr.DecodeDefaultMaxDepth) + o := xdr.DefaultDecodeOptions + o.MaxInputLen = len(inp) + d := xdr.NewDecoderWithOptions(r, o) + _, err := s.DecodeFrom(d, o.MaxDepth) return err } @@ -10581,8 +10706,7 @@ var ( _ encoding.BinaryUnmarshaler = (*EnvelopeType)(nil) ) -// xdrType signals that this type is an type representing -// representing XDR values defined by this package. +// xdrType signals that this type represents XDR values defined by this package. func (s EnvelopeType) xdrType() {} var _ xdrType = (*EnvelopeType)(nil) @@ -10635,8 +10759,10 @@ func (s UpgradeType) MarshalBinary() ([]byte, error) { // UnmarshalBinary implements encoding.BinaryUnmarshaler. func (s *UpgradeType) UnmarshalBinary(inp []byte) error { r := bytes.NewReader(inp) - d := xdr.NewDecoder(r) - _, err := s.DecodeFrom(d, xdr.DecodeDefaultMaxDepth) + o := xdr.DefaultDecodeOptions + o.MaxInputLen = len(inp) + d := xdr.NewDecoderWithOptions(r, o) + _, err := s.DecodeFrom(d, o.MaxDepth) return err } @@ -10645,8 +10771,7 @@ var ( _ encoding.BinaryUnmarshaler = (*UpgradeType)(nil) ) -// xdrType signals that this type is an type representing -// representing XDR values defined by this package. +// xdrType signals that this type represents XDR values defined by this package. func (s UpgradeType) xdrType() {} var _ xdrType = (*UpgradeType)(nil) @@ -10722,8 +10847,10 @@ func (s StellarValueType) MarshalBinary() ([]byte, error) { // UnmarshalBinary implements encoding.BinaryUnmarshaler. func (s *StellarValueType) UnmarshalBinary(inp []byte) error { r := bytes.NewReader(inp) - d := xdr.NewDecoder(r) - _, err := s.DecodeFrom(d, xdr.DecodeDefaultMaxDepth) + o := xdr.DefaultDecodeOptions + o.MaxInputLen = len(inp) + d := xdr.NewDecoderWithOptions(r, o) + _, err := s.DecodeFrom(d, o.MaxDepth) return err } @@ -10732,8 +10859,7 @@ var ( _ encoding.BinaryUnmarshaler = (*StellarValueType)(nil) ) -// xdrType signals that this type is an type representing -// representing XDR values defined by this package. +// xdrType signals that this type represents XDR values defined by this package. func (s StellarValueType) xdrType() {} var _ xdrType = (*StellarValueType)(nil) @@ -10796,8 +10922,10 @@ func (s LedgerCloseValueSignature) MarshalBinary() ([]byte, error) { // UnmarshalBinary implements encoding.BinaryUnmarshaler. func (s *LedgerCloseValueSignature) UnmarshalBinary(inp []byte) error { r := bytes.NewReader(inp) - d := xdr.NewDecoder(r) - _, err := s.DecodeFrom(d, xdr.DecodeDefaultMaxDepth) + o := xdr.DefaultDecodeOptions + o.MaxInputLen = len(inp) + d := xdr.NewDecoderWithOptions(r, o) + _, err := s.DecodeFrom(d, o.MaxDepth) return err } @@ -10806,8 +10934,7 @@ var ( _ encoding.BinaryUnmarshaler = (*LedgerCloseValueSignature)(nil) ) -// xdrType signals that this type is an type representing -// representing XDR values defined by this package. +// xdrType signals that this type represents XDR values defined by this package. func (s LedgerCloseValueSignature) xdrType() {} var _ xdrType = (*LedgerCloseValueSignature)(nil) @@ -10947,8 +11074,10 @@ func (s StellarValueExt) MarshalBinary() ([]byte, error) { // UnmarshalBinary implements encoding.BinaryUnmarshaler. func (s *StellarValueExt) UnmarshalBinary(inp []byte) error { r := bytes.NewReader(inp) - d := xdr.NewDecoder(r) - _, err := s.DecodeFrom(d, xdr.DecodeDefaultMaxDepth) + o := xdr.DefaultDecodeOptions + o.MaxInputLen = len(inp) + d := xdr.NewDecoderWithOptions(r, o) + _, err := s.DecodeFrom(d, o.MaxDepth) return err } @@ -10957,8 +11086,7 @@ var ( _ encoding.BinaryUnmarshaler = (*StellarValueExt)(nil) ) -// xdrType signals that this type is an type representing -// representing XDR values defined by this package. +// xdrType signals that this type represents XDR values defined by this package. func (s StellarValueExt) xdrType() {} var _ xdrType = (*StellarValueExt)(nil) @@ -11048,8 +11176,11 @@ func (s *StellarValue) DecodeFrom(d *xdr.Decoder, maxDepth uint) (int, error) { } s.Upgrades = nil if l > 0 { + if il, ok := d.InputLen(); ok && uint(il) < uint(l) { + return n, fmt.Errorf("decoding UpgradeType: length (%d) exceeds remaining input length (%d)", l, il) + } s.Upgrades = make([]UpgradeType, l) - for i := uint32(0); i < l; i++ { + for i := uint32(0); uint(i) < uint(l); i++ { nTmp, err = s.Upgrades[i].DecodeFrom(d, maxDepth) n += nTmp if err != nil { @@ -11076,8 +11207,10 @@ func (s StellarValue) MarshalBinary() ([]byte, error) { // UnmarshalBinary implements encoding.BinaryUnmarshaler. func (s *StellarValue) UnmarshalBinary(inp []byte) error { r := bytes.NewReader(inp) - d := xdr.NewDecoder(r) - _, err := s.DecodeFrom(d, xdr.DecodeDefaultMaxDepth) + o := xdr.DefaultDecodeOptions + o.MaxInputLen = len(inp) + d := xdr.NewDecoderWithOptions(r, o) + _, err := s.DecodeFrom(d, o.MaxDepth) return err } @@ -11086,8 +11219,7 @@ var ( _ encoding.BinaryUnmarshaler = (*StellarValue)(nil) ) -// xdrType signals that this type is an type representing -// representing XDR values defined by this package. +// xdrType signals that this type represents XDR values defined by this package. func (s StellarValue) xdrType() {} var _ xdrType = (*StellarValue)(nil) @@ -11171,8 +11303,10 @@ func (s LedgerHeaderFlags) MarshalBinary() ([]byte, error) { // UnmarshalBinary implements encoding.BinaryUnmarshaler. func (s *LedgerHeaderFlags) UnmarshalBinary(inp []byte) error { r := bytes.NewReader(inp) - d := xdr.NewDecoder(r) - _, err := s.DecodeFrom(d, xdr.DecodeDefaultMaxDepth) + o := xdr.DefaultDecodeOptions + o.MaxInputLen = len(inp) + d := xdr.NewDecoderWithOptions(r, o) + _, err := s.DecodeFrom(d, o.MaxDepth) return err } @@ -11181,8 +11315,7 @@ var ( _ encoding.BinaryUnmarshaler = (*LedgerHeaderFlags)(nil) ) -// xdrType signals that this type is an type representing -// representing XDR values defined by this package. +// xdrType signals that this type represents XDR values defined by this package. func (s LedgerHeaderFlags) xdrType() {} var _ xdrType = (*LedgerHeaderFlags)(nil) @@ -11272,8 +11405,10 @@ func (s LedgerHeaderExtensionV1Ext) MarshalBinary() ([]byte, error) { // UnmarshalBinary implements encoding.BinaryUnmarshaler. func (s *LedgerHeaderExtensionV1Ext) UnmarshalBinary(inp []byte) error { r := bytes.NewReader(inp) - d := xdr.NewDecoder(r) - _, err := s.DecodeFrom(d, xdr.DecodeDefaultMaxDepth) + o := xdr.DefaultDecodeOptions + o.MaxInputLen = len(inp) + d := xdr.NewDecoderWithOptions(r, o) + _, err := s.DecodeFrom(d, o.MaxDepth) return err } @@ -11282,8 +11417,7 @@ var ( _ encoding.BinaryUnmarshaler = (*LedgerHeaderExtensionV1Ext)(nil) ) -// xdrType signals that this type is an type representing -// representing XDR values defined by this package. +// xdrType signals that this type represents XDR values defined by this package. func (s LedgerHeaderExtensionV1Ext) xdrType() {} var _ xdrType = (*LedgerHeaderExtensionV1Ext)(nil) @@ -11352,8 +11486,10 @@ func (s LedgerHeaderExtensionV1) MarshalBinary() ([]byte, error) { // UnmarshalBinary implements encoding.BinaryUnmarshaler. func (s *LedgerHeaderExtensionV1) UnmarshalBinary(inp []byte) error { r := bytes.NewReader(inp) - d := xdr.NewDecoder(r) - _, err := s.DecodeFrom(d, xdr.DecodeDefaultMaxDepth) + o := xdr.DefaultDecodeOptions + o.MaxInputLen = len(inp) + d := xdr.NewDecoderWithOptions(r, o) + _, err := s.DecodeFrom(d, o.MaxDepth) return err } @@ -11362,8 +11498,7 @@ var ( _ encoding.BinaryUnmarshaler = (*LedgerHeaderExtensionV1)(nil) ) -// xdrType signals that this type is an type representing -// representing XDR values defined by this package. +// xdrType signals that this type represents XDR values defined by this package. func (s LedgerHeaderExtensionV1) xdrType() {} var _ xdrType = (*LedgerHeaderExtensionV1)(nil) @@ -11503,8 +11638,10 @@ func (s LedgerHeaderExt) MarshalBinary() ([]byte, error) { // UnmarshalBinary implements encoding.BinaryUnmarshaler. func (s *LedgerHeaderExt) UnmarshalBinary(inp []byte) error { r := bytes.NewReader(inp) - d := xdr.NewDecoder(r) - _, err := s.DecodeFrom(d, xdr.DecodeDefaultMaxDepth) + o := xdr.DefaultDecodeOptions + o.MaxInputLen = len(inp) + d := xdr.NewDecoderWithOptions(r, o) + _, err := s.DecodeFrom(d, o.MaxDepth) return err } @@ -11513,8 +11650,7 @@ var ( _ encoding.BinaryUnmarshaler = (*LedgerHeaderExt)(nil) ) -// xdrType signals that this type is an type representing -// representing XDR values defined by this package. +// xdrType signals that this type represents XDR values defined by this package. func (s LedgerHeaderExt) xdrType() {} var _ xdrType = (*LedgerHeaderExt)(nil) @@ -11732,8 +11868,10 @@ func (s LedgerHeader) MarshalBinary() ([]byte, error) { // UnmarshalBinary implements encoding.BinaryUnmarshaler. func (s *LedgerHeader) UnmarshalBinary(inp []byte) error { r := bytes.NewReader(inp) - d := xdr.NewDecoder(r) - _, err := s.DecodeFrom(d, xdr.DecodeDefaultMaxDepth) + o := xdr.DefaultDecodeOptions + o.MaxInputLen = len(inp) + d := xdr.NewDecoderWithOptions(r, o) + _, err := s.DecodeFrom(d, o.MaxDepth) return err } @@ -11742,8 +11880,7 @@ var ( _ encoding.BinaryUnmarshaler = (*LedgerHeader)(nil) ) -// xdrType signals that this type is an type representing -// representing XDR values defined by this package. +// xdrType signals that this type represents XDR values defined by this package. func (s LedgerHeader) xdrType() {} var _ xdrType = (*LedgerHeader)(nil) @@ -11834,8 +11971,10 @@ func (s LedgerUpgradeType) MarshalBinary() ([]byte, error) { // UnmarshalBinary implements encoding.BinaryUnmarshaler. func (s *LedgerUpgradeType) UnmarshalBinary(inp []byte) error { r := bytes.NewReader(inp) - d := xdr.NewDecoder(r) - _, err := s.DecodeFrom(d, xdr.DecodeDefaultMaxDepth) + o := xdr.DefaultDecodeOptions + o.MaxInputLen = len(inp) + d := xdr.NewDecoderWithOptions(r, o) + _, err := s.DecodeFrom(d, o.MaxDepth) return err } @@ -11844,8 +11983,7 @@ var ( _ encoding.BinaryUnmarshaler = (*LedgerUpgradeType)(nil) ) -// xdrType signals that this type is an type representing -// representing XDR values defined by this package. +// xdrType signals that this type represents XDR values defined by this package. func (s LedgerUpgradeType) xdrType() {} var _ xdrType = (*LedgerUpgradeType)(nil) @@ -11907,8 +12045,10 @@ func (s ConfigUpgradeSetKey) MarshalBinary() ([]byte, error) { // UnmarshalBinary implements encoding.BinaryUnmarshaler. func (s *ConfigUpgradeSetKey) UnmarshalBinary(inp []byte) error { r := bytes.NewReader(inp) - d := xdr.NewDecoder(r) - _, err := s.DecodeFrom(d, xdr.DecodeDefaultMaxDepth) + o := xdr.DefaultDecodeOptions + o.MaxInputLen = len(inp) + d := xdr.NewDecoderWithOptions(r, o) + _, err := s.DecodeFrom(d, o.MaxDepth) return err } @@ -11917,8 +12057,7 @@ var ( _ encoding.BinaryUnmarshaler = (*ConfigUpgradeSetKey)(nil) ) -// xdrType signals that this type is an type representing -// representing XDR values defined by this package. +// xdrType signals that this type represents XDR values defined by this package. func (s ConfigUpgradeSetKey) xdrType() {} var _ xdrType = (*ConfigUpgradeSetKey)(nil) @@ -12349,8 +12488,10 @@ func (s LedgerUpgrade) MarshalBinary() ([]byte, error) { // UnmarshalBinary implements encoding.BinaryUnmarshaler. func (s *LedgerUpgrade) UnmarshalBinary(inp []byte) error { r := bytes.NewReader(inp) - d := xdr.NewDecoder(r) - _, err := s.DecodeFrom(d, xdr.DecodeDefaultMaxDepth) + o := xdr.DefaultDecodeOptions + o.MaxInputLen = len(inp) + d := xdr.NewDecoderWithOptions(r, o) + _, err := s.DecodeFrom(d, o.MaxDepth) return err } @@ -12359,8 +12500,7 @@ var ( _ encoding.BinaryUnmarshaler = (*LedgerUpgrade)(nil) ) -// xdrType signals that this type is an type representing -// representing XDR values defined by this package. +// xdrType signals that this type represents XDR values defined by this package. func (s LedgerUpgrade) xdrType() {} var _ xdrType = (*LedgerUpgrade)(nil) @@ -12406,8 +12546,11 @@ func (s *ConfigUpgradeSet) DecodeFrom(d *xdr.Decoder, maxDepth uint) (int, error } s.UpdatedEntry = nil if l > 0 { + if il, ok := d.InputLen(); ok && uint(il) < uint(l) { + return n, fmt.Errorf("decoding ConfigSettingEntry: length (%d) exceeds remaining input length (%d)", l, il) + } s.UpdatedEntry = make([]ConfigSettingEntry, l) - for i := uint32(0); i < l; i++ { + for i := uint32(0); uint(i) < uint(l); i++ { nTmp, err = s.UpdatedEntry[i].DecodeFrom(d, maxDepth) n += nTmp if err != nil { @@ -12429,8 +12572,10 @@ func (s ConfigUpgradeSet) MarshalBinary() ([]byte, error) { // UnmarshalBinary implements encoding.BinaryUnmarshaler. func (s *ConfigUpgradeSet) UnmarshalBinary(inp []byte) error { r := bytes.NewReader(inp) - d := xdr.NewDecoder(r) - _, err := s.DecodeFrom(d, xdr.DecodeDefaultMaxDepth) + o := xdr.DefaultDecodeOptions + o.MaxInputLen = len(inp) + d := xdr.NewDecoderWithOptions(r, o) + _, err := s.DecodeFrom(d, o.MaxDepth) return err } @@ -12439,8 +12584,7 @@ var ( _ encoding.BinaryUnmarshaler = (*ConfigUpgradeSet)(nil) ) -// xdrType signals that this type is an type representing -// representing XDR values defined by this package. +// xdrType signals that this type represents XDR values defined by this package. func (s ConfigUpgradeSet) xdrType() {} var _ xdrType = (*ConfigUpgradeSet)(nil) @@ -12524,8 +12668,10 @@ func (s BucketEntryType) MarshalBinary() ([]byte, error) { // UnmarshalBinary implements encoding.BinaryUnmarshaler. func (s *BucketEntryType) UnmarshalBinary(inp []byte) error { r := bytes.NewReader(inp) - d := xdr.NewDecoder(r) - _, err := s.DecodeFrom(d, xdr.DecodeDefaultMaxDepth) + o := xdr.DefaultDecodeOptions + o.MaxInputLen = len(inp) + d := xdr.NewDecoderWithOptions(r, o) + _, err := s.DecodeFrom(d, o.MaxDepth) return err } @@ -12534,8 +12680,7 @@ var ( _ encoding.BinaryUnmarshaler = (*BucketEntryType)(nil) ) -// xdrType signals that this type is an type representing -// representing XDR values defined by this package. +// xdrType signals that this type represents XDR values defined by this package. func (s BucketEntryType) xdrType() {} var _ xdrType = (*BucketEntryType)(nil) @@ -12625,8 +12770,10 @@ func (s BucketMetadataExt) MarshalBinary() ([]byte, error) { // UnmarshalBinary implements encoding.BinaryUnmarshaler. func (s *BucketMetadataExt) UnmarshalBinary(inp []byte) error { r := bytes.NewReader(inp) - d := xdr.NewDecoder(r) - _, err := s.DecodeFrom(d, xdr.DecodeDefaultMaxDepth) + o := xdr.DefaultDecodeOptions + o.MaxInputLen = len(inp) + d := xdr.NewDecoderWithOptions(r, o) + _, err := s.DecodeFrom(d, o.MaxDepth) return err } @@ -12635,8 +12782,7 @@ var ( _ encoding.BinaryUnmarshaler = (*BucketMetadataExt)(nil) ) -// xdrType signals that this type is an type representing -// representing XDR values defined by this package. +// xdrType signals that this type represents XDR values defined by this package. func (s BucketMetadataExt) xdrType() {} var _ xdrType = (*BucketMetadataExt)(nil) @@ -12707,8 +12853,10 @@ func (s BucketMetadata) MarshalBinary() ([]byte, error) { // UnmarshalBinary implements encoding.BinaryUnmarshaler. func (s *BucketMetadata) UnmarshalBinary(inp []byte) error { r := bytes.NewReader(inp) - d := xdr.NewDecoder(r) - _, err := s.DecodeFrom(d, xdr.DecodeDefaultMaxDepth) + o := xdr.DefaultDecodeOptions + o.MaxInputLen = len(inp) + d := xdr.NewDecoderWithOptions(r, o) + _, err := s.DecodeFrom(d, o.MaxDepth) return err } @@ -12717,8 +12865,7 @@ var ( _ encoding.BinaryUnmarshaler = (*BucketMetadata)(nil) ) -// xdrType signals that this type is an type representing -// representing XDR values defined by this package. +// xdrType signals that this type represents XDR values defined by this package. func (s BucketMetadata) xdrType() {} var _ xdrType = (*BucketMetadata)(nil) @@ -12970,8 +13117,10 @@ func (s BucketEntry) MarshalBinary() ([]byte, error) { // UnmarshalBinary implements encoding.BinaryUnmarshaler. func (s *BucketEntry) UnmarshalBinary(inp []byte) error { r := bytes.NewReader(inp) - d := xdr.NewDecoder(r) - _, err := s.DecodeFrom(d, xdr.DecodeDefaultMaxDepth) + o := xdr.DefaultDecodeOptions + o.MaxInputLen = len(inp) + d := xdr.NewDecoderWithOptions(r, o) + _, err := s.DecodeFrom(d, o.MaxDepth) return err } @@ -12980,8 +13129,7 @@ var ( _ encoding.BinaryUnmarshaler = (*BucketEntry)(nil) ) -// xdrType signals that this type is an type representing -// representing XDR values defined by this package. +// xdrType signals that this type represents XDR values defined by this package. func (s BucketEntry) xdrType() {} var _ xdrType = (*BucketEntry)(nil) @@ -13056,8 +13204,10 @@ func (s TxSetComponentType) MarshalBinary() ([]byte, error) { // UnmarshalBinary implements encoding.BinaryUnmarshaler. func (s *TxSetComponentType) UnmarshalBinary(inp []byte) error { r := bytes.NewReader(inp) - d := xdr.NewDecoder(r) - _, err := s.DecodeFrom(d, xdr.DecodeDefaultMaxDepth) + o := xdr.DefaultDecodeOptions + o.MaxInputLen = len(inp) + d := xdr.NewDecoderWithOptions(r, o) + _, err := s.DecodeFrom(d, o.MaxDepth) return err } @@ -13066,8 +13216,7 @@ var ( _ encoding.BinaryUnmarshaler = (*TxSetComponentType)(nil) ) -// xdrType signals that this type is an type representing -// representing XDR values defined by this package. +// xdrType signals that this type represents XDR values defined by this package. func (s TxSetComponentType) xdrType() {} var _ xdrType = (*TxSetComponentType)(nil) @@ -13139,8 +13288,11 @@ func (s *TxSetComponentTxsMaybeDiscountedFee) DecodeFrom(d *xdr.Decoder, maxDept } s.Txs = nil if l > 0 { + if il, ok := d.InputLen(); ok && uint(il) < uint(l) { + return n, fmt.Errorf("decoding TransactionEnvelope: length (%d) exceeds remaining input length (%d)", l, il) + } s.Txs = make([]TransactionEnvelope, l) - for i := uint32(0); i < l; i++ { + for i := uint32(0); uint(i) < uint(l); i++ { nTmp, err = s.Txs[i].DecodeFrom(d, maxDepth) n += nTmp if err != nil { @@ -13162,8 +13314,10 @@ func (s TxSetComponentTxsMaybeDiscountedFee) MarshalBinary() ([]byte, error) { // UnmarshalBinary implements encoding.BinaryUnmarshaler. func (s *TxSetComponentTxsMaybeDiscountedFee) UnmarshalBinary(inp []byte) error { r := bytes.NewReader(inp) - d := xdr.NewDecoder(r) - _, err := s.DecodeFrom(d, xdr.DecodeDefaultMaxDepth) + o := xdr.DefaultDecodeOptions + o.MaxInputLen = len(inp) + d := xdr.NewDecoderWithOptions(r, o) + _, err := s.DecodeFrom(d, o.MaxDepth) return err } @@ -13172,8 +13326,7 @@ var ( _ encoding.BinaryUnmarshaler = (*TxSetComponentTxsMaybeDiscountedFee)(nil) ) -// xdrType signals that this type is an type representing -// representing XDR values defined by this package. +// xdrType signals that this type represents XDR values defined by this package. func (s TxSetComponentTxsMaybeDiscountedFee) xdrType() {} var _ xdrType = (*TxSetComponentTxsMaybeDiscountedFee)(nil) @@ -13305,8 +13458,10 @@ func (s TxSetComponent) MarshalBinary() ([]byte, error) { // UnmarshalBinary implements encoding.BinaryUnmarshaler. func (s *TxSetComponent) UnmarshalBinary(inp []byte) error { r := bytes.NewReader(inp) - d := xdr.NewDecoder(r) - _, err := s.DecodeFrom(d, xdr.DecodeDefaultMaxDepth) + o := xdr.DefaultDecodeOptions + o.MaxInputLen = len(inp) + d := xdr.NewDecoderWithOptions(r, o) + _, err := s.DecodeFrom(d, o.MaxDepth) return err } @@ -13315,8 +13470,7 @@ var ( _ encoding.BinaryUnmarshaler = (*TxSetComponent)(nil) ) -// xdrType signals that this type is an type representing -// representing XDR values defined by this package. +// xdrType signals that this type represents XDR values defined by this package. func (s TxSetComponent) xdrType() {} var _ xdrType = (*TxSetComponent)(nil) @@ -13436,8 +13590,11 @@ func (u *TransactionPhase) DecodeFrom(d *xdr.Decoder, maxDepth uint) (int, error } (*u.V0Components) = nil if l > 0 { + if il, ok := d.InputLen(); ok && uint(il) < uint(l) { + return n, fmt.Errorf("decoding TxSetComponent: length (%d) exceeds remaining input length (%d)", l, il) + } (*u.V0Components) = make([]TxSetComponent, l) - for i := uint32(0); i < l; i++ { + for i := uint32(0); uint(i) < uint(l); i++ { nTmp, err = (*u.V0Components)[i].DecodeFrom(d, maxDepth) n += nTmp if err != nil { @@ -13461,8 +13618,10 @@ func (s TransactionPhase) MarshalBinary() ([]byte, error) { // UnmarshalBinary implements encoding.BinaryUnmarshaler. func (s *TransactionPhase) UnmarshalBinary(inp []byte) error { r := bytes.NewReader(inp) - d := xdr.NewDecoder(r) - _, err := s.DecodeFrom(d, xdr.DecodeDefaultMaxDepth) + o := xdr.DefaultDecodeOptions + o.MaxInputLen = len(inp) + d := xdr.NewDecoderWithOptions(r, o) + _, err := s.DecodeFrom(d, o.MaxDepth) return err } @@ -13471,8 +13630,7 @@ var ( _ encoding.BinaryUnmarshaler = (*TransactionPhase)(nil) ) -// xdrType signals that this type is an type representing -// representing XDR values defined by this package. +// xdrType signals that this type represents XDR values defined by this package. func (s TransactionPhase) xdrType() {} var _ xdrType = (*TransactionPhase)(nil) @@ -13529,8 +13687,11 @@ func (s *TransactionSet) DecodeFrom(d *xdr.Decoder, maxDepth uint) (int, error) } s.Txs = nil if l > 0 { + if il, ok := d.InputLen(); ok && uint(il) < uint(l) { + return n, fmt.Errorf("decoding TransactionEnvelope: length (%d) exceeds remaining input length (%d)", l, il) + } s.Txs = make([]TransactionEnvelope, l) - for i := uint32(0); i < l; i++ { + for i := uint32(0); uint(i) < uint(l); i++ { nTmp, err = s.Txs[i].DecodeFrom(d, maxDepth) n += nTmp if err != nil { @@ -13552,8 +13713,10 @@ func (s TransactionSet) MarshalBinary() ([]byte, error) { // UnmarshalBinary implements encoding.BinaryUnmarshaler. func (s *TransactionSet) UnmarshalBinary(inp []byte) error { r := bytes.NewReader(inp) - d := xdr.NewDecoder(r) - _, err := s.DecodeFrom(d, xdr.DecodeDefaultMaxDepth) + o := xdr.DefaultDecodeOptions + o.MaxInputLen = len(inp) + d := xdr.NewDecoderWithOptions(r, o) + _, err := s.DecodeFrom(d, o.MaxDepth) return err } @@ -13562,8 +13725,7 @@ var ( _ encoding.BinaryUnmarshaler = (*TransactionSet)(nil) ) -// xdrType signals that this type is an type representing -// representing XDR values defined by this package. +// xdrType signals that this type represents XDR values defined by this package. func (s TransactionSet) xdrType() {} var _ xdrType = (*TransactionSet)(nil) @@ -13620,8 +13782,11 @@ func (s *TransactionSetV1) DecodeFrom(d *xdr.Decoder, maxDepth uint) (int, error } s.Phases = nil if l > 0 { + if il, ok := d.InputLen(); ok && uint(il) < uint(l) { + return n, fmt.Errorf("decoding TransactionPhase: length (%d) exceeds remaining input length (%d)", l, il) + } s.Phases = make([]TransactionPhase, l) - for i := uint32(0); i < l; i++ { + for i := uint32(0); uint(i) < uint(l); i++ { nTmp, err = s.Phases[i].DecodeFrom(d, maxDepth) n += nTmp if err != nil { @@ -13643,8 +13808,10 @@ func (s TransactionSetV1) MarshalBinary() ([]byte, error) { // UnmarshalBinary implements encoding.BinaryUnmarshaler. func (s *TransactionSetV1) UnmarshalBinary(inp []byte) error { r := bytes.NewReader(inp) - d := xdr.NewDecoder(r) - _, err := s.DecodeFrom(d, xdr.DecodeDefaultMaxDepth) + o := xdr.DefaultDecodeOptions + o.MaxInputLen = len(inp) + d := xdr.NewDecoderWithOptions(r, o) + _, err := s.DecodeFrom(d, o.MaxDepth) return err } @@ -13653,8 +13820,7 @@ var ( _ encoding.BinaryUnmarshaler = (*TransactionSetV1)(nil) ) -// xdrType signals that this type is an type representing -// representing XDR values defined by this package. +// xdrType signals that this type represents XDR values defined by this package. func (s TransactionSetV1) xdrType() {} var _ xdrType = (*TransactionSetV1)(nil) @@ -13783,8 +13949,10 @@ func (s GeneralizedTransactionSet) MarshalBinary() ([]byte, error) { // UnmarshalBinary implements encoding.BinaryUnmarshaler. func (s *GeneralizedTransactionSet) UnmarshalBinary(inp []byte) error { r := bytes.NewReader(inp) - d := xdr.NewDecoder(r) - _, err := s.DecodeFrom(d, xdr.DecodeDefaultMaxDepth) + o := xdr.DefaultDecodeOptions + o.MaxInputLen = len(inp) + d := xdr.NewDecoderWithOptions(r, o) + _, err := s.DecodeFrom(d, o.MaxDepth) return err } @@ -13793,8 +13961,7 @@ var ( _ encoding.BinaryUnmarshaler = (*GeneralizedTransactionSet)(nil) ) -// xdrType signals that this type is an type representing -// representing XDR values defined by this package. +// xdrType signals that this type represents XDR values defined by this package. func (s GeneralizedTransactionSet) xdrType() {} var _ xdrType = (*GeneralizedTransactionSet)(nil) @@ -13857,8 +14024,10 @@ func (s TransactionResultPair) MarshalBinary() ([]byte, error) { // UnmarshalBinary implements encoding.BinaryUnmarshaler. func (s *TransactionResultPair) UnmarshalBinary(inp []byte) error { r := bytes.NewReader(inp) - d := xdr.NewDecoder(r) - _, err := s.DecodeFrom(d, xdr.DecodeDefaultMaxDepth) + o := xdr.DefaultDecodeOptions + o.MaxInputLen = len(inp) + d := xdr.NewDecoderWithOptions(r, o) + _, err := s.DecodeFrom(d, o.MaxDepth) return err } @@ -13867,8 +14036,7 @@ var ( _ encoding.BinaryUnmarshaler = (*TransactionResultPair)(nil) ) -// xdrType signals that this type is an type representing -// representing XDR values defined by this package. +// xdrType signals that this type represents XDR values defined by this package. func (s TransactionResultPair) xdrType() {} var _ xdrType = (*TransactionResultPair)(nil) @@ -13915,8 +14083,11 @@ func (s *TransactionResultSet) DecodeFrom(d *xdr.Decoder, maxDepth uint) (int, e } s.Results = nil if l > 0 { + if il, ok := d.InputLen(); ok && uint(il) < uint(l) { + return n, fmt.Errorf("decoding TransactionResultPair: length (%d) exceeds remaining input length (%d)", l, il) + } s.Results = make([]TransactionResultPair, l) - for i := uint32(0); i < l; i++ { + for i := uint32(0); uint(i) < uint(l); i++ { nTmp, err = s.Results[i].DecodeFrom(d, maxDepth) n += nTmp if err != nil { @@ -13938,8 +14109,10 @@ func (s TransactionResultSet) MarshalBinary() ([]byte, error) { // UnmarshalBinary implements encoding.BinaryUnmarshaler. func (s *TransactionResultSet) UnmarshalBinary(inp []byte) error { r := bytes.NewReader(inp) - d := xdr.NewDecoder(r) - _, err := s.DecodeFrom(d, xdr.DecodeDefaultMaxDepth) + o := xdr.DefaultDecodeOptions + o.MaxInputLen = len(inp) + d := xdr.NewDecoderWithOptions(r, o) + _, err := s.DecodeFrom(d, o.MaxDepth) return err } @@ -13948,8 +14121,7 @@ var ( _ encoding.BinaryUnmarshaler = (*TransactionResultSet)(nil) ) -// xdrType signals that this type is an type representing -// representing XDR values defined by this package. +// xdrType signals that this type represents XDR values defined by this package. func (s TransactionResultSet) xdrType() {} var _ xdrType = (*TransactionResultSet)(nil) @@ -14089,8 +14261,10 @@ func (s TransactionHistoryEntryExt) MarshalBinary() ([]byte, error) { // UnmarshalBinary implements encoding.BinaryUnmarshaler. func (s *TransactionHistoryEntryExt) UnmarshalBinary(inp []byte) error { r := bytes.NewReader(inp) - d := xdr.NewDecoder(r) - _, err := s.DecodeFrom(d, xdr.DecodeDefaultMaxDepth) + o := xdr.DefaultDecodeOptions + o.MaxInputLen = len(inp) + d := xdr.NewDecoderWithOptions(r, o) + _, err := s.DecodeFrom(d, o.MaxDepth) return err } @@ -14099,8 +14273,7 @@ var ( _ encoding.BinaryUnmarshaler = (*TransactionHistoryEntryExt)(nil) ) -// xdrType signals that this type is an type representing -// representing XDR values defined by this package. +// xdrType signals that this type represents XDR values defined by this package. func (s TransactionHistoryEntryExt) xdrType() {} var _ xdrType = (*TransactionHistoryEntryExt)(nil) @@ -14182,8 +14355,10 @@ func (s TransactionHistoryEntry) MarshalBinary() ([]byte, error) { // UnmarshalBinary implements encoding.BinaryUnmarshaler. func (s *TransactionHistoryEntry) UnmarshalBinary(inp []byte) error { r := bytes.NewReader(inp) - d := xdr.NewDecoder(r) - _, err := s.DecodeFrom(d, xdr.DecodeDefaultMaxDepth) + o := xdr.DefaultDecodeOptions + o.MaxInputLen = len(inp) + d := xdr.NewDecoderWithOptions(r, o) + _, err := s.DecodeFrom(d, o.MaxDepth) return err } @@ -14192,8 +14367,7 @@ var ( _ encoding.BinaryUnmarshaler = (*TransactionHistoryEntry)(nil) ) -// xdrType signals that this type is an type representing -// representing XDR values defined by this package. +// xdrType signals that this type represents XDR values defined by this package. func (s TransactionHistoryEntry) xdrType() {} var _ xdrType = (*TransactionHistoryEntry)(nil) @@ -14283,8 +14457,10 @@ func (s TransactionHistoryResultEntryExt) MarshalBinary() ([]byte, error) { // UnmarshalBinary implements encoding.BinaryUnmarshaler. func (s *TransactionHistoryResultEntryExt) UnmarshalBinary(inp []byte) error { r := bytes.NewReader(inp) - d := xdr.NewDecoder(r) - _, err := s.DecodeFrom(d, xdr.DecodeDefaultMaxDepth) + o := xdr.DefaultDecodeOptions + o.MaxInputLen = len(inp) + d := xdr.NewDecoderWithOptions(r, o) + _, err := s.DecodeFrom(d, o.MaxDepth) return err } @@ -14293,8 +14469,7 @@ var ( _ encoding.BinaryUnmarshaler = (*TransactionHistoryResultEntryExt)(nil) ) -// xdrType signals that this type is an type representing -// representing XDR values defined by this package. +// xdrType signals that this type represents XDR values defined by this package. func (s TransactionHistoryResultEntryExt) xdrType() {} var _ xdrType = (*TransactionHistoryResultEntryExt)(nil) @@ -14374,8 +14549,10 @@ func (s TransactionHistoryResultEntry) MarshalBinary() ([]byte, error) { // UnmarshalBinary implements encoding.BinaryUnmarshaler. func (s *TransactionHistoryResultEntry) UnmarshalBinary(inp []byte) error { r := bytes.NewReader(inp) - d := xdr.NewDecoder(r) - _, err := s.DecodeFrom(d, xdr.DecodeDefaultMaxDepth) + o := xdr.DefaultDecodeOptions + o.MaxInputLen = len(inp) + d := xdr.NewDecoderWithOptions(r, o) + _, err := s.DecodeFrom(d, o.MaxDepth) return err } @@ -14384,8 +14561,7 @@ var ( _ encoding.BinaryUnmarshaler = (*TransactionHistoryResultEntry)(nil) ) -// xdrType signals that this type is an type representing -// representing XDR values defined by this package. +// xdrType signals that this type represents XDR values defined by this package. func (s TransactionHistoryResultEntry) xdrType() {} var _ xdrType = (*TransactionHistoryResultEntry)(nil) @@ -14475,8 +14651,10 @@ func (s LedgerHeaderHistoryEntryExt) MarshalBinary() ([]byte, error) { // UnmarshalBinary implements encoding.BinaryUnmarshaler. func (s *LedgerHeaderHistoryEntryExt) UnmarshalBinary(inp []byte) error { r := bytes.NewReader(inp) - d := xdr.NewDecoder(r) - _, err := s.DecodeFrom(d, xdr.DecodeDefaultMaxDepth) + o := xdr.DefaultDecodeOptions + o.MaxInputLen = len(inp) + d := xdr.NewDecoderWithOptions(r, o) + _, err := s.DecodeFrom(d, o.MaxDepth) return err } @@ -14485,8 +14663,7 @@ var ( _ encoding.BinaryUnmarshaler = (*LedgerHeaderHistoryEntryExt)(nil) ) -// xdrType signals that this type is an type representing -// representing XDR values defined by this package. +// xdrType signals that this type represents XDR values defined by this package. func (s LedgerHeaderHistoryEntryExt) xdrType() {} var _ xdrType = (*LedgerHeaderHistoryEntryExt)(nil) @@ -14566,8 +14743,10 @@ func (s LedgerHeaderHistoryEntry) MarshalBinary() ([]byte, error) { // UnmarshalBinary implements encoding.BinaryUnmarshaler. func (s *LedgerHeaderHistoryEntry) UnmarshalBinary(inp []byte) error { r := bytes.NewReader(inp) - d := xdr.NewDecoder(r) - _, err := s.DecodeFrom(d, xdr.DecodeDefaultMaxDepth) + o := xdr.DefaultDecodeOptions + o.MaxInputLen = len(inp) + d := xdr.NewDecoderWithOptions(r, o) + _, err := s.DecodeFrom(d, o.MaxDepth) return err } @@ -14576,8 +14755,7 @@ var ( _ encoding.BinaryUnmarshaler = (*LedgerHeaderHistoryEntry)(nil) ) -// xdrType signals that this type is an type representing -// representing XDR values defined by this package. +// xdrType signals that this type represents XDR values defined by this package. func (s LedgerHeaderHistoryEntry) xdrType() {} var _ xdrType = (*LedgerHeaderHistoryEntry)(nil) @@ -14634,8 +14812,11 @@ func (s *LedgerScpMessages) DecodeFrom(d *xdr.Decoder, maxDepth uint) (int, erro } s.Messages = nil if l > 0 { + if il, ok := d.InputLen(); ok && uint(il) < uint(l) { + return n, fmt.Errorf("decoding ScpEnvelope: length (%d) exceeds remaining input length (%d)", l, il) + } s.Messages = make([]ScpEnvelope, l) - for i := uint32(0); i < l; i++ { + for i := uint32(0); uint(i) < uint(l); i++ { nTmp, err = s.Messages[i].DecodeFrom(d, maxDepth) n += nTmp if err != nil { @@ -14657,8 +14838,10 @@ func (s LedgerScpMessages) MarshalBinary() ([]byte, error) { // UnmarshalBinary implements encoding.BinaryUnmarshaler. func (s *LedgerScpMessages) UnmarshalBinary(inp []byte) error { r := bytes.NewReader(inp) - d := xdr.NewDecoder(r) - _, err := s.DecodeFrom(d, xdr.DecodeDefaultMaxDepth) + o := xdr.DefaultDecodeOptions + o.MaxInputLen = len(inp) + d := xdr.NewDecoderWithOptions(r, o) + _, err := s.DecodeFrom(d, o.MaxDepth) return err } @@ -14667,8 +14850,7 @@ var ( _ encoding.BinaryUnmarshaler = (*LedgerScpMessages)(nil) ) -// xdrType signals that this type is an type representing -// representing XDR values defined by this package. +// xdrType signals that this type represents XDR values defined by this package. func (s LedgerScpMessages) xdrType() {} var _ xdrType = (*LedgerScpMessages)(nil) @@ -14720,8 +14902,11 @@ func (s *ScpHistoryEntryV0) DecodeFrom(d *xdr.Decoder, maxDepth uint) (int, erro } s.QuorumSets = nil if l > 0 { + if il, ok := d.InputLen(); ok && uint(il) < uint(l) { + return n, fmt.Errorf("decoding ScpQuorumSet: length (%d) exceeds remaining input length (%d)", l, il) + } s.QuorumSets = make([]ScpQuorumSet, l) - for i := uint32(0); i < l; i++ { + for i := uint32(0); uint(i) < uint(l); i++ { nTmp, err = s.QuorumSets[i].DecodeFrom(d, maxDepth) n += nTmp if err != nil { @@ -14748,8 +14933,10 @@ func (s ScpHistoryEntryV0) MarshalBinary() ([]byte, error) { // UnmarshalBinary implements encoding.BinaryUnmarshaler. func (s *ScpHistoryEntryV0) UnmarshalBinary(inp []byte) error { r := bytes.NewReader(inp) - d := xdr.NewDecoder(r) - _, err := s.DecodeFrom(d, xdr.DecodeDefaultMaxDepth) + o := xdr.DefaultDecodeOptions + o.MaxInputLen = len(inp) + d := xdr.NewDecoderWithOptions(r, o) + _, err := s.DecodeFrom(d, o.MaxDepth) return err } @@ -14758,8 +14945,7 @@ var ( _ encoding.BinaryUnmarshaler = (*ScpHistoryEntryV0)(nil) ) -// xdrType signals that this type is an type representing -// representing XDR values defined by this package. +// xdrType signals that this type represents XDR values defined by this package. func (s ScpHistoryEntryV0) xdrType() {} var _ xdrType = (*ScpHistoryEntryV0)(nil) @@ -14887,8 +15073,10 @@ func (s ScpHistoryEntry) MarshalBinary() ([]byte, error) { // UnmarshalBinary implements encoding.BinaryUnmarshaler. func (s *ScpHistoryEntry) UnmarshalBinary(inp []byte) error { r := bytes.NewReader(inp) - d := xdr.NewDecoder(r) - _, err := s.DecodeFrom(d, xdr.DecodeDefaultMaxDepth) + o := xdr.DefaultDecodeOptions + o.MaxInputLen = len(inp) + d := xdr.NewDecoderWithOptions(r, o) + _, err := s.DecodeFrom(d, o.MaxDepth) return err } @@ -14897,8 +15085,7 @@ var ( _ encoding.BinaryUnmarshaler = (*ScpHistoryEntry)(nil) ) -// xdrType signals that this type is an type representing -// representing XDR values defined by this package. +// xdrType signals that this type represents XDR values defined by this package. func (s ScpHistoryEntry) xdrType() {} var _ xdrType = (*ScpHistoryEntry)(nil) @@ -14980,8 +15167,10 @@ func (s LedgerEntryChangeType) MarshalBinary() ([]byte, error) { // UnmarshalBinary implements encoding.BinaryUnmarshaler. func (s *LedgerEntryChangeType) UnmarshalBinary(inp []byte) error { r := bytes.NewReader(inp) - d := xdr.NewDecoder(r) - _, err := s.DecodeFrom(d, xdr.DecodeDefaultMaxDepth) + o := xdr.DefaultDecodeOptions + o.MaxInputLen = len(inp) + d := xdr.NewDecoderWithOptions(r, o) + _, err := s.DecodeFrom(d, o.MaxDepth) return err } @@ -14990,8 +15179,7 @@ var ( _ encoding.BinaryUnmarshaler = (*LedgerEntryChangeType)(nil) ) -// xdrType signals that this type is an type representing -// representing XDR values defined by this package. +// xdrType signals that this type represents XDR values defined by this package. func (s LedgerEntryChangeType) xdrType() {} var _ xdrType = (*LedgerEntryChangeType)(nil) @@ -15269,8 +15457,10 @@ func (s LedgerEntryChange) MarshalBinary() ([]byte, error) { // UnmarshalBinary implements encoding.BinaryUnmarshaler. func (s *LedgerEntryChange) UnmarshalBinary(inp []byte) error { r := bytes.NewReader(inp) - d := xdr.NewDecoder(r) - _, err := s.DecodeFrom(d, xdr.DecodeDefaultMaxDepth) + o := xdr.DefaultDecodeOptions + o.MaxInputLen = len(inp) + d := xdr.NewDecoderWithOptions(r, o) + _, err := s.DecodeFrom(d, o.MaxDepth) return err } @@ -15279,8 +15469,7 @@ var ( _ encoding.BinaryUnmarshaler = (*LedgerEntryChange)(nil) ) -// xdrType signals that this type is an type representing -// representing XDR values defined by this package. +// xdrType signals that this type represents XDR values defined by this package. func (s LedgerEntryChange) xdrType() {} var _ xdrType = (*LedgerEntryChange)(nil) @@ -15322,8 +15511,11 @@ func (s *LedgerEntryChanges) DecodeFrom(d *xdr.Decoder, maxDepth uint) (int, err } (*s) = nil if l > 0 { + if il, ok := d.InputLen(); ok && uint(il) < uint(l) { + return n, fmt.Errorf("decoding LedgerEntryChange: length (%d) exceeds remaining input length (%d)", l, il) + } (*s) = make([]LedgerEntryChange, l) - for i := uint32(0); i < l; i++ { + for i := uint32(0); uint(i) < uint(l); i++ { nTmp, err = (*s)[i].DecodeFrom(d, maxDepth) n += nTmp if err != nil { @@ -15345,8 +15537,10 @@ func (s LedgerEntryChanges) MarshalBinary() ([]byte, error) { // UnmarshalBinary implements encoding.BinaryUnmarshaler. func (s *LedgerEntryChanges) UnmarshalBinary(inp []byte) error { r := bytes.NewReader(inp) - d := xdr.NewDecoder(r) - _, err := s.DecodeFrom(d, xdr.DecodeDefaultMaxDepth) + o := xdr.DefaultDecodeOptions + o.MaxInputLen = len(inp) + d := xdr.NewDecoderWithOptions(r, o) + _, err := s.DecodeFrom(d, o.MaxDepth) return err } @@ -15355,8 +15549,7 @@ var ( _ encoding.BinaryUnmarshaler = (*LedgerEntryChanges)(nil) ) -// xdrType signals that this type is an type representing -// representing XDR values defined by this package. +// xdrType signals that this type represents XDR values defined by this package. func (s LedgerEntryChanges) xdrType() {} var _ xdrType = (*LedgerEntryChanges)(nil) @@ -15409,8 +15602,10 @@ func (s OperationMeta) MarshalBinary() ([]byte, error) { // UnmarshalBinary implements encoding.BinaryUnmarshaler. func (s *OperationMeta) UnmarshalBinary(inp []byte) error { r := bytes.NewReader(inp) - d := xdr.NewDecoder(r) - _, err := s.DecodeFrom(d, xdr.DecodeDefaultMaxDepth) + o := xdr.DefaultDecodeOptions + o.MaxInputLen = len(inp) + d := xdr.NewDecoderWithOptions(r, o) + _, err := s.DecodeFrom(d, o.MaxDepth) return err } @@ -15419,8 +15614,7 @@ var ( _ encoding.BinaryUnmarshaler = (*OperationMeta)(nil) ) -// xdrType signals that this type is an type representing -// representing XDR values defined by this package. +// xdrType signals that this type represents XDR values defined by this package. func (s OperationMeta) xdrType() {} var _ xdrType = (*OperationMeta)(nil) @@ -15477,8 +15671,11 @@ func (s *TransactionMetaV1) DecodeFrom(d *xdr.Decoder, maxDepth uint) (int, erro } s.Operations = nil if l > 0 { + if il, ok := d.InputLen(); ok && uint(il) < uint(l) { + return n, fmt.Errorf("decoding OperationMeta: length (%d) exceeds remaining input length (%d)", l, il) + } s.Operations = make([]OperationMeta, l) - for i := uint32(0); i < l; i++ { + for i := uint32(0); uint(i) < uint(l); i++ { nTmp, err = s.Operations[i].DecodeFrom(d, maxDepth) n += nTmp if err != nil { @@ -15500,8 +15697,10 @@ func (s TransactionMetaV1) MarshalBinary() ([]byte, error) { // UnmarshalBinary implements encoding.BinaryUnmarshaler. func (s *TransactionMetaV1) UnmarshalBinary(inp []byte) error { r := bytes.NewReader(inp) - d := xdr.NewDecoder(r) - _, err := s.DecodeFrom(d, xdr.DecodeDefaultMaxDepth) + o := xdr.DefaultDecodeOptions + o.MaxInputLen = len(inp) + d := xdr.NewDecoderWithOptions(r, o) + _, err := s.DecodeFrom(d, o.MaxDepth) return err } @@ -15510,8 +15709,7 @@ var ( _ encoding.BinaryUnmarshaler = (*TransactionMetaV1)(nil) ) -// xdrType signals that this type is an type representing -// representing XDR values defined by this package. +// xdrType signals that this type represents XDR values defined by this package. func (s TransactionMetaV1) xdrType() {} var _ xdrType = (*TransactionMetaV1)(nil) @@ -15575,8 +15773,11 @@ func (s *TransactionMetaV2) DecodeFrom(d *xdr.Decoder, maxDepth uint) (int, erro } s.Operations = nil if l > 0 { + if il, ok := d.InputLen(); ok && uint(il) < uint(l) { + return n, fmt.Errorf("decoding OperationMeta: length (%d) exceeds remaining input length (%d)", l, il) + } s.Operations = make([]OperationMeta, l) - for i := uint32(0); i < l; i++ { + for i := uint32(0); uint(i) < uint(l); i++ { nTmp, err = s.Operations[i].DecodeFrom(d, maxDepth) n += nTmp if err != nil { @@ -15603,8 +15804,10 @@ func (s TransactionMetaV2) MarshalBinary() ([]byte, error) { // UnmarshalBinary implements encoding.BinaryUnmarshaler. func (s *TransactionMetaV2) UnmarshalBinary(inp []byte) error { r := bytes.NewReader(inp) - d := xdr.NewDecoder(r) - _, err := s.DecodeFrom(d, xdr.DecodeDefaultMaxDepth) + o := xdr.DefaultDecodeOptions + o.MaxInputLen = len(inp) + d := xdr.NewDecoderWithOptions(r, o) + _, err := s.DecodeFrom(d, o.MaxDepth) return err } @@ -15613,8 +15816,7 @@ var ( _ encoding.BinaryUnmarshaler = (*TransactionMetaV2)(nil) ) -// xdrType signals that this type is an type representing -// representing XDR values defined by this package. +// xdrType signals that this type represents XDR values defined by this package. func (s TransactionMetaV2) xdrType() {} var _ xdrType = (*TransactionMetaV2)(nil) @@ -15693,8 +15895,10 @@ func (s ContractEventType) MarshalBinary() ([]byte, error) { // UnmarshalBinary implements encoding.BinaryUnmarshaler. func (s *ContractEventType) UnmarshalBinary(inp []byte) error { r := bytes.NewReader(inp) - d := xdr.NewDecoder(r) - _, err := s.DecodeFrom(d, xdr.DecodeDefaultMaxDepth) + o := xdr.DefaultDecodeOptions + o.MaxInputLen = len(inp) + d := xdr.NewDecoderWithOptions(r, o) + _, err := s.DecodeFrom(d, o.MaxDepth) return err } @@ -15703,8 +15907,7 @@ var ( _ encoding.BinaryUnmarshaler = (*ContractEventType)(nil) ) -// xdrType signals that this type is an type representing -// representing XDR values defined by this package. +// xdrType signals that this type represents XDR values defined by this package. func (s ContractEventType) xdrType() {} var _ xdrType = (*ContractEventType)(nil) @@ -15756,8 +15959,11 @@ func (s *ContractEventV0) DecodeFrom(d *xdr.Decoder, maxDepth uint) (int, error) } s.Topics = nil if l > 0 { + if il, ok := d.InputLen(); ok && uint(il) < uint(l) { + return n, fmt.Errorf("decoding ScVal: length (%d) exceeds remaining input length (%d)", l, il) + } s.Topics = make([]ScVal, l) - for i := uint32(0); i < l; i++ { + for i := uint32(0); uint(i) < uint(l); i++ { nTmp, err = s.Topics[i].DecodeFrom(d, maxDepth) n += nTmp if err != nil { @@ -15784,8 +15990,10 @@ func (s ContractEventV0) MarshalBinary() ([]byte, error) { // UnmarshalBinary implements encoding.BinaryUnmarshaler. func (s *ContractEventV0) UnmarshalBinary(inp []byte) error { r := bytes.NewReader(inp) - d := xdr.NewDecoder(r) - _, err := s.DecodeFrom(d, xdr.DecodeDefaultMaxDepth) + o := xdr.DefaultDecodeOptions + o.MaxInputLen = len(inp) + d := xdr.NewDecoderWithOptions(r, o) + _, err := s.DecodeFrom(d, o.MaxDepth) return err } @@ -15794,8 +16002,7 @@ var ( _ encoding.BinaryUnmarshaler = (*ContractEventV0)(nil) ) -// xdrType signals that this type is an type representing -// representing XDR values defined by this package. +// xdrType signals that this type represents XDR values defined by this package. func (s ContractEventV0) xdrType() {} var _ xdrType = (*ContractEventV0)(nil) @@ -15927,8 +16134,10 @@ func (s ContractEventBody) MarshalBinary() ([]byte, error) { // UnmarshalBinary implements encoding.BinaryUnmarshaler. func (s *ContractEventBody) UnmarshalBinary(inp []byte) error { r := bytes.NewReader(inp) - d := xdr.NewDecoder(r) - _, err := s.DecodeFrom(d, xdr.DecodeDefaultMaxDepth) + o := xdr.DefaultDecodeOptions + o.MaxInputLen = len(inp) + d := xdr.NewDecoderWithOptions(r, o) + _, err := s.DecodeFrom(d, o.MaxDepth) return err } @@ -15937,8 +16146,7 @@ var ( _ encoding.BinaryUnmarshaler = (*ContractEventBody)(nil) ) -// xdrType signals that this type is an type representing -// representing XDR values defined by this package. +// xdrType signals that this type represents XDR values defined by this package. func (s ContractEventBody) xdrType() {} var _ xdrType = (*ContractEventBody)(nil) @@ -16049,8 +16257,10 @@ func (s ContractEvent) MarshalBinary() ([]byte, error) { // UnmarshalBinary implements encoding.BinaryUnmarshaler. func (s *ContractEvent) UnmarshalBinary(inp []byte) error { r := bytes.NewReader(inp) - d := xdr.NewDecoder(r) - _, err := s.DecodeFrom(d, xdr.DecodeDefaultMaxDepth) + o := xdr.DefaultDecodeOptions + o.MaxInputLen = len(inp) + d := xdr.NewDecoderWithOptions(r, o) + _, err := s.DecodeFrom(d, o.MaxDepth) return err } @@ -16059,8 +16269,7 @@ var ( _ encoding.BinaryUnmarshaler = (*ContractEvent)(nil) ) -// xdrType signals that this type is an type representing -// representing XDR values defined by this package. +// xdrType signals that this type represents XDR values defined by this package. func (s ContractEvent) xdrType() {} var _ xdrType = (*ContractEvent)(nil) @@ -16123,8 +16332,10 @@ func (s DiagnosticEvent) MarshalBinary() ([]byte, error) { // UnmarshalBinary implements encoding.BinaryUnmarshaler. func (s *DiagnosticEvent) UnmarshalBinary(inp []byte) error { r := bytes.NewReader(inp) - d := xdr.NewDecoder(r) - _, err := s.DecodeFrom(d, xdr.DecodeDefaultMaxDepth) + o := xdr.DefaultDecodeOptions + o.MaxInputLen = len(inp) + d := xdr.NewDecoderWithOptions(r, o) + _, err := s.DecodeFrom(d, o.MaxDepth) return err } @@ -16133,8 +16344,7 @@ var ( _ encoding.BinaryUnmarshaler = (*DiagnosticEvent)(nil) ) -// xdrType signals that this type is an type representing -// representing XDR values defined by this package. +// xdrType signals that this type represents XDR values defined by this package. func (s DiagnosticEvent) xdrType() {} var _ xdrType = (*DiagnosticEvent)(nil) @@ -16212,8 +16422,11 @@ func (s *SorobanTransactionMeta) DecodeFrom(d *xdr.Decoder, maxDepth uint) (int, } s.Events = nil if l > 0 { + if il, ok := d.InputLen(); ok && uint(il) < uint(l) { + return n, fmt.Errorf("decoding ContractEvent: length (%d) exceeds remaining input length (%d)", l, il) + } s.Events = make([]ContractEvent, l) - for i := uint32(0); i < l; i++ { + for i := uint32(0); uint(i) < uint(l); i++ { nTmp, err = s.Events[i].DecodeFrom(d, maxDepth) n += nTmp if err != nil { @@ -16233,8 +16446,11 @@ func (s *SorobanTransactionMeta) DecodeFrom(d *xdr.Decoder, maxDepth uint) (int, } s.DiagnosticEvents = nil if l > 0 { + if il, ok := d.InputLen(); ok && uint(il) < uint(l) { + return n, fmt.Errorf("decoding DiagnosticEvent: length (%d) exceeds remaining input length (%d)", l, il) + } s.DiagnosticEvents = make([]DiagnosticEvent, l) - for i := uint32(0); i < l; i++ { + for i := uint32(0); uint(i) < uint(l); i++ { nTmp, err = s.DiagnosticEvents[i].DecodeFrom(d, maxDepth) n += nTmp if err != nil { @@ -16256,8 +16472,10 @@ func (s SorobanTransactionMeta) MarshalBinary() ([]byte, error) { // UnmarshalBinary implements encoding.BinaryUnmarshaler. func (s *SorobanTransactionMeta) UnmarshalBinary(inp []byte) error { r := bytes.NewReader(inp) - d := xdr.NewDecoder(r) - _, err := s.DecodeFrom(d, xdr.DecodeDefaultMaxDepth) + o := xdr.DefaultDecodeOptions + o.MaxInputLen = len(inp) + d := xdr.NewDecoderWithOptions(r, o) + _, err := s.DecodeFrom(d, o.MaxDepth) return err } @@ -16266,8 +16484,7 @@ var ( _ encoding.BinaryUnmarshaler = (*SorobanTransactionMeta)(nil) ) -// xdrType signals that this type is an type representing -// representing XDR values defined by this package. +// xdrType signals that this type represents XDR values defined by this package. func (s SorobanTransactionMeta) xdrType() {} var _ xdrType = (*SorobanTransactionMeta)(nil) @@ -16353,8 +16570,11 @@ func (s *TransactionMetaV3) DecodeFrom(d *xdr.Decoder, maxDepth uint) (int, erro } s.Operations = nil if l > 0 { + if il, ok := d.InputLen(); ok && uint(il) < uint(l) { + return n, fmt.Errorf("decoding OperationMeta: length (%d) exceeds remaining input length (%d)", l, il) + } s.Operations = make([]OperationMeta, l) - for i := uint32(0); i < l; i++ { + for i := uint32(0); uint(i) < uint(l); i++ { nTmp, err = s.Operations[i].DecodeFrom(d, maxDepth) n += nTmp if err != nil { @@ -16396,8 +16616,10 @@ func (s TransactionMetaV3) MarshalBinary() ([]byte, error) { // UnmarshalBinary implements encoding.BinaryUnmarshaler. func (s *TransactionMetaV3) UnmarshalBinary(inp []byte) error { r := bytes.NewReader(inp) - d := xdr.NewDecoder(r) - _, err := s.DecodeFrom(d, xdr.DecodeDefaultMaxDepth) + o := xdr.DefaultDecodeOptions + o.MaxInputLen = len(inp) + d := xdr.NewDecoderWithOptions(r, o) + _, err := s.DecodeFrom(d, o.MaxDepth) return err } @@ -16406,8 +16628,7 @@ var ( _ encoding.BinaryUnmarshaler = (*TransactionMetaV3)(nil) ) -// xdrType signals that this type is an type representing -// representing XDR values defined by this package. +// xdrType signals that this type represents XDR values defined by this package. func (s TransactionMetaV3) xdrType() {} var _ xdrType = (*TransactionMetaV3)(nil) @@ -16464,8 +16685,11 @@ func (s *InvokeHostFunctionSuccessPreImage) DecodeFrom(d *xdr.Decoder, maxDepth } s.Events = nil if l > 0 { + if il, ok := d.InputLen(); ok && uint(il) < uint(l) { + return n, fmt.Errorf("decoding ContractEvent: length (%d) exceeds remaining input length (%d)", l, il) + } s.Events = make([]ContractEvent, l) - for i := uint32(0); i < l; i++ { + for i := uint32(0); uint(i) < uint(l); i++ { nTmp, err = s.Events[i].DecodeFrom(d, maxDepth) n += nTmp if err != nil { @@ -16487,8 +16711,10 @@ func (s InvokeHostFunctionSuccessPreImage) MarshalBinary() ([]byte, error) { // UnmarshalBinary implements encoding.BinaryUnmarshaler. func (s *InvokeHostFunctionSuccessPreImage) UnmarshalBinary(inp []byte) error { r := bytes.NewReader(inp) - d := xdr.NewDecoder(r) - _, err := s.DecodeFrom(d, xdr.DecodeDefaultMaxDepth) + o := xdr.DefaultDecodeOptions + o.MaxInputLen = len(inp) + d := xdr.NewDecoderWithOptions(r, o) + _, err := s.DecodeFrom(d, o.MaxDepth) return err } @@ -16497,8 +16723,7 @@ var ( _ encoding.BinaryUnmarshaler = (*InvokeHostFunctionSuccessPreImage)(nil) ) -// xdrType signals that this type is an type representing -// representing XDR values defined by this package. +// xdrType signals that this type represents XDR values defined by this package. func (s InvokeHostFunctionSuccessPreImage) xdrType() {} var _ xdrType = (*InvokeHostFunctionSuccessPreImage)(nil) @@ -16744,8 +16969,11 @@ func (u *TransactionMeta) DecodeFrom(d *xdr.Decoder, maxDepth uint) (int, error) } (*u.Operations) = nil if l > 0 { + if il, ok := d.InputLen(); ok && uint(il) < uint(l) { + return n, fmt.Errorf("decoding OperationMeta: length (%d) exceeds remaining input length (%d)", l, il) + } (*u.Operations) = make([]OperationMeta, l) - for i := uint32(0); i < l; i++ { + for i := uint32(0); uint(i) < uint(l); i++ { nTmp, err = (*u.Operations)[i].DecodeFrom(d, maxDepth) n += nTmp if err != nil { @@ -16793,8 +17021,10 @@ func (s TransactionMeta) MarshalBinary() ([]byte, error) { // UnmarshalBinary implements encoding.BinaryUnmarshaler. func (s *TransactionMeta) UnmarshalBinary(inp []byte) error { r := bytes.NewReader(inp) - d := xdr.NewDecoder(r) - _, err := s.DecodeFrom(d, xdr.DecodeDefaultMaxDepth) + o := xdr.DefaultDecodeOptions + o.MaxInputLen = len(inp) + d := xdr.NewDecoderWithOptions(r, o) + _, err := s.DecodeFrom(d, o.MaxDepth) return err } @@ -16803,8 +17033,7 @@ var ( _ encoding.BinaryUnmarshaler = (*TransactionMeta)(nil) ) -// xdrType signals that this type is an type representing -// representing XDR values defined by this package. +// xdrType signals that this type represents XDR values defined by this package. func (s TransactionMeta) xdrType() {} var _ xdrType = (*TransactionMeta)(nil) @@ -16877,8 +17106,10 @@ func (s TransactionResultMeta) MarshalBinary() ([]byte, error) { // UnmarshalBinary implements encoding.BinaryUnmarshaler. func (s *TransactionResultMeta) UnmarshalBinary(inp []byte) error { r := bytes.NewReader(inp) - d := xdr.NewDecoder(r) - _, err := s.DecodeFrom(d, xdr.DecodeDefaultMaxDepth) + o := xdr.DefaultDecodeOptions + o.MaxInputLen = len(inp) + d := xdr.NewDecoderWithOptions(r, o) + _, err := s.DecodeFrom(d, o.MaxDepth) return err } @@ -16887,8 +17118,7 @@ var ( _ encoding.BinaryUnmarshaler = (*TransactionResultMeta)(nil) ) -// xdrType signals that this type is an type representing -// representing XDR values defined by this package. +// xdrType signals that this type represents XDR values defined by this package. func (s TransactionResultMeta) xdrType() {} var _ xdrType = (*TransactionResultMeta)(nil) @@ -16951,8 +17181,10 @@ func (s UpgradeEntryMeta) MarshalBinary() ([]byte, error) { // UnmarshalBinary implements encoding.BinaryUnmarshaler. func (s *UpgradeEntryMeta) UnmarshalBinary(inp []byte) error { r := bytes.NewReader(inp) - d := xdr.NewDecoder(r) - _, err := s.DecodeFrom(d, xdr.DecodeDefaultMaxDepth) + o := xdr.DefaultDecodeOptions + o.MaxInputLen = len(inp) + d := xdr.NewDecoderWithOptions(r, o) + _, err := s.DecodeFrom(d, o.MaxDepth) return err } @@ -16961,8 +17193,7 @@ var ( _ encoding.BinaryUnmarshaler = (*UpgradeEntryMeta)(nil) ) -// xdrType signals that this type is an type representing -// representing XDR values defined by this package. +// xdrType signals that this type represents XDR values defined by this package. func (s UpgradeEntryMeta) xdrType() {} var _ xdrType = (*UpgradeEntryMeta)(nil) @@ -17058,8 +17289,11 @@ func (s *LedgerCloseMetaV0) DecodeFrom(d *xdr.Decoder, maxDepth uint) (int, erro } s.TxProcessing = nil if l > 0 { + if il, ok := d.InputLen(); ok && uint(il) < uint(l) { + return n, fmt.Errorf("decoding TransactionResultMeta: length (%d) exceeds remaining input length (%d)", l, il) + } s.TxProcessing = make([]TransactionResultMeta, l) - for i := uint32(0); i < l; i++ { + for i := uint32(0); uint(i) < uint(l); i++ { nTmp, err = s.TxProcessing[i].DecodeFrom(d, maxDepth) n += nTmp if err != nil { @@ -17074,8 +17308,11 @@ func (s *LedgerCloseMetaV0) DecodeFrom(d *xdr.Decoder, maxDepth uint) (int, erro } s.UpgradesProcessing = nil if l > 0 { + if il, ok := d.InputLen(); ok && uint(il) < uint(l) { + return n, fmt.Errorf("decoding UpgradeEntryMeta: length (%d) exceeds remaining input length (%d)", l, il) + } s.UpgradesProcessing = make([]UpgradeEntryMeta, l) - for i := uint32(0); i < l; i++ { + for i := uint32(0); uint(i) < uint(l); i++ { nTmp, err = s.UpgradesProcessing[i].DecodeFrom(d, maxDepth) n += nTmp if err != nil { @@ -17090,8 +17327,11 @@ func (s *LedgerCloseMetaV0) DecodeFrom(d *xdr.Decoder, maxDepth uint) (int, erro } s.ScpInfo = nil if l > 0 { + if il, ok := d.InputLen(); ok && uint(il) < uint(l) { + return n, fmt.Errorf("decoding ScpHistoryEntry: length (%d) exceeds remaining input length (%d)", l, il) + } s.ScpInfo = make([]ScpHistoryEntry, l) - for i := uint32(0); i < l; i++ { + for i := uint32(0); uint(i) < uint(l); i++ { nTmp, err = s.ScpInfo[i].DecodeFrom(d, maxDepth) n += nTmp if err != nil { @@ -17113,8 +17353,10 @@ func (s LedgerCloseMetaV0) MarshalBinary() ([]byte, error) { // UnmarshalBinary implements encoding.BinaryUnmarshaler. func (s *LedgerCloseMetaV0) UnmarshalBinary(inp []byte) error { r := bytes.NewReader(inp) - d := xdr.NewDecoder(r) - _, err := s.DecodeFrom(d, xdr.DecodeDefaultMaxDepth) + o := xdr.DefaultDecodeOptions + o.MaxInputLen = len(inp) + d := xdr.NewDecoderWithOptions(r, o) + _, err := s.DecodeFrom(d, o.MaxDepth) return err } @@ -17123,8 +17365,7 @@ var ( _ encoding.BinaryUnmarshaler = (*LedgerCloseMetaV0)(nil) ) -// xdrType signals that this type is an type representing -// representing XDR values defined by this package. +// xdrType signals that this type represents XDR values defined by this package. func (s LedgerCloseMetaV0) xdrType() {} var _ xdrType = (*LedgerCloseMetaV0)(nil) @@ -17266,8 +17507,11 @@ func (s *LedgerCloseMetaV1) DecodeFrom(d *xdr.Decoder, maxDepth uint) (int, erro } s.TxProcessing = nil if l > 0 { + if il, ok := d.InputLen(); ok && uint(il) < uint(l) { + return n, fmt.Errorf("decoding TransactionResultMeta: length (%d) exceeds remaining input length (%d)", l, il) + } s.TxProcessing = make([]TransactionResultMeta, l) - for i := uint32(0); i < l; i++ { + for i := uint32(0); uint(i) < uint(l); i++ { nTmp, err = s.TxProcessing[i].DecodeFrom(d, maxDepth) n += nTmp if err != nil { @@ -17282,8 +17526,11 @@ func (s *LedgerCloseMetaV1) DecodeFrom(d *xdr.Decoder, maxDepth uint) (int, erro } s.UpgradesProcessing = nil if l > 0 { + if il, ok := d.InputLen(); ok && uint(il) < uint(l) { + return n, fmt.Errorf("decoding UpgradeEntryMeta: length (%d) exceeds remaining input length (%d)", l, il) + } s.UpgradesProcessing = make([]UpgradeEntryMeta, l) - for i := uint32(0); i < l; i++ { + for i := uint32(0); uint(i) < uint(l); i++ { nTmp, err = s.UpgradesProcessing[i].DecodeFrom(d, maxDepth) n += nTmp if err != nil { @@ -17298,8 +17545,11 @@ func (s *LedgerCloseMetaV1) DecodeFrom(d *xdr.Decoder, maxDepth uint) (int, erro } s.ScpInfo = nil if l > 0 { + if il, ok := d.InputLen(); ok && uint(il) < uint(l) { + return n, fmt.Errorf("decoding ScpHistoryEntry: length (%d) exceeds remaining input length (%d)", l, il) + } s.ScpInfo = make([]ScpHistoryEntry, l) - for i := uint32(0); i < l; i++ { + for i := uint32(0); uint(i) < uint(l); i++ { nTmp, err = s.ScpInfo[i].DecodeFrom(d, maxDepth) n += nTmp if err != nil { @@ -17319,8 +17569,11 @@ func (s *LedgerCloseMetaV1) DecodeFrom(d *xdr.Decoder, maxDepth uint) (int, erro } s.EvictedTemporaryLedgerKeys = nil if l > 0 { + if il, ok := d.InputLen(); ok && uint(il) < uint(l) { + return n, fmt.Errorf("decoding LedgerKey: length (%d) exceeds remaining input length (%d)", l, il) + } s.EvictedTemporaryLedgerKeys = make([]LedgerKey, l) - for i := uint32(0); i < l; i++ { + for i := uint32(0); uint(i) < uint(l); i++ { nTmp, err = s.EvictedTemporaryLedgerKeys[i].DecodeFrom(d, maxDepth) n += nTmp if err != nil { @@ -17335,8 +17588,11 @@ func (s *LedgerCloseMetaV1) DecodeFrom(d *xdr.Decoder, maxDepth uint) (int, erro } s.EvictedPersistentLedgerEntries = nil if l > 0 { + if il, ok := d.InputLen(); ok && uint(il) < uint(l) { + return n, fmt.Errorf("decoding LedgerEntry: length (%d) exceeds remaining input length (%d)", l, il) + } s.EvictedPersistentLedgerEntries = make([]LedgerEntry, l) - for i := uint32(0); i < l; i++ { + for i := uint32(0); uint(i) < uint(l); i++ { nTmp, err = s.EvictedPersistentLedgerEntries[i].DecodeFrom(d, maxDepth) n += nTmp if err != nil { @@ -17358,8 +17614,10 @@ func (s LedgerCloseMetaV1) MarshalBinary() ([]byte, error) { // UnmarshalBinary implements encoding.BinaryUnmarshaler. func (s *LedgerCloseMetaV1) UnmarshalBinary(inp []byte) error { r := bytes.NewReader(inp) - d := xdr.NewDecoder(r) - _, err := s.DecodeFrom(d, xdr.DecodeDefaultMaxDepth) + o := xdr.DefaultDecodeOptions + o.MaxInputLen = len(inp) + d := xdr.NewDecoderWithOptions(r, o) + _, err := s.DecodeFrom(d, o.MaxDepth) return err } @@ -17368,8 +17626,7 @@ var ( _ encoding.BinaryUnmarshaler = (*LedgerCloseMetaV1)(nil) ) -// xdrType signals that this type is an type representing -// representing XDR values defined by this package. +// xdrType signals that this type represents XDR values defined by this package. func (s LedgerCloseMetaV1) xdrType() {} var _ xdrType = (*LedgerCloseMetaV1)(nil) @@ -17547,8 +17804,10 @@ func (s LedgerCloseMeta) MarshalBinary() ([]byte, error) { // UnmarshalBinary implements encoding.BinaryUnmarshaler. func (s *LedgerCloseMeta) UnmarshalBinary(inp []byte) error { r := bytes.NewReader(inp) - d := xdr.NewDecoder(r) - _, err := s.DecodeFrom(d, xdr.DecodeDefaultMaxDepth) + o := xdr.DefaultDecodeOptions + o.MaxInputLen = len(inp) + d := xdr.NewDecoderWithOptions(r, o) + _, err := s.DecodeFrom(d, o.MaxDepth) return err } @@ -17557,8 +17816,7 @@ var ( _ encoding.BinaryUnmarshaler = (*LedgerCloseMeta)(nil) ) -// xdrType signals that this type is an type representing -// representing XDR values defined by this package. +// xdrType signals that this type represents XDR values defined by this package. func (s LedgerCloseMeta) xdrType() {} var _ xdrType = (*LedgerCloseMeta)(nil) @@ -17643,8 +17901,10 @@ func (s ErrorCode) MarshalBinary() ([]byte, error) { // UnmarshalBinary implements encoding.BinaryUnmarshaler. func (s *ErrorCode) UnmarshalBinary(inp []byte) error { r := bytes.NewReader(inp) - d := xdr.NewDecoder(r) - _, err := s.DecodeFrom(d, xdr.DecodeDefaultMaxDepth) + o := xdr.DefaultDecodeOptions + o.MaxInputLen = len(inp) + d := xdr.NewDecoderWithOptions(r, o) + _, err := s.DecodeFrom(d, o.MaxDepth) return err } @@ -17653,8 +17913,7 @@ var ( _ encoding.BinaryUnmarshaler = (*ErrorCode)(nil) ) -// xdrType signals that this type is an type representing -// representing XDR values defined by this package. +// xdrType signals that this type represents XDR values defined by this package. func (s ErrorCode) xdrType() {} var _ xdrType = (*ErrorCode)(nil) @@ -17717,8 +17976,10 @@ func (s Error) MarshalBinary() ([]byte, error) { // UnmarshalBinary implements encoding.BinaryUnmarshaler. func (s *Error) UnmarshalBinary(inp []byte) error { r := bytes.NewReader(inp) - d := xdr.NewDecoder(r) - _, err := s.DecodeFrom(d, xdr.DecodeDefaultMaxDepth) + o := xdr.DefaultDecodeOptions + o.MaxInputLen = len(inp) + d := xdr.NewDecoderWithOptions(r, o) + _, err := s.DecodeFrom(d, o.MaxDepth) return err } @@ -17727,8 +17988,7 @@ var ( _ encoding.BinaryUnmarshaler = (*Error)(nil) ) -// xdrType signals that this type is an type representing -// representing XDR values defined by this package. +// xdrType signals that this type represents XDR values defined by this package. func (s Error) xdrType() {} var _ xdrType = (*Error)(nil) @@ -17781,8 +18041,10 @@ func (s SendMore) MarshalBinary() ([]byte, error) { // UnmarshalBinary implements encoding.BinaryUnmarshaler. func (s *SendMore) UnmarshalBinary(inp []byte) error { r := bytes.NewReader(inp) - d := xdr.NewDecoder(r) - _, err := s.DecodeFrom(d, xdr.DecodeDefaultMaxDepth) + o := xdr.DefaultDecodeOptions + o.MaxInputLen = len(inp) + d := xdr.NewDecoderWithOptions(r, o) + _, err := s.DecodeFrom(d, o.MaxDepth) return err } @@ -17791,8 +18053,7 @@ var ( _ encoding.BinaryUnmarshaler = (*SendMore)(nil) ) -// xdrType signals that this type is an type representing -// representing XDR values defined by this package. +// xdrType signals that this type represents XDR values defined by this package. func (s SendMore) xdrType() {} var _ xdrType = (*SendMore)(nil) @@ -17855,8 +18116,10 @@ func (s SendMoreExtended) MarshalBinary() ([]byte, error) { // UnmarshalBinary implements encoding.BinaryUnmarshaler. func (s *SendMoreExtended) UnmarshalBinary(inp []byte) error { r := bytes.NewReader(inp) - d := xdr.NewDecoder(r) - _, err := s.DecodeFrom(d, xdr.DecodeDefaultMaxDepth) + o := xdr.DefaultDecodeOptions + o.MaxInputLen = len(inp) + d := xdr.NewDecoderWithOptions(r, o) + _, err := s.DecodeFrom(d, o.MaxDepth) return err } @@ -17865,8 +18128,7 @@ var ( _ encoding.BinaryUnmarshaler = (*SendMoreExtended)(nil) ) -// xdrType signals that this type is an type representing -// representing XDR values defined by this package. +// xdrType signals that this type represents XDR values defined by this package. func (s SendMoreExtended) xdrType() {} var _ xdrType = (*SendMoreExtended)(nil) @@ -17939,8 +18201,10 @@ func (s AuthCert) MarshalBinary() ([]byte, error) { // UnmarshalBinary implements encoding.BinaryUnmarshaler. func (s *AuthCert) UnmarshalBinary(inp []byte) error { r := bytes.NewReader(inp) - d := xdr.NewDecoder(r) - _, err := s.DecodeFrom(d, xdr.DecodeDefaultMaxDepth) + o := xdr.DefaultDecodeOptions + o.MaxInputLen = len(inp) + d := xdr.NewDecoderWithOptions(r, o) + _, err := s.DecodeFrom(d, o.MaxDepth) return err } @@ -17949,8 +18213,7 @@ var ( _ encoding.BinaryUnmarshaler = (*AuthCert)(nil) ) -// xdrType signals that this type is an type representing -// representing XDR values defined by this package. +// xdrType signals that this type represents XDR values defined by this package. func (s AuthCert) xdrType() {} var _ xdrType = (*AuthCert)(nil) @@ -18083,8 +18346,10 @@ func (s Hello) MarshalBinary() ([]byte, error) { // UnmarshalBinary implements encoding.BinaryUnmarshaler. func (s *Hello) UnmarshalBinary(inp []byte) error { r := bytes.NewReader(inp) - d := xdr.NewDecoder(r) - _, err := s.DecodeFrom(d, xdr.DecodeDefaultMaxDepth) + o := xdr.DefaultDecodeOptions + o.MaxInputLen = len(inp) + d := xdr.NewDecoderWithOptions(r, o) + _, err := s.DecodeFrom(d, o.MaxDepth) return err } @@ -18093,8 +18358,7 @@ var ( _ encoding.BinaryUnmarshaler = (*Hello)(nil) ) -// xdrType signals that this type is an type representing -// representing XDR values defined by this package. +// xdrType signals that this type represents XDR values defined by this package. func (s Hello) xdrType() {} var _ xdrType = (*Hello)(nil) @@ -18152,8 +18416,10 @@ func (s Auth) MarshalBinary() ([]byte, error) { // UnmarshalBinary implements encoding.BinaryUnmarshaler. func (s *Auth) UnmarshalBinary(inp []byte) error { r := bytes.NewReader(inp) - d := xdr.NewDecoder(r) - _, err := s.DecodeFrom(d, xdr.DecodeDefaultMaxDepth) + o := xdr.DefaultDecodeOptions + o.MaxInputLen = len(inp) + d := xdr.NewDecoderWithOptions(r, o) + _, err := s.DecodeFrom(d, o.MaxDepth) return err } @@ -18162,8 +18428,7 @@ var ( _ encoding.BinaryUnmarshaler = (*Auth)(nil) ) -// xdrType signals that this type is an type representing -// representing XDR values defined by this package. +// xdrType signals that this type represents XDR values defined by this package. func (s Auth) xdrType() {} var _ xdrType = (*Auth)(nil) @@ -18239,8 +18504,10 @@ func (s IpAddrType) MarshalBinary() ([]byte, error) { // UnmarshalBinary implements encoding.BinaryUnmarshaler. func (s *IpAddrType) UnmarshalBinary(inp []byte) error { r := bytes.NewReader(inp) - d := xdr.NewDecoder(r) - _, err := s.DecodeFrom(d, xdr.DecodeDefaultMaxDepth) + o := xdr.DefaultDecodeOptions + o.MaxInputLen = len(inp) + d := xdr.NewDecoderWithOptions(r, o) + _, err := s.DecodeFrom(d, o.MaxDepth) return err } @@ -18249,8 +18516,7 @@ var ( _ encoding.BinaryUnmarshaler = (*IpAddrType)(nil) ) -// xdrType signals that this type is an type representing -// representing XDR values defined by this package. +// xdrType signals that this type represents XDR values defined by this package. func (s IpAddrType) xdrType() {} var _ xdrType = (*IpAddrType)(nil) @@ -18428,8 +18694,10 @@ func (s PeerAddressIp) MarshalBinary() ([]byte, error) { // UnmarshalBinary implements encoding.BinaryUnmarshaler. func (s *PeerAddressIp) UnmarshalBinary(inp []byte) error { r := bytes.NewReader(inp) - d := xdr.NewDecoder(r) - _, err := s.DecodeFrom(d, xdr.DecodeDefaultMaxDepth) + o := xdr.DefaultDecodeOptions + o.MaxInputLen = len(inp) + d := xdr.NewDecoderWithOptions(r, o) + _, err := s.DecodeFrom(d, o.MaxDepth) return err } @@ -18438,8 +18706,7 @@ var ( _ encoding.BinaryUnmarshaler = (*PeerAddressIp)(nil) ) -// xdrType signals that this type is an type representing -// representing XDR values defined by this package. +// xdrType signals that this type represents XDR values defined by this package. func (s PeerAddressIp) xdrType() {} var _ xdrType = (*PeerAddressIp)(nil) @@ -18519,8 +18786,10 @@ func (s PeerAddress) MarshalBinary() ([]byte, error) { // UnmarshalBinary implements encoding.BinaryUnmarshaler. func (s *PeerAddress) UnmarshalBinary(inp []byte) error { r := bytes.NewReader(inp) - d := xdr.NewDecoder(r) - _, err := s.DecodeFrom(d, xdr.DecodeDefaultMaxDepth) + o := xdr.DefaultDecodeOptions + o.MaxInputLen = len(inp) + d := xdr.NewDecoderWithOptions(r, o) + _, err := s.DecodeFrom(d, o.MaxDepth) return err } @@ -18529,8 +18798,7 @@ var ( _ encoding.BinaryUnmarshaler = (*PeerAddress)(nil) ) -// xdrType signals that this type is an type representing -// representing XDR values defined by this package. +// xdrType signals that this type represents XDR values defined by this package. func (s PeerAddress) xdrType() {} var _ xdrType = (*PeerAddress)(nil) @@ -18670,8 +18938,10 @@ func (s MessageType) MarshalBinary() ([]byte, error) { // UnmarshalBinary implements encoding.BinaryUnmarshaler. func (s *MessageType) UnmarshalBinary(inp []byte) error { r := bytes.NewReader(inp) - d := xdr.NewDecoder(r) - _, err := s.DecodeFrom(d, xdr.DecodeDefaultMaxDepth) + o := xdr.DefaultDecodeOptions + o.MaxInputLen = len(inp) + d := xdr.NewDecoderWithOptions(r, o) + _, err := s.DecodeFrom(d, o.MaxDepth) return err } @@ -18680,8 +18950,7 @@ var ( _ encoding.BinaryUnmarshaler = (*MessageType)(nil) ) -// xdrType signals that this type is an type representing -// representing XDR values defined by this package. +// xdrType signals that this type represents XDR values defined by this package. func (s MessageType) xdrType() {} var _ xdrType = (*MessageType)(nil) @@ -18744,8 +19013,10 @@ func (s DontHave) MarshalBinary() ([]byte, error) { // UnmarshalBinary implements encoding.BinaryUnmarshaler. func (s *DontHave) UnmarshalBinary(inp []byte) error { r := bytes.NewReader(inp) - d := xdr.NewDecoder(r) - _, err := s.DecodeFrom(d, xdr.DecodeDefaultMaxDepth) + o := xdr.DefaultDecodeOptions + o.MaxInputLen = len(inp) + d := xdr.NewDecoderWithOptions(r, o) + _, err := s.DecodeFrom(d, o.MaxDepth) return err } @@ -18754,8 +19025,7 @@ var ( _ encoding.BinaryUnmarshaler = (*DontHave)(nil) ) -// xdrType signals that this type is an type representing -// representing XDR values defined by this package. +// xdrType signals that this type represents XDR values defined by this package. func (s DontHave) xdrType() {} var _ xdrType = (*DontHave)(nil) @@ -18828,8 +19098,10 @@ func (s SurveyMessageCommandType) MarshalBinary() ([]byte, error) { // UnmarshalBinary implements encoding.BinaryUnmarshaler. func (s *SurveyMessageCommandType) UnmarshalBinary(inp []byte) error { r := bytes.NewReader(inp) - d := xdr.NewDecoder(r) - _, err := s.DecodeFrom(d, xdr.DecodeDefaultMaxDepth) + o := xdr.DefaultDecodeOptions + o.MaxInputLen = len(inp) + d := xdr.NewDecoderWithOptions(r, o) + _, err := s.DecodeFrom(d, o.MaxDepth) return err } @@ -18838,8 +19110,7 @@ var ( _ encoding.BinaryUnmarshaler = (*SurveyMessageCommandType)(nil) ) -// xdrType signals that this type is an type representing -// representing XDR values defined by this package. +// xdrType signals that this type represents XDR values defined by this package. func (s SurveyMessageCommandType) xdrType() {} var _ xdrType = (*SurveyMessageCommandType)(nil) @@ -18915,8 +19186,10 @@ func (s SurveyMessageResponseType) MarshalBinary() ([]byte, error) { // UnmarshalBinary implements encoding.BinaryUnmarshaler. func (s *SurveyMessageResponseType) UnmarshalBinary(inp []byte) error { r := bytes.NewReader(inp) - d := xdr.NewDecoder(r) - _, err := s.DecodeFrom(d, xdr.DecodeDefaultMaxDepth) + o := xdr.DefaultDecodeOptions + o.MaxInputLen = len(inp) + d := xdr.NewDecoderWithOptions(r, o) + _, err := s.DecodeFrom(d, o.MaxDepth) return err } @@ -18925,8 +19198,7 @@ var ( _ encoding.BinaryUnmarshaler = (*SurveyMessageResponseType)(nil) ) -// xdrType signals that this type is an type representing -// representing XDR values defined by this package. +// xdrType signals that this type represents XDR values defined by this package. func (s SurveyMessageResponseType) xdrType() {} var _ xdrType = (*SurveyMessageResponseType)(nil) @@ -19019,8 +19291,10 @@ func (s SurveyRequestMessage) MarshalBinary() ([]byte, error) { // UnmarshalBinary implements encoding.BinaryUnmarshaler. func (s *SurveyRequestMessage) UnmarshalBinary(inp []byte) error { r := bytes.NewReader(inp) - d := xdr.NewDecoder(r) - _, err := s.DecodeFrom(d, xdr.DecodeDefaultMaxDepth) + o := xdr.DefaultDecodeOptions + o.MaxInputLen = len(inp) + d := xdr.NewDecoderWithOptions(r, o) + _, err := s.DecodeFrom(d, o.MaxDepth) return err } @@ -19029,8 +19303,7 @@ var ( _ encoding.BinaryUnmarshaler = (*SurveyRequestMessage)(nil) ) -// xdrType signals that this type is an type representing -// representing XDR values defined by this package. +// xdrType signals that this type represents XDR values defined by this package. func (s SurveyRequestMessage) xdrType() {} var _ xdrType = (*SurveyRequestMessage)(nil) @@ -19093,8 +19366,10 @@ func (s SignedSurveyRequestMessage) MarshalBinary() ([]byte, error) { // UnmarshalBinary implements encoding.BinaryUnmarshaler. func (s *SignedSurveyRequestMessage) UnmarshalBinary(inp []byte) error { r := bytes.NewReader(inp) - d := xdr.NewDecoder(r) - _, err := s.DecodeFrom(d, xdr.DecodeDefaultMaxDepth) + o := xdr.DefaultDecodeOptions + o.MaxInputLen = len(inp) + d := xdr.NewDecoderWithOptions(r, o) + _, err := s.DecodeFrom(d, o.MaxDepth) return err } @@ -19103,8 +19378,7 @@ var ( _ encoding.BinaryUnmarshaler = (*SignedSurveyRequestMessage)(nil) ) -// xdrType signals that this type is an type representing -// representing XDR values defined by this package. +// xdrType signals that this type represents XDR values defined by this package. func (s SignedSurveyRequestMessage) xdrType() {} var _ xdrType = (*SignedSurveyRequestMessage)(nil) @@ -19157,8 +19431,10 @@ func (s EncryptedBody) MarshalBinary() ([]byte, error) { // UnmarshalBinary implements encoding.BinaryUnmarshaler. func (s *EncryptedBody) UnmarshalBinary(inp []byte) error { r := bytes.NewReader(inp) - d := xdr.NewDecoder(r) - _, err := s.DecodeFrom(d, xdr.DecodeDefaultMaxDepth) + o := xdr.DefaultDecodeOptions + o.MaxInputLen = len(inp) + d := xdr.NewDecoderWithOptions(r, o) + _, err := s.DecodeFrom(d, o.MaxDepth) return err } @@ -19167,8 +19443,7 @@ var ( _ encoding.BinaryUnmarshaler = (*EncryptedBody)(nil) ) -// xdrType signals that this type is an type representing -// representing XDR values defined by this package. +// xdrType signals that this type represents XDR values defined by this package. func (s EncryptedBody) xdrType() {} var _ xdrType = (*EncryptedBody)(nil) @@ -19261,8 +19536,10 @@ func (s SurveyResponseMessage) MarshalBinary() ([]byte, error) { // UnmarshalBinary implements encoding.BinaryUnmarshaler. func (s *SurveyResponseMessage) UnmarshalBinary(inp []byte) error { r := bytes.NewReader(inp) - d := xdr.NewDecoder(r) - _, err := s.DecodeFrom(d, xdr.DecodeDefaultMaxDepth) + o := xdr.DefaultDecodeOptions + o.MaxInputLen = len(inp) + d := xdr.NewDecoderWithOptions(r, o) + _, err := s.DecodeFrom(d, o.MaxDepth) return err } @@ -19271,8 +19548,7 @@ var ( _ encoding.BinaryUnmarshaler = (*SurveyResponseMessage)(nil) ) -// xdrType signals that this type is an type representing -// representing XDR values defined by this package. +// xdrType signals that this type represents XDR values defined by this package. func (s SurveyResponseMessage) xdrType() {} var _ xdrType = (*SurveyResponseMessage)(nil) @@ -19335,8 +19611,10 @@ func (s SignedSurveyResponseMessage) MarshalBinary() ([]byte, error) { // UnmarshalBinary implements encoding.BinaryUnmarshaler. func (s *SignedSurveyResponseMessage) UnmarshalBinary(inp []byte) error { r := bytes.NewReader(inp) - d := xdr.NewDecoder(r) - _, err := s.DecodeFrom(d, xdr.DecodeDefaultMaxDepth) + o := xdr.DefaultDecodeOptions + o.MaxInputLen = len(inp) + d := xdr.NewDecoderWithOptions(r, o) + _, err := s.DecodeFrom(d, o.MaxDepth) return err } @@ -19345,8 +19623,7 @@ var ( _ encoding.BinaryUnmarshaler = (*SignedSurveyResponseMessage)(nil) ) -// xdrType signals that this type is an type representing -// representing XDR values defined by this package. +// xdrType signals that this type represents XDR values defined by this package. func (s SignedSurveyResponseMessage) xdrType() {} var _ xdrType = (*SignedSurveyResponseMessage)(nil) @@ -19541,8 +19818,10 @@ func (s PeerStats) MarshalBinary() ([]byte, error) { // UnmarshalBinary implements encoding.BinaryUnmarshaler. func (s *PeerStats) UnmarshalBinary(inp []byte) error { r := bytes.NewReader(inp) - d := xdr.NewDecoder(r) - _, err := s.DecodeFrom(d, xdr.DecodeDefaultMaxDepth) + o := xdr.DefaultDecodeOptions + o.MaxInputLen = len(inp) + d := xdr.NewDecoderWithOptions(r, o) + _, err := s.DecodeFrom(d, o.MaxDepth) return err } @@ -19551,8 +19830,7 @@ var ( _ encoding.BinaryUnmarshaler = (*PeerStats)(nil) ) -// xdrType signals that this type is an type representing -// representing XDR values defined by this package. +// xdrType signals that this type represents XDR values defined by this package. func (s PeerStats) xdrType() {} var _ xdrType = (*PeerStats)(nil) @@ -19602,8 +19880,11 @@ func (s *PeerStatList) DecodeFrom(d *xdr.Decoder, maxDepth uint) (int, error) { } (*s) = nil if l > 0 { + if il, ok := d.InputLen(); ok && uint(il) < uint(l) { + return n, fmt.Errorf("decoding PeerStats: length (%d) exceeds remaining input length (%d)", l, il) + } (*s) = make([]PeerStats, l) - for i := uint32(0); i < l; i++ { + for i := uint32(0); uint(i) < uint(l); i++ { nTmp, err = (*s)[i].DecodeFrom(d, maxDepth) n += nTmp if err != nil { @@ -19625,8 +19906,10 @@ func (s PeerStatList) MarshalBinary() ([]byte, error) { // UnmarshalBinary implements encoding.BinaryUnmarshaler. func (s *PeerStatList) UnmarshalBinary(inp []byte) error { r := bytes.NewReader(inp) - d := xdr.NewDecoder(r) - _, err := s.DecodeFrom(d, xdr.DecodeDefaultMaxDepth) + o := xdr.DefaultDecodeOptions + o.MaxInputLen = len(inp) + d := xdr.NewDecoderWithOptions(r, o) + _, err := s.DecodeFrom(d, o.MaxDepth) return err } @@ -19635,8 +19918,7 @@ var ( _ encoding.BinaryUnmarshaler = (*PeerStatList)(nil) ) -// xdrType signals that this type is an type representing -// representing XDR values defined by this package. +// xdrType signals that this type represents XDR values defined by this package. func (s PeerStatList) xdrType() {} var _ xdrType = (*PeerStatList)(nil) @@ -19720,8 +20002,10 @@ func (s TopologyResponseBodyV0) MarshalBinary() ([]byte, error) { // UnmarshalBinary implements encoding.BinaryUnmarshaler. func (s *TopologyResponseBodyV0) UnmarshalBinary(inp []byte) error { r := bytes.NewReader(inp) - d := xdr.NewDecoder(r) - _, err := s.DecodeFrom(d, xdr.DecodeDefaultMaxDepth) + o := xdr.DefaultDecodeOptions + o.MaxInputLen = len(inp) + d := xdr.NewDecoderWithOptions(r, o) + _, err := s.DecodeFrom(d, o.MaxDepth) return err } @@ -19730,8 +20014,7 @@ var ( _ encoding.BinaryUnmarshaler = (*TopologyResponseBodyV0)(nil) ) -// xdrType signals that this type is an type representing -// representing XDR values defined by this package. +// xdrType signals that this type represents XDR values defined by this package. func (s TopologyResponseBodyV0) xdrType() {} var _ xdrType = (*TopologyResponseBodyV0)(nil) @@ -19836,8 +20119,10 @@ func (s TopologyResponseBodyV1) MarshalBinary() ([]byte, error) { // UnmarshalBinary implements encoding.BinaryUnmarshaler. func (s *TopologyResponseBodyV1) UnmarshalBinary(inp []byte) error { r := bytes.NewReader(inp) - d := xdr.NewDecoder(r) - _, err := s.DecodeFrom(d, xdr.DecodeDefaultMaxDepth) + o := xdr.DefaultDecodeOptions + o.MaxInputLen = len(inp) + d := xdr.NewDecoderWithOptions(r, o) + _, err := s.DecodeFrom(d, o.MaxDepth) return err } @@ -19846,8 +20131,7 @@ var ( _ encoding.BinaryUnmarshaler = (*TopologyResponseBodyV1)(nil) ) -// xdrType signals that this type is an type representing -// representing XDR values defined by this package. +// xdrType signals that this type represents XDR values defined by this package. func (s TopologyResponseBodyV1) xdrType() {} var _ xdrType = (*TopologyResponseBodyV1)(nil) @@ -20025,8 +20309,10 @@ func (s SurveyResponseBody) MarshalBinary() ([]byte, error) { // UnmarshalBinary implements encoding.BinaryUnmarshaler. func (s *SurveyResponseBody) UnmarshalBinary(inp []byte) error { r := bytes.NewReader(inp) - d := xdr.NewDecoder(r) - _, err := s.DecodeFrom(d, xdr.DecodeDefaultMaxDepth) + o := xdr.DefaultDecodeOptions + o.MaxInputLen = len(inp) + d := xdr.NewDecoderWithOptions(r, o) + _, err := s.DecodeFrom(d, o.MaxDepth) return err } @@ -20035,8 +20321,7 @@ var ( _ encoding.BinaryUnmarshaler = (*SurveyResponseBody)(nil) ) -// xdrType signals that this type is an type representing -// representing XDR values defined by this package. +// xdrType signals that this type represents XDR values defined by this package. func (s SurveyResponseBody) xdrType() {} var _ xdrType = (*SurveyResponseBody)(nil) @@ -20091,8 +20376,11 @@ func (s *TxAdvertVector) DecodeFrom(d *xdr.Decoder, maxDepth uint) (int, error) } (*s) = nil if l > 0 { + if il, ok := d.InputLen(); ok && uint(il) < uint(l) { + return n, fmt.Errorf("decoding Hash: length (%d) exceeds remaining input length (%d)", l, il) + } (*s) = make([]Hash, l) - for i := uint32(0); i < l; i++ { + for i := uint32(0); uint(i) < uint(l); i++ { nTmp, err = (*s)[i].DecodeFrom(d, maxDepth) n += nTmp if err != nil { @@ -20114,8 +20402,10 @@ func (s TxAdvertVector) MarshalBinary() ([]byte, error) { // UnmarshalBinary implements encoding.BinaryUnmarshaler. func (s *TxAdvertVector) UnmarshalBinary(inp []byte) error { r := bytes.NewReader(inp) - d := xdr.NewDecoder(r) - _, err := s.DecodeFrom(d, xdr.DecodeDefaultMaxDepth) + o := xdr.DefaultDecodeOptions + o.MaxInputLen = len(inp) + d := xdr.NewDecoderWithOptions(r, o) + _, err := s.DecodeFrom(d, o.MaxDepth) return err } @@ -20124,8 +20414,7 @@ var ( _ encoding.BinaryUnmarshaler = (*TxAdvertVector)(nil) ) -// xdrType signals that this type is an type representing -// representing XDR values defined by this package. +// xdrType signals that this type represents XDR values defined by this package. func (s TxAdvertVector) xdrType() {} var _ xdrType = (*TxAdvertVector)(nil) @@ -20178,8 +20467,10 @@ func (s FloodAdvert) MarshalBinary() ([]byte, error) { // UnmarshalBinary implements encoding.BinaryUnmarshaler. func (s *FloodAdvert) UnmarshalBinary(inp []byte) error { r := bytes.NewReader(inp) - d := xdr.NewDecoder(r) - _, err := s.DecodeFrom(d, xdr.DecodeDefaultMaxDepth) + o := xdr.DefaultDecodeOptions + o.MaxInputLen = len(inp) + d := xdr.NewDecoderWithOptions(r, o) + _, err := s.DecodeFrom(d, o.MaxDepth) return err } @@ -20188,8 +20479,7 @@ var ( _ encoding.BinaryUnmarshaler = (*FloodAdvert)(nil) ) -// xdrType signals that this type is an type representing -// representing XDR values defined by this package. +// xdrType signals that this type represents XDR values defined by this package. func (s FloodAdvert) xdrType() {} var _ xdrType = (*FloodAdvert)(nil) @@ -20244,8 +20534,11 @@ func (s *TxDemandVector) DecodeFrom(d *xdr.Decoder, maxDepth uint) (int, error) } (*s) = nil if l > 0 { + if il, ok := d.InputLen(); ok && uint(il) < uint(l) { + return n, fmt.Errorf("decoding Hash: length (%d) exceeds remaining input length (%d)", l, il) + } (*s) = make([]Hash, l) - for i := uint32(0); i < l; i++ { + for i := uint32(0); uint(i) < uint(l); i++ { nTmp, err = (*s)[i].DecodeFrom(d, maxDepth) n += nTmp if err != nil { @@ -20267,8 +20560,10 @@ func (s TxDemandVector) MarshalBinary() ([]byte, error) { // UnmarshalBinary implements encoding.BinaryUnmarshaler. func (s *TxDemandVector) UnmarshalBinary(inp []byte) error { r := bytes.NewReader(inp) - d := xdr.NewDecoder(r) - _, err := s.DecodeFrom(d, xdr.DecodeDefaultMaxDepth) + o := xdr.DefaultDecodeOptions + o.MaxInputLen = len(inp) + d := xdr.NewDecoderWithOptions(r, o) + _, err := s.DecodeFrom(d, o.MaxDepth) return err } @@ -20277,8 +20572,7 @@ var ( _ encoding.BinaryUnmarshaler = (*TxDemandVector)(nil) ) -// xdrType signals that this type is an type representing -// representing XDR values defined by this package. +// xdrType signals that this type represents XDR values defined by this package. func (s TxDemandVector) xdrType() {} var _ xdrType = (*TxDemandVector)(nil) @@ -20331,8 +20625,10 @@ func (s FloodDemand) MarshalBinary() ([]byte, error) { // UnmarshalBinary implements encoding.BinaryUnmarshaler. func (s *FloodDemand) UnmarshalBinary(inp []byte) error { r := bytes.NewReader(inp) - d := xdr.NewDecoder(r) - _, err := s.DecodeFrom(d, xdr.DecodeDefaultMaxDepth) + o := xdr.DefaultDecodeOptions + o.MaxInputLen = len(inp) + d := xdr.NewDecoderWithOptions(r, o) + _, err := s.DecodeFrom(d, o.MaxDepth) return err } @@ -20341,8 +20637,7 @@ var ( _ encoding.BinaryUnmarshaler = (*FloodDemand)(nil) ) -// xdrType signals that this type is an type representing -// representing XDR values defined by this package. +// xdrType signals that this type represents XDR values defined by this package. func (s FloodDemand) xdrType() {} var _ xdrType = (*FloodDemand)(nil) @@ -21272,8 +21567,11 @@ func (u *StellarMessage) DecodeFrom(d *xdr.Decoder, maxDepth uint) (int, error) } (*u.Peers) = nil if l > 0 { + if il, ok := d.InputLen(); ok && uint(il) < uint(l) { + return n, fmt.Errorf("decoding PeerAddress: length (%d) exceeds remaining input length (%d)", l, il) + } (*u.Peers) = make([]PeerAddress, l) - for i := uint32(0); i < l; i++ { + for i := uint32(0); uint(i) < uint(l); i++ { nTmp, err = (*u.Peers)[i].DecodeFrom(d, maxDepth) n += nTmp if err != nil { @@ -21409,8 +21707,10 @@ func (s StellarMessage) MarshalBinary() ([]byte, error) { // UnmarshalBinary implements encoding.BinaryUnmarshaler. func (s *StellarMessage) UnmarshalBinary(inp []byte) error { r := bytes.NewReader(inp) - d := xdr.NewDecoder(r) - _, err := s.DecodeFrom(d, xdr.DecodeDefaultMaxDepth) + o := xdr.DefaultDecodeOptions + o.MaxInputLen = len(inp) + d := xdr.NewDecoderWithOptions(r, o) + _, err := s.DecodeFrom(d, o.MaxDepth) return err } @@ -21419,8 +21719,7 @@ var ( _ encoding.BinaryUnmarshaler = (*StellarMessage)(nil) ) -// xdrType signals that this type is an type representing -// representing XDR values defined by this package. +// xdrType signals that this type represents XDR values defined by this package. func (s StellarMessage) xdrType() {} var _ xdrType = (*StellarMessage)(nil) @@ -21493,8 +21792,10 @@ func (s AuthenticatedMessageV0) MarshalBinary() ([]byte, error) { // UnmarshalBinary implements encoding.BinaryUnmarshaler. func (s *AuthenticatedMessageV0) UnmarshalBinary(inp []byte) error { r := bytes.NewReader(inp) - d := xdr.NewDecoder(r) - _, err := s.DecodeFrom(d, xdr.DecodeDefaultMaxDepth) + o := xdr.DefaultDecodeOptions + o.MaxInputLen = len(inp) + d := xdr.NewDecoderWithOptions(r, o) + _, err := s.DecodeFrom(d, o.MaxDepth) return err } @@ -21503,8 +21804,7 @@ var ( _ encoding.BinaryUnmarshaler = (*AuthenticatedMessageV0)(nil) ) -// xdrType signals that this type is an type representing -// representing XDR values defined by this package. +// xdrType signals that this type represents XDR values defined by this package. func (s AuthenticatedMessageV0) xdrType() {} var _ xdrType = (*AuthenticatedMessageV0)(nil) @@ -21637,8 +21937,10 @@ func (s AuthenticatedMessage) MarshalBinary() ([]byte, error) { // UnmarshalBinary implements encoding.BinaryUnmarshaler. func (s *AuthenticatedMessage) UnmarshalBinary(inp []byte) error { r := bytes.NewReader(inp) - d := xdr.NewDecoder(r) - _, err := s.DecodeFrom(d, xdr.DecodeDefaultMaxDepth) + o := xdr.DefaultDecodeOptions + o.MaxInputLen = len(inp) + d := xdr.NewDecoderWithOptions(r, o) + _, err := s.DecodeFrom(d, o.MaxDepth) return err } @@ -21647,8 +21949,7 @@ var ( _ encoding.BinaryUnmarshaler = (*AuthenticatedMessage)(nil) ) -// xdrType signals that this type is an type representing -// representing XDR values defined by this package. +// xdrType signals that this type represents XDR values defined by this package. func (s AuthenticatedMessage) xdrType() {} var _ xdrType = (*AuthenticatedMessage)(nil) @@ -21781,8 +22082,10 @@ func (s LiquidityPoolParameters) MarshalBinary() ([]byte, error) { // UnmarshalBinary implements encoding.BinaryUnmarshaler. func (s *LiquidityPoolParameters) UnmarshalBinary(inp []byte) error { r := bytes.NewReader(inp) - d := xdr.NewDecoder(r) - _, err := s.DecodeFrom(d, xdr.DecodeDefaultMaxDepth) + o := xdr.DefaultDecodeOptions + o.MaxInputLen = len(inp) + d := xdr.NewDecoderWithOptions(r, o) + _, err := s.DecodeFrom(d, o.MaxDepth) return err } @@ -21791,8 +22094,7 @@ var ( _ encoding.BinaryUnmarshaler = (*LiquidityPoolParameters)(nil) ) -// xdrType signals that this type is an type representing -// representing XDR values defined by this package. +// xdrType signals that this type represents XDR values defined by this package. func (s LiquidityPoolParameters) xdrType() {} var _ xdrType = (*LiquidityPoolParameters)(nil) @@ -21855,8 +22157,10 @@ func (s MuxedAccountMed25519) MarshalBinary() ([]byte, error) { // UnmarshalBinary implements encoding.BinaryUnmarshaler. func (s *MuxedAccountMed25519) UnmarshalBinary(inp []byte) error { r := bytes.NewReader(inp) - d := xdr.NewDecoder(r) - _, err := s.DecodeFrom(d, xdr.DecodeDefaultMaxDepth) + o := xdr.DefaultDecodeOptions + o.MaxInputLen = len(inp) + d := xdr.NewDecoderWithOptions(r, o) + _, err := s.DecodeFrom(d, o.MaxDepth) return err } @@ -21865,8 +22169,7 @@ var ( _ encoding.BinaryUnmarshaler = (*MuxedAccountMed25519)(nil) ) -// xdrType signals that this type is an type representing -// representing XDR values defined by this package. +// xdrType signals that this type represents XDR values defined by this package. func (s MuxedAccountMed25519) xdrType() {} var _ xdrType = (*MuxedAccountMed25519)(nil) @@ -22048,8 +22351,10 @@ func (s MuxedAccount) MarshalBinary() ([]byte, error) { // UnmarshalBinary implements encoding.BinaryUnmarshaler. func (s *MuxedAccount) UnmarshalBinary(inp []byte) error { r := bytes.NewReader(inp) - d := xdr.NewDecoder(r) - _, err := s.DecodeFrom(d, xdr.DecodeDefaultMaxDepth) + o := xdr.DefaultDecodeOptions + o.MaxInputLen = len(inp) + d := xdr.NewDecoderWithOptions(r, o) + _, err := s.DecodeFrom(d, o.MaxDepth) return err } @@ -22058,8 +22363,7 @@ var ( _ encoding.BinaryUnmarshaler = (*MuxedAccount)(nil) ) -// xdrType signals that this type is an type representing -// representing XDR values defined by this package. +// xdrType signals that this type represents XDR values defined by this package. func (s MuxedAccount) xdrType() {} var _ xdrType = (*MuxedAccount)(nil) @@ -22122,8 +22426,10 @@ func (s DecoratedSignature) MarshalBinary() ([]byte, error) { // UnmarshalBinary implements encoding.BinaryUnmarshaler. func (s *DecoratedSignature) UnmarshalBinary(inp []byte) error { r := bytes.NewReader(inp) - d := xdr.NewDecoder(r) - _, err := s.DecodeFrom(d, xdr.DecodeDefaultMaxDepth) + o := xdr.DefaultDecodeOptions + o.MaxInputLen = len(inp) + d := xdr.NewDecoderWithOptions(r, o) + _, err := s.DecodeFrom(d, o.MaxDepth) return err } @@ -22132,8 +22438,7 @@ var ( _ encoding.BinaryUnmarshaler = (*DecoratedSignature)(nil) ) -// xdrType signals that this type is an type representing -// representing XDR values defined by this package. +// xdrType signals that this type represents XDR values defined by this package. func (s DecoratedSignature) xdrType() {} var _ xdrType = (*DecoratedSignature)(nil) @@ -22284,8 +22589,10 @@ func (s OperationType) MarshalBinary() ([]byte, error) { // UnmarshalBinary implements encoding.BinaryUnmarshaler. func (s *OperationType) UnmarshalBinary(inp []byte) error { r := bytes.NewReader(inp) - d := xdr.NewDecoder(r) - _, err := s.DecodeFrom(d, xdr.DecodeDefaultMaxDepth) + o := xdr.DefaultDecodeOptions + o.MaxInputLen = len(inp) + d := xdr.NewDecoderWithOptions(r, o) + _, err := s.DecodeFrom(d, o.MaxDepth) return err } @@ -22294,8 +22601,7 @@ var ( _ encoding.BinaryUnmarshaler = (*OperationType)(nil) ) -// xdrType signals that this type is an type representing -// representing XDR values defined by this package. +// xdrType signals that this type represents XDR values defined by this package. func (s OperationType) xdrType() {} var _ xdrType = (*OperationType)(nil) @@ -22358,8 +22664,10 @@ func (s CreateAccountOp) MarshalBinary() ([]byte, error) { // UnmarshalBinary implements encoding.BinaryUnmarshaler. func (s *CreateAccountOp) UnmarshalBinary(inp []byte) error { r := bytes.NewReader(inp) - d := xdr.NewDecoder(r) - _, err := s.DecodeFrom(d, xdr.DecodeDefaultMaxDepth) + o := xdr.DefaultDecodeOptions + o.MaxInputLen = len(inp) + d := xdr.NewDecoderWithOptions(r, o) + _, err := s.DecodeFrom(d, o.MaxDepth) return err } @@ -22368,8 +22676,7 @@ var ( _ encoding.BinaryUnmarshaler = (*CreateAccountOp)(nil) ) -// xdrType signals that this type is an type representing -// representing XDR values defined by this package. +// xdrType signals that this type represents XDR values defined by this package. func (s CreateAccountOp) xdrType() {} var _ xdrType = (*CreateAccountOp)(nil) @@ -22442,8 +22749,10 @@ func (s PaymentOp) MarshalBinary() ([]byte, error) { // UnmarshalBinary implements encoding.BinaryUnmarshaler. func (s *PaymentOp) UnmarshalBinary(inp []byte) error { r := bytes.NewReader(inp) - d := xdr.NewDecoder(r) - _, err := s.DecodeFrom(d, xdr.DecodeDefaultMaxDepth) + o := xdr.DefaultDecodeOptions + o.MaxInputLen = len(inp) + d := xdr.NewDecoderWithOptions(r, o) + _, err := s.DecodeFrom(d, o.MaxDepth) return err } @@ -22452,8 +22761,7 @@ var ( _ encoding.BinaryUnmarshaler = (*PaymentOp)(nil) ) -// xdrType signals that this type is an type representing -// representing XDR values defined by this package. +// xdrType signals that this type represents XDR values defined by this package. func (s PaymentOp) xdrType() {} var _ xdrType = (*PaymentOp)(nil) @@ -22557,8 +22865,11 @@ func (s *PathPaymentStrictReceiveOp) DecodeFrom(d *xdr.Decoder, maxDepth uint) ( } s.Path = nil if l > 0 { + if il, ok := d.InputLen(); ok && uint(il) < uint(l) { + return n, fmt.Errorf("decoding Asset: length (%d) exceeds remaining input length (%d)", l, il) + } s.Path = make([]Asset, l) - for i := uint32(0); i < l; i++ { + for i := uint32(0); uint(i) < uint(l); i++ { nTmp, err = s.Path[i].DecodeFrom(d, maxDepth) n += nTmp if err != nil { @@ -22580,8 +22891,10 @@ func (s PathPaymentStrictReceiveOp) MarshalBinary() ([]byte, error) { // UnmarshalBinary implements encoding.BinaryUnmarshaler. func (s *PathPaymentStrictReceiveOp) UnmarshalBinary(inp []byte) error { r := bytes.NewReader(inp) - d := xdr.NewDecoder(r) - _, err := s.DecodeFrom(d, xdr.DecodeDefaultMaxDepth) + o := xdr.DefaultDecodeOptions + o.MaxInputLen = len(inp) + d := xdr.NewDecoderWithOptions(r, o) + _, err := s.DecodeFrom(d, o.MaxDepth) return err } @@ -22590,8 +22903,7 @@ var ( _ encoding.BinaryUnmarshaler = (*PathPaymentStrictReceiveOp)(nil) ) -// xdrType signals that this type is an type representing -// representing XDR values defined by this package. +// xdrType signals that this type represents XDR values defined by this package. func (s PathPaymentStrictReceiveOp) xdrType() {} var _ xdrType = (*PathPaymentStrictReceiveOp)(nil) @@ -22695,8 +23007,11 @@ func (s *PathPaymentStrictSendOp) DecodeFrom(d *xdr.Decoder, maxDepth uint) (int } s.Path = nil if l > 0 { + if il, ok := d.InputLen(); ok && uint(il) < uint(l) { + return n, fmt.Errorf("decoding Asset: length (%d) exceeds remaining input length (%d)", l, il) + } s.Path = make([]Asset, l) - for i := uint32(0); i < l; i++ { + for i := uint32(0); uint(i) < uint(l); i++ { nTmp, err = s.Path[i].DecodeFrom(d, maxDepth) n += nTmp if err != nil { @@ -22718,8 +23033,10 @@ func (s PathPaymentStrictSendOp) MarshalBinary() ([]byte, error) { // UnmarshalBinary implements encoding.BinaryUnmarshaler. func (s *PathPaymentStrictSendOp) UnmarshalBinary(inp []byte) error { r := bytes.NewReader(inp) - d := xdr.NewDecoder(r) - _, err := s.DecodeFrom(d, xdr.DecodeDefaultMaxDepth) + o := xdr.DefaultDecodeOptions + o.MaxInputLen = len(inp) + d := xdr.NewDecoderWithOptions(r, o) + _, err := s.DecodeFrom(d, o.MaxDepth) return err } @@ -22728,8 +23045,7 @@ var ( _ encoding.BinaryUnmarshaler = (*PathPaymentStrictSendOp)(nil) ) -// xdrType signals that this type is an type representing -// representing XDR values defined by this package. +// xdrType signals that this type represents XDR values defined by this package. func (s PathPaymentStrictSendOp) xdrType() {} var _ xdrType = (*PathPaymentStrictSendOp)(nil) @@ -22824,8 +23140,10 @@ func (s ManageSellOfferOp) MarshalBinary() ([]byte, error) { // UnmarshalBinary implements encoding.BinaryUnmarshaler. func (s *ManageSellOfferOp) UnmarshalBinary(inp []byte) error { r := bytes.NewReader(inp) - d := xdr.NewDecoder(r) - _, err := s.DecodeFrom(d, xdr.DecodeDefaultMaxDepth) + o := xdr.DefaultDecodeOptions + o.MaxInputLen = len(inp) + d := xdr.NewDecoderWithOptions(r, o) + _, err := s.DecodeFrom(d, o.MaxDepth) return err } @@ -22834,8 +23152,7 @@ var ( _ encoding.BinaryUnmarshaler = (*ManageSellOfferOp)(nil) ) -// xdrType signals that this type is an type representing -// representing XDR values defined by this package. +// xdrType signals that this type represents XDR values defined by this package. func (s ManageSellOfferOp) xdrType() {} var _ xdrType = (*ManageSellOfferOp)(nil) @@ -22931,8 +23248,10 @@ func (s ManageBuyOfferOp) MarshalBinary() ([]byte, error) { // UnmarshalBinary implements encoding.BinaryUnmarshaler. func (s *ManageBuyOfferOp) UnmarshalBinary(inp []byte) error { r := bytes.NewReader(inp) - d := xdr.NewDecoder(r) - _, err := s.DecodeFrom(d, xdr.DecodeDefaultMaxDepth) + o := xdr.DefaultDecodeOptions + o.MaxInputLen = len(inp) + d := xdr.NewDecoderWithOptions(r, o) + _, err := s.DecodeFrom(d, o.MaxDepth) return err } @@ -22941,8 +23260,7 @@ var ( _ encoding.BinaryUnmarshaler = (*ManageBuyOfferOp)(nil) ) -// xdrType signals that this type is an type representing -// representing XDR values defined by this package. +// xdrType signals that this type represents XDR values defined by this package. func (s ManageBuyOfferOp) xdrType() {} var _ xdrType = (*ManageBuyOfferOp)(nil) @@ -23025,8 +23343,10 @@ func (s CreatePassiveSellOfferOp) MarshalBinary() ([]byte, error) { // UnmarshalBinary implements encoding.BinaryUnmarshaler. func (s *CreatePassiveSellOfferOp) UnmarshalBinary(inp []byte) error { r := bytes.NewReader(inp) - d := xdr.NewDecoder(r) - _, err := s.DecodeFrom(d, xdr.DecodeDefaultMaxDepth) + o := xdr.DefaultDecodeOptions + o.MaxInputLen = len(inp) + d := xdr.NewDecoderWithOptions(r, o) + _, err := s.DecodeFrom(d, o.MaxDepth) return err } @@ -23035,8 +23355,7 @@ var ( _ encoding.BinaryUnmarshaler = (*CreatePassiveSellOfferOp)(nil) ) -// xdrType signals that this type is an type representing -// representing XDR values defined by this package. +// xdrType signals that this type represents XDR values defined by this package. func (s CreatePassiveSellOfferOp) xdrType() {} var _ xdrType = (*CreatePassiveSellOfferOp)(nil) @@ -23303,8 +23622,10 @@ func (s SetOptionsOp) MarshalBinary() ([]byte, error) { // UnmarshalBinary implements encoding.BinaryUnmarshaler. func (s *SetOptionsOp) UnmarshalBinary(inp []byte) error { r := bytes.NewReader(inp) - d := xdr.NewDecoder(r) - _, err := s.DecodeFrom(d, xdr.DecodeDefaultMaxDepth) + o := xdr.DefaultDecodeOptions + o.MaxInputLen = len(inp) + d := xdr.NewDecoderWithOptions(r, o) + _, err := s.DecodeFrom(d, o.MaxDepth) return err } @@ -23313,8 +23634,7 @@ var ( _ encoding.BinaryUnmarshaler = (*SetOptionsOp)(nil) ) -// xdrType signals that this type is an type representing -// representing XDR values defined by this package. +// xdrType signals that this type represents XDR values defined by this package. func (s SetOptionsOp) xdrType() {} var _ xdrType = (*SetOptionsOp)(nil) @@ -23559,8 +23879,10 @@ func (s ChangeTrustAsset) MarshalBinary() ([]byte, error) { // UnmarshalBinary implements encoding.BinaryUnmarshaler. func (s *ChangeTrustAsset) UnmarshalBinary(inp []byte) error { r := bytes.NewReader(inp) - d := xdr.NewDecoder(r) - _, err := s.DecodeFrom(d, xdr.DecodeDefaultMaxDepth) + o := xdr.DefaultDecodeOptions + o.MaxInputLen = len(inp) + d := xdr.NewDecoderWithOptions(r, o) + _, err := s.DecodeFrom(d, o.MaxDepth) return err } @@ -23569,8 +23891,7 @@ var ( _ encoding.BinaryUnmarshaler = (*ChangeTrustAsset)(nil) ) -// xdrType signals that this type is an type representing -// representing XDR values defined by this package. +// xdrType signals that this type represents XDR values defined by this package. func (s ChangeTrustAsset) xdrType() {} var _ xdrType = (*ChangeTrustAsset)(nil) @@ -23635,8 +23956,10 @@ func (s ChangeTrustOp) MarshalBinary() ([]byte, error) { // UnmarshalBinary implements encoding.BinaryUnmarshaler. func (s *ChangeTrustOp) UnmarshalBinary(inp []byte) error { r := bytes.NewReader(inp) - d := xdr.NewDecoder(r) - _, err := s.DecodeFrom(d, xdr.DecodeDefaultMaxDepth) + o := xdr.DefaultDecodeOptions + o.MaxInputLen = len(inp) + d := xdr.NewDecoderWithOptions(r, o) + _, err := s.DecodeFrom(d, o.MaxDepth) return err } @@ -23645,8 +23968,7 @@ var ( _ encoding.BinaryUnmarshaler = (*ChangeTrustOp)(nil) ) -// xdrType signals that this type is an type representing -// representing XDR values defined by this package. +// xdrType signals that this type represents XDR values defined by this package. func (s ChangeTrustOp) xdrType() {} var _ xdrType = (*ChangeTrustOp)(nil) @@ -23721,8 +24043,10 @@ func (s AllowTrustOp) MarshalBinary() ([]byte, error) { // UnmarshalBinary implements encoding.BinaryUnmarshaler. func (s *AllowTrustOp) UnmarshalBinary(inp []byte) error { r := bytes.NewReader(inp) - d := xdr.NewDecoder(r) - _, err := s.DecodeFrom(d, xdr.DecodeDefaultMaxDepth) + o := xdr.DefaultDecodeOptions + o.MaxInputLen = len(inp) + d := xdr.NewDecoderWithOptions(r, o) + _, err := s.DecodeFrom(d, o.MaxDepth) return err } @@ -23731,8 +24055,7 @@ var ( _ encoding.BinaryUnmarshaler = (*AllowTrustOp)(nil) ) -// xdrType signals that this type is an type representing -// representing XDR values defined by this package. +// xdrType signals that this type represents XDR values defined by this package. func (s AllowTrustOp) xdrType() {} var _ xdrType = (*AllowTrustOp)(nil) @@ -23810,8 +24133,10 @@ func (s ManageDataOp) MarshalBinary() ([]byte, error) { // UnmarshalBinary implements encoding.BinaryUnmarshaler. func (s *ManageDataOp) UnmarshalBinary(inp []byte) error { r := bytes.NewReader(inp) - d := xdr.NewDecoder(r) - _, err := s.DecodeFrom(d, xdr.DecodeDefaultMaxDepth) + o := xdr.DefaultDecodeOptions + o.MaxInputLen = len(inp) + d := xdr.NewDecoderWithOptions(r, o) + _, err := s.DecodeFrom(d, o.MaxDepth) return err } @@ -23820,8 +24145,7 @@ var ( _ encoding.BinaryUnmarshaler = (*ManageDataOp)(nil) ) -// xdrType signals that this type is an type representing -// representing XDR values defined by this package. +// xdrType signals that this type represents XDR values defined by this package. func (s ManageDataOp) xdrType() {} var _ xdrType = (*ManageDataOp)(nil) @@ -23874,8 +24198,10 @@ func (s BumpSequenceOp) MarshalBinary() ([]byte, error) { // UnmarshalBinary implements encoding.BinaryUnmarshaler. func (s *BumpSequenceOp) UnmarshalBinary(inp []byte) error { r := bytes.NewReader(inp) - d := xdr.NewDecoder(r) - _, err := s.DecodeFrom(d, xdr.DecodeDefaultMaxDepth) + o := xdr.DefaultDecodeOptions + o.MaxInputLen = len(inp) + d := xdr.NewDecoderWithOptions(r, o) + _, err := s.DecodeFrom(d, o.MaxDepth) return err } @@ -23884,8 +24210,7 @@ var ( _ encoding.BinaryUnmarshaler = (*BumpSequenceOp)(nil) ) -// xdrType signals that this type is an type representing -// representing XDR values defined by this package. +// xdrType signals that this type represents XDR values defined by this package. func (s BumpSequenceOp) xdrType() {} var _ xdrType = (*BumpSequenceOp)(nil) @@ -23955,8 +24280,11 @@ func (s *CreateClaimableBalanceOp) DecodeFrom(d *xdr.Decoder, maxDepth uint) (in } s.Claimants = nil if l > 0 { + if il, ok := d.InputLen(); ok && uint(il) < uint(l) { + return n, fmt.Errorf("decoding Claimant: length (%d) exceeds remaining input length (%d)", l, il) + } s.Claimants = make([]Claimant, l) - for i := uint32(0); i < l; i++ { + for i := uint32(0); uint(i) < uint(l); i++ { nTmp, err = s.Claimants[i].DecodeFrom(d, maxDepth) n += nTmp if err != nil { @@ -23978,8 +24306,10 @@ func (s CreateClaimableBalanceOp) MarshalBinary() ([]byte, error) { // UnmarshalBinary implements encoding.BinaryUnmarshaler. func (s *CreateClaimableBalanceOp) UnmarshalBinary(inp []byte) error { r := bytes.NewReader(inp) - d := xdr.NewDecoder(r) - _, err := s.DecodeFrom(d, xdr.DecodeDefaultMaxDepth) + o := xdr.DefaultDecodeOptions + o.MaxInputLen = len(inp) + d := xdr.NewDecoderWithOptions(r, o) + _, err := s.DecodeFrom(d, o.MaxDepth) return err } @@ -23988,8 +24318,7 @@ var ( _ encoding.BinaryUnmarshaler = (*CreateClaimableBalanceOp)(nil) ) -// xdrType signals that this type is an type representing -// representing XDR values defined by this package. +// xdrType signals that this type represents XDR values defined by this package. func (s CreateClaimableBalanceOp) xdrType() {} var _ xdrType = (*CreateClaimableBalanceOp)(nil) @@ -24042,8 +24371,10 @@ func (s ClaimClaimableBalanceOp) MarshalBinary() ([]byte, error) { // UnmarshalBinary implements encoding.BinaryUnmarshaler. func (s *ClaimClaimableBalanceOp) UnmarshalBinary(inp []byte) error { r := bytes.NewReader(inp) - d := xdr.NewDecoder(r) - _, err := s.DecodeFrom(d, xdr.DecodeDefaultMaxDepth) + o := xdr.DefaultDecodeOptions + o.MaxInputLen = len(inp) + d := xdr.NewDecoderWithOptions(r, o) + _, err := s.DecodeFrom(d, o.MaxDepth) return err } @@ -24052,8 +24383,7 @@ var ( _ encoding.BinaryUnmarshaler = (*ClaimClaimableBalanceOp)(nil) ) -// xdrType signals that this type is an type representing -// representing XDR values defined by this package. +// xdrType signals that this type represents XDR values defined by this package. func (s ClaimClaimableBalanceOp) xdrType() {} var _ xdrType = (*ClaimClaimableBalanceOp)(nil) @@ -24106,8 +24436,10 @@ func (s BeginSponsoringFutureReservesOp) MarshalBinary() ([]byte, error) { // UnmarshalBinary implements encoding.BinaryUnmarshaler. func (s *BeginSponsoringFutureReservesOp) UnmarshalBinary(inp []byte) error { r := bytes.NewReader(inp) - d := xdr.NewDecoder(r) - _, err := s.DecodeFrom(d, xdr.DecodeDefaultMaxDepth) + o := xdr.DefaultDecodeOptions + o.MaxInputLen = len(inp) + d := xdr.NewDecoderWithOptions(r, o) + _, err := s.DecodeFrom(d, o.MaxDepth) return err } @@ -24116,8 +24448,7 @@ var ( _ encoding.BinaryUnmarshaler = (*BeginSponsoringFutureReservesOp)(nil) ) -// xdrType signals that this type is an type representing -// representing XDR values defined by this package. +// xdrType signals that this type represents XDR values defined by this package. func (s BeginSponsoringFutureReservesOp) xdrType() {} var _ xdrType = (*BeginSponsoringFutureReservesOp)(nil) @@ -24193,8 +24524,10 @@ func (s RevokeSponsorshipType) MarshalBinary() ([]byte, error) { // UnmarshalBinary implements encoding.BinaryUnmarshaler. func (s *RevokeSponsorshipType) UnmarshalBinary(inp []byte) error { r := bytes.NewReader(inp) - d := xdr.NewDecoder(r) - _, err := s.DecodeFrom(d, xdr.DecodeDefaultMaxDepth) + o := xdr.DefaultDecodeOptions + o.MaxInputLen = len(inp) + d := xdr.NewDecoderWithOptions(r, o) + _, err := s.DecodeFrom(d, o.MaxDepth) return err } @@ -24203,8 +24536,7 @@ var ( _ encoding.BinaryUnmarshaler = (*RevokeSponsorshipType)(nil) ) -// xdrType signals that this type is an type representing -// representing XDR values defined by this package. +// xdrType signals that this type represents XDR values defined by this package. func (s RevokeSponsorshipType) xdrType() {} var _ xdrType = (*RevokeSponsorshipType)(nil) @@ -24267,8 +24599,10 @@ func (s RevokeSponsorshipOpSigner) MarshalBinary() ([]byte, error) { // UnmarshalBinary implements encoding.BinaryUnmarshaler. func (s *RevokeSponsorshipOpSigner) UnmarshalBinary(inp []byte) error { r := bytes.NewReader(inp) - d := xdr.NewDecoder(r) - _, err := s.DecodeFrom(d, xdr.DecodeDefaultMaxDepth) + o := xdr.DefaultDecodeOptions + o.MaxInputLen = len(inp) + d := xdr.NewDecoderWithOptions(r, o) + _, err := s.DecodeFrom(d, o.MaxDepth) return err } @@ -24277,8 +24611,7 @@ var ( _ encoding.BinaryUnmarshaler = (*RevokeSponsorshipOpSigner)(nil) ) -// xdrType signals that this type is an type representing -// representing XDR values defined by this package. +// xdrType signals that this type represents XDR values defined by this package. func (s RevokeSponsorshipOpSigner) xdrType() {} var _ xdrType = (*RevokeSponsorshipOpSigner)(nil) @@ -24460,8 +24793,10 @@ func (s RevokeSponsorshipOp) MarshalBinary() ([]byte, error) { // UnmarshalBinary implements encoding.BinaryUnmarshaler. func (s *RevokeSponsorshipOp) UnmarshalBinary(inp []byte) error { r := bytes.NewReader(inp) - d := xdr.NewDecoder(r) - _, err := s.DecodeFrom(d, xdr.DecodeDefaultMaxDepth) + o := xdr.DefaultDecodeOptions + o.MaxInputLen = len(inp) + d := xdr.NewDecoderWithOptions(r, o) + _, err := s.DecodeFrom(d, o.MaxDepth) return err } @@ -24470,8 +24805,7 @@ var ( _ encoding.BinaryUnmarshaler = (*RevokeSponsorshipOp)(nil) ) -// xdrType signals that this type is an type representing -// representing XDR values defined by this package. +// xdrType signals that this type represents XDR values defined by this package. func (s RevokeSponsorshipOp) xdrType() {} var _ xdrType = (*RevokeSponsorshipOp)(nil) @@ -24544,8 +24878,10 @@ func (s ClawbackOp) MarshalBinary() ([]byte, error) { // UnmarshalBinary implements encoding.BinaryUnmarshaler. func (s *ClawbackOp) UnmarshalBinary(inp []byte) error { r := bytes.NewReader(inp) - d := xdr.NewDecoder(r) - _, err := s.DecodeFrom(d, xdr.DecodeDefaultMaxDepth) + o := xdr.DefaultDecodeOptions + o.MaxInputLen = len(inp) + d := xdr.NewDecoderWithOptions(r, o) + _, err := s.DecodeFrom(d, o.MaxDepth) return err } @@ -24554,8 +24890,7 @@ var ( _ encoding.BinaryUnmarshaler = (*ClawbackOp)(nil) ) -// xdrType signals that this type is an type representing -// representing XDR values defined by this package. +// xdrType signals that this type represents XDR values defined by this package. func (s ClawbackOp) xdrType() {} var _ xdrType = (*ClawbackOp)(nil) @@ -24608,8 +24943,10 @@ func (s ClawbackClaimableBalanceOp) MarshalBinary() ([]byte, error) { // UnmarshalBinary implements encoding.BinaryUnmarshaler. func (s *ClawbackClaimableBalanceOp) UnmarshalBinary(inp []byte) error { r := bytes.NewReader(inp) - d := xdr.NewDecoder(r) - _, err := s.DecodeFrom(d, xdr.DecodeDefaultMaxDepth) + o := xdr.DefaultDecodeOptions + o.MaxInputLen = len(inp) + d := xdr.NewDecoderWithOptions(r, o) + _, err := s.DecodeFrom(d, o.MaxDepth) return err } @@ -24618,8 +24955,7 @@ var ( _ encoding.BinaryUnmarshaler = (*ClawbackClaimableBalanceOp)(nil) ) -// xdrType signals that this type is an type representing -// representing XDR values defined by this package. +// xdrType signals that this type represents XDR values defined by this package. func (s ClawbackClaimableBalanceOp) xdrType() {} var _ xdrType = (*ClawbackClaimableBalanceOp)(nil) @@ -24703,8 +25039,10 @@ func (s SetTrustLineFlagsOp) MarshalBinary() ([]byte, error) { // UnmarshalBinary implements encoding.BinaryUnmarshaler. func (s *SetTrustLineFlagsOp) UnmarshalBinary(inp []byte) error { r := bytes.NewReader(inp) - d := xdr.NewDecoder(r) - _, err := s.DecodeFrom(d, xdr.DecodeDefaultMaxDepth) + o := xdr.DefaultDecodeOptions + o.MaxInputLen = len(inp) + d := xdr.NewDecoderWithOptions(r, o) + _, err := s.DecodeFrom(d, o.MaxDepth) return err } @@ -24713,8 +25051,7 @@ var ( _ encoding.BinaryUnmarshaler = (*SetTrustLineFlagsOp)(nil) ) -// xdrType signals that this type is an type representing -// representing XDR values defined by this package. +// xdrType signals that this type represents XDR values defined by this package. func (s SetTrustLineFlagsOp) xdrType() {} var _ xdrType = (*SetTrustLineFlagsOp)(nil) @@ -24812,8 +25149,10 @@ func (s LiquidityPoolDepositOp) MarshalBinary() ([]byte, error) { // UnmarshalBinary implements encoding.BinaryUnmarshaler. func (s *LiquidityPoolDepositOp) UnmarshalBinary(inp []byte) error { r := bytes.NewReader(inp) - d := xdr.NewDecoder(r) - _, err := s.DecodeFrom(d, xdr.DecodeDefaultMaxDepth) + o := xdr.DefaultDecodeOptions + o.MaxInputLen = len(inp) + d := xdr.NewDecoderWithOptions(r, o) + _, err := s.DecodeFrom(d, o.MaxDepth) return err } @@ -24822,8 +25161,7 @@ var ( _ encoding.BinaryUnmarshaler = (*LiquidityPoolDepositOp)(nil) ) -// xdrType signals that this type is an type representing -// representing XDR values defined by this package. +// xdrType signals that this type represents XDR values defined by this package. func (s LiquidityPoolDepositOp) xdrType() {} var _ xdrType = (*LiquidityPoolDepositOp)(nil) @@ -24906,8 +25244,10 @@ func (s LiquidityPoolWithdrawOp) MarshalBinary() ([]byte, error) { // UnmarshalBinary implements encoding.BinaryUnmarshaler. func (s *LiquidityPoolWithdrawOp) UnmarshalBinary(inp []byte) error { r := bytes.NewReader(inp) - d := xdr.NewDecoder(r) - _, err := s.DecodeFrom(d, xdr.DecodeDefaultMaxDepth) + o := xdr.DefaultDecodeOptions + o.MaxInputLen = len(inp) + d := xdr.NewDecoderWithOptions(r, o) + _, err := s.DecodeFrom(d, o.MaxDepth) return err } @@ -24916,8 +25256,7 @@ var ( _ encoding.BinaryUnmarshaler = (*LiquidityPoolWithdrawOp)(nil) ) -// xdrType signals that this type is an type representing -// representing XDR values defined by this package. +// xdrType signals that this type represents XDR values defined by this package. func (s LiquidityPoolWithdrawOp) xdrType() {} var _ xdrType = (*LiquidityPoolWithdrawOp)(nil) @@ -24996,8 +25335,10 @@ func (s HostFunctionType) MarshalBinary() ([]byte, error) { // UnmarshalBinary implements encoding.BinaryUnmarshaler. func (s *HostFunctionType) UnmarshalBinary(inp []byte) error { r := bytes.NewReader(inp) - d := xdr.NewDecoder(r) - _, err := s.DecodeFrom(d, xdr.DecodeDefaultMaxDepth) + o := xdr.DefaultDecodeOptions + o.MaxInputLen = len(inp) + d := xdr.NewDecoderWithOptions(r, o) + _, err := s.DecodeFrom(d, o.MaxDepth) return err } @@ -25006,8 +25347,7 @@ var ( _ encoding.BinaryUnmarshaler = (*HostFunctionType)(nil) ) -// xdrType signals that this type is an type representing -// representing XDR values defined by this package. +// xdrType signals that this type represents XDR values defined by this package. func (s HostFunctionType) xdrType() {} var _ xdrType = (*HostFunctionType)(nil) @@ -25083,8 +25423,10 @@ func (s ContractIdPreimageType) MarshalBinary() ([]byte, error) { // UnmarshalBinary implements encoding.BinaryUnmarshaler. func (s *ContractIdPreimageType) UnmarshalBinary(inp []byte) error { r := bytes.NewReader(inp) - d := xdr.NewDecoder(r) - _, err := s.DecodeFrom(d, xdr.DecodeDefaultMaxDepth) + o := xdr.DefaultDecodeOptions + o.MaxInputLen = len(inp) + d := xdr.NewDecoderWithOptions(r, o) + _, err := s.DecodeFrom(d, o.MaxDepth) return err } @@ -25093,8 +25435,7 @@ var ( _ encoding.BinaryUnmarshaler = (*ContractIdPreimageType)(nil) ) -// xdrType signals that this type is an type representing -// representing XDR values defined by this package. +// xdrType signals that this type represents XDR values defined by this package. func (s ContractIdPreimageType) xdrType() {} var _ xdrType = (*ContractIdPreimageType)(nil) @@ -25157,8 +25498,10 @@ func (s ContractIdPreimageFromAddress) MarshalBinary() ([]byte, error) { // UnmarshalBinary implements encoding.BinaryUnmarshaler. func (s *ContractIdPreimageFromAddress) UnmarshalBinary(inp []byte) error { r := bytes.NewReader(inp) - d := xdr.NewDecoder(r) - _, err := s.DecodeFrom(d, xdr.DecodeDefaultMaxDepth) + o := xdr.DefaultDecodeOptions + o.MaxInputLen = len(inp) + d := xdr.NewDecoderWithOptions(r, o) + _, err := s.DecodeFrom(d, o.MaxDepth) return err } @@ -25167,8 +25510,7 @@ var ( _ encoding.BinaryUnmarshaler = (*ContractIdPreimageFromAddress)(nil) ) -// xdrType signals that this type is an type representing -// representing XDR values defined by this package. +// xdrType signals that this type represents XDR values defined by this package. func (s ContractIdPreimageFromAddress) xdrType() {} var _ xdrType = (*ContractIdPreimageFromAddress)(nil) @@ -25350,8 +25692,10 @@ func (s ContractIdPreimage) MarshalBinary() ([]byte, error) { // UnmarshalBinary implements encoding.BinaryUnmarshaler. func (s *ContractIdPreimage) UnmarshalBinary(inp []byte) error { r := bytes.NewReader(inp) - d := xdr.NewDecoder(r) - _, err := s.DecodeFrom(d, xdr.DecodeDefaultMaxDepth) + o := xdr.DefaultDecodeOptions + o.MaxInputLen = len(inp) + d := xdr.NewDecoderWithOptions(r, o) + _, err := s.DecodeFrom(d, o.MaxDepth) return err } @@ -25360,8 +25704,7 @@ var ( _ encoding.BinaryUnmarshaler = (*ContractIdPreimage)(nil) ) -// xdrType signals that this type is an type representing -// representing XDR values defined by this package. +// xdrType signals that this type represents XDR values defined by this package. func (s ContractIdPreimage) xdrType() {} var _ xdrType = (*ContractIdPreimage)(nil) @@ -25424,8 +25767,10 @@ func (s CreateContractArgs) MarshalBinary() ([]byte, error) { // UnmarshalBinary implements encoding.BinaryUnmarshaler. func (s *CreateContractArgs) UnmarshalBinary(inp []byte) error { r := bytes.NewReader(inp) - d := xdr.NewDecoder(r) - _, err := s.DecodeFrom(d, xdr.DecodeDefaultMaxDepth) + o := xdr.DefaultDecodeOptions + o.MaxInputLen = len(inp) + d := xdr.NewDecoderWithOptions(r, o) + _, err := s.DecodeFrom(d, o.MaxDepth) return err } @@ -25434,8 +25779,7 @@ var ( _ encoding.BinaryUnmarshaler = (*CreateContractArgs)(nil) ) -// xdrType signals that this type is an type representing -// representing XDR values defined by this package. +// xdrType signals that this type represents XDR values defined by this package. func (s CreateContractArgs) xdrType() {} var _ xdrType = (*CreateContractArgs)(nil) @@ -25501,8 +25845,11 @@ func (s *InvokeContractArgs) DecodeFrom(d *xdr.Decoder, maxDepth uint) (int, err } s.Args = nil if l > 0 { + if il, ok := d.InputLen(); ok && uint(il) < uint(l) { + return n, fmt.Errorf("decoding ScVal: length (%d) exceeds remaining input length (%d)", l, il) + } s.Args = make([]ScVal, l) - for i := uint32(0); i < l; i++ { + for i := uint32(0); uint(i) < uint(l); i++ { nTmp, err = s.Args[i].DecodeFrom(d, maxDepth) n += nTmp if err != nil { @@ -25524,8 +25871,10 @@ func (s InvokeContractArgs) MarshalBinary() ([]byte, error) { // UnmarshalBinary implements encoding.BinaryUnmarshaler. func (s *InvokeContractArgs) UnmarshalBinary(inp []byte) error { r := bytes.NewReader(inp) - d := xdr.NewDecoder(r) - _, err := s.DecodeFrom(d, xdr.DecodeDefaultMaxDepth) + o := xdr.DefaultDecodeOptions + o.MaxInputLen = len(inp) + d := xdr.NewDecoderWithOptions(r, o) + _, err := s.DecodeFrom(d, o.MaxDepth) return err } @@ -25534,8 +25883,7 @@ var ( _ encoding.BinaryUnmarshaler = (*InvokeContractArgs)(nil) ) -// xdrType signals that this type is an type representing -// representing XDR values defined by this package. +// xdrType signals that this type represents XDR values defined by this package. func (s InvokeContractArgs) xdrType() {} var _ xdrType = (*InvokeContractArgs)(nil) @@ -25763,8 +26111,10 @@ func (s HostFunction) MarshalBinary() ([]byte, error) { // UnmarshalBinary implements encoding.BinaryUnmarshaler. func (s *HostFunction) UnmarshalBinary(inp []byte) error { r := bytes.NewReader(inp) - d := xdr.NewDecoder(r) - _, err := s.DecodeFrom(d, xdr.DecodeDefaultMaxDepth) + o := xdr.DefaultDecodeOptions + o.MaxInputLen = len(inp) + d := xdr.NewDecoderWithOptions(r, o) + _, err := s.DecodeFrom(d, o.MaxDepth) return err } @@ -25773,8 +26123,7 @@ var ( _ encoding.BinaryUnmarshaler = (*HostFunction)(nil) ) -// xdrType signals that this type is an type representing -// representing XDR values defined by this package. +// xdrType signals that this type represents XDR values defined by this package. func (s HostFunction) xdrType() {} var _ xdrType = (*HostFunction)(nil) @@ -25850,8 +26199,10 @@ func (s SorobanAuthorizedFunctionType) MarshalBinary() ([]byte, error) { // UnmarshalBinary implements encoding.BinaryUnmarshaler. func (s *SorobanAuthorizedFunctionType) UnmarshalBinary(inp []byte) error { r := bytes.NewReader(inp) - d := xdr.NewDecoder(r) - _, err := s.DecodeFrom(d, xdr.DecodeDefaultMaxDepth) + o := xdr.DefaultDecodeOptions + o.MaxInputLen = len(inp) + d := xdr.NewDecoderWithOptions(r, o) + _, err := s.DecodeFrom(d, o.MaxDepth) return err } @@ -25860,8 +26211,7 @@ var ( _ encoding.BinaryUnmarshaler = (*SorobanAuthorizedFunctionType)(nil) ) -// xdrType signals that this type is an type representing -// representing XDR values defined by this package. +// xdrType signals that this type represents XDR values defined by this package. func (s SorobanAuthorizedFunctionType) xdrType() {} var _ xdrType = (*SorobanAuthorizedFunctionType)(nil) @@ -26039,8 +26389,10 @@ func (s SorobanAuthorizedFunction) MarshalBinary() ([]byte, error) { // UnmarshalBinary implements encoding.BinaryUnmarshaler. func (s *SorobanAuthorizedFunction) UnmarshalBinary(inp []byte) error { r := bytes.NewReader(inp) - d := xdr.NewDecoder(r) - _, err := s.DecodeFrom(d, xdr.DecodeDefaultMaxDepth) + o := xdr.DefaultDecodeOptions + o.MaxInputLen = len(inp) + d := xdr.NewDecoderWithOptions(r, o) + _, err := s.DecodeFrom(d, o.MaxDepth) return err } @@ -26049,8 +26401,7 @@ var ( _ encoding.BinaryUnmarshaler = (*SorobanAuthorizedFunction)(nil) ) -// xdrType signals that this type is an type representing -// representing XDR values defined by this package. +// xdrType signals that this type represents XDR values defined by this package. func (s SorobanAuthorizedFunction) xdrType() {} var _ xdrType = (*SorobanAuthorizedFunction)(nil) @@ -26107,8 +26458,11 @@ func (s *SorobanAuthorizedInvocation) DecodeFrom(d *xdr.Decoder, maxDepth uint) } s.SubInvocations = nil if l > 0 { + if il, ok := d.InputLen(); ok && uint(il) < uint(l) { + return n, fmt.Errorf("decoding SorobanAuthorizedInvocation: length (%d) exceeds remaining input length (%d)", l, il) + } s.SubInvocations = make([]SorobanAuthorizedInvocation, l) - for i := uint32(0); i < l; i++ { + for i := uint32(0); uint(i) < uint(l); i++ { nTmp, err = s.SubInvocations[i].DecodeFrom(d, maxDepth) n += nTmp if err != nil { @@ -26130,8 +26484,10 @@ func (s SorobanAuthorizedInvocation) MarshalBinary() ([]byte, error) { // UnmarshalBinary implements encoding.BinaryUnmarshaler. func (s *SorobanAuthorizedInvocation) UnmarshalBinary(inp []byte) error { r := bytes.NewReader(inp) - d := xdr.NewDecoder(r) - _, err := s.DecodeFrom(d, xdr.DecodeDefaultMaxDepth) + o := xdr.DefaultDecodeOptions + o.MaxInputLen = len(inp) + d := xdr.NewDecoderWithOptions(r, o) + _, err := s.DecodeFrom(d, o.MaxDepth) return err } @@ -26140,8 +26496,7 @@ var ( _ encoding.BinaryUnmarshaler = (*SorobanAuthorizedInvocation)(nil) ) -// xdrType signals that this type is an type representing -// representing XDR values defined by this package. +// xdrType signals that this type represents XDR values defined by this package. func (s SorobanAuthorizedInvocation) xdrType() {} var _ xdrType = (*SorobanAuthorizedInvocation)(nil) @@ -26224,8 +26579,10 @@ func (s SorobanAddressCredentials) MarshalBinary() ([]byte, error) { // UnmarshalBinary implements encoding.BinaryUnmarshaler. func (s *SorobanAddressCredentials) UnmarshalBinary(inp []byte) error { r := bytes.NewReader(inp) - d := xdr.NewDecoder(r) - _, err := s.DecodeFrom(d, xdr.DecodeDefaultMaxDepth) + o := xdr.DefaultDecodeOptions + o.MaxInputLen = len(inp) + d := xdr.NewDecoderWithOptions(r, o) + _, err := s.DecodeFrom(d, o.MaxDepth) return err } @@ -26234,8 +26591,7 @@ var ( _ encoding.BinaryUnmarshaler = (*SorobanAddressCredentials)(nil) ) -// xdrType signals that this type is an type representing -// representing XDR values defined by this package. +// xdrType signals that this type represents XDR values defined by this package. func (s SorobanAddressCredentials) xdrType() {} var _ xdrType = (*SorobanAddressCredentials)(nil) @@ -26311,8 +26667,10 @@ func (s SorobanCredentialsType) MarshalBinary() ([]byte, error) { // UnmarshalBinary implements encoding.BinaryUnmarshaler. func (s *SorobanCredentialsType) UnmarshalBinary(inp []byte) error { r := bytes.NewReader(inp) - d := xdr.NewDecoder(r) - _, err := s.DecodeFrom(d, xdr.DecodeDefaultMaxDepth) + o := xdr.DefaultDecodeOptions + o.MaxInputLen = len(inp) + d := xdr.NewDecoderWithOptions(r, o) + _, err := s.DecodeFrom(d, o.MaxDepth) return err } @@ -26321,8 +26679,7 @@ var ( _ encoding.BinaryUnmarshaler = (*SorobanCredentialsType)(nil) ) -// xdrType signals that this type is an type representing -// representing XDR values defined by this package. +// xdrType signals that this type represents XDR values defined by this package. func (s SorobanCredentialsType) xdrType() {} var _ xdrType = (*SorobanCredentialsType)(nil) @@ -26462,8 +26819,10 @@ func (s SorobanCredentials) MarshalBinary() ([]byte, error) { // UnmarshalBinary implements encoding.BinaryUnmarshaler. func (s *SorobanCredentials) UnmarshalBinary(inp []byte) error { r := bytes.NewReader(inp) - d := xdr.NewDecoder(r) - _, err := s.DecodeFrom(d, xdr.DecodeDefaultMaxDepth) + o := xdr.DefaultDecodeOptions + o.MaxInputLen = len(inp) + d := xdr.NewDecoderWithOptions(r, o) + _, err := s.DecodeFrom(d, o.MaxDepth) return err } @@ -26472,8 +26831,7 @@ var ( _ encoding.BinaryUnmarshaler = (*SorobanCredentials)(nil) ) -// xdrType signals that this type is an type representing -// representing XDR values defined by this package. +// xdrType signals that this type represents XDR values defined by this package. func (s SorobanCredentials) xdrType() {} var _ xdrType = (*SorobanCredentials)(nil) @@ -26536,8 +26894,10 @@ func (s SorobanAuthorizationEntry) MarshalBinary() ([]byte, error) { // UnmarshalBinary implements encoding.BinaryUnmarshaler. func (s *SorobanAuthorizationEntry) UnmarshalBinary(inp []byte) error { r := bytes.NewReader(inp) - d := xdr.NewDecoder(r) - _, err := s.DecodeFrom(d, xdr.DecodeDefaultMaxDepth) + o := xdr.DefaultDecodeOptions + o.MaxInputLen = len(inp) + d := xdr.NewDecoderWithOptions(r, o) + _, err := s.DecodeFrom(d, o.MaxDepth) return err } @@ -26546,8 +26906,7 @@ var ( _ encoding.BinaryUnmarshaler = (*SorobanAuthorizationEntry)(nil) ) -// xdrType signals that this type is an type representing -// representing XDR values defined by this package. +// xdrType signals that this type represents XDR values defined by this package. func (s SorobanAuthorizationEntry) xdrType() {} var _ xdrType = (*SorobanAuthorizationEntry)(nil) @@ -26606,8 +26965,11 @@ func (s *InvokeHostFunctionOp) DecodeFrom(d *xdr.Decoder, maxDepth uint) (int, e } s.Auth = nil if l > 0 { + if il, ok := d.InputLen(); ok && uint(il) < uint(l) { + return n, fmt.Errorf("decoding SorobanAuthorizationEntry: length (%d) exceeds remaining input length (%d)", l, il) + } s.Auth = make([]SorobanAuthorizationEntry, l) - for i := uint32(0); i < l; i++ { + for i := uint32(0); uint(i) < uint(l); i++ { nTmp, err = s.Auth[i].DecodeFrom(d, maxDepth) n += nTmp if err != nil { @@ -26629,8 +26991,10 @@ func (s InvokeHostFunctionOp) MarshalBinary() ([]byte, error) { // UnmarshalBinary implements encoding.BinaryUnmarshaler. func (s *InvokeHostFunctionOp) UnmarshalBinary(inp []byte) error { r := bytes.NewReader(inp) - d := xdr.NewDecoder(r) - _, err := s.DecodeFrom(d, xdr.DecodeDefaultMaxDepth) + o := xdr.DefaultDecodeOptions + o.MaxInputLen = len(inp) + d := xdr.NewDecoderWithOptions(r, o) + _, err := s.DecodeFrom(d, o.MaxDepth) return err } @@ -26639,8 +27003,7 @@ var ( _ encoding.BinaryUnmarshaler = (*InvokeHostFunctionOp)(nil) ) -// xdrType signals that this type is an type representing -// representing XDR values defined by this package. +// xdrType signals that this type represents XDR values defined by this package. func (s InvokeHostFunctionOp) xdrType() {} var _ xdrType = (*InvokeHostFunctionOp)(nil) @@ -26703,8 +27066,10 @@ func (s ExtendFootprintTtlOp) MarshalBinary() ([]byte, error) { // UnmarshalBinary implements encoding.BinaryUnmarshaler. func (s *ExtendFootprintTtlOp) UnmarshalBinary(inp []byte) error { r := bytes.NewReader(inp) - d := xdr.NewDecoder(r) - _, err := s.DecodeFrom(d, xdr.DecodeDefaultMaxDepth) + o := xdr.DefaultDecodeOptions + o.MaxInputLen = len(inp) + d := xdr.NewDecoderWithOptions(r, o) + _, err := s.DecodeFrom(d, o.MaxDepth) return err } @@ -26713,8 +27078,7 @@ var ( _ encoding.BinaryUnmarshaler = (*ExtendFootprintTtlOp)(nil) ) -// xdrType signals that this type is an type representing -// representing XDR values defined by this package. +// xdrType signals that this type represents XDR values defined by this package. func (s ExtendFootprintTtlOp) xdrType() {} var _ xdrType = (*ExtendFootprintTtlOp)(nil) @@ -26767,8 +27131,10 @@ func (s RestoreFootprintOp) MarshalBinary() ([]byte, error) { // UnmarshalBinary implements encoding.BinaryUnmarshaler. func (s *RestoreFootprintOp) UnmarshalBinary(inp []byte) error { r := bytes.NewReader(inp) - d := xdr.NewDecoder(r) - _, err := s.DecodeFrom(d, xdr.DecodeDefaultMaxDepth) + o := xdr.DefaultDecodeOptions + o.MaxInputLen = len(inp) + d := xdr.NewDecoderWithOptions(r, o) + _, err := s.DecodeFrom(d, o.MaxDepth) return err } @@ -26777,8 +27143,7 @@ var ( _ encoding.BinaryUnmarshaler = (*RestoreFootprintOp)(nil) ) -// xdrType signals that this type is an type representing -// representing XDR values defined by this package. +// xdrType signals that this type represents XDR values defined by this package. func (s RestoreFootprintOp) xdrType() {} var _ xdrType = (*RestoreFootprintOp)(nil) @@ -28130,8 +28495,10 @@ func (s OperationBody) MarshalBinary() ([]byte, error) { // UnmarshalBinary implements encoding.BinaryUnmarshaler. func (s *OperationBody) UnmarshalBinary(inp []byte) error { r := bytes.NewReader(inp) - d := xdr.NewDecoder(r) - _, err := s.DecodeFrom(d, xdr.DecodeDefaultMaxDepth) + o := xdr.DefaultDecodeOptions + o.MaxInputLen = len(inp) + d := xdr.NewDecoderWithOptions(r, o) + _, err := s.DecodeFrom(d, o.MaxDepth) return err } @@ -28140,8 +28507,7 @@ var ( _ encoding.BinaryUnmarshaler = (*OperationBody)(nil) ) -// xdrType signals that this type is an type representing -// representing XDR values defined by this package. +// xdrType signals that this type represents XDR values defined by this package. func (s OperationBody) xdrType() {} var _ xdrType = (*OperationBody)(nil) @@ -28280,8 +28646,10 @@ func (s Operation) MarshalBinary() ([]byte, error) { // UnmarshalBinary implements encoding.BinaryUnmarshaler. func (s *Operation) UnmarshalBinary(inp []byte) error { r := bytes.NewReader(inp) - d := xdr.NewDecoder(r) - _, err := s.DecodeFrom(d, xdr.DecodeDefaultMaxDepth) + o := xdr.DefaultDecodeOptions + o.MaxInputLen = len(inp) + d := xdr.NewDecoderWithOptions(r, o) + _, err := s.DecodeFrom(d, o.MaxDepth) return err } @@ -28290,8 +28658,7 @@ var ( _ encoding.BinaryUnmarshaler = (*Operation)(nil) ) -// xdrType signals that this type is an type representing -// representing XDR values defined by this package. +// xdrType signals that this type represents XDR values defined by this package. func (s Operation) xdrType() {} var _ xdrType = (*Operation)(nil) @@ -28364,8 +28731,10 @@ func (s HashIdPreimageOperationId) MarshalBinary() ([]byte, error) { // UnmarshalBinary implements encoding.BinaryUnmarshaler. func (s *HashIdPreimageOperationId) UnmarshalBinary(inp []byte) error { r := bytes.NewReader(inp) - d := xdr.NewDecoder(r) - _, err := s.DecodeFrom(d, xdr.DecodeDefaultMaxDepth) + o := xdr.DefaultDecodeOptions + o.MaxInputLen = len(inp) + d := xdr.NewDecoderWithOptions(r, o) + _, err := s.DecodeFrom(d, o.MaxDepth) return err } @@ -28374,8 +28743,7 @@ var ( _ encoding.BinaryUnmarshaler = (*HashIdPreimageOperationId)(nil) ) -// xdrType signals that this type is an type representing -// representing XDR values defined by this package. +// xdrType signals that this type represents XDR values defined by this package. func (s HashIdPreimageOperationId) xdrType() {} var _ xdrType = (*HashIdPreimageOperationId)(nil) @@ -28468,8 +28836,10 @@ func (s HashIdPreimageRevokeId) MarshalBinary() ([]byte, error) { // UnmarshalBinary implements encoding.BinaryUnmarshaler. func (s *HashIdPreimageRevokeId) UnmarshalBinary(inp []byte) error { r := bytes.NewReader(inp) - d := xdr.NewDecoder(r) - _, err := s.DecodeFrom(d, xdr.DecodeDefaultMaxDepth) + o := xdr.DefaultDecodeOptions + o.MaxInputLen = len(inp) + d := xdr.NewDecoderWithOptions(r, o) + _, err := s.DecodeFrom(d, o.MaxDepth) return err } @@ -28478,8 +28848,7 @@ var ( _ encoding.BinaryUnmarshaler = (*HashIdPreimageRevokeId)(nil) ) -// xdrType signals that this type is an type representing -// representing XDR values defined by this package. +// xdrType signals that this type represents XDR values defined by this package. func (s HashIdPreimageRevokeId) xdrType() {} var _ xdrType = (*HashIdPreimageRevokeId)(nil) @@ -28542,8 +28911,10 @@ func (s HashIdPreimageContractId) MarshalBinary() ([]byte, error) { // UnmarshalBinary implements encoding.BinaryUnmarshaler. func (s *HashIdPreimageContractId) UnmarshalBinary(inp []byte) error { r := bytes.NewReader(inp) - d := xdr.NewDecoder(r) - _, err := s.DecodeFrom(d, xdr.DecodeDefaultMaxDepth) + o := xdr.DefaultDecodeOptions + o.MaxInputLen = len(inp) + d := xdr.NewDecoderWithOptions(r, o) + _, err := s.DecodeFrom(d, o.MaxDepth) return err } @@ -28552,8 +28923,7 @@ var ( _ encoding.BinaryUnmarshaler = (*HashIdPreimageContractId)(nil) ) -// xdrType signals that this type is an type representing -// representing XDR values defined by this package. +// xdrType signals that this type represents XDR values defined by this package. func (s HashIdPreimageContractId) xdrType() {} var _ xdrType = (*HashIdPreimageContractId)(nil) @@ -28636,8 +29006,10 @@ func (s HashIdPreimageSorobanAuthorization) MarshalBinary() ([]byte, error) { // UnmarshalBinary implements encoding.BinaryUnmarshaler. func (s *HashIdPreimageSorobanAuthorization) UnmarshalBinary(inp []byte) error { r := bytes.NewReader(inp) - d := xdr.NewDecoder(r) - _, err := s.DecodeFrom(d, xdr.DecodeDefaultMaxDepth) + o := xdr.DefaultDecodeOptions + o.MaxInputLen = len(inp) + d := xdr.NewDecoderWithOptions(r, o) + _, err := s.DecodeFrom(d, o.MaxDepth) return err } @@ -28646,8 +29018,7 @@ var ( _ encoding.BinaryUnmarshaler = (*HashIdPreimageSorobanAuthorization)(nil) ) -// xdrType signals that this type is an type representing -// representing XDR values defined by this package. +// xdrType signals that this type represents XDR values defined by this package. func (s HashIdPreimageSorobanAuthorization) xdrType() {} var _ xdrType = (*HashIdPreimageSorobanAuthorization)(nil) @@ -28947,8 +29318,10 @@ func (s HashIdPreimage) MarshalBinary() ([]byte, error) { // UnmarshalBinary implements encoding.BinaryUnmarshaler. func (s *HashIdPreimage) UnmarshalBinary(inp []byte) error { r := bytes.NewReader(inp) - d := xdr.NewDecoder(r) - _, err := s.DecodeFrom(d, xdr.DecodeDefaultMaxDepth) + o := xdr.DefaultDecodeOptions + o.MaxInputLen = len(inp) + d := xdr.NewDecoderWithOptions(r, o) + _, err := s.DecodeFrom(d, o.MaxDepth) return err } @@ -28957,8 +29330,7 @@ var ( _ encoding.BinaryUnmarshaler = (*HashIdPreimage)(nil) ) -// xdrType signals that this type is an type representing -// representing XDR values defined by this package. +// xdrType signals that this type represents XDR values defined by this package. func (s HashIdPreimage) xdrType() {} var _ xdrType = (*HashIdPreimage)(nil) @@ -29043,8 +29415,10 @@ func (s MemoType) MarshalBinary() ([]byte, error) { // UnmarshalBinary implements encoding.BinaryUnmarshaler. func (s *MemoType) UnmarshalBinary(inp []byte) error { r := bytes.NewReader(inp) - d := xdr.NewDecoder(r) - _, err := s.DecodeFrom(d, xdr.DecodeDefaultMaxDepth) + o := xdr.DefaultDecodeOptions + o.MaxInputLen = len(inp) + d := xdr.NewDecoderWithOptions(r, o) + _, err := s.DecodeFrom(d, o.MaxDepth) return err } @@ -29053,8 +29427,7 @@ var ( _ encoding.BinaryUnmarshaler = (*MemoType)(nil) ) -// xdrType signals that this type is an type representing -// representing XDR values defined by this package. +// xdrType signals that this type represents XDR values defined by this package. func (s MemoType) xdrType() {} var _ xdrType = (*MemoType)(nil) @@ -29344,8 +29717,10 @@ func (s Memo) MarshalBinary() ([]byte, error) { // UnmarshalBinary implements encoding.BinaryUnmarshaler. func (s *Memo) UnmarshalBinary(inp []byte) error { r := bytes.NewReader(inp) - d := xdr.NewDecoder(r) - _, err := s.DecodeFrom(d, xdr.DecodeDefaultMaxDepth) + o := xdr.DefaultDecodeOptions + o.MaxInputLen = len(inp) + d := xdr.NewDecoderWithOptions(r, o) + _, err := s.DecodeFrom(d, o.MaxDepth) return err } @@ -29354,8 +29729,7 @@ var ( _ encoding.BinaryUnmarshaler = (*Memo)(nil) ) -// xdrType signals that this type is an type representing -// representing XDR values defined by this package. +// xdrType signals that this type represents XDR values defined by this package. func (s Memo) xdrType() {} var _ xdrType = (*Memo)(nil) @@ -29418,8 +29792,10 @@ func (s TimeBounds) MarshalBinary() ([]byte, error) { // UnmarshalBinary implements encoding.BinaryUnmarshaler. func (s *TimeBounds) UnmarshalBinary(inp []byte) error { r := bytes.NewReader(inp) - d := xdr.NewDecoder(r) - _, err := s.DecodeFrom(d, xdr.DecodeDefaultMaxDepth) + o := xdr.DefaultDecodeOptions + o.MaxInputLen = len(inp) + d := xdr.NewDecoderWithOptions(r, o) + _, err := s.DecodeFrom(d, o.MaxDepth) return err } @@ -29428,8 +29804,7 @@ var ( _ encoding.BinaryUnmarshaler = (*TimeBounds)(nil) ) -// xdrType signals that this type is an type representing -// representing XDR values defined by this package. +// xdrType signals that this type represents XDR values defined by this package. func (s TimeBounds) xdrType() {} var _ xdrType = (*TimeBounds)(nil) @@ -29492,8 +29867,10 @@ func (s LedgerBounds) MarshalBinary() ([]byte, error) { // UnmarshalBinary implements encoding.BinaryUnmarshaler. func (s *LedgerBounds) UnmarshalBinary(inp []byte) error { r := bytes.NewReader(inp) - d := xdr.NewDecoder(r) - _, err := s.DecodeFrom(d, xdr.DecodeDefaultMaxDepth) + o := xdr.DefaultDecodeOptions + o.MaxInputLen = len(inp) + d := xdr.NewDecoderWithOptions(r, o) + _, err := s.DecodeFrom(d, o.MaxDepth) return err } @@ -29502,8 +29879,7 @@ var ( _ encoding.BinaryUnmarshaler = (*LedgerBounds)(nil) ) -// xdrType signals that this type is an type representing -// representing XDR values defined by this package. +// xdrType signals that this type represents XDR values defined by this package. func (s LedgerBounds) xdrType() {} var _ xdrType = (*LedgerBounds)(nil) @@ -29669,8 +30045,11 @@ func (s *PreconditionsV2) DecodeFrom(d *xdr.Decoder, maxDepth uint) (int, error) } s.ExtraSigners = nil if l > 0 { + if il, ok := d.InputLen(); ok && uint(il) < uint(l) { + return n, fmt.Errorf("decoding SignerKey: length (%d) exceeds remaining input length (%d)", l, il) + } s.ExtraSigners = make([]SignerKey, l) - for i := uint32(0); i < l; i++ { + for i := uint32(0); uint(i) < uint(l); i++ { nTmp, err = s.ExtraSigners[i].DecodeFrom(d, maxDepth) n += nTmp if err != nil { @@ -29692,8 +30071,10 @@ func (s PreconditionsV2) MarshalBinary() ([]byte, error) { // UnmarshalBinary implements encoding.BinaryUnmarshaler. func (s *PreconditionsV2) UnmarshalBinary(inp []byte) error { r := bytes.NewReader(inp) - d := xdr.NewDecoder(r) - _, err := s.DecodeFrom(d, xdr.DecodeDefaultMaxDepth) + o := xdr.DefaultDecodeOptions + o.MaxInputLen = len(inp) + d := xdr.NewDecoderWithOptions(r, o) + _, err := s.DecodeFrom(d, o.MaxDepth) return err } @@ -29702,8 +30083,7 @@ var ( _ encoding.BinaryUnmarshaler = (*PreconditionsV2)(nil) ) -// xdrType signals that this type is an type representing -// representing XDR values defined by this package. +// xdrType signals that this type represents XDR values defined by this package. func (s PreconditionsV2) xdrType() {} var _ xdrType = (*PreconditionsV2)(nil) @@ -29782,8 +30162,10 @@ func (s PreconditionType) MarshalBinary() ([]byte, error) { // UnmarshalBinary implements encoding.BinaryUnmarshaler. func (s *PreconditionType) UnmarshalBinary(inp []byte) error { r := bytes.NewReader(inp) - d := xdr.NewDecoder(r) - _, err := s.DecodeFrom(d, xdr.DecodeDefaultMaxDepth) + o := xdr.DefaultDecodeOptions + o.MaxInputLen = len(inp) + d := xdr.NewDecoderWithOptions(r, o) + _, err := s.DecodeFrom(d, o.MaxDepth) return err } @@ -29792,8 +30174,7 @@ var ( _ encoding.BinaryUnmarshaler = (*PreconditionType)(nil) ) -// xdrType signals that this type is an type representing -// representing XDR values defined by this package. +// xdrType signals that this type represents XDR values defined by this package. func (s PreconditionType) xdrType() {} var _ xdrType = (*PreconditionType)(nil) @@ -29983,8 +30364,10 @@ func (s Preconditions) MarshalBinary() ([]byte, error) { // UnmarshalBinary implements encoding.BinaryUnmarshaler. func (s *Preconditions) UnmarshalBinary(inp []byte) error { r := bytes.NewReader(inp) - d := xdr.NewDecoder(r) - _, err := s.DecodeFrom(d, xdr.DecodeDefaultMaxDepth) + o := xdr.DefaultDecodeOptions + o.MaxInputLen = len(inp) + d := xdr.NewDecoderWithOptions(r, o) + _, err := s.DecodeFrom(d, o.MaxDepth) return err } @@ -29993,8 +30376,7 @@ var ( _ encoding.BinaryUnmarshaler = (*Preconditions)(nil) ) -// xdrType signals that this type is an type representing -// representing XDR values defined by this package. +// xdrType signals that this type represents XDR values defined by this package. func (s Preconditions) xdrType() {} var _ xdrType = (*Preconditions)(nil) @@ -30051,8 +30433,11 @@ func (s *LedgerFootprint) DecodeFrom(d *xdr.Decoder, maxDepth uint) (int, error) } s.ReadOnly = nil if l > 0 { + if il, ok := d.InputLen(); ok && uint(il) < uint(l) { + return n, fmt.Errorf("decoding LedgerKey: length (%d) exceeds remaining input length (%d)", l, il) + } s.ReadOnly = make([]LedgerKey, l) - for i := uint32(0); i < l; i++ { + for i := uint32(0); uint(i) < uint(l); i++ { nTmp, err = s.ReadOnly[i].DecodeFrom(d, maxDepth) n += nTmp if err != nil { @@ -30067,8 +30452,11 @@ func (s *LedgerFootprint) DecodeFrom(d *xdr.Decoder, maxDepth uint) (int, error) } s.ReadWrite = nil if l > 0 { + if il, ok := d.InputLen(); ok && uint(il) < uint(l) { + return n, fmt.Errorf("decoding LedgerKey: length (%d) exceeds remaining input length (%d)", l, il) + } s.ReadWrite = make([]LedgerKey, l) - for i := uint32(0); i < l; i++ { + for i := uint32(0); uint(i) < uint(l); i++ { nTmp, err = s.ReadWrite[i].DecodeFrom(d, maxDepth) n += nTmp if err != nil { @@ -30090,8 +30478,10 @@ func (s LedgerFootprint) MarshalBinary() ([]byte, error) { // UnmarshalBinary implements encoding.BinaryUnmarshaler. func (s *LedgerFootprint) UnmarshalBinary(inp []byte) error { r := bytes.NewReader(inp) - d := xdr.NewDecoder(r) - _, err := s.DecodeFrom(d, xdr.DecodeDefaultMaxDepth) + o := xdr.DefaultDecodeOptions + o.MaxInputLen = len(inp) + d := xdr.NewDecoderWithOptions(r, o) + _, err := s.DecodeFrom(d, o.MaxDepth) return err } @@ -30100,8 +30490,7 @@ var ( _ encoding.BinaryUnmarshaler = (*LedgerFootprint)(nil) ) -// xdrType signals that this type is an type representing -// representing XDR values defined by this package. +// xdrType signals that this type represents XDR values defined by this package. func (s LedgerFootprint) xdrType() {} var _ xdrType = (*LedgerFootprint)(nil) @@ -30189,8 +30578,10 @@ func (s SorobanResources) MarshalBinary() ([]byte, error) { // UnmarshalBinary implements encoding.BinaryUnmarshaler. func (s *SorobanResources) UnmarshalBinary(inp []byte) error { r := bytes.NewReader(inp) - d := xdr.NewDecoder(r) - _, err := s.DecodeFrom(d, xdr.DecodeDefaultMaxDepth) + o := xdr.DefaultDecodeOptions + o.MaxInputLen = len(inp) + d := xdr.NewDecoderWithOptions(r, o) + _, err := s.DecodeFrom(d, o.MaxDepth) return err } @@ -30199,8 +30590,7 @@ var ( _ encoding.BinaryUnmarshaler = (*SorobanResources)(nil) ) -// xdrType signals that this type is an type representing -// representing XDR values defined by this package. +// xdrType signals that this type represents XDR values defined by this package. func (s SorobanResources) xdrType() {} var _ xdrType = (*SorobanResources)(nil) @@ -30282,8 +30672,10 @@ func (s SorobanTransactionData) MarshalBinary() ([]byte, error) { // UnmarshalBinary implements encoding.BinaryUnmarshaler. func (s *SorobanTransactionData) UnmarshalBinary(inp []byte) error { r := bytes.NewReader(inp) - d := xdr.NewDecoder(r) - _, err := s.DecodeFrom(d, xdr.DecodeDefaultMaxDepth) + o := xdr.DefaultDecodeOptions + o.MaxInputLen = len(inp) + d := xdr.NewDecoderWithOptions(r, o) + _, err := s.DecodeFrom(d, o.MaxDepth) return err } @@ -30292,8 +30684,7 @@ var ( _ encoding.BinaryUnmarshaler = (*SorobanTransactionData)(nil) ) -// xdrType signals that this type is an type representing -// representing XDR values defined by this package. +// xdrType signals that this type represents XDR values defined by this package. func (s SorobanTransactionData) xdrType() {} var _ xdrType = (*SorobanTransactionData)(nil) @@ -30383,8 +30774,10 @@ func (s TransactionV0Ext) MarshalBinary() ([]byte, error) { // UnmarshalBinary implements encoding.BinaryUnmarshaler. func (s *TransactionV0Ext) UnmarshalBinary(inp []byte) error { r := bytes.NewReader(inp) - d := xdr.NewDecoder(r) - _, err := s.DecodeFrom(d, xdr.DecodeDefaultMaxDepth) + o := xdr.DefaultDecodeOptions + o.MaxInputLen = len(inp) + d := xdr.NewDecoderWithOptions(r, o) + _, err := s.DecodeFrom(d, o.MaxDepth) return err } @@ -30393,8 +30786,7 @@ var ( _ encoding.BinaryUnmarshaler = (*TransactionV0Ext)(nil) ) -// xdrType signals that this type is an type representing -// representing XDR values defined by this package. +// xdrType signals that this type represents XDR values defined by this package. func (s TransactionV0Ext) xdrType() {} var _ xdrType = (*TransactionV0Ext)(nil) @@ -30519,8 +30911,11 @@ func (s *TransactionV0) DecodeFrom(d *xdr.Decoder, maxDepth uint) (int, error) { } s.Operations = nil if l > 0 { + if il, ok := d.InputLen(); ok && uint(il) < uint(l) { + return n, fmt.Errorf("decoding Operation: length (%d) exceeds remaining input length (%d)", l, il) + } s.Operations = make([]Operation, l) - for i := uint32(0); i < l; i++ { + for i := uint32(0); uint(i) < uint(l); i++ { nTmp, err = s.Operations[i].DecodeFrom(d, maxDepth) n += nTmp if err != nil { @@ -30547,8 +30942,10 @@ func (s TransactionV0) MarshalBinary() ([]byte, error) { // UnmarshalBinary implements encoding.BinaryUnmarshaler. func (s *TransactionV0) UnmarshalBinary(inp []byte) error { r := bytes.NewReader(inp) - d := xdr.NewDecoder(r) - _, err := s.DecodeFrom(d, xdr.DecodeDefaultMaxDepth) + o := xdr.DefaultDecodeOptions + o.MaxInputLen = len(inp) + d := xdr.NewDecoderWithOptions(r, o) + _, err := s.DecodeFrom(d, o.MaxDepth) return err } @@ -30557,8 +30954,7 @@ var ( _ encoding.BinaryUnmarshaler = (*TransactionV0)(nil) ) -// xdrType signals that this type is an type representing -// representing XDR values defined by this package. +// xdrType signals that this type represents XDR values defined by this package. func (s TransactionV0) xdrType() {} var _ xdrType = (*TransactionV0)(nil) @@ -30620,8 +31016,11 @@ func (s *TransactionV0Envelope) DecodeFrom(d *xdr.Decoder, maxDepth uint) (int, } s.Signatures = nil if l > 0 { + if il, ok := d.InputLen(); ok && uint(il) < uint(l) { + return n, fmt.Errorf("decoding DecoratedSignature: length (%d) exceeds remaining input length (%d)", l, il) + } s.Signatures = make([]DecoratedSignature, l) - for i := uint32(0); i < l; i++ { + for i := uint32(0); uint(i) < uint(l); i++ { nTmp, err = s.Signatures[i].DecodeFrom(d, maxDepth) n += nTmp if err != nil { @@ -30643,8 +31042,10 @@ func (s TransactionV0Envelope) MarshalBinary() ([]byte, error) { // UnmarshalBinary implements encoding.BinaryUnmarshaler. func (s *TransactionV0Envelope) UnmarshalBinary(inp []byte) error { r := bytes.NewReader(inp) - d := xdr.NewDecoder(r) - _, err := s.DecodeFrom(d, xdr.DecodeDefaultMaxDepth) + o := xdr.DefaultDecodeOptions + o.MaxInputLen = len(inp) + d := xdr.NewDecoderWithOptions(r, o) + _, err := s.DecodeFrom(d, o.MaxDepth) return err } @@ -30653,8 +31054,7 @@ var ( _ encoding.BinaryUnmarshaler = (*TransactionV0Envelope)(nil) ) -// xdrType signals that this type is an type representing -// representing XDR values defined by this package. +// xdrType signals that this type represents XDR values defined by this package. func (s TransactionV0Envelope) xdrType() {} var _ xdrType = (*TransactionV0Envelope)(nil) @@ -30794,8 +31194,10 @@ func (s TransactionExt) MarshalBinary() ([]byte, error) { // UnmarshalBinary implements encoding.BinaryUnmarshaler. func (s *TransactionExt) UnmarshalBinary(inp []byte) error { r := bytes.NewReader(inp) - d := xdr.NewDecoder(r) - _, err := s.DecodeFrom(d, xdr.DecodeDefaultMaxDepth) + o := xdr.DefaultDecodeOptions + o.MaxInputLen = len(inp) + d := xdr.NewDecoderWithOptions(r, o) + _, err := s.DecodeFrom(d, o.MaxDepth) return err } @@ -30804,8 +31206,7 @@ var ( _ encoding.BinaryUnmarshaler = (*TransactionExt)(nil) ) -// xdrType signals that this type is an type representing -// representing XDR values defined by this package. +// xdrType signals that this type represents XDR values defined by this package. func (s TransactionExt) xdrType() {} var _ xdrType = (*TransactionExt)(nil) @@ -30928,8 +31329,11 @@ func (s *Transaction) DecodeFrom(d *xdr.Decoder, maxDepth uint) (int, error) { } s.Operations = nil if l > 0 { + if il, ok := d.InputLen(); ok && uint(il) < uint(l) { + return n, fmt.Errorf("decoding Operation: length (%d) exceeds remaining input length (%d)", l, il) + } s.Operations = make([]Operation, l) - for i := uint32(0); i < l; i++ { + for i := uint32(0); uint(i) < uint(l); i++ { nTmp, err = s.Operations[i].DecodeFrom(d, maxDepth) n += nTmp if err != nil { @@ -30956,8 +31360,10 @@ func (s Transaction) MarshalBinary() ([]byte, error) { // UnmarshalBinary implements encoding.BinaryUnmarshaler. func (s *Transaction) UnmarshalBinary(inp []byte) error { r := bytes.NewReader(inp) - d := xdr.NewDecoder(r) - _, err := s.DecodeFrom(d, xdr.DecodeDefaultMaxDepth) + o := xdr.DefaultDecodeOptions + o.MaxInputLen = len(inp) + d := xdr.NewDecoderWithOptions(r, o) + _, err := s.DecodeFrom(d, o.MaxDepth) return err } @@ -30966,8 +31372,7 @@ var ( _ encoding.BinaryUnmarshaler = (*Transaction)(nil) ) -// xdrType signals that this type is an type representing -// representing XDR values defined by this package. +// xdrType signals that this type represents XDR values defined by this package. func (s Transaction) xdrType() {} var _ xdrType = (*Transaction)(nil) @@ -31029,8 +31434,11 @@ func (s *TransactionV1Envelope) DecodeFrom(d *xdr.Decoder, maxDepth uint) (int, } s.Signatures = nil if l > 0 { + if il, ok := d.InputLen(); ok && uint(il) < uint(l) { + return n, fmt.Errorf("decoding DecoratedSignature: length (%d) exceeds remaining input length (%d)", l, il) + } s.Signatures = make([]DecoratedSignature, l) - for i := uint32(0); i < l; i++ { + for i := uint32(0); uint(i) < uint(l); i++ { nTmp, err = s.Signatures[i].DecodeFrom(d, maxDepth) n += nTmp if err != nil { @@ -31052,8 +31460,10 @@ func (s TransactionV1Envelope) MarshalBinary() ([]byte, error) { // UnmarshalBinary implements encoding.BinaryUnmarshaler. func (s *TransactionV1Envelope) UnmarshalBinary(inp []byte) error { r := bytes.NewReader(inp) - d := xdr.NewDecoder(r) - _, err := s.DecodeFrom(d, xdr.DecodeDefaultMaxDepth) + o := xdr.DefaultDecodeOptions + o.MaxInputLen = len(inp) + d := xdr.NewDecoderWithOptions(r, o) + _, err := s.DecodeFrom(d, o.MaxDepth) return err } @@ -31062,8 +31472,7 @@ var ( _ encoding.BinaryUnmarshaler = (*TransactionV1Envelope)(nil) ) -// xdrType signals that this type is an type representing -// representing XDR values defined by this package. +// xdrType signals that this type represents XDR values defined by this package. func (s TransactionV1Envelope) xdrType() {} var _ xdrType = (*TransactionV1Envelope)(nil) @@ -31191,8 +31600,10 @@ func (s FeeBumpTransactionInnerTx) MarshalBinary() ([]byte, error) { // UnmarshalBinary implements encoding.BinaryUnmarshaler. func (s *FeeBumpTransactionInnerTx) UnmarshalBinary(inp []byte) error { r := bytes.NewReader(inp) - d := xdr.NewDecoder(r) - _, err := s.DecodeFrom(d, xdr.DecodeDefaultMaxDepth) + o := xdr.DefaultDecodeOptions + o.MaxInputLen = len(inp) + d := xdr.NewDecoderWithOptions(r, o) + _, err := s.DecodeFrom(d, o.MaxDepth) return err } @@ -31201,8 +31612,7 @@ var ( _ encoding.BinaryUnmarshaler = (*FeeBumpTransactionInnerTx)(nil) ) -// xdrType signals that this type is an type representing -// representing XDR values defined by this package. +// xdrType signals that this type represents XDR values defined by this package. func (s FeeBumpTransactionInnerTx) xdrType() {} var _ xdrType = (*FeeBumpTransactionInnerTx)(nil) @@ -31292,8 +31702,10 @@ func (s FeeBumpTransactionExt) MarshalBinary() ([]byte, error) { // UnmarshalBinary implements encoding.BinaryUnmarshaler. func (s *FeeBumpTransactionExt) UnmarshalBinary(inp []byte) error { r := bytes.NewReader(inp) - d := xdr.NewDecoder(r) - _, err := s.DecodeFrom(d, xdr.DecodeDefaultMaxDepth) + o := xdr.DefaultDecodeOptions + o.MaxInputLen = len(inp) + d := xdr.NewDecoderWithOptions(r, o) + _, err := s.DecodeFrom(d, o.MaxDepth) return err } @@ -31302,8 +31714,7 @@ var ( _ encoding.BinaryUnmarshaler = (*FeeBumpTransactionExt)(nil) ) -// xdrType signals that this type is an type representing -// representing XDR values defined by this package. +// xdrType signals that this type represents XDR values defined by this package. func (s FeeBumpTransactionExt) xdrType() {} var _ xdrType = (*FeeBumpTransactionExt)(nil) @@ -31396,8 +31807,10 @@ func (s FeeBumpTransaction) MarshalBinary() ([]byte, error) { // UnmarshalBinary implements encoding.BinaryUnmarshaler. func (s *FeeBumpTransaction) UnmarshalBinary(inp []byte) error { r := bytes.NewReader(inp) - d := xdr.NewDecoder(r) - _, err := s.DecodeFrom(d, xdr.DecodeDefaultMaxDepth) + o := xdr.DefaultDecodeOptions + o.MaxInputLen = len(inp) + d := xdr.NewDecoderWithOptions(r, o) + _, err := s.DecodeFrom(d, o.MaxDepth) return err } @@ -31406,8 +31819,7 @@ var ( _ encoding.BinaryUnmarshaler = (*FeeBumpTransaction)(nil) ) -// xdrType signals that this type is an type representing -// representing XDR values defined by this package. +// xdrType signals that this type represents XDR values defined by this package. func (s FeeBumpTransaction) xdrType() {} var _ xdrType = (*FeeBumpTransaction)(nil) @@ -31469,8 +31881,11 @@ func (s *FeeBumpTransactionEnvelope) DecodeFrom(d *xdr.Decoder, maxDepth uint) ( } s.Signatures = nil if l > 0 { + if il, ok := d.InputLen(); ok && uint(il) < uint(l) { + return n, fmt.Errorf("decoding DecoratedSignature: length (%d) exceeds remaining input length (%d)", l, il) + } s.Signatures = make([]DecoratedSignature, l) - for i := uint32(0); i < l; i++ { + for i := uint32(0); uint(i) < uint(l); i++ { nTmp, err = s.Signatures[i].DecodeFrom(d, maxDepth) n += nTmp if err != nil { @@ -31492,8 +31907,10 @@ func (s FeeBumpTransactionEnvelope) MarshalBinary() ([]byte, error) { // UnmarshalBinary implements encoding.BinaryUnmarshaler. func (s *FeeBumpTransactionEnvelope) UnmarshalBinary(inp []byte) error { r := bytes.NewReader(inp) - d := xdr.NewDecoder(r) - _, err := s.DecodeFrom(d, xdr.DecodeDefaultMaxDepth) + o := xdr.DefaultDecodeOptions + o.MaxInputLen = len(inp) + d := xdr.NewDecoderWithOptions(r, o) + _, err := s.DecodeFrom(d, o.MaxDepth) return err } @@ -31502,8 +31919,7 @@ var ( _ encoding.BinaryUnmarshaler = (*FeeBumpTransactionEnvelope)(nil) ) -// xdrType signals that this type is an type representing -// representing XDR values defined by this package. +// xdrType signals that this type represents XDR values defined by this package. func (s FeeBumpTransactionEnvelope) xdrType() {} var _ xdrType = (*FeeBumpTransactionEnvelope)(nil) @@ -31731,8 +32147,10 @@ func (s TransactionEnvelope) MarshalBinary() ([]byte, error) { // UnmarshalBinary implements encoding.BinaryUnmarshaler. func (s *TransactionEnvelope) UnmarshalBinary(inp []byte) error { r := bytes.NewReader(inp) - d := xdr.NewDecoder(r) - _, err := s.DecodeFrom(d, xdr.DecodeDefaultMaxDepth) + o := xdr.DefaultDecodeOptions + o.MaxInputLen = len(inp) + d := xdr.NewDecoderWithOptions(r, o) + _, err := s.DecodeFrom(d, o.MaxDepth) return err } @@ -31741,8 +32159,7 @@ var ( _ encoding.BinaryUnmarshaler = (*TransactionEnvelope)(nil) ) -// xdrType signals that this type is an type representing -// representing XDR values defined by this package. +// xdrType signals that this type represents XDR values defined by this package. func (s TransactionEnvelope) xdrType() {} var _ xdrType = (*TransactionEnvelope)(nil) @@ -31921,8 +32338,10 @@ func (s TransactionSignaturePayloadTaggedTransaction) MarshalBinary() ([]byte, e // UnmarshalBinary implements encoding.BinaryUnmarshaler. func (s *TransactionSignaturePayloadTaggedTransaction) UnmarshalBinary(inp []byte) error { r := bytes.NewReader(inp) - d := xdr.NewDecoder(r) - _, err := s.DecodeFrom(d, xdr.DecodeDefaultMaxDepth) + o := xdr.DefaultDecodeOptions + o.MaxInputLen = len(inp) + d := xdr.NewDecoderWithOptions(r, o) + _, err := s.DecodeFrom(d, o.MaxDepth) return err } @@ -31931,8 +32350,7 @@ var ( _ encoding.BinaryUnmarshaler = (*TransactionSignaturePayloadTaggedTransaction)(nil) ) -// xdrType signals that this type is an type representing -// representing XDR values defined by this package. +// xdrType signals that this type represents XDR values defined by this package. func (s TransactionSignaturePayloadTaggedTransaction) xdrType() {} var _ xdrType = (*TransactionSignaturePayloadTaggedTransaction)(nil) @@ -32003,8 +32421,10 @@ func (s TransactionSignaturePayload) MarshalBinary() ([]byte, error) { // UnmarshalBinary implements encoding.BinaryUnmarshaler. func (s *TransactionSignaturePayload) UnmarshalBinary(inp []byte) error { r := bytes.NewReader(inp) - d := xdr.NewDecoder(r) - _, err := s.DecodeFrom(d, xdr.DecodeDefaultMaxDepth) + o := xdr.DefaultDecodeOptions + o.MaxInputLen = len(inp) + d := xdr.NewDecoderWithOptions(r, o) + _, err := s.DecodeFrom(d, o.MaxDepth) return err } @@ -32013,8 +32433,7 @@ var ( _ encoding.BinaryUnmarshaler = (*TransactionSignaturePayload)(nil) ) -// xdrType signals that this type is an type representing -// representing XDR values defined by this package. +// xdrType signals that this type represents XDR values defined by this package. func (s TransactionSignaturePayload) xdrType() {} var _ xdrType = (*TransactionSignaturePayload)(nil) @@ -32093,8 +32512,10 @@ func (s ClaimAtomType) MarshalBinary() ([]byte, error) { // UnmarshalBinary implements encoding.BinaryUnmarshaler. func (s *ClaimAtomType) UnmarshalBinary(inp []byte) error { r := bytes.NewReader(inp) - d := xdr.NewDecoder(r) - _, err := s.DecodeFrom(d, xdr.DecodeDefaultMaxDepth) + o := xdr.DefaultDecodeOptions + o.MaxInputLen = len(inp) + d := xdr.NewDecoderWithOptions(r, o) + _, err := s.DecodeFrom(d, o.MaxDepth) return err } @@ -32103,8 +32524,7 @@ var ( _ encoding.BinaryUnmarshaler = (*ClaimAtomType)(nil) ) -// xdrType signals that this type is an type representing -// representing XDR values defined by this package. +// xdrType signals that this type represents XDR values defined by this package. func (s ClaimAtomType) xdrType() {} var _ xdrType = (*ClaimAtomType)(nil) @@ -32212,8 +32632,10 @@ func (s ClaimOfferAtomV0) MarshalBinary() ([]byte, error) { // UnmarshalBinary implements encoding.BinaryUnmarshaler. func (s *ClaimOfferAtomV0) UnmarshalBinary(inp []byte) error { r := bytes.NewReader(inp) - d := xdr.NewDecoder(r) - _, err := s.DecodeFrom(d, xdr.DecodeDefaultMaxDepth) + o := xdr.DefaultDecodeOptions + o.MaxInputLen = len(inp) + d := xdr.NewDecoderWithOptions(r, o) + _, err := s.DecodeFrom(d, o.MaxDepth) return err } @@ -32222,8 +32644,7 @@ var ( _ encoding.BinaryUnmarshaler = (*ClaimOfferAtomV0)(nil) ) -// xdrType signals that this type is an type representing -// representing XDR values defined by this package. +// xdrType signals that this type represents XDR values defined by this package. func (s ClaimOfferAtomV0) xdrType() {} var _ xdrType = (*ClaimOfferAtomV0)(nil) @@ -32331,8 +32752,10 @@ func (s ClaimOfferAtom) MarshalBinary() ([]byte, error) { // UnmarshalBinary implements encoding.BinaryUnmarshaler. func (s *ClaimOfferAtom) UnmarshalBinary(inp []byte) error { r := bytes.NewReader(inp) - d := xdr.NewDecoder(r) - _, err := s.DecodeFrom(d, xdr.DecodeDefaultMaxDepth) + o := xdr.DefaultDecodeOptions + o.MaxInputLen = len(inp) + d := xdr.NewDecoderWithOptions(r, o) + _, err := s.DecodeFrom(d, o.MaxDepth) return err } @@ -32341,8 +32764,7 @@ var ( _ encoding.BinaryUnmarshaler = (*ClaimOfferAtom)(nil) ) -// xdrType signals that this type is an type representing -// representing XDR values defined by this package. +// xdrType signals that this type represents XDR values defined by this package. func (s ClaimOfferAtom) xdrType() {} var _ xdrType = (*ClaimOfferAtom)(nil) @@ -32439,8 +32861,10 @@ func (s ClaimLiquidityAtom) MarshalBinary() ([]byte, error) { // UnmarshalBinary implements encoding.BinaryUnmarshaler. func (s *ClaimLiquidityAtom) UnmarshalBinary(inp []byte) error { r := bytes.NewReader(inp) - d := xdr.NewDecoder(r) - _, err := s.DecodeFrom(d, xdr.DecodeDefaultMaxDepth) + o := xdr.DefaultDecodeOptions + o.MaxInputLen = len(inp) + d := xdr.NewDecoderWithOptions(r, o) + _, err := s.DecodeFrom(d, o.MaxDepth) return err } @@ -32449,8 +32873,7 @@ var ( _ encoding.BinaryUnmarshaler = (*ClaimLiquidityAtom)(nil) ) -// xdrType signals that this type is an type representing -// representing XDR values defined by this package. +// xdrType signals that this type represents XDR values defined by this package. func (s ClaimLiquidityAtom) xdrType() {} var _ xdrType = (*ClaimLiquidityAtom)(nil) @@ -32678,8 +33101,10 @@ func (s ClaimAtom) MarshalBinary() ([]byte, error) { // UnmarshalBinary implements encoding.BinaryUnmarshaler. func (s *ClaimAtom) UnmarshalBinary(inp []byte) error { r := bytes.NewReader(inp) - d := xdr.NewDecoder(r) - _, err := s.DecodeFrom(d, xdr.DecodeDefaultMaxDepth) + o := xdr.DefaultDecodeOptions + o.MaxInputLen = len(inp) + d := xdr.NewDecoderWithOptions(r, o) + _, err := s.DecodeFrom(d, o.MaxDepth) return err } @@ -32688,8 +33113,7 @@ var ( _ encoding.BinaryUnmarshaler = (*ClaimAtom)(nil) ) -// xdrType signals that this type is an type representing -// representing XDR values defined by this package. +// xdrType signals that this type represents XDR values defined by this package. func (s ClaimAtom) xdrType() {} var _ xdrType = (*ClaimAtom)(nil) @@ -32778,8 +33202,10 @@ func (s CreateAccountResultCode) MarshalBinary() ([]byte, error) { // UnmarshalBinary implements encoding.BinaryUnmarshaler. func (s *CreateAccountResultCode) UnmarshalBinary(inp []byte) error { r := bytes.NewReader(inp) - d := xdr.NewDecoder(r) - _, err := s.DecodeFrom(d, xdr.DecodeDefaultMaxDepth) + o := xdr.DefaultDecodeOptions + o.MaxInputLen = len(inp) + d := xdr.NewDecoderWithOptions(r, o) + _, err := s.DecodeFrom(d, o.MaxDepth) return err } @@ -32788,8 +33214,7 @@ var ( _ encoding.BinaryUnmarshaler = (*CreateAccountResultCode)(nil) ) -// xdrType signals that this type is an type representing -// representing XDR values defined by this package. +// xdrType signals that this type represents XDR values defined by this package. func (s CreateAccountResultCode) xdrType() {} var _ xdrType = (*CreateAccountResultCode)(nil) @@ -32924,8 +33349,10 @@ func (s CreateAccountResult) MarshalBinary() ([]byte, error) { // UnmarshalBinary implements encoding.BinaryUnmarshaler. func (s *CreateAccountResult) UnmarshalBinary(inp []byte) error { r := bytes.NewReader(inp) - d := xdr.NewDecoder(r) - _, err := s.DecodeFrom(d, xdr.DecodeDefaultMaxDepth) + o := xdr.DefaultDecodeOptions + o.MaxInputLen = len(inp) + d := xdr.NewDecoderWithOptions(r, o) + _, err := s.DecodeFrom(d, o.MaxDepth) return err } @@ -32934,8 +33361,7 @@ var ( _ encoding.BinaryUnmarshaler = (*CreateAccountResult)(nil) ) -// xdrType signals that this type is an type representing -// representing XDR values defined by this package. +// xdrType signals that this type represents XDR values defined by this package. func (s CreateAccountResult) xdrType() {} var _ xdrType = (*CreateAccountResult)(nil) @@ -33038,8 +33464,10 @@ func (s PaymentResultCode) MarshalBinary() ([]byte, error) { // UnmarshalBinary implements encoding.BinaryUnmarshaler. func (s *PaymentResultCode) UnmarshalBinary(inp []byte) error { r := bytes.NewReader(inp) - d := xdr.NewDecoder(r) - _, err := s.DecodeFrom(d, xdr.DecodeDefaultMaxDepth) + o := xdr.DefaultDecodeOptions + o.MaxInputLen = len(inp) + d := xdr.NewDecoderWithOptions(r, o) + _, err := s.DecodeFrom(d, o.MaxDepth) return err } @@ -33048,8 +33476,7 @@ var ( _ encoding.BinaryUnmarshaler = (*PaymentResultCode)(nil) ) -// xdrType signals that this type is an type representing -// representing XDR values defined by this package. +// xdrType signals that this type represents XDR values defined by this package. func (s PaymentResultCode) xdrType() {} var _ xdrType = (*PaymentResultCode)(nil) @@ -33239,8 +33666,10 @@ func (s PaymentResult) MarshalBinary() ([]byte, error) { // UnmarshalBinary implements encoding.BinaryUnmarshaler. func (s *PaymentResult) UnmarshalBinary(inp []byte) error { r := bytes.NewReader(inp) - d := xdr.NewDecoder(r) - _, err := s.DecodeFrom(d, xdr.DecodeDefaultMaxDepth) + o := xdr.DefaultDecodeOptions + o.MaxInputLen = len(inp) + d := xdr.NewDecoderWithOptions(r, o) + _, err := s.DecodeFrom(d, o.MaxDepth) return err } @@ -33249,8 +33678,7 @@ var ( _ encoding.BinaryUnmarshaler = (*PaymentResult)(nil) ) -// xdrType signals that this type is an type representing -// representing XDR values defined by this package. +// xdrType signals that this type represents XDR values defined by this package. func (s PaymentResult) xdrType() {} var _ xdrType = (*PaymentResult)(nil) @@ -33371,8 +33799,10 @@ func (s PathPaymentStrictReceiveResultCode) MarshalBinary() ([]byte, error) { // UnmarshalBinary implements encoding.BinaryUnmarshaler. func (s *PathPaymentStrictReceiveResultCode) UnmarshalBinary(inp []byte) error { r := bytes.NewReader(inp) - d := xdr.NewDecoder(r) - _, err := s.DecodeFrom(d, xdr.DecodeDefaultMaxDepth) + o := xdr.DefaultDecodeOptions + o.MaxInputLen = len(inp) + d := xdr.NewDecoderWithOptions(r, o) + _, err := s.DecodeFrom(d, o.MaxDepth) return err } @@ -33381,8 +33811,7 @@ var ( _ encoding.BinaryUnmarshaler = (*PathPaymentStrictReceiveResultCode)(nil) ) -// xdrType signals that this type is an type representing -// representing XDR values defined by this package. +// xdrType signals that this type represents XDR values defined by this package. func (s PathPaymentStrictReceiveResultCode) xdrType() {} var _ xdrType = (*PathPaymentStrictReceiveResultCode)(nil) @@ -33455,8 +33884,10 @@ func (s SimplePaymentResult) MarshalBinary() ([]byte, error) { // UnmarshalBinary implements encoding.BinaryUnmarshaler. func (s *SimplePaymentResult) UnmarshalBinary(inp []byte) error { r := bytes.NewReader(inp) - d := xdr.NewDecoder(r) - _, err := s.DecodeFrom(d, xdr.DecodeDefaultMaxDepth) + o := xdr.DefaultDecodeOptions + o.MaxInputLen = len(inp) + d := xdr.NewDecoderWithOptions(r, o) + _, err := s.DecodeFrom(d, o.MaxDepth) return err } @@ -33465,8 +33896,7 @@ var ( _ encoding.BinaryUnmarshaler = (*SimplePaymentResult)(nil) ) -// xdrType signals that this type is an type representing -// representing XDR values defined by this package. +// xdrType signals that this type represents XDR values defined by this package. func (s SimplePaymentResult) xdrType() {} var _ xdrType = (*SimplePaymentResult)(nil) @@ -33518,8 +33948,11 @@ func (s *PathPaymentStrictReceiveResultSuccess) DecodeFrom(d *xdr.Decoder, maxDe } s.Offers = nil if l > 0 { + if il, ok := d.InputLen(); ok && uint(il) < uint(l) { + return n, fmt.Errorf("decoding ClaimAtom: length (%d) exceeds remaining input length (%d)", l, il) + } s.Offers = make([]ClaimAtom, l) - for i := uint32(0); i < l; i++ { + for i := uint32(0); uint(i) < uint(l); i++ { nTmp, err = s.Offers[i].DecodeFrom(d, maxDepth) n += nTmp if err != nil { @@ -33546,8 +33979,10 @@ func (s PathPaymentStrictReceiveResultSuccess) MarshalBinary() ([]byte, error) { // UnmarshalBinary implements encoding.BinaryUnmarshaler. func (s *PathPaymentStrictReceiveResultSuccess) UnmarshalBinary(inp []byte) error { r := bytes.NewReader(inp) - d := xdr.NewDecoder(r) - _, err := s.DecodeFrom(d, xdr.DecodeDefaultMaxDepth) + o := xdr.DefaultDecodeOptions + o.MaxInputLen = len(inp) + d := xdr.NewDecoderWithOptions(r, o) + _, err := s.DecodeFrom(d, o.MaxDepth) return err } @@ -33556,8 +33991,7 @@ var ( _ encoding.BinaryUnmarshaler = (*PathPaymentStrictReceiveResultSuccess)(nil) ) -// xdrType signals that this type is an type representing -// representing XDR values defined by this package. +// xdrType signals that this type represents XDR values defined by this package. func (s PathPaymentStrictReceiveResultSuccess) xdrType() {} var _ xdrType = (*PathPaymentStrictReceiveResultSuccess)(nil) @@ -33863,8 +34297,10 @@ func (s PathPaymentStrictReceiveResult) MarshalBinary() ([]byte, error) { // UnmarshalBinary implements encoding.BinaryUnmarshaler. func (s *PathPaymentStrictReceiveResult) UnmarshalBinary(inp []byte) error { r := bytes.NewReader(inp) - d := xdr.NewDecoder(r) - _, err := s.DecodeFrom(d, xdr.DecodeDefaultMaxDepth) + o := xdr.DefaultDecodeOptions + o.MaxInputLen = len(inp) + d := xdr.NewDecoderWithOptions(r, o) + _, err := s.DecodeFrom(d, o.MaxDepth) return err } @@ -33873,8 +34309,7 @@ var ( _ encoding.BinaryUnmarshaler = (*PathPaymentStrictReceiveResult)(nil) ) -// xdrType signals that this type is an type representing -// representing XDR values defined by this package. +// xdrType signals that this type represents XDR values defined by this package. func (s PathPaymentStrictReceiveResult) xdrType() {} var _ xdrType = (*PathPaymentStrictReceiveResult)(nil) @@ -33994,8 +34429,10 @@ func (s PathPaymentStrictSendResultCode) MarshalBinary() ([]byte, error) { // UnmarshalBinary implements encoding.BinaryUnmarshaler. func (s *PathPaymentStrictSendResultCode) UnmarshalBinary(inp []byte) error { r := bytes.NewReader(inp) - d := xdr.NewDecoder(r) - _, err := s.DecodeFrom(d, xdr.DecodeDefaultMaxDepth) + o := xdr.DefaultDecodeOptions + o.MaxInputLen = len(inp) + d := xdr.NewDecoderWithOptions(r, o) + _, err := s.DecodeFrom(d, o.MaxDepth) return err } @@ -34004,8 +34441,7 @@ var ( _ encoding.BinaryUnmarshaler = (*PathPaymentStrictSendResultCode)(nil) ) -// xdrType signals that this type is an type representing -// representing XDR values defined by this package. +// xdrType signals that this type represents XDR values defined by this package. func (s PathPaymentStrictSendResultCode) xdrType() {} var _ xdrType = (*PathPaymentStrictSendResultCode)(nil) @@ -34057,8 +34493,11 @@ func (s *PathPaymentStrictSendResultSuccess) DecodeFrom(d *xdr.Decoder, maxDepth } s.Offers = nil if l > 0 { + if il, ok := d.InputLen(); ok && uint(il) < uint(l) { + return n, fmt.Errorf("decoding ClaimAtom: length (%d) exceeds remaining input length (%d)", l, il) + } s.Offers = make([]ClaimAtom, l) - for i := uint32(0); i < l; i++ { + for i := uint32(0); uint(i) < uint(l); i++ { nTmp, err = s.Offers[i].DecodeFrom(d, maxDepth) n += nTmp if err != nil { @@ -34085,8 +34524,10 @@ func (s PathPaymentStrictSendResultSuccess) MarshalBinary() ([]byte, error) { // UnmarshalBinary implements encoding.BinaryUnmarshaler. func (s *PathPaymentStrictSendResultSuccess) UnmarshalBinary(inp []byte) error { r := bytes.NewReader(inp) - d := xdr.NewDecoder(r) - _, err := s.DecodeFrom(d, xdr.DecodeDefaultMaxDepth) + o := xdr.DefaultDecodeOptions + o.MaxInputLen = len(inp) + d := xdr.NewDecoderWithOptions(r, o) + _, err := s.DecodeFrom(d, o.MaxDepth) return err } @@ -34095,8 +34536,7 @@ var ( _ encoding.BinaryUnmarshaler = (*PathPaymentStrictSendResultSuccess)(nil) ) -// xdrType signals that this type is an type representing -// representing XDR values defined by this package. +// xdrType signals that this type represents XDR values defined by this package. func (s PathPaymentStrictSendResultSuccess) xdrType() {} var _ xdrType = (*PathPaymentStrictSendResultSuccess)(nil) @@ -34401,8 +34841,10 @@ func (s PathPaymentStrictSendResult) MarshalBinary() ([]byte, error) { // UnmarshalBinary implements encoding.BinaryUnmarshaler. func (s *PathPaymentStrictSendResult) UnmarshalBinary(inp []byte) error { r := bytes.NewReader(inp) - d := xdr.NewDecoder(r) - _, err := s.DecodeFrom(d, xdr.DecodeDefaultMaxDepth) + o := xdr.DefaultDecodeOptions + o.MaxInputLen = len(inp) + d := xdr.NewDecoderWithOptions(r, o) + _, err := s.DecodeFrom(d, o.MaxDepth) return err } @@ -34411,8 +34853,7 @@ var ( _ encoding.BinaryUnmarshaler = (*PathPaymentStrictSendResult)(nil) ) -// xdrType signals that this type is an type representing -// representing XDR values defined by this package. +// xdrType signals that this type represents XDR values defined by this package. func (s PathPaymentStrictSendResult) xdrType() {} var _ xdrType = (*PathPaymentStrictSendResult)(nil) @@ -34531,8 +34972,10 @@ func (s ManageSellOfferResultCode) MarshalBinary() ([]byte, error) { // UnmarshalBinary implements encoding.BinaryUnmarshaler. func (s *ManageSellOfferResultCode) UnmarshalBinary(inp []byte) error { r := bytes.NewReader(inp) - d := xdr.NewDecoder(r) - _, err := s.DecodeFrom(d, xdr.DecodeDefaultMaxDepth) + o := xdr.DefaultDecodeOptions + o.MaxInputLen = len(inp) + d := xdr.NewDecoderWithOptions(r, o) + _, err := s.DecodeFrom(d, o.MaxDepth) return err } @@ -34541,8 +34984,7 @@ var ( _ encoding.BinaryUnmarshaler = (*ManageSellOfferResultCode)(nil) ) -// xdrType signals that this type is an type representing -// representing XDR values defined by this package. +// xdrType signals that this type represents XDR values defined by this package. func (s ManageSellOfferResultCode) xdrType() {} var _ xdrType = (*ManageSellOfferResultCode)(nil) @@ -34621,8 +35063,10 @@ func (s ManageOfferEffect) MarshalBinary() ([]byte, error) { // UnmarshalBinary implements encoding.BinaryUnmarshaler. func (s *ManageOfferEffect) UnmarshalBinary(inp []byte) error { r := bytes.NewReader(inp) - d := xdr.NewDecoder(r) - _, err := s.DecodeFrom(d, xdr.DecodeDefaultMaxDepth) + o := xdr.DefaultDecodeOptions + o.MaxInputLen = len(inp) + d := xdr.NewDecoderWithOptions(r, o) + _, err := s.DecodeFrom(d, o.MaxDepth) return err } @@ -34631,8 +35075,7 @@ var ( _ encoding.BinaryUnmarshaler = (*ManageOfferEffect)(nil) ) -// xdrType signals that this type is an type representing -// representing XDR values defined by this package. +// xdrType signals that this type represents XDR values defined by this package. func (s ManageOfferEffect) xdrType() {} var _ xdrType = (*ManageOfferEffect)(nil) @@ -34795,8 +35238,10 @@ func (s ManageOfferSuccessResultOffer) MarshalBinary() ([]byte, error) { // UnmarshalBinary implements encoding.BinaryUnmarshaler. func (s *ManageOfferSuccessResultOffer) UnmarshalBinary(inp []byte) error { r := bytes.NewReader(inp) - d := xdr.NewDecoder(r) - _, err := s.DecodeFrom(d, xdr.DecodeDefaultMaxDepth) + o := xdr.DefaultDecodeOptions + o.MaxInputLen = len(inp) + d := xdr.NewDecoderWithOptions(r, o) + _, err := s.DecodeFrom(d, o.MaxDepth) return err } @@ -34805,8 +35250,7 @@ var ( _ encoding.BinaryUnmarshaler = (*ManageOfferSuccessResultOffer)(nil) ) -// xdrType signals that this type is an type representing -// representing XDR values defined by this package. +// xdrType signals that this type represents XDR values defined by this package. func (s ManageOfferSuccessResultOffer) xdrType() {} var _ xdrType = (*ManageOfferSuccessResultOffer)(nil) @@ -34868,8 +35312,11 @@ func (s *ManageOfferSuccessResult) DecodeFrom(d *xdr.Decoder, maxDepth uint) (in } s.OffersClaimed = nil if l > 0 { + if il, ok := d.InputLen(); ok && uint(il) < uint(l) { + return n, fmt.Errorf("decoding ClaimAtom: length (%d) exceeds remaining input length (%d)", l, il) + } s.OffersClaimed = make([]ClaimAtom, l) - for i := uint32(0); i < l; i++ { + for i := uint32(0); uint(i) < uint(l); i++ { nTmp, err = s.OffersClaimed[i].DecodeFrom(d, maxDepth) n += nTmp if err != nil { @@ -34896,8 +35343,10 @@ func (s ManageOfferSuccessResult) MarshalBinary() ([]byte, error) { // UnmarshalBinary implements encoding.BinaryUnmarshaler. func (s *ManageOfferSuccessResult) UnmarshalBinary(inp []byte) error { r := bytes.NewReader(inp) - d := xdr.NewDecoder(r) - _, err := s.DecodeFrom(d, xdr.DecodeDefaultMaxDepth) + o := xdr.DefaultDecodeOptions + o.MaxInputLen = len(inp) + d := xdr.NewDecoderWithOptions(r, o) + _, err := s.DecodeFrom(d, o.MaxDepth) return err } @@ -34906,8 +35355,7 @@ var ( _ encoding.BinaryUnmarshaler = (*ManageOfferSuccessResult)(nil) ) -// xdrType signals that this type is an type representing -// representing XDR values defined by this package. +// xdrType signals that this type represents XDR values defined by this package. func (s ManageOfferSuccessResult) xdrType() {} var _ xdrType = (*ManageOfferSuccessResult)(nil) @@ -35168,8 +35616,10 @@ func (s ManageSellOfferResult) MarshalBinary() ([]byte, error) { // UnmarshalBinary implements encoding.BinaryUnmarshaler. func (s *ManageSellOfferResult) UnmarshalBinary(inp []byte) error { r := bytes.NewReader(inp) - d := xdr.NewDecoder(r) - _, err := s.DecodeFrom(d, xdr.DecodeDefaultMaxDepth) + o := xdr.DefaultDecodeOptions + o.MaxInputLen = len(inp) + d := xdr.NewDecoderWithOptions(r, o) + _, err := s.DecodeFrom(d, o.MaxDepth) return err } @@ -35178,8 +35628,7 @@ var ( _ encoding.BinaryUnmarshaler = (*ManageSellOfferResult)(nil) ) -// xdrType signals that this type is an type representing -// representing XDR values defined by this package. +// xdrType signals that this type represents XDR values defined by this package. func (s ManageSellOfferResult) xdrType() {} var _ xdrType = (*ManageSellOfferResult)(nil) @@ -35295,8 +35744,10 @@ func (s ManageBuyOfferResultCode) MarshalBinary() ([]byte, error) { // UnmarshalBinary implements encoding.BinaryUnmarshaler. func (s *ManageBuyOfferResultCode) UnmarshalBinary(inp []byte) error { r := bytes.NewReader(inp) - d := xdr.NewDecoder(r) - _, err := s.DecodeFrom(d, xdr.DecodeDefaultMaxDepth) + o := xdr.DefaultDecodeOptions + o.MaxInputLen = len(inp) + d := xdr.NewDecoderWithOptions(r, o) + _, err := s.DecodeFrom(d, o.MaxDepth) return err } @@ -35305,8 +35756,7 @@ var ( _ encoding.BinaryUnmarshaler = (*ManageBuyOfferResultCode)(nil) ) -// xdrType signals that this type is an type representing -// representing XDR values defined by this package. +// xdrType signals that this type represents XDR values defined by this package. func (s ManageBuyOfferResultCode) xdrType() {} var _ xdrType = (*ManageBuyOfferResultCode)(nil) @@ -35567,8 +36017,10 @@ func (s ManageBuyOfferResult) MarshalBinary() ([]byte, error) { // UnmarshalBinary implements encoding.BinaryUnmarshaler. func (s *ManageBuyOfferResult) UnmarshalBinary(inp []byte) error { r := bytes.NewReader(inp) - d := xdr.NewDecoder(r) - _, err := s.DecodeFrom(d, xdr.DecodeDefaultMaxDepth) + o := xdr.DefaultDecodeOptions + o.MaxInputLen = len(inp) + d := xdr.NewDecoderWithOptions(r, o) + _, err := s.DecodeFrom(d, o.MaxDepth) return err } @@ -35577,8 +36029,7 @@ var ( _ encoding.BinaryUnmarshaler = (*ManageBuyOfferResult)(nil) ) -// xdrType signals that this type is an type representing -// representing XDR values defined by this package. +// xdrType signals that this type represents XDR values defined by this package. func (s ManageBuyOfferResult) xdrType() {} var _ xdrType = (*ManageBuyOfferResult)(nil) @@ -35684,8 +36135,10 @@ func (s SetOptionsResultCode) MarshalBinary() ([]byte, error) { // UnmarshalBinary implements encoding.BinaryUnmarshaler. func (s *SetOptionsResultCode) UnmarshalBinary(inp []byte) error { r := bytes.NewReader(inp) - d := xdr.NewDecoder(r) - _, err := s.DecodeFrom(d, xdr.DecodeDefaultMaxDepth) + o := xdr.DefaultDecodeOptions + o.MaxInputLen = len(inp) + d := xdr.NewDecoderWithOptions(r, o) + _, err := s.DecodeFrom(d, o.MaxDepth) return err } @@ -35694,8 +36147,7 @@ var ( _ encoding.BinaryUnmarshaler = (*SetOptionsResultCode)(nil) ) -// xdrType signals that this type is an type representing -// representing XDR values defined by this package. +// xdrType signals that this type represents XDR values defined by this package. func (s SetOptionsResultCode) xdrType() {} var _ xdrType = (*SetOptionsResultCode)(nil) @@ -35896,8 +36348,10 @@ func (s SetOptionsResult) MarshalBinary() ([]byte, error) { // UnmarshalBinary implements encoding.BinaryUnmarshaler. func (s *SetOptionsResult) UnmarshalBinary(inp []byte) error { r := bytes.NewReader(inp) - d := xdr.NewDecoder(r) - _, err := s.DecodeFrom(d, xdr.DecodeDefaultMaxDepth) + o := xdr.DefaultDecodeOptions + o.MaxInputLen = len(inp) + d := xdr.NewDecoderWithOptions(r, o) + _, err := s.DecodeFrom(d, o.MaxDepth) return err } @@ -35906,8 +36360,7 @@ var ( _ encoding.BinaryUnmarshaler = (*SetOptionsResult)(nil) ) -// xdrType signals that this type is an type representing -// representing XDR values defined by this package. +// xdrType signals that this type represents XDR values defined by this package. func (s SetOptionsResult) xdrType() {} var _ xdrType = (*SetOptionsResult)(nil) @@ -36010,8 +36463,10 @@ func (s ChangeTrustResultCode) MarshalBinary() ([]byte, error) { // UnmarshalBinary implements encoding.BinaryUnmarshaler. func (s *ChangeTrustResultCode) UnmarshalBinary(inp []byte) error { r := bytes.NewReader(inp) - d := xdr.NewDecoder(r) - _, err := s.DecodeFrom(d, xdr.DecodeDefaultMaxDepth) + o := xdr.DefaultDecodeOptions + o.MaxInputLen = len(inp) + d := xdr.NewDecoderWithOptions(r, o) + _, err := s.DecodeFrom(d, o.MaxDepth) return err } @@ -36020,8 +36475,7 @@ var ( _ encoding.BinaryUnmarshaler = (*ChangeTrustResultCode)(nil) ) -// xdrType signals that this type is an type representing -// representing XDR values defined by this package. +// xdrType signals that this type represents XDR values defined by this package. func (s ChangeTrustResultCode) xdrType() {} var _ xdrType = (*ChangeTrustResultCode)(nil) @@ -36200,8 +36654,10 @@ func (s ChangeTrustResult) MarshalBinary() ([]byte, error) { // UnmarshalBinary implements encoding.BinaryUnmarshaler. func (s *ChangeTrustResult) UnmarshalBinary(inp []byte) error { r := bytes.NewReader(inp) - d := xdr.NewDecoder(r) - _, err := s.DecodeFrom(d, xdr.DecodeDefaultMaxDepth) + o := xdr.DefaultDecodeOptions + o.MaxInputLen = len(inp) + d := xdr.NewDecoderWithOptions(r, o) + _, err := s.DecodeFrom(d, o.MaxDepth) return err } @@ -36210,8 +36666,7 @@ var ( _ encoding.BinaryUnmarshaler = (*ChangeTrustResult)(nil) ) -// xdrType signals that this type is an type representing -// representing XDR values defined by this package. +// xdrType signals that this type represents XDR values defined by this package. func (s ChangeTrustResult) xdrType() {} var _ xdrType = (*ChangeTrustResult)(nil) @@ -36306,8 +36761,10 @@ func (s AllowTrustResultCode) MarshalBinary() ([]byte, error) { // UnmarshalBinary implements encoding.BinaryUnmarshaler. func (s *AllowTrustResultCode) UnmarshalBinary(inp []byte) error { r := bytes.NewReader(inp) - d := xdr.NewDecoder(r) - _, err := s.DecodeFrom(d, xdr.DecodeDefaultMaxDepth) + o := xdr.DefaultDecodeOptions + o.MaxInputLen = len(inp) + d := xdr.NewDecoderWithOptions(r, o) + _, err := s.DecodeFrom(d, o.MaxDepth) return err } @@ -36316,8 +36773,7 @@ var ( _ encoding.BinaryUnmarshaler = (*AllowTrustResultCode)(nil) ) -// xdrType signals that this type is an type representing -// representing XDR values defined by this package. +// xdrType signals that this type represents XDR values defined by this package. func (s AllowTrustResultCode) xdrType() {} var _ xdrType = (*AllowTrustResultCode)(nil) @@ -36474,8 +36930,10 @@ func (s AllowTrustResult) MarshalBinary() ([]byte, error) { // UnmarshalBinary implements encoding.BinaryUnmarshaler. func (s *AllowTrustResult) UnmarshalBinary(inp []byte) error { r := bytes.NewReader(inp) - d := xdr.NewDecoder(r) - _, err := s.DecodeFrom(d, xdr.DecodeDefaultMaxDepth) + o := xdr.DefaultDecodeOptions + o.MaxInputLen = len(inp) + d := xdr.NewDecoderWithOptions(r, o) + _, err := s.DecodeFrom(d, o.MaxDepth) return err } @@ -36484,8 +36942,7 @@ var ( _ encoding.BinaryUnmarshaler = (*AllowTrustResult)(nil) ) -// xdrType signals that this type is an type representing -// representing XDR values defined by this package. +// xdrType signals that this type represents XDR values defined by this package. func (s AllowTrustResult) xdrType() {} var _ xdrType = (*AllowTrustResult)(nil) @@ -36582,8 +37039,10 @@ func (s AccountMergeResultCode) MarshalBinary() ([]byte, error) { // UnmarshalBinary implements encoding.BinaryUnmarshaler. func (s *AccountMergeResultCode) UnmarshalBinary(inp []byte) error { r := bytes.NewReader(inp) - d := xdr.NewDecoder(r) - _, err := s.DecodeFrom(d, xdr.DecodeDefaultMaxDepth) + o := xdr.DefaultDecodeOptions + o.MaxInputLen = len(inp) + d := xdr.NewDecoderWithOptions(r, o) + _, err := s.DecodeFrom(d, o.MaxDepth) return err } @@ -36592,8 +37051,7 @@ var ( _ encoding.BinaryUnmarshaler = (*AccountMergeResultCode)(nil) ) -// xdrType signals that this type is an type representing -// representing XDR values defined by this package. +// xdrType signals that this type represents XDR values defined by this package. func (s AccountMergeResultCode) xdrType() {} var _ xdrType = (*AccountMergeResultCode)(nil) @@ -36799,8 +37257,10 @@ func (s AccountMergeResult) MarshalBinary() ([]byte, error) { // UnmarshalBinary implements encoding.BinaryUnmarshaler. func (s *AccountMergeResult) UnmarshalBinary(inp []byte) error { r := bytes.NewReader(inp) - d := xdr.NewDecoder(r) - _, err := s.DecodeFrom(d, xdr.DecodeDefaultMaxDepth) + o := xdr.DefaultDecodeOptions + o.MaxInputLen = len(inp) + d := xdr.NewDecoderWithOptions(r, o) + _, err := s.DecodeFrom(d, o.MaxDepth) return err } @@ -36809,8 +37269,7 @@ var ( _ encoding.BinaryUnmarshaler = (*AccountMergeResult)(nil) ) -// xdrType signals that this type is an type representing -// representing XDR values defined by this package. +// xdrType signals that this type represents XDR values defined by this package. func (s AccountMergeResult) xdrType() {} var _ xdrType = (*AccountMergeResult)(nil) @@ -36888,8 +37347,10 @@ func (s InflationResultCode) MarshalBinary() ([]byte, error) { // UnmarshalBinary implements encoding.BinaryUnmarshaler. func (s *InflationResultCode) UnmarshalBinary(inp []byte) error { r := bytes.NewReader(inp) - d := xdr.NewDecoder(r) - _, err := s.DecodeFrom(d, xdr.DecodeDefaultMaxDepth) + o := xdr.DefaultDecodeOptions + o.MaxInputLen = len(inp) + d := xdr.NewDecoderWithOptions(r, o) + _, err := s.DecodeFrom(d, o.MaxDepth) return err } @@ -36898,8 +37359,7 @@ var ( _ encoding.BinaryUnmarshaler = (*InflationResultCode)(nil) ) -// xdrType signals that this type is an type representing -// representing XDR values defined by this package. +// xdrType signals that this type represents XDR values defined by this package. func (s InflationResultCode) xdrType() {} var _ xdrType = (*InflationResultCode)(nil) @@ -36962,8 +37422,10 @@ func (s InflationPayout) MarshalBinary() ([]byte, error) { // UnmarshalBinary implements encoding.BinaryUnmarshaler. func (s *InflationPayout) UnmarshalBinary(inp []byte) error { r := bytes.NewReader(inp) - d := xdr.NewDecoder(r) - _, err := s.DecodeFrom(d, xdr.DecodeDefaultMaxDepth) + o := xdr.DefaultDecodeOptions + o.MaxInputLen = len(inp) + d := xdr.NewDecoderWithOptions(r, o) + _, err := s.DecodeFrom(d, o.MaxDepth) return err } @@ -36972,8 +37434,7 @@ var ( _ encoding.BinaryUnmarshaler = (*InflationPayout)(nil) ) -// xdrType signals that this type is an type representing -// representing XDR values defined by this package. +// xdrType signals that this type represents XDR values defined by this package. func (s InflationPayout) xdrType() {} var _ xdrType = (*InflationPayout)(nil) @@ -37102,8 +37563,11 @@ func (u *InflationResult) DecodeFrom(d *xdr.Decoder, maxDepth uint) (int, error) } (*u.Payouts) = nil if l > 0 { + if il, ok := d.InputLen(); ok && uint(il) < uint(l) { + return n, fmt.Errorf("decoding InflationPayout: length (%d) exceeds remaining input length (%d)", l, il) + } (*u.Payouts) = make([]InflationPayout, l) - for i := uint32(0); i < l; i++ { + for i := uint32(0); uint(i) < uint(l); i++ { nTmp, err = (*u.Payouts)[i].DecodeFrom(d, maxDepth) n += nTmp if err != nil { @@ -37130,8 +37594,10 @@ func (s InflationResult) MarshalBinary() ([]byte, error) { // UnmarshalBinary implements encoding.BinaryUnmarshaler. func (s *InflationResult) UnmarshalBinary(inp []byte) error { r := bytes.NewReader(inp) - d := xdr.NewDecoder(r) - _, err := s.DecodeFrom(d, xdr.DecodeDefaultMaxDepth) + o := xdr.DefaultDecodeOptions + o.MaxInputLen = len(inp) + d := xdr.NewDecoderWithOptions(r, o) + _, err := s.DecodeFrom(d, o.MaxDepth) return err } @@ -37140,8 +37606,7 @@ var ( _ encoding.BinaryUnmarshaler = (*InflationResult)(nil) ) -// xdrType signals that this type is an type representing -// representing XDR values defined by this package. +// xdrType signals that this type represents XDR values defined by this package. func (s InflationResult) xdrType() {} var _ xdrType = (*InflationResult)(nil) @@ -37230,8 +37695,10 @@ func (s ManageDataResultCode) MarshalBinary() ([]byte, error) { // UnmarshalBinary implements encoding.BinaryUnmarshaler. func (s *ManageDataResultCode) UnmarshalBinary(inp []byte) error { r := bytes.NewReader(inp) - d := xdr.NewDecoder(r) - _, err := s.DecodeFrom(d, xdr.DecodeDefaultMaxDepth) + o := xdr.DefaultDecodeOptions + o.MaxInputLen = len(inp) + d := xdr.NewDecoderWithOptions(r, o) + _, err := s.DecodeFrom(d, o.MaxDepth) return err } @@ -37240,8 +37707,7 @@ var ( _ encoding.BinaryUnmarshaler = (*ManageDataResultCode)(nil) ) -// xdrType signals that this type is an type representing -// representing XDR values defined by this package. +// xdrType signals that this type represents XDR values defined by this package. func (s ManageDataResultCode) xdrType() {} var _ xdrType = (*ManageDataResultCode)(nil) @@ -37376,8 +37842,10 @@ func (s ManageDataResult) MarshalBinary() ([]byte, error) { // UnmarshalBinary implements encoding.BinaryUnmarshaler. func (s *ManageDataResult) UnmarshalBinary(inp []byte) error { r := bytes.NewReader(inp) - d := xdr.NewDecoder(r) - _, err := s.DecodeFrom(d, xdr.DecodeDefaultMaxDepth) + o := xdr.DefaultDecodeOptions + o.MaxInputLen = len(inp) + d := xdr.NewDecoderWithOptions(r, o) + _, err := s.DecodeFrom(d, o.MaxDepth) return err } @@ -37386,8 +37854,7 @@ var ( _ encoding.BinaryUnmarshaler = (*ManageDataResult)(nil) ) -// xdrType signals that this type is an type representing -// representing XDR values defined by this package. +// xdrType signals that this type represents XDR values defined by this package. func (s ManageDataResult) xdrType() {} var _ xdrType = (*ManageDataResult)(nil) @@ -37465,8 +37932,10 @@ func (s BumpSequenceResultCode) MarshalBinary() ([]byte, error) { // UnmarshalBinary implements encoding.BinaryUnmarshaler. func (s *BumpSequenceResultCode) UnmarshalBinary(inp []byte) error { r := bytes.NewReader(inp) - d := xdr.NewDecoder(r) - _, err := s.DecodeFrom(d, xdr.DecodeDefaultMaxDepth) + o := xdr.DefaultDecodeOptions + o.MaxInputLen = len(inp) + d := xdr.NewDecoderWithOptions(r, o) + _, err := s.DecodeFrom(d, o.MaxDepth) return err } @@ -37475,8 +37944,7 @@ var ( _ encoding.BinaryUnmarshaler = (*BumpSequenceResultCode)(nil) ) -// xdrType signals that this type is an type representing -// representing XDR values defined by this package. +// xdrType signals that this type represents XDR values defined by this package. func (s BumpSequenceResultCode) xdrType() {} var _ xdrType = (*BumpSequenceResultCode)(nil) @@ -37578,8 +38046,10 @@ func (s BumpSequenceResult) MarshalBinary() ([]byte, error) { // UnmarshalBinary implements encoding.BinaryUnmarshaler. func (s *BumpSequenceResult) UnmarshalBinary(inp []byte) error { r := bytes.NewReader(inp) - d := xdr.NewDecoder(r) - _, err := s.DecodeFrom(d, xdr.DecodeDefaultMaxDepth) + o := xdr.DefaultDecodeOptions + o.MaxInputLen = len(inp) + d := xdr.NewDecoderWithOptions(r, o) + _, err := s.DecodeFrom(d, o.MaxDepth) return err } @@ -37588,8 +38058,7 @@ var ( _ encoding.BinaryUnmarshaler = (*BumpSequenceResult)(nil) ) -// xdrType signals that this type is an type representing -// representing XDR values defined by this package. +// xdrType signals that this type represents XDR values defined by this package. func (s BumpSequenceResult) xdrType() {} var _ xdrType = (*BumpSequenceResult)(nil) @@ -37677,8 +38146,10 @@ func (s CreateClaimableBalanceResultCode) MarshalBinary() ([]byte, error) { // UnmarshalBinary implements encoding.BinaryUnmarshaler. func (s *CreateClaimableBalanceResultCode) UnmarshalBinary(inp []byte) error { r := bytes.NewReader(inp) - d := xdr.NewDecoder(r) - _, err := s.DecodeFrom(d, xdr.DecodeDefaultMaxDepth) + o := xdr.DefaultDecodeOptions + o.MaxInputLen = len(inp) + d := xdr.NewDecoderWithOptions(r, o) + _, err := s.DecodeFrom(d, o.MaxDepth) return err } @@ -37687,8 +38158,7 @@ var ( _ encoding.BinaryUnmarshaler = (*CreateClaimableBalanceResultCode)(nil) ) -// xdrType signals that this type is an type representing -// representing XDR values defined by this package. +// xdrType signals that this type represents XDR values defined by this package. func (s CreateClaimableBalanceResultCode) xdrType() {} var _ xdrType = (*CreateClaimableBalanceResultCode)(nil) @@ -37873,8 +38343,10 @@ func (s CreateClaimableBalanceResult) MarshalBinary() ([]byte, error) { // UnmarshalBinary implements encoding.BinaryUnmarshaler. func (s *CreateClaimableBalanceResult) UnmarshalBinary(inp []byte) error { r := bytes.NewReader(inp) - d := xdr.NewDecoder(r) - _, err := s.DecodeFrom(d, xdr.DecodeDefaultMaxDepth) + o := xdr.DefaultDecodeOptions + o.MaxInputLen = len(inp) + d := xdr.NewDecoderWithOptions(r, o) + _, err := s.DecodeFrom(d, o.MaxDepth) return err } @@ -37883,8 +38355,7 @@ var ( _ encoding.BinaryUnmarshaler = (*CreateClaimableBalanceResult)(nil) ) -// xdrType signals that this type is an type representing -// representing XDR values defined by this package. +// xdrType signals that this type represents XDR values defined by this package. func (s CreateClaimableBalanceResult) xdrType() {} var _ xdrType = (*CreateClaimableBalanceResult)(nil) @@ -37972,8 +38443,10 @@ func (s ClaimClaimableBalanceResultCode) MarshalBinary() ([]byte, error) { // UnmarshalBinary implements encoding.BinaryUnmarshaler. func (s *ClaimClaimableBalanceResultCode) UnmarshalBinary(inp []byte) error { r := bytes.NewReader(inp) - d := xdr.NewDecoder(r) - _, err := s.DecodeFrom(d, xdr.DecodeDefaultMaxDepth) + o := xdr.DefaultDecodeOptions + o.MaxInputLen = len(inp) + d := xdr.NewDecoderWithOptions(r, o) + _, err := s.DecodeFrom(d, o.MaxDepth) return err } @@ -37982,8 +38455,7 @@ var ( _ encoding.BinaryUnmarshaler = (*ClaimClaimableBalanceResultCode)(nil) ) -// xdrType signals that this type is an type representing -// representing XDR values defined by this package. +// xdrType signals that this type represents XDR values defined by this package. func (s ClaimClaimableBalanceResultCode) xdrType() {} var _ xdrType = (*ClaimClaimableBalanceResultCode)(nil) @@ -38129,8 +38601,10 @@ func (s ClaimClaimableBalanceResult) MarshalBinary() ([]byte, error) { // UnmarshalBinary implements encoding.BinaryUnmarshaler. func (s *ClaimClaimableBalanceResult) UnmarshalBinary(inp []byte) error { r := bytes.NewReader(inp) - d := xdr.NewDecoder(r) - _, err := s.DecodeFrom(d, xdr.DecodeDefaultMaxDepth) + o := xdr.DefaultDecodeOptions + o.MaxInputLen = len(inp) + d := xdr.NewDecoderWithOptions(r, o) + _, err := s.DecodeFrom(d, o.MaxDepth) return err } @@ -38139,8 +38613,7 @@ var ( _ encoding.BinaryUnmarshaler = (*ClaimClaimableBalanceResult)(nil) ) -// xdrType signals that this type is an type representing -// representing XDR values defined by this package. +// xdrType signals that this type represents XDR values defined by this package. func (s ClaimClaimableBalanceResult) xdrType() {} var _ xdrType = (*ClaimClaimableBalanceResult)(nil) @@ -38225,8 +38698,10 @@ func (s BeginSponsoringFutureReservesResultCode) MarshalBinary() ([]byte, error) // UnmarshalBinary implements encoding.BinaryUnmarshaler. func (s *BeginSponsoringFutureReservesResultCode) UnmarshalBinary(inp []byte) error { r := bytes.NewReader(inp) - d := xdr.NewDecoder(r) - _, err := s.DecodeFrom(d, xdr.DecodeDefaultMaxDepth) + o := xdr.DefaultDecodeOptions + o.MaxInputLen = len(inp) + d := xdr.NewDecoderWithOptions(r, o) + _, err := s.DecodeFrom(d, o.MaxDepth) return err } @@ -38235,8 +38710,7 @@ var ( _ encoding.BinaryUnmarshaler = (*BeginSponsoringFutureReservesResultCode)(nil) ) -// xdrType signals that this type is an type representing -// representing XDR values defined by this package. +// xdrType signals that this type represents XDR values defined by this package. func (s BeginSponsoringFutureReservesResultCode) xdrType() {} var _ xdrType = (*BeginSponsoringFutureReservesResultCode)(nil) @@ -38361,8 +38835,10 @@ func (s BeginSponsoringFutureReservesResult) MarshalBinary() ([]byte, error) { // UnmarshalBinary implements encoding.BinaryUnmarshaler. func (s *BeginSponsoringFutureReservesResult) UnmarshalBinary(inp []byte) error { r := bytes.NewReader(inp) - d := xdr.NewDecoder(r) - _, err := s.DecodeFrom(d, xdr.DecodeDefaultMaxDepth) + o := xdr.DefaultDecodeOptions + o.MaxInputLen = len(inp) + d := xdr.NewDecoderWithOptions(r, o) + _, err := s.DecodeFrom(d, o.MaxDepth) return err } @@ -38371,8 +38847,7 @@ var ( _ encoding.BinaryUnmarshaler = (*BeginSponsoringFutureReservesResult)(nil) ) -// xdrType signals that this type is an type representing -// representing XDR values defined by this package. +// xdrType signals that this type represents XDR values defined by this package. func (s BeginSponsoringFutureReservesResult) xdrType() {} var _ xdrType = (*BeginSponsoringFutureReservesResult)(nil) @@ -38451,8 +38926,10 @@ func (s EndSponsoringFutureReservesResultCode) MarshalBinary() ([]byte, error) { // UnmarshalBinary implements encoding.BinaryUnmarshaler. func (s *EndSponsoringFutureReservesResultCode) UnmarshalBinary(inp []byte) error { r := bytes.NewReader(inp) - d := xdr.NewDecoder(r) - _, err := s.DecodeFrom(d, xdr.DecodeDefaultMaxDepth) + o := xdr.DefaultDecodeOptions + o.MaxInputLen = len(inp) + d := xdr.NewDecoderWithOptions(r, o) + _, err := s.DecodeFrom(d, o.MaxDepth) return err } @@ -38461,8 +38938,7 @@ var ( _ encoding.BinaryUnmarshaler = (*EndSponsoringFutureReservesResultCode)(nil) ) -// xdrType signals that this type is an type representing -// representing XDR values defined by this package. +// xdrType signals that this type represents XDR values defined by this package. func (s EndSponsoringFutureReservesResultCode) xdrType() {} var _ xdrType = (*EndSponsoringFutureReservesResultCode)(nil) @@ -38565,8 +39041,10 @@ func (s EndSponsoringFutureReservesResult) MarshalBinary() ([]byte, error) { // UnmarshalBinary implements encoding.BinaryUnmarshaler. func (s *EndSponsoringFutureReservesResult) UnmarshalBinary(inp []byte) error { r := bytes.NewReader(inp) - d := xdr.NewDecoder(r) - _, err := s.DecodeFrom(d, xdr.DecodeDefaultMaxDepth) + o := xdr.DefaultDecodeOptions + o.MaxInputLen = len(inp) + d := xdr.NewDecoderWithOptions(r, o) + _, err := s.DecodeFrom(d, o.MaxDepth) return err } @@ -38575,8 +39053,7 @@ var ( _ encoding.BinaryUnmarshaler = (*EndSponsoringFutureReservesResult)(nil) ) -// xdrType signals that this type is an type representing -// representing XDR values defined by this package. +// xdrType signals that this type represents XDR values defined by this package. func (s EndSponsoringFutureReservesResult) xdrType() {} var _ xdrType = (*EndSponsoringFutureReservesResult)(nil) @@ -38667,8 +39144,10 @@ func (s RevokeSponsorshipResultCode) MarshalBinary() ([]byte, error) { // UnmarshalBinary implements encoding.BinaryUnmarshaler. func (s *RevokeSponsorshipResultCode) UnmarshalBinary(inp []byte) error { r := bytes.NewReader(inp) - d := xdr.NewDecoder(r) - _, err := s.DecodeFrom(d, xdr.DecodeDefaultMaxDepth) + o := xdr.DefaultDecodeOptions + o.MaxInputLen = len(inp) + d := xdr.NewDecoderWithOptions(r, o) + _, err := s.DecodeFrom(d, o.MaxDepth) return err } @@ -38677,8 +39156,7 @@ var ( _ encoding.BinaryUnmarshaler = (*RevokeSponsorshipResultCode)(nil) ) -// xdrType signals that this type is an type representing -// representing XDR values defined by this package. +// xdrType signals that this type represents XDR values defined by this package. func (s RevokeSponsorshipResultCode) xdrType() {} var _ xdrType = (*RevokeSponsorshipResultCode)(nil) @@ -38824,8 +39302,10 @@ func (s RevokeSponsorshipResult) MarshalBinary() ([]byte, error) { // UnmarshalBinary implements encoding.BinaryUnmarshaler. func (s *RevokeSponsorshipResult) UnmarshalBinary(inp []byte) error { r := bytes.NewReader(inp) - d := xdr.NewDecoder(r) - _, err := s.DecodeFrom(d, xdr.DecodeDefaultMaxDepth) + o := xdr.DefaultDecodeOptions + o.MaxInputLen = len(inp) + d := xdr.NewDecoderWithOptions(r, o) + _, err := s.DecodeFrom(d, o.MaxDepth) return err } @@ -38834,8 +39314,7 @@ var ( _ encoding.BinaryUnmarshaler = (*RevokeSponsorshipResult)(nil) ) -// xdrType signals that this type is an type representing -// representing XDR values defined by this package. +// xdrType signals that this type represents XDR values defined by this package. func (s RevokeSponsorshipResult) xdrType() {} var _ xdrType = (*RevokeSponsorshipResult)(nil) @@ -38923,8 +39402,10 @@ func (s ClawbackResultCode) MarshalBinary() ([]byte, error) { // UnmarshalBinary implements encoding.BinaryUnmarshaler. func (s *ClawbackResultCode) UnmarshalBinary(inp []byte) error { r := bytes.NewReader(inp) - d := xdr.NewDecoder(r) - _, err := s.DecodeFrom(d, xdr.DecodeDefaultMaxDepth) + o := xdr.DefaultDecodeOptions + o.MaxInputLen = len(inp) + d := xdr.NewDecoderWithOptions(r, o) + _, err := s.DecodeFrom(d, o.MaxDepth) return err } @@ -38933,8 +39414,7 @@ var ( _ encoding.BinaryUnmarshaler = (*ClawbackResultCode)(nil) ) -// xdrType signals that this type is an type representing -// representing XDR values defined by this package. +// xdrType signals that this type represents XDR values defined by this package. func (s ClawbackResultCode) xdrType() {} var _ xdrType = (*ClawbackResultCode)(nil) @@ -39069,8 +39549,10 @@ func (s ClawbackResult) MarshalBinary() ([]byte, error) { // UnmarshalBinary implements encoding.BinaryUnmarshaler. func (s *ClawbackResult) UnmarshalBinary(inp []byte) error { r := bytes.NewReader(inp) - d := xdr.NewDecoder(r) - _, err := s.DecodeFrom(d, xdr.DecodeDefaultMaxDepth) + o := xdr.DefaultDecodeOptions + o.MaxInputLen = len(inp) + d := xdr.NewDecoderWithOptions(r, o) + _, err := s.DecodeFrom(d, o.MaxDepth) return err } @@ -39079,8 +39561,7 @@ var ( _ encoding.BinaryUnmarshaler = (*ClawbackResult)(nil) ) -// xdrType signals that this type is an type representing -// representing XDR values defined by this package. +// xdrType signals that this type represents XDR values defined by this package. func (s ClawbackResult) xdrType() {} var _ xdrType = (*ClawbackResult)(nil) @@ -39165,8 +39646,10 @@ func (s ClawbackClaimableBalanceResultCode) MarshalBinary() ([]byte, error) { // UnmarshalBinary implements encoding.BinaryUnmarshaler. func (s *ClawbackClaimableBalanceResultCode) UnmarshalBinary(inp []byte) error { r := bytes.NewReader(inp) - d := xdr.NewDecoder(r) - _, err := s.DecodeFrom(d, xdr.DecodeDefaultMaxDepth) + o := xdr.DefaultDecodeOptions + o.MaxInputLen = len(inp) + d := xdr.NewDecoderWithOptions(r, o) + _, err := s.DecodeFrom(d, o.MaxDepth) return err } @@ -39175,8 +39658,7 @@ var ( _ encoding.BinaryUnmarshaler = (*ClawbackClaimableBalanceResultCode)(nil) ) -// xdrType signals that this type is an type representing -// representing XDR values defined by this package. +// xdrType signals that this type represents XDR values defined by this package. func (s ClawbackClaimableBalanceResultCode) xdrType() {} var _ xdrType = (*ClawbackClaimableBalanceResultCode)(nil) @@ -39301,8 +39783,10 @@ func (s ClawbackClaimableBalanceResult) MarshalBinary() ([]byte, error) { // UnmarshalBinary implements encoding.BinaryUnmarshaler. func (s *ClawbackClaimableBalanceResult) UnmarshalBinary(inp []byte) error { r := bytes.NewReader(inp) - d := xdr.NewDecoder(r) - _, err := s.DecodeFrom(d, xdr.DecodeDefaultMaxDepth) + o := xdr.DefaultDecodeOptions + o.MaxInputLen = len(inp) + d := xdr.NewDecoderWithOptions(r, o) + _, err := s.DecodeFrom(d, o.MaxDepth) return err } @@ -39311,8 +39795,7 @@ var ( _ encoding.BinaryUnmarshaler = (*ClawbackClaimableBalanceResult)(nil) ) -// xdrType signals that this type is an type representing -// representing XDR values defined by this package. +// xdrType signals that this type represents XDR values defined by this package. func (s ClawbackClaimableBalanceResult) xdrType() {} var _ xdrType = (*ClawbackClaimableBalanceResult)(nil) @@ -39404,8 +39887,10 @@ func (s SetTrustLineFlagsResultCode) MarshalBinary() ([]byte, error) { // UnmarshalBinary implements encoding.BinaryUnmarshaler. func (s *SetTrustLineFlagsResultCode) UnmarshalBinary(inp []byte) error { r := bytes.NewReader(inp) - d := xdr.NewDecoder(r) - _, err := s.DecodeFrom(d, xdr.DecodeDefaultMaxDepth) + o := xdr.DefaultDecodeOptions + o.MaxInputLen = len(inp) + d := xdr.NewDecoderWithOptions(r, o) + _, err := s.DecodeFrom(d, o.MaxDepth) return err } @@ -39414,8 +39899,7 @@ var ( _ encoding.BinaryUnmarshaler = (*SetTrustLineFlagsResultCode)(nil) ) -// xdrType signals that this type is an type representing -// representing XDR values defined by this package. +// xdrType signals that this type represents XDR values defined by this package. func (s SetTrustLineFlagsResultCode) xdrType() {} var _ xdrType = (*SetTrustLineFlagsResultCode)(nil) @@ -39561,8 +40045,10 @@ func (s SetTrustLineFlagsResult) MarshalBinary() ([]byte, error) { // UnmarshalBinary implements encoding.BinaryUnmarshaler. func (s *SetTrustLineFlagsResult) UnmarshalBinary(inp []byte) error { r := bytes.NewReader(inp) - d := xdr.NewDecoder(r) - _, err := s.DecodeFrom(d, xdr.DecodeDefaultMaxDepth) + o := xdr.DefaultDecodeOptions + o.MaxInputLen = len(inp) + d := xdr.NewDecoderWithOptions(r, o) + _, err := s.DecodeFrom(d, o.MaxDepth) return err } @@ -39571,8 +40057,7 @@ var ( _ encoding.BinaryUnmarshaler = (*SetTrustLineFlagsResult)(nil) ) -// xdrType signals that this type is an type representing -// representing XDR values defined by this package. +// xdrType signals that this type represents XDR values defined by this package. func (s SetTrustLineFlagsResult) xdrType() {} var _ xdrType = (*SetTrustLineFlagsResult)(nil) @@ -39673,8 +40158,10 @@ func (s LiquidityPoolDepositResultCode) MarshalBinary() ([]byte, error) { // UnmarshalBinary implements encoding.BinaryUnmarshaler. func (s *LiquidityPoolDepositResultCode) UnmarshalBinary(inp []byte) error { r := bytes.NewReader(inp) - d := xdr.NewDecoder(r) - _, err := s.DecodeFrom(d, xdr.DecodeDefaultMaxDepth) + o := xdr.DefaultDecodeOptions + o.MaxInputLen = len(inp) + d := xdr.NewDecoderWithOptions(r, o) + _, err := s.DecodeFrom(d, o.MaxDepth) return err } @@ -39683,8 +40170,7 @@ var ( _ encoding.BinaryUnmarshaler = (*LiquidityPoolDepositResultCode)(nil) ) -// xdrType signals that this type is an type representing -// representing XDR values defined by this package. +// xdrType signals that this type represents XDR values defined by this package. func (s LiquidityPoolDepositResultCode) xdrType() {} var _ xdrType = (*LiquidityPoolDepositResultCode)(nil) @@ -39852,8 +40338,10 @@ func (s LiquidityPoolDepositResult) MarshalBinary() ([]byte, error) { // UnmarshalBinary implements encoding.BinaryUnmarshaler. func (s *LiquidityPoolDepositResult) UnmarshalBinary(inp []byte) error { r := bytes.NewReader(inp) - d := xdr.NewDecoder(r) - _, err := s.DecodeFrom(d, xdr.DecodeDefaultMaxDepth) + o := xdr.DefaultDecodeOptions + o.MaxInputLen = len(inp) + d := xdr.NewDecoderWithOptions(r, o) + _, err := s.DecodeFrom(d, o.MaxDepth) return err } @@ -39862,8 +40350,7 @@ var ( _ encoding.BinaryUnmarshaler = (*LiquidityPoolDepositResult)(nil) ) -// xdrType signals that this type is an type representing -// representing XDR values defined by this package. +// xdrType signals that this type represents XDR values defined by this package. func (s LiquidityPoolDepositResult) xdrType() {} var _ xdrType = (*LiquidityPoolDepositResult)(nil) @@ -39957,8 +40444,10 @@ func (s LiquidityPoolWithdrawResultCode) MarshalBinary() ([]byte, error) { // UnmarshalBinary implements encoding.BinaryUnmarshaler. func (s *LiquidityPoolWithdrawResultCode) UnmarshalBinary(inp []byte) error { r := bytes.NewReader(inp) - d := xdr.NewDecoder(r) - _, err := s.DecodeFrom(d, xdr.DecodeDefaultMaxDepth) + o := xdr.DefaultDecodeOptions + o.MaxInputLen = len(inp) + d := xdr.NewDecoderWithOptions(r, o) + _, err := s.DecodeFrom(d, o.MaxDepth) return err } @@ -39967,8 +40456,7 @@ var ( _ encoding.BinaryUnmarshaler = (*LiquidityPoolWithdrawResultCode)(nil) ) -// xdrType signals that this type is an type representing -// representing XDR values defined by this package. +// xdrType signals that this type represents XDR values defined by this package. func (s LiquidityPoolWithdrawResultCode) xdrType() {} var _ xdrType = (*LiquidityPoolWithdrawResultCode)(nil) @@ -40114,8 +40602,10 @@ func (s LiquidityPoolWithdrawResult) MarshalBinary() ([]byte, error) { // UnmarshalBinary implements encoding.BinaryUnmarshaler. func (s *LiquidityPoolWithdrawResult) UnmarshalBinary(inp []byte) error { r := bytes.NewReader(inp) - d := xdr.NewDecoder(r) - _, err := s.DecodeFrom(d, xdr.DecodeDefaultMaxDepth) + o := xdr.DefaultDecodeOptions + o.MaxInputLen = len(inp) + d := xdr.NewDecoderWithOptions(r, o) + _, err := s.DecodeFrom(d, o.MaxDepth) return err } @@ -40124,8 +40614,7 @@ var ( _ encoding.BinaryUnmarshaler = (*LiquidityPoolWithdrawResult)(nil) ) -// xdrType signals that this type is an type representing -// representing XDR values defined by this package. +// xdrType signals that this type represents XDR values defined by this package. func (s LiquidityPoolWithdrawResult) xdrType() {} var _ xdrType = (*LiquidityPoolWithdrawResult)(nil) @@ -40216,8 +40705,10 @@ func (s InvokeHostFunctionResultCode) MarshalBinary() ([]byte, error) { // UnmarshalBinary implements encoding.BinaryUnmarshaler. func (s *InvokeHostFunctionResultCode) UnmarshalBinary(inp []byte) error { r := bytes.NewReader(inp) - d := xdr.NewDecoder(r) - _, err := s.DecodeFrom(d, xdr.DecodeDefaultMaxDepth) + o := xdr.DefaultDecodeOptions + o.MaxInputLen = len(inp) + d := xdr.NewDecoderWithOptions(r, o) + _, err := s.DecodeFrom(d, o.MaxDepth) return err } @@ -40226,8 +40717,7 @@ var ( _ encoding.BinaryUnmarshaler = (*InvokeHostFunctionResultCode)(nil) ) -// xdrType signals that this type is an type representing -// representing XDR values defined by this package. +// xdrType signals that this type represents XDR values defined by this package. func (s InvokeHostFunctionResultCode) xdrType() {} var _ xdrType = (*InvokeHostFunctionResultCode)(nil) @@ -40411,8 +40901,10 @@ func (s InvokeHostFunctionResult) MarshalBinary() ([]byte, error) { // UnmarshalBinary implements encoding.BinaryUnmarshaler. func (s *InvokeHostFunctionResult) UnmarshalBinary(inp []byte) error { r := bytes.NewReader(inp) - d := xdr.NewDecoder(r) - _, err := s.DecodeFrom(d, xdr.DecodeDefaultMaxDepth) + o := xdr.DefaultDecodeOptions + o.MaxInputLen = len(inp) + d := xdr.NewDecoderWithOptions(r, o) + _, err := s.DecodeFrom(d, o.MaxDepth) return err } @@ -40421,8 +40913,7 @@ var ( _ encoding.BinaryUnmarshaler = (*InvokeHostFunctionResult)(nil) ) -// xdrType signals that this type is an type representing -// representing XDR values defined by this package. +// xdrType signals that this type represents XDR values defined by this package. func (s InvokeHostFunctionResult) xdrType() {} var _ xdrType = (*InvokeHostFunctionResult)(nil) @@ -40507,8 +40998,10 @@ func (s ExtendFootprintTtlResultCode) MarshalBinary() ([]byte, error) { // UnmarshalBinary implements encoding.BinaryUnmarshaler. func (s *ExtendFootprintTtlResultCode) UnmarshalBinary(inp []byte) error { r := bytes.NewReader(inp) - d := xdr.NewDecoder(r) - _, err := s.DecodeFrom(d, xdr.DecodeDefaultMaxDepth) + o := xdr.DefaultDecodeOptions + o.MaxInputLen = len(inp) + d := xdr.NewDecoderWithOptions(r, o) + _, err := s.DecodeFrom(d, o.MaxDepth) return err } @@ -40517,8 +41010,7 @@ var ( _ encoding.BinaryUnmarshaler = (*ExtendFootprintTtlResultCode)(nil) ) -// xdrType signals that this type is an type representing -// representing XDR values defined by this package. +// xdrType signals that this type represents XDR values defined by this package. func (s ExtendFootprintTtlResultCode) xdrType() {} var _ xdrType = (*ExtendFootprintTtlResultCode)(nil) @@ -40642,8 +41134,10 @@ func (s ExtendFootprintTtlResult) MarshalBinary() ([]byte, error) { // UnmarshalBinary implements encoding.BinaryUnmarshaler. func (s *ExtendFootprintTtlResult) UnmarshalBinary(inp []byte) error { r := bytes.NewReader(inp) - d := xdr.NewDecoder(r) - _, err := s.DecodeFrom(d, xdr.DecodeDefaultMaxDepth) + o := xdr.DefaultDecodeOptions + o.MaxInputLen = len(inp) + d := xdr.NewDecoderWithOptions(r, o) + _, err := s.DecodeFrom(d, o.MaxDepth) return err } @@ -40652,8 +41146,7 @@ var ( _ encoding.BinaryUnmarshaler = (*ExtendFootprintTtlResult)(nil) ) -// xdrType signals that this type is an type representing -// representing XDR values defined by this package. +// xdrType signals that this type represents XDR values defined by this package. func (s ExtendFootprintTtlResult) xdrType() {} var _ xdrType = (*ExtendFootprintTtlResult)(nil) @@ -40738,8 +41231,10 @@ func (s RestoreFootprintResultCode) MarshalBinary() ([]byte, error) { // UnmarshalBinary implements encoding.BinaryUnmarshaler. func (s *RestoreFootprintResultCode) UnmarshalBinary(inp []byte) error { r := bytes.NewReader(inp) - d := xdr.NewDecoder(r) - _, err := s.DecodeFrom(d, xdr.DecodeDefaultMaxDepth) + o := xdr.DefaultDecodeOptions + o.MaxInputLen = len(inp) + d := xdr.NewDecoderWithOptions(r, o) + _, err := s.DecodeFrom(d, o.MaxDepth) return err } @@ -40748,8 +41243,7 @@ var ( _ encoding.BinaryUnmarshaler = (*RestoreFootprintResultCode)(nil) ) -// xdrType signals that this type is an type representing -// representing XDR values defined by this package. +// xdrType signals that this type represents XDR values defined by this package. func (s RestoreFootprintResultCode) xdrType() {} var _ xdrType = (*RestoreFootprintResultCode)(nil) @@ -40873,8 +41367,10 @@ func (s RestoreFootprintResult) MarshalBinary() ([]byte, error) { // UnmarshalBinary implements encoding.BinaryUnmarshaler. func (s *RestoreFootprintResult) UnmarshalBinary(inp []byte) error { r := bytes.NewReader(inp) - d := xdr.NewDecoder(r) - _, err := s.DecodeFrom(d, xdr.DecodeDefaultMaxDepth) + o := xdr.DefaultDecodeOptions + o.MaxInputLen = len(inp) + d := xdr.NewDecoderWithOptions(r, o) + _, err := s.DecodeFrom(d, o.MaxDepth) return err } @@ -40883,8 +41379,7 @@ var ( _ encoding.BinaryUnmarshaler = (*RestoreFootprintResult)(nil) ) -// xdrType signals that this type is an type representing -// representing XDR values defined by this package. +// xdrType signals that this type represents XDR values defined by this package. func (s RestoreFootprintResult) xdrType() {} var _ xdrType = (*RestoreFootprintResult)(nil) @@ -40976,8 +41471,10 @@ func (s OperationResultCode) MarshalBinary() ([]byte, error) { // UnmarshalBinary implements encoding.BinaryUnmarshaler. func (s *OperationResultCode) UnmarshalBinary(inp []byte) error { r := bytes.NewReader(inp) - d := xdr.NewDecoder(r) - _, err := s.DecodeFrom(d, xdr.DecodeDefaultMaxDepth) + o := xdr.DefaultDecodeOptions + o.MaxInputLen = len(inp) + d := xdr.NewDecoderWithOptions(r, o) + _, err := s.DecodeFrom(d, o.MaxDepth) return err } @@ -40986,8 +41483,7 @@ var ( _ encoding.BinaryUnmarshaler = (*OperationResultCode)(nil) ) -// xdrType signals that this type is an type representing -// representing XDR values defined by this package. +// xdrType signals that this type represents XDR values defined by this package. func (s OperationResultCode) xdrType() {} var _ xdrType = (*OperationResultCode)(nil) @@ -42415,8 +42911,10 @@ func (s OperationResultTr) MarshalBinary() ([]byte, error) { // UnmarshalBinary implements encoding.BinaryUnmarshaler. func (s *OperationResultTr) UnmarshalBinary(inp []byte) error { r := bytes.NewReader(inp) - d := xdr.NewDecoder(r) - _, err := s.DecodeFrom(d, xdr.DecodeDefaultMaxDepth) + o := xdr.DefaultDecodeOptions + o.MaxInputLen = len(inp) + d := xdr.NewDecoderWithOptions(r, o) + _, err := s.DecodeFrom(d, o.MaxDepth) return err } @@ -42425,8 +42923,7 @@ var ( _ encoding.BinaryUnmarshaler = (*OperationResultTr)(nil) ) -// xdrType signals that this type is an type representing -// representing XDR values defined by this package. +// xdrType signals that this type represents XDR values defined by this package. func (s OperationResultTr) xdrType() {} var _ xdrType = (*OperationResultTr)(nil) @@ -42678,8 +43175,10 @@ func (s OperationResult) MarshalBinary() ([]byte, error) { // UnmarshalBinary implements encoding.BinaryUnmarshaler. func (s *OperationResult) UnmarshalBinary(inp []byte) error { r := bytes.NewReader(inp) - d := xdr.NewDecoder(r) - _, err := s.DecodeFrom(d, xdr.DecodeDefaultMaxDepth) + o := xdr.DefaultDecodeOptions + o.MaxInputLen = len(inp) + d := xdr.NewDecoderWithOptions(r, o) + _, err := s.DecodeFrom(d, o.MaxDepth) return err } @@ -42688,8 +43187,7 @@ var ( _ encoding.BinaryUnmarshaler = (*OperationResult)(nil) ) -// xdrType signals that this type is an type representing -// representing XDR values defined by this package. +// xdrType signals that this type represents XDR values defined by this package. func (s OperationResult) xdrType() {} var _ xdrType = (*OperationResult)(nil) @@ -42820,8 +43318,10 @@ func (s TransactionResultCode) MarshalBinary() ([]byte, error) { // UnmarshalBinary implements encoding.BinaryUnmarshaler. func (s *TransactionResultCode) UnmarshalBinary(inp []byte) error { r := bytes.NewReader(inp) - d := xdr.NewDecoder(r) - _, err := s.DecodeFrom(d, xdr.DecodeDefaultMaxDepth) + o := xdr.DefaultDecodeOptions + o.MaxInputLen = len(inp) + d := xdr.NewDecoderWithOptions(r, o) + _, err := s.DecodeFrom(d, o.MaxDepth) return err } @@ -42830,8 +43330,7 @@ var ( _ encoding.BinaryUnmarshaler = (*TransactionResultCode)(nil) ) -// xdrType signals that this type is an type representing -// representing XDR values defined by this package. +// xdrType signals that this type represents XDR values defined by this package. func (s TransactionResultCode) xdrType() {} var _ xdrType = (*TransactionResultCode)(nil) @@ -43094,8 +43593,11 @@ func (u *InnerTransactionResultResult) DecodeFrom(d *xdr.Decoder, maxDepth uint) } (*u.Results) = nil if l > 0 { + if il, ok := d.InputLen(); ok && uint(il) < uint(l) { + return n, fmt.Errorf("decoding OperationResult: length (%d) exceeds remaining input length (%d)", l, il) + } (*u.Results) = make([]OperationResult, l) - for i := uint32(0); i < l; i++ { + for i := uint32(0); uint(i) < uint(l); i++ { nTmp, err = (*u.Results)[i].DecodeFrom(d, maxDepth) n += nTmp if err != nil { @@ -43114,8 +43616,11 @@ func (u *InnerTransactionResultResult) DecodeFrom(d *xdr.Decoder, maxDepth uint) } (*u.Results) = nil if l > 0 { + if il, ok := d.InputLen(); ok && uint(il) < uint(l) { + return n, fmt.Errorf("decoding OperationResult: length (%d) exceeds remaining input length (%d)", l, il) + } (*u.Results) = make([]OperationResult, l) - for i := uint32(0); i < l; i++ { + for i := uint32(0); uint(i) < uint(l); i++ { nTmp, err = (*u.Results)[i].DecodeFrom(d, maxDepth) n += nTmp if err != nil { @@ -43184,8 +43689,10 @@ func (s InnerTransactionResultResult) MarshalBinary() ([]byte, error) { // UnmarshalBinary implements encoding.BinaryUnmarshaler. func (s *InnerTransactionResultResult) UnmarshalBinary(inp []byte) error { r := bytes.NewReader(inp) - d := xdr.NewDecoder(r) - _, err := s.DecodeFrom(d, xdr.DecodeDefaultMaxDepth) + o := xdr.DefaultDecodeOptions + o.MaxInputLen = len(inp) + d := xdr.NewDecoderWithOptions(r, o) + _, err := s.DecodeFrom(d, o.MaxDepth) return err } @@ -43194,8 +43701,7 @@ var ( _ encoding.BinaryUnmarshaler = (*InnerTransactionResultResult)(nil) ) -// xdrType signals that this type is an type representing -// representing XDR values defined by this package. +// xdrType signals that this type represents XDR values defined by this package. func (s InnerTransactionResultResult) xdrType() {} var _ xdrType = (*InnerTransactionResultResult)(nil) @@ -43285,8 +43791,10 @@ func (s InnerTransactionResultExt) MarshalBinary() ([]byte, error) { // UnmarshalBinary implements encoding.BinaryUnmarshaler. func (s *InnerTransactionResultExt) UnmarshalBinary(inp []byte) error { r := bytes.NewReader(inp) - d := xdr.NewDecoder(r) - _, err := s.DecodeFrom(d, xdr.DecodeDefaultMaxDepth) + o := xdr.DefaultDecodeOptions + o.MaxInputLen = len(inp) + d := xdr.NewDecoderWithOptions(r, o) + _, err := s.DecodeFrom(d, o.MaxDepth) return err } @@ -43295,8 +43803,7 @@ var ( _ encoding.BinaryUnmarshaler = (*InnerTransactionResultExt)(nil) ) -// xdrType signals that this type is an type representing -// representing XDR values defined by this package. +// xdrType signals that this type represents XDR values defined by this package. func (s InnerTransactionResultExt) xdrType() {} var _ xdrType = (*InnerTransactionResultExt)(nil) @@ -43402,8 +43909,10 @@ func (s InnerTransactionResult) MarshalBinary() ([]byte, error) { // UnmarshalBinary implements encoding.BinaryUnmarshaler. func (s *InnerTransactionResult) UnmarshalBinary(inp []byte) error { r := bytes.NewReader(inp) - d := xdr.NewDecoder(r) - _, err := s.DecodeFrom(d, xdr.DecodeDefaultMaxDepth) + o := xdr.DefaultDecodeOptions + o.MaxInputLen = len(inp) + d := xdr.NewDecoderWithOptions(r, o) + _, err := s.DecodeFrom(d, o.MaxDepth) return err } @@ -43412,8 +43921,7 @@ var ( _ encoding.BinaryUnmarshaler = (*InnerTransactionResult)(nil) ) -// xdrType signals that this type is an type representing -// representing XDR values defined by this package. +// xdrType signals that this type represents XDR values defined by this package. func (s InnerTransactionResult) xdrType() {} var _ xdrType = (*InnerTransactionResult)(nil) @@ -43476,8 +43984,10 @@ func (s InnerTransactionResultPair) MarshalBinary() ([]byte, error) { // UnmarshalBinary implements encoding.BinaryUnmarshaler. func (s *InnerTransactionResultPair) UnmarshalBinary(inp []byte) error { r := bytes.NewReader(inp) - d := xdr.NewDecoder(r) - _, err := s.DecodeFrom(d, xdr.DecodeDefaultMaxDepth) + o := xdr.DefaultDecodeOptions + o.MaxInputLen = len(inp) + d := xdr.NewDecoderWithOptions(r, o) + _, err := s.DecodeFrom(d, o.MaxDepth) return err } @@ -43486,8 +43996,7 @@ var ( _ encoding.BinaryUnmarshaler = (*InnerTransactionResultPair)(nil) ) -// xdrType signals that this type is an type representing -// representing XDR values defined by this package. +// xdrType signals that this type represents XDR values defined by this package. func (s InnerTransactionResultPair) xdrType() {} var _ xdrType = (*InnerTransactionResultPair)(nil) @@ -43822,8 +44331,11 @@ func (u *TransactionResultResult) DecodeFrom(d *xdr.Decoder, maxDepth uint) (int } (*u.Results) = nil if l > 0 { + if il, ok := d.InputLen(); ok && uint(il) < uint(l) { + return n, fmt.Errorf("decoding OperationResult: length (%d) exceeds remaining input length (%d)", l, il) + } (*u.Results) = make([]OperationResult, l) - for i := uint32(0); i < l; i++ { + for i := uint32(0); uint(i) < uint(l); i++ { nTmp, err = (*u.Results)[i].DecodeFrom(d, maxDepth) n += nTmp if err != nil { @@ -43842,8 +44354,11 @@ func (u *TransactionResultResult) DecodeFrom(d *xdr.Decoder, maxDepth uint) (int } (*u.Results) = nil if l > 0 { + if il, ok := d.InputLen(); ok && uint(il) < uint(l) { + return n, fmt.Errorf("decoding OperationResult: length (%d) exceeds remaining input length (%d)", l, il) + } (*u.Results) = make([]OperationResult, l) - for i := uint32(0); i < l; i++ { + for i := uint32(0); uint(i) < uint(l); i++ { nTmp, err = (*u.Results)[i].DecodeFrom(d, maxDepth) n += nTmp if err != nil { @@ -43912,8 +44427,10 @@ func (s TransactionResultResult) MarshalBinary() ([]byte, error) { // UnmarshalBinary implements encoding.BinaryUnmarshaler. func (s *TransactionResultResult) UnmarshalBinary(inp []byte) error { r := bytes.NewReader(inp) - d := xdr.NewDecoder(r) - _, err := s.DecodeFrom(d, xdr.DecodeDefaultMaxDepth) + o := xdr.DefaultDecodeOptions + o.MaxInputLen = len(inp) + d := xdr.NewDecoderWithOptions(r, o) + _, err := s.DecodeFrom(d, o.MaxDepth) return err } @@ -43922,8 +44439,7 @@ var ( _ encoding.BinaryUnmarshaler = (*TransactionResultResult)(nil) ) -// xdrType signals that this type is an type representing -// representing XDR values defined by this package. +// xdrType signals that this type represents XDR values defined by this package. func (s TransactionResultResult) xdrType() {} var _ xdrType = (*TransactionResultResult)(nil) @@ -44013,8 +44529,10 @@ func (s TransactionResultExt) MarshalBinary() ([]byte, error) { // UnmarshalBinary implements encoding.BinaryUnmarshaler. func (s *TransactionResultExt) UnmarshalBinary(inp []byte) error { r := bytes.NewReader(inp) - d := xdr.NewDecoder(r) - _, err := s.DecodeFrom(d, xdr.DecodeDefaultMaxDepth) + o := xdr.DefaultDecodeOptions + o.MaxInputLen = len(inp) + d := xdr.NewDecoderWithOptions(r, o) + _, err := s.DecodeFrom(d, o.MaxDepth) return err } @@ -44023,8 +44541,7 @@ var ( _ encoding.BinaryUnmarshaler = (*TransactionResultExt)(nil) ) -// xdrType signals that this type is an type representing -// representing XDR values defined by this package. +// xdrType signals that this type represents XDR values defined by this package. func (s TransactionResultExt) xdrType() {} var _ xdrType = (*TransactionResultExt)(nil) @@ -44131,8 +44648,10 @@ func (s TransactionResult) MarshalBinary() ([]byte, error) { // UnmarshalBinary implements encoding.BinaryUnmarshaler. func (s *TransactionResult) UnmarshalBinary(inp []byte) error { r := bytes.NewReader(inp) - d := xdr.NewDecoder(r) - _, err := s.DecodeFrom(d, xdr.DecodeDefaultMaxDepth) + o := xdr.DefaultDecodeOptions + o.MaxInputLen = len(inp) + d := xdr.NewDecoderWithOptions(r, o) + _, err := s.DecodeFrom(d, o.MaxDepth) return err } @@ -44141,8 +44660,7 @@ var ( _ encoding.BinaryUnmarshaler = (*TransactionResult)(nil) ) -// xdrType signals that this type is an type representing -// representing XDR values defined by this package. +// xdrType signals that this type represents XDR values defined by this package. func (s TransactionResult) xdrType() {} var _ xdrType = (*TransactionResult)(nil) @@ -44195,8 +44713,10 @@ func (s Hash) MarshalBinary() ([]byte, error) { // UnmarshalBinary implements encoding.BinaryUnmarshaler. func (s *Hash) UnmarshalBinary(inp []byte) error { r := bytes.NewReader(inp) - d := xdr.NewDecoder(r) - _, err := s.DecodeFrom(d, xdr.DecodeDefaultMaxDepth) + o := xdr.DefaultDecodeOptions + o.MaxInputLen = len(inp) + d := xdr.NewDecoderWithOptions(r, o) + _, err := s.DecodeFrom(d, o.MaxDepth) return err } @@ -44205,8 +44725,7 @@ var ( _ encoding.BinaryUnmarshaler = (*Hash)(nil) ) -// xdrType signals that this type is an type representing -// representing XDR values defined by this package. +// xdrType signals that this type represents XDR values defined by this package. func (s Hash) xdrType() {} var _ xdrType = (*Hash)(nil) @@ -44259,8 +44778,10 @@ func (s Uint256) MarshalBinary() ([]byte, error) { // UnmarshalBinary implements encoding.BinaryUnmarshaler. func (s *Uint256) UnmarshalBinary(inp []byte) error { r := bytes.NewReader(inp) - d := xdr.NewDecoder(r) - _, err := s.DecodeFrom(d, xdr.DecodeDefaultMaxDepth) + o := xdr.DefaultDecodeOptions + o.MaxInputLen = len(inp) + d := xdr.NewDecoderWithOptions(r, o) + _, err := s.DecodeFrom(d, o.MaxDepth) return err } @@ -44269,8 +44790,7 @@ var ( _ encoding.BinaryUnmarshaler = (*Uint256)(nil) ) -// xdrType signals that this type is an type representing -// representing XDR values defined by this package. +// xdrType signals that this type represents XDR values defined by this package. func (s Uint256) xdrType() {} var _ xdrType = (*Uint256)(nil) @@ -44320,8 +44840,10 @@ func (s Uint32) MarshalBinary() ([]byte, error) { // UnmarshalBinary implements encoding.BinaryUnmarshaler. func (s *Uint32) UnmarshalBinary(inp []byte) error { r := bytes.NewReader(inp) - d := xdr.NewDecoder(r) - _, err := s.DecodeFrom(d, xdr.DecodeDefaultMaxDepth) + o := xdr.DefaultDecodeOptions + o.MaxInputLen = len(inp) + d := xdr.NewDecoderWithOptions(r, o) + _, err := s.DecodeFrom(d, o.MaxDepth) return err } @@ -44330,8 +44852,7 @@ var ( _ encoding.BinaryUnmarshaler = (*Uint32)(nil) ) -// xdrType signals that this type is an type representing -// representing XDR values defined by this package. +// xdrType signals that this type represents XDR values defined by this package. func (s Uint32) xdrType() {} var _ xdrType = (*Uint32)(nil) @@ -44381,8 +44902,10 @@ func (s Int32) MarshalBinary() ([]byte, error) { // UnmarshalBinary implements encoding.BinaryUnmarshaler. func (s *Int32) UnmarshalBinary(inp []byte) error { r := bytes.NewReader(inp) - d := xdr.NewDecoder(r) - _, err := s.DecodeFrom(d, xdr.DecodeDefaultMaxDepth) + o := xdr.DefaultDecodeOptions + o.MaxInputLen = len(inp) + d := xdr.NewDecoderWithOptions(r, o) + _, err := s.DecodeFrom(d, o.MaxDepth) return err } @@ -44391,8 +44914,7 @@ var ( _ encoding.BinaryUnmarshaler = (*Int32)(nil) ) -// xdrType signals that this type is an type representing -// representing XDR values defined by this package. +// xdrType signals that this type represents XDR values defined by this package. func (s Int32) xdrType() {} var _ xdrType = (*Int32)(nil) @@ -44442,8 +44964,10 @@ func (s Uint64) MarshalBinary() ([]byte, error) { // UnmarshalBinary implements encoding.BinaryUnmarshaler. func (s *Uint64) UnmarshalBinary(inp []byte) error { r := bytes.NewReader(inp) - d := xdr.NewDecoder(r) - _, err := s.DecodeFrom(d, xdr.DecodeDefaultMaxDepth) + o := xdr.DefaultDecodeOptions + o.MaxInputLen = len(inp) + d := xdr.NewDecoderWithOptions(r, o) + _, err := s.DecodeFrom(d, o.MaxDepth) return err } @@ -44452,8 +44976,7 @@ var ( _ encoding.BinaryUnmarshaler = (*Uint64)(nil) ) -// xdrType signals that this type is an type representing -// representing XDR values defined by this package. +// xdrType signals that this type represents XDR values defined by this package. func (s Uint64) xdrType() {} var _ xdrType = (*Uint64)(nil) @@ -44503,8 +45026,10 @@ func (s Int64) MarshalBinary() ([]byte, error) { // UnmarshalBinary implements encoding.BinaryUnmarshaler. func (s *Int64) UnmarshalBinary(inp []byte) error { r := bytes.NewReader(inp) - d := xdr.NewDecoder(r) - _, err := s.DecodeFrom(d, xdr.DecodeDefaultMaxDepth) + o := xdr.DefaultDecodeOptions + o.MaxInputLen = len(inp) + d := xdr.NewDecoderWithOptions(r, o) + _, err := s.DecodeFrom(d, o.MaxDepth) return err } @@ -44513,8 +45038,7 @@ var ( _ encoding.BinaryUnmarshaler = (*Int64)(nil) ) -// xdrType signals that this type is an type representing -// representing XDR values defined by this package. +// xdrType signals that this type represents XDR values defined by this package. func (s Int64) xdrType() {} var _ xdrType = (*Int64)(nil) @@ -44562,8 +45086,10 @@ func (s TimePoint) MarshalBinary() ([]byte, error) { // UnmarshalBinary implements encoding.BinaryUnmarshaler. func (s *TimePoint) UnmarshalBinary(inp []byte) error { r := bytes.NewReader(inp) - d := xdr.NewDecoder(r) - _, err := s.DecodeFrom(d, xdr.DecodeDefaultMaxDepth) + o := xdr.DefaultDecodeOptions + o.MaxInputLen = len(inp) + d := xdr.NewDecoderWithOptions(r, o) + _, err := s.DecodeFrom(d, o.MaxDepth) return err } @@ -44572,8 +45098,7 @@ var ( _ encoding.BinaryUnmarshaler = (*TimePoint)(nil) ) -// xdrType signals that this type is an type representing -// representing XDR values defined by this package. +// xdrType signals that this type represents XDR values defined by this package. func (s TimePoint) xdrType() {} var _ xdrType = (*TimePoint)(nil) @@ -44621,8 +45146,10 @@ func (s Duration) MarshalBinary() ([]byte, error) { // UnmarshalBinary implements encoding.BinaryUnmarshaler. func (s *Duration) UnmarshalBinary(inp []byte) error { r := bytes.NewReader(inp) - d := xdr.NewDecoder(r) - _, err := s.DecodeFrom(d, xdr.DecodeDefaultMaxDepth) + o := xdr.DefaultDecodeOptions + o.MaxInputLen = len(inp) + d := xdr.NewDecoderWithOptions(r, o) + _, err := s.DecodeFrom(d, o.MaxDepth) return err } @@ -44631,8 +45158,7 @@ var ( _ encoding.BinaryUnmarshaler = (*Duration)(nil) ) -// xdrType signals that this type is an type representing -// representing XDR values defined by this package. +// xdrType signals that this type represents XDR values defined by this package. func (s Duration) xdrType() {} var _ xdrType = (*Duration)(nil) @@ -44722,8 +45248,10 @@ func (s ExtensionPoint) MarshalBinary() ([]byte, error) { // UnmarshalBinary implements encoding.BinaryUnmarshaler. func (s *ExtensionPoint) UnmarshalBinary(inp []byte) error { r := bytes.NewReader(inp) - d := xdr.NewDecoder(r) - _, err := s.DecodeFrom(d, xdr.DecodeDefaultMaxDepth) + o := xdr.DefaultDecodeOptions + o.MaxInputLen = len(inp) + d := xdr.NewDecoderWithOptions(r, o) + _, err := s.DecodeFrom(d, o.MaxDepth) return err } @@ -44732,8 +45260,7 @@ var ( _ encoding.BinaryUnmarshaler = (*ExtensionPoint)(nil) ) -// xdrType signals that this type is an type representing -// representing XDR values defined by this package. +// xdrType signals that this type represents XDR values defined by this package. func (s ExtensionPoint) xdrType() {} var _ xdrType = (*ExtensionPoint)(nil) @@ -44820,8 +45347,10 @@ func (s CryptoKeyType) MarshalBinary() ([]byte, error) { // UnmarshalBinary implements encoding.BinaryUnmarshaler. func (s *CryptoKeyType) UnmarshalBinary(inp []byte) error { r := bytes.NewReader(inp) - d := xdr.NewDecoder(r) - _, err := s.DecodeFrom(d, xdr.DecodeDefaultMaxDepth) + o := xdr.DefaultDecodeOptions + o.MaxInputLen = len(inp) + d := xdr.NewDecoderWithOptions(r, o) + _, err := s.DecodeFrom(d, o.MaxDepth) return err } @@ -44830,8 +45359,7 @@ var ( _ encoding.BinaryUnmarshaler = (*CryptoKeyType)(nil) ) -// xdrType signals that this type is an type representing -// representing XDR values defined by this package. +// xdrType signals that this type represents XDR values defined by this package. func (s CryptoKeyType) xdrType() {} var _ xdrType = (*CryptoKeyType)(nil) @@ -44904,8 +45432,10 @@ func (s PublicKeyType) MarshalBinary() ([]byte, error) { // UnmarshalBinary implements encoding.BinaryUnmarshaler. func (s *PublicKeyType) UnmarshalBinary(inp []byte) error { r := bytes.NewReader(inp) - d := xdr.NewDecoder(r) - _, err := s.DecodeFrom(d, xdr.DecodeDefaultMaxDepth) + o := xdr.DefaultDecodeOptions + o.MaxInputLen = len(inp) + d := xdr.NewDecoderWithOptions(r, o) + _, err := s.DecodeFrom(d, o.MaxDepth) return err } @@ -44914,8 +45444,7 @@ var ( _ encoding.BinaryUnmarshaler = (*PublicKeyType)(nil) ) -// xdrType signals that this type is an type representing -// representing XDR values defined by this package. +// xdrType signals that this type represents XDR values defined by this package. func (s PublicKeyType) xdrType() {} var _ xdrType = (*PublicKeyType)(nil) @@ -44997,8 +45526,10 @@ func (s SignerKeyType) MarshalBinary() ([]byte, error) { // UnmarshalBinary implements encoding.BinaryUnmarshaler. func (s *SignerKeyType) UnmarshalBinary(inp []byte) error { r := bytes.NewReader(inp) - d := xdr.NewDecoder(r) - _, err := s.DecodeFrom(d, xdr.DecodeDefaultMaxDepth) + o := xdr.DefaultDecodeOptions + o.MaxInputLen = len(inp) + d := xdr.NewDecoderWithOptions(r, o) + _, err := s.DecodeFrom(d, o.MaxDepth) return err } @@ -45007,8 +45538,7 @@ var ( _ encoding.BinaryUnmarshaler = (*SignerKeyType)(nil) ) -// xdrType signals that this type is an type representing -// representing XDR values defined by this package. +// xdrType signals that this type represents XDR values defined by this package. func (s SignerKeyType) xdrType() {} var _ xdrType = (*SignerKeyType)(nil) @@ -45136,8 +45666,10 @@ func (s PublicKey) MarshalBinary() ([]byte, error) { // UnmarshalBinary implements encoding.BinaryUnmarshaler. func (s *PublicKey) UnmarshalBinary(inp []byte) error { r := bytes.NewReader(inp) - d := xdr.NewDecoder(r) - _, err := s.DecodeFrom(d, xdr.DecodeDefaultMaxDepth) + o := xdr.DefaultDecodeOptions + o.MaxInputLen = len(inp) + d := xdr.NewDecoderWithOptions(r, o) + _, err := s.DecodeFrom(d, o.MaxDepth) return err } @@ -45146,8 +45678,7 @@ var ( _ encoding.BinaryUnmarshaler = (*PublicKey)(nil) ) -// xdrType signals that this type is an type representing -// representing XDR values defined by this package. +// xdrType signals that this type represents XDR values defined by this package. func (s PublicKey) xdrType() {} var _ xdrType = (*PublicKey)(nil) @@ -45212,8 +45743,10 @@ func (s SignerKeyEd25519SignedPayload) MarshalBinary() ([]byte, error) { // UnmarshalBinary implements encoding.BinaryUnmarshaler. func (s *SignerKeyEd25519SignedPayload) UnmarshalBinary(inp []byte) error { r := bytes.NewReader(inp) - d := xdr.NewDecoder(r) - _, err := s.DecodeFrom(d, xdr.DecodeDefaultMaxDepth) + o := xdr.DefaultDecodeOptions + o.MaxInputLen = len(inp) + d := xdr.NewDecoderWithOptions(r, o) + _, err := s.DecodeFrom(d, o.MaxDepth) return err } @@ -45222,8 +45755,7 @@ var ( _ encoding.BinaryUnmarshaler = (*SignerKeyEd25519SignedPayload)(nil) ) -// xdrType signals that this type is an type representing -// representing XDR values defined by this package. +// xdrType signals that this type represents XDR values defined by this package. func (s SignerKeyEd25519SignedPayload) xdrType() {} var _ xdrType = (*SignerKeyEd25519SignedPayload)(nil) @@ -45509,8 +46041,10 @@ func (s SignerKey) MarshalBinary() ([]byte, error) { // UnmarshalBinary implements encoding.BinaryUnmarshaler. func (s *SignerKey) UnmarshalBinary(inp []byte) error { r := bytes.NewReader(inp) - d := xdr.NewDecoder(r) - _, err := s.DecodeFrom(d, xdr.DecodeDefaultMaxDepth) + o := xdr.DefaultDecodeOptions + o.MaxInputLen = len(inp) + d := xdr.NewDecoderWithOptions(r, o) + _, err := s.DecodeFrom(d, o.MaxDepth) return err } @@ -45519,8 +46053,7 @@ var ( _ encoding.BinaryUnmarshaler = (*SignerKey)(nil) ) -// xdrType signals that this type is an type representing -// representing XDR values defined by this package. +// xdrType signals that this type represents XDR values defined by this package. func (s SignerKey) xdrType() {} var _ xdrType = (*SignerKey)(nil) @@ -45573,8 +46106,10 @@ func (s Signature) MarshalBinary() ([]byte, error) { // UnmarshalBinary implements encoding.BinaryUnmarshaler. func (s *Signature) UnmarshalBinary(inp []byte) error { r := bytes.NewReader(inp) - d := xdr.NewDecoder(r) - _, err := s.DecodeFrom(d, xdr.DecodeDefaultMaxDepth) + o := xdr.DefaultDecodeOptions + o.MaxInputLen = len(inp) + d := xdr.NewDecoderWithOptions(r, o) + _, err := s.DecodeFrom(d, o.MaxDepth) return err } @@ -45583,8 +46118,7 @@ var ( _ encoding.BinaryUnmarshaler = (*Signature)(nil) ) -// xdrType signals that this type is an type representing -// representing XDR values defined by this package. +// xdrType signals that this type represents XDR values defined by this package. func (s Signature) xdrType() {} var _ xdrType = (*Signature)(nil) @@ -45637,8 +46171,10 @@ func (s SignatureHint) MarshalBinary() ([]byte, error) { // UnmarshalBinary implements encoding.BinaryUnmarshaler. func (s *SignatureHint) UnmarshalBinary(inp []byte) error { r := bytes.NewReader(inp) - d := xdr.NewDecoder(r) - _, err := s.DecodeFrom(d, xdr.DecodeDefaultMaxDepth) + o := xdr.DefaultDecodeOptions + o.MaxInputLen = len(inp) + d := xdr.NewDecoderWithOptions(r, o) + _, err := s.DecodeFrom(d, o.MaxDepth) return err } @@ -45647,8 +46183,7 @@ var ( _ encoding.BinaryUnmarshaler = (*SignatureHint)(nil) ) -// xdrType signals that this type is an type representing -// representing XDR values defined by this package. +// xdrType signals that this type represents XDR values defined by this package. func (s SignatureHint) xdrType() {} var _ xdrType = (*SignatureHint)(nil) @@ -45727,8 +46262,10 @@ func (s NodeId) MarshalBinary() ([]byte, error) { // UnmarshalBinary implements encoding.BinaryUnmarshaler. func (s *NodeId) UnmarshalBinary(inp []byte) error { r := bytes.NewReader(inp) - d := xdr.NewDecoder(r) - _, err := s.DecodeFrom(d, xdr.DecodeDefaultMaxDepth) + o := xdr.DefaultDecodeOptions + o.MaxInputLen = len(inp) + d := xdr.NewDecoderWithOptions(r, o) + _, err := s.DecodeFrom(d, o.MaxDepth) return err } @@ -45737,8 +46274,7 @@ var ( _ encoding.BinaryUnmarshaler = (*NodeId)(nil) ) -// xdrType signals that this type is an type representing -// representing XDR values defined by this package. +// xdrType signals that this type represents XDR values defined by this package. func (s NodeId) xdrType() {} var _ xdrType = (*NodeId)(nil) @@ -45817,8 +46353,10 @@ func (s AccountId) MarshalBinary() ([]byte, error) { // UnmarshalBinary implements encoding.BinaryUnmarshaler. func (s *AccountId) UnmarshalBinary(inp []byte) error { r := bytes.NewReader(inp) - d := xdr.NewDecoder(r) - _, err := s.DecodeFrom(d, xdr.DecodeDefaultMaxDepth) + o := xdr.DefaultDecodeOptions + o.MaxInputLen = len(inp) + d := xdr.NewDecoderWithOptions(r, o) + _, err := s.DecodeFrom(d, o.MaxDepth) return err } @@ -45827,8 +46365,7 @@ var ( _ encoding.BinaryUnmarshaler = (*AccountId)(nil) ) -// xdrType signals that this type is an type representing -// representing XDR values defined by this package. +// xdrType signals that this type represents XDR values defined by this package. func (s AccountId) xdrType() {} var _ xdrType = (*AccountId)(nil) @@ -45881,8 +46418,10 @@ func (s Curve25519Secret) MarshalBinary() ([]byte, error) { // UnmarshalBinary implements encoding.BinaryUnmarshaler. func (s *Curve25519Secret) UnmarshalBinary(inp []byte) error { r := bytes.NewReader(inp) - d := xdr.NewDecoder(r) - _, err := s.DecodeFrom(d, xdr.DecodeDefaultMaxDepth) + o := xdr.DefaultDecodeOptions + o.MaxInputLen = len(inp) + d := xdr.NewDecoderWithOptions(r, o) + _, err := s.DecodeFrom(d, o.MaxDepth) return err } @@ -45891,8 +46430,7 @@ var ( _ encoding.BinaryUnmarshaler = (*Curve25519Secret)(nil) ) -// xdrType signals that this type is an type representing -// representing XDR values defined by this package. +// xdrType signals that this type represents XDR values defined by this package. func (s Curve25519Secret) xdrType() {} var _ xdrType = (*Curve25519Secret)(nil) @@ -45945,8 +46483,10 @@ func (s Curve25519Public) MarshalBinary() ([]byte, error) { // UnmarshalBinary implements encoding.BinaryUnmarshaler. func (s *Curve25519Public) UnmarshalBinary(inp []byte) error { r := bytes.NewReader(inp) - d := xdr.NewDecoder(r) - _, err := s.DecodeFrom(d, xdr.DecodeDefaultMaxDepth) + o := xdr.DefaultDecodeOptions + o.MaxInputLen = len(inp) + d := xdr.NewDecoderWithOptions(r, o) + _, err := s.DecodeFrom(d, o.MaxDepth) return err } @@ -45955,8 +46495,7 @@ var ( _ encoding.BinaryUnmarshaler = (*Curve25519Public)(nil) ) -// xdrType signals that this type is an type representing -// representing XDR values defined by this package. +// xdrType signals that this type represents XDR values defined by this package. func (s Curve25519Public) xdrType() {} var _ xdrType = (*Curve25519Public)(nil) @@ -46009,8 +46548,10 @@ func (s HmacSha256Key) MarshalBinary() ([]byte, error) { // UnmarshalBinary implements encoding.BinaryUnmarshaler. func (s *HmacSha256Key) UnmarshalBinary(inp []byte) error { r := bytes.NewReader(inp) - d := xdr.NewDecoder(r) - _, err := s.DecodeFrom(d, xdr.DecodeDefaultMaxDepth) + o := xdr.DefaultDecodeOptions + o.MaxInputLen = len(inp) + d := xdr.NewDecoderWithOptions(r, o) + _, err := s.DecodeFrom(d, o.MaxDepth) return err } @@ -46019,8 +46560,7 @@ var ( _ encoding.BinaryUnmarshaler = (*HmacSha256Key)(nil) ) -// xdrType signals that this type is an type representing -// representing XDR values defined by this package. +// xdrType signals that this type represents XDR values defined by this package. func (s HmacSha256Key) xdrType() {} var _ xdrType = (*HmacSha256Key)(nil) @@ -46073,8 +46613,10 @@ func (s HmacSha256Mac) MarshalBinary() ([]byte, error) { // UnmarshalBinary implements encoding.BinaryUnmarshaler. func (s *HmacSha256Mac) UnmarshalBinary(inp []byte) error { r := bytes.NewReader(inp) - d := xdr.NewDecoder(r) - _, err := s.DecodeFrom(d, xdr.DecodeDefaultMaxDepth) + o := xdr.DefaultDecodeOptions + o.MaxInputLen = len(inp) + d := xdr.NewDecoderWithOptions(r, o) + _, err := s.DecodeFrom(d, o.MaxDepth) return err } @@ -46083,8 +46625,7 @@ var ( _ encoding.BinaryUnmarshaler = (*HmacSha256Mac)(nil) ) -// xdrType signals that this type is an type representing -// representing XDR values defined by this package. +// xdrType signals that this type represents XDR values defined by this package. func (s HmacSha256Mac) xdrType() {} var _ xdrType = (*HmacSha256Mac)(nil) @@ -46157,8 +46698,10 @@ func (s ScEnvMetaKind) MarshalBinary() ([]byte, error) { // UnmarshalBinary implements encoding.BinaryUnmarshaler. func (s *ScEnvMetaKind) UnmarshalBinary(inp []byte) error { r := bytes.NewReader(inp) - d := xdr.NewDecoder(r) - _, err := s.DecodeFrom(d, xdr.DecodeDefaultMaxDepth) + o := xdr.DefaultDecodeOptions + o.MaxInputLen = len(inp) + d := xdr.NewDecoderWithOptions(r, o) + _, err := s.DecodeFrom(d, o.MaxDepth) return err } @@ -46167,8 +46710,7 @@ var ( _ encoding.BinaryUnmarshaler = (*ScEnvMetaKind)(nil) ) -// xdrType signals that this type is an type representing -// representing XDR values defined by this package. +// xdrType signals that this type represents XDR values defined by this package. func (s ScEnvMetaKind) xdrType() {} var _ xdrType = (*ScEnvMetaKind)(nil) @@ -46296,8 +46838,10 @@ func (s ScEnvMetaEntry) MarshalBinary() ([]byte, error) { // UnmarshalBinary implements encoding.BinaryUnmarshaler. func (s *ScEnvMetaEntry) UnmarshalBinary(inp []byte) error { r := bytes.NewReader(inp) - d := xdr.NewDecoder(r) - _, err := s.DecodeFrom(d, xdr.DecodeDefaultMaxDepth) + o := xdr.DefaultDecodeOptions + o.MaxInputLen = len(inp) + d := xdr.NewDecoderWithOptions(r, o) + _, err := s.DecodeFrom(d, o.MaxDepth) return err } @@ -46306,8 +46850,7 @@ var ( _ encoding.BinaryUnmarshaler = (*ScEnvMetaEntry)(nil) ) -// xdrType signals that this type is an type representing -// representing XDR values defined by this package. +// xdrType signals that this type represents XDR values defined by this package. func (s ScEnvMetaEntry) xdrType() {} var _ xdrType = (*ScEnvMetaEntry)(nil) @@ -46370,8 +46913,10 @@ func (s ScMetaV0) MarshalBinary() ([]byte, error) { // UnmarshalBinary implements encoding.BinaryUnmarshaler. func (s *ScMetaV0) UnmarshalBinary(inp []byte) error { r := bytes.NewReader(inp) - d := xdr.NewDecoder(r) - _, err := s.DecodeFrom(d, xdr.DecodeDefaultMaxDepth) + o := xdr.DefaultDecodeOptions + o.MaxInputLen = len(inp) + d := xdr.NewDecoderWithOptions(r, o) + _, err := s.DecodeFrom(d, o.MaxDepth) return err } @@ -46380,8 +46925,7 @@ var ( _ encoding.BinaryUnmarshaler = (*ScMetaV0)(nil) ) -// xdrType signals that this type is an type representing -// representing XDR values defined by this package. +// xdrType signals that this type represents XDR values defined by this package. func (s ScMetaV0) xdrType() {} var _ xdrType = (*ScMetaV0)(nil) @@ -46454,8 +46998,10 @@ func (s ScMetaKind) MarshalBinary() ([]byte, error) { // UnmarshalBinary implements encoding.BinaryUnmarshaler. func (s *ScMetaKind) UnmarshalBinary(inp []byte) error { r := bytes.NewReader(inp) - d := xdr.NewDecoder(r) - _, err := s.DecodeFrom(d, xdr.DecodeDefaultMaxDepth) + o := xdr.DefaultDecodeOptions + o.MaxInputLen = len(inp) + d := xdr.NewDecoderWithOptions(r, o) + _, err := s.DecodeFrom(d, o.MaxDepth) return err } @@ -46464,8 +47010,7 @@ var ( _ encoding.BinaryUnmarshaler = (*ScMetaKind)(nil) ) -// xdrType signals that this type is an type representing -// representing XDR values defined by this package. +// xdrType signals that this type represents XDR values defined by this package. func (s ScMetaKind) xdrType() {} var _ xdrType = (*ScMetaKind)(nil) @@ -46593,8 +47138,10 @@ func (s ScMetaEntry) MarshalBinary() ([]byte, error) { // UnmarshalBinary implements encoding.BinaryUnmarshaler. func (s *ScMetaEntry) UnmarshalBinary(inp []byte) error { r := bytes.NewReader(inp) - d := xdr.NewDecoder(r) - _, err := s.DecodeFrom(d, xdr.DecodeDefaultMaxDepth) + o := xdr.DefaultDecodeOptions + o.MaxInputLen = len(inp) + d := xdr.NewDecoderWithOptions(r, o) + _, err := s.DecodeFrom(d, o.MaxDepth) return err } @@ -46603,8 +47150,7 @@ var ( _ encoding.BinaryUnmarshaler = (*ScMetaEntry)(nil) ) -// xdrType signals that this type is an type representing -// representing XDR values defined by this package. +// xdrType signals that this type represents XDR values defined by this package. func (s ScMetaEntry) xdrType() {} var _ xdrType = (*ScMetaEntry)(nil) @@ -46760,8 +47306,10 @@ func (s ScSpecType) MarshalBinary() ([]byte, error) { // UnmarshalBinary implements encoding.BinaryUnmarshaler. func (s *ScSpecType) UnmarshalBinary(inp []byte) error { r := bytes.NewReader(inp) - d := xdr.NewDecoder(r) - _, err := s.DecodeFrom(d, xdr.DecodeDefaultMaxDepth) + o := xdr.DefaultDecodeOptions + o.MaxInputLen = len(inp) + d := xdr.NewDecoderWithOptions(r, o) + _, err := s.DecodeFrom(d, o.MaxDepth) return err } @@ -46770,8 +47318,7 @@ var ( _ encoding.BinaryUnmarshaler = (*ScSpecType)(nil) ) -// xdrType signals that this type is an type representing -// representing XDR values defined by this package. +// xdrType signals that this type represents XDR values defined by this package. func (s ScSpecType) xdrType() {} var _ xdrType = (*ScSpecType)(nil) @@ -46824,8 +47371,10 @@ func (s ScSpecTypeOption) MarshalBinary() ([]byte, error) { // UnmarshalBinary implements encoding.BinaryUnmarshaler. func (s *ScSpecTypeOption) UnmarshalBinary(inp []byte) error { r := bytes.NewReader(inp) - d := xdr.NewDecoder(r) - _, err := s.DecodeFrom(d, xdr.DecodeDefaultMaxDepth) + o := xdr.DefaultDecodeOptions + o.MaxInputLen = len(inp) + d := xdr.NewDecoderWithOptions(r, o) + _, err := s.DecodeFrom(d, o.MaxDepth) return err } @@ -46834,8 +47383,7 @@ var ( _ encoding.BinaryUnmarshaler = (*ScSpecTypeOption)(nil) ) -// xdrType signals that this type is an type representing -// representing XDR values defined by this package. +// xdrType signals that this type represents XDR values defined by this package. func (s ScSpecTypeOption) xdrType() {} var _ xdrType = (*ScSpecTypeOption)(nil) @@ -46898,8 +47446,10 @@ func (s ScSpecTypeResult) MarshalBinary() ([]byte, error) { // UnmarshalBinary implements encoding.BinaryUnmarshaler. func (s *ScSpecTypeResult) UnmarshalBinary(inp []byte) error { r := bytes.NewReader(inp) - d := xdr.NewDecoder(r) - _, err := s.DecodeFrom(d, xdr.DecodeDefaultMaxDepth) + o := xdr.DefaultDecodeOptions + o.MaxInputLen = len(inp) + d := xdr.NewDecoderWithOptions(r, o) + _, err := s.DecodeFrom(d, o.MaxDepth) return err } @@ -46908,8 +47458,7 @@ var ( _ encoding.BinaryUnmarshaler = (*ScSpecTypeResult)(nil) ) -// xdrType signals that this type is an type representing -// representing XDR values defined by this package. +// xdrType signals that this type represents XDR values defined by this package. func (s ScSpecTypeResult) xdrType() {} var _ xdrType = (*ScSpecTypeResult)(nil) @@ -46962,8 +47511,10 @@ func (s ScSpecTypeVec) MarshalBinary() ([]byte, error) { // UnmarshalBinary implements encoding.BinaryUnmarshaler. func (s *ScSpecTypeVec) UnmarshalBinary(inp []byte) error { r := bytes.NewReader(inp) - d := xdr.NewDecoder(r) - _, err := s.DecodeFrom(d, xdr.DecodeDefaultMaxDepth) + o := xdr.DefaultDecodeOptions + o.MaxInputLen = len(inp) + d := xdr.NewDecoderWithOptions(r, o) + _, err := s.DecodeFrom(d, o.MaxDepth) return err } @@ -46972,8 +47523,7 @@ var ( _ encoding.BinaryUnmarshaler = (*ScSpecTypeVec)(nil) ) -// xdrType signals that this type is an type representing -// representing XDR values defined by this package. +// xdrType signals that this type represents XDR values defined by this package. func (s ScSpecTypeVec) xdrType() {} var _ xdrType = (*ScSpecTypeVec)(nil) @@ -47036,8 +47586,10 @@ func (s ScSpecTypeMap) MarshalBinary() ([]byte, error) { // UnmarshalBinary implements encoding.BinaryUnmarshaler. func (s *ScSpecTypeMap) UnmarshalBinary(inp []byte) error { r := bytes.NewReader(inp) - d := xdr.NewDecoder(r) - _, err := s.DecodeFrom(d, xdr.DecodeDefaultMaxDepth) + o := xdr.DefaultDecodeOptions + o.MaxInputLen = len(inp) + d := xdr.NewDecoderWithOptions(r, o) + _, err := s.DecodeFrom(d, o.MaxDepth) return err } @@ -47046,8 +47598,7 @@ var ( _ encoding.BinaryUnmarshaler = (*ScSpecTypeMap)(nil) ) -// xdrType signals that this type is an type representing -// representing XDR values defined by this package. +// xdrType signals that this type represents XDR values defined by this package. func (s ScSpecTypeMap) xdrType() {} var _ xdrType = (*ScSpecTypeMap)(nil) @@ -47097,8 +47648,11 @@ func (s *ScSpecTypeTuple) DecodeFrom(d *xdr.Decoder, maxDepth uint) (int, error) } s.ValueTypes = nil if l > 0 { + if il, ok := d.InputLen(); ok && uint(il) < uint(l) { + return n, fmt.Errorf("decoding ScSpecTypeDef: length (%d) exceeds remaining input length (%d)", l, il) + } s.ValueTypes = make([]ScSpecTypeDef, l) - for i := uint32(0); i < l; i++ { + for i := uint32(0); uint(i) < uint(l); i++ { nTmp, err = s.ValueTypes[i].DecodeFrom(d, maxDepth) n += nTmp if err != nil { @@ -47120,8 +47674,10 @@ func (s ScSpecTypeTuple) MarshalBinary() ([]byte, error) { // UnmarshalBinary implements encoding.BinaryUnmarshaler. func (s *ScSpecTypeTuple) UnmarshalBinary(inp []byte) error { r := bytes.NewReader(inp) - d := xdr.NewDecoder(r) - _, err := s.DecodeFrom(d, xdr.DecodeDefaultMaxDepth) + o := xdr.DefaultDecodeOptions + o.MaxInputLen = len(inp) + d := xdr.NewDecoderWithOptions(r, o) + _, err := s.DecodeFrom(d, o.MaxDepth) return err } @@ -47130,8 +47686,7 @@ var ( _ encoding.BinaryUnmarshaler = (*ScSpecTypeTuple)(nil) ) -// xdrType signals that this type is an type representing -// representing XDR values defined by this package. +// xdrType signals that this type represents XDR values defined by this package. func (s ScSpecTypeTuple) xdrType() {} var _ xdrType = (*ScSpecTypeTuple)(nil) @@ -47184,8 +47739,10 @@ func (s ScSpecTypeBytesN) MarshalBinary() ([]byte, error) { // UnmarshalBinary implements encoding.BinaryUnmarshaler. func (s *ScSpecTypeBytesN) UnmarshalBinary(inp []byte) error { r := bytes.NewReader(inp) - d := xdr.NewDecoder(r) - _, err := s.DecodeFrom(d, xdr.DecodeDefaultMaxDepth) + o := xdr.DefaultDecodeOptions + o.MaxInputLen = len(inp) + d := xdr.NewDecoderWithOptions(r, o) + _, err := s.DecodeFrom(d, o.MaxDepth) return err } @@ -47194,8 +47751,7 @@ var ( _ encoding.BinaryUnmarshaler = (*ScSpecTypeBytesN)(nil) ) -// xdrType signals that this type is an type representing -// representing XDR values defined by this package. +// xdrType signals that this type represents XDR values defined by this package. func (s ScSpecTypeBytesN) xdrType() {} var _ xdrType = (*ScSpecTypeBytesN)(nil) @@ -47248,8 +47804,10 @@ func (s ScSpecTypeUdt) MarshalBinary() ([]byte, error) { // UnmarshalBinary implements encoding.BinaryUnmarshaler. func (s *ScSpecTypeUdt) UnmarshalBinary(inp []byte) error { r := bytes.NewReader(inp) - d := xdr.NewDecoder(r) - _, err := s.DecodeFrom(d, xdr.DecodeDefaultMaxDepth) + o := xdr.DefaultDecodeOptions + o.MaxInputLen = len(inp) + d := xdr.NewDecoderWithOptions(r, o) + _, err := s.DecodeFrom(d, o.MaxDepth) return err } @@ -47258,8 +47816,7 @@ var ( _ encoding.BinaryUnmarshaler = (*ScSpecTypeUdt)(nil) ) -// xdrType signals that this type is an type representing -// representing XDR values defined by this package. +// xdrType signals that this type represents XDR values defined by this package. func (s ScSpecTypeUdt) xdrType() {} var _ xdrType = (*ScSpecTypeUdt)(nil) @@ -47886,8 +48443,10 @@ func (s ScSpecTypeDef) MarshalBinary() ([]byte, error) { // UnmarshalBinary implements encoding.BinaryUnmarshaler. func (s *ScSpecTypeDef) UnmarshalBinary(inp []byte) error { r := bytes.NewReader(inp) - d := xdr.NewDecoder(r) - _, err := s.DecodeFrom(d, xdr.DecodeDefaultMaxDepth) + o := xdr.DefaultDecodeOptions + o.MaxInputLen = len(inp) + d := xdr.NewDecoderWithOptions(r, o) + _, err := s.DecodeFrom(d, o.MaxDepth) return err } @@ -47896,8 +48455,7 @@ var ( _ encoding.BinaryUnmarshaler = (*ScSpecTypeDef)(nil) ) -// xdrType signals that this type is an type representing -// representing XDR values defined by this package. +// xdrType signals that this type represents XDR values defined by this package. func (s ScSpecTypeDef) xdrType() {} var _ xdrType = (*ScSpecTypeDef)(nil) @@ -47970,8 +48528,10 @@ func (s ScSpecUdtStructFieldV0) MarshalBinary() ([]byte, error) { // UnmarshalBinary implements encoding.BinaryUnmarshaler. func (s *ScSpecUdtStructFieldV0) UnmarshalBinary(inp []byte) error { r := bytes.NewReader(inp) - d := xdr.NewDecoder(r) - _, err := s.DecodeFrom(d, xdr.DecodeDefaultMaxDepth) + o := xdr.DefaultDecodeOptions + o.MaxInputLen = len(inp) + d := xdr.NewDecoderWithOptions(r, o) + _, err := s.DecodeFrom(d, o.MaxDepth) return err } @@ -47980,8 +48540,7 @@ var ( _ encoding.BinaryUnmarshaler = (*ScSpecUdtStructFieldV0)(nil) ) -// xdrType signals that this type is an type representing -// representing XDR values defined by this package. +// xdrType signals that this type represents XDR values defined by this package. func (s ScSpecUdtStructFieldV0) xdrType() {} var _ xdrType = (*ScSpecUdtStructFieldV0)(nil) @@ -48061,8 +48620,11 @@ func (s *ScSpecUdtStructV0) DecodeFrom(d *xdr.Decoder, maxDepth uint) (int, erro } s.Fields = nil if l > 0 { + if il, ok := d.InputLen(); ok && uint(il) < uint(l) { + return n, fmt.Errorf("decoding ScSpecUdtStructFieldV0: length (%d) exceeds remaining input length (%d)", l, il) + } s.Fields = make([]ScSpecUdtStructFieldV0, l) - for i := uint32(0); i < l; i++ { + for i := uint32(0); uint(i) < uint(l); i++ { nTmp, err = s.Fields[i].DecodeFrom(d, maxDepth) n += nTmp if err != nil { @@ -48084,8 +48646,10 @@ func (s ScSpecUdtStructV0) MarshalBinary() ([]byte, error) { // UnmarshalBinary implements encoding.BinaryUnmarshaler. func (s *ScSpecUdtStructV0) UnmarshalBinary(inp []byte) error { r := bytes.NewReader(inp) - d := xdr.NewDecoder(r) - _, err := s.DecodeFrom(d, xdr.DecodeDefaultMaxDepth) + o := xdr.DefaultDecodeOptions + o.MaxInputLen = len(inp) + d := xdr.NewDecoderWithOptions(r, o) + _, err := s.DecodeFrom(d, o.MaxDepth) return err } @@ -48094,8 +48658,7 @@ var ( _ encoding.BinaryUnmarshaler = (*ScSpecUdtStructV0)(nil) ) -// xdrType signals that this type is an type representing -// representing XDR values defined by this package. +// xdrType signals that this type represents XDR values defined by this package. func (s ScSpecUdtStructV0) xdrType() {} var _ xdrType = (*ScSpecUdtStructV0)(nil) @@ -48158,8 +48721,10 @@ func (s ScSpecUdtUnionCaseVoidV0) MarshalBinary() ([]byte, error) { // UnmarshalBinary implements encoding.BinaryUnmarshaler. func (s *ScSpecUdtUnionCaseVoidV0) UnmarshalBinary(inp []byte) error { r := bytes.NewReader(inp) - d := xdr.NewDecoder(r) - _, err := s.DecodeFrom(d, xdr.DecodeDefaultMaxDepth) + o := xdr.DefaultDecodeOptions + o.MaxInputLen = len(inp) + d := xdr.NewDecoderWithOptions(r, o) + _, err := s.DecodeFrom(d, o.MaxDepth) return err } @@ -48168,8 +48733,7 @@ var ( _ encoding.BinaryUnmarshaler = (*ScSpecUdtUnionCaseVoidV0)(nil) ) -// xdrType signals that this type is an type representing -// representing XDR values defined by this package. +// xdrType signals that this type represents XDR values defined by this package. func (s ScSpecUdtUnionCaseVoidV0) xdrType() {} var _ xdrType = (*ScSpecUdtUnionCaseVoidV0)(nil) @@ -48239,8 +48803,11 @@ func (s *ScSpecUdtUnionCaseTupleV0) DecodeFrom(d *xdr.Decoder, maxDepth uint) (i } s.Type = nil if l > 0 { + if il, ok := d.InputLen(); ok && uint(il) < uint(l) { + return n, fmt.Errorf("decoding ScSpecTypeDef: length (%d) exceeds remaining input length (%d)", l, il) + } s.Type = make([]ScSpecTypeDef, l) - for i := uint32(0); i < l; i++ { + for i := uint32(0); uint(i) < uint(l); i++ { nTmp, err = s.Type[i].DecodeFrom(d, maxDepth) n += nTmp if err != nil { @@ -48262,8 +48829,10 @@ func (s ScSpecUdtUnionCaseTupleV0) MarshalBinary() ([]byte, error) { // UnmarshalBinary implements encoding.BinaryUnmarshaler. func (s *ScSpecUdtUnionCaseTupleV0) UnmarshalBinary(inp []byte) error { r := bytes.NewReader(inp) - d := xdr.NewDecoder(r) - _, err := s.DecodeFrom(d, xdr.DecodeDefaultMaxDepth) + o := xdr.DefaultDecodeOptions + o.MaxInputLen = len(inp) + d := xdr.NewDecoderWithOptions(r, o) + _, err := s.DecodeFrom(d, o.MaxDepth) return err } @@ -48272,8 +48841,7 @@ var ( _ encoding.BinaryUnmarshaler = (*ScSpecUdtUnionCaseTupleV0)(nil) ) -// xdrType signals that this type is an type representing -// representing XDR values defined by this package. +// xdrType signals that this type represents XDR values defined by this package. func (s ScSpecUdtUnionCaseTupleV0) xdrType() {} var _ xdrType = (*ScSpecUdtUnionCaseTupleV0)(nil) @@ -48349,8 +48917,10 @@ func (s ScSpecUdtUnionCaseV0Kind) MarshalBinary() ([]byte, error) { // UnmarshalBinary implements encoding.BinaryUnmarshaler. func (s *ScSpecUdtUnionCaseV0Kind) UnmarshalBinary(inp []byte) error { r := bytes.NewReader(inp) - d := xdr.NewDecoder(r) - _, err := s.DecodeFrom(d, xdr.DecodeDefaultMaxDepth) + o := xdr.DefaultDecodeOptions + o.MaxInputLen = len(inp) + d := xdr.NewDecoderWithOptions(r, o) + _, err := s.DecodeFrom(d, o.MaxDepth) return err } @@ -48359,8 +48929,7 @@ var ( _ encoding.BinaryUnmarshaler = (*ScSpecUdtUnionCaseV0Kind)(nil) ) -// xdrType signals that this type is an type representing -// representing XDR values defined by this package. +// xdrType signals that this type represents XDR values defined by this package. func (s ScSpecUdtUnionCaseV0Kind) xdrType() {} var _ xdrType = (*ScSpecUdtUnionCaseV0Kind)(nil) @@ -48538,8 +49107,10 @@ func (s ScSpecUdtUnionCaseV0) MarshalBinary() ([]byte, error) { // UnmarshalBinary implements encoding.BinaryUnmarshaler. func (s *ScSpecUdtUnionCaseV0) UnmarshalBinary(inp []byte) error { r := bytes.NewReader(inp) - d := xdr.NewDecoder(r) - _, err := s.DecodeFrom(d, xdr.DecodeDefaultMaxDepth) + o := xdr.DefaultDecodeOptions + o.MaxInputLen = len(inp) + d := xdr.NewDecoderWithOptions(r, o) + _, err := s.DecodeFrom(d, o.MaxDepth) return err } @@ -48548,8 +49119,7 @@ var ( _ encoding.BinaryUnmarshaler = (*ScSpecUdtUnionCaseV0)(nil) ) -// xdrType signals that this type is an type representing -// representing XDR values defined by this package. +// xdrType signals that this type represents XDR values defined by this package. func (s ScSpecUdtUnionCaseV0) xdrType() {} var _ xdrType = (*ScSpecUdtUnionCaseV0)(nil) @@ -48629,8 +49199,11 @@ func (s *ScSpecUdtUnionV0) DecodeFrom(d *xdr.Decoder, maxDepth uint) (int, error } s.Cases = nil if l > 0 { + if il, ok := d.InputLen(); ok && uint(il) < uint(l) { + return n, fmt.Errorf("decoding ScSpecUdtUnionCaseV0: length (%d) exceeds remaining input length (%d)", l, il) + } s.Cases = make([]ScSpecUdtUnionCaseV0, l) - for i := uint32(0); i < l; i++ { + for i := uint32(0); uint(i) < uint(l); i++ { nTmp, err = s.Cases[i].DecodeFrom(d, maxDepth) n += nTmp if err != nil { @@ -48652,8 +49225,10 @@ func (s ScSpecUdtUnionV0) MarshalBinary() ([]byte, error) { // UnmarshalBinary implements encoding.BinaryUnmarshaler. func (s *ScSpecUdtUnionV0) UnmarshalBinary(inp []byte) error { r := bytes.NewReader(inp) - d := xdr.NewDecoder(r) - _, err := s.DecodeFrom(d, xdr.DecodeDefaultMaxDepth) + o := xdr.DefaultDecodeOptions + o.MaxInputLen = len(inp) + d := xdr.NewDecoderWithOptions(r, o) + _, err := s.DecodeFrom(d, o.MaxDepth) return err } @@ -48662,8 +49237,7 @@ var ( _ encoding.BinaryUnmarshaler = (*ScSpecUdtUnionV0)(nil) ) -// xdrType signals that this type is an type representing -// representing XDR values defined by this package. +// xdrType signals that this type represents XDR values defined by this package. func (s ScSpecUdtUnionV0) xdrType() {} var _ xdrType = (*ScSpecUdtUnionV0)(nil) @@ -48736,8 +49310,10 @@ func (s ScSpecUdtEnumCaseV0) MarshalBinary() ([]byte, error) { // UnmarshalBinary implements encoding.BinaryUnmarshaler. func (s *ScSpecUdtEnumCaseV0) UnmarshalBinary(inp []byte) error { r := bytes.NewReader(inp) - d := xdr.NewDecoder(r) - _, err := s.DecodeFrom(d, xdr.DecodeDefaultMaxDepth) + o := xdr.DefaultDecodeOptions + o.MaxInputLen = len(inp) + d := xdr.NewDecoderWithOptions(r, o) + _, err := s.DecodeFrom(d, o.MaxDepth) return err } @@ -48746,8 +49322,7 @@ var ( _ encoding.BinaryUnmarshaler = (*ScSpecUdtEnumCaseV0)(nil) ) -// xdrType signals that this type is an type representing -// representing XDR values defined by this package. +// xdrType signals that this type represents XDR values defined by this package. func (s ScSpecUdtEnumCaseV0) xdrType() {} var _ xdrType = (*ScSpecUdtEnumCaseV0)(nil) @@ -48827,8 +49402,11 @@ func (s *ScSpecUdtEnumV0) DecodeFrom(d *xdr.Decoder, maxDepth uint) (int, error) } s.Cases = nil if l > 0 { + if il, ok := d.InputLen(); ok && uint(il) < uint(l) { + return n, fmt.Errorf("decoding ScSpecUdtEnumCaseV0: length (%d) exceeds remaining input length (%d)", l, il) + } s.Cases = make([]ScSpecUdtEnumCaseV0, l) - for i := uint32(0); i < l; i++ { + for i := uint32(0); uint(i) < uint(l); i++ { nTmp, err = s.Cases[i].DecodeFrom(d, maxDepth) n += nTmp if err != nil { @@ -48850,8 +49428,10 @@ func (s ScSpecUdtEnumV0) MarshalBinary() ([]byte, error) { // UnmarshalBinary implements encoding.BinaryUnmarshaler. func (s *ScSpecUdtEnumV0) UnmarshalBinary(inp []byte) error { r := bytes.NewReader(inp) - d := xdr.NewDecoder(r) - _, err := s.DecodeFrom(d, xdr.DecodeDefaultMaxDepth) + o := xdr.DefaultDecodeOptions + o.MaxInputLen = len(inp) + d := xdr.NewDecoderWithOptions(r, o) + _, err := s.DecodeFrom(d, o.MaxDepth) return err } @@ -48860,8 +49440,7 @@ var ( _ encoding.BinaryUnmarshaler = (*ScSpecUdtEnumV0)(nil) ) -// xdrType signals that this type is an type representing -// representing XDR values defined by this package. +// xdrType signals that this type represents XDR values defined by this package. func (s ScSpecUdtEnumV0) xdrType() {} var _ xdrType = (*ScSpecUdtEnumV0)(nil) @@ -48934,8 +49513,10 @@ func (s ScSpecUdtErrorEnumCaseV0) MarshalBinary() ([]byte, error) { // UnmarshalBinary implements encoding.BinaryUnmarshaler. func (s *ScSpecUdtErrorEnumCaseV0) UnmarshalBinary(inp []byte) error { r := bytes.NewReader(inp) - d := xdr.NewDecoder(r) - _, err := s.DecodeFrom(d, xdr.DecodeDefaultMaxDepth) + o := xdr.DefaultDecodeOptions + o.MaxInputLen = len(inp) + d := xdr.NewDecoderWithOptions(r, o) + _, err := s.DecodeFrom(d, o.MaxDepth) return err } @@ -48944,8 +49525,7 @@ var ( _ encoding.BinaryUnmarshaler = (*ScSpecUdtErrorEnumCaseV0)(nil) ) -// xdrType signals that this type is an type representing -// representing XDR values defined by this package. +// xdrType signals that this type represents XDR values defined by this package. func (s ScSpecUdtErrorEnumCaseV0) xdrType() {} var _ xdrType = (*ScSpecUdtErrorEnumCaseV0)(nil) @@ -49025,8 +49605,11 @@ func (s *ScSpecUdtErrorEnumV0) DecodeFrom(d *xdr.Decoder, maxDepth uint) (int, e } s.Cases = nil if l > 0 { + if il, ok := d.InputLen(); ok && uint(il) < uint(l) { + return n, fmt.Errorf("decoding ScSpecUdtErrorEnumCaseV0: length (%d) exceeds remaining input length (%d)", l, il) + } s.Cases = make([]ScSpecUdtErrorEnumCaseV0, l) - for i := uint32(0); i < l; i++ { + for i := uint32(0); uint(i) < uint(l); i++ { nTmp, err = s.Cases[i].DecodeFrom(d, maxDepth) n += nTmp if err != nil { @@ -49048,8 +49631,10 @@ func (s ScSpecUdtErrorEnumV0) MarshalBinary() ([]byte, error) { // UnmarshalBinary implements encoding.BinaryUnmarshaler. func (s *ScSpecUdtErrorEnumV0) UnmarshalBinary(inp []byte) error { r := bytes.NewReader(inp) - d := xdr.NewDecoder(r) - _, err := s.DecodeFrom(d, xdr.DecodeDefaultMaxDepth) + o := xdr.DefaultDecodeOptions + o.MaxInputLen = len(inp) + d := xdr.NewDecoderWithOptions(r, o) + _, err := s.DecodeFrom(d, o.MaxDepth) return err } @@ -49058,8 +49643,7 @@ var ( _ encoding.BinaryUnmarshaler = (*ScSpecUdtErrorEnumV0)(nil) ) -// xdrType signals that this type is an type representing -// representing XDR values defined by this package. +// xdrType signals that this type represents XDR values defined by this package. func (s ScSpecUdtErrorEnumV0) xdrType() {} var _ xdrType = (*ScSpecUdtErrorEnumV0)(nil) @@ -49132,8 +49716,10 @@ func (s ScSpecFunctionInputV0) MarshalBinary() ([]byte, error) { // UnmarshalBinary implements encoding.BinaryUnmarshaler. func (s *ScSpecFunctionInputV0) UnmarshalBinary(inp []byte) error { r := bytes.NewReader(inp) - d := xdr.NewDecoder(r) - _, err := s.DecodeFrom(d, xdr.DecodeDefaultMaxDepth) + o := xdr.DefaultDecodeOptions + o.MaxInputLen = len(inp) + d := xdr.NewDecoderWithOptions(r, o) + _, err := s.DecodeFrom(d, o.MaxDepth) return err } @@ -49142,8 +49728,7 @@ var ( _ encoding.BinaryUnmarshaler = (*ScSpecFunctionInputV0)(nil) ) -// xdrType signals that this type is an type representing -// representing XDR values defined by this package. +// xdrType signals that this type represents XDR values defined by this package. func (s ScSpecFunctionInputV0) xdrType() {} var _ xdrType = (*ScSpecFunctionInputV0)(nil) @@ -49223,8 +49808,11 @@ func (s *ScSpecFunctionV0) DecodeFrom(d *xdr.Decoder, maxDepth uint) (int, error } s.Inputs = nil if l > 0 { + if il, ok := d.InputLen(); ok && uint(il) < uint(l) { + return n, fmt.Errorf("decoding ScSpecFunctionInputV0: length (%d) exceeds remaining input length (%d)", l, il) + } s.Inputs = make([]ScSpecFunctionInputV0, l) - for i := uint32(0); i < l; i++ { + for i := uint32(0); uint(i) < uint(l); i++ { nTmp, err = s.Inputs[i].DecodeFrom(d, maxDepth) n += nTmp if err != nil { @@ -49242,8 +49830,11 @@ func (s *ScSpecFunctionV0) DecodeFrom(d *xdr.Decoder, maxDepth uint) (int, error } s.Outputs = nil if l > 0 { + if il, ok := d.InputLen(); ok && uint(il) < uint(l) { + return n, fmt.Errorf("decoding ScSpecTypeDef: length (%d) exceeds remaining input length (%d)", l, il) + } s.Outputs = make([]ScSpecTypeDef, l) - for i := uint32(0); i < l; i++ { + for i := uint32(0); uint(i) < uint(l); i++ { nTmp, err = s.Outputs[i].DecodeFrom(d, maxDepth) n += nTmp if err != nil { @@ -49265,8 +49856,10 @@ func (s ScSpecFunctionV0) MarshalBinary() ([]byte, error) { // UnmarshalBinary implements encoding.BinaryUnmarshaler. func (s *ScSpecFunctionV0) UnmarshalBinary(inp []byte) error { r := bytes.NewReader(inp) - d := xdr.NewDecoder(r) - _, err := s.DecodeFrom(d, xdr.DecodeDefaultMaxDepth) + o := xdr.DefaultDecodeOptions + o.MaxInputLen = len(inp) + d := xdr.NewDecoderWithOptions(r, o) + _, err := s.DecodeFrom(d, o.MaxDepth) return err } @@ -49275,8 +49868,7 @@ var ( _ encoding.BinaryUnmarshaler = (*ScSpecFunctionV0)(nil) ) -// xdrType signals that this type is an type representing -// representing XDR values defined by this package. +// xdrType signals that this type represents XDR values defined by this package. func (s ScSpecFunctionV0) xdrType() {} var _ xdrType = (*ScSpecFunctionV0)(nil) @@ -49361,8 +49953,10 @@ func (s ScSpecEntryKind) MarshalBinary() ([]byte, error) { // UnmarshalBinary implements encoding.BinaryUnmarshaler. func (s *ScSpecEntryKind) UnmarshalBinary(inp []byte) error { r := bytes.NewReader(inp) - d := xdr.NewDecoder(r) - _, err := s.DecodeFrom(d, xdr.DecodeDefaultMaxDepth) + o := xdr.DefaultDecodeOptions + o.MaxInputLen = len(inp) + d := xdr.NewDecoderWithOptions(r, o) + _, err := s.DecodeFrom(d, o.MaxDepth) return err } @@ -49371,8 +49965,7 @@ var ( _ encoding.BinaryUnmarshaler = (*ScSpecEntryKind)(nil) ) -// xdrType signals that this type is an type representing -// representing XDR values defined by this package. +// xdrType signals that this type represents XDR values defined by this package. func (s ScSpecEntryKind) xdrType() {} var _ xdrType = (*ScSpecEntryKind)(nil) @@ -49700,8 +50293,10 @@ func (s ScSpecEntry) MarshalBinary() ([]byte, error) { // UnmarshalBinary implements encoding.BinaryUnmarshaler. func (s *ScSpecEntry) UnmarshalBinary(inp []byte) error { r := bytes.NewReader(inp) - d := xdr.NewDecoder(r) - _, err := s.DecodeFrom(d, xdr.DecodeDefaultMaxDepth) + o := xdr.DefaultDecodeOptions + o.MaxInputLen = len(inp) + d := xdr.NewDecoderWithOptions(r, o) + _, err := s.DecodeFrom(d, o.MaxDepth) return err } @@ -49710,8 +50305,7 @@ var ( _ encoding.BinaryUnmarshaler = (*ScSpecEntry)(nil) ) -// xdrType signals that this type is an type representing -// representing XDR values defined by this package. +// xdrType signals that this type represents XDR values defined by this package. func (s ScSpecEntry) xdrType() {} var _ xdrType = (*ScSpecEntry)(nil) @@ -49876,8 +50470,10 @@ func (s ScValType) MarshalBinary() ([]byte, error) { // UnmarshalBinary implements encoding.BinaryUnmarshaler. func (s *ScValType) UnmarshalBinary(inp []byte) error { r := bytes.NewReader(inp) - d := xdr.NewDecoder(r) - _, err := s.DecodeFrom(d, xdr.DecodeDefaultMaxDepth) + o := xdr.DefaultDecodeOptions + o.MaxInputLen = len(inp) + d := xdr.NewDecoderWithOptions(r, o) + _, err := s.DecodeFrom(d, o.MaxDepth) return err } @@ -49886,8 +50482,7 @@ var ( _ encoding.BinaryUnmarshaler = (*ScValType)(nil) ) -// xdrType signals that this type is an type representing -// representing XDR values defined by this package. +// xdrType signals that this type represents XDR values defined by this package. func (s ScValType) xdrType() {} var _ xdrType = (*ScValType)(nil) @@ -49987,8 +50582,10 @@ func (s ScErrorType) MarshalBinary() ([]byte, error) { // UnmarshalBinary implements encoding.BinaryUnmarshaler. func (s *ScErrorType) UnmarshalBinary(inp []byte) error { r := bytes.NewReader(inp) - d := xdr.NewDecoder(r) - _, err := s.DecodeFrom(d, xdr.DecodeDefaultMaxDepth) + o := xdr.DefaultDecodeOptions + o.MaxInputLen = len(inp) + d := xdr.NewDecoderWithOptions(r, o) + _, err := s.DecodeFrom(d, o.MaxDepth) return err } @@ -49997,8 +50594,7 @@ var ( _ encoding.BinaryUnmarshaler = (*ScErrorType)(nil) ) -// xdrType signals that this type is an type representing -// representing XDR values defined by this package. +// xdrType signals that this type represents XDR values defined by this package. func (s ScErrorType) xdrType() {} var _ xdrType = (*ScErrorType)(nil) @@ -50098,8 +50694,10 @@ func (s ScErrorCode) MarshalBinary() ([]byte, error) { // UnmarshalBinary implements encoding.BinaryUnmarshaler. func (s *ScErrorCode) UnmarshalBinary(inp []byte) error { r := bytes.NewReader(inp) - d := xdr.NewDecoder(r) - _, err := s.DecodeFrom(d, xdr.DecodeDefaultMaxDepth) + o := xdr.DefaultDecodeOptions + o.MaxInputLen = len(inp) + d := xdr.NewDecoderWithOptions(r, o) + _, err := s.DecodeFrom(d, o.MaxDepth) return err } @@ -50108,8 +50706,7 @@ var ( _ encoding.BinaryUnmarshaler = (*ScErrorCode)(nil) ) -// xdrType signals that this type is an type representing -// representing XDR values defined by this package. +// xdrType signals that this type represents XDR values defined by this package. func (s ScErrorCode) xdrType() {} var _ xdrType = (*ScErrorCode)(nil) @@ -50471,8 +51068,10 @@ func (s ScError) MarshalBinary() ([]byte, error) { // UnmarshalBinary implements encoding.BinaryUnmarshaler. func (s *ScError) UnmarshalBinary(inp []byte) error { r := bytes.NewReader(inp) - d := xdr.NewDecoder(r) - _, err := s.DecodeFrom(d, xdr.DecodeDefaultMaxDepth) + o := xdr.DefaultDecodeOptions + o.MaxInputLen = len(inp) + d := xdr.NewDecoderWithOptions(r, o) + _, err := s.DecodeFrom(d, o.MaxDepth) return err } @@ -50481,8 +51080,7 @@ var ( _ encoding.BinaryUnmarshaler = (*ScError)(nil) ) -// xdrType signals that this type is an type representing -// representing XDR values defined by this package. +// xdrType signals that this type represents XDR values defined by this package. func (s ScError) xdrType() {} var _ xdrType = (*ScError)(nil) @@ -50544,8 +51142,10 @@ func (s UInt128Parts) MarshalBinary() ([]byte, error) { // UnmarshalBinary implements encoding.BinaryUnmarshaler. func (s *UInt128Parts) UnmarshalBinary(inp []byte) error { r := bytes.NewReader(inp) - d := xdr.NewDecoder(r) - _, err := s.DecodeFrom(d, xdr.DecodeDefaultMaxDepth) + o := xdr.DefaultDecodeOptions + o.MaxInputLen = len(inp) + d := xdr.NewDecoderWithOptions(r, o) + _, err := s.DecodeFrom(d, o.MaxDepth) return err } @@ -50554,8 +51154,7 @@ var ( _ encoding.BinaryUnmarshaler = (*UInt128Parts)(nil) ) -// xdrType signals that this type is an type representing -// representing XDR values defined by this package. +// xdrType signals that this type represents XDR values defined by this package. func (s UInt128Parts) xdrType() {} var _ xdrType = (*UInt128Parts)(nil) @@ -50617,8 +51216,10 @@ func (s Int128Parts) MarshalBinary() ([]byte, error) { // UnmarshalBinary implements encoding.BinaryUnmarshaler. func (s *Int128Parts) UnmarshalBinary(inp []byte) error { r := bytes.NewReader(inp) - d := xdr.NewDecoder(r) - _, err := s.DecodeFrom(d, xdr.DecodeDefaultMaxDepth) + o := xdr.DefaultDecodeOptions + o.MaxInputLen = len(inp) + d := xdr.NewDecoderWithOptions(r, o) + _, err := s.DecodeFrom(d, o.MaxDepth) return err } @@ -50627,8 +51228,7 @@ var ( _ encoding.BinaryUnmarshaler = (*Int128Parts)(nil) ) -// xdrType signals that this type is an type representing -// representing XDR values defined by this package. +// xdrType signals that this type represents XDR values defined by this package. func (s Int128Parts) xdrType() {} var _ xdrType = (*Int128Parts)(nil) @@ -50710,8 +51310,10 @@ func (s UInt256Parts) MarshalBinary() ([]byte, error) { // UnmarshalBinary implements encoding.BinaryUnmarshaler. func (s *UInt256Parts) UnmarshalBinary(inp []byte) error { r := bytes.NewReader(inp) - d := xdr.NewDecoder(r) - _, err := s.DecodeFrom(d, xdr.DecodeDefaultMaxDepth) + o := xdr.DefaultDecodeOptions + o.MaxInputLen = len(inp) + d := xdr.NewDecoderWithOptions(r, o) + _, err := s.DecodeFrom(d, o.MaxDepth) return err } @@ -50720,8 +51322,7 @@ var ( _ encoding.BinaryUnmarshaler = (*UInt256Parts)(nil) ) -// xdrType signals that this type is an type representing -// representing XDR values defined by this package. +// xdrType signals that this type represents XDR values defined by this package. func (s UInt256Parts) xdrType() {} var _ xdrType = (*UInt256Parts)(nil) @@ -50803,8 +51404,10 @@ func (s Int256Parts) MarshalBinary() ([]byte, error) { // UnmarshalBinary implements encoding.BinaryUnmarshaler. func (s *Int256Parts) UnmarshalBinary(inp []byte) error { r := bytes.NewReader(inp) - d := xdr.NewDecoder(r) - _, err := s.DecodeFrom(d, xdr.DecodeDefaultMaxDepth) + o := xdr.DefaultDecodeOptions + o.MaxInputLen = len(inp) + d := xdr.NewDecoderWithOptions(r, o) + _, err := s.DecodeFrom(d, o.MaxDepth) return err } @@ -50813,8 +51416,7 @@ var ( _ encoding.BinaryUnmarshaler = (*Int256Parts)(nil) ) -// xdrType signals that this type is an type representing -// representing XDR values defined by this package. +// xdrType signals that this type represents XDR values defined by this package. func (s Int256Parts) xdrType() {} var _ xdrType = (*Int256Parts)(nil) @@ -50890,8 +51492,10 @@ func (s ContractExecutableType) MarshalBinary() ([]byte, error) { // UnmarshalBinary implements encoding.BinaryUnmarshaler. func (s *ContractExecutableType) UnmarshalBinary(inp []byte) error { r := bytes.NewReader(inp) - d := xdr.NewDecoder(r) - _, err := s.DecodeFrom(d, xdr.DecodeDefaultMaxDepth) + o := xdr.DefaultDecodeOptions + o.MaxInputLen = len(inp) + d := xdr.NewDecoderWithOptions(r, o) + _, err := s.DecodeFrom(d, o.MaxDepth) return err } @@ -50900,8 +51504,7 @@ var ( _ encoding.BinaryUnmarshaler = (*ContractExecutableType)(nil) ) -// xdrType signals that this type is an type representing -// representing XDR values defined by this package. +// xdrType signals that this type represents XDR values defined by this package. func (s ContractExecutableType) xdrType() {} var _ xdrType = (*ContractExecutableType)(nil) @@ -51041,8 +51644,10 @@ func (s ContractExecutable) MarshalBinary() ([]byte, error) { // UnmarshalBinary implements encoding.BinaryUnmarshaler. func (s *ContractExecutable) UnmarshalBinary(inp []byte) error { r := bytes.NewReader(inp) - d := xdr.NewDecoder(r) - _, err := s.DecodeFrom(d, xdr.DecodeDefaultMaxDepth) + o := xdr.DefaultDecodeOptions + o.MaxInputLen = len(inp) + d := xdr.NewDecoderWithOptions(r, o) + _, err := s.DecodeFrom(d, o.MaxDepth) return err } @@ -51051,8 +51656,7 @@ var ( _ encoding.BinaryUnmarshaler = (*ContractExecutable)(nil) ) -// xdrType signals that this type is an type representing -// representing XDR values defined by this package. +// xdrType signals that this type represents XDR values defined by this package. func (s ContractExecutable) xdrType() {} var _ xdrType = (*ContractExecutable)(nil) @@ -51128,8 +51732,10 @@ func (s ScAddressType) MarshalBinary() ([]byte, error) { // UnmarshalBinary implements encoding.BinaryUnmarshaler. func (s *ScAddressType) UnmarshalBinary(inp []byte) error { r := bytes.NewReader(inp) - d := xdr.NewDecoder(r) - _, err := s.DecodeFrom(d, xdr.DecodeDefaultMaxDepth) + o := xdr.DefaultDecodeOptions + o.MaxInputLen = len(inp) + d := xdr.NewDecoderWithOptions(r, o) + _, err := s.DecodeFrom(d, o.MaxDepth) return err } @@ -51138,8 +51744,7 @@ var ( _ encoding.BinaryUnmarshaler = (*ScAddressType)(nil) ) -// xdrType signals that this type is an type representing -// representing XDR values defined by this package. +// xdrType signals that this type represents XDR values defined by this package. func (s ScAddressType) xdrType() {} var _ xdrType = (*ScAddressType)(nil) @@ -51317,8 +51922,10 @@ func (s ScAddress) MarshalBinary() ([]byte, error) { // UnmarshalBinary implements encoding.BinaryUnmarshaler. func (s *ScAddress) UnmarshalBinary(inp []byte) error { r := bytes.NewReader(inp) - d := xdr.NewDecoder(r) - _, err := s.DecodeFrom(d, xdr.DecodeDefaultMaxDepth) + o := xdr.DefaultDecodeOptions + o.MaxInputLen = len(inp) + d := xdr.NewDecoderWithOptions(r, o) + _, err := s.DecodeFrom(d, o.MaxDepth) return err } @@ -51327,8 +51934,7 @@ var ( _ encoding.BinaryUnmarshaler = (*ScAddress)(nil) ) -// xdrType signals that this type is an type representing -// representing XDR values defined by this package. +// xdrType signals that this type represents XDR values defined by this package. func (s ScAddress) xdrType() {} var _ xdrType = (*ScAddress)(nil) @@ -51375,8 +51981,11 @@ func (s *ScVec) DecodeFrom(d *xdr.Decoder, maxDepth uint) (int, error) { } (*s) = nil if l > 0 { + if il, ok := d.InputLen(); ok && uint(il) < uint(l) { + return n, fmt.Errorf("decoding ScVal: length (%d) exceeds remaining input length (%d)", l, il) + } (*s) = make([]ScVal, l) - for i := uint32(0); i < l; i++ { + for i := uint32(0); uint(i) < uint(l); i++ { nTmp, err = (*s)[i].DecodeFrom(d, maxDepth) n += nTmp if err != nil { @@ -51398,8 +52007,10 @@ func (s ScVec) MarshalBinary() ([]byte, error) { // UnmarshalBinary implements encoding.BinaryUnmarshaler. func (s *ScVec) UnmarshalBinary(inp []byte) error { r := bytes.NewReader(inp) - d := xdr.NewDecoder(r) - _, err := s.DecodeFrom(d, xdr.DecodeDefaultMaxDepth) + o := xdr.DefaultDecodeOptions + o.MaxInputLen = len(inp) + d := xdr.NewDecoderWithOptions(r, o) + _, err := s.DecodeFrom(d, o.MaxDepth) return err } @@ -51408,8 +52019,7 @@ var ( _ encoding.BinaryUnmarshaler = (*ScVec)(nil) ) -// xdrType signals that this type is an type representing -// representing XDR values defined by this package. +// xdrType signals that this type represents XDR values defined by this package. func (s ScVec) xdrType() {} var _ xdrType = (*ScVec)(nil) @@ -51451,8 +52061,11 @@ func (s *ScMap) DecodeFrom(d *xdr.Decoder, maxDepth uint) (int, error) { } (*s) = nil if l > 0 { + if il, ok := d.InputLen(); ok && uint(il) < uint(l) { + return n, fmt.Errorf("decoding ScMapEntry: length (%d) exceeds remaining input length (%d)", l, il) + } (*s) = make([]ScMapEntry, l) - for i := uint32(0); i < l; i++ { + for i := uint32(0); uint(i) < uint(l); i++ { nTmp, err = (*s)[i].DecodeFrom(d, maxDepth) n += nTmp if err != nil { @@ -51474,8 +52087,10 @@ func (s ScMap) MarshalBinary() ([]byte, error) { // UnmarshalBinary implements encoding.BinaryUnmarshaler. func (s *ScMap) UnmarshalBinary(inp []byte) error { r := bytes.NewReader(inp) - d := xdr.NewDecoder(r) - _, err := s.DecodeFrom(d, xdr.DecodeDefaultMaxDepth) + o := xdr.DefaultDecodeOptions + o.MaxInputLen = len(inp) + d := xdr.NewDecoderWithOptions(r, o) + _, err := s.DecodeFrom(d, o.MaxDepth) return err } @@ -51484,8 +52099,7 @@ var ( _ encoding.BinaryUnmarshaler = (*ScMap)(nil) ) -// xdrType signals that this type is an type representing -// representing XDR values defined by this package. +// xdrType signals that this type represents XDR values defined by this package. func (s ScMap) xdrType() {} var _ xdrType = (*ScMap)(nil) @@ -51533,8 +52147,10 @@ func (s ScBytes) MarshalBinary() ([]byte, error) { // UnmarshalBinary implements encoding.BinaryUnmarshaler. func (s *ScBytes) UnmarshalBinary(inp []byte) error { r := bytes.NewReader(inp) - d := xdr.NewDecoder(r) - _, err := s.DecodeFrom(d, xdr.DecodeDefaultMaxDepth) + o := xdr.DefaultDecodeOptions + o.MaxInputLen = len(inp) + d := xdr.NewDecoderWithOptions(r, o) + _, err := s.DecodeFrom(d, o.MaxDepth) return err } @@ -51543,8 +52159,7 @@ var ( _ encoding.BinaryUnmarshaler = (*ScBytes)(nil) ) -// xdrType signals that this type is an type representing -// representing XDR values defined by this package. +// xdrType signals that this type represents XDR values defined by this package. func (s ScBytes) xdrType() {} var _ xdrType = (*ScBytes)(nil) @@ -51594,8 +52209,10 @@ func (s ScString) MarshalBinary() ([]byte, error) { // UnmarshalBinary implements encoding.BinaryUnmarshaler. func (s *ScString) UnmarshalBinary(inp []byte) error { r := bytes.NewReader(inp) - d := xdr.NewDecoder(r) - _, err := s.DecodeFrom(d, xdr.DecodeDefaultMaxDepth) + o := xdr.DefaultDecodeOptions + o.MaxInputLen = len(inp) + d := xdr.NewDecoderWithOptions(r, o) + _, err := s.DecodeFrom(d, o.MaxDepth) return err } @@ -51604,8 +52221,7 @@ var ( _ encoding.BinaryUnmarshaler = (*ScString)(nil) ) -// xdrType signals that this type is an type representing -// representing XDR values defined by this package. +// xdrType signals that this type represents XDR values defined by this package. func (s ScString) xdrType() {} var _ xdrType = (*ScString)(nil) @@ -51660,8 +52276,10 @@ func (s ScSymbol) MarshalBinary() ([]byte, error) { // UnmarshalBinary implements encoding.BinaryUnmarshaler. func (s *ScSymbol) UnmarshalBinary(inp []byte) error { r := bytes.NewReader(inp) - d := xdr.NewDecoder(r) - _, err := s.DecodeFrom(d, xdr.DecodeDefaultMaxDepth) + o := xdr.DefaultDecodeOptions + o.MaxInputLen = len(inp) + d := xdr.NewDecoderWithOptions(r, o) + _, err := s.DecodeFrom(d, o.MaxDepth) return err } @@ -51670,8 +52288,7 @@ var ( _ encoding.BinaryUnmarshaler = (*ScSymbol)(nil) ) -// xdrType signals that this type is an type representing -// representing XDR values defined by this package. +// xdrType signals that this type represents XDR values defined by this package. func (s ScSymbol) xdrType() {} var _ xdrType = (*ScSymbol)(nil) @@ -51723,8 +52340,10 @@ func (s ScNonceKey) MarshalBinary() ([]byte, error) { // UnmarshalBinary implements encoding.BinaryUnmarshaler. func (s *ScNonceKey) UnmarshalBinary(inp []byte) error { r := bytes.NewReader(inp) - d := xdr.NewDecoder(r) - _, err := s.DecodeFrom(d, xdr.DecodeDefaultMaxDepth) + o := xdr.DefaultDecodeOptions + o.MaxInputLen = len(inp) + d := xdr.NewDecoderWithOptions(r, o) + _, err := s.DecodeFrom(d, o.MaxDepth) return err } @@ -51733,8 +52352,7 @@ var ( _ encoding.BinaryUnmarshaler = (*ScNonceKey)(nil) ) -// xdrType signals that this type is an type representing -// representing XDR values defined by this package. +// xdrType signals that this type represents XDR values defined by this package. func (s ScNonceKey) xdrType() {} var _ xdrType = (*ScNonceKey)(nil) @@ -51811,8 +52429,10 @@ func (s ScContractInstance) MarshalBinary() ([]byte, error) { // UnmarshalBinary implements encoding.BinaryUnmarshaler. func (s *ScContractInstance) UnmarshalBinary(inp []byte) error { r := bytes.NewReader(inp) - d := xdr.NewDecoder(r) - _, err := s.DecodeFrom(d, xdr.DecodeDefaultMaxDepth) + o := xdr.DefaultDecodeOptions + o.MaxInputLen = len(inp) + d := xdr.NewDecoderWithOptions(r, o) + _, err := s.DecodeFrom(d, o.MaxDepth) return err } @@ -51821,8 +52441,7 @@ var ( _ encoding.BinaryUnmarshaler = (*ScContractInstance)(nil) ) -// xdrType signals that this type is an type representing -// representing XDR values defined by this package. +// xdrType signals that this type represents XDR values defined by this package. func (s ScContractInstance) xdrType() {} var _ xdrType = (*ScContractInstance)(nil) @@ -52968,8 +53587,10 @@ func (s ScVal) MarshalBinary() ([]byte, error) { // UnmarshalBinary implements encoding.BinaryUnmarshaler. func (s *ScVal) UnmarshalBinary(inp []byte) error { r := bytes.NewReader(inp) - d := xdr.NewDecoder(r) - _, err := s.DecodeFrom(d, xdr.DecodeDefaultMaxDepth) + o := xdr.DefaultDecodeOptions + o.MaxInputLen = len(inp) + d := xdr.NewDecoderWithOptions(r, o) + _, err := s.DecodeFrom(d, o.MaxDepth) return err } @@ -52978,8 +53599,7 @@ var ( _ encoding.BinaryUnmarshaler = (*ScVal)(nil) ) -// xdrType signals that this type is an type representing -// representing XDR values defined by this package. +// xdrType signals that this type represents XDR values defined by this package. func (s ScVal) xdrType() {} var _ xdrType = (*ScVal)(nil) @@ -53042,8 +53662,10 @@ func (s ScMapEntry) MarshalBinary() ([]byte, error) { // UnmarshalBinary implements encoding.BinaryUnmarshaler. func (s *ScMapEntry) UnmarshalBinary(inp []byte) error { r := bytes.NewReader(inp) - d := xdr.NewDecoder(r) - _, err := s.DecodeFrom(d, xdr.DecodeDefaultMaxDepth) + o := xdr.DefaultDecodeOptions + o.MaxInputLen = len(inp) + d := xdr.NewDecoderWithOptions(r, o) + _, err := s.DecodeFrom(d, o.MaxDepth) return err } @@ -53052,8 +53674,7 @@ var ( _ encoding.BinaryUnmarshaler = (*ScMapEntry)(nil) ) -// xdrType signals that this type is an type representing -// representing XDR values defined by this package. +// xdrType signals that this type represents XDR values defined by this package. func (s ScMapEntry) xdrType() {} var _ xdrType = (*ScMapEntry)(nil) @@ -53231,8 +53852,10 @@ func (s StoredTransactionSet) MarshalBinary() ([]byte, error) { // UnmarshalBinary implements encoding.BinaryUnmarshaler. func (s *StoredTransactionSet) UnmarshalBinary(inp []byte) error { r := bytes.NewReader(inp) - d := xdr.NewDecoder(r) - _, err := s.DecodeFrom(d, xdr.DecodeDefaultMaxDepth) + o := xdr.DefaultDecodeOptions + o.MaxInputLen = len(inp) + d := xdr.NewDecoderWithOptions(r, o) + _, err := s.DecodeFrom(d, o.MaxDepth) return err } @@ -53241,8 +53864,7 @@ var ( _ encoding.BinaryUnmarshaler = (*StoredTransactionSet)(nil) ) -// xdrType signals that this type is an type representing -// representing XDR values defined by this package. +// xdrType signals that this type represents XDR values defined by this package. func (s StoredTransactionSet) xdrType() {} var _ xdrType = (*StoredTransactionSet)(nil) @@ -53315,8 +53937,10 @@ func (s StoredDebugTransactionSet) MarshalBinary() ([]byte, error) { // UnmarshalBinary implements encoding.BinaryUnmarshaler. func (s *StoredDebugTransactionSet) UnmarshalBinary(inp []byte) error { r := bytes.NewReader(inp) - d := xdr.NewDecoder(r) - _, err := s.DecodeFrom(d, xdr.DecodeDefaultMaxDepth) + o := xdr.DefaultDecodeOptions + o.MaxInputLen = len(inp) + d := xdr.NewDecoderWithOptions(r, o) + _, err := s.DecodeFrom(d, o.MaxDepth) return err } @@ -53325,8 +53949,7 @@ var ( _ encoding.BinaryUnmarshaler = (*StoredDebugTransactionSet)(nil) ) -// xdrType signals that this type is an type representing -// representing XDR values defined by this package. +// xdrType signals that this type represents XDR values defined by this package. func (s StoredDebugTransactionSet) xdrType() {} var _ xdrType = (*StoredDebugTransactionSet)(nil) @@ -53393,8 +54016,11 @@ func (s *PersistedScpStateV0) DecodeFrom(d *xdr.Decoder, maxDepth uint) (int, er } s.ScpEnvelopes = nil if l > 0 { + if il, ok := d.InputLen(); ok && uint(il) < uint(l) { + return n, fmt.Errorf("decoding ScpEnvelope: length (%d) exceeds remaining input length (%d)", l, il) + } s.ScpEnvelopes = make([]ScpEnvelope, l) - for i := uint32(0); i < l; i++ { + for i := uint32(0); uint(i) < uint(l); i++ { nTmp, err = s.ScpEnvelopes[i].DecodeFrom(d, maxDepth) n += nTmp if err != nil { @@ -53409,8 +54035,11 @@ func (s *PersistedScpStateV0) DecodeFrom(d *xdr.Decoder, maxDepth uint) (int, er } s.QuorumSets = nil if l > 0 { + if il, ok := d.InputLen(); ok && uint(il) < uint(l) { + return n, fmt.Errorf("decoding ScpQuorumSet: length (%d) exceeds remaining input length (%d)", l, il) + } s.QuorumSets = make([]ScpQuorumSet, l) - for i := uint32(0); i < l; i++ { + for i := uint32(0); uint(i) < uint(l); i++ { nTmp, err = s.QuorumSets[i].DecodeFrom(d, maxDepth) n += nTmp if err != nil { @@ -53425,8 +54054,11 @@ func (s *PersistedScpStateV0) DecodeFrom(d *xdr.Decoder, maxDepth uint) (int, er } s.TxSets = nil if l > 0 { + if il, ok := d.InputLen(); ok && uint(il) < uint(l) { + return n, fmt.Errorf("decoding StoredTransactionSet: length (%d) exceeds remaining input length (%d)", l, il) + } s.TxSets = make([]StoredTransactionSet, l) - for i := uint32(0); i < l; i++ { + for i := uint32(0); uint(i) < uint(l); i++ { nTmp, err = s.TxSets[i].DecodeFrom(d, maxDepth) n += nTmp if err != nil { @@ -53448,8 +54080,10 @@ func (s PersistedScpStateV0) MarshalBinary() ([]byte, error) { // UnmarshalBinary implements encoding.BinaryUnmarshaler. func (s *PersistedScpStateV0) UnmarshalBinary(inp []byte) error { r := bytes.NewReader(inp) - d := xdr.NewDecoder(r) - _, err := s.DecodeFrom(d, xdr.DecodeDefaultMaxDepth) + o := xdr.DefaultDecodeOptions + o.MaxInputLen = len(inp) + d := xdr.NewDecoderWithOptions(r, o) + _, err := s.DecodeFrom(d, o.MaxDepth) return err } @@ -53458,8 +54092,7 @@ var ( _ encoding.BinaryUnmarshaler = (*PersistedScpStateV0)(nil) ) -// xdrType signals that this type is an type representing -// representing XDR values defined by this package. +// xdrType signals that this type represents XDR values defined by this package. func (s PersistedScpStateV0) xdrType() {} var _ xdrType = (*PersistedScpStateV0)(nil) @@ -53517,8 +54150,11 @@ func (s *PersistedScpStateV1) DecodeFrom(d *xdr.Decoder, maxDepth uint) (int, er } s.ScpEnvelopes = nil if l > 0 { + if il, ok := d.InputLen(); ok && uint(il) < uint(l) { + return n, fmt.Errorf("decoding ScpEnvelope: length (%d) exceeds remaining input length (%d)", l, il) + } s.ScpEnvelopes = make([]ScpEnvelope, l) - for i := uint32(0); i < l; i++ { + for i := uint32(0); uint(i) < uint(l); i++ { nTmp, err = s.ScpEnvelopes[i].DecodeFrom(d, maxDepth) n += nTmp if err != nil { @@ -53533,8 +54169,11 @@ func (s *PersistedScpStateV1) DecodeFrom(d *xdr.Decoder, maxDepth uint) (int, er } s.QuorumSets = nil if l > 0 { + if il, ok := d.InputLen(); ok && uint(il) < uint(l) { + return n, fmt.Errorf("decoding ScpQuorumSet: length (%d) exceeds remaining input length (%d)", l, il) + } s.QuorumSets = make([]ScpQuorumSet, l) - for i := uint32(0); i < l; i++ { + for i := uint32(0); uint(i) < uint(l); i++ { nTmp, err = s.QuorumSets[i].DecodeFrom(d, maxDepth) n += nTmp if err != nil { @@ -53556,8 +54195,10 @@ func (s PersistedScpStateV1) MarshalBinary() ([]byte, error) { // UnmarshalBinary implements encoding.BinaryUnmarshaler. func (s *PersistedScpStateV1) UnmarshalBinary(inp []byte) error { r := bytes.NewReader(inp) - d := xdr.NewDecoder(r) - _, err := s.DecodeFrom(d, xdr.DecodeDefaultMaxDepth) + o := xdr.DefaultDecodeOptions + o.MaxInputLen = len(inp) + d := xdr.NewDecoderWithOptions(r, o) + _, err := s.DecodeFrom(d, o.MaxDepth) return err } @@ -53566,8 +54207,7 @@ var ( _ encoding.BinaryUnmarshaler = (*PersistedScpStateV1)(nil) ) -// xdrType signals that this type is an type representing -// representing XDR values defined by this package. +// xdrType signals that this type represents XDR values defined by this package. func (s PersistedScpStateV1) xdrType() {} var _ xdrType = (*PersistedScpStateV1)(nil) @@ -53745,8 +54385,10 @@ func (s PersistedScpState) MarshalBinary() ([]byte, error) { // UnmarshalBinary implements encoding.BinaryUnmarshaler. func (s *PersistedScpState) UnmarshalBinary(inp []byte) error { r := bytes.NewReader(inp) - d := xdr.NewDecoder(r) - _, err := s.DecodeFrom(d, xdr.DecodeDefaultMaxDepth) + o := xdr.DefaultDecodeOptions + o.MaxInputLen = len(inp) + d := xdr.NewDecoderWithOptions(r, o) + _, err := s.DecodeFrom(d, o.MaxDepth) return err } @@ -53755,8 +54397,7 @@ var ( _ encoding.BinaryUnmarshaler = (*PersistedScpState)(nil) ) -// xdrType signals that this type is an type representing -// representing XDR values defined by this package. +// xdrType signals that this type represents XDR values defined by this package. func (s PersistedScpState) xdrType() {} var _ xdrType = (*PersistedScpState)(nil) @@ -53810,8 +54451,10 @@ func (s ConfigSettingContractExecutionLanesV0) MarshalBinary() ([]byte, error) { // UnmarshalBinary implements encoding.BinaryUnmarshaler. func (s *ConfigSettingContractExecutionLanesV0) UnmarshalBinary(inp []byte) error { r := bytes.NewReader(inp) - d := xdr.NewDecoder(r) - _, err := s.DecodeFrom(d, xdr.DecodeDefaultMaxDepth) + o := xdr.DefaultDecodeOptions + o.MaxInputLen = len(inp) + d := xdr.NewDecoderWithOptions(r, o) + _, err := s.DecodeFrom(d, o.MaxDepth) return err } @@ -53820,8 +54463,7 @@ var ( _ encoding.BinaryUnmarshaler = (*ConfigSettingContractExecutionLanesV0)(nil) ) -// xdrType signals that this type is an type representing -// representing XDR values defined by this package. +// xdrType signals that this type represents XDR values defined by this package. func (s ConfigSettingContractExecutionLanesV0) xdrType() {} var _ xdrType = (*ConfigSettingContractExecutionLanesV0)(nil) @@ -53910,8 +54552,10 @@ func (s ConfigSettingContractComputeV0) MarshalBinary() ([]byte, error) { // UnmarshalBinary implements encoding.BinaryUnmarshaler. func (s *ConfigSettingContractComputeV0) UnmarshalBinary(inp []byte) error { r := bytes.NewReader(inp) - d := xdr.NewDecoder(r) - _, err := s.DecodeFrom(d, xdr.DecodeDefaultMaxDepth) + o := xdr.DefaultDecodeOptions + o.MaxInputLen = len(inp) + d := xdr.NewDecoderWithOptions(r, o) + _, err := s.DecodeFrom(d, o.MaxDepth) return err } @@ -53920,8 +54564,7 @@ var ( _ encoding.BinaryUnmarshaler = (*ConfigSettingContractComputeV0)(nil) ) -// xdrType signals that this type is an type representing -// representing XDR values defined by this package. +// xdrType signals that this type represents XDR values defined by this package. func (s ConfigSettingContractComputeV0) xdrType() {} var _ xdrType = (*ConfigSettingContractComputeV0)(nil) @@ -54131,8 +54774,10 @@ func (s ConfigSettingContractLedgerCostV0) MarshalBinary() ([]byte, error) { // UnmarshalBinary implements encoding.BinaryUnmarshaler. func (s *ConfigSettingContractLedgerCostV0) UnmarshalBinary(inp []byte) error { r := bytes.NewReader(inp) - d := xdr.NewDecoder(r) - _, err := s.DecodeFrom(d, xdr.DecodeDefaultMaxDepth) + o := xdr.DefaultDecodeOptions + o.MaxInputLen = len(inp) + d := xdr.NewDecoderWithOptions(r, o) + _, err := s.DecodeFrom(d, o.MaxDepth) return err } @@ -54141,8 +54786,7 @@ var ( _ encoding.BinaryUnmarshaler = (*ConfigSettingContractLedgerCostV0)(nil) ) -// xdrType signals that this type is an type representing -// representing XDR values defined by this package. +// xdrType signals that this type represents XDR values defined by this package. func (s ConfigSettingContractLedgerCostV0) xdrType() {} var _ xdrType = (*ConfigSettingContractLedgerCostV0)(nil) @@ -54195,8 +54839,10 @@ func (s ConfigSettingContractHistoricalDataV0) MarshalBinary() ([]byte, error) { // UnmarshalBinary implements encoding.BinaryUnmarshaler. func (s *ConfigSettingContractHistoricalDataV0) UnmarshalBinary(inp []byte) error { r := bytes.NewReader(inp) - d := xdr.NewDecoder(r) - _, err := s.DecodeFrom(d, xdr.DecodeDefaultMaxDepth) + o := xdr.DefaultDecodeOptions + o.MaxInputLen = len(inp) + d := xdr.NewDecoderWithOptions(r, o) + _, err := s.DecodeFrom(d, o.MaxDepth) return err } @@ -54205,8 +54851,7 @@ var ( _ encoding.BinaryUnmarshaler = (*ConfigSettingContractHistoricalDataV0)(nil) ) -// xdrType signals that this type is an type representing -// representing XDR values defined by this package. +// xdrType signals that this type represents XDR values defined by this package. func (s ConfigSettingContractHistoricalDataV0) xdrType() {} var _ xdrType = (*ConfigSettingContractHistoricalDataV0)(nil) @@ -54271,8 +54916,10 @@ func (s ConfigSettingContractEventsV0) MarshalBinary() ([]byte, error) { // UnmarshalBinary implements encoding.BinaryUnmarshaler. func (s *ConfigSettingContractEventsV0) UnmarshalBinary(inp []byte) error { r := bytes.NewReader(inp) - d := xdr.NewDecoder(r) - _, err := s.DecodeFrom(d, xdr.DecodeDefaultMaxDepth) + o := xdr.DefaultDecodeOptions + o.MaxInputLen = len(inp) + d := xdr.NewDecoderWithOptions(r, o) + _, err := s.DecodeFrom(d, o.MaxDepth) return err } @@ -54281,8 +54928,7 @@ var ( _ encoding.BinaryUnmarshaler = (*ConfigSettingContractEventsV0)(nil) ) -// xdrType signals that this type is an type representing -// representing XDR values defined by this package. +// xdrType signals that this type represents XDR values defined by this package. func (s ConfigSettingContractEventsV0) xdrType() {} var _ xdrType = (*ConfigSettingContractEventsV0)(nil) @@ -54359,8 +55005,10 @@ func (s ConfigSettingContractBandwidthV0) MarshalBinary() ([]byte, error) { // UnmarshalBinary implements encoding.BinaryUnmarshaler. func (s *ConfigSettingContractBandwidthV0) UnmarshalBinary(inp []byte) error { r := bytes.NewReader(inp) - d := xdr.NewDecoder(r) - _, err := s.DecodeFrom(d, xdr.DecodeDefaultMaxDepth) + o := xdr.DefaultDecodeOptions + o.MaxInputLen = len(inp) + d := xdr.NewDecoderWithOptions(r, o) + _, err := s.DecodeFrom(d, o.MaxDepth) return err } @@ -54369,8 +55017,7 @@ var ( _ encoding.BinaryUnmarshaler = (*ConfigSettingContractBandwidthV0)(nil) ) -// xdrType signals that this type is an type representing -// representing XDR values defined by this package. +// xdrType signals that this type represents XDR values defined by this package. func (s ConfigSettingContractBandwidthV0) xdrType() {} var _ xdrType = (*ConfigSettingContractBandwidthV0)(nil) @@ -54535,8 +55182,10 @@ func (s ContractCostType) MarshalBinary() ([]byte, error) { // UnmarshalBinary implements encoding.BinaryUnmarshaler. func (s *ContractCostType) UnmarshalBinary(inp []byte) error { r := bytes.NewReader(inp) - d := xdr.NewDecoder(r) - _, err := s.DecodeFrom(d, xdr.DecodeDefaultMaxDepth) + o := xdr.DefaultDecodeOptions + o.MaxInputLen = len(inp) + d := xdr.NewDecoderWithOptions(r, o) + _, err := s.DecodeFrom(d, o.MaxDepth) return err } @@ -54545,8 +55194,7 @@ var ( _ encoding.BinaryUnmarshaler = (*ContractCostType)(nil) ) -// xdrType signals that this type is an type representing -// representing XDR values defined by this package. +// xdrType signals that this type represents XDR values defined by this package. func (s ContractCostType) xdrType() {} var _ xdrType = (*ContractCostType)(nil) @@ -54620,8 +55268,10 @@ func (s ContractCostParamEntry) MarshalBinary() ([]byte, error) { // UnmarshalBinary implements encoding.BinaryUnmarshaler. func (s *ContractCostParamEntry) UnmarshalBinary(inp []byte) error { r := bytes.NewReader(inp) - d := xdr.NewDecoder(r) - _, err := s.DecodeFrom(d, xdr.DecodeDefaultMaxDepth) + o := xdr.DefaultDecodeOptions + o.MaxInputLen = len(inp) + d := xdr.NewDecoderWithOptions(r, o) + _, err := s.DecodeFrom(d, o.MaxDepth) return err } @@ -54630,8 +55280,7 @@ var ( _ encoding.BinaryUnmarshaler = (*ContractCostParamEntry)(nil) ) -// xdrType signals that this type is an type representing -// representing XDR values defined by this package. +// xdrType signals that this type represents XDR values defined by this package. func (s ContractCostParamEntry) xdrType() {} var _ xdrType = (*ContractCostParamEntry)(nil) @@ -54773,8 +55422,10 @@ func (s StateArchivalSettings) MarshalBinary() ([]byte, error) { // UnmarshalBinary implements encoding.BinaryUnmarshaler. func (s *StateArchivalSettings) UnmarshalBinary(inp []byte) error { r := bytes.NewReader(inp) - d := xdr.NewDecoder(r) - _, err := s.DecodeFrom(d, xdr.DecodeDefaultMaxDepth) + o := xdr.DefaultDecodeOptions + o.MaxInputLen = len(inp) + d := xdr.NewDecoderWithOptions(r, o) + _, err := s.DecodeFrom(d, o.MaxDepth) return err } @@ -54783,8 +55434,7 @@ var ( _ encoding.BinaryUnmarshaler = (*StateArchivalSettings)(nil) ) -// xdrType signals that this type is an type representing -// representing XDR values defined by this package. +// xdrType signals that this type represents XDR values defined by this package. func (s StateArchivalSettings) xdrType() {} var _ xdrType = (*StateArchivalSettings)(nil) @@ -54856,8 +55506,10 @@ func (s EvictionIterator) MarshalBinary() ([]byte, error) { // UnmarshalBinary implements encoding.BinaryUnmarshaler. func (s *EvictionIterator) UnmarshalBinary(inp []byte) error { r := bytes.NewReader(inp) - d := xdr.NewDecoder(r) - _, err := s.DecodeFrom(d, xdr.DecodeDefaultMaxDepth) + o := xdr.DefaultDecodeOptions + o.MaxInputLen = len(inp) + d := xdr.NewDecoderWithOptions(r, o) + _, err := s.DecodeFrom(d, o.MaxDepth) return err } @@ -54866,8 +55518,7 @@ var ( _ encoding.BinaryUnmarshaler = (*EvictionIterator)(nil) ) -// xdrType signals that this type is an type representing -// representing XDR values defined by this package. +// xdrType signals that this type represents XDR values defined by this package. func (s EvictionIterator) xdrType() {} var _ xdrType = (*EvictionIterator)(nil) @@ -54922,8 +55573,11 @@ func (s *ContractCostParams) DecodeFrom(d *xdr.Decoder, maxDepth uint) (int, err } (*s) = nil if l > 0 { + if il, ok := d.InputLen(); ok && uint(il) < uint(l) { + return n, fmt.Errorf("decoding ContractCostParamEntry: length (%d) exceeds remaining input length (%d)", l, il) + } (*s) = make([]ContractCostParamEntry, l) - for i := uint32(0); i < l; i++ { + for i := uint32(0); uint(i) < uint(l); i++ { nTmp, err = (*s)[i].DecodeFrom(d, maxDepth) n += nTmp if err != nil { @@ -54945,8 +55599,10 @@ func (s ContractCostParams) MarshalBinary() ([]byte, error) { // UnmarshalBinary implements encoding.BinaryUnmarshaler. func (s *ContractCostParams) UnmarshalBinary(inp []byte) error { r := bytes.NewReader(inp) - d := xdr.NewDecoder(r) - _, err := s.DecodeFrom(d, xdr.DecodeDefaultMaxDepth) + o := xdr.DefaultDecodeOptions + o.MaxInputLen = len(inp) + d := xdr.NewDecoderWithOptions(r, o) + _, err := s.DecodeFrom(d, o.MaxDepth) return err } @@ -54955,8 +55611,7 @@ var ( _ encoding.BinaryUnmarshaler = (*ContractCostParams)(nil) ) -// xdrType signals that this type is an type representing -// representing XDR values defined by this package. +// xdrType signals that this type represents XDR values defined by this package. func (s ContractCostParams) xdrType() {} var _ xdrType = (*ContractCostParams)(nil) @@ -55068,8 +55723,10 @@ func (s ConfigSettingId) MarshalBinary() ([]byte, error) { // UnmarshalBinary implements encoding.BinaryUnmarshaler. func (s *ConfigSettingId) UnmarshalBinary(inp []byte) error { r := bytes.NewReader(inp) - d := xdr.NewDecoder(r) - _, err := s.DecodeFrom(d, xdr.DecodeDefaultMaxDepth) + o := xdr.DefaultDecodeOptions + o.MaxInputLen = len(inp) + d := xdr.NewDecoderWithOptions(r, o) + _, err := s.DecodeFrom(d, o.MaxDepth) return err } @@ -55078,8 +55735,7 @@ var ( _ encoding.BinaryUnmarshaler = (*ConfigSettingId)(nil) ) -// xdrType signals that this type is an type representing -// representing XDR values defined by this package. +// xdrType signals that this type represents XDR values defined by this package. func (s ConfigSettingId) xdrType() {} var _ xdrType = (*ConfigSettingId)(nil) @@ -55841,8 +56497,11 @@ func (u *ConfigSettingEntry) DecodeFrom(d *xdr.Decoder, maxDepth uint) (int, err } (*u.BucketListSizeWindow) = nil if l > 0 { + if il, ok := d.InputLen(); ok && uint(il) < uint(l) { + return n, fmt.Errorf("decoding Uint64: length (%d) exceeds remaining input length (%d)", l, il) + } (*u.BucketListSizeWindow) = make([]Uint64, l) - for i := uint32(0); i < l; i++ { + for i := uint32(0); uint(i) < uint(l); i++ { nTmp, err = (*u.BucketListSizeWindow)[i].DecodeFrom(d, maxDepth) n += nTmp if err != nil { @@ -55874,8 +56533,10 @@ func (s ConfigSettingEntry) MarshalBinary() ([]byte, error) { // UnmarshalBinary implements encoding.BinaryUnmarshaler. func (s *ConfigSettingEntry) UnmarshalBinary(inp []byte) error { r := bytes.NewReader(inp) - d := xdr.NewDecoder(r) - _, err := s.DecodeFrom(d, xdr.DecodeDefaultMaxDepth) + o := xdr.DefaultDecodeOptions + o.MaxInputLen = len(inp) + d := xdr.NewDecoderWithOptions(r, o) + _, err := s.DecodeFrom(d, o.MaxDepth) return err } @@ -55884,8 +56545,7 @@ var ( _ encoding.BinaryUnmarshaler = (*ConfigSettingEntry)(nil) ) -// xdrType signals that this type is an type representing -// representing XDR values defined by this package. +// xdrType signals that this type represents XDR values defined by this package. func (s ConfigSettingEntry) xdrType() {} var _ xdrType = (*ConfigSettingEntry)(nil) From abc49f512ef5b4f8f9504aa470862157f5e53903 Mon Sep 17 00:00:00 2001 From: tamirms Date: Mon, 27 Nov 2023 10:32:23 +0000 Subject: [PATCH 12/16] services/horizon: Add integration tests for asset balance expiration / restoration (#5120) --- .../docker/captive-core-integration-tests.cfg | 3 + ...-core-reingest-range-integration-tests.cfg | 2 + .../docker/stellar-core-integration-tests.cfg | 3 + services/horizon/internal/flags.go | 2 +- .../internal/integration/contracts/Cargo.lock | 162 +++---- .../internal/integration/contracts/Cargo.toml | 1 + .../integration/contracts/store/Cargo.toml | 17 + .../integration/contracts/store/src/lib.rs | 16 + .../integration/extend_footprint_ttl_test.go | 29 +- .../horizon/internal/integration/sac_test.go | 406 ++++++++++++++++-- .../integration/testdata/soroban_add_u64.wasm | Bin 631 -> 631 bytes .../testdata/soroban_increment_contract.wasm | Bin 701 -> 701 bytes .../testdata/soroban_sac_test.wasm | Bin 1924 -> 1924 bytes .../integration/testdata/soroban_store.wasm | Bin 0 -> 449 bytes .../internal/test/integration/integration.go | 110 ++++- 15 files changed, 597 insertions(+), 154 deletions(-) create mode 100644 services/horizon/internal/integration/contracts/store/Cargo.toml create mode 100644 services/horizon/internal/integration/contracts/store/src/lib.rs create mode 100755 services/horizon/internal/integration/testdata/soroban_store.wasm diff --git a/services/horizon/docker/captive-core-integration-tests.cfg b/services/horizon/docker/captive-core-integration-tests.cfg index abea8c8ede..275599bacd 100644 --- a/services/horizon/docker/captive-core-integration-tests.cfg +++ b/services/horizon/docker/captive-core-integration-tests.cfg @@ -5,6 +5,9 @@ UNSAFE_QUORUM=true FAILURE_SAFETY=0 ENABLE_SOROBAN_DIAGNOSTIC_EVENTS=true +# 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 [[VALIDATORS]] diff --git a/services/horizon/docker/captive-core-reingest-range-integration-tests.cfg b/services/horizon/docker/captive-core-reingest-range-integration-tests.cfg index 26a4cd6fd2..44820f5933 100644 --- a/services/horizon/docker/captive-core-reingest-range-integration-tests.cfg +++ b/services/horizon/docker/captive-core-reingest-range-integration-tests.cfg @@ -1,5 +1,7 @@ ARTIFICIALLY_ACCELERATE_TIME_FOR_TESTING=true TESTING_SOROBAN_HIGH_LIMIT_OVERRIDE=true +TESTING_MINIMUM_PERSISTENT_ENTRY_LIFETIME=10 +ENABLE_SOROBAN_DIAGNOSTIC_EVENTS=true [[VALIDATORS]] NAME="local_core" diff --git a/services/horizon/docker/stellar-core-integration-tests.cfg b/services/horizon/docker/stellar-core-integration-tests.cfg index 27adf63f4b..594a35b244 100644 --- a/services/horizon/docker/stellar-core-integration-tests.cfg +++ b/services/horizon/docker/stellar-core-integration-tests.cfg @@ -14,6 +14,9 @@ FAILURE_SAFETY=0 DATABASE="postgresql://user=postgres password=mysecretpassword host=core-postgres port=5641 dbname=stellar" +# 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 [QUORUM_SET] diff --git a/services/horizon/internal/flags.go b/services/horizon/internal/flags.go index d2cc055ef8..11c154fb8a 100644 --- a/services/horizon/internal/flags.go +++ b/services/horizon/internal/flags.go @@ -549,7 +549,7 @@ func Flags() (*Config, support.ConfigOptions) { ConfigKey: &config.IngestDisableStateVerification, OptType: types.Bool, FlagDefault: false, - Usage: "ingestion system runs a verification routing to compare state in local database with history buckets, this can be disabled however it's not recommended", + Usage: "disable periodic verification of ledger state in horizon db (not recommended)", }, &support.ConfigOption{ Name: "ingest-state-verification-checkpoint-frequency", diff --git a/services/horizon/internal/integration/contracts/Cargo.lock b/services/horizon/internal/integration/contracts/Cargo.lock index 417d3ff74f..006b35e8e2 100644 --- a/services/horizon/internal/integration/contracts/Cargo.lock +++ b/services/horizon/internal/integration/contracts/Cargo.lock @@ -34,9 +34,9 @@ dependencies = [ [[package]] name = "arbitrary" -version = "1.3.1" +version = "1.3.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a2e1373abdaa212b704512ec2bd8b26bd0b7d5c3f70117411a5d9a451383c859" +checksum = "7d5a26814d8dcb93b0e5a0ff3c6d80a8843bafb21b39e8e18a6f05471870e110" dependencies = [ "derive_arbitrary", ] @@ -82,9 +82,9 @@ checksum = "9e1b586273c5702936fe7b7d6896644d8be71e6314cfe09d3167c95f712589e8" [[package]] name = "base64" -version = "0.21.4" +version = "0.21.5" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9ba43ea6f343b788c8764558649e08df62f86c6ef251fdaeb1ffd010a9ae50a2" +checksum = "35636a1494ede3b646cc98f74f8e62c773a38a659ebc777a2cf26b9b74171df9" [[package]] name = "base64ct" @@ -161,9 +161,9 @@ checksum = "e496a50fda8aacccc86d7529e2c1e0892dbd0f898a6b5645b5561b89c3210efa" [[package]] name = "cpufeatures" -version = "0.2.9" +version = "0.2.11" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a17b76ff3a4162b0b27f354a0c87015ddad39d35f9c0c36607a3bdd175dde1f1" +checksum = "ce420fe07aecd3e67c5f910618fe65e94158f6dcc0adf44e00d69ce2bdfe0fd0" dependencies = [ "libc", ] @@ -181,9 +181,9 @@ dependencies = [ [[package]] name = "crypto-bigint" -version = "0.5.3" +version = "0.5.5" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "740fe28e594155f10cfc383984cbefd529d7396050557148f79cb0f621204124" +checksum = "0dc92fb57ca44df6db8059111ab3af99a63d5d0f8375d9972e319a379c6bab76" dependencies = [ "generic-array", "rand_core", @@ -230,9 +230,9 @@ dependencies = [ [[package]] name = "curve25519-dalek-derive" -version = "0.1.0" +version = "0.1.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "83fdaf97f4804dcebfa5862639bc9ce4121e82140bec2a987ac5140294865b5b" +checksum = "f46882e17999c6cc590af592290432be3bce0428cb0d5f8b6715e4dc7b383eb3" dependencies = [ "proc-macro2", "quote", @@ -296,9 +296,9 @@ dependencies = [ [[package]] name = "derive_arbitrary" -version = "1.3.1" +version = "1.3.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "53e0efad4403bfc52dc201159c4b842a246a14b98c64b55dfd0f2d89729dfeb8" +checksum = "67e77553c4162a157adbf834ebae5b415acbecbeafc7a74b0e886657506a7611" dependencies = [ "proc-macro2", "quote", @@ -325,9 +325,9 @@ checksum = "9ea835d29036a4087793836fa931b08837ad5e957da9e23886b29586fb9b6650" [[package]] name = "ecdsa" -version = "0.16.8" +version = "0.16.9" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a4b1e0c257a9e9f25f90ff76d7a68360ed497ee519c8e428d1825ef0000799d4" +checksum = "ee27f32b5c5292967d2d4a9d7f1e0b0aed2c15daded5a60300e4abb9d8020bca" dependencies = [ "der", "digest", @@ -349,15 +349,16 @@ dependencies = [ [[package]] name = "ed25519-dalek" -version = "2.0.0" +version = "2.1.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7277392b266383ef8396db7fdeb1e77b6c52fed775f5df15bb24f35b72156980" +checksum = "1f628eaec48bfd21b865dc2950cfa014450c01d2fa2b69a86c2fd5844ec523c0" dependencies = [ "curve25519-dalek", "ed25519", "rand_core", "serde", "sha2", + "subtle", "zeroize", ] @@ -369,9 +370,9 @@ checksum = "a26ae43d7bcc3b814de94796a5e736d4029efb0ee900c12e2d54c993ad1a1e07" [[package]] name = "elliptic-curve" -version = "0.13.6" +version = "0.13.8" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d97ca172ae9dc9f9b779a6e3a65d308f2af74e5b8c921299075bdb4a0370e914" +checksum = "b5e6043086bf7973472e0c7dff2142ea0b680d30e18d9cc40f267efbf222bd47" dependencies = [ "base16ct", "crypto-bigint", @@ -394,9 +395,9 @@ checksum = "5443807d6dff69373d433ab9ef5378ad8df50ca6298caf15de6e52e24aaf54d5" [[package]] name = "ethnum" -version = "1.4.0" +version = "1.5.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "6c8ff382b2fa527fb7fb06eeebfc5bbb3f17e3cc6b9d70b006c41daa8824adac" +checksum = "b90ca2580b73ab6a1f724b76ca11ab632df820fd6040c336200d2c1df7b3c82c" [[package]] name = "ff" @@ -410,9 +411,9 @@ dependencies = [ [[package]] name = "fiat-crypto" -version = "0.2.1" +version = "0.2.5" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d0870c84016d4b481be5c9f323c24f65e31e901ae618f0e80f4308fb00de1d2d" +checksum = "27573eac26f4dd11e2b1916c3fe1baa56407c83c71a773a8ba17ec0bca03b6b7" [[package]] name = "fnv" @@ -433,9 +434,9 @@ dependencies = [ [[package]] name = "getrandom" -version = "0.2.10" +version = "0.2.11" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "be4136b2a15dd319360be1c07d9933517ccf0be8f16bf62a3bee4f0d618df427" +checksum = "fe9006bed769170c11f845cf00c7c1e9092aeb3f268e007c3e760ac68008070f" dependencies = [ "cfg-if", "js-sys", @@ -469,9 +470,9 @@ checksum = "8a9ee70c43aaf417c914396645a0fa852624801b24ebb7ae78fe8272889ac888" [[package]] name = "hashbrown" -version = "0.14.1" +version = "0.14.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7dfda62a12f55daeae5015f81b0baea145391cb4520f86c248fc615d72640d12" +checksum = "f93e7192158dbcda357bdec5fb5788eebf8bbac027f3f33e719d29135ae84156" [[package]] name = "hex" @@ -493,16 +494,16 @@ dependencies = [ [[package]] name = "iana-time-zone" -version = "0.1.57" +version = "0.1.58" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "2fad5b825842d2b38bd206f3e81d6957625fd7f0a361e345c30e01a0ae2dd613" +checksum = "8326b86b6cff230b97d0d312a6c40a60726df3332e721f72a1b035f451663b20" dependencies = [ "android_system_properties", "core-foundation-sys", "iana-time-zone-haiku", "js-sys", "wasm-bindgen", - "windows", + "windows-core", ] [[package]] @@ -533,12 +534,12 @@ dependencies = [ [[package]] name = "indexmap" -version = "2.0.2" +version = "2.1.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8adf3ddd720272c6ea8bf59463c04e0f93d0bbf7c5439b691bca2987e0270897" +checksum = "d530e1a18b1cb4c484e6e34556a0d948706958449fca0cab753d649f2bce3d1f" dependencies = [ "equivalent", - "hashbrown 0.14.1", + "hashbrown 0.14.2", "serde", ] @@ -565,18 +566,18 @@ checksum = "af150ab688ff2122fcef229be89cb50dd66af9e01a4ff320cc137eecc9bacc38" [[package]] name = "js-sys" -version = "0.3.64" +version = "0.3.65" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c5f195fe497f702db0f318b07fdd68edb16955aed830df8363d837542f8f935a" +checksum = "54c0c35952f67de54bb584e9fd912b3023117cbafc0a77d8f3dee1fb5f572fe8" dependencies = [ "wasm-bindgen", ] [[package]] name = "k256" -version = "0.13.1" +version = "0.13.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "cadb76004ed8e97623117f3df85b17aaa6626ab0b0831e6573f104df16cd1bcc" +checksum = "3f01b677d82ef7a676aa37e099defd83a28e15687112cafdd112d60236b6115b" dependencies = [ "cfg-if", "ecdsa", @@ -597,9 +598,9 @@ dependencies = [ [[package]] name = "libc" -version = "0.2.149" +version = "0.2.150" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a08173bc88b7955d1b3145aa561539096c421ac8debde8cbc3612ec635fee29b" +checksum = "89d92a4743f9a61002fae18374ed11e7973f530cb3a3255fb354818118b2203c" [[package]] name = "libm" @@ -702,9 +703,9 @@ dependencies = [ [[package]] name = "platforms" -version = "3.1.2" +version = "3.2.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4503fa043bf02cee09a9582e9554b4c6403b2ef55e4612e96561d294419429f8" +checksum = "14e6ab3f592e6fb464fc9712d8d6e6912de6473954635fd76a589d832cffcbb0" [[package]] name = "powerfmt" @@ -829,18 +830,18 @@ checksum = "836fa6a3e1e547f9a2c4040802ec865b5d85f4014efe00555d7090a3dcaa1090" [[package]] name = "serde" -version = "1.0.189" +version = "1.0.192" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8e422a44e74ad4001bdc8eede9a4570ab52f71190e9c076d14369f38b9200537" +checksum = "bca2a08484b285dcb282d0f67b26cadc0df8b19f8c12502c13d966bf9482f001" dependencies = [ "serde_derive", ] [[package]] name = "serde_derive" -version = "1.0.189" +version = "1.0.192" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1e48d1f918009ce3145511378cf68d613e3b3d9137d67272562080d68a2b32d5" +checksum = "d6c7207fbec9faa48073f3e3074cbe553af6ea512d7c21ba46e434e70ea9fbc1" dependencies = [ "proc-macro2", "quote", @@ -849,9 +850,9 @@ dependencies = [ [[package]] name = "serde_json" -version = "1.0.107" +version = "1.0.108" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "6b420ce6e3d8bd882e9b243c6eed35dbc9a6110c9769e74b584e0d68d1f20c65" +checksum = "3d1c7e3eac408d115102c4c24ad393e0821bb3a5df4d506a80f85f7a742a526b" dependencies = [ "itoa", "ryu", @@ -860,15 +861,15 @@ dependencies = [ [[package]] name = "serde_with" -version = "3.3.0" +version = "3.4.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1ca3b16a3d82c4088f343b7480a93550b3eabe1a358569c2dfe38bbcead07237" +checksum = "64cd236ccc1b7a29e7e2739f27c0b2dd199804abc4290e32f59f3b68d6405c23" dependencies = [ - "base64 0.21.4", + "base64 0.21.5", "chrono", "hex", "indexmap 1.9.3", - "indexmap 2.0.2", + "indexmap 2.1.0", "serde", "serde_json", "serde_with_macros", @@ -877,9 +878,9 @@ dependencies = [ [[package]] name = "serde_with_macros" -version = "3.3.0" +version = "3.4.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "2e6be15c453eb305019bfa438b1593c731f36a289a7853f7707ee29e870b3b3c" +checksum = "93634eb5f75a2323b16de4748022ac4297f9e76b6dced2be287a099f41b5e788" dependencies = [ "darling", "proc-macro2", @@ -910,9 +911,9 @@ dependencies = [ [[package]] name = "signature" -version = "2.1.0" +version = "2.2.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5e1788eed21689f9cf370582dfc467ef36ed9c707f073528ddafa8d83e3b8500" +checksum = "77549399552de45a898a580c1b41d445bf730df867cc44e6c0233bbc4b8329de" dependencies = [ "digest", "rand_core", @@ -920,9 +921,9 @@ dependencies = [ [[package]] name = "smallvec" -version = "1.11.1" +version = "1.11.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "942b4a808e05215192e39f4ab80813e599068285906cc91aa64f923db842bd5a" +checksum = "4dccd0940a2dcdf68d092b8cbab7dc0ad8fa938bf95787e1b916b0e3d0e8e970" [[package]] name = "soroban-env-common" @@ -1086,6 +1087,13 @@ dependencies = [ "thiserror", ] +[[package]] +name = "soroban-store" +version = "0.0.0" +dependencies = [ + "soroban-sdk", +] + [[package]] name = "soroban-wasmi" version = "0.31.0-soroban1" @@ -1163,9 +1171,9 @@ checksum = "81cdd64d312baedb58e21336b31bc043b77e01cc99033ce76ef539f78e965ebc" [[package]] name = "syn" -version = "2.0.38" +version = "2.0.39" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e96b79aaa137db8f61e26363a0c9b47d8b4ec75da28b7d1d614c2303e232408b" +checksum = "23e78b90f2fcf45d3e842032ce32e3f2d1545ba6636271dcbf24fa306d87be7a" dependencies = [ "proc-macro2", "quote", @@ -1174,18 +1182,18 @@ dependencies = [ [[package]] name = "thiserror" -version = "1.0.49" +version = "1.0.50" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1177e8c6d7ede7afde3585fd2513e611227efd6481bd78d2e82ba1ce16557ed4" +checksum = "f9a7210f5c9a7156bb50aa36aed4c95afb51df0df00713949448cf9e97d382d2" dependencies = [ "thiserror-impl", ] [[package]] name = "thiserror-impl" -version = "1.0.49" +version = "1.0.50" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "10712f02019e9288794769fba95cd6847df9874d49d871d062172f9dd41bc4cc" +checksum = "266b2e40bc00e5a6c09c3584011e08b06f123c00362c92b975ba9843aaaa14b8" dependencies = [ "proc-macro2", "quote", @@ -1247,9 +1255,9 @@ checksum = "9c8d87e72b64a3b4db28d11ce29237c246188f4f51057d65a7eab63b7987e423" [[package]] name = "wasm-bindgen" -version = "0.2.87" +version = "0.2.88" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7706a72ab36d8cb1f80ffbf0e071533974a60d0a308d01a5d0375bf60499a342" +checksum = "7daec296f25a1bae309c0cd5c29c4b260e510e6d813c286b19eaadf409d40fce" dependencies = [ "cfg-if", "wasm-bindgen-macro", @@ -1257,9 +1265,9 @@ dependencies = [ [[package]] name = "wasm-bindgen-backend" -version = "0.2.87" +version = "0.2.88" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5ef2b6d3c510e9625e5fe6f509ab07d66a760f0885d858736483c32ed7809abd" +checksum = "e397f4664c0e4e428e8313a469aaa58310d302159845980fd23b0f22a847f217" dependencies = [ "bumpalo", "log", @@ -1272,9 +1280,9 @@ dependencies = [ [[package]] name = "wasm-bindgen-macro" -version = "0.2.87" +version = "0.2.88" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "dee495e55982a3bd48105a7b947fd2a9b4a8ae3010041b9e0faab3f9cd028f1d" +checksum = "5961017b3b08ad5f3fe39f1e79877f8ee7c23c5e5fd5eb80de95abc41f1f16b2" dependencies = [ "quote", "wasm-bindgen-macro-support", @@ -1282,9 +1290,9 @@ dependencies = [ [[package]] name = "wasm-bindgen-macro-support" -version = "0.2.87" +version = "0.2.88" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "54681b18a46765f095758388f2d0cf16eb8d4169b639ab575a8f5693af210c7b" +checksum = "c5353b8dab669f5e10f5bd76df26a9360c748f054f862ff5f3f8aae0c7fb3907" dependencies = [ "proc-macro2", "quote", @@ -1295,9 +1303,9 @@ dependencies = [ [[package]] name = "wasm-bindgen-shared" -version = "0.2.87" +version = "0.2.88" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ca6ad05a4870b2bf5fe995117d3728437bd27d7cd5f06f13c17443ef369775a1" +checksum = "0d046c5d029ba91a1ed14da14dca44b68bf2f124cfbaf741c54151fdb3e0750b" [[package]] name = "wasmi_arena" @@ -1334,10 +1342,10 @@ dependencies = [ ] [[package]] -name = "windows" -version = "0.48.0" +name = "windows-core" +version = "0.51.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e686886bc078bc1b0b600cac0147aadb815089b6e4da64016cbd754b6342700f" +checksum = "f1f8cf84f35d2db49a46868f947758c7a1138116f7fac3bc844f43ade1292e64" dependencies = [ "windows-targets", ] @@ -1401,6 +1409,6 @@ checksum = "ed94fce61571a4006852b7389a063ab983c02eb1bb37b47f8272ce92d06d9538" [[package]] name = "zeroize" -version = "1.6.0" +version = "1.7.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "2a0956f1ba7c7909bfb66c2e9e4124ab6f6482560f6628b5aaeba39207c9aad9" +checksum = "525b4ec142c6b68a2d10f01f7bbf6755599ca3f81ea53b8431b7dd348f5fdb2d" diff --git a/services/horizon/internal/integration/contracts/Cargo.toml b/services/horizon/internal/integration/contracts/Cargo.toml index f7e3b81aed..d27b45dd4f 100644 --- a/services/horizon/internal/integration/contracts/Cargo.toml +++ b/services/horizon/internal/integration/contracts/Cargo.toml @@ -5,6 +5,7 @@ members = [ "sac_test", "increment", "add_u64", + "store", ] [profile.release-with-logs] diff --git a/services/horizon/internal/integration/contracts/store/Cargo.toml b/services/horizon/internal/integration/contracts/store/Cargo.toml new file mode 100644 index 0000000000..080ae44abd --- /dev/null +++ b/services/horizon/internal/integration/contracts/store/Cargo.toml @@ -0,0 +1,17 @@ +[package] +version = "0.0.0" +name = "soroban-store" +authors = ["Stellar Development Foundation "] +license = "Apache-2.0" +edition = "2021" +publish = false + +[lib] +crate-type = ["cdylib"] +doctest = false + +[dependencies] +soroban-sdk = { workspace = true } + +[dev_dependencies] +soroban-sdk = { workspace = true, features = ["testutils"] } \ No newline at end of file diff --git a/services/horizon/internal/integration/contracts/store/src/lib.rs b/services/horizon/internal/integration/contracts/store/src/lib.rs new file mode 100644 index 0000000000..3a80d77ed7 --- /dev/null +++ b/services/horizon/internal/integration/contracts/store/src/lib.rs @@ -0,0 +1,16 @@ +#![no_std] +use soroban_sdk::{contract, contractimpl, Env, Val}; + +#[contract] +pub struct Contract; + +#[contractimpl] +impl Contract { + pub fn set(e: Env, key: Val, val: Val) { + e.storage().persistent().set(&key, &val) + } + + pub fn remove(e: Env, key: Val) { + e.storage().persistent().remove(&key) + } +} \ No newline at end of file diff --git a/services/horizon/internal/integration/extend_footprint_ttl_test.go b/services/horizon/internal/integration/extend_footprint_ttl_test.go index b0c9258827..e280184b65 100644 --- a/services/horizon/internal/integration/extend_footprint_ttl_test.go +++ b/services/horizon/internal/integration/extend_footprint_ttl_test.go @@ -9,7 +9,6 @@ import ( "github.com/stellar/go/protocols/horizon/operations" "github.com/stellar/go/services/horizon/internal/test/integration" "github.com/stellar/go/txnbuild" - "github.com/stellar/go/xdr" ) func TestExtendFootprintTtl(t *testing.T) { @@ -35,29 +34,11 @@ func TestExtendFootprintTtl(t *testing.T) { _, err = itest.Client().TransactionDetail(tx.Hash) require.NoError(t, err) - sourceAccount, err = itest.Client().AccountDetail(horizonclient.AccountRequest{ - AccountID: itest.Master().Address(), - }) - require.NoError(t, err) - - bumpFootPrint := txnbuild.ExtendFootprintTtl{ - ExtendTo: 10000, - SourceAccount: "", - Ext: xdr.TransactionExt{ - V: 1, - SorobanData: &xdr.SorobanTransactionData{ - Ext: xdr.ExtensionPoint{}, - Resources: xdr.SorobanResources{ - Footprint: xdr.LedgerFootprint{ - ReadOnly: preFlightOp.Ext.SorobanData.Resources.Footprint.ReadWrite, - ReadWrite: nil, - }, - }, - ResourceFee: 0, - }, - }, - } - bumpFootPrint, minFee = itest.PreflightBumpFootprintExpiration(&sourceAccount, bumpFootPrint) + sourceAccount, bumpFootPrint, minFee := itest.PreflightExtendExpiration( + itest.Master().Address(), + preFlightOp.Ext.SorobanData.Resources.Footprint.ReadWrite, + 10000, + ) tx = itest.MustSubmitOperationsWithFee(&sourceAccount, itest.Master(), minFee+txnbuild.MinBaseFee, &bumpFootPrint) ops, err := itest.Client().Operations(horizonclient.OperationRequest{ForTransaction: tx.Hash}) diff --git a/services/horizon/internal/integration/sac_test.go b/services/horizon/internal/integration/sac_test.go index 68236ca3fe..64c772b44c 100644 --- a/services/horizon/internal/integration/sac_test.go +++ b/services/horizon/internal/integration/sac_test.go @@ -1,6 +1,7 @@ package integration import ( + "context" "math" "math/big" "strings" @@ -14,6 +15,8 @@ import ( "github.com/stellar/go/keypair" "github.com/stellar/go/protocols/horizon/effects" "github.com/stellar/go/protocols/horizon/operations" + "github.com/stellar/go/services/horizon/internal/db2/history" + "github.com/stellar/go/services/horizon/internal/ingest/processors" "github.com/stellar/go/services/horizon/internal/test/integration" "github.com/stellar/go/strkey" "github.com/stellar/go/txnbuild" @@ -22,6 +25,11 @@ import ( const sac_contract = "soroban_sac_test.wasm" +// LongTermTTL is used to extend the lifetime of ledger entries by 10000 ledgers. +// This will ensure that the ledger entries never expire during the execution +// of the integration tests. +const LongTermTTL = 10000 + // Tests use precompiled wasm bin files that are added to the testdata directory. // Refer to ./services/horizon/internal/integration/contracts/README.md on how to recompile // contract code if needed to new wasm. @@ -41,7 +49,7 @@ func TestContractMintToAccount(t *testing.T) { code := "USD" asset := xdr.MustNewCreditAsset(code, issuer) - assertInvokeHostFnSucceeds(itest, itest.Master(), createSAC(issuer, asset)) + createSAC(itest, asset) recipientKp, recipient := itest.CreateAccount("100") itest.MustEstablishTrustline(recipientKp, recipient, txnbuild.MustAssetFromXDR(asset)) @@ -105,6 +113,32 @@ func TestContractMintToAccount(t *testing.T) { }) } +func createSAC(itest *integration.Test, asset xdr.Asset) { + invokeHostFunction := &txnbuild.InvokeHostFunction{ + HostFunction: xdr.HostFunction{ + Type: xdr.HostFunctionTypeHostFunctionTypeCreateContract, + CreateContract: &xdr.CreateContractArgs{ + ContractIdPreimage: xdr.ContractIdPreimage{ + Type: xdr.ContractIdPreimageTypeContractIdPreimageFromAsset, + FromAsset: &asset, + }, + Executable: xdr.ContractExecutable{ + Type: xdr.ContractExecutableTypeContractExecutableStellarAsset, + WasmHash: nil, + }, + }, + }, + SourceAccount: itest.Master().Address(), + } + _, _, preFlightOp := assertInvokeHostFnSucceeds(itest, itest.Master(), invokeHostFunction) + sourceAccount, extendTTLOp, minFee := itest.PreflightExtendExpiration( + itest.Master().Address(), + preFlightOp.Ext.SorobanData.Resources.Footprint.ReadWrite, + LongTermTTL, + ) + itest.MustSubmitOperationsWithFee(&sourceAccount, itest.Master(), minFee+txnbuild.MinBaseFee, &extendTTLOp) +} + func TestContractMintToContract(t *testing.T) { if integration.GetCoreMaxSupportedProtocol() < 20 { t.Skip("This test run does not support less than Protocol 20") @@ -119,7 +153,7 @@ func TestContractMintToContract(t *testing.T) { code := "USD" asset := xdr.MustNewCreditAsset(code, issuer) - assertInvokeHostFnSucceeds(itest, itest.Master(), createSAC(issuer, asset)) + createSAC(itest, asset) // Create recipient contract recipientContractID, _ := mustCreateAndInstallContract(itest, itest.Master(), "a1", add_u64_contract) @@ -185,6 +219,287 @@ func TestContractMintToContract(t *testing.T) { }) } +func TestExpirationAndRestoration(t *testing.T) { + if integration.GetCoreMaxSupportedProtocol() < 20 { + t.Skip("This test run does not support less than Protocol 20") + } + + itest := integration.NewTest(t, integration.Config{ + ProtocolVersion: 20, + EnableSorobanRPC: true, + HorizonIngestParameters: map[string]string{ + // disable state verification because we will insert + // a fake asset contract in the horizon db and we don't + // want state verification to detect this + "ingest-disable-state-verification": "true", + }, + }) + + issuer := itest.Master().Address() + code := "USD" + + // Create contract to store synthetic asset balances + storeContractID, _ := mustCreateAndInstallContract( + itest, + itest.Master(), + "a1", + "soroban_store.wasm", + ) + syntheticAssetStat := history.ExpAssetStat{ + AssetType: xdr.AssetTypeAssetTypeCreditAlphanum4, + AssetCode: code, + AssetIssuer: issuer, + Accounts: history.ExpAssetStatAccounts{ + Authorized: 0, + AuthorizedToMaintainLiabilities: 0, + ClaimableBalances: 0, + LiquidityPools: 0, + Unauthorized: 0, + }, + Balances: history.ExpAssetStatBalances{ + Authorized: "0", + AuthorizedToMaintainLiabilities: "0", + ClaimableBalances: "0", + LiquidityPools: "0", + Unauthorized: "0", + }, + Amount: "0", + NumAccounts: 0, + ContractID: nil, + } + syntheticAssetStat.SetContractID(storeContractID) + _, err := itest.HorizonIngest().HistoryQ().InsertAssetStat( + context.Background(), + syntheticAssetStat, + ) + assert.NoError(t, err) + + // create active balance + _, _, setOp := assertInvokeHostFnSucceeds( + itest, + itest.Master(), + invokeStoreSet( + itest, + storeContractID, + processors.BalanceToContractData( + storeContractID, + [32]byte{1}, + 23, + ), + ), + ) + sourceAccount, extendTTLOp, minFee := itest.PreflightExtendExpiration( + itest.Master().Address(), + setOp.Ext.SorobanData.Resources.Footprint.ReadWrite, + LongTermTTL, + ) + itest.MustSubmitOperationsWithFee(&sourceAccount, itest.Master(), minFee+txnbuild.MinBaseFee, &extendTTLOp) + assertAssetStats(itest, assetStats{ + code: code, + issuer: issuer, + numAccounts: 0, + balanceAccounts: 0, + balanceArchivedContracts: big.NewInt(0), + numArchivedContracts: 0, + numContracts: 1, + balanceContracts: big.NewInt(23), + contractID: storeContractID, + }) + + // create balance which we will expire + balanceToExpire := processors.BalanceToContractData( + storeContractID, + [32]byte{2}, + 37, + ) + assertInvokeHostFnSucceeds( + itest, + itest.Master(), + invokeStoreSet( + itest, + storeContractID, + balanceToExpire, + ), + ) + assertAssetStats(itest, assetStats{ + code: code, + issuer: issuer, + numAccounts: 0, + balanceAccounts: 0, + balanceArchivedContracts: big.NewInt(0), + numArchivedContracts: 0, + numContracts: 2, + balanceContracts: big.NewInt(60), + contractID: storeContractID, + }) + + balanceToExpireLedgerKey := xdr.LedgerKey{ + Type: xdr.LedgerEntryTypeContractData, + ContractData: &xdr.LedgerKeyContractData{ + Contract: balanceToExpire.ContractData.Contract, + Key: balanceToExpire.ContractData.Key, + Durability: balanceToExpire.ContractData.Durability, + }, + } + // The TESTING_MINIMUM_PERSISTENT_ENTRY_LIFETIME=10 configuration in stellar-core + // will ensure that the ledger entry expires after 10 ledgers. + // Because ARTIFICIALLY_ACCELERATE_TIME_FOR_TESTING is set to true, 10 ledgers + // should elapse in 10 seconds + itest.WaitUntilLedgerEntryTTL(balanceToExpireLedgerKey) + assertAssetStats(itest, assetStats{ + code: code, + issuer: issuer, + numAccounts: 0, + balanceAccounts: 0, + balanceArchivedContracts: big.NewInt(37), + numArchivedContracts: 1, + numContracts: 1, + balanceContracts: big.NewInt(23), + contractID: storeContractID, + }) + + // increase active balance from 23 to 50 + assertInvokeHostFnSucceeds( + itest, + itest.Master(), + invokeStoreSet( + itest, + storeContractID, + processors.BalanceToContractData( + storeContractID, + [32]byte{1}, + 50, + ), + ), + ) + assertAssetStats(itest, assetStats{ + code: code, + issuer: issuer, + numAccounts: 0, + balanceAccounts: 0, + balanceArchivedContracts: big.NewInt(37), + numArchivedContracts: 1, + numContracts: 1, + balanceContracts: big.NewInt(50), + contractID: storeContractID, + }) + + // restore expired balance + sourceAccount, restoreFootprint, minFee := itest.RestoreFootprint( + itest.Master().Address(), + balanceToExpireLedgerKey, + ) + itest.MustSubmitOperationsWithFee(&sourceAccount, itest.Master(), minFee+txnbuild.MinBaseFee, &restoreFootprint) + assertAssetStats(itest, assetStats{ + code: code, + issuer: issuer, + numAccounts: 0, + balanceAccounts: 0, + balanceArchivedContracts: big.NewInt(0), + numArchivedContracts: 0, + numContracts: 2, + balanceContracts: big.NewInt(87), + contractID: storeContractID, + }) + + // expire the balance again + itest.WaitUntilLedgerEntryTTL(balanceToExpireLedgerKey) + + // decrease active balance from 50 to 3 + assertInvokeHostFnSucceeds( + itest, + itest.Master(), + invokeStoreSet( + itest, + storeContractID, + processors.BalanceToContractData( + storeContractID, + [32]byte{1}, + 3, + ), + ), + ) + assertAssetStats(itest, assetStats{ + code: code, + issuer: issuer, + numAccounts: 0, + balanceAccounts: 0, + balanceArchivedContracts: big.NewInt(37), + numArchivedContracts: 1, + numContracts: 1, + balanceContracts: big.NewInt(3), + contractID: storeContractID, + }) + + // remove active balance + assertInvokeHostFnSucceeds( + itest, + itest.Master(), + invokeStoreRemove( + itest, + storeContractID, + processors.ContractBalanceLedgerKey( + storeContractID, + [32]byte{1}, + ), + ), + ) + assertAssetStats(itest, assetStats{ + code: code, + issuer: issuer, + numAccounts: 0, + balanceAccounts: 0, + balanceArchivedContracts: big.NewInt(37), + numArchivedContracts: 1, + numContracts: 0, + balanceContracts: big.NewInt(0), + contractID: storeContractID, + }) +} + +func invokeStoreSet( + itest *integration.Test, + storeContractID xdr.Hash, + ledgerEntryData xdr.LedgerEntryData, +) *txnbuild.InvokeHostFunction { + key := ledgerEntryData.MustContractData().Key + val := ledgerEntryData.MustContractData().Val + return &txnbuild.InvokeHostFunction{ + HostFunction: xdr.HostFunction{ + Type: xdr.HostFunctionTypeHostFunctionTypeInvokeContract, + InvokeContract: &xdr.InvokeContractArgs{ + ContractAddress: contractIDParam(storeContractID), + FunctionName: "set", + Args: xdr.ScVec{ + key, + val, + }, + }, + }, + SourceAccount: itest.Master().Address(), + } +} + +func invokeStoreRemove( + itest *integration.Test, + storeContractID xdr.Hash, + ledgerKey xdr.LedgerKey, +) *txnbuild.InvokeHostFunction { + return &txnbuild.InvokeHostFunction{ + HostFunction: xdr.HostFunction{ + Type: xdr.HostFunctionTypeHostFunctionTypeInvokeContract, + InvokeContract: &xdr.InvokeContractArgs{ + ContractAddress: contractIDParam(storeContractID), + FunctionName: "remove", + Args: xdr.ScVec{ + ledgerKey.MustContractData().Key, + }, + }, + }, + SourceAccount: itest.Master().Address(), + } +} + func TestContractTransferBetweenAccounts(t *testing.T) { if integration.GetCoreMaxSupportedProtocol() < 20 { t.Skip("This test run does not support less than Protocol 20") @@ -199,7 +514,7 @@ func TestContractTransferBetweenAccounts(t *testing.T) { code := "USD" asset := xdr.MustNewCreditAsset(code, issuer) - assertInvokeHostFnSucceeds(itest, itest.Master(), createSAC(issuer, asset)) + createSAC(itest, asset) recipientKp, recipient := itest.CreateAccount("100") itest.MustEstablishTrustline(recipientKp, recipient, txnbuild.MustAssetFromXDR(asset)) @@ -274,7 +589,7 @@ func TestContractTransferBetweenAccountAndContract(t *testing.T) { code := "USDLONG" asset := xdr.MustNewCreditAsset(code, issuer) - assertInvokeHostFnSucceeds(itest, itest.Master(), createSAC(issuer, asset)) + createSAC(itest, asset) recipientKp, recipient := itest.CreateAccount("100") itest.MustEstablishTrustline(recipientKp, recipient, txnbuild.MustAssetFromXDR(asset)) @@ -395,7 +710,7 @@ func TestContractTransferBetweenContracts(t *testing.T) { code := "USD" asset := xdr.MustNewCreditAsset(code, issuer) - assertInvokeHostFnSucceeds(itest, itest.Master(), createSAC(issuer, asset)) + createSAC(itest, asset) // Create recipient contract recipientContractID, _ := mustCreateAndInstallContract(itest, itest.Master(), "a1", sac_contract) @@ -477,7 +792,7 @@ func TestContractBurnFromAccount(t *testing.T) { code := "USD" asset := xdr.MustNewCreditAsset(code, issuer) - assertInvokeHostFnSucceeds(itest, itest.Master(), createSAC(issuer, asset)) + createSAC(itest, asset) recipientKp, recipient := itest.CreateAccount("100") itest.MustEstablishTrustline(recipientKp, recipient, txnbuild.MustAssetFromXDR(asset)) @@ -553,7 +868,7 @@ func TestContractBurnFromContract(t *testing.T) { code := "USD" asset := xdr.MustNewCreditAsset(code, issuer) - assertInvokeHostFnSucceeds(itest, itest.Master(), createSAC(issuer, asset)) + createSAC(itest, asset) // Create recipient contract recipientContractID, recipientContractHash := mustCreateAndInstallContract(itest, itest.Master(), "a1", sac_contract) @@ -631,7 +946,7 @@ func TestContractClawbackFromAccount(t *testing.T) { code := "USD" asset := xdr.MustNewCreditAsset(code, issuer) - assertInvokeHostFnSucceeds(itest, itest.Master(), createSAC(issuer, asset)) + createSAC(itest, asset) recipientKp, recipient := itest.CreateAccount("100") itest.MustEstablishTrustline(recipientKp, recipient, txnbuild.MustAssetFromXDR(asset)) @@ -709,7 +1024,7 @@ func TestContractClawbackFromContract(t *testing.T) { code := "USD" asset := xdr.MustNewCreditAsset(code, issuer) - assertInvokeHostFnSucceeds(itest, itest.Master(), createSAC(issuer, asset)) + createSAC(itest, asset) // Create recipient contract recipientContractID, _ := mustCreateAndInstallContract(itest, itest.Master(), "a2", sac_contract) @@ -788,7 +1103,8 @@ func assertAssetStats(itest *integration.Test, expected assetStats) { }) assert.NoError(itest.CurrentTest(), err) - if expected.numContracts == 0 && expected.numAccounts == 0 && + if expected.numContracts == 0 && expected.numAccounts == 0 && expected.numArchivedContracts == 0 && + expected.balanceArchivedContracts.Cmp(big.NewInt(0)) == 0 && expected.balanceContracts.Cmp(big.NewInt(0)) == 0 && expected.balanceAccounts == 0 { assert.Empty(itest.CurrentTest(), assets) return @@ -913,27 +1229,6 @@ func i128Param(hi int64, lo uint64) xdr.ScVal { } } -func createSAC(sourceAccount string, asset xdr.Asset) *txnbuild.InvokeHostFunction { - invokeHostFunction := &txnbuild.InvokeHostFunction{ - HostFunction: xdr.HostFunction{ - Type: xdr.HostFunctionTypeHostFunctionTypeCreateContract, - CreateContract: &xdr.CreateContractArgs{ - ContractIdPreimage: xdr.ContractIdPreimage{ - Type: xdr.ContractIdPreimageTypeContractIdPreimageFromAsset, - FromAsset: &asset, - }, - Executable: xdr.ContractExecutable{ - Type: xdr.ContractExecutableTypeContractExecutableStellarAsset, - WasmHash: nil, - }, - }, - }, - SourceAccount: sourceAccount, - } - - return invokeHostFunction -} - func mint(itest *integration.Test, sourceAccount string, asset xdr.Asset, assetAmount string, recipient xdr.ScVal) *txnbuild.InvokeHostFunction { return mintWithAmt(itest, sourceAccount, asset, i128Param(0, uint64(amount.MustParse(assetAmount))), recipient) } @@ -1098,13 +1393,9 @@ func burn(itest *integration.Test, sourceAccount string, asset xdr.Asset, assetA func assertInvokeHostFnSucceeds(itest *integration.Test, signer *keypair.Full, op *txnbuild.InvokeHostFunction) (*xdr.ScVal, string, *txnbuild.InvokeHostFunction) { acc := itest.MustGetAccount(signer) preFlightOp, minFee := itest.PreflightHostFunctions(&acc, *op) - tx, err := itest.SubmitOperationsWithFee(&acc, signer, minFee+txnbuild.MinBaseFee, &preFlightOp) + clientTx, err := itest.SubmitOperationsWithFee(&acc, signer, minFee+txnbuild.MinBaseFee, &preFlightOp) require.NoError(itest.CurrentTest(), err) - clientTx, err := itest.Client().TransactionDetail(tx.Hash) - require.NoError(itest.CurrentTest(), err) - - assert.Equal(itest.CurrentTest(), tx.Hash, clientTx.Hash) var txResult xdr.TransactionResult err = xdr.SafeUnmarshalBase64(clientTx.ResultXdr, &txResult) require.NoError(itest.CurrentTest(), err) @@ -1122,7 +1413,7 @@ func assertInvokeHostFnSucceeds(itest *integration.Test, signer *keypair.Full, o returnValue := txMetaResult.MustV3().SorobanMeta.ReturnValue - return &returnValue, tx.Hash, &preFlightOp + return &returnValue, clientTx.Hash, &preFlightOp } func stellarAssetContractID(itest *integration.Test, asset xdr.Asset) xdr.Hash { @@ -1132,11 +1423,40 @@ func stellarAssetContractID(itest *integration.Test, asset xdr.Asset) xdr.Hash { } func mustCreateAndInstallContract(itest *integration.Test, signer *keypair.Full, contractSalt string, wasmFileName string) (xdr.Hash, xdr.Hash) { - installContractOp := assembleInstallContractCodeOp(itest.CurrentTest(), itest.Master().Address(), wasmFileName) - assertInvokeHostFnSucceeds(itest, signer, installContractOp) - createContractOp := assembleCreateContractOp(itest.CurrentTest(), itest.Master().Address(), wasmFileName, contractSalt, itest.GetPassPhrase()) - _, _, preflightOp := assertInvokeHostFnSucceeds(itest, signer, createContractOp) - contractHash := preflightOp.Ext.SorobanData.Resources.Footprint.ReadOnly[0].MustContractCode().Hash - contractID := preflightOp.Ext.SorobanData.Resources.Footprint.ReadWrite[0].MustContractData().Contract.ContractId + _, _, installContractOp := assertInvokeHostFnSucceeds( + itest, + signer, + assembleInstallContractCodeOp( + itest.CurrentTest(), + itest.Master().Address(), + wasmFileName, + ), + ) + _, _, createContractOp := assertInvokeHostFnSucceeds( + itest, + signer, + assembleCreateContractOp( + itest.CurrentTest(), + itest.Master().Address(), + wasmFileName, + contractSalt, + itest.GetPassPhrase(), + ), + ) + + keys := append( + installContractOp.Ext.SorobanData.Resources.Footprint.ReadWrite, + createContractOp.Ext.SorobanData.Resources.Footprint.ReadWrite..., + ) + + sourceAccount, extendTTLOp, minFee := itest.PreflightExtendExpiration( + itest.Master().Address(), + keys, + LongTermTTL, + ) + itest.MustSubmitOperationsWithFee(&sourceAccount, itest.Master(), minFee+txnbuild.MinBaseFee, &extendTTLOp) + + contractHash := createContractOp.Ext.SorobanData.Resources.Footprint.ReadOnly[0].MustContractCode().Hash + contractID := createContractOp.Ext.SorobanData.Resources.Footprint.ReadWrite[0].MustContractData().Contract.ContractId return *contractID, contractHash } diff --git a/services/horizon/internal/integration/testdata/soroban_add_u64.wasm b/services/horizon/internal/integration/testdata/soroban_add_u64.wasm index 9aac34ea654e19ee731b56ced4e60fd08bd60c89..91ca4537f6e738227283b49ed13edb55bf6ddf2a 100755 GIT binary patch delta 13 Ucmey)@||Ua789e%WNjuN03$*K6aWAK delta 13 Ucmey)@||Ua789fKWNjuN03$sF6951J diff --git a/services/horizon/internal/integration/testdata/soroban_increment_contract.wasm b/services/horizon/internal/integration/testdata/soroban_increment_contract.wasm index 55308fd40a61dffbda9628f24a35cc266f5b5721..ddcbadea30ad4ca60ca158955ab4e0f5c9548019 100755 GIT binary patch delta 13 UcmdnXx|elB0TZLi 0 { + liveUntilLedgerSeq := *result.Entries[0].LiveUntilLedgerSeq + + root, err := i.horizonClient.Root() + assert.NoError(i.t, err) + if uint32(root.HorizonSequence) > liveUntilLedgerSeq { + ttled = true + i.t.Logf("ledger entry ttl'ed") + break + } + i.t.Log("waiting for ledger entry to ttl at ledger", liveUntilLedgerSeq) + } else { + i.t.Log("waiting for soroban-rpc to ingest the ledger entries") + } + time.Sleep(time.Second) + } + assert.True(i.t, ttled) +} + +func (i *Test) PreflightExtendExpiration( + account string, ledgerKeys []xdr.LedgerKey, extendAmt uint32, +) (proto.Account, txnbuild.ExtendFootprintTtl, int64) { + sourceAccount, err := i.Client().AccountDetail(sdk.AccountRequest{ + AccountID: account, + }) + assert.NoError(i.t, err) + + bumpFootprint := txnbuild.ExtendFootprintTtl{ + ExtendTo: extendAmt, + SourceAccount: "", + Ext: xdr.TransactionExt{ + V: 1, + SorobanData: &xdr.SorobanTransactionData{ + Ext: xdr.ExtensionPoint{}, + Resources: xdr.SorobanResources{ + Footprint: xdr.LedgerFootprint{ + ReadOnly: ledgerKeys, + ReadWrite: nil, + }, + }, + ResourceFee: 0, + }, + }, + } + result, transactionData := i.simulateTransaction(&sourceAccount, &bumpFootprint) bumpFootprint.Ext = xdr.TransactionExt{ V: 1, SorobanData: &transactionData, } - return bumpFootprint, result.MinResourceFee + return sourceAccount, bumpFootprint, result.MinResourceFee +} + +func (i *Test) RestoreFootprint( + account string, ledgerKey xdr.LedgerKey, +) (proto.Account, txnbuild.RestoreFootprint, int64) { + sourceAccount, err := i.Client().AccountDetail(sdk.AccountRequest{ + AccountID: account, + }) + assert.NoError(i.t, err) + + restoreFootprint := txnbuild.RestoreFootprint{ + SourceAccount: "", + Ext: xdr.TransactionExt{ + V: 1, + SorobanData: &xdr.SorobanTransactionData{ + Ext: xdr.ExtensionPoint{}, + Resources: xdr.SorobanResources{ + Footprint: xdr.LedgerFootprint{ + ReadWrite: []xdr.LedgerKey{ledgerKey}, + }, + }, + ResourceFee: 0, + }, + }, + } + result, transactionData := i.simulateTransaction(&sourceAccount, &restoreFootprint) + restoreFootprint.Ext = xdr.TransactionExt{ + V: 1, + SorobanData: &transactionData, + } + + return sourceAccount, restoreFootprint, result.MinResourceFee } // UpgradeProtocol arms Core with upgrade and blocks until protocol is upgraded. From 0fabc0cdbd39f8f92d04cd224c1dd031cfe1b282 Mon Sep 17 00:00:00 2001 From: Alfonso Acosta Date: Thu, 30 Nov 2023 14:11:09 +0100 Subject: [PATCH 13/16] fixed dependecnies for verify-range to to get go version dynmaically from go.mod (#5131) Co-authored-by: Shawn Reuland --- services/horizon/docker/verify-range/dependencies | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/services/horizon/docker/verify-range/dependencies b/services/horizon/docker/verify-range/dependencies index fa622f9d2e..910ee9cf21 100644 --- a/services/horizon/docker/verify-range/dependencies +++ b/services/horizon/docker/verify-range/dependencies @@ -11,13 +11,17 @@ echo "deb https://apt.stellar.org $(lsb_release -cs) stable" | sudo tee -a /etc/ apt-get update apt-get install -y stellar-core=${STELLAR_CORE_VERSION} -wget -q https://dl.google.com/go/go1.18.linux-amd64.tar.gz -tar -C /usr/local -xzf go1.18.linux-amd64.tar.gz - git clone https://github.com/stellar/go.git stellar-go cd stellar-go + # By default "git fetch" only fetches refs/ # Below ensures we also fetch PR refs git config --add remote.origin.fetch "+refs/pull/*/head:refs/remotes/origin/pull/*" git fetch --force --quiet origin + +GO_VERSION=$(sed -En 's/^go[[:space:]]+([[:digit:].]+)$/\1/p' go.mod) +wget -q https://dl.google.com/go/go${GO_VERSION}.linux-amd64.tar.gz +tar -C /usr/local -xzf go${GO_VERSION}.linux-amd64.tar.gz +rm -f go${GO_VERSION}.linux-amd64.tar.gz + /usr/local/go/bin/go build -v ./services/horizon From e9027a62f8025e94841ad58a8f2a5d0da23b5565 Mon Sep 17 00:00:00 2001 From: Alfonso Acosta Date: Thu, 30 Nov 2023 16:40:29 +0100 Subject: [PATCH 14/16] services/horizon: Bump Core and soroban-rpc versions (#5130) --- .github/workflows/horizon.yml | 6 +- ...ive-core-integration-tests.soroban-rpc.cfg | 7 +- .../internal/integration/contracts/Cargo.lock | 117 ++++++++++-------- .../internal/integration/contracts/Cargo.toml | 2 +- .../integration/testdata/soroban_add_u64.wasm | Bin 631 -> 631 bytes .../testdata/soroban_increment_contract.wasm | Bin 701 -> 701 bytes .../testdata/soroban_sac_test.wasm | Bin 1924 -> 1924 bytes .../integration/testdata/soroban_store.wasm | Bin 449 -> 449 bytes .../internal/test/integration/integration.go | 2 +- 9 files changed, 77 insertions(+), 57 deletions(-) diff --git a/.github/workflows/horizon.yml b/.github/workflows/horizon.yml index fd167bfce7..1a5415f74b 100644 --- a/.github/workflows/horizon.yml +++ b/.github/workflows/horizon.yml @@ -33,9 +33,9 @@ jobs: env: HORIZON_INTEGRATION_TESTS_ENABLED: true HORIZON_INTEGRATION_TESTS_CORE_MAX_SUPPORTED_PROTOCOL: ${{ matrix.protocol-version }} - PROTOCOL_20_CORE_DEBIAN_PKG_VERSION: 19.14.1-1529.fcbbad4ce.focal - PROTOCOL_20_CORE_DOCKER_IMG: 2opremio/stellar-core:19.14.1-1529.fcbbad4ce.focal - PROTOCOL_20_SOROBAN_RPC_DOCKER_IMG: stellar/soroban-rpc:20.0.0-rc4pubnet-42 + PROTOCOL_20_CORE_DEBIAN_PKG_VERSION: 19.14.1-1590.b6b730a0c.focal + PROTOCOL_20_CORE_DOCKER_IMG: stellar/unsafe-stellar-core:19.14.1-1590.b6b730a0c.focal + PROTOCOL_20_SOROBAN_RPC_DOCKER_IMG: stellar/soroban-rpc:20.0.0-rc4231129-43 PROTOCOL_19_CORE_DEBIAN_PKG_VERSION: 19.12.0-1378.2109a168a.focal PROTOCOL_19_CORE_DOCKER_IMG: stellar/stellar-core:19.12.0-1378.2109a168a.focal PGHOST: localhost diff --git a/services/horizon/docker/captive-core-integration-tests.soroban-rpc.cfg b/services/horizon/docker/captive-core-integration-tests.soroban-rpc.cfg index 2e3dd346e5..9a7ad9d769 100644 --- a/services/horizon/docker/captive-core-integration-tests.soroban-rpc.cfg +++ b/services/horizon/docker/captive-core-integration-tests.soroban-rpc.cfg @@ -1,10 +1,15 @@ PEER_PORT=11725 ARTIFICIALLY_ACCELERATE_TIME_FOR_TESTING=true -ENABLE_SOROBAN_DIAGNOSTIC_EVENTS=true UNSAFE_QUORUM=true FAILURE_SAFETY=0 +ENABLE_SOROBAN_DIAGNOSTIC_EVENTS=true +# 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 + [[VALIDATORS]] NAME="local_core" HOME_DOMAIN="core.local" diff --git a/services/horizon/internal/integration/contracts/Cargo.lock b/services/horizon/internal/integration/contracts/Cargo.lock index 006b35e8e2..e80d7d5d28 100644 --- a/services/horizon/internal/integration/contracts/Cargo.lock +++ b/services/horizon/internal/integration/contracts/Cargo.lock @@ -447,9 +447,9 @@ dependencies = [ [[package]] name = "gimli" -version = "0.28.0" +version = "0.28.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "6fb8d784f27acf97159b40fc4db5ecd8aa23b9ad5ef69cdd136d3bc80665f0c0" +checksum = "4271d37baee1b8c7e4b708028c57d816cf9d2434acb33a549475f78c181f6253" [[package]] name = "group" @@ -470,9 +470,9 @@ checksum = "8a9ee70c43aaf417c914396645a0fa852624801b24ebb7ae78fe8272889ac888" [[package]] name = "hashbrown" -version = "0.14.2" +version = "0.14.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f93e7192158dbcda357bdec5fb5788eebf8bbac027f3f33e719d29135ae84156" +checksum = "290f1a1d9242c78d09ce40a5e87e7554ee637af1351968159f4952f028f75604" [[package]] name = "hex" @@ -483,6 +483,12 @@ dependencies = [ "serde", ] +[[package]] +name = "hex-literal" +version = "0.4.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "6fe2267d4ed49bc07b63801559be28c718ea06c4738b7a03c94df7386d2cde46" + [[package]] name = "hmac" version = "0.12.1" @@ -539,7 +545,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "d530e1a18b1cb4c484e6e34556a0d948706958449fca0cab753d649f2bce3d1f" dependencies = [ "equivalent", - "hashbrown 0.14.2", + "hashbrown 0.14.3", "serde", ] @@ -551,9 +557,9 @@ checksum = "8e04e2fd2b8188ea827b32ef11de88377086d690286ab35747ef7f9bf3ccb590" [[package]] name = "itertools" -version = "0.10.5" +version = "0.11.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b0fd2260e829bddf4cb6ea802289de2f86d6a7a690192fbe91b3f46e0f2c8473" +checksum = "b1c173a5686ce8bfa551b3563d0c2170bf24ca44da99c7ca4bfdab5418c3fe57" dependencies = [ "either", ] @@ -566,9 +572,9 @@ checksum = "af150ab688ff2122fcef229be89cb50dd66af9e01a4ff320cc137eecc9bacc38" [[package]] name = "js-sys" -version = "0.3.65" +version = "0.3.66" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "54c0c35952f67de54bb584e9fd912b3023117cbafc0a77d8f3dee1fb5f572fe8" +checksum = "cee9c64da59eae3b50095c18d3e74f8b73c0b86d2792824ff01bbce68ba229ca" dependencies = [ "wasm-bindgen", ] @@ -731,9 +737,9 @@ dependencies = [ [[package]] name = "proc-macro2" -version = "1.0.69" +version = "1.0.70" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "134c189feb4956b20f6f547d2cf727d4c0fe06722b20a0eec87ed445a97f92da" +checksum = "39278fbbf5fb4f646ce651690877f89d1c5811a3d4acb27700c1cb3cdb78fd3b" dependencies = [ "unicode-ident", ] @@ -830,18 +836,18 @@ checksum = "836fa6a3e1e547f9a2c4040802ec865b5d85f4014efe00555d7090a3dcaa1090" [[package]] name = "serde" -version = "1.0.192" +version = "1.0.193" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "bca2a08484b285dcb282d0f67b26cadc0df8b19f8c12502c13d966bf9482f001" +checksum = "25dd9975e68d0cb5aa1120c288333fc98731bd1dd12f561e468ea4728c042b89" dependencies = [ "serde_derive", ] [[package]] name = "serde_derive" -version = "1.0.192" +version = "1.0.193" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d6c7207fbec9faa48073f3e3074cbe553af6ea512d7c21ba46e434e70ea9fbc1" +checksum = "43576ca501357b9b071ac53cdc7da8ef0cbd9493d8df094cd821777ea6e894d3" dependencies = [ "proc-macro2", "quote", @@ -925,10 +931,21 @@ version = "1.11.2" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "4dccd0940a2dcdf68d092b8cbab7dc0ad8fa938bf95787e1b916b0e3d0e8e970" +[[package]] +name = "soroban-builtin-sdk-macros" +version = "20.0.0-rc2" +source = "git+https://github.com/stellar/rs-soroban-env?rev=be04cf31e925ba5bacd9b22db7caf7b4f6dd8372#be04cf31e925ba5bacd9b22db7caf7b4f6dd8372" +dependencies = [ + "itertools", + "proc-macro2", + "quote", + "syn", +] + [[package]] name = "soroban-env-common" version = "20.0.0-rc2" -source = "git+https://github.com/stellar/rs-soroban-env?rev=91f44778389490ad863d61a8a90ac9875ba6d8fd#91f44778389490ad863d61a8a90ac9875ba6d8fd" +source = "git+https://github.com/stellar/rs-soroban-env?rev=be04cf31e925ba5bacd9b22db7caf7b4f6dd8372#be04cf31e925ba5bacd9b22db7caf7b4f6dd8372" dependencies = [ "arbitrary", "crate-git-revision", @@ -945,7 +962,7 @@ dependencies = [ [[package]] name = "soroban-env-guest" version = "20.0.0-rc2" -source = "git+https://github.com/stellar/rs-soroban-env?rev=91f44778389490ad863d61a8a90ac9875ba6d8fd#91f44778389490ad863d61a8a90ac9875ba6d8fd" +source = "git+https://github.com/stellar/rs-soroban-env?rev=be04cf31e925ba5bacd9b22db7caf7b4f6dd8372#be04cf31e925ba5bacd9b22db7caf7b4f6dd8372" dependencies = [ "soroban-env-common", "static_assertions", @@ -954,11 +971,14 @@ dependencies = [ [[package]] name = "soroban-env-host" version = "20.0.0-rc2" -source = "git+https://github.com/stellar/rs-soroban-env?rev=91f44778389490ad863d61a8a90ac9875ba6d8fd#91f44778389490ad863d61a8a90ac9875ba6d8fd" +source = "git+https://github.com/stellar/rs-soroban-env?rev=be04cf31e925ba5bacd9b22db7caf7b4f6dd8372#be04cf31e925ba5bacd9b22db7caf7b4f6dd8372" dependencies = [ "backtrace", + "curve25519-dalek", "ed25519-dalek", "getrandom", + "hex-literal", + "hmac", "k256", "num-derive", "num-integer", @@ -967,8 +987,8 @@ dependencies = [ "rand_chacha", "sha2", "sha3", + "soroban-builtin-sdk-macros", "soroban-env-common", - "soroban-native-sdk-macros", "soroban-wasmi", "static_assertions", "stellar-strkey", @@ -977,7 +997,7 @@ dependencies = [ [[package]] name = "soroban-env-macros" version = "20.0.0-rc2" -source = "git+https://github.com/stellar/rs-soroban-env?rev=91f44778389490ad863d61a8a90ac9875ba6d8fd#91f44778389490ad863d61a8a90ac9875ba6d8fd" +source = "git+https://github.com/stellar/rs-soroban-env?rev=be04cf31e925ba5bacd9b22db7caf7b4f6dd8372#be04cf31e925ba5bacd9b22db7caf7b4f6dd8372" dependencies = [ "itertools", "proc-macro2", @@ -998,26 +1018,16 @@ dependencies = [ [[package]] name = "soroban-ledger-snapshot" version = "20.0.0-rc2" -source = "git+https://github.com/stellar/rs-soroban-sdk?rev=729ed3ac5fe8600a3245d5816eadd3c95ab2eb54#729ed3ac5fe8600a3245d5816eadd3c95ab2eb54" +source = "git+https://github.com/stellar/rs-soroban-sdk?rev=e35bace9de5addae7c32f405cdc11bb459cb1d61#e35bace9de5addae7c32f405cdc11bb459cb1d61" dependencies = [ "serde", "serde_json", + "serde_with", "soroban-env-common", "soroban-env-host", "thiserror", ] -[[package]] -name = "soroban-native-sdk-macros" -version = "20.0.0-rc2" -source = "git+https://github.com/stellar/rs-soroban-env?rev=91f44778389490ad863d61a8a90ac9875ba6d8fd#91f44778389490ad863d61a8a90ac9875ba6d8fd" -dependencies = [ - "itertools", - "proc-macro2", - "quote", - "syn", -] - [[package]] name = "soroban-sac-test" version = "0.0.0" @@ -1028,13 +1038,15 @@ dependencies = [ [[package]] name = "soroban-sdk" version = "20.0.0-rc2" -source = "git+https://github.com/stellar/rs-soroban-sdk?rev=729ed3ac5fe8600a3245d5816eadd3c95ab2eb54#729ed3ac5fe8600a3245d5816eadd3c95ab2eb54" +source = "git+https://github.com/stellar/rs-soroban-sdk?rev=e35bace9de5addae7c32f405cdc11bb459cb1d61#e35bace9de5addae7c32f405cdc11bb459cb1d61" dependencies = [ "arbitrary", "bytes-lit", "ctor", "ed25519-dalek", "rand", + "serde", + "serde_json", "soroban-env-guest", "soroban-env-host", "soroban-ledger-snapshot", @@ -1045,7 +1057,7 @@ dependencies = [ [[package]] name = "soroban-sdk-macros" version = "20.0.0-rc2" -source = "git+https://github.com/stellar/rs-soroban-sdk?rev=729ed3ac5fe8600a3245d5816eadd3c95ab2eb54#729ed3ac5fe8600a3245d5816eadd3c95ab2eb54" +source = "git+https://github.com/stellar/rs-soroban-sdk?rev=e35bace9de5addae7c32f405cdc11bb459cb1d61#e35bace9de5addae7c32f405cdc11bb459cb1d61" dependencies = [ "crate-git-revision", "darling", @@ -1064,7 +1076,7 @@ dependencies = [ [[package]] name = "soroban-spec" version = "20.0.0-rc2" -source = "git+https://github.com/stellar/rs-soroban-sdk?rev=729ed3ac5fe8600a3245d5816eadd3c95ab2eb54#729ed3ac5fe8600a3245d5816eadd3c95ab2eb54" +source = "git+https://github.com/stellar/rs-soroban-sdk?rev=e35bace9de5addae7c32f405cdc11bb459cb1d61#e35bace9de5addae7c32f405cdc11bb459cb1d61" dependencies = [ "base64 0.13.1", "stellar-xdr", @@ -1075,7 +1087,7 @@ dependencies = [ [[package]] name = "soroban-spec-rust" version = "20.0.0-rc2" -source = "git+https://github.com/stellar/rs-soroban-sdk?rev=729ed3ac5fe8600a3245d5816eadd3c95ab2eb54#729ed3ac5fe8600a3245d5816eadd3c95ab2eb54" +source = "git+https://github.com/stellar/rs-soroban-sdk?rev=e35bace9de5addae7c32f405cdc11bb459cb1d61#e35bace9de5addae7c32f405cdc11bb459cb1d61" dependencies = [ "prettyplease", "proc-macro2", @@ -1121,9 +1133,9 @@ checksum = "6980e8d7511241f8acf4aebddbb1ff938df5eebe98691418c4468d0b72a96a67" [[package]] name = "spki" -version = "0.7.2" +version = "0.7.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9d1e996ef02c474957d681f1b05213dfb0abab947b446a62d37770b23500184a" +checksum = "d91ed6c858b01f942cd56b37a94b3e0a1798290327d1236e4d9cf4eaca44d29d" dependencies = [ "base64ct", "der", @@ -1137,17 +1149,19 @@ checksum = "a2eb9349b6444b326872e140eb1cf5e7c522154d69e7a0ffb0fb81c06b37543f" [[package]] name = "stellar-strkey" -version = "0.0.7" -source = "git+https://github.com/stellar/rs-stellar-strkey?rev=e6ba45c60c16de28c7522586b80ed0150157df73#e6ba45c60c16de28c7522586b80ed0150157df73" +version = "0.0.8" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "12d2bf45e114117ea91d820a846fd1afbe3ba7d717988fee094ce8227a3bf8bd" dependencies = [ "base32", + "crate-git-revision", "thiserror", ] [[package]] name = "stellar-xdr" version = "20.0.0-rc1" -source = "git+https://github.com/stellar/rs-stellar-xdr?rev=9c97e4fa909a0b6455547a4f4a95800696b2a69a#9c97e4fa909a0b6455547a4f4a95800696b2a69a" +source = "git+https://github.com/stellar/rs-stellar-xdr?rev=d6f8ece2c89809d5e2800b9df64ae60787ee492b#d6f8ece2c89809d5e2800b9df64ae60787ee492b" dependencies = [ "arbitrary", "base64 0.13.1", @@ -1155,6 +1169,7 @@ dependencies = [ "hex", "serde", "serde_with", + "stellar-strkey", ] [[package]] @@ -1255,9 +1270,9 @@ checksum = "9c8d87e72b64a3b4db28d11ce29237c246188f4f51057d65a7eab63b7987e423" [[package]] name = "wasm-bindgen" -version = "0.2.88" +version = "0.2.89" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7daec296f25a1bae309c0cd5c29c4b260e510e6d813c286b19eaadf409d40fce" +checksum = "0ed0d4f68a3015cc185aff4db9506a015f4b96f95303897bfa23f846db54064e" dependencies = [ "cfg-if", "wasm-bindgen-macro", @@ -1265,9 +1280,9 @@ dependencies = [ [[package]] name = "wasm-bindgen-backend" -version = "0.2.88" +version = "0.2.89" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e397f4664c0e4e428e8313a469aaa58310d302159845980fd23b0f22a847f217" +checksum = "1b56f625e64f3a1084ded111c4d5f477df9f8c92df113852fa5a374dbda78826" dependencies = [ "bumpalo", "log", @@ -1280,9 +1295,9 @@ dependencies = [ [[package]] name = "wasm-bindgen-macro" -version = "0.2.88" +version = "0.2.89" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5961017b3b08ad5f3fe39f1e79877f8ee7c23c5e5fd5eb80de95abc41f1f16b2" +checksum = "0162dbf37223cd2afce98f3d0785506dcb8d266223983e4b5b525859e6e182b2" dependencies = [ "quote", "wasm-bindgen-macro-support", @@ -1290,9 +1305,9 @@ dependencies = [ [[package]] name = "wasm-bindgen-macro-support" -version = "0.2.88" +version = "0.2.89" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c5353b8dab669f5e10f5bd76df26a9360c748f054f862ff5f3f8aae0c7fb3907" +checksum = "f0eb82fcb7930ae6219a7ecfd55b217f5f0893484b7a13022ebb2b2bf20b5283" dependencies = [ "proc-macro2", "quote", @@ -1303,9 +1318,9 @@ dependencies = [ [[package]] name = "wasm-bindgen-shared" -version = "0.2.88" +version = "0.2.89" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "0d046c5d029ba91a1ed14da14dca44b68bf2f124cfbaf741c54151fdb3e0750b" +checksum = "7ab9b36309365056cd639da3134bf87fa8f3d86008abf99e612384a6eecd459f" [[package]] name = "wasmi_arena" diff --git a/services/horizon/internal/integration/contracts/Cargo.toml b/services/horizon/internal/integration/contracts/Cargo.toml index d27b45dd4f..72ada87404 100644 --- a/services/horizon/internal/integration/contracts/Cargo.toml +++ b/services/horizon/internal/integration/contracts/Cargo.toml @@ -25,4 +25,4 @@ lto = true [workspace.dependencies.soroban-sdk] version = "20.0.0-rc2" git = "https://github.com/stellar/rs-soroban-sdk" -rev = "729ed3ac5fe8600a3245d5816eadd3c95ab2eb54" +rev = "e35bace9de5addae7c32f405cdc11bb459cb1d61" diff --git a/services/horizon/internal/integration/testdata/soroban_add_u64.wasm b/services/horizon/internal/integration/testdata/soroban_add_u64.wasm index 91ca4537f6e738227283b49ed13edb55bf6ddf2a..9ffd8622b744ae3355a7a3fbda92b20afdba0dc5 100755 GIT binary patch delta 55 zcmey)@||S^BNHRTWF{sb%~WI4q{QS@%al~p#FUi8RP$tGqcjr()8v$7L&Kyb6I09N KB*PRlLk0lM#1G~G delta 55 zcmey)@||S^BNL;`WF{sbO>-m5)D+{yWYe@%3o`?QL}Mcp(-cz+L$lPxloaD+OVh+8 Kqtql*69xdeCl5&g diff --git a/services/horizon/internal/integration/testdata/soroban_increment_contract.wasm b/services/horizon/internal/integration/testdata/soroban_increment_contract.wasm index ddcbadea30ad4ca60ca158955ab4e0f5c9548019..b975e5ccd5f8c20f1ce9364a928321773712ce85 100755 GIT binary patch delta 55 zcmdnXx|el>I};I}@YJWDh1EO>-m5)D+{yWYe@%3o`?QL}Mcp(-cz+L$lPxloaD+OVh+8 Kqtql*69xdg6Axnm diff --git a/services/horizon/internal/integration/testdata/soroban_sac_test.wasm b/services/horizon/internal/integration/testdata/soroban_sac_test.wasm index 984fe5911e881be7f79b1c24a196d285064fd2b3..9424da50fd6f580b243c78ea1a342b13d2432169 100755 GIT binary patch delta 55 zcmZqSZ{gp-$Ii$wnV;Q9Gu7BMDKRN&@d^<#MCl5 K$uPytkO2Uvat}HH delta 55 zcmZqSZ{gp-$Ij?7nV;Q9)7;21HN`kF*)%QH!py)R(b&kuG{w}y&@44ECB-<|(ljy2 KC^gB{gaH7P)efBi diff --git a/services/horizon/internal/integration/testdata/soroban_store.wasm b/services/horizon/internal/integration/testdata/soroban_store.wasm index 1082f8335ec9131f2ea414e66e67e4b374e03d9c..7f839bd20839c603505278596459bc09871e5760 100755 GIT binary patch delta 55 zcmX@ee2{sAHzOm%WFJN!%~WI4q{QS@%al~p#FUi8RP$tGqcjr()8v$7L&Kyb6I09N KB*PRlLk0lQs}KqR delta 55 zcmX@ee2{sAHzT9VWFJN!O>-m5)D+{yWYe@%3o`?QL}Mcp(-cz+L$lPxloaD+OVh+8 Kqtql*69xdi4i9Yr diff --git a/services/horizon/internal/test/integration/integration.go b/services/horizon/internal/test/integration/integration.go index 1a109a77df..4e10262913 100644 --- a/services/horizon/internal/test/integration/integration.go +++ b/services/horizon/internal/test/integration/integration.go @@ -720,7 +720,7 @@ func (i *Test) WaitUntilLedgerEntryTTL(ledgerKey xdr.LedgerKey) { for attempt := 0; attempt < 50; attempt++ { var result struct { Entries []struct { - LiveUntilLedgerSeq *uint32 `json:"liveUntilLedgerSeqLedgerSeq,string,omitempty"` + LiveUntilLedgerSeq *uint32 `json:"liveUntilLedgerSeq,omitempty"` } `json:"entries"` } err := client.CallResult(context.Background(), "getLedgerEntries", request, &result) From af6f4ebad72870cdad1122613f7ef547df7eb78d Mon Sep 17 00:00:00 2001 From: tamirms Date: Mon, 4 Dec 2023 18:36:05 +0000 Subject: [PATCH 15/16] Update xdrgen and xdr definitions (#5136) --- Makefile | 4 +- gxdr/xdr_generated.go | 6 +- xdr/Stellar-transaction.x | 6 +- xdr/xdr_commit_generated.txt | 2 +- xdr/xdr_generated.go | 162 +++++++++++++++++------------------ 5 files changed, 88 insertions(+), 92 deletions(-) diff --git a/Makefile b/Makefile index 7b0cda6df6..08b25c5665 100644 --- a/Makefile +++ b/Makefile @@ -14,8 +14,8 @@ xdr/Stellar-contract.x \ xdr/Stellar-internal.x \ xdr/Stellar-contract-config-setting.x -XDRGEN_COMMIT=f9995ef529eb83db6b70206a0a857dc88e33c750 -XDR_COMMIT=6a620d160aab22609c982d54578ff6a63bfcdc01 +XDRGEN_COMMIT=e2cac557162d99b12ae73b846cf3d5bfe16636de +XDR_COMMIT=bb54e505f814386a3f45172e0b7e95b7badbe969 .PHONY: xdr xdr-clean xdr-update diff --git a/gxdr/xdr_generated.go b/gxdr/xdr_generated.go index 2c20497952..67270fcbbd 100644 --- a/gxdr/xdr_generated.go +++ b/gxdr/xdr_generated.go @@ -2159,7 +2159,7 @@ type SorobanAuthorizationEntry struct { } /* -Upload WASM, create, and invoke contracts in Soroban. +Upload Wasm, create, and invoke contracts in Soroban. Threshold: med Result: InvokeHostFunctionResult @@ -2176,7 +2176,7 @@ Extend the TTL of the entries specified in the readOnly footprint so they will live at least extendTo ledgers from lcl. - Threshold: med + Threshold: low Result: ExtendFootprintTTLResult */ type ExtendFootprintTTLOp struct { @@ -2187,7 +2187,7 @@ type ExtendFootprintTTLOp struct { /* Restore the archived entries specified in the readWrite footprint. - Threshold: med + Threshold: low Result: RestoreFootprintOp */ type RestoreFootprintOp struct { diff --git a/xdr/Stellar-transaction.x b/xdr/Stellar-transaction.x index c7f0f5e276..87dd32d385 100644 --- a/xdr/Stellar-transaction.x +++ b/xdr/Stellar-transaction.x @@ -572,7 +572,7 @@ struct SorobanAuthorizationEntry SorobanAuthorizedInvocation rootInvocation; }; -/* Upload WASM, create, and invoke contracts in Soroban. +/* Upload Wasm, create, and invoke contracts in Soroban. Threshold: med Result: InvokeHostFunctionResult @@ -588,7 +588,7 @@ struct InvokeHostFunctionOp /* Extend the TTL of the entries specified in the readOnly footprint so they will live at least extendTo ledgers from lcl. - Threshold: med + Threshold: low Result: ExtendFootprintTTLResult */ struct ExtendFootprintTTLOp @@ -599,7 +599,7 @@ struct ExtendFootprintTTLOp /* Restore the archived entries specified in the readWrite footprint. - Threshold: med + Threshold: low Result: RestoreFootprintOp */ struct RestoreFootprintOp diff --git a/xdr/xdr_commit_generated.txt b/xdr/xdr_commit_generated.txt index 3c6d18d90d..9746cc5569 100644 --- a/xdr/xdr_commit_generated.txt +++ b/xdr/xdr_commit_generated.txt @@ -1 +1 @@ -6a620d160aab22609c982d54578ff6a63bfcdc01 \ No newline at end of file +bb54e505f814386a3f45172e0b7e95b7badbe969 \ No newline at end of file diff --git a/xdr/xdr_generated.go b/xdr/xdr_generated.go index d4d6b12107..e8f49981ff 100644 --- a/xdr/xdr_generated.go +++ b/xdr/xdr_generated.go @@ -25,14 +25,10 @@ import ( "errors" "fmt" "io" - "unsafe" "github.com/stellar/go-xdr/xdr3" ) -// Needed since unsafe is not used in all cases -var _ = unsafe.Sizeof(0) - // XdrFilesSHA256 is the SHA256 hashes of source files. var XdrFilesSHA256 = map[string]string{ "xdr/Stellar-SCP.x": "8f32b04d008f8bc33b8843d075e69837231a673691ee41d8b821ca229a6e802a", @@ -45,7 +41,7 @@ var XdrFilesSHA256 = map[string]string{ "xdr/Stellar-ledger-entries.x": "4f8f2324f567a40065f54f696ea1428740f043ea4154f5986d9f499ad00ac333", "xdr/Stellar-ledger.x": "2c842f3fe6e269498af5467f849cf6818554e90babc845f34c87cda471298d0f", "xdr/Stellar-overlay.x": "de3957c58b96ae07968b3d3aebea84f83603e95322d1fa336360e13e3aba737a", - "xdr/Stellar-transaction.x": "c5dd8507bc84e10b67bf3bc74c8f716a660b425814b015025c6f6b6f20cb70e7", + "xdr/Stellar-transaction.x": "0d2b35a331a540b48643925d0869857236eb2487c02d340ea32e365e784ea2b8", "xdr/Stellar-types.x": "6e3b13f0d3e360b09fa5e2b0e55d43f4d974a769df66afb34e8aecbb329d3f15", } @@ -384,7 +380,7 @@ func (s *ScpNomination) DecodeFrom(d *xdr.Decoder, maxDepth uint) (int, error) { return n, fmt.Errorf("decoding Value: length (%d) exceeds remaining input length (%d)", l, il) } s.Votes = make([]Value, l) - for i := uint32(0); uint(i) < uint(l); i++ { + for i := uint32(0); i < l; i++ { nTmp, err = s.Votes[i].DecodeFrom(d, maxDepth) n += nTmp if err != nil { @@ -403,7 +399,7 @@ func (s *ScpNomination) DecodeFrom(d *xdr.Decoder, maxDepth uint) (int, error) { return n, fmt.Errorf("decoding Value: length (%d) exceeds remaining input length (%d)", l, il) } s.Accepted = make([]Value, l) - for i := uint32(0); uint(i) < uint(l); i++ { + for i := uint32(0); i < l; i++ { nTmp, err = s.Accepted[i].DecodeFrom(d, maxDepth) n += nTmp if err != nil { @@ -1344,7 +1340,7 @@ func (s *ScpQuorumSet) DecodeFrom(d *xdr.Decoder, maxDepth uint) (int, error) { return n, fmt.Errorf("decoding NodeId: length (%d) exceeds remaining input length (%d)", l, il) } s.Validators = make([]NodeId, l) - for i := uint32(0); uint(i) < uint(l); i++ { + for i := uint32(0); i < l; i++ { nTmp, err = s.Validators[i].DecodeFrom(d, maxDepth) n += nTmp if err != nil { @@ -1363,7 +1359,7 @@ func (s *ScpQuorumSet) DecodeFrom(d *xdr.Decoder, maxDepth uint) (int, error) { return n, fmt.Errorf("decoding ScpQuorumSet: length (%d) exceeds remaining input length (%d)", l, il) } s.InnerSets = make([]ScpQuorumSet, l) - for i := uint32(0); uint(i) < uint(l); i++ { + for i := uint32(0); i < l; i++ { nTmp, err = s.InnerSets[i].DecodeFrom(d, maxDepth) n += nTmp if err != nil { @@ -3444,7 +3440,7 @@ func (s *AccountEntryExtensionV2) DecodeFrom(d *xdr.Decoder, maxDepth uint) (int return n, fmt.Errorf("decoding SponsorshipDescriptor: length (%d) exceeds remaining input length (%d)", l, il) } s.SignerSponsoringIDs = make([]SponsorshipDescriptor, l) - for i := uint32(0); uint(i) < uint(l); i++ { + for i := uint32(0); i < l; i++ { var eb bool eb, nTmp, err = d.DecodeBool() n += nTmp @@ -4049,7 +4045,7 @@ func (s *AccountEntry) DecodeFrom(d *xdr.Decoder, maxDepth uint) (int, error) { return n, fmt.Errorf("decoding Signer: length (%d) exceeds remaining input length (%d)", l, il) } s.Signers = make([]Signer, l) - for i := uint32(0); uint(i) < uint(l); i++ { + for i := uint32(0); i < l; i++ { nTmp, err = s.Signers[i].DecodeFrom(d, maxDepth) n += nTmp if err != nil { @@ -6225,7 +6221,7 @@ func (u *ClaimPredicate) DecodeFrom(d *xdr.Decoder, maxDepth uint) (int, error) return n, fmt.Errorf("decoding ClaimPredicate: length (%d) exceeds remaining input length (%d)", l, il) } (*u.AndPredicates) = make([]ClaimPredicate, l) - for i := uint32(0); uint(i) < uint(l); i++ { + for i := uint32(0); i < l; i++ { nTmp, err = (*u.AndPredicates)[i].DecodeFrom(d, maxDepth) n += nTmp if err != nil { @@ -6251,7 +6247,7 @@ func (u *ClaimPredicate) DecodeFrom(d *xdr.Decoder, maxDepth uint) (int, error) return n, fmt.Errorf("decoding ClaimPredicate: length (%d) exceeds remaining input length (%d)", l, il) } (*u.OrPredicates) = make([]ClaimPredicate, l) - for i := uint32(0); uint(i) < uint(l); i++ { + for i := uint32(0); i < l; i++ { nTmp, err = (*u.OrPredicates)[i].DecodeFrom(d, maxDepth) n += nTmp if err != nil { @@ -7372,7 +7368,7 @@ func (s *ClaimableBalanceEntry) DecodeFrom(d *xdr.Decoder, maxDepth uint) (int, return n, fmt.Errorf("decoding Claimant: length (%d) exceeds remaining input length (%d)", l, il) } s.Claimants = make([]Claimant, l) - for i := uint32(0); uint(i) < uint(l); i++ { + for i := uint32(0); i < l; i++ { nTmp, err = s.Claimants[i].DecodeFrom(d, maxDepth) n += nTmp if err != nil { @@ -11180,7 +11176,7 @@ func (s *StellarValue) DecodeFrom(d *xdr.Decoder, maxDepth uint) (int, error) { return n, fmt.Errorf("decoding UpgradeType: length (%d) exceeds remaining input length (%d)", l, il) } s.Upgrades = make([]UpgradeType, l) - for i := uint32(0); uint(i) < uint(l); i++ { + for i := uint32(0); i < l; i++ { nTmp, err = s.Upgrades[i].DecodeFrom(d, maxDepth) n += nTmp if err != nil { @@ -12550,7 +12546,7 @@ func (s *ConfigUpgradeSet) DecodeFrom(d *xdr.Decoder, maxDepth uint) (int, error return n, fmt.Errorf("decoding ConfigSettingEntry: length (%d) exceeds remaining input length (%d)", l, il) } s.UpdatedEntry = make([]ConfigSettingEntry, l) - for i := uint32(0); uint(i) < uint(l); i++ { + for i := uint32(0); i < l; i++ { nTmp, err = s.UpdatedEntry[i].DecodeFrom(d, maxDepth) n += nTmp if err != nil { @@ -13292,7 +13288,7 @@ func (s *TxSetComponentTxsMaybeDiscountedFee) DecodeFrom(d *xdr.Decoder, maxDept return n, fmt.Errorf("decoding TransactionEnvelope: length (%d) exceeds remaining input length (%d)", l, il) } s.Txs = make([]TransactionEnvelope, l) - for i := uint32(0); uint(i) < uint(l); i++ { + for i := uint32(0); i < l; i++ { nTmp, err = s.Txs[i].DecodeFrom(d, maxDepth) n += nTmp if err != nil { @@ -13594,7 +13590,7 @@ func (u *TransactionPhase) DecodeFrom(d *xdr.Decoder, maxDepth uint) (int, error return n, fmt.Errorf("decoding TxSetComponent: length (%d) exceeds remaining input length (%d)", l, il) } (*u.V0Components) = make([]TxSetComponent, l) - for i := uint32(0); uint(i) < uint(l); i++ { + for i := uint32(0); i < l; i++ { nTmp, err = (*u.V0Components)[i].DecodeFrom(d, maxDepth) n += nTmp if err != nil { @@ -13691,7 +13687,7 @@ func (s *TransactionSet) DecodeFrom(d *xdr.Decoder, maxDepth uint) (int, error) return n, fmt.Errorf("decoding TransactionEnvelope: length (%d) exceeds remaining input length (%d)", l, il) } s.Txs = make([]TransactionEnvelope, l) - for i := uint32(0); uint(i) < uint(l); i++ { + for i := uint32(0); i < l; i++ { nTmp, err = s.Txs[i].DecodeFrom(d, maxDepth) n += nTmp if err != nil { @@ -13786,7 +13782,7 @@ func (s *TransactionSetV1) DecodeFrom(d *xdr.Decoder, maxDepth uint) (int, error return n, fmt.Errorf("decoding TransactionPhase: length (%d) exceeds remaining input length (%d)", l, il) } s.Phases = make([]TransactionPhase, l) - for i := uint32(0); uint(i) < uint(l); i++ { + for i := uint32(0); i < l; i++ { nTmp, err = s.Phases[i].DecodeFrom(d, maxDepth) n += nTmp if err != nil { @@ -14087,7 +14083,7 @@ func (s *TransactionResultSet) DecodeFrom(d *xdr.Decoder, maxDepth uint) (int, e return n, fmt.Errorf("decoding TransactionResultPair: length (%d) exceeds remaining input length (%d)", l, il) } s.Results = make([]TransactionResultPair, l) - for i := uint32(0); uint(i) < uint(l); i++ { + for i := uint32(0); i < l; i++ { nTmp, err = s.Results[i].DecodeFrom(d, maxDepth) n += nTmp if err != nil { @@ -14816,7 +14812,7 @@ func (s *LedgerScpMessages) DecodeFrom(d *xdr.Decoder, maxDepth uint) (int, erro return n, fmt.Errorf("decoding ScpEnvelope: length (%d) exceeds remaining input length (%d)", l, il) } s.Messages = make([]ScpEnvelope, l) - for i := uint32(0); uint(i) < uint(l); i++ { + for i := uint32(0); i < l; i++ { nTmp, err = s.Messages[i].DecodeFrom(d, maxDepth) n += nTmp if err != nil { @@ -14906,7 +14902,7 @@ func (s *ScpHistoryEntryV0) DecodeFrom(d *xdr.Decoder, maxDepth uint) (int, erro return n, fmt.Errorf("decoding ScpQuorumSet: length (%d) exceeds remaining input length (%d)", l, il) } s.QuorumSets = make([]ScpQuorumSet, l) - for i := uint32(0); uint(i) < uint(l); i++ { + for i := uint32(0); i < l; i++ { nTmp, err = s.QuorumSets[i].DecodeFrom(d, maxDepth) n += nTmp if err != nil { @@ -15515,7 +15511,7 @@ func (s *LedgerEntryChanges) DecodeFrom(d *xdr.Decoder, maxDepth uint) (int, err return n, fmt.Errorf("decoding LedgerEntryChange: length (%d) exceeds remaining input length (%d)", l, il) } (*s) = make([]LedgerEntryChange, l) - for i := uint32(0); uint(i) < uint(l); i++ { + for i := uint32(0); i < l; i++ { nTmp, err = (*s)[i].DecodeFrom(d, maxDepth) n += nTmp if err != nil { @@ -15675,7 +15671,7 @@ func (s *TransactionMetaV1) DecodeFrom(d *xdr.Decoder, maxDepth uint) (int, erro return n, fmt.Errorf("decoding OperationMeta: length (%d) exceeds remaining input length (%d)", l, il) } s.Operations = make([]OperationMeta, l) - for i := uint32(0); uint(i) < uint(l); i++ { + for i := uint32(0); i < l; i++ { nTmp, err = s.Operations[i].DecodeFrom(d, maxDepth) n += nTmp if err != nil { @@ -15777,7 +15773,7 @@ func (s *TransactionMetaV2) DecodeFrom(d *xdr.Decoder, maxDepth uint) (int, erro return n, fmt.Errorf("decoding OperationMeta: length (%d) exceeds remaining input length (%d)", l, il) } s.Operations = make([]OperationMeta, l) - for i := uint32(0); uint(i) < uint(l); i++ { + for i := uint32(0); i < l; i++ { nTmp, err = s.Operations[i].DecodeFrom(d, maxDepth) n += nTmp if err != nil { @@ -15963,7 +15959,7 @@ func (s *ContractEventV0) DecodeFrom(d *xdr.Decoder, maxDepth uint) (int, error) return n, fmt.Errorf("decoding ScVal: length (%d) exceeds remaining input length (%d)", l, il) } s.Topics = make([]ScVal, l) - for i := uint32(0); uint(i) < uint(l); i++ { + for i := uint32(0); i < l; i++ { nTmp, err = s.Topics[i].DecodeFrom(d, maxDepth) n += nTmp if err != nil { @@ -16426,7 +16422,7 @@ func (s *SorobanTransactionMeta) DecodeFrom(d *xdr.Decoder, maxDepth uint) (int, return n, fmt.Errorf("decoding ContractEvent: length (%d) exceeds remaining input length (%d)", l, il) } s.Events = make([]ContractEvent, l) - for i := uint32(0); uint(i) < uint(l); i++ { + for i := uint32(0); i < l; i++ { nTmp, err = s.Events[i].DecodeFrom(d, maxDepth) n += nTmp if err != nil { @@ -16450,7 +16446,7 @@ func (s *SorobanTransactionMeta) DecodeFrom(d *xdr.Decoder, maxDepth uint) (int, return n, fmt.Errorf("decoding DiagnosticEvent: length (%d) exceeds remaining input length (%d)", l, il) } s.DiagnosticEvents = make([]DiagnosticEvent, l) - for i := uint32(0); uint(i) < uint(l); i++ { + for i := uint32(0); i < l; i++ { nTmp, err = s.DiagnosticEvents[i].DecodeFrom(d, maxDepth) n += nTmp if err != nil { @@ -16574,7 +16570,7 @@ func (s *TransactionMetaV3) DecodeFrom(d *xdr.Decoder, maxDepth uint) (int, erro return n, fmt.Errorf("decoding OperationMeta: length (%d) exceeds remaining input length (%d)", l, il) } s.Operations = make([]OperationMeta, l) - for i := uint32(0); uint(i) < uint(l); i++ { + for i := uint32(0); i < l; i++ { nTmp, err = s.Operations[i].DecodeFrom(d, maxDepth) n += nTmp if err != nil { @@ -16689,7 +16685,7 @@ func (s *InvokeHostFunctionSuccessPreImage) DecodeFrom(d *xdr.Decoder, maxDepth return n, fmt.Errorf("decoding ContractEvent: length (%d) exceeds remaining input length (%d)", l, il) } s.Events = make([]ContractEvent, l) - for i := uint32(0); uint(i) < uint(l); i++ { + for i := uint32(0); i < l; i++ { nTmp, err = s.Events[i].DecodeFrom(d, maxDepth) n += nTmp if err != nil { @@ -16973,7 +16969,7 @@ func (u *TransactionMeta) DecodeFrom(d *xdr.Decoder, maxDepth uint) (int, error) return n, fmt.Errorf("decoding OperationMeta: length (%d) exceeds remaining input length (%d)", l, il) } (*u.Operations) = make([]OperationMeta, l) - for i := uint32(0); uint(i) < uint(l); i++ { + for i := uint32(0); i < l; i++ { nTmp, err = (*u.Operations)[i].DecodeFrom(d, maxDepth) n += nTmp if err != nil { @@ -17293,7 +17289,7 @@ func (s *LedgerCloseMetaV0) DecodeFrom(d *xdr.Decoder, maxDepth uint) (int, erro return n, fmt.Errorf("decoding TransactionResultMeta: length (%d) exceeds remaining input length (%d)", l, il) } s.TxProcessing = make([]TransactionResultMeta, l) - for i := uint32(0); uint(i) < uint(l); i++ { + for i := uint32(0); i < l; i++ { nTmp, err = s.TxProcessing[i].DecodeFrom(d, maxDepth) n += nTmp if err != nil { @@ -17312,7 +17308,7 @@ func (s *LedgerCloseMetaV0) DecodeFrom(d *xdr.Decoder, maxDepth uint) (int, erro return n, fmt.Errorf("decoding UpgradeEntryMeta: length (%d) exceeds remaining input length (%d)", l, il) } s.UpgradesProcessing = make([]UpgradeEntryMeta, l) - for i := uint32(0); uint(i) < uint(l); i++ { + for i := uint32(0); i < l; i++ { nTmp, err = s.UpgradesProcessing[i].DecodeFrom(d, maxDepth) n += nTmp if err != nil { @@ -17331,7 +17327,7 @@ func (s *LedgerCloseMetaV0) DecodeFrom(d *xdr.Decoder, maxDepth uint) (int, erro return n, fmt.Errorf("decoding ScpHistoryEntry: length (%d) exceeds remaining input length (%d)", l, il) } s.ScpInfo = make([]ScpHistoryEntry, l) - for i := uint32(0); uint(i) < uint(l); i++ { + for i := uint32(0); i < l; i++ { nTmp, err = s.ScpInfo[i].DecodeFrom(d, maxDepth) n += nTmp if err != nil { @@ -17511,7 +17507,7 @@ func (s *LedgerCloseMetaV1) DecodeFrom(d *xdr.Decoder, maxDepth uint) (int, erro return n, fmt.Errorf("decoding TransactionResultMeta: length (%d) exceeds remaining input length (%d)", l, il) } s.TxProcessing = make([]TransactionResultMeta, l) - for i := uint32(0); uint(i) < uint(l); i++ { + for i := uint32(0); i < l; i++ { nTmp, err = s.TxProcessing[i].DecodeFrom(d, maxDepth) n += nTmp if err != nil { @@ -17530,7 +17526,7 @@ func (s *LedgerCloseMetaV1) DecodeFrom(d *xdr.Decoder, maxDepth uint) (int, erro return n, fmt.Errorf("decoding UpgradeEntryMeta: length (%d) exceeds remaining input length (%d)", l, il) } s.UpgradesProcessing = make([]UpgradeEntryMeta, l) - for i := uint32(0); uint(i) < uint(l); i++ { + for i := uint32(0); i < l; i++ { nTmp, err = s.UpgradesProcessing[i].DecodeFrom(d, maxDepth) n += nTmp if err != nil { @@ -17549,7 +17545,7 @@ func (s *LedgerCloseMetaV1) DecodeFrom(d *xdr.Decoder, maxDepth uint) (int, erro return n, fmt.Errorf("decoding ScpHistoryEntry: length (%d) exceeds remaining input length (%d)", l, il) } s.ScpInfo = make([]ScpHistoryEntry, l) - for i := uint32(0); uint(i) < uint(l); i++ { + for i := uint32(0); i < l; i++ { nTmp, err = s.ScpInfo[i].DecodeFrom(d, maxDepth) n += nTmp if err != nil { @@ -17573,7 +17569,7 @@ func (s *LedgerCloseMetaV1) DecodeFrom(d *xdr.Decoder, maxDepth uint) (int, erro return n, fmt.Errorf("decoding LedgerKey: length (%d) exceeds remaining input length (%d)", l, il) } s.EvictedTemporaryLedgerKeys = make([]LedgerKey, l) - for i := uint32(0); uint(i) < uint(l); i++ { + for i := uint32(0); i < l; i++ { nTmp, err = s.EvictedTemporaryLedgerKeys[i].DecodeFrom(d, maxDepth) n += nTmp if err != nil { @@ -17592,7 +17588,7 @@ func (s *LedgerCloseMetaV1) DecodeFrom(d *xdr.Decoder, maxDepth uint) (int, erro return n, fmt.Errorf("decoding LedgerEntry: length (%d) exceeds remaining input length (%d)", l, il) } s.EvictedPersistentLedgerEntries = make([]LedgerEntry, l) - for i := uint32(0); uint(i) < uint(l); i++ { + for i := uint32(0); i < l; i++ { nTmp, err = s.EvictedPersistentLedgerEntries[i].DecodeFrom(d, maxDepth) n += nTmp if err != nil { @@ -19884,7 +19880,7 @@ func (s *PeerStatList) DecodeFrom(d *xdr.Decoder, maxDepth uint) (int, error) { return n, fmt.Errorf("decoding PeerStats: length (%d) exceeds remaining input length (%d)", l, il) } (*s) = make([]PeerStats, l) - for i := uint32(0); uint(i) < uint(l); i++ { + for i := uint32(0); i < l; i++ { nTmp, err = (*s)[i].DecodeFrom(d, maxDepth) n += nTmp if err != nil { @@ -20380,7 +20376,7 @@ func (s *TxAdvertVector) DecodeFrom(d *xdr.Decoder, maxDepth uint) (int, error) return n, fmt.Errorf("decoding Hash: length (%d) exceeds remaining input length (%d)", l, il) } (*s) = make([]Hash, l) - for i := uint32(0); uint(i) < uint(l); i++ { + for i := uint32(0); i < l; i++ { nTmp, err = (*s)[i].DecodeFrom(d, maxDepth) n += nTmp if err != nil { @@ -20538,7 +20534,7 @@ func (s *TxDemandVector) DecodeFrom(d *xdr.Decoder, maxDepth uint) (int, error) return n, fmt.Errorf("decoding Hash: length (%d) exceeds remaining input length (%d)", l, il) } (*s) = make([]Hash, l) - for i := uint32(0); uint(i) < uint(l); i++ { + for i := uint32(0); i < l; i++ { nTmp, err = (*s)[i].DecodeFrom(d, maxDepth) n += nTmp if err != nil { @@ -21571,7 +21567,7 @@ func (u *StellarMessage) DecodeFrom(d *xdr.Decoder, maxDepth uint) (int, error) return n, fmt.Errorf("decoding PeerAddress: length (%d) exceeds remaining input length (%d)", l, il) } (*u.Peers) = make([]PeerAddress, l) - for i := uint32(0); uint(i) < uint(l); i++ { + for i := uint32(0); i < l; i++ { nTmp, err = (*u.Peers)[i].DecodeFrom(d, maxDepth) n += nTmp if err != nil { @@ -22869,7 +22865,7 @@ func (s *PathPaymentStrictReceiveOp) DecodeFrom(d *xdr.Decoder, maxDepth uint) ( return n, fmt.Errorf("decoding Asset: length (%d) exceeds remaining input length (%d)", l, il) } s.Path = make([]Asset, l) - for i := uint32(0); uint(i) < uint(l); i++ { + for i := uint32(0); i < l; i++ { nTmp, err = s.Path[i].DecodeFrom(d, maxDepth) n += nTmp if err != nil { @@ -23011,7 +23007,7 @@ func (s *PathPaymentStrictSendOp) DecodeFrom(d *xdr.Decoder, maxDepth uint) (int return n, fmt.Errorf("decoding Asset: length (%d) exceeds remaining input length (%d)", l, il) } s.Path = make([]Asset, l) - for i := uint32(0); uint(i) < uint(l); i++ { + for i := uint32(0); i < l; i++ { nTmp, err = s.Path[i].DecodeFrom(d, maxDepth) n += nTmp if err != nil { @@ -24284,7 +24280,7 @@ func (s *CreateClaimableBalanceOp) DecodeFrom(d *xdr.Decoder, maxDepth uint) (in return n, fmt.Errorf("decoding Claimant: length (%d) exceeds remaining input length (%d)", l, il) } s.Claimants = make([]Claimant, l) - for i := uint32(0); uint(i) < uint(l); i++ { + for i := uint32(0); i < l; i++ { nTmp, err = s.Claimants[i].DecodeFrom(d, maxDepth) n += nTmp if err != nil { @@ -25849,7 +25845,7 @@ func (s *InvokeContractArgs) DecodeFrom(d *xdr.Decoder, maxDepth uint) (int, err return n, fmt.Errorf("decoding ScVal: length (%d) exceeds remaining input length (%d)", l, il) } s.Args = make([]ScVal, l) - for i := uint32(0); uint(i) < uint(l); i++ { + for i := uint32(0); i < l; i++ { nTmp, err = s.Args[i].DecodeFrom(d, maxDepth) n += nTmp if err != nil { @@ -26462,7 +26458,7 @@ func (s *SorobanAuthorizedInvocation) DecodeFrom(d *xdr.Decoder, maxDepth uint) return n, fmt.Errorf("decoding SorobanAuthorizedInvocation: length (%d) exceeds remaining input length (%d)", l, il) } s.SubInvocations = make([]SorobanAuthorizedInvocation, l) - for i := uint32(0); uint(i) < uint(l); i++ { + for i := uint32(0); i < l; i++ { nTmp, err = s.SubInvocations[i].DecodeFrom(d, maxDepth) n += nTmp if err != nil { @@ -26969,7 +26965,7 @@ func (s *InvokeHostFunctionOp) DecodeFrom(d *xdr.Decoder, maxDepth uint) (int, e return n, fmt.Errorf("decoding SorobanAuthorizationEntry: length (%d) exceeds remaining input length (%d)", l, il) } s.Auth = make([]SorobanAuthorizationEntry, l) - for i := uint32(0); uint(i) < uint(l); i++ { + for i := uint32(0); i < l; i++ { nTmp, err = s.Auth[i].DecodeFrom(d, maxDepth) n += nTmp if err != nil { @@ -30049,7 +30045,7 @@ func (s *PreconditionsV2) DecodeFrom(d *xdr.Decoder, maxDepth uint) (int, error) return n, fmt.Errorf("decoding SignerKey: length (%d) exceeds remaining input length (%d)", l, il) } s.ExtraSigners = make([]SignerKey, l) - for i := uint32(0); uint(i) < uint(l); i++ { + for i := uint32(0); i < l; i++ { nTmp, err = s.ExtraSigners[i].DecodeFrom(d, maxDepth) n += nTmp if err != nil { @@ -30437,7 +30433,7 @@ func (s *LedgerFootprint) DecodeFrom(d *xdr.Decoder, maxDepth uint) (int, error) return n, fmt.Errorf("decoding LedgerKey: length (%d) exceeds remaining input length (%d)", l, il) } s.ReadOnly = make([]LedgerKey, l) - for i := uint32(0); uint(i) < uint(l); i++ { + for i := uint32(0); i < l; i++ { nTmp, err = s.ReadOnly[i].DecodeFrom(d, maxDepth) n += nTmp if err != nil { @@ -30456,7 +30452,7 @@ func (s *LedgerFootprint) DecodeFrom(d *xdr.Decoder, maxDepth uint) (int, error) return n, fmt.Errorf("decoding LedgerKey: length (%d) exceeds remaining input length (%d)", l, il) } s.ReadWrite = make([]LedgerKey, l) - for i := uint32(0); uint(i) < uint(l); i++ { + for i := uint32(0); i < l; i++ { nTmp, err = s.ReadWrite[i].DecodeFrom(d, maxDepth) n += nTmp if err != nil { @@ -30915,7 +30911,7 @@ func (s *TransactionV0) DecodeFrom(d *xdr.Decoder, maxDepth uint) (int, error) { return n, fmt.Errorf("decoding Operation: length (%d) exceeds remaining input length (%d)", l, il) } s.Operations = make([]Operation, l) - for i := uint32(0); uint(i) < uint(l); i++ { + for i := uint32(0); i < l; i++ { nTmp, err = s.Operations[i].DecodeFrom(d, maxDepth) n += nTmp if err != nil { @@ -31020,7 +31016,7 @@ func (s *TransactionV0Envelope) DecodeFrom(d *xdr.Decoder, maxDepth uint) (int, return n, fmt.Errorf("decoding DecoratedSignature: length (%d) exceeds remaining input length (%d)", l, il) } s.Signatures = make([]DecoratedSignature, l) - for i := uint32(0); uint(i) < uint(l); i++ { + for i := uint32(0); i < l; i++ { nTmp, err = s.Signatures[i].DecodeFrom(d, maxDepth) n += nTmp if err != nil { @@ -31333,7 +31329,7 @@ func (s *Transaction) DecodeFrom(d *xdr.Decoder, maxDepth uint) (int, error) { return n, fmt.Errorf("decoding Operation: length (%d) exceeds remaining input length (%d)", l, il) } s.Operations = make([]Operation, l) - for i := uint32(0); uint(i) < uint(l); i++ { + for i := uint32(0); i < l; i++ { nTmp, err = s.Operations[i].DecodeFrom(d, maxDepth) n += nTmp if err != nil { @@ -31438,7 +31434,7 @@ func (s *TransactionV1Envelope) DecodeFrom(d *xdr.Decoder, maxDepth uint) (int, return n, fmt.Errorf("decoding DecoratedSignature: length (%d) exceeds remaining input length (%d)", l, il) } s.Signatures = make([]DecoratedSignature, l) - for i := uint32(0); uint(i) < uint(l); i++ { + for i := uint32(0); i < l; i++ { nTmp, err = s.Signatures[i].DecodeFrom(d, maxDepth) n += nTmp if err != nil { @@ -31885,7 +31881,7 @@ func (s *FeeBumpTransactionEnvelope) DecodeFrom(d *xdr.Decoder, maxDepth uint) ( return n, fmt.Errorf("decoding DecoratedSignature: length (%d) exceeds remaining input length (%d)", l, il) } s.Signatures = make([]DecoratedSignature, l) - for i := uint32(0); uint(i) < uint(l); i++ { + for i := uint32(0); i < l; i++ { nTmp, err = s.Signatures[i].DecodeFrom(d, maxDepth) n += nTmp if err != nil { @@ -33952,7 +33948,7 @@ func (s *PathPaymentStrictReceiveResultSuccess) DecodeFrom(d *xdr.Decoder, maxDe return n, fmt.Errorf("decoding ClaimAtom: length (%d) exceeds remaining input length (%d)", l, il) } s.Offers = make([]ClaimAtom, l) - for i := uint32(0); uint(i) < uint(l); i++ { + for i := uint32(0); i < l; i++ { nTmp, err = s.Offers[i].DecodeFrom(d, maxDepth) n += nTmp if err != nil { @@ -34497,7 +34493,7 @@ func (s *PathPaymentStrictSendResultSuccess) DecodeFrom(d *xdr.Decoder, maxDepth return n, fmt.Errorf("decoding ClaimAtom: length (%d) exceeds remaining input length (%d)", l, il) } s.Offers = make([]ClaimAtom, l) - for i := uint32(0); uint(i) < uint(l); i++ { + for i := uint32(0); i < l; i++ { nTmp, err = s.Offers[i].DecodeFrom(d, maxDepth) n += nTmp if err != nil { @@ -35316,7 +35312,7 @@ func (s *ManageOfferSuccessResult) DecodeFrom(d *xdr.Decoder, maxDepth uint) (in return n, fmt.Errorf("decoding ClaimAtom: length (%d) exceeds remaining input length (%d)", l, il) } s.OffersClaimed = make([]ClaimAtom, l) - for i := uint32(0); uint(i) < uint(l); i++ { + for i := uint32(0); i < l; i++ { nTmp, err = s.OffersClaimed[i].DecodeFrom(d, maxDepth) n += nTmp if err != nil { @@ -37567,7 +37563,7 @@ func (u *InflationResult) DecodeFrom(d *xdr.Decoder, maxDepth uint) (int, error) return n, fmt.Errorf("decoding InflationPayout: length (%d) exceeds remaining input length (%d)", l, il) } (*u.Payouts) = make([]InflationPayout, l) - for i := uint32(0); uint(i) < uint(l); i++ { + for i := uint32(0); i < l; i++ { nTmp, err = (*u.Payouts)[i].DecodeFrom(d, maxDepth) n += nTmp if err != nil { @@ -43597,7 +43593,7 @@ func (u *InnerTransactionResultResult) DecodeFrom(d *xdr.Decoder, maxDepth uint) return n, fmt.Errorf("decoding OperationResult: length (%d) exceeds remaining input length (%d)", l, il) } (*u.Results) = make([]OperationResult, l) - for i := uint32(0); uint(i) < uint(l); i++ { + for i := uint32(0); i < l; i++ { nTmp, err = (*u.Results)[i].DecodeFrom(d, maxDepth) n += nTmp if err != nil { @@ -43620,7 +43616,7 @@ func (u *InnerTransactionResultResult) DecodeFrom(d *xdr.Decoder, maxDepth uint) return n, fmt.Errorf("decoding OperationResult: length (%d) exceeds remaining input length (%d)", l, il) } (*u.Results) = make([]OperationResult, l) - for i := uint32(0); uint(i) < uint(l); i++ { + for i := uint32(0); i < l; i++ { nTmp, err = (*u.Results)[i].DecodeFrom(d, maxDepth) n += nTmp if err != nil { @@ -44335,7 +44331,7 @@ func (u *TransactionResultResult) DecodeFrom(d *xdr.Decoder, maxDepth uint) (int return n, fmt.Errorf("decoding OperationResult: length (%d) exceeds remaining input length (%d)", l, il) } (*u.Results) = make([]OperationResult, l) - for i := uint32(0); uint(i) < uint(l); i++ { + for i := uint32(0); i < l; i++ { nTmp, err = (*u.Results)[i].DecodeFrom(d, maxDepth) n += nTmp if err != nil { @@ -44358,7 +44354,7 @@ func (u *TransactionResultResult) DecodeFrom(d *xdr.Decoder, maxDepth uint) (int return n, fmt.Errorf("decoding OperationResult: length (%d) exceeds remaining input length (%d)", l, il) } (*u.Results) = make([]OperationResult, l) - for i := uint32(0); uint(i) < uint(l); i++ { + for i := uint32(0); i < l; i++ { nTmp, err = (*u.Results)[i].DecodeFrom(d, maxDepth) n += nTmp if err != nil { @@ -47652,7 +47648,7 @@ func (s *ScSpecTypeTuple) DecodeFrom(d *xdr.Decoder, maxDepth uint) (int, error) return n, fmt.Errorf("decoding ScSpecTypeDef: length (%d) exceeds remaining input length (%d)", l, il) } s.ValueTypes = make([]ScSpecTypeDef, l) - for i := uint32(0); uint(i) < uint(l); i++ { + for i := uint32(0); i < l; i++ { nTmp, err = s.ValueTypes[i].DecodeFrom(d, maxDepth) n += nTmp if err != nil { @@ -48624,7 +48620,7 @@ func (s *ScSpecUdtStructV0) DecodeFrom(d *xdr.Decoder, maxDepth uint) (int, erro return n, fmt.Errorf("decoding ScSpecUdtStructFieldV0: length (%d) exceeds remaining input length (%d)", l, il) } s.Fields = make([]ScSpecUdtStructFieldV0, l) - for i := uint32(0); uint(i) < uint(l); i++ { + for i := uint32(0); i < l; i++ { nTmp, err = s.Fields[i].DecodeFrom(d, maxDepth) n += nTmp if err != nil { @@ -48807,7 +48803,7 @@ func (s *ScSpecUdtUnionCaseTupleV0) DecodeFrom(d *xdr.Decoder, maxDepth uint) (i return n, fmt.Errorf("decoding ScSpecTypeDef: length (%d) exceeds remaining input length (%d)", l, il) } s.Type = make([]ScSpecTypeDef, l) - for i := uint32(0); uint(i) < uint(l); i++ { + for i := uint32(0); i < l; i++ { nTmp, err = s.Type[i].DecodeFrom(d, maxDepth) n += nTmp if err != nil { @@ -49203,7 +49199,7 @@ func (s *ScSpecUdtUnionV0) DecodeFrom(d *xdr.Decoder, maxDepth uint) (int, error return n, fmt.Errorf("decoding ScSpecUdtUnionCaseV0: length (%d) exceeds remaining input length (%d)", l, il) } s.Cases = make([]ScSpecUdtUnionCaseV0, l) - for i := uint32(0); uint(i) < uint(l); i++ { + for i := uint32(0); i < l; i++ { nTmp, err = s.Cases[i].DecodeFrom(d, maxDepth) n += nTmp if err != nil { @@ -49406,7 +49402,7 @@ func (s *ScSpecUdtEnumV0) DecodeFrom(d *xdr.Decoder, maxDepth uint) (int, error) return n, fmt.Errorf("decoding ScSpecUdtEnumCaseV0: length (%d) exceeds remaining input length (%d)", l, il) } s.Cases = make([]ScSpecUdtEnumCaseV0, l) - for i := uint32(0); uint(i) < uint(l); i++ { + for i := uint32(0); i < l; i++ { nTmp, err = s.Cases[i].DecodeFrom(d, maxDepth) n += nTmp if err != nil { @@ -49609,7 +49605,7 @@ func (s *ScSpecUdtErrorEnumV0) DecodeFrom(d *xdr.Decoder, maxDepth uint) (int, e return n, fmt.Errorf("decoding ScSpecUdtErrorEnumCaseV0: length (%d) exceeds remaining input length (%d)", l, il) } s.Cases = make([]ScSpecUdtErrorEnumCaseV0, l) - for i := uint32(0); uint(i) < uint(l); i++ { + for i := uint32(0); i < l; i++ { nTmp, err = s.Cases[i].DecodeFrom(d, maxDepth) n += nTmp if err != nil { @@ -49812,7 +49808,7 @@ func (s *ScSpecFunctionV0) DecodeFrom(d *xdr.Decoder, maxDepth uint) (int, error return n, fmt.Errorf("decoding ScSpecFunctionInputV0: length (%d) exceeds remaining input length (%d)", l, il) } s.Inputs = make([]ScSpecFunctionInputV0, l) - for i := uint32(0); uint(i) < uint(l); i++ { + for i := uint32(0); i < l; i++ { nTmp, err = s.Inputs[i].DecodeFrom(d, maxDepth) n += nTmp if err != nil { @@ -49834,7 +49830,7 @@ func (s *ScSpecFunctionV0) DecodeFrom(d *xdr.Decoder, maxDepth uint) (int, error return n, fmt.Errorf("decoding ScSpecTypeDef: length (%d) exceeds remaining input length (%d)", l, il) } s.Outputs = make([]ScSpecTypeDef, l) - for i := uint32(0); uint(i) < uint(l); i++ { + for i := uint32(0); i < l; i++ { nTmp, err = s.Outputs[i].DecodeFrom(d, maxDepth) n += nTmp if err != nil { @@ -51985,7 +51981,7 @@ func (s *ScVec) DecodeFrom(d *xdr.Decoder, maxDepth uint) (int, error) { return n, fmt.Errorf("decoding ScVal: length (%d) exceeds remaining input length (%d)", l, il) } (*s) = make([]ScVal, l) - for i := uint32(0); uint(i) < uint(l); i++ { + for i := uint32(0); i < l; i++ { nTmp, err = (*s)[i].DecodeFrom(d, maxDepth) n += nTmp if err != nil { @@ -52065,7 +52061,7 @@ func (s *ScMap) DecodeFrom(d *xdr.Decoder, maxDepth uint) (int, error) { return n, fmt.Errorf("decoding ScMapEntry: length (%d) exceeds remaining input length (%d)", l, il) } (*s) = make([]ScMapEntry, l) - for i := uint32(0); uint(i) < uint(l); i++ { + for i := uint32(0); i < l; i++ { nTmp, err = (*s)[i].DecodeFrom(d, maxDepth) n += nTmp if err != nil { @@ -54020,7 +54016,7 @@ func (s *PersistedScpStateV0) DecodeFrom(d *xdr.Decoder, maxDepth uint) (int, er return n, fmt.Errorf("decoding ScpEnvelope: length (%d) exceeds remaining input length (%d)", l, il) } s.ScpEnvelopes = make([]ScpEnvelope, l) - for i := uint32(0); uint(i) < uint(l); i++ { + for i := uint32(0); i < l; i++ { nTmp, err = s.ScpEnvelopes[i].DecodeFrom(d, maxDepth) n += nTmp if err != nil { @@ -54039,7 +54035,7 @@ func (s *PersistedScpStateV0) DecodeFrom(d *xdr.Decoder, maxDepth uint) (int, er return n, fmt.Errorf("decoding ScpQuorumSet: length (%d) exceeds remaining input length (%d)", l, il) } s.QuorumSets = make([]ScpQuorumSet, l) - for i := uint32(0); uint(i) < uint(l); i++ { + for i := uint32(0); i < l; i++ { nTmp, err = s.QuorumSets[i].DecodeFrom(d, maxDepth) n += nTmp if err != nil { @@ -54058,7 +54054,7 @@ func (s *PersistedScpStateV0) DecodeFrom(d *xdr.Decoder, maxDepth uint) (int, er return n, fmt.Errorf("decoding StoredTransactionSet: length (%d) exceeds remaining input length (%d)", l, il) } s.TxSets = make([]StoredTransactionSet, l) - for i := uint32(0); uint(i) < uint(l); i++ { + for i := uint32(0); i < l; i++ { nTmp, err = s.TxSets[i].DecodeFrom(d, maxDepth) n += nTmp if err != nil { @@ -54154,7 +54150,7 @@ func (s *PersistedScpStateV1) DecodeFrom(d *xdr.Decoder, maxDepth uint) (int, er return n, fmt.Errorf("decoding ScpEnvelope: length (%d) exceeds remaining input length (%d)", l, il) } s.ScpEnvelopes = make([]ScpEnvelope, l) - for i := uint32(0); uint(i) < uint(l); i++ { + for i := uint32(0); i < l; i++ { nTmp, err = s.ScpEnvelopes[i].DecodeFrom(d, maxDepth) n += nTmp if err != nil { @@ -54173,7 +54169,7 @@ func (s *PersistedScpStateV1) DecodeFrom(d *xdr.Decoder, maxDepth uint) (int, er return n, fmt.Errorf("decoding ScpQuorumSet: length (%d) exceeds remaining input length (%d)", l, il) } s.QuorumSets = make([]ScpQuorumSet, l) - for i := uint32(0); uint(i) < uint(l); i++ { + for i := uint32(0); i < l; i++ { nTmp, err = s.QuorumSets[i].DecodeFrom(d, maxDepth) n += nTmp if err != nil { @@ -55577,7 +55573,7 @@ func (s *ContractCostParams) DecodeFrom(d *xdr.Decoder, maxDepth uint) (int, err return n, fmt.Errorf("decoding ContractCostParamEntry: length (%d) exceeds remaining input length (%d)", l, il) } (*s) = make([]ContractCostParamEntry, l) - for i := uint32(0); uint(i) < uint(l); i++ { + for i := uint32(0); i < l; i++ { nTmp, err = (*s)[i].DecodeFrom(d, maxDepth) n += nTmp if err != nil { @@ -56501,7 +56497,7 @@ func (u *ConfigSettingEntry) DecodeFrom(d *xdr.Decoder, maxDepth uint) (int, err return n, fmt.Errorf("decoding Uint64: length (%d) exceeds remaining input length (%d)", l, il) } (*u.BucketListSizeWindow) = make([]Uint64, l) - for i := uint32(0); uint(i) < uint(l); i++ { + for i := uint32(0); i < l; i++ { nTmp, err = (*u.BucketListSizeWindow)[i].DecodeFrom(d, maxDepth) n += nTmp if err != nil { From 208a73f6165f59c4eeacf672b6d24659fe54d256 Mon Sep 17 00:00:00 2001 From: tamirms Date: Wed, 6 Dec 2023 19:07:10 +0000 Subject: [PATCH 16/16] Bump Core and soroban-rpc versions (#5137) --- .github/workflows/horizon.yml | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/.github/workflows/horizon.yml b/.github/workflows/horizon.yml index 1a5415f74b..592abe5370 100644 --- a/.github/workflows/horizon.yml +++ b/.github/workflows/horizon.yml @@ -33,9 +33,9 @@ jobs: env: HORIZON_INTEGRATION_TESTS_ENABLED: true HORIZON_INTEGRATION_TESTS_CORE_MAX_SUPPORTED_PROTOCOL: ${{ matrix.protocol-version }} - PROTOCOL_20_CORE_DEBIAN_PKG_VERSION: 19.14.1-1590.b6b730a0c.focal - PROTOCOL_20_CORE_DOCKER_IMG: stellar/unsafe-stellar-core:19.14.1-1590.b6b730a0c.focal - PROTOCOL_20_SOROBAN_RPC_DOCKER_IMG: stellar/soroban-rpc:20.0.0-rc4231129-43 + PROTOCOL_20_CORE_DEBIAN_PKG_VERSION: 20.0.0-1615.617729910.focal + PROTOCOL_20_CORE_DOCKER_IMG: stellar/unsafe-stellar-core:20.0.0-1615.617729910.focal + PROTOCOL_20_SOROBAN_RPC_DOCKER_IMG: stellar/soroban-rpc:20.0.0-tests-45 PROTOCOL_19_CORE_DEBIAN_PKG_VERSION: 19.12.0-1378.2109a168a.focal PROTOCOL_19_CORE_DOCKER_IMG: stellar/stellar-core:19.12.0-1378.2109a168a.focal PGHOST: localhost