Skip to content

Commit

Permalink
feat(proto): add cosmos Tx and celestia MsgPayForBlobs (#75)
Browse files Browse the repository at this point in the history
  • Loading branch information
zvolin authored Sep 21, 2023
1 parent 08af7a9 commit c48098c
Show file tree
Hide file tree
Showing 12 changed files with 721 additions and 1 deletion.
4 changes: 4 additions & 0 deletions proto/build.rs
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ const OPTION_TIMESTAMP: &str =
#[rustfmt::skip]
pub static CUSTOM_TYPE_ATTRIBUTES: &[(&str, &str)] = &[
(".celestia.da.DataAvailabilityHeader", SERIALIZED),
(".celestia.blob.v1.MsgPayForBlobs", SERIALIZED),
(".cosmos.base.abci.v1beta1.ABCIMessageLog", SERIALIZED),
(".cosmos.base.abci.v1beta1.Attribute", SERIALIZED),
(".cosmos.base.abci.v1beta1.StringEvent", SERIALIZED),
Expand Down Expand Up @@ -86,12 +87,15 @@ fn main() -> Result<()> {
.compile_protos(
&[
"vendor/celestia/da/data_availability_header.proto",
"vendor/celestia/blob/v1/tx.proto",
"vendor/header/pb/extended_header.proto",
"vendor/share/p2p/shrexnd/pb/share.proto",
"vendor/share/eds/byzantine/pb/share.proto",
"vendor/cosmos/base/v1beta1/coin.proto",
"vendor/cosmos/base/abci/v1beta1/abci.proto",
"vendor/cosmos/crypto/multisig/v1beta1/multisig.proto",
"vendor/cosmos/staking/v1beta1/query.proto",
"vendor/cosmos/tx/v1beta1/tx.proto",
"vendor/go-header/p2p/pb/header_request.proto",
],
&["vendor"],
Expand Down
2 changes: 1 addition & 1 deletion proto/vendor/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,6 @@
* `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/base` and `cosmos/stacking` directories are vendores from [cosmos-sdk](https://github.com/celestiaorg/cosmos-sdk/tree/release/v0.46.x-celestia/proto/cosmos)
* `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)
23 changes: 23 additions & 0 deletions proto/vendor/cosmos/crypto/ed25519/keys.proto
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
syntax = "proto3";
package cosmos.crypto.ed25519;

import "gogoproto/gogo.proto";

option go_package = "github.com/cosmos/cosmos-sdk/crypto/keys/ed25519";

// PubKey is an ed25519 public key for handling Tendermint keys in SDK.
// It's needed for Any serialization and SDK compatibility.
// It must not be used in a non Tendermint key context because it doesn't implement
// ADR-28. Nevertheless, you will like to use ed25519 in app user level
// then you must create a new proto message and follow ADR-28 for Address construction.
message PubKey {
option (gogoproto.goproto_stringer) = false;

bytes key = 1 [(gogoproto.casttype) = "crypto/ed25519.PublicKey"];
}

// Deprecated: PrivKey defines a ed25519 private key.
// NOTE: ed25519 keys must not be used in SDK apps except in a tendermint validator context.
message PrivKey {
bytes key = 1 [(gogoproto.casttype) = "crypto/ed25519.PrivateKey"];
}
24 changes: 24 additions & 0 deletions proto/vendor/cosmos/crypto/hd/v1/hd.proto
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
// Since: cosmos-sdk 0.46
syntax = "proto3";
package cosmos.crypto.hd.v1;

import "gogoproto/gogo.proto";

option go_package = "github.com/cosmos/cosmos-sdk/crypto/hd";
option (gogoproto.goproto_getters_all) = false;

// BIP44Params is used as path field in ledger item in Record.
message BIP44Params {
option (gogoproto.goproto_stringer) = false;
// purpose is a constant set to 44' (or 0x8000002C) following the BIP43 recommendation
uint32 purpose = 1;
// coin_type is a constant that improves privacy
uint32 coin_type = 2;
// account splits the key space into independent user identities
uint32 account = 3;
// change is a constant used for public derivation. Constant 0 is used for external chain and constant 1 for internal
// chain.
bool change = 4;
// address_index is used as child index in BIP32 derivation
uint32 address_index = 5;
}
47 changes: 47 additions & 0 deletions proto/vendor/cosmos/crypto/keyring/v1/record.proto
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
// Since: cosmos-sdk 0.46
syntax = "proto3";
package cosmos.crypto.keyring.v1;

import "gogoproto/gogo.proto";
import "google/protobuf/any.proto";
import "cosmos/crypto/hd/v1/hd.proto";

option go_package = "github.com/cosmos/cosmos-sdk/crypto/keyring";
option (gogoproto.goproto_getters_all) = false;

// Record is used for representing a key in the keyring.
message Record {
// name represents a name of Record
string name = 1;
// pub_key represents a public key in any format
google.protobuf.Any pub_key = 2;

// Record contains one of the following items
oneof item {
// local stores the private key locally.
Local local = 3;
// ledger stores the information about a Ledger key.
Ledger ledger = 4;
// Multi does not store any other information.
Multi multi = 5;
// Offline does not store any other information.
Offline offline = 6;
}

// Item is a keyring item stored in a keyring backend.
// Local item
message Local {
google.protobuf.Any priv_key = 1;
}

// Ledger item
message Ledger {
hd.v1.BIP44Params path = 1;
}

// Multi item
message Multi {}

// Offline item
message Offline {}
}
17 changes: 17 additions & 0 deletions proto/vendor/cosmos/crypto/multisig/keys.proto
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
syntax = "proto3";
package cosmos.crypto.multisig;

import "gogoproto/gogo.proto";
import "google/protobuf/any.proto";

option go_package = "github.com/cosmos/cosmos-sdk/crypto/keys/multisig";

// LegacyAminoPubKey specifies a public key type
// which nests multiple public keys and a threshold,
// it uses legacy amino address rules.
message LegacyAminoPubKey {
option (gogoproto.goproto_getters) = false;

uint32 threshold = 1;
repeated google.protobuf.Any public_keys = 2 [(gogoproto.customname) = "PubKeys"];
}
25 changes: 25 additions & 0 deletions proto/vendor/cosmos/crypto/multisig/v1beta1/multisig.proto
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
syntax = "proto3";
package cosmos.crypto.multisig.v1beta1;

import "gogoproto/gogo.proto";

option go_package = "github.com/cosmos/cosmos-sdk/crypto/types";

// MultiSignature wraps the signatures from a multisig.LegacyAminoPubKey.
// See cosmos.tx.v1betata1.ModeInfo.Multi for how to specify which signers
// signed and with which modes.
message MultiSignature {
option (gogoproto.goproto_unrecognized) = true;
repeated bytes signatures = 1;
}

// CompactBitArray is an implementation of a space efficient bit array.
// This is used to ensure that the encoded data takes up a minimal amount of
// space after proto encoding.
// This is not thread safe, and is not intended for concurrent usage.
message CompactBitArray {
option (gogoproto.goproto_stringer) = false;

uint32 extra_bits_stored = 1;
bytes elems = 2;
}
22 changes: 22 additions & 0 deletions proto/vendor/cosmos/crypto/secp256k1/keys.proto
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
syntax = "proto3";
package cosmos.crypto.secp256k1;

import "gogoproto/gogo.proto";

option go_package = "github.com/cosmos/cosmos-sdk/crypto/keys/secp256k1";

// PubKey defines a secp256k1 public key
// Key is the compressed form of the pubkey. The first byte depends is a 0x02 byte
// if the y-coordinate is the lexicographically largest of the two associated with
// the x-coordinate. Otherwise the first byte is a 0x03.
// This prefix is followed with the x-coordinate.
message PubKey {
option (gogoproto.goproto_stringer) = false;

bytes key = 1;
}

// PrivKey defines a secp256k1 private key.
message PrivKey {
bytes key = 1;
}
23 changes: 23 additions & 0 deletions proto/vendor/cosmos/crypto/secp256r1/keys.proto
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
// Since: cosmos-sdk 0.43
syntax = "proto3";
package cosmos.crypto.secp256r1;

import "gogoproto/gogo.proto";

option go_package = "github.com/cosmos/cosmos-sdk/crypto/keys/secp256r1";
option (gogoproto.messagename_all) = true;
option (gogoproto.goproto_stringer_all) = false;
option (gogoproto.goproto_getters_all) = false;

// PubKey defines a secp256r1 ECDSA public key.
message PubKey {
// Point on secp256r1 curve in a compressed representation as specified in section
// 4.3.6 of ANSI X9.62: https://webstore.ansi.org/standards/ascx9/ansix9621998
bytes key = 1 [(gogoproto.customtype) = "ecdsaPK"];
}

// PrivKey defines a secp256r1 ECDSA private key.
message PrivKey {
// secret number serialized using big-endian encoding
bytes secret = 1 [(gogoproto.customtype) = "ecdsaSK"];
}
106 changes: 106 additions & 0 deletions proto/vendor/cosmos/tx/signing/v1beta1/signing.proto
Original file line number Diff line number Diff line change
@@ -0,0 +1,106 @@
syntax = "proto3";
package cosmos.tx.signing.v1beta1;

import "cosmos/crypto/multisig/v1beta1/multisig.proto";
import "google/protobuf/any.proto";

option go_package = "github.com/cosmos/cosmos-sdk/types/tx/signing";

// SignMode represents a signing mode with its own security guarantees.
//
// This enum should be considered a registry of all known sign modes
// in the Cosmos ecosystem. Apps are not expected to support all known
// sign modes. Apps that would like to support custom sign modes are
// encouraged to open a small PR against this file to add a new case
// to this SignMode enum describing their sign mode so that different
// apps have a consistent version of this enum.
enum SignMode {
// SIGN_MODE_UNSPECIFIED specifies an unknown signing mode and will be
// rejected.
SIGN_MODE_UNSPECIFIED = 0;

// SIGN_MODE_DIRECT specifies a signing mode which uses SignDoc and is
// verified with raw bytes from Tx.
SIGN_MODE_DIRECT = 1;

// SIGN_MODE_TEXTUAL is a future signing mode that will verify some
// human-readable textual representation on top of the binary representation
// from SIGN_MODE_DIRECT. It is currently not supported.
SIGN_MODE_TEXTUAL = 2;

// SIGN_MODE_DIRECT_AUX specifies a signing mode which uses
// SignDocDirectAux. As opposed to SIGN_MODE_DIRECT, this sign mode does not
// require signers signing over other signers' `signer_info`. It also allows
// for adding Tips in transactions.
//
// Since: cosmos-sdk 0.46
SIGN_MODE_DIRECT_AUX = 3;

// SIGN_MODE_LEGACY_AMINO_JSON is a backwards compatibility mode which uses
// Amino JSON and will be removed in the future.
SIGN_MODE_LEGACY_AMINO_JSON = 127;

// SIGN_MODE_EIP_191 specifies the sign mode for EIP 191 signing on the Cosmos
// SDK. Ref: https://eips.ethereum.org/EIPS/eip-191
//
// Currently, SIGN_MODE_EIP_191 is registered as a SignMode enum variant,
// but is not implemented on the SDK by default. To enable EIP-191, you need
// to pass a custom `TxConfig` that has an implementation of
// `SignModeHandler` for EIP-191. The SDK may decide to fully support
// EIP-191 in the future.
//
// Since: cosmos-sdk 0.45.2
SIGN_MODE_EIP_191 = 191;
}

// SignatureDescriptors wraps multiple SignatureDescriptor's.
message SignatureDescriptors {
// signatures are the signature descriptors
repeated SignatureDescriptor signatures = 1;
}

// SignatureDescriptor is a convenience type which represents the full data for
// a signature including the public key of the signer, signing modes and the
// signature itself. It is primarily used for coordinating signatures between
// clients.
message SignatureDescriptor {
// public_key is the public key of the signer
google.protobuf.Any public_key = 1;

Data data = 2;

// sequence is the sequence of the account, which describes the
// number of committed transactions signed by a given address. It is used to prevent
// replay attacks.
uint64 sequence = 3;

// Data represents signature data
message Data {
// sum is the oneof that specifies whether this represents single or multi-signature data
oneof sum {
// single represents a single signer
Single single = 1;

// multi represents a multisig signer
Multi multi = 2;
}

// Single is the signature data for a single signer
message Single {
// mode is the signing mode of the single signer
SignMode mode = 1;

// signature is the raw signature bytes
bytes signature = 2;
}

// Multi is the signature data for a multisig public key
message Multi {
// bitarray specifies which keys within the multisig are signing
cosmos.crypto.multisig.v1beta1.CompactBitArray bitarray = 1;

// signatures is the signatures of the multi-signature
repeated Data signatures = 2;
}
}
}
Loading

0 comments on commit c48098c

Please sign in to comment.