diff --git a/.github/workflows/starknet_p2p_specs_ci.yml b/.github/workflows/starknet_p2p_specs_ci.yml new file mode 100644 index 0000000..11a7618 --- /dev/null +++ b/.github/workflows/starknet_p2p_specs_ci.yml @@ -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/setup-protoc@1.1.0 + 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 diff --git a/p2p/proto/capabilities.proto b/p2p/proto/capabilities.proto index 50b39ec..caa8e41 100644 --- a/p2p/proto/capabilities.proto +++ b/p2p/proto/capabilities.proto @@ -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/ diff --git a/p2p/proto/class.proto b/p2p/proto/class.proto index f63a0b4..4fc1be5 100644 --- a/p2p/proto/class.proto +++ b/p2p/proto/class.proto @@ -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; diff --git a/p2p/proto/common.proto b/p2p/proto/common.proto index d6c2d34..b8fdf7c 100644 --- a/p2p/proto/common.proto +++ b/p2p/proto/common.proto @@ -1,5 +1,7 @@ syntax = "proto3"; +option go_package = "github.com/starknet-io/starknet-p2pspecs/p2p/proto/common"; + message Felt252 { bytes elements = 1; } diff --git a/p2p/proto/consensus/consensus.proto b/p2p/proto/consensus/consensus.proto index b7e996a..4e894bf 100644 --- a/p2p/proto/consensus/consensus.proto +++ b/p2p/proto/consensus/consensus.proto @@ -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 diff --git a/p2p/proto/discovery.proto b/p2p/proto/discovery.proto index 2210765..d7b3a98 100644 --- a/p2p/proto/discovery.proto +++ b/p2p/proto/discovery.proto @@ -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; } diff --git a/p2p/proto/mempool/transaction.proto b/p2p/proto/mempool/transaction.proto index 4d23295..f1dc0b2 100644 --- a/p2p/proto/mempool/transaction.proto +++ b/p2p/proto/mempool/transaction.proto @@ -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 { diff --git a/p2p/proto/snapshot.proto b/p2p/proto/snapshot.proto index a4f1863..d812ac4 100644 --- a/p2p/proto/snapshot.proto +++ b/p2p/proto/snapshot.proto @@ -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 { @@ -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 { diff --git a/p2p/proto/sync/class.proto b/p2p/proto/sync/class.proto index 12e285e..dbbdc43 100644 --- a/p2p/proto/sync/class.proto +++ b/p2p/proto/sync/class.proto @@ -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; } diff --git a/p2p/proto/sync/common.proto b/p2p/proto/sync/common.proto index df392d4..2155e30 100644 --- a/p2p/proto/sync/common.proto +++ b/p2p/proto/sync/common.proto @@ -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; diff --git a/p2p/proto/sync/event.proto b/p2p/proto/sync/event.proto index 2037184..fb93811 100644 --- a/p2p/proto/sync/event.proto +++ b/p2p/proto/sync/event.proto @@ -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; diff --git a/p2p/proto/sync/header.proto b/p2p/proto/sync/header.proto index d6c9834..4e63696 100644 --- a/p2p/proto/sync/header.proto +++ b/p2p/proto/sync/header.proto @@ -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 { diff --git a/p2p/proto/sync/receipt.proto b/p2p/proto/sync/receipt.proto index 025888d..239a29b 100644 --- a/p2p/proto/sync/receipt.proto +++ b/p2p/proto/sync/receipt.proto @@ -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; diff --git a/p2p/proto/sync/state.proto b/p2p/proto/sync/state.proto index b097765..9eb14e2 100644 --- a/p2p/proto/sync/state.proto +++ b/p2p/proto/sync/state.proto @@ -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 { diff --git a/p2p/proto/sync/transaction.proto b/p2p/proto/sync/transaction.proto index 4c070ef..7567c76 100644 --- a/p2p/proto/sync/transaction.proto +++ b/p2p/proto/sync/transaction.proto @@ -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 { diff --git a/p2p/proto/transaction.proto b/p2p/proto/transaction.proto index dcb45ba..5143a5c 100644 --- a/p2p/proto/transaction.proto +++ b/p2p/proto/transaction.proto @@ -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;