diff --git a/Makefile b/Makefile index a32425358..55be1a96f 100644 --- a/Makefile +++ b/Makefile @@ -15,7 +15,7 @@ xdr/Stellar-contract-config-setting.x # xdrgen commit to use, see https://github.com/stellar/xdrgen XDRGEN_COMMIT=6d4d47b4bc6815e26a52d62fd6613cfb56676d4b # stellar-xdr commit to use, see https://github.com/stellar/stellar-xdr -XDRNEXT_COMMIT=1a04392432dacc0092caaeae22a600ea1af3c6a5 +XDR_COMMIT=529d5176f24c73eeccfa5eba481d4e89c19b1181 .PHONY: xdr xdr-clean xdr-update @@ -31,7 +31,7 @@ xdr-generate: $(XDRS) ./gradlew :spotlessApply xdr/%.x: - curl -Lsf -o $@ https://raw.githubusercontent.com/stellar/stellar-xdr/$(XDRNEXT_COMMIT)/$(@F) + curl -Lsf -o $@ https://raw.githubusercontent.com/stellar/stellar-xdr/$(XDR_COMMIT)/$(@F) xdr-clean: rm xdr/*.x || true diff --git a/src/main/java/org/stellar/sdk/xdr/ArchivalProof.java b/src/main/java/org/stellar/sdk/xdr/ArchivalProof.java new file mode 100644 index 000000000..4662da740 --- /dev/null +++ b/src/main/java/org/stellar/sdk/xdr/ArchivalProof.java @@ -0,0 +1,123 @@ +// Automatically generated by xdrgen +// DO NOT EDIT or your changes may be overwritten + +package org.stellar.sdk.xdr; + +import java.io.ByteArrayInputStream; +import java.io.IOException; +import lombok.AllArgsConstructor; +import lombok.Builder; +import lombok.Data; +import lombok.NoArgsConstructor; +import org.stellar.sdk.Base64Factory; + +/** + * ArchivalProof's original definition in the XDR file is: + * + *
+ * struct ArchivalProof
+ * {
+ *     uint32 epoch; // AST Subtree for this proof
+ *
+ *     union switch (ArchivalProofType t)
+ *     {
+ *     case EXISTENCE:
+ *         NonexistenceProofBody nonexistenceProof;
+ *     case NONEXISTENCE:
+ *         ExistenceProofBody existenceProof;
+ *     } body;
+ * };
+ * 
+ */ +@Data +@NoArgsConstructor +@AllArgsConstructor +@Builder(toBuilder = true) +public class ArchivalProof implements XdrElement { + private Uint32 epoch; + private ArchivalProofBody body; + + public void encode(XdrDataOutputStream stream) throws IOException { + epoch.encode(stream); + body.encode(stream); + } + + public static ArchivalProof decode(XdrDataInputStream stream) throws IOException { + ArchivalProof decodedArchivalProof = new ArchivalProof(); + decodedArchivalProof.epoch = Uint32.decode(stream); + decodedArchivalProof.body = ArchivalProofBody.decode(stream); + return decodedArchivalProof; + } + + public static ArchivalProof fromXdrBase64(String xdr) throws IOException { + byte[] bytes = Base64Factory.getInstance().decode(xdr); + return fromXdrByteArray(bytes); + } + + public static ArchivalProof fromXdrByteArray(byte[] xdr) throws IOException { + ByteArrayInputStream byteArrayInputStream = new ByteArrayInputStream(xdr); + XdrDataInputStream xdrDataInputStream = new XdrDataInputStream(byteArrayInputStream); + return decode(xdrDataInputStream); + } + + /** + * ArchivalProofBody's original definition in the XDR file is: + * + *
+   * union switch (ArchivalProofType t)
+   *     {
+   *     case EXISTENCE:
+   *         NonexistenceProofBody nonexistenceProof;
+   *     case NONEXISTENCE:
+   *         ExistenceProofBody existenceProof;
+   *     }
+   * 
+ */ + @Data + @NoArgsConstructor + @AllArgsConstructor + @Builder(toBuilder = true) + public static class ArchivalProofBody implements XdrElement { + private ArchivalProofType discriminant; + private NonexistenceProofBody nonexistenceProof; + private ExistenceProofBody existenceProof; + + public void encode(XdrDataOutputStream stream) throws IOException { + stream.writeInt(discriminant.getValue()); + switch (discriminant) { + case EXISTENCE: + nonexistenceProof.encode(stream); + break; + case NONEXISTENCE: + existenceProof.encode(stream); + break; + } + } + + public static ArchivalProofBody decode(XdrDataInputStream stream) throws IOException { + ArchivalProofBody decodedArchivalProofBody = new ArchivalProofBody(); + ArchivalProofType discriminant = ArchivalProofType.decode(stream); + decodedArchivalProofBody.setDiscriminant(discriminant); + switch (decodedArchivalProofBody.getDiscriminant()) { + case EXISTENCE: + decodedArchivalProofBody.nonexistenceProof = NonexistenceProofBody.decode(stream); + break; + case NONEXISTENCE: + decodedArchivalProofBody.existenceProof = ExistenceProofBody.decode(stream); + break; + } + return decodedArchivalProofBody; + } + + public static ArchivalProofBody fromXdrBase64(String xdr) throws IOException { + byte[] bytes = Base64Factory.getInstance().decode(xdr); + return fromXdrByteArray(bytes); + } + + public static ArchivalProofBody fromXdrByteArray(byte[] xdr) throws IOException { + ByteArrayInputStream byteArrayInputStream = new ByteArrayInputStream(xdr); + XdrDataInputStream xdrDataInputStream = new XdrDataInputStream(byteArrayInputStream); + return decode(xdrDataInputStream); + } + } +} diff --git a/src/main/java/org/stellar/sdk/xdr/ArchivalProofNode.java b/src/main/java/org/stellar/sdk/xdr/ArchivalProofNode.java new file mode 100644 index 000000000..2c2164e3b --- /dev/null +++ b/src/main/java/org/stellar/sdk/xdr/ArchivalProofNode.java @@ -0,0 +1,55 @@ +// Automatically generated by xdrgen +// DO NOT EDIT or your changes may be overwritten + +package org.stellar.sdk.xdr; + +import java.io.ByteArrayInputStream; +import java.io.IOException; +import lombok.AllArgsConstructor; +import lombok.Builder; +import lombok.Data; +import lombok.NoArgsConstructor; +import org.stellar.sdk.Base64Factory; + +/** + * ArchivalProofNode's original definition in the XDR file is: + * + *
+ * struct ArchivalProofNode
+ * {
+ *     uint32 index;
+ *     Hash hash;
+ * };
+ * 
+ */ +@Data +@NoArgsConstructor +@AllArgsConstructor +@Builder(toBuilder = true) +public class ArchivalProofNode implements XdrElement { + private Uint32 index; + private Hash hash; + + public void encode(XdrDataOutputStream stream) throws IOException { + index.encode(stream); + hash.encode(stream); + } + + public static ArchivalProofNode decode(XdrDataInputStream stream) throws IOException { + ArchivalProofNode decodedArchivalProofNode = new ArchivalProofNode(); + decodedArchivalProofNode.index = Uint32.decode(stream); + decodedArchivalProofNode.hash = Hash.decode(stream); + return decodedArchivalProofNode; + } + + public static ArchivalProofNode fromXdrBase64(String xdr) throws IOException { + byte[] bytes = Base64Factory.getInstance().decode(xdr); + return fromXdrByteArray(bytes); + } + + public static ArchivalProofNode fromXdrByteArray(byte[] xdr) throws IOException { + ByteArrayInputStream byteArrayInputStream = new ByteArrayInputStream(xdr); + XdrDataInputStream xdrDataInputStream = new XdrDataInputStream(byteArrayInputStream); + return decode(xdrDataInputStream); + } +} diff --git a/src/main/java/org/stellar/sdk/xdr/ArchivalProofType.java b/src/main/java/org/stellar/sdk/xdr/ArchivalProofType.java new file mode 100644 index 000000000..d1286c57f --- /dev/null +++ b/src/main/java/org/stellar/sdk/xdr/ArchivalProofType.java @@ -0,0 +1,61 @@ +// Automatically generated by xdrgen +// DO NOT EDIT or your changes may be overwritten + +package org.stellar.sdk.xdr; + +import java.io.ByteArrayInputStream; +import java.io.IOException; +import org.stellar.sdk.Base64Factory; + +/** + * ArchivalProofType's original definition in the XDR file is: + * + *
+ * enum ArchivalProofType
+ * {
+ *     EXISTENCE = 0,
+ *     NONEXISTENCE = 1
+ * };
+ * 
+ */ +public enum ArchivalProofType implements XdrElement { + EXISTENCE(0), + NONEXISTENCE(1); + + private final int value; + + ArchivalProofType(int value) { + this.value = value; + } + + public int getValue() { + return value; + } + + public static ArchivalProofType decode(XdrDataInputStream stream) throws IOException { + int value = stream.readInt(); + switch (value) { + case 0: + return EXISTENCE; + case 1: + return NONEXISTENCE; + default: + throw new IllegalArgumentException("Unknown enum value: " + value); + } + } + + public void encode(XdrDataOutputStream stream) throws IOException { + stream.writeInt(value); + } + + public static ArchivalProofType fromXdrBase64(String xdr) throws IOException { + byte[] bytes = Base64Factory.getInstance().decode(xdr); + return fromXdrByteArray(bytes); + } + + public static ArchivalProofType fromXdrByteArray(byte[] xdr) throws IOException { + ByteArrayInputStream byteArrayInputStream = new ByteArrayInputStream(xdr); + XdrDataInputStream xdrDataInputStream = new XdrDataInputStream(byteArrayInputStream); + return decode(xdrDataInputStream); + } +} diff --git a/src/main/java/org/stellar/sdk/xdr/BinaryFuseFilterType.java b/src/main/java/org/stellar/sdk/xdr/BinaryFuseFilterType.java new file mode 100644 index 000000000..4f2e58d04 --- /dev/null +++ b/src/main/java/org/stellar/sdk/xdr/BinaryFuseFilterType.java @@ -0,0 +1,65 @@ +// Automatically generated by xdrgen +// DO NOT EDIT or your changes may be overwritten + +package org.stellar.sdk.xdr; + +import java.io.ByteArrayInputStream; +import java.io.IOException; +import org.stellar.sdk.Base64Factory; + +/** + * BinaryFuseFilterType's original definition in the XDR file is: + * + *
+ * enum BinaryFuseFilterType
+ * {
+ *     BINARY_FUSE_FILTER_8_BIT = 0,
+ *     BINARY_FUSE_FILTER_16_BIT = 1,
+ *     BINARY_FUSE_FILTER_32_BIT = 2
+ * };
+ * 
+ */ +public enum BinaryFuseFilterType implements XdrElement { + BINARY_FUSE_FILTER_8_BIT(0), + BINARY_FUSE_FILTER_16_BIT(1), + BINARY_FUSE_FILTER_32_BIT(2); + + private final int value; + + BinaryFuseFilterType(int value) { + this.value = value; + } + + public int getValue() { + return value; + } + + public static BinaryFuseFilterType decode(XdrDataInputStream stream) throws IOException { + int value = stream.readInt(); + switch (value) { + case 0: + return BINARY_FUSE_FILTER_8_BIT; + case 1: + return BINARY_FUSE_FILTER_16_BIT; + case 2: + return BINARY_FUSE_FILTER_32_BIT; + default: + throw new IllegalArgumentException("Unknown enum value: " + value); + } + } + + public void encode(XdrDataOutputStream stream) throws IOException { + stream.writeInt(value); + } + + public static BinaryFuseFilterType fromXdrBase64(String xdr) throws IOException { + byte[] bytes = Base64Factory.getInstance().decode(xdr); + return fromXdrByteArray(bytes); + } + + public static BinaryFuseFilterType fromXdrByteArray(byte[] xdr) throws IOException { + ByteArrayInputStream byteArrayInputStream = new ByteArrayInputStream(xdr); + XdrDataInputStream xdrDataInputStream = new XdrDataInputStream(byteArrayInputStream); + return decode(xdrDataInputStream); + } +} diff --git a/src/main/java/org/stellar/sdk/xdr/BucketListType.java b/src/main/java/org/stellar/sdk/xdr/BucketListType.java new file mode 100644 index 000000000..4d60b7395 --- /dev/null +++ b/src/main/java/org/stellar/sdk/xdr/BucketListType.java @@ -0,0 +1,65 @@ +// Automatically generated by xdrgen +// DO NOT EDIT or your changes may be overwritten + +package org.stellar.sdk.xdr; + +import java.io.ByteArrayInputStream; +import java.io.IOException; +import org.stellar.sdk.Base64Factory; + +/** + * BucketListType's original definition in the XDR file is: + * + *
+ * enum BucketListType
+ * {
+ *     LIVE = 0,
+ *     HOT_ARCHIVE = 1,
+ *     COLD_ARCHIVE = 2
+ * };
+ * 
+ */ +public enum BucketListType implements XdrElement { + LIVE(0), + HOT_ARCHIVE(1), + COLD_ARCHIVE(2); + + private final int value; + + BucketListType(int value) { + this.value = value; + } + + public int getValue() { + return value; + } + + public static BucketListType decode(XdrDataInputStream stream) throws IOException { + int value = stream.readInt(); + switch (value) { + case 0: + return LIVE; + case 1: + return HOT_ARCHIVE; + case 2: + return COLD_ARCHIVE; + default: + throw new IllegalArgumentException("Unknown enum value: " + value); + } + } + + public void encode(XdrDataOutputStream stream) throws IOException { + stream.writeInt(value); + } + + public static BucketListType fromXdrBase64(String xdr) throws IOException { + byte[] bytes = Base64Factory.getInstance().decode(xdr); + return fromXdrByteArray(bytes); + } + + public static BucketListType fromXdrByteArray(byte[] xdr) throws IOException { + ByteArrayInputStream byteArrayInputStream = new ByteArrayInputStream(xdr); + XdrDataInputStream xdrDataInputStream = new XdrDataInputStream(byteArrayInputStream); + return decode(xdrDataInputStream); + } +} diff --git a/src/main/java/org/stellar/sdk/xdr/BucketMetadata.java b/src/main/java/org/stellar/sdk/xdr/BucketMetadata.java index bd6822b5b..e51bc5828 100644 --- a/src/main/java/org/stellar/sdk/xdr/BucketMetadata.java +++ b/src/main/java/org/stellar/sdk/xdr/BucketMetadata.java @@ -25,6 +25,8 @@ * { * case 0: * void; + * case 1: + * BucketListType bucketListType; * } * ext; * }; @@ -69,6 +71,8 @@ public static BucketMetadata fromXdrByteArray(byte[] xdr) throws IOException { * { * case 0: * void; + * case 1: + * BucketListType bucketListType; * } * */ @@ -78,12 +82,16 @@ public static BucketMetadata fromXdrByteArray(byte[] xdr) throws IOException { @Builder(toBuilder = true) public static class BucketMetadataExt implements XdrElement { private Integer discriminant; + private BucketListType bucketListType; public void encode(XdrDataOutputStream stream) throws IOException { stream.writeInt(discriminant); switch (discriminant) { case 0: break; + case 1: + bucketListType.encode(stream); + break; } } @@ -94,6 +102,9 @@ public static BucketMetadataExt decode(XdrDataInputStream stream) throws IOExcep switch (decodedBucketMetadataExt.getDiscriminant()) { case 0: break; + case 1: + decodedBucketMetadataExt.bucketListType = BucketListType.decode(stream); + break; } return decodedBucketMetadataExt; } diff --git a/src/main/java/org/stellar/sdk/xdr/ColdArchiveArchivedLeaf.java b/src/main/java/org/stellar/sdk/xdr/ColdArchiveArchivedLeaf.java new file mode 100644 index 000000000..4c07e619c --- /dev/null +++ b/src/main/java/org/stellar/sdk/xdr/ColdArchiveArchivedLeaf.java @@ -0,0 +1,55 @@ +// Automatically generated by xdrgen +// DO NOT EDIT or your changes may be overwritten + +package org.stellar.sdk.xdr; + +import java.io.ByteArrayInputStream; +import java.io.IOException; +import lombok.AllArgsConstructor; +import lombok.Builder; +import lombok.Data; +import lombok.NoArgsConstructor; +import org.stellar.sdk.Base64Factory; + +/** + * ColdArchiveArchivedLeaf's original definition in the XDR file is: + * + *
+ * struct ColdArchiveArchivedLeaf
+ * {
+ *     uint32 index;
+ *     LedgerEntry archivedEntry;
+ * };
+ * 
+ */ +@Data +@NoArgsConstructor +@AllArgsConstructor +@Builder(toBuilder = true) +public class ColdArchiveArchivedLeaf implements XdrElement { + private Uint32 index; + private LedgerEntry archivedEntry; + + public void encode(XdrDataOutputStream stream) throws IOException { + index.encode(stream); + archivedEntry.encode(stream); + } + + public static ColdArchiveArchivedLeaf decode(XdrDataInputStream stream) throws IOException { + ColdArchiveArchivedLeaf decodedColdArchiveArchivedLeaf = new ColdArchiveArchivedLeaf(); + decodedColdArchiveArchivedLeaf.index = Uint32.decode(stream); + decodedColdArchiveArchivedLeaf.archivedEntry = LedgerEntry.decode(stream); + return decodedColdArchiveArchivedLeaf; + } + + public static ColdArchiveArchivedLeaf fromXdrBase64(String xdr) throws IOException { + byte[] bytes = Base64Factory.getInstance().decode(xdr); + return fromXdrByteArray(bytes); + } + + public static ColdArchiveArchivedLeaf fromXdrByteArray(byte[] xdr) throws IOException { + ByteArrayInputStream byteArrayInputStream = new ByteArrayInputStream(xdr); + XdrDataInputStream xdrDataInputStream = new XdrDataInputStream(byteArrayInputStream); + return decode(xdrDataInputStream); + } +} diff --git a/src/main/java/org/stellar/sdk/xdr/ColdArchiveBoundaryLeaf.java b/src/main/java/org/stellar/sdk/xdr/ColdArchiveBoundaryLeaf.java new file mode 100644 index 000000000..40337a042 --- /dev/null +++ b/src/main/java/org/stellar/sdk/xdr/ColdArchiveBoundaryLeaf.java @@ -0,0 +1,55 @@ +// Automatically generated by xdrgen +// DO NOT EDIT or your changes may be overwritten + +package org.stellar.sdk.xdr; + +import java.io.ByteArrayInputStream; +import java.io.IOException; +import lombok.AllArgsConstructor; +import lombok.Builder; +import lombok.Data; +import lombok.NoArgsConstructor; +import org.stellar.sdk.Base64Factory; + +/** + * ColdArchiveBoundaryLeaf's original definition in the XDR file is: + * + *
+ * struct ColdArchiveBoundaryLeaf
+ * {
+ *     uint32 index;
+ *     bool isLowerBound;
+ * };
+ * 
+ */ +@Data +@NoArgsConstructor +@AllArgsConstructor +@Builder(toBuilder = true) +public class ColdArchiveBoundaryLeaf implements XdrElement { + private Uint32 index; + private Boolean isLowerBound; + + public void encode(XdrDataOutputStream stream) throws IOException { + index.encode(stream); + stream.writeInt(isLowerBound ? 1 : 0); + } + + public static ColdArchiveBoundaryLeaf decode(XdrDataInputStream stream) throws IOException { + ColdArchiveBoundaryLeaf decodedColdArchiveBoundaryLeaf = new ColdArchiveBoundaryLeaf(); + decodedColdArchiveBoundaryLeaf.index = Uint32.decode(stream); + decodedColdArchiveBoundaryLeaf.isLowerBound = stream.readInt() == 1 ? true : false; + return decodedColdArchiveBoundaryLeaf; + } + + public static ColdArchiveBoundaryLeaf fromXdrBase64(String xdr) throws IOException { + byte[] bytes = Base64Factory.getInstance().decode(xdr); + return fromXdrByteArray(bytes); + } + + public static ColdArchiveBoundaryLeaf fromXdrByteArray(byte[] xdr) throws IOException { + ByteArrayInputStream byteArrayInputStream = new ByteArrayInputStream(xdr); + XdrDataInputStream xdrDataInputStream = new XdrDataInputStream(byteArrayInputStream); + return decode(xdrDataInputStream); + } +} diff --git a/src/main/java/org/stellar/sdk/xdr/ColdArchiveBucketEntry.java b/src/main/java/org/stellar/sdk/xdr/ColdArchiveBucketEntry.java new file mode 100644 index 000000000..68dce34df --- /dev/null +++ b/src/main/java/org/stellar/sdk/xdr/ColdArchiveBucketEntry.java @@ -0,0 +1,100 @@ +// Automatically generated by xdrgen +// DO NOT EDIT or your changes may be overwritten + +package org.stellar.sdk.xdr; + +import java.io.ByteArrayInputStream; +import java.io.IOException; +import lombok.AllArgsConstructor; +import lombok.Builder; +import lombok.Data; +import lombok.NoArgsConstructor; +import org.stellar.sdk.Base64Factory; + +/** + * ColdArchiveBucketEntry's original definition in the XDR file is: + * + *
+ * union ColdArchiveBucketEntry switch (ColdArchiveBucketEntryType type)
+ * {
+ * case COLD_ARCHIVE_METAENTRY:
+ *     BucketMetadata metaEntry;
+ * case COLD_ARCHIVE_ARCHIVED_LEAF:
+ *     ColdArchiveArchivedLeaf archivedLeaf;
+ * case COLD_ARCHIVE_DELETED_LEAF:
+ *     ColdArchiveDeletedLeaf deletedLeaf;
+ * case COLD_ARCHIVE_BOUNDARY_LEAF:
+ *     ColdArchiveBoundaryLeaf boundaryLeaf;
+ * case COLD_ARCHIVE_HASH:
+ *     ColdArchiveHashEntry hashEntry;
+ * };
+ * 
+ */ +@Data +@NoArgsConstructor +@AllArgsConstructor +@Builder(toBuilder = true) +public class ColdArchiveBucketEntry implements XdrElement { + private ColdArchiveBucketEntryType discriminant; + private BucketMetadata metaEntry; + private ColdArchiveArchivedLeaf archivedLeaf; + private ColdArchiveDeletedLeaf deletedLeaf; + private ColdArchiveBoundaryLeaf boundaryLeaf; + private ColdArchiveHashEntry hashEntry; + + public void encode(XdrDataOutputStream stream) throws IOException { + stream.writeInt(discriminant.getValue()); + switch (discriminant) { + case COLD_ARCHIVE_METAENTRY: + metaEntry.encode(stream); + break; + case COLD_ARCHIVE_ARCHIVED_LEAF: + archivedLeaf.encode(stream); + break; + case COLD_ARCHIVE_DELETED_LEAF: + deletedLeaf.encode(stream); + break; + case COLD_ARCHIVE_BOUNDARY_LEAF: + boundaryLeaf.encode(stream); + break; + case COLD_ARCHIVE_HASH: + hashEntry.encode(stream); + break; + } + } + + public static ColdArchiveBucketEntry decode(XdrDataInputStream stream) throws IOException { + ColdArchiveBucketEntry decodedColdArchiveBucketEntry = new ColdArchiveBucketEntry(); + ColdArchiveBucketEntryType discriminant = ColdArchiveBucketEntryType.decode(stream); + decodedColdArchiveBucketEntry.setDiscriminant(discriminant); + switch (decodedColdArchiveBucketEntry.getDiscriminant()) { + case COLD_ARCHIVE_METAENTRY: + decodedColdArchiveBucketEntry.metaEntry = BucketMetadata.decode(stream); + break; + case COLD_ARCHIVE_ARCHIVED_LEAF: + decodedColdArchiveBucketEntry.archivedLeaf = ColdArchiveArchivedLeaf.decode(stream); + break; + case COLD_ARCHIVE_DELETED_LEAF: + decodedColdArchiveBucketEntry.deletedLeaf = ColdArchiveDeletedLeaf.decode(stream); + break; + case COLD_ARCHIVE_BOUNDARY_LEAF: + decodedColdArchiveBucketEntry.boundaryLeaf = ColdArchiveBoundaryLeaf.decode(stream); + break; + case COLD_ARCHIVE_HASH: + decodedColdArchiveBucketEntry.hashEntry = ColdArchiveHashEntry.decode(stream); + break; + } + return decodedColdArchiveBucketEntry; + } + + public static ColdArchiveBucketEntry fromXdrBase64(String xdr) throws IOException { + byte[] bytes = Base64Factory.getInstance().decode(xdr); + return fromXdrByteArray(bytes); + } + + public static ColdArchiveBucketEntry fromXdrByteArray(byte[] xdr) throws IOException { + ByteArrayInputStream byteArrayInputStream = new ByteArrayInputStream(xdr); + XdrDataInputStream xdrDataInputStream = new XdrDataInputStream(byteArrayInputStream); + return decode(xdrDataInputStream); + } +} diff --git a/src/main/java/org/stellar/sdk/xdr/ColdArchiveBucketEntryType.java b/src/main/java/org/stellar/sdk/xdr/ColdArchiveBucketEntryType.java new file mode 100644 index 000000000..43bc8a4c8 --- /dev/null +++ b/src/main/java/org/stellar/sdk/xdr/ColdArchiveBucketEntryType.java @@ -0,0 +1,73 @@ +// Automatically generated by xdrgen +// DO NOT EDIT or your changes may be overwritten + +package org.stellar.sdk.xdr; + +import java.io.ByteArrayInputStream; +import java.io.IOException; +import org.stellar.sdk.Base64Factory; + +/** + * ColdArchiveBucketEntryType's original definition in the XDR file is: + * + *
+ * enum ColdArchiveBucketEntryType
+ * {
+ *     COLD_ARCHIVE_METAENTRY     = -1,  // Bucket metadata, should come first.
+ *     COLD_ARCHIVE_ARCHIVED_LEAF = 0,   // Full LedgerEntry that was archived during the epoch
+ *     COLD_ARCHIVE_DELETED_LEAF  = 1,   // LedgerKey that was deleted during the epoch
+ *     COLD_ARCHIVE_BOUNDARY_LEAF = 2,   // Dummy leaf representing low/high bound
+ *     COLD_ARCHIVE_HASH          = 3    // Intermediary Merkle hash entry
+ * };
+ * 
+ */ +public enum ColdArchiveBucketEntryType implements XdrElement { + COLD_ARCHIVE_METAENTRY(-1), + COLD_ARCHIVE_ARCHIVED_LEAF(0), + COLD_ARCHIVE_DELETED_LEAF(1), + COLD_ARCHIVE_BOUNDARY_LEAF(2), + COLD_ARCHIVE_HASH(3); + + private final int value; + + ColdArchiveBucketEntryType(int value) { + this.value = value; + } + + public int getValue() { + return value; + } + + public static ColdArchiveBucketEntryType decode(XdrDataInputStream stream) throws IOException { + int value = stream.readInt(); + switch (value) { + case -1: + return COLD_ARCHIVE_METAENTRY; + case 0: + return COLD_ARCHIVE_ARCHIVED_LEAF; + case 1: + return COLD_ARCHIVE_DELETED_LEAF; + case 2: + return COLD_ARCHIVE_BOUNDARY_LEAF; + case 3: + return COLD_ARCHIVE_HASH; + default: + throw new IllegalArgumentException("Unknown enum value: " + value); + } + } + + public void encode(XdrDataOutputStream stream) throws IOException { + stream.writeInt(value); + } + + public static ColdArchiveBucketEntryType fromXdrBase64(String xdr) throws IOException { + byte[] bytes = Base64Factory.getInstance().decode(xdr); + return fromXdrByteArray(bytes); + } + + public static ColdArchiveBucketEntryType fromXdrByteArray(byte[] xdr) throws IOException { + ByteArrayInputStream byteArrayInputStream = new ByteArrayInputStream(xdr); + XdrDataInputStream xdrDataInputStream = new XdrDataInputStream(byteArrayInputStream); + return decode(xdrDataInputStream); + } +} diff --git a/src/main/java/org/stellar/sdk/xdr/ColdArchiveDeletedLeaf.java b/src/main/java/org/stellar/sdk/xdr/ColdArchiveDeletedLeaf.java new file mode 100644 index 000000000..a196bec08 --- /dev/null +++ b/src/main/java/org/stellar/sdk/xdr/ColdArchiveDeletedLeaf.java @@ -0,0 +1,55 @@ +// Automatically generated by xdrgen +// DO NOT EDIT or your changes may be overwritten + +package org.stellar.sdk.xdr; + +import java.io.ByteArrayInputStream; +import java.io.IOException; +import lombok.AllArgsConstructor; +import lombok.Builder; +import lombok.Data; +import lombok.NoArgsConstructor; +import org.stellar.sdk.Base64Factory; + +/** + * ColdArchiveDeletedLeaf's original definition in the XDR file is: + * + *
+ * struct ColdArchiveDeletedLeaf
+ * {
+ *     uint32 index;
+ *     LedgerKey deletedKey;
+ * };
+ * 
+ */ +@Data +@NoArgsConstructor +@AllArgsConstructor +@Builder(toBuilder = true) +public class ColdArchiveDeletedLeaf implements XdrElement { + private Uint32 index; + private LedgerKey deletedKey; + + public void encode(XdrDataOutputStream stream) throws IOException { + index.encode(stream); + deletedKey.encode(stream); + } + + public static ColdArchiveDeletedLeaf decode(XdrDataInputStream stream) throws IOException { + ColdArchiveDeletedLeaf decodedColdArchiveDeletedLeaf = new ColdArchiveDeletedLeaf(); + decodedColdArchiveDeletedLeaf.index = Uint32.decode(stream); + decodedColdArchiveDeletedLeaf.deletedKey = LedgerKey.decode(stream); + return decodedColdArchiveDeletedLeaf; + } + + public static ColdArchiveDeletedLeaf fromXdrBase64(String xdr) throws IOException { + byte[] bytes = Base64Factory.getInstance().decode(xdr); + return fromXdrByteArray(bytes); + } + + public static ColdArchiveDeletedLeaf fromXdrByteArray(byte[] xdr) throws IOException { + ByteArrayInputStream byteArrayInputStream = new ByteArrayInputStream(xdr); + XdrDataInputStream xdrDataInputStream = new XdrDataInputStream(byteArrayInputStream); + return decode(xdrDataInputStream); + } +} diff --git a/src/main/java/org/stellar/sdk/xdr/ColdArchiveHashEntry.java b/src/main/java/org/stellar/sdk/xdr/ColdArchiveHashEntry.java new file mode 100644 index 000000000..a42e4af45 --- /dev/null +++ b/src/main/java/org/stellar/sdk/xdr/ColdArchiveHashEntry.java @@ -0,0 +1,59 @@ +// Automatically generated by xdrgen +// DO NOT EDIT or your changes may be overwritten + +package org.stellar.sdk.xdr; + +import java.io.ByteArrayInputStream; +import java.io.IOException; +import lombok.AllArgsConstructor; +import lombok.Builder; +import lombok.Data; +import lombok.NoArgsConstructor; +import org.stellar.sdk.Base64Factory; + +/** + * ColdArchiveHashEntry's original definition in the XDR file is: + * + *
+ * struct ColdArchiveHashEntry
+ * {
+ *     uint32 index;
+ *     uint32 level;
+ *     Hash hash;
+ * };
+ * 
+ */ +@Data +@NoArgsConstructor +@AllArgsConstructor +@Builder(toBuilder = true) +public class ColdArchiveHashEntry implements XdrElement { + private Uint32 index; + private Uint32 level; + private Hash hash; + + public void encode(XdrDataOutputStream stream) throws IOException { + index.encode(stream); + level.encode(stream); + hash.encode(stream); + } + + public static ColdArchiveHashEntry decode(XdrDataInputStream stream) throws IOException { + ColdArchiveHashEntry decodedColdArchiveHashEntry = new ColdArchiveHashEntry(); + decodedColdArchiveHashEntry.index = Uint32.decode(stream); + decodedColdArchiveHashEntry.level = Uint32.decode(stream); + decodedColdArchiveHashEntry.hash = Hash.decode(stream); + return decodedColdArchiveHashEntry; + } + + public static ColdArchiveHashEntry fromXdrBase64(String xdr) throws IOException { + byte[] bytes = Base64Factory.getInstance().decode(xdr); + return fromXdrByteArray(bytes); + } + + public static ColdArchiveHashEntry fromXdrByteArray(byte[] xdr) throws IOException { + ByteArrayInputStream byteArrayInputStream = new ByteArrayInputStream(xdr); + XdrDataInputStream xdrDataInputStream = new XdrDataInputStream(byteArrayInputStream); + return decode(xdrDataInputStream); + } +} diff --git a/src/main/java/org/stellar/sdk/xdr/ContractCostType.java b/src/main/java/org/stellar/sdk/xdr/ContractCostType.java index 66494c770..139d9ddfc 100644 --- a/src/main/java/org/stellar/sdk/xdr/ContractCostType.java +++ b/src/main/java/org/stellar/sdk/xdr/ContractCostType.java @@ -110,7 +110,58 @@ * // point on a 256-bit elliptic curve * Sec1DecodePointUncompressed = 43, * // Cost of verifying an ECDSA Secp256r1 signature - * VerifyEcdsaSecp256r1Sig = 44 + * VerifyEcdsaSecp256r1Sig = 44, + * + * // Cost of encoding a BLS12-381 Fp (base field element) + * Bls12381EncodeFp = 45, + * // Cost of decoding a BLS12-381 Fp (base field element) + * Bls12381DecodeFp = 46, + * // Cost of checking a G1 point lies on the curve + * Bls12381G1CheckPointOnCurve = 47, + * // Cost of checking a G1 point belongs to the correct subgroup + * Bls12381G1CheckPointInSubgroup = 48, + * // Cost of checking a G2 point lies on the curve + * Bls12381G2CheckPointOnCurve = 49, + * // Cost of checking a G2 point belongs to the correct subgroup + * Bls12381G2CheckPointInSubgroup = 50, + * // Cost of converting a BLS12-381 G1 point from projective to affine coordinates + * Bls12381G1ProjectiveToAffine = 51, + * // Cost of converting a BLS12-381 G2 point from projective to affine coordinates + * Bls12381G2ProjectiveToAffine = 52, + * // Cost of performing BLS12-381 G1 point addition + * Bls12381G1Add = 53, + * // Cost of performing BLS12-381 G1 scalar multiplication + * Bls12381G1Mul = 54, + * // Cost of performing BLS12-381 G1 multi-scalar multiplication (MSM) + * Bls12381G1Msm = 55, + * // Cost of mapping a BLS12-381 Fp field element to a G1 point + * Bls12381MapFpToG1 = 56, + * // Cost of hashing to a BLS12-381 G1 point + * Bls12381HashToG1 = 57, + * // Cost of performing BLS12-381 G2 point addition + * Bls12381G2Add = 58, + * // Cost of performing BLS12-381 G2 scalar multiplication + * Bls12381G2Mul = 59, + * // Cost of performing BLS12-381 G2 multi-scalar multiplication (MSM) + * Bls12381G2Msm = 60, + * // Cost of mapping a BLS12-381 Fp2 field element to a G2 point + * Bls12381MapFp2ToG2 = 61, + * // Cost of hashing to a BLS12-381 G2 point + * Bls12381HashToG2 = 62, + * // Cost of performing BLS12-381 pairing operation + * Bls12381Pairing = 63, + * // Cost of converting a BLS12-381 scalar element from U256 + * Bls12381FrFromU256 = 64, + * // Cost of converting a BLS12-381 scalar element to U256 + * Bls12381FrToU256 = 65, + * // Cost of performing BLS12-381 scalar element addition/subtraction + * Bls12381FrAddSub = 66, + * // Cost of performing BLS12-381 scalar element multiplication + * Bls12381FrMul = 67, + * // Cost of performing BLS12-381 scalar element exponentiation + * Bls12381FrPow = 68, + * // Cost of performing BLS12-381 scalar element inversion + * Bls12381FrInv = 69 * }; * */ @@ -159,7 +210,32 @@ public enum ContractCostType implements XdrElement { InstantiateWasmExports(41), InstantiateWasmDataSegmentBytes(42), Sec1DecodePointUncompressed(43), - VerifyEcdsaSecp256r1Sig(44); + VerifyEcdsaSecp256r1Sig(44), + Bls12381EncodeFp(45), + Bls12381DecodeFp(46), + Bls12381G1CheckPointOnCurve(47), + Bls12381G1CheckPointInSubgroup(48), + Bls12381G2CheckPointOnCurve(49), + Bls12381G2CheckPointInSubgroup(50), + Bls12381G1ProjectiveToAffine(51), + Bls12381G2ProjectiveToAffine(52), + Bls12381G1Add(53), + Bls12381G1Mul(54), + Bls12381G1Msm(55), + Bls12381MapFpToG1(56), + Bls12381HashToG1(57), + Bls12381G2Add(58), + Bls12381G2Mul(59), + Bls12381G2Msm(60), + Bls12381MapFp2ToG2(61), + Bls12381HashToG2(62), + Bls12381Pairing(63), + Bls12381FrFromU256(64), + Bls12381FrToU256(65), + Bls12381FrAddSub(66), + Bls12381FrMul(67), + Bls12381FrPow(68), + Bls12381FrInv(69); private final int value; @@ -264,6 +340,56 @@ public static ContractCostType decode(XdrDataInputStream stream) throws IOExcept return Sec1DecodePointUncompressed; case 44: return VerifyEcdsaSecp256r1Sig; + case 45: + return Bls12381EncodeFp; + case 46: + return Bls12381DecodeFp; + case 47: + return Bls12381G1CheckPointOnCurve; + case 48: + return Bls12381G1CheckPointInSubgroup; + case 49: + return Bls12381G2CheckPointOnCurve; + case 50: + return Bls12381G2CheckPointInSubgroup; + case 51: + return Bls12381G1ProjectiveToAffine; + case 52: + return Bls12381G2ProjectiveToAffine; + case 53: + return Bls12381G1Add; + case 54: + return Bls12381G1Mul; + case 55: + return Bls12381G1Msm; + case 56: + return Bls12381MapFpToG1; + case 57: + return Bls12381HashToG1; + case 58: + return Bls12381G2Add; + case 59: + return Bls12381G2Mul; + case 60: + return Bls12381G2Msm; + case 61: + return Bls12381MapFp2ToG2; + case 62: + return Bls12381HashToG2; + case 63: + return Bls12381Pairing; + case 64: + return Bls12381FrFromU256; + case 65: + return Bls12381FrToU256; + case 66: + return Bls12381FrAddSub; + case 67: + return Bls12381FrMul; + case 68: + return Bls12381FrPow; + case 69: + return Bls12381FrInv; default: throw new IllegalArgumentException("Unknown enum value: " + value); } diff --git a/src/main/java/org/stellar/sdk/xdr/CreateContractArgsV2.java b/src/main/java/org/stellar/sdk/xdr/CreateContractArgsV2.java new file mode 100644 index 000000000..ee080eb38 --- /dev/null +++ b/src/main/java/org/stellar/sdk/xdr/CreateContractArgsV2.java @@ -0,0 +1,68 @@ +// Automatically generated by xdrgen +// DO NOT EDIT or your changes may be overwritten + +package org.stellar.sdk.xdr; + +import java.io.ByteArrayInputStream; +import java.io.IOException; +import lombok.AllArgsConstructor; +import lombok.Builder; +import lombok.Data; +import lombok.NoArgsConstructor; +import org.stellar.sdk.Base64Factory; + +/** + * CreateContractArgsV2's original definition in the XDR file is: + * + *
+ * struct CreateContractArgsV2
+ * {
+ *     ContractIDPreimage contractIDPreimage;
+ *     ContractExecutable executable;
+ *     // Arguments of the contract's constructor.
+ *     SCVal constructorArgs<>;
+ * };
+ * 
+ */ +@Data +@NoArgsConstructor +@AllArgsConstructor +@Builder(toBuilder = true) +public class CreateContractArgsV2 implements XdrElement { + private ContractIDPreimage contractIDPreimage; + private ContractExecutable executable; + private SCVal[] constructorArgs; + + public void encode(XdrDataOutputStream stream) throws IOException { + contractIDPreimage.encode(stream); + executable.encode(stream); + int constructorArgsSize = getConstructorArgs().length; + stream.writeInt(constructorArgsSize); + for (int i = 0; i < constructorArgsSize; i++) { + constructorArgs[i].encode(stream); + } + } + + public static CreateContractArgsV2 decode(XdrDataInputStream stream) throws IOException { + CreateContractArgsV2 decodedCreateContractArgsV2 = new CreateContractArgsV2(); + decodedCreateContractArgsV2.contractIDPreimage = ContractIDPreimage.decode(stream); + decodedCreateContractArgsV2.executable = ContractExecutable.decode(stream); + int constructorArgsSize = stream.readInt(); + decodedCreateContractArgsV2.constructorArgs = new SCVal[constructorArgsSize]; + for (int i = 0; i < constructorArgsSize; i++) { + decodedCreateContractArgsV2.constructorArgs[i] = SCVal.decode(stream); + } + return decodedCreateContractArgsV2; + } + + public static CreateContractArgsV2 fromXdrBase64(String xdr) throws IOException { + byte[] bytes = Base64Factory.getInstance().decode(xdr); + return fromXdrByteArray(bytes); + } + + public static CreateContractArgsV2 fromXdrByteArray(byte[] xdr) throws IOException { + ByteArrayInputStream byteArrayInputStream = new ByteArrayInputStream(xdr); + XdrDataInputStream xdrDataInputStream = new XdrDataInputStream(byteArrayInputStream); + return decode(xdrDataInputStream); + } +} diff --git a/src/main/java/org/stellar/sdk/xdr/DiagnosticEvents.java b/src/main/java/org/stellar/sdk/xdr/DiagnosticEvents.java new file mode 100644 index 000000000..efd1848f5 --- /dev/null +++ b/src/main/java/org/stellar/sdk/xdr/DiagnosticEvents.java @@ -0,0 +1,54 @@ +// Automatically generated by xdrgen +// DO NOT EDIT or your changes may be overwritten + +package org.stellar.sdk.xdr; + +import java.io.ByteArrayInputStream; +import java.io.IOException; +import lombok.AllArgsConstructor; +import lombok.Data; +import lombok.NoArgsConstructor; +import org.stellar.sdk.Base64Factory; + +/** + * DiagnosticEvents's original definition in the XDR file is: + * + *
+ * typedef DiagnosticEvent DiagnosticEvents<>;
+ * 
+ */ +@Data +@NoArgsConstructor +@AllArgsConstructor +public class DiagnosticEvents implements XdrElement { + private DiagnosticEvent[] DiagnosticEvents; + + public void encode(XdrDataOutputStream stream) throws IOException { + int DiagnosticEventsSize = getDiagnosticEvents().length; + stream.writeInt(DiagnosticEventsSize); + for (int i = 0; i < DiagnosticEventsSize; i++) { + DiagnosticEvents[i].encode(stream); + } + } + + public static DiagnosticEvents decode(XdrDataInputStream stream) throws IOException { + DiagnosticEvents decodedDiagnosticEvents = new DiagnosticEvents(); + int DiagnosticEventsSize = stream.readInt(); + decodedDiagnosticEvents.DiagnosticEvents = new DiagnosticEvent[DiagnosticEventsSize]; + for (int i = 0; i < DiagnosticEventsSize; i++) { + decodedDiagnosticEvents.DiagnosticEvents[i] = DiagnosticEvent.decode(stream); + } + return decodedDiagnosticEvents; + } + + public static DiagnosticEvents fromXdrBase64(String xdr) throws IOException { + byte[] bytes = Base64Factory.getInstance().decode(xdr); + return fromXdrByteArray(bytes); + } + + public static DiagnosticEvents fromXdrByteArray(byte[] xdr) throws IOException { + ByteArrayInputStream byteArrayInputStream = new ByteArrayInputStream(xdr); + XdrDataInputStream xdrDataInputStream = new XdrDataInputStream(byteArrayInputStream); + return decode(xdrDataInputStream); + } +} diff --git a/src/main/java/org/stellar/sdk/xdr/ExistenceProofBody.java b/src/main/java/org/stellar/sdk/xdr/ExistenceProofBody.java new file mode 100644 index 000000000..87cfe030c --- /dev/null +++ b/src/main/java/org/stellar/sdk/xdr/ExistenceProofBody.java @@ -0,0 +1,101 @@ +// Automatically generated by xdrgen +// DO NOT EDIT or your changes may be overwritten + +package org.stellar.sdk.xdr; + +import java.io.ByteArrayInputStream; +import java.io.IOException; +import lombok.AllArgsConstructor; +import lombok.Builder; +import lombok.Data; +import lombok.NoArgsConstructor; +import org.stellar.sdk.Base64Factory; + +/** + * ExistenceProofBody's original definition in the XDR file is: + * + *
+ * struct ExistenceProofBody
+ * {
+ *     LedgerKey keysToProve<>;
+ *
+ *     // Bounds for each key being proved, where bound[n]
+ *     // corresponds to keysToProve[n]
+ *     ColdArchiveBucketEntry lowBoundEntries<>;
+ *     ColdArchiveBucketEntry highBoundEntries<>;
+ *
+ *     // Vector of vectors, where proofLevels[level]
+ *     // contains all HashNodes that correspond with that level
+ *     ProofLevel proofLevels<>;
+ * };
+ * 
+ */ +@Data +@NoArgsConstructor +@AllArgsConstructor +@Builder(toBuilder = true) +public class ExistenceProofBody implements XdrElement { + private LedgerKey[] keysToProve; + private ColdArchiveBucketEntry[] lowBoundEntries; + private ColdArchiveBucketEntry[] highBoundEntries; + private ProofLevel[] proofLevels; + + public void encode(XdrDataOutputStream stream) throws IOException { + int keysToProveSize = getKeysToProve().length; + stream.writeInt(keysToProveSize); + for (int i = 0; i < keysToProveSize; i++) { + keysToProve[i].encode(stream); + } + int lowBoundEntriesSize = getLowBoundEntries().length; + stream.writeInt(lowBoundEntriesSize); + for (int i = 0; i < lowBoundEntriesSize; i++) { + lowBoundEntries[i].encode(stream); + } + int highBoundEntriesSize = getHighBoundEntries().length; + stream.writeInt(highBoundEntriesSize); + for (int i = 0; i < highBoundEntriesSize; i++) { + highBoundEntries[i].encode(stream); + } + int proofLevelsSize = getProofLevels().length; + stream.writeInt(proofLevelsSize); + for (int i = 0; i < proofLevelsSize; i++) { + proofLevels[i].encode(stream); + } + } + + public static ExistenceProofBody decode(XdrDataInputStream stream) throws IOException { + ExistenceProofBody decodedExistenceProofBody = new ExistenceProofBody(); + int keysToProveSize = stream.readInt(); + decodedExistenceProofBody.keysToProve = new LedgerKey[keysToProveSize]; + for (int i = 0; i < keysToProveSize; i++) { + decodedExistenceProofBody.keysToProve[i] = LedgerKey.decode(stream); + } + int lowBoundEntriesSize = stream.readInt(); + decodedExistenceProofBody.lowBoundEntries = new ColdArchiveBucketEntry[lowBoundEntriesSize]; + for (int i = 0; i < lowBoundEntriesSize; i++) { + decodedExistenceProofBody.lowBoundEntries[i] = ColdArchiveBucketEntry.decode(stream); + } + int highBoundEntriesSize = stream.readInt(); + decodedExistenceProofBody.highBoundEntries = new ColdArchiveBucketEntry[highBoundEntriesSize]; + for (int i = 0; i < highBoundEntriesSize; i++) { + decodedExistenceProofBody.highBoundEntries[i] = ColdArchiveBucketEntry.decode(stream); + } + int proofLevelsSize = stream.readInt(); + decodedExistenceProofBody.proofLevels = new ProofLevel[proofLevelsSize]; + for (int i = 0; i < proofLevelsSize; i++) { + decodedExistenceProofBody.proofLevels[i] = ProofLevel.decode(stream); + } + return decodedExistenceProofBody; + } + + public static ExistenceProofBody fromXdrBase64(String xdr) throws IOException { + byte[] bytes = Base64Factory.getInstance().decode(xdr); + return fromXdrByteArray(bytes); + } + + public static ExistenceProofBody fromXdrByteArray(byte[] xdr) throws IOException { + ByteArrayInputStream byteArrayInputStream = new ByteArrayInputStream(xdr); + XdrDataInputStream xdrDataInputStream = new XdrDataInputStream(byteArrayInputStream); + return decode(xdrDataInputStream); + } +} diff --git a/src/main/java/org/stellar/sdk/xdr/HostFunction.java b/src/main/java/org/stellar/sdk/xdr/HostFunction.java index e1d7e355f..30008da52 100644 --- a/src/main/java/org/stellar/sdk/xdr/HostFunction.java +++ b/src/main/java/org/stellar/sdk/xdr/HostFunction.java @@ -23,6 +23,8 @@ * CreateContractArgs createContract; * case HOST_FUNCTION_TYPE_UPLOAD_CONTRACT_WASM: * opaque wasm<>; + * case HOST_FUNCTION_TYPE_CREATE_CONTRACT_V2: + * CreateContractArgsV2 createContractV2; * }; * */ @@ -35,6 +37,7 @@ public class HostFunction implements XdrElement { private InvokeContractArgs invokeContract; private CreateContractArgs createContract; private byte[] wasm; + private CreateContractArgsV2 createContractV2; public void encode(XdrDataOutputStream stream) throws IOException { stream.writeInt(discriminant.getValue()); @@ -50,6 +53,9 @@ public void encode(XdrDataOutputStream stream) throws IOException { stream.writeInt(wasmSize); stream.write(getWasm(), 0, wasmSize); break; + case HOST_FUNCTION_TYPE_CREATE_CONTRACT_V2: + createContractV2.encode(stream); + break; } } @@ -69,6 +75,9 @@ public static HostFunction decode(XdrDataInputStream stream) throws IOException decodedHostFunction.wasm = new byte[wasmSize]; stream.read(decodedHostFunction.wasm, 0, wasmSize); break; + case HOST_FUNCTION_TYPE_CREATE_CONTRACT_V2: + decodedHostFunction.createContractV2 = CreateContractArgsV2.decode(stream); + break; } return decodedHostFunction; } diff --git a/src/main/java/org/stellar/sdk/xdr/HostFunctionType.java b/src/main/java/org/stellar/sdk/xdr/HostFunctionType.java index 3ee4ccaae..1a101de2e 100644 --- a/src/main/java/org/stellar/sdk/xdr/HostFunctionType.java +++ b/src/main/java/org/stellar/sdk/xdr/HostFunctionType.java @@ -15,14 +15,16 @@ * { * HOST_FUNCTION_TYPE_INVOKE_CONTRACT = 0, * HOST_FUNCTION_TYPE_CREATE_CONTRACT = 1, - * HOST_FUNCTION_TYPE_UPLOAD_CONTRACT_WASM = 2 + * HOST_FUNCTION_TYPE_UPLOAD_CONTRACT_WASM = 2, + * HOST_FUNCTION_TYPE_CREATE_CONTRACT_V2 = 3 * }; * */ public enum HostFunctionType implements XdrElement { HOST_FUNCTION_TYPE_INVOKE_CONTRACT(0), HOST_FUNCTION_TYPE_CREATE_CONTRACT(1), - HOST_FUNCTION_TYPE_UPLOAD_CONTRACT_WASM(2); + HOST_FUNCTION_TYPE_UPLOAD_CONTRACT_WASM(2), + HOST_FUNCTION_TYPE_CREATE_CONTRACT_V2(3); private final int value; @@ -43,6 +45,8 @@ public static HostFunctionType decode(XdrDataInputStream stream) throws IOExcept return HOST_FUNCTION_TYPE_CREATE_CONTRACT; case 2: return HOST_FUNCTION_TYPE_UPLOAD_CONTRACT_WASM; + case 3: + return HOST_FUNCTION_TYPE_CREATE_CONTRACT_V2; default: throw new IllegalArgumentException("Unknown enum value: " + value); } diff --git a/src/main/java/org/stellar/sdk/xdr/HotArchiveBucketEntry.java b/src/main/java/org/stellar/sdk/xdr/HotArchiveBucketEntry.java new file mode 100644 index 000000000..a10e9a6ac --- /dev/null +++ b/src/main/java/org/stellar/sdk/xdr/HotArchiveBucketEntry.java @@ -0,0 +1,86 @@ +// Automatically generated by xdrgen +// DO NOT EDIT or your changes may be overwritten + +package org.stellar.sdk.xdr; + +import java.io.ByteArrayInputStream; +import java.io.IOException; +import lombok.AllArgsConstructor; +import lombok.Builder; +import lombok.Data; +import lombok.NoArgsConstructor; +import org.stellar.sdk.Base64Factory; + +/** + * HotArchiveBucketEntry's original definition in the XDR file is: + * + *
+ * union HotArchiveBucketEntry switch (HotArchiveBucketEntryType type)
+ * {
+ * case HOT_ARCHIVE_ARCHIVED:
+ *     LedgerEntry archivedEntry;
+ *
+ * case HOT_ARCHIVE_LIVE:
+ * case HOT_ARCHIVE_DELETED:
+ *     LedgerKey key;
+ * case HOT_ARCHIVE_METAENTRY:
+ *     BucketMetadata metaEntry;
+ * };
+ * 
+ */ +@Data +@NoArgsConstructor +@AllArgsConstructor +@Builder(toBuilder = true) +public class HotArchiveBucketEntry implements XdrElement { + private HotArchiveBucketEntryType discriminant; + private LedgerEntry archivedEntry; + private LedgerKey key; + private BucketMetadata metaEntry; + + public void encode(XdrDataOutputStream stream) throws IOException { + stream.writeInt(discriminant.getValue()); + switch (discriminant) { + case HOT_ARCHIVE_ARCHIVED: + archivedEntry.encode(stream); + break; + case HOT_ARCHIVE_LIVE: + case HOT_ARCHIVE_DELETED: + key.encode(stream); + break; + case HOT_ARCHIVE_METAENTRY: + metaEntry.encode(stream); + break; + } + } + + public static HotArchiveBucketEntry decode(XdrDataInputStream stream) throws IOException { + HotArchiveBucketEntry decodedHotArchiveBucketEntry = new HotArchiveBucketEntry(); + HotArchiveBucketEntryType discriminant = HotArchiveBucketEntryType.decode(stream); + decodedHotArchiveBucketEntry.setDiscriminant(discriminant); + switch (decodedHotArchiveBucketEntry.getDiscriminant()) { + case HOT_ARCHIVE_ARCHIVED: + decodedHotArchiveBucketEntry.archivedEntry = LedgerEntry.decode(stream); + break; + case HOT_ARCHIVE_LIVE: + case HOT_ARCHIVE_DELETED: + decodedHotArchiveBucketEntry.key = LedgerKey.decode(stream); + break; + case HOT_ARCHIVE_METAENTRY: + decodedHotArchiveBucketEntry.metaEntry = BucketMetadata.decode(stream); + break; + } + return decodedHotArchiveBucketEntry; + } + + public static HotArchiveBucketEntry fromXdrBase64(String xdr) throws IOException { + byte[] bytes = Base64Factory.getInstance().decode(xdr); + return fromXdrByteArray(bytes); + } + + public static HotArchiveBucketEntry fromXdrByteArray(byte[] xdr) throws IOException { + ByteArrayInputStream byteArrayInputStream = new ByteArrayInputStream(xdr); + XdrDataInputStream xdrDataInputStream = new XdrDataInputStream(byteArrayInputStream); + return decode(xdrDataInputStream); + } +} diff --git a/src/main/java/org/stellar/sdk/xdr/HotArchiveBucketEntryType.java b/src/main/java/org/stellar/sdk/xdr/HotArchiveBucketEntryType.java new file mode 100644 index 000000000..913c752da --- /dev/null +++ b/src/main/java/org/stellar/sdk/xdr/HotArchiveBucketEntryType.java @@ -0,0 +1,71 @@ +// Automatically generated by xdrgen +// DO NOT EDIT or your changes may be overwritten + +package org.stellar.sdk.xdr; + +import java.io.ByteArrayInputStream; +import java.io.IOException; +import org.stellar.sdk.Base64Factory; + +/** + * HotArchiveBucketEntryType's original definition in the XDR file is: + * + *
+ * enum HotArchiveBucketEntryType
+ * {
+ *     HOT_ARCHIVE_METAENTRY = -1, // Bucket metadata, should come first.
+ *     HOT_ARCHIVE_ARCHIVED = 0,   // Entry is Archived
+ *     HOT_ARCHIVE_LIVE = 1,       // Entry was previously HOT_ARCHIVE_ARCHIVED, or HOT_ARCHIVE_DELETED, but
+ *                                 // has been added back to the live BucketList.
+ *                                 // Does not need to be persisted.
+ *     HOT_ARCHIVE_DELETED = 2     // Entry deleted (Note: must be persisted in archive)
+ * };
+ * 
+ */ +public enum HotArchiveBucketEntryType implements XdrElement { + HOT_ARCHIVE_METAENTRY(-1), + HOT_ARCHIVE_ARCHIVED(0), + HOT_ARCHIVE_LIVE(1), + HOT_ARCHIVE_DELETED(2); + + private final int value; + + HotArchiveBucketEntryType(int value) { + this.value = value; + } + + public int getValue() { + return value; + } + + public static HotArchiveBucketEntryType decode(XdrDataInputStream stream) throws IOException { + int value = stream.readInt(); + switch (value) { + case -1: + return HOT_ARCHIVE_METAENTRY; + case 0: + return HOT_ARCHIVE_ARCHIVED; + case 1: + return HOT_ARCHIVE_LIVE; + case 2: + return HOT_ARCHIVE_DELETED; + default: + throw new IllegalArgumentException("Unknown enum value: " + value); + } + } + + public void encode(XdrDataOutputStream stream) throws IOException { + stream.writeInt(value); + } + + public static HotArchiveBucketEntryType fromXdrBase64(String xdr) throws IOException { + byte[] bytes = Base64Factory.getInstance().decode(xdr); + return fromXdrByteArray(bytes); + } + + public static HotArchiveBucketEntryType fromXdrByteArray(byte[] xdr) throws IOException { + ByteArrayInputStream byteArrayInputStream = new ByteArrayInputStream(xdr); + XdrDataInputStream xdrDataInputStream = new XdrDataInputStream(byteArrayInputStream); + return decode(xdrDataInputStream); + } +} diff --git a/src/main/java/org/stellar/sdk/xdr/MessageType.java b/src/main/java/org/stellar/sdk/xdr/MessageType.java index e7d48e867..65fba5070 100644 --- a/src/main/java/org/stellar/sdk/xdr/MessageType.java +++ b/src/main/java/org/stellar/sdk/xdr/MessageType.java @@ -42,7 +42,12 @@ * SEND_MORE_EXTENDED = 20, * * FLOOD_ADVERT = 18, - * FLOOD_DEMAND = 19 + * FLOOD_DEMAND = 19, + * + * TIME_SLICED_SURVEY_REQUEST = 21, + * TIME_SLICED_SURVEY_RESPONSE = 22, + * TIME_SLICED_SURVEY_START_COLLECTING = 23, + * TIME_SLICED_SURVEY_STOP_COLLECTING = 24 * }; * */ @@ -66,7 +71,11 @@ public enum MessageType implements XdrElement { SEND_MORE(16), SEND_MORE_EXTENDED(20), FLOOD_ADVERT(18), - FLOOD_DEMAND(19); + FLOOD_DEMAND(19), + TIME_SLICED_SURVEY_REQUEST(21), + TIME_SLICED_SURVEY_RESPONSE(22), + TIME_SLICED_SURVEY_START_COLLECTING(23), + TIME_SLICED_SURVEY_STOP_COLLECTING(24); private final int value; @@ -121,6 +130,14 @@ public static MessageType decode(XdrDataInputStream stream) throws IOException { return FLOOD_ADVERT; case 19: return FLOOD_DEMAND; + case 21: + return TIME_SLICED_SURVEY_REQUEST; + case 22: + return TIME_SLICED_SURVEY_RESPONSE; + case 23: + return TIME_SLICED_SURVEY_START_COLLECTING; + case 24: + return TIME_SLICED_SURVEY_STOP_COLLECTING; default: throw new IllegalArgumentException("Unknown enum value: " + value); } diff --git a/src/main/java/org/stellar/sdk/xdr/NonexistenceProofBody.java b/src/main/java/org/stellar/sdk/xdr/NonexistenceProofBody.java new file mode 100644 index 000000000..6a944889c --- /dev/null +++ b/src/main/java/org/stellar/sdk/xdr/NonexistenceProofBody.java @@ -0,0 +1,74 @@ +// Automatically generated by xdrgen +// DO NOT EDIT or your changes may be overwritten + +package org.stellar.sdk.xdr; + +import java.io.ByteArrayInputStream; +import java.io.IOException; +import lombok.AllArgsConstructor; +import lombok.Builder; +import lombok.Data; +import lombok.NoArgsConstructor; +import org.stellar.sdk.Base64Factory; + +/** + * NonexistenceProofBody's original definition in the XDR file is: + * + *
+ * struct NonexistenceProofBody
+ * {
+ *     ColdArchiveBucketEntry entriesToProve<>;
+ *
+ *     // Vector of vectors, where proofLevels[level]
+ *     // contains all HashNodes that correspond with that level
+ *     ProofLevel proofLevels<>;
+ * };
+ * 
+ */ +@Data +@NoArgsConstructor +@AllArgsConstructor +@Builder(toBuilder = true) +public class NonexistenceProofBody implements XdrElement { + private ColdArchiveBucketEntry[] entriesToProve; + private ProofLevel[] proofLevels; + + public void encode(XdrDataOutputStream stream) throws IOException { + int entriesToProveSize = getEntriesToProve().length; + stream.writeInt(entriesToProveSize); + for (int i = 0; i < entriesToProveSize; i++) { + entriesToProve[i].encode(stream); + } + int proofLevelsSize = getProofLevels().length; + stream.writeInt(proofLevelsSize); + for (int i = 0; i < proofLevelsSize; i++) { + proofLevels[i].encode(stream); + } + } + + public static NonexistenceProofBody decode(XdrDataInputStream stream) throws IOException { + NonexistenceProofBody decodedNonexistenceProofBody = new NonexistenceProofBody(); + int entriesToProveSize = stream.readInt(); + decodedNonexistenceProofBody.entriesToProve = new ColdArchiveBucketEntry[entriesToProveSize]; + for (int i = 0; i < entriesToProveSize; i++) { + decodedNonexistenceProofBody.entriesToProve[i] = ColdArchiveBucketEntry.decode(stream); + } + int proofLevelsSize = stream.readInt(); + decodedNonexistenceProofBody.proofLevels = new ProofLevel[proofLevelsSize]; + for (int i = 0; i < proofLevelsSize; i++) { + decodedNonexistenceProofBody.proofLevels[i] = ProofLevel.decode(stream); + } + return decodedNonexistenceProofBody; + } + + public static NonexistenceProofBody fromXdrBase64(String xdr) throws IOException { + byte[] bytes = Base64Factory.getInstance().decode(xdr); + return fromXdrByteArray(bytes); + } + + public static NonexistenceProofBody fromXdrByteArray(byte[] xdr) throws IOException { + ByteArrayInputStream byteArrayInputStream = new ByteArrayInputStream(xdr); + XdrDataInputStream xdrDataInputStream = new XdrDataInputStream(byteArrayInputStream); + return decode(xdrDataInputStream); + } +} diff --git a/src/main/java/org/stellar/sdk/xdr/ProofLevel.java b/src/main/java/org/stellar/sdk/xdr/ProofLevel.java new file mode 100644 index 000000000..f4649d220 --- /dev/null +++ b/src/main/java/org/stellar/sdk/xdr/ProofLevel.java @@ -0,0 +1,54 @@ +// Automatically generated by xdrgen +// DO NOT EDIT or your changes may be overwritten + +package org.stellar.sdk.xdr; + +import java.io.ByteArrayInputStream; +import java.io.IOException; +import lombok.AllArgsConstructor; +import lombok.Data; +import lombok.NoArgsConstructor; +import org.stellar.sdk.Base64Factory; + +/** + * ProofLevel's original definition in the XDR file is: + * + *
+ * typedef ArchivalProofNode ProofLevel<>;
+ * 
+ */ +@Data +@NoArgsConstructor +@AllArgsConstructor +public class ProofLevel implements XdrElement { + private ArchivalProofNode[] ProofLevel; + + public void encode(XdrDataOutputStream stream) throws IOException { + int ProofLevelSize = getProofLevel().length; + stream.writeInt(ProofLevelSize); + for (int i = 0; i < ProofLevelSize; i++) { + ProofLevel[i].encode(stream); + } + } + + public static ProofLevel decode(XdrDataInputStream stream) throws IOException { + ProofLevel decodedProofLevel = new ProofLevel(); + int ProofLevelSize = stream.readInt(); + decodedProofLevel.ProofLevel = new ArchivalProofNode[ProofLevelSize]; + for (int i = 0; i < ProofLevelSize; i++) { + decodedProofLevel.ProofLevel[i] = ArchivalProofNode.decode(stream); + } + return decodedProofLevel; + } + + public static ProofLevel fromXdrBase64(String xdr) throws IOException { + byte[] bytes = Base64Factory.getInstance().decode(xdr); + return fromXdrByteArray(bytes); + } + + public static ProofLevel fromXdrByteArray(byte[] xdr) throws IOException { + ByteArrayInputStream byteArrayInputStream = new ByteArrayInputStream(xdr); + XdrDataInputStream xdrDataInputStream = new XdrDataInputStream(byteArrayInputStream); + return decode(xdrDataInputStream); + } +} diff --git a/src/main/java/org/stellar/sdk/xdr/SCEnvMetaEntry.java b/src/main/java/org/stellar/sdk/xdr/SCEnvMetaEntry.java index 2c87309e1..ae112b266 100644 --- a/src/main/java/org/stellar/sdk/xdr/SCEnvMetaEntry.java +++ b/src/main/java/org/stellar/sdk/xdr/SCEnvMetaEntry.java @@ -18,7 +18,10 @@ * union SCEnvMetaEntry switch (SCEnvMetaKind kind) * { * case SC_ENV_META_KIND_INTERFACE_VERSION: - * uint64 interfaceVersion; + * struct { + * uint32 protocol; + * uint32 preRelease; + * } interfaceVersion; * }; * */ @@ -28,7 +31,7 @@ @Builder(toBuilder = true) public class SCEnvMetaEntry implements XdrElement { private SCEnvMetaKind discriminant; - private Uint64 interfaceVersion; + private SCEnvMetaEntryInterfaceVersion interfaceVersion; public void encode(XdrDataOutputStream stream) throws IOException { stream.writeInt(discriminant.getValue()); @@ -45,7 +48,7 @@ public static SCEnvMetaEntry decode(XdrDataInputStream stream) throws IOExceptio decodedSCEnvMetaEntry.setDiscriminant(discriminant); switch (decodedSCEnvMetaEntry.getDiscriminant()) { case SC_ENV_META_KIND_INTERFACE_VERSION: - decodedSCEnvMetaEntry.interfaceVersion = Uint64.decode(stream); + decodedSCEnvMetaEntry.interfaceVersion = SCEnvMetaEntryInterfaceVersion.decode(stream); break; } return decodedSCEnvMetaEntry; @@ -61,4 +64,48 @@ public static SCEnvMetaEntry fromXdrByteArray(byte[] xdr) throws IOException { XdrDataInputStream xdrDataInputStream = new XdrDataInputStream(byteArrayInputStream); return decode(xdrDataInputStream); } + + /** + * SCEnvMetaEntryInterfaceVersion's original definition in the XDR file is: + * + *
+   * struct {
+   *         uint32 protocol;
+   *         uint32 preRelease;
+   *     }
+   * 
+ */ + @Data + @NoArgsConstructor + @AllArgsConstructor + @Builder(toBuilder = true) + public static class SCEnvMetaEntryInterfaceVersion implements XdrElement { + private Uint32 protocol; + private Uint32 preRelease; + + public void encode(XdrDataOutputStream stream) throws IOException { + protocol.encode(stream); + preRelease.encode(stream); + } + + public static SCEnvMetaEntryInterfaceVersion decode(XdrDataInputStream stream) + throws IOException { + SCEnvMetaEntryInterfaceVersion decodedSCEnvMetaEntryInterfaceVersion = + new SCEnvMetaEntryInterfaceVersion(); + decodedSCEnvMetaEntryInterfaceVersion.protocol = Uint32.decode(stream); + decodedSCEnvMetaEntryInterfaceVersion.preRelease = Uint32.decode(stream); + return decodedSCEnvMetaEntryInterfaceVersion; + } + + public static SCEnvMetaEntryInterfaceVersion fromXdrBase64(String xdr) throws IOException { + byte[] bytes = Base64Factory.getInstance().decode(xdr); + return fromXdrByteArray(bytes); + } + + public static SCEnvMetaEntryInterfaceVersion fromXdrByteArray(byte[] xdr) throws IOException { + ByteArrayInputStream byteArrayInputStream = new ByteArrayInputStream(xdr); + XdrDataInputStream xdrDataInputStream = new XdrDataInputStream(byteArrayInputStream); + return decode(xdrDataInputStream); + } + } } diff --git a/src/main/java/org/stellar/sdk/xdr/SerializedBinaryFuseFilter.java b/src/main/java/org/stellar/sdk/xdr/SerializedBinaryFuseFilter.java new file mode 100644 index 000000000..c8837970f --- /dev/null +++ b/src/main/java/org/stellar/sdk/xdr/SerializedBinaryFuseFilter.java @@ -0,0 +1,93 @@ +// Automatically generated by xdrgen +// DO NOT EDIT or your changes may be overwritten + +package org.stellar.sdk.xdr; + +import java.io.ByteArrayInputStream; +import java.io.IOException; +import lombok.AllArgsConstructor; +import lombok.Builder; +import lombok.Data; +import lombok.NoArgsConstructor; +import org.stellar.sdk.Base64Factory; + +/** + * SerializedBinaryFuseFilter's original definition in the XDR file is: + * + *
+ * struct SerializedBinaryFuseFilter
+ * {
+ *     BinaryFuseFilterType type;
+ *
+ *     // Seed used to hash input to filter
+ *     ShortHashSeed inputHashSeed;
+ *
+ *     // Seed used for internal filter hash operations
+ *     ShortHashSeed filterSeed;
+ *     uint32 segmentLength;
+ *     uint32 segementLengthMask;
+ *     uint32 segmentCount;
+ *     uint32 segmentCountLength;
+ *     uint32 fingerprintLength; // Length in terms of element count, not bytes
+ *
+ *     // Array of uint8_t, uint16_t, or uint32_t depending on filter type
+ *     opaque fingerprints<>;
+ * };
+ * 
+ */ +@Data +@NoArgsConstructor +@AllArgsConstructor +@Builder(toBuilder = true) +public class SerializedBinaryFuseFilter implements XdrElement { + private BinaryFuseFilterType type; + private ShortHashSeed inputHashSeed; + private ShortHashSeed filterSeed; + private Uint32 segmentLength; + private Uint32 segementLengthMask; + private Uint32 segmentCount; + private Uint32 segmentCountLength; + private Uint32 fingerprintLength; + private byte[] fingerprints; + + public void encode(XdrDataOutputStream stream) throws IOException { + type.encode(stream); + inputHashSeed.encode(stream); + filterSeed.encode(stream); + segmentLength.encode(stream); + segementLengthMask.encode(stream); + segmentCount.encode(stream); + segmentCountLength.encode(stream); + fingerprintLength.encode(stream); + int fingerprintsSize = fingerprints.length; + stream.writeInt(fingerprintsSize); + stream.write(getFingerprints(), 0, fingerprintsSize); + } + + public static SerializedBinaryFuseFilter decode(XdrDataInputStream stream) throws IOException { + SerializedBinaryFuseFilter decodedSerializedBinaryFuseFilter = new SerializedBinaryFuseFilter(); + decodedSerializedBinaryFuseFilter.type = BinaryFuseFilterType.decode(stream); + decodedSerializedBinaryFuseFilter.inputHashSeed = ShortHashSeed.decode(stream); + decodedSerializedBinaryFuseFilter.filterSeed = ShortHashSeed.decode(stream); + decodedSerializedBinaryFuseFilter.segmentLength = Uint32.decode(stream); + decodedSerializedBinaryFuseFilter.segementLengthMask = Uint32.decode(stream); + decodedSerializedBinaryFuseFilter.segmentCount = Uint32.decode(stream); + decodedSerializedBinaryFuseFilter.segmentCountLength = Uint32.decode(stream); + decodedSerializedBinaryFuseFilter.fingerprintLength = Uint32.decode(stream); + int fingerprintsSize = stream.readInt(); + decodedSerializedBinaryFuseFilter.fingerprints = new byte[fingerprintsSize]; + stream.read(decodedSerializedBinaryFuseFilter.fingerprints, 0, fingerprintsSize); + return decodedSerializedBinaryFuseFilter; + } + + public static SerializedBinaryFuseFilter fromXdrBase64(String xdr) throws IOException { + byte[] bytes = Base64Factory.getInstance().decode(xdr); + return fromXdrByteArray(bytes); + } + + public static SerializedBinaryFuseFilter fromXdrByteArray(byte[] xdr) throws IOException { + ByteArrayInputStream byteArrayInputStream = new ByteArrayInputStream(xdr); + XdrDataInputStream xdrDataInputStream = new XdrDataInputStream(byteArrayInputStream); + return decode(xdrDataInputStream); + } +} diff --git a/src/main/java/org/stellar/sdk/xdr/ShortHashSeed.java b/src/main/java/org/stellar/sdk/xdr/ShortHashSeed.java new file mode 100644 index 000000000..27b6661c2 --- /dev/null +++ b/src/main/java/org/stellar/sdk/xdr/ShortHashSeed.java @@ -0,0 +1,54 @@ +// Automatically generated by xdrgen +// DO NOT EDIT or your changes may be overwritten + +package org.stellar.sdk.xdr; + +import java.io.ByteArrayInputStream; +import java.io.IOException; +import lombok.AllArgsConstructor; +import lombok.Builder; +import lombok.Data; +import lombok.NoArgsConstructor; +import org.stellar.sdk.Base64Factory; + +/** + * ShortHashSeed's original definition in the XDR file is: + * + *
+ * struct ShortHashSeed
+ * {
+ *     opaque seed[16];
+ * };
+ * 
+ */ +@Data +@NoArgsConstructor +@AllArgsConstructor +@Builder(toBuilder = true) +public class ShortHashSeed implements XdrElement { + private byte[] seed; + + public void encode(XdrDataOutputStream stream) throws IOException { + int seedSize = seed.length; + stream.write(getSeed(), 0, seedSize); + } + + public static ShortHashSeed decode(XdrDataInputStream stream) throws IOException { + ShortHashSeed decodedShortHashSeed = new ShortHashSeed(); + int seedSize = 16; + decodedShortHashSeed.seed = new byte[seedSize]; + stream.read(decodedShortHashSeed.seed, 0, seedSize); + return decodedShortHashSeed; + } + + public static ShortHashSeed fromXdrBase64(String xdr) throws IOException { + byte[] bytes = Base64Factory.getInstance().decode(xdr); + return fromXdrByteArray(bytes); + } + + public static ShortHashSeed fromXdrByteArray(byte[] xdr) throws IOException { + ByteArrayInputStream byteArrayInputStream = new ByteArrayInputStream(xdr); + XdrDataInputStream xdrDataInputStream = new XdrDataInputStream(byteArrayInputStream); + return decode(xdrDataInputStream); + } +} diff --git a/src/main/java/org/stellar/sdk/xdr/SignedTimeSlicedSurveyRequestMessage.java b/src/main/java/org/stellar/sdk/xdr/SignedTimeSlicedSurveyRequestMessage.java new file mode 100644 index 000000000..a2f994481 --- /dev/null +++ b/src/main/java/org/stellar/sdk/xdr/SignedTimeSlicedSurveyRequestMessage.java @@ -0,0 +1,59 @@ +// Automatically generated by xdrgen +// DO NOT EDIT or your changes may be overwritten + +package org.stellar.sdk.xdr; + +import java.io.ByteArrayInputStream; +import java.io.IOException; +import lombok.AllArgsConstructor; +import lombok.Builder; +import lombok.Data; +import lombok.NoArgsConstructor; +import org.stellar.sdk.Base64Factory; + +/** + * SignedTimeSlicedSurveyRequestMessage's original definition in the XDR file is: + * + *
+ * struct SignedTimeSlicedSurveyRequestMessage
+ * {
+ *     Signature requestSignature;
+ *     TimeSlicedSurveyRequestMessage request;
+ * };
+ * 
+ */ +@Data +@NoArgsConstructor +@AllArgsConstructor +@Builder(toBuilder = true) +public class SignedTimeSlicedSurveyRequestMessage implements XdrElement { + private Signature requestSignature; + private TimeSlicedSurveyRequestMessage request; + + public void encode(XdrDataOutputStream stream) throws IOException { + requestSignature.encode(stream); + request.encode(stream); + } + + public static SignedTimeSlicedSurveyRequestMessage decode(XdrDataInputStream stream) + throws IOException { + SignedTimeSlicedSurveyRequestMessage decodedSignedTimeSlicedSurveyRequestMessage = + new SignedTimeSlicedSurveyRequestMessage(); + decodedSignedTimeSlicedSurveyRequestMessage.requestSignature = Signature.decode(stream); + decodedSignedTimeSlicedSurveyRequestMessage.request = + TimeSlicedSurveyRequestMessage.decode(stream); + return decodedSignedTimeSlicedSurveyRequestMessage; + } + + public static SignedTimeSlicedSurveyRequestMessage fromXdrBase64(String xdr) throws IOException { + byte[] bytes = Base64Factory.getInstance().decode(xdr); + return fromXdrByteArray(bytes); + } + + public static SignedTimeSlicedSurveyRequestMessage fromXdrByteArray(byte[] xdr) + throws IOException { + ByteArrayInputStream byteArrayInputStream = new ByteArrayInputStream(xdr); + XdrDataInputStream xdrDataInputStream = new XdrDataInputStream(byteArrayInputStream); + return decode(xdrDataInputStream); + } +} diff --git a/src/main/java/org/stellar/sdk/xdr/SignedTimeSlicedSurveyResponseMessage.java b/src/main/java/org/stellar/sdk/xdr/SignedTimeSlicedSurveyResponseMessage.java new file mode 100644 index 000000000..2cd2bde37 --- /dev/null +++ b/src/main/java/org/stellar/sdk/xdr/SignedTimeSlicedSurveyResponseMessage.java @@ -0,0 +1,59 @@ +// Automatically generated by xdrgen +// DO NOT EDIT or your changes may be overwritten + +package org.stellar.sdk.xdr; + +import java.io.ByteArrayInputStream; +import java.io.IOException; +import lombok.AllArgsConstructor; +import lombok.Builder; +import lombok.Data; +import lombok.NoArgsConstructor; +import org.stellar.sdk.Base64Factory; + +/** + * SignedTimeSlicedSurveyResponseMessage's original definition in the XDR file is: + * + *
+ * struct SignedTimeSlicedSurveyResponseMessage
+ * {
+ *     Signature responseSignature;
+ *     TimeSlicedSurveyResponseMessage response;
+ * };
+ * 
+ */ +@Data +@NoArgsConstructor +@AllArgsConstructor +@Builder(toBuilder = true) +public class SignedTimeSlicedSurveyResponseMessage implements XdrElement { + private Signature responseSignature; + private TimeSlicedSurveyResponseMessage response; + + public void encode(XdrDataOutputStream stream) throws IOException { + responseSignature.encode(stream); + response.encode(stream); + } + + public static SignedTimeSlicedSurveyResponseMessage decode(XdrDataInputStream stream) + throws IOException { + SignedTimeSlicedSurveyResponseMessage decodedSignedTimeSlicedSurveyResponseMessage = + new SignedTimeSlicedSurveyResponseMessage(); + decodedSignedTimeSlicedSurveyResponseMessage.responseSignature = Signature.decode(stream); + decodedSignedTimeSlicedSurveyResponseMessage.response = + TimeSlicedSurveyResponseMessage.decode(stream); + return decodedSignedTimeSlicedSurveyResponseMessage; + } + + public static SignedTimeSlicedSurveyResponseMessage fromXdrBase64(String xdr) throws IOException { + byte[] bytes = Base64Factory.getInstance().decode(xdr); + return fromXdrByteArray(bytes); + } + + public static SignedTimeSlicedSurveyResponseMessage fromXdrByteArray(byte[] xdr) + throws IOException { + ByteArrayInputStream byteArrayInputStream = new ByteArrayInputStream(xdr); + XdrDataInputStream xdrDataInputStream = new XdrDataInputStream(byteArrayInputStream); + return decode(xdrDataInputStream); + } +} diff --git a/src/main/java/org/stellar/sdk/xdr/SignedTimeSlicedSurveyStartCollectingMessage.java b/src/main/java/org/stellar/sdk/xdr/SignedTimeSlicedSurveyStartCollectingMessage.java new file mode 100644 index 000000000..993c54473 --- /dev/null +++ b/src/main/java/org/stellar/sdk/xdr/SignedTimeSlicedSurveyStartCollectingMessage.java @@ -0,0 +1,61 @@ +// Automatically generated by xdrgen +// DO NOT EDIT or your changes may be overwritten + +package org.stellar.sdk.xdr; + +import java.io.ByteArrayInputStream; +import java.io.IOException; +import lombok.AllArgsConstructor; +import lombok.Builder; +import lombok.Data; +import lombok.NoArgsConstructor; +import org.stellar.sdk.Base64Factory; + +/** + * SignedTimeSlicedSurveyStartCollectingMessage's original definition in the XDR file is: + * + *
+ * struct SignedTimeSlicedSurveyStartCollectingMessage
+ * {
+ *     Signature signature;
+ *     TimeSlicedSurveyStartCollectingMessage startCollecting;
+ * };
+ * 
+ */ +@Data +@NoArgsConstructor +@AllArgsConstructor +@Builder(toBuilder = true) +public class SignedTimeSlicedSurveyStartCollectingMessage implements XdrElement { + private Signature signature; + private TimeSlicedSurveyStartCollectingMessage startCollecting; + + public void encode(XdrDataOutputStream stream) throws IOException { + signature.encode(stream); + startCollecting.encode(stream); + } + + public static SignedTimeSlicedSurveyStartCollectingMessage decode(XdrDataInputStream stream) + throws IOException { + SignedTimeSlicedSurveyStartCollectingMessage + decodedSignedTimeSlicedSurveyStartCollectingMessage = + new SignedTimeSlicedSurveyStartCollectingMessage(); + decodedSignedTimeSlicedSurveyStartCollectingMessage.signature = Signature.decode(stream); + decodedSignedTimeSlicedSurveyStartCollectingMessage.startCollecting = + TimeSlicedSurveyStartCollectingMessage.decode(stream); + return decodedSignedTimeSlicedSurveyStartCollectingMessage; + } + + public static SignedTimeSlicedSurveyStartCollectingMessage fromXdrBase64(String xdr) + throws IOException { + byte[] bytes = Base64Factory.getInstance().decode(xdr); + return fromXdrByteArray(bytes); + } + + public static SignedTimeSlicedSurveyStartCollectingMessage fromXdrByteArray(byte[] xdr) + throws IOException { + ByteArrayInputStream byteArrayInputStream = new ByteArrayInputStream(xdr); + XdrDataInputStream xdrDataInputStream = new XdrDataInputStream(byteArrayInputStream); + return decode(xdrDataInputStream); + } +} diff --git a/src/main/java/org/stellar/sdk/xdr/SignedTimeSlicedSurveyStopCollectingMessage.java b/src/main/java/org/stellar/sdk/xdr/SignedTimeSlicedSurveyStopCollectingMessage.java new file mode 100644 index 000000000..cb4ae36f2 --- /dev/null +++ b/src/main/java/org/stellar/sdk/xdr/SignedTimeSlicedSurveyStopCollectingMessage.java @@ -0,0 +1,60 @@ +// Automatically generated by xdrgen +// DO NOT EDIT or your changes may be overwritten + +package org.stellar.sdk.xdr; + +import java.io.ByteArrayInputStream; +import java.io.IOException; +import lombok.AllArgsConstructor; +import lombok.Builder; +import lombok.Data; +import lombok.NoArgsConstructor; +import org.stellar.sdk.Base64Factory; + +/** + * SignedTimeSlicedSurveyStopCollectingMessage's original definition in the XDR file is: + * + *
+ * struct SignedTimeSlicedSurveyStopCollectingMessage
+ * {
+ *     Signature signature;
+ *     TimeSlicedSurveyStopCollectingMessage stopCollecting;
+ * };
+ * 
+ */ +@Data +@NoArgsConstructor +@AllArgsConstructor +@Builder(toBuilder = true) +public class SignedTimeSlicedSurveyStopCollectingMessage implements XdrElement { + private Signature signature; + private TimeSlicedSurveyStopCollectingMessage stopCollecting; + + public void encode(XdrDataOutputStream stream) throws IOException { + signature.encode(stream); + stopCollecting.encode(stream); + } + + public static SignedTimeSlicedSurveyStopCollectingMessage decode(XdrDataInputStream stream) + throws IOException { + SignedTimeSlicedSurveyStopCollectingMessage decodedSignedTimeSlicedSurveyStopCollectingMessage = + new SignedTimeSlicedSurveyStopCollectingMessage(); + decodedSignedTimeSlicedSurveyStopCollectingMessage.signature = Signature.decode(stream); + decodedSignedTimeSlicedSurveyStopCollectingMessage.stopCollecting = + TimeSlicedSurveyStopCollectingMessage.decode(stream); + return decodedSignedTimeSlicedSurveyStopCollectingMessage; + } + + public static SignedTimeSlicedSurveyStopCollectingMessage fromXdrBase64(String xdr) + throws IOException { + byte[] bytes = Base64Factory.getInstance().decode(xdr); + return fromXdrByteArray(bytes); + } + + public static SignedTimeSlicedSurveyStopCollectingMessage fromXdrByteArray(byte[] xdr) + throws IOException { + ByteArrayInputStream byteArrayInputStream = new ByteArrayInputStream(xdr); + XdrDataInputStream xdrDataInputStream = new XdrDataInputStream(byteArrayInputStream); + return decode(xdrDataInputStream); + } +} diff --git a/src/main/java/org/stellar/sdk/xdr/SorobanAuthorizedFunction.java b/src/main/java/org/stellar/sdk/xdr/SorobanAuthorizedFunction.java index c78a6bb07..a7b5c3e33 100644 --- a/src/main/java/org/stellar/sdk/xdr/SorobanAuthorizedFunction.java +++ b/src/main/java/org/stellar/sdk/xdr/SorobanAuthorizedFunction.java @@ -19,8 +19,18 @@ * { * case SOROBAN_AUTHORIZED_FUNCTION_TYPE_CONTRACT_FN: * InvokeContractArgs contractFn; + * // This variant of auth payload for creating new contract instances + * // doesn't allow specifying the constructor arguments, creating contracts + * // with constructors that take arguments is only possible by authorizing + * // `SOROBAN_AUTHORIZED_FUNCTION_TYPE_CREATE_CONTRACT_V2_HOST_FN` + * // (protocol 22+). * case SOROBAN_AUTHORIZED_FUNCTION_TYPE_CREATE_CONTRACT_HOST_FN: * CreateContractArgs createContractHostFn; + * // This variant of auth payload for creating new contract instances + * // is only accepted in and after protocol 22. It allows authorizing the + * // contract constructor arguments. + * case SOROBAN_AUTHORIZED_FUNCTION_TYPE_CREATE_CONTRACT_V2_HOST_FN: + * CreateContractArgsV2 createContractV2HostFn; * }; * */ @@ -32,6 +42,7 @@ public class SorobanAuthorizedFunction implements XdrElement { private SorobanAuthorizedFunctionType discriminant; private InvokeContractArgs contractFn; private CreateContractArgs createContractHostFn; + private CreateContractArgsV2 createContractV2HostFn; public void encode(XdrDataOutputStream stream) throws IOException { stream.writeInt(discriminant.getValue()); @@ -42,6 +53,9 @@ public void encode(XdrDataOutputStream stream) throws IOException { case SOROBAN_AUTHORIZED_FUNCTION_TYPE_CREATE_CONTRACT_HOST_FN: createContractHostFn.encode(stream); break; + case SOROBAN_AUTHORIZED_FUNCTION_TYPE_CREATE_CONTRACT_V2_HOST_FN: + createContractV2HostFn.encode(stream); + break; } } @@ -56,6 +70,10 @@ public static SorobanAuthorizedFunction decode(XdrDataInputStream stream) throws case SOROBAN_AUTHORIZED_FUNCTION_TYPE_CREATE_CONTRACT_HOST_FN: decodedSorobanAuthorizedFunction.createContractHostFn = CreateContractArgs.decode(stream); break; + case SOROBAN_AUTHORIZED_FUNCTION_TYPE_CREATE_CONTRACT_V2_HOST_FN: + decodedSorobanAuthorizedFunction.createContractV2HostFn = + CreateContractArgsV2.decode(stream); + break; } return decodedSorobanAuthorizedFunction; } diff --git a/src/main/java/org/stellar/sdk/xdr/SorobanAuthorizedFunctionType.java b/src/main/java/org/stellar/sdk/xdr/SorobanAuthorizedFunctionType.java index 513cccce8..906042719 100644 --- a/src/main/java/org/stellar/sdk/xdr/SorobanAuthorizedFunctionType.java +++ b/src/main/java/org/stellar/sdk/xdr/SorobanAuthorizedFunctionType.java @@ -14,13 +14,15 @@ * enum SorobanAuthorizedFunctionType * { * SOROBAN_AUTHORIZED_FUNCTION_TYPE_CONTRACT_FN = 0, - * SOROBAN_AUTHORIZED_FUNCTION_TYPE_CREATE_CONTRACT_HOST_FN = 1 + * SOROBAN_AUTHORIZED_FUNCTION_TYPE_CREATE_CONTRACT_HOST_FN = 1, + * SOROBAN_AUTHORIZED_FUNCTION_TYPE_CREATE_CONTRACT_V2_HOST_FN = 2 * }; * */ public enum SorobanAuthorizedFunctionType implements XdrElement { SOROBAN_AUTHORIZED_FUNCTION_TYPE_CONTRACT_FN(0), - SOROBAN_AUTHORIZED_FUNCTION_TYPE_CREATE_CONTRACT_HOST_FN(1); + SOROBAN_AUTHORIZED_FUNCTION_TYPE_CREATE_CONTRACT_HOST_FN(1), + SOROBAN_AUTHORIZED_FUNCTION_TYPE_CREATE_CONTRACT_V2_HOST_FN(2); private final int value; @@ -39,6 +41,8 @@ public static SorobanAuthorizedFunctionType decode(XdrDataInputStream stream) th return SOROBAN_AUTHORIZED_FUNCTION_TYPE_CONTRACT_FN; case 1: return SOROBAN_AUTHORIZED_FUNCTION_TYPE_CREATE_CONTRACT_HOST_FN; + case 2: + return SOROBAN_AUTHORIZED_FUNCTION_TYPE_CREATE_CONTRACT_V2_HOST_FN; default: throw new IllegalArgumentException("Unknown enum value: " + value); } diff --git a/src/main/java/org/stellar/sdk/xdr/StellarMessage.java b/src/main/java/org/stellar/sdk/xdr/StellarMessage.java index 01dc1390b..34a21ae77 100644 --- a/src/main/java/org/stellar/sdk/xdr/StellarMessage.java +++ b/src/main/java/org/stellar/sdk/xdr/StellarMessage.java @@ -46,6 +46,20 @@ * case SURVEY_RESPONSE: * SignedSurveyResponseMessage signedSurveyResponseMessage; * + * case TIME_SLICED_SURVEY_REQUEST: + * SignedTimeSlicedSurveyRequestMessage signedTimeSlicedSurveyRequestMessage; + * + * case TIME_SLICED_SURVEY_RESPONSE: + * SignedTimeSlicedSurveyResponseMessage signedTimeSlicedSurveyResponseMessage; + * + * case TIME_SLICED_SURVEY_START_COLLECTING: + * SignedTimeSlicedSurveyStartCollectingMessage + * signedTimeSlicedSurveyStartCollectingMessage; + * + * case TIME_SLICED_SURVEY_STOP_COLLECTING: + * SignedTimeSlicedSurveyStopCollectingMessage + * signedTimeSlicedSurveyStopCollectingMessage; + * * // SCP * case GET_SCP_QUORUMSET: * uint256 qSetHash; @@ -84,6 +98,10 @@ public class StellarMessage implements XdrElement { private TransactionEnvelope transaction; private SignedSurveyRequestMessage signedSurveyRequestMessage; private SignedSurveyResponseMessage signedSurveyResponseMessage; + private SignedTimeSlicedSurveyRequestMessage signedTimeSlicedSurveyRequestMessage; + private SignedTimeSlicedSurveyResponseMessage signedTimeSlicedSurveyResponseMessage; + private SignedTimeSlicedSurveyStartCollectingMessage signedTimeSlicedSurveyStartCollectingMessage; + private SignedTimeSlicedSurveyStopCollectingMessage signedTimeSlicedSurveyStopCollectingMessage; private Uint256 qSetHash; private SCPQuorumSet qSet; private SCPEnvelope envelope; @@ -135,6 +153,18 @@ public void encode(XdrDataOutputStream stream) throws IOException { case SURVEY_RESPONSE: signedSurveyResponseMessage.encode(stream); break; + case TIME_SLICED_SURVEY_REQUEST: + signedTimeSlicedSurveyRequestMessage.encode(stream); + break; + case TIME_SLICED_SURVEY_RESPONSE: + signedTimeSlicedSurveyResponseMessage.encode(stream); + break; + case TIME_SLICED_SURVEY_START_COLLECTING: + signedTimeSlicedSurveyStartCollectingMessage.encode(stream); + break; + case TIME_SLICED_SURVEY_STOP_COLLECTING: + signedTimeSlicedSurveyStopCollectingMessage.encode(stream); + break; case GET_SCP_QUORUMSET: qSetHash.encode(stream); break; @@ -208,6 +238,22 @@ public static StellarMessage decode(XdrDataInputStream stream) throws IOExceptio decodedStellarMessage.signedSurveyResponseMessage = SignedSurveyResponseMessage.decode(stream); break; + case TIME_SLICED_SURVEY_REQUEST: + decodedStellarMessage.signedTimeSlicedSurveyRequestMessage = + SignedTimeSlicedSurveyRequestMessage.decode(stream); + break; + case TIME_SLICED_SURVEY_RESPONSE: + decodedStellarMessage.signedTimeSlicedSurveyResponseMessage = + SignedTimeSlicedSurveyResponseMessage.decode(stream); + break; + case TIME_SLICED_SURVEY_START_COLLECTING: + decodedStellarMessage.signedTimeSlicedSurveyStartCollectingMessage = + SignedTimeSlicedSurveyStartCollectingMessage.decode(stream); + break; + case TIME_SLICED_SURVEY_STOP_COLLECTING: + decodedStellarMessage.signedTimeSlicedSurveyStopCollectingMessage = + SignedTimeSlicedSurveyStopCollectingMessage.decode(stream); + break; case GET_SCP_QUORUMSET: decodedStellarMessage.qSetHash = Uint256.decode(stream); break; diff --git a/src/main/java/org/stellar/sdk/xdr/SurveyMessageCommandType.java b/src/main/java/org/stellar/sdk/xdr/SurveyMessageCommandType.java index 77e357665..41d7f37d0 100644 --- a/src/main/java/org/stellar/sdk/xdr/SurveyMessageCommandType.java +++ b/src/main/java/org/stellar/sdk/xdr/SurveyMessageCommandType.java @@ -13,12 +13,14 @@ *
  * enum SurveyMessageCommandType
  * {
- *     SURVEY_TOPOLOGY = 0
+ *     SURVEY_TOPOLOGY = 0,
+ *     TIME_SLICED_SURVEY_TOPOLOGY = 1
  * };
  * 
*/ public enum SurveyMessageCommandType implements XdrElement { - SURVEY_TOPOLOGY(0); + SURVEY_TOPOLOGY(0), + TIME_SLICED_SURVEY_TOPOLOGY(1); private final int value; @@ -35,6 +37,8 @@ public static SurveyMessageCommandType decode(XdrDataInputStream stream) throws switch (value) { case 0: return SURVEY_TOPOLOGY; + case 1: + return TIME_SLICED_SURVEY_TOPOLOGY; default: throw new IllegalArgumentException("Unknown enum value: " + value); } diff --git a/src/main/java/org/stellar/sdk/xdr/SurveyMessageResponseType.java b/src/main/java/org/stellar/sdk/xdr/SurveyMessageResponseType.java index e082ef5c3..d655f79f4 100644 --- a/src/main/java/org/stellar/sdk/xdr/SurveyMessageResponseType.java +++ b/src/main/java/org/stellar/sdk/xdr/SurveyMessageResponseType.java @@ -14,13 +14,15 @@ * enum SurveyMessageResponseType * { * SURVEY_TOPOLOGY_RESPONSE_V0 = 0, - * SURVEY_TOPOLOGY_RESPONSE_V1 = 1 + * SURVEY_TOPOLOGY_RESPONSE_V1 = 1, + * SURVEY_TOPOLOGY_RESPONSE_V2 = 2 * }; * */ public enum SurveyMessageResponseType implements XdrElement { SURVEY_TOPOLOGY_RESPONSE_V0(0), - SURVEY_TOPOLOGY_RESPONSE_V1(1); + SURVEY_TOPOLOGY_RESPONSE_V1(1), + SURVEY_TOPOLOGY_RESPONSE_V2(2); private final int value; @@ -39,6 +41,8 @@ public static SurveyMessageResponseType decode(XdrDataInputStream stream) throws return SURVEY_TOPOLOGY_RESPONSE_V0; case 1: return SURVEY_TOPOLOGY_RESPONSE_V1; + case 2: + return SURVEY_TOPOLOGY_RESPONSE_V2; default: throw new IllegalArgumentException("Unknown enum value: " + value); } diff --git a/src/main/java/org/stellar/sdk/xdr/SurveyResponseBody.java b/src/main/java/org/stellar/sdk/xdr/SurveyResponseBody.java index aeda7dab3..4c2d5524d 100644 --- a/src/main/java/org/stellar/sdk/xdr/SurveyResponseBody.java +++ b/src/main/java/org/stellar/sdk/xdr/SurveyResponseBody.java @@ -21,6 +21,8 @@ * TopologyResponseBodyV0 topologyResponseBodyV0; * case SURVEY_TOPOLOGY_RESPONSE_V1: * TopologyResponseBodyV1 topologyResponseBodyV1; + * case SURVEY_TOPOLOGY_RESPONSE_V2: + * TopologyResponseBodyV2 topologyResponseBodyV2; * }; * */ @@ -32,6 +34,7 @@ public class SurveyResponseBody implements XdrElement { private SurveyMessageResponseType discriminant; private TopologyResponseBodyV0 topologyResponseBodyV0; private TopologyResponseBodyV1 topologyResponseBodyV1; + private TopologyResponseBodyV2 topologyResponseBodyV2; public void encode(XdrDataOutputStream stream) throws IOException { stream.writeInt(discriminant.getValue()); @@ -42,6 +45,9 @@ public void encode(XdrDataOutputStream stream) throws IOException { case SURVEY_TOPOLOGY_RESPONSE_V1: topologyResponseBodyV1.encode(stream); break; + case SURVEY_TOPOLOGY_RESPONSE_V2: + topologyResponseBodyV2.encode(stream); + break; } } @@ -56,6 +62,9 @@ public static SurveyResponseBody decode(XdrDataInputStream stream) throws IOExce case SURVEY_TOPOLOGY_RESPONSE_V1: decodedSurveyResponseBody.topologyResponseBodyV1 = TopologyResponseBodyV1.decode(stream); break; + case SURVEY_TOPOLOGY_RESPONSE_V2: + decodedSurveyResponseBody.topologyResponseBodyV2 = TopologyResponseBodyV2.decode(stream); + break; } return decodedSurveyResponseBody; } diff --git a/src/main/java/org/stellar/sdk/xdr/TimeSlicedNodeData.java b/src/main/java/org/stellar/sdk/xdr/TimeSlicedNodeData.java new file mode 100644 index 000000000..56dd494d1 --- /dev/null +++ b/src/main/java/org/stellar/sdk/xdr/TimeSlicedNodeData.java @@ -0,0 +1,93 @@ +// Automatically generated by xdrgen +// DO NOT EDIT or your changes may be overwritten + +package org.stellar.sdk.xdr; + +import java.io.ByteArrayInputStream; +import java.io.IOException; +import lombok.AllArgsConstructor; +import lombok.Builder; +import lombok.Data; +import lombok.NoArgsConstructor; +import org.stellar.sdk.Base64Factory; + +/** + * TimeSlicedNodeData's original definition in the XDR file is: + * + *
+ * struct TimeSlicedNodeData
+ * {
+ *     uint32 addedAuthenticatedPeers;
+ *     uint32 droppedAuthenticatedPeers;
+ *     uint32 totalInboundPeerCount;
+ *     uint32 totalOutboundPeerCount;
+ *
+ *     // SCP stats
+ *     uint32 p75SCPFirstToSelfLatencyMs;
+ *     uint32 p75SCPSelfToOtherLatencyMs;
+ *
+ *     // How many times the node lost sync in the time slice
+ *     uint32 lostSyncCount;
+ *
+ *     // Config data
+ *     bool isValidator;
+ *     uint32 maxInboundPeerCount;
+ *     uint32 maxOutboundPeerCount;
+ * };
+ * 
+ */ +@Data +@NoArgsConstructor +@AllArgsConstructor +@Builder(toBuilder = true) +public class TimeSlicedNodeData implements XdrElement { + private Uint32 addedAuthenticatedPeers; + private Uint32 droppedAuthenticatedPeers; + private Uint32 totalInboundPeerCount; + private Uint32 totalOutboundPeerCount; + private Uint32 p75SCPFirstToSelfLatencyMs; + private Uint32 p75SCPSelfToOtherLatencyMs; + private Uint32 lostSyncCount; + private Boolean isValidator; + private Uint32 maxInboundPeerCount; + private Uint32 maxOutboundPeerCount; + + public void encode(XdrDataOutputStream stream) throws IOException { + addedAuthenticatedPeers.encode(stream); + droppedAuthenticatedPeers.encode(stream); + totalInboundPeerCount.encode(stream); + totalOutboundPeerCount.encode(stream); + p75SCPFirstToSelfLatencyMs.encode(stream); + p75SCPSelfToOtherLatencyMs.encode(stream); + lostSyncCount.encode(stream); + stream.writeInt(isValidator ? 1 : 0); + maxInboundPeerCount.encode(stream); + maxOutboundPeerCount.encode(stream); + } + + public static TimeSlicedNodeData decode(XdrDataInputStream stream) throws IOException { + TimeSlicedNodeData decodedTimeSlicedNodeData = new TimeSlicedNodeData(); + decodedTimeSlicedNodeData.addedAuthenticatedPeers = Uint32.decode(stream); + decodedTimeSlicedNodeData.droppedAuthenticatedPeers = Uint32.decode(stream); + decodedTimeSlicedNodeData.totalInboundPeerCount = Uint32.decode(stream); + decodedTimeSlicedNodeData.totalOutboundPeerCount = Uint32.decode(stream); + decodedTimeSlicedNodeData.p75SCPFirstToSelfLatencyMs = Uint32.decode(stream); + decodedTimeSlicedNodeData.p75SCPSelfToOtherLatencyMs = Uint32.decode(stream); + decodedTimeSlicedNodeData.lostSyncCount = Uint32.decode(stream); + decodedTimeSlicedNodeData.isValidator = stream.readInt() == 1 ? true : false; + decodedTimeSlicedNodeData.maxInboundPeerCount = Uint32.decode(stream); + decodedTimeSlicedNodeData.maxOutboundPeerCount = Uint32.decode(stream); + return decodedTimeSlicedNodeData; + } + + public static TimeSlicedNodeData fromXdrBase64(String xdr) throws IOException { + byte[] bytes = Base64Factory.getInstance().decode(xdr); + return fromXdrByteArray(bytes); + } + + public static TimeSlicedNodeData fromXdrByteArray(byte[] xdr) throws IOException { + ByteArrayInputStream byteArrayInputStream = new ByteArrayInputStream(xdr); + XdrDataInputStream xdrDataInputStream = new XdrDataInputStream(byteArrayInputStream); + return decode(xdrDataInputStream); + } +} diff --git a/src/main/java/org/stellar/sdk/xdr/TimeSlicedPeerData.java b/src/main/java/org/stellar/sdk/xdr/TimeSlicedPeerData.java new file mode 100644 index 000000000..f4e4018cd --- /dev/null +++ b/src/main/java/org/stellar/sdk/xdr/TimeSlicedPeerData.java @@ -0,0 +1,55 @@ +// Automatically generated by xdrgen +// DO NOT EDIT or your changes may be overwritten + +package org.stellar.sdk.xdr; + +import java.io.ByteArrayInputStream; +import java.io.IOException; +import lombok.AllArgsConstructor; +import lombok.Builder; +import lombok.Data; +import lombok.NoArgsConstructor; +import org.stellar.sdk.Base64Factory; + +/** + * TimeSlicedPeerData's original definition in the XDR file is: + * + *
+ * struct TimeSlicedPeerData
+ * {
+ *     PeerStats peerStats;
+ *     uint32 averageLatencyMs;
+ * };
+ * 
+ */ +@Data +@NoArgsConstructor +@AllArgsConstructor +@Builder(toBuilder = true) +public class TimeSlicedPeerData implements XdrElement { + private PeerStats peerStats; + private Uint32 averageLatencyMs; + + public void encode(XdrDataOutputStream stream) throws IOException { + peerStats.encode(stream); + averageLatencyMs.encode(stream); + } + + public static TimeSlicedPeerData decode(XdrDataInputStream stream) throws IOException { + TimeSlicedPeerData decodedTimeSlicedPeerData = new TimeSlicedPeerData(); + decodedTimeSlicedPeerData.peerStats = PeerStats.decode(stream); + decodedTimeSlicedPeerData.averageLatencyMs = Uint32.decode(stream); + return decodedTimeSlicedPeerData; + } + + public static TimeSlicedPeerData fromXdrBase64(String xdr) throws IOException { + byte[] bytes = Base64Factory.getInstance().decode(xdr); + return fromXdrByteArray(bytes); + } + + public static TimeSlicedPeerData fromXdrByteArray(byte[] xdr) throws IOException { + ByteArrayInputStream byteArrayInputStream = new ByteArrayInputStream(xdr); + XdrDataInputStream xdrDataInputStream = new XdrDataInputStream(byteArrayInputStream); + return decode(xdrDataInputStream); + } +} diff --git a/src/main/java/org/stellar/sdk/xdr/TimeSlicedPeerDataList.java b/src/main/java/org/stellar/sdk/xdr/TimeSlicedPeerDataList.java new file mode 100644 index 000000000..1059916c2 --- /dev/null +++ b/src/main/java/org/stellar/sdk/xdr/TimeSlicedPeerDataList.java @@ -0,0 +1,55 @@ +// Automatically generated by xdrgen +// DO NOT EDIT or your changes may be overwritten + +package org.stellar.sdk.xdr; + +import java.io.ByteArrayInputStream; +import java.io.IOException; +import lombok.AllArgsConstructor; +import lombok.Data; +import lombok.NoArgsConstructor; +import org.stellar.sdk.Base64Factory; + +/** + * TimeSlicedPeerDataList's original definition in the XDR file is: + * + *
+ * typedef TimeSlicedPeerData TimeSlicedPeerDataList<25>;
+ * 
+ */ +@Data +@NoArgsConstructor +@AllArgsConstructor +public class TimeSlicedPeerDataList implements XdrElement { + private TimeSlicedPeerData[] TimeSlicedPeerDataList; + + public void encode(XdrDataOutputStream stream) throws IOException { + int TimeSlicedPeerDataListSize = getTimeSlicedPeerDataList().length; + stream.writeInt(TimeSlicedPeerDataListSize); + for (int i = 0; i < TimeSlicedPeerDataListSize; i++) { + TimeSlicedPeerDataList[i].encode(stream); + } + } + + public static TimeSlicedPeerDataList decode(XdrDataInputStream stream) throws IOException { + TimeSlicedPeerDataList decodedTimeSlicedPeerDataList = new TimeSlicedPeerDataList(); + int TimeSlicedPeerDataListSize = stream.readInt(); + decodedTimeSlicedPeerDataList.TimeSlicedPeerDataList = + new TimeSlicedPeerData[TimeSlicedPeerDataListSize]; + for (int i = 0; i < TimeSlicedPeerDataListSize; i++) { + decodedTimeSlicedPeerDataList.TimeSlicedPeerDataList[i] = TimeSlicedPeerData.decode(stream); + } + return decodedTimeSlicedPeerDataList; + } + + public static TimeSlicedPeerDataList fromXdrBase64(String xdr) throws IOException { + byte[] bytes = Base64Factory.getInstance().decode(xdr); + return fromXdrByteArray(bytes); + } + + public static TimeSlicedPeerDataList fromXdrByteArray(byte[] xdr) throws IOException { + ByteArrayInputStream byteArrayInputStream = new ByteArrayInputStream(xdr); + XdrDataInputStream xdrDataInputStream = new XdrDataInputStream(byteArrayInputStream); + return decode(xdrDataInputStream); + } +} diff --git a/src/main/java/org/stellar/sdk/xdr/TimeSlicedSurveyRequestMessage.java b/src/main/java/org/stellar/sdk/xdr/TimeSlicedSurveyRequestMessage.java new file mode 100644 index 000000000..adfdfce16 --- /dev/null +++ b/src/main/java/org/stellar/sdk/xdr/TimeSlicedSurveyRequestMessage.java @@ -0,0 +1,65 @@ +// Automatically generated by xdrgen +// DO NOT EDIT or your changes may be overwritten + +package org.stellar.sdk.xdr; + +import java.io.ByteArrayInputStream; +import java.io.IOException; +import lombok.AllArgsConstructor; +import lombok.Builder; +import lombok.Data; +import lombok.NoArgsConstructor; +import org.stellar.sdk.Base64Factory; + +/** + * TimeSlicedSurveyRequestMessage's original definition in the XDR file is: + * + *
+ * struct TimeSlicedSurveyRequestMessage
+ * {
+ *     SurveyRequestMessage request;
+ *     uint32 nonce;
+ *     uint32 inboundPeersIndex;
+ *     uint32 outboundPeersIndex;
+ * };
+ * 
+ */ +@Data +@NoArgsConstructor +@AllArgsConstructor +@Builder(toBuilder = true) +public class TimeSlicedSurveyRequestMessage implements XdrElement { + private SurveyRequestMessage request; + private Uint32 nonce; + private Uint32 inboundPeersIndex; + private Uint32 outboundPeersIndex; + + public void encode(XdrDataOutputStream stream) throws IOException { + request.encode(stream); + nonce.encode(stream); + inboundPeersIndex.encode(stream); + outboundPeersIndex.encode(stream); + } + + public static TimeSlicedSurveyRequestMessage decode(XdrDataInputStream stream) + throws IOException { + TimeSlicedSurveyRequestMessage decodedTimeSlicedSurveyRequestMessage = + new TimeSlicedSurveyRequestMessage(); + decodedTimeSlicedSurveyRequestMessage.request = SurveyRequestMessage.decode(stream); + decodedTimeSlicedSurveyRequestMessage.nonce = Uint32.decode(stream); + decodedTimeSlicedSurveyRequestMessage.inboundPeersIndex = Uint32.decode(stream); + decodedTimeSlicedSurveyRequestMessage.outboundPeersIndex = Uint32.decode(stream); + return decodedTimeSlicedSurveyRequestMessage; + } + + public static TimeSlicedSurveyRequestMessage fromXdrBase64(String xdr) throws IOException { + byte[] bytes = Base64Factory.getInstance().decode(xdr); + return fromXdrByteArray(bytes); + } + + public static TimeSlicedSurveyRequestMessage fromXdrByteArray(byte[] xdr) throws IOException { + ByteArrayInputStream byteArrayInputStream = new ByteArrayInputStream(xdr); + XdrDataInputStream xdrDataInputStream = new XdrDataInputStream(byteArrayInputStream); + return decode(xdrDataInputStream); + } +} diff --git a/src/main/java/org/stellar/sdk/xdr/TimeSlicedSurveyResponseMessage.java b/src/main/java/org/stellar/sdk/xdr/TimeSlicedSurveyResponseMessage.java new file mode 100644 index 000000000..ff2f013b5 --- /dev/null +++ b/src/main/java/org/stellar/sdk/xdr/TimeSlicedSurveyResponseMessage.java @@ -0,0 +1,57 @@ +// Automatically generated by xdrgen +// DO NOT EDIT or your changes may be overwritten + +package org.stellar.sdk.xdr; + +import java.io.ByteArrayInputStream; +import java.io.IOException; +import lombok.AllArgsConstructor; +import lombok.Builder; +import lombok.Data; +import lombok.NoArgsConstructor; +import org.stellar.sdk.Base64Factory; + +/** + * TimeSlicedSurveyResponseMessage's original definition in the XDR file is: + * + *
+ * struct TimeSlicedSurveyResponseMessage
+ * {
+ *     SurveyResponseMessage response;
+ *     uint32 nonce;
+ * };
+ * 
+ */ +@Data +@NoArgsConstructor +@AllArgsConstructor +@Builder(toBuilder = true) +public class TimeSlicedSurveyResponseMessage implements XdrElement { + private SurveyResponseMessage response; + private Uint32 nonce; + + public void encode(XdrDataOutputStream stream) throws IOException { + response.encode(stream); + nonce.encode(stream); + } + + public static TimeSlicedSurveyResponseMessage decode(XdrDataInputStream stream) + throws IOException { + TimeSlicedSurveyResponseMessage decodedTimeSlicedSurveyResponseMessage = + new TimeSlicedSurveyResponseMessage(); + decodedTimeSlicedSurveyResponseMessage.response = SurveyResponseMessage.decode(stream); + decodedTimeSlicedSurveyResponseMessage.nonce = Uint32.decode(stream); + return decodedTimeSlicedSurveyResponseMessage; + } + + public static TimeSlicedSurveyResponseMessage fromXdrBase64(String xdr) throws IOException { + byte[] bytes = Base64Factory.getInstance().decode(xdr); + return fromXdrByteArray(bytes); + } + + public static TimeSlicedSurveyResponseMessage fromXdrByteArray(byte[] xdr) throws IOException { + ByteArrayInputStream byteArrayInputStream = new ByteArrayInputStream(xdr); + XdrDataInputStream xdrDataInputStream = new XdrDataInputStream(byteArrayInputStream); + return decode(xdrDataInputStream); + } +} diff --git a/src/main/java/org/stellar/sdk/xdr/TimeSlicedSurveyStartCollectingMessage.java b/src/main/java/org/stellar/sdk/xdr/TimeSlicedSurveyStartCollectingMessage.java new file mode 100644 index 000000000..de8460599 --- /dev/null +++ b/src/main/java/org/stellar/sdk/xdr/TimeSlicedSurveyStartCollectingMessage.java @@ -0,0 +1,63 @@ +// Automatically generated by xdrgen +// DO NOT EDIT or your changes may be overwritten + +package org.stellar.sdk.xdr; + +import java.io.ByteArrayInputStream; +import java.io.IOException; +import lombok.AllArgsConstructor; +import lombok.Builder; +import lombok.Data; +import lombok.NoArgsConstructor; +import org.stellar.sdk.Base64Factory; + +/** + * TimeSlicedSurveyStartCollectingMessage's original definition in the XDR file is: + * + *
+ * struct TimeSlicedSurveyStartCollectingMessage
+ * {
+ *     NodeID surveyorID;
+ *     uint32 nonce;
+ *     uint32 ledgerNum;
+ * };
+ * 
+ */ +@Data +@NoArgsConstructor +@AllArgsConstructor +@Builder(toBuilder = true) +public class TimeSlicedSurveyStartCollectingMessage implements XdrElement { + private NodeID surveyorID; + private Uint32 nonce; + private Uint32 ledgerNum; + + public void encode(XdrDataOutputStream stream) throws IOException { + surveyorID.encode(stream); + nonce.encode(stream); + ledgerNum.encode(stream); + } + + public static TimeSlicedSurveyStartCollectingMessage decode(XdrDataInputStream stream) + throws IOException { + TimeSlicedSurveyStartCollectingMessage decodedTimeSlicedSurveyStartCollectingMessage = + new TimeSlicedSurveyStartCollectingMessage(); + decodedTimeSlicedSurveyStartCollectingMessage.surveyorID = NodeID.decode(stream); + decodedTimeSlicedSurveyStartCollectingMessage.nonce = Uint32.decode(stream); + decodedTimeSlicedSurveyStartCollectingMessage.ledgerNum = Uint32.decode(stream); + return decodedTimeSlicedSurveyStartCollectingMessage; + } + + public static TimeSlicedSurveyStartCollectingMessage fromXdrBase64(String xdr) + throws IOException { + byte[] bytes = Base64Factory.getInstance().decode(xdr); + return fromXdrByteArray(bytes); + } + + public static TimeSlicedSurveyStartCollectingMessage fromXdrByteArray(byte[] xdr) + throws IOException { + ByteArrayInputStream byteArrayInputStream = new ByteArrayInputStream(xdr); + XdrDataInputStream xdrDataInputStream = new XdrDataInputStream(byteArrayInputStream); + return decode(xdrDataInputStream); + } +} diff --git a/src/main/java/org/stellar/sdk/xdr/TimeSlicedSurveyStopCollectingMessage.java b/src/main/java/org/stellar/sdk/xdr/TimeSlicedSurveyStopCollectingMessage.java new file mode 100644 index 000000000..5f567e0d7 --- /dev/null +++ b/src/main/java/org/stellar/sdk/xdr/TimeSlicedSurveyStopCollectingMessage.java @@ -0,0 +1,62 @@ +// Automatically generated by xdrgen +// DO NOT EDIT or your changes may be overwritten + +package org.stellar.sdk.xdr; + +import java.io.ByteArrayInputStream; +import java.io.IOException; +import lombok.AllArgsConstructor; +import lombok.Builder; +import lombok.Data; +import lombok.NoArgsConstructor; +import org.stellar.sdk.Base64Factory; + +/** + * TimeSlicedSurveyStopCollectingMessage's original definition in the XDR file is: + * + *
+ * struct TimeSlicedSurveyStopCollectingMessage
+ * {
+ *     NodeID surveyorID;
+ *     uint32 nonce;
+ *     uint32 ledgerNum;
+ * };
+ * 
+ */ +@Data +@NoArgsConstructor +@AllArgsConstructor +@Builder(toBuilder = true) +public class TimeSlicedSurveyStopCollectingMessage implements XdrElement { + private NodeID surveyorID; + private Uint32 nonce; + private Uint32 ledgerNum; + + public void encode(XdrDataOutputStream stream) throws IOException { + surveyorID.encode(stream); + nonce.encode(stream); + ledgerNum.encode(stream); + } + + public static TimeSlicedSurveyStopCollectingMessage decode(XdrDataInputStream stream) + throws IOException { + TimeSlicedSurveyStopCollectingMessage decodedTimeSlicedSurveyStopCollectingMessage = + new TimeSlicedSurveyStopCollectingMessage(); + decodedTimeSlicedSurveyStopCollectingMessage.surveyorID = NodeID.decode(stream); + decodedTimeSlicedSurveyStopCollectingMessage.nonce = Uint32.decode(stream); + decodedTimeSlicedSurveyStopCollectingMessage.ledgerNum = Uint32.decode(stream); + return decodedTimeSlicedSurveyStopCollectingMessage; + } + + public static TimeSlicedSurveyStopCollectingMessage fromXdrBase64(String xdr) throws IOException { + byte[] bytes = Base64Factory.getInstance().decode(xdr); + return fromXdrByteArray(bytes); + } + + public static TimeSlicedSurveyStopCollectingMessage fromXdrByteArray(byte[] xdr) + throws IOException { + ByteArrayInputStream byteArrayInputStream = new ByteArrayInputStream(xdr); + XdrDataInputStream xdrDataInputStream = new XdrDataInputStream(byteArrayInputStream); + return decode(xdrDataInputStream); + } +} diff --git a/src/main/java/org/stellar/sdk/xdr/TopologyResponseBodyV2.java b/src/main/java/org/stellar/sdk/xdr/TopologyResponseBodyV2.java new file mode 100644 index 000000000..6dd53f039 --- /dev/null +++ b/src/main/java/org/stellar/sdk/xdr/TopologyResponseBodyV2.java @@ -0,0 +1,59 @@ +// Automatically generated by xdrgen +// DO NOT EDIT or your changes may be overwritten + +package org.stellar.sdk.xdr; + +import java.io.ByteArrayInputStream; +import java.io.IOException; +import lombok.AllArgsConstructor; +import lombok.Builder; +import lombok.Data; +import lombok.NoArgsConstructor; +import org.stellar.sdk.Base64Factory; + +/** + * TopologyResponseBodyV2's original definition in the XDR file is: + * + *
+ * struct TopologyResponseBodyV2
+ * {
+ *     TimeSlicedPeerDataList inboundPeers;
+ *     TimeSlicedPeerDataList outboundPeers;
+ *     TimeSlicedNodeData nodeData;
+ * };
+ * 
+ */ +@Data +@NoArgsConstructor +@AllArgsConstructor +@Builder(toBuilder = true) +public class TopologyResponseBodyV2 implements XdrElement { + private TimeSlicedPeerDataList inboundPeers; + private TimeSlicedPeerDataList outboundPeers; + private TimeSlicedNodeData nodeData; + + public void encode(XdrDataOutputStream stream) throws IOException { + inboundPeers.encode(stream); + outboundPeers.encode(stream); + nodeData.encode(stream); + } + + public static TopologyResponseBodyV2 decode(XdrDataInputStream stream) throws IOException { + TopologyResponseBodyV2 decodedTopologyResponseBodyV2 = new TopologyResponseBodyV2(); + decodedTopologyResponseBodyV2.inboundPeers = TimeSlicedPeerDataList.decode(stream); + decodedTopologyResponseBodyV2.outboundPeers = TimeSlicedPeerDataList.decode(stream); + decodedTopologyResponseBodyV2.nodeData = TimeSlicedNodeData.decode(stream); + return decodedTopologyResponseBodyV2; + } + + public static TopologyResponseBodyV2 fromXdrBase64(String xdr) throws IOException { + byte[] bytes = Base64Factory.getInstance().decode(xdr); + return fromXdrByteArray(bytes); + } + + public static TopologyResponseBodyV2 fromXdrByteArray(byte[] xdr) throws IOException { + ByteArrayInputStream byteArrayInputStream = new ByteArrayInputStream(xdr); + XdrDataInputStream xdrDataInputStream = new XdrDataInputStream(byteArrayInputStream); + return decode(xdrDataInputStream); + } +} diff --git a/xdr/Stellar-contract-config-setting.x b/xdr/Stellar-contract-config-setting.x index 52cc0224d..9f09c7b0e 100644 --- a/xdr/Stellar-contract-config-setting.x +++ b/xdr/Stellar-contract-config-setting.x @@ -188,7 +188,58 @@ enum ContractCostType { // point on a 256-bit elliptic curve Sec1DecodePointUncompressed = 43, // Cost of verifying an ECDSA Secp256r1 signature - VerifyEcdsaSecp256r1Sig = 44 + VerifyEcdsaSecp256r1Sig = 44, + + // Cost of encoding a BLS12-381 Fp (base field element) + Bls12381EncodeFp = 45, + // Cost of decoding a BLS12-381 Fp (base field element) + Bls12381DecodeFp = 46, + // Cost of checking a G1 point lies on the curve + Bls12381G1CheckPointOnCurve = 47, + // Cost of checking a G1 point belongs to the correct subgroup + Bls12381G1CheckPointInSubgroup = 48, + // Cost of checking a G2 point lies on the curve + Bls12381G2CheckPointOnCurve = 49, + // Cost of checking a G2 point belongs to the correct subgroup + Bls12381G2CheckPointInSubgroup = 50, + // Cost of converting a BLS12-381 G1 point from projective to affine coordinates + Bls12381G1ProjectiveToAffine = 51, + // Cost of converting a BLS12-381 G2 point from projective to affine coordinates + Bls12381G2ProjectiveToAffine = 52, + // Cost of performing BLS12-381 G1 point addition + Bls12381G1Add = 53, + // Cost of performing BLS12-381 G1 scalar multiplication + Bls12381G1Mul = 54, + // Cost of performing BLS12-381 G1 multi-scalar multiplication (MSM) + Bls12381G1Msm = 55, + // Cost of mapping a BLS12-381 Fp field element to a G1 point + Bls12381MapFpToG1 = 56, + // Cost of hashing to a BLS12-381 G1 point + Bls12381HashToG1 = 57, + // Cost of performing BLS12-381 G2 point addition + Bls12381G2Add = 58, + // Cost of performing BLS12-381 G2 scalar multiplication + Bls12381G2Mul = 59, + // Cost of performing BLS12-381 G2 multi-scalar multiplication (MSM) + Bls12381G2Msm = 60, + // Cost of mapping a BLS12-381 Fp2 field element to a G2 point + Bls12381MapFp2ToG2 = 61, + // Cost of hashing to a BLS12-381 G2 point + Bls12381HashToG2 = 62, + // Cost of performing BLS12-381 pairing operation + Bls12381Pairing = 63, + // Cost of converting a BLS12-381 scalar element from U256 + Bls12381FrFromU256 = 64, + // Cost of converting a BLS12-381 scalar element to U256 + Bls12381FrToU256 = 65, + // Cost of performing BLS12-381 scalar element addition/subtraction + Bls12381FrAddSub = 66, + // Cost of performing BLS12-381 scalar element multiplication + Bls12381FrMul = 67, + // Cost of performing BLS12-381 scalar element exponentiation + Bls12381FrPow = 68, + // Cost of performing BLS12-381 scalar element inversion + Bls12381FrInv = 69 }; struct ContractCostParamEntry { diff --git a/xdr/Stellar-contract-env-meta.x b/xdr/Stellar-contract-env-meta.x index 330726de4..ed6b0b675 100644 --- a/xdr/Stellar-contract-env-meta.x +++ b/xdr/Stellar-contract-env-meta.x @@ -17,7 +17,10 @@ enum SCEnvMetaKind union SCEnvMetaEntry switch (SCEnvMetaKind kind) { case SC_ENV_META_KIND_INTERFACE_VERSION: - uint64 interfaceVersion; + struct { + uint32 protocol; + uint32 preRelease; + } interfaceVersion; }; } diff --git a/xdr/Stellar-ledger-entries.x b/xdr/Stellar-ledger-entries.x index 3a137ae60..5bf4f9d36 100644 --- a/xdr/Stellar-ledger-entries.x +++ b/xdr/Stellar-ledger-entries.x @@ -678,4 +678,120 @@ enum EnvelopeType ENVELOPE_TYPE_CONTRACT_ID = 8, ENVELOPE_TYPE_SOROBAN_AUTHORIZATION = 9 }; -} + +enum BucketListType +{ + LIVE = 0, + HOT_ARCHIVE = 1, + COLD_ARCHIVE = 2 +}; + +/* Entries used to define the bucket list */ +enum BucketEntryType +{ + METAENTRY = + -1, // At-and-after protocol 11: bucket metadata, should come first. + LIVEENTRY = 0, // Before protocol 11: created-or-updated; + // At-and-after protocol 11: only updated. + DEADENTRY = 1, + INITENTRY = 2 // At-and-after protocol 11: only created. +}; + +enum HotArchiveBucketEntryType +{ + HOT_ARCHIVE_METAENTRY = -1, // Bucket metadata, should come first. + HOT_ARCHIVE_ARCHIVED = 0, // Entry is Archived + HOT_ARCHIVE_LIVE = 1, // Entry was previously HOT_ARCHIVE_ARCHIVED, or HOT_ARCHIVE_DELETED, but + // has been added back to the live BucketList. + // Does not need to be persisted. + HOT_ARCHIVE_DELETED = 2 // Entry deleted (Note: must be persisted in archive) +}; + +enum ColdArchiveBucketEntryType +{ + COLD_ARCHIVE_METAENTRY = -1, // Bucket metadata, should come first. + COLD_ARCHIVE_ARCHIVED_LEAF = 0, // Full LedgerEntry that was archived during the epoch + COLD_ARCHIVE_DELETED_LEAF = 1, // LedgerKey that was deleted during the epoch + COLD_ARCHIVE_BOUNDARY_LEAF = 2, // Dummy leaf representing low/high bound + COLD_ARCHIVE_HASH = 3 // Intermediary Merkle hash entry +}; + +struct BucketMetadata +{ + // Indicates the protocol version used to create / merge this bucket. + uint32 ledgerVersion; + + // reserved for future use + union switch (int v) + { + case 0: + void; + case 1: + BucketListType bucketListType; + } + ext; +}; + +union BucketEntry switch (BucketEntryType type) +{ +case LIVEENTRY: +case INITENTRY: + LedgerEntry liveEntry; + +case DEADENTRY: + LedgerKey deadEntry; +case METAENTRY: + BucketMetadata metaEntry; +}; + +union HotArchiveBucketEntry switch (HotArchiveBucketEntryType type) +{ +case HOT_ARCHIVE_ARCHIVED: + LedgerEntry archivedEntry; + +case HOT_ARCHIVE_LIVE: +case HOT_ARCHIVE_DELETED: + LedgerKey key; +case HOT_ARCHIVE_METAENTRY: + BucketMetadata metaEntry; +}; + +struct ColdArchiveArchivedLeaf +{ + uint32 index; + LedgerEntry archivedEntry; +}; + +struct ColdArchiveDeletedLeaf +{ + uint32 index; + LedgerKey deletedKey; +}; + +struct ColdArchiveBoundaryLeaf +{ + uint32 index; + bool isLowerBound; +}; + +struct ColdArchiveHashEntry +{ + uint32 index; + uint32 level; + Hash hash; +}; + +union ColdArchiveBucketEntry switch (ColdArchiveBucketEntryType type) +{ +case COLD_ARCHIVE_METAENTRY: + BucketMetadata metaEntry; +case COLD_ARCHIVE_ARCHIVED_LEAF: + ColdArchiveArchivedLeaf archivedLeaf; +case COLD_ARCHIVE_DELETED_LEAF: + ColdArchiveDeletedLeaf deletedLeaf; +case COLD_ARCHIVE_BOUNDARY_LEAF: + ColdArchiveBoundaryLeaf boundaryLeaf; +case COLD_ARCHIVE_HASH: + ColdArchiveHashEntry hashEntry; +}; +} \ No newline at end of file diff --git a/xdr/Stellar-ledger.x b/xdr/Stellar-ledger.x index dd58ae8d9..0fc03e2af 100644 --- a/xdr/Stellar-ledger.x +++ b/xdr/Stellar-ledger.x @@ -157,43 +157,6 @@ struct ConfigUpgradeSet { ConfigSettingEntry updatedEntry<>; }; -/* Entries used to define the bucket list */ -enum BucketEntryType -{ - METAENTRY = - -1, // At-and-after protocol 11: bucket metadata, should come first. - LIVEENTRY = 0, // Before protocol 11: created-or-updated; - // At-and-after protocol 11: only updated. - DEADENTRY = 1, - INITENTRY = 2 // At-and-after protocol 11: only created. -}; - -struct BucketMetadata -{ - // Indicates the protocol version used to create / merge this bucket. - uint32 ledgerVersion; - - // reserved for future use - union switch (int v) - { - case 0: - void; - } - ext; -}; - -union BucketEntry switch (BucketEntryType type) -{ -case LIVEENTRY: -case INITENTRY: - LedgerEntry liveEntry; - -case DEADENTRY: - LedgerKey deadEntry; -case METAENTRY: - BucketMetadata metaEntry; -}; - enum TxSetComponentType { // txs with effective fee <= bid derived from a base fee (if any). @@ -400,6 +363,8 @@ struct DiagnosticEvent ContractEvent event; }; +typedef DiagnosticEvent DiagnosticEvents<>; + struct SorobanTransactionMetaExtV1 { ExtensionPoint ext; diff --git a/xdr/Stellar-overlay.x b/xdr/Stellar-overlay.x index 4c964736d..b398f883d 100644 --- a/xdr/Stellar-overlay.x +++ b/xdr/Stellar-overlay.x @@ -119,7 +119,12 @@ enum MessageType SEND_MORE_EXTENDED = 20, FLOOD_ADVERT = 18, - FLOOD_DEMAND = 19 + FLOOD_DEMAND = 19, + + TIME_SLICED_SURVEY_REQUEST = 21, + TIME_SLICED_SURVEY_RESPONSE = 22, + TIME_SLICED_SURVEY_START_COLLECTING = 23, + TIME_SLICED_SURVEY_STOP_COLLECTING = 24 }; struct DontHave @@ -130,13 +135,41 @@ struct DontHave enum SurveyMessageCommandType { - SURVEY_TOPOLOGY = 0 + SURVEY_TOPOLOGY = 0, + TIME_SLICED_SURVEY_TOPOLOGY = 1 }; enum SurveyMessageResponseType { SURVEY_TOPOLOGY_RESPONSE_V0 = 0, - SURVEY_TOPOLOGY_RESPONSE_V1 = 1 + SURVEY_TOPOLOGY_RESPONSE_V1 = 1, + SURVEY_TOPOLOGY_RESPONSE_V2 = 2 +}; + +struct TimeSlicedSurveyStartCollectingMessage +{ + NodeID surveyorID; + uint32 nonce; + uint32 ledgerNum; +}; + +struct SignedTimeSlicedSurveyStartCollectingMessage +{ + Signature signature; + TimeSlicedSurveyStartCollectingMessage startCollecting; +}; + +struct TimeSlicedSurveyStopCollectingMessage +{ + NodeID surveyorID; + uint32 nonce; + uint32 ledgerNum; +}; + +struct SignedTimeSlicedSurveyStopCollectingMessage +{ + Signature signature; + TimeSlicedSurveyStopCollectingMessage stopCollecting; }; struct SurveyRequestMessage @@ -148,12 +181,26 @@ struct SurveyRequestMessage SurveyMessageCommandType commandType; }; +struct TimeSlicedSurveyRequestMessage +{ + SurveyRequestMessage request; + uint32 nonce; + uint32 inboundPeersIndex; + uint32 outboundPeersIndex; +}; + struct SignedSurveyRequestMessage { Signature requestSignature; SurveyRequestMessage request; }; +struct SignedTimeSlicedSurveyRequestMessage +{ + Signature requestSignature; + TimeSlicedSurveyRequestMessage request; +}; + typedef opaque EncryptedBody<64000>; struct SurveyResponseMessage { @@ -164,12 +211,24 @@ struct SurveyResponseMessage EncryptedBody encryptedBody; }; +struct TimeSlicedSurveyResponseMessage +{ + SurveyResponseMessage response; + uint32 nonce; +}; + struct SignedSurveyResponseMessage { Signature responseSignature; SurveyResponseMessage response; }; +struct SignedTimeSlicedSurveyResponseMessage +{ + Signature responseSignature; + TimeSlicedSurveyResponseMessage response; +}; + struct PeerStats { NodeID id; @@ -193,6 +252,34 @@ struct PeerStats typedef PeerStats PeerStatList<25>; +struct TimeSlicedNodeData +{ + uint32 addedAuthenticatedPeers; + uint32 droppedAuthenticatedPeers; + uint32 totalInboundPeerCount; + uint32 totalOutboundPeerCount; + + // SCP stats + uint32 p75SCPFirstToSelfLatencyMs; + uint32 p75SCPSelfToOtherLatencyMs; + + // How many times the node lost sync in the time slice + uint32 lostSyncCount; + + // Config data + bool isValidator; + uint32 maxInboundPeerCount; + uint32 maxOutboundPeerCount; +}; + +struct TimeSlicedPeerData +{ + PeerStats peerStats; + uint32 averageLatencyMs; +}; + +typedef TimeSlicedPeerData TimeSlicedPeerDataList<25>; + struct TopologyResponseBodyV0 { PeerStatList inboundPeers; @@ -214,12 +301,21 @@ struct TopologyResponseBodyV1 uint32 maxOutboundPeerCount; }; +struct TopologyResponseBodyV2 +{ + TimeSlicedPeerDataList inboundPeers; + TimeSlicedPeerDataList outboundPeers; + TimeSlicedNodeData nodeData; +}; + union SurveyResponseBody switch (SurveyMessageResponseType type) { case SURVEY_TOPOLOGY_RESPONSE_V0: TopologyResponseBodyV0 topologyResponseBodyV0; case SURVEY_TOPOLOGY_RESPONSE_V1: TopologyResponseBodyV1 topologyResponseBodyV1; +case SURVEY_TOPOLOGY_RESPONSE_V2: + TopologyResponseBodyV2 topologyResponseBodyV2; }; const TX_ADVERT_VECTOR_MAX_SIZE = 1000; @@ -269,6 +365,20 @@ case SURVEY_REQUEST: case SURVEY_RESPONSE: SignedSurveyResponseMessage signedSurveyResponseMessage; +case TIME_SLICED_SURVEY_REQUEST: + SignedTimeSlicedSurveyRequestMessage signedTimeSlicedSurveyRequestMessage; + +case TIME_SLICED_SURVEY_RESPONSE: + SignedTimeSlicedSurveyResponseMessage signedTimeSlicedSurveyResponseMessage; + +case TIME_SLICED_SURVEY_START_COLLECTING: + SignedTimeSlicedSurveyStartCollectingMessage + signedTimeSlicedSurveyStartCollectingMessage; + +case TIME_SLICED_SURVEY_STOP_COLLECTING: + SignedTimeSlicedSurveyStopCollectingMessage + signedTimeSlicedSurveyStopCollectingMessage; + // SCP case GET_SCP_QUORUMSET: uint256 qSetHash; diff --git a/xdr/Stellar-transaction.x b/xdr/Stellar-transaction.x index 87dd32d38..7d3248102 100644 --- a/xdr/Stellar-transaction.x +++ b/xdr/Stellar-transaction.x @@ -476,7 +476,8 @@ enum HostFunctionType { HOST_FUNCTION_TYPE_INVOKE_CONTRACT = 0, HOST_FUNCTION_TYPE_CREATE_CONTRACT = 1, - HOST_FUNCTION_TYPE_UPLOAD_CONTRACT_WASM = 2 + HOST_FUNCTION_TYPE_UPLOAD_CONTRACT_WASM = 2, + HOST_FUNCTION_TYPE_CREATE_CONTRACT_V2 = 3 }; enum ContractIDPreimageType @@ -503,6 +504,14 @@ struct CreateContractArgs ContractExecutable executable; }; +struct CreateContractArgsV2 +{ + ContractIDPreimage contractIDPreimage; + ContractExecutable executable; + // Arguments of the contract's constructor. + SCVal constructorArgs<>; +}; + struct InvokeContractArgs { SCAddress contractAddress; SCSymbol functionName; @@ -517,20 +526,33 @@ case HOST_FUNCTION_TYPE_CREATE_CONTRACT: CreateContractArgs createContract; case HOST_FUNCTION_TYPE_UPLOAD_CONTRACT_WASM: opaque wasm<>; +case HOST_FUNCTION_TYPE_CREATE_CONTRACT_V2: + CreateContractArgsV2 createContractV2; }; enum SorobanAuthorizedFunctionType { SOROBAN_AUTHORIZED_FUNCTION_TYPE_CONTRACT_FN = 0, - SOROBAN_AUTHORIZED_FUNCTION_TYPE_CREATE_CONTRACT_HOST_FN = 1 + SOROBAN_AUTHORIZED_FUNCTION_TYPE_CREATE_CONTRACT_HOST_FN = 1, + SOROBAN_AUTHORIZED_FUNCTION_TYPE_CREATE_CONTRACT_V2_HOST_FN = 2 }; union SorobanAuthorizedFunction switch (SorobanAuthorizedFunctionType type) { case SOROBAN_AUTHORIZED_FUNCTION_TYPE_CONTRACT_FN: InvokeContractArgs contractFn; +// This variant of auth payload for creating new contract instances +// doesn't allow specifying the constructor arguments, creating contracts +// with constructors that take arguments is only possible by authorizing +// `SOROBAN_AUTHORIZED_FUNCTION_TYPE_CREATE_CONTRACT_V2_HOST_FN` +// (protocol 22+). case SOROBAN_AUTHORIZED_FUNCTION_TYPE_CREATE_CONTRACT_HOST_FN: CreateContractArgs createContractHostFn; +// This variant of auth payload for creating new contract instances +// is only accepted in and after protocol 22. It allows authorizing the +// contract constructor arguments. +case SOROBAN_AUTHORIZED_FUNCTION_TYPE_CREATE_CONTRACT_V2_HOST_FN: + CreateContractArgsV2 createContractV2HostFn; }; struct SorobanAuthorizedInvocation @@ -801,6 +823,56 @@ struct LedgerFootprint LedgerKey readWrite<>; }; +enum ArchivalProofType +{ + EXISTENCE = 0, + NONEXISTENCE = 1 +}; + +struct ArchivalProofNode +{ + uint32 index; + Hash hash; +}; + +typedef ArchivalProofNode ProofLevel<>; + +struct NonexistenceProofBody +{ + ColdArchiveBucketEntry entriesToProve<>; + + // Vector of vectors, where proofLevels[level] + // contains all HashNodes that correspond with that level + ProofLevel proofLevels<>; +}; + +struct ExistenceProofBody +{ + LedgerKey keysToProve<>; + + // Bounds for each key being proved, where bound[n] + // corresponds to keysToProve[n] + ColdArchiveBucketEntry lowBoundEntries<>; + ColdArchiveBucketEntry highBoundEntries<>; + + // Vector of vectors, where proofLevels[level] + // contains all HashNodes that correspond with that level + ProofLevel proofLevels<>; +}; + +struct ArchivalProof +{ + uint32 epoch; // AST Subtree for this proof + + union switch (ArchivalProofType t) + { + case EXISTENCE: + NonexistenceProofBody nonexistenceProof; + case NONEXISTENCE: + ExistenceProofBody existenceProof; + } body; +}; + // Resource limits for a Soroban transaction. // The transaction will fail if it exceeds any of these limits. struct SorobanResources diff --git a/xdr/Stellar-types.x b/xdr/Stellar-types.x index d71bf0d49..73c4e7958 100644 --- a/xdr/Stellar-types.x +++ b/xdr/Stellar-types.x @@ -103,4 +103,35 @@ struct HmacSha256Mac { opaque mac[32]; }; -} + +struct ShortHashSeed +{ + opaque seed[16]; +}; + +enum BinaryFuseFilterType +{ + BINARY_FUSE_FILTER_8_BIT = 0, + BINARY_FUSE_FILTER_16_BIT = 1, + BINARY_FUSE_FILTER_32_BIT = 2 +}; + +struct SerializedBinaryFuseFilter +{ + BinaryFuseFilterType type; + + // Seed used to hash input to filter + ShortHashSeed inputHashSeed; + + // Seed used for internal filter hash operations + ShortHashSeed filterSeed; + uint32 segmentLength; + uint32 segementLengthMask; + uint32 segmentCount; + uint32 segmentCountLength; + uint32 fingerprintLength; // Length in terms of element count, not bytes + + // Array of uint8_t, uint16_t, or uint32_t depending on filter type + opaque fingerprints<>; +}; +} \ No newline at end of file