From f00ebfb6f6ee9508580ba194615703cb3d6fce36 Mon Sep 17 00:00:00 2001 From: afkbyte Date: Tue, 11 Jun 2024 14:45:20 -0500 Subject: [PATCH 1/7] save work --- .github/workflows/contract-tests.yml | 2 +- foundry.toml | 1 + package.json | 7 +- scripts/disperseBlob.ts | 140 ++ scripts/eigenDAClient/proto/common.proto | 9 + scripts/eigenDAClient/proto/common.ts | 98 + scripts/eigenDAClient/proto/disperser.proto | 253 +++ scripts/eigenDAClient/proto/disperser.ts | 1785 +++++++++++++++++++ src/bridge/SequencerInbox.sol | 4 + test/foundry/SequencerInbox.t.sol | 115 +- test/foundry/blobInfo/blobInfo.json | 44 + yarn.lock | 118 +- 12 files changed, 2520 insertions(+), 56 deletions(-) create mode 100644 scripts/disperseBlob.ts create mode 100644 scripts/eigenDAClient/proto/common.proto create mode 100644 scripts/eigenDAClient/proto/common.ts create mode 100644 scripts/eigenDAClient/proto/disperser.proto create mode 100644 scripts/eigenDAClient/proto/disperser.ts create mode 100644 test/foundry/blobInfo/blobInfo.json diff --git a/.github/workflows/contract-tests.yml b/.github/workflows/contract-tests.yml index 5637607f..48bd3470 100644 --- a/.github/workflows/contract-tests.yml +++ b/.github/workflows/contract-tests.yml @@ -34,7 +34,7 @@ jobs: run: yarn - name: Build - run: forge test + run: forge test --fork-url https://rpc.holesky.ethpandaops.io/ tests: name: Contract tests runs-on: ubuntu-8 diff --git a/foundry.toml b/foundry.toml index b37100ba..124f0678 100644 --- a/foundry.toml +++ b/foundry.toml @@ -8,6 +8,7 @@ optimizer = true optimizer_runs = 100 via_ir = false solc_version = '0.8.12' +fs_permissions = [{ access = "read", path = "./"}] [profile.yul] src = 'yul' diff --git a/package.json b/package.json index 4e3cf233..8cc1a9ec 100644 --- a/package.json +++ b/package.json @@ -41,14 +41,18 @@ "postinstall": "patch-package", "deploy-factory": "hardhat run scripts/deployment.ts", "deploy-eth-rollup": "hardhat run scripts/createEthRollup.ts", - "deploy-erc20-rollup": "hardhat run scripts/createERC20Rollup.ts" + "deploy-erc20-rollup": "hardhat run scripts/createERC20Rollup.ts", + "deploy-blob": "yarn ts-node scripts/disperseBlob.ts" }, "dependencies": { "@eigenda/eigenda-utils": "2.0.0", + "@grpc/grpc-js": "^1.8.22", + "@grpc/proto-loader": "^0.7.13", "@offchainlabs/upgrade-executor": "1.1.0-beta.0", "@openzeppelin-upgrades/contracts": "npm:@openzeppelin/contracts-upgradeable@4.7", "@openzeppelin/contracts": "4.7", "@openzeppelin/contracts-upgradeable": "4.7", + "google-protobuf": "^3.21.2", "patch-package": "^6.4.7" }, "private": false, @@ -62,6 +66,7 @@ "@typechain/ethers-v5": "^10.0.0", "@typechain/hardhat": "^6.0.0", "@types/chai": "^4.3.0", + "@types/google-protobuf": "^3.15.12", "@types/mocha": "^9.0.0", "@types/node": "^17.0.5", "@typescript-eslint/eslint-plugin": "^5.14.0", diff --git a/scripts/disperseBlob.ts b/scripts/disperseBlob.ts new file mode 100644 index 00000000..f97a405c --- /dev/null +++ b/scripts/disperseBlob.ts @@ -0,0 +1,140 @@ +import { disperser } from "./eigenDAClient/proto/disperser"; +import { ChannelCredentials } from "@grpc/grpc-js"; +import * as fs from 'fs'; + +const blobInfoPath = "./test/foundry/blobInfo/blobInfo.json"; +const client = new disperser.DisperserClient("disperser-holesky.eigenda.xyz:443", ChannelCredentials.createSsl()); +const disperseBlobRequest = new disperser.DisperseBlobRequest({ data: new Uint8Array([0, 1, 2, 3]) }); + +async function checkBlobStatus() { + if (fs.existsSync(blobInfoPath)) { + const blobInfo = JSON.parse(fs.readFileSync(blobInfoPath, "utf8")); + let request_id_bytes = new Uint8Array(Buffer.from(blobInfo.request_id, 'hex')); + + const blobStatusRequest = new disperser.BlobStatusRequest({ request_id: request_id_bytes }); + + return new Promise((resolve) => { + client.GetBlobStatus(blobStatusRequest, (error: Error | null, blobStatusReply?: disperser.BlobStatusReply) => { + if (error) { + switch (error.message) { + case "5 NOT_FOUND: no metadata found for the requestID": + console.log("Blob has expired, disperse again"); + resolve(true); + break; + default: + console.error("Error:", error); + resolve(false); + } + } else if (blobStatusReply) { + console.log("Blob found, no need to disperse"); + resolve(false); + } else { + console.error("No reply from GetBlobStatus"); + resolve(false); + } + }); + }); + } else { + return true; + } +} + +(async () => { + const needToDisperseBlob = await checkBlobStatus(); + + if (needToDisperseBlob) { + console.log("DisperseBlob"); + client.DisperseBlob(disperseBlobRequest, (error: Error | null, disperseBlobReply?: disperser.DisperseBlobReply) => { + if (error) { + console.error("Error:", error); + } else if (disperseBlobReply) { + console.log("Blob ID:", Buffer.from(disperseBlobReply.request_id).toString("hex")); + + const blobStatusRequest = new disperser.BlobStatusRequest({ request_id: disperseBlobReply.request_id }); + + const blobStatusChecker = setInterval(() => { + client.GetBlobStatus(blobStatusRequest, (statusError: Error | null, blobStatusReply?: disperser.BlobStatusReply) => { + if (statusError) { + console.error("Status Error:", statusError); + } else if (blobStatusReply) { + switch (blobStatusReply.status) { + case disperser.BlobStatus.PROCESSING: + console.log("Blob is currently being processed."); + break; + case disperser.BlobStatus.DISPERSING: + console.log("Blob is currently being dispersed."); + break; + case disperser.BlobStatus.CONFIRMED: + console.log("Blob has been confirmed."); + let blobInfoWithRequestId = parseBlobInfo(disperseBlobReply, blobStatusReply); + fs.writeFileSync(blobInfoPath, JSON.stringify(blobInfoWithRequestId, null, 2)); + clearInterval(blobStatusChecker); + break; + case disperser.BlobStatus.FAILED: + console.log("Blob has failed."); + break; + case disperser.BlobStatus.FINALIZED: + console.log("Blob has been finalized."); + break; + case disperser.BlobStatus.INSUFFICIENT_SIGNATURES: + console.log("Blob has insufficient signatures."); + break; + } + } else { + console.error("No reply from GetBlobStatus"); + } + }); + }, 30000); + } else { + console.error("No reply from DisperseBlob"); + } + }); + } +})(); + +function parseBlobInfo(disperseBlobReply: disperser.DisperseBlobReply, blobStatusReply: disperser.BlobStatusReply) { + const blobQuorumParams = blobStatusReply.info.blob_header.blob_quorum_params.map(param => ({ + quorum_number: param.quorum_number, + adversary_threshold_percentage: param.adversary_threshold_percentage, + confirmation_threshold_percentage: param.confirmation_threshold_percentage, + chunk_length: param.chunk_length + })); + + return { + request_id: Buffer.from(disperseBlobReply.request_id).toString("hex"), + blob_info: { + blob_header: { + commitment: { + x: Buffer.from(blobStatusReply.info.blob_header.commitment.x).toString("hex"), + y: Buffer.from(blobStatusReply.info.blob_header.commitment.y).toString("hex") + }, + data_length: blobStatusReply.info.blob_header.data_length, + blob_quorum_params: blobQuorumParams + }, + blob_verification_proof: { + batch_id: blobStatusReply.info.blob_verification_proof.batch_id, + blob_index: blobStatusReply.info.blob_verification_proof.blob_index, + batch_metadata: { + batch_header: { + batch_root: Buffer.from(blobStatusReply.info.blob_verification_proof.batch_metadata.batch_header.batch_root).toString("hex"), + quorum_numbers: Buffer.from(blobStatusReply.info.blob_verification_proof.batch_metadata.batch_header.quorum_numbers).toString("hex"), + quorum_signed_percentages: Buffer.from(blobStatusReply.info.blob_verification_proof.batch_metadata.batch_header.quorum_signed_percentages).toString("hex"), + reference_block_number: blobStatusReply.info.blob_verification_proof.batch_metadata.batch_header.reference_block_number + }, + signatory_record_hash: Buffer.from(blobStatusReply.info.blob_verification_proof.batch_metadata.signatory_record_hash).toString("hex"), + fee: Buffer.from(blobStatusReply.info.blob_verification_proof.batch_metadata.fee).toString("hex"), + confirmation_block_number: blobStatusReply.info.blob_verification_proof.batch_metadata.confirmation_block_number, + batch_header_hash: Buffer.from(blobStatusReply.info.blob_verification_proof.batch_metadata.batch_header_hash).toString("hex") + }, + inclusion_proof: Buffer.from(blobStatusReply.info.blob_verification_proof.inclusion_proof).toString("hex"), + quorum_indexes: Buffer.from(blobStatusReply.info.blob_verification_proof.quorum_indexes).toString("hex") + } + } + }; +} + + + + + + diff --git a/scripts/eigenDAClient/proto/common.proto b/scripts/eigenDAClient/proto/common.proto new file mode 100644 index 00000000..cee33e8d --- /dev/null +++ b/scripts/eigenDAClient/proto/common.proto @@ -0,0 +1,9 @@ +syntax = "proto3"; +package common; + +message G1Commitment { + // The X coordinate of the KZG commitment. This is the raw byte representation of the field element. + bytes x = 1; + // The Y coordinate of the KZG commitment. This is the raw byte representation of the field element. + bytes y = 2; +} \ No newline at end of file diff --git a/scripts/eigenDAClient/proto/common.ts b/scripts/eigenDAClient/proto/common.ts new file mode 100644 index 00000000..b86d7f3a --- /dev/null +++ b/scripts/eigenDAClient/proto/common.ts @@ -0,0 +1,98 @@ +/** + * Generated by the protoc-gen-ts. DO NOT EDIT! + * compiler version: 5.26.1 + * source: proto/common.proto + * git: https://github.com/thesayyn/protoc-gen-ts */ +import * as pb_1 from "google-protobuf"; +export namespace common { + export class G1Commitment extends pb_1.Message { + #one_of_decls: number[][] = []; + constructor(data?: any[] | { + x?: Uint8Array; + y?: Uint8Array; + }) { + super(); + pb_1.Message.initialize(this, Array.isArray(data) ? data : [], 0, -1, [], this.#one_of_decls); + if (!Array.isArray(data) && typeof data == "object") { + if ("x" in data && data.x != undefined) { + this.x = data.x; + } + if ("y" in data && data.y != undefined) { + this.y = data.y; + } + } + } + get x() { + return pb_1.Message.getFieldWithDefault(this, 1, new Uint8Array(0)) as Uint8Array; + } + set x(value: Uint8Array) { + pb_1.Message.setField(this, 1, value); + } + get y() { + return pb_1.Message.getFieldWithDefault(this, 2, new Uint8Array(0)) as Uint8Array; + } + set y(value: Uint8Array) { + pb_1.Message.setField(this, 2, value); + } + static fromObject(data: { + x?: Uint8Array; + y?: Uint8Array; + }): G1Commitment { + const message = new G1Commitment({}); + if (data.x != null) { + message.x = data.x; + } + if (data.y != null) { + message.y = data.y; + } + return message; + } + toObject() { + const data: { + x?: Uint8Array; + y?: Uint8Array; + } = {}; + if (this.x != null) { + data.x = this.x; + } + if (this.y != null) { + data.y = this.y; + } + return data; + } + serialize(): Uint8Array; + serialize(w: pb_1.BinaryWriter): void; + serialize(w?: pb_1.BinaryWriter): Uint8Array | void { + const writer = w || new pb_1.BinaryWriter(); + if (this.x.length) + writer.writeBytes(1, this.x); + if (this.y.length) + writer.writeBytes(2, this.y); + if (!w) + return writer.getResultBuffer(); + } + static deserialize(bytes: Uint8Array | pb_1.BinaryReader): G1Commitment { + const reader = bytes instanceof pb_1.BinaryReader ? bytes : new pb_1.BinaryReader(bytes), message = new G1Commitment(); + while (reader.nextField()) { + if (reader.isEndGroup()) + break; + switch (reader.getFieldNumber()) { + case 1: + message.x = reader.readBytes(); + break; + case 2: + message.y = reader.readBytes(); + break; + default: reader.skipField(); + } + } + return message; + } + serializeBinary(): Uint8Array { + return this.serialize(); + } + static deserializeBinary(bytes: Uint8Array): G1Commitment { + return G1Commitment.deserialize(bytes); + } + } +} diff --git a/scripts/eigenDAClient/proto/disperser.proto b/scripts/eigenDAClient/proto/disperser.proto new file mode 100644 index 00000000..c867747d --- /dev/null +++ b/scripts/eigenDAClient/proto/disperser.proto @@ -0,0 +1,253 @@ +// from https://github.com/Layr-Labs/eigenda/blob/36307ab8ab66676e6ebe10ccf04240c0bf49102c/api/proto/disperser/disperser.proto + +syntax = "proto3"; +package disperser; +import "proto/common.proto"; + +// Disperser defines the public APIs for dispersing blobs. +service Disperser { + // This API accepts blob to disperse from clients. + // This executes the dispersal async, i.e. it returns once the request + // is accepted. The client could use GetBlobStatus() API to poll the the + // processing status of the blob. + rpc DisperseBlob(DisperseBlobRequest) returns (DisperseBlobReply) {} + + + // DisperseBlobAuthenticated is similar to DisperseBlob, except that it requires the + // client to authenticate itself via the AuthenticationData message. The protoco is as follows: + // 1. The client sends a DisperseBlobAuthenticated request with the DisperseBlobRequest message + // 2. The Disperser sends back a BlobAuthHeader message containing information for the client to + // verify and sign. + // 3. The client verifies the BlobAuthHeader and sends back the signed BlobAuthHeader in an + // AuthenticationData message. + // 4. The Disperser verifies the signature and returns a DisperseBlobReply message. + rpc DisperseBlobAuthenticated(stream AuthenticatedRequest) returns (stream AuthenticatedReply); + + // This API is meant to be polled for the blob status. + rpc GetBlobStatus(BlobStatusRequest) returns (BlobStatusReply) {} + + // This retrieves the requested blob from the Disperser's backend. + // This is a more efficient way to retrieve blobs than directly retrieving + // from the DA Nodes (see detail about this approach in + // api/proto/retriever/retriever.proto). + // The blob should have been initially dispersed via this Disperser service + // for this API to work. + rpc RetrieveBlob(RetrieveBlobRequest) returns (RetrieveBlobReply) {} +} + +// Requests and Responses + +// Authenicated Message Types + +message AuthenticatedRequest { + oneof payload { + DisperseBlobRequest disperse_request = 1; + AuthenticationData authentication_data = 2; + } +} + +message AuthenticatedReply { + oneof payload { + BlobAuthHeader blob_auth_header = 1; + DisperseBlobReply disperse_reply = 2; + } +} + +// BlobAuthHeader contains information about the blob for the client to verify and sign. +// - Once payments are enabled, the BlobAuthHeader will contain the KZG commitment to the blob, which the client + // will verify and sign. Having the client verify the KZG commitment instead of calculating it avoids +// the need for the client to have the KZG structured reference string (SRS), which can be large. +// The signed KZG commitment prevents the disperser from sending a different blob to the DA Nodes +// than the one the client sent. +// - In the meantime, the BlobAuthHeader contains a simple challenge parameter is used to prevent +// replay attacks in the event that a signature is leaked. +message BlobAuthHeader { + uint32 challenge_parameter = 1; +} + +// AuthenticationData contains the signature of the BlobAuthHeader. +message AuthenticationData { + bytes authentication_data = 1; +} + +message DisperseBlobRequest { + // The data to be dispersed. + // The size of data must be <= 2MiB. Every 32 bytes of data chunk is interpreted as an integer in big endian format + // where the lower address has more significant bits. The integer must stay in the valid range to be interpreted + // as a field element on the bn254 curve. The valid range is + // 0 <= x < 21888242871839275222246405745257275088548364400416034343698204186575808495617 + // containing slightly less than 254 bits and more than 253 bits. If any one of the 32 bytes chunk is outside the range, + // the whole request is deemed as invalid, and rejected. + bytes data = 1; + // The quorums to which the blob will be sent, in addition to the required quorums which are configured + // on the EigenDA smart contract. If required quorums are included here, an error will be returned. + // The disperser will ensure that the encoded blobs for each quorum are all processed + // within the same batch. + repeated uint32 custom_quorum_numbers = 2; + + // The account ID of the client. This should be a hex-encoded string of the ECSDA public key + // corresponding to the key used by the client to sign the BlobAuthHeader. + string account_id = 3; +} + +message DisperseBlobReply { + // The status of the blob associated with the request_id. + BlobStatus result = 1; + // The request ID generated by the disperser. + // Once a request is accepted (although not processed), a unique request ID will be + // generated. + // Two different DisperseBlobRequests (determined by the hash of the DisperseBlobRequest) + // will have different IDs, and the same DisperseBlobRequest sent repeatedly at different + // times will also have different IDs. + // The client should use this ID to query the processing status of the request (via + // the GetBlobStatus API). + bytes request_id = 2; +} + +// BlobStatusRequest is used to query the status of a blob. +message BlobStatusRequest { + bytes request_id = 1; +} + +message BlobStatusReply { + // The status of the blob. + BlobStatus status = 1; + // The blob info needed for clients to confirm the blob against the EigenDA contracts. + BlobInfo info = 2; +} + +// RetrieveBlobRequest contains parameters to retrieve the blob. +message RetrieveBlobRequest { + bytes batch_header_hash = 1; + uint32 blob_index = 2; +} + +// RetrieveBlobReply contains the retrieved blob data +message RetrieveBlobReply { + bytes data = 1; +} + +// Data Types + +// BlobStatus represents the status of a blob. +// The status of a blob is updated as the blob is processed by the disperser. +// The status of a blob can be queried by the client using the GetBlobStatus API. +// Intermediate states are states that the blob can be in while being processed, and it can be updated to a differet state: +// - PROCESSING +// - DISPERSING +// - CONFIRMED +// Terminal states are states that will not be updated to a different state: +// - FAILED +// - FINALIZED +// - INSUFFICIENT_SIGNATURES +enum BlobStatus { + UNKNOWN = 0; + + // PROCESSING means that the blob is currently being processed by the disperser + PROCESSING = 1; + // CONFIRMED means that the blob has been dispersed to DA Nodes and the dispersed + // batch containing the blob has been confirmed onchain + CONFIRMED = 2; + + // FAILED means that the blob has failed permanently (for reasons other than insufficient + // signatures, which is a separate state) + FAILED = 3; + // FINALIZED means that the block containing the blob's confirmation transaction has been finalized on Ethereum + FINALIZED = 4; + // INSUFFICIENT_SIGNATURES means that the confirmation threshold for the blob was not met + // for at least one quorum. + INSUFFICIENT_SIGNATURES = 5; + + // DISPERSING means that the blob is currently being dispersed to DA Nodes and being confirmed onchain + DISPERSING = 6; +} + +// Types below correspond to the types necessary to verify a blob +// https://github.com/Layr-Labs/eigenda/blob/master/contracts/src/libraries/EigenDABlobUtils.sol#L29 + +// BlobInfo contains information needed to confirm the blob against the EigenDA contracts +message BlobInfo { + BlobHeader blob_header = 1; + BlobVerificationProof blob_verification_proof = 2; +} + +message BlobHeader { + // KZG commitment of the blob. + common.G1Commitment commitment = 1; + // The length of the blob in symbols (each symbol is 32 bytes). + uint32 data_length = 2; + // The params of the quorums that this blob participates in. + repeated BlobQuorumParam blob_quorum_params = 3; +} + +message BlobQuorumParam { + // The ID of the quorum. + uint32 quorum_number = 1; + // The max percentage of stake within the quorum that can be held by or delegated + // to adversarial operators. Currently, this and the next parameter are standardized + // across the quorum using values read from the EigenDA contracts. + uint32 adversary_threshold_percentage = 2; + // The min percentage of stake that must attest in order to consider + // the dispersal is successful. + uint32 confirmation_threshold_percentage = 3; + // The length of each chunk. + uint32 chunk_length = 4; +} + +message BlobVerificationProof { + // batch_id is an incremental ID assigned to a batch by EigenDAServiceManager + uint32 batch_id = 1; + // The index of the blob in the batch (which is logically an ordered list of blobs). + uint32 blob_index = 2; + BatchMetadata batch_metadata = 3; + // inclusion_proof is a merkle proof for a blob header's inclusion in a batch + bytes inclusion_proof = 4; + // indexes of quorums in BatchHeader.quorum_numbers that match the quorums in BlobHeader.blob_quorum_params + // Ex. BlobHeader.blob_quorum_params = [ + // { + // quorum_number = 0, + // ... + // }, + // { + // quorum_number = 3, + // ... + // }, + // { + // quorum_number = 5, + // ... + // }, + // ] + // BatchHeader.quorum_numbers = [0, 5, 3] => 0x000503 + // Then, quorum_indexes = [0, 2, 1] => 0x000201 + bytes quorum_indexes = 5; +} + +message BatchMetadata { + BatchHeader batch_header = 1; + // The hash of all public keys of the operators that did not sign the batch. + bytes signatory_record_hash = 2; + // The fee payment paid by users for dispersing this batch. It's the bytes + // representation of a big.Int value. + bytes fee = 3; + // The Ethereum block number at which the batch is confirmed onchain. + uint32 confirmation_block_number = 4; + // This is the hash of the ReducedBatchHeader defined onchain, see: + // https://github.com/Layr-Labs/eigenda/blob/master/contracts/src/interfaces/IEigenDAServiceManager.sol#L43 + // The is the message that the operators will sign their signatures on. + bytes batch_header_hash = 5; +} + +message BatchHeader { + // The root of the merkle tree with the hashes of blob headers as leaves. + bytes batch_root = 1; + // All quorums associated with blobs in this batch. Sorted in ascending order. + // Ex. [0, 2, 1] => 0x000102 + bytes quorum_numbers = 2; + // The percentage of stake that has signed for this batch. + // The quorum_signed_percentages[i] is percentage for the quorum_numbers[i]. + bytes quorum_signed_percentages = 3; + // The Ethereum block number at which the batch was created. + // The Disperser will encode and disperse the blobs based on the onchain info + // (e.g. operator stakes) at this block number. + uint32 reference_block_number = 4; +} \ No newline at end of file diff --git a/scripts/eigenDAClient/proto/disperser.ts b/scripts/eigenDAClient/proto/disperser.ts new file mode 100644 index 00000000..e64bd2f2 --- /dev/null +++ b/scripts/eigenDAClient/proto/disperser.ts @@ -0,0 +1,1785 @@ +/** + * Generated by the protoc-gen-ts. DO NOT EDIT! + * compiler version: 5.26.1 + * source: proto/disperser.proto + * git: https://github.com/thesayyn/protoc-gen-ts */ +import * as dependency_1 from "./common"; +import * as pb_1 from "google-protobuf"; +import * as grpc_1 from "@grpc/grpc-js"; +export namespace disperser { + export enum BlobStatus { + UNKNOWN = 0, + PROCESSING = 1, + CONFIRMED = 2, + FAILED = 3, + FINALIZED = 4, + INSUFFICIENT_SIGNATURES = 5, + DISPERSING = 6 + } + export class AuthenticatedRequest extends pb_1.Message { + #one_of_decls: number[][] = [[1, 2]]; + constructor(data?: any[] | ({} & (({ + disperse_request?: DisperseBlobRequest; + authentication_data?: never; + } | { + disperse_request?: never; + authentication_data?: AuthenticationData; + })))) { + super(); + pb_1.Message.initialize(this, Array.isArray(data) ? data : [], 0, -1, [], this.#one_of_decls); + if (!Array.isArray(data) && typeof data == "object") { + if ("disperse_request" in data && data.disperse_request != undefined) { + this.disperse_request = data.disperse_request; + } + if ("authentication_data" in data && data.authentication_data != undefined) { + this.authentication_data = data.authentication_data; + } + } + } + get disperse_request() { + return pb_1.Message.getWrapperField(this, DisperseBlobRequest, 1) as DisperseBlobRequest; + } + set disperse_request(value: DisperseBlobRequest) { + pb_1.Message.setOneofWrapperField(this, 1, this.#one_of_decls[0], value); + } + get has_disperse_request() { + return pb_1.Message.getField(this, 1) != null; + } + get authentication_data() { + return pb_1.Message.getWrapperField(this, AuthenticationData, 2) as AuthenticationData; + } + set authentication_data(value: AuthenticationData) { + pb_1.Message.setOneofWrapperField(this, 2, this.#one_of_decls[0], value); + } + get has_authentication_data() { + return pb_1.Message.getField(this, 2) != null; + } + get payload() { + const cases: { + [index: number]: "none" | "disperse_request" | "authentication_data"; + } = { + 0: "none", + 1: "disperse_request", + 2: "authentication_data" + }; + return cases[pb_1.Message.computeOneofCase(this, [1, 2])]; + } + static fromObject(data: { + disperse_request?: ReturnType; + authentication_data?: ReturnType; + }): AuthenticatedRequest { + const message = new AuthenticatedRequest({}); + if (data.disperse_request != null) { + message.disperse_request = DisperseBlobRequest.fromObject(data.disperse_request); + } + if (data.authentication_data != null) { + message.authentication_data = AuthenticationData.fromObject(data.authentication_data); + } + return message; + } + toObject() { + const data: { + disperse_request?: ReturnType; + authentication_data?: ReturnType; + } = {}; + if (this.disperse_request != null) { + data.disperse_request = this.disperse_request.toObject(); + } + if (this.authentication_data != null) { + data.authentication_data = this.authentication_data.toObject(); + } + return data; + } + serialize(): Uint8Array; + serialize(w: pb_1.BinaryWriter): void; + serialize(w?: pb_1.BinaryWriter): Uint8Array | void { + const writer = w || new pb_1.BinaryWriter(); + if (this.has_disperse_request) + writer.writeMessage(1, this.disperse_request, () => this.disperse_request.serialize(writer)); + if (this.has_authentication_data) + writer.writeMessage(2, this.authentication_data, () => this.authentication_data.serialize(writer)); + if (!w) + return writer.getResultBuffer(); + } + static deserialize(bytes: Uint8Array | pb_1.BinaryReader): AuthenticatedRequest { + const reader = bytes instanceof pb_1.BinaryReader ? bytes : new pb_1.BinaryReader(bytes), message = new AuthenticatedRequest(); + while (reader.nextField()) { + if (reader.isEndGroup()) + break; + switch (reader.getFieldNumber()) { + case 1: + reader.readMessage(message.disperse_request, () => message.disperse_request = DisperseBlobRequest.deserialize(reader)); + break; + case 2: + reader.readMessage(message.authentication_data, () => message.authentication_data = AuthenticationData.deserialize(reader)); + break; + default: reader.skipField(); + } + } + return message; + } + serializeBinary(): Uint8Array { + return this.serialize(); + } + static deserializeBinary(bytes: Uint8Array): AuthenticatedRequest { + return AuthenticatedRequest.deserialize(bytes); + } + } + export class AuthenticatedReply extends pb_1.Message { + #one_of_decls: number[][] = [[1, 2]]; + constructor(data?: any[] | ({} & (({ + blob_auth_header?: BlobAuthHeader; + disperse_reply?: never; + } | { + blob_auth_header?: never; + disperse_reply?: DisperseBlobReply; + })))) { + super(); + pb_1.Message.initialize(this, Array.isArray(data) ? data : [], 0, -1, [], this.#one_of_decls); + if (!Array.isArray(data) && typeof data == "object") { + if ("blob_auth_header" in data && data.blob_auth_header != undefined) { + this.blob_auth_header = data.blob_auth_header; + } + if ("disperse_reply" in data && data.disperse_reply != undefined) { + this.disperse_reply = data.disperse_reply; + } + } + } + get blob_auth_header() { + return pb_1.Message.getWrapperField(this, BlobAuthHeader, 1) as BlobAuthHeader; + } + set blob_auth_header(value: BlobAuthHeader) { + pb_1.Message.setOneofWrapperField(this, 1, this.#one_of_decls[0], value); + } + get has_blob_auth_header() { + return pb_1.Message.getField(this, 1) != null; + } + get disperse_reply() { + return pb_1.Message.getWrapperField(this, DisperseBlobReply, 2) as DisperseBlobReply; + } + set disperse_reply(value: DisperseBlobReply) { + pb_1.Message.setOneofWrapperField(this, 2, this.#one_of_decls[0], value); + } + get has_disperse_reply() { + return pb_1.Message.getField(this, 2) != null; + } + get payload() { + const cases: { + [index: number]: "none" | "blob_auth_header" | "disperse_reply"; + } = { + 0: "none", + 1: "blob_auth_header", + 2: "disperse_reply" + }; + return cases[pb_1.Message.computeOneofCase(this, [1, 2])]; + } + static fromObject(data: { + blob_auth_header?: ReturnType; + disperse_reply?: ReturnType; + }): AuthenticatedReply { + const message = new AuthenticatedReply({}); + if (data.blob_auth_header != null) { + message.blob_auth_header = BlobAuthHeader.fromObject(data.blob_auth_header); + } + if (data.disperse_reply != null) { + message.disperse_reply = DisperseBlobReply.fromObject(data.disperse_reply); + } + return message; + } + toObject() { + const data: { + blob_auth_header?: ReturnType; + disperse_reply?: ReturnType; + } = {}; + if (this.blob_auth_header != null) { + data.blob_auth_header = this.blob_auth_header.toObject(); + } + if (this.disperse_reply != null) { + data.disperse_reply = this.disperse_reply.toObject(); + } + return data; + } + serialize(): Uint8Array; + serialize(w: pb_1.BinaryWriter): void; + serialize(w?: pb_1.BinaryWriter): Uint8Array | void { + const writer = w || new pb_1.BinaryWriter(); + if (this.has_blob_auth_header) + writer.writeMessage(1, this.blob_auth_header, () => this.blob_auth_header.serialize(writer)); + if (this.has_disperse_reply) + writer.writeMessage(2, this.disperse_reply, () => this.disperse_reply.serialize(writer)); + if (!w) + return writer.getResultBuffer(); + } + static deserialize(bytes: Uint8Array | pb_1.BinaryReader): AuthenticatedReply { + const reader = bytes instanceof pb_1.BinaryReader ? bytes : new pb_1.BinaryReader(bytes), message = new AuthenticatedReply(); + while (reader.nextField()) { + if (reader.isEndGroup()) + break; + switch (reader.getFieldNumber()) { + case 1: + reader.readMessage(message.blob_auth_header, () => message.blob_auth_header = BlobAuthHeader.deserialize(reader)); + break; + case 2: + reader.readMessage(message.disperse_reply, () => message.disperse_reply = DisperseBlobReply.deserialize(reader)); + break; + default: reader.skipField(); + } + } + return message; + } + serializeBinary(): Uint8Array { + return this.serialize(); + } + static deserializeBinary(bytes: Uint8Array): AuthenticatedReply { + return AuthenticatedReply.deserialize(bytes); + } + } + export class BlobAuthHeader extends pb_1.Message { + #one_of_decls: number[][] = []; + constructor(data?: any[] | { + challenge_parameter?: number; + }) { + super(); + pb_1.Message.initialize(this, Array.isArray(data) ? data : [], 0, -1, [], this.#one_of_decls); + if (!Array.isArray(data) && typeof data == "object") { + if ("challenge_parameter" in data && data.challenge_parameter != undefined) { + this.challenge_parameter = data.challenge_parameter; + } + } + } + get challenge_parameter() { + return pb_1.Message.getFieldWithDefault(this, 1, 0) as number; + } + set challenge_parameter(value: number) { + pb_1.Message.setField(this, 1, value); + } + static fromObject(data: { + challenge_parameter?: number; + }): BlobAuthHeader { + const message = new BlobAuthHeader({}); + if (data.challenge_parameter != null) { + message.challenge_parameter = data.challenge_parameter; + } + return message; + } + toObject() { + const data: { + challenge_parameter?: number; + } = {}; + if (this.challenge_parameter != null) { + data.challenge_parameter = this.challenge_parameter; + } + return data; + } + serialize(): Uint8Array; + serialize(w: pb_1.BinaryWriter): void; + serialize(w?: pb_1.BinaryWriter): Uint8Array | void { + const writer = w || new pb_1.BinaryWriter(); + if (this.challenge_parameter != 0) + writer.writeUint32(1, this.challenge_parameter); + if (!w) + return writer.getResultBuffer(); + } + static deserialize(bytes: Uint8Array | pb_1.BinaryReader): BlobAuthHeader { + const reader = bytes instanceof pb_1.BinaryReader ? bytes : new pb_1.BinaryReader(bytes), message = new BlobAuthHeader(); + while (reader.nextField()) { + if (reader.isEndGroup()) + break; + switch (reader.getFieldNumber()) { + case 1: + message.challenge_parameter = reader.readUint32(); + break; + default: reader.skipField(); + } + } + return message; + } + serializeBinary(): Uint8Array { + return this.serialize(); + } + static deserializeBinary(bytes: Uint8Array): BlobAuthHeader { + return BlobAuthHeader.deserialize(bytes); + } + } + export class AuthenticationData extends pb_1.Message { + #one_of_decls: number[][] = []; + constructor(data?: any[] | { + authentication_data?: Uint8Array; + }) { + super(); + pb_1.Message.initialize(this, Array.isArray(data) ? data : [], 0, -1, [], this.#one_of_decls); + if (!Array.isArray(data) && typeof data == "object") { + if ("authentication_data" in data && data.authentication_data != undefined) { + this.authentication_data = data.authentication_data; + } + } + } + get authentication_data() { + return pb_1.Message.getFieldWithDefault(this, 1, new Uint8Array(0)) as Uint8Array; + } + set authentication_data(value: Uint8Array) { + pb_1.Message.setField(this, 1, value); + } + static fromObject(data: { + authentication_data?: Uint8Array; + }): AuthenticationData { + const message = new AuthenticationData({}); + if (data.authentication_data != null) { + message.authentication_data = data.authentication_data; + } + return message; + } + toObject() { + const data: { + authentication_data?: Uint8Array; + } = {}; + if (this.authentication_data != null) { + data.authentication_data = this.authentication_data; + } + return data; + } + serialize(): Uint8Array; + serialize(w: pb_1.BinaryWriter): void; + serialize(w?: pb_1.BinaryWriter): Uint8Array | void { + const writer = w || new pb_1.BinaryWriter(); + if (this.authentication_data.length) + writer.writeBytes(1, this.authentication_data); + if (!w) + return writer.getResultBuffer(); + } + static deserialize(bytes: Uint8Array | pb_1.BinaryReader): AuthenticationData { + const reader = bytes instanceof pb_1.BinaryReader ? bytes : new pb_1.BinaryReader(bytes), message = new AuthenticationData(); + while (reader.nextField()) { + if (reader.isEndGroup()) + break; + switch (reader.getFieldNumber()) { + case 1: + message.authentication_data = reader.readBytes(); + break; + default: reader.skipField(); + } + } + return message; + } + serializeBinary(): Uint8Array { + return this.serialize(); + } + static deserializeBinary(bytes: Uint8Array): AuthenticationData { + return AuthenticationData.deserialize(bytes); + } + } + export class DisperseBlobRequest extends pb_1.Message { + #one_of_decls: number[][] = []; + constructor(data?: any[] | { + data?: Uint8Array; + custom_quorum_numbers?: number[]; + account_id?: string; + }) { + super(); + pb_1.Message.initialize(this, Array.isArray(data) ? data : [], 0, -1, [2], this.#one_of_decls); + if (!Array.isArray(data) && typeof data == "object") { + if ("data" in data && data.data != undefined) { + this.data = data.data; + } + if ("custom_quorum_numbers" in data && data.custom_quorum_numbers != undefined) { + this.custom_quorum_numbers = data.custom_quorum_numbers; + } + if ("account_id" in data && data.account_id != undefined) { + this.account_id = data.account_id; + } + } + } + get data() { + return pb_1.Message.getFieldWithDefault(this, 1, new Uint8Array(0)) as Uint8Array; + } + set data(value: Uint8Array) { + pb_1.Message.setField(this, 1, value); + } + get custom_quorum_numbers() { + return pb_1.Message.getFieldWithDefault(this, 2, []) as number[]; + } + set custom_quorum_numbers(value: number[]) { + pb_1.Message.setField(this, 2, value); + } + get account_id() { + return pb_1.Message.getFieldWithDefault(this, 3, "") as string; + } + set account_id(value: string) { + pb_1.Message.setField(this, 3, value); + } + static fromObject(data: { + data?: Uint8Array; + custom_quorum_numbers?: number[]; + account_id?: string; + }): DisperseBlobRequest { + const message = new DisperseBlobRequest({}); + if (data.data != null) { + message.data = data.data; + } + if (data.custom_quorum_numbers != null) { + message.custom_quorum_numbers = data.custom_quorum_numbers; + } + if (data.account_id != null) { + message.account_id = data.account_id; + } + return message; + } + toObject() { + const data: { + data?: Uint8Array; + custom_quorum_numbers?: number[]; + account_id?: string; + } = {}; + if (this.data != null) { + data.data = this.data; + } + if (this.custom_quorum_numbers != null) { + data.custom_quorum_numbers = this.custom_quorum_numbers; + } + if (this.account_id != null) { + data.account_id = this.account_id; + } + return data; + } + serialize(): Uint8Array; + serialize(w: pb_1.BinaryWriter): void; + serialize(w?: pb_1.BinaryWriter): Uint8Array | void { + const writer = w || new pb_1.BinaryWriter(); + if (this.data.length) + writer.writeBytes(1, this.data); + if (this.custom_quorum_numbers.length) + writer.writePackedUint32(2, this.custom_quorum_numbers); + if (this.account_id.length) + writer.writeString(3, this.account_id); + if (!w) + return writer.getResultBuffer(); + } + static deserialize(bytes: Uint8Array | pb_1.BinaryReader): DisperseBlobRequest { + const reader = bytes instanceof pb_1.BinaryReader ? bytes : new pb_1.BinaryReader(bytes), message = new DisperseBlobRequest(); + while (reader.nextField()) { + if (reader.isEndGroup()) + break; + switch (reader.getFieldNumber()) { + case 1: + message.data = reader.readBytes(); + break; + case 2: + message.custom_quorum_numbers = reader.readPackedUint32(); + break; + case 3: + message.account_id = reader.readString(); + break; + default: reader.skipField(); + } + } + return message; + } + serializeBinary(): Uint8Array { + return this.serialize(); + } + static deserializeBinary(bytes: Uint8Array): DisperseBlobRequest { + return DisperseBlobRequest.deserialize(bytes); + } + } + export class DisperseBlobReply extends pb_1.Message { + #one_of_decls: number[][] = []; + constructor(data?: any[] | { + result?: BlobStatus; + request_id?: Uint8Array; + }) { + super(); + pb_1.Message.initialize(this, Array.isArray(data) ? data : [], 0, -1, [], this.#one_of_decls); + if (!Array.isArray(data) && typeof data == "object") { + if ("result" in data && data.result != undefined) { + this.result = data.result; + } + if ("request_id" in data && data.request_id != undefined) { + this.request_id = data.request_id; + } + } + } + get result() { + return pb_1.Message.getFieldWithDefault(this, 1, BlobStatus.UNKNOWN) as BlobStatus; + } + set result(value: BlobStatus) { + pb_1.Message.setField(this, 1, value); + } + get request_id() { + return pb_1.Message.getFieldWithDefault(this, 2, new Uint8Array(0)) as Uint8Array; + } + set request_id(value: Uint8Array) { + pb_1.Message.setField(this, 2, value); + } + static fromObject(data: { + result?: BlobStatus; + request_id?: Uint8Array; + }): DisperseBlobReply { + const message = new DisperseBlobReply({}); + if (data.result != null) { + message.result = data.result; + } + if (data.request_id != null) { + message.request_id = data.request_id; + } + return message; + } + toObject() { + const data: { + result?: BlobStatus; + request_id?: Uint8Array; + } = {}; + if (this.result != null) { + data.result = this.result; + } + if (this.request_id != null) { + data.request_id = this.request_id; + } + return data; + } + serialize(): Uint8Array; + serialize(w: pb_1.BinaryWriter): void; + serialize(w?: pb_1.BinaryWriter): Uint8Array | void { + const writer = w || new pb_1.BinaryWriter(); + if (this.result != BlobStatus.UNKNOWN) + writer.writeEnum(1, this.result); + if (this.request_id.length) + writer.writeBytes(2, this.request_id); + if (!w) + return writer.getResultBuffer(); + } + static deserialize(bytes: Uint8Array | pb_1.BinaryReader): DisperseBlobReply { + const reader = bytes instanceof pb_1.BinaryReader ? bytes : new pb_1.BinaryReader(bytes), message = new DisperseBlobReply(); + while (reader.nextField()) { + if (reader.isEndGroup()) + break; + switch (reader.getFieldNumber()) { + case 1: + message.result = reader.readEnum(); + break; + case 2: + message.request_id = reader.readBytes(); + break; + default: reader.skipField(); + } + } + return message; + } + serializeBinary(): Uint8Array { + return this.serialize(); + } + static deserializeBinary(bytes: Uint8Array): DisperseBlobReply { + return DisperseBlobReply.deserialize(bytes); + } + } + export class BlobStatusRequest extends pb_1.Message { + #one_of_decls: number[][] = []; + constructor(data?: any[] | { + request_id?: Uint8Array; + }) { + super(); + pb_1.Message.initialize(this, Array.isArray(data) ? data : [], 0, -1, [], this.#one_of_decls); + if (!Array.isArray(data) && typeof data == "object") { + if ("request_id" in data && data.request_id != undefined) { + this.request_id = data.request_id; + } + } + } + get request_id() { + return pb_1.Message.getFieldWithDefault(this, 1, new Uint8Array(0)) as Uint8Array; + } + set request_id(value: Uint8Array) { + pb_1.Message.setField(this, 1, value); + } + static fromObject(data: { + request_id?: Uint8Array; + }): BlobStatusRequest { + const message = new BlobStatusRequest({}); + if (data.request_id != null) { + message.request_id = data.request_id; + } + return message; + } + toObject() { + const data: { + request_id?: Uint8Array; + } = {}; + if (this.request_id != null) { + data.request_id = this.request_id; + } + return data; + } + serialize(): Uint8Array; + serialize(w: pb_1.BinaryWriter): void; + serialize(w?: pb_1.BinaryWriter): Uint8Array | void { + const writer = w || new pb_1.BinaryWriter(); + if (this.request_id.length) + writer.writeBytes(1, this.request_id); + if (!w) + return writer.getResultBuffer(); + } + static deserialize(bytes: Uint8Array | pb_1.BinaryReader): BlobStatusRequest { + const reader = bytes instanceof pb_1.BinaryReader ? bytes : new pb_1.BinaryReader(bytes), message = new BlobStatusRequest(); + while (reader.nextField()) { + if (reader.isEndGroup()) + break; + switch (reader.getFieldNumber()) { + case 1: + message.request_id = reader.readBytes(); + break; + default: reader.skipField(); + } + } + return message; + } + serializeBinary(): Uint8Array { + return this.serialize(); + } + static deserializeBinary(bytes: Uint8Array): BlobStatusRequest { + return BlobStatusRequest.deserialize(bytes); + } + } + export class BlobStatusReply extends pb_1.Message { + #one_of_decls: number[][] = []; + constructor(data?: any[] | { + status?: BlobStatus; + info?: BlobInfo; + }) { + super(); + pb_1.Message.initialize(this, Array.isArray(data) ? data : [], 0, -1, [], this.#one_of_decls); + if (!Array.isArray(data) && typeof data == "object") { + if ("status" in data && data.status != undefined) { + this.status = data.status; + } + if ("info" in data && data.info != undefined) { + this.info = data.info; + } + } + } + get status() { + return pb_1.Message.getFieldWithDefault(this, 1, BlobStatus.UNKNOWN) as BlobStatus; + } + set status(value: BlobStatus) { + pb_1.Message.setField(this, 1, value); + } + get info() { + return pb_1.Message.getWrapperField(this, BlobInfo, 2) as BlobInfo; + } + set info(value: BlobInfo) { + pb_1.Message.setWrapperField(this, 2, value); + } + get has_info() { + return pb_1.Message.getField(this, 2) != null; + } + static fromObject(data: { + status?: BlobStatus; + info?: ReturnType; + }): BlobStatusReply { + const message = new BlobStatusReply({}); + if (data.status != null) { + message.status = data.status; + } + if (data.info != null) { + message.info = BlobInfo.fromObject(data.info); + } + return message; + } + toObject() { + const data: { + status?: BlobStatus; + info?: ReturnType; + } = {}; + if (this.status != null) { + data.status = this.status; + } + if (this.info != null) { + data.info = this.info.toObject(); + } + return data; + } + serialize(): Uint8Array; + serialize(w: pb_1.BinaryWriter): void; + serialize(w?: pb_1.BinaryWriter): Uint8Array | void { + const writer = w || new pb_1.BinaryWriter(); + if (this.status != BlobStatus.UNKNOWN) + writer.writeEnum(1, this.status); + if (this.has_info) + writer.writeMessage(2, this.info, () => this.info.serialize(writer)); + if (!w) + return writer.getResultBuffer(); + } + static deserialize(bytes: Uint8Array | pb_1.BinaryReader): BlobStatusReply { + const reader = bytes instanceof pb_1.BinaryReader ? bytes : new pb_1.BinaryReader(bytes), message = new BlobStatusReply(); + while (reader.nextField()) { + if (reader.isEndGroup()) + break; + switch (reader.getFieldNumber()) { + case 1: + message.status = reader.readEnum(); + break; + case 2: + reader.readMessage(message.info, () => message.info = BlobInfo.deserialize(reader)); + break; + default: reader.skipField(); + } + } + return message; + } + serializeBinary(): Uint8Array { + return this.serialize(); + } + static deserializeBinary(bytes: Uint8Array): BlobStatusReply { + return BlobStatusReply.deserialize(bytes); + } + } + export class RetrieveBlobRequest extends pb_1.Message { + #one_of_decls: number[][] = []; + constructor(data?: any[] | { + batch_header_hash?: Uint8Array; + blob_index?: number; + }) { + super(); + pb_1.Message.initialize(this, Array.isArray(data) ? data : [], 0, -1, [], this.#one_of_decls); + if (!Array.isArray(data) && typeof data == "object") { + if ("batch_header_hash" in data && data.batch_header_hash != undefined) { + this.batch_header_hash = data.batch_header_hash; + } + if ("blob_index" in data && data.blob_index != undefined) { + this.blob_index = data.blob_index; + } + } + } + get batch_header_hash() { + return pb_1.Message.getFieldWithDefault(this, 1, new Uint8Array(0)) as Uint8Array; + } + set batch_header_hash(value: Uint8Array) { + pb_1.Message.setField(this, 1, value); + } + get blob_index() { + return pb_1.Message.getFieldWithDefault(this, 2, 0) as number; + } + set blob_index(value: number) { + pb_1.Message.setField(this, 2, value); + } + static fromObject(data: { + batch_header_hash?: Uint8Array; + blob_index?: number; + }): RetrieveBlobRequest { + const message = new RetrieveBlobRequest({}); + if (data.batch_header_hash != null) { + message.batch_header_hash = data.batch_header_hash; + } + if (data.blob_index != null) { + message.blob_index = data.blob_index; + } + return message; + } + toObject() { + const data: { + batch_header_hash?: Uint8Array; + blob_index?: number; + } = {}; + if (this.batch_header_hash != null) { + data.batch_header_hash = this.batch_header_hash; + } + if (this.blob_index != null) { + data.blob_index = this.blob_index; + } + return data; + } + serialize(): Uint8Array; + serialize(w: pb_1.BinaryWriter): void; + serialize(w?: pb_1.BinaryWriter): Uint8Array | void { + const writer = w || new pb_1.BinaryWriter(); + if (this.batch_header_hash.length) + writer.writeBytes(1, this.batch_header_hash); + if (this.blob_index != 0) + writer.writeUint32(2, this.blob_index); + if (!w) + return writer.getResultBuffer(); + } + static deserialize(bytes: Uint8Array | pb_1.BinaryReader): RetrieveBlobRequest { + const reader = bytes instanceof pb_1.BinaryReader ? bytes : new pb_1.BinaryReader(bytes), message = new RetrieveBlobRequest(); + while (reader.nextField()) { + if (reader.isEndGroup()) + break; + switch (reader.getFieldNumber()) { + case 1: + message.batch_header_hash = reader.readBytes(); + break; + case 2: + message.blob_index = reader.readUint32(); + break; + default: reader.skipField(); + } + } + return message; + } + serializeBinary(): Uint8Array { + return this.serialize(); + } + static deserializeBinary(bytes: Uint8Array): RetrieveBlobRequest { + return RetrieveBlobRequest.deserialize(bytes); + } + } + export class RetrieveBlobReply extends pb_1.Message { + #one_of_decls: number[][] = []; + constructor(data?: any[] | { + data?: Uint8Array; + }) { + super(); + pb_1.Message.initialize(this, Array.isArray(data) ? data : [], 0, -1, [], this.#one_of_decls); + if (!Array.isArray(data) && typeof data == "object") { + if ("data" in data && data.data != undefined) { + this.data = data.data; + } + } + } + get data() { + return pb_1.Message.getFieldWithDefault(this, 1, new Uint8Array(0)) as Uint8Array; + } + set data(value: Uint8Array) { + pb_1.Message.setField(this, 1, value); + } + static fromObject(data: { + data?: Uint8Array; + }): RetrieveBlobReply { + const message = new RetrieveBlobReply({}); + if (data.data != null) { + message.data = data.data; + } + return message; + } + toObject() { + const data: { + data?: Uint8Array; + } = {}; + if (this.data != null) { + data.data = this.data; + } + return data; + } + serialize(): Uint8Array; + serialize(w: pb_1.BinaryWriter): void; + serialize(w?: pb_1.BinaryWriter): Uint8Array | void { + const writer = w || new pb_1.BinaryWriter(); + if (this.data.length) + writer.writeBytes(1, this.data); + if (!w) + return writer.getResultBuffer(); + } + static deserialize(bytes: Uint8Array | pb_1.BinaryReader): RetrieveBlobReply { + const reader = bytes instanceof pb_1.BinaryReader ? bytes : new pb_1.BinaryReader(bytes), message = new RetrieveBlobReply(); + while (reader.nextField()) { + if (reader.isEndGroup()) + break; + switch (reader.getFieldNumber()) { + case 1: + message.data = reader.readBytes(); + break; + default: reader.skipField(); + } + } + return message; + } + serializeBinary(): Uint8Array { + return this.serialize(); + } + static deserializeBinary(bytes: Uint8Array): RetrieveBlobReply { + return RetrieveBlobReply.deserialize(bytes); + } + } + export class BlobInfo extends pb_1.Message { + #one_of_decls: number[][] = []; + constructor(data?: any[] | { + blob_header?: BlobHeader; + blob_verification_proof?: BlobVerificationProof; + }) { + super(); + pb_1.Message.initialize(this, Array.isArray(data) ? data : [], 0, -1, [], this.#one_of_decls); + if (!Array.isArray(data) && typeof data == "object") { + if ("blob_header" in data && data.blob_header != undefined) { + this.blob_header = data.blob_header; + } + if ("blob_verification_proof" in data && data.blob_verification_proof != undefined) { + this.blob_verification_proof = data.blob_verification_proof; + } + } + } + get blob_header() { + return pb_1.Message.getWrapperField(this, BlobHeader, 1) as BlobHeader; + } + set blob_header(value: BlobHeader) { + pb_1.Message.setWrapperField(this, 1, value); + } + get has_blob_header() { + return pb_1.Message.getField(this, 1) != null; + } + get blob_verification_proof() { + return pb_1.Message.getWrapperField(this, BlobVerificationProof, 2) as BlobVerificationProof; + } + set blob_verification_proof(value: BlobVerificationProof) { + pb_1.Message.setWrapperField(this, 2, value); + } + get has_blob_verification_proof() { + return pb_1.Message.getField(this, 2) != null; + } + static fromObject(data: { + blob_header?: ReturnType; + blob_verification_proof?: ReturnType; + }): BlobInfo { + const message = new BlobInfo({}); + if (data.blob_header != null) { + message.blob_header = BlobHeader.fromObject(data.blob_header); + } + if (data.blob_verification_proof != null) { + message.blob_verification_proof = BlobVerificationProof.fromObject(data.blob_verification_proof); + } + return message; + } + toObject() { + const data: { + blob_header?: ReturnType; + blob_verification_proof?: ReturnType; + } = {}; + if (this.blob_header != null) { + data.blob_header = this.blob_header.toObject(); + } + if (this.blob_verification_proof != null) { + data.blob_verification_proof = this.blob_verification_proof.toObject(); + } + return data; + } + serialize(): Uint8Array; + serialize(w: pb_1.BinaryWriter): void; + serialize(w?: pb_1.BinaryWriter): Uint8Array | void { + const writer = w || new pb_1.BinaryWriter(); + if (this.has_blob_header) + writer.writeMessage(1, this.blob_header, () => this.blob_header.serialize(writer)); + if (this.has_blob_verification_proof) + writer.writeMessage(2, this.blob_verification_proof, () => this.blob_verification_proof.serialize(writer)); + if (!w) + return writer.getResultBuffer(); + } + static deserialize(bytes: Uint8Array | pb_1.BinaryReader): BlobInfo { + const reader = bytes instanceof pb_1.BinaryReader ? bytes : new pb_1.BinaryReader(bytes), message = new BlobInfo(); + while (reader.nextField()) { + if (reader.isEndGroup()) + break; + switch (reader.getFieldNumber()) { + case 1: + reader.readMessage(message.blob_header, () => message.blob_header = BlobHeader.deserialize(reader)); + break; + case 2: + reader.readMessage(message.blob_verification_proof, () => message.blob_verification_proof = BlobVerificationProof.deserialize(reader)); + break; + default: reader.skipField(); + } + } + return message; + } + serializeBinary(): Uint8Array { + return this.serialize(); + } + static deserializeBinary(bytes: Uint8Array): BlobInfo { + return BlobInfo.deserialize(bytes); + } + } + export class BlobHeader extends pb_1.Message { + #one_of_decls: number[][] = []; + constructor(data?: any[] | { + commitment?: dependency_1.common.G1Commitment; + data_length?: number; + blob_quorum_params?: BlobQuorumParam[]; + }) { + super(); + pb_1.Message.initialize(this, Array.isArray(data) ? data : [], 0, -1, [3], this.#one_of_decls); + if (!Array.isArray(data) && typeof data == "object") { + if ("commitment" in data && data.commitment != undefined) { + this.commitment = data.commitment; + } + if ("data_length" in data && data.data_length != undefined) { + this.data_length = data.data_length; + } + if ("blob_quorum_params" in data && data.blob_quorum_params != undefined) { + this.blob_quorum_params = data.blob_quorum_params; + } + } + } + get commitment() { + return pb_1.Message.getWrapperField(this, dependency_1.common.G1Commitment, 1) as dependency_1.common.G1Commitment; + } + set commitment(value: dependency_1.common.G1Commitment) { + pb_1.Message.setWrapperField(this, 1, value); + } + get has_commitment() { + return pb_1.Message.getField(this, 1) != null; + } + get data_length() { + return pb_1.Message.getFieldWithDefault(this, 2, 0) as number; + } + set data_length(value: number) { + pb_1.Message.setField(this, 2, value); + } + get blob_quorum_params() { + return pb_1.Message.getRepeatedWrapperField(this, BlobQuorumParam, 3) as BlobQuorumParam[]; + } + set blob_quorum_params(value: BlobQuorumParam[]) { + pb_1.Message.setRepeatedWrapperField(this, 3, value); + } + static fromObject(data: { + commitment?: ReturnType; + data_length?: number; + blob_quorum_params?: ReturnType[]; + }): BlobHeader { + const message = new BlobHeader({}); + if (data.commitment != null) { + message.commitment = dependency_1.common.G1Commitment.fromObject(data.commitment); + } + if (data.data_length != null) { + message.data_length = data.data_length; + } + if (data.blob_quorum_params != null) { + message.blob_quorum_params = data.blob_quorum_params.map(item => BlobQuorumParam.fromObject(item)); + } + return message; + } + toObject() { + const data: { + commitment?: ReturnType; + data_length?: number; + blob_quorum_params?: ReturnType[]; + } = {}; + if (this.commitment != null) { + data.commitment = this.commitment.toObject(); + } + if (this.data_length != null) { + data.data_length = this.data_length; + } + if (this.blob_quorum_params != null) { + data.blob_quorum_params = this.blob_quorum_params.map((item: BlobQuorumParam) => item.toObject()); + } + return data; + } + serialize(): Uint8Array; + serialize(w: pb_1.BinaryWriter): void; + serialize(w?: pb_1.BinaryWriter): Uint8Array | void { + const writer = w || new pb_1.BinaryWriter(); + if (this.has_commitment) + writer.writeMessage(1, this.commitment, () => this.commitment.serialize(writer)); + if (this.data_length != 0) + writer.writeUint32(2, this.data_length); + if (this.blob_quorum_params.length) + writer.writeRepeatedMessage(3, this.blob_quorum_params, (item: BlobQuorumParam) => item.serialize(writer)); + if (!w) + return writer.getResultBuffer(); + } + static deserialize(bytes: Uint8Array | pb_1.BinaryReader): BlobHeader { + const reader = bytes instanceof pb_1.BinaryReader ? bytes : new pb_1.BinaryReader(bytes), message = new BlobHeader(); + while (reader.nextField()) { + if (reader.isEndGroup()) + break; + switch (reader.getFieldNumber()) { + case 1: + reader.readMessage(message.commitment, () => message.commitment = dependency_1.common.G1Commitment.deserialize(reader)); + break; + case 2: + message.data_length = reader.readUint32(); + break; + case 3: + reader.readMessage(message.blob_quorum_params, () => pb_1.Message.addToRepeatedWrapperField(message, 3, BlobQuorumParam.deserialize(reader), BlobQuorumParam)); + break; + default: reader.skipField(); + } + } + return message; + } + serializeBinary(): Uint8Array { + return this.serialize(); + } + static deserializeBinary(bytes: Uint8Array): BlobHeader { + return BlobHeader.deserialize(bytes); + } + } + export class BlobQuorumParam extends pb_1.Message { + #one_of_decls: number[][] = []; + constructor(data?: any[] | { + quorum_number?: number; + adversary_threshold_percentage?: number; + confirmation_threshold_percentage?: number; + chunk_length?: number; + }) { + super(); + pb_1.Message.initialize(this, Array.isArray(data) ? data : [], 0, -1, [], this.#one_of_decls); + if (!Array.isArray(data) && typeof data == "object") { + if ("quorum_number" in data && data.quorum_number != undefined) { + this.quorum_number = data.quorum_number; + } + if ("adversary_threshold_percentage" in data && data.adversary_threshold_percentage != undefined) { + this.adversary_threshold_percentage = data.adversary_threshold_percentage; + } + if ("confirmation_threshold_percentage" in data && data.confirmation_threshold_percentage != undefined) { + this.confirmation_threshold_percentage = data.confirmation_threshold_percentage; + } + if ("chunk_length" in data && data.chunk_length != undefined) { + this.chunk_length = data.chunk_length; + } + } + } + get quorum_number() { + return pb_1.Message.getFieldWithDefault(this, 1, 0) as number; + } + set quorum_number(value: number) { + pb_1.Message.setField(this, 1, value); + } + get adversary_threshold_percentage() { + return pb_1.Message.getFieldWithDefault(this, 2, 0) as number; + } + set adversary_threshold_percentage(value: number) { + pb_1.Message.setField(this, 2, value); + } + get confirmation_threshold_percentage() { + return pb_1.Message.getFieldWithDefault(this, 3, 0) as number; + } + set confirmation_threshold_percentage(value: number) { + pb_1.Message.setField(this, 3, value); + } + get chunk_length() { + return pb_1.Message.getFieldWithDefault(this, 4, 0) as number; + } + set chunk_length(value: number) { + pb_1.Message.setField(this, 4, value); + } + static fromObject(data: { + quorum_number?: number; + adversary_threshold_percentage?: number; + confirmation_threshold_percentage?: number; + chunk_length?: number; + }): BlobQuorumParam { + const message = new BlobQuorumParam({}); + if (data.quorum_number != null) { + message.quorum_number = data.quorum_number; + } + if (data.adversary_threshold_percentage != null) { + message.adversary_threshold_percentage = data.adversary_threshold_percentage; + } + if (data.confirmation_threshold_percentage != null) { + message.confirmation_threshold_percentage = data.confirmation_threshold_percentage; + } + if (data.chunk_length != null) { + message.chunk_length = data.chunk_length; + } + return message; + } + toObject() { + const data: { + quorum_number?: number; + adversary_threshold_percentage?: number; + confirmation_threshold_percentage?: number; + chunk_length?: number; + } = {}; + if (this.quorum_number != null) { + data.quorum_number = this.quorum_number; + } + if (this.adversary_threshold_percentage != null) { + data.adversary_threshold_percentage = this.adversary_threshold_percentage; + } + if (this.confirmation_threshold_percentage != null) { + data.confirmation_threshold_percentage = this.confirmation_threshold_percentage; + } + if (this.chunk_length != null) { + data.chunk_length = this.chunk_length; + } + return data; + } + serialize(): Uint8Array; + serialize(w: pb_1.BinaryWriter): void; + serialize(w?: pb_1.BinaryWriter): Uint8Array | void { + const writer = w || new pb_1.BinaryWriter(); + if (this.quorum_number != 0) + writer.writeUint32(1, this.quorum_number); + if (this.adversary_threshold_percentage != 0) + writer.writeUint32(2, this.adversary_threshold_percentage); + if (this.confirmation_threshold_percentage != 0) + writer.writeUint32(3, this.confirmation_threshold_percentage); + if (this.chunk_length != 0) + writer.writeUint32(4, this.chunk_length); + if (!w) + return writer.getResultBuffer(); + } + static deserialize(bytes: Uint8Array | pb_1.BinaryReader): BlobQuorumParam { + const reader = bytes instanceof pb_1.BinaryReader ? bytes : new pb_1.BinaryReader(bytes), message = new BlobQuorumParam(); + while (reader.nextField()) { + if (reader.isEndGroup()) + break; + switch (reader.getFieldNumber()) { + case 1: + message.quorum_number = reader.readUint32(); + break; + case 2: + message.adversary_threshold_percentage = reader.readUint32(); + break; + case 3: + message.confirmation_threshold_percentage = reader.readUint32(); + break; + case 4: + message.chunk_length = reader.readUint32(); + break; + default: reader.skipField(); + } + } + return message; + } + serializeBinary(): Uint8Array { + return this.serialize(); + } + static deserializeBinary(bytes: Uint8Array): BlobQuorumParam { + return BlobQuorumParam.deserialize(bytes); + } + } + export class BlobVerificationProof extends pb_1.Message { + #one_of_decls: number[][] = []; + constructor(data?: any[] | { + batch_id?: number; + blob_index?: number; + batch_metadata?: BatchMetadata; + inclusion_proof?: Uint8Array; + quorum_indexes?: Uint8Array; + }) { + super(); + pb_1.Message.initialize(this, Array.isArray(data) ? data : [], 0, -1, [], this.#one_of_decls); + if (!Array.isArray(data) && typeof data == "object") { + if ("batch_id" in data && data.batch_id != undefined) { + this.batch_id = data.batch_id; + } + if ("blob_index" in data && data.blob_index != undefined) { + this.blob_index = data.blob_index; + } + if ("batch_metadata" in data && data.batch_metadata != undefined) { + this.batch_metadata = data.batch_metadata; + } + if ("inclusion_proof" in data && data.inclusion_proof != undefined) { + this.inclusion_proof = data.inclusion_proof; + } + if ("quorum_indexes" in data && data.quorum_indexes != undefined) { + this.quorum_indexes = data.quorum_indexes; + } + } + } + get batch_id() { + return pb_1.Message.getFieldWithDefault(this, 1, 0) as number; + } + set batch_id(value: number) { + pb_1.Message.setField(this, 1, value); + } + get blob_index() { + return pb_1.Message.getFieldWithDefault(this, 2, 0) as number; + } + set blob_index(value: number) { + pb_1.Message.setField(this, 2, value); + } + get batch_metadata() { + return pb_1.Message.getWrapperField(this, BatchMetadata, 3) as BatchMetadata; + } + set batch_metadata(value: BatchMetadata) { + pb_1.Message.setWrapperField(this, 3, value); + } + get has_batch_metadata() { + return pb_1.Message.getField(this, 3) != null; + } + get inclusion_proof() { + return pb_1.Message.getFieldWithDefault(this, 4, new Uint8Array(0)) as Uint8Array; + } + set inclusion_proof(value: Uint8Array) { + pb_1.Message.setField(this, 4, value); + } + get quorum_indexes() { + return pb_1.Message.getFieldWithDefault(this, 5, new Uint8Array(0)) as Uint8Array; + } + set quorum_indexes(value: Uint8Array) { + pb_1.Message.setField(this, 5, value); + } + static fromObject(data: { + batch_id?: number; + blob_index?: number; + batch_metadata?: ReturnType; + inclusion_proof?: Uint8Array; + quorum_indexes?: Uint8Array; + }): BlobVerificationProof { + const message = new BlobVerificationProof({}); + if (data.batch_id != null) { + message.batch_id = data.batch_id; + } + if (data.blob_index != null) { + message.blob_index = data.blob_index; + } + if (data.batch_metadata != null) { + message.batch_metadata = BatchMetadata.fromObject(data.batch_metadata); + } + if (data.inclusion_proof != null) { + message.inclusion_proof = data.inclusion_proof; + } + if (data.quorum_indexes != null) { + message.quorum_indexes = data.quorum_indexes; + } + return message; + } + toObject() { + const data: { + batch_id?: number; + blob_index?: number; + batch_metadata?: ReturnType; + inclusion_proof?: Uint8Array; + quorum_indexes?: Uint8Array; + } = {}; + if (this.batch_id != null) { + data.batch_id = this.batch_id; + } + if (this.blob_index != null) { + data.blob_index = this.blob_index; + } + if (this.batch_metadata != null) { + data.batch_metadata = this.batch_metadata.toObject(); + } + if (this.inclusion_proof != null) { + data.inclusion_proof = this.inclusion_proof; + } + if (this.quorum_indexes != null) { + data.quorum_indexes = this.quorum_indexes; + } + return data; + } + serialize(): Uint8Array; + serialize(w: pb_1.BinaryWriter): void; + serialize(w?: pb_1.BinaryWriter): Uint8Array | void { + const writer = w || new pb_1.BinaryWriter(); + if (this.batch_id != 0) + writer.writeUint32(1, this.batch_id); + if (this.blob_index != 0) + writer.writeUint32(2, this.blob_index); + if (this.has_batch_metadata) + writer.writeMessage(3, this.batch_metadata, () => this.batch_metadata.serialize(writer)); + if (this.inclusion_proof.length) + writer.writeBytes(4, this.inclusion_proof); + if (this.quorum_indexes.length) + writer.writeBytes(5, this.quorum_indexes); + if (!w) + return writer.getResultBuffer(); + } + static deserialize(bytes: Uint8Array | pb_1.BinaryReader): BlobVerificationProof { + const reader = bytes instanceof pb_1.BinaryReader ? bytes : new pb_1.BinaryReader(bytes), message = new BlobVerificationProof(); + while (reader.nextField()) { + if (reader.isEndGroup()) + break; + switch (reader.getFieldNumber()) { + case 1: + message.batch_id = reader.readUint32(); + break; + case 2: + message.blob_index = reader.readUint32(); + break; + case 3: + reader.readMessage(message.batch_metadata, () => message.batch_metadata = BatchMetadata.deserialize(reader)); + break; + case 4: + message.inclusion_proof = reader.readBytes(); + break; + case 5: + message.quorum_indexes = reader.readBytes(); + break; + default: reader.skipField(); + } + } + return message; + } + serializeBinary(): Uint8Array { + return this.serialize(); + } + static deserializeBinary(bytes: Uint8Array): BlobVerificationProof { + return BlobVerificationProof.deserialize(bytes); + } + } + export class BatchMetadata extends pb_1.Message { + #one_of_decls: number[][] = []; + constructor(data?: any[] | { + batch_header?: BatchHeader; + signatory_record_hash?: Uint8Array; + fee?: Uint8Array; + confirmation_block_number?: number; + batch_header_hash?: Uint8Array; + }) { + super(); + pb_1.Message.initialize(this, Array.isArray(data) ? data : [], 0, -1, [], this.#one_of_decls); + if (!Array.isArray(data) && typeof data == "object") { + if ("batch_header" in data && data.batch_header != undefined) { + this.batch_header = data.batch_header; + } + if ("signatory_record_hash" in data && data.signatory_record_hash != undefined) { + this.signatory_record_hash = data.signatory_record_hash; + } + if ("fee" in data && data.fee != undefined) { + this.fee = data.fee; + } + if ("confirmation_block_number" in data && data.confirmation_block_number != undefined) { + this.confirmation_block_number = data.confirmation_block_number; + } + if ("batch_header_hash" in data && data.batch_header_hash != undefined) { + this.batch_header_hash = data.batch_header_hash; + } + } + } + get batch_header() { + return pb_1.Message.getWrapperField(this, BatchHeader, 1) as BatchHeader; + } + set batch_header(value: BatchHeader) { + pb_1.Message.setWrapperField(this, 1, value); + } + get has_batch_header() { + return pb_1.Message.getField(this, 1) != null; + } + get signatory_record_hash() { + return pb_1.Message.getFieldWithDefault(this, 2, new Uint8Array(0)) as Uint8Array; + } + set signatory_record_hash(value: Uint8Array) { + pb_1.Message.setField(this, 2, value); + } + get fee() { + return pb_1.Message.getFieldWithDefault(this, 3, new Uint8Array(0)) as Uint8Array; + } + set fee(value: Uint8Array) { + pb_1.Message.setField(this, 3, value); + } + get confirmation_block_number() { + return pb_1.Message.getFieldWithDefault(this, 4, 0) as number; + } + set confirmation_block_number(value: number) { + pb_1.Message.setField(this, 4, value); + } + get batch_header_hash() { + return pb_1.Message.getFieldWithDefault(this, 5, new Uint8Array(0)) as Uint8Array; + } + set batch_header_hash(value: Uint8Array) { + pb_1.Message.setField(this, 5, value); + } + static fromObject(data: { + batch_header?: ReturnType; + signatory_record_hash?: Uint8Array; + fee?: Uint8Array; + confirmation_block_number?: number; + batch_header_hash?: Uint8Array; + }): BatchMetadata { + const message = new BatchMetadata({}); + if (data.batch_header != null) { + message.batch_header = BatchHeader.fromObject(data.batch_header); + } + if (data.signatory_record_hash != null) { + message.signatory_record_hash = data.signatory_record_hash; + } + if (data.fee != null) { + message.fee = data.fee; + } + if (data.confirmation_block_number != null) { + message.confirmation_block_number = data.confirmation_block_number; + } + if (data.batch_header_hash != null) { + message.batch_header_hash = data.batch_header_hash; + } + return message; + } + toObject() { + const data: { + batch_header?: ReturnType; + signatory_record_hash?: Uint8Array; + fee?: Uint8Array; + confirmation_block_number?: number; + batch_header_hash?: Uint8Array; + } = {}; + if (this.batch_header != null) { + data.batch_header = this.batch_header.toObject(); + } + if (this.signatory_record_hash != null) { + data.signatory_record_hash = this.signatory_record_hash; + } + if (this.fee != null) { + data.fee = this.fee; + } + if (this.confirmation_block_number != null) { + data.confirmation_block_number = this.confirmation_block_number; + } + if (this.batch_header_hash != null) { + data.batch_header_hash = this.batch_header_hash; + } + return data; + } + serialize(): Uint8Array; + serialize(w: pb_1.BinaryWriter): void; + serialize(w?: pb_1.BinaryWriter): Uint8Array | void { + const writer = w || new pb_1.BinaryWriter(); + if (this.has_batch_header) + writer.writeMessage(1, this.batch_header, () => this.batch_header.serialize(writer)); + if (this.signatory_record_hash.length) + writer.writeBytes(2, this.signatory_record_hash); + if (this.fee.length) + writer.writeBytes(3, this.fee); + if (this.confirmation_block_number != 0) + writer.writeUint32(4, this.confirmation_block_number); + if (this.batch_header_hash.length) + writer.writeBytes(5, this.batch_header_hash); + if (!w) + return writer.getResultBuffer(); + } + static deserialize(bytes: Uint8Array | pb_1.BinaryReader): BatchMetadata { + const reader = bytes instanceof pb_1.BinaryReader ? bytes : new pb_1.BinaryReader(bytes), message = new BatchMetadata(); + while (reader.nextField()) { + if (reader.isEndGroup()) + break; + switch (reader.getFieldNumber()) { + case 1: + reader.readMessage(message.batch_header, () => message.batch_header = BatchHeader.deserialize(reader)); + break; + case 2: + message.signatory_record_hash = reader.readBytes(); + break; + case 3: + message.fee = reader.readBytes(); + break; + case 4: + message.confirmation_block_number = reader.readUint32(); + break; + case 5: + message.batch_header_hash = reader.readBytes(); + break; + default: reader.skipField(); + } + } + return message; + } + serializeBinary(): Uint8Array { + return this.serialize(); + } + static deserializeBinary(bytes: Uint8Array): BatchMetadata { + return BatchMetadata.deserialize(bytes); + } + } + export class BatchHeader extends pb_1.Message { + #one_of_decls: number[][] = []; + constructor(data?: any[] | { + batch_root?: Uint8Array; + quorum_numbers?: Uint8Array; + quorum_signed_percentages?: Uint8Array; + reference_block_number?: number; + }) { + super(); + pb_1.Message.initialize(this, Array.isArray(data) ? data : [], 0, -1, [], this.#one_of_decls); + if (!Array.isArray(data) && typeof data == "object") { + if ("batch_root" in data && data.batch_root != undefined) { + this.batch_root = data.batch_root; + } + if ("quorum_numbers" in data && data.quorum_numbers != undefined) { + this.quorum_numbers = data.quorum_numbers; + } + if ("quorum_signed_percentages" in data && data.quorum_signed_percentages != undefined) { + this.quorum_signed_percentages = data.quorum_signed_percentages; + } + if ("reference_block_number" in data && data.reference_block_number != undefined) { + this.reference_block_number = data.reference_block_number; + } + } + } + get batch_root() { + return pb_1.Message.getFieldWithDefault(this, 1, new Uint8Array(0)) as Uint8Array; + } + set batch_root(value: Uint8Array) { + pb_1.Message.setField(this, 1, value); + } + get quorum_numbers() { + return pb_1.Message.getFieldWithDefault(this, 2, new Uint8Array(0)) as Uint8Array; + } + set quorum_numbers(value: Uint8Array) { + pb_1.Message.setField(this, 2, value); + } + get quorum_signed_percentages() { + return pb_1.Message.getFieldWithDefault(this, 3, new Uint8Array(0)) as Uint8Array; + } + set quorum_signed_percentages(value: Uint8Array) { + pb_1.Message.setField(this, 3, value); + } + get reference_block_number() { + return pb_1.Message.getFieldWithDefault(this, 4, 0) as number; + } + set reference_block_number(value: number) { + pb_1.Message.setField(this, 4, value); + } + static fromObject(data: { + batch_root?: Uint8Array; + quorum_numbers?: Uint8Array; + quorum_signed_percentages?: Uint8Array; + reference_block_number?: number; + }): BatchHeader { + const message = new BatchHeader({}); + if (data.batch_root != null) { + message.batch_root = data.batch_root; + } + if (data.quorum_numbers != null) { + message.quorum_numbers = data.quorum_numbers; + } + if (data.quorum_signed_percentages != null) { + message.quorum_signed_percentages = data.quorum_signed_percentages; + } + if (data.reference_block_number != null) { + message.reference_block_number = data.reference_block_number; + } + return message; + } + toObject() { + const data: { + batch_root?: Uint8Array; + quorum_numbers?: Uint8Array; + quorum_signed_percentages?: Uint8Array; + reference_block_number?: number; + } = {}; + if (this.batch_root != null) { + data.batch_root = this.batch_root; + } + if (this.quorum_numbers != null) { + data.quorum_numbers = this.quorum_numbers; + } + if (this.quorum_signed_percentages != null) { + data.quorum_signed_percentages = this.quorum_signed_percentages; + } + if (this.reference_block_number != null) { + data.reference_block_number = this.reference_block_number; + } + return data; + } + serialize(): Uint8Array; + serialize(w: pb_1.BinaryWriter): void; + serialize(w?: pb_1.BinaryWriter): Uint8Array | void { + const writer = w || new pb_1.BinaryWriter(); + if (this.batch_root.length) + writer.writeBytes(1, this.batch_root); + if (this.quorum_numbers.length) + writer.writeBytes(2, this.quorum_numbers); + if (this.quorum_signed_percentages.length) + writer.writeBytes(3, this.quorum_signed_percentages); + if (this.reference_block_number != 0) + writer.writeUint32(4, this.reference_block_number); + if (!w) + return writer.getResultBuffer(); + } + static deserialize(bytes: Uint8Array | pb_1.BinaryReader): BatchHeader { + const reader = bytes instanceof pb_1.BinaryReader ? bytes : new pb_1.BinaryReader(bytes), message = new BatchHeader(); + while (reader.nextField()) { + if (reader.isEndGroup()) + break; + switch (reader.getFieldNumber()) { + case 1: + message.batch_root = reader.readBytes(); + break; + case 2: + message.quorum_numbers = reader.readBytes(); + break; + case 3: + message.quorum_signed_percentages = reader.readBytes(); + break; + case 4: + message.reference_block_number = reader.readUint32(); + break; + default: reader.skipField(); + } + } + return message; + } + serializeBinary(): Uint8Array { + return this.serialize(); + } + static deserializeBinary(bytes: Uint8Array): BatchHeader { + return BatchHeader.deserialize(bytes); + } + } + interface GrpcUnaryServiceInterface { + (message: P, metadata: grpc_1.Metadata, options: grpc_1.CallOptions, callback: grpc_1.requestCallback): grpc_1.ClientUnaryCall; + (message: P, metadata: grpc_1.Metadata, callback: grpc_1.requestCallback): grpc_1.ClientUnaryCall; + (message: P, options: grpc_1.CallOptions, callback: grpc_1.requestCallback): grpc_1.ClientUnaryCall; + (message: P, callback: grpc_1.requestCallback): grpc_1.ClientUnaryCall; + } + interface GrpcStreamServiceInterface { + (message: P, metadata: grpc_1.Metadata, options?: grpc_1.CallOptions): grpc_1.ClientReadableStream; + (message: P, options?: grpc_1.CallOptions): grpc_1.ClientReadableStream; + } + interface GrpWritableServiceInterface { + (metadata: grpc_1.Metadata, options: grpc_1.CallOptions, callback: grpc_1.requestCallback): grpc_1.ClientWritableStream

; + (metadata: grpc_1.Metadata, callback: grpc_1.requestCallback): grpc_1.ClientWritableStream

; + (options: grpc_1.CallOptions, callback: grpc_1.requestCallback): grpc_1.ClientWritableStream

; + (callback: grpc_1.requestCallback): grpc_1.ClientWritableStream

; + } + interface GrpcChunkServiceInterface { + (metadata: grpc_1.Metadata, options?: grpc_1.CallOptions): grpc_1.ClientDuplexStream; + (options?: grpc_1.CallOptions): grpc_1.ClientDuplexStream; + } + interface GrpcPromiseServiceInterface { + (message: P, metadata: grpc_1.Metadata, options?: grpc_1.CallOptions): Promise; + (message: P, options?: grpc_1.CallOptions): Promise; + } + export abstract class UnimplementedDisperserService { + static definition = { + DisperseBlob: { + path: "/disperser.Disperser/DisperseBlob", + requestStream: false, + responseStream: false, + requestSerialize: (message: DisperseBlobRequest) => Buffer.from(message.serialize()), + requestDeserialize: (bytes: Buffer) => DisperseBlobRequest.deserialize(new Uint8Array(bytes)), + responseSerialize: (message: DisperseBlobReply) => Buffer.from(message.serialize()), + responseDeserialize: (bytes: Buffer) => DisperseBlobReply.deserialize(new Uint8Array(bytes)) + }, + DisperseBlobAuthenticated: { + path: "/disperser.Disperser/DisperseBlobAuthenticated", + requestStream: true, + responseStream: true, + requestSerialize: (message: AuthenticatedRequest) => Buffer.from(message.serialize()), + requestDeserialize: (bytes: Buffer) => AuthenticatedRequest.deserialize(new Uint8Array(bytes)), + responseSerialize: (message: AuthenticatedReply) => Buffer.from(message.serialize()), + responseDeserialize: (bytes: Buffer) => AuthenticatedReply.deserialize(new Uint8Array(bytes)) + }, + GetBlobStatus: { + path: "/disperser.Disperser/GetBlobStatus", + requestStream: false, + responseStream: false, + requestSerialize: (message: BlobStatusRequest) => Buffer.from(message.serialize()), + requestDeserialize: (bytes: Buffer) => BlobStatusRequest.deserialize(new Uint8Array(bytes)), + responseSerialize: (message: BlobStatusReply) => Buffer.from(message.serialize()), + responseDeserialize: (bytes: Buffer) => BlobStatusReply.deserialize(new Uint8Array(bytes)) + }, + RetrieveBlob: { + path: "/disperser.Disperser/RetrieveBlob", + requestStream: false, + responseStream: false, + requestSerialize: (message: RetrieveBlobRequest) => Buffer.from(message.serialize()), + requestDeserialize: (bytes: Buffer) => RetrieveBlobRequest.deserialize(new Uint8Array(bytes)), + responseSerialize: (message: RetrieveBlobReply) => Buffer.from(message.serialize()), + responseDeserialize: (bytes: Buffer) => RetrieveBlobReply.deserialize(new Uint8Array(bytes)) + } + }; + [method: string]: grpc_1.UntypedHandleCall; + abstract DisperseBlob(call: grpc_1.ServerUnaryCall, callback: grpc_1.sendUnaryData): void; + abstract DisperseBlobAuthenticated(call: grpc_1.ServerDuplexStream): void; + abstract GetBlobStatus(call: grpc_1.ServerUnaryCall, callback: grpc_1.sendUnaryData): void; + abstract RetrieveBlob(call: grpc_1.ServerUnaryCall, callback: grpc_1.sendUnaryData): void; + } + export class DisperserClient extends grpc_1.makeGenericClientConstructor(UnimplementedDisperserService.definition, "Disperser", {}) { + constructor(address: string, credentials: grpc_1.ChannelCredentials, options?: Partial) { + super(address, credentials, options); + } + DisperseBlob: GrpcUnaryServiceInterface = (message: DisperseBlobRequest, metadata: grpc_1.Metadata | grpc_1.CallOptions | grpc_1.requestCallback, options?: grpc_1.CallOptions | grpc_1.requestCallback, callback?: grpc_1.requestCallback): grpc_1.ClientUnaryCall => { + return super.DisperseBlob(message, metadata, options, callback); + }; + DisperseBlobAuthenticated: GrpcChunkServiceInterface = (metadata?: grpc_1.Metadata | grpc_1.CallOptions, options?: grpc_1.CallOptions): grpc_1.ClientDuplexStream => { + return super.DisperseBlobAuthenticated(metadata, options); + }; + GetBlobStatus: GrpcUnaryServiceInterface = (message: BlobStatusRequest, metadata: grpc_1.Metadata | grpc_1.CallOptions | grpc_1.requestCallback, options?: grpc_1.CallOptions | grpc_1.requestCallback, callback?: grpc_1.requestCallback): grpc_1.ClientUnaryCall => { + return super.GetBlobStatus(message, metadata, options, callback); + }; + RetrieveBlob: GrpcUnaryServiceInterface = (message: RetrieveBlobRequest, metadata: grpc_1.Metadata | grpc_1.CallOptions | grpc_1.requestCallback, options?: grpc_1.CallOptions | grpc_1.requestCallback, callback?: grpc_1.requestCallback): grpc_1.ClientUnaryCall => { + return super.RetrieveBlob(message, metadata, options, callback); + }; + } +} diff --git a/src/bridge/SequencerInbox.sol b/src/bridge/SequencerInbox.sol index 59eefff3..d0683f87 100644 --- a/src/bridge/SequencerInbox.sol +++ b/src/bridge/SequencerInbox.sol @@ -50,6 +50,8 @@ import {IERC20Bridge} from "./IERC20Bridge.sol"; import {IRollupManager} from "./RollupManager.sol"; import {IEigenDAServiceManager} from "@eigenda/eigenda-utils/interfaces/IEigenDAServiceManager.sol"; +import "forge-std/console.sol"; + /** * @title Accepts batches from the sequencer and adds them to the rollup inbox. * @notice Contains the inbox accumulator which is the ordering of all data and transactions to be processed by the rollup. @@ -425,7 +427,9 @@ contract SequencerInbox is DelegateCallAware, GasRefundEnabled, ISequencerInbox if (!isBatchPoster[msg.sender]) revert NotBatchPoster(); // verify that the blob was actually included before continuing + console.log("verifying blob"); eigenDARollupManager.verifyBlob(blobHeader, eigenDAServiceManager, blobVerificationProof); + console.log("blob verified"); // NOTE: to retrieve need the following // see: https://github.com/Layr-Labs/eigenda/blob/master/api/docs/retriever.md#blobrequest diff --git a/test/foundry/SequencerInbox.t.sol b/test/foundry/SequencerInbox.t.sol index c57e686e..d3191420 100644 --- a/test/foundry/SequencerInbox.t.sol +++ b/test/foundry/SequencerInbox.t.sol @@ -590,60 +590,9 @@ contract SequencerInboxTest is Test { ); } - // TODO: put these in jsons later - // grpcurl \ - // -import-path ./api/proto \ - // -proto ./api/proto/disperser/disperser.proto \ - // -d '{"request_id": "NmQ2ODZiOWY4YzcwOGQ0YjhhNDJiN2FiOGRjYmI2MDAzOTk2NDk4NTU5Nzk0OWZkNjQ3ZGE4N2I2NDViZGUxNS0zMTM3MzEzMjM4MzQzNTMyMzgzNjMzMzkzODM5MzYzOTM3MzMzNDJmMzAyZjMzMzMyZjMxMmYzMzMzMmZlM2IwYzQ0Mjk4ZmMxYzE0OWFmYmY0Yzg5OTZmYjkyNDI3YWU0MWU0NjQ5YjkzNGNhNDk1OTkxYjc4NTJiODU1"}' \ - // disperser-holesky.eigenda.xyz:443 disperser.Disperser/GetBlobStatus - BN254.G1Point commitment = BN254.G1Point({ - X: 11973800683352706081745043032492841023821816921595457420358142752350183450007, - Y: 2805225659489681354691976220137232537594717765057043399317547797368322962514 - }); - - IEigenDAServiceManager.BlobHeader blobHeader; - - IEigenDAServiceManager.BatchHeader batchHeader = IEigenDAServiceManager.BatchHeader({ - blobHeadersRoot: 0x2f3d0afe00f1a3eccb2a77a053c9fa850d4809913ece2f6a5dcdc9ecb5347c8b, - quorumNumbers: hex"0001", - signedStakeForQuorums: hex"4d4f", // quorum_signed_percentages - referenceBlockNumber: 1325741 - }); - - IEigenDAServiceManager.BatchMetadata batchMetadata = IEigenDAServiceManager.BatchMetadata({ - batchHeader: batchHeader, - signatoryRecordHash: 0x9c2295a45e69a5369008e65fa2afc40eccb8e8be2f453998207e9b0a8d3bc72b, - confirmationBlockNumber: 1325845 - }); - - EigenDARollupUtils.BlobVerificationProof blobVerificationProof = EigenDARollupUtils - .BlobVerificationProof({ - batchId: 9869, - blobIndex: 570, - batchMetadata: batchMetadata, - inclusionProof: hex"86d042bea74e8fc60ce55410490d2e8bf312ff03aca9d369296d8cb25cd622096d79ebf24023971807ca680bfeac081bca250544e65147ffc0f7fdd3f3f973b885c252331c8385b767138702b5ba6155ae518fd98ebb966c5d2dfc2364ee0d49c203f38ebd01f85755bd59903ad850ea040fb94611fd554deb03c35ce43453f616866b1248350c1f1af7f3ce0f9b1beb712de850ce4e9cdfee6073fd54b8bca69011c9eca7800d59e6831f055972ae7430b8b52423cf455c2e0a3b11343890c713b16d87b5458476d589dd0f2146b14b9380f69aa8b1b546c75de4bfe925167204dd92138a76c02a4854973ed7016c6c110d41563acbc8cafefbe5d2f0ff490a83cd05a84bdfdd1542ebbbf20ca8b8968407a993919ffe5e159faf5941a95ae878a69d797b170a7a375d88b92c000c70871ae9ed5042f481743a27e97cf8665e8ebdea8f3dc226cc4c9a1cf3863ab4e60900a600fbfe5381cc0912f7aab88686", - quorumIndices: hex"0001" - }); function testAddSequencerL2BatchFromEigenDA() public { - blobHeader.commitment = commitment; - blobHeader.dataLength = 1; - blobHeader.quorumBlobParams.push( - IEigenDAServiceManager.QuorumBlobParam({ - quorumNumber: 0, - adversaryThresholdPercentage: 33, - confirmationThresholdPercentage: 55, - chunkLength: 1 - }) - ); - blobHeader.quorumBlobParams.push( - IEigenDAServiceManager.QuorumBlobParam({ - quorumNumber: 1, - adversaryThresholdPercentage: 33, - confirmationThresholdPercentage: 55, - chunkLength: 1 - }) - ); + (SequencerInbox seqInbox, Bridge bridge) = deployRollup(false); // update the dummyEigenDAServiceManager to use the holesky serviceManager contract @@ -656,6 +605,8 @@ contract SequencerInboxTest is Test { vm.prank(dummyInbox); bridge.enqueueDelayedMessage(delayedInboxKind, delayedInboxSender, messageDataHash); + (IEigenDAServiceManager.BlobHeader memory blobHeader, EigenDARollupUtils.BlobVerificationProof memory blobVerificationProof) = readAndParseBlobInfo(); + // ed is EIGEN_DA_MESSAGE_HEADER_FLAG rest is abi.encodePacked(blobHeader.commitment.X, blobHeader.commitment.Y, blobHeader.dataLength) bytes memory data = hex"ed1a78ee576b0026de661b72106bf447f5bb70881f24a3fa8b1f312992c8e165970633b392b3d3f66407d912aafcc2f0231c31918f0485e8476975edc710fcb45200000001"; @@ -710,7 +661,7 @@ contract SequencerInboxTest is Test { quorumIndices: bytes("") }); - function testAddSequencerL2BatchFromEigenDARevert() public { + function testAddSequencerL2BatchFrom() public { // finish filling out the illegalBlobHeader illegalBlobHeader.commitment = illegalCommitment; illegalBlobHeader.dataLength = 20; @@ -872,4 +823,62 @@ contract SequencerInboxTest is Test { }) ); } + + function readAndParseBlobInfo() public returns (IEigenDAServiceManager.BlobHeader memory, EigenDARollupUtils.BlobVerificationProof memory) { + string memory json = vm.readFile("test/foundry/blobInfo/blobInfo.json"); + + + // parse the blob header + + IEigenDAServiceManager.BlobHeader memory blobHeader; + + BN254.G1Point memory commitment = BN254.G1Point({ + X: uint256(vm.parseJsonInt(json, ".blob_info.blob_header.commitment.x")), + Y: uint256(vm.parseJsonInt(json, ".blob_info.blob_header.commitment.y")) + }); + + blobHeader.commitment = commitment; + blobHeader.dataLength = uint32(uint256(vm.parseJsonInt(json, ".blob_info.blob_header.data_length"))); + + bytes memory quorumParams = vm.parseJson(json, ".blob_info.blob_header.quorum_blob_params"); + + for (uint256 i = 0; i < quorumParams.length; i++) { + IEigenDAServiceManager.QuorumBlobParam memory quorumBlobParam = IEigenDAServiceManager.QuorumBlobParam({ + quorumNumber: uint8(uint256(vm.parseJsonInt(json, ".blob_info.blob_header.quorum_blob_params[i].quorum_number"))), + adversaryThresholdPercentage: uint8(uint256(vm.parseJsonInt(json, ".blob_info.blob_header.quorum_blob_params[i].adversary_threshold_percentage"))), + confirmationThresholdPercentage: uint8(uint256(vm.parseJsonInt(json, ".blob_info.blob_header.quorum_blob_params[i].confirmation_threshold_percentage"))), + chunkLength: uint32(uint256(vm.parseJsonInt(json, ".blob_info.blob_header.quorum_blob_params[i].chunk_length"))) + }); + + blobHeader.quorumBlobParams[i] = quorumBlobParam; + } + + // parse the blob verification proof + + IEigenDAServiceManager.BatchHeader memory batchHeader = IEigenDAServiceManager.BatchHeader({ + blobHeadersRoot: vm.parseJsonBytes32(json, ".blob_info.blob_verification_proof.batch_metadata.batch_header.batch_root"), + quorumNumbers: vm.parseJsonBytes(json, ".blob_info.blob_verification_proof.batch_metadata.batch_header.quorum_numbers"), + signedStakeForQuorums: vm.parseJsonBytes(json, ".blob_info.blob_verification_proof.batch_metadata.batch_header.quorum_signed_percentages"), + referenceBlockNumber: uint32(uint256(vm.parseJsonUint(json, ".blob_info.blob_verification_proof.batch_metadata.batch_header.reference_block_number"))) + }); + + IEigenDAServiceManager.BatchMetadata memory batchMetadata = IEigenDAServiceManager.BatchMetadata({ + batchHeader: batchHeader, + signatoryRecordHash: vm.parseJsonBytes32(json, ".blob_info.blob_verification_proof.batch_metadata.signatory_record_hash"), + confirmationBlockNumber: uint32(uint256(vm.parseJsonUint(json, ".blob_info.blob_verification_proof.batch_metadata.confirmation_block_number"))) + }); + + EigenDARollupUtils.BlobVerificationProof memory blobVerificationProof = EigenDARollupUtils + .BlobVerificationProof({ + batchId: uint32(uint256(vm.parseJsonUint(json, ".blob_info.blob_verification_proof.batch_id"))), + blobIndex: uint32(uint256(vm.parseJsonUint(json, ".blob_info.blob_verification_proof.blob_index"))), + batchMetadata: batchMetadata, + inclusionProof: vm.parseJsonBytes(json, ".blob_info.blob_verification_proof.inclusion_proof"), + quorumIndices: vm.parseJsonBytes(json, ".blob_info.blob_verification_proof.quorum_indexes") + }); + + return (blobHeader, blobVerificationProof); + } + + } diff --git a/test/foundry/blobInfo/blobInfo.json b/test/foundry/blobInfo/blobInfo.json new file mode 100644 index 00000000..e62d52cd --- /dev/null +++ b/test/foundry/blobInfo/blobInfo.json @@ -0,0 +1,44 @@ +{ + "request_id": "303534656465633164303231316636323466656430636263613964346639343030623065343931633433373432616632633562306162656266306339393064382d33313337333133383331333333303339333533313336333733313333333933303330333333373266333032663333333332663331326633333333326665336230633434323938666331633134396166626634633839393666623932343237616534316534363439623933346361343935393931623738353262383535", + "blob_info": { + "blob_header": { + "commitment": { + "x": "0x278a3fd705f7af609df05a835e19dbaf4ffb739ab046b9ed5611318fac7e36bd", + "y": "0x1807884a3d61612f244b436cf5d038a83b5a465562aa155ee291302968de104f" + }, + "data_length": 1, + "blob_quorum_params": [ + { + "quorum_number": 0, + "adversary_threshold_percentage": 33, + "confirmation_threshold_percentage": 55, + "chunk_length": 1 + }, + { + "quorum_number": 1, + "adversary_threshold_percentage": 33, + "confirmation_threshold_percentage": 55, + "chunk_length": 1 + } + ] + }, + "blob_verification_proof": { + "batch_id": 18782, + "blob_index": 1078, + "batch_metadata": { + "batch_header": { + "batch_root": "0x6c97bb63dcab3ce68ed6bcf43aaa9526d77f4c16a132f754909d291ec7ecc5fa", + "quorum_numbers": "0x0001", + "quorum_signed_percentages": "0x5d5f", + "reference_block_number": 1716391 + }, + "signatory_record_hash": "0x27675411031ec867b25300f5c97a99c462b9c7780bdde40d9d2623b5c5264b7e", + "fee": "0x00", + "confirmation_block_number": 1716521, + "batch_header_hash": "0x41032605efd3fd1da443b4478a8067d41d1647ac32f26b5a0450a96282ed85b6" + }, + "inclusion_proof": "0x67d74b70e5ea162cac407eae686ab953c940e6f8d38ea3fc82fde2a3ac1c53c7248c3426c33bdc43a937028ffc079eca518569ee0276ee71f2240b5d98750c51dd38e3dc827a1ebda70b6b66d380bf6bb4572e1499ad38086d959f78b718dc85c9c70d54e7607836d37d6382d57020ba14d44ef4d6f3720622a03bb6f2635b02902939347e0eba188d807a9fe59592c54c8cb04779c5cec82eb04588172522675dd1fe5acb38390e427a0255225682039720e541956f973ec85d73b51793750246fe6a8527f7d0f1025b4b46df7c907832f33c5e2613fac20cc96e622979aa263fd2fafd915ad0b0816a388c8ca19af24a2f859dafab26251e42f4a924709e459867cc5f7f196b93bae1e27e6320742445d290f2263827498b54fec539f756afcefad4e508c098b9a7e1d8feb19955fb02ba9675585078710969d3440f5054e0e6d22dd06c098efed540bb36a5325893265de57eff4797b545dfd69c1e858731", + "quorum_indexes": "0x0001" + } + } +} \ No newline at end of file diff --git a/yarn.lock b/yarn.lock index 8cd61d15..50c6fa22 100644 --- a/yarn.lock +++ b/yarn.lock @@ -855,6 +855,24 @@ optionalDependencies: "@trufflesuite/bigint-buffer" "1.1.9" +"@grpc/grpc-js@^1.8.22": + version "1.8.22" + resolved "https://registry.yarnpkg.com/@grpc/grpc-js/-/grpc-js-1.8.22.tgz#847930c9af46e14df05b57fc12325db140ceff1d" + integrity sha512-oAjDdN7fzbUi+4hZjKG96MR6KTEubAeMpQEb+77qy+3r0Ua5xTFuie6JOLr4ZZgl5g+W5/uRTS2M1V8mVAFPuA== + dependencies: + "@grpc/proto-loader" "^0.7.0" + "@types/node" ">=12.12.47" + +"@grpc/proto-loader@^0.7.0", "@grpc/proto-loader@^0.7.13": + version "0.7.13" + resolved "https://registry.yarnpkg.com/@grpc/proto-loader/-/proto-loader-0.7.13.tgz#f6a44b2b7c9f7b609f5748c6eac2d420e37670cf" + integrity sha512-AiXO/bfe9bmxBjxxtYxFAXGZvMaN5s8kO+jBHAJCON8rJoB5YS/D6X7ZNc6XQkuHNmyl4CYaMI1fJ/Gn27RGGw== + dependencies: + lodash.camelcase "^4.3.0" + long "^5.0.0" + protobufjs "^7.2.5" + yargs "^17.7.2" + "@humanwhocodes/config-array@^0.10.4": version "0.10.4" resolved "https://registry.yarnpkg.com/@humanwhocodes/config-array/-/config-array-0.10.4.tgz#01e7366e57d2ad104feea63e72248f22015c520c" @@ -1204,6 +1222,59 @@ resolved "https://registry.yarnpkg.com/@openzeppelin/contracts/-/contracts-4.7.3.tgz#939534757a81f8d69cc854c7692805684ff3111e" integrity sha512-dGRS0agJzu8ybo44pCIf3xBaPQN/65AIXNgK8+4gzKd5kbvlqyxryUYVLJv7fK98Seyd2hDZzVEHSWAh0Bt1Yw== +"@protobufjs/aspromise@^1.1.1", "@protobufjs/aspromise@^1.1.2": + version "1.1.2" + resolved "https://registry.yarnpkg.com/@protobufjs/aspromise/-/aspromise-1.1.2.tgz#9b8b0cc663d669a7d8f6f5d0893a14d348f30fbf" + integrity sha512-j+gKExEuLmKwvz3OgROXtrJ2UG2x8Ch2YZUxahh+s1F2HZ+wAceUNLkvy6zKCPVRkU++ZWQrdxsUeQXmcg4uoQ== + +"@protobufjs/base64@^1.1.2": + version "1.1.2" + resolved "https://registry.yarnpkg.com/@protobufjs/base64/-/base64-1.1.2.tgz#4c85730e59b9a1f1f349047dbf24296034bb2735" + integrity sha512-AZkcAA5vnN/v4PDqKyMR5lx7hZttPDgClv83E//FMNhR2TMcLUhfRUBHCmSl0oi9zMgDDqRUJkSxO3wm85+XLg== + +"@protobufjs/codegen@^2.0.4": + version "2.0.4" + resolved "https://registry.yarnpkg.com/@protobufjs/codegen/-/codegen-2.0.4.tgz#7ef37f0d010fb028ad1ad59722e506d9262815cb" + integrity sha512-YyFaikqM5sH0ziFZCN3xDC7zeGaB/d0IUb9CATugHWbd1FRFwWwt4ld4OYMPWu5a3Xe01mGAULCdqhMlPl29Jg== + +"@protobufjs/eventemitter@^1.1.0": + version "1.1.0" + resolved "https://registry.yarnpkg.com/@protobufjs/eventemitter/-/eventemitter-1.1.0.tgz#355cbc98bafad5978f9ed095f397621f1d066b70" + integrity sha512-j9ednRT81vYJ9OfVuXG6ERSTdEL1xVsNgqpkxMsbIabzSo3goCjDIveeGv5d03om39ML71RdmrGNjG5SReBP/Q== + +"@protobufjs/fetch@^1.1.0": + version "1.1.0" + resolved "https://registry.yarnpkg.com/@protobufjs/fetch/-/fetch-1.1.0.tgz#ba99fb598614af65700c1619ff06d454b0d84c45" + integrity sha512-lljVXpqXebpsijW71PZaCYeIcE5on1w5DlQy5WH6GLbFryLUrBD4932W/E2BSpfRJWseIL4v/KPgBFxDOIdKpQ== + dependencies: + "@protobufjs/aspromise" "^1.1.1" + "@protobufjs/inquire" "^1.1.0" + +"@protobufjs/float@^1.0.2": + version "1.0.2" + resolved "https://registry.yarnpkg.com/@protobufjs/float/-/float-1.0.2.tgz#5e9e1abdcb73fc0a7cb8b291df78c8cbd97b87d1" + integrity sha512-Ddb+kVXlXst9d+R9PfTIxh1EdNkgoRe5tOX6t01f1lYWOvJnSPDBlG241QLzcyPdoNTsblLUdujGSE4RzrTZGQ== + +"@protobufjs/inquire@^1.1.0": + version "1.1.0" + resolved "https://registry.yarnpkg.com/@protobufjs/inquire/-/inquire-1.1.0.tgz#ff200e3e7cf2429e2dcafc1140828e8cc638f089" + integrity sha512-kdSefcPdruJiFMVSbn801t4vFK7KB/5gd2fYvrxhuJYg8ILrmn9SKSX2tZdV6V+ksulWqS7aXjBcRXl3wHoD9Q== + +"@protobufjs/path@^1.1.2": + version "1.1.2" + resolved "https://registry.yarnpkg.com/@protobufjs/path/-/path-1.1.2.tgz#6cc2b20c5c9ad6ad0dccfd21ca7673d8d7fbf68d" + integrity sha512-6JOcJ5Tm08dOHAbdR3GrvP+yUUfkjG5ePsHYczMFLq3ZmMkAD98cDgcT2iA1lJ9NVwFd4tH/iSSoe44YWkltEA== + +"@protobufjs/pool@^1.1.0": + version "1.1.0" + resolved "https://registry.yarnpkg.com/@protobufjs/pool/-/pool-1.1.0.tgz#09fd15f2d6d3abfa9b65bc366506d6ad7846ff54" + integrity sha512-0kELaGSIDBKvcgS4zkjz1PeddatrjYcmMWOlAuAPwAeccUrPHdUqo/J6LiymHHEiJT5NrF1UVwxY14f+fy4WQw== + +"@protobufjs/utf8@^1.1.0": + version "1.1.0" + resolved "https://registry.yarnpkg.com/@protobufjs/utf8/-/utf8-1.1.0.tgz#a777360b5b39a1a2e5106f8e858f2fd2d060c570" + integrity sha512-Vvn3zZrhQZkkBE8LSuW3em98c0FwgO4nxzv6OdSxPKJIEKY2bGbHn+mhGIPerzI4twdxaP8/0+06HBpwf345Lw== + "@resolver-engine/core@^0.3.3": version "0.3.3" resolved "https://registry.yarnpkg.com/@resolver-engine/core/-/core-0.3.3.tgz#590f77d85d45bc7ecc4e06c654f41345db6ca967" @@ -1488,6 +1559,11 @@ "@types/minimatch" "*" "@types/node" "*" +"@types/google-protobuf@^3.15.12": + version "3.15.12" + resolved "https://registry.yarnpkg.com/@types/google-protobuf/-/google-protobuf-3.15.12.tgz#eb2ba0eddd65712211a2b455dc6071d665ccf49b" + integrity sha512-40um9QqwHjRS92qnOaDpL7RmDK15NuZYo9HihiJRbYkMQZlWnuH8AdvbMy8/o6lgLmKbDUKa+OALCltHdbOTpQ== + "@types/json-schema@^7.0.9": version "7.0.11" resolved "https://registry.yarnpkg.com/@types/json-schema/-/json-schema-7.0.11.tgz#d421b6c527a3037f7c84433fd2c4229e016863d3" @@ -1566,6 +1642,13 @@ resolved "https://registry.yarnpkg.com/@types/node/-/node-11.11.6.tgz#df929d1bb2eee5afdda598a41930fe50b43eaa6a" integrity sha512-Exw4yUWMBXM3X+8oqzJNRqZSwUAaS4+7NdvHqQuFi/d+synz++xmX3QIf+BFqneW8N31R8Ky+sikfZUXq07ggQ== +"@types/node@>=12.12.47", "@types/node@>=13.7.0": + version "20.14.2" + resolved "https://registry.yarnpkg.com/@types/node/-/node-20.14.2.tgz#a5f4d2bcb4b6a87bffcaa717718c5a0f208f4a18" + integrity sha512-xyu6WAMVwv6AKFLB+e/7ySZVr/0zLCzOa7rSpq6jNwpqOrUbcACDWC+53d4n2QHOnDou0fbIsg8wZu/sxrnI4Q== + dependencies: + undici-types "~5.26.4" + "@types/node@^10.0.3": version "10.17.60" resolved "https://registry.yarnpkg.com/@types/node/-/node-10.17.60.tgz#35f3d6213daed95da7f0f73e75bcc6980e90597b" @@ -4333,6 +4416,11 @@ globby@^11.1.0: merge2 "^1.4.1" slash "^3.0.0" +google-protobuf@^3.21.2: + version "3.21.2" + resolved "https://registry.yarnpkg.com/google-protobuf/-/google-protobuf-3.21.2.tgz#4580a2bea8bbb291ee579d1fefb14d6fa3070ea4" + integrity sha512-3MSOYFO5U9mPGikIYCzK0SaThypfGgS6bHqrUGXG3DPHCrb+txNqeEcns1W0lkGfk0rCyNXm7xB9rMxnCiZOoA== + graceful-fs@^4.1.11, graceful-fs@^4.1.2, graceful-fs@^4.1.6, graceful-fs@^4.1.9, graceful-fs@^4.2.0: version "4.2.10" resolved "https://registry.yarnpkg.com/graceful-fs/-/graceful-fs-4.2.10.tgz#147d3a006da4ca3ce14728c7aefc287c367d7a6c" @@ -5367,6 +5455,11 @@ log-symbols@4.1.0: chalk "^4.1.0" is-unicode-supported "^0.1.0" +long@^5.0.0: + version "5.2.3" + resolved "https://registry.yarnpkg.com/long/-/long-5.2.3.tgz#a3ba97f3877cf1d778eccbcb048525ebb77499e1" + integrity sha512-lcHwpNoggQTObv5apGNCTdJrO69eHOZMi4BNC+rTLER8iHAqGrUVeLh/irVIM7zTw2bOXA8T6uNPeujwOLg/2Q== + loupe@^2.3.1: version "2.3.4" resolved "https://registry.yarnpkg.com/loupe/-/loupe-2.3.4.tgz#7e0b9bffc76f148f9be769cb1321d3dcf3cb25f3" @@ -6280,6 +6373,24 @@ promise@^8.0.0: dependencies: asap "~2.0.6" +protobufjs@^7.2.5: + version "7.3.0" + resolved "https://registry.yarnpkg.com/protobufjs/-/protobufjs-7.3.0.tgz#a32ec0422c039798c41a0700306a6e305b9cb32c" + integrity sha512-YWD03n3shzV9ImZRX3ccbjqLxj7NokGN0V/ESiBV5xWqrommYHYiihuIyavq03pWSGqlyvYUFmfoMKd+1rPA/g== + dependencies: + "@protobufjs/aspromise" "^1.1.2" + "@protobufjs/base64" "^1.1.2" + "@protobufjs/codegen" "^2.0.4" + "@protobufjs/eventemitter" "^1.1.0" + "@protobufjs/fetch" "^1.1.0" + "@protobufjs/float" "^1.0.2" + "@protobufjs/inquire" "^1.1.0" + "@protobufjs/path" "^1.1.2" + "@protobufjs/pool" "^1.1.0" + "@protobufjs/utf8" "^1.1.0" + "@types/node" ">=13.7.0" + long "^5.0.0" + prr@~1.0.1: version "1.0.1" resolved "https://registry.yarnpkg.com/prr/-/prr-1.0.1.tgz#d3fc114ba06995a45ec6893f484ceb1d78f5f476" @@ -7738,6 +7849,11 @@ unbox-primitive@^1.0.1: has-symbols "^1.0.2" which-boxed-primitive "^1.0.2" +undici-types@~5.26.4: + version "5.26.5" + resolved "https://registry.yarnpkg.com/undici-types/-/undici-types-5.26.5.tgz#bcd539893d00b56e964fd2657a4866b221a65617" + integrity sha512-JlCMO+ehdEIKqlFxk6IfVoAUVmgz7cU7zD/h9XZ0qzeosSHmUJVOzSQvvYSYWXkFXC+IfLKSIffhv0sVZup6pA== + undici@^5.14.0: version "5.23.0" resolved "https://registry.yarnpkg.com/undici/-/undici-5.23.0.tgz#e7bdb0ed42cebe7b7aca87ced53e6eaafb8f8ca0" @@ -8102,7 +8218,7 @@ yargs@^11.0.0: y18n "^3.2.1" yargs-parser "^9.0.2" -yargs@^17.0.0: +yargs@^17.0.0, yargs@^17.7.2: version "17.7.2" resolved "https://registry.yarnpkg.com/yargs/-/yargs-17.7.2.tgz#991df39aca675a192b816e1e0363f9d75d2aa269" integrity sha512-7dSzzRQ++CKnNI/krKnYRV7JKKPUXMEh61soaHKg9mrWEhzFWhFnxPxGl+69cD1Ou63C13NUPCnmIcrvqCuM6w== From fa30403a7e9c61d24f73dce27e2576741b524f93 Mon Sep 17 00:00:00 2001 From: QUAQ Date: Tue, 18 Jun 2024 18:02:03 -0500 Subject: [PATCH 2/7] Update ERC20Outbox.t.sol --- test/foundry/ERC20Outbox.t.sol | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/test/foundry/ERC20Outbox.t.sol b/test/foundry/ERC20Outbox.t.sol index f97e96be..1c6176f5 100644 --- a/test/foundry/ERC20Outbox.t.sol +++ b/test/foundry/ERC20Outbox.t.sol @@ -14,7 +14,10 @@ contract ERC20OutboxTest is AbsOutboxTest { function setUp() public { // deploy token, bridge and outbox - nativeToken = new ERC20PresetFixedSupply("Appchain Token", "App", 1_000_000, address(this)); + IERC20 nativeTokenCode = new ERC20PresetFixedSupply("Appchain Token", "App", 1_000_000, address(this)); + nativeToken = IERC20(0xFEfC6BAF87cF3684058D62Da40Ff3A795946Ab06); + vm.etch(address(nativeToken), address(nativeTokenCode).code); + bridge = IBridge(TestUtil.deployProxy(address(new ERC20Bridge()))); erc20Bridge = ERC20Bridge(address(bridge)); outbox = IOutbox(TestUtil.deployProxy(address(new ERC20Outbox()))); @@ -51,7 +54,9 @@ contract ERC20OutboxTest is AbsOutboxTest { ); // create msg receiver on L1 - ERC20L2ToL1Target target = new ERC20L2ToL1Target(); + ERC20L2ToL1Target targetCode = new ERC20L2ToL1Target(); + ERC20L2ToL1Target target = ERC20L2ToL1Target(0x87B2d08110B7D50861141D7bBDd49326af3Ecb31); + vm.etch(address(target), address(targetCode).code); target.setOutbox(address(outbox)); //// execute transaction From c81054f5acb11b6fb7b1f0cca4e035953cde727f Mon Sep 17 00:00:00 2001 From: QUAQ Date: Tue, 18 Jun 2024 18:19:22 -0500 Subject: [PATCH 3/7] Update ERC20Outbox.t.sol --- test/foundry/ERC20Outbox.t.sol | 1 + 1 file changed, 1 insertion(+) diff --git a/test/foundry/ERC20Outbox.t.sol b/test/foundry/ERC20Outbox.t.sol index 1c6176f5..16ccf35e 100644 --- a/test/foundry/ERC20Outbox.t.sol +++ b/test/foundry/ERC20Outbox.t.sol @@ -17,6 +17,7 @@ contract ERC20OutboxTest is AbsOutboxTest { IERC20 nativeTokenCode = new ERC20PresetFixedSupply("Appchain Token", "App", 1_000_000, address(this)); nativeToken = IERC20(0xFEfC6BAF87cF3684058D62Da40Ff3A795946Ab06); vm.etch(address(nativeToken), address(nativeTokenCode).code); + deal(address(nativeToken), address(this), 1_000_000); bridge = IBridge(TestUtil.deployProxy(address(new ERC20Bridge()))); erc20Bridge = ERC20Bridge(address(bridge)); From fa9a0b36bc123cba887fb6ba3a49a3a1047ec806 Mon Sep 17 00:00:00 2001 From: afkbyte Date: Wed, 19 Jun 2024 11:55:53 -0400 Subject: [PATCH 4/7] update storage layout --- test/foundry/SequencerInbox.t.sol | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/test/foundry/SequencerInbox.t.sol b/test/foundry/SequencerInbox.t.sol index d3191420..491b998c 100644 --- a/test/foundry/SequencerInbox.t.sol +++ b/test/foundry/SequencerInbox.t.sol @@ -732,10 +732,10 @@ contract SequencerInboxTest is Test { ); // IMPORTANT: slots have moved down by one because we have added additional variables for eigenDA - vm.store(address(seqInbox), bytes32(uint256(5)), bytes32(uint256(delayBlocks))); // slot 5: delayBlocks - vm.store(address(seqInbox), bytes32(uint256(6)), bytes32(uint256(futureBlocks))); // slot 6: futureBlocks - vm.store(address(seqInbox), bytes32(uint256(7)), bytes32(uint256(delaySeconds))); // slot 7: delaySeconds - vm.store(address(seqInbox), bytes32(uint256(8)), bytes32(uint256(futureSeconds))); // slot 8: futureSeconds + vm.store(address(seqInbox), bytes32(uint256(6)), bytes32(uint256(delayBlocks))); // slot 6: delayBlocks + vm.store(address(seqInbox), bytes32(uint256(7)), bytes32(uint256(futureBlocks))); // slot 7: futureBlocks + vm.store(address(seqInbox), bytes32(uint256(8)), bytes32(uint256(delaySeconds))); // slot 8: delaySeconds + vm.store(address(seqInbox), bytes32(uint256(9)), bytes32(uint256(futureSeconds))); // slot 9: futureSeconds vm.prank(proxyAdmin); TransparentUpgradeableProxy(payable(address(seqInbox))).upgradeToAndCall( address(seqInboxImpl), abi.encodeWithSelector(SequencerInbox.postUpgradeInit.selector) From 6e5074ec14b2639a7189f2a45e4731de83d55419 Mon Sep 17 00:00:00 2001 From: QUAQ Date: Thu, 20 Jun 2024 13:52:11 -0500 Subject: [PATCH 5/7] nit: etching comment --- test/foundry/ERC20Outbox.t.sol | 3 +++ 1 file changed, 3 insertions(+) diff --git a/test/foundry/ERC20Outbox.t.sol b/test/foundry/ERC20Outbox.t.sol index 16ccf35e..165d1657 100644 --- a/test/foundry/ERC20Outbox.t.sol +++ b/test/foundry/ERC20Outbox.t.sol @@ -14,6 +14,8 @@ contract ERC20OutboxTest is AbsOutboxTest { function setUp() public { // deploy token, bridge and outbox + + // hardcoded proof in tests assume that this contract is deployed at the repsective address IERC20 nativeTokenCode = new ERC20PresetFixedSupply("Appchain Token", "App", 1_000_000, address(this)); nativeToken = IERC20(0xFEfC6BAF87cF3684058D62Da40Ff3A795946Ab06); vm.etch(address(nativeToken), address(nativeTokenCode).code); @@ -55,6 +57,7 @@ contract ERC20OutboxTest is AbsOutboxTest { ); // create msg receiver on L1 + // hardcoded proof in tests assume that this contract is deployed at the repsective address ERC20L2ToL1Target targetCode = new ERC20L2ToL1Target(); ERC20L2ToL1Target target = ERC20L2ToL1Target(0x87B2d08110B7D50861141D7bBDd49326af3Ecb31); vm.etch(address(target), address(targetCode).code); From 2d525bdec83f7818fbee62c8bbf6ec83bff86ca2 Mon Sep 17 00:00:00 2001 From: afkbyte Date: Thu, 27 Jun 2024 16:54:50 -0400 Subject: [PATCH 6/7] dispersed new blob and deployed rollup manager --- .github/workflows/contract-tests.yml | 2 +- scripts/disperseBlob.ts | 16 +++++++-------- src/bridge/ISequencerInbox.sol | 3 +++ src/bridge/SequencerInbox.sol | 6 ++++++ test/foundry/SequencerInbox.t.sol | 10 ++++++++-- test/foundry/blobInfo/blobInfo.json | 30 ++++++++++++++-------------- 6 files changed, 41 insertions(+), 26 deletions(-) diff --git a/.github/workflows/contract-tests.yml b/.github/workflows/contract-tests.yml index 48bd3470..afd31ba1 100644 --- a/.github/workflows/contract-tests.yml +++ b/.github/workflows/contract-tests.yml @@ -21,7 +21,7 @@ jobs: - name: Install Foundry uses: foundry-rs/foundry-toolchain@v1 with: - version: nightly + version: nightly-5b7e4cb3c882b28f3c32ba580de27ce7381f415a - name: Setup node/yarn uses: actions/setup-node@v3 diff --git a/scripts/disperseBlob.ts b/scripts/disperseBlob.ts index f97a405c..fc729284 100644 --- a/scripts/disperseBlob.ts +++ b/scripts/disperseBlob.ts @@ -116,18 +116,18 @@ function parseBlobInfo(disperseBlobReply: disperser.DisperseBlobReply, blobStatu blob_index: blobStatusReply.info.blob_verification_proof.blob_index, batch_metadata: { batch_header: { - batch_root: Buffer.from(blobStatusReply.info.blob_verification_proof.batch_metadata.batch_header.batch_root).toString("hex"), - quorum_numbers: Buffer.from(blobStatusReply.info.blob_verification_proof.batch_metadata.batch_header.quorum_numbers).toString("hex"), - quorum_signed_percentages: Buffer.from(blobStatusReply.info.blob_verification_proof.batch_metadata.batch_header.quorum_signed_percentages).toString("hex"), + batch_root: '0x' + Buffer.from(blobStatusReply.info.blob_verification_proof.batch_metadata.batch_header.batch_root).toString("hex"), + quorum_numbers: '0x' + Buffer.from(blobStatusReply.info.blob_verification_proof.batch_metadata.batch_header.quorum_numbers).toString("hex"), + quorum_signed_percentages: '0x' + Buffer.from(blobStatusReply.info.blob_verification_proof.batch_metadata.batch_header.quorum_signed_percentages).toString("hex"), reference_block_number: blobStatusReply.info.blob_verification_proof.batch_metadata.batch_header.reference_block_number }, - signatory_record_hash: Buffer.from(blobStatusReply.info.blob_verification_proof.batch_metadata.signatory_record_hash).toString("hex"), - fee: Buffer.from(blobStatusReply.info.blob_verification_proof.batch_metadata.fee).toString("hex"), + signatory_record_hash: '0x' + Buffer.from(blobStatusReply.info.blob_verification_proof.batch_metadata.signatory_record_hash).toString("hex"), + fee: '0x' + Buffer.from(blobStatusReply.info.blob_verification_proof.batch_metadata.fee).toString("hex"), confirmation_block_number: blobStatusReply.info.blob_verification_proof.batch_metadata.confirmation_block_number, - batch_header_hash: Buffer.from(blobStatusReply.info.blob_verification_proof.batch_metadata.batch_header_hash).toString("hex") + batch_header_hash: '0x' + Buffer.from(blobStatusReply.info.blob_verification_proof.batch_metadata.batch_header_hash).toString("hex") }, - inclusion_proof: Buffer.from(blobStatusReply.info.blob_verification_proof.inclusion_proof).toString("hex"), - quorum_indexes: Buffer.from(blobStatusReply.info.blob_verification_proof.quorum_indexes).toString("hex") + inclusion_proof: '0x' + Buffer.from(blobStatusReply.info.blob_verification_proof.inclusion_proof).toString("hex"), + quorum_indexes: '0x' + Buffer.from(blobStatusReply.info.blob_verification_proof.quorum_indexes).toString("hex") } } }; diff --git a/src/bridge/ISequencerInbox.sol b/src/bridge/ISequencerInbox.sol index e5e01a4f..adc2ceba 100644 --- a/src/bridge/ISequencerInbox.sol +++ b/src/bridge/ISequencerInbox.sol @@ -244,6 +244,9 @@ interface ISequencerInbox is IDelayedMessageProvider { /// @notice Allows the rollup owner to update the eigenDAServiceManager address function updateEigenDAServiceManager(address newEigenDAServiceManager) external; + + /// @notice Allows the rollup owner to update the eigenDARollupManager address + function updateEigenDARollupManager(address newEigenDARollupManager) external; // ---------- initializer ---------- diff --git a/src/bridge/SequencerInbox.sol b/src/bridge/SequencerInbox.sol index d0683f87..6b8e9c92 100644 --- a/src/bridge/SequencerInbox.sol +++ b/src/bridge/SequencerInbox.sol @@ -802,6 +802,12 @@ contract SequencerInbox is DelegateCallAware, GasRefundEnabled, ISequencerInbox emit OwnerFunctionCalled(31); } + /// @inheritdoc ISequencerInbox + function updateEigenDARollupManager(address newEigenDARollupManager) external onlyRollupOwner { + eigenDARollupManager = IRollupManager(newEigenDARollupManager); + emit OwnerFunctionCalled(32); + } + function isValidKeysetHash(bytes32 ksHash) external view returns (bool) { return dasKeySetInfo[ksHash].isValidKeyset; } diff --git a/test/foundry/SequencerInbox.t.sol b/test/foundry/SequencerInbox.t.sol index 491b998c..2fa04c06 100644 --- a/test/foundry/SequencerInbox.t.sol +++ b/test/foundry/SequencerInbox.t.sol @@ -10,6 +10,7 @@ import "@openzeppelin/contracts/token/ERC20/presets/ERC20PresetMinterPauser.sol" import {EigenDARollupUtils} from "@eigenda/eigenda-utils/libraries/EigenDARollupUtils.sol"; import {IEigenDAServiceManager} from "@eigenda/eigenda-utils/interfaces/IEigenDAServiceManager.sol"; +import {EigenDARollupManager} from "../../src/bridge/RollupManager.sol"; import {BN254} from "@eigenda/eigenda-utils/libraries/BN254.sol"; contract RollupMock { @@ -593,11 +594,16 @@ contract SequencerInboxTest is Test { function testAddSequencerL2BatchFromEigenDA() public { - + EigenDARollupManager rollupManagerImpl = new EigenDARollupManager(); (SequencerInbox seqInbox, Bridge bridge) = deployRollup(false); // update the dummyEigenDAServiceManager to use the holesky serviceManager contract - vm.prank(rollupOwner); + + vm.startPrank(rollupOwner); + // deploy rollup + seqInbox.updateEigenDARollupManager(address(rollupManagerImpl)); seqInbox.updateEigenDAServiceManager(0xD4A7E1Bd8015057293f0D0A557088c286942e84b); + vm.stopPrank(); + address delayedInboxSender = address(140); uint8 delayedInboxKind = 3; bytes32 messageDataHash = RAND.Bytes32(); diff --git a/test/foundry/blobInfo/blobInfo.json b/test/foundry/blobInfo/blobInfo.json index e62d52cd..f246c564 100644 --- a/test/foundry/blobInfo/blobInfo.json +++ b/test/foundry/blobInfo/blobInfo.json @@ -1,10 +1,10 @@ { - "request_id": "303534656465633164303231316636323466656430636263613964346639343030623065343931633433373432616632633562306162656266306339393064382d33313337333133383331333333303339333533313336333733313333333933303330333333373266333032663333333332663331326633333333326665336230633434323938666331633134396166626634633839393666623932343237616534316534363439623933346361343935393931623738353262383535", + "request_id": "303534656465633164303231316636323466656430636263613964346639343030623065343931633433373432616632633562306162656266306339393064382d33313337333133393335333233303330333333373330333633353336333833393332333533393266333032663333333332663331326633333333326665336230633434323938666331633134396166626634633839393666623932343237616534316534363439623933346361343935393931623738353262383535", "blob_info": { "blob_header": { "commitment": { - "x": "0x278a3fd705f7af609df05a835e19dbaf4ffb739ab046b9ed5611318fac7e36bd", - "y": "0x1807884a3d61612f244b436cf5d038a83b5a465562aa155ee291302968de104f" + "x": 17884466596723640612337833969319382563829916848310977140316164241640721888957, + "y": 10868816934455168343290327410860226464964837648654804015599259489599053762639 }, "data_length": 1, "blob_quorum_params": [ @@ -23,22 +23,22 @@ ] }, "blob_verification_proof": { - "batch_id": 18782, - "blob_index": 1078, + "batch_id": 21090, + "blob_index": 3418, "batch_metadata": { "batch_header": { - "batch_root": "0x6c97bb63dcab3ce68ed6bcf43aaa9526d77f4c16a132f754909d291ec7ecc5fa", - "quorum_numbers": "0x0001", - "quorum_signed_percentages": "0x5d5f", - "reference_block_number": 1716391 + "batch_root": "80484028685a85c629eb25fda1409cb21f8181f8105d1ca9b100da71f59acc74", + "quorum_numbers": "0001", + "quorum_signed_percentages": "6362", + "reference_block_number": 1820211 }, - "signatory_record_hash": "0x27675411031ec867b25300f5c97a99c462b9c7780bdde40d9d2623b5c5264b7e", - "fee": "0x00", - "confirmation_block_number": 1716521, - "batch_header_hash": "0x41032605efd3fd1da443b4478a8067d41d1647ac32f26b5a0450a96282ed85b6" + "signatory_record_hash": "c5ac31e8de27b9eade6718e806a7df00d9c3557d37b287746e96ec2cacc3224e", + "fee": "00", + "confirmation_block_number": 1820343, + "batch_header_hash": "eb2c9d6ab0dcd46244d35a0b51131f69f0ddd1cd7635d8a73dc9f62a1866cd2c" }, - "inclusion_proof": "0x67d74b70e5ea162cac407eae686ab953c940e6f8d38ea3fc82fde2a3ac1c53c7248c3426c33bdc43a937028ffc079eca518569ee0276ee71f2240b5d98750c51dd38e3dc827a1ebda70b6b66d380bf6bb4572e1499ad38086d959f78b718dc85c9c70d54e7607836d37d6382d57020ba14d44ef4d6f3720622a03bb6f2635b02902939347e0eba188d807a9fe59592c54c8cb04779c5cec82eb04588172522675dd1fe5acb38390e427a0255225682039720e541956f973ec85d73b51793750246fe6a8527f7d0f1025b4b46df7c907832f33c5e2613fac20cc96e622979aa263fd2fafd915ad0b0816a388c8ca19af24a2f859dafab26251e42f4a924709e459867cc5f7f196b93bae1e27e6320742445d290f2263827498b54fec539f756afcefad4e508c098b9a7e1d8feb19955fb02ba9675585078710969d3440f5054e0e6d22dd06c098efed540bb36a5325893265de57eff4797b545dfd69c1e858731", - "quorum_indexes": "0x0001" + "inclusion_proof": "3e7dc1e7c2b26d75d850e11aeaaaaee508585ef811e733fef9ce70081f5d2449bbcd2d9dd6b5c8dd707024578df8eb0da64bab41f03228146656b2df610a465719808e7a321cd8351f558bfe4e0311c6c61344a707eb53b27a151e34dbecc70c3b3be2fc6e34138afbe6e9bfe6389a3b7cc8ed316aa85e3fe39255cd3f97167c2695916aa8540f5000fd98111ae9d5b8505ab761935cb63fba6d5874690487e9cee8dd024091c3ac5b5c2322abeb57d01ed65db82f056ee0cb6fee5d71a4d5c64f591d8878c02b6a8f32c3a5cb3ea2f295b467c553fcd130782db6e7dc75eec7185f7d4ef896b06cb8f39a5b33d5ac60ac22f73dc0ef6837a9d9874412b64e4fe2509331ff450db394f3a2da8dfceb6a9762dc97e822156a2d3ebb83715f1c0b260c11e4c9b925da81855d71c837798ef495ffd5592a4547fded970e1f3128a303a3d7ec87b45042575eceeca20227dcb42e96e0cb50547f4d1ed17a940083de616b5f841fd06de0f181b32dd60c89f0bac67a076a23c953b1288ac581f30e10", + "quorum_indexes": "0001" } } } \ No newline at end of file From a8eebefc231b407478bbc6d8d62f3f5f965fab80 Mon Sep 17 00:00:00 2001 From: afkbyte Date: Thu, 27 Jun 2024 19:01:24 -0400 Subject: [PATCH 7/7] all tests passing --- test/foundry/SequencerInbox.t.sol | 33 +++++++++++++++++------------ test/foundry/blobInfo/blobInfo.json | 22 +++++++++---------- 2 files changed, 30 insertions(+), 25 deletions(-) diff --git a/test/foundry/SequencerInbox.t.sol b/test/foundry/SequencerInbox.t.sol index 2fa04c06..6f4ff5fa 100644 --- a/test/foundry/SequencerInbox.t.sol +++ b/test/foundry/SequencerInbox.t.sol @@ -615,7 +615,7 @@ contract SequencerInboxTest is Test { // ed is EIGEN_DA_MESSAGE_HEADER_FLAG rest is abi.encodePacked(blobHeader.commitment.X, blobHeader.commitment.Y, blobHeader.dataLength) bytes memory data = - hex"ed1a78ee576b0026de661b72106bf447f5bb70881f24a3fa8b1f312992c8e165970633b392b3d3f66407d912aafcc2f0231c31918f0485e8476975edc710fcb45200000001"; + abi.encodePacked(hex"ed",blobHeader.commitment.X, blobHeader.commitment.Y, blobHeader.dataLength); uint256 subMessageCount = bridge.sequencerReportedSubMessageCount(); uint256 sequenceNumber = bridge.sequencerMessageCount(); @@ -833,7 +833,6 @@ contract SequencerInboxTest is Test { function readAndParseBlobInfo() public returns (IEigenDAServiceManager.BlobHeader memory, EigenDARollupUtils.BlobVerificationProof memory) { string memory json = vm.readFile("test/foundry/blobInfo/blobInfo.json"); - // parse the blob header IEigenDAServiceManager.BlobHeader memory blobHeader; @@ -846,19 +845,24 @@ contract SequencerInboxTest is Test { blobHeader.commitment = commitment; blobHeader.dataLength = uint32(uint256(vm.parseJsonInt(json, ".blob_info.blob_header.data_length"))); - bytes memory quorumParams = vm.parseJson(json, ".blob_info.blob_header.quorum_blob_params"); + //bytes memory quorumParamsBytes = vm.parseJson(json, ".blob_info.blob_header.blob_quorum_params"); + + // TODO: Parse these from the array, for some reason parsing them reads in the wrong order + IEigenDAServiceManager.QuorumBlobParam[] memory quorumParams = new IEigenDAServiceManager.QuorumBlobParam[](2); + + quorumParams[0].quorumNumber = 0; + quorumParams[0].adversaryThresholdPercentage = 33; + quorumParams[0].confirmationThresholdPercentage = 55; + quorumParams[0].chunkLength = 1; + + quorumParams[1].quorumNumber = 1; + quorumParams[1].adversaryThresholdPercentage = 33; + quorumParams[1].confirmationThresholdPercentage = 55; + quorumParams[1].chunkLength = 1; + + blobHeader.quorumBlobParams = quorumParams; - for (uint256 i = 0; i < quorumParams.length; i++) { - IEigenDAServiceManager.QuorumBlobParam memory quorumBlobParam = IEigenDAServiceManager.QuorumBlobParam({ - quorumNumber: uint8(uint256(vm.parseJsonInt(json, ".blob_info.blob_header.quorum_blob_params[i].quorum_number"))), - adversaryThresholdPercentage: uint8(uint256(vm.parseJsonInt(json, ".blob_info.blob_header.quorum_blob_params[i].adversary_threshold_percentage"))), - confirmationThresholdPercentage: uint8(uint256(vm.parseJsonInt(json, ".blob_info.blob_header.quorum_blob_params[i].confirmation_threshold_percentage"))), - chunkLength: uint32(uint256(vm.parseJsonInt(json, ".blob_info.blob_header.quorum_blob_params[i].chunk_length"))) - }); - blobHeader.quorumBlobParams[i] = quorumBlobParam; - } - // parse the blob verification proof IEigenDAServiceManager.BatchHeader memory batchHeader = IEigenDAServiceManager.BatchHeader({ @@ -882,8 +886,9 @@ contract SequencerInboxTest is Test { inclusionProof: vm.parseJsonBytes(json, ".blob_info.blob_verification_proof.inclusion_proof"), quorumIndices: vm.parseJsonBytes(json, ".blob_info.blob_verification_proof.quorum_indexes") }); - + console.logBytes32(keccak256(abi.encode(blobHeader))); return (blobHeader, blobVerificationProof); + } diff --git a/test/foundry/blobInfo/blobInfo.json b/test/foundry/blobInfo/blobInfo.json index f246c564..e45fdd28 100644 --- a/test/foundry/blobInfo/blobInfo.json +++ b/test/foundry/blobInfo/blobInfo.json @@ -1,10 +1,10 @@ { - "request_id": "303534656465633164303231316636323466656430636263613964346639343030623065343931633433373432616632633562306162656266306339393064382d33313337333133393335333233303330333333373330333633353336333833393332333533393266333032663333333332663331326633333333326665336230633434323938666331633134396166626634633839393666623932343237616534316534363439623933346361343935393931623738353262383535", + "request_id": "316638323561613266303032306566376366393164666133306461343636386437393163356434383234666338653431333534623839656330353739356162332d33313337333133393335333233373333333633303336333133363333333533303330333133363266333032663333333332663331326633333333326665336230633434323938666331633134396166626634633839393666623932343237616534316534363439623933346361343935393931623738353262383535", "blob_info": { "blob_header": { "commitment": { - "x": 17884466596723640612337833969319382563829916848310977140316164241640721888957, - "y": 10868816934455168343290327410860226464964837648654804015599259489599053762639 + "x": "0x2569a1994232d43b210e860d876c0bbc8d7f22dc0b8ae17d4c369ce7c2d33c26", + "y": "0x14f8198412fea43aaeb4a5355600d0fe3f175ea2f5d7246a7c6472c453fcde53" }, "data_length": 1, "blob_quorum_params": [ @@ -23,21 +23,21 @@ ] }, "blob_verification_proof": { - "batch_id": 21090, - "blob_index": 3418, + "batch_id": 21103, + "blob_index": 1905, "batch_metadata": { "batch_header": { - "batch_root": "80484028685a85c629eb25fda1409cb21f8181f8105d1ca9b100da71f59acc74", + "batch_root": "d627b55c1f307c37d0543562cdb2e1faf907dd98c1e5f94be62785ac30cca851", "quorum_numbers": "0001", "quorum_signed_percentages": "6362", - "reference_block_number": 1820211 + "reference_block_number": 1820787 }, - "signatory_record_hash": "c5ac31e8de27b9eade6718e806a7df00d9c3557d37b287746e96ec2cacc3224e", + "signatory_record_hash": "390703dea190bab4fc41037a72055dfe8ad3df2cf359a15dca3ebe601c4a0bd9", "fee": "00", - "confirmation_block_number": 1820343, - "batch_header_hash": "eb2c9d6ab0dcd46244d35a0b51131f69f0ddd1cd7635d8a73dc9f62a1866cd2c" + "confirmation_block_number": 1820926, + "batch_header_hash": "f38003c8fed893238c3e8712efe1149333ed86a163fffdb77c98595fa76454aa" }, - "inclusion_proof": "3e7dc1e7c2b26d75d850e11aeaaaaee508585ef811e733fef9ce70081f5d2449bbcd2d9dd6b5c8dd707024578df8eb0da64bab41f03228146656b2df610a465719808e7a321cd8351f558bfe4e0311c6c61344a707eb53b27a151e34dbecc70c3b3be2fc6e34138afbe6e9bfe6389a3b7cc8ed316aa85e3fe39255cd3f97167c2695916aa8540f5000fd98111ae9d5b8505ab761935cb63fba6d5874690487e9cee8dd024091c3ac5b5c2322abeb57d01ed65db82f056ee0cb6fee5d71a4d5c64f591d8878c02b6a8f32c3a5cb3ea2f295b467c553fcd130782db6e7dc75eec7185f7d4ef896b06cb8f39a5b33d5ac60ac22f73dc0ef6837a9d9874412b64e4fe2509331ff450db394f3a2da8dfceb6a9762dc97e822156a2d3ebb83715f1c0b260c11e4c9b925da81855d71c837798ef495ffd5592a4547fded970e1f3128a303a3d7ec87b45042575eceeca20227dcb42e96e0cb50547f4d1ed17a940083de616b5f841fd06de0f181b32dd60c89f0bac67a076a23c953b1288ac581f30e10", + "inclusion_proof": "75ad90fbbde05f97f78dd7908f85a45c4e851cc29b796b70f78cf704a6e32815089c0d4db7fafbb64881a16d7f85e0e8c87129295a31a33e496cde48b1d08c8355754e58189833af2acd177159cd5f433420f335089f657643b85bef9d5701972354f1d752a9d31fce3ca7773c341b8aa729c88a2b3a2bb678c166f563b33f622c587b69c2ec92c998385010f08dc4170a08747c42e23ef429b67cf505a471d0eed3f79adb6a4d781e242ff800c29214f8fbf4f57d7d57ea48082f54e52d7f759afd178572e6986ba7ef6e9050184332eebd04cec473279188ae2a0f780d2ed69a0b17cfa3962bc09162db8b469ae8a38e3db31042338457f765c77f6b28cdd7e14df7b2c40f27f32bd7d4907816fb2655e06414a5b180ade4ebe295662c007428e2141faccaee62f177305df72d1f3b0f8dfc90235272f9a741af4eae6af6dc7bce2ce5f9c820c78fe436beaeef9b6734702cfc3d7863fac39ed52dc3061a1cf4f895c0797e6aff0a6076044102b00663e5e74f5ec53e4621312b98f4c74a7e", "quorum_indexes": "0001" } }