Skip to content

Commit

Permalink
Bump XDR
Browse files Browse the repository at this point in the history
  • Loading branch information
2opremio committed Oct 11, 2023
1 parent e50ba18 commit 0faa252
Show file tree
Hide file tree
Showing 37 changed files with 1,060 additions and 1,289 deletions.
2 changes: 1 addition & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ xdr/Stellar-internal.x \
xdr/Stellar-contract-config-setting.x

XDRGEN_COMMIT=a231a92475ac6154c0c2f46dc503809823985060
XDR_COMMIT=9ac02641139e6717924fdad716f6e958d0168491
XDR_COMMIT=bdb81c3710ecb12f0fcc23268b211eb237500019

.PHONY: xdr xdr-clean xdr-update

Expand Down
685 changes: 313 additions & 372 deletions gxdr/xdr_generated.go

Large diffs are not rendered by default.

8 changes: 4 additions & 4 deletions ingest/ledger_change_reader_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down Expand Up @@ -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,
Expand Down
20 changes: 10 additions & 10 deletions ingest/stats_change_processor.go
Original file line number Diff line number Diff line change
Expand Up @@ -51,9 +51,9 @@ type StatsChangeProcessorResults struct {
ConfigSettingsUpdated int64
ConfigSettingsRemoved int64

ExpirationCreated int64
ExpirationUpdated int64
ExpirationRemoved int64
TtlCreated int64

Check failure on line 54 in ingest/stats_change_processor.go

View workflow job for this annotation

GitHub Actions / golangci

ST1003: struct field TtlCreated should be TTLCreated (stylecheck)

Check failure on line 54 in ingest/stats_change_processor.go

View workflow job for this annotation

GitHub Actions / golangci

ST1003: struct field TtlCreated should be TTLCreated (stylecheck)
TtlUpdated int64

Check failure on line 55 in ingest/stats_change_processor.go

View workflow job for this annotation

GitHub Actions / golangci

ST1003: struct field TtlUpdated should be TTLUpdated (stylecheck)

Check failure on line 55 in ingest/stats_change_processor.go

View workflow job for this annotation

GitHub Actions / golangci

ST1003: struct field TtlUpdated should be TTLUpdated (stylecheck)
TtlRemoved int64

Check failure on line 56 in ingest/stats_change_processor.go

View workflow job for this annotation

GitHub Actions / golangci

ST1003: struct field TtlRemoved should be TTLRemoved (stylecheck)

Check failure on line 56 in ingest/stats_change_processor.go

View workflow job for this annotation

GitHub Actions / golangci

ST1003: struct field TtlRemoved should be TTLRemoved (stylecheck)
}

func (p *StatsChangeProcessor) ProcessChange(ctx context.Context, change Change) error {
Expand Down Expand Up @@ -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())
Expand Down Expand Up @@ -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_expiration_created": stats.TtlCreated,
"stats_expiration_updated": stats.TtlUpdated,
"stats_expiration_removed": stats.TtlRemoved,
}
}
6 changes: 3 additions & 3 deletions ingest/stats_change_processor_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand All @@ -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)
Expand All @@ -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()))
}
14 changes: 7 additions & 7 deletions protocols/horizon/operations/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -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",
}

Expand Down Expand Up @@ -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 {

Check failure on line 378 in protocols/horizon/operations/main.go

View workflow job for this annotation

GitHub Actions / golangci

ST1003: type ExtendFootprintTtl should be ExtendFootprintTTL (stylecheck)

Check failure on line 378 in protocols/horizon/operations/main.go

View workflow job for this annotation

GitHub Actions / golangci

ST1003: type ExtendFootprintTtl should be ExtendFootprintTTL (stylecheck)
Base
LedgersToExpire uint32 `json:"ledgers_to_expire"`
ExtendTo uint32 `json:"extend_to"`
}

// RestoreFootprint is the json resource representing a single RestoreFootprint.
Expand Down Expand Up @@ -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
}
Expand Down
18 changes: 9 additions & 9 deletions services/horizon/internal/codes/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down Expand Up @@ -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
}
Expand Down
5 changes: 3 additions & 2 deletions services/horizon/internal/codes/main_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand Down Expand Up @@ -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.
Expand Down
2 changes: 1 addition & 1 deletion services/horizon/internal/ingest/main_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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,
},
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down Expand Up @@ -244,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:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ import (
"encoding/base64"
"encoding/json"
"fmt"

"github.com/guregu/null"

"github.com/stellar/go/amount"
Expand Down Expand Up @@ -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["ledgers_to_expire"] = op.ExtendTo
case xdr.OperationTypeRestoreFootprint:
default:
panic(fmt.Errorf("unknown operation type: %s", operation.OperationType()))
Expand Down Expand Up @@ -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
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -215,7 +215,7 @@ func (s *OperationsProcessorTestSuiteLedger) TestOperationTypeInvokeHostFunction
},
},
Executable: xdr.ContractExecutable{
Type: xdr.ContractExecutableTypeContractExecutableToken,
Type: xdr.ContractExecutableTypeContractExecutableStellarAsset,
},
},
},
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ type StatsLedgerTransactionProcessorResults struct {
OperationsLiquidityPoolDeposit int64
OperationsLiquidityPoolWithdraw int64
OperationsInvokeHostFunction int64
OperationsBumpFootprintExpiration int64
OperationsExtendFootprintTtl int64

Check failure on line 53 in services/horizon/internal/ingest/processors/stats_ledger_transaction_processor.go

View workflow job for this annotation

GitHub Actions / golangci

ST1003: struct field OperationsExtendFootprintTtl should be OperationsExtendFootprintTTL (stylecheck)

Check failure on line 53 in services/horizon/internal/ingest/processors/stats_ledger_transaction_processor.go

View workflow job for this annotation

GitHub Actions / golangci

ST1003: struct field OperationsExtendFootprintTtl should be OperationsExtendFootprintTTL (stylecheck)
OperationsRestoreFootprint int64
}

Expand Down Expand Up @@ -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:
Expand Down
2 changes: 1 addition & 1 deletion services/horizon/internal/ingest/verify.go
Original file line number Diff line number Diff line change
Expand Up @@ -242,7 +242,7 @@ func (s *system) verifyState(verifyAgainstLatestCheckpoint bool) error {
return errors.Wrap(err, "Error running assetStats.AddContractData")
}
totalByType["contract_data"]++
case xdr.LedgerEntryTypeExpiration:
case xdr.LedgerEntryTypeTtl:
// we don't store expiration entries in the db,
// so there is nothing to verify in that case.
if err = verifier.Write(entry); err != nil {
Expand Down
6 changes: 3 additions & 3 deletions services/horizon/internal/ingest/verify_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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))
Expand Down Expand Up @@ -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)...)
}
Expand Down
8 changes: 4 additions & 4 deletions services/horizon/internal/integration/db_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -167,9 +167,9 @@ 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(),
bumpFootprintExpirationOp := &txnbuild.ExtendFootprintTtl{
ExtendTo: 100,
SourceAccount: itest.Master().Address(),
}
itest.MustSubmitOperations(itest.MasterAccount(), itest.Master(), bumpFootprintExpirationOp)

Expand Down Expand Up @@ -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)
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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")
}
Expand Down Expand Up @@ -40,19 +40,20 @@ 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,
},
},
}
Expand All @@ -63,6 +64,6 @@ func TestBumpFootPrintExpiration(t *testing.T) {
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)
}
2 changes: 1 addition & 1 deletion services/horizon/internal/integration/sac_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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,
},
},
Expand Down
Loading

0 comments on commit 0faa252

Please sign in to comment.