Skip to content

Commit

Permalink
Protobuf definition for Optimint types (cosmos#73)
Browse files Browse the repository at this point in the history
Protobuf definition for Optimint types
  • Loading branch information
tzdybal authored Jun 7, 2021
1 parent 753bba0 commit 3bd96a4
Show file tree
Hide file tree
Showing 5 changed files with 1,807 additions and 0 deletions.
1 change: 1 addition & 0 deletions go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ require (
github.com/dgraph-io/badger/v3 v3.2011.1
github.com/go-kit/kit v0.10.0
github.com/gogo/protobuf v1.3.2
github.com/golang/protobuf v1.4.3
github.com/ipfs/go-log v1.0.4
github.com/lazyledger/lazyledger-core v0.0.0-20210219190522-0eccfb24e2aa
github.com/libp2p/go-libp2p v0.13.0
Expand Down
7 changes: 7 additions & 0 deletions proto/gen.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
#!/usr/bin/env bash

# see: https://stackoverflow.com/a/246128
SCRIPT_DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" &> /dev/null && pwd )"

cd $SCRIPT_DIR
protoc -I=. -I=$GOPATH/src -I=$GOPATH/src/github.com/gogo/protobuf --gofast_out=../types/pb/optimint optimint.proto
73 changes: 73 additions & 0 deletions proto/optimint.proto
Original file line number Diff line number Diff line change
@@ -0,0 +1,73 @@
syntax = "proto3";
package optimint;

// option go_package = "github.com/lazyledger/optimint/proto";
import "tendermint/abci/types.proto";

// Version captures the consensus rules for processing a block in the blockchain,
// including all blockchain data structures and the rules of the application's
// state transition machine.
// This is equivalent to the tmversion.Consensus type in Tendermint.
message Version {
uint32 block = 1;
uint32 app = 2;
}

message Header {
// Block and App version
Version version = 1;
// NamespaceID identifies this chain e.g. when connected to other rollups via IBC.
bytes namespace_id = 2;

// Block height
uint64 height = 3;

// Block creation time
uint64 time = 4;

// Previous block info
bytes last_header_hash = 5;

// Commit from aggregator(s) from the last block
bytes last_commit_hash = 6;

// Block.Data root aka Transactions
bytes data_hash = 7;

// Consensus params for current block
bytes consensus_hash = 8;

// State after applying txs from the current block
bytes app_hash = 9;

// Root hash of all results from the txs from the previous block.
// This is ABCI specific but smart-contract chains require some way of committing
// to transaction receipts/results.
bytes last_results_hash = 10;

// Original proposer of the block
// Note that the address can be derived from the pubkey which can be derived
// from the signature when using secp256k.
// We keep this in case users choose another signature format where the
// pubkey can't be recovered by the signature (e.g. ed25519).
bytes proposer_address = 11;
}

message Commit {
uint64 height = 1;
bytes hader_hash = 2;
// Note: most of the time this will be a single sinature
repeated bytes signatures = 3;
}

message Data {
repeated bytes txs = 1;
repeated bytes intermediate_state_roots = 2;
repeated tendermint.abci.Evidence evidence = 3;
}

message Block {
Header header = 1;
Data data = 2;
Commit last_commit = 3;
}
44 changes: 44 additions & 0 deletions proto/tendermint/abci/types.proto
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
syntax = "proto3";
package tendermint.abci;

option go_package = "github.com/lazyledger/lazyledger-core/abci/types";

// For more information on gogo.proto, see:
// https://github.com/gogo/protobuf/blob/master/extensions.md
import "google/protobuf/timestamp.proto";
import "gogoproto/gogo.proto";

// This file is copied from http://github.com/tendermint/abci
// NOTE: When using custom types, mind the warnings.
// https://github.com/gogo/protobuf/blob/master/custom_types.md#warnings-and-issues

// Validator
message Validator {
bytes address = 1; // The first 20 bytes of SHA256(public key)
// PubKey pub_key = 2 [(gogoproto.nullable)=false];
int64 power = 3; // The voting power
}

enum EvidenceType {
UNKNOWN = 0;
DUPLICATE_VOTE = 1;
LIGHT_CLIENT_ATTACK = 2;
}

message Evidence {
EvidenceType type = 1;
// The offending validator
Validator validator = 2 [(gogoproto.nullable) = false];
// The height when the offense occurred
int64 height = 3;
// The corresponding time where the offense occurred
google.protobuf.Timestamp time = 4 [
(gogoproto.nullable) = false,
(gogoproto.stdtime) = true
];
// Total voting power of the validator set in case the ABCI application does
// not store historical validators.
// https://github.com/tendermint/tendermint/issues/4581
int64 total_voting_power = 5;
}

Loading

0 comments on commit 3bd96a4

Please sign in to comment.