Skip to content
New issue

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

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

Already on GitHub? Sign in to your account

feat: new protobuf files and match latest version of chain #28

Merged
merged 2 commits into from
Nov 1, 2024
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -4,15 +4,15 @@ members = ["crates/common", "crates/proto-common"]

[workspace.dependencies]
base64 = "0.22.1"
cosmos-sdk-proto = "0.25"
cosmos-sdk-proto = { version = "0.26", default-features = false }
cosmwasm-schema = "1.5"
cosmwasm-std = "1.5"
cw-storage-plus = "1.2.0"
hex = "0.4.3"
k256 = "0.13"
lazy_static = "1.5.0"
prost = "0.13"
prost-types = "0.13"
prost = { version = "0.13", default-features = false }
prost-types = { version = "0.13", default-features = false }
schemars = { version = "0.8", features = ["semver"] }
sha3 = "0.10"
semver = { version = "1.0", features = ["serde"] }
Expand Down
18 changes: 14 additions & 4 deletions crates/proto-common/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -4,16 +4,26 @@ version = "0.4.0-dev.0"
edition = "2021"

[dependencies]
prost = { workspace = true, default-features = false }
prost-types = { workspace = true, default-features = false, optional = true }
cosmos-sdk-proto = { version = "0.25", default-features = false, optional = true }
prost = { workspace = true }
prost-types = { workspace = true, optional = true }
cosmos-sdk-proto = { workspace = true, optional = true }

[features]
default = []
all = ["data_proxy", "randomness", "staking", "vesting", "wasm_storage"]
all = [
"batching",
"data_proxy",
"pubkey",
"randomness",
"staking",
"vesting",
"wasm_storage",
]
batching = ["cosmos"]
cosmos = ["dep:cosmos-sdk-proto"]
cosmwasm = ["cosmos", "cosmos-sdk-proto/cosmwasm"]
data_proxy = []
pubkey = ["dep:prost-types"]
randomness = ["dep:prost-types"]
staking = ["dep:prost-types"]
vesting = []
Expand Down
84 changes: 84 additions & 0 deletions crates/proto-common/proto/sedachain/batching/v1/batching.proto
Original file line number Diff line number Diff line change
@@ -0,0 +1,84 @@
syntax = "proto3";
package sedachain.batching.v1;

import "gogoproto/gogo.proto";
import "cosmos_proto/cosmos.proto";

option go_package = "github.com/sedaprotocol/seda-chain/x/batching/types";

// Batch is an aggregation of data request results along with validator
// signatures used to prove these results on destination chains.
message Batch {
// batch_number is a unique identifier of the batch incremented
// every time a batch is created.
uint64 batch_number = 1;
// block_height is the height at which the batch was created.
int64 block_height = 2;
// data_result_root is the hex-encoded root of the data result
// merkle tree.
string data_result_root = 3;
// validator_root is the hex-encoded root of the validator merkle
// tree.
string validator_root = 4;
// batch_id is the Keccack-256 hash of the batch content.
bytes batch_id = 5;
// proving_medatada is a field for additional proving data.
bytes proving_medatada = 6;
}

// TreeEntries are the given batch's data result tree entries and
// validator tree entries.
message TreeEntries {
// batch_number is the identifier of the batch the tree entries from.
uint64 batch_number = 1;
// data_result_entries are the entries (unhashed leaf contents) of
// the data result tree.
repeated bytes data_result_entries = 2;
// validator_entries are the entries (unhashed leaf contents) of
// the validator tree.
repeated bytes validator_entries = 3;
}

// BatchSignatures contains basic validator data and its batch signatures
// under various cryptographic schemes.
message BatchSignatures {
string validator_addr = 1
[ (cosmos_proto.scalar) = "cosmos.ValidatorAddressString" ];
int64 voting_power = 2;
gluax marked this conversation as resolved.
Show resolved Hide resolved
bytes signatures = 3;
}

// Params is a list of parameters which can be changed through governance.
message Params {
option (gogoproto.equal) = true;

// validator_set_trim_percent is the percentage of the validator
// set to store in the validator merkle tree in the batch.
uint32 validator_set_trim_percent = 1;
}

// DataResult represents the result of a resolved data request.
message DataResult {
// id is the Keccack-256 hash of the data result.
string id = 1;
// dr_id is the data request identifier.
string dr_id = 2;
// version is a semantic version string.
string version = 3;
// block_height is the height at which the data request was tallied.
uint64 block_height = 4;
// exit_code is the exit code of the tally wasm binary execution.
uint32 exit_code = 5;
// gas_used is the gas used by the data request execution.
uint64 gas_used = 6;
// result is the result of the tally wasm binary execution.
bytes result = 7;
// payback_address is the payback address set by the relayer.
string payback_address = 8;
// seda_payload is the payload set by SEDA Protocol (e.g. OEV-enabled
// data requests)
string seda_payload = 9;
// consensus indicates whether consensus was reached in the tally
// process.
bool consensus = 10;
}
27 changes: 27 additions & 0 deletions crates/proto-common/proto/sedachain/batching/v1/genesis.proto
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
syntax = "proto3";
package sedachain.batching.v1;

import "gogoproto/gogo.proto";
import "sedachain/batching/v1/batching.proto";

option go_package = "github.com/sedaprotocol/seda-chain/x/batching/types";

// GenesisState defines the batching module's genesis state.
message GenesisState {
// current_batch_number is the batch number of the most recently-
// created batch.
uint64 current_batch_number = 1;
repeated Batch batches = 2 [ (gogoproto.nullable) = false ];
repeated TreeEntries tree_entries = 3 [ (gogoproto.nullable) = false ];
repeated DataResult data_results = 4 [ (gogoproto.nullable) = false ];
repeated BatchAssignment batch_assignments = 5
[ (gogoproto.nullable) = false ];
Params params = 6 [ (gogoproto.nullable) = false ];
}

// BatchAssignment represents a batch assignment for genesis export
// and import.
message BatchAssignment {
uint64 batch_number = 1;
string data_request_id = 2;
}
114 changes: 114 additions & 0 deletions crates/proto-common/proto/sedachain/batching/v1/query.proto
Original file line number Diff line number Diff line change
@@ -0,0 +1,114 @@
syntax = "proto3";
package sedachain.batching.v1;

import "gogoproto/gogo.proto";
import "google/api/annotations.proto";
import "cosmos/base/query/v1beta1/pagination.proto";
import "sedachain/batching/v1/batching.proto";

option go_package = "github.com/sedaprotocol/seda-chain/x/batching/types";

// Query defines the gRPC querier service.
service Query {
// Batch returns a batch given the batch number.
rpc Batch(QueryBatchRequest) returns (QueryBatchResponse) {
option (google.api.http).get = "/seda-chain/batching/batch/{batch_number}";
}

// BatchForHeight returns a batch created at a given block height.
rpc BatchForHeight(QueryBatchForHeightRequest)
returns (QueryBatchForHeightResponse) {
option (google.api.http).get =
"/seda-chain/batching/batch_for_height/{block_height}";
}

// Batch returns all batches in the store.
rpc Batches(QueryBatchesRequest) returns (QueryBatchesResponse) {
option (google.api.http).get = "/seda-chain/batching/batches";
}

// TreeEntries returns the tree entries from the given batch number.
rpc TreeEntries(QueryTreeEntriesRequest) returns (QueryTreeEntriesResponse) {
option (google.api.http).get =
"/seda-chain/batching/tree_entries/{batch_number}";
}

// BatchSignatures returns the batch signatures for the given batch
// and the
rpc BatchSignatures(QueryBatchSignaturesRequest)
returns (QueryBatchSignaturesResponse) {
option (google.api.http).get =
"/seda-chain/batching/batch_signatures/{batch_number}";
}

// DataResult returns a data result given its associated data request's
// ID.
rpc DataResult(QueryDataResultRequest) returns (QueryDataResultResponse) {
option (google.api.http).get =
"/seda-chain/batching/data_result/{data_request_id}";
}

// BatchAssignment returns the batch number that a given data request
// has been assigned to.
rpc BatchAssignment(QueryBatchAssignmentRequest)
returns (QueryBatchAssignmentResponse) {
option (google.api.http).get =
"/seda-chain/batching/batch_assignment/{data_request_id}";
}
}

// The request message for QueryBatch RPC.
message QueryBatchRequest { uint64 batch_number = 1; }

// The response message for QueryBatch RPC.
message QueryBatchResponse { Batch batch = 1 [ (gogoproto.nullable) = false ]; }

// The request message for BatchForHeight RPC.
message QueryBatchForHeightRequest { int64 block_height = 1; }

// The response message for BatchForHeight RPC.
message QueryBatchForHeightResponse {
Batch batch = 1 [ (gogoproto.nullable) = false ];
}

// The request message for QueryBatches RPC.
message QueryBatchesRequest {
// pagination defines an optional pagination for the request.
cosmos.base.query.v1beta1.PageRequest pagination = 1;
}

// The response message for QueryBatches RPC.
message QueryBatchesResponse {
repeated Batch batches = 1 [ (gogoproto.nullable) = false ];
cosmos.base.query.v1beta1.PageResponse pagination = 2;
}

// The request message for QueryTreeEntries RPC.
message QueryTreeEntriesRequest { uint64 batch_number = 1; }

// The response message for QueryTreeEntries RPC.
message QueryTreeEntriesResponse {
TreeEntries entries = 1 [ (gogoproto.nullable) = false ];
}

// The request message for QueryBatchSignaturesRequest RPC.
message QueryBatchSignaturesRequest { uint64 batch_number = 1; }

// The response message for QueryQueryBatchSignatures RPC.
message QueryBatchSignaturesResponse {
repeated BatchSignatures batch_sigs = 1 [ (gogoproto.nullable) = false ];
}

// The request message for QueryDataResult RPC.
message QueryDataResultRequest { string data_request_id = 1; }

// The response message for QueryDataResult RPC.
message QueryDataResultResponse {
DataResult data_result = 1 [ (gogoproto.nullable) = false ];
}

// The request message for QueryBatchAssignment RPC.
message QueryBatchAssignmentRequest { string data_request_id = 1; }

// The response message for QueryBatchAssignment RPC.
message QueryBatchAssignmentResponse { uint64 batch_number = 1; }
22 changes: 22 additions & 0 deletions crates/proto-common/proto/sedachain/pubkey/v1/genesis.proto
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
syntax = "proto3";
package sedachain.pubkey.v1;

import "gogoproto/gogo.proto";
import "cosmos_proto/cosmos.proto";
import "sedachain/pubkey/v1/pubkey.proto";

option go_package = "github.com/sedaprotocol/seda-chain/x/pubkey/types";

// GenesisState defines pubkey module's genesis state.
message GenesisState {
repeated ValidatorPubKeys validator_pub_keys = 1
[ (gogoproto.nullable) = false ];
}

// ValidatorPubKeys defines a validator's list of registered public keys
// primarily used in the x/pubkey genesis state.
message ValidatorPubKeys {
string validator_addr = 1
[ (cosmos_proto.scalar) = "cosmos.ValidatorAddressString" ];
repeated IndexedPubKey indexed_pub_keys = 2 [ (gogoproto.nullable) = false ];
}
14 changes: 14 additions & 0 deletions crates/proto-common/proto/sedachain/pubkey/v1/pubkey.proto
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
syntax = "proto3";
package sedachain.pubkey.v1;

import "google/protobuf/any.proto";
import "cosmos_proto/cosmos.proto";

option go_package = "github.com/sedaprotocol/seda-chain/x/pubkey/types";

// IndexPubKeyPair defines an index - public key pair.
message IndexedPubKey {
uint32 index = 1;
google.protobuf.Any pub_key = 2
[ (cosmos_proto.accepts_interface) = "cosmos.crypto.PubKey" ];
}
32 changes: 32 additions & 0 deletions crates/proto-common/proto/sedachain/pubkey/v1/query.proto
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
syntax = "proto3";
package sedachain.pubkey.v1;

import "google/api/annotations.proto";
import "gogoproto/gogo.proto";
import "cosmos_proto/cosmos.proto";
import "sedachain/pubkey/v1/genesis.proto";

option go_package = "github.com/sedaprotocol/seda-chain/x/pubkey/types";

// Query defines the gRPC querier service.
service Query {
// ValidatorKeys returns a given validator's registered keys.
rpc ValidatorKeys(QueryValidatorKeysRequest)
returns (QueryValidatorKeysResponse) {
option (google.api.http).get =
"/seda-chain/pubkey/validator_keys/{validator_addr}";
}
}

// QueryValidatorKeysRequest is request type for the Query/ValidatorKeys RPC
// method.
message QueryValidatorKeysRequest {
string validator_addr = 1
[ (cosmos_proto.scalar) = "cosmos.ValidatorAddressString" ];
}

// QueryValidatorKeysResponse is response type for the Query/ValidatorKeys RPC
// method.
message QueryValidatorKeysResponse {
ValidatorPubKeys validator_pub_keys = 1 [ (gogoproto.nullable) = false ];
}
29 changes: 29 additions & 0 deletions crates/proto-common/proto/sedachain/pubkey/v1/tx.proto
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
syntax = "proto3";
package sedachain.pubkey.v1;

import "gogoproto/gogo.proto";
import "cosmos_proto/cosmos.proto";
import "cosmos/msg/v1/msg.proto";
import "sedachain/pubkey/v1/pubkey.proto";

option go_package = "github.com/sedaprotocol/seda-chain/x/pubkey/types";

// Msg defines the pubkey Msg service.
service Msg {
option (cosmos.msg.v1.service) = true;

// AddKey defines a method for registering a new public key.
rpc AddKey(MsgAddKey) returns (MsgAddKeyResponse);
}

// MsgAddKey defines a message for registering a new public key.
message MsgAddKey {
option (cosmos.msg.v1.signer) = "validator_addr";

string validator_addr = 1
[ (cosmos_proto.scalar) = "cosmos.ValidatorAddressString" ];
repeated IndexedPubKey indexed_pub_keys = 2 [ (gogoproto.nullable) = false ];
}

// MsgAddKeyResponse defines the Msg/MsgAddKey response type.
message MsgAddKeyResponse {}

This file was deleted.

Loading