Skip to content

Commit

Permalink
chore: Update protobuf definitions (#40)
Browse files Browse the repository at this point in the history
* chore: Update protobuf definitions

* fix json in tests

* fetch go-header protos

* vendor google protos

* update proto readme

* Update tools/update-proto-vendor.sh

Co-authored-by: Maciej Zwoliński <mac.zwolinski@gmail.com>

* fix shellcheck

* remove serde(default) on the fields because it is now used on the whole container

* update proto readme

---------

Co-authored-by: Maciej Zwoliński <mac.zwolinski@gmail.com>
  • Loading branch information
oblique and zvolin authored Sep 22, 2023
1 parent c48098c commit dc77ab0
Show file tree
Hide file tree
Showing 24 changed files with 242 additions and 116 deletions.
4 changes: 2 additions & 2 deletions ci/Dockerfile.bridge
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,8 @@ ENV CELESTIA_HOME=/root
RUN apk update && apk add --no-cache bash jq

# Copy in the binary
COPY --from=ghcr.io/celestiaorg/celestia-node:v0.11.0-rc13 /bin/celestia /bin/celestia
COPY --from=ghcr.io/celestiaorg/celestia-node:v0.11.0-rc13 /bin/cel-key /bin/cel-key
COPY --from=ghcr.io/celestiaorg/celestia-node:v0.11.0-rc14 /bin/celestia /bin/celestia
COPY --from=ghcr.io/celestiaorg/celestia-node:v0.11.0-rc14 /bin/cel-key /bin/cel-key

COPY ./run-bridge.sh /opt/entrypoint.sh

Expand Down
2 changes: 1 addition & 1 deletion ci/Dockerfile.validator
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ ENV CELESTIA_HOME=/root
RUN apk update && apk add --no-cache bash jq

# Copy in the binary
COPY --from=ghcr.io/celestiaorg/celestia-app:v1.0.0-rc14 /bin/celestia-appd /bin/celestia-appd
COPY --from=ghcr.io/celestiaorg/celestia-app:v1.0.0-rc17 /bin/celestia-appd /bin/celestia-appd

COPY ./run-validator.sh /opt/entrypoint.sh

Expand Down
27 changes: 9 additions & 18 deletions proto/build.rs
Original file line number Diff line number Diff line change
@@ -1,15 +1,13 @@
use anyhow::Result;

const DEFAULT: &str = r#"#[serde(default)]"#;
const SERIALIZED: &str = r#"#[derive(::serde::Deserialize, ::serde::Serialize)]"#;
const SERIALIZED: &str = r#"#[derive(::serde::Deserialize, ::serde::Serialize)] #[serde(default)]"#;
const BASE64STRING: &str =
r#"#[serde(with = "tendermint_proto::serializers::bytes::base64string")]"#;
const QUOTED: &str = r#"#[serde(with = "tendermint_proto::serializers::from_str")]"#;
const VEC_BASE64STRING: &str =
r#"#[serde(with = "tendermint_proto::serializers::bytes::vec_base64string")]"#;
const OPTION_ANY: &str = r#"#[serde(default, with = "crate::serializers::option_any")]"#;
const OPTION_TIMESTAMP: &str =
r#"#[serde(default, with = "crate::serializers::option_timestamp")]"#;
const OPTION_ANY: &str = r#"#[serde(with = "crate::serializers::option_any")]"#;
const OPTION_TIMESTAMP: &str = r#"#[serde(with = "crate::serializers::option_timestamp")]"#;

#[rustfmt::skip]
pub static CUSTOM_TYPE_ATTRIBUTES: &[(&str, &str)] = &[
Expand All @@ -34,10 +32,9 @@ pub static CUSTOM_TYPE_ATTRIBUTES: &[(&str, &str)] = &[
(".cosmos.staking.v1beta1.UnbondingDelegationEntry", SERIALIZED),
(".header.pb.ExtendedHeader", SERIALIZED),
(".share.eds.byzantine.pb.BadEncoding", SERIALIZED),
(".share.eds.byzantine.pb.MerkleProof", SERIALIZED),
(".share.eds.byzantine.pb.Share", SERIALIZED),
(".share.p2p.shrex.nd.Proof", SERIALIZED),
(".share.p2p.shrex.nd.Row", SERIALIZED),
(".proof.pb.Proof", SERIALIZED),
(".share.p2p.shrex.nd.NamespaceRowResponse", SERIALIZED),
];

#[rustfmt::skip]
Expand All @@ -48,16 +45,10 @@ pub static CUSTOM_FIELD_ATTRIBUTES: &[(&str, &str)] = &[
(".cosmos.base.query.v1beta1.PageResponse.next_key", BASE64STRING),
(".cosmos.staking.v1beta1.RedelegationEntry.completion_time", OPTION_TIMESTAMP),
(".cosmos.staking.v1beta1.UnbondingDelegationEntry.completion_time", OPTION_TIMESTAMP),
(".share.eds.byzantine.pb.MerkleProof.nodes", VEC_BASE64STRING),
(".share.eds.byzantine.pb.MerkleProof.leaf_hash", DEFAULT),
(".share.eds.byzantine.pb.MerkleProof.leaf_hash", BASE64STRING),
(".share.eds.byzantine.pb.BadEncoding.axis", QUOTED),
(".share.p2p.shrex.nd.Proof.nodes", VEC_BASE64STRING),
(".share.p2p.shrex.nd.Proof.hashleaf", DEFAULT),
(".share.p2p.shrex.nd.Proof.hashleaf", BASE64STRING),
// TODO: remove me https://github.com/celestiaorg/celestia-node/issues/2427
(".share.p2p.shrex.nd.Proof.hashleaf", r#"#[serde(rename = "leaf_hash")]"#),
(".share.p2p.shrex.nd.Row.shares", VEC_BASE64STRING),
(".proof.pb.Proof.nodes", VEC_BASE64STRING),
(".proof.pb.Proof.leaf_hash", BASE64STRING),
(".share.p2p.shrex.nd.NamespaceRowResponse.shares", VEC_BASE64STRING),
];

fn main() -> Result<()> {
Expand Down Expand Up @@ -98,7 +89,7 @@ fn main() -> Result<()> {
"vendor/cosmos/tx/v1beta1/tx.proto",
"vendor/go-header/p2p/pb/header_request.proto",
],
&["vendor"],
&["vendor", "vendor/nmt"],
)?;

Ok(())
Expand Down
11 changes: 11 additions & 0 deletions proto/vendor/README.md
Original file line number Diff line number Diff line change
@@ -1,7 +1,18 @@
## Update

To update protobuf definitions run:

```bash
./tools/update-proto-vendor.sh
```

## Sources

* `tendermint` directory is vendored from [celestia-core](https://github.com/celestiaorg/celestia-core/tree/v0.34.x-celestia/proto)
* `gogoproto` directory is vendored from [gogoproto](https://github.com/cosmos/gogoproto/tree/v1.4.10/gogoproto)
* `celestia` directory is vendored from [celestia-app](https://github.com/celestiaorg/celestia-app/tree/main/proto)
* `share` and `header` directories are vendored from [celestia-node](https://github.com/celestiaorg/celestia-node)
* `cosmos` subdirectories are vendored from [cosmos-sdk](https://github.com/celestiaorg/cosmos-sdk/tree/release/v0.46.x-celestia/proto/cosmos)
* `cosmos_proto` directory is vendored from [cosmos-proto](https://github.com/cosmos/cosmos-proto/tree/v1.0.0-alpha4/proto/cosmos_proto)
* `go-header` directory is vendored from [go-header](https://github.com/celestiaorg/go-header/tree/main)
* `google` directory is vendored from [googleapis](https://github.com/googleapis/googleapis/tree/master/google/api)
4 changes: 2 additions & 2 deletions proto/vendor/celestia/blob/v1/event.proto
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ message EventPayForBlobs {
string signer = 1;
repeated uint32 blob_sizes = 2;
// namespaces is a list of namespaces that the blobs in blob_sizes belong to.
// A namespace has length of 33 bytes where the first byte is the
// namespaceVersion and the subsequent 32 bytes are the namespaceID.
// A namespace has length of 29 bytes where the first byte is the
// namespaceVersion and the subsequent 28 bytes are the namespaceID.
repeated bytes namespaces = 3;
}
4 changes: 2 additions & 2 deletions proto/vendor/celestia/blob/v1/tx.proto
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,8 @@ service Msg {
message MsgPayForBlobs {
string signer = 1;
// namespaces is a list of namespaces that the blobs are associated with. A
// namespace is a byte slice of length 33 where the first byte is the
// namespaceVersion and the subsequent 32 bytes are the namespaceId.
// namespace is a byte slice of length 29 where the first byte is the
// namespaceVersion and the subsequent 28 bytes are the namespaceId.
repeated bytes namespaces = 2;
repeated uint32 blob_sizes = 3;
// share_commitments is a list of share commitments (one per blob).
Expand Down
9 changes: 4 additions & 5 deletions proto/vendor/celestia/mint/v1/genesis.proto
Original file line number Diff line number Diff line change
@@ -1,13 +1,12 @@
syntax = "proto3";
package celestia.mint.v1;

import "gogoproto/gogo.proto";
import "celestia/mint/v1/mint.proto";

option go_package = "github.com/celestiaorg/celestia-app/x/mint/types";

// GenesisState defines the mint module's genesis state.
message GenesisState {
// minter is a space for holding current inflation information.
Minter minter = 1 [ (gogoproto.nullable) = false ];
reserved 1; // 1 was previously used for the `Minter` field.

// BondDenom is the denomination of the token that should be minted.
string bond_denom = 2;
}
9 changes: 6 additions & 3 deletions proto/vendor/celestia/mint/v1/mint.proto
Original file line number Diff line number Diff line change
Expand Up @@ -25,13 +25,16 @@ message Minter {
(gogoproto.nullable) = false
];

// GenesisTime is the timestamp of the genesis block.
google.protobuf.Timestamp genesis_time = 3 [ (gogoproto.stdtime) = true ];

// PreviousBlockTime is the timestamp of the previous block.
google.protobuf.Timestamp previous_block_time = 4
[ (gogoproto.stdtime) = true ];

// BondDenom is the denomination of the token that should be minted.
string bond_denom = 5;
}

// GenesisTime contains the timestamp of the genesis block.
message GenesisTime {
// GenesisTime is the timestamp of the genesis block.
google.protobuf.Timestamp genesis_time = 1 [ (gogoproto.stdtime) = true ];
}
2 changes: 1 addition & 1 deletion proto/vendor/celestia/qgb/v1/genesis.proto
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,6 @@ message Params {
uint64 data_commitment_window = 1;
}

// GenesisState struct, containing all persistent data required by the Gravity
// GenesisState struct, containing all persistent data required by the QGB
// module
message GenesisState { Params params = 1; }
12 changes: 12 additions & 0 deletions proto/vendor/celestia/qgb/v1/query.proto
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,12 @@ service Query {
returns (QueryLatestDataCommitmentResponse) {
option (google.api.http).get = "/qgb/v1/data_commitment/latest";
}

// EVMAddress returns the evm address associated with a supplied
// validator address
rpc EVMAddress(QueryEVMAddressRequest) returns (QueryEVMAddressResponse) {
option (google.api.http).get = "/qgb/v1/evm_address";
}
}

// QueryParamsRequest
Expand Down Expand Up @@ -116,3 +122,9 @@ message QueryDataCommitmentRangeForHeightRequest { uint64 height = 1; }
message QueryDataCommitmentRangeForHeightResponse {
DataCommitment data_commitment = 1;
}

// QueryEVMAddressRequest
message QueryEVMAddressRequest { string validator_address = 1; }

// QueryEVMAddressResponse
message QueryEVMAddressResponse { string evm_address = 1; }
34 changes: 34 additions & 0 deletions proto/vendor/celestia/qgb/v1/tx.proto
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
syntax = "proto3";
package celestia.qgb.v1;

import "gogoproto/gogo.proto";
import "cosmos_proto/cosmos.proto";
import "google/api/annotations.proto";

option go_package = "github.com/celestiaorg/celestia-app/x/qgb/types";

// Msg is the message server for receiving qgb transactions
service Msg {
// RegisterEVMAddress records an evm address for the validator which is used
// by the relayer to aggregate signatures. A validator can only register a
// single EVM address. The EVM address can be overridden by a later message.
// There are no validity checks of the EVM addresses existence on the Ethereum
// state machine.
rpc RegisterEVMAddress(MsgRegisterEVMAddress)
returns (MsgRegisterEVMAddressResponse) {
option (google.api.http).get = "/qgb/v1/register_evm_address";
}
}

// MsgRegisterEVMAddress registers an evm address to a validator.
message MsgRegisterEVMAddress {
// The operating address of the validator.
string validator_address = 1
[ (cosmos_proto.scalar) = "cosmos.AddressString" ];

// The matching HEX encoded EVM address.
string evm_address = 2;
}

// MsgRegisterEVMAddressResponse is the response to registering an EVM address.
message MsgRegisterEVMAddressResponse {}
3 changes: 0 additions & 3 deletions proto/vendor/cosmos/staking/v1beta1/staking.proto
Original file line number Diff line number Diff line change
Expand Up @@ -124,9 +124,6 @@ message Validator {
(gogoproto.customtype) = "github.com/cosmos/cosmos-sdk/types.Int",
(gogoproto.nullable) = false
];
// This is a hex encoded 0x EVM public key that will be used by this
// validator on the target EVM chain.
string evm_address = 12;
}

// BondStatus is the status of a validator.
Expand Down
10 changes: 3 additions & 7 deletions proto/vendor/cosmos/staking/v1beta1/tx.proto
Original file line number Diff line number Diff line change
Expand Up @@ -62,9 +62,6 @@ message MsgCreateValidator {
string validator_address = 5 [(cosmos_proto.scalar) = "cosmos.AddressString"];
google.protobuf.Any pubkey = 6 [(cosmos_proto.accepts_interface) = "cosmos.crypto.PubKey"];
cosmos.base.v1beta1.Coin value = 7 [(gogoproto.nullable) = false];
// This is a hex encoded 0x EVM public key that will be used by this
// validator on the target EVM chain.
string evm_address = 8;
}

// MsgCreateValidatorResponse defines the Msg/CreateValidator response type.
Expand All @@ -88,7 +85,6 @@ message MsgEditValidator {
[(cosmos_proto.scalar) = "cosmos.Dec", (gogoproto.customtype) = "github.com/cosmos/cosmos-sdk/types.Dec"];
string min_self_delegation = 4
[(cosmos_proto.scalar) = "cosmos.Int", (gogoproto.customtype) = "github.com/cosmos/cosmos-sdk/types.Int"];
string evm_address = 5;
}

// MsgEditValidatorResponse defines the Msg/EditValidator response type.
Expand Down Expand Up @@ -151,10 +147,10 @@ message MsgCancelUnbondingDelegation {
option (cosmos.msg.v1.signer) = "delegator_address";
option (gogoproto.equal) = false;

string delegator_address = 1 [(cosmos_proto.scalar) = "cosmos.AddressString"];
string validator_address = 2 [(cosmos_proto.scalar) = "cosmos.AddressString"];
string delegator_address = 1 [(cosmos_proto.scalar) = "cosmos.AddressString"];
string validator_address = 2 [(cosmos_proto.scalar) = "cosmos.AddressString"];
// amount is always less than or equal to unbonding delegation entry balance
cosmos.base.v1beta1.Coin amount = 3 [(gogoproto.nullable) = false];
cosmos.base.v1beta1.Coin amount = 3 [(gogoproto.nullable) = false];
// creation_height is the height which the unbonding took place.
int64 creation_height = 4;
}
Expand Down
22 changes: 22 additions & 0 deletions proto/vendor/nmt/pb/proof.proto
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
syntax="proto3";

package proof.pb;

option go_package = "github.com/celestiaorg/nmt/pb";

message Proof {
// Start index of the leaves that match the queried namespace.ID.
int64 start = 1;
// End index (non-inclusive) of the leaves that match the queried
// namespace.ID.
int64 end = 2;
// Nodes hold the tree nodes necessary for the Merkle range proof.
repeated bytes nodes = 3;
// leaf_hash contains the namespace.ID if NMT does not have it and
// it should be proven. leaf_hash is necessary to prove the Absence Proof.
// This field will be empty in case of Inclusion Proof.
bytes leaf_hash = 4;
// The is_max_namespace_ignored flag influences the calculation of the
// namespace ID range for intermediate nodes in the tree.
bool is_max_namespace_ignored=5;
}
10 changes: 2 additions & 8 deletions proto/vendor/share/eds/byzantine/pb/share.proto
Original file line number Diff line number Diff line change
@@ -1,17 +1,11 @@
syntax = "proto3";

package share.eds.byzantine.pb;

message MerkleProof {
int64 start = 1;
int64 end = 2;
repeated bytes nodes = 3;
bytes leaf_hash = 4;
}
import "pb/proof.proto";

message Share {
bytes Data = 1;
MerkleProof Proof = 2;
proof.pb.Proof Proof = 2;
}

enum axis {
Expand Down
18 changes: 5 additions & 13 deletions proto/vendor/share/p2p/shrexnd/pb/share.proto
Original file line number Diff line number Diff line change
@@ -1,33 +1,25 @@
syntax = "proto3";

package share.p2p.shrex.nd;
import "pb/proof.proto";

message GetSharesByNamespaceRequest{
bytes root_hash = 1;
bytes namespace_id = 2;
bytes namespace = 2;
}

message GetSharesByNamespaceResponse{
message GetSharesByNamespaceStatusResponse{
StatusCode status = 1;
repeated Row rows = 2;
}

enum StatusCode {
INVALID = 0;
OK = 1;
NOT_FOUND = 2;
INTERNAL = 3;
NAMESPACE_NOT_FOUND = 4;
};

message Row {
message NamespaceRowResponse {
repeated bytes shares = 1;
Proof proof = 2;
}

message Proof {
int64 start = 1;
int64 end = 2;
repeated bytes nodes = 3;
bytes hashleaf = 4;
proof.pb.Proof proof = 2;
}
8 changes: 8 additions & 0 deletions proto/vendor/tendermint/abci/types.proto
Original file line number Diff line number Diff line change
Expand Up @@ -133,6 +133,14 @@ message RequestPrepareProposal {
tendermint.types.Data block_data = 1;
// If an application decides to populate block_data with extra information, they can not exceed this value.
int64 block_data_size = 2;
// chain_id is a unique identifier for the blockchain network this proposal
// belongs to (e.g. mocha-1).
string chain_id = 3;
// height is the height of the proposal block
int64 height = 4;
// time is the time that will end up in the header. This is the voting power
// weighted median of the last commit.
google.protobuf.Timestamp time = 5 [(gogoproto.nullable) = false, (gogoproto.stdtime) = true];
}

message RequestProcessProposal {
Expand Down
Loading

0 comments on commit dc77ab0

Please sign in to comment.