Skip to content

Commit

Permalink
Add CI to validate proto compilation (#59)
Browse files Browse the repository at this point in the history
* add ci to validate proto compilation

* Setup CI and fixes to some .proto files (#61)

* add quotations on main branch name

* cr

* testing changes

* cleaning up and swaping to Noelware proto instead of installing

* test protoc version

* add missing syntax on capabilities.proto

* attempting to fix compilation errors

* adding Classes message to snapshot.proto

* experimental-codegen

* kernel

* temp file instead of /dev/null

* package transaction duplication

* disable java compilation

* remove package declaration

* install protoc-gen-go before compiling to go

* add option go_package specification

* clean up

* testing find *.proto

* find proto step

* compiling each file seperatly

* apply changes to all compilations

* clean comments

* add --fatal_warnings flag to error on warnings

* move state.proto back into sync dir

* fix CR comments
  • Loading branch information
AlonLStarkWare authored Dec 8, 2024
1 parent 40aef58 commit 3531126
Show file tree
Hide file tree
Showing 16 changed files with 108 additions and 3 deletions.
70 changes: 70 additions & 0 deletions .github/workflows/starknet_p2p_specs_ci.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,70 @@
name: Starknet-P2p-Specs-CI

on:
workflow_dispatch:
pull_request:
branches:
- '*'
types:
- opened
- reopened
- synchronize
- auto_merge_enabled
- edited

env:
PROTOC_VERSION: v25.1

jobs:
compile-protos:
runs-on: ubuntu-latest
steps:
- name: Checkout repo
uses: actions/checkout@v4

- uses: Noelware/[email protected]
with:
version: ${{env.PROTOC_VERSION}}

- name: Find .proto files
id: find-protos
run: |
proto_files=$(find . -name "*.proto")
if [ -z "$proto_files" ]; then
echo "No .proto files found."
exit 1
fi
echo "Found the following .proto files:"
echo "$proto_files"
# Save the list as an output
echo "proto_files=$(echo "$proto_files" | tr '\n' ' ')" >> $GITHUB_OUTPUT
- name: Validate Rust compatibility
run: |
for file in ${{ steps.find-protos.outputs.proto_files }}; do
echo "Compiling $file"
protoc --fatal_warnings --rust_out=experimental-codegen=enabled,kernel=upb:$(mktemp -d) $file
done
- name: Validate Python compatibility
run: |
for file in ${{ steps.find-protos.outputs.proto_files }}; do
echo "Compiling $file"
protoc --fatal_warnings --python_out=$(mktemp -d) $file
done
- name: Validate C++ compatibility
run: |
for file in ${{ steps.find-protos.outputs.proto_files }}; do
echo "Compiling $file"
protoc --fatal_warnings --cpp_out=$(mktemp -d) $file
done
- name: Validate GO compatibility
run: |
go install google.golang.org/protobuf/cmd/protoc-gen-go@latest
export PATH=$PATH:$(go env GOPATH)/bin
for file in ${{ steps.find-protos.outputs.proto_files }}; do
echo "Compiling $file"
protoc --fatal_warnings --go_out=$(mktemp -d) --go_opt=paths=source_relative $file
done
4 changes: 3 additions & 1 deletion p2p/proto/capabilities.proto
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
import "p2p/proto/common.proto";
syntax = "proto3";

option go_package = "github.com/starknet-io/starknet-p2pspecs/p2p/proto/capabilities";

// A capability for one of the following protocols:
// 1. /starknet/headers/
Expand Down
1 change: 1 addition & 0 deletions p2p/proto/class.proto
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
syntax = "proto3";
import "p2p/proto/common.proto";

option go_package = "github.com/starknet-io/starknet-p2pspecs/p2p/proto/class";

message EntryPoint {
Felt252 selector = 1;
Expand Down
2 changes: 2 additions & 0 deletions p2p/proto/common.proto
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
syntax = "proto3";

option go_package = "github.com/starknet-io/starknet-p2pspecs/p2p/proto/common";

message Felt252 {
bytes elements = 1;
}
Expand Down
2 changes: 2 additions & 0 deletions p2p/proto/consensus/consensus.proto
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,8 @@ syntax = "proto3";
import "p2p/proto/common.proto";
import "p2p/proto/transaction.proto";

option go_package = "github.com/starknet-io/starknet-p2pspecs/p2p/proto/consensus/consensus";

// WIP - will change

// Contains all variants of mempool and an L1Handler variant to cover all transactions that can be
Expand Down
2 changes: 2 additions & 0 deletions p2p/proto/discovery.proto
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,8 @@ syntax = "proto3";
import "p2p/proto/common.proto";
import "google/protobuf/descriptor.proto";

option go_package = "github.com/starknet-io/starknet-p2pspecs/p2p/proto/discovery";

extend google.protobuf.MessageOptions {
optional bytes powDifficulty = 1001;
}
Expand Down
3 changes: 2 additions & 1 deletion p2p/proto/mempool/transaction.proto
Original file line number Diff line number Diff line change
@@ -1,9 +1,10 @@
syntax = "proto3";

import "p2p/proto/class.proto";
import "p2p/proto/common.proto";
import "p2p/proto/transaction.proto";

option go_package = "github.com/starknet-io/starknet-p2pspecs/p2p/proto/mempool/transaction";

// Doesn't contain L1Handler, as those don't need to be propagated and can be downloaded from L1.
message MempoolTransaction {
oneof txn {
Expand Down
10 changes: 9 additions & 1 deletion p2p/proto/snapshot.proto
Original file line number Diff line number Diff line change
@@ -1,7 +1,10 @@
syntax = "proto3";

import "p2p/proto/common.proto";
import "p2p/proto/state.proto";
import "p2p/proto/sync/state.proto";
import "p2p/proto/class.proto";

option go_package = "github.com/starknet-io/starknet-p2pspecs/p2p/proto/snapshot";

message PatriciaNode {
message Edge {
Expand Down Expand Up @@ -59,6 +62,11 @@ message ContractRangeResponse {
}
}

message Classes {
uint32 domain = 1;
repeated Class classes = 2;
}

// duplicate of GetContractRange. Can introduce a 'type' instead.
// result is (Classes+, PatriciaRangeProof)*
message ClassRangeRequest {
Expand Down
2 changes: 2 additions & 0 deletions p2p/proto/sync/class.proto
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,8 @@ import "p2p/proto/class.proto";
import "p2p/proto/common.proto";
import "p2p/proto/sync/common.proto";

option go_package = "github.com/starknet-io/starknet-p2pspecs/p2p/proto/sync/class";

message ClassesRequest {
Iteration iteration = 1;
}
Expand Down
2 changes: 2 additions & 0 deletions p2p/proto/sync/common.proto
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
syntax = "proto3";
import "p2p/proto/common.proto";

option go_package = "github.com/starknet-io/starknet-p2pspecs/p2p/proto/sync/common";

message StateDiffCommitment {
uint64 state_diff_length = 1;
Hash root = 2;
Expand Down
2 changes: 2 additions & 0 deletions p2p/proto/sync/event.proto
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@ syntax = "proto3";
import "p2p/proto/common.proto";
import "p2p/proto/sync/common.proto";

option go_package = "github.com/starknet-io/starknet-p2pspecs/p2p/proto/sync/event";

message Event {
Hash transaction_hash = 1;
Felt252 from_address = 3;
Expand Down
2 changes: 2 additions & 0 deletions p2p/proto/sync/header.proto
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@ syntax = "proto3";
import "p2p/proto/common.proto";
import "p2p/proto/sync/common.proto";

option go_package = "github.com/starknet-io/starknet-p2pspecs/p2p/proto/sync/header";

// Note: commitments may change to be for the previous blocks like comet/tendermint
// hash of block header sent to L1
message SignedBlockHeader {
Expand Down
2 changes: 2 additions & 0 deletions p2p/proto/sync/receipt.proto
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
syntax = "proto3";
import "p2p/proto/common.proto";

option go_package = "github.com/starknet-io/starknet-p2pspecs/p2p/proto/sync/receipt";

message MessageToL1 {
Felt252 from_address = 2;
repeated Felt252 payload = 3;
Expand Down
2 changes: 2 additions & 0 deletions p2p/proto/sync/state.proto
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@ syntax = "proto3";
import "p2p/proto/common.proto";
import "p2p/proto/sync/common.proto";

option go_package = "github.com/starknet-io/starknet-p2pspecs/p2p/proto/sync/state";


// optimized for flat storage, not through a trie (not sharing key prefixes)
message ContractStoredValue {
Expand Down
2 changes: 2 additions & 0 deletions p2p/proto/sync/transaction.proto
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,8 @@ import "p2p/proto/sync/common.proto";
import "p2p/proto/sync/receipt.proto";
import "p2p/proto/transaction.proto";

option go_package = "github.com/starknet-io/starknet-p2pspecs/p2p/proto/sync/transaction";

// TBD: can support a flag to return tx hashes only, good for standalone mempool to remove them,
// or any node that keeps track of transaction streaming in the consensus.
message TransactionsRequest {
Expand Down
3 changes: 3 additions & 0 deletions p2p/proto/transaction.proto
Original file line number Diff line number Diff line change
@@ -1,5 +1,8 @@
syntax = "proto3";
import "p2p/proto/common.proto";
import "p2p/proto/class.proto";

option go_package = "github.com/starknet-io/starknet-p2pspecs/p2p/proto/transaction";

message ResourceLimits {
Felt252 max_amount = 1;
Expand Down

0 comments on commit 3531126

Please sign in to comment.