Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add rest of CAP-0056 #22

Merged
merged 1 commit into from
Aug 24, 2022
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
71 changes: 71 additions & 0 deletions Stellar-ledger.x
Original file line number Diff line number Diff line change
Expand Up @@ -275,6 +275,32 @@ struct TransactionHistoryResultEntry
ext;
};

struct TransactionResultPairV2
{
Hash transactionHash;
Hash hashOfMetaHashes; // hash of hashes in TransactionMetaV3
// TransactionResult is in the meta
};

struct TransactionResultSetV2
{
TransactionResultPairV2 results<>;
};

struct TransactionHistoryResultEntryV2
{
uint32 ledgerSeq;
TransactionResultSetV2 txResultSet;

// reserved for future use
union switch (int v)
{
case 0:
void;
}
ext;
};

struct LedgerHeaderHistoryEntry
{
Hash hash;
Expand Down Expand Up @@ -386,6 +412,21 @@ struct ContractEvent
body;
};

struct TransactionMetaV3
{
LedgerEntryChanges txChangesBefore; // tx level changes before operations
// are applied if any
OperationMeta operations<>; // meta for each operation
LedgerEntryChanges txChangesAfter; // tx level changes after operations are
// applied if any
ContractEvent events<>; // custom events populated by the
// contracts themselves
TransactionResult txResult;

Hash hashes[3]; // stores sha256(txChangesBefore, operations, txChangesAfter),
// sha256(events), and sha256(txResult)
};

// this is the meta produced when applying transactions
// it does not include pre-apply updates such as fees
union TransactionMeta switch (int v)
Expand All @@ -396,6 +437,8 @@ case 1:
TransactionMetaV1 v1;
case 2:
TransactionMetaV2 v2;
case 3:
TransactionMetaV3 v3;
};

// This struct groups together changes on a per transaction basis
Expand All @@ -408,6 +451,13 @@ struct TransactionResultMeta
TransactionMeta txApplyProcessing;
};

struct TransactionResultMetaV2
{
TransactionResultPairV2 result;
LedgerEntryChanges feeProcessing;
TransactionMeta txApplyProcessing;
};

// this represents a single upgrade that was performed as part of a ledger
// upgrade
struct UpgradeEntryMeta
Expand Down Expand Up @@ -452,11 +502,32 @@ struct LedgerCloseMetaV1
SCPHistoryEntry scpInfo<>;
};

// only difference between V1 and V2 is this uses TransactionResultMetaV2
struct LedgerCloseMetaV2
{
LedgerHeaderHistoryEntry ledgerHeader;

GeneralizedTransactionSet txSet;

// NB: transactions are sorted in apply order here
// fees for all transactions are processed first
// followed by applying transactions
TransactionResultMetaV2 txProcessing<>;

// upgrades are applied last
UpgradeEntryMeta upgradesProcessing<>;

// other misc information attached to the ledger close
SCPHistoryEntry scpInfo<>;
};

union LedgerCloseMeta switch (int v)
{
case 0:
LedgerCloseMetaV0 v0;
case 1:
LedgerCloseMetaV1 v1;
case 2:
LedgerCloseMetaV2 v2;
};
}