diff --git a/go.mod b/go.mod index 3d561be59..9f67e281e 100644 --- a/go.mod +++ b/go.mod @@ -66,7 +66,8 @@ require ( github.com/golang/protobuf v1.5.3 // indirect github.com/google/gopacket v1.1.19 // indirect github.com/google/pprof v0.0.0-20230602150820-91b7bce49751 // indirect - github.com/gorilla/websocket v1.5.0 // indirect + github.com/google/uuid v1.4.0 // indirect + github.com/gorilla/websocket v1.5.1 // indirect github.com/huin/goupnp v1.2.0 // indirect github.com/inconshreveable/mousetrap v1.0.0 // indirect github.com/ipfs/go-log/v2 v2.5.1 // indirect @@ -94,6 +95,7 @@ require ( github.com/mikioh/tcpinfo v0.0.0-20190314235526-30a79bb1804b // indirect github.com/mikioh/tcpopt v0.0.0-20190314235656-172688c1accc // indirect github.com/minio/sha256-simd v1.0.1 // indirect + github.com/mitchellh/hashstructure v1.1.0 // indirect github.com/mr-tron/base58 v1.2.0 // indirect github.com/multiformats/go-base32 v0.1.0 // indirect github.com/multiformats/go-base36 v0.2.0 // indirect @@ -118,6 +120,7 @@ require ( github.com/quic-go/quic-go v0.33.0 // indirect github.com/quic-go/webtransport-go v0.5.3 // indirect github.com/raulk/go-watchdog v1.3.0 // indirect + github.com/rs/cors v1.10.1 // indirect github.com/spaolacci/murmur3 v1.1.0 // indirect github.com/spf13/pflag v1.0.5 // indirect github.com/stretchr/objx v0.5.0 // indirect diff --git a/go.sum b/go.sum index 78ce51628..b5ba08aa5 100644 --- a/go.sum +++ b/go.sum @@ -139,12 +139,16 @@ github.com/google/martian v2.1.0+incompatible/go.mod h1:9I4somxYTbIHy5NJKHRl3wXi github.com/google/pprof v0.0.0-20181206194817-3ea8567a2e57/go.mod h1:zfwlbNMJ+OItoe0UupaVj+oy1omPYYDuagoSzA8v9mc= github.com/google/pprof v0.0.0-20230602150820-91b7bce49751 h1:hR7/MlvK23p6+lIw9SN1TigNLn9ZnF3W4SYRKq2gAHs= github.com/google/pprof v0.0.0-20230602150820-91b7bce49751/go.mod h1:Jh3hGz2jkYak8qXPD19ryItVnUgpgeqzdkY/D0EaeuA= +github.com/google/uuid v1.4.0 h1:MtMxsa51/r9yyhkyLsVeVt0B+BGQZzpQiTQ4eHZ8bc4= +github.com/google/uuid v1.4.0/go.mod h1:TIyPZe4MgqvfeYDBFedMoGGpEw/LqOeaOT+nhxU+yHo= github.com/googleapis/gax-go v2.0.0+incompatible/go.mod h1:SFVmujtThgffbyetf+mdk2eWhX2bMyUtNHzFKcPA9HY= github.com/googleapis/gax-go/v2 v2.0.3/go.mod h1:LLvjysVCY1JZeum8Z6l8qUty8fiNwE08qbEPm1M08qg= github.com/gopherjs/gopherjs v0.0.0-20181017120253-0766667cb4d1/go.mod h1:wJfORRmW1u3UXTncJ5qlYoELFm8eSnnEO6hX4iZ3EWY= github.com/gorilla/websocket v1.4.1/go.mod h1:YR8l580nyteQvAITg2hZ9XVh4b55+EU/adAjf1fMHhE= github.com/gorilla/websocket v1.5.0 h1:PPwGk2jz7EePpoHN/+ClbZu8SPxiqlu12wZP/3sWmnc= github.com/gorilla/websocket v1.5.0/go.mod h1:YR8l580nyteQvAITg2hZ9XVh4b55+EU/adAjf1fMHhE= +github.com/gorilla/websocket v1.5.1 h1:gmztn0JnHVt9JZquRuzLw3g4wouNVzKL15iLr/zn/QY= +github.com/gorilla/websocket v1.5.1/go.mod h1:x3kM2JMyaluk02fnUJpQuwD2dCS5NDG2ZHL0uE0tcaY= github.com/gregjones/httpcache v0.0.0-20180305231024-9cad4c3443a7/go.mod h1:FecbI9+v66THATjSRHfNgh1IVFe/9kFxbXtjV0ctIMA= github.com/grpc-ecosystem/grpc-gateway v1.5.0/go.mod h1:RSKVYQBd5MCa4OVpNdGskqpgL2+G+NZTnrVHpWWfpdw= github.com/hinshun/vt10x v0.0.0-20180616224451-1954e6464174 h1:WlZsjVhE8Af9IcZDGgJGQpNflI3+MJSBhsgT5PCtzBQ= @@ -252,6 +256,8 @@ github.com/minio/blake2b-simd v0.0.0-20160723061019-3f5f724cb5b1/go.mod h1:pD8Rv github.com/minio/sha256-simd v0.1.1-0.20190913151208-6de447530771/go.mod h1:B5e1o+1/KgNmWrSQK08Y6Z1Vb5pwIktudl0J58iy0KM= github.com/minio/sha256-simd v1.0.1 h1:6kaan5IFmwTNynnKKpDHe6FWHohJOHhCPchzK49dzMM= github.com/minio/sha256-simd v1.0.1/go.mod h1:Pz6AKMiUdngCLpeTL/RJY1M9rUuPMYujV5xJjtbRSN8= +github.com/mitchellh/hashstructure v1.1.0 h1:P6P1hdjqAAknpY/M1CGipelZgp+4y9ja9kmUZPXP+H0= +github.com/mitchellh/hashstructure v1.1.0/go.mod h1:xUDAozZz0Wmdiufv0uyhnHkUTN6/6d8ulp4AwfLKrmA= github.com/modern-go/concurrent v0.0.0-20180228061459-e0a39a4cb421/go.mod h1:6dJC0mAP4ikYIbvyc7fijjWJddQyLn8Ig3JB5CqoB9Q= github.com/modern-go/concurrent v0.0.0-20180306012644-bacd9c7ef1dd h1:TRLaZ9cD/w8PVh93nsPXa1VrQ6jlwL5oN8l14QlcNfg= github.com/modern-go/concurrent v0.0.0-20180306012644-bacd9c7ef1dd/go.mod h1:6dJC0mAP4ikYIbvyc7fijjWJddQyLn8Ig3JB5CqoB9Q= @@ -340,6 +346,8 @@ github.com/raulk/go-watchdog v1.3.0 h1:oUmdlHxdkXRJlwfG0O9omj8ukerm8MEQavSiDTEtB github.com/raulk/go-watchdog v1.3.0/go.mod h1:fIvOnLbF0b0ZwkB9YU4mOW9Did//4vPZtDqv66NfsMU= github.com/reactivex/rxgo/v2 v2.5.0 h1:FhPgHwX9vKdNQB2gq9EPt+EKk9QrrzoeztGbEEnZam4= github.com/reactivex/rxgo/v2 v2.5.0/go.mod h1:bs4fVZxcb5ZckLIOeIeVH942yunJLWDABWGbrHAW+qU= +github.com/rs/cors v1.10.1 h1:L0uuZVXIKlI1SShY2nhFfo44TYvDPQ1w4oFkUJNfhyo= +github.com/rs/cors v1.10.1/go.mod h1:XyqrcTp5zjWr1wsJ8PIRZssZ8b/WMcMf71DJnit4EMU= github.com/russross/blackfriday v1.5.2/go.mod h1:JO/DiYxRf+HjHt06OyowR9PTA263kcR/rfWxYHBV53g= github.com/russross/blackfriday/v2 v2.0.1/go.mod h1:+Rmxgy9KzJVeS9/2gXHxylqXiyQDYRxCVz55jmeOWTM= github.com/russross/blackfriday/v2 v2.1.0/go.mod h1:+Rmxgy9KzJVeS9/2gXHxylqXiyQDYRxCVz55jmeOWTM= diff --git a/pkg/blockchain/README.md b/pkg/blockchain/README.md new file mode 100644 index 000000000..d182c9204 --- /dev/null +++ b/pkg/blockchain/README.md @@ -0,0 +1,457 @@ +# Blockchain System + +This "Blockchain System" is a modular implementation of a longest-chain consensus protocol modeling proof-of-work. + +The goal of this system is to provide a simple modular blockchain run on a fixed set of nodes. + +It provides the core elements with only the actual business logic to be implemented by an application module. + +> #### Important +> +> This system is only intended for **demonstration purposes**. + +## Overview + +We will first outline the different parts that make up the system. +How these elements interact with each other will be described in [Operation](#operation) and a more detailed description of every element can be found in [Modules](#modules). + +Each node has a set of core modules running the blockchain and an application module that runs the business logic and provides certain functionality to the core modules. + +The blocks making up the blockchain contain the following: + +- **block id:** Identifier of a block, computed by hashing the block with the block id set to 0. +- **previous block id:** Identifier of the predecessor block. +- **payload:** An application dependant payload. +- **timestamp:** Timestamp of when the block was mined. +- **miner id:** Identifier of the node that mined the block. + +Every node keeps track of all nodes that it knows of. +At the very beginning, this is solely the genesis block. +After a couple of blocks have been mined, all nodes together form a tree of blocks. +Whichever leaf of this tree is the deepest is called the head, and the chain of blocks from the genesis block to this leaf is the canonical chain. +The payloads of all the blocks in the canonical chain together define the current state stored in the blockchain. + +```mermaid +flowchart LR; + +subgraph Longest Chain Consensus +BCM[Blockchain Management \n Module] +Miner[Miner \n Module] +Synchronizer[Synchronizer \n Module] +Transport[gRPC Transport \n Module] +Broadcast[Broadcast \n Module] + +end + +Application[Application \n Module] + + +Broadcast <--> Transport + +Miner <--> Application +Miner <--> Broadcast + +BCM <--> Miner +BCM <--> Application +BCM <--> Synchronizer + +Synchronizer <--> Transport +``` + +The nodes consist of the following core modules: + +- **Blockchain Management Module (BCM):** + It forms the core of the system and is responsible for managing the blockchain. + +- **Miner Module:** + Mines new blocks by simulating proof-of-work. + +- **Synchronizer Module:** + Resolves issues when new blocks are to be added to the blockchain, but their parent blocks are unknown to this node's BCM. + +- **Broadcast Module:** + Broadcasts newly mined blocks to all other nodes. + It can also simulate network delay and dropped messages. + +and the following supporting modules (provided by mir): + +- **gRPC Transport Module:** + Used for communication between nodes. + +- **Event Mangler Module:** + Used by the broadcast module to simulate network delay and dropped messages. + +- **Timer Module:** + Used by the Miner to simulate proof-of-work. + +Lastly, a user-implemented **Application Module** handles all business logic. +In particular, it needs to compute the state of the blockchain, verify payloads, and provide payloads to the miner. + +Next to the modules, it also includes an interceptor that intercepts all communication between different modules and allows for visualization/debugging tools to consume this communication via a websocket connection. +An example of how to use the information provided by the interception can be found [here](https://github.com/komplexon3/longest-chain-project/tree/main/chain-visualizer). + +(Note that the event mangler module and the timer module were omitted from the diagram above for simplicity.) + +## Operation + +We will now walk through how the different modules interact with each other. +At the start, the application module must initialize the BCM by sending it an _InitBlockchain_ event, which contains the initial state. +The BCM creates a genesis block with an empty payload and stores it together with the initial state. +It then instructs the miner module to start mining via a _NewHead_ event. +To start mining, the miner module requests a payload (_PayloadRequest_) from the application module. +The miner now starts to mine, and the initialization sequence of the node is completed. + +After this, the node will remain inactive (other than mining a block) until a new block has been mined. +This block was either mined by this node's miner or by another node's miner. +In the first case, the miner would send the new block to its BCM and broadcast the block to all other nodes via the broadcast module (_NewBlock_ event). +In the second case, the broadcast module would have received the block from the other node's broadcast module and sent it to the BCM as a _NewBlock_ event. + +The BCM will then check whether or not it can connect this block to its tree of blocks. +If it cannot connect the block, we call it an orphan block. +Such cases can occur if the block's parent was mined by another node and the broadcast message for this block has not (yet) reached this node. +The BCM will try to resolve these problems with the help of the synchronizer, which will coordinate with other nodes to get the missing blocks. +This procedure will be described in more detail below. + +The BCM now potentially has multiple blocks to add, which are the new block and possibly a chain of additional blocks from the synchronizer. +The blocks are not trusted by the BCM as they might have been mined by another node and must, therefore, be verified. +This happens in two ways: + +1. The BCM sends all the blocks together with some additional information to the application module (_VerifyChainRequest_). + The application then verifies that the payloads are valid. + This logic is application-specific. +2. The BCM verifies that the nodes link together correctly. + +The BCM can now add all new blocks to the block tree. +If the canonical chain changes, i.e., there is a new head, it instructs the miner to start mining on the new head (_NewHead_ event). +Also, it informs the application about the new head (_HeadChange_ event). +This event contains some additional information about how the canonical chain changes. +For example, if a different branch of the tree is now the canonical chain, it also includes which blocks are no longer part of the canonical chain. +This allows for the application to resubmit these payloads if desired. +In any case, the application will compute the state corresponding to the new head and register it in the BCM (_RegisterCheckpoint_). + +**Note**: In the sequence diagrams, the boxes with a dotted outline have a different meaning depending on the label in the top left corner: + +- loop: The sequence in the box repeats indefinitely or until the condition in the brackets holds. +- alt: The two boxes making up this box describe two alternative sequences. +- opt: The sequence in the box is optional. + It is performed if the condition in the boxes holds. +- par: The two boxes making up this box describe two sequences that are performed in parallel. + +```mermaid +sequenceDiagram + Application ->> BCM: InitBlockchain + + BCM ->> Miner: NewHead + Miner ->> Application: PayloadRequest + Application ->> Miner: PayloadResponse + Note over Miner: Start mining + + loop + alt receiving new block from another node + Broadcast ->> BCM: NewBlock + else this node's miner mined a new block + Miner ->> Broadcast: NewBlock + Miner ->> BCM: NewBlock + end + + Note over BCM: Check that the block can be connected to the block tree + opt if it cannot the block to the blocktree + BCM ->> Synchronizer: SyncRequest + Note over Synchronizer: Get missing blocks from other nodes, details omitted + Synchronizer ->> BCM: NewChain + end + BCM ->> Application: VerifyChainRequest + Note over Application: Verify that payloads are valid + Application ->> BCM: VerifyChainRespose + Note over BCM: Add blocks of chain to block tree, verify that they link together + + opt if head changes + par + BCM ->> Miner: NewHead + Note over Miner: Abort current mining operation, prepare to mine on new head + Miner ->> Application: PayloadRequest + Application ->> Miner: PayloadResponse + Note over Miner: Start mining on new head + and + BCM ->> Application: HeadChange + Note over Application: Compute state for new head + Application ->> BCM: RegisterCheckpoint + end + end + end +``` + +The functionality of the synchronizer was already outlined above. +This part will go into more detail on how the synchronizer resolves orphan blocks. +Every _SyncRequest_ from the BCM contains the id of the orphan block and a collection of id of the block that the BCM has in its tree. +With this information, the synchronizer asks one node after another to give it a chain that connects the orphan block to one of the known blocks (_ChainRequest_). +The other nodes' synchronizers then query their BCM via a _GetChainRequest_ for such a segment and forward the answer back to the initiator's synchronizer. +The responses can be unsuccessful. +In that case, the synchronizer asks the next node. +When a successful response is received, the synchronizer instructs the BCM to add the new chain to the block tree (_NewChain_ event). + +```mermaid +sequenceDiagram + +box Initiator Node +participant BCM (I) +participant Synchronizer (I) +end + +box Other Node(s) +participant Synchronizer +participant BCM +end + +Note over BCM (I): Cannot connect block +BCM (I) ->> Synchronizer (I): SyncRequest + +loop: until successful, one node at a time +Synchronizer (I) ->> Synchronizer: ChainRequest +Synchronizer ->> BCM: GetChainRequest +BCM ->> Synchronizer: GetChainResponse (successful/unsuccessful) +Synchronizer ->> Synchronizer (I): ChainResponse (successful/unsuccessful) +end +Synchronizer (I) ->> BCM (I): NewChain +``` + +At any point in time, the application can get the current state at the head of the blockchain by sending a _GetChainToHeadRequest_ to the BCM. +The response to this will include a chain of blocks from a checkpoint to the current head and the state associated with the checkpoint. +Using this information, the application can compute the current state. + +```mermaid +sequenceDiagram +Application ->> BCM: GetChainToHeadRequest +Note over BCM: Compute shortest chain from any checkpoint to the head +BCM ->> Application: GetChainToHeadResponse +Note over Application: Compute state from checkpoint state and chain to head +``` + +## Modules + +After outlining the modules that make up a node and describing how they interact, the following will describe the modules' functionality in a bit more detail. + +### Blockchain Management Module (BCM) + +The blockchain manager module is responsible for managing the blockchain. +It keeps track of all blocks and links them together to form a tree. +In particular, it keeps track of the genesis block, the head of the blockchain, all leaves, and so-called checkpoints. +A checkpoint is a block stored by the BCM that has a state stored with it. +Technically, checkpoints are not necessary as the state can be computed from the blocks. +However, it is convenient not to have to recompute the state from the genesis block every time it is needed. + +The BCM must perform the following tasks: + +1. Initialize the blockchain by receiving an _InitBlockchain_ event from the application module, which contains the initial state that is associated with the genesis block. +2. Add new blocks to the blockchain. If a block with a parent that is not in the blockchain is added, the BCM requests the missing block from the synchronizer. + Blocks that are missing their parent are called orphans. + All blocks added to the blockchain are verified in two steps: + + - It has the application module verify that the payloads are valid given the chain that the block is part of. + - The BCM must verify that the blocks link together correctly. + + Additionally, it emits a _TreeUpdate_ event. This is solely for debugging/visualization purposes and is not necessary for the operation of the blockchain. + +3. Register checkpoints when receiving a _RegisterCheckpoint_ event from the application module. +4. Provide the synchronizer with chains when requested. This is to resolve orphan blocks in other nodes. +5. When the head changes, it sends a _HeadChange_ event to the application module. + This event contains all information necessary for the application to compute the state at the new head as well as information about which payloads are now part of the canonical (i.e., longest) and which ones are no longer part of the canonical chain. + Also, it instructs the miner to start mining on the new head (_NewHead_ event). +6. Provide a chain of blocks from a checkpoint to the current head and the state associated with the checkpoint when receiving a _GetChainToHeadRequest_. + This is used by the application to query the current state. + +### Miner Module + +The miner module is responsible for mining new blocks. +It simulates the process of mining a block by waiting for a random amount of time and then broadcasting the mined block. +This random amount of time is sampled from an exponential distribution with a mean of `expMinuteFactor` minutes. +The mining is orchestrated by a separate goroutine (`mineWorkerManager`) such that the miner module can continue to receive and process events. + +The operation of the miner module is as follows: + +1. When it is notified of a new head (_NewHead_ event), it prepares to mine the next block by sending a _PayloadRequest_ event to the application module. + If it is already mining a block, it aborts the ongoing mining operation. +2. When it receives the _PayloadResponse_ containing a payload for the next block, it starts mining a new block with the received payload. +3. When it mines a new block, it broadcasts it to all other modules by sending a _NewBlock_ message to the broadcast module. + It also shares the block with the blockchain manager module (BCM) by sending a _NewBlock_ event to it. + +### Broadcast Module + +The broadcast module is responsible for broadcasting new blocks to all other nodes. +It either does this directly via the transport module or the mangler (parameter mangle). +If the mangler is used, messages might be dropped and delayed. +How many messages should be dropped can be configured by the parameter `dropRate` and the delay can be configured by the parameters `minDelay` and `maxDelay`. + +### Synchronizer Module + +The synchronizer module assists the blockchain manager (BCM) in resolving cases when BCM receives an orphan block. +An orphan block is a block that cannot be linked to the blockchain because the blockchain does not contain the block that the orphan block is linked to. +To do this, the synchronizer module communicates with other nodes to get the missing blocks. + +Terminology: + +- internal sync request: a request to synchronize a chain segment that was initiated by this node +- external sync request: a request to synchronize a chain segment that was initiated by another node + +The synchronizer module performs the following tasks: + +For internal sync requests: + +1. When it receives a _SyncRequest_ event, it must register the request and send a _ChainRequest_ message to one of the another nodes. +2. When it receives a successful _ChainResponse_ message, it sends the blockchain manager (BCM) the chain fixing the missing bit with a _NewChain_ event. + It then deletes the request. +3. When it receives an unsuccessful _ChainResponse_ message, it sends a _ChainRequest_ message to the next node. + If there are no more nodes to ask, it deletes the request. + +For external sync requests: + +1. When it receives a _ChainRequest_ message, it must register the request and send a _GetChainRequest_ event to the BCM. +2. When the BCM responds with a _GetChainResponse_ event, the synchronizer responds to the node that sent the _ChainRequest_ message with a _ChainResponse_ message. + +**IMPORTANT:** +This module assumes that all other nodes respond to requests. +For this reason, the messages sent from the synchronizer do not go through the mangler. + +### Application Module + +The application module is responsible for performing the actual application logic and interacting with users. +It does not hold any persistent state but instead relies on the blockchain manager module (BCM) to store the state. +However, the application is responsible for computing the state given a chain of blocks and a state associated with the first block in the chain. +Also, the application module manages payloads and must provide payloads for new blocks to the miner. + +The application module must perform the following tasks: + +1. Initialize the blockchain by sending the initial state to the BCM in an _InitBlockchain_ event. +2. When it receives a _PayloadRequest_ event, it must provide a payload for the next block. + Even if no payloads are available, a payload must be provided; however, this payload can be empty. +3. When it receives a _HeadChange_ event, it must compute the state at the new head of the blockchain. + This state is then registered with the BCM by sending it a _RegisterCheckpoint_ event. + A checkpoint is a block stored by the BCM that has a state stored with it. +4. When it receives a _VerifyBlocksRequest_ event, it must verify that the given chain is valid at an application level and respond with a _VerifyBlocksResponse_ event. + Whether or not the blocks link together correctly is verified by the BCM. + +An example of such an application is the [Blockchain Chat App](../../samples/blockchain-chat/) that is in the samples directory. +As the name implies, it implements a simple chat application. + +### Websocket Interceptor + +The websocket interceptor intercepts all events and sends them to a websocket server. +Any connected client can then receive these events by subscribing to the websocket server. +The interceptor proto file defines events that are specifically intended for the interceptor and not used by the actual blockchain. +Since these events technically don't have a destination module, they are sent to the "null" module (a module that simply ignores all incoming events). +However, all events are intercepted and sent to the websocket server. +The interceptor proto is simply for "extra" events. + +For this implementation, there are two such dedicated events: + +- _TreeUpdate_: This event is sent by the blockchain manager (BCM) when the blockchain is updated. + It contains all blocks in the blockchain and the id of the new head. +- _StateUpdate_: This event is sent by the application when it computes the state for the newest head of the blockchain. + +**Important note:** +This is a very simple implementation and it fails to properly handle connections which causes a crash when subscribers disconnect. + +## How to use the system + +To use the blockchain system, you must first define your application's state and payloads in `statepb.proto` and `payloadpb.proto` files. + +Next, you must implement an application module that performs the following actions: + +1. Initialize the blockchain by sending an initial state as an _InitBlockchain_ event to the BCM. +2. When it receives a _PayloadRequest_ event, it must provide a payload for the next block. + Even if no payloads are available, a payload **must** be provided. + However, this payload can be empty. +3. When it receives a _HeadChange_ event, it must compute the state at the new head of the blockchain. + This state must then be registered with the BCM by sending it a _RegisterCheckpoint_ event. + Additionally, the information provided in the _HeadChange_ event might be useful for payload management. +4. When it receives a _VerifyBlocksRequest_ event, it must verify that the given chain is valid at an application level and respond with a _VerifyBlocksResponse_ event. + +See the example blockchain chat app as a reference. + +You can now set up all the modules using `system.New(...)` where you can configure the system and provide it with your application module. +For the node initialization, you can get all modules of the system by calling `system.Modules()`. + +## Example: Blockchain Chat App + +An example of how to use the longest-chain consensus system is the [Blockchain Chat App](../../samples/blockchain-chat/). +Users can enter input through standard input line by line and the system replicates all messages in the same order across all nodes. +It enforces that all messages sent from the same sender appear in the history in a monotonically increasing order of submission time. + +### Specification of the Chat App + +The following lists the key specifications of the chat app: + +- **Payload:** + The payloads consist of a message, the sender id (id of the node from which the message was sent) and a submission ("sent") timestamp. + +- **State:** + The state consists of the message history and a collection of "last sent" timestamps, one for each sender, where the timestamp corresponds to the submission time of the last message of this sender. + +- **Applying blocks to compute state:** + When applying a block to a state, the message in the payload is appended to the message history and the "last sent" timestamp corresponding to the sender is updated. + +- **Verifying blocks:** + To verify a block, the application verifies that the "sent" timestamp of the payload is not before the "last sent" timestamp of the sender stored in the state associated with the block's parent block. + +- **Providing payloads:** + Each node's application keeps track of all messages that were submitted to it. + Additionally, if a fork happens and the branch changes, it re-adds payloads that were previously part of the old canonical chain to its payload pool and removes the ones that are now part of the canonical chain. + If no payloads are available, it simply provides an empty payload. + +### Running the chat app + +> All commands listed here are intended to be run in [this directory](../../samples/blockchain-chat/). + +To run the chat app, you can run the following in multiple terminals, once for each node + +``` +go run . -numberOfNodes -nodeID +``` + +Further, you can add the following options to modify the characteristics of the system(s). +If they are not set, default values will be used + +- **-disableMangle:** + Disables all mangling of the messages between the nodes. +- **-dropRate:** The rate at which to drop messages between nodes. (Ignored if _disableMangle_ is set.) +- **-minDelay:** The minimum delay by which to delay messages between nodes. (Ignored if _disableMangle_ is set.) +- **-maxDelay:** The maximum delay by which to delay messages between nodes. (Ignored if _disableMangle_ is set.) +- **-expMiningFactor:** Factor for exponential distribution for random mining duration. + +If `tmux` is installed, you can run `./run.sh` to start a network of 4 nodes with reasonable options set. + +### Visualization + +> The visualization tool can be found [here](https://github.com/komplexon3/longest-chain-project/tree/main/chain-visualizer). + +For this chat application, there exists an accompanying browser-based visualization tool that utilizes the aforementioned websocket interceptor. +The visualizer provides insight into the state of the different nodes. +In particular, it displays the block tree stored in every node, the current and the current chat/message history (i.e., state corresponding to the current head). + +This information is shown once for each node. +In the box at the top, you see the chat/message history. +Right below it, you can see the id of the current head (truncated for readability) and the message part of the head's payload. +The biggest part of the window is filled with the block tree that is stored by the node's BCM. +It shows how the blocks are connected and the current head is marked with a red border. +To compare the trees more easily, each block's background color is derived from its id. + +![visualizer](./images/visualizers.png) + +Every single block displays the following information: + +- **Block ID:** + The id of the block (truncated for readability). +- **Miner ID:** The id of the node that mined the block. + The background color is unique per id. +- **Sent Timestamp:** + The time at which the message was sent. + This information is part of the payload. + Not to be confused with the time at which the block was mined. +- **Payload Message**: + The message that is part of the payload. +- **Sender ID:** + The id of the node from which the message was sent. + Again, the background is unique per id. + Note that this information is part of the payload. + +![visualizer block](./images/visualizer_block.png) diff --git a/pkg/blockchain/bcm/bcm.go b/pkg/blockchain/bcm/bcm.go new file mode 100644 index 000000000..bc5da2cff --- /dev/null +++ b/pkg/blockchain/bcm/bcm.go @@ -0,0 +1,612 @@ +package bcm + +import ( + "errors" + "slices" + "time" + + "github.com/filecoin-project/mir/pkg/blockchain/utils" + "github.com/filecoin-project/mir/pkg/dsl" + "github.com/filecoin-project/mir/pkg/logging" + "github.com/filecoin-project/mir/pkg/modules" + applicationpbdsl "github.com/filecoin-project/mir/pkg/pb/blockchainpb/applicationpb/dsl" + bcmpbdsl "github.com/filecoin-project/mir/pkg/pb/blockchainpb/bcmpb/dsl" + interceptorpbdsl "github.com/filecoin-project/mir/pkg/pb/blockchainpb/interceptorpb/dsl" + minerpbdsl "github.com/filecoin-project/mir/pkg/pb/blockchainpb/minerpb/dsl" + payloadpbtypes "github.com/filecoin-project/mir/pkg/pb/blockchainpb/payloadpb/types" + statepbtypes "github.com/filecoin-project/mir/pkg/pb/blockchainpb/statepb/types" + synchronizerpbdsl "github.com/filecoin-project/mir/pkg/pb/blockchainpb/synchronizerpb/dsl" + blockchainpbtypes "github.com/filecoin-project/mir/pkg/pb/blockchainpb/types" + t "github.com/filecoin-project/mir/pkg/types" + "golang.org/x/exp/maps" + "google.golang.org/protobuf/types/known/timestamppb" +) + +/** + * Blockchain Manager Module (BCM) + * =============================== + * + * The blockchain manager module is responsible for managing the blockchain. + * It keeps track of all blocks and links them together to form a tree. + * In particular, it keeps track of the head of the blockchain, all leaves and so-called checkpoints. + * A checkpoint is a block stored by the BCM that has a state stored with it. + * Technically, checkpoints are not necessary as the state can be computed from the blocks. + * However, it is convenient not to have to recompute the state from the genesis block every time it is needed. + * + * The BCM must perform the following tasks: + * 1. Initialize the blockchain by receiving an InitBlockchain event from the application module which contains the initial state that is associated with the genesis block. + * 2. Add new blocks to the blockchain. If a block with a parent that that is not in the blockchain is added, the BCM requests the missing block from the synchronizer. + * Blocks that are missing their parent are called orphans. + * All blocks added to the blockchain are verified in two steps: + * - It has the application module verify that the payloads are valid given the chain that the block is part of. + * - The BCM must verify that the blocks link together correctly. + * Additionally, it sends a TreeUpdate event to the interceptor module. This is solely for debugging/visualization purposes and not necessary for the operation of the blockchain. + * Also, it instructs the miner to start mining on the new head (NewHead event). + * 3. Register checkpoints when receiving a RegisterCheckpoint event from the application module. + * 4. It must provide the synchronizer with chains when requested. This is to resolve orphan blocks in other nodes. + * 5. When the head changes, it sends a HeadChange event to the application module. This event contains all information necessary for the application to compute the state at the new head + * as well as information about which payloads are now part of the canonical (i.e., longest) and which ones are no longer part of the canonical chain. + * 6. Provide a chain of blocks from a checkpoint to the current head and the state associated with the checkpoint when receiving a GetChainToHeadRequest. + * This is used by the application to query the current state. + */ + +var ( + ErrParentNotFound = errors.New("parent not found") + ErrNodeAlreadyInTree = errors.New("node already in tree") + ErrRollback = errors.New("rollback - should never happen") + ErrUninitialized = errors.New("uninitialized - the application must initialize the blockchain first by sending it a initBlockchain message") + ErrNoHit = errors.New("no hit") +) + +type bcmBlock struct { + block *blockchainpbtypes.Block + state *statepbtypes.State + parent *bcmBlock + depth uint64 + scanCount uint64 +} + +type bcmModule struct { + m *dsl.Module + blocks []bcmBlock // IMPORTANT: only to be used for visualization, not for actual block lookup + leaves map[uint64]*bcmBlock + head *bcmBlock + genesis *bcmBlock + checkpoints map[uint64]*bcmBlock + currentScanCount uint64 + logger logging.Logger + initialized bool +} + +/** + * Helper Functions + */ + +// checkInitialization checks whether the blockchain has been initialized and returns an error if not +func (bcm *bcmModule) checkInitialization() error { + if !bcm.initialized { + bcm.logger.Log(logging.LevelError, ErrUninitialized.Error()) + return ErrUninitialized + } + + return nil +} + +// The blockTreeTraversal function traverses the block tree starting from the leaves and applying the traversalFunc to each block. +// It will stop when the traversalFunc returns true and return the current block for which the traversalFunc returned true. +// If the traversalFunc never returns true, the function will return nil and ErrNoHit. +// if the traversalFunc returns an error, the function will return nil and the error. +func (bcm *bcmModule) blockTreeTraversal(traversalFunc func(currBlock *bcmBlock) (bool, error)) (*bcmBlock, error) { + bcm.currentScanCount = bcm.currentScanCount + 1 + queue := make([]*bcmBlock, 0) + + for _, v := range bcm.leaves { + queue = append(queue, v) + } + + for len(queue) > 0 { + // pop from queue + curr := queue[0] + queue = queue[1:] + + // mark as scanned + curr.scanCount = bcm.currentScanCount + + // check whether current block matches + if match, err := traversalFunc(curr); err != nil { + return nil, err + } else if match { + return curr, nil + } + + // add curr's parents to queue if it exist hasn't been scanned yet + // if curr.parent == nil, we are at the genesis block and can stop + if curr.parent != nil && curr.parent.scanCount <= bcm.currentScanCount { + queue = append(queue, curr.parent) + } + } + + return nil, ErrNoHit +} + +func (bcm *bcmModule) handleNewHead(newHead, oldHead *bcmBlock) { + bcm.logger.Log(logging.LevelInfo, "Head changed", "old head", utils.FormatBlockId(oldHead.block.BlockId), "new head", utils.FormatBlockId(newHead.block.BlockId)) + // TODO: short circuit if newHead is oldHead's parent + + // compute delta where removeChain is the chain leading to the old head and addChain is the chain leading to the new head + // the first block in each chain is the common ancestor (fork root) + removeChain, addChain, err := bcm.computeDelta(oldHead, newHead) + if err != nil { + // should never happen + bcm.logger.Log(logging.LevelError, "Error computing delta", "error", err) + panic(err) + } + + // get fork state + // TODO: fork might not happen right at checkpoint... find segment, add segment to fork update + forkRoot, err := bcm.findBlock(addChain[0].BlockId) + if err != nil { + bcm.logger.Log(logging.LevelError, "Failed to get fork parent - this should not happen", "blockId", utils.FormatBlockId(addChain[0].BlockId)) + panic(err) + } + checkpointToForkRootChain, checkpointState := bcm.getChainFromCheckpointToBlock(forkRoot) + + applicationpbdsl.HeadChange(*bcm.m, "application", + removeChain[1:], + addChain[1:], + checkpointToForkRootChain, + checkpointState) + + minerpbdsl.NewHead(*bcm.m, "miner", newHead.block.BlockId) +} + +func (bcm *bcmModule) computeDelta(removeHead *bcmBlock, addHead *bcmBlock) ([]*blockchainpbtypes.Block, []*blockchainpbtypes.Block, error) { + bcm.logger.Log(logging.LevelDebug, "Computing Delta", "removeHead", removeHead.block.BlockId, "addHead", addHead.block.BlockId) + + // short circuit for most simple cases + if removeHead.block.BlockId == addHead.block.BlockId { + // no delta + return []*blockchainpbtypes.Block{addHead.block}, []*blockchainpbtypes.Block{addHead.block}, nil + } else if addHead.block.PreviousBlockId == removeHead.block.BlockId { + // just appending + return []*blockchainpbtypes.Block{removeHead.block}, []*blockchainpbtypes.Block{removeHead.block, addHead.block}, nil + } else if removeHead.block.PreviousBlockId == addHead.block.BlockId { + // rollbacks should never happen, this only checks for the most simple case + return nil, nil, ErrRollback + } + + // traverse backwards from both heads until we find a common ancestor + // current ancecor is given when we find a block was already scanned by the other traversal + // this is the case if + initialScanCount := bcm.currentScanCount + + removeChain := make([]*blockchainpbtypes.Block, 0) + addChain := make([]*blockchainpbtypes.Block, 0) + + currRemove := removeHead + currAdd := addHead + + // TODO: consider weird cases like when they only have the genesis block in common + // at least one hasn't reached the end yet + for (currRemove != nil) || (currAdd != nil) { + + // handle remove step + if currRemove != nil { + + removeChain = append(removeChain, currRemove.block) + + // check for intersection + if currRemove.scanCount > initialScanCount { + // remove chain intersects with add chain, remove chain is ok, add chain needs to be truncated + // find currRemove in addChain + currRemoveBlockId := currRemove.block.BlockId + index := slices.IndexFunc(addChain, func(i *blockchainpbtypes.Block) bool { return i.BlockId == currRemoveBlockId }) + if index == -1 { + // should never happen + bcm.logger.Log(logging.LevelError, "Intersection trucation failed (remove intersection case) - this should never happen", "blockId", utils.FormatBlockId(currRemoveBlockId)) + panic("Intersection trucation failed (remove into add intersection case)") + } + return utils.Reverse(removeChain), utils.Reverse(addChain[:index+1]), nil + } + + currRemove.scanCount = initialScanCount + 1 + currRemove = currRemove.parent + } + + // handle add step + if currAdd != nil { + + addChain = append(addChain, currAdd.block) + + // check for intersection + if currAdd.scanCount > initialScanCount { + // add chain intersects with remove chain, add chain is ok, remove chain needs to be truncated + // find addRemove in removeChain + currAddBlockId := currAdd.block.BlockId + index := slices.IndexFunc(removeChain, func(i *blockchainpbtypes.Block) bool { return i.BlockId == currAddBlockId }) + if index == -1 { + // should never happen + bcm.logger.Log(logging.LevelError, "Intersection trucation failed (add intersection case) - this should never happen", "blockId", utils.FormatBlockId(currAddBlockId)) + panic("Intersection trucation failed (add into remove intersection case)") + } + return utils.Reverse(removeChain[:index+1]), utils.Reverse(addChain), nil + } + + currAdd.scanCount = initialScanCount + 1 + currAdd = currAdd.parent + } + + } + + // if we get here, we didn't find a common ancestor, this should never happen + bcm.logger.Log(logging.LevelError, "Intersection not found - this should never happen") + panic("intersection not found - this should never happen") +} + +// TODO: might need to add some "cleanup" to handle very old leaves in case this grows too much +func (bcm *bcmModule) addBlock(block *blockchainpbtypes.Block) error { + bcm.logger.Log(logging.LevelInfo, "Adding new block", "blockId", utils.FormatBlockId(block.BlockId), "parentId", utils.FormatBlockId(block.PreviousBlockId)) + + // check if block is already in the leaves, reject if so + if _, ok := bcm.leaves[block.BlockId]; ok { + bcm.logger.Log(logging.LevelDebug, "Block already in leaves - ignore", "blockId", utils.FormatBlockId(block.BlockId)) + return nil + } + + parentId := block.PreviousBlockId + // check leaves for parent with its id + // return nil if it isn't there + if parent, ok := bcm.leaves[parentId]; ok { + bcm.logger.Log(logging.LevelDebug, "Found parend in leaves", "blockId", utils.FormatBlockId(block.BlockId), "parentId", utils.FormatBlockId(parentId)) + blockNode := bcmBlock{ + block: block, + parent: parent, + depth: parent.depth + 1, + } + bcm.blocks = append(bcm.blocks, blockNode) + // replace leave + delete(bcm.leaves, parentId) + bcm.leaves[block.BlockId] = &blockNode + if blockNode.depth > bcm.head.depth { // update head only if new block is deeper, i.e. is the longest chain + bcm.head = &blockNode + } + return nil + } + + if _, err := bcm.blockTreeTraversal(func(currBlock *bcmBlock) (bool, error) { + // check if curr matches the block to be added - if so, ignore + if currBlock.block.BlockId == block.BlockId { + bcm.logger.Log(logging.LevelDebug, "Block already in tree", "blockId", utils.FormatBlockId(block.BlockId)) + return true, ErrNodeAlreadyInTree + } + + // check if curr is parent + if currBlock.block.BlockId == parentId { + bcm.logger.Log(logging.LevelDebug, "Found parend in tree", "blockId", utils.FormatBlockId(block.BlockId), "parentId", utils.FormatBlockId(parentId)) + blockNode := bcmBlock{ + block: block, + parent: currBlock, + depth: currBlock.depth + 1, + scanCount: 0, + } + // add new leave + bcm.leaves[block.BlockId] = &blockNode + bcm.blocks = append(bcm.blocks, blockNode) + if blockNode.depth > bcm.head.depth { // update head only if new block is deeper, i.e. is the longest chain + bcm.head = &blockNode + } + return true, nil + } + + return false, nil + }); err != nil { + bcm.logger.Log(logging.LevelWarn, "Couldn't find parent", "blockId", utils.FormatBlockId(block.BlockId), "error", err) + return err + } + + return nil +} + +func (bcm *bcmModule) findBlock(blockId uint64) (*bcmBlock, error) { + return bcm.blockTreeTraversal(func(currBlock *bcmBlock) (bool, error) { + if currBlock.block.BlockId == blockId { + return true, nil + } + return false, nil + }) +} + +// first send off to application to verify that payloads are valid, then check that everything links together +func (bcm *bcmModule) processNewChain(blocks []*blockchainpbtypes.Block) error { + parent, _ := bcm.findBlock(blocks[0].PreviousBlockId) + if parent == nil { + bcm.logger.Log(logging.LevelError, "Parent not found. Could be invalid chain/block or we are missing a part. Sending sync req to sync end of chain.", "blockId", utils.FormatBlockId(blocks[0].BlockId)) + connectionNodeIDs := append(maps.Keys(bcm.leaves), bcm.genesis.block.BlockId) + bcm.logger.Log(logging.LevelDebug, "Sending sync request", "blockId", utils.FormatBlockId(blocks[len(blocks)-1].BlockId), "leaves+genesis", utils.FormatBlockIdSlice(connectionNodeIDs)) + synchronizerpbdsl.SyncRequest(*bcm.m, "synchronizer", blocks[len(blocks)-1], connectionNodeIDs) + return nil + } + + checkpointToParent, checkpointState := bcm.getChainFromCheckpointToBlock(parent) + + applicationpbdsl.VerifyBlocksRequest(*bcm.m, "application", checkpointState, checkpointToParent, blocks) + return nil +} + +func (bcm *bcmModule) getChainFromCheckpointToBlock(block *bcmBlock) ([]*blockchainpbtypes.Block, *statepbtypes.State) { + + chain := make([]*blockchainpbtypes.Block, 0) + + currentBlock := block + for currentBlock != nil { + chain = append(chain, currentBlock.block) + if bcmBlock, ok := bcm.checkpoints[currentBlock.block.BlockId]; ok { + return utils.Reverse(chain), bcmBlock.state + } + currentBlock = currentBlock.parent + } + + bcm.logger.Log(logging.LevelWarn, "Cannot link up with checkpoints", "source", utils.FormatBlockId(block.block.BlockId), "chain", chain) + return nil, nil +} + +/** + * For visualization only, not relevant for the actual operation + */ + +// Sends all blocks to the interceptor for visualization +func (bcm *bcmModule) sendTreeUpdate() { + blocks := func() []*blockchainpbtypes.Block { + blocks := make([]*blockchainpbtypes.Block, 0, len(bcm.blocks)) + for _, v := range bcm.blocks { + blocks = append(blocks, v.block) + } + return blocks + }() + + interceptorpbdsl.TreeUpdate(*bcm.m, "devnull", blocks, bcm.head.block.BlockId) +} + +/** + * Mir Event Handlers + */ + +func (bcm *bcmModule) handleVerifyBlocksResponse(blocks []*blockchainpbtypes.Block) error { + bcm.logger.Log(logging.LevelDebug, "Received verify blocks response", "first block", utils.FormatBlockId(blocks[0].BlockId), "last block", utils.FormatBlockId(blocks[len(blocks)-1].BlockId)) + + currentHead := bcm.head + // insert block + for _, block := range blocks { + if err := bcm.addBlock(block); err != nil { + switch err { + case ErrNodeAlreadyInTree: + // ignore + bcm.logger.Log(logging.LevelDebug, "Block already in tree - ignore", "blockId", utils.FormatBlockId(block.BlockId)) + case ErrParentNotFound: + // this should not happen + bcm.logger.Log(logging.LevelError, "Parent not found - this should not happen", "blockId", utils.FormatBlockId(block.BlockId)) + panic(err) + default: + // some other error + bcm.logger.Log(logging.LevelError, "Unexpected error adding block", "blockId", utils.FormatBlockId(block.BlockId), "error", err) + panic(err) + } + } + } + + // if head changed, trigger get tpm to prep new block (only need to do this once) + if newHead := bcm.head; newHead != currentHead { + bcm.handleNewHead(newHead, currentHead) + } + + // send to chainviewer + bcm.sendTreeUpdate() + + return nil +} + +func (bcm *bcmModule) handleNewBlock(block *blockchainpbtypes.Block) error { + bcm.logger.Log(logging.LevelDebug, "Adding new block", "blockId", utils.FormatBlockId(block.BlockId)) + return bcm.processNewChain([]*blockchainpbtypes.Block{block}) +} + +func (bcm *bcmModule) handleNewChain(blocks []*blockchainpbtypes.Block) error { + if len(blocks) == 0 { + bcm.logger.Log(logging.LevelError, "Received empty chain") + return nil + } + + bcm.logger.Log(logging.LevelDebug, "Adding new chain", "first block", utils.FormatBlockId(blocks[0].BlockId), "last block", utils.FormatBlockId(blocks[len(blocks)-1].BlockId)) + + return bcm.processNewChain(blocks) +} + +func (bcm *bcmModule) handleRegisterCheckpoint(block_id uint64, state *statepbtypes.State) error { + bcm.logger.Log(logging.LevelDebug, "Received register checkpoint", "blockId", utils.FormatBlockId(block_id)) + if err := bcm.checkInitialization(); err != nil { + return err + } + if _, ok := bcm.checkpoints[block_id]; ok { + + bcm.logger.Log(logging.LevelDebug, "Checkpoint already registered - ignore", "blockId", utils.FormatBlockId(block_id)) + return nil + } + + // find block + // should be a leave or a block really close + if hit, err := bcm.findBlock(block_id); err != nil { + bcm.logger.Log(logging.LevelError, "Block not found - can't register checkpoint", "blockId", utils.FormatBlockId(block_id), "error", err) + panic("block not found when registering checkpoint") // should never happen + } else { + bcm.logger.Log(logging.LevelDebug, "Found block - registering checkpoint", "blockId", utils.FormatBlockId(block_id)) + hit.state = state + bcm.checkpoints[block_id] = hit + } + + return nil +} + +func (bcm *bcmModule) handleGetChainRequest(requestID string, sourceModule t.ModuleID, endBlockId uint64, sourceBlockIds []uint64) error { + bcm.logger.Log(logging.LevelDebug, "Received get chain request", "requestId", requestID, "sourceModule", sourceModule, "endBlockId", utils.FormatBlockId(endBlockId), "sourceBlockIds", utils.FormatBlockIdSlice(sourceBlockIds)) + + chain := make([]*blockchainpbtypes.Block, 0) + // for easier lookup... + sourceBlockIdsMap := make(map[uint64]uint64) + for _, v := range sourceBlockIds { + sourceBlockIdsMap[v] = v + } + currentBlock, err := bcm.findBlock(endBlockId) + + if err != nil { + bcm.logger.Log(logging.LevelDebug, "Block not found - can't build chain", "requestId", requestID, "error", err) + bcmpbdsl.GetChainResponse(*bcm.m, sourceModule, requestID, false, nil) + return nil + } + + bcm.logger.Log(logging.LevelDebug, "Found block in tree - building chain", "requestId", requestID) + + // initialize chain + chain = append(chain, currentBlock.block) + + for currentBlock.parent != nil { + // if parent is in sourceBlockIds, stop + if _, ok := sourceBlockIdsMap[currentBlock.parent.block.BlockId]; ok { + // chain build + bcm.logger.Log(logging.LevelDebug, "Found link with sourceBlockIds - chain build", "requestId", requestID) + // reversing chain to send it in the right order + for i, j := 0, len(chain)-1; i < j; i, j = i+1, j-1 { + chain[i], chain[j] = chain[j], chain[i] + } + bcmpbdsl.GetChainResponse(*bcm.m, sourceModule, requestID, true, chain) + return nil + } + + chain = append(chain, currentBlock.parent.block) + currentBlock = currentBlock.parent + } + + // if we get here, we didn't find a link with sourceBlockIds + bcm.logger.Log(logging.LevelDebug, "No link with sourceBlockIds - can't build chain", "requestId", requestID) + bcmpbdsl.GetChainResponse(*bcm.m, sourceModule, requestID, false, nil) + + return nil + +} + +func (bcm *bcmModule) handleGetChainToHeadRequest(sourceModule t.ModuleID) error { + bcm.logger.Log(logging.LevelDebug, "Received get chain to head request", "sourceModule", sourceModule) + chain, checkpontState := bcm.getChainFromCheckpointToBlock(bcm.head) + bcmpbdsl.GetChainToHeadResponse(*bcm.m, sourceModule, chain, checkpontState) + return nil + +} + +func (bcm *bcmModule) handleInitBlockchain(initialState *statepbtypes.State) error { + // initialize blockchain + + // making up a genisis block + genesis := &blockchainpbtypes.Block{ + BlockId: 0, + PreviousBlockId: 0, + Payload: &payloadpbtypes.Payload{}, + Timestamp: timestamppb.New(time.Date(0, 0, 0, 0, 0, 0, 0, time.UTC)), // unix 0 + MinerId: "", // no node mined this block, leaving node id empty + } + + hash := utils.HashBlock(genesis) //uint64(0) + genesis.BlockId = hash + genesisBcm := bcmBlock{ + block: genesis, + state: initialState, + parent: nil, + depth: 0, + } + + bcm.head = &genesisBcm + bcm.genesis = &genesisBcm + + bcm.blocks = []bcmBlock{genesisBcm} + bcm.leaves[hash] = &genesisBcm + bcm.checkpoints[hash] = &genesisBcm + + bcm.initialized = true + + // initialized, start operations + + bcm.logger.Log(logging.LevelInfo, "Initialized blockchain") + minerpbdsl.NewHead(*bcm.m, "miner", hash) + + return nil +} + +/** + * Module Definition + */ + +func NewBCM(logger logging.Logger) modules.PassiveModule { + m := dsl.NewModule("bcm") + + // init bcm genisis block + bcm := bcmModule{ + m: &m, + blocks: nil, // will be initialized in handleInitBlockchain, triggered by application + leaves: make(map[uint64]*bcmBlock), + head: nil, // will be initialized in handleInitBlockchain, triggered by application + genesis: nil, // will be initialized in handleInitBlockchain, triggered by application + checkpoints: make(map[uint64]*bcmBlock), + currentScanCount: 0, + logger: logger, + initialized: false, + } + + dsl.UponInit(m, func() error { + return nil + }) + + bcmpbdsl.UponNewBlock(m, func(block *blockchainpbtypes.Block) error { + if err := bcm.checkInitialization(); err != nil { + return err + } + return bcm.handleNewBlock(block) + }) + + bcmpbdsl.UponNewChain(m, func(blocks []*blockchainpbtypes.Block) error { + bcm.logger.Log(logging.LevelDebug, "Received chain from synchronizer") + if err := bcm.checkInitialization(); err != nil { + return err + } + return bcm.handleNewChain(blocks) + }) + + bcmpbdsl.UponGetChainRequest(m, func(requestID string, sourceModule t.ModuleID, endBlockId uint64, sourceBlockIds []uint64) error { + if err := bcm.checkInitialization(); err != nil { + return err + } + return bcm.handleGetChainRequest(requestID, sourceModule, endBlockId, sourceBlockIds) + }) + + bcmpbdsl.UponGetChainToHeadRequest(m, func(sourceModule t.ModuleID) error { + if err := bcm.checkInitialization(); err != nil { + return err + } + return bcm.handleGetChainToHeadRequest(sourceModule) + }) + + bcmpbdsl.UponRegisterCheckpoint(m, func(block_id uint64, state *statepbtypes.State) error { + if err := bcm.checkInitialization(); err != nil { + return err + } + return bcm.handleRegisterCheckpoint(block_id, state) + }) + + applicationpbdsl.UponVerifyBlocksResponse(m, func(blocks []*blockchainpbtypes.Block) error { + if err := bcm.checkInitialization(); err != nil { + return err + } + return bcm.handleVerifyBlocksResponse(blocks) + }) + + bcmpbdsl.UponInitBlockchain(m, bcm.handleInitBlockchain) + + return m +} diff --git a/pkg/blockchain/broadcast/broadcast.go b/pkg/blockchain/broadcast/broadcast.go new file mode 100644 index 000000000..5fd1da8a0 --- /dev/null +++ b/pkg/blockchain/broadcast/broadcast.go @@ -0,0 +1,61 @@ +// handles all commmunication between nodes + +package broadcast + +import ( + "github.com/filecoin-project/mir/pkg/blockchain/utils" + "github.com/filecoin-project/mir/pkg/dsl" + "github.com/filecoin-project/mir/pkg/logging" + "github.com/filecoin-project/mir/pkg/modules" + bcmpbdsl "github.com/filecoin-project/mir/pkg/pb/blockchainpb/bcmpb/dsl" + broadcastpbdsl "github.com/filecoin-project/mir/pkg/pb/blockchainpb/broadcastpb/dsl" + broadcastpbmsgs "github.com/filecoin-project/mir/pkg/pb/blockchainpb/broadcastpb/msgs" + blockchainpbtypes "github.com/filecoin-project/mir/pkg/pb/blockchainpb/types" + transportpbdsl "github.com/filecoin-project/mir/pkg/pb/transportpb/dsl" + t "github.com/filecoin-project/mir/pkg/types" +) + +/** +* Broadcast module +* ================= +* +* The broadcast module is responsible for broadcasting new blocks to all other nodes. +* It either does this directly via the transport module or via the mangler (parameter mangle). +* If the mangler is used, messages might will be dropped and delayed. +* How many messages should be dropped can be configured by the parameter `dropRate` +* and the delay can be configured by the parameters `minDelay` and `maxDelay`. + */ + +func NewBroadcast(otherNodes []t.NodeID, mangle bool, logger logging.Logger) modules.PassiveModule { + m := dsl.NewModule("broadcast") + + dsl.UponInit(m, func() error { + return nil + }) + + broadcastpbdsl.UponNewBlock(m, func(block *blockchainpbtypes.Block) error { + // take the block and send it to all other nodes + + logger.Log(logging.LevelDebug, "broadcasting block", "blockId", utils.FormatBlockId(block.BlockId), "manlge", mangle) + + if mangle { + // send via mangler + for _, node := range otherNodes { + transportpbdsl.SendMessage(m, "mangler", broadcastpbmsgs.NewBlockMessage("broadcast", block), []t.NodeID{node}) + } + } else { + transportpbdsl.SendMessage(m, "transport", broadcastpbmsgs.NewBlockMessage("broadcast", block), otherNodes) + } + + return nil + }) + + broadcastpbdsl.UponNewBlockMessageReceived(m, func(from t.NodeID, block *blockchainpbtypes.Block) error { + logger.Log(logging.LevelDebug, "new block received", "blockId", utils.FormatBlockId(block.BlockId)) + + bcmpbdsl.NewBlock(m, "bcm", block) + return nil + }) + + return m +} diff --git a/pkg/blockchain/images/visualizer.png b/pkg/blockchain/images/visualizer.png new file mode 100644 index 000000000..9eae71b80 Binary files /dev/null and b/pkg/blockchain/images/visualizer.png differ diff --git a/pkg/blockchain/images/visualizer_block.png b/pkg/blockchain/images/visualizer_block.png new file mode 100644 index 000000000..ff5182401 Binary files /dev/null and b/pkg/blockchain/images/visualizer_block.png differ diff --git a/pkg/blockchain/images/visualizers.png b/pkg/blockchain/images/visualizers.png new file mode 100644 index 000000000..b50821fac Binary files /dev/null and b/pkg/blockchain/images/visualizers.png differ diff --git a/pkg/blockchain/miner/miner.go b/pkg/blockchain/miner/miner.go new file mode 100644 index 000000000..5819c6ed4 --- /dev/null +++ b/pkg/blockchain/miner/miner.go @@ -0,0 +1,136 @@ +package miner + +import ( + "context" + "math/rand" + "time" + + "github.com/filecoin-project/mir/pkg/blockchain/utils" + "github.com/filecoin-project/mir/pkg/events" + "github.com/filecoin-project/mir/pkg/logging" + "github.com/filecoin-project/mir/pkg/modules" + "github.com/filecoin-project/mir/pkg/pb/blockchainpb/applicationpb" + applicationpbevents "github.com/filecoin-project/mir/pkg/pb/blockchainpb/applicationpb/events" + bcmpbevents "github.com/filecoin-project/mir/pkg/pb/blockchainpb/bcmpb/events" + broadcastpbevents "github.com/filecoin-project/mir/pkg/pb/blockchainpb/broadcastpb/events" + "github.com/filecoin-project/mir/pkg/pb/blockchainpb/minerpb" + payloadpbtypes "github.com/filecoin-project/mir/pkg/pb/blockchainpb/payloadpb/types" + blockchainpbtypes "github.com/filecoin-project/mir/pkg/pb/blockchainpb/types" + "github.com/filecoin-project/mir/pkg/pb/eventpb" + t "github.com/filecoin-project/mir/pkg/types" + "github.com/go-errors/errors" + "github.com/mitchellh/hashstructure" + "google.golang.org/protobuf/types/known/timestamppb" +) + +/** + * Miner module + * ============ + * + * The miner module is responsible for mining new blocks. + * It simulates the process of mining a block by waiting for a random amount of time and then broadcasting the mined block. + * This random amount of time is sampled from an exponential distribution with a mean of `expMinuteFactor` minutes. + * The mining is orchestrated by a separate goroutine (mineWorkerManager), so that the miner module can continue to receive and process events. + * + * The operation of the miner module at a high level is as follows: + * 1. When it is notified of a new head (NewHead event), it prepares to mine the next block by sending a PayloadRequest event to the application module. + * If it is already mining a block, it aborts the ongoing mining operation. + * 2. When it receives the PayloadResponse containing a payload for the next block, it starts mining a new block with the received payload. + * 3. When it mines a new block, it broadcasts it to all other modules by sending a NewBlock message to the broadcast module. + * It also shares the block with the blockchain manager module (BCM) by sending a NewBlock event to it. + */ + +/** + * Request for a new block to be mined. + */ +type blockRequest struct { + HeadId uint64 // id of the head of the blockchain (parent of the new block) + Payload *payloadpbtypes.Payload // payload for the new block +} + +type minerModule struct { + nodeID t.NodeID // id of this node + expMinuteFactor float64 // factor for exponential distribution for random mining duration + blockRequests chan blockRequest // channel to send block requests to mineWorker + eventsOut chan *events.EventList // channel to send events to other modules + logger logging.Logger +} + +func NewMiner(nodeID t.NodeID, expMinuteFactor float64, logger logging.Logger) modules.ActiveModule { + return &minerModule{ + nodeID: nodeID, + expMinuteFactor: expMinuteFactor, + blockRequests: make(chan blockRequest), + eventsOut: make(chan *events.EventList), + logger: logger, + } +} + +func (m *minerModule) ImplementsModule() {} + +func (m *minerModule) EventsOut() <-chan *events.EventList { + return m.eventsOut +} + +func (m *minerModule) ApplyEvents(context context.Context, eventList *events.EventList) error { + for _, event := range eventList.Slice() { + switch e := event.Type.(type) { + case *eventpb.Event_Init: + go m.mineWorkerManager() + case *eventpb.Event_Application: + switch e := e.Application.Type.(type) { + case *applicationpb.Event_PayloadResponse: + m.blockRequests <- blockRequest{e.PayloadResponse.HeadId, payloadpbtypes.PayloadFromPb(e.PayloadResponse.Payload)} + return nil + default: + return errors.Errorf("unknown event: %T", e) + } + case *eventpb.Event_Miner: + switch e := e.Miner.Type.(type) { + case *minerpb.Event_NewHead: + m.eventsOut <- events.ListOf(applicationpbevents.PayloadRequest("application", e.NewHead.HeadId).Pb()) + default: + return errors.Errorf("unknown miner event: %T", e) + } + default: + return errors.Errorf("unknown event: %T", e) + } + } + + return nil +} + +func (m *minerModule) mineWorkerManager() { + ctx, cancel := context.WithCancel(context.Background()) + + for { + blockRequest := <-m.blockRequests // blocking until a new block request is received + cancel() // abort ongoing mining + ctx, cancel = context.WithCancel(context.Background()) // new context for new mining + m.logger.Log(logging.LevelInfo, "New mining operation", "headId", utils.FormatBlockId(blockRequest.HeadId)) + + // spawn new goroutine to mine the requested block + go func() { + delay := time.Duration(rand.ExpFloat64() * float64(time.Minute) * m.expMinuteFactor) + select { + case <-ctx.Done(): + // Mining aborted. Do nothing. + m.logger.Log(logging.LevelInfo, "Mining aborted", "headId", utils.FormatBlockId(blockRequest.HeadId)) + return + case <-time.After(delay): + // Mining completed. Create block and broadcast. + block := &blockchainpbtypes.Block{BlockId: 0, PreviousBlockId: blockRequest.HeadId, Payload: blockRequest.Payload, Timestamp: timestamppb.Now(), MinerId: m.nodeID} + hash, err := hashstructure.Hash(block, nil) + if err != nil { + m.logger.Log(logging.LevelError, "Failed to hash block", "error", err) + panic(err) + } + block.BlockId = hash + // Send block to BCM and broadcast module + m.logger.Log(logging.LevelInfo, "Block mined", "blockId", utils.FormatBlockId(hash), "parentId", utils.FormatBlockId(blockRequest.HeadId)) + m.eventsOut <- events.ListOf(bcmpbevents.NewBlock("bcm", block).Pb(), broadcastpbevents.NewBlock("broadcast", block).Pb()) + return + } + }() + } +} diff --git a/pkg/blockchain/synchronizer/synchronizer.go b/pkg/blockchain/synchronizer/synchronizer.go new file mode 100644 index 000000000..bd73604a6 --- /dev/null +++ b/pkg/blockchain/synchronizer/synchronizer.go @@ -0,0 +1,265 @@ +package synchronizer + +import ( + "errors" + "fmt" + "math/rand" + + "github.com/filecoin-project/mir/pkg/blockchain/utils" + "github.com/filecoin-project/mir/pkg/dsl" + "github.com/filecoin-project/mir/pkg/logging" + "github.com/filecoin-project/mir/pkg/modules" + bcmpbdsl "github.com/filecoin-project/mir/pkg/pb/blockchainpb/bcmpb/dsl" + synchronizerpbdsl "github.com/filecoin-project/mir/pkg/pb/blockchainpb/synchronizerpb/dsl" + synchronizerpbmsgs "github.com/filecoin-project/mir/pkg/pb/blockchainpb/synchronizerpb/msgs" + blockchainpbtypes "github.com/filecoin-project/mir/pkg/pb/blockchainpb/types" + transportpbdsl "github.com/filecoin-project/mir/pkg/pb/transportpb/dsl" + t "github.com/filecoin-project/mir/pkg/types" +) + +/** + * Synchronizer module + * =================== + * + * The synchronizer module assists the blockchain manager (BCM) in resolving cases whe BCM receives an orphan block. + * An orphan block is a block that cannot be linked to the blockchain because the blockchain does not contain the block that the orphan block is linked to. + * To do this, the synchronizer module communicates with other nodes to get the missing blocks. + * + * Terminology: + * - internal sync request: a request to synchronize a chain segment that was initiated by this node + * - external sync request: a request to synchronize a chain segment that was initiated by another node + * + * The synchronizer module performs the following tasks: + * For internal sync requests: + * 1. When it receives a SyncRequest event, it must register the request and send a ChainRequest message to another node. + * It asks one node after another. + * 2. When it receives a successful ChainResponse message, it sends the blockchain manager (BCM) the chain fixing the missing bit with a NewChain event. + * It then deletes the request. + * 3. When it receives a unsuccessful ChainResponse message, it sends a ChainRequest message to the next node. + * If there are no more nodes to ask, it deletes the request. + * + * For external sync requests: + * 1. When it receives a ChainRequest message, it must register the request and send a GetChainRequest event to the BCM. + * 2. WHen the BCM responds with a GetChainResponse event, the synchronizer responds to the node that sent the ChainRequest message with a ChainResponse message. + * + * IMPORTANT: This module assumes that all other nodes resppond to requests. For this reason, the messages send by the synchronizer do not go through the mangler. + */ + +var ( + ErrRequestAlreadyExists = errors.New("request already exists") + ErrNoMoreNodes = errors.New("no more nodes to contact") + ErrUnknownRequest = errors.New("unknown request") + ErrUnkownGetBlockRequest = errors.New("unknown get block request") +) + +// NOTE: add 'crashed node detection' - remove nodes that don't respond to requests +// rn it would just get stuck on such a node... + +type synchronizerModule struct { + m *dsl.Module + nodeID t.NodeID // id of this node + syncRequests map[string]*syncRequest // map to keep track of sync requests - for internal sync requests + getRequests map[string]*getRequest // map to keep track of get requests - for external sync request + otherNodes []t.NodeID // ids of all other nodes + internalLogger logging.Logger // logger for internal sync requests + externaLogger logging.Logger // logger for external sync requests +} + +/************************* + * Internal sync requests + *************************/ + +// struct to keep track of sync requests +// it hold all information needed to send sync requests to other nodes and keeps track of which nodes have already been contacted +type syncRequest struct { + requestID string // id of the request, used as key in syncRequests map + blockID uint64 // id of the blocks that cannot be linked to the blockchain + connectionNodeIDs []uint64 // ids of the block + nodesContacted []int // index of node in otherNodes +} + +/** + * Helper functions for internal requests + */ + +// registers a sync request +func (sm *synchronizerModule) registerSyncRequest(block *blockchainpbtypes.Block, connectionNodeIDs []uint64) (string, error) { + requestId := fmt.Sprint(block.BlockId) + "-" + string(sm.nodeID) + // check if request already exists + if _, ok := sm.syncRequests[requestId]; ok { + return "", ErrRequestAlreadyExists + } + + sm.syncRequests[requestId] = &syncRequest{requestID: requestId, blockID: block.BlockId, connectionNodeIDs: connectionNodeIDs, nodesContacted: []int{}} + + return requestId, nil +} + +func (sm *synchronizerModule) contactNextNode(requestID string) error { + request, ok := sm.syncRequests[requestID] + if !ok { + return ErrUnknownRequest + } + + var nextNodeIndex int + // check if we have contacted all nodes + if len(request.nodesContacted) == len(sm.otherNodes) { + return ErrNoMoreNodes + } else if len(request.nodesContacted) == 0 { + // first node to contact, pick randomly + nextNodeIndex = rand.Intn(len(sm.otherNodes)) + + } else { + // get next node + nextNodeIndex = (request.nodesContacted[len(request.nodesContacted)-1] + 1) % len(sm.otherNodes) + } + + request.nodesContacted = append(request.nodesContacted, nextNodeIndex) + nextNode := sm.otherNodes[nextNodeIndex] + + sm.internalLogger.Log(logging.LevelDebug, "asking node for block", "block", utils.FormatBlockId(request.blockID), "node", nextNode) + + // send request + transportpbdsl.SendMessage(*sm.m, "transport", synchronizerpbmsgs.ChainRequest("synchronizer", requestID, request.blockID, request.connectionNodeIDs), []t.NodeID{nextNode}) + + return nil +} + +/** + * Mir handlers for internal requests + */ + +func (sm *synchronizerModule) handleSyncRequest(orphanBlock *blockchainpbtypes.Block, connectionNodeIDs []uint64) error { + + // register request + requestId, err := sm.registerSyncRequest(orphanBlock, connectionNodeIDs) + if err != nil { + switch err { + case ErrRequestAlreadyExists: + // ignore request + sm.internalLogger.Log(logging.LevelDebug, "sync request already exists", "orphanBlock", utils.FormatBlockId(orphanBlock.BlockId), "connectionNodeIDs", utils.FormatBlockIdSlice(connectionNodeIDs)) + return nil + default: + sm.internalLogger.Log(logging.LevelError, "sync registration failed", "error", err.Error(), "orphanBlock", utils.FormatBlockId(orphanBlock.BlockId), "connectionNodeIDs", utils.FormatBlockIdSlice(connectionNodeIDs)) + return err + } + } + + if err := sm.contactNextNode(requestId); err != nil { + // could check for 'ErrNoMoreNodes' here but there should always be at least one node + sm.internalLogger.Log(logging.LevelError, "sync registration failed", "error", err.Error(), "orphanBlock", utils.FormatBlockId(orphanBlock.BlockId), "connectionNodeIDs", utils.FormatBlockIdSlice(connectionNodeIDs)) + return err + } + + return nil +} + +func (sm *synchronizerModule) handleChainResponseReceived(from t.NodeID, requestID string, found bool, chain []*blockchainpbtypes.Block) error { + // check if request exists + request, ok := sm.syncRequests[requestID] + if !ok { + // assume this is a delayed response and we already handled it + return nil + } + + if !found { + // check whether the response came from he last node we contacted + // NOTE: this is getting messy + if sm.otherNodes[request.nodesContacted[len(request.nodesContacted)-1]] != from { + // there is still a request out in the ether - don't send another one + return nil + + } + // send request to the next node + if err := sm.contactNextNode(requestID); err == ErrNoMoreNodes { + sm.internalLogger.Log(logging.LevelError, "no more nodes to contact - forgetting request - shouldn't happen ", "error", err.Error(), "requestId", requestID) + delete(sm.syncRequests, requestID) + } else if err != nil { + sm.internalLogger.Log(logging.LevelError, "Unexpected error contacting next node", "error", err.Error(), "requestId", requestID) + // TODO: should we actually fail here? + panic(err) + } + + return nil + } + + delete(sm.syncRequests, requestID) + bcmpbdsl.NewChain(*sm.m, "bcm", chain) + + // we got a block + return nil +} + +/************************* + * External sync requests + *************************/ +type getRequest struct { + requestID string + from t.NodeID +} + +/** + * Mir handlers for external requests + */ + +func (sm *synchronizerModule) handleChainRequestReceived(from t.NodeID, requestID string, blockID uint64, connectionNodeIDs []uint64) error { + // check if request is already being processed + if _, ok := sm.getRequests[requestID]; ok { + sm.externaLogger.Log(logging.LevelError, "Get block request already exists", "from", from, "requestId", requestID) + return nil + } + + // register request + sm.getRequests[requestID] = &getRequest{requestID: requestID, from: from} + + // send get request to blockchain manager + bcmpbdsl.GetChainRequest(*sm.m, "bcm", requestID, "synchronizer", blockID, connectionNodeIDs) + + return nil + +} + +func (sm *synchronizerModule) handleGetChainResponse(requestID string, found bool, chain []*blockchainpbtypes.Block) error { + request, ok := sm.getRequests[requestID] + if !ok { + sm.externaLogger.Log(logging.LevelError, "Unknown get block request", "requestId", requestID) + return ErrUnkownGetBlockRequest + } + + sm.externaLogger.Log(logging.LevelDebug, "Responsing to block request", "requestId", requestID, "found", found) + + // respond to sync request + transportpbdsl.SendMessage(*sm.m, "transport", synchronizerpbmsgs.ChainResponse("synchronizer", requestID, found, chain), []t.NodeID{request.from}) + + // delete request + delete(sm.getRequests, requestID) + + return nil +} + +func NewSynchronizer(nodeID t.NodeID, otherNodes []t.NodeID, logger logging.Logger) modules.PassiveModule { + m := dsl.NewModule("synchronizer") + var sm = synchronizerModule{ + m: &m, + nodeID: nodeID, + getRequests: make(map[string]*getRequest), + syncRequests: make(map[string]*syncRequest), + otherNodes: otherNodes, + internalLogger: logging.Decorate(logger, "Intern - "), + externaLogger: logging.Decorate(logger, "External - "), + } + + dsl.UponInit(m, func() error { + return nil + }) + + // internal sync requests + synchronizerpbdsl.UponChainRequestReceived(m, sm.handleChainRequestReceived) + bcmpbdsl.UponGetChainResponse(m, sm.handleGetChainResponse) + + // external sync requests + synchronizerpbdsl.UponSyncRequest(m, sm.handleSyncRequest) + synchronizerpbdsl.UponChainResponseReceived(m, sm.handleChainResponseReceived) + + return m +} diff --git a/pkg/blockchain/system.go b/pkg/blockchain/system.go new file mode 100644 index 000000000..0a7a408b7 --- /dev/null +++ b/pkg/blockchain/system.go @@ -0,0 +1,94 @@ +package blockchain + +import ( + "math" + "strconv" + "time" + + "github.com/filecoin-project/mir/pkg/blockchain/bcm" + "github.com/filecoin-project/mir/pkg/blockchain/broadcast" + "github.com/filecoin-project/mir/pkg/blockchain/miner" + "github.com/filecoin-project/mir/pkg/blockchain/synchronizer" + "github.com/filecoin-project/mir/pkg/eventmangler" + "github.com/filecoin-project/mir/pkg/logging" + "github.com/filecoin-project/mir/pkg/modules" + "github.com/filecoin-project/mir/pkg/net/grpc" + trantorpbtypes "github.com/filecoin-project/mir/pkg/pb/trantorpb/types" + "github.com/filecoin-project/mir/pkg/timer" + t "github.com/filecoin-project/mir/pkg/types" +) + +type System struct { + modules modules.Modules +} + +func New( + ownId t.NodeID, // id of this node + application modules.Module, // application module to use - see samples/blockchain-chat/application for example + disableMangle bool, // whether to disable mangling of messages + dropRate float64, // the rate at which to drop messages + minDelay float64, // minimum delay by which to delay messages [seconds] + maxDelay float64, // maximum delay by which to delay messages [seconds] + exponentialMiningFactor float64, // factor for exponential distribution for random mining duration + numberOfNodes int, // number of nodes in the network + logger logging.Logger, // logger to be used by the system + transportLogger logging.Logger, // logger to be used by the transport exlusively +) *System { + // determine "other" nodes for this node + nodes := make(map[t.NodeID]*trantorpbtypes.NodeIdentity, numberOfNodes) + allNodeIds := make([]t.NodeID, numberOfNodes) + otherNodes := make([]t.NodeID, numberOfNodes-1) + otherNodesIndex := 0 + for i := 0; i < numberOfNodes; i++ { + nodeIdStr := strconv.Itoa(i) + nodeId := t.NodeID(nodeIdStr) + allNodeIds[i] = nodeId + if nodeId != ownId { + otherNodes[otherNodesIndex] = nodeId + otherNodesIndex++ + } + nodes[nodeId] = &trantorpbtypes.NodeIdentity{Id: nodeId, Addr: "/ip4/127.0.0.1/tcp/1000" + nodeIdStr, Key: nil, Weight: "1"} + } + membership := &trantorpbtypes.Membership{Nodes: nodes} + + // Instantiate network transport module and establish connections. + transport, err := grpc.NewTransport(ownId, membership.Nodes[ownId].Addr, transportLogger) + if err != nil { + panic(err) + } + if err := transport.Start(); err != nil { + panic(err) + } + transport.Connect(membership) + + modules := modules.Modules{ + "transport": transport, + "bcm": bcm.NewBCM(logging.Decorate(logger, "BCM:\t")), + "miner": miner.NewMiner(ownId, exponentialMiningFactor, logging.Decorate(logger, "Miner:\t")), + "broadcast": broadcast.NewBroadcast(otherNodes, !disableMangle, logging.Decorate(logger, "Comm:\t")), + "synchronizer": synchronizer.NewSynchronizer(ownId, otherNodes, logging.Decorate(logger, "Sync:\t")), + "devnull": modules.NullPassive{}, // for messages that are actually destined for the interceptor + "application": application, + } + + if !disableMangle { + minDelayDuration := time.Duration(int64(math.Round(minDelay * float64(time.Second)))) + maxDelayDuration := time.Duration(int64(math.Round(maxDelay * float64(time.Second)))) + manglerModule, err := eventmangler.NewModule( + eventmangler.ModuleConfig{Self: "mangler", Dest: "transport", Timer: "timer"}, + &eventmangler.ModuleParams{MinDelay: minDelayDuration, MaxDelay: maxDelayDuration, DropRate: float32(dropRate)}, + ) + if err != nil { + panic(err) + } + + modules["timer"] = timer.New() + modules["mangler"] = manglerModule + } + + return &System{modules: modules} +} + +func (s *System) Modules() modules.Modules { + return s.modules +} diff --git a/pkg/blockchain/utils/format.go b/pkg/blockchain/utils/format.go new file mode 100644 index 000000000..583dc2186 --- /dev/null +++ b/pkg/blockchain/utils/format.go @@ -0,0 +1,22 @@ +package utils + +import ( + "fmt" +) + +func FormatBlockId(blockId uint64) string { + strId := fmt.Sprint(blockId) + // just in case we have a very small id for some reason + if len(strId) > 6 { + strId = strId[:6] + } + return strId +} + +func FormatBlockIdSlice(blockIds []uint64) string { + str := "" + for _, blockId := range blockIds { + str += FormatBlockId(blockId) + " " + } + return str +} diff --git a/pkg/blockchain/utils/hash.go b/pkg/blockchain/utils/hash.go new file mode 100644 index 000000000..1b020d85e --- /dev/null +++ b/pkg/blockchain/utils/hash.go @@ -0,0 +1,16 @@ +package utils + +import ( + blockchainpbtypes "github.com/filecoin-project/mir/pkg/pb/blockchainpb/types" + "github.com/mitchellh/hashstructure" +) + +func HashBlock(block *blockchainpbtypes.Block) uint64 { + hashBlock := *block + hashBlock.BlockId = 0 + hash, err := hashstructure.Hash(hashBlock, nil) + if err != nil { + panic(err) + } + return hash +} diff --git a/pkg/blockchain/utils/slices.go b/pkg/blockchain/utils/slices.go new file mode 100644 index 000000000..9ce59cff3 --- /dev/null +++ b/pkg/blockchain/utils/slices.go @@ -0,0 +1,9 @@ +package utils + +import "slices" + +// Reverse reverses the order of the elements in a slice and returns the result +func Reverse[S ~[]T, T any](slice S) S { + slices.Reverse(slice) + return slice +} diff --git a/pkg/blockchain/wsInterceptor/wsInterceptor.go b/pkg/blockchain/wsInterceptor/wsInterceptor.go new file mode 100644 index 000000000..31d718b22 --- /dev/null +++ b/pkg/blockchain/wsInterceptor/wsInterceptor.go @@ -0,0 +1,65 @@ +package wsInterceptor + +import ( + "github.com/filecoin-project/mir/pkg/blockchain/wsInterceptor/wsServer" + "github.com/filecoin-project/mir/pkg/events" + "github.com/filecoin-project/mir/pkg/logging" + "github.com/filecoin-project/mir/pkg/pb/eventpb" + "google.golang.org/protobuf/proto" +) + +/** +* Websocket interceptor +* ===================== +* +* The websocket interceptor intercepts all events and sends them to a websocket server. +* Any connected client can then receive these events by subscribing to the websocket server. +* +* The interceptor proto file defines events which are specificly intended for the interceptor and not used by the actual blockchain. +* Since these events technically don't have a destination module, they are sent to the "null" module. +* However, all events are intercepted and sent to the websocket server. +The interceptor proto is simply for "extra" events. +* +* The interceptor proto defines two such events: +* - TreeUpdate: This event is sent by the blockchain manager (BCM) when the blockchain is updated. It contains all blocks in the blockchain and the id of the new head. +* - StateUpdate: This event is sent by the application when it computes the state for the newest head of the blockchain. +* +* Important note: This is a very simple implementation and it fails to properly handle connections which causes a crash when subscribers disconnect. +*/ + +type eventFilterFn func(*eventpb.Event) bool + +type wsInterceptor struct { + server *wsServer.WsServer + eventFilter eventFilterFn + logger logging.Logger +} + +func (i *wsInterceptor) Intercept(events *events.EventList) error { + for _, e := range events.Slice() { + if i.eventFilter(e) { + payload, err := proto.Marshal(e) + if err != nil { + // log? + return err + } + i.server.SendChan <- wsServer.WsMessage{ + MessageType: 2, + Payload: []byte(payload), + } + } + } + + return nil +} + +func NewWsInterceptor(eventFilter eventFilterFn, port int, logger logging.Logger) *wsInterceptor { + server := wsServer.NewWsServer(port, logger) + logger.Log(logging.LevelInfo, "Starting websocker interceptor server") + go server.StartServers() + return &wsInterceptor{ + server: server, + eventFilter: eventFilter, + logger: logger, + } +} diff --git a/pkg/blockchain/wsInterceptor/wsServer/wsServer.go b/pkg/blockchain/wsInterceptor/wsServer/wsServer.go new file mode 100644 index 000000000..245727836 --- /dev/null +++ b/pkg/blockchain/wsInterceptor/wsServer/wsServer.go @@ -0,0 +1,159 @@ +package wsServer + +import ( + "context" + "fmt" + "net/http" + "sync" + + "github.com/filecoin-project/mir/pkg/logging" + "github.com/google/uuid" + "github.com/gorilla/websocket" +) + +/** + * Websocket server + * ================= + * + * A simple websocket server which accepts connections and sends messages to all connected clients. + * The messages are sent to the server through a channel. + * + * Note: This is a very shotty implementation. For example, it crashes if a client disconnects. + * It is only intended for debugging purposes. + */ + +type WsMessage struct { + MessageType int + Payload []byte +} + +type connection struct { + id string + server *WsServer + ws *websocket.Conn + sendChan chan WsMessage +} + +type WsServer struct { + SendChan chan WsMessage + port int + connections map[string]connection + connectionsLock sync.Mutex + logger logging.Logger +} + +var upgrader = websocket.Upgrader{ + ReadBufferSize: 1024, + WriteBufferSize: 1024, +} + +func (wss *WsServer) handleHome(w http.ResponseWriter, r *http.Request) { + if r.URL.Path != "/" { + http.Error(w, "Not found", http.StatusNotFound) + return + } + if r.Method != "GET" { + http.Error(w, "Method not allowed", http.StatusMethodNotAllowed) + return + } + w.Write([]byte("Hello world!")) +} + +func (wsc *connection) wsConnection() { + wsc.server.logger.Log(logging.LevelInfo, "New WS connection", "total connections: ", len(wsc.server.connections)) + ctx, cancel := context.WithCancel(context.Background()) // new context for new mining + // close connection + defer wsc.ws.Close() + // close up channels and remove connection + defer func() { + wsc.server.connectionsLock.Lock() + delete(wsc.server.connections, wsc.id) + close(wsc.sendChan) + wsc.server.connectionsLock.Unlock() + }() + defer cancel() // cancel context for event sending loop + + // sending msgs + go func() { + for { + select { + case <-ctx.Done(): + return + case message := <-wsc.sendChan: + err := wsc.ws.WriteMessage(message.MessageType, message.Payload) + if err != nil { + wsc.server.logger.Log(logging.LevelError, "Error sending WS message: ", err) + } + } + } + }() + + // "receiving" msgs + for { + msgType, _, err := wsc.ws.ReadMessage() + // catching all erros but actually only interested in "going away" errors + if msgType == websocket.CloseMessage || err != nil { + wsc.server.logger.Log(logging.LevelWarn, "WS connection closed") + return + } + wsc.server.logger.Log(logging.LevelWarn, "Received WS message - ignored") + } +} + +func (wss *WsServer) handleWs(w http.ResponseWriter, r *http.Request) { + // cors * + upgrader.CheckOrigin = func(r *http.Request) bool { return true } + ws, err := upgrader.Upgrade(w, r, nil) + if err != nil { + wss.logger.Log(logging.LevelError, "Upgrade failed: ", err) + return + } + wss.connectionsLock.Lock() + id := "" + for { + id = uuid.New().String() + if _, ok := wss.connections[id]; !ok { + break + } + } + conn := connection{id, wss, ws, make(chan WsMessage)} + wss.connections[id] = conn + wss.connectionsLock.Unlock() + go conn.wsConnection() +} + +func (wss *WsServer) setupHttpRoutes() { + http.HandleFunc("/", wss.handleHome) + http.HandleFunc("/ws", wss.handleWs) +} + +func (wss *WsServer) sendHandler() { + for { + message := <-wss.SendChan + wss.connectionsLock.Lock() + for _, conn := range wss.connections { + conn.sendChan <- message + } + wss.connectionsLock.Unlock() + } +} + +func (wss *WsServer) StartServers() { + wss.logger.Log(logging.LevelInfo, "Starting servers...") + wss.setupHttpRoutes() + go wss.sendHandler() + if err := http.ListenAndServe(fmt.Sprintf(":%d", wss.port), nil); err != nil { + wss.logger.Log(logging.LevelError, "ListenAndServe: ", err) + } +} + +func NewWsServer(port int, logger logging.Logger) *WsServer { + wss := &WsServer{ + port: port, + connections: make(map[string]connection), + SendChan: make(chan WsMessage), + logger: logger, + } + + return wss +} diff --git a/pkg/net/grpc/grpctransport.pb.go b/pkg/net/grpc/grpctransport.pb.go index 4d1221563..7b367b225 100644 --- a/pkg/net/grpc/grpctransport.pb.go +++ b/pkg/net/grpc/grpctransport.pb.go @@ -5,8 +5,8 @@ // Code generated by protoc-gen-go. DO NOT EDIT. // versions: -// protoc-gen-go v1.25.0-devel -// protoc v3.14.0 +// protoc-gen-go v1.31.0 +// protoc v4.25.2 // source: net/grpc/grpctransport.proto package grpc diff --git a/pkg/net/grpc/grpctransport_grpc.pb.go b/pkg/net/grpc/grpctransport_grpc.pb.go index ba59dbbbe..33258bf7e 100644 --- a/pkg/net/grpc/grpctransport_grpc.pb.go +++ b/pkg/net/grpc/grpctransport_grpc.pb.go @@ -1,4 +1,13 @@ +// +//Copyright IBM Corp. All Rights Reserved. +// +//SPDX-License-Identifier: Apache-2.0 + // Code generated by protoc-gen-go-grpc. DO NOT EDIT. +// versions: +// - protoc-gen-go-grpc v1.3.0 +// - protoc v4.25.2 +// source: net/grpc/grpctransport.proto package grpc @@ -14,6 +23,10 @@ import ( // Requires gRPC-Go v1.32.0 or later. const _ = grpc.SupportPackageIsVersion7 +const ( + GrpcTransport_Listen_FullMethodName = "/grpctransport.GrpcTransport/Listen" +) + // GrpcTransportClient is the client API for GrpcTransport service. // // For semantics around ctx use and closing/ending streaming RPCs, please refer to https://pkg.go.dev/google.golang.org/grpc/?tab=doc#ClientConn.NewStream. @@ -30,7 +43,7 @@ func NewGrpcTransportClient(cc grpc.ClientConnInterface) GrpcTransportClient { } func (c *grpcTransportClient) Listen(ctx context.Context, opts ...grpc.CallOption) (GrpcTransport_ListenClient, error) { - stream, err := c.cc.NewStream(ctx, &GrpcTransport_ServiceDesc.Streams[0], "/grpctransport.GrpcTransport/Listen", opts...) + stream, err := c.cc.NewStream(ctx, &GrpcTransport_ServiceDesc.Streams[0], GrpcTransport_Listen_FullMethodName, opts...) if err != nil { return nil, err } diff --git a/pkg/pb/apppb/apppb.pb.go b/pkg/pb/apppb/apppb.pb.go index e06601992..2de466a54 100644 --- a/pkg/pb/apppb/apppb.pb.go +++ b/pkg/pb/apppb/apppb.pb.go @@ -1,7 +1,7 @@ // Code generated by protoc-gen-go. DO NOT EDIT. // versions: -// protoc-gen-go v1.25.0-devel -// protoc v3.14.0 +// protoc-gen-go v1.31.0 +// protoc v4.25.2 // source: apppb/apppb.proto package apppb @@ -28,6 +28,7 @@ type Event struct { unknownFields protoimpl.UnknownFields // Types that are assignable to Type: + // // *Event_SnapshotRequest // *Event_Snapshot // *Event_RestoreState diff --git a/pkg/pb/availabilitypb/availabilitypb.pb.go b/pkg/pb/availabilitypb/availabilitypb.pb.go index 28985f452..ae27f9f6c 100644 --- a/pkg/pb/availabilitypb/availabilitypb.pb.go +++ b/pkg/pb/availabilitypb/availabilitypb.pb.go @@ -1,7 +1,7 @@ // Code generated by protoc-gen-go. DO NOT EDIT. // versions: -// protoc-gen-go v1.25.0-devel -// protoc v3.14.0 +// protoc-gen-go v1.31.0 +// protoc v4.25.2 // source: availabilitypb/availabilitypb.proto package availabilitypb @@ -31,6 +31,7 @@ type Event struct { unknownFields protoimpl.UnknownFields // Types that are assignable to Type: + // // *Event_RequestCert // *Event_NewCert // *Event_VerifyCert @@ -521,6 +522,7 @@ type RequestCertOrigin struct { Module string `protobuf:"bytes,1,opt,name=module,proto3" json:"module,omitempty"` // Types that are assignable to Type: + // // *RequestCertOrigin_ContextStore // *RequestCertOrigin_Dsl Type isRequestCertOrigin_Type `protobuf_oneof:"type"` @@ -609,6 +611,7 @@ type RequestTransactionsOrigin struct { Module string `protobuf:"bytes,1,opt,name=module,proto3" json:"module,omitempty"` // Types that are assignable to Type: + // // *RequestTransactionsOrigin_ContextStore // *RequestTransactionsOrigin_Dsl Type isRequestTransactionsOrigin_Type `protobuf_oneof:"type"` @@ -697,6 +700,7 @@ type VerifyCertOrigin struct { Module string `protobuf:"bytes,1,opt,name=module,proto3" json:"module,omitempty"` // Types that are assignable to Type: + // // *VerifyCertOrigin_ContextStore // *VerifyCertOrigin_Dsl Type isVerifyCertOrigin_Type `protobuf_oneof:"type"` @@ -784,6 +788,7 @@ type Cert struct { unknownFields protoimpl.UnknownFields // Types that are assignable to Type: + // // *Cert_Mscs Type isCert_Type `protobuf_oneof:"type"` } diff --git a/pkg/pb/availabilitypb/batchdbpb/batchdbpb.pb.go b/pkg/pb/availabilitypb/batchdbpb/batchdbpb.pb.go index 1aeb34ad7..d52e69ab4 100644 --- a/pkg/pb/availabilitypb/batchdbpb/batchdbpb.pb.go +++ b/pkg/pb/availabilitypb/batchdbpb/batchdbpb.pb.go @@ -1,7 +1,7 @@ // Code generated by protoc-gen-go. DO NOT EDIT. // versions: -// protoc-gen-go v1.25.0-devel -// protoc v3.14.0 +// protoc-gen-go v1.31.0 +// protoc v4.25.2 // source: availabilitypb/batchdbpb/batchdbpb.proto package batchdbpb @@ -30,6 +30,7 @@ type Event struct { unknownFields protoimpl.UnknownFields // Types that are assignable to Type: + // // *Event_Lookup // *Event_LookupResponse // *Event_Store @@ -440,6 +441,7 @@ type LookupBatchOrigin struct { Module string `protobuf:"bytes,1,opt,name=module,proto3" json:"module,omitempty"` // Types that are assignable to Type: + // // *LookupBatchOrigin_ContextStore // *LookupBatchOrigin_Dsl Type isLookupBatchOrigin_Type `protobuf_oneof:"Type"` @@ -528,6 +530,7 @@ type StoreBatchOrigin struct { Module string `protobuf:"bytes,1,opt,name=module,proto3" json:"module,omitempty"` // Types that are assignable to Type: + // // *StoreBatchOrigin_ContextStore // *StoreBatchOrigin_Dsl Type isStoreBatchOrigin_Type `protobuf_oneof:"Type"` diff --git a/pkg/pb/availabilitypb/mscpb/mscpb.pb.go b/pkg/pb/availabilitypb/mscpb/mscpb.pb.go index b12d59ada..4da32c509 100644 --- a/pkg/pb/availabilitypb/mscpb/mscpb.pb.go +++ b/pkg/pb/availabilitypb/mscpb/mscpb.pb.go @@ -1,7 +1,7 @@ // Code generated by protoc-gen-go. DO NOT EDIT. // versions: -// protoc-gen-go v1.25.0-devel -// protoc v3.14.0 +// protoc-gen-go v1.31.0 +// protoc v4.25.2 // source: availabilitypb/mscpb/mscpb.proto package mscpb @@ -29,6 +29,7 @@ type Message struct { unknownFields protoimpl.UnknownFields // Types that are assignable to Type: + // // *Message_RequestSig // *Message_Sig // *Message_RequestBatch diff --git a/pkg/pb/batchfetcherpb/batchfetcherpb.pb.go b/pkg/pb/batchfetcherpb/batchfetcherpb.pb.go index f67eaeecf..62ac595e4 100644 --- a/pkg/pb/batchfetcherpb/batchfetcherpb.pb.go +++ b/pkg/pb/batchfetcherpb/batchfetcherpb.pb.go @@ -1,7 +1,7 @@ // Code generated by protoc-gen-go. DO NOT EDIT. // versions: -// protoc-gen-go v1.25.0-devel -// protoc v3.14.0 +// protoc-gen-go v1.31.0 +// protoc v4.25.2 // source: batchfetcherpb/batchfetcherpb.proto package batchfetcherpb @@ -28,6 +28,7 @@ type Event struct { unknownFields protoimpl.UnknownFields // Types that are assignable to Type: + // // *Event_NewOrderedBatch // *Event_ClientProgress Type isEvent_Type `protobuf_oneof:"Type"` diff --git a/pkg/pb/bcbpb/bcbpb.pb.go b/pkg/pb/bcbpb/bcbpb.pb.go index 67620e1e8..81a71f5e5 100644 --- a/pkg/pb/bcbpb/bcbpb.pb.go +++ b/pkg/pb/bcbpb/bcbpb.pb.go @@ -1,7 +1,7 @@ // Code generated by protoc-gen-go. DO NOT EDIT. // versions: -// protoc-gen-go v1.25.0-devel -// protoc v3.14.0 +// protoc-gen-go v1.31.0 +// protoc v4.25.2 // source: bcbpb/bcbpb.proto package bcbpb @@ -28,6 +28,7 @@ type Event struct { unknownFields protoimpl.UnknownFields // Types that are assignable to Type: + // // *Event_Request // *Event_Deliver Type isEvent_Type `protobuf_oneof:"type"` @@ -202,6 +203,7 @@ type Message struct { unknownFields protoimpl.UnknownFields // Types that are assignable to Type: + // // *Message_StartMessage // *Message_EchoMessage // *Message_FinalMessage diff --git a/pkg/pb/blockchainpb/applicationpb/applicationpb.pb.go b/pkg/pb/blockchainpb/applicationpb/applicationpb.pb.go new file mode 100644 index 000000000..3bdeecdf3 --- /dev/null +++ b/pkg/pb/blockchainpb/applicationpb/applicationpb.pb.go @@ -0,0 +1,762 @@ +// Code generated by protoc-gen-go. DO NOT EDIT. +// versions: +// protoc-gen-go v1.31.0 +// protoc v4.25.2 +// source: blockchainpb/applicationpb/applicationpb.proto + +package applicationpb + +import ( + blockchainpb "github.com/filecoin-project/mir/pkg/pb/blockchainpb" + payloadpb "github.com/filecoin-project/mir/pkg/pb/blockchainpb/payloadpb" + statepb "github.com/filecoin-project/mir/pkg/pb/blockchainpb/statepb" + _ "github.com/filecoin-project/mir/pkg/pb/mir" + protoreflect "google.golang.org/protobuf/reflect/protoreflect" + protoimpl "google.golang.org/protobuf/runtime/protoimpl" + reflect "reflect" + sync "sync" +) + +const ( + // Verify that this generated code is sufficiently up-to-date. + _ = protoimpl.EnforceVersion(20 - protoimpl.MinVersion) + // Verify that runtime/protoimpl is sufficiently up-to-date. + _ = protoimpl.EnforceVersion(protoimpl.MaxVersion - 20) +) + +type Event struct { + state protoimpl.MessageState + sizeCache protoimpl.SizeCache + unknownFields protoimpl.UnknownFields + + // Types that are assignable to Type: + // + // *Event_VerifyBlockRequest + // *Event_VerifyBlockResponse + // *Event_PayloadRequest + // *Event_PayloadResponse + // *Event_HeadChange + // *Event_MessageInput + Type isEvent_Type `protobuf_oneof:"type"` +} + +func (x *Event) Reset() { + *x = Event{} + if protoimpl.UnsafeEnabled { + mi := &file_blockchainpb_applicationpb_applicationpb_proto_msgTypes[0] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) + } +} + +func (x *Event) String() string { + return protoimpl.X.MessageStringOf(x) +} + +func (*Event) ProtoMessage() {} + +func (x *Event) ProtoReflect() protoreflect.Message { + mi := &file_blockchainpb_applicationpb_applicationpb_proto_msgTypes[0] + if protoimpl.UnsafeEnabled && x != nil { + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + if ms.LoadMessageInfo() == nil { + ms.StoreMessageInfo(mi) + } + return ms + } + return mi.MessageOf(x) +} + +// Deprecated: Use Event.ProtoReflect.Descriptor instead. +func (*Event) Descriptor() ([]byte, []int) { + return file_blockchainpb_applicationpb_applicationpb_proto_rawDescGZIP(), []int{0} +} + +func (m *Event) GetType() isEvent_Type { + if m != nil { + return m.Type + } + return nil +} + +func (x *Event) GetVerifyBlockRequest() *VerifyBlocksRequest { + if x, ok := x.GetType().(*Event_VerifyBlockRequest); ok { + return x.VerifyBlockRequest + } + return nil +} + +func (x *Event) GetVerifyBlockResponse() *VerifyBlocksResponse { + if x, ok := x.GetType().(*Event_VerifyBlockResponse); ok { + return x.VerifyBlockResponse + } + return nil +} + +func (x *Event) GetPayloadRequest() *PayloadRequest { + if x, ok := x.GetType().(*Event_PayloadRequest); ok { + return x.PayloadRequest + } + return nil +} + +func (x *Event) GetPayloadResponse() *PayloadResponse { + if x, ok := x.GetType().(*Event_PayloadResponse); ok { + return x.PayloadResponse + } + return nil +} + +func (x *Event) GetHeadChange() *HeadChange { + if x, ok := x.GetType().(*Event_HeadChange); ok { + return x.HeadChange + } + return nil +} + +func (x *Event) GetMessageInput() *MessageInput { + if x, ok := x.GetType().(*Event_MessageInput); ok { + return x.MessageInput + } + return nil +} + +type isEvent_Type interface { + isEvent_Type() +} + +type Event_VerifyBlockRequest struct { + VerifyBlockRequest *VerifyBlocksRequest `protobuf:"bytes,1,opt,name=verify_block_request,json=verifyBlockRequest,proto3,oneof"` +} + +type Event_VerifyBlockResponse struct { + VerifyBlockResponse *VerifyBlocksResponse `protobuf:"bytes,2,opt,name=verify_block_response,json=verifyBlockResponse,proto3,oneof"` +} + +type Event_PayloadRequest struct { + PayloadRequest *PayloadRequest `protobuf:"bytes,3,opt,name=payload_request,json=payloadRequest,proto3,oneof"` +} + +type Event_PayloadResponse struct { + PayloadResponse *PayloadResponse `protobuf:"bytes,4,opt,name=payload_response,json=payloadResponse,proto3,oneof"` +} + +type Event_HeadChange struct { + HeadChange *HeadChange `protobuf:"bytes,5,opt,name=head_change,json=headChange,proto3,oneof"` +} + +type Event_MessageInput struct { + // Message input + MessageInput *MessageInput `protobuf:"bytes,10,opt,name=message_input,json=messageInput,proto3,oneof"` +} + +func (*Event_VerifyBlockRequest) isEvent_Type() {} + +func (*Event_VerifyBlockResponse) isEvent_Type() {} + +func (*Event_PayloadRequest) isEvent_Type() {} + +func (*Event_PayloadResponse) isEvent_Type() {} + +func (*Event_HeadChange) isEvent_Type() {} + +func (*Event_MessageInput) isEvent_Type() {} + +type VerifyBlocksRequest struct { + state protoimpl.MessageState + sizeCache protoimpl.SizeCache + unknownFields protoimpl.UnknownFields + + CheckpointState *statepb.State `protobuf:"bytes,1,opt,name=checkpoint_state,json=checkpointState,proto3" json:"checkpoint_state,omitempty"` + ChainCheckpointToStart []*blockchainpb.Block `protobuf:"bytes,2,rep,name=chain_checkpoint_to_start,json=chainCheckpointToStart,proto3" json:"chain_checkpoint_to_start,omitempty"` + ChainToVerify []*blockchainpb.Block `protobuf:"bytes,3,rep,name=chain_to_verify,json=chainToVerify,proto3" json:"chain_to_verify,omitempty"` +} + +func (x *VerifyBlocksRequest) Reset() { + *x = VerifyBlocksRequest{} + if protoimpl.UnsafeEnabled { + mi := &file_blockchainpb_applicationpb_applicationpb_proto_msgTypes[1] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) + } +} + +func (x *VerifyBlocksRequest) String() string { + return protoimpl.X.MessageStringOf(x) +} + +func (*VerifyBlocksRequest) ProtoMessage() {} + +func (x *VerifyBlocksRequest) ProtoReflect() protoreflect.Message { + mi := &file_blockchainpb_applicationpb_applicationpb_proto_msgTypes[1] + if protoimpl.UnsafeEnabled && x != nil { + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + if ms.LoadMessageInfo() == nil { + ms.StoreMessageInfo(mi) + } + return ms + } + return mi.MessageOf(x) +} + +// Deprecated: Use VerifyBlocksRequest.ProtoReflect.Descriptor instead. +func (*VerifyBlocksRequest) Descriptor() ([]byte, []int) { + return file_blockchainpb_applicationpb_applicationpb_proto_rawDescGZIP(), []int{1} +} + +func (x *VerifyBlocksRequest) GetCheckpointState() *statepb.State { + if x != nil { + return x.CheckpointState + } + return nil +} + +func (x *VerifyBlocksRequest) GetChainCheckpointToStart() []*blockchainpb.Block { + if x != nil { + return x.ChainCheckpointToStart + } + return nil +} + +func (x *VerifyBlocksRequest) GetChainToVerify() []*blockchainpb.Block { + if x != nil { + return x.ChainToVerify + } + return nil +} + +type VerifyBlocksResponse struct { + state protoimpl.MessageState + sizeCache protoimpl.SizeCache + unknownFields protoimpl.UnknownFields + + VerifiedBlocks []*blockchainpb.Block `protobuf:"bytes,1,rep,name=verified_blocks,json=verifiedBlocks,proto3" json:"verified_blocks,omitempty"` +} + +func (x *VerifyBlocksResponse) Reset() { + *x = VerifyBlocksResponse{} + if protoimpl.UnsafeEnabled { + mi := &file_blockchainpb_applicationpb_applicationpb_proto_msgTypes[2] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) + } +} + +func (x *VerifyBlocksResponse) String() string { + return protoimpl.X.MessageStringOf(x) +} + +func (*VerifyBlocksResponse) ProtoMessage() {} + +func (x *VerifyBlocksResponse) ProtoReflect() protoreflect.Message { + mi := &file_blockchainpb_applicationpb_applicationpb_proto_msgTypes[2] + if protoimpl.UnsafeEnabled && x != nil { + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + if ms.LoadMessageInfo() == nil { + ms.StoreMessageInfo(mi) + } + return ms + } + return mi.MessageOf(x) +} + +// Deprecated: Use VerifyBlocksResponse.ProtoReflect.Descriptor instead. +func (*VerifyBlocksResponse) Descriptor() ([]byte, []int) { + return file_blockchainpb_applicationpb_applicationpb_proto_rawDescGZIP(), []int{2} +} + +func (x *VerifyBlocksResponse) GetVerifiedBlocks() []*blockchainpb.Block { + if x != nil { + return x.VerifiedBlocks + } + return nil +} + +type HeadChange struct { + state protoimpl.MessageState + sizeCache protoimpl.SizeCache + unknownFields protoimpl.UnknownFields + + RemovedChain []*blockchainpb.Block `protobuf:"bytes,1,rep,name=removed_chain,json=removedChain,proto3" json:"removed_chain,omitempty"` + AddedChain []*blockchainpb.Block `protobuf:"bytes,2,rep,name=added_chain,json=addedChain,proto3" json:"added_chain,omitempty"` + CheckpointToForkRoot []*blockchainpb.Block `protobuf:"bytes,3,rep,name=checkpoint_to_fork_root,json=checkpointToForkRoot,proto3" json:"checkpoint_to_fork_root,omitempty"` + CheckpointState *statepb.State `protobuf:"bytes,4,opt,name=checkpoint_state,json=checkpointState,proto3" json:"checkpoint_state,omitempty"` +} + +func (x *HeadChange) Reset() { + *x = HeadChange{} + if protoimpl.UnsafeEnabled { + mi := &file_blockchainpb_applicationpb_applicationpb_proto_msgTypes[3] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) + } +} + +func (x *HeadChange) String() string { + return protoimpl.X.MessageStringOf(x) +} + +func (*HeadChange) ProtoMessage() {} + +func (x *HeadChange) ProtoReflect() protoreflect.Message { + mi := &file_blockchainpb_applicationpb_applicationpb_proto_msgTypes[3] + if protoimpl.UnsafeEnabled && x != nil { + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + if ms.LoadMessageInfo() == nil { + ms.StoreMessageInfo(mi) + } + return ms + } + return mi.MessageOf(x) +} + +// Deprecated: Use HeadChange.ProtoReflect.Descriptor instead. +func (*HeadChange) Descriptor() ([]byte, []int) { + return file_blockchainpb_applicationpb_applicationpb_proto_rawDescGZIP(), []int{3} +} + +func (x *HeadChange) GetRemovedChain() []*blockchainpb.Block { + if x != nil { + return x.RemovedChain + } + return nil +} + +func (x *HeadChange) GetAddedChain() []*blockchainpb.Block { + if x != nil { + return x.AddedChain + } + return nil +} + +func (x *HeadChange) GetCheckpointToForkRoot() []*blockchainpb.Block { + if x != nil { + return x.CheckpointToForkRoot + } + return nil +} + +func (x *HeadChange) GetCheckpointState() *statepb.State { + if x != nil { + return x.CheckpointState + } + return nil +} + +type PayloadRequest struct { + state protoimpl.MessageState + sizeCache protoimpl.SizeCache + unknownFields protoimpl.UnknownFields + + HeadId uint64 `protobuf:"varint,1,opt,name=head_id,json=headId,proto3" json:"head_id,omitempty"` +} + +func (x *PayloadRequest) Reset() { + *x = PayloadRequest{} + if protoimpl.UnsafeEnabled { + mi := &file_blockchainpb_applicationpb_applicationpb_proto_msgTypes[4] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) + } +} + +func (x *PayloadRequest) String() string { + return protoimpl.X.MessageStringOf(x) +} + +func (*PayloadRequest) ProtoMessage() {} + +func (x *PayloadRequest) ProtoReflect() protoreflect.Message { + mi := &file_blockchainpb_applicationpb_applicationpb_proto_msgTypes[4] + if protoimpl.UnsafeEnabled && x != nil { + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + if ms.LoadMessageInfo() == nil { + ms.StoreMessageInfo(mi) + } + return ms + } + return mi.MessageOf(x) +} + +// Deprecated: Use PayloadRequest.ProtoReflect.Descriptor instead. +func (*PayloadRequest) Descriptor() ([]byte, []int) { + return file_blockchainpb_applicationpb_applicationpb_proto_rawDescGZIP(), []int{4} +} + +func (x *PayloadRequest) GetHeadId() uint64 { + if x != nil { + return x.HeadId + } + return 0 +} + +type PayloadResponse struct { + state protoimpl.MessageState + sizeCache protoimpl.SizeCache + unknownFields protoimpl.UnknownFields + + HeadId uint64 `protobuf:"varint,1,opt,name=head_id,json=headId,proto3" json:"head_id,omitempty"` + Payload *payloadpb.Payload `protobuf:"bytes,2,opt,name=payload,proto3" json:"payload,omitempty"` +} + +func (x *PayloadResponse) Reset() { + *x = PayloadResponse{} + if protoimpl.UnsafeEnabled { + mi := &file_blockchainpb_applicationpb_applicationpb_proto_msgTypes[5] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) + } +} + +func (x *PayloadResponse) String() string { + return protoimpl.X.MessageStringOf(x) +} + +func (*PayloadResponse) ProtoMessage() {} + +func (x *PayloadResponse) ProtoReflect() protoreflect.Message { + mi := &file_blockchainpb_applicationpb_applicationpb_proto_msgTypes[5] + if protoimpl.UnsafeEnabled && x != nil { + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + if ms.LoadMessageInfo() == nil { + ms.StoreMessageInfo(mi) + } + return ms + } + return mi.MessageOf(x) +} + +// Deprecated: Use PayloadResponse.ProtoReflect.Descriptor instead. +func (*PayloadResponse) Descriptor() ([]byte, []int) { + return file_blockchainpb_applicationpb_applicationpb_proto_rawDescGZIP(), []int{5} +} + +func (x *PayloadResponse) GetHeadId() uint64 { + if x != nil { + return x.HeadId + } + return 0 +} + +func (x *PayloadResponse) GetPayload() *payloadpb.Payload { + if x != nil { + return x.Payload + } + return nil +} + +type MessageInput struct { + state protoimpl.MessageState + sizeCache protoimpl.SizeCache + unknownFields protoimpl.UnknownFields + + Text string `protobuf:"bytes,1,opt,name=text,proto3" json:"text,omitempty"` +} + +func (x *MessageInput) Reset() { + *x = MessageInput{} + if protoimpl.UnsafeEnabled { + mi := &file_blockchainpb_applicationpb_applicationpb_proto_msgTypes[6] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) + } +} + +func (x *MessageInput) String() string { + return protoimpl.X.MessageStringOf(x) +} + +func (*MessageInput) ProtoMessage() {} + +func (x *MessageInput) ProtoReflect() protoreflect.Message { + mi := &file_blockchainpb_applicationpb_applicationpb_proto_msgTypes[6] + if protoimpl.UnsafeEnabled && x != nil { + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + if ms.LoadMessageInfo() == nil { + ms.StoreMessageInfo(mi) + } + return ms + } + return mi.MessageOf(x) +} + +// Deprecated: Use MessageInput.ProtoReflect.Descriptor instead. +func (*MessageInput) Descriptor() ([]byte, []int) { + return file_blockchainpb_applicationpb_applicationpb_proto_rawDescGZIP(), []int{6} +} + +func (x *MessageInput) GetText() string { + if x != nil { + return x.Text + } + return "" +} + +var File_blockchainpb_applicationpb_applicationpb_proto protoreflect.FileDescriptor + +var file_blockchainpb_applicationpb_applicationpb_proto_rawDesc = []byte{ + 0x0a, 0x2e, 0x62, 0x6c, 0x6f, 0x63, 0x6b, 0x63, 0x68, 0x61, 0x69, 0x6e, 0x70, 0x62, 0x2f, 0x61, + 0x70, 0x70, 0x6c, 0x69, 0x63, 0x61, 0x74, 0x69, 0x6f, 0x6e, 0x70, 0x62, 0x2f, 0x61, 0x70, 0x70, + 0x6c, 0x69, 0x63, 0x61, 0x74, 0x69, 0x6f, 0x6e, 0x70, 0x62, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, + 0x12, 0x0d, 0x61, 0x70, 0x70, 0x6c, 0x69, 0x63, 0x61, 0x74, 0x69, 0x6f, 0x6e, 0x70, 0x62, 0x1a, + 0x1c, 0x6d, 0x69, 0x72, 0x2f, 0x63, 0x6f, 0x64, 0x65, 0x67, 0x65, 0x6e, 0x5f, 0x65, 0x78, 0x74, + 0x65, 0x6e, 0x73, 0x69, 0x6f, 0x6e, 0x73, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x1a, 0x26, 0x62, + 0x6c, 0x6f, 0x63, 0x6b, 0x63, 0x68, 0x61, 0x69, 0x6e, 0x70, 0x62, 0x2f, 0x70, 0x61, 0x79, 0x6c, + 0x6f, 0x61, 0x64, 0x70, 0x62, 0x2f, 0x70, 0x61, 0x79, 0x6c, 0x6f, 0x61, 0x64, 0x70, 0x62, 0x2e, + 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x1a, 0x22, 0x62, 0x6c, 0x6f, 0x63, 0x6b, 0x63, 0x68, 0x61, 0x69, + 0x6e, 0x70, 0x62, 0x2f, 0x73, 0x74, 0x61, 0x74, 0x65, 0x70, 0x62, 0x2f, 0x73, 0x74, 0x61, 0x74, + 0x65, 0x70, 0x62, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x1a, 0x1f, 0x62, 0x6c, 0x6f, 0x63, 0x6b, + 0x63, 0x68, 0x61, 0x69, 0x6e, 0x70, 0x62, 0x2f, 0x62, 0x6c, 0x6f, 0x63, 0x6b, 0x63, 0x68, 0x61, + 0x69, 0x6e, 0x70, 0x62, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x22, 0xe7, 0x03, 0x0a, 0x05, 0x45, + 0x76, 0x65, 0x6e, 0x74, 0x12, 0x56, 0x0a, 0x14, 0x76, 0x65, 0x72, 0x69, 0x66, 0x79, 0x5f, 0x62, + 0x6c, 0x6f, 0x63, 0x6b, 0x5f, 0x72, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x18, 0x01, 0x20, 0x01, + 0x28, 0x0b, 0x32, 0x22, 0x2e, 0x61, 0x70, 0x70, 0x6c, 0x69, 0x63, 0x61, 0x74, 0x69, 0x6f, 0x6e, + 0x70, 0x62, 0x2e, 0x56, 0x65, 0x72, 0x69, 0x66, 0x79, 0x42, 0x6c, 0x6f, 0x63, 0x6b, 0x73, 0x52, + 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x48, 0x00, 0x52, 0x12, 0x76, 0x65, 0x72, 0x69, 0x66, 0x79, + 0x42, 0x6c, 0x6f, 0x63, 0x6b, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x12, 0x59, 0x0a, 0x15, + 0x76, 0x65, 0x72, 0x69, 0x66, 0x79, 0x5f, 0x62, 0x6c, 0x6f, 0x63, 0x6b, 0x5f, 0x72, 0x65, 0x73, + 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x18, 0x02, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x23, 0x2e, 0x61, 0x70, + 0x70, 0x6c, 0x69, 0x63, 0x61, 0x74, 0x69, 0x6f, 0x6e, 0x70, 0x62, 0x2e, 0x56, 0x65, 0x72, 0x69, + 0x66, 0x79, 0x42, 0x6c, 0x6f, 0x63, 0x6b, 0x73, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, + 0x48, 0x00, 0x52, 0x13, 0x76, 0x65, 0x72, 0x69, 0x66, 0x79, 0x42, 0x6c, 0x6f, 0x63, 0x6b, 0x52, + 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x12, 0x48, 0x0a, 0x0f, 0x70, 0x61, 0x79, 0x6c, 0x6f, + 0x61, 0x64, 0x5f, 0x72, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x18, 0x03, 0x20, 0x01, 0x28, 0x0b, + 0x32, 0x1d, 0x2e, 0x61, 0x70, 0x70, 0x6c, 0x69, 0x63, 0x61, 0x74, 0x69, 0x6f, 0x6e, 0x70, 0x62, + 0x2e, 0x50, 0x61, 0x79, 0x6c, 0x6f, 0x61, 0x64, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x48, + 0x00, 0x52, 0x0e, 0x70, 0x61, 0x79, 0x6c, 0x6f, 0x61, 0x64, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, + 0x74, 0x12, 0x4b, 0x0a, 0x10, 0x70, 0x61, 0x79, 0x6c, 0x6f, 0x61, 0x64, 0x5f, 0x72, 0x65, 0x73, + 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x18, 0x04, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x1e, 0x2e, 0x61, 0x70, + 0x70, 0x6c, 0x69, 0x63, 0x61, 0x74, 0x69, 0x6f, 0x6e, 0x70, 0x62, 0x2e, 0x50, 0x61, 0x79, 0x6c, + 0x6f, 0x61, 0x64, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x48, 0x00, 0x52, 0x0f, 0x70, + 0x61, 0x79, 0x6c, 0x6f, 0x61, 0x64, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x12, 0x3c, + 0x0a, 0x0b, 0x68, 0x65, 0x61, 0x64, 0x5f, 0x63, 0x68, 0x61, 0x6e, 0x67, 0x65, 0x18, 0x05, 0x20, + 0x01, 0x28, 0x0b, 0x32, 0x19, 0x2e, 0x61, 0x70, 0x70, 0x6c, 0x69, 0x63, 0x61, 0x74, 0x69, 0x6f, + 0x6e, 0x70, 0x62, 0x2e, 0x48, 0x65, 0x61, 0x64, 0x43, 0x68, 0x61, 0x6e, 0x67, 0x65, 0x48, 0x00, + 0x52, 0x0a, 0x68, 0x65, 0x61, 0x64, 0x43, 0x68, 0x61, 0x6e, 0x67, 0x65, 0x12, 0x42, 0x0a, 0x0d, + 0x6d, 0x65, 0x73, 0x73, 0x61, 0x67, 0x65, 0x5f, 0x69, 0x6e, 0x70, 0x75, 0x74, 0x18, 0x0a, 0x20, + 0x01, 0x28, 0x0b, 0x32, 0x1b, 0x2e, 0x61, 0x70, 0x70, 0x6c, 0x69, 0x63, 0x61, 0x74, 0x69, 0x6f, + 0x6e, 0x70, 0x62, 0x2e, 0x4d, 0x65, 0x73, 0x73, 0x61, 0x67, 0x65, 0x49, 0x6e, 0x70, 0x75, 0x74, + 0x48, 0x00, 0x52, 0x0c, 0x6d, 0x65, 0x73, 0x73, 0x61, 0x67, 0x65, 0x49, 0x6e, 0x70, 0x75, 0x74, + 0x3a, 0x04, 0x90, 0xa6, 0x1d, 0x01, 0x42, 0x0c, 0x0a, 0x04, 0x74, 0x79, 0x70, 0x65, 0x12, 0x04, + 0x80, 0xa6, 0x1d, 0x01, 0x22, 0xe3, 0x01, 0x0a, 0x13, 0x56, 0x65, 0x72, 0x69, 0x66, 0x79, 0x42, + 0x6c, 0x6f, 0x63, 0x6b, 0x73, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x12, 0x39, 0x0a, 0x10, + 0x63, 0x68, 0x65, 0x63, 0x6b, 0x70, 0x6f, 0x69, 0x6e, 0x74, 0x5f, 0x73, 0x74, 0x61, 0x74, 0x65, + 0x18, 0x01, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x0e, 0x2e, 0x73, 0x74, 0x61, 0x74, 0x65, 0x70, 0x62, + 0x2e, 0x53, 0x74, 0x61, 0x74, 0x65, 0x52, 0x0f, 0x63, 0x68, 0x65, 0x63, 0x6b, 0x70, 0x6f, 0x69, + 0x6e, 0x74, 0x53, 0x74, 0x61, 0x74, 0x65, 0x12, 0x4e, 0x0a, 0x19, 0x63, 0x68, 0x61, 0x69, 0x6e, + 0x5f, 0x63, 0x68, 0x65, 0x63, 0x6b, 0x70, 0x6f, 0x69, 0x6e, 0x74, 0x5f, 0x74, 0x6f, 0x5f, 0x73, + 0x74, 0x61, 0x72, 0x74, 0x18, 0x02, 0x20, 0x03, 0x28, 0x0b, 0x32, 0x13, 0x2e, 0x62, 0x6c, 0x6f, + 0x63, 0x6b, 0x63, 0x68, 0x61, 0x69, 0x6e, 0x70, 0x62, 0x2e, 0x42, 0x6c, 0x6f, 0x63, 0x6b, 0x52, + 0x16, 0x63, 0x68, 0x61, 0x69, 0x6e, 0x43, 0x68, 0x65, 0x63, 0x6b, 0x70, 0x6f, 0x69, 0x6e, 0x74, + 0x54, 0x6f, 0x53, 0x74, 0x61, 0x72, 0x74, 0x12, 0x3b, 0x0a, 0x0f, 0x63, 0x68, 0x61, 0x69, 0x6e, + 0x5f, 0x74, 0x6f, 0x5f, 0x76, 0x65, 0x72, 0x69, 0x66, 0x79, 0x18, 0x03, 0x20, 0x03, 0x28, 0x0b, + 0x32, 0x13, 0x2e, 0x62, 0x6c, 0x6f, 0x63, 0x6b, 0x63, 0x68, 0x61, 0x69, 0x6e, 0x70, 0x62, 0x2e, + 0x42, 0x6c, 0x6f, 0x63, 0x6b, 0x52, 0x0d, 0x63, 0x68, 0x61, 0x69, 0x6e, 0x54, 0x6f, 0x56, 0x65, + 0x72, 0x69, 0x66, 0x79, 0x3a, 0x04, 0x98, 0xa6, 0x1d, 0x01, 0x22, 0x5a, 0x0a, 0x14, 0x56, 0x65, + 0x72, 0x69, 0x66, 0x79, 0x42, 0x6c, 0x6f, 0x63, 0x6b, 0x73, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, + 0x73, 0x65, 0x12, 0x3c, 0x0a, 0x0f, 0x76, 0x65, 0x72, 0x69, 0x66, 0x69, 0x65, 0x64, 0x5f, 0x62, + 0x6c, 0x6f, 0x63, 0x6b, 0x73, 0x18, 0x01, 0x20, 0x03, 0x28, 0x0b, 0x32, 0x13, 0x2e, 0x62, 0x6c, + 0x6f, 0x63, 0x6b, 0x63, 0x68, 0x61, 0x69, 0x6e, 0x70, 0x62, 0x2e, 0x42, 0x6c, 0x6f, 0x63, 0x6b, + 0x52, 0x0e, 0x76, 0x65, 0x72, 0x69, 0x66, 0x69, 0x65, 0x64, 0x42, 0x6c, 0x6f, 0x63, 0x6b, 0x73, + 0x3a, 0x04, 0x98, 0xa6, 0x1d, 0x01, 0x22, 0x89, 0x02, 0x0a, 0x0a, 0x48, 0x65, 0x61, 0x64, 0x43, + 0x68, 0x61, 0x6e, 0x67, 0x65, 0x12, 0x38, 0x0a, 0x0d, 0x72, 0x65, 0x6d, 0x6f, 0x76, 0x65, 0x64, + 0x5f, 0x63, 0x68, 0x61, 0x69, 0x6e, 0x18, 0x01, 0x20, 0x03, 0x28, 0x0b, 0x32, 0x13, 0x2e, 0x62, + 0x6c, 0x6f, 0x63, 0x6b, 0x63, 0x68, 0x61, 0x69, 0x6e, 0x70, 0x62, 0x2e, 0x42, 0x6c, 0x6f, 0x63, + 0x6b, 0x52, 0x0c, 0x72, 0x65, 0x6d, 0x6f, 0x76, 0x65, 0x64, 0x43, 0x68, 0x61, 0x69, 0x6e, 0x12, + 0x34, 0x0a, 0x0b, 0x61, 0x64, 0x64, 0x65, 0x64, 0x5f, 0x63, 0x68, 0x61, 0x69, 0x6e, 0x18, 0x02, + 0x20, 0x03, 0x28, 0x0b, 0x32, 0x13, 0x2e, 0x62, 0x6c, 0x6f, 0x63, 0x6b, 0x63, 0x68, 0x61, 0x69, + 0x6e, 0x70, 0x62, 0x2e, 0x42, 0x6c, 0x6f, 0x63, 0x6b, 0x52, 0x0a, 0x61, 0x64, 0x64, 0x65, 0x64, + 0x43, 0x68, 0x61, 0x69, 0x6e, 0x12, 0x4a, 0x0a, 0x17, 0x63, 0x68, 0x65, 0x63, 0x6b, 0x70, 0x6f, + 0x69, 0x6e, 0x74, 0x5f, 0x74, 0x6f, 0x5f, 0x66, 0x6f, 0x72, 0x6b, 0x5f, 0x72, 0x6f, 0x6f, 0x74, + 0x18, 0x03, 0x20, 0x03, 0x28, 0x0b, 0x32, 0x13, 0x2e, 0x62, 0x6c, 0x6f, 0x63, 0x6b, 0x63, 0x68, + 0x61, 0x69, 0x6e, 0x70, 0x62, 0x2e, 0x42, 0x6c, 0x6f, 0x63, 0x6b, 0x52, 0x14, 0x63, 0x68, 0x65, + 0x63, 0x6b, 0x70, 0x6f, 0x69, 0x6e, 0x74, 0x54, 0x6f, 0x46, 0x6f, 0x72, 0x6b, 0x52, 0x6f, 0x6f, + 0x74, 0x12, 0x39, 0x0a, 0x10, 0x63, 0x68, 0x65, 0x63, 0x6b, 0x70, 0x6f, 0x69, 0x6e, 0x74, 0x5f, + 0x73, 0x74, 0x61, 0x74, 0x65, 0x18, 0x04, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x0e, 0x2e, 0x73, 0x74, + 0x61, 0x74, 0x65, 0x70, 0x62, 0x2e, 0x53, 0x74, 0x61, 0x74, 0x65, 0x52, 0x0f, 0x63, 0x68, 0x65, + 0x63, 0x6b, 0x70, 0x6f, 0x69, 0x6e, 0x74, 0x53, 0x74, 0x61, 0x74, 0x65, 0x3a, 0x04, 0x98, 0xa6, + 0x1d, 0x01, 0x22, 0x2f, 0x0a, 0x0e, 0x50, 0x61, 0x79, 0x6c, 0x6f, 0x61, 0x64, 0x52, 0x65, 0x71, + 0x75, 0x65, 0x73, 0x74, 0x12, 0x17, 0x0a, 0x07, 0x68, 0x65, 0x61, 0x64, 0x5f, 0x69, 0x64, 0x18, + 0x01, 0x20, 0x01, 0x28, 0x04, 0x52, 0x06, 0x68, 0x65, 0x61, 0x64, 0x49, 0x64, 0x3a, 0x04, 0x98, + 0xa6, 0x1d, 0x01, 0x22, 0x5e, 0x0a, 0x0f, 0x50, 0x61, 0x79, 0x6c, 0x6f, 0x61, 0x64, 0x52, 0x65, + 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x12, 0x17, 0x0a, 0x07, 0x68, 0x65, 0x61, 0x64, 0x5f, 0x69, + 0x64, 0x18, 0x01, 0x20, 0x01, 0x28, 0x04, 0x52, 0x06, 0x68, 0x65, 0x61, 0x64, 0x49, 0x64, 0x12, + 0x2c, 0x0a, 0x07, 0x70, 0x61, 0x79, 0x6c, 0x6f, 0x61, 0x64, 0x18, 0x02, 0x20, 0x01, 0x28, 0x0b, + 0x32, 0x12, 0x2e, 0x70, 0x61, 0x79, 0x6c, 0x6f, 0x61, 0x64, 0x70, 0x62, 0x2e, 0x50, 0x61, 0x79, + 0x6c, 0x6f, 0x61, 0x64, 0x52, 0x07, 0x70, 0x61, 0x79, 0x6c, 0x6f, 0x61, 0x64, 0x3a, 0x04, 0x98, + 0xa6, 0x1d, 0x01, 0x22, 0x28, 0x0a, 0x0c, 0x4d, 0x65, 0x73, 0x73, 0x61, 0x67, 0x65, 0x49, 0x6e, + 0x70, 0x75, 0x74, 0x12, 0x12, 0x0a, 0x04, 0x74, 0x65, 0x78, 0x74, 0x18, 0x01, 0x20, 0x01, 0x28, + 0x09, 0x52, 0x04, 0x74, 0x65, 0x78, 0x74, 0x3a, 0x04, 0x98, 0xa6, 0x1d, 0x01, 0x42, 0x43, 0x5a, + 0x41, 0x67, 0x69, 0x74, 0x68, 0x75, 0x62, 0x2e, 0x63, 0x6f, 0x6d, 0x2f, 0x66, 0x69, 0x6c, 0x65, + 0x63, 0x6f, 0x69, 0x6e, 0x2d, 0x70, 0x72, 0x6f, 0x6a, 0x65, 0x63, 0x74, 0x2f, 0x6d, 0x69, 0x72, + 0x2f, 0x70, 0x6b, 0x67, 0x2f, 0x70, 0x62, 0x2f, 0x62, 0x6c, 0x6f, 0x63, 0x6b, 0x63, 0x68, 0x61, + 0x69, 0x6e, 0x70, 0x62, 0x2f, 0x61, 0x70, 0x70, 0x6c, 0x69, 0x63, 0x61, 0x74, 0x69, 0x6f, 0x6e, + 0x70, 0x62, 0x62, 0x06, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x33, +} + +var ( + file_blockchainpb_applicationpb_applicationpb_proto_rawDescOnce sync.Once + file_blockchainpb_applicationpb_applicationpb_proto_rawDescData = file_blockchainpb_applicationpb_applicationpb_proto_rawDesc +) + +func file_blockchainpb_applicationpb_applicationpb_proto_rawDescGZIP() []byte { + file_blockchainpb_applicationpb_applicationpb_proto_rawDescOnce.Do(func() { + file_blockchainpb_applicationpb_applicationpb_proto_rawDescData = protoimpl.X.CompressGZIP(file_blockchainpb_applicationpb_applicationpb_proto_rawDescData) + }) + return file_blockchainpb_applicationpb_applicationpb_proto_rawDescData +} + +var file_blockchainpb_applicationpb_applicationpb_proto_msgTypes = make([]protoimpl.MessageInfo, 7) +var file_blockchainpb_applicationpb_applicationpb_proto_goTypes = []interface{}{ + (*Event)(nil), // 0: applicationpb.Event + (*VerifyBlocksRequest)(nil), // 1: applicationpb.VerifyBlocksRequest + (*VerifyBlocksResponse)(nil), // 2: applicationpb.VerifyBlocksResponse + (*HeadChange)(nil), // 3: applicationpb.HeadChange + (*PayloadRequest)(nil), // 4: applicationpb.PayloadRequest + (*PayloadResponse)(nil), // 5: applicationpb.PayloadResponse + (*MessageInput)(nil), // 6: applicationpb.MessageInput + (*statepb.State)(nil), // 7: statepb.State + (*blockchainpb.Block)(nil), // 8: blockchainpb.Block + (*payloadpb.Payload)(nil), // 9: payloadpb.Payload +} +var file_blockchainpb_applicationpb_applicationpb_proto_depIdxs = []int32{ + 1, // 0: applicationpb.Event.verify_block_request:type_name -> applicationpb.VerifyBlocksRequest + 2, // 1: applicationpb.Event.verify_block_response:type_name -> applicationpb.VerifyBlocksResponse + 4, // 2: applicationpb.Event.payload_request:type_name -> applicationpb.PayloadRequest + 5, // 3: applicationpb.Event.payload_response:type_name -> applicationpb.PayloadResponse + 3, // 4: applicationpb.Event.head_change:type_name -> applicationpb.HeadChange + 6, // 5: applicationpb.Event.message_input:type_name -> applicationpb.MessageInput + 7, // 6: applicationpb.VerifyBlocksRequest.checkpoint_state:type_name -> statepb.State + 8, // 7: applicationpb.VerifyBlocksRequest.chain_checkpoint_to_start:type_name -> blockchainpb.Block + 8, // 8: applicationpb.VerifyBlocksRequest.chain_to_verify:type_name -> blockchainpb.Block + 8, // 9: applicationpb.VerifyBlocksResponse.verified_blocks:type_name -> blockchainpb.Block + 8, // 10: applicationpb.HeadChange.removed_chain:type_name -> blockchainpb.Block + 8, // 11: applicationpb.HeadChange.added_chain:type_name -> blockchainpb.Block + 8, // 12: applicationpb.HeadChange.checkpoint_to_fork_root:type_name -> blockchainpb.Block + 7, // 13: applicationpb.HeadChange.checkpoint_state:type_name -> statepb.State + 9, // 14: applicationpb.PayloadResponse.payload:type_name -> payloadpb.Payload + 15, // [15:15] is the sub-list for method output_type + 15, // [15:15] is the sub-list for method input_type + 15, // [15:15] is the sub-list for extension type_name + 15, // [15:15] is the sub-list for extension extendee + 0, // [0:15] is the sub-list for field type_name +} + +func init() { file_blockchainpb_applicationpb_applicationpb_proto_init() } +func file_blockchainpb_applicationpb_applicationpb_proto_init() { + if File_blockchainpb_applicationpb_applicationpb_proto != nil { + return + } + if !protoimpl.UnsafeEnabled { + file_blockchainpb_applicationpb_applicationpb_proto_msgTypes[0].Exporter = func(v interface{}, i int) interface{} { + switch v := v.(*Event); i { + case 0: + return &v.state + case 1: + return &v.sizeCache + case 2: + return &v.unknownFields + default: + return nil + } + } + file_blockchainpb_applicationpb_applicationpb_proto_msgTypes[1].Exporter = func(v interface{}, i int) interface{} { + switch v := v.(*VerifyBlocksRequest); i { + case 0: + return &v.state + case 1: + return &v.sizeCache + case 2: + return &v.unknownFields + default: + return nil + } + } + file_blockchainpb_applicationpb_applicationpb_proto_msgTypes[2].Exporter = func(v interface{}, i int) interface{} { + switch v := v.(*VerifyBlocksResponse); i { + case 0: + return &v.state + case 1: + return &v.sizeCache + case 2: + return &v.unknownFields + default: + return nil + } + } + file_blockchainpb_applicationpb_applicationpb_proto_msgTypes[3].Exporter = func(v interface{}, i int) interface{} { + switch v := v.(*HeadChange); i { + case 0: + return &v.state + case 1: + return &v.sizeCache + case 2: + return &v.unknownFields + default: + return nil + } + } + file_blockchainpb_applicationpb_applicationpb_proto_msgTypes[4].Exporter = func(v interface{}, i int) interface{} { + switch v := v.(*PayloadRequest); i { + case 0: + return &v.state + case 1: + return &v.sizeCache + case 2: + return &v.unknownFields + default: + return nil + } + } + file_blockchainpb_applicationpb_applicationpb_proto_msgTypes[5].Exporter = func(v interface{}, i int) interface{} { + switch v := v.(*PayloadResponse); i { + case 0: + return &v.state + case 1: + return &v.sizeCache + case 2: + return &v.unknownFields + default: + return nil + } + } + file_blockchainpb_applicationpb_applicationpb_proto_msgTypes[6].Exporter = func(v interface{}, i int) interface{} { + switch v := v.(*MessageInput); i { + case 0: + return &v.state + case 1: + return &v.sizeCache + case 2: + return &v.unknownFields + default: + return nil + } + } + } + file_blockchainpb_applicationpb_applicationpb_proto_msgTypes[0].OneofWrappers = []interface{}{ + (*Event_VerifyBlockRequest)(nil), + (*Event_VerifyBlockResponse)(nil), + (*Event_PayloadRequest)(nil), + (*Event_PayloadResponse)(nil), + (*Event_HeadChange)(nil), + (*Event_MessageInput)(nil), + } + type x struct{} + out := protoimpl.TypeBuilder{ + File: protoimpl.DescBuilder{ + GoPackagePath: reflect.TypeOf(x{}).PkgPath(), + RawDescriptor: file_blockchainpb_applicationpb_applicationpb_proto_rawDesc, + NumEnums: 0, + NumMessages: 7, + NumExtensions: 0, + NumServices: 0, + }, + GoTypes: file_blockchainpb_applicationpb_applicationpb_proto_goTypes, + DependencyIndexes: file_blockchainpb_applicationpb_applicationpb_proto_depIdxs, + MessageInfos: file_blockchainpb_applicationpb_applicationpb_proto_msgTypes, + }.Build() + File_blockchainpb_applicationpb_applicationpb_proto = out.File + file_blockchainpb_applicationpb_applicationpb_proto_rawDesc = nil + file_blockchainpb_applicationpb_applicationpb_proto_goTypes = nil + file_blockchainpb_applicationpb_applicationpb_proto_depIdxs = nil +} diff --git a/pkg/pb/blockchainpb/applicationpb/applicationpb.pb.mir.go b/pkg/pb/blockchainpb/applicationpb/applicationpb.pb.mir.go new file mode 100644 index 000000000..0f330839c --- /dev/null +++ b/pkg/pb/blockchainpb/applicationpb/applicationpb.pb.mir.go @@ -0,0 +1,18 @@ +// Code generated by Mir codegen. DO NOT EDIT. + +package applicationpb + +import ( + reflect "reflect" +) + +func (*Event) ReflectTypeOptions() []reflect.Type { + return []reflect.Type{ + reflect.TypeOf((*Event_VerifyBlockRequest)(nil)), + reflect.TypeOf((*Event_VerifyBlockResponse)(nil)), + reflect.TypeOf((*Event_PayloadRequest)(nil)), + reflect.TypeOf((*Event_PayloadResponse)(nil)), + reflect.TypeOf((*Event_HeadChange)(nil)), + reflect.TypeOf((*Event_MessageInput)(nil)), + } +} diff --git a/pkg/pb/blockchainpb/applicationpb/dsl/emit.mir.go b/pkg/pb/blockchainpb/applicationpb/dsl/emit.mir.go new file mode 100644 index 000000000..a51bfebbf --- /dev/null +++ b/pkg/pb/blockchainpb/applicationpb/dsl/emit.mir.go @@ -0,0 +1,38 @@ +// Code generated by Mir codegen. DO NOT EDIT. + +package applicationpbdsl + +import ( + dsl "github.com/filecoin-project/mir/pkg/dsl" + events "github.com/filecoin-project/mir/pkg/pb/blockchainpb/applicationpb/events" + types3 "github.com/filecoin-project/mir/pkg/pb/blockchainpb/payloadpb/types" + types1 "github.com/filecoin-project/mir/pkg/pb/blockchainpb/statepb/types" + types2 "github.com/filecoin-project/mir/pkg/pb/blockchainpb/types" + types "github.com/filecoin-project/mir/pkg/types" +) + +// Module-specific dsl functions for emitting events. + +func VerifyBlocksRequest(m dsl.Module, destModule types.ModuleID, checkpointState *types1.State, chainCheckpointToStart []*types2.Block, chainToVerify []*types2.Block) { + dsl.EmitMirEvent(m, events.VerifyBlocksRequest(destModule, checkpointState, chainCheckpointToStart, chainToVerify)) +} + +func VerifyBlocksResponse(m dsl.Module, destModule types.ModuleID, verifiedBlocks []*types2.Block) { + dsl.EmitMirEvent(m, events.VerifyBlocksResponse(destModule, verifiedBlocks)) +} + +func PayloadRequest(m dsl.Module, destModule types.ModuleID, headId uint64) { + dsl.EmitMirEvent(m, events.PayloadRequest(destModule, headId)) +} + +func PayloadResponse(m dsl.Module, destModule types.ModuleID, headId uint64, payload *types3.Payload) { + dsl.EmitMirEvent(m, events.PayloadResponse(destModule, headId, payload)) +} + +func HeadChange(m dsl.Module, destModule types.ModuleID, removedChain []*types2.Block, addedChain []*types2.Block, checkpointToForkRoot []*types2.Block, checkpointState *types1.State) { + dsl.EmitMirEvent(m, events.HeadChange(destModule, removedChain, addedChain, checkpointToForkRoot, checkpointState)) +} + +func MessageInput(m dsl.Module, destModule types.ModuleID, text string) { + dsl.EmitMirEvent(m, events.MessageInput(destModule, text)) +} diff --git a/pkg/pb/blockchainpb/applicationpb/dsl/upon.mir.go b/pkg/pb/blockchainpb/applicationpb/dsl/upon.mir.go new file mode 100644 index 000000000..1338ad39f --- /dev/null +++ b/pkg/pb/blockchainpb/applicationpb/dsl/upon.mir.go @@ -0,0 +1,61 @@ +// Code generated by Mir codegen. DO NOT EDIT. + +package applicationpbdsl + +import ( + dsl "github.com/filecoin-project/mir/pkg/dsl" + types "github.com/filecoin-project/mir/pkg/pb/blockchainpb/applicationpb/types" + types4 "github.com/filecoin-project/mir/pkg/pb/blockchainpb/payloadpb/types" + types2 "github.com/filecoin-project/mir/pkg/pb/blockchainpb/statepb/types" + types3 "github.com/filecoin-project/mir/pkg/pb/blockchainpb/types" + types1 "github.com/filecoin-project/mir/pkg/pb/eventpb/types" +) + +// Module-specific dsl functions for processing events. + +func UponEvent[W types.Event_TypeWrapper[Ev], Ev any](m dsl.Module, handler func(ev *Ev) error) { + dsl.UponMirEvent[*types1.Event_Application](m, func(ev *types.Event) error { + w, ok := ev.Type.(W) + if !ok { + return nil + } + + return handler(w.Unwrap()) + }) +} + +func UponVerifyBlocksRequest(m dsl.Module, handler func(checkpointState *types2.State, chainCheckpointToStart []*types3.Block, chainToVerify []*types3.Block) error) { + UponEvent[*types.Event_VerifyBlockRequest](m, func(ev *types.VerifyBlocksRequest) error { + return handler(ev.CheckpointState, ev.ChainCheckpointToStart, ev.ChainToVerify) + }) +} + +func UponVerifyBlocksResponse(m dsl.Module, handler func(verifiedBlocks []*types3.Block) error) { + UponEvent[*types.Event_VerifyBlockResponse](m, func(ev *types.VerifyBlocksResponse) error { + return handler(ev.VerifiedBlocks) + }) +} + +func UponPayloadRequest(m dsl.Module, handler func(headId uint64) error) { + UponEvent[*types.Event_PayloadRequest](m, func(ev *types.PayloadRequest) error { + return handler(ev.HeadId) + }) +} + +func UponPayloadResponse(m dsl.Module, handler func(headId uint64, payload *types4.Payload) error) { + UponEvent[*types.Event_PayloadResponse](m, func(ev *types.PayloadResponse) error { + return handler(ev.HeadId, ev.Payload) + }) +} + +func UponHeadChange(m dsl.Module, handler func(removedChain []*types3.Block, addedChain []*types3.Block, checkpointToForkRoot []*types3.Block, checkpointState *types2.State) error) { + UponEvent[*types.Event_HeadChange](m, func(ev *types.HeadChange) error { + return handler(ev.RemovedChain, ev.AddedChain, ev.CheckpointToForkRoot, ev.CheckpointState) + }) +} + +func UponMessageInput(m dsl.Module, handler func(text string) error) { + UponEvent[*types.Event_MessageInput](m, func(ev *types.MessageInput) error { + return handler(ev.Text) + }) +} diff --git a/pkg/pb/blockchainpb/applicationpb/events/events.mir.go b/pkg/pb/blockchainpb/applicationpb/events/events.mir.go new file mode 100644 index 000000000..049c51844 --- /dev/null +++ b/pkg/pb/blockchainpb/applicationpb/events/events.mir.go @@ -0,0 +1,108 @@ +// Code generated by Mir codegen. DO NOT EDIT. + +package applicationpbevents + +import ( + types4 "github.com/filecoin-project/mir/pkg/pb/blockchainpb/applicationpb/types" + types5 "github.com/filecoin-project/mir/pkg/pb/blockchainpb/payloadpb/types" + types1 "github.com/filecoin-project/mir/pkg/pb/blockchainpb/statepb/types" + types2 "github.com/filecoin-project/mir/pkg/pb/blockchainpb/types" + types3 "github.com/filecoin-project/mir/pkg/pb/eventpb/types" + types "github.com/filecoin-project/mir/pkg/types" +) + +func VerifyBlocksRequest(destModule types.ModuleID, checkpointState *types1.State, chainCheckpointToStart []*types2.Block, chainToVerify []*types2.Block) *types3.Event { + return &types3.Event{ + DestModule: destModule, + Type: &types3.Event_Application{ + Application: &types4.Event{ + Type: &types4.Event_VerifyBlockRequest{ + VerifyBlockRequest: &types4.VerifyBlocksRequest{ + CheckpointState: checkpointState, + ChainCheckpointToStart: chainCheckpointToStart, + ChainToVerify: chainToVerify, + }, + }, + }, + }, + } +} + +func VerifyBlocksResponse(destModule types.ModuleID, verifiedBlocks []*types2.Block) *types3.Event { + return &types3.Event{ + DestModule: destModule, + Type: &types3.Event_Application{ + Application: &types4.Event{ + Type: &types4.Event_VerifyBlockResponse{ + VerifyBlockResponse: &types4.VerifyBlocksResponse{ + VerifiedBlocks: verifiedBlocks, + }, + }, + }, + }, + } +} + +func PayloadRequest(destModule types.ModuleID, headId uint64) *types3.Event { + return &types3.Event{ + DestModule: destModule, + Type: &types3.Event_Application{ + Application: &types4.Event{ + Type: &types4.Event_PayloadRequest{ + PayloadRequest: &types4.PayloadRequest{ + HeadId: headId, + }, + }, + }, + }, + } +} + +func PayloadResponse(destModule types.ModuleID, headId uint64, payload *types5.Payload) *types3.Event { + return &types3.Event{ + DestModule: destModule, + Type: &types3.Event_Application{ + Application: &types4.Event{ + Type: &types4.Event_PayloadResponse{ + PayloadResponse: &types4.PayloadResponse{ + HeadId: headId, + Payload: payload, + }, + }, + }, + }, + } +} + +func HeadChange(destModule types.ModuleID, removedChain []*types2.Block, addedChain []*types2.Block, checkpointToForkRoot []*types2.Block, checkpointState *types1.State) *types3.Event { + return &types3.Event{ + DestModule: destModule, + Type: &types3.Event_Application{ + Application: &types4.Event{ + Type: &types4.Event_HeadChange{ + HeadChange: &types4.HeadChange{ + RemovedChain: removedChain, + AddedChain: addedChain, + CheckpointToForkRoot: checkpointToForkRoot, + CheckpointState: checkpointState, + }, + }, + }, + }, + } +} + +func MessageInput(destModule types.ModuleID, text string) *types3.Event { + return &types3.Event{ + DestModule: destModule, + Type: &types3.Event_Application{ + Application: &types4.Event{ + Type: &types4.Event_MessageInput{ + MessageInput: &types4.MessageInput{ + Text: text, + }, + }, + }, + }, + } +} diff --git a/pkg/pb/blockchainpb/applicationpb/oneof_interfaces.mir.go b/pkg/pb/blockchainpb/applicationpb/oneof_interfaces.mir.go new file mode 100644 index 000000000..0994da1e5 --- /dev/null +++ b/pkg/pb/blockchainpb/applicationpb/oneof_interfaces.mir.go @@ -0,0 +1,34 @@ +// Code generated by Mir codegen. DO NOT EDIT. + +package applicationpb + +type Event_Type = isEvent_Type + +type Event_TypeWrapper[T any] interface { + Event_Type + Unwrap() *T +} + +func (w *Event_VerifyBlockRequest) Unwrap() *VerifyBlocksRequest { + return w.VerifyBlockRequest +} + +func (w *Event_VerifyBlockResponse) Unwrap() *VerifyBlocksResponse { + return w.VerifyBlockResponse +} + +func (w *Event_PayloadRequest) Unwrap() *PayloadRequest { + return w.PayloadRequest +} + +func (w *Event_PayloadResponse) Unwrap() *PayloadResponse { + return w.PayloadResponse +} + +func (w *Event_HeadChange) Unwrap() *HeadChange { + return w.HeadChange +} + +func (w *Event_MessageInput) Unwrap() *MessageInput { + return w.MessageInput +} diff --git a/pkg/pb/blockchainpb/applicationpb/types/types.mir.go b/pkg/pb/blockchainpb/applicationpb/types/types.mir.go new file mode 100644 index 000000000..8e9060202 --- /dev/null +++ b/pkg/pb/blockchainpb/applicationpb/types/types.mir.go @@ -0,0 +1,443 @@ +// Code generated by Mir codegen. DO NOT EDIT. + +package applicationpbtypes + +import ( + mirreflect "github.com/filecoin-project/mir/codegen/mirreflect" + types2 "github.com/filecoin-project/mir/codegen/model/types" + blockchainpb "github.com/filecoin-project/mir/pkg/pb/blockchainpb" + applicationpb "github.com/filecoin-project/mir/pkg/pb/blockchainpb/applicationpb" + types3 "github.com/filecoin-project/mir/pkg/pb/blockchainpb/payloadpb/types" + types "github.com/filecoin-project/mir/pkg/pb/blockchainpb/statepb/types" + types1 "github.com/filecoin-project/mir/pkg/pb/blockchainpb/types" + reflectutil "github.com/filecoin-project/mir/pkg/util/reflectutil" +) + +type Event struct { + Type Event_Type +} + +type Event_Type interface { + mirreflect.GeneratedType + isEvent_Type() + Pb() applicationpb.Event_Type +} + +type Event_TypeWrapper[T any] interface { + Event_Type + Unwrap() *T +} + +func Event_TypeFromPb(pb applicationpb.Event_Type) Event_Type { + if pb == nil { + return nil + } + switch pb := pb.(type) { + case *applicationpb.Event_VerifyBlockRequest: + return &Event_VerifyBlockRequest{VerifyBlockRequest: VerifyBlocksRequestFromPb(pb.VerifyBlockRequest)} + case *applicationpb.Event_VerifyBlockResponse: + return &Event_VerifyBlockResponse{VerifyBlockResponse: VerifyBlocksResponseFromPb(pb.VerifyBlockResponse)} + case *applicationpb.Event_PayloadRequest: + return &Event_PayloadRequest{PayloadRequest: PayloadRequestFromPb(pb.PayloadRequest)} + case *applicationpb.Event_PayloadResponse: + return &Event_PayloadResponse{PayloadResponse: PayloadResponseFromPb(pb.PayloadResponse)} + case *applicationpb.Event_HeadChange: + return &Event_HeadChange{HeadChange: HeadChangeFromPb(pb.HeadChange)} + case *applicationpb.Event_MessageInput: + return &Event_MessageInput{MessageInput: MessageInputFromPb(pb.MessageInput)} + } + return nil +} + +type Event_VerifyBlockRequest struct { + VerifyBlockRequest *VerifyBlocksRequest +} + +func (*Event_VerifyBlockRequest) isEvent_Type() {} + +func (w *Event_VerifyBlockRequest) Unwrap() *VerifyBlocksRequest { + return w.VerifyBlockRequest +} + +func (w *Event_VerifyBlockRequest) Pb() applicationpb.Event_Type { + if w == nil { + return nil + } + if w.VerifyBlockRequest == nil { + return &applicationpb.Event_VerifyBlockRequest{} + } + return &applicationpb.Event_VerifyBlockRequest{VerifyBlockRequest: (w.VerifyBlockRequest).Pb()} +} + +func (*Event_VerifyBlockRequest) MirReflect() mirreflect.Type { + return mirreflect.TypeImpl{PbType_: reflectutil.TypeOf[*applicationpb.Event_VerifyBlockRequest]()} +} + +type Event_VerifyBlockResponse struct { + VerifyBlockResponse *VerifyBlocksResponse +} + +func (*Event_VerifyBlockResponse) isEvent_Type() {} + +func (w *Event_VerifyBlockResponse) Unwrap() *VerifyBlocksResponse { + return w.VerifyBlockResponse +} + +func (w *Event_VerifyBlockResponse) Pb() applicationpb.Event_Type { + if w == nil { + return nil + } + if w.VerifyBlockResponse == nil { + return &applicationpb.Event_VerifyBlockResponse{} + } + return &applicationpb.Event_VerifyBlockResponse{VerifyBlockResponse: (w.VerifyBlockResponse).Pb()} +} + +func (*Event_VerifyBlockResponse) MirReflect() mirreflect.Type { + return mirreflect.TypeImpl{PbType_: reflectutil.TypeOf[*applicationpb.Event_VerifyBlockResponse]()} +} + +type Event_PayloadRequest struct { + PayloadRequest *PayloadRequest +} + +func (*Event_PayloadRequest) isEvent_Type() {} + +func (w *Event_PayloadRequest) Unwrap() *PayloadRequest { + return w.PayloadRequest +} + +func (w *Event_PayloadRequest) Pb() applicationpb.Event_Type { + if w == nil { + return nil + } + if w.PayloadRequest == nil { + return &applicationpb.Event_PayloadRequest{} + } + return &applicationpb.Event_PayloadRequest{PayloadRequest: (w.PayloadRequest).Pb()} +} + +func (*Event_PayloadRequest) MirReflect() mirreflect.Type { + return mirreflect.TypeImpl{PbType_: reflectutil.TypeOf[*applicationpb.Event_PayloadRequest]()} +} + +type Event_PayloadResponse struct { + PayloadResponse *PayloadResponse +} + +func (*Event_PayloadResponse) isEvent_Type() {} + +func (w *Event_PayloadResponse) Unwrap() *PayloadResponse { + return w.PayloadResponse +} + +func (w *Event_PayloadResponse) Pb() applicationpb.Event_Type { + if w == nil { + return nil + } + if w.PayloadResponse == nil { + return &applicationpb.Event_PayloadResponse{} + } + return &applicationpb.Event_PayloadResponse{PayloadResponse: (w.PayloadResponse).Pb()} +} + +func (*Event_PayloadResponse) MirReflect() mirreflect.Type { + return mirreflect.TypeImpl{PbType_: reflectutil.TypeOf[*applicationpb.Event_PayloadResponse]()} +} + +type Event_HeadChange struct { + HeadChange *HeadChange +} + +func (*Event_HeadChange) isEvent_Type() {} + +func (w *Event_HeadChange) Unwrap() *HeadChange { + return w.HeadChange +} + +func (w *Event_HeadChange) Pb() applicationpb.Event_Type { + if w == nil { + return nil + } + if w.HeadChange == nil { + return &applicationpb.Event_HeadChange{} + } + return &applicationpb.Event_HeadChange{HeadChange: (w.HeadChange).Pb()} +} + +func (*Event_HeadChange) MirReflect() mirreflect.Type { + return mirreflect.TypeImpl{PbType_: reflectutil.TypeOf[*applicationpb.Event_HeadChange]()} +} + +type Event_MessageInput struct { + MessageInput *MessageInput +} + +func (*Event_MessageInput) isEvent_Type() {} + +func (w *Event_MessageInput) Unwrap() *MessageInput { + return w.MessageInput +} + +func (w *Event_MessageInput) Pb() applicationpb.Event_Type { + if w == nil { + return nil + } + if w.MessageInput == nil { + return &applicationpb.Event_MessageInput{} + } + return &applicationpb.Event_MessageInput{MessageInput: (w.MessageInput).Pb()} +} + +func (*Event_MessageInput) MirReflect() mirreflect.Type { + return mirreflect.TypeImpl{PbType_: reflectutil.TypeOf[*applicationpb.Event_MessageInput]()} +} + +func EventFromPb(pb *applicationpb.Event) *Event { + if pb == nil { + return nil + } + return &Event{ + Type: Event_TypeFromPb(pb.Type), + } +} + +func (m *Event) Pb() *applicationpb.Event { + if m == nil { + return nil + } + pbMessage := &applicationpb.Event{} + { + if m.Type != nil { + pbMessage.Type = (m.Type).Pb() + } + } + + return pbMessage +} + +func (*Event) MirReflect() mirreflect.Type { + return mirreflect.TypeImpl{PbType_: reflectutil.TypeOf[*applicationpb.Event]()} +} + +type VerifyBlocksRequest struct { + CheckpointState *types.State + ChainCheckpointToStart []*types1.Block + ChainToVerify []*types1.Block +} + +func VerifyBlocksRequestFromPb(pb *applicationpb.VerifyBlocksRequest) *VerifyBlocksRequest { + if pb == nil { + return nil + } + return &VerifyBlocksRequest{ + CheckpointState: types.StateFromPb(pb.CheckpointState), + ChainCheckpointToStart: types2.ConvertSlice(pb.ChainCheckpointToStart, func(t *blockchainpb.Block) *types1.Block { + return types1.BlockFromPb(t) + }), + ChainToVerify: types2.ConvertSlice(pb.ChainToVerify, func(t *blockchainpb.Block) *types1.Block { + return types1.BlockFromPb(t) + }), + } +} + +func (m *VerifyBlocksRequest) Pb() *applicationpb.VerifyBlocksRequest { + if m == nil { + return nil + } + pbMessage := &applicationpb.VerifyBlocksRequest{} + { + if m.CheckpointState != nil { + pbMessage.CheckpointState = (m.CheckpointState).Pb() + } + pbMessage.ChainCheckpointToStart = types2.ConvertSlice(m.ChainCheckpointToStart, func(t *types1.Block) *blockchainpb.Block { + return (t).Pb() + }) + pbMessage.ChainToVerify = types2.ConvertSlice(m.ChainToVerify, func(t *types1.Block) *blockchainpb.Block { + return (t).Pb() + }) + } + + return pbMessage +} + +func (*VerifyBlocksRequest) MirReflect() mirreflect.Type { + return mirreflect.TypeImpl{PbType_: reflectutil.TypeOf[*applicationpb.VerifyBlocksRequest]()} +} + +type VerifyBlocksResponse struct { + VerifiedBlocks []*types1.Block +} + +func VerifyBlocksResponseFromPb(pb *applicationpb.VerifyBlocksResponse) *VerifyBlocksResponse { + if pb == nil { + return nil + } + return &VerifyBlocksResponse{ + VerifiedBlocks: types2.ConvertSlice(pb.VerifiedBlocks, func(t *blockchainpb.Block) *types1.Block { + return types1.BlockFromPb(t) + }), + } +} + +func (m *VerifyBlocksResponse) Pb() *applicationpb.VerifyBlocksResponse { + if m == nil { + return nil + } + pbMessage := &applicationpb.VerifyBlocksResponse{} + { + pbMessage.VerifiedBlocks = types2.ConvertSlice(m.VerifiedBlocks, func(t *types1.Block) *blockchainpb.Block { + return (t).Pb() + }) + } + + return pbMessage +} + +func (*VerifyBlocksResponse) MirReflect() mirreflect.Type { + return mirreflect.TypeImpl{PbType_: reflectutil.TypeOf[*applicationpb.VerifyBlocksResponse]()} +} + +type HeadChange struct { + RemovedChain []*types1.Block + AddedChain []*types1.Block + CheckpointToForkRoot []*types1.Block + CheckpointState *types.State +} + +func HeadChangeFromPb(pb *applicationpb.HeadChange) *HeadChange { + if pb == nil { + return nil + } + return &HeadChange{ + RemovedChain: types2.ConvertSlice(pb.RemovedChain, func(t *blockchainpb.Block) *types1.Block { + return types1.BlockFromPb(t) + }), + AddedChain: types2.ConvertSlice(pb.AddedChain, func(t *blockchainpb.Block) *types1.Block { + return types1.BlockFromPb(t) + }), + CheckpointToForkRoot: types2.ConvertSlice(pb.CheckpointToForkRoot, func(t *blockchainpb.Block) *types1.Block { + return types1.BlockFromPb(t) + }), + CheckpointState: types.StateFromPb(pb.CheckpointState), + } +} + +func (m *HeadChange) Pb() *applicationpb.HeadChange { + if m == nil { + return nil + } + pbMessage := &applicationpb.HeadChange{} + { + pbMessage.RemovedChain = types2.ConvertSlice(m.RemovedChain, func(t *types1.Block) *blockchainpb.Block { + return (t).Pb() + }) + pbMessage.AddedChain = types2.ConvertSlice(m.AddedChain, func(t *types1.Block) *blockchainpb.Block { + return (t).Pb() + }) + pbMessage.CheckpointToForkRoot = types2.ConvertSlice(m.CheckpointToForkRoot, func(t *types1.Block) *blockchainpb.Block { + return (t).Pb() + }) + if m.CheckpointState != nil { + pbMessage.CheckpointState = (m.CheckpointState).Pb() + } + } + + return pbMessage +} + +func (*HeadChange) MirReflect() mirreflect.Type { + return mirreflect.TypeImpl{PbType_: reflectutil.TypeOf[*applicationpb.HeadChange]()} +} + +type PayloadRequest struct { + HeadId uint64 +} + +func PayloadRequestFromPb(pb *applicationpb.PayloadRequest) *PayloadRequest { + if pb == nil { + return nil + } + return &PayloadRequest{ + HeadId: pb.HeadId, + } +} + +func (m *PayloadRequest) Pb() *applicationpb.PayloadRequest { + if m == nil { + return nil + } + pbMessage := &applicationpb.PayloadRequest{} + { + pbMessage.HeadId = m.HeadId + } + + return pbMessage +} + +func (*PayloadRequest) MirReflect() mirreflect.Type { + return mirreflect.TypeImpl{PbType_: reflectutil.TypeOf[*applicationpb.PayloadRequest]()} +} + +type PayloadResponse struct { + HeadId uint64 + Payload *types3.Payload +} + +func PayloadResponseFromPb(pb *applicationpb.PayloadResponse) *PayloadResponse { + if pb == nil { + return nil + } + return &PayloadResponse{ + HeadId: pb.HeadId, + Payload: types3.PayloadFromPb(pb.Payload), + } +} + +func (m *PayloadResponse) Pb() *applicationpb.PayloadResponse { + if m == nil { + return nil + } + pbMessage := &applicationpb.PayloadResponse{} + { + pbMessage.HeadId = m.HeadId + if m.Payload != nil { + pbMessage.Payload = (m.Payload).Pb() + } + } + + return pbMessage +} + +func (*PayloadResponse) MirReflect() mirreflect.Type { + return mirreflect.TypeImpl{PbType_: reflectutil.TypeOf[*applicationpb.PayloadResponse]()} +} + +type MessageInput struct { + Text string +} + +func MessageInputFromPb(pb *applicationpb.MessageInput) *MessageInput { + if pb == nil { + return nil + } + return &MessageInput{ + Text: pb.Text, + } +} + +func (m *MessageInput) Pb() *applicationpb.MessageInput { + if m == nil { + return nil + } + pbMessage := &applicationpb.MessageInput{} + { + pbMessage.Text = m.Text + } + + return pbMessage +} + +func (*MessageInput) MirReflect() mirreflect.Type { + return mirreflect.TypeImpl{PbType_: reflectutil.TypeOf[*applicationpb.MessageInput]()} +} diff --git a/pkg/pb/blockchainpb/bcmpb/bcmpb.pb.go b/pkg/pb/blockchainpb/bcmpb/bcmpb.pb.go new file mode 100644 index 000000000..91ff2a44e --- /dev/null +++ b/pkg/pb/blockchainpb/bcmpb/bcmpb.pb.go @@ -0,0 +1,928 @@ +// Code generated by protoc-gen-go. DO NOT EDIT. +// versions: +// protoc-gen-go v1.31.0 +// protoc v4.25.2 +// source: blockchainpb/bcmpb/bcmpb.proto + +package bcmpb + +import ( + blockchainpb "github.com/filecoin-project/mir/pkg/pb/blockchainpb" + statepb "github.com/filecoin-project/mir/pkg/pb/blockchainpb/statepb" + _ "github.com/filecoin-project/mir/pkg/pb/mir" + protoreflect "google.golang.org/protobuf/reflect/protoreflect" + protoimpl "google.golang.org/protobuf/runtime/protoimpl" + reflect "reflect" + sync "sync" +) + +const ( + // Verify that this generated code is sufficiently up-to-date. + _ = protoimpl.EnforceVersion(20 - protoimpl.MinVersion) + // Verify that runtime/protoimpl is sufficiently up-to-date. + _ = protoimpl.EnforceVersion(protoimpl.MaxVersion - 20) +) + +type Event struct { + state protoimpl.MessageState + sizeCache protoimpl.SizeCache + unknownFields protoimpl.UnknownFields + + // Types that are assignable to Type: + // + // *Event_NewBlock + // *Event_NewChain + // *Event_GetChainRequest + // *Event_GetChainResponse + // *Event_RegisterCheckpoint + // *Event_GetChainToHeadRequest + // *Event_GetChainToHeadResponse + // *Event_InitBlockchain + Type isEvent_Type `protobuf_oneof:"type"` +} + +func (x *Event) Reset() { + *x = Event{} + if protoimpl.UnsafeEnabled { + mi := &file_blockchainpb_bcmpb_bcmpb_proto_msgTypes[0] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) + } +} + +func (x *Event) String() string { + return protoimpl.X.MessageStringOf(x) +} + +func (*Event) ProtoMessage() {} + +func (x *Event) ProtoReflect() protoreflect.Message { + mi := &file_blockchainpb_bcmpb_bcmpb_proto_msgTypes[0] + if protoimpl.UnsafeEnabled && x != nil { + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + if ms.LoadMessageInfo() == nil { + ms.StoreMessageInfo(mi) + } + return ms + } + return mi.MessageOf(x) +} + +// Deprecated: Use Event.ProtoReflect.Descriptor instead. +func (*Event) Descriptor() ([]byte, []int) { + return file_blockchainpb_bcmpb_bcmpb_proto_rawDescGZIP(), []int{0} +} + +func (m *Event) GetType() isEvent_Type { + if m != nil { + return m.Type + } + return nil +} + +func (x *Event) GetNewBlock() *NewBlock { + if x, ok := x.GetType().(*Event_NewBlock); ok { + return x.NewBlock + } + return nil +} + +func (x *Event) GetNewChain() *NewChain { + if x, ok := x.GetType().(*Event_NewChain); ok { + return x.NewChain + } + return nil +} + +func (x *Event) GetGetChainRequest() *GetChainRequest { + if x, ok := x.GetType().(*Event_GetChainRequest); ok { + return x.GetChainRequest + } + return nil +} + +func (x *Event) GetGetChainResponse() *GetChainResponse { + if x, ok := x.GetType().(*Event_GetChainResponse); ok { + return x.GetChainResponse + } + return nil +} + +func (x *Event) GetRegisterCheckpoint() *RegisterCheckpoint { + if x, ok := x.GetType().(*Event_RegisterCheckpoint); ok { + return x.RegisterCheckpoint + } + return nil +} + +func (x *Event) GetGetChainToHeadRequest() *GetChainToHeadRequest { + if x, ok := x.GetType().(*Event_GetChainToHeadRequest); ok { + return x.GetChainToHeadRequest + } + return nil +} + +func (x *Event) GetGetChainToHeadResponse() *GetChainToHeadResponse { + if x, ok := x.GetType().(*Event_GetChainToHeadResponse); ok { + return x.GetChainToHeadResponse + } + return nil +} + +func (x *Event) GetInitBlockchain() *InitBlockchain { + if x, ok := x.GetType().(*Event_InitBlockchain); ok { + return x.InitBlockchain + } + return nil +} + +type isEvent_Type interface { + isEvent_Type() +} + +type Event_NewBlock struct { + NewBlock *NewBlock `protobuf:"bytes,1,opt,name=new_block,json=newBlock,proto3,oneof"` +} + +type Event_NewChain struct { + NewChain *NewChain `protobuf:"bytes,2,opt,name=new_chain,json=newChain,proto3,oneof"` +} + +type Event_GetChainRequest struct { + GetChainRequest *GetChainRequest `protobuf:"bytes,5,opt,name=get_chain_request,json=getChainRequest,proto3,oneof"` +} + +type Event_GetChainResponse struct { + GetChainResponse *GetChainResponse `protobuf:"bytes,6,opt,name=get_chain_response,json=getChainResponse,proto3,oneof"` +} + +type Event_RegisterCheckpoint struct { + RegisterCheckpoint *RegisterCheckpoint `protobuf:"bytes,7,opt,name=register_checkpoint,json=registerCheckpoint,proto3,oneof"` +} + +type Event_GetChainToHeadRequest struct { + GetChainToHeadRequest *GetChainToHeadRequest `protobuf:"bytes,8,opt,name=get_chain_to_head_request,json=getChainToHeadRequest,proto3,oneof"` +} + +type Event_GetChainToHeadResponse struct { + GetChainToHeadResponse *GetChainToHeadResponse `protobuf:"bytes,9,opt,name=get_chain_to_head_response,json=getChainToHeadResponse,proto3,oneof"` +} + +type Event_InitBlockchain struct { + InitBlockchain *InitBlockchain `protobuf:"bytes,100,opt,name=init_blockchain,json=initBlockchain,proto3,oneof"` +} + +func (*Event_NewBlock) isEvent_Type() {} + +func (*Event_NewChain) isEvent_Type() {} + +func (*Event_GetChainRequest) isEvent_Type() {} + +func (*Event_GetChainResponse) isEvent_Type() {} + +func (*Event_RegisterCheckpoint) isEvent_Type() {} + +func (*Event_GetChainToHeadRequest) isEvent_Type() {} + +func (*Event_GetChainToHeadResponse) isEvent_Type() {} + +func (*Event_InitBlockchain) isEvent_Type() {} + +type NewBlock struct { + state protoimpl.MessageState + sizeCache protoimpl.SizeCache + unknownFields protoimpl.UnknownFields + + Block *blockchainpb.Block `protobuf:"bytes,1,opt,name=block,proto3" json:"block,omitempty"` +} + +func (x *NewBlock) Reset() { + *x = NewBlock{} + if protoimpl.UnsafeEnabled { + mi := &file_blockchainpb_bcmpb_bcmpb_proto_msgTypes[1] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) + } +} + +func (x *NewBlock) String() string { + return protoimpl.X.MessageStringOf(x) +} + +func (*NewBlock) ProtoMessage() {} + +func (x *NewBlock) ProtoReflect() protoreflect.Message { + mi := &file_blockchainpb_bcmpb_bcmpb_proto_msgTypes[1] + if protoimpl.UnsafeEnabled && x != nil { + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + if ms.LoadMessageInfo() == nil { + ms.StoreMessageInfo(mi) + } + return ms + } + return mi.MessageOf(x) +} + +// Deprecated: Use NewBlock.ProtoReflect.Descriptor instead. +func (*NewBlock) Descriptor() ([]byte, []int) { + return file_blockchainpb_bcmpb_bcmpb_proto_rawDescGZIP(), []int{1} +} + +func (x *NewBlock) GetBlock() *blockchainpb.Block { + if x != nil { + return x.Block + } + return nil +} + +type NewChain struct { + state protoimpl.MessageState + sizeCache protoimpl.SizeCache + unknownFields protoimpl.UnknownFields + + // chain segment ordered blocks[0]<-blocks[1]<-blocks[2]... + Blocks []*blockchainpb.Block `protobuf:"bytes,1,rep,name=blocks,proto3" json:"blocks,omitempty"` +} + +func (x *NewChain) Reset() { + *x = NewChain{} + if protoimpl.UnsafeEnabled { + mi := &file_blockchainpb_bcmpb_bcmpb_proto_msgTypes[2] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) + } +} + +func (x *NewChain) String() string { + return protoimpl.X.MessageStringOf(x) +} + +func (*NewChain) ProtoMessage() {} + +func (x *NewChain) ProtoReflect() protoreflect.Message { + mi := &file_blockchainpb_bcmpb_bcmpb_proto_msgTypes[2] + if protoimpl.UnsafeEnabled && x != nil { + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + if ms.LoadMessageInfo() == nil { + ms.StoreMessageInfo(mi) + } + return ms + } + return mi.MessageOf(x) +} + +// Deprecated: Use NewChain.ProtoReflect.Descriptor instead. +func (*NewChain) Descriptor() ([]byte, []int) { + return file_blockchainpb_bcmpb_bcmpb_proto_rawDescGZIP(), []int{2} +} + +func (x *NewChain) GetBlocks() []*blockchainpb.Block { + if x != nil { + return x.Blocks + } + return nil +} + +type GetChainRequest struct { + state protoimpl.MessageState + sizeCache protoimpl.SizeCache + unknownFields protoimpl.UnknownFields + + RequestId string `protobuf:"bytes,1,opt,name=request_id,json=requestId,proto3" json:"request_id,omitempty"` + SourceModule string `protobuf:"bytes,2,opt,name=source_module,json=sourceModule,proto3" json:"source_module,omitempty"` + EndBlockId uint64 `protobuf:"varint,3,opt,name=end_block_id,json=endBlockId,proto3" json:"end_block_id,omitempty"` + SourceBlockIds []uint64 `protobuf:"varint,4,rep,packed,name=source_block_ids,json=sourceBlockIds,proto3" json:"source_block_ids,omitempty"` +} + +func (x *GetChainRequest) Reset() { + *x = GetChainRequest{} + if protoimpl.UnsafeEnabled { + mi := &file_blockchainpb_bcmpb_bcmpb_proto_msgTypes[3] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) + } +} + +func (x *GetChainRequest) String() string { + return protoimpl.X.MessageStringOf(x) +} + +func (*GetChainRequest) ProtoMessage() {} + +func (x *GetChainRequest) ProtoReflect() protoreflect.Message { + mi := &file_blockchainpb_bcmpb_bcmpb_proto_msgTypes[3] + if protoimpl.UnsafeEnabled && x != nil { + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + if ms.LoadMessageInfo() == nil { + ms.StoreMessageInfo(mi) + } + return ms + } + return mi.MessageOf(x) +} + +// Deprecated: Use GetChainRequest.ProtoReflect.Descriptor instead. +func (*GetChainRequest) Descriptor() ([]byte, []int) { + return file_blockchainpb_bcmpb_bcmpb_proto_rawDescGZIP(), []int{3} +} + +func (x *GetChainRequest) GetRequestId() string { + if x != nil { + return x.RequestId + } + return "" +} + +func (x *GetChainRequest) GetSourceModule() string { + if x != nil { + return x.SourceModule + } + return "" +} + +func (x *GetChainRequest) GetEndBlockId() uint64 { + if x != nil { + return x.EndBlockId + } + return 0 +} + +func (x *GetChainRequest) GetSourceBlockIds() []uint64 { + if x != nil { + return x.SourceBlockIds + } + return nil +} + +type GetChainResponse struct { + state protoimpl.MessageState + sizeCache protoimpl.SizeCache + unknownFields protoimpl.UnknownFields + + RequestId string `protobuf:"bytes,1,opt,name=request_id,json=requestId,proto3" json:"request_id,omitempty"` + Success bool `protobuf:"varint,2,opt,name=success,proto3" json:"success,omitempty"` + Chain []*blockchainpb.Block `protobuf:"bytes,3,rep,name=chain,proto3" json:"chain,omitempty"` // sorted from oldest to youngest +} + +func (x *GetChainResponse) Reset() { + *x = GetChainResponse{} + if protoimpl.UnsafeEnabled { + mi := &file_blockchainpb_bcmpb_bcmpb_proto_msgTypes[4] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) + } +} + +func (x *GetChainResponse) String() string { + return protoimpl.X.MessageStringOf(x) +} + +func (*GetChainResponse) ProtoMessage() {} + +func (x *GetChainResponse) ProtoReflect() protoreflect.Message { + mi := &file_blockchainpb_bcmpb_bcmpb_proto_msgTypes[4] + if protoimpl.UnsafeEnabled && x != nil { + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + if ms.LoadMessageInfo() == nil { + ms.StoreMessageInfo(mi) + } + return ms + } + return mi.MessageOf(x) +} + +// Deprecated: Use GetChainResponse.ProtoReflect.Descriptor instead. +func (*GetChainResponse) Descriptor() ([]byte, []int) { + return file_blockchainpb_bcmpb_bcmpb_proto_rawDescGZIP(), []int{4} +} + +func (x *GetChainResponse) GetRequestId() string { + if x != nil { + return x.RequestId + } + return "" +} + +func (x *GetChainResponse) GetSuccess() bool { + if x != nil { + return x.Success + } + return false +} + +func (x *GetChainResponse) GetChain() []*blockchainpb.Block { + if x != nil { + return x.Chain + } + return nil +} + +type GetChainToHeadRequest struct { + state protoimpl.MessageState + sizeCache protoimpl.SizeCache + unknownFields protoimpl.UnknownFields + + SourceModule string `protobuf:"bytes,1,opt,name=source_module,json=sourceModule,proto3" json:"source_module,omitempty"` +} + +func (x *GetChainToHeadRequest) Reset() { + *x = GetChainToHeadRequest{} + if protoimpl.UnsafeEnabled { + mi := &file_blockchainpb_bcmpb_bcmpb_proto_msgTypes[5] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) + } +} + +func (x *GetChainToHeadRequest) String() string { + return protoimpl.X.MessageStringOf(x) +} + +func (*GetChainToHeadRequest) ProtoMessage() {} + +func (x *GetChainToHeadRequest) ProtoReflect() protoreflect.Message { + mi := &file_blockchainpb_bcmpb_bcmpb_proto_msgTypes[5] + if protoimpl.UnsafeEnabled && x != nil { + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + if ms.LoadMessageInfo() == nil { + ms.StoreMessageInfo(mi) + } + return ms + } + return mi.MessageOf(x) +} + +// Deprecated: Use GetChainToHeadRequest.ProtoReflect.Descriptor instead. +func (*GetChainToHeadRequest) Descriptor() ([]byte, []int) { + return file_blockchainpb_bcmpb_bcmpb_proto_rawDescGZIP(), []int{5} +} + +func (x *GetChainToHeadRequest) GetSourceModule() string { + if x != nil { + return x.SourceModule + } + return "" +} + +type GetChainToHeadResponse struct { + state protoimpl.MessageState + sizeCache protoimpl.SizeCache + unknownFields protoimpl.UnknownFields + + Chain []*blockchainpb.Block `protobuf:"bytes,1,rep,name=chain,proto3" json:"chain,omitempty"` // sorted from oldest to youngest + CheckpointState *statepb.State `protobuf:"bytes,2,opt,name=checkpointState,proto3" json:"checkpointState,omitempty"` +} + +func (x *GetChainToHeadResponse) Reset() { + *x = GetChainToHeadResponse{} + if protoimpl.UnsafeEnabled { + mi := &file_blockchainpb_bcmpb_bcmpb_proto_msgTypes[6] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) + } +} + +func (x *GetChainToHeadResponse) String() string { + return protoimpl.X.MessageStringOf(x) +} + +func (*GetChainToHeadResponse) ProtoMessage() {} + +func (x *GetChainToHeadResponse) ProtoReflect() protoreflect.Message { + mi := &file_blockchainpb_bcmpb_bcmpb_proto_msgTypes[6] + if protoimpl.UnsafeEnabled && x != nil { + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + if ms.LoadMessageInfo() == nil { + ms.StoreMessageInfo(mi) + } + return ms + } + return mi.MessageOf(x) +} + +// Deprecated: Use GetChainToHeadResponse.ProtoReflect.Descriptor instead. +func (*GetChainToHeadResponse) Descriptor() ([]byte, []int) { + return file_blockchainpb_bcmpb_bcmpb_proto_rawDescGZIP(), []int{6} +} + +func (x *GetChainToHeadResponse) GetChain() []*blockchainpb.Block { + if x != nil { + return x.Chain + } + return nil +} + +func (x *GetChainToHeadResponse) GetCheckpointState() *statepb.State { + if x != nil { + return x.CheckpointState + } + return nil +} + +type RegisterCheckpoint struct { + state protoimpl.MessageState + sizeCache protoimpl.SizeCache + unknownFields protoimpl.UnknownFields + + BlockId uint64 `protobuf:"varint,1,opt,name=block_id,json=blockId,proto3" json:"block_id,omitempty"` + State *statepb.State `protobuf:"bytes,2,opt,name=state,proto3" json:"state,omitempty"` +} + +func (x *RegisterCheckpoint) Reset() { + *x = RegisterCheckpoint{} + if protoimpl.UnsafeEnabled { + mi := &file_blockchainpb_bcmpb_bcmpb_proto_msgTypes[7] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) + } +} + +func (x *RegisterCheckpoint) String() string { + return protoimpl.X.MessageStringOf(x) +} + +func (*RegisterCheckpoint) ProtoMessage() {} + +func (x *RegisterCheckpoint) ProtoReflect() protoreflect.Message { + mi := &file_blockchainpb_bcmpb_bcmpb_proto_msgTypes[7] + if protoimpl.UnsafeEnabled && x != nil { + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + if ms.LoadMessageInfo() == nil { + ms.StoreMessageInfo(mi) + } + return ms + } + return mi.MessageOf(x) +} + +// Deprecated: Use RegisterCheckpoint.ProtoReflect.Descriptor instead. +func (*RegisterCheckpoint) Descriptor() ([]byte, []int) { + return file_blockchainpb_bcmpb_bcmpb_proto_rawDescGZIP(), []int{7} +} + +func (x *RegisterCheckpoint) GetBlockId() uint64 { + if x != nil { + return x.BlockId + } + return 0 +} + +func (x *RegisterCheckpoint) GetState() *statepb.State { + if x != nil { + return x.State + } + return nil +} + +type InitBlockchain struct { + state protoimpl.MessageState + sizeCache protoimpl.SizeCache + unknownFields protoimpl.UnknownFields + + InitialState *statepb.State `protobuf:"bytes,1,opt,name=initial_state,json=initialState,proto3" json:"initial_state,omitempty"` +} + +func (x *InitBlockchain) Reset() { + *x = InitBlockchain{} + if protoimpl.UnsafeEnabled { + mi := &file_blockchainpb_bcmpb_bcmpb_proto_msgTypes[8] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) + } +} + +func (x *InitBlockchain) String() string { + return protoimpl.X.MessageStringOf(x) +} + +func (*InitBlockchain) ProtoMessage() {} + +func (x *InitBlockchain) ProtoReflect() protoreflect.Message { + mi := &file_blockchainpb_bcmpb_bcmpb_proto_msgTypes[8] + if protoimpl.UnsafeEnabled && x != nil { + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + if ms.LoadMessageInfo() == nil { + ms.StoreMessageInfo(mi) + } + return ms + } + return mi.MessageOf(x) +} + +// Deprecated: Use InitBlockchain.ProtoReflect.Descriptor instead. +func (*InitBlockchain) Descriptor() ([]byte, []int) { + return file_blockchainpb_bcmpb_bcmpb_proto_rawDescGZIP(), []int{8} +} + +func (x *InitBlockchain) GetInitialState() *statepb.State { + if x != nil { + return x.InitialState + } + return nil +} + +var File_blockchainpb_bcmpb_bcmpb_proto protoreflect.FileDescriptor + +var file_blockchainpb_bcmpb_bcmpb_proto_rawDesc = []byte{ + 0x0a, 0x1e, 0x62, 0x6c, 0x6f, 0x63, 0x6b, 0x63, 0x68, 0x61, 0x69, 0x6e, 0x70, 0x62, 0x2f, 0x62, + 0x63, 0x6d, 0x70, 0x62, 0x2f, 0x62, 0x63, 0x6d, 0x70, 0x62, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, + 0x12, 0x05, 0x62, 0x63, 0x6d, 0x70, 0x62, 0x1a, 0x1f, 0x62, 0x6c, 0x6f, 0x63, 0x6b, 0x63, 0x68, + 0x61, 0x69, 0x6e, 0x70, 0x62, 0x2f, 0x62, 0x6c, 0x6f, 0x63, 0x6b, 0x63, 0x68, 0x61, 0x69, 0x6e, + 0x70, 0x62, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x1a, 0x22, 0x62, 0x6c, 0x6f, 0x63, 0x6b, 0x63, + 0x68, 0x61, 0x69, 0x6e, 0x70, 0x62, 0x2f, 0x73, 0x74, 0x61, 0x74, 0x65, 0x70, 0x62, 0x2f, 0x73, + 0x74, 0x61, 0x74, 0x65, 0x70, 0x62, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x1a, 0x1c, 0x6d, 0x69, + 0x72, 0x2f, 0x63, 0x6f, 0x64, 0x65, 0x67, 0x65, 0x6e, 0x5f, 0x65, 0x78, 0x74, 0x65, 0x6e, 0x73, + 0x69, 0x6f, 0x6e, 0x73, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x22, 0xd1, 0x04, 0x0a, 0x05, 0x45, + 0x76, 0x65, 0x6e, 0x74, 0x12, 0x2e, 0x0a, 0x09, 0x6e, 0x65, 0x77, 0x5f, 0x62, 0x6c, 0x6f, 0x63, + 0x6b, 0x18, 0x01, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x0f, 0x2e, 0x62, 0x63, 0x6d, 0x70, 0x62, 0x2e, + 0x4e, 0x65, 0x77, 0x42, 0x6c, 0x6f, 0x63, 0x6b, 0x48, 0x00, 0x52, 0x08, 0x6e, 0x65, 0x77, 0x42, + 0x6c, 0x6f, 0x63, 0x6b, 0x12, 0x2e, 0x0a, 0x09, 0x6e, 0x65, 0x77, 0x5f, 0x63, 0x68, 0x61, 0x69, + 0x6e, 0x18, 0x02, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x0f, 0x2e, 0x62, 0x63, 0x6d, 0x70, 0x62, 0x2e, + 0x4e, 0x65, 0x77, 0x43, 0x68, 0x61, 0x69, 0x6e, 0x48, 0x00, 0x52, 0x08, 0x6e, 0x65, 0x77, 0x43, + 0x68, 0x61, 0x69, 0x6e, 0x12, 0x44, 0x0a, 0x11, 0x67, 0x65, 0x74, 0x5f, 0x63, 0x68, 0x61, 0x69, + 0x6e, 0x5f, 0x72, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x18, 0x05, 0x20, 0x01, 0x28, 0x0b, 0x32, + 0x16, 0x2e, 0x62, 0x63, 0x6d, 0x70, 0x62, 0x2e, 0x47, 0x65, 0x74, 0x43, 0x68, 0x61, 0x69, 0x6e, + 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x48, 0x00, 0x52, 0x0f, 0x67, 0x65, 0x74, 0x43, 0x68, + 0x61, 0x69, 0x6e, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x12, 0x47, 0x0a, 0x12, 0x67, 0x65, + 0x74, 0x5f, 0x63, 0x68, 0x61, 0x69, 0x6e, 0x5f, 0x72, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, + 0x18, 0x06, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x17, 0x2e, 0x62, 0x63, 0x6d, 0x70, 0x62, 0x2e, 0x47, + 0x65, 0x74, 0x43, 0x68, 0x61, 0x69, 0x6e, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x48, + 0x00, 0x52, 0x10, 0x67, 0x65, 0x74, 0x43, 0x68, 0x61, 0x69, 0x6e, 0x52, 0x65, 0x73, 0x70, 0x6f, + 0x6e, 0x73, 0x65, 0x12, 0x4c, 0x0a, 0x13, 0x72, 0x65, 0x67, 0x69, 0x73, 0x74, 0x65, 0x72, 0x5f, + 0x63, 0x68, 0x65, 0x63, 0x6b, 0x70, 0x6f, 0x69, 0x6e, 0x74, 0x18, 0x07, 0x20, 0x01, 0x28, 0x0b, + 0x32, 0x19, 0x2e, 0x62, 0x63, 0x6d, 0x70, 0x62, 0x2e, 0x52, 0x65, 0x67, 0x69, 0x73, 0x74, 0x65, + 0x72, 0x43, 0x68, 0x65, 0x63, 0x6b, 0x70, 0x6f, 0x69, 0x6e, 0x74, 0x48, 0x00, 0x52, 0x12, 0x72, + 0x65, 0x67, 0x69, 0x73, 0x74, 0x65, 0x72, 0x43, 0x68, 0x65, 0x63, 0x6b, 0x70, 0x6f, 0x69, 0x6e, + 0x74, 0x12, 0x58, 0x0a, 0x19, 0x67, 0x65, 0x74, 0x5f, 0x63, 0x68, 0x61, 0x69, 0x6e, 0x5f, 0x74, + 0x6f, 0x5f, 0x68, 0x65, 0x61, 0x64, 0x5f, 0x72, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x18, 0x08, + 0x20, 0x01, 0x28, 0x0b, 0x32, 0x1c, 0x2e, 0x62, 0x63, 0x6d, 0x70, 0x62, 0x2e, 0x47, 0x65, 0x74, + 0x43, 0x68, 0x61, 0x69, 0x6e, 0x54, 0x6f, 0x48, 0x65, 0x61, 0x64, 0x52, 0x65, 0x71, 0x75, 0x65, + 0x73, 0x74, 0x48, 0x00, 0x52, 0x15, 0x67, 0x65, 0x74, 0x43, 0x68, 0x61, 0x69, 0x6e, 0x54, 0x6f, + 0x48, 0x65, 0x61, 0x64, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x12, 0x5b, 0x0a, 0x1a, 0x67, + 0x65, 0x74, 0x5f, 0x63, 0x68, 0x61, 0x69, 0x6e, 0x5f, 0x74, 0x6f, 0x5f, 0x68, 0x65, 0x61, 0x64, + 0x5f, 0x72, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x18, 0x09, 0x20, 0x01, 0x28, 0x0b, 0x32, + 0x1d, 0x2e, 0x62, 0x63, 0x6d, 0x70, 0x62, 0x2e, 0x47, 0x65, 0x74, 0x43, 0x68, 0x61, 0x69, 0x6e, + 0x54, 0x6f, 0x48, 0x65, 0x61, 0x64, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x48, 0x00, + 0x52, 0x16, 0x67, 0x65, 0x74, 0x43, 0x68, 0x61, 0x69, 0x6e, 0x54, 0x6f, 0x48, 0x65, 0x61, 0x64, + 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x12, 0x40, 0x0a, 0x0f, 0x69, 0x6e, 0x69, 0x74, + 0x5f, 0x62, 0x6c, 0x6f, 0x63, 0x6b, 0x63, 0x68, 0x61, 0x69, 0x6e, 0x18, 0x64, 0x20, 0x01, 0x28, + 0x0b, 0x32, 0x15, 0x2e, 0x62, 0x63, 0x6d, 0x70, 0x62, 0x2e, 0x49, 0x6e, 0x69, 0x74, 0x42, 0x6c, + 0x6f, 0x63, 0x6b, 0x63, 0x68, 0x61, 0x69, 0x6e, 0x48, 0x00, 0x52, 0x0e, 0x69, 0x6e, 0x69, 0x74, + 0x42, 0x6c, 0x6f, 0x63, 0x6b, 0x63, 0x68, 0x61, 0x69, 0x6e, 0x3a, 0x04, 0x90, 0xa6, 0x1d, 0x01, + 0x42, 0x0c, 0x0a, 0x04, 0x74, 0x79, 0x70, 0x65, 0x12, 0x04, 0x80, 0xa6, 0x1d, 0x01, 0x22, 0x3b, + 0x0a, 0x08, 0x4e, 0x65, 0x77, 0x42, 0x6c, 0x6f, 0x63, 0x6b, 0x12, 0x29, 0x0a, 0x05, 0x62, 0x6c, + 0x6f, 0x63, 0x6b, 0x18, 0x01, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x13, 0x2e, 0x62, 0x6c, 0x6f, 0x63, + 0x6b, 0x63, 0x68, 0x61, 0x69, 0x6e, 0x70, 0x62, 0x2e, 0x42, 0x6c, 0x6f, 0x63, 0x6b, 0x52, 0x05, + 0x62, 0x6c, 0x6f, 0x63, 0x6b, 0x3a, 0x04, 0x98, 0xa6, 0x1d, 0x01, 0x22, 0x3d, 0x0a, 0x08, 0x4e, + 0x65, 0x77, 0x43, 0x68, 0x61, 0x69, 0x6e, 0x12, 0x2b, 0x0a, 0x06, 0x62, 0x6c, 0x6f, 0x63, 0x6b, + 0x73, 0x18, 0x01, 0x20, 0x03, 0x28, 0x0b, 0x32, 0x13, 0x2e, 0x62, 0x6c, 0x6f, 0x63, 0x6b, 0x63, + 0x68, 0x61, 0x69, 0x6e, 0x70, 0x62, 0x2e, 0x42, 0x6c, 0x6f, 0x63, 0x6b, 0x52, 0x06, 0x62, 0x6c, + 0x6f, 0x63, 0x6b, 0x73, 0x3a, 0x04, 0x98, 0xa6, 0x1d, 0x01, 0x22, 0xdf, 0x01, 0x0a, 0x0f, 0x47, + 0x65, 0x74, 0x43, 0x68, 0x61, 0x69, 0x6e, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x12, 0x1d, + 0x0a, 0x0a, 0x72, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x5f, 0x69, 0x64, 0x18, 0x01, 0x20, 0x01, + 0x28, 0x09, 0x52, 0x09, 0x72, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x49, 0x64, 0x12, 0x5b, 0x0a, + 0x0d, 0x73, 0x6f, 0x75, 0x72, 0x63, 0x65, 0x5f, 0x6d, 0x6f, 0x64, 0x75, 0x6c, 0x65, 0x18, 0x02, + 0x20, 0x01, 0x28, 0x09, 0x42, 0x36, 0x82, 0xa6, 0x1d, 0x32, 0x67, 0x69, 0x74, 0x68, 0x75, 0x62, + 0x2e, 0x63, 0x6f, 0x6d, 0x2f, 0x66, 0x69, 0x6c, 0x65, 0x63, 0x6f, 0x69, 0x6e, 0x2d, 0x70, 0x72, + 0x6f, 0x6a, 0x65, 0x63, 0x74, 0x2f, 0x6d, 0x69, 0x72, 0x2f, 0x70, 0x6b, 0x67, 0x2f, 0x74, 0x79, + 0x70, 0x65, 0x73, 0x2e, 0x4d, 0x6f, 0x64, 0x75, 0x6c, 0x65, 0x49, 0x44, 0x52, 0x0c, 0x73, 0x6f, + 0x75, 0x72, 0x63, 0x65, 0x4d, 0x6f, 0x64, 0x75, 0x6c, 0x65, 0x12, 0x20, 0x0a, 0x0c, 0x65, 0x6e, + 0x64, 0x5f, 0x62, 0x6c, 0x6f, 0x63, 0x6b, 0x5f, 0x69, 0x64, 0x18, 0x03, 0x20, 0x01, 0x28, 0x04, + 0x52, 0x0a, 0x65, 0x6e, 0x64, 0x42, 0x6c, 0x6f, 0x63, 0x6b, 0x49, 0x64, 0x12, 0x28, 0x0a, 0x10, + 0x73, 0x6f, 0x75, 0x72, 0x63, 0x65, 0x5f, 0x62, 0x6c, 0x6f, 0x63, 0x6b, 0x5f, 0x69, 0x64, 0x73, + 0x18, 0x04, 0x20, 0x03, 0x28, 0x04, 0x52, 0x0e, 0x73, 0x6f, 0x75, 0x72, 0x63, 0x65, 0x42, 0x6c, + 0x6f, 0x63, 0x6b, 0x49, 0x64, 0x73, 0x3a, 0x04, 0x98, 0xa6, 0x1d, 0x01, 0x22, 0x7c, 0x0a, 0x10, + 0x47, 0x65, 0x74, 0x43, 0x68, 0x61, 0x69, 0x6e, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, + 0x12, 0x1d, 0x0a, 0x0a, 0x72, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x5f, 0x69, 0x64, 0x18, 0x01, + 0x20, 0x01, 0x28, 0x09, 0x52, 0x09, 0x72, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x49, 0x64, 0x12, + 0x18, 0x0a, 0x07, 0x73, 0x75, 0x63, 0x63, 0x65, 0x73, 0x73, 0x18, 0x02, 0x20, 0x01, 0x28, 0x08, + 0x52, 0x07, 0x73, 0x75, 0x63, 0x63, 0x65, 0x73, 0x73, 0x12, 0x29, 0x0a, 0x05, 0x63, 0x68, 0x61, + 0x69, 0x6e, 0x18, 0x03, 0x20, 0x03, 0x28, 0x0b, 0x32, 0x13, 0x2e, 0x62, 0x6c, 0x6f, 0x63, 0x6b, + 0x63, 0x68, 0x61, 0x69, 0x6e, 0x70, 0x62, 0x2e, 0x42, 0x6c, 0x6f, 0x63, 0x6b, 0x52, 0x05, 0x63, + 0x68, 0x61, 0x69, 0x6e, 0x3a, 0x04, 0x98, 0xa6, 0x1d, 0x01, 0x22, 0x7a, 0x0a, 0x15, 0x47, 0x65, + 0x74, 0x43, 0x68, 0x61, 0x69, 0x6e, 0x54, 0x6f, 0x48, 0x65, 0x61, 0x64, 0x52, 0x65, 0x71, 0x75, + 0x65, 0x73, 0x74, 0x12, 0x5b, 0x0a, 0x0d, 0x73, 0x6f, 0x75, 0x72, 0x63, 0x65, 0x5f, 0x6d, 0x6f, + 0x64, 0x75, 0x6c, 0x65, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x42, 0x36, 0x82, 0xa6, 0x1d, 0x32, + 0x67, 0x69, 0x74, 0x68, 0x75, 0x62, 0x2e, 0x63, 0x6f, 0x6d, 0x2f, 0x66, 0x69, 0x6c, 0x65, 0x63, + 0x6f, 0x69, 0x6e, 0x2d, 0x70, 0x72, 0x6f, 0x6a, 0x65, 0x63, 0x74, 0x2f, 0x6d, 0x69, 0x72, 0x2f, + 0x70, 0x6b, 0x67, 0x2f, 0x74, 0x79, 0x70, 0x65, 0x73, 0x2e, 0x4d, 0x6f, 0x64, 0x75, 0x6c, 0x65, + 0x49, 0x44, 0x52, 0x0c, 0x73, 0x6f, 0x75, 0x72, 0x63, 0x65, 0x4d, 0x6f, 0x64, 0x75, 0x6c, 0x65, + 0x3a, 0x04, 0x98, 0xa6, 0x1d, 0x01, 0x22, 0x83, 0x01, 0x0a, 0x16, 0x47, 0x65, 0x74, 0x43, 0x68, + 0x61, 0x69, 0x6e, 0x54, 0x6f, 0x48, 0x65, 0x61, 0x64, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, + 0x65, 0x12, 0x29, 0x0a, 0x05, 0x63, 0x68, 0x61, 0x69, 0x6e, 0x18, 0x01, 0x20, 0x03, 0x28, 0x0b, + 0x32, 0x13, 0x2e, 0x62, 0x6c, 0x6f, 0x63, 0x6b, 0x63, 0x68, 0x61, 0x69, 0x6e, 0x70, 0x62, 0x2e, + 0x42, 0x6c, 0x6f, 0x63, 0x6b, 0x52, 0x05, 0x63, 0x68, 0x61, 0x69, 0x6e, 0x12, 0x38, 0x0a, 0x0f, + 0x63, 0x68, 0x65, 0x63, 0x6b, 0x70, 0x6f, 0x69, 0x6e, 0x74, 0x53, 0x74, 0x61, 0x74, 0x65, 0x18, + 0x02, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x0e, 0x2e, 0x73, 0x74, 0x61, 0x74, 0x65, 0x70, 0x62, 0x2e, + 0x53, 0x74, 0x61, 0x74, 0x65, 0x52, 0x0f, 0x63, 0x68, 0x65, 0x63, 0x6b, 0x70, 0x6f, 0x69, 0x6e, + 0x74, 0x53, 0x74, 0x61, 0x74, 0x65, 0x3a, 0x04, 0x98, 0xa6, 0x1d, 0x01, 0x22, 0x5b, 0x0a, 0x12, + 0x52, 0x65, 0x67, 0x69, 0x73, 0x74, 0x65, 0x72, 0x43, 0x68, 0x65, 0x63, 0x6b, 0x70, 0x6f, 0x69, + 0x6e, 0x74, 0x12, 0x19, 0x0a, 0x08, 0x62, 0x6c, 0x6f, 0x63, 0x6b, 0x5f, 0x69, 0x64, 0x18, 0x01, + 0x20, 0x01, 0x28, 0x04, 0x52, 0x07, 0x62, 0x6c, 0x6f, 0x63, 0x6b, 0x49, 0x64, 0x12, 0x24, 0x0a, + 0x05, 0x73, 0x74, 0x61, 0x74, 0x65, 0x18, 0x02, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x0e, 0x2e, 0x73, + 0x74, 0x61, 0x74, 0x65, 0x70, 0x62, 0x2e, 0x53, 0x74, 0x61, 0x74, 0x65, 0x52, 0x05, 0x73, 0x74, + 0x61, 0x74, 0x65, 0x3a, 0x04, 0x98, 0xa6, 0x1d, 0x01, 0x22, 0x4b, 0x0a, 0x0e, 0x49, 0x6e, 0x69, + 0x74, 0x42, 0x6c, 0x6f, 0x63, 0x6b, 0x63, 0x68, 0x61, 0x69, 0x6e, 0x12, 0x33, 0x0a, 0x0d, 0x69, + 0x6e, 0x69, 0x74, 0x69, 0x61, 0x6c, 0x5f, 0x73, 0x74, 0x61, 0x74, 0x65, 0x18, 0x01, 0x20, 0x01, + 0x28, 0x0b, 0x32, 0x0e, 0x2e, 0x73, 0x74, 0x61, 0x74, 0x65, 0x70, 0x62, 0x2e, 0x53, 0x74, 0x61, + 0x74, 0x65, 0x52, 0x0c, 0x69, 0x6e, 0x69, 0x74, 0x69, 0x61, 0x6c, 0x53, 0x74, 0x61, 0x74, 0x65, + 0x3a, 0x04, 0x98, 0xa6, 0x1d, 0x01, 0x42, 0x3b, 0x5a, 0x39, 0x67, 0x69, 0x74, 0x68, 0x75, 0x62, + 0x2e, 0x63, 0x6f, 0x6d, 0x2f, 0x66, 0x69, 0x6c, 0x65, 0x63, 0x6f, 0x69, 0x6e, 0x2d, 0x70, 0x72, + 0x6f, 0x6a, 0x65, 0x63, 0x74, 0x2f, 0x6d, 0x69, 0x72, 0x2f, 0x70, 0x6b, 0x67, 0x2f, 0x70, 0x62, + 0x2f, 0x62, 0x6c, 0x6f, 0x63, 0x6b, 0x63, 0x68, 0x61, 0x69, 0x6e, 0x70, 0x62, 0x2f, 0x62, 0x63, + 0x6d, 0x70, 0x62, 0x62, 0x06, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x33, +} + +var ( + file_blockchainpb_bcmpb_bcmpb_proto_rawDescOnce sync.Once + file_blockchainpb_bcmpb_bcmpb_proto_rawDescData = file_blockchainpb_bcmpb_bcmpb_proto_rawDesc +) + +func file_blockchainpb_bcmpb_bcmpb_proto_rawDescGZIP() []byte { + file_blockchainpb_bcmpb_bcmpb_proto_rawDescOnce.Do(func() { + file_blockchainpb_bcmpb_bcmpb_proto_rawDescData = protoimpl.X.CompressGZIP(file_blockchainpb_bcmpb_bcmpb_proto_rawDescData) + }) + return file_blockchainpb_bcmpb_bcmpb_proto_rawDescData +} + +var file_blockchainpb_bcmpb_bcmpb_proto_msgTypes = make([]protoimpl.MessageInfo, 9) +var file_blockchainpb_bcmpb_bcmpb_proto_goTypes = []interface{}{ + (*Event)(nil), // 0: bcmpb.Event + (*NewBlock)(nil), // 1: bcmpb.NewBlock + (*NewChain)(nil), // 2: bcmpb.NewChain + (*GetChainRequest)(nil), // 3: bcmpb.GetChainRequest + (*GetChainResponse)(nil), // 4: bcmpb.GetChainResponse + (*GetChainToHeadRequest)(nil), // 5: bcmpb.GetChainToHeadRequest + (*GetChainToHeadResponse)(nil), // 6: bcmpb.GetChainToHeadResponse + (*RegisterCheckpoint)(nil), // 7: bcmpb.RegisterCheckpoint + (*InitBlockchain)(nil), // 8: bcmpb.InitBlockchain + (*blockchainpb.Block)(nil), // 9: blockchainpb.Block + (*statepb.State)(nil), // 10: statepb.State +} +var file_blockchainpb_bcmpb_bcmpb_proto_depIdxs = []int32{ + 1, // 0: bcmpb.Event.new_block:type_name -> bcmpb.NewBlock + 2, // 1: bcmpb.Event.new_chain:type_name -> bcmpb.NewChain + 3, // 2: bcmpb.Event.get_chain_request:type_name -> bcmpb.GetChainRequest + 4, // 3: bcmpb.Event.get_chain_response:type_name -> bcmpb.GetChainResponse + 7, // 4: bcmpb.Event.register_checkpoint:type_name -> bcmpb.RegisterCheckpoint + 5, // 5: bcmpb.Event.get_chain_to_head_request:type_name -> bcmpb.GetChainToHeadRequest + 6, // 6: bcmpb.Event.get_chain_to_head_response:type_name -> bcmpb.GetChainToHeadResponse + 8, // 7: bcmpb.Event.init_blockchain:type_name -> bcmpb.InitBlockchain + 9, // 8: bcmpb.NewBlock.block:type_name -> blockchainpb.Block + 9, // 9: bcmpb.NewChain.blocks:type_name -> blockchainpb.Block + 9, // 10: bcmpb.GetChainResponse.chain:type_name -> blockchainpb.Block + 9, // 11: bcmpb.GetChainToHeadResponse.chain:type_name -> blockchainpb.Block + 10, // 12: bcmpb.GetChainToHeadResponse.checkpointState:type_name -> statepb.State + 10, // 13: bcmpb.RegisterCheckpoint.state:type_name -> statepb.State + 10, // 14: bcmpb.InitBlockchain.initial_state:type_name -> statepb.State + 15, // [15:15] is the sub-list for method output_type + 15, // [15:15] is the sub-list for method input_type + 15, // [15:15] is the sub-list for extension type_name + 15, // [15:15] is the sub-list for extension extendee + 0, // [0:15] is the sub-list for field type_name +} + +func init() { file_blockchainpb_bcmpb_bcmpb_proto_init() } +func file_blockchainpb_bcmpb_bcmpb_proto_init() { + if File_blockchainpb_bcmpb_bcmpb_proto != nil { + return + } + if !protoimpl.UnsafeEnabled { + file_blockchainpb_bcmpb_bcmpb_proto_msgTypes[0].Exporter = func(v interface{}, i int) interface{} { + switch v := v.(*Event); i { + case 0: + return &v.state + case 1: + return &v.sizeCache + case 2: + return &v.unknownFields + default: + return nil + } + } + file_blockchainpb_bcmpb_bcmpb_proto_msgTypes[1].Exporter = func(v interface{}, i int) interface{} { + switch v := v.(*NewBlock); i { + case 0: + return &v.state + case 1: + return &v.sizeCache + case 2: + return &v.unknownFields + default: + return nil + } + } + file_blockchainpb_bcmpb_bcmpb_proto_msgTypes[2].Exporter = func(v interface{}, i int) interface{} { + switch v := v.(*NewChain); i { + case 0: + return &v.state + case 1: + return &v.sizeCache + case 2: + return &v.unknownFields + default: + return nil + } + } + file_blockchainpb_bcmpb_bcmpb_proto_msgTypes[3].Exporter = func(v interface{}, i int) interface{} { + switch v := v.(*GetChainRequest); i { + case 0: + return &v.state + case 1: + return &v.sizeCache + case 2: + return &v.unknownFields + default: + return nil + } + } + file_blockchainpb_bcmpb_bcmpb_proto_msgTypes[4].Exporter = func(v interface{}, i int) interface{} { + switch v := v.(*GetChainResponse); i { + case 0: + return &v.state + case 1: + return &v.sizeCache + case 2: + return &v.unknownFields + default: + return nil + } + } + file_blockchainpb_bcmpb_bcmpb_proto_msgTypes[5].Exporter = func(v interface{}, i int) interface{} { + switch v := v.(*GetChainToHeadRequest); i { + case 0: + return &v.state + case 1: + return &v.sizeCache + case 2: + return &v.unknownFields + default: + return nil + } + } + file_blockchainpb_bcmpb_bcmpb_proto_msgTypes[6].Exporter = func(v interface{}, i int) interface{} { + switch v := v.(*GetChainToHeadResponse); i { + case 0: + return &v.state + case 1: + return &v.sizeCache + case 2: + return &v.unknownFields + default: + return nil + } + } + file_blockchainpb_bcmpb_bcmpb_proto_msgTypes[7].Exporter = func(v interface{}, i int) interface{} { + switch v := v.(*RegisterCheckpoint); i { + case 0: + return &v.state + case 1: + return &v.sizeCache + case 2: + return &v.unknownFields + default: + return nil + } + } + file_blockchainpb_bcmpb_bcmpb_proto_msgTypes[8].Exporter = func(v interface{}, i int) interface{} { + switch v := v.(*InitBlockchain); i { + case 0: + return &v.state + case 1: + return &v.sizeCache + case 2: + return &v.unknownFields + default: + return nil + } + } + } + file_blockchainpb_bcmpb_bcmpb_proto_msgTypes[0].OneofWrappers = []interface{}{ + (*Event_NewBlock)(nil), + (*Event_NewChain)(nil), + (*Event_GetChainRequest)(nil), + (*Event_GetChainResponse)(nil), + (*Event_RegisterCheckpoint)(nil), + (*Event_GetChainToHeadRequest)(nil), + (*Event_GetChainToHeadResponse)(nil), + (*Event_InitBlockchain)(nil), + } + type x struct{} + out := protoimpl.TypeBuilder{ + File: protoimpl.DescBuilder{ + GoPackagePath: reflect.TypeOf(x{}).PkgPath(), + RawDescriptor: file_blockchainpb_bcmpb_bcmpb_proto_rawDesc, + NumEnums: 0, + NumMessages: 9, + NumExtensions: 0, + NumServices: 0, + }, + GoTypes: file_blockchainpb_bcmpb_bcmpb_proto_goTypes, + DependencyIndexes: file_blockchainpb_bcmpb_bcmpb_proto_depIdxs, + MessageInfos: file_blockchainpb_bcmpb_bcmpb_proto_msgTypes, + }.Build() + File_blockchainpb_bcmpb_bcmpb_proto = out.File + file_blockchainpb_bcmpb_bcmpb_proto_rawDesc = nil + file_blockchainpb_bcmpb_bcmpb_proto_goTypes = nil + file_blockchainpb_bcmpb_bcmpb_proto_depIdxs = nil +} diff --git a/pkg/pb/blockchainpb/bcmpb/bcmpb.pb.mir.go b/pkg/pb/blockchainpb/bcmpb/bcmpb.pb.mir.go new file mode 100644 index 000000000..664eb50ce --- /dev/null +++ b/pkg/pb/blockchainpb/bcmpb/bcmpb.pb.mir.go @@ -0,0 +1,20 @@ +// Code generated by Mir codegen. DO NOT EDIT. + +package bcmpb + +import ( + reflect "reflect" +) + +func (*Event) ReflectTypeOptions() []reflect.Type { + return []reflect.Type{ + reflect.TypeOf((*Event_NewBlock)(nil)), + reflect.TypeOf((*Event_NewChain)(nil)), + reflect.TypeOf((*Event_GetChainRequest)(nil)), + reflect.TypeOf((*Event_GetChainResponse)(nil)), + reflect.TypeOf((*Event_RegisterCheckpoint)(nil)), + reflect.TypeOf((*Event_GetChainToHeadRequest)(nil)), + reflect.TypeOf((*Event_GetChainToHeadResponse)(nil)), + reflect.TypeOf((*Event_InitBlockchain)(nil)), + } +} diff --git a/pkg/pb/blockchainpb/bcmpb/dsl/emit.mir.go b/pkg/pb/blockchainpb/bcmpb/dsl/emit.mir.go new file mode 100644 index 000000000..0366cd2ca --- /dev/null +++ b/pkg/pb/blockchainpb/bcmpb/dsl/emit.mir.go @@ -0,0 +1,45 @@ +// Code generated by Mir codegen. DO NOT EDIT. + +package bcmpbdsl + +import ( + dsl "github.com/filecoin-project/mir/pkg/dsl" + events "github.com/filecoin-project/mir/pkg/pb/blockchainpb/bcmpb/events" + types2 "github.com/filecoin-project/mir/pkg/pb/blockchainpb/statepb/types" + types1 "github.com/filecoin-project/mir/pkg/pb/blockchainpb/types" + types "github.com/filecoin-project/mir/pkg/types" +) + +// Module-specific dsl functions for emitting events. + +func NewBlock(m dsl.Module, destModule types.ModuleID, block *types1.Block) { + dsl.EmitMirEvent(m, events.NewBlock(destModule, block)) +} + +func NewChain(m dsl.Module, destModule types.ModuleID, blocks []*types1.Block) { + dsl.EmitMirEvent(m, events.NewChain(destModule, blocks)) +} + +func GetChainRequest(m dsl.Module, destModule types.ModuleID, requestId string, sourceModule types.ModuleID, endBlockId uint64, sourceBlockIds []uint64) { + dsl.EmitMirEvent(m, events.GetChainRequest(destModule, requestId, sourceModule, endBlockId, sourceBlockIds)) +} + +func GetChainResponse(m dsl.Module, destModule types.ModuleID, requestId string, success bool, chain []*types1.Block) { + dsl.EmitMirEvent(m, events.GetChainResponse(destModule, requestId, success, chain)) +} + +func RegisterCheckpoint(m dsl.Module, destModule types.ModuleID, blockId uint64, state *types2.State) { + dsl.EmitMirEvent(m, events.RegisterCheckpoint(destModule, blockId, state)) +} + +func GetChainToHeadRequest(m dsl.Module, destModule types.ModuleID, sourceModule types.ModuleID) { + dsl.EmitMirEvent(m, events.GetChainToHeadRequest(destModule, sourceModule)) +} + +func GetChainToHeadResponse(m dsl.Module, destModule types.ModuleID, chain []*types1.Block, checkpointState *types2.State) { + dsl.EmitMirEvent(m, events.GetChainToHeadResponse(destModule, chain, checkpointState)) +} + +func InitBlockchain(m dsl.Module, destModule types.ModuleID, initialState *types2.State) { + dsl.EmitMirEvent(m, events.InitBlockchain(destModule, initialState)) +} diff --git a/pkg/pb/blockchainpb/bcmpb/dsl/upon.mir.go b/pkg/pb/blockchainpb/bcmpb/dsl/upon.mir.go new file mode 100644 index 000000000..5e65c6a02 --- /dev/null +++ b/pkg/pb/blockchainpb/bcmpb/dsl/upon.mir.go @@ -0,0 +1,73 @@ +// Code generated by Mir codegen. DO NOT EDIT. + +package bcmpbdsl + +import ( + dsl "github.com/filecoin-project/mir/pkg/dsl" + types "github.com/filecoin-project/mir/pkg/pb/blockchainpb/bcmpb/types" + types4 "github.com/filecoin-project/mir/pkg/pb/blockchainpb/statepb/types" + types2 "github.com/filecoin-project/mir/pkg/pb/blockchainpb/types" + types1 "github.com/filecoin-project/mir/pkg/pb/eventpb/types" + types3 "github.com/filecoin-project/mir/pkg/types" +) + +// Module-specific dsl functions for processing events. + +func UponEvent[W types.Event_TypeWrapper[Ev], Ev any](m dsl.Module, handler func(ev *Ev) error) { + dsl.UponMirEvent[*types1.Event_Bcm](m, func(ev *types.Event) error { + w, ok := ev.Type.(W) + if !ok { + return nil + } + + return handler(w.Unwrap()) + }) +} + +func UponNewBlock(m dsl.Module, handler func(block *types2.Block) error) { + UponEvent[*types.Event_NewBlock](m, func(ev *types.NewBlock) error { + return handler(ev.Block) + }) +} + +func UponNewChain(m dsl.Module, handler func(blocks []*types2.Block) error) { + UponEvent[*types.Event_NewChain](m, func(ev *types.NewChain) error { + return handler(ev.Blocks) + }) +} + +func UponGetChainRequest(m dsl.Module, handler func(requestId string, sourceModule types3.ModuleID, endBlockId uint64, sourceBlockIds []uint64) error) { + UponEvent[*types.Event_GetChainRequest](m, func(ev *types.GetChainRequest) error { + return handler(ev.RequestId, ev.SourceModule, ev.EndBlockId, ev.SourceBlockIds) + }) +} + +func UponGetChainResponse(m dsl.Module, handler func(requestId string, success bool, chain []*types2.Block) error) { + UponEvent[*types.Event_GetChainResponse](m, func(ev *types.GetChainResponse) error { + return handler(ev.RequestId, ev.Success, ev.Chain) + }) +} + +func UponRegisterCheckpoint(m dsl.Module, handler func(blockId uint64, state *types4.State) error) { + UponEvent[*types.Event_RegisterCheckpoint](m, func(ev *types.RegisterCheckpoint) error { + return handler(ev.BlockId, ev.State) + }) +} + +func UponGetChainToHeadRequest(m dsl.Module, handler func(sourceModule types3.ModuleID) error) { + UponEvent[*types.Event_GetChainToHeadRequest](m, func(ev *types.GetChainToHeadRequest) error { + return handler(ev.SourceModule) + }) +} + +func UponGetChainToHeadResponse(m dsl.Module, handler func(chain []*types2.Block, checkpointState *types4.State) error) { + UponEvent[*types.Event_GetChainToHeadResponse](m, func(ev *types.GetChainToHeadResponse) error { + return handler(ev.Chain, ev.CheckpointState) + }) +} + +func UponInitBlockchain(m dsl.Module, handler func(initialState *types4.State) error) { + UponEvent[*types.Event_InitBlockchain](m, func(ev *types.InitBlockchain) error { + return handler(ev.InitialState) + }) +} diff --git a/pkg/pb/blockchainpb/bcmpb/events/events.mir.go b/pkg/pb/blockchainpb/bcmpb/events/events.mir.go new file mode 100644 index 000000000..3dc5a3bd2 --- /dev/null +++ b/pkg/pb/blockchainpb/bcmpb/events/events.mir.go @@ -0,0 +1,138 @@ +// Code generated by Mir codegen. DO NOT EDIT. + +package bcmpbevents + +import ( + types3 "github.com/filecoin-project/mir/pkg/pb/blockchainpb/bcmpb/types" + types4 "github.com/filecoin-project/mir/pkg/pb/blockchainpb/statepb/types" + types1 "github.com/filecoin-project/mir/pkg/pb/blockchainpb/types" + types2 "github.com/filecoin-project/mir/pkg/pb/eventpb/types" + types "github.com/filecoin-project/mir/pkg/types" +) + +func NewBlock(destModule types.ModuleID, block *types1.Block) *types2.Event { + return &types2.Event{ + DestModule: destModule, + Type: &types2.Event_Bcm{ + Bcm: &types3.Event{ + Type: &types3.Event_NewBlock{ + NewBlock: &types3.NewBlock{ + Block: block, + }, + }, + }, + }, + } +} + +func NewChain(destModule types.ModuleID, blocks []*types1.Block) *types2.Event { + return &types2.Event{ + DestModule: destModule, + Type: &types2.Event_Bcm{ + Bcm: &types3.Event{ + Type: &types3.Event_NewChain{ + NewChain: &types3.NewChain{ + Blocks: blocks, + }, + }, + }, + }, + } +} + +func GetChainRequest(destModule types.ModuleID, requestId string, sourceModule types.ModuleID, endBlockId uint64, sourceBlockIds []uint64) *types2.Event { + return &types2.Event{ + DestModule: destModule, + Type: &types2.Event_Bcm{ + Bcm: &types3.Event{ + Type: &types3.Event_GetChainRequest{ + GetChainRequest: &types3.GetChainRequest{ + RequestId: requestId, + SourceModule: sourceModule, + EndBlockId: endBlockId, + SourceBlockIds: sourceBlockIds, + }, + }, + }, + }, + } +} + +func GetChainResponse(destModule types.ModuleID, requestId string, success bool, chain []*types1.Block) *types2.Event { + return &types2.Event{ + DestModule: destModule, + Type: &types2.Event_Bcm{ + Bcm: &types3.Event{ + Type: &types3.Event_GetChainResponse{ + GetChainResponse: &types3.GetChainResponse{ + RequestId: requestId, + Success: success, + Chain: chain, + }, + }, + }, + }, + } +} + +func RegisterCheckpoint(destModule types.ModuleID, blockId uint64, state *types4.State) *types2.Event { + return &types2.Event{ + DestModule: destModule, + Type: &types2.Event_Bcm{ + Bcm: &types3.Event{ + Type: &types3.Event_RegisterCheckpoint{ + RegisterCheckpoint: &types3.RegisterCheckpoint{ + BlockId: blockId, + State: state, + }, + }, + }, + }, + } +} + +func GetChainToHeadRequest(destModule types.ModuleID, sourceModule types.ModuleID) *types2.Event { + return &types2.Event{ + DestModule: destModule, + Type: &types2.Event_Bcm{ + Bcm: &types3.Event{ + Type: &types3.Event_GetChainToHeadRequest{ + GetChainToHeadRequest: &types3.GetChainToHeadRequest{ + SourceModule: sourceModule, + }, + }, + }, + }, + } +} + +func GetChainToHeadResponse(destModule types.ModuleID, chain []*types1.Block, checkpointState *types4.State) *types2.Event { + return &types2.Event{ + DestModule: destModule, + Type: &types2.Event_Bcm{ + Bcm: &types3.Event{ + Type: &types3.Event_GetChainToHeadResponse{ + GetChainToHeadResponse: &types3.GetChainToHeadResponse{ + Chain: chain, + CheckpointState: checkpointState, + }, + }, + }, + }, + } +} + +func InitBlockchain(destModule types.ModuleID, initialState *types4.State) *types2.Event { + return &types2.Event{ + DestModule: destModule, + Type: &types2.Event_Bcm{ + Bcm: &types3.Event{ + Type: &types3.Event_InitBlockchain{ + InitBlockchain: &types3.InitBlockchain{ + InitialState: initialState, + }, + }, + }, + }, + } +} diff --git a/pkg/pb/blockchainpb/bcmpb/oneof_interfaces.mir.go b/pkg/pb/blockchainpb/bcmpb/oneof_interfaces.mir.go new file mode 100644 index 000000000..63456ea49 --- /dev/null +++ b/pkg/pb/blockchainpb/bcmpb/oneof_interfaces.mir.go @@ -0,0 +1,42 @@ +// Code generated by Mir codegen. DO NOT EDIT. + +package bcmpb + +type Event_Type = isEvent_Type + +type Event_TypeWrapper[T any] interface { + Event_Type + Unwrap() *T +} + +func (w *Event_NewBlock) Unwrap() *NewBlock { + return w.NewBlock +} + +func (w *Event_NewChain) Unwrap() *NewChain { + return w.NewChain +} + +func (w *Event_GetChainRequest) Unwrap() *GetChainRequest { + return w.GetChainRequest +} + +func (w *Event_GetChainResponse) Unwrap() *GetChainResponse { + return w.GetChainResponse +} + +func (w *Event_RegisterCheckpoint) Unwrap() *RegisterCheckpoint { + return w.RegisterCheckpoint +} + +func (w *Event_GetChainToHeadRequest) Unwrap() *GetChainToHeadRequest { + return w.GetChainToHeadRequest +} + +func (w *Event_GetChainToHeadResponse) Unwrap() *GetChainToHeadResponse { + return w.GetChainToHeadResponse +} + +func (w *Event_InitBlockchain) Unwrap() *InitBlockchain { + return w.InitBlockchain +} diff --git a/pkg/pb/blockchainpb/bcmpb/types/types.mir.go b/pkg/pb/blockchainpb/bcmpb/types/types.mir.go new file mode 100644 index 000000000..2aab85903 --- /dev/null +++ b/pkg/pb/blockchainpb/bcmpb/types/types.mir.go @@ -0,0 +1,546 @@ +// Code generated by Mir codegen. DO NOT EDIT. + +package bcmpbtypes + +import ( + mirreflect "github.com/filecoin-project/mir/codegen/mirreflect" + types1 "github.com/filecoin-project/mir/codegen/model/types" + blockchainpb "github.com/filecoin-project/mir/pkg/pb/blockchainpb" + bcmpb "github.com/filecoin-project/mir/pkg/pb/blockchainpb/bcmpb" + types3 "github.com/filecoin-project/mir/pkg/pb/blockchainpb/statepb/types" + types "github.com/filecoin-project/mir/pkg/pb/blockchainpb/types" + types2 "github.com/filecoin-project/mir/pkg/types" + reflectutil "github.com/filecoin-project/mir/pkg/util/reflectutil" +) + +type Event struct { + Type Event_Type +} + +type Event_Type interface { + mirreflect.GeneratedType + isEvent_Type() + Pb() bcmpb.Event_Type +} + +type Event_TypeWrapper[T any] interface { + Event_Type + Unwrap() *T +} + +func Event_TypeFromPb(pb bcmpb.Event_Type) Event_Type { + if pb == nil { + return nil + } + switch pb := pb.(type) { + case *bcmpb.Event_NewBlock: + return &Event_NewBlock{NewBlock: NewBlockFromPb(pb.NewBlock)} + case *bcmpb.Event_NewChain: + return &Event_NewChain{NewChain: NewChainFromPb(pb.NewChain)} + case *bcmpb.Event_GetChainRequest: + return &Event_GetChainRequest{GetChainRequest: GetChainRequestFromPb(pb.GetChainRequest)} + case *bcmpb.Event_GetChainResponse: + return &Event_GetChainResponse{GetChainResponse: GetChainResponseFromPb(pb.GetChainResponse)} + case *bcmpb.Event_RegisterCheckpoint: + return &Event_RegisterCheckpoint{RegisterCheckpoint: RegisterCheckpointFromPb(pb.RegisterCheckpoint)} + case *bcmpb.Event_GetChainToHeadRequest: + return &Event_GetChainToHeadRequest{GetChainToHeadRequest: GetChainToHeadRequestFromPb(pb.GetChainToHeadRequest)} + case *bcmpb.Event_GetChainToHeadResponse: + return &Event_GetChainToHeadResponse{GetChainToHeadResponse: GetChainToHeadResponseFromPb(pb.GetChainToHeadResponse)} + case *bcmpb.Event_InitBlockchain: + return &Event_InitBlockchain{InitBlockchain: InitBlockchainFromPb(pb.InitBlockchain)} + } + return nil +} + +type Event_NewBlock struct { + NewBlock *NewBlock +} + +func (*Event_NewBlock) isEvent_Type() {} + +func (w *Event_NewBlock) Unwrap() *NewBlock { + return w.NewBlock +} + +func (w *Event_NewBlock) Pb() bcmpb.Event_Type { + if w == nil { + return nil + } + if w.NewBlock == nil { + return &bcmpb.Event_NewBlock{} + } + return &bcmpb.Event_NewBlock{NewBlock: (w.NewBlock).Pb()} +} + +func (*Event_NewBlock) MirReflect() mirreflect.Type { + return mirreflect.TypeImpl{PbType_: reflectutil.TypeOf[*bcmpb.Event_NewBlock]()} +} + +type Event_NewChain struct { + NewChain *NewChain +} + +func (*Event_NewChain) isEvent_Type() {} + +func (w *Event_NewChain) Unwrap() *NewChain { + return w.NewChain +} + +func (w *Event_NewChain) Pb() bcmpb.Event_Type { + if w == nil { + return nil + } + if w.NewChain == nil { + return &bcmpb.Event_NewChain{} + } + return &bcmpb.Event_NewChain{NewChain: (w.NewChain).Pb()} +} + +func (*Event_NewChain) MirReflect() mirreflect.Type { + return mirreflect.TypeImpl{PbType_: reflectutil.TypeOf[*bcmpb.Event_NewChain]()} +} + +type Event_GetChainRequest struct { + GetChainRequest *GetChainRequest +} + +func (*Event_GetChainRequest) isEvent_Type() {} + +func (w *Event_GetChainRequest) Unwrap() *GetChainRequest { + return w.GetChainRequest +} + +func (w *Event_GetChainRequest) Pb() bcmpb.Event_Type { + if w == nil { + return nil + } + if w.GetChainRequest == nil { + return &bcmpb.Event_GetChainRequest{} + } + return &bcmpb.Event_GetChainRequest{GetChainRequest: (w.GetChainRequest).Pb()} +} + +func (*Event_GetChainRequest) MirReflect() mirreflect.Type { + return mirreflect.TypeImpl{PbType_: reflectutil.TypeOf[*bcmpb.Event_GetChainRequest]()} +} + +type Event_GetChainResponse struct { + GetChainResponse *GetChainResponse +} + +func (*Event_GetChainResponse) isEvent_Type() {} + +func (w *Event_GetChainResponse) Unwrap() *GetChainResponse { + return w.GetChainResponse +} + +func (w *Event_GetChainResponse) Pb() bcmpb.Event_Type { + if w == nil { + return nil + } + if w.GetChainResponse == nil { + return &bcmpb.Event_GetChainResponse{} + } + return &bcmpb.Event_GetChainResponse{GetChainResponse: (w.GetChainResponse).Pb()} +} + +func (*Event_GetChainResponse) MirReflect() mirreflect.Type { + return mirreflect.TypeImpl{PbType_: reflectutil.TypeOf[*bcmpb.Event_GetChainResponse]()} +} + +type Event_RegisterCheckpoint struct { + RegisterCheckpoint *RegisterCheckpoint +} + +func (*Event_RegisterCheckpoint) isEvent_Type() {} + +func (w *Event_RegisterCheckpoint) Unwrap() *RegisterCheckpoint { + return w.RegisterCheckpoint +} + +func (w *Event_RegisterCheckpoint) Pb() bcmpb.Event_Type { + if w == nil { + return nil + } + if w.RegisterCheckpoint == nil { + return &bcmpb.Event_RegisterCheckpoint{} + } + return &bcmpb.Event_RegisterCheckpoint{RegisterCheckpoint: (w.RegisterCheckpoint).Pb()} +} + +func (*Event_RegisterCheckpoint) MirReflect() mirreflect.Type { + return mirreflect.TypeImpl{PbType_: reflectutil.TypeOf[*bcmpb.Event_RegisterCheckpoint]()} +} + +type Event_GetChainToHeadRequest struct { + GetChainToHeadRequest *GetChainToHeadRequest +} + +func (*Event_GetChainToHeadRequest) isEvent_Type() {} + +func (w *Event_GetChainToHeadRequest) Unwrap() *GetChainToHeadRequest { + return w.GetChainToHeadRequest +} + +func (w *Event_GetChainToHeadRequest) Pb() bcmpb.Event_Type { + if w == nil { + return nil + } + if w.GetChainToHeadRequest == nil { + return &bcmpb.Event_GetChainToHeadRequest{} + } + return &bcmpb.Event_GetChainToHeadRequest{GetChainToHeadRequest: (w.GetChainToHeadRequest).Pb()} +} + +func (*Event_GetChainToHeadRequest) MirReflect() mirreflect.Type { + return mirreflect.TypeImpl{PbType_: reflectutil.TypeOf[*bcmpb.Event_GetChainToHeadRequest]()} +} + +type Event_GetChainToHeadResponse struct { + GetChainToHeadResponse *GetChainToHeadResponse +} + +func (*Event_GetChainToHeadResponse) isEvent_Type() {} + +func (w *Event_GetChainToHeadResponse) Unwrap() *GetChainToHeadResponse { + return w.GetChainToHeadResponse +} + +func (w *Event_GetChainToHeadResponse) Pb() bcmpb.Event_Type { + if w == nil { + return nil + } + if w.GetChainToHeadResponse == nil { + return &bcmpb.Event_GetChainToHeadResponse{} + } + return &bcmpb.Event_GetChainToHeadResponse{GetChainToHeadResponse: (w.GetChainToHeadResponse).Pb()} +} + +func (*Event_GetChainToHeadResponse) MirReflect() mirreflect.Type { + return mirreflect.TypeImpl{PbType_: reflectutil.TypeOf[*bcmpb.Event_GetChainToHeadResponse]()} +} + +type Event_InitBlockchain struct { + InitBlockchain *InitBlockchain +} + +func (*Event_InitBlockchain) isEvent_Type() {} + +func (w *Event_InitBlockchain) Unwrap() *InitBlockchain { + return w.InitBlockchain +} + +func (w *Event_InitBlockchain) Pb() bcmpb.Event_Type { + if w == nil { + return nil + } + if w.InitBlockchain == nil { + return &bcmpb.Event_InitBlockchain{} + } + return &bcmpb.Event_InitBlockchain{InitBlockchain: (w.InitBlockchain).Pb()} +} + +func (*Event_InitBlockchain) MirReflect() mirreflect.Type { + return mirreflect.TypeImpl{PbType_: reflectutil.TypeOf[*bcmpb.Event_InitBlockchain]()} +} + +func EventFromPb(pb *bcmpb.Event) *Event { + if pb == nil { + return nil + } + return &Event{ + Type: Event_TypeFromPb(pb.Type), + } +} + +func (m *Event) Pb() *bcmpb.Event { + if m == nil { + return nil + } + pbMessage := &bcmpb.Event{} + { + if m.Type != nil { + pbMessage.Type = (m.Type).Pb() + } + } + + return pbMessage +} + +func (*Event) MirReflect() mirreflect.Type { + return mirreflect.TypeImpl{PbType_: reflectutil.TypeOf[*bcmpb.Event]()} +} + +type NewBlock struct { + Block *types.Block +} + +func NewBlockFromPb(pb *bcmpb.NewBlock) *NewBlock { + if pb == nil { + return nil + } + return &NewBlock{ + Block: types.BlockFromPb(pb.Block), + } +} + +func (m *NewBlock) Pb() *bcmpb.NewBlock { + if m == nil { + return nil + } + pbMessage := &bcmpb.NewBlock{} + { + if m.Block != nil { + pbMessage.Block = (m.Block).Pb() + } + } + + return pbMessage +} + +func (*NewBlock) MirReflect() mirreflect.Type { + return mirreflect.TypeImpl{PbType_: reflectutil.TypeOf[*bcmpb.NewBlock]()} +} + +type NewChain struct { + Blocks []*types.Block +} + +func NewChainFromPb(pb *bcmpb.NewChain) *NewChain { + if pb == nil { + return nil + } + return &NewChain{ + Blocks: types1.ConvertSlice(pb.Blocks, func(t *blockchainpb.Block) *types.Block { + return types.BlockFromPb(t) + }), + } +} + +func (m *NewChain) Pb() *bcmpb.NewChain { + if m == nil { + return nil + } + pbMessage := &bcmpb.NewChain{} + { + pbMessage.Blocks = types1.ConvertSlice(m.Blocks, func(t *types.Block) *blockchainpb.Block { + return (t).Pb() + }) + } + + return pbMessage +} + +func (*NewChain) MirReflect() mirreflect.Type { + return mirreflect.TypeImpl{PbType_: reflectutil.TypeOf[*bcmpb.NewChain]()} +} + +type GetChainRequest struct { + RequestId string + SourceModule types2.ModuleID + EndBlockId uint64 + SourceBlockIds []uint64 +} + +func GetChainRequestFromPb(pb *bcmpb.GetChainRequest) *GetChainRequest { + if pb == nil { + return nil + } + return &GetChainRequest{ + RequestId: pb.RequestId, + SourceModule: (types2.ModuleID)(pb.SourceModule), + EndBlockId: pb.EndBlockId, + SourceBlockIds: pb.SourceBlockIds, + } +} + +func (m *GetChainRequest) Pb() *bcmpb.GetChainRequest { + if m == nil { + return nil + } + pbMessage := &bcmpb.GetChainRequest{} + { + pbMessage.RequestId = m.RequestId + pbMessage.SourceModule = (string)(m.SourceModule) + pbMessage.EndBlockId = m.EndBlockId + pbMessage.SourceBlockIds = m.SourceBlockIds + } + + return pbMessage +} + +func (*GetChainRequest) MirReflect() mirreflect.Type { + return mirreflect.TypeImpl{PbType_: reflectutil.TypeOf[*bcmpb.GetChainRequest]()} +} + +type GetChainResponse struct { + RequestId string + Success bool + Chain []*types.Block +} + +func GetChainResponseFromPb(pb *bcmpb.GetChainResponse) *GetChainResponse { + if pb == nil { + return nil + } + return &GetChainResponse{ + RequestId: pb.RequestId, + Success: pb.Success, + Chain: types1.ConvertSlice(pb.Chain, func(t *blockchainpb.Block) *types.Block { + return types.BlockFromPb(t) + }), + } +} + +func (m *GetChainResponse) Pb() *bcmpb.GetChainResponse { + if m == nil { + return nil + } + pbMessage := &bcmpb.GetChainResponse{} + { + pbMessage.RequestId = m.RequestId + pbMessage.Success = m.Success + pbMessage.Chain = types1.ConvertSlice(m.Chain, func(t *types.Block) *blockchainpb.Block { + return (t).Pb() + }) + } + + return pbMessage +} + +func (*GetChainResponse) MirReflect() mirreflect.Type { + return mirreflect.TypeImpl{PbType_: reflectutil.TypeOf[*bcmpb.GetChainResponse]()} +} + +type GetChainToHeadRequest struct { + SourceModule types2.ModuleID +} + +func GetChainToHeadRequestFromPb(pb *bcmpb.GetChainToHeadRequest) *GetChainToHeadRequest { + if pb == nil { + return nil + } + return &GetChainToHeadRequest{ + SourceModule: (types2.ModuleID)(pb.SourceModule), + } +} + +func (m *GetChainToHeadRequest) Pb() *bcmpb.GetChainToHeadRequest { + if m == nil { + return nil + } + pbMessage := &bcmpb.GetChainToHeadRequest{} + { + pbMessage.SourceModule = (string)(m.SourceModule) + } + + return pbMessage +} + +func (*GetChainToHeadRequest) MirReflect() mirreflect.Type { + return mirreflect.TypeImpl{PbType_: reflectutil.TypeOf[*bcmpb.GetChainToHeadRequest]()} +} + +type GetChainToHeadResponse struct { + Chain []*types.Block + CheckpointState *types3.State +} + +func GetChainToHeadResponseFromPb(pb *bcmpb.GetChainToHeadResponse) *GetChainToHeadResponse { + if pb == nil { + return nil + } + return &GetChainToHeadResponse{ + Chain: types1.ConvertSlice(pb.Chain, func(t *blockchainpb.Block) *types.Block { + return types.BlockFromPb(t) + }), + CheckpointState: types3.StateFromPb(pb.CheckpointState), + } +} + +func (m *GetChainToHeadResponse) Pb() *bcmpb.GetChainToHeadResponse { + if m == nil { + return nil + } + pbMessage := &bcmpb.GetChainToHeadResponse{} + { + pbMessage.Chain = types1.ConvertSlice(m.Chain, func(t *types.Block) *blockchainpb.Block { + return (t).Pb() + }) + if m.CheckpointState != nil { + pbMessage.CheckpointState = (m.CheckpointState).Pb() + } + } + + return pbMessage +} + +func (*GetChainToHeadResponse) MirReflect() mirreflect.Type { + return mirreflect.TypeImpl{PbType_: reflectutil.TypeOf[*bcmpb.GetChainToHeadResponse]()} +} + +type RegisterCheckpoint struct { + BlockId uint64 + State *types3.State +} + +func RegisterCheckpointFromPb(pb *bcmpb.RegisterCheckpoint) *RegisterCheckpoint { + if pb == nil { + return nil + } + return &RegisterCheckpoint{ + BlockId: pb.BlockId, + State: types3.StateFromPb(pb.State), + } +} + +func (m *RegisterCheckpoint) Pb() *bcmpb.RegisterCheckpoint { + if m == nil { + return nil + } + pbMessage := &bcmpb.RegisterCheckpoint{} + { + pbMessage.BlockId = m.BlockId + if m.State != nil { + pbMessage.State = (m.State).Pb() + } + } + + return pbMessage +} + +func (*RegisterCheckpoint) MirReflect() mirreflect.Type { + return mirreflect.TypeImpl{PbType_: reflectutil.TypeOf[*bcmpb.RegisterCheckpoint]()} +} + +type InitBlockchain struct { + InitialState *types3.State +} + +func InitBlockchainFromPb(pb *bcmpb.InitBlockchain) *InitBlockchain { + if pb == nil { + return nil + } + return &InitBlockchain{ + InitialState: types3.StateFromPb(pb.InitialState), + } +} + +func (m *InitBlockchain) Pb() *bcmpb.InitBlockchain { + if m == nil { + return nil + } + pbMessage := &bcmpb.InitBlockchain{} + { + if m.InitialState != nil { + pbMessage.InitialState = (m.InitialState).Pb() + } + } + + return pbMessage +} + +func (*InitBlockchain) MirReflect() mirreflect.Type { + return mirreflect.TypeImpl{PbType_: reflectutil.TypeOf[*bcmpb.InitBlockchain]()} +} diff --git a/pkg/pb/blockchainpb/blockchainpb.pb.go b/pkg/pb/blockchainpb/blockchainpb.pb.go new file mode 100644 index 000000000..c1a8467ac --- /dev/null +++ b/pkg/pb/blockchainpb/blockchainpb.pb.go @@ -0,0 +1,206 @@ +// Code generated by protoc-gen-go. DO NOT EDIT. +// versions: +// protoc-gen-go v1.31.0 +// protoc v4.25.2 +// source: blockchainpb/blockchainpb.proto + +package blockchainpb + +import ( + payloadpb "github.com/filecoin-project/mir/pkg/pb/blockchainpb/payloadpb" + _ "github.com/filecoin-project/mir/pkg/pb/mir" + protoreflect "google.golang.org/protobuf/reflect/protoreflect" + protoimpl "google.golang.org/protobuf/runtime/protoimpl" + timestamppb "google.golang.org/protobuf/types/known/timestamppb" + reflect "reflect" + sync "sync" +) + +const ( + // Verify that this generated code is sufficiently up-to-date. + _ = protoimpl.EnforceVersion(20 - protoimpl.MinVersion) + // Verify that runtime/protoimpl is sufficiently up-to-date. + _ = protoimpl.EnforceVersion(protoimpl.MaxVersion - 20) +) + +type Block struct { + state protoimpl.MessageState + sizeCache protoimpl.SizeCache + unknownFields protoimpl.UnknownFields + + BlockId uint64 `protobuf:"varint,1,opt,name=block_id,json=blockId,proto3" json:"block_id,omitempty"` + PreviousBlockId uint64 `protobuf:"varint,2,opt,name=previous_block_id,json=previousBlockId,proto3" json:"previous_block_id,omitempty"` + Payload *payloadpb.Payload `protobuf:"bytes,3,opt,name=payload,proto3" json:"payload,omitempty"` + Timestamp *timestamppb.Timestamp `protobuf:"bytes,4,opt,name=timestamp,proto3" json:"timestamp,omitempty"` + MinerId string `protobuf:"bytes,5,opt,name=miner_id,json=minerId,proto3" json:"miner_id,omitempty"` +} + +func (x *Block) Reset() { + *x = Block{} + if protoimpl.UnsafeEnabled { + mi := &file_blockchainpb_blockchainpb_proto_msgTypes[0] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) + } +} + +func (x *Block) String() string { + return protoimpl.X.MessageStringOf(x) +} + +func (*Block) ProtoMessage() {} + +func (x *Block) ProtoReflect() protoreflect.Message { + mi := &file_blockchainpb_blockchainpb_proto_msgTypes[0] + if protoimpl.UnsafeEnabled && x != nil { + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + if ms.LoadMessageInfo() == nil { + ms.StoreMessageInfo(mi) + } + return ms + } + return mi.MessageOf(x) +} + +// Deprecated: Use Block.ProtoReflect.Descriptor instead. +func (*Block) Descriptor() ([]byte, []int) { + return file_blockchainpb_blockchainpb_proto_rawDescGZIP(), []int{0} +} + +func (x *Block) GetBlockId() uint64 { + if x != nil { + return x.BlockId + } + return 0 +} + +func (x *Block) GetPreviousBlockId() uint64 { + if x != nil { + return x.PreviousBlockId + } + return 0 +} + +func (x *Block) GetPayload() *payloadpb.Payload { + if x != nil { + return x.Payload + } + return nil +} + +func (x *Block) GetTimestamp() *timestamppb.Timestamp { + if x != nil { + return x.Timestamp + } + return nil +} + +func (x *Block) GetMinerId() string { + if x != nil { + return x.MinerId + } + return "" +} + +var File_blockchainpb_blockchainpb_proto protoreflect.FileDescriptor + +var file_blockchainpb_blockchainpb_proto_rawDesc = []byte{ + 0x0a, 0x1f, 0x62, 0x6c, 0x6f, 0x63, 0x6b, 0x63, 0x68, 0x61, 0x69, 0x6e, 0x70, 0x62, 0x2f, 0x62, + 0x6c, 0x6f, 0x63, 0x6b, 0x63, 0x68, 0x61, 0x69, 0x6e, 0x70, 0x62, 0x2e, 0x70, 0x72, 0x6f, 0x74, + 0x6f, 0x12, 0x0c, 0x62, 0x6c, 0x6f, 0x63, 0x6b, 0x63, 0x68, 0x61, 0x69, 0x6e, 0x70, 0x62, 0x1a, + 0x1c, 0x6d, 0x69, 0x72, 0x2f, 0x63, 0x6f, 0x64, 0x65, 0x67, 0x65, 0x6e, 0x5f, 0x65, 0x78, 0x74, + 0x65, 0x6e, 0x73, 0x69, 0x6f, 0x6e, 0x73, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x1a, 0x26, 0x62, + 0x6c, 0x6f, 0x63, 0x6b, 0x63, 0x68, 0x61, 0x69, 0x6e, 0x70, 0x62, 0x2f, 0x70, 0x61, 0x79, 0x6c, + 0x6f, 0x61, 0x64, 0x70, 0x62, 0x2f, 0x70, 0x61, 0x79, 0x6c, 0x6f, 0x61, 0x64, 0x70, 0x62, 0x2e, + 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x1a, 0x1f, 0x67, 0x6f, 0x6f, 0x67, 0x6c, 0x65, 0x2f, 0x70, 0x72, + 0x6f, 0x74, 0x6f, 0x62, 0x75, 0x66, 0x2f, 0x74, 0x69, 0x6d, 0x65, 0x73, 0x74, 0x61, 0x6d, 0x70, + 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x22, 0x8d, 0x02, 0x0a, 0x05, 0x42, 0x6c, 0x6f, 0x63, 0x6b, + 0x12, 0x19, 0x0a, 0x08, 0x62, 0x6c, 0x6f, 0x63, 0x6b, 0x5f, 0x69, 0x64, 0x18, 0x01, 0x20, 0x01, + 0x28, 0x04, 0x52, 0x07, 0x62, 0x6c, 0x6f, 0x63, 0x6b, 0x49, 0x64, 0x12, 0x2a, 0x0a, 0x11, 0x70, + 0x72, 0x65, 0x76, 0x69, 0x6f, 0x75, 0x73, 0x5f, 0x62, 0x6c, 0x6f, 0x63, 0x6b, 0x5f, 0x69, 0x64, + 0x18, 0x02, 0x20, 0x01, 0x28, 0x04, 0x52, 0x0f, 0x70, 0x72, 0x65, 0x76, 0x69, 0x6f, 0x75, 0x73, + 0x42, 0x6c, 0x6f, 0x63, 0x6b, 0x49, 0x64, 0x12, 0x2c, 0x0a, 0x07, 0x70, 0x61, 0x79, 0x6c, 0x6f, + 0x61, 0x64, 0x18, 0x03, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x12, 0x2e, 0x70, 0x61, 0x79, 0x6c, 0x6f, + 0x61, 0x64, 0x70, 0x62, 0x2e, 0x50, 0x61, 0x79, 0x6c, 0x6f, 0x61, 0x64, 0x52, 0x07, 0x70, 0x61, + 0x79, 0x6c, 0x6f, 0x61, 0x64, 0x12, 0x38, 0x0a, 0x09, 0x74, 0x69, 0x6d, 0x65, 0x73, 0x74, 0x61, + 0x6d, 0x70, 0x18, 0x04, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x1a, 0x2e, 0x67, 0x6f, 0x6f, 0x67, 0x6c, + 0x65, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x62, 0x75, 0x66, 0x2e, 0x54, 0x69, 0x6d, 0x65, 0x73, + 0x74, 0x61, 0x6d, 0x70, 0x52, 0x09, 0x74, 0x69, 0x6d, 0x65, 0x73, 0x74, 0x61, 0x6d, 0x70, 0x12, + 0x4f, 0x0a, 0x08, 0x6d, 0x69, 0x6e, 0x65, 0x72, 0x5f, 0x69, 0x64, 0x18, 0x05, 0x20, 0x01, 0x28, + 0x09, 0x42, 0x34, 0x82, 0xa6, 0x1d, 0x30, 0x67, 0x69, 0x74, 0x68, 0x75, 0x62, 0x2e, 0x63, 0x6f, + 0x6d, 0x2f, 0x66, 0x69, 0x6c, 0x65, 0x63, 0x6f, 0x69, 0x6e, 0x2d, 0x70, 0x72, 0x6f, 0x6a, 0x65, + 0x63, 0x74, 0x2f, 0x6d, 0x69, 0x72, 0x2f, 0x70, 0x6b, 0x67, 0x2f, 0x74, 0x79, 0x70, 0x65, 0x73, + 0x2e, 0x4e, 0x6f, 0x64, 0x65, 0x49, 0x44, 0x52, 0x07, 0x6d, 0x69, 0x6e, 0x65, 0x72, 0x49, 0x64, + 0x3a, 0x04, 0x80, 0xa6, 0x1d, 0x01, 0x42, 0x35, 0x5a, 0x33, 0x67, 0x69, 0x74, 0x68, 0x75, 0x62, + 0x2e, 0x63, 0x6f, 0x6d, 0x2f, 0x66, 0x69, 0x6c, 0x65, 0x63, 0x6f, 0x69, 0x6e, 0x2d, 0x70, 0x72, + 0x6f, 0x6a, 0x65, 0x63, 0x74, 0x2f, 0x6d, 0x69, 0x72, 0x2f, 0x70, 0x6b, 0x67, 0x2f, 0x70, 0x62, + 0x2f, 0x62, 0x6c, 0x6f, 0x63, 0x6b, 0x63, 0x68, 0x61, 0x69, 0x6e, 0x70, 0x62, 0x62, 0x06, 0x70, + 0x72, 0x6f, 0x74, 0x6f, 0x33, +} + +var ( + file_blockchainpb_blockchainpb_proto_rawDescOnce sync.Once + file_blockchainpb_blockchainpb_proto_rawDescData = file_blockchainpb_blockchainpb_proto_rawDesc +) + +func file_blockchainpb_blockchainpb_proto_rawDescGZIP() []byte { + file_blockchainpb_blockchainpb_proto_rawDescOnce.Do(func() { + file_blockchainpb_blockchainpb_proto_rawDescData = protoimpl.X.CompressGZIP(file_blockchainpb_blockchainpb_proto_rawDescData) + }) + return file_blockchainpb_blockchainpb_proto_rawDescData +} + +var file_blockchainpb_blockchainpb_proto_msgTypes = make([]protoimpl.MessageInfo, 1) +var file_blockchainpb_blockchainpb_proto_goTypes = []interface{}{ + (*Block)(nil), // 0: blockchainpb.Block + (*payloadpb.Payload)(nil), // 1: payloadpb.Payload + (*timestamppb.Timestamp)(nil), // 2: google.protobuf.Timestamp +} +var file_blockchainpb_blockchainpb_proto_depIdxs = []int32{ + 1, // 0: blockchainpb.Block.payload:type_name -> payloadpb.Payload + 2, // 1: blockchainpb.Block.timestamp:type_name -> google.protobuf.Timestamp + 2, // [2:2] is the sub-list for method output_type + 2, // [2:2] is the sub-list for method input_type + 2, // [2:2] is the sub-list for extension type_name + 2, // [2:2] is the sub-list for extension extendee + 0, // [0:2] is the sub-list for field type_name +} + +func init() { file_blockchainpb_blockchainpb_proto_init() } +func file_blockchainpb_blockchainpb_proto_init() { + if File_blockchainpb_blockchainpb_proto != nil { + return + } + if !protoimpl.UnsafeEnabled { + file_blockchainpb_blockchainpb_proto_msgTypes[0].Exporter = func(v interface{}, i int) interface{} { + switch v := v.(*Block); i { + case 0: + return &v.state + case 1: + return &v.sizeCache + case 2: + return &v.unknownFields + default: + return nil + } + } + } + type x struct{} + out := protoimpl.TypeBuilder{ + File: protoimpl.DescBuilder{ + GoPackagePath: reflect.TypeOf(x{}).PkgPath(), + RawDescriptor: file_blockchainpb_blockchainpb_proto_rawDesc, + NumEnums: 0, + NumMessages: 1, + NumExtensions: 0, + NumServices: 0, + }, + GoTypes: file_blockchainpb_blockchainpb_proto_goTypes, + DependencyIndexes: file_blockchainpb_blockchainpb_proto_depIdxs, + MessageInfos: file_blockchainpb_blockchainpb_proto_msgTypes, + }.Build() + File_blockchainpb_blockchainpb_proto = out.File + file_blockchainpb_blockchainpb_proto_rawDesc = nil + file_blockchainpb_blockchainpb_proto_goTypes = nil + file_blockchainpb_blockchainpb_proto_depIdxs = nil +} diff --git a/pkg/pb/blockchainpb/broadcastpb/broadcastpb.pb.go b/pkg/pb/blockchainpb/broadcastpb/broadcastpb.pb.go new file mode 100644 index 000000000..68c3110e8 --- /dev/null +++ b/pkg/pb/blockchainpb/broadcastpb/broadcastpb.pb.go @@ -0,0 +1,404 @@ +// Code generated by protoc-gen-go. DO NOT EDIT. +// versions: +// protoc-gen-go v1.31.0 +// protoc v4.25.2 +// source: blockchainpb/broadcastpb/broadcastpb.proto + +package broadcastpb + +import ( + blockchainpb "github.com/filecoin-project/mir/pkg/pb/blockchainpb" + _ "github.com/filecoin-project/mir/pkg/pb/mir" + _ "github.com/filecoin-project/mir/pkg/pb/net" + protoreflect "google.golang.org/protobuf/reflect/protoreflect" + protoimpl "google.golang.org/protobuf/runtime/protoimpl" + reflect "reflect" + sync "sync" +) + +const ( + // Verify that this generated code is sufficiently up-to-date. + _ = protoimpl.EnforceVersion(20 - protoimpl.MinVersion) + // Verify that runtime/protoimpl is sufficiently up-to-date. + _ = protoimpl.EnforceVersion(protoimpl.MaxVersion - 20) +) + +type Event struct { + state protoimpl.MessageState + sizeCache protoimpl.SizeCache + unknownFields protoimpl.UnknownFields + + // Types that are assignable to Type: + // + // *Event_NewBlock + Type isEvent_Type `protobuf_oneof:"type"` +} + +func (x *Event) Reset() { + *x = Event{} + if protoimpl.UnsafeEnabled { + mi := &file_blockchainpb_broadcastpb_broadcastpb_proto_msgTypes[0] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) + } +} + +func (x *Event) String() string { + return protoimpl.X.MessageStringOf(x) +} + +func (*Event) ProtoMessage() {} + +func (x *Event) ProtoReflect() protoreflect.Message { + mi := &file_blockchainpb_broadcastpb_broadcastpb_proto_msgTypes[0] + if protoimpl.UnsafeEnabled && x != nil { + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + if ms.LoadMessageInfo() == nil { + ms.StoreMessageInfo(mi) + } + return ms + } + return mi.MessageOf(x) +} + +// Deprecated: Use Event.ProtoReflect.Descriptor instead. +func (*Event) Descriptor() ([]byte, []int) { + return file_blockchainpb_broadcastpb_broadcastpb_proto_rawDescGZIP(), []int{0} +} + +func (m *Event) GetType() isEvent_Type { + if m != nil { + return m.Type + } + return nil +} + +func (x *Event) GetNewBlock() *NewBlock { + if x, ok := x.GetType().(*Event_NewBlock); ok { + return x.NewBlock + } + return nil +} + +type isEvent_Type interface { + isEvent_Type() +} + +type Event_NewBlock struct { + NewBlock *NewBlock `protobuf:"bytes,1,opt,name=new_block,json=newBlock,proto3,oneof"` +} + +func (*Event_NewBlock) isEvent_Type() {} + +type NewBlock struct { + state protoimpl.MessageState + sizeCache protoimpl.SizeCache + unknownFields protoimpl.UnknownFields + + Block *blockchainpb.Block `protobuf:"bytes,1,opt,name=block,proto3" json:"block,omitempty"` +} + +func (x *NewBlock) Reset() { + *x = NewBlock{} + if protoimpl.UnsafeEnabled { + mi := &file_blockchainpb_broadcastpb_broadcastpb_proto_msgTypes[1] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) + } +} + +func (x *NewBlock) String() string { + return protoimpl.X.MessageStringOf(x) +} + +func (*NewBlock) ProtoMessage() {} + +func (x *NewBlock) ProtoReflect() protoreflect.Message { + mi := &file_blockchainpb_broadcastpb_broadcastpb_proto_msgTypes[1] + if protoimpl.UnsafeEnabled && x != nil { + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + if ms.LoadMessageInfo() == nil { + ms.StoreMessageInfo(mi) + } + return ms + } + return mi.MessageOf(x) +} + +// Deprecated: Use NewBlock.ProtoReflect.Descriptor instead. +func (*NewBlock) Descriptor() ([]byte, []int) { + return file_blockchainpb_broadcastpb_broadcastpb_proto_rawDescGZIP(), []int{1} +} + +func (x *NewBlock) GetBlock() *blockchainpb.Block { + if x != nil { + return x.Block + } + return nil +} + +type Message struct { + state protoimpl.MessageState + sizeCache protoimpl.SizeCache + unknownFields protoimpl.UnknownFields + + // Types that are assignable to Type: + // + // *Message_NewBlock + Type isMessage_Type `protobuf_oneof:"type"` +} + +func (x *Message) Reset() { + *x = Message{} + if protoimpl.UnsafeEnabled { + mi := &file_blockchainpb_broadcastpb_broadcastpb_proto_msgTypes[2] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) + } +} + +func (x *Message) String() string { + return protoimpl.X.MessageStringOf(x) +} + +func (*Message) ProtoMessage() {} + +func (x *Message) ProtoReflect() protoreflect.Message { + mi := &file_blockchainpb_broadcastpb_broadcastpb_proto_msgTypes[2] + if protoimpl.UnsafeEnabled && x != nil { + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + if ms.LoadMessageInfo() == nil { + ms.StoreMessageInfo(mi) + } + return ms + } + return mi.MessageOf(x) +} + +// Deprecated: Use Message.ProtoReflect.Descriptor instead. +func (*Message) Descriptor() ([]byte, []int) { + return file_blockchainpb_broadcastpb_broadcastpb_proto_rawDescGZIP(), []int{2} +} + +func (m *Message) GetType() isMessage_Type { + if m != nil { + return m.Type + } + return nil +} + +func (x *Message) GetNewBlock() *NewBlockMessage { + if x, ok := x.GetType().(*Message_NewBlock); ok { + return x.NewBlock + } + return nil +} + +type isMessage_Type interface { + isMessage_Type() +} + +type Message_NewBlock struct { + NewBlock *NewBlockMessage `protobuf:"bytes,1,opt,name=new_block,json=newBlock,proto3,oneof"` +} + +func (*Message_NewBlock) isMessage_Type() {} + +type NewBlockMessage struct { + state protoimpl.MessageState + sizeCache protoimpl.SizeCache + unknownFields protoimpl.UnknownFields + + Block *blockchainpb.Block `protobuf:"bytes,1,opt,name=block,proto3" json:"block,omitempty"` +} + +func (x *NewBlockMessage) Reset() { + *x = NewBlockMessage{} + if protoimpl.UnsafeEnabled { + mi := &file_blockchainpb_broadcastpb_broadcastpb_proto_msgTypes[3] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) + } +} + +func (x *NewBlockMessage) String() string { + return protoimpl.X.MessageStringOf(x) +} + +func (*NewBlockMessage) ProtoMessage() {} + +func (x *NewBlockMessage) ProtoReflect() protoreflect.Message { + mi := &file_blockchainpb_broadcastpb_broadcastpb_proto_msgTypes[3] + if protoimpl.UnsafeEnabled && x != nil { + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + if ms.LoadMessageInfo() == nil { + ms.StoreMessageInfo(mi) + } + return ms + } + return mi.MessageOf(x) +} + +// Deprecated: Use NewBlockMessage.ProtoReflect.Descriptor instead. +func (*NewBlockMessage) Descriptor() ([]byte, []int) { + return file_blockchainpb_broadcastpb_broadcastpb_proto_rawDescGZIP(), []int{3} +} + +func (x *NewBlockMessage) GetBlock() *blockchainpb.Block { + if x != nil { + return x.Block + } + return nil +} + +var File_blockchainpb_broadcastpb_broadcastpb_proto protoreflect.FileDescriptor + +var file_blockchainpb_broadcastpb_broadcastpb_proto_rawDesc = []byte{ + 0x0a, 0x2a, 0x62, 0x6c, 0x6f, 0x63, 0x6b, 0x63, 0x68, 0x61, 0x69, 0x6e, 0x70, 0x62, 0x2f, 0x62, + 0x72, 0x6f, 0x61, 0x64, 0x63, 0x61, 0x73, 0x74, 0x70, 0x62, 0x2f, 0x62, 0x72, 0x6f, 0x61, 0x64, + 0x63, 0x61, 0x73, 0x74, 0x70, 0x62, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x12, 0x0b, 0x62, 0x72, + 0x6f, 0x61, 0x64, 0x63, 0x61, 0x73, 0x74, 0x70, 0x62, 0x1a, 0x1f, 0x62, 0x6c, 0x6f, 0x63, 0x6b, + 0x63, 0x68, 0x61, 0x69, 0x6e, 0x70, 0x62, 0x2f, 0x62, 0x6c, 0x6f, 0x63, 0x6b, 0x63, 0x68, 0x61, + 0x69, 0x6e, 0x70, 0x62, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x1a, 0x1c, 0x6d, 0x69, 0x72, 0x2f, + 0x63, 0x6f, 0x64, 0x65, 0x67, 0x65, 0x6e, 0x5f, 0x65, 0x78, 0x74, 0x65, 0x6e, 0x73, 0x69, 0x6f, + 0x6e, 0x73, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x1a, 0x1c, 0x6e, 0x65, 0x74, 0x2f, 0x63, 0x6f, + 0x64, 0x65, 0x67, 0x65, 0x6e, 0x5f, 0x65, 0x78, 0x74, 0x65, 0x6e, 0x73, 0x69, 0x6f, 0x6e, 0x73, + 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x22, 0x51, 0x0a, 0x05, 0x45, 0x76, 0x65, 0x6e, 0x74, 0x12, + 0x34, 0x0a, 0x09, 0x6e, 0x65, 0x77, 0x5f, 0x62, 0x6c, 0x6f, 0x63, 0x6b, 0x18, 0x01, 0x20, 0x01, + 0x28, 0x0b, 0x32, 0x15, 0x2e, 0x62, 0x72, 0x6f, 0x61, 0x64, 0x63, 0x61, 0x73, 0x74, 0x70, 0x62, + 0x2e, 0x4e, 0x65, 0x77, 0x42, 0x6c, 0x6f, 0x63, 0x6b, 0x48, 0x00, 0x52, 0x08, 0x6e, 0x65, 0x77, + 0x42, 0x6c, 0x6f, 0x63, 0x6b, 0x3a, 0x04, 0x90, 0xa6, 0x1d, 0x01, 0x42, 0x0c, 0x0a, 0x04, 0x74, + 0x79, 0x70, 0x65, 0x12, 0x04, 0x80, 0xa6, 0x1d, 0x01, 0x22, 0x3b, 0x0a, 0x08, 0x4e, 0x65, 0x77, + 0x42, 0x6c, 0x6f, 0x63, 0x6b, 0x12, 0x29, 0x0a, 0x05, 0x62, 0x6c, 0x6f, 0x63, 0x6b, 0x18, 0x01, + 0x20, 0x01, 0x28, 0x0b, 0x32, 0x13, 0x2e, 0x62, 0x6c, 0x6f, 0x63, 0x6b, 0x63, 0x68, 0x61, 0x69, + 0x6e, 0x70, 0x62, 0x2e, 0x42, 0x6c, 0x6f, 0x63, 0x6b, 0x52, 0x05, 0x62, 0x6c, 0x6f, 0x63, 0x6b, + 0x3a, 0x04, 0x98, 0xa6, 0x1d, 0x01, 0x22, 0x5a, 0x0a, 0x07, 0x4d, 0x65, 0x73, 0x73, 0x61, 0x67, + 0x65, 0x12, 0x3b, 0x0a, 0x09, 0x6e, 0x65, 0x77, 0x5f, 0x62, 0x6c, 0x6f, 0x63, 0x6b, 0x18, 0x01, + 0x20, 0x01, 0x28, 0x0b, 0x32, 0x1c, 0x2e, 0x62, 0x72, 0x6f, 0x61, 0x64, 0x63, 0x61, 0x73, 0x74, + 0x70, 0x62, 0x2e, 0x4e, 0x65, 0x77, 0x42, 0x6c, 0x6f, 0x63, 0x6b, 0x4d, 0x65, 0x73, 0x73, 0x61, + 0x67, 0x65, 0x48, 0x00, 0x52, 0x08, 0x6e, 0x65, 0x77, 0x42, 0x6c, 0x6f, 0x63, 0x6b, 0x3a, 0x04, + 0xc8, 0xe4, 0x1d, 0x01, 0x42, 0x0c, 0x0a, 0x04, 0x74, 0x79, 0x70, 0x65, 0x12, 0x04, 0xc8, 0xe4, + 0x1d, 0x01, 0x22, 0x42, 0x0a, 0x0f, 0x4e, 0x65, 0x77, 0x42, 0x6c, 0x6f, 0x63, 0x6b, 0x4d, 0x65, + 0x73, 0x73, 0x61, 0x67, 0x65, 0x12, 0x29, 0x0a, 0x05, 0x62, 0x6c, 0x6f, 0x63, 0x6b, 0x18, 0x01, + 0x20, 0x01, 0x28, 0x0b, 0x32, 0x13, 0x2e, 0x62, 0x6c, 0x6f, 0x63, 0x6b, 0x63, 0x68, 0x61, 0x69, + 0x6e, 0x70, 0x62, 0x2e, 0x42, 0x6c, 0x6f, 0x63, 0x6b, 0x52, 0x05, 0x62, 0x6c, 0x6f, 0x63, 0x6b, + 0x3a, 0x04, 0xd0, 0xe4, 0x1d, 0x01, 0x42, 0x41, 0x5a, 0x3f, 0x67, 0x69, 0x74, 0x68, 0x75, 0x62, + 0x2e, 0x63, 0x6f, 0x6d, 0x2f, 0x66, 0x69, 0x6c, 0x65, 0x63, 0x6f, 0x69, 0x6e, 0x2d, 0x70, 0x72, + 0x6f, 0x6a, 0x65, 0x63, 0x74, 0x2f, 0x6d, 0x69, 0x72, 0x2f, 0x70, 0x6b, 0x67, 0x2f, 0x70, 0x62, + 0x2f, 0x62, 0x6c, 0x6f, 0x63, 0x6b, 0x63, 0x68, 0x61, 0x69, 0x6e, 0x70, 0x62, 0x2f, 0x62, 0x72, + 0x6f, 0x61, 0x64, 0x63, 0x61, 0x73, 0x74, 0x70, 0x62, 0x62, 0x06, 0x70, 0x72, 0x6f, 0x74, 0x6f, + 0x33, +} + +var ( + file_blockchainpb_broadcastpb_broadcastpb_proto_rawDescOnce sync.Once + file_blockchainpb_broadcastpb_broadcastpb_proto_rawDescData = file_blockchainpb_broadcastpb_broadcastpb_proto_rawDesc +) + +func file_blockchainpb_broadcastpb_broadcastpb_proto_rawDescGZIP() []byte { + file_blockchainpb_broadcastpb_broadcastpb_proto_rawDescOnce.Do(func() { + file_blockchainpb_broadcastpb_broadcastpb_proto_rawDescData = protoimpl.X.CompressGZIP(file_blockchainpb_broadcastpb_broadcastpb_proto_rawDescData) + }) + return file_blockchainpb_broadcastpb_broadcastpb_proto_rawDescData +} + +var file_blockchainpb_broadcastpb_broadcastpb_proto_msgTypes = make([]protoimpl.MessageInfo, 4) +var file_blockchainpb_broadcastpb_broadcastpb_proto_goTypes = []interface{}{ + (*Event)(nil), // 0: broadcastpb.Event + (*NewBlock)(nil), // 1: broadcastpb.NewBlock + (*Message)(nil), // 2: broadcastpb.Message + (*NewBlockMessage)(nil), // 3: broadcastpb.NewBlockMessage + (*blockchainpb.Block)(nil), // 4: blockchainpb.Block +} +var file_blockchainpb_broadcastpb_broadcastpb_proto_depIdxs = []int32{ + 1, // 0: broadcastpb.Event.new_block:type_name -> broadcastpb.NewBlock + 4, // 1: broadcastpb.NewBlock.block:type_name -> blockchainpb.Block + 3, // 2: broadcastpb.Message.new_block:type_name -> broadcastpb.NewBlockMessage + 4, // 3: broadcastpb.NewBlockMessage.block:type_name -> blockchainpb.Block + 4, // [4:4] is the sub-list for method output_type + 4, // [4:4] is the sub-list for method input_type + 4, // [4:4] is the sub-list for extension type_name + 4, // [4:4] is the sub-list for extension extendee + 0, // [0:4] is the sub-list for field type_name +} + +func init() { file_blockchainpb_broadcastpb_broadcastpb_proto_init() } +func file_blockchainpb_broadcastpb_broadcastpb_proto_init() { + if File_blockchainpb_broadcastpb_broadcastpb_proto != nil { + return + } + if !protoimpl.UnsafeEnabled { + file_blockchainpb_broadcastpb_broadcastpb_proto_msgTypes[0].Exporter = func(v interface{}, i int) interface{} { + switch v := v.(*Event); i { + case 0: + return &v.state + case 1: + return &v.sizeCache + case 2: + return &v.unknownFields + default: + return nil + } + } + file_blockchainpb_broadcastpb_broadcastpb_proto_msgTypes[1].Exporter = func(v interface{}, i int) interface{} { + switch v := v.(*NewBlock); i { + case 0: + return &v.state + case 1: + return &v.sizeCache + case 2: + return &v.unknownFields + default: + return nil + } + } + file_blockchainpb_broadcastpb_broadcastpb_proto_msgTypes[2].Exporter = func(v interface{}, i int) interface{} { + switch v := v.(*Message); i { + case 0: + return &v.state + case 1: + return &v.sizeCache + case 2: + return &v.unknownFields + default: + return nil + } + } + file_blockchainpb_broadcastpb_broadcastpb_proto_msgTypes[3].Exporter = func(v interface{}, i int) interface{} { + switch v := v.(*NewBlockMessage); i { + case 0: + return &v.state + case 1: + return &v.sizeCache + case 2: + return &v.unknownFields + default: + return nil + } + } + } + file_blockchainpb_broadcastpb_broadcastpb_proto_msgTypes[0].OneofWrappers = []interface{}{ + (*Event_NewBlock)(nil), + } + file_blockchainpb_broadcastpb_broadcastpb_proto_msgTypes[2].OneofWrappers = []interface{}{ + (*Message_NewBlock)(nil), + } + type x struct{} + out := protoimpl.TypeBuilder{ + File: protoimpl.DescBuilder{ + GoPackagePath: reflect.TypeOf(x{}).PkgPath(), + RawDescriptor: file_blockchainpb_broadcastpb_broadcastpb_proto_rawDesc, + NumEnums: 0, + NumMessages: 4, + NumExtensions: 0, + NumServices: 0, + }, + GoTypes: file_blockchainpb_broadcastpb_broadcastpb_proto_goTypes, + DependencyIndexes: file_blockchainpb_broadcastpb_broadcastpb_proto_depIdxs, + MessageInfos: file_blockchainpb_broadcastpb_broadcastpb_proto_msgTypes, + }.Build() + File_blockchainpb_broadcastpb_broadcastpb_proto = out.File + file_blockchainpb_broadcastpb_broadcastpb_proto_rawDesc = nil + file_blockchainpb_broadcastpb_broadcastpb_proto_goTypes = nil + file_blockchainpb_broadcastpb_broadcastpb_proto_depIdxs = nil +} diff --git a/pkg/pb/blockchainpb/broadcastpb/broadcastpb.pb.mir.go b/pkg/pb/blockchainpb/broadcastpb/broadcastpb.pb.mir.go new file mode 100644 index 000000000..8edb387d7 --- /dev/null +++ b/pkg/pb/blockchainpb/broadcastpb/broadcastpb.pb.mir.go @@ -0,0 +1,19 @@ +// Code generated by Mir codegen. DO NOT EDIT. + +package broadcastpb + +import ( + reflect "reflect" +) + +func (*Event) ReflectTypeOptions() []reflect.Type { + return []reflect.Type{ + reflect.TypeOf((*Event_NewBlock)(nil)), + } +} + +func (*Message) ReflectTypeOptions() []reflect.Type { + return []reflect.Type{ + reflect.TypeOf((*Message_NewBlock)(nil)), + } +} diff --git a/pkg/pb/blockchainpb/broadcastpb/dsl/emit.mir.go b/pkg/pb/blockchainpb/broadcastpb/dsl/emit.mir.go new file mode 100644 index 000000000..8d917b5b6 --- /dev/null +++ b/pkg/pb/blockchainpb/broadcastpb/dsl/emit.mir.go @@ -0,0 +1,16 @@ +// Code generated by Mir codegen. DO NOT EDIT. + +package broadcastpbdsl + +import ( + dsl "github.com/filecoin-project/mir/pkg/dsl" + events "github.com/filecoin-project/mir/pkg/pb/blockchainpb/broadcastpb/events" + types1 "github.com/filecoin-project/mir/pkg/pb/blockchainpb/types" + types "github.com/filecoin-project/mir/pkg/types" +) + +// Module-specific dsl functions for emitting events. + +func NewBlock(m dsl.Module, destModule types.ModuleID, block *types1.Block) { + dsl.EmitMirEvent(m, events.NewBlock(destModule, block)) +} diff --git a/pkg/pb/blockchainpb/broadcastpb/dsl/messages.mir.go b/pkg/pb/blockchainpb/broadcastpb/dsl/messages.mir.go new file mode 100644 index 000000000..9864811b8 --- /dev/null +++ b/pkg/pb/blockchainpb/broadcastpb/dsl/messages.mir.go @@ -0,0 +1,31 @@ +// Code generated by Mir codegen. DO NOT EDIT. + +package broadcastpbdsl + +import ( + dsl "github.com/filecoin-project/mir/pkg/dsl" + types "github.com/filecoin-project/mir/pkg/pb/blockchainpb/broadcastpb/types" + types3 "github.com/filecoin-project/mir/pkg/pb/blockchainpb/types" + dsl1 "github.com/filecoin-project/mir/pkg/pb/messagepb/dsl" + types2 "github.com/filecoin-project/mir/pkg/pb/messagepb/types" + types1 "github.com/filecoin-project/mir/pkg/types" +) + +// Module-specific dsl functions for processing net messages. + +func UponMessageReceived[W types.Message_TypeWrapper[M], M any](m dsl.Module, handler func(from types1.NodeID, msg *M) error) { + dsl1.UponMessageReceived[*types2.Message_Broadcast](m, func(from types1.NodeID, msg *types.Message) error { + w, ok := msg.Type.(W) + if !ok { + return nil + } + + return handler(from, w.Unwrap()) + }) +} + +func UponNewBlockMessageReceived(m dsl.Module, handler func(from types1.NodeID, block *types3.Block) error) { + UponMessageReceived[*types.Message_NewBlock](m, func(from types1.NodeID, msg *types.NewBlockMessage) error { + return handler(from, msg.Block) + }) +} diff --git a/pkg/pb/blockchainpb/broadcastpb/dsl/upon.mir.go b/pkg/pb/blockchainpb/broadcastpb/dsl/upon.mir.go new file mode 100644 index 000000000..0c844498d --- /dev/null +++ b/pkg/pb/blockchainpb/broadcastpb/dsl/upon.mir.go @@ -0,0 +1,29 @@ +// Code generated by Mir codegen. DO NOT EDIT. + +package broadcastpbdsl + +import ( + dsl "github.com/filecoin-project/mir/pkg/dsl" + types "github.com/filecoin-project/mir/pkg/pb/blockchainpb/broadcastpb/types" + types2 "github.com/filecoin-project/mir/pkg/pb/blockchainpb/types" + types1 "github.com/filecoin-project/mir/pkg/pb/eventpb/types" +) + +// Module-specific dsl functions for processing events. + +func UponEvent[W types.Event_TypeWrapper[Ev], Ev any](m dsl.Module, handler func(ev *Ev) error) { + dsl.UponMirEvent[*types1.Event_Broadcast](m, func(ev *types.Event) error { + w, ok := ev.Type.(W) + if !ok { + return nil + } + + return handler(w.Unwrap()) + }) +} + +func UponNewBlock(m dsl.Module, handler func(block *types2.Block) error) { + UponEvent[*types.Event_NewBlock](m, func(ev *types.NewBlock) error { + return handler(ev.Block) + }) +} diff --git a/pkg/pb/blockchainpb/broadcastpb/events/events.mir.go b/pkg/pb/blockchainpb/broadcastpb/events/events.mir.go new file mode 100644 index 000000000..2c2ff13d9 --- /dev/null +++ b/pkg/pb/blockchainpb/broadcastpb/events/events.mir.go @@ -0,0 +1,25 @@ +// Code generated by Mir codegen. DO NOT EDIT. + +package broadcastpbevents + +import ( + types3 "github.com/filecoin-project/mir/pkg/pb/blockchainpb/broadcastpb/types" + types1 "github.com/filecoin-project/mir/pkg/pb/blockchainpb/types" + types2 "github.com/filecoin-project/mir/pkg/pb/eventpb/types" + types "github.com/filecoin-project/mir/pkg/types" +) + +func NewBlock(destModule types.ModuleID, block *types1.Block) *types2.Event { + return &types2.Event{ + DestModule: destModule, + Type: &types2.Event_Broadcast{ + Broadcast: &types3.Event{ + Type: &types3.Event_NewBlock{ + NewBlock: &types3.NewBlock{ + Block: block, + }, + }, + }, + }, + } +} diff --git a/pkg/pb/blockchainpb/broadcastpb/msgs/msgs.mir.go b/pkg/pb/blockchainpb/broadcastpb/msgs/msgs.mir.go new file mode 100644 index 000000000..29929236d --- /dev/null +++ b/pkg/pb/blockchainpb/broadcastpb/msgs/msgs.mir.go @@ -0,0 +1,25 @@ +// Code generated by Mir codegen. DO NOT EDIT. + +package broadcastpbmsgs + +import ( + types3 "github.com/filecoin-project/mir/pkg/pb/blockchainpb/broadcastpb/types" + types1 "github.com/filecoin-project/mir/pkg/pb/blockchainpb/types" + types2 "github.com/filecoin-project/mir/pkg/pb/messagepb/types" + types "github.com/filecoin-project/mir/pkg/types" +) + +func NewBlockMessage(destModule types.ModuleID, block *types1.Block) *types2.Message { + return &types2.Message{ + DestModule: destModule, + Type: &types2.Message_Broadcast{ + Broadcast: &types3.Message{ + Type: &types3.Message_NewBlock{ + NewBlock: &types3.NewBlockMessage{ + Block: block, + }, + }, + }, + }, + } +} diff --git a/pkg/pb/blockchainpb/broadcastpb/oneof_interfaces.mir.go b/pkg/pb/blockchainpb/broadcastpb/oneof_interfaces.mir.go new file mode 100644 index 000000000..9d4f562ad --- /dev/null +++ b/pkg/pb/blockchainpb/broadcastpb/oneof_interfaces.mir.go @@ -0,0 +1,25 @@ +// Code generated by Mir codegen. DO NOT EDIT. + +package broadcastpb + +type Event_Type = isEvent_Type + +type Event_TypeWrapper[T any] interface { + Event_Type + Unwrap() *T +} + +func (w *Event_NewBlock) Unwrap() *NewBlock { + return w.NewBlock +} + +type Message_Type = isMessage_Type + +type Message_TypeWrapper[T any] interface { + Message_Type + Unwrap() *T +} + +func (w *Message_NewBlock) Unwrap() *NewBlockMessage { + return w.NewBlock +} diff --git a/pkg/pb/blockchainpb/broadcastpb/types/types.mir.go b/pkg/pb/blockchainpb/broadcastpb/types/types.mir.go new file mode 100644 index 000000000..eeda98930 --- /dev/null +++ b/pkg/pb/blockchainpb/broadcastpb/types/types.mir.go @@ -0,0 +1,226 @@ +// Code generated by Mir codegen. DO NOT EDIT. + +package broadcastpbtypes + +import ( + mirreflect "github.com/filecoin-project/mir/codegen/mirreflect" + broadcastpb "github.com/filecoin-project/mir/pkg/pb/blockchainpb/broadcastpb" + types "github.com/filecoin-project/mir/pkg/pb/blockchainpb/types" + reflectutil "github.com/filecoin-project/mir/pkg/util/reflectutil" +) + +type Event struct { + Type Event_Type +} + +type Event_Type interface { + mirreflect.GeneratedType + isEvent_Type() + Pb() broadcastpb.Event_Type +} + +type Event_TypeWrapper[T any] interface { + Event_Type + Unwrap() *T +} + +func Event_TypeFromPb(pb broadcastpb.Event_Type) Event_Type { + if pb == nil { + return nil + } + switch pb := pb.(type) { + case *broadcastpb.Event_NewBlock: + return &Event_NewBlock{NewBlock: NewBlockFromPb(pb.NewBlock)} + } + return nil +} + +type Event_NewBlock struct { + NewBlock *NewBlock +} + +func (*Event_NewBlock) isEvent_Type() {} + +func (w *Event_NewBlock) Unwrap() *NewBlock { + return w.NewBlock +} + +func (w *Event_NewBlock) Pb() broadcastpb.Event_Type { + if w == nil { + return nil + } + if w.NewBlock == nil { + return &broadcastpb.Event_NewBlock{} + } + return &broadcastpb.Event_NewBlock{NewBlock: (w.NewBlock).Pb()} +} + +func (*Event_NewBlock) MirReflect() mirreflect.Type { + return mirreflect.TypeImpl{PbType_: reflectutil.TypeOf[*broadcastpb.Event_NewBlock]()} +} + +func EventFromPb(pb *broadcastpb.Event) *Event { + if pb == nil { + return nil + } + return &Event{ + Type: Event_TypeFromPb(pb.Type), + } +} + +func (m *Event) Pb() *broadcastpb.Event { + if m == nil { + return nil + } + pbMessage := &broadcastpb.Event{} + { + if m.Type != nil { + pbMessage.Type = (m.Type).Pb() + } + } + + return pbMessage +} + +func (*Event) MirReflect() mirreflect.Type { + return mirreflect.TypeImpl{PbType_: reflectutil.TypeOf[*broadcastpb.Event]()} +} + +type NewBlock struct { + Block *types.Block +} + +func NewBlockFromPb(pb *broadcastpb.NewBlock) *NewBlock { + if pb == nil { + return nil + } + return &NewBlock{ + Block: types.BlockFromPb(pb.Block), + } +} + +func (m *NewBlock) Pb() *broadcastpb.NewBlock { + if m == nil { + return nil + } + pbMessage := &broadcastpb.NewBlock{} + { + if m.Block != nil { + pbMessage.Block = (m.Block).Pb() + } + } + + return pbMessage +} + +func (*NewBlock) MirReflect() mirreflect.Type { + return mirreflect.TypeImpl{PbType_: reflectutil.TypeOf[*broadcastpb.NewBlock]()} +} + +type Message struct { + Type Message_Type +} + +type Message_Type interface { + mirreflect.GeneratedType + isMessage_Type() + Pb() broadcastpb.Message_Type +} + +type Message_TypeWrapper[T any] interface { + Message_Type + Unwrap() *T +} + +func Message_TypeFromPb(pb broadcastpb.Message_Type) Message_Type { + if pb == nil { + return nil + } + switch pb := pb.(type) { + case *broadcastpb.Message_NewBlock: + return &Message_NewBlock{NewBlock: NewBlockMessageFromPb(pb.NewBlock)} + } + return nil +} + +type Message_NewBlock struct { + NewBlock *NewBlockMessage +} + +func (*Message_NewBlock) isMessage_Type() {} + +func (w *Message_NewBlock) Unwrap() *NewBlockMessage { + return w.NewBlock +} + +func (w *Message_NewBlock) Pb() broadcastpb.Message_Type { + if w == nil { + return nil + } + if w.NewBlock == nil { + return &broadcastpb.Message_NewBlock{} + } + return &broadcastpb.Message_NewBlock{NewBlock: (w.NewBlock).Pb()} +} + +func (*Message_NewBlock) MirReflect() mirreflect.Type { + return mirreflect.TypeImpl{PbType_: reflectutil.TypeOf[*broadcastpb.Message_NewBlock]()} +} + +func MessageFromPb(pb *broadcastpb.Message) *Message { + if pb == nil { + return nil + } + return &Message{ + Type: Message_TypeFromPb(pb.Type), + } +} + +func (m *Message) Pb() *broadcastpb.Message { + if m == nil { + return nil + } + pbMessage := &broadcastpb.Message{} + { + if m.Type != nil { + pbMessage.Type = (m.Type).Pb() + } + } + + return pbMessage +} + +func (*Message) MirReflect() mirreflect.Type { + return mirreflect.TypeImpl{PbType_: reflectutil.TypeOf[*broadcastpb.Message]()} +} + +type NewBlockMessage struct { + Block *types.Block +} + +func NewBlockMessageFromPb(pb *broadcastpb.NewBlockMessage) *NewBlockMessage { + if pb == nil { + return nil + } + return &NewBlockMessage{ + Block: types.BlockFromPb(pb.Block), + } +} + +func (m *NewBlockMessage) Pb() *broadcastpb.NewBlockMessage { + if m == nil { + return nil + } + pbMessage := &broadcastpb.NewBlockMessage{} + { + if m.Block != nil { + pbMessage.Block = (m.Block).Pb() + } + } + + return pbMessage +} + +func (*NewBlockMessage) MirReflect() mirreflect.Type { + return mirreflect.TypeImpl{PbType_: reflectutil.TypeOf[*broadcastpb.NewBlockMessage]()} +} diff --git a/pkg/pb/blockchainpb/interceptorpb/dsl/emit.mir.go b/pkg/pb/blockchainpb/interceptorpb/dsl/emit.mir.go new file mode 100644 index 000000000..e5531e0ec --- /dev/null +++ b/pkg/pb/blockchainpb/interceptorpb/dsl/emit.mir.go @@ -0,0 +1,21 @@ +// Code generated by Mir codegen. DO NOT EDIT. + +package interceptorpbdsl + +import ( + dsl "github.com/filecoin-project/mir/pkg/dsl" + events "github.com/filecoin-project/mir/pkg/pb/blockchainpb/interceptorpb/events" + types2 "github.com/filecoin-project/mir/pkg/pb/blockchainpb/statepb/types" + types1 "github.com/filecoin-project/mir/pkg/pb/blockchainpb/types" + types "github.com/filecoin-project/mir/pkg/types" +) + +// Module-specific dsl functions for emitting events. + +func TreeUpdate(m dsl.Module, destModule types.ModuleID, blocks []*types1.Block, headId uint64) { + dsl.EmitMirEvent(m, events.TreeUpdate(destModule, blocks, headId)) +} + +func StateUpdate(m dsl.Module, destModule types.ModuleID, state *types2.State) { + dsl.EmitMirEvent(m, events.StateUpdate(destModule, state)) +} diff --git a/pkg/pb/blockchainpb/interceptorpb/dsl/upon.mir.go b/pkg/pb/blockchainpb/interceptorpb/dsl/upon.mir.go new file mode 100644 index 000000000..32f0e598b --- /dev/null +++ b/pkg/pb/blockchainpb/interceptorpb/dsl/upon.mir.go @@ -0,0 +1,36 @@ +// Code generated by Mir codegen. DO NOT EDIT. + +package interceptorpbdsl + +import ( + dsl "github.com/filecoin-project/mir/pkg/dsl" + types "github.com/filecoin-project/mir/pkg/pb/blockchainpb/interceptorpb/types" + types3 "github.com/filecoin-project/mir/pkg/pb/blockchainpb/statepb/types" + types2 "github.com/filecoin-project/mir/pkg/pb/blockchainpb/types" + types1 "github.com/filecoin-project/mir/pkg/pb/eventpb/types" +) + +// Module-specific dsl functions for processing events. + +func UponEvent[W types.Event_TypeWrapper[Ev], Ev any](m dsl.Module, handler func(ev *Ev) error) { + dsl.UponMirEvent[*types1.Event_Bcinterceptor](m, func(ev *types.Event) error { + w, ok := ev.Type.(W) + if !ok { + return nil + } + + return handler(w.Unwrap()) + }) +} + +func UponTreeUpdate(m dsl.Module, handler func(blocks []*types2.Block, headId uint64) error) { + UponEvent[*types.Event_TreeUpdate](m, func(ev *types.TreeUpdate) error { + return handler(ev.Blocks, ev.HeadId) + }) +} + +func UponStateUpdate(m dsl.Module, handler func(state *types3.State) error) { + UponEvent[*types.Event_StateUpdate](m, func(ev *types.StateUpdate) error { + return handler(ev.State) + }) +} diff --git a/pkg/pb/blockchainpb/interceptorpb/events/events.mir.go b/pkg/pb/blockchainpb/interceptorpb/events/events.mir.go new file mode 100644 index 000000000..3a3b5f357 --- /dev/null +++ b/pkg/pb/blockchainpb/interceptorpb/events/events.mir.go @@ -0,0 +1,42 @@ +// Code generated by Mir codegen. DO NOT EDIT. + +package interceptorpbevents + +import ( + types3 "github.com/filecoin-project/mir/pkg/pb/blockchainpb/interceptorpb/types" + types4 "github.com/filecoin-project/mir/pkg/pb/blockchainpb/statepb/types" + types1 "github.com/filecoin-project/mir/pkg/pb/blockchainpb/types" + types2 "github.com/filecoin-project/mir/pkg/pb/eventpb/types" + types "github.com/filecoin-project/mir/pkg/types" +) + +func TreeUpdate(destModule types.ModuleID, blocks []*types1.Block, headId uint64) *types2.Event { + return &types2.Event{ + DestModule: destModule, + Type: &types2.Event_Bcinterceptor{ + Bcinterceptor: &types3.Event{ + Type: &types3.Event_TreeUpdate{ + TreeUpdate: &types3.TreeUpdate{ + Blocks: blocks, + HeadId: headId, + }, + }, + }, + }, + } +} + +func StateUpdate(destModule types.ModuleID, state *types4.State) *types2.Event { + return &types2.Event{ + DestModule: destModule, + Type: &types2.Event_Bcinterceptor{ + Bcinterceptor: &types3.Event{ + Type: &types3.Event_StateUpdate{ + StateUpdate: &types3.StateUpdate{ + State: state, + }, + }, + }, + }, + } +} diff --git a/pkg/pb/blockchainpb/interceptorpb/interceptorpb.pb.go b/pkg/pb/blockchainpb/interceptorpb/interceptorpb.pb.go new file mode 100644 index 000000000..695dc4a90 --- /dev/null +++ b/pkg/pb/blockchainpb/interceptorpb/interceptorpb.pb.go @@ -0,0 +1,346 @@ +// Code generated by protoc-gen-go. DO NOT EDIT. +// versions: +// protoc-gen-go v1.31.0 +// protoc v4.25.2 +// source: blockchainpb/interceptorpb/interceptorpb.proto + +package interceptorpb + +import ( + blockchainpb "github.com/filecoin-project/mir/pkg/pb/blockchainpb" + statepb "github.com/filecoin-project/mir/pkg/pb/blockchainpb/statepb" + _ "github.com/filecoin-project/mir/pkg/pb/mir" + protoreflect "google.golang.org/protobuf/reflect/protoreflect" + protoimpl "google.golang.org/protobuf/runtime/protoimpl" + reflect "reflect" + sync "sync" +) + +const ( + // Verify that this generated code is sufficiently up-to-date. + _ = protoimpl.EnforceVersion(20 - protoimpl.MinVersion) + // Verify that runtime/protoimpl is sufficiently up-to-date. + _ = protoimpl.EnforceVersion(protoimpl.MaxVersion - 20) +) + +type Event struct { + state protoimpl.MessageState + sizeCache protoimpl.SizeCache + unknownFields protoimpl.UnknownFields + + // Types that are assignable to Type: + // + // *Event_TreeUpdate + // *Event_StateUpdate + Type isEvent_Type `protobuf_oneof:"type"` +} + +func (x *Event) Reset() { + *x = Event{} + if protoimpl.UnsafeEnabled { + mi := &file_blockchainpb_interceptorpb_interceptorpb_proto_msgTypes[0] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) + } +} + +func (x *Event) String() string { + return protoimpl.X.MessageStringOf(x) +} + +func (*Event) ProtoMessage() {} + +func (x *Event) ProtoReflect() protoreflect.Message { + mi := &file_blockchainpb_interceptorpb_interceptorpb_proto_msgTypes[0] + if protoimpl.UnsafeEnabled && x != nil { + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + if ms.LoadMessageInfo() == nil { + ms.StoreMessageInfo(mi) + } + return ms + } + return mi.MessageOf(x) +} + +// Deprecated: Use Event.ProtoReflect.Descriptor instead. +func (*Event) Descriptor() ([]byte, []int) { + return file_blockchainpb_interceptorpb_interceptorpb_proto_rawDescGZIP(), []int{0} +} + +func (m *Event) GetType() isEvent_Type { + if m != nil { + return m.Type + } + return nil +} + +func (x *Event) GetTreeUpdate() *TreeUpdate { + if x, ok := x.GetType().(*Event_TreeUpdate); ok { + return x.TreeUpdate + } + return nil +} + +func (x *Event) GetStateUpdate() *StateUpdate { + if x, ok := x.GetType().(*Event_StateUpdate); ok { + return x.StateUpdate + } + return nil +} + +type isEvent_Type interface { + isEvent_Type() +} + +type Event_TreeUpdate struct { + TreeUpdate *TreeUpdate `protobuf:"bytes,1,opt,name=tree_update,json=treeUpdate,proto3,oneof"` +} + +type Event_StateUpdate struct { + StateUpdate *StateUpdate `protobuf:"bytes,2,opt,name=state_update,json=stateUpdate,proto3,oneof"` +} + +func (*Event_TreeUpdate) isEvent_Type() {} + +func (*Event_StateUpdate) isEvent_Type() {} + +type TreeUpdate struct { + state protoimpl.MessageState + sizeCache protoimpl.SizeCache + unknownFields protoimpl.UnknownFields + + Blocks []*blockchainpb.Block `protobuf:"bytes,1,rep,name=blocks,proto3" json:"blocks,omitempty"` + HeadId uint64 `protobuf:"varint,2,opt,name=head_id,json=headId,proto3" json:"head_id,omitempty"` +} + +func (x *TreeUpdate) Reset() { + *x = TreeUpdate{} + if protoimpl.UnsafeEnabled { + mi := &file_blockchainpb_interceptorpb_interceptorpb_proto_msgTypes[1] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) + } +} + +func (x *TreeUpdate) String() string { + return protoimpl.X.MessageStringOf(x) +} + +func (*TreeUpdate) ProtoMessage() {} + +func (x *TreeUpdate) ProtoReflect() protoreflect.Message { + mi := &file_blockchainpb_interceptorpb_interceptorpb_proto_msgTypes[1] + if protoimpl.UnsafeEnabled && x != nil { + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + if ms.LoadMessageInfo() == nil { + ms.StoreMessageInfo(mi) + } + return ms + } + return mi.MessageOf(x) +} + +// Deprecated: Use TreeUpdate.ProtoReflect.Descriptor instead. +func (*TreeUpdate) Descriptor() ([]byte, []int) { + return file_blockchainpb_interceptorpb_interceptorpb_proto_rawDescGZIP(), []int{1} +} + +func (x *TreeUpdate) GetBlocks() []*blockchainpb.Block { + if x != nil { + return x.Blocks + } + return nil +} + +func (x *TreeUpdate) GetHeadId() uint64 { + if x != nil { + return x.HeadId + } + return 0 +} + +type StateUpdate struct { + state protoimpl.MessageState + sizeCache protoimpl.SizeCache + unknownFields protoimpl.UnknownFields + + State *statepb.State `protobuf:"bytes,1,opt,name=state,proto3" json:"state,omitempty"` +} + +func (x *StateUpdate) Reset() { + *x = StateUpdate{} + if protoimpl.UnsafeEnabled { + mi := &file_blockchainpb_interceptorpb_interceptorpb_proto_msgTypes[2] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) + } +} + +func (x *StateUpdate) String() string { + return protoimpl.X.MessageStringOf(x) +} + +func (*StateUpdate) ProtoMessage() {} + +func (x *StateUpdate) ProtoReflect() protoreflect.Message { + mi := &file_blockchainpb_interceptorpb_interceptorpb_proto_msgTypes[2] + if protoimpl.UnsafeEnabled && x != nil { + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + if ms.LoadMessageInfo() == nil { + ms.StoreMessageInfo(mi) + } + return ms + } + return mi.MessageOf(x) +} + +// Deprecated: Use StateUpdate.ProtoReflect.Descriptor instead. +func (*StateUpdate) Descriptor() ([]byte, []int) { + return file_blockchainpb_interceptorpb_interceptorpb_proto_rawDescGZIP(), []int{2} +} + +func (x *StateUpdate) GetState() *statepb.State { + if x != nil { + return x.State + } + return nil +} + +var File_blockchainpb_interceptorpb_interceptorpb_proto protoreflect.FileDescriptor + +var file_blockchainpb_interceptorpb_interceptorpb_proto_rawDesc = []byte{ + 0x0a, 0x2e, 0x62, 0x6c, 0x6f, 0x63, 0x6b, 0x63, 0x68, 0x61, 0x69, 0x6e, 0x70, 0x62, 0x2f, 0x69, + 0x6e, 0x74, 0x65, 0x72, 0x63, 0x65, 0x70, 0x74, 0x6f, 0x72, 0x70, 0x62, 0x2f, 0x69, 0x6e, 0x74, + 0x65, 0x72, 0x63, 0x65, 0x70, 0x74, 0x6f, 0x72, 0x70, 0x62, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, + 0x12, 0x0d, 0x69, 0x6e, 0x74, 0x65, 0x72, 0x63, 0x65, 0x70, 0x74, 0x6f, 0x72, 0x70, 0x62, 0x1a, + 0x1f, 0x62, 0x6c, 0x6f, 0x63, 0x6b, 0x63, 0x68, 0x61, 0x69, 0x6e, 0x70, 0x62, 0x2f, 0x62, 0x6c, + 0x6f, 0x63, 0x6b, 0x63, 0x68, 0x61, 0x69, 0x6e, 0x70, 0x62, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, + 0x1a, 0x22, 0x62, 0x6c, 0x6f, 0x63, 0x6b, 0x63, 0x68, 0x61, 0x69, 0x6e, 0x70, 0x62, 0x2f, 0x73, + 0x74, 0x61, 0x74, 0x65, 0x70, 0x62, 0x2f, 0x73, 0x74, 0x61, 0x74, 0x65, 0x70, 0x62, 0x2e, 0x70, + 0x72, 0x6f, 0x74, 0x6f, 0x1a, 0x1c, 0x6d, 0x69, 0x72, 0x2f, 0x63, 0x6f, 0x64, 0x65, 0x67, 0x65, + 0x6e, 0x5f, 0x65, 0x78, 0x74, 0x65, 0x6e, 0x73, 0x69, 0x6f, 0x6e, 0x73, 0x2e, 0x70, 0x72, 0x6f, + 0x74, 0x6f, 0x22, 0x9a, 0x01, 0x0a, 0x05, 0x45, 0x76, 0x65, 0x6e, 0x74, 0x12, 0x3c, 0x0a, 0x0b, + 0x74, 0x72, 0x65, 0x65, 0x5f, 0x75, 0x70, 0x64, 0x61, 0x74, 0x65, 0x18, 0x01, 0x20, 0x01, 0x28, + 0x0b, 0x32, 0x19, 0x2e, 0x69, 0x6e, 0x74, 0x65, 0x72, 0x63, 0x65, 0x70, 0x74, 0x6f, 0x72, 0x70, + 0x62, 0x2e, 0x54, 0x72, 0x65, 0x65, 0x55, 0x70, 0x64, 0x61, 0x74, 0x65, 0x48, 0x00, 0x52, 0x0a, + 0x74, 0x72, 0x65, 0x65, 0x55, 0x70, 0x64, 0x61, 0x74, 0x65, 0x12, 0x3f, 0x0a, 0x0c, 0x73, 0x74, + 0x61, 0x74, 0x65, 0x5f, 0x75, 0x70, 0x64, 0x61, 0x74, 0x65, 0x18, 0x02, 0x20, 0x01, 0x28, 0x0b, + 0x32, 0x1a, 0x2e, 0x69, 0x6e, 0x74, 0x65, 0x72, 0x63, 0x65, 0x70, 0x74, 0x6f, 0x72, 0x70, 0x62, + 0x2e, 0x53, 0x74, 0x61, 0x74, 0x65, 0x55, 0x70, 0x64, 0x61, 0x74, 0x65, 0x48, 0x00, 0x52, 0x0b, + 0x73, 0x74, 0x61, 0x74, 0x65, 0x55, 0x70, 0x64, 0x61, 0x74, 0x65, 0x3a, 0x04, 0x90, 0xa6, 0x1d, + 0x01, 0x42, 0x0c, 0x0a, 0x04, 0x74, 0x79, 0x70, 0x65, 0x12, 0x04, 0x80, 0xa6, 0x1d, 0x01, 0x22, + 0x58, 0x0a, 0x0a, 0x54, 0x72, 0x65, 0x65, 0x55, 0x70, 0x64, 0x61, 0x74, 0x65, 0x12, 0x2b, 0x0a, + 0x06, 0x62, 0x6c, 0x6f, 0x63, 0x6b, 0x73, 0x18, 0x01, 0x20, 0x03, 0x28, 0x0b, 0x32, 0x13, 0x2e, + 0x62, 0x6c, 0x6f, 0x63, 0x6b, 0x63, 0x68, 0x61, 0x69, 0x6e, 0x70, 0x62, 0x2e, 0x42, 0x6c, 0x6f, + 0x63, 0x6b, 0x52, 0x06, 0x62, 0x6c, 0x6f, 0x63, 0x6b, 0x73, 0x12, 0x17, 0x0a, 0x07, 0x68, 0x65, + 0x61, 0x64, 0x5f, 0x69, 0x64, 0x18, 0x02, 0x20, 0x01, 0x28, 0x04, 0x52, 0x06, 0x68, 0x65, 0x61, + 0x64, 0x49, 0x64, 0x3a, 0x04, 0x98, 0xa6, 0x1d, 0x01, 0x22, 0x39, 0x0a, 0x0b, 0x53, 0x74, 0x61, + 0x74, 0x65, 0x55, 0x70, 0x64, 0x61, 0x74, 0x65, 0x12, 0x24, 0x0a, 0x05, 0x73, 0x74, 0x61, 0x74, + 0x65, 0x18, 0x01, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x0e, 0x2e, 0x73, 0x74, 0x61, 0x74, 0x65, 0x70, + 0x62, 0x2e, 0x53, 0x74, 0x61, 0x74, 0x65, 0x52, 0x05, 0x73, 0x74, 0x61, 0x74, 0x65, 0x3a, 0x04, + 0x98, 0xa6, 0x1d, 0x01, 0x42, 0x43, 0x5a, 0x41, 0x67, 0x69, 0x74, 0x68, 0x75, 0x62, 0x2e, 0x63, + 0x6f, 0x6d, 0x2f, 0x66, 0x69, 0x6c, 0x65, 0x63, 0x6f, 0x69, 0x6e, 0x2d, 0x70, 0x72, 0x6f, 0x6a, + 0x65, 0x63, 0x74, 0x2f, 0x6d, 0x69, 0x72, 0x2f, 0x70, 0x6b, 0x67, 0x2f, 0x70, 0x62, 0x2f, 0x62, + 0x6c, 0x6f, 0x63, 0x6b, 0x63, 0x68, 0x61, 0x69, 0x6e, 0x70, 0x62, 0x2f, 0x69, 0x6e, 0x74, 0x65, + 0x72, 0x63, 0x65, 0x70, 0x74, 0x6f, 0x72, 0x70, 0x62, 0x62, 0x06, 0x70, 0x72, 0x6f, 0x74, 0x6f, + 0x33, +} + +var ( + file_blockchainpb_interceptorpb_interceptorpb_proto_rawDescOnce sync.Once + file_blockchainpb_interceptorpb_interceptorpb_proto_rawDescData = file_blockchainpb_interceptorpb_interceptorpb_proto_rawDesc +) + +func file_blockchainpb_interceptorpb_interceptorpb_proto_rawDescGZIP() []byte { + file_blockchainpb_interceptorpb_interceptorpb_proto_rawDescOnce.Do(func() { + file_blockchainpb_interceptorpb_interceptorpb_proto_rawDescData = protoimpl.X.CompressGZIP(file_blockchainpb_interceptorpb_interceptorpb_proto_rawDescData) + }) + return file_blockchainpb_interceptorpb_interceptorpb_proto_rawDescData +} + +var file_blockchainpb_interceptorpb_interceptorpb_proto_msgTypes = make([]protoimpl.MessageInfo, 3) +var file_blockchainpb_interceptorpb_interceptorpb_proto_goTypes = []interface{}{ + (*Event)(nil), // 0: interceptorpb.Event + (*TreeUpdate)(nil), // 1: interceptorpb.TreeUpdate + (*StateUpdate)(nil), // 2: interceptorpb.StateUpdate + (*blockchainpb.Block)(nil), // 3: blockchainpb.Block + (*statepb.State)(nil), // 4: statepb.State +} +var file_blockchainpb_interceptorpb_interceptorpb_proto_depIdxs = []int32{ + 1, // 0: interceptorpb.Event.tree_update:type_name -> interceptorpb.TreeUpdate + 2, // 1: interceptorpb.Event.state_update:type_name -> interceptorpb.StateUpdate + 3, // 2: interceptorpb.TreeUpdate.blocks:type_name -> blockchainpb.Block + 4, // 3: interceptorpb.StateUpdate.state:type_name -> statepb.State + 4, // [4:4] is the sub-list for method output_type + 4, // [4:4] is the sub-list for method input_type + 4, // [4:4] is the sub-list for extension type_name + 4, // [4:4] is the sub-list for extension extendee + 0, // [0:4] is the sub-list for field type_name +} + +func init() { file_blockchainpb_interceptorpb_interceptorpb_proto_init() } +func file_blockchainpb_interceptorpb_interceptorpb_proto_init() { + if File_blockchainpb_interceptorpb_interceptorpb_proto != nil { + return + } + if !protoimpl.UnsafeEnabled { + file_blockchainpb_interceptorpb_interceptorpb_proto_msgTypes[0].Exporter = func(v interface{}, i int) interface{} { + switch v := v.(*Event); i { + case 0: + return &v.state + case 1: + return &v.sizeCache + case 2: + return &v.unknownFields + default: + return nil + } + } + file_blockchainpb_interceptorpb_interceptorpb_proto_msgTypes[1].Exporter = func(v interface{}, i int) interface{} { + switch v := v.(*TreeUpdate); i { + case 0: + return &v.state + case 1: + return &v.sizeCache + case 2: + return &v.unknownFields + default: + return nil + } + } + file_blockchainpb_interceptorpb_interceptorpb_proto_msgTypes[2].Exporter = func(v interface{}, i int) interface{} { + switch v := v.(*StateUpdate); i { + case 0: + return &v.state + case 1: + return &v.sizeCache + case 2: + return &v.unknownFields + default: + return nil + } + } + } + file_blockchainpb_interceptorpb_interceptorpb_proto_msgTypes[0].OneofWrappers = []interface{}{ + (*Event_TreeUpdate)(nil), + (*Event_StateUpdate)(nil), + } + type x struct{} + out := protoimpl.TypeBuilder{ + File: protoimpl.DescBuilder{ + GoPackagePath: reflect.TypeOf(x{}).PkgPath(), + RawDescriptor: file_blockchainpb_interceptorpb_interceptorpb_proto_rawDesc, + NumEnums: 0, + NumMessages: 3, + NumExtensions: 0, + NumServices: 0, + }, + GoTypes: file_blockchainpb_interceptorpb_interceptorpb_proto_goTypes, + DependencyIndexes: file_blockchainpb_interceptorpb_interceptorpb_proto_depIdxs, + MessageInfos: file_blockchainpb_interceptorpb_interceptorpb_proto_msgTypes, + }.Build() + File_blockchainpb_interceptorpb_interceptorpb_proto = out.File + file_blockchainpb_interceptorpb_interceptorpb_proto_rawDesc = nil + file_blockchainpb_interceptorpb_interceptorpb_proto_goTypes = nil + file_blockchainpb_interceptorpb_interceptorpb_proto_depIdxs = nil +} diff --git a/pkg/pb/blockchainpb/interceptorpb/interceptorpb.pb.mir.go b/pkg/pb/blockchainpb/interceptorpb/interceptorpb.pb.mir.go new file mode 100644 index 000000000..dcf3cb82a --- /dev/null +++ b/pkg/pb/blockchainpb/interceptorpb/interceptorpb.pb.mir.go @@ -0,0 +1,14 @@ +// Code generated by Mir codegen. DO NOT EDIT. + +package interceptorpb + +import ( + reflect "reflect" +) + +func (*Event) ReflectTypeOptions() []reflect.Type { + return []reflect.Type{ + reflect.TypeOf((*Event_TreeUpdate)(nil)), + reflect.TypeOf((*Event_StateUpdate)(nil)), + } +} diff --git a/pkg/pb/blockchainpb/interceptorpb/oneof_interfaces.mir.go b/pkg/pb/blockchainpb/interceptorpb/oneof_interfaces.mir.go new file mode 100644 index 000000000..4a4417002 --- /dev/null +++ b/pkg/pb/blockchainpb/interceptorpb/oneof_interfaces.mir.go @@ -0,0 +1,18 @@ +// Code generated by Mir codegen. DO NOT EDIT. + +package interceptorpb + +type Event_Type = isEvent_Type + +type Event_TypeWrapper[T any] interface { + Event_Type + Unwrap() *T +} + +func (w *Event_TreeUpdate) Unwrap() *TreeUpdate { + return w.TreeUpdate +} + +func (w *Event_StateUpdate) Unwrap() *StateUpdate { + return w.StateUpdate +} diff --git a/pkg/pb/blockchainpb/interceptorpb/types/types.mir.go b/pkg/pb/blockchainpb/interceptorpb/types/types.mir.go new file mode 100644 index 000000000..8942f527e --- /dev/null +++ b/pkg/pb/blockchainpb/interceptorpb/types/types.mir.go @@ -0,0 +1,183 @@ +// Code generated by Mir codegen. DO NOT EDIT. + +package interceptorpbtypes + +import ( + mirreflect "github.com/filecoin-project/mir/codegen/mirreflect" + types1 "github.com/filecoin-project/mir/codegen/model/types" + blockchainpb "github.com/filecoin-project/mir/pkg/pb/blockchainpb" + interceptorpb "github.com/filecoin-project/mir/pkg/pb/blockchainpb/interceptorpb" + types2 "github.com/filecoin-project/mir/pkg/pb/blockchainpb/statepb/types" + types "github.com/filecoin-project/mir/pkg/pb/blockchainpb/types" + reflectutil "github.com/filecoin-project/mir/pkg/util/reflectutil" +) + +type Event struct { + Type Event_Type +} + +type Event_Type interface { + mirreflect.GeneratedType + isEvent_Type() + Pb() interceptorpb.Event_Type +} + +type Event_TypeWrapper[T any] interface { + Event_Type + Unwrap() *T +} + +func Event_TypeFromPb(pb interceptorpb.Event_Type) Event_Type { + if pb == nil { + return nil + } + switch pb := pb.(type) { + case *interceptorpb.Event_TreeUpdate: + return &Event_TreeUpdate{TreeUpdate: TreeUpdateFromPb(pb.TreeUpdate)} + case *interceptorpb.Event_StateUpdate: + return &Event_StateUpdate{StateUpdate: StateUpdateFromPb(pb.StateUpdate)} + } + return nil +} + +type Event_TreeUpdate struct { + TreeUpdate *TreeUpdate +} + +func (*Event_TreeUpdate) isEvent_Type() {} + +func (w *Event_TreeUpdate) Unwrap() *TreeUpdate { + return w.TreeUpdate +} + +func (w *Event_TreeUpdate) Pb() interceptorpb.Event_Type { + if w == nil { + return nil + } + if w.TreeUpdate == nil { + return &interceptorpb.Event_TreeUpdate{} + } + return &interceptorpb.Event_TreeUpdate{TreeUpdate: (w.TreeUpdate).Pb()} +} + +func (*Event_TreeUpdate) MirReflect() mirreflect.Type { + return mirreflect.TypeImpl{PbType_: reflectutil.TypeOf[*interceptorpb.Event_TreeUpdate]()} +} + +type Event_StateUpdate struct { + StateUpdate *StateUpdate +} + +func (*Event_StateUpdate) isEvent_Type() {} + +func (w *Event_StateUpdate) Unwrap() *StateUpdate { + return w.StateUpdate +} + +func (w *Event_StateUpdate) Pb() interceptorpb.Event_Type { + if w == nil { + return nil + } + if w.StateUpdate == nil { + return &interceptorpb.Event_StateUpdate{} + } + return &interceptorpb.Event_StateUpdate{StateUpdate: (w.StateUpdate).Pb()} +} + +func (*Event_StateUpdate) MirReflect() mirreflect.Type { + return mirreflect.TypeImpl{PbType_: reflectutil.TypeOf[*interceptorpb.Event_StateUpdate]()} +} + +func EventFromPb(pb *interceptorpb.Event) *Event { + if pb == nil { + return nil + } + return &Event{ + Type: Event_TypeFromPb(pb.Type), + } +} + +func (m *Event) Pb() *interceptorpb.Event { + if m == nil { + return nil + } + pbMessage := &interceptorpb.Event{} + { + if m.Type != nil { + pbMessage.Type = (m.Type).Pb() + } + } + + return pbMessage +} + +func (*Event) MirReflect() mirreflect.Type { + return mirreflect.TypeImpl{PbType_: reflectutil.TypeOf[*interceptorpb.Event]()} +} + +type TreeUpdate struct { + Blocks []*types.Block + HeadId uint64 +} + +func TreeUpdateFromPb(pb *interceptorpb.TreeUpdate) *TreeUpdate { + if pb == nil { + return nil + } + return &TreeUpdate{ + Blocks: types1.ConvertSlice(pb.Blocks, func(t *blockchainpb.Block) *types.Block { + return types.BlockFromPb(t) + }), + HeadId: pb.HeadId, + } +} + +func (m *TreeUpdate) Pb() *interceptorpb.TreeUpdate { + if m == nil { + return nil + } + pbMessage := &interceptorpb.TreeUpdate{} + { + pbMessage.Blocks = types1.ConvertSlice(m.Blocks, func(t *types.Block) *blockchainpb.Block { + return (t).Pb() + }) + pbMessage.HeadId = m.HeadId + } + + return pbMessage +} + +func (*TreeUpdate) MirReflect() mirreflect.Type { + return mirreflect.TypeImpl{PbType_: reflectutil.TypeOf[*interceptorpb.TreeUpdate]()} +} + +type StateUpdate struct { + State *types2.State +} + +func StateUpdateFromPb(pb *interceptorpb.StateUpdate) *StateUpdate { + if pb == nil { + return nil + } + return &StateUpdate{ + State: types2.StateFromPb(pb.State), + } +} + +func (m *StateUpdate) Pb() *interceptorpb.StateUpdate { + if m == nil { + return nil + } + pbMessage := &interceptorpb.StateUpdate{} + { + if m.State != nil { + pbMessage.State = (m.State).Pb() + } + } + + return pbMessage +} + +func (*StateUpdate) MirReflect() mirreflect.Type { + return mirreflect.TypeImpl{PbType_: reflectutil.TypeOf[*interceptorpb.StateUpdate]()} +} diff --git a/pkg/pb/blockchainpb/minerpb/dsl/emit.mir.go b/pkg/pb/blockchainpb/minerpb/dsl/emit.mir.go new file mode 100644 index 000000000..abd98a1f7 --- /dev/null +++ b/pkg/pb/blockchainpb/minerpb/dsl/emit.mir.go @@ -0,0 +1,20 @@ +// Code generated by Mir codegen. DO NOT EDIT. + +package minerpbdsl + +import ( + dsl "github.com/filecoin-project/mir/pkg/dsl" + events "github.com/filecoin-project/mir/pkg/pb/blockchainpb/minerpb/events" + types1 "github.com/filecoin-project/mir/pkg/pb/blockchainpb/payloadpb/types" + types "github.com/filecoin-project/mir/pkg/types" +) + +// Module-specific dsl functions for emitting events. + +func BlockRequest(m dsl.Module, destModule types.ModuleID, headId uint64, payload *types1.Payload) { + dsl.EmitMirEvent(m, events.BlockRequest(destModule, headId, payload)) +} + +func NewHead(m dsl.Module, destModule types.ModuleID, headId uint64) { + dsl.EmitMirEvent(m, events.NewHead(destModule, headId)) +} diff --git a/pkg/pb/blockchainpb/minerpb/dsl/upon.mir.go b/pkg/pb/blockchainpb/minerpb/dsl/upon.mir.go new file mode 100644 index 000000000..676701e40 --- /dev/null +++ b/pkg/pb/blockchainpb/minerpb/dsl/upon.mir.go @@ -0,0 +1,35 @@ +// Code generated by Mir codegen. DO NOT EDIT. + +package minerpbdsl + +import ( + dsl "github.com/filecoin-project/mir/pkg/dsl" + types "github.com/filecoin-project/mir/pkg/pb/blockchainpb/minerpb/types" + types2 "github.com/filecoin-project/mir/pkg/pb/blockchainpb/payloadpb/types" + types1 "github.com/filecoin-project/mir/pkg/pb/eventpb/types" +) + +// Module-specific dsl functions for processing events. + +func UponEvent[W types.Event_TypeWrapper[Ev], Ev any](m dsl.Module, handler func(ev *Ev) error) { + dsl.UponMirEvent[*types1.Event_Miner](m, func(ev *types.Event) error { + w, ok := ev.Type.(W) + if !ok { + return nil + } + + return handler(w.Unwrap()) + }) +} + +func UponBlockRequest(m dsl.Module, handler func(headId uint64, payload *types2.Payload) error) { + UponEvent[*types.Event_BlockRequest](m, func(ev *types.BlockRequest) error { + return handler(ev.HeadId, ev.Payload) + }) +} + +func UponNewHead(m dsl.Module, handler func(headId uint64) error) { + UponEvent[*types.Event_NewHead](m, func(ev *types.NewHead) error { + return handler(ev.HeadId) + }) +} diff --git a/pkg/pb/blockchainpb/minerpb/events/events.mir.go b/pkg/pb/blockchainpb/minerpb/events/events.mir.go new file mode 100644 index 000000000..b8c58c99b --- /dev/null +++ b/pkg/pb/blockchainpb/minerpb/events/events.mir.go @@ -0,0 +1,41 @@ +// Code generated by Mir codegen. DO NOT EDIT. + +package minerpbevents + +import ( + types3 "github.com/filecoin-project/mir/pkg/pb/blockchainpb/minerpb/types" + types1 "github.com/filecoin-project/mir/pkg/pb/blockchainpb/payloadpb/types" + types2 "github.com/filecoin-project/mir/pkg/pb/eventpb/types" + types "github.com/filecoin-project/mir/pkg/types" +) + +func BlockRequest(destModule types.ModuleID, headId uint64, payload *types1.Payload) *types2.Event { + return &types2.Event{ + DestModule: destModule, + Type: &types2.Event_Miner{ + Miner: &types3.Event{ + Type: &types3.Event_BlockRequest{ + BlockRequest: &types3.BlockRequest{ + HeadId: headId, + Payload: payload, + }, + }, + }, + }, + } +} + +func NewHead(destModule types.ModuleID, headId uint64) *types2.Event { + return &types2.Event{ + DestModule: destModule, + Type: &types2.Event_Miner{ + Miner: &types3.Event{ + Type: &types3.Event_NewHead{ + NewHead: &types3.NewHead{ + HeadId: headId, + }, + }, + }, + }, + } +} diff --git a/pkg/pb/blockchainpb/minerpb/minerpb.pb.go b/pkg/pb/blockchainpb/minerpb/minerpb.pb.go new file mode 100644 index 000000000..188169f97 --- /dev/null +++ b/pkg/pb/blockchainpb/minerpb/minerpb.pb.go @@ -0,0 +1,337 @@ +// Code generated by protoc-gen-go. DO NOT EDIT. +// versions: +// protoc-gen-go v1.31.0 +// protoc v4.25.2 +// source: blockchainpb/minerpb/minerpb.proto + +package minerpb + +import ( + payloadpb "github.com/filecoin-project/mir/pkg/pb/blockchainpb/payloadpb" + _ "github.com/filecoin-project/mir/pkg/pb/mir" + protoreflect "google.golang.org/protobuf/reflect/protoreflect" + protoimpl "google.golang.org/protobuf/runtime/protoimpl" + reflect "reflect" + sync "sync" +) + +const ( + // Verify that this generated code is sufficiently up-to-date. + _ = protoimpl.EnforceVersion(20 - protoimpl.MinVersion) + // Verify that runtime/protoimpl is sufficiently up-to-date. + _ = protoimpl.EnforceVersion(protoimpl.MaxVersion - 20) +) + +type Event struct { + state protoimpl.MessageState + sizeCache protoimpl.SizeCache + unknownFields protoimpl.UnknownFields + + // Types that are assignable to Type: + // + // *Event_BlockRequest + // *Event_NewHead + Type isEvent_Type `protobuf_oneof:"type"` +} + +func (x *Event) Reset() { + *x = Event{} + if protoimpl.UnsafeEnabled { + mi := &file_blockchainpb_minerpb_minerpb_proto_msgTypes[0] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) + } +} + +func (x *Event) String() string { + return protoimpl.X.MessageStringOf(x) +} + +func (*Event) ProtoMessage() {} + +func (x *Event) ProtoReflect() protoreflect.Message { + mi := &file_blockchainpb_minerpb_minerpb_proto_msgTypes[0] + if protoimpl.UnsafeEnabled && x != nil { + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + if ms.LoadMessageInfo() == nil { + ms.StoreMessageInfo(mi) + } + return ms + } + return mi.MessageOf(x) +} + +// Deprecated: Use Event.ProtoReflect.Descriptor instead. +func (*Event) Descriptor() ([]byte, []int) { + return file_blockchainpb_minerpb_minerpb_proto_rawDescGZIP(), []int{0} +} + +func (m *Event) GetType() isEvent_Type { + if m != nil { + return m.Type + } + return nil +} + +func (x *Event) GetBlockRequest() *BlockRequest { + if x, ok := x.GetType().(*Event_BlockRequest); ok { + return x.BlockRequest + } + return nil +} + +func (x *Event) GetNewHead() *NewHead { + if x, ok := x.GetType().(*Event_NewHead); ok { + return x.NewHead + } + return nil +} + +type isEvent_Type interface { + isEvent_Type() +} + +type Event_BlockRequest struct { + BlockRequest *BlockRequest `protobuf:"bytes,1,opt,name=block_request,json=blockRequest,proto3,oneof"` +} + +type Event_NewHead struct { + NewHead *NewHead `protobuf:"bytes,2,opt,name=new_head,json=newHead,proto3,oneof"` +} + +func (*Event_BlockRequest) isEvent_Type() {} + +func (*Event_NewHead) isEvent_Type() {} + +type BlockRequest struct { + state protoimpl.MessageState + sizeCache protoimpl.SizeCache + unknownFields protoimpl.UnknownFields + + HeadId uint64 `protobuf:"varint,1,opt,name=head_id,json=headId,proto3" json:"head_id,omitempty"` + Payload *payloadpb.Payload `protobuf:"bytes,2,opt,name=payload,proto3" json:"payload,omitempty"` +} + +func (x *BlockRequest) Reset() { + *x = BlockRequest{} + if protoimpl.UnsafeEnabled { + mi := &file_blockchainpb_minerpb_minerpb_proto_msgTypes[1] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) + } +} + +func (x *BlockRequest) String() string { + return protoimpl.X.MessageStringOf(x) +} + +func (*BlockRequest) ProtoMessage() {} + +func (x *BlockRequest) ProtoReflect() protoreflect.Message { + mi := &file_blockchainpb_minerpb_minerpb_proto_msgTypes[1] + if protoimpl.UnsafeEnabled && x != nil { + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + if ms.LoadMessageInfo() == nil { + ms.StoreMessageInfo(mi) + } + return ms + } + return mi.MessageOf(x) +} + +// Deprecated: Use BlockRequest.ProtoReflect.Descriptor instead. +func (*BlockRequest) Descriptor() ([]byte, []int) { + return file_blockchainpb_minerpb_minerpb_proto_rawDescGZIP(), []int{1} +} + +func (x *BlockRequest) GetHeadId() uint64 { + if x != nil { + return x.HeadId + } + return 0 +} + +func (x *BlockRequest) GetPayload() *payloadpb.Payload { + if x != nil { + return x.Payload + } + return nil +} + +type NewHead struct { + state protoimpl.MessageState + sizeCache protoimpl.SizeCache + unknownFields protoimpl.UnknownFields + + HeadId uint64 `protobuf:"varint,1,opt,name=head_id,json=headId,proto3" json:"head_id,omitempty"` +} + +func (x *NewHead) Reset() { + *x = NewHead{} + if protoimpl.UnsafeEnabled { + mi := &file_blockchainpb_minerpb_minerpb_proto_msgTypes[2] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) + } +} + +func (x *NewHead) String() string { + return protoimpl.X.MessageStringOf(x) +} + +func (*NewHead) ProtoMessage() {} + +func (x *NewHead) ProtoReflect() protoreflect.Message { + mi := &file_blockchainpb_minerpb_minerpb_proto_msgTypes[2] + if protoimpl.UnsafeEnabled && x != nil { + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + if ms.LoadMessageInfo() == nil { + ms.StoreMessageInfo(mi) + } + return ms + } + return mi.MessageOf(x) +} + +// Deprecated: Use NewHead.ProtoReflect.Descriptor instead. +func (*NewHead) Descriptor() ([]byte, []int) { + return file_blockchainpb_minerpb_minerpb_proto_rawDescGZIP(), []int{2} +} + +func (x *NewHead) GetHeadId() uint64 { + if x != nil { + return x.HeadId + } + return 0 +} + +var File_blockchainpb_minerpb_minerpb_proto protoreflect.FileDescriptor + +var file_blockchainpb_minerpb_minerpb_proto_rawDesc = []byte{ + 0x0a, 0x22, 0x62, 0x6c, 0x6f, 0x63, 0x6b, 0x63, 0x68, 0x61, 0x69, 0x6e, 0x70, 0x62, 0x2f, 0x6d, + 0x69, 0x6e, 0x65, 0x72, 0x70, 0x62, 0x2f, 0x6d, 0x69, 0x6e, 0x65, 0x72, 0x70, 0x62, 0x2e, 0x70, + 0x72, 0x6f, 0x74, 0x6f, 0x12, 0x07, 0x6d, 0x69, 0x6e, 0x65, 0x72, 0x70, 0x62, 0x1a, 0x1c, 0x6d, + 0x69, 0x72, 0x2f, 0x63, 0x6f, 0x64, 0x65, 0x67, 0x65, 0x6e, 0x5f, 0x65, 0x78, 0x74, 0x65, 0x6e, + 0x73, 0x69, 0x6f, 0x6e, 0x73, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x1a, 0x26, 0x62, 0x6c, 0x6f, + 0x63, 0x6b, 0x63, 0x68, 0x61, 0x69, 0x6e, 0x70, 0x62, 0x2f, 0x70, 0x61, 0x79, 0x6c, 0x6f, 0x61, + 0x64, 0x70, 0x62, 0x2f, 0x70, 0x61, 0x79, 0x6c, 0x6f, 0x61, 0x64, 0x70, 0x62, 0x2e, 0x70, 0x72, + 0x6f, 0x74, 0x6f, 0x22, 0x88, 0x01, 0x0a, 0x05, 0x45, 0x76, 0x65, 0x6e, 0x74, 0x12, 0x3c, 0x0a, + 0x0d, 0x62, 0x6c, 0x6f, 0x63, 0x6b, 0x5f, 0x72, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x18, 0x01, + 0x20, 0x01, 0x28, 0x0b, 0x32, 0x15, 0x2e, 0x6d, 0x69, 0x6e, 0x65, 0x72, 0x70, 0x62, 0x2e, 0x42, + 0x6c, 0x6f, 0x63, 0x6b, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x48, 0x00, 0x52, 0x0c, 0x62, + 0x6c, 0x6f, 0x63, 0x6b, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x12, 0x2d, 0x0a, 0x08, 0x6e, + 0x65, 0x77, 0x5f, 0x68, 0x65, 0x61, 0x64, 0x18, 0x02, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x10, 0x2e, + 0x6d, 0x69, 0x6e, 0x65, 0x72, 0x70, 0x62, 0x2e, 0x4e, 0x65, 0x77, 0x48, 0x65, 0x61, 0x64, 0x48, + 0x00, 0x52, 0x07, 0x6e, 0x65, 0x77, 0x48, 0x65, 0x61, 0x64, 0x3a, 0x04, 0x90, 0xa6, 0x1d, 0x01, + 0x42, 0x0c, 0x0a, 0x04, 0x74, 0x79, 0x70, 0x65, 0x12, 0x04, 0x80, 0xa6, 0x1d, 0x01, 0x22, 0x5b, + 0x0a, 0x0c, 0x42, 0x6c, 0x6f, 0x63, 0x6b, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x12, 0x17, + 0x0a, 0x07, 0x68, 0x65, 0x61, 0x64, 0x5f, 0x69, 0x64, 0x18, 0x01, 0x20, 0x01, 0x28, 0x04, 0x52, + 0x06, 0x68, 0x65, 0x61, 0x64, 0x49, 0x64, 0x12, 0x2c, 0x0a, 0x07, 0x70, 0x61, 0x79, 0x6c, 0x6f, + 0x61, 0x64, 0x18, 0x02, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x12, 0x2e, 0x70, 0x61, 0x79, 0x6c, 0x6f, + 0x61, 0x64, 0x70, 0x62, 0x2e, 0x50, 0x61, 0x79, 0x6c, 0x6f, 0x61, 0x64, 0x52, 0x07, 0x70, 0x61, + 0x79, 0x6c, 0x6f, 0x61, 0x64, 0x3a, 0x04, 0x98, 0xa6, 0x1d, 0x01, 0x22, 0x28, 0x0a, 0x07, 0x4e, + 0x65, 0x77, 0x48, 0x65, 0x61, 0x64, 0x12, 0x17, 0x0a, 0x07, 0x68, 0x65, 0x61, 0x64, 0x5f, 0x69, + 0x64, 0x18, 0x01, 0x20, 0x01, 0x28, 0x04, 0x52, 0x06, 0x68, 0x65, 0x61, 0x64, 0x49, 0x64, 0x3a, + 0x04, 0x98, 0xa6, 0x1d, 0x01, 0x42, 0x3d, 0x5a, 0x3b, 0x67, 0x69, 0x74, 0x68, 0x75, 0x62, 0x2e, + 0x63, 0x6f, 0x6d, 0x2f, 0x66, 0x69, 0x6c, 0x65, 0x63, 0x6f, 0x69, 0x6e, 0x2d, 0x70, 0x72, 0x6f, + 0x6a, 0x65, 0x63, 0x74, 0x2f, 0x6d, 0x69, 0x72, 0x2f, 0x70, 0x6b, 0x67, 0x2f, 0x70, 0x62, 0x2f, + 0x62, 0x6c, 0x6f, 0x63, 0x6b, 0x63, 0x68, 0x61, 0x69, 0x6e, 0x70, 0x62, 0x2f, 0x6d, 0x69, 0x6e, + 0x65, 0x72, 0x70, 0x62, 0x62, 0x06, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x33, +} + +var ( + file_blockchainpb_minerpb_minerpb_proto_rawDescOnce sync.Once + file_blockchainpb_minerpb_minerpb_proto_rawDescData = file_blockchainpb_minerpb_minerpb_proto_rawDesc +) + +func file_blockchainpb_minerpb_minerpb_proto_rawDescGZIP() []byte { + file_blockchainpb_minerpb_minerpb_proto_rawDescOnce.Do(func() { + file_blockchainpb_minerpb_minerpb_proto_rawDescData = protoimpl.X.CompressGZIP(file_blockchainpb_minerpb_minerpb_proto_rawDescData) + }) + return file_blockchainpb_minerpb_minerpb_proto_rawDescData +} + +var file_blockchainpb_minerpb_minerpb_proto_msgTypes = make([]protoimpl.MessageInfo, 3) +var file_blockchainpb_minerpb_minerpb_proto_goTypes = []interface{}{ + (*Event)(nil), // 0: minerpb.Event + (*BlockRequest)(nil), // 1: minerpb.BlockRequest + (*NewHead)(nil), // 2: minerpb.NewHead + (*payloadpb.Payload)(nil), // 3: payloadpb.Payload +} +var file_blockchainpb_minerpb_minerpb_proto_depIdxs = []int32{ + 1, // 0: minerpb.Event.block_request:type_name -> minerpb.BlockRequest + 2, // 1: minerpb.Event.new_head:type_name -> minerpb.NewHead + 3, // 2: minerpb.BlockRequest.payload:type_name -> payloadpb.Payload + 3, // [3:3] is the sub-list for method output_type + 3, // [3:3] is the sub-list for method input_type + 3, // [3:3] is the sub-list for extension type_name + 3, // [3:3] is the sub-list for extension extendee + 0, // [0:3] is the sub-list for field type_name +} + +func init() { file_blockchainpb_minerpb_minerpb_proto_init() } +func file_blockchainpb_minerpb_minerpb_proto_init() { + if File_blockchainpb_minerpb_minerpb_proto != nil { + return + } + if !protoimpl.UnsafeEnabled { + file_blockchainpb_minerpb_minerpb_proto_msgTypes[0].Exporter = func(v interface{}, i int) interface{} { + switch v := v.(*Event); i { + case 0: + return &v.state + case 1: + return &v.sizeCache + case 2: + return &v.unknownFields + default: + return nil + } + } + file_blockchainpb_minerpb_minerpb_proto_msgTypes[1].Exporter = func(v interface{}, i int) interface{} { + switch v := v.(*BlockRequest); i { + case 0: + return &v.state + case 1: + return &v.sizeCache + case 2: + return &v.unknownFields + default: + return nil + } + } + file_blockchainpb_minerpb_minerpb_proto_msgTypes[2].Exporter = func(v interface{}, i int) interface{} { + switch v := v.(*NewHead); i { + case 0: + return &v.state + case 1: + return &v.sizeCache + case 2: + return &v.unknownFields + default: + return nil + } + } + } + file_blockchainpb_minerpb_minerpb_proto_msgTypes[0].OneofWrappers = []interface{}{ + (*Event_BlockRequest)(nil), + (*Event_NewHead)(nil), + } + type x struct{} + out := protoimpl.TypeBuilder{ + File: protoimpl.DescBuilder{ + GoPackagePath: reflect.TypeOf(x{}).PkgPath(), + RawDescriptor: file_blockchainpb_minerpb_minerpb_proto_rawDesc, + NumEnums: 0, + NumMessages: 3, + NumExtensions: 0, + NumServices: 0, + }, + GoTypes: file_blockchainpb_minerpb_minerpb_proto_goTypes, + DependencyIndexes: file_blockchainpb_minerpb_minerpb_proto_depIdxs, + MessageInfos: file_blockchainpb_minerpb_minerpb_proto_msgTypes, + }.Build() + File_blockchainpb_minerpb_minerpb_proto = out.File + file_blockchainpb_minerpb_minerpb_proto_rawDesc = nil + file_blockchainpb_minerpb_minerpb_proto_goTypes = nil + file_blockchainpb_minerpb_minerpb_proto_depIdxs = nil +} diff --git a/pkg/pb/blockchainpb/minerpb/minerpb.pb.mir.go b/pkg/pb/blockchainpb/minerpb/minerpb.pb.mir.go new file mode 100644 index 000000000..bdc485481 --- /dev/null +++ b/pkg/pb/blockchainpb/minerpb/minerpb.pb.mir.go @@ -0,0 +1,14 @@ +// Code generated by Mir codegen. DO NOT EDIT. + +package minerpb + +import ( + reflect "reflect" +) + +func (*Event) ReflectTypeOptions() []reflect.Type { + return []reflect.Type{ + reflect.TypeOf((*Event_BlockRequest)(nil)), + reflect.TypeOf((*Event_NewHead)(nil)), + } +} diff --git a/pkg/pb/blockchainpb/minerpb/oneof_interfaces.mir.go b/pkg/pb/blockchainpb/minerpb/oneof_interfaces.mir.go new file mode 100644 index 000000000..9a8f8c8f1 --- /dev/null +++ b/pkg/pb/blockchainpb/minerpb/oneof_interfaces.mir.go @@ -0,0 +1,18 @@ +// Code generated by Mir codegen. DO NOT EDIT. + +package minerpb + +type Event_Type = isEvent_Type + +type Event_TypeWrapper[T any] interface { + Event_Type + Unwrap() *T +} + +func (w *Event_BlockRequest) Unwrap() *BlockRequest { + return w.BlockRequest +} + +func (w *Event_NewHead) Unwrap() *NewHead { + return w.NewHead +} diff --git a/pkg/pb/blockchainpb/minerpb/types/types.mir.go b/pkg/pb/blockchainpb/minerpb/types/types.mir.go new file mode 100644 index 000000000..9c299b5d3 --- /dev/null +++ b/pkg/pb/blockchainpb/minerpb/types/types.mir.go @@ -0,0 +1,176 @@ +// Code generated by Mir codegen. DO NOT EDIT. + +package minerpbtypes + +import ( + mirreflect "github.com/filecoin-project/mir/codegen/mirreflect" + minerpb "github.com/filecoin-project/mir/pkg/pb/blockchainpb/minerpb" + types "github.com/filecoin-project/mir/pkg/pb/blockchainpb/payloadpb/types" + reflectutil "github.com/filecoin-project/mir/pkg/util/reflectutil" +) + +type Event struct { + Type Event_Type +} + +type Event_Type interface { + mirreflect.GeneratedType + isEvent_Type() + Pb() minerpb.Event_Type +} + +type Event_TypeWrapper[T any] interface { + Event_Type + Unwrap() *T +} + +func Event_TypeFromPb(pb minerpb.Event_Type) Event_Type { + if pb == nil { + return nil + } + switch pb := pb.(type) { + case *minerpb.Event_BlockRequest: + return &Event_BlockRequest{BlockRequest: BlockRequestFromPb(pb.BlockRequest)} + case *minerpb.Event_NewHead: + return &Event_NewHead{NewHead: NewHeadFromPb(pb.NewHead)} + } + return nil +} + +type Event_BlockRequest struct { + BlockRequest *BlockRequest +} + +func (*Event_BlockRequest) isEvent_Type() {} + +func (w *Event_BlockRequest) Unwrap() *BlockRequest { + return w.BlockRequest +} + +func (w *Event_BlockRequest) Pb() minerpb.Event_Type { + if w == nil { + return nil + } + if w.BlockRequest == nil { + return &minerpb.Event_BlockRequest{} + } + return &minerpb.Event_BlockRequest{BlockRequest: (w.BlockRequest).Pb()} +} + +func (*Event_BlockRequest) MirReflect() mirreflect.Type { + return mirreflect.TypeImpl{PbType_: reflectutil.TypeOf[*minerpb.Event_BlockRequest]()} +} + +type Event_NewHead struct { + NewHead *NewHead +} + +func (*Event_NewHead) isEvent_Type() {} + +func (w *Event_NewHead) Unwrap() *NewHead { + return w.NewHead +} + +func (w *Event_NewHead) Pb() minerpb.Event_Type { + if w == nil { + return nil + } + if w.NewHead == nil { + return &minerpb.Event_NewHead{} + } + return &minerpb.Event_NewHead{NewHead: (w.NewHead).Pb()} +} + +func (*Event_NewHead) MirReflect() mirreflect.Type { + return mirreflect.TypeImpl{PbType_: reflectutil.TypeOf[*minerpb.Event_NewHead]()} +} + +func EventFromPb(pb *minerpb.Event) *Event { + if pb == nil { + return nil + } + return &Event{ + Type: Event_TypeFromPb(pb.Type), + } +} + +func (m *Event) Pb() *minerpb.Event { + if m == nil { + return nil + } + pbMessage := &minerpb.Event{} + { + if m.Type != nil { + pbMessage.Type = (m.Type).Pb() + } + } + + return pbMessage +} + +func (*Event) MirReflect() mirreflect.Type { + return mirreflect.TypeImpl{PbType_: reflectutil.TypeOf[*minerpb.Event]()} +} + +type BlockRequest struct { + HeadId uint64 + Payload *types.Payload +} + +func BlockRequestFromPb(pb *minerpb.BlockRequest) *BlockRequest { + if pb == nil { + return nil + } + return &BlockRequest{ + HeadId: pb.HeadId, + Payload: types.PayloadFromPb(pb.Payload), + } +} + +func (m *BlockRequest) Pb() *minerpb.BlockRequest { + if m == nil { + return nil + } + pbMessage := &minerpb.BlockRequest{} + { + pbMessage.HeadId = m.HeadId + if m.Payload != nil { + pbMessage.Payload = (m.Payload).Pb() + } + } + + return pbMessage +} + +func (*BlockRequest) MirReflect() mirreflect.Type { + return mirreflect.TypeImpl{PbType_: reflectutil.TypeOf[*minerpb.BlockRequest]()} +} + +type NewHead struct { + HeadId uint64 +} + +func NewHeadFromPb(pb *minerpb.NewHead) *NewHead { + if pb == nil { + return nil + } + return &NewHead{ + HeadId: pb.HeadId, + } +} + +func (m *NewHead) Pb() *minerpb.NewHead { + if m == nil { + return nil + } + pbMessage := &minerpb.NewHead{} + { + pbMessage.HeadId = m.HeadId + } + + return pbMessage +} + +func (*NewHead) MirReflect() mirreflect.Type { + return mirreflect.TypeImpl{PbType_: reflectutil.TypeOf[*minerpb.NewHead]()} +} diff --git a/pkg/pb/blockchainpb/oneof_interfaces.mir.go b/pkg/pb/blockchainpb/oneof_interfaces.mir.go new file mode 100644 index 000000000..a1e6dd597 --- /dev/null +++ b/pkg/pb/blockchainpb/oneof_interfaces.mir.go @@ -0,0 +1,3 @@ +// Code generated by Mir codegen. DO NOT EDIT. + +package blockchainpb diff --git a/pkg/pb/blockchainpb/payloadpb/oneof_interfaces.mir.go b/pkg/pb/blockchainpb/payloadpb/oneof_interfaces.mir.go new file mode 100644 index 000000000..8f5d1f8ea --- /dev/null +++ b/pkg/pb/blockchainpb/payloadpb/oneof_interfaces.mir.go @@ -0,0 +1,3 @@ +// Code generated by Mir codegen. DO NOT EDIT. + +package payloadpb diff --git a/pkg/pb/blockchainpb/payloadpb/payloadpb.pb.go b/pkg/pb/blockchainpb/payloadpb/payloadpb.pb.go new file mode 100644 index 000000000..66951a67f --- /dev/null +++ b/pkg/pb/blockchainpb/payloadpb/payloadpb.pb.go @@ -0,0 +1,180 @@ +// Code generated by protoc-gen-go. DO NOT EDIT. +// versions: +// protoc-gen-go v1.31.0 +// protoc v4.25.2 +// source: blockchainpb/payloadpb/payloadpb.proto + +package payloadpb + +import ( + _ "github.com/filecoin-project/mir/pkg/pb/mir" + protoreflect "google.golang.org/protobuf/reflect/protoreflect" + protoimpl "google.golang.org/protobuf/runtime/protoimpl" + timestamppb "google.golang.org/protobuf/types/known/timestamppb" + reflect "reflect" + sync "sync" +) + +const ( + // Verify that this generated code is sufficiently up-to-date. + _ = protoimpl.EnforceVersion(20 - protoimpl.MinVersion) + // Verify that runtime/protoimpl is sufficiently up-to-date. + _ = protoimpl.EnforceVersion(protoimpl.MaxVersion - 20) +) + +type Payload struct { + state protoimpl.MessageState + sizeCache protoimpl.SizeCache + unknownFields protoimpl.UnknownFields + + // application specific payload + Message string `protobuf:"bytes,1,opt,name=message,proto3" json:"message,omitempty"` + Timestamp *timestamppb.Timestamp `protobuf:"bytes,2,opt,name=timestamp,proto3" json:"timestamp,omitempty"` + Sender string `protobuf:"bytes,3,opt,name=sender,proto3" json:"sender,omitempty"` +} + +func (x *Payload) Reset() { + *x = Payload{} + if protoimpl.UnsafeEnabled { + mi := &file_blockchainpb_payloadpb_payloadpb_proto_msgTypes[0] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) + } +} + +func (x *Payload) String() string { + return protoimpl.X.MessageStringOf(x) +} + +func (*Payload) ProtoMessage() {} + +func (x *Payload) ProtoReflect() protoreflect.Message { + mi := &file_blockchainpb_payloadpb_payloadpb_proto_msgTypes[0] + if protoimpl.UnsafeEnabled && x != nil { + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + if ms.LoadMessageInfo() == nil { + ms.StoreMessageInfo(mi) + } + return ms + } + return mi.MessageOf(x) +} + +// Deprecated: Use Payload.ProtoReflect.Descriptor instead. +func (*Payload) Descriptor() ([]byte, []int) { + return file_blockchainpb_payloadpb_payloadpb_proto_rawDescGZIP(), []int{0} +} + +func (x *Payload) GetMessage() string { + if x != nil { + return x.Message + } + return "" +} + +func (x *Payload) GetTimestamp() *timestamppb.Timestamp { + if x != nil { + return x.Timestamp + } + return nil +} + +func (x *Payload) GetSender() string { + if x != nil { + return x.Sender + } + return "" +} + +var File_blockchainpb_payloadpb_payloadpb_proto protoreflect.FileDescriptor + +var file_blockchainpb_payloadpb_payloadpb_proto_rawDesc = []byte{ + 0x0a, 0x26, 0x62, 0x6c, 0x6f, 0x63, 0x6b, 0x63, 0x68, 0x61, 0x69, 0x6e, 0x70, 0x62, 0x2f, 0x70, + 0x61, 0x79, 0x6c, 0x6f, 0x61, 0x64, 0x70, 0x62, 0x2f, 0x70, 0x61, 0x79, 0x6c, 0x6f, 0x61, 0x64, + 0x70, 0x62, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x12, 0x09, 0x70, 0x61, 0x79, 0x6c, 0x6f, 0x61, + 0x64, 0x70, 0x62, 0x1a, 0x1c, 0x6d, 0x69, 0x72, 0x2f, 0x63, 0x6f, 0x64, 0x65, 0x67, 0x65, 0x6e, + 0x5f, 0x65, 0x78, 0x74, 0x65, 0x6e, 0x73, 0x69, 0x6f, 0x6e, 0x73, 0x2e, 0x70, 0x72, 0x6f, 0x74, + 0x6f, 0x1a, 0x1f, 0x67, 0x6f, 0x6f, 0x67, 0x6c, 0x65, 0x2f, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x62, + 0x75, 0x66, 0x2f, 0x74, 0x69, 0x6d, 0x65, 0x73, 0x74, 0x61, 0x6d, 0x70, 0x2e, 0x70, 0x72, 0x6f, + 0x74, 0x6f, 0x22, 0xb1, 0x01, 0x0a, 0x07, 0x50, 0x61, 0x79, 0x6c, 0x6f, 0x61, 0x64, 0x12, 0x18, + 0x0a, 0x07, 0x6d, 0x65, 0x73, 0x73, 0x61, 0x67, 0x65, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, + 0x07, 0x6d, 0x65, 0x73, 0x73, 0x61, 0x67, 0x65, 0x12, 0x38, 0x0a, 0x09, 0x74, 0x69, 0x6d, 0x65, + 0x73, 0x74, 0x61, 0x6d, 0x70, 0x18, 0x02, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x1a, 0x2e, 0x67, 0x6f, + 0x6f, 0x67, 0x6c, 0x65, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x62, 0x75, 0x66, 0x2e, 0x54, 0x69, + 0x6d, 0x65, 0x73, 0x74, 0x61, 0x6d, 0x70, 0x52, 0x09, 0x74, 0x69, 0x6d, 0x65, 0x73, 0x74, 0x61, + 0x6d, 0x70, 0x12, 0x4c, 0x0a, 0x06, 0x73, 0x65, 0x6e, 0x64, 0x65, 0x72, 0x18, 0x03, 0x20, 0x01, + 0x28, 0x09, 0x42, 0x34, 0x82, 0xa6, 0x1d, 0x30, 0x67, 0x69, 0x74, 0x68, 0x75, 0x62, 0x2e, 0x63, + 0x6f, 0x6d, 0x2f, 0x66, 0x69, 0x6c, 0x65, 0x63, 0x6f, 0x69, 0x6e, 0x2d, 0x70, 0x72, 0x6f, 0x6a, + 0x65, 0x63, 0x74, 0x2f, 0x6d, 0x69, 0x72, 0x2f, 0x70, 0x6b, 0x67, 0x2f, 0x74, 0x79, 0x70, 0x65, + 0x73, 0x2e, 0x4e, 0x6f, 0x64, 0x65, 0x49, 0x44, 0x52, 0x06, 0x73, 0x65, 0x6e, 0x64, 0x65, 0x72, + 0x3a, 0x04, 0x80, 0xa6, 0x1d, 0x01, 0x42, 0x3f, 0x5a, 0x3d, 0x67, 0x69, 0x74, 0x68, 0x75, 0x62, + 0x2e, 0x63, 0x6f, 0x6d, 0x2f, 0x66, 0x69, 0x6c, 0x65, 0x63, 0x6f, 0x69, 0x6e, 0x2d, 0x70, 0x72, + 0x6f, 0x6a, 0x65, 0x63, 0x74, 0x2f, 0x6d, 0x69, 0x72, 0x2f, 0x70, 0x6b, 0x67, 0x2f, 0x70, 0x62, + 0x2f, 0x62, 0x6c, 0x6f, 0x63, 0x6b, 0x63, 0x68, 0x61, 0x69, 0x6e, 0x70, 0x62, 0x2f, 0x70, 0x61, + 0x79, 0x6c, 0x6f, 0x61, 0x64, 0x70, 0x62, 0x62, 0x06, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x33, +} + +var ( + file_blockchainpb_payloadpb_payloadpb_proto_rawDescOnce sync.Once + file_blockchainpb_payloadpb_payloadpb_proto_rawDescData = file_blockchainpb_payloadpb_payloadpb_proto_rawDesc +) + +func file_blockchainpb_payloadpb_payloadpb_proto_rawDescGZIP() []byte { + file_blockchainpb_payloadpb_payloadpb_proto_rawDescOnce.Do(func() { + file_blockchainpb_payloadpb_payloadpb_proto_rawDescData = protoimpl.X.CompressGZIP(file_blockchainpb_payloadpb_payloadpb_proto_rawDescData) + }) + return file_blockchainpb_payloadpb_payloadpb_proto_rawDescData +} + +var file_blockchainpb_payloadpb_payloadpb_proto_msgTypes = make([]protoimpl.MessageInfo, 1) +var file_blockchainpb_payloadpb_payloadpb_proto_goTypes = []interface{}{ + (*Payload)(nil), // 0: payloadpb.Payload + (*timestamppb.Timestamp)(nil), // 1: google.protobuf.Timestamp +} +var file_blockchainpb_payloadpb_payloadpb_proto_depIdxs = []int32{ + 1, // 0: payloadpb.Payload.timestamp:type_name -> google.protobuf.Timestamp + 1, // [1:1] is the sub-list for method output_type + 1, // [1:1] is the sub-list for method input_type + 1, // [1:1] is the sub-list for extension type_name + 1, // [1:1] is the sub-list for extension extendee + 0, // [0:1] is the sub-list for field type_name +} + +func init() { file_blockchainpb_payloadpb_payloadpb_proto_init() } +func file_blockchainpb_payloadpb_payloadpb_proto_init() { + if File_blockchainpb_payloadpb_payloadpb_proto != nil { + return + } + if !protoimpl.UnsafeEnabled { + file_blockchainpb_payloadpb_payloadpb_proto_msgTypes[0].Exporter = func(v interface{}, i int) interface{} { + switch v := v.(*Payload); i { + case 0: + return &v.state + case 1: + return &v.sizeCache + case 2: + return &v.unknownFields + default: + return nil + } + } + } + type x struct{} + out := protoimpl.TypeBuilder{ + File: protoimpl.DescBuilder{ + GoPackagePath: reflect.TypeOf(x{}).PkgPath(), + RawDescriptor: file_blockchainpb_payloadpb_payloadpb_proto_rawDesc, + NumEnums: 0, + NumMessages: 1, + NumExtensions: 0, + NumServices: 0, + }, + GoTypes: file_blockchainpb_payloadpb_payloadpb_proto_goTypes, + DependencyIndexes: file_blockchainpb_payloadpb_payloadpb_proto_depIdxs, + MessageInfos: file_blockchainpb_payloadpb_payloadpb_proto_msgTypes, + }.Build() + File_blockchainpb_payloadpb_payloadpb_proto = out.File + file_blockchainpb_payloadpb_payloadpb_proto_rawDesc = nil + file_blockchainpb_payloadpb_payloadpb_proto_goTypes = nil + file_blockchainpb_payloadpb_payloadpb_proto_depIdxs = nil +} diff --git a/pkg/pb/blockchainpb/payloadpb/types/types.mir.go b/pkg/pb/blockchainpb/payloadpb/types/types.mir.go new file mode 100644 index 000000000..8568db1f3 --- /dev/null +++ b/pkg/pb/blockchainpb/payloadpb/types/types.mir.go @@ -0,0 +1,48 @@ +// Code generated by Mir codegen. DO NOT EDIT. + +package payloadpbtypes + +import ( + mirreflect "github.com/filecoin-project/mir/codegen/mirreflect" + payloadpb "github.com/filecoin-project/mir/pkg/pb/blockchainpb/payloadpb" + types "github.com/filecoin-project/mir/pkg/types" + reflectutil "github.com/filecoin-project/mir/pkg/util/reflectutil" + timestamppb "google.golang.org/protobuf/types/known/timestamppb" +) + +type Payload struct { + Message string + Timestamp *timestamppb.Timestamp + Sender types.NodeID +} + +func PayloadFromPb(pb *payloadpb.Payload) *Payload { + if pb == nil { + return nil + } + return &Payload{ + Message: pb.Message, + Timestamp: pb.Timestamp, + Sender: (types.NodeID)(pb.Sender), + } +} + +func (m *Payload) Pb() *payloadpb.Payload { + if m == nil { + return nil + } + pbMessage := &payloadpb.Payload{} + { + pbMessage.Message = m.Message + if m.Timestamp != nil { + pbMessage.Timestamp = m.Timestamp + } + pbMessage.Sender = (string)(m.Sender) + } + + return pbMessage +} + +func (*Payload) MirReflect() mirreflect.Type { + return mirreflect.TypeImpl{PbType_: reflectutil.TypeOf[*payloadpb.Payload]()} +} diff --git a/pkg/pb/blockchainpb/statepb/oneof_interfaces.mir.go b/pkg/pb/blockchainpb/statepb/oneof_interfaces.mir.go new file mode 100644 index 000000000..e03a0f056 --- /dev/null +++ b/pkg/pb/blockchainpb/statepb/oneof_interfaces.mir.go @@ -0,0 +1,3 @@ +// Code generated by Mir codegen. DO NOT EDIT. + +package statepb diff --git a/pkg/pb/blockchainpb/statepb/statepb.pb.go b/pkg/pb/blockchainpb/statepb/statepb.pb.go new file mode 100644 index 000000000..0f7da5336 --- /dev/null +++ b/pkg/pb/blockchainpb/statepb/statepb.pb.go @@ -0,0 +1,254 @@ +// Code generated by protoc-gen-go. DO NOT EDIT. +// versions: +// protoc-gen-go v1.31.0 +// protoc v4.25.2 +// source: blockchainpb/statepb/statepb.proto + +package statepb + +import ( + payloadpb "github.com/filecoin-project/mir/pkg/pb/blockchainpb/payloadpb" + _ "github.com/filecoin-project/mir/pkg/pb/mir" + protoreflect "google.golang.org/protobuf/reflect/protoreflect" + protoimpl "google.golang.org/protobuf/runtime/protoimpl" + timestamppb "google.golang.org/protobuf/types/known/timestamppb" + reflect "reflect" + sync "sync" +) + +const ( + // Verify that this generated code is sufficiently up-to-date. + _ = protoimpl.EnforceVersion(20 - protoimpl.MinVersion) + // Verify that runtime/protoimpl is sufficiently up-to-date. + _ = protoimpl.EnforceVersion(protoimpl.MaxVersion - 20) +) + +type State struct { + state protoimpl.MessageState + sizeCache protoimpl.SizeCache + unknownFields protoimpl.UnknownFields + + // application specific state + History []*payloadpb.Payload `protobuf:"bytes,1,rep,name=history,proto3" json:"history,omitempty"` + LastSentTimestamps []*LastSentTimestamp `protobuf:"bytes,2,rep,name=last_sent_timestamps,json=lastSentTimestamps,proto3" json:"last_sent_timestamps,omitempty"` +} + +func (x *State) Reset() { + *x = State{} + if protoimpl.UnsafeEnabled { + mi := &file_blockchainpb_statepb_statepb_proto_msgTypes[0] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) + } +} + +func (x *State) String() string { + return protoimpl.X.MessageStringOf(x) +} + +func (*State) ProtoMessage() {} + +func (x *State) ProtoReflect() protoreflect.Message { + mi := &file_blockchainpb_statepb_statepb_proto_msgTypes[0] + if protoimpl.UnsafeEnabled && x != nil { + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + if ms.LoadMessageInfo() == nil { + ms.StoreMessageInfo(mi) + } + return ms + } + return mi.MessageOf(x) +} + +// Deprecated: Use State.ProtoReflect.Descriptor instead. +func (*State) Descriptor() ([]byte, []int) { + return file_blockchainpb_statepb_statepb_proto_rawDescGZIP(), []int{0} +} + +func (x *State) GetHistory() []*payloadpb.Payload { + if x != nil { + return x.History + } + return nil +} + +func (x *State) GetLastSentTimestamps() []*LastSentTimestamp { + if x != nil { + return x.LastSentTimestamps + } + return nil +} + +type LastSentTimestamp struct { + state protoimpl.MessageState + sizeCache protoimpl.SizeCache + unknownFields protoimpl.UnknownFields + + NodeId string `protobuf:"bytes,1,opt,name=node_id,json=nodeId,proto3" json:"node_id,omitempty"` + Timestamp *timestamppb.Timestamp `protobuf:"bytes,2,opt,name=timestamp,proto3" json:"timestamp,omitempty"` +} + +func (x *LastSentTimestamp) Reset() { + *x = LastSentTimestamp{} + if protoimpl.UnsafeEnabled { + mi := &file_blockchainpb_statepb_statepb_proto_msgTypes[1] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) + } +} + +func (x *LastSentTimestamp) String() string { + return protoimpl.X.MessageStringOf(x) +} + +func (*LastSentTimestamp) ProtoMessage() {} + +func (x *LastSentTimestamp) ProtoReflect() protoreflect.Message { + mi := &file_blockchainpb_statepb_statepb_proto_msgTypes[1] + if protoimpl.UnsafeEnabled && x != nil { + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + if ms.LoadMessageInfo() == nil { + ms.StoreMessageInfo(mi) + } + return ms + } + return mi.MessageOf(x) +} + +// Deprecated: Use LastSentTimestamp.ProtoReflect.Descriptor instead. +func (*LastSentTimestamp) Descriptor() ([]byte, []int) { + return file_blockchainpb_statepb_statepb_proto_rawDescGZIP(), []int{1} +} + +func (x *LastSentTimestamp) GetNodeId() string { + if x != nil { + return x.NodeId + } + return "" +} + +func (x *LastSentTimestamp) GetTimestamp() *timestamppb.Timestamp { + if x != nil { + return x.Timestamp + } + return nil +} + +var File_blockchainpb_statepb_statepb_proto protoreflect.FileDescriptor + +var file_blockchainpb_statepb_statepb_proto_rawDesc = []byte{ + 0x0a, 0x22, 0x62, 0x6c, 0x6f, 0x63, 0x6b, 0x63, 0x68, 0x61, 0x69, 0x6e, 0x70, 0x62, 0x2f, 0x73, + 0x74, 0x61, 0x74, 0x65, 0x70, 0x62, 0x2f, 0x73, 0x74, 0x61, 0x74, 0x65, 0x70, 0x62, 0x2e, 0x70, + 0x72, 0x6f, 0x74, 0x6f, 0x12, 0x07, 0x73, 0x74, 0x61, 0x74, 0x65, 0x70, 0x62, 0x1a, 0x26, 0x62, + 0x6c, 0x6f, 0x63, 0x6b, 0x63, 0x68, 0x61, 0x69, 0x6e, 0x70, 0x62, 0x2f, 0x70, 0x61, 0x79, 0x6c, + 0x6f, 0x61, 0x64, 0x70, 0x62, 0x2f, 0x70, 0x61, 0x79, 0x6c, 0x6f, 0x61, 0x64, 0x70, 0x62, 0x2e, + 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x1a, 0x1c, 0x6d, 0x69, 0x72, 0x2f, 0x63, 0x6f, 0x64, 0x65, 0x67, + 0x65, 0x6e, 0x5f, 0x65, 0x78, 0x74, 0x65, 0x6e, 0x73, 0x69, 0x6f, 0x6e, 0x73, 0x2e, 0x70, 0x72, + 0x6f, 0x74, 0x6f, 0x1a, 0x1f, 0x67, 0x6f, 0x6f, 0x67, 0x6c, 0x65, 0x2f, 0x70, 0x72, 0x6f, 0x74, + 0x6f, 0x62, 0x75, 0x66, 0x2f, 0x74, 0x69, 0x6d, 0x65, 0x73, 0x74, 0x61, 0x6d, 0x70, 0x2e, 0x70, + 0x72, 0x6f, 0x74, 0x6f, 0x22, 0x89, 0x01, 0x0a, 0x05, 0x53, 0x74, 0x61, 0x74, 0x65, 0x12, 0x2c, + 0x0a, 0x07, 0x68, 0x69, 0x73, 0x74, 0x6f, 0x72, 0x79, 0x18, 0x01, 0x20, 0x03, 0x28, 0x0b, 0x32, + 0x12, 0x2e, 0x70, 0x61, 0x79, 0x6c, 0x6f, 0x61, 0x64, 0x70, 0x62, 0x2e, 0x50, 0x61, 0x79, 0x6c, + 0x6f, 0x61, 0x64, 0x52, 0x07, 0x68, 0x69, 0x73, 0x74, 0x6f, 0x72, 0x79, 0x12, 0x4c, 0x0a, 0x14, + 0x6c, 0x61, 0x73, 0x74, 0x5f, 0x73, 0x65, 0x6e, 0x74, 0x5f, 0x74, 0x69, 0x6d, 0x65, 0x73, 0x74, + 0x61, 0x6d, 0x70, 0x73, 0x18, 0x02, 0x20, 0x03, 0x28, 0x0b, 0x32, 0x1a, 0x2e, 0x73, 0x74, 0x61, + 0x74, 0x65, 0x70, 0x62, 0x2e, 0x4c, 0x61, 0x73, 0x74, 0x53, 0x65, 0x6e, 0x74, 0x54, 0x69, 0x6d, + 0x65, 0x73, 0x74, 0x61, 0x6d, 0x70, 0x52, 0x12, 0x6c, 0x61, 0x73, 0x74, 0x53, 0x65, 0x6e, 0x74, + 0x54, 0x69, 0x6d, 0x65, 0x73, 0x74, 0x61, 0x6d, 0x70, 0x73, 0x3a, 0x04, 0x80, 0xa6, 0x1d, 0x01, + 0x22, 0xa2, 0x01, 0x0a, 0x11, 0x4c, 0x61, 0x73, 0x74, 0x53, 0x65, 0x6e, 0x74, 0x54, 0x69, 0x6d, + 0x65, 0x73, 0x74, 0x61, 0x6d, 0x70, 0x12, 0x4d, 0x0a, 0x07, 0x6e, 0x6f, 0x64, 0x65, 0x5f, 0x69, + 0x64, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x42, 0x34, 0x82, 0xa6, 0x1d, 0x30, 0x67, 0x69, 0x74, + 0x68, 0x75, 0x62, 0x2e, 0x63, 0x6f, 0x6d, 0x2f, 0x66, 0x69, 0x6c, 0x65, 0x63, 0x6f, 0x69, 0x6e, + 0x2d, 0x70, 0x72, 0x6f, 0x6a, 0x65, 0x63, 0x74, 0x2f, 0x6d, 0x69, 0x72, 0x2f, 0x70, 0x6b, 0x67, + 0x2f, 0x74, 0x79, 0x70, 0x65, 0x73, 0x2e, 0x4e, 0x6f, 0x64, 0x65, 0x49, 0x44, 0x52, 0x06, 0x6e, + 0x6f, 0x64, 0x65, 0x49, 0x64, 0x12, 0x38, 0x0a, 0x09, 0x74, 0x69, 0x6d, 0x65, 0x73, 0x74, 0x61, + 0x6d, 0x70, 0x18, 0x02, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x1a, 0x2e, 0x67, 0x6f, 0x6f, 0x67, 0x6c, + 0x65, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x62, 0x75, 0x66, 0x2e, 0x54, 0x69, 0x6d, 0x65, 0x73, + 0x74, 0x61, 0x6d, 0x70, 0x52, 0x09, 0x74, 0x69, 0x6d, 0x65, 0x73, 0x74, 0x61, 0x6d, 0x70, 0x3a, + 0x04, 0x80, 0xa6, 0x1d, 0x01, 0x42, 0x3d, 0x5a, 0x3b, 0x67, 0x69, 0x74, 0x68, 0x75, 0x62, 0x2e, + 0x63, 0x6f, 0x6d, 0x2f, 0x66, 0x69, 0x6c, 0x65, 0x63, 0x6f, 0x69, 0x6e, 0x2d, 0x70, 0x72, 0x6f, + 0x6a, 0x65, 0x63, 0x74, 0x2f, 0x6d, 0x69, 0x72, 0x2f, 0x70, 0x6b, 0x67, 0x2f, 0x70, 0x62, 0x2f, + 0x62, 0x6c, 0x6f, 0x63, 0x6b, 0x63, 0x68, 0x61, 0x69, 0x6e, 0x70, 0x62, 0x2f, 0x73, 0x74, 0x61, + 0x74, 0x65, 0x70, 0x62, 0x62, 0x06, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x33, +} + +var ( + file_blockchainpb_statepb_statepb_proto_rawDescOnce sync.Once + file_blockchainpb_statepb_statepb_proto_rawDescData = file_blockchainpb_statepb_statepb_proto_rawDesc +) + +func file_blockchainpb_statepb_statepb_proto_rawDescGZIP() []byte { + file_blockchainpb_statepb_statepb_proto_rawDescOnce.Do(func() { + file_blockchainpb_statepb_statepb_proto_rawDescData = protoimpl.X.CompressGZIP(file_blockchainpb_statepb_statepb_proto_rawDescData) + }) + return file_blockchainpb_statepb_statepb_proto_rawDescData +} + +var file_blockchainpb_statepb_statepb_proto_msgTypes = make([]protoimpl.MessageInfo, 2) +var file_blockchainpb_statepb_statepb_proto_goTypes = []interface{}{ + (*State)(nil), // 0: statepb.State + (*LastSentTimestamp)(nil), // 1: statepb.LastSentTimestamp + (*payloadpb.Payload)(nil), // 2: payloadpb.Payload + (*timestamppb.Timestamp)(nil), // 3: google.protobuf.Timestamp +} +var file_blockchainpb_statepb_statepb_proto_depIdxs = []int32{ + 2, // 0: statepb.State.history:type_name -> payloadpb.Payload + 1, // 1: statepb.State.last_sent_timestamps:type_name -> statepb.LastSentTimestamp + 3, // 2: statepb.LastSentTimestamp.timestamp:type_name -> google.protobuf.Timestamp + 3, // [3:3] is the sub-list for method output_type + 3, // [3:3] is the sub-list for method input_type + 3, // [3:3] is the sub-list for extension type_name + 3, // [3:3] is the sub-list for extension extendee + 0, // [0:3] is the sub-list for field type_name +} + +func init() { file_blockchainpb_statepb_statepb_proto_init() } +func file_blockchainpb_statepb_statepb_proto_init() { + if File_blockchainpb_statepb_statepb_proto != nil { + return + } + if !protoimpl.UnsafeEnabled { + file_blockchainpb_statepb_statepb_proto_msgTypes[0].Exporter = func(v interface{}, i int) interface{} { + switch v := v.(*State); i { + case 0: + return &v.state + case 1: + return &v.sizeCache + case 2: + return &v.unknownFields + default: + return nil + } + } + file_blockchainpb_statepb_statepb_proto_msgTypes[1].Exporter = func(v interface{}, i int) interface{} { + switch v := v.(*LastSentTimestamp); i { + case 0: + return &v.state + case 1: + return &v.sizeCache + case 2: + return &v.unknownFields + default: + return nil + } + } + } + type x struct{} + out := protoimpl.TypeBuilder{ + File: protoimpl.DescBuilder{ + GoPackagePath: reflect.TypeOf(x{}).PkgPath(), + RawDescriptor: file_blockchainpb_statepb_statepb_proto_rawDesc, + NumEnums: 0, + NumMessages: 2, + NumExtensions: 0, + NumServices: 0, + }, + GoTypes: file_blockchainpb_statepb_statepb_proto_goTypes, + DependencyIndexes: file_blockchainpb_statepb_statepb_proto_depIdxs, + MessageInfos: file_blockchainpb_statepb_statepb_proto_msgTypes, + }.Build() + File_blockchainpb_statepb_statepb_proto = out.File + file_blockchainpb_statepb_statepb_proto_rawDesc = nil + file_blockchainpb_statepb_statepb_proto_goTypes = nil + file_blockchainpb_statepb_statepb_proto_depIdxs = nil +} diff --git a/pkg/pb/blockchainpb/statepb/types/types.mir.go b/pkg/pb/blockchainpb/statepb/types/types.mir.go new file mode 100644 index 000000000..7531157a5 --- /dev/null +++ b/pkg/pb/blockchainpb/statepb/types/types.mir.go @@ -0,0 +1,88 @@ +// Code generated by Mir codegen. DO NOT EDIT. + +package statepbtypes + +import ( + mirreflect "github.com/filecoin-project/mir/codegen/mirreflect" + types1 "github.com/filecoin-project/mir/codegen/model/types" + payloadpb "github.com/filecoin-project/mir/pkg/pb/blockchainpb/payloadpb" + types "github.com/filecoin-project/mir/pkg/pb/blockchainpb/payloadpb/types" + statepb "github.com/filecoin-project/mir/pkg/pb/blockchainpb/statepb" + types2 "github.com/filecoin-project/mir/pkg/types" + reflectutil "github.com/filecoin-project/mir/pkg/util/reflectutil" + timestamppb "google.golang.org/protobuf/types/known/timestamppb" +) + +type State struct { + History []*types.Payload + LastSentTimestamps []*LastSentTimestamp +} + +func StateFromPb(pb *statepb.State) *State { + if pb == nil { + return nil + } + return &State{ + History: types1.ConvertSlice(pb.History, func(t *payloadpb.Payload) *types.Payload { + return types.PayloadFromPb(t) + }), + LastSentTimestamps: types1.ConvertSlice(pb.LastSentTimestamps, func(t *statepb.LastSentTimestamp) *LastSentTimestamp { + return LastSentTimestampFromPb(t) + }), + } +} + +func (m *State) Pb() *statepb.State { + if m == nil { + return nil + } + pbMessage := &statepb.State{} + { + pbMessage.History = types1.ConvertSlice(m.History, func(t *types.Payload) *payloadpb.Payload { + return (t).Pb() + }) + pbMessage.LastSentTimestamps = types1.ConvertSlice(m.LastSentTimestamps, func(t *LastSentTimestamp) *statepb.LastSentTimestamp { + return (t).Pb() + }) + } + + return pbMessage +} + +func (*State) MirReflect() mirreflect.Type { + return mirreflect.TypeImpl{PbType_: reflectutil.TypeOf[*statepb.State]()} +} + +type LastSentTimestamp struct { + NodeId types2.NodeID + Timestamp *timestamppb.Timestamp +} + +func LastSentTimestampFromPb(pb *statepb.LastSentTimestamp) *LastSentTimestamp { + if pb == nil { + return nil + } + return &LastSentTimestamp{ + NodeId: (types2.NodeID)(pb.NodeId), + Timestamp: pb.Timestamp, + } +} + +func (m *LastSentTimestamp) Pb() *statepb.LastSentTimestamp { + if m == nil { + return nil + } + pbMessage := &statepb.LastSentTimestamp{} + { + pbMessage.NodeId = (string)(m.NodeId) + if m.Timestamp != nil { + pbMessage.Timestamp = m.Timestamp + } + } + + return pbMessage +} + +func (*LastSentTimestamp) MirReflect() mirreflect.Type { + return mirreflect.TypeImpl{PbType_: reflectutil.TypeOf[*statepb.LastSentTimestamp]()} +} diff --git a/pkg/pb/blockchainpb/synchronizerpb/dsl/emit.mir.go b/pkg/pb/blockchainpb/synchronizerpb/dsl/emit.mir.go new file mode 100644 index 000000000..8ff753256 --- /dev/null +++ b/pkg/pb/blockchainpb/synchronizerpb/dsl/emit.mir.go @@ -0,0 +1,16 @@ +// Code generated by Mir codegen. DO NOT EDIT. + +package synchronizerpbdsl + +import ( + dsl "github.com/filecoin-project/mir/pkg/dsl" + events "github.com/filecoin-project/mir/pkg/pb/blockchainpb/synchronizerpb/events" + types1 "github.com/filecoin-project/mir/pkg/pb/blockchainpb/types" + types "github.com/filecoin-project/mir/pkg/types" +) + +// Module-specific dsl functions for emitting events. + +func SyncRequest(m dsl.Module, destModule types.ModuleID, orphanBlock *types1.Block, leaveNodeIds []uint64) { + dsl.EmitMirEvent(m, events.SyncRequest(destModule, orphanBlock, leaveNodeIds)) +} diff --git a/pkg/pb/blockchainpb/synchronizerpb/dsl/messages.mir.go b/pkg/pb/blockchainpb/synchronizerpb/dsl/messages.mir.go new file mode 100644 index 000000000..f7b614d7e --- /dev/null +++ b/pkg/pb/blockchainpb/synchronizerpb/dsl/messages.mir.go @@ -0,0 +1,37 @@ +// Code generated by Mir codegen. DO NOT EDIT. + +package synchronizerpbdsl + +import ( + dsl "github.com/filecoin-project/mir/pkg/dsl" + types "github.com/filecoin-project/mir/pkg/pb/blockchainpb/synchronizerpb/types" + types3 "github.com/filecoin-project/mir/pkg/pb/blockchainpb/types" + dsl1 "github.com/filecoin-project/mir/pkg/pb/messagepb/dsl" + types2 "github.com/filecoin-project/mir/pkg/pb/messagepb/types" + types1 "github.com/filecoin-project/mir/pkg/types" +) + +// Module-specific dsl functions for processing net messages. + +func UponMessageReceived[W types.Message_TypeWrapper[M], M any](m dsl.Module, handler func(from types1.NodeID, msg *M) error) { + dsl1.UponMessageReceived[*types2.Message_Synchronizer](m, func(from types1.NodeID, msg *types.Message) error { + w, ok := msg.Type.(W) + if !ok { + return nil + } + + return handler(from, w.Unwrap()) + }) +} + +func UponChainRequestReceived(m dsl.Module, handler func(from types1.NodeID, requestId string, blockId uint64, leaveNodeIds []uint64) error) { + UponMessageReceived[*types.Message_ChainRequest](m, func(from types1.NodeID, msg *types.ChainRequest) error { + return handler(from, msg.RequestId, msg.BlockId, msg.LeaveNodeIds) + }) +} + +func UponChainResponseReceived(m dsl.Module, handler func(from types1.NodeID, requestId string, found bool, chain []*types3.Block) error) { + UponMessageReceived[*types.Message_ChainResponse](m, func(from types1.NodeID, msg *types.ChainResponse) error { + return handler(from, msg.RequestId, msg.Found, msg.Chain) + }) +} diff --git a/pkg/pb/blockchainpb/synchronizerpb/dsl/upon.mir.go b/pkg/pb/blockchainpb/synchronizerpb/dsl/upon.mir.go new file mode 100644 index 000000000..043306635 --- /dev/null +++ b/pkg/pb/blockchainpb/synchronizerpb/dsl/upon.mir.go @@ -0,0 +1,29 @@ +// Code generated by Mir codegen. DO NOT EDIT. + +package synchronizerpbdsl + +import ( + dsl "github.com/filecoin-project/mir/pkg/dsl" + types "github.com/filecoin-project/mir/pkg/pb/blockchainpb/synchronizerpb/types" + types2 "github.com/filecoin-project/mir/pkg/pb/blockchainpb/types" + types1 "github.com/filecoin-project/mir/pkg/pb/eventpb/types" +) + +// Module-specific dsl functions for processing events. + +func UponEvent[W types.Event_TypeWrapper[Ev], Ev any](m dsl.Module, handler func(ev *Ev) error) { + dsl.UponMirEvent[*types1.Event_Synchronizer](m, func(ev *types.Event) error { + w, ok := ev.Type.(W) + if !ok { + return nil + } + + return handler(w.Unwrap()) + }) +} + +func UponSyncRequest(m dsl.Module, handler func(orphanBlock *types2.Block, leaveNodeIds []uint64) error) { + UponEvent[*types.Event_SyncRequest](m, func(ev *types.SyncRequest) error { + return handler(ev.OrphanBlock, ev.LeaveNodeIds) + }) +} diff --git a/pkg/pb/blockchainpb/synchronizerpb/events/events.mir.go b/pkg/pb/blockchainpb/synchronizerpb/events/events.mir.go new file mode 100644 index 000000000..f41dadfb4 --- /dev/null +++ b/pkg/pb/blockchainpb/synchronizerpb/events/events.mir.go @@ -0,0 +1,26 @@ +// Code generated by Mir codegen. DO NOT EDIT. + +package synchronizerpbevents + +import ( + types3 "github.com/filecoin-project/mir/pkg/pb/blockchainpb/synchronizerpb/types" + types1 "github.com/filecoin-project/mir/pkg/pb/blockchainpb/types" + types2 "github.com/filecoin-project/mir/pkg/pb/eventpb/types" + types "github.com/filecoin-project/mir/pkg/types" +) + +func SyncRequest(destModule types.ModuleID, orphanBlock *types1.Block, leaveNodeIds []uint64) *types2.Event { + return &types2.Event{ + DestModule: destModule, + Type: &types2.Event_Synchronizer{ + Synchronizer: &types3.Event{ + Type: &types3.Event_SyncRequest{ + SyncRequest: &types3.SyncRequest{ + OrphanBlock: orphanBlock, + LeaveNodeIds: leaveNodeIds, + }, + }, + }, + }, + } +} diff --git a/pkg/pb/blockchainpb/synchronizerpb/msgs/msgs.mir.go b/pkg/pb/blockchainpb/synchronizerpb/msgs/msgs.mir.go new file mode 100644 index 000000000..058045720 --- /dev/null +++ b/pkg/pb/blockchainpb/synchronizerpb/msgs/msgs.mir.go @@ -0,0 +1,44 @@ +// Code generated by Mir codegen. DO NOT EDIT. + +package synchronizerpbmsgs + +import ( + types2 "github.com/filecoin-project/mir/pkg/pb/blockchainpb/synchronizerpb/types" + types3 "github.com/filecoin-project/mir/pkg/pb/blockchainpb/types" + types1 "github.com/filecoin-project/mir/pkg/pb/messagepb/types" + types "github.com/filecoin-project/mir/pkg/types" +) + +func ChainRequest(destModule types.ModuleID, requestId string, blockId uint64, leaveNodeIds []uint64) *types1.Message { + return &types1.Message{ + DestModule: destModule, + Type: &types1.Message_Synchronizer{ + Synchronizer: &types2.Message{ + Type: &types2.Message_ChainRequest{ + ChainRequest: &types2.ChainRequest{ + RequestId: requestId, + BlockId: blockId, + LeaveNodeIds: leaveNodeIds, + }, + }, + }, + }, + } +} + +func ChainResponse(destModule types.ModuleID, requestId string, found bool, chain []*types3.Block) *types1.Message { + return &types1.Message{ + DestModule: destModule, + Type: &types1.Message_Synchronizer{ + Synchronizer: &types2.Message{ + Type: &types2.Message_ChainResponse{ + ChainResponse: &types2.ChainResponse{ + RequestId: requestId, + Found: found, + Chain: chain, + }, + }, + }, + }, + } +} diff --git a/pkg/pb/blockchainpb/synchronizerpb/oneof_interfaces.mir.go b/pkg/pb/blockchainpb/synchronizerpb/oneof_interfaces.mir.go new file mode 100644 index 000000000..4a78f3920 --- /dev/null +++ b/pkg/pb/blockchainpb/synchronizerpb/oneof_interfaces.mir.go @@ -0,0 +1,29 @@ +// Code generated by Mir codegen. DO NOT EDIT. + +package synchronizerpb + +type Event_Type = isEvent_Type + +type Event_TypeWrapper[T any] interface { + Event_Type + Unwrap() *T +} + +func (w *Event_SyncRequest) Unwrap() *SyncRequest { + return w.SyncRequest +} + +type Message_Type = isMessage_Type + +type Message_TypeWrapper[T any] interface { + Message_Type + Unwrap() *T +} + +func (w *Message_ChainRequest) Unwrap() *ChainRequest { + return w.ChainRequest +} + +func (w *Message_ChainResponse) Unwrap() *ChainResponse { + return w.ChainResponse +} diff --git a/pkg/pb/blockchainpb/synchronizerpb/synchronizerpb.pb.go b/pkg/pb/blockchainpb/synchronizerpb/synchronizerpb.pb.go new file mode 100644 index 000000000..65f1f32aa --- /dev/null +++ b/pkg/pb/blockchainpb/synchronizerpb/synchronizerpb.pb.go @@ -0,0 +1,540 @@ +// Code generated by protoc-gen-go. DO NOT EDIT. +// versions: +// protoc-gen-go v1.31.0 +// protoc v4.25.2 +// source: blockchainpb/synchronizerpb/synchronizerpb.proto + +package synchronizerpb + +import ( + blockchainpb "github.com/filecoin-project/mir/pkg/pb/blockchainpb" + _ "github.com/filecoin-project/mir/pkg/pb/mir" + _ "github.com/filecoin-project/mir/pkg/pb/net" + protoreflect "google.golang.org/protobuf/reflect/protoreflect" + protoimpl "google.golang.org/protobuf/runtime/protoimpl" + reflect "reflect" + sync "sync" +) + +const ( + // Verify that this generated code is sufficiently up-to-date. + _ = protoimpl.EnforceVersion(20 - protoimpl.MinVersion) + // Verify that runtime/protoimpl is sufficiently up-to-date. + _ = protoimpl.EnforceVersion(protoimpl.MaxVersion - 20) +) + +type Event struct { + state protoimpl.MessageState + sizeCache protoimpl.SizeCache + unknownFields protoimpl.UnknownFields + + // Types that are assignable to Type: + // + // *Event_SyncRequest + Type isEvent_Type `protobuf_oneof:"type"` +} + +func (x *Event) Reset() { + *x = Event{} + if protoimpl.UnsafeEnabled { + mi := &file_blockchainpb_synchronizerpb_synchronizerpb_proto_msgTypes[0] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) + } +} + +func (x *Event) String() string { + return protoimpl.X.MessageStringOf(x) +} + +func (*Event) ProtoMessage() {} + +func (x *Event) ProtoReflect() protoreflect.Message { + mi := &file_blockchainpb_synchronizerpb_synchronizerpb_proto_msgTypes[0] + if protoimpl.UnsafeEnabled && x != nil { + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + if ms.LoadMessageInfo() == nil { + ms.StoreMessageInfo(mi) + } + return ms + } + return mi.MessageOf(x) +} + +// Deprecated: Use Event.ProtoReflect.Descriptor instead. +func (*Event) Descriptor() ([]byte, []int) { + return file_blockchainpb_synchronizerpb_synchronizerpb_proto_rawDescGZIP(), []int{0} +} + +func (m *Event) GetType() isEvent_Type { + if m != nil { + return m.Type + } + return nil +} + +func (x *Event) GetSyncRequest() *SyncRequest { + if x, ok := x.GetType().(*Event_SyncRequest); ok { + return x.SyncRequest + } + return nil +} + +type isEvent_Type interface { + isEvent_Type() +} + +type Event_SyncRequest struct { + SyncRequest *SyncRequest `protobuf:"bytes,1,opt,name=sync_request,json=syncRequest,proto3,oneof"` +} + +func (*Event_SyncRequest) isEvent_Type() {} + +type SyncRequest struct { + state protoimpl.MessageState + sizeCache protoimpl.SizeCache + unknownFields protoimpl.UnknownFields + + OrphanBlock *blockchainpb.Block `protobuf:"bytes,1,opt,name=orphan_block,json=orphanBlock,proto3" json:"orphan_block,omitempty"` + LeaveNodeIds []uint64 `protobuf:"varint,2,rep,packed,name=leave_node_ids,json=leaveNodeIds,proto3" json:"leave_node_ids,omitempty"` +} + +func (x *SyncRequest) Reset() { + *x = SyncRequest{} + if protoimpl.UnsafeEnabled { + mi := &file_blockchainpb_synchronizerpb_synchronizerpb_proto_msgTypes[1] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) + } +} + +func (x *SyncRequest) String() string { + return protoimpl.X.MessageStringOf(x) +} + +func (*SyncRequest) ProtoMessage() {} + +func (x *SyncRequest) ProtoReflect() protoreflect.Message { + mi := &file_blockchainpb_synchronizerpb_synchronizerpb_proto_msgTypes[1] + if protoimpl.UnsafeEnabled && x != nil { + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + if ms.LoadMessageInfo() == nil { + ms.StoreMessageInfo(mi) + } + return ms + } + return mi.MessageOf(x) +} + +// Deprecated: Use SyncRequest.ProtoReflect.Descriptor instead. +func (*SyncRequest) Descriptor() ([]byte, []int) { + return file_blockchainpb_synchronizerpb_synchronizerpb_proto_rawDescGZIP(), []int{1} +} + +func (x *SyncRequest) GetOrphanBlock() *blockchainpb.Block { + if x != nil { + return x.OrphanBlock + } + return nil +} + +func (x *SyncRequest) GetLeaveNodeIds() []uint64 { + if x != nil { + return x.LeaveNodeIds + } + return nil +} + +type Message struct { + state protoimpl.MessageState + sizeCache protoimpl.SizeCache + unknownFields protoimpl.UnknownFields + + // Types that are assignable to Type: + // + // *Message_ChainRequest + // *Message_ChainResponse + Type isMessage_Type `protobuf_oneof:"type"` +} + +func (x *Message) Reset() { + *x = Message{} + if protoimpl.UnsafeEnabled { + mi := &file_blockchainpb_synchronizerpb_synchronizerpb_proto_msgTypes[2] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) + } +} + +func (x *Message) String() string { + return protoimpl.X.MessageStringOf(x) +} + +func (*Message) ProtoMessage() {} + +func (x *Message) ProtoReflect() protoreflect.Message { + mi := &file_blockchainpb_synchronizerpb_synchronizerpb_proto_msgTypes[2] + if protoimpl.UnsafeEnabled && x != nil { + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + if ms.LoadMessageInfo() == nil { + ms.StoreMessageInfo(mi) + } + return ms + } + return mi.MessageOf(x) +} + +// Deprecated: Use Message.ProtoReflect.Descriptor instead. +func (*Message) Descriptor() ([]byte, []int) { + return file_blockchainpb_synchronizerpb_synchronizerpb_proto_rawDescGZIP(), []int{2} +} + +func (m *Message) GetType() isMessage_Type { + if m != nil { + return m.Type + } + return nil +} + +func (x *Message) GetChainRequest() *ChainRequest { + if x, ok := x.GetType().(*Message_ChainRequest); ok { + return x.ChainRequest + } + return nil +} + +func (x *Message) GetChainResponse() *ChainResponse { + if x, ok := x.GetType().(*Message_ChainResponse); ok { + return x.ChainResponse + } + return nil +} + +type isMessage_Type interface { + isMessage_Type() +} + +type Message_ChainRequest struct { + ChainRequest *ChainRequest `protobuf:"bytes,1,opt,name=chain_request,json=chainRequest,proto3,oneof"` +} + +type Message_ChainResponse struct { + ChainResponse *ChainResponse `protobuf:"bytes,2,opt,name=chain_response,json=chainResponse,proto3,oneof"` +} + +func (*Message_ChainRequest) isMessage_Type() {} + +func (*Message_ChainResponse) isMessage_Type() {} + +type ChainRequest struct { + state protoimpl.MessageState + sizeCache protoimpl.SizeCache + unknownFields protoimpl.UnknownFields + + RequestId string `protobuf:"bytes,1,opt,name=request_id,json=requestId,proto3" json:"request_id,omitempty"` + BlockId uint64 `protobuf:"varint,2,opt,name=block_id,json=blockId,proto3" json:"block_id,omitempty"` + LeaveNodeIds []uint64 `protobuf:"varint,3,rep,packed,name=leave_node_ids,json=leaveNodeIds,proto3" json:"leave_node_ids,omitempty"` +} + +func (x *ChainRequest) Reset() { + *x = ChainRequest{} + if protoimpl.UnsafeEnabled { + mi := &file_blockchainpb_synchronizerpb_synchronizerpb_proto_msgTypes[3] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) + } +} + +func (x *ChainRequest) String() string { + return protoimpl.X.MessageStringOf(x) +} + +func (*ChainRequest) ProtoMessage() {} + +func (x *ChainRequest) ProtoReflect() protoreflect.Message { + mi := &file_blockchainpb_synchronizerpb_synchronizerpb_proto_msgTypes[3] + if protoimpl.UnsafeEnabled && x != nil { + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + if ms.LoadMessageInfo() == nil { + ms.StoreMessageInfo(mi) + } + return ms + } + return mi.MessageOf(x) +} + +// Deprecated: Use ChainRequest.ProtoReflect.Descriptor instead. +func (*ChainRequest) Descriptor() ([]byte, []int) { + return file_blockchainpb_synchronizerpb_synchronizerpb_proto_rawDescGZIP(), []int{3} +} + +func (x *ChainRequest) GetRequestId() string { + if x != nil { + return x.RequestId + } + return "" +} + +func (x *ChainRequest) GetBlockId() uint64 { + if x != nil { + return x.BlockId + } + return 0 +} + +func (x *ChainRequest) GetLeaveNodeIds() []uint64 { + if x != nil { + return x.LeaveNodeIds + } + return nil +} + +type ChainResponse struct { + state protoimpl.MessageState + sizeCache protoimpl.SizeCache + unknownFields protoimpl.UnknownFields + + RequestId string `protobuf:"bytes,1,opt,name=request_id,json=requestId,proto3" json:"request_id,omitempty"` + Found bool `protobuf:"varint,2,opt,name=found,proto3" json:"found,omitempty"` + Chain []*blockchainpb.Block `protobuf:"bytes,3,rep,name=chain,proto3" json:"chain,omitempty"` // possibly undefined (proto3 spec no-longer supports optional/required...) +} + +func (x *ChainResponse) Reset() { + *x = ChainResponse{} + if protoimpl.UnsafeEnabled { + mi := &file_blockchainpb_synchronizerpb_synchronizerpb_proto_msgTypes[4] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) + } +} + +func (x *ChainResponse) String() string { + return protoimpl.X.MessageStringOf(x) +} + +func (*ChainResponse) ProtoMessage() {} + +func (x *ChainResponse) ProtoReflect() protoreflect.Message { + mi := &file_blockchainpb_synchronizerpb_synchronizerpb_proto_msgTypes[4] + if protoimpl.UnsafeEnabled && x != nil { + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + if ms.LoadMessageInfo() == nil { + ms.StoreMessageInfo(mi) + } + return ms + } + return mi.MessageOf(x) +} + +// Deprecated: Use ChainResponse.ProtoReflect.Descriptor instead. +func (*ChainResponse) Descriptor() ([]byte, []int) { + return file_blockchainpb_synchronizerpb_synchronizerpb_proto_rawDescGZIP(), []int{4} +} + +func (x *ChainResponse) GetRequestId() string { + if x != nil { + return x.RequestId + } + return "" +} + +func (x *ChainResponse) GetFound() bool { + if x != nil { + return x.Found + } + return false +} + +func (x *ChainResponse) GetChain() []*blockchainpb.Block { + if x != nil { + return x.Chain + } + return nil +} + +var File_blockchainpb_synchronizerpb_synchronizerpb_proto protoreflect.FileDescriptor + +var file_blockchainpb_synchronizerpb_synchronizerpb_proto_rawDesc = []byte{ + 0x0a, 0x30, 0x62, 0x6c, 0x6f, 0x63, 0x6b, 0x63, 0x68, 0x61, 0x69, 0x6e, 0x70, 0x62, 0x2f, 0x73, + 0x79, 0x6e, 0x63, 0x68, 0x72, 0x6f, 0x6e, 0x69, 0x7a, 0x65, 0x72, 0x70, 0x62, 0x2f, 0x73, 0x79, + 0x6e, 0x63, 0x68, 0x72, 0x6f, 0x6e, 0x69, 0x7a, 0x65, 0x72, 0x70, 0x62, 0x2e, 0x70, 0x72, 0x6f, + 0x74, 0x6f, 0x12, 0x0e, 0x73, 0x79, 0x6e, 0x63, 0x68, 0x72, 0x6f, 0x6e, 0x69, 0x7a, 0x65, 0x72, + 0x70, 0x62, 0x1a, 0x1f, 0x62, 0x6c, 0x6f, 0x63, 0x6b, 0x63, 0x68, 0x61, 0x69, 0x6e, 0x70, 0x62, + 0x2f, 0x62, 0x6c, 0x6f, 0x63, 0x6b, 0x63, 0x68, 0x61, 0x69, 0x6e, 0x70, 0x62, 0x2e, 0x70, 0x72, + 0x6f, 0x74, 0x6f, 0x1a, 0x1c, 0x6d, 0x69, 0x72, 0x2f, 0x63, 0x6f, 0x64, 0x65, 0x67, 0x65, 0x6e, + 0x5f, 0x65, 0x78, 0x74, 0x65, 0x6e, 0x73, 0x69, 0x6f, 0x6e, 0x73, 0x2e, 0x70, 0x72, 0x6f, 0x74, + 0x6f, 0x1a, 0x1c, 0x6e, 0x65, 0x74, 0x2f, 0x63, 0x6f, 0x64, 0x65, 0x67, 0x65, 0x6e, 0x5f, 0x65, + 0x78, 0x74, 0x65, 0x6e, 0x73, 0x69, 0x6f, 0x6e, 0x73, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x22, + 0x5d, 0x0a, 0x05, 0x45, 0x76, 0x65, 0x6e, 0x74, 0x12, 0x40, 0x0a, 0x0c, 0x73, 0x79, 0x6e, 0x63, + 0x5f, 0x72, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x18, 0x01, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x1b, + 0x2e, 0x73, 0x79, 0x6e, 0x63, 0x68, 0x72, 0x6f, 0x6e, 0x69, 0x7a, 0x65, 0x72, 0x70, 0x62, 0x2e, + 0x53, 0x79, 0x6e, 0x63, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x48, 0x00, 0x52, 0x0b, 0x73, + 0x79, 0x6e, 0x63, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x3a, 0x04, 0x90, 0xa6, 0x1d, 0x01, + 0x42, 0x0c, 0x0a, 0x04, 0x74, 0x79, 0x70, 0x65, 0x12, 0x04, 0x80, 0xa6, 0x1d, 0x01, 0x22, 0x71, + 0x0a, 0x0b, 0x53, 0x79, 0x6e, 0x63, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x12, 0x36, 0x0a, + 0x0c, 0x6f, 0x72, 0x70, 0x68, 0x61, 0x6e, 0x5f, 0x62, 0x6c, 0x6f, 0x63, 0x6b, 0x18, 0x01, 0x20, + 0x01, 0x28, 0x0b, 0x32, 0x13, 0x2e, 0x62, 0x6c, 0x6f, 0x63, 0x6b, 0x63, 0x68, 0x61, 0x69, 0x6e, + 0x70, 0x62, 0x2e, 0x42, 0x6c, 0x6f, 0x63, 0x6b, 0x52, 0x0b, 0x6f, 0x72, 0x70, 0x68, 0x61, 0x6e, + 0x42, 0x6c, 0x6f, 0x63, 0x6b, 0x12, 0x24, 0x0a, 0x0e, 0x6c, 0x65, 0x61, 0x76, 0x65, 0x5f, 0x6e, + 0x6f, 0x64, 0x65, 0x5f, 0x69, 0x64, 0x73, 0x18, 0x02, 0x20, 0x03, 0x28, 0x04, 0x52, 0x0c, 0x6c, + 0x65, 0x61, 0x76, 0x65, 0x4e, 0x6f, 0x64, 0x65, 0x49, 0x64, 0x73, 0x3a, 0x04, 0x98, 0xa6, 0x1d, + 0x01, 0x22, 0xaa, 0x01, 0x0a, 0x07, 0x4d, 0x65, 0x73, 0x73, 0x61, 0x67, 0x65, 0x12, 0x43, 0x0a, + 0x0d, 0x63, 0x68, 0x61, 0x69, 0x6e, 0x5f, 0x72, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x18, 0x01, + 0x20, 0x01, 0x28, 0x0b, 0x32, 0x1c, 0x2e, 0x73, 0x79, 0x6e, 0x63, 0x68, 0x72, 0x6f, 0x6e, 0x69, + 0x7a, 0x65, 0x72, 0x70, 0x62, 0x2e, 0x43, 0x68, 0x61, 0x69, 0x6e, 0x52, 0x65, 0x71, 0x75, 0x65, + 0x73, 0x74, 0x48, 0x00, 0x52, 0x0c, 0x63, 0x68, 0x61, 0x69, 0x6e, 0x52, 0x65, 0x71, 0x75, 0x65, + 0x73, 0x74, 0x12, 0x46, 0x0a, 0x0e, 0x63, 0x68, 0x61, 0x69, 0x6e, 0x5f, 0x72, 0x65, 0x73, 0x70, + 0x6f, 0x6e, 0x73, 0x65, 0x18, 0x02, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x1d, 0x2e, 0x73, 0x79, 0x6e, + 0x63, 0x68, 0x72, 0x6f, 0x6e, 0x69, 0x7a, 0x65, 0x72, 0x70, 0x62, 0x2e, 0x43, 0x68, 0x61, 0x69, + 0x6e, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x48, 0x00, 0x52, 0x0d, 0x63, 0x68, 0x61, + 0x69, 0x6e, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x3a, 0x04, 0xc8, 0xe4, 0x1d, 0x01, + 0x42, 0x0c, 0x0a, 0x04, 0x74, 0x79, 0x70, 0x65, 0x12, 0x04, 0xc8, 0xe4, 0x1d, 0x01, 0x22, 0x74, + 0x0a, 0x0c, 0x43, 0x68, 0x61, 0x69, 0x6e, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x12, 0x1d, + 0x0a, 0x0a, 0x72, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x5f, 0x69, 0x64, 0x18, 0x01, 0x20, 0x01, + 0x28, 0x09, 0x52, 0x09, 0x72, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x49, 0x64, 0x12, 0x19, 0x0a, + 0x08, 0x62, 0x6c, 0x6f, 0x63, 0x6b, 0x5f, 0x69, 0x64, 0x18, 0x02, 0x20, 0x01, 0x28, 0x04, 0x52, + 0x07, 0x62, 0x6c, 0x6f, 0x63, 0x6b, 0x49, 0x64, 0x12, 0x24, 0x0a, 0x0e, 0x6c, 0x65, 0x61, 0x76, + 0x65, 0x5f, 0x6e, 0x6f, 0x64, 0x65, 0x5f, 0x69, 0x64, 0x73, 0x18, 0x03, 0x20, 0x03, 0x28, 0x04, + 0x52, 0x0c, 0x6c, 0x65, 0x61, 0x76, 0x65, 0x4e, 0x6f, 0x64, 0x65, 0x49, 0x64, 0x73, 0x3a, 0x04, + 0xd0, 0xe4, 0x1d, 0x01, 0x22, 0x75, 0x0a, 0x0d, 0x43, 0x68, 0x61, 0x69, 0x6e, 0x52, 0x65, 0x73, + 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x12, 0x1d, 0x0a, 0x0a, 0x72, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, + 0x5f, 0x69, 0x64, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, 0x09, 0x72, 0x65, 0x71, 0x75, 0x65, + 0x73, 0x74, 0x49, 0x64, 0x12, 0x14, 0x0a, 0x05, 0x66, 0x6f, 0x75, 0x6e, 0x64, 0x18, 0x02, 0x20, + 0x01, 0x28, 0x08, 0x52, 0x05, 0x66, 0x6f, 0x75, 0x6e, 0x64, 0x12, 0x29, 0x0a, 0x05, 0x63, 0x68, + 0x61, 0x69, 0x6e, 0x18, 0x03, 0x20, 0x03, 0x28, 0x0b, 0x32, 0x13, 0x2e, 0x62, 0x6c, 0x6f, 0x63, + 0x6b, 0x63, 0x68, 0x61, 0x69, 0x6e, 0x70, 0x62, 0x2e, 0x42, 0x6c, 0x6f, 0x63, 0x6b, 0x52, 0x05, + 0x63, 0x68, 0x61, 0x69, 0x6e, 0x3a, 0x04, 0xd0, 0xe4, 0x1d, 0x01, 0x42, 0x44, 0x5a, 0x42, 0x67, + 0x69, 0x74, 0x68, 0x75, 0x62, 0x2e, 0x63, 0x6f, 0x6d, 0x2f, 0x66, 0x69, 0x6c, 0x65, 0x63, 0x6f, + 0x69, 0x6e, 0x2d, 0x70, 0x72, 0x6f, 0x6a, 0x65, 0x63, 0x74, 0x2f, 0x6d, 0x69, 0x72, 0x2f, 0x70, + 0x6b, 0x67, 0x2f, 0x70, 0x62, 0x2f, 0x62, 0x6c, 0x6f, 0x63, 0x6b, 0x63, 0x68, 0x61, 0x69, 0x6e, + 0x70, 0x62, 0x2f, 0x73, 0x79, 0x6e, 0x63, 0x68, 0x72, 0x6f, 0x6e, 0x69, 0x7a, 0x65, 0x72, 0x70, + 0x62, 0x62, 0x06, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x33, +} + +var ( + file_blockchainpb_synchronizerpb_synchronizerpb_proto_rawDescOnce sync.Once + file_blockchainpb_synchronizerpb_synchronizerpb_proto_rawDescData = file_blockchainpb_synchronizerpb_synchronizerpb_proto_rawDesc +) + +func file_blockchainpb_synchronizerpb_synchronizerpb_proto_rawDescGZIP() []byte { + file_blockchainpb_synchronizerpb_synchronizerpb_proto_rawDescOnce.Do(func() { + file_blockchainpb_synchronizerpb_synchronizerpb_proto_rawDescData = protoimpl.X.CompressGZIP(file_blockchainpb_synchronizerpb_synchronizerpb_proto_rawDescData) + }) + return file_blockchainpb_synchronizerpb_synchronizerpb_proto_rawDescData +} + +var file_blockchainpb_synchronizerpb_synchronizerpb_proto_msgTypes = make([]protoimpl.MessageInfo, 5) +var file_blockchainpb_synchronizerpb_synchronizerpb_proto_goTypes = []interface{}{ + (*Event)(nil), // 0: synchronizerpb.Event + (*SyncRequest)(nil), // 1: synchronizerpb.SyncRequest + (*Message)(nil), // 2: synchronizerpb.Message + (*ChainRequest)(nil), // 3: synchronizerpb.ChainRequest + (*ChainResponse)(nil), // 4: synchronizerpb.ChainResponse + (*blockchainpb.Block)(nil), // 5: blockchainpb.Block +} +var file_blockchainpb_synchronizerpb_synchronizerpb_proto_depIdxs = []int32{ + 1, // 0: synchronizerpb.Event.sync_request:type_name -> synchronizerpb.SyncRequest + 5, // 1: synchronizerpb.SyncRequest.orphan_block:type_name -> blockchainpb.Block + 3, // 2: synchronizerpb.Message.chain_request:type_name -> synchronizerpb.ChainRequest + 4, // 3: synchronizerpb.Message.chain_response:type_name -> synchronizerpb.ChainResponse + 5, // 4: synchronizerpb.ChainResponse.chain:type_name -> blockchainpb.Block + 5, // [5:5] is the sub-list for method output_type + 5, // [5:5] is the sub-list for method input_type + 5, // [5:5] is the sub-list for extension type_name + 5, // [5:5] is the sub-list for extension extendee + 0, // [0:5] is the sub-list for field type_name +} + +func init() { file_blockchainpb_synchronizerpb_synchronizerpb_proto_init() } +func file_blockchainpb_synchronizerpb_synchronizerpb_proto_init() { + if File_blockchainpb_synchronizerpb_synchronizerpb_proto != nil { + return + } + if !protoimpl.UnsafeEnabled { + file_blockchainpb_synchronizerpb_synchronizerpb_proto_msgTypes[0].Exporter = func(v interface{}, i int) interface{} { + switch v := v.(*Event); i { + case 0: + return &v.state + case 1: + return &v.sizeCache + case 2: + return &v.unknownFields + default: + return nil + } + } + file_blockchainpb_synchronizerpb_synchronizerpb_proto_msgTypes[1].Exporter = func(v interface{}, i int) interface{} { + switch v := v.(*SyncRequest); i { + case 0: + return &v.state + case 1: + return &v.sizeCache + case 2: + return &v.unknownFields + default: + return nil + } + } + file_blockchainpb_synchronizerpb_synchronizerpb_proto_msgTypes[2].Exporter = func(v interface{}, i int) interface{} { + switch v := v.(*Message); i { + case 0: + return &v.state + case 1: + return &v.sizeCache + case 2: + return &v.unknownFields + default: + return nil + } + } + file_blockchainpb_synchronizerpb_synchronizerpb_proto_msgTypes[3].Exporter = func(v interface{}, i int) interface{} { + switch v := v.(*ChainRequest); i { + case 0: + return &v.state + case 1: + return &v.sizeCache + case 2: + return &v.unknownFields + default: + return nil + } + } + file_blockchainpb_synchronizerpb_synchronizerpb_proto_msgTypes[4].Exporter = func(v interface{}, i int) interface{} { + switch v := v.(*ChainResponse); i { + case 0: + return &v.state + case 1: + return &v.sizeCache + case 2: + return &v.unknownFields + default: + return nil + } + } + } + file_blockchainpb_synchronizerpb_synchronizerpb_proto_msgTypes[0].OneofWrappers = []interface{}{ + (*Event_SyncRequest)(nil), + } + file_blockchainpb_synchronizerpb_synchronizerpb_proto_msgTypes[2].OneofWrappers = []interface{}{ + (*Message_ChainRequest)(nil), + (*Message_ChainResponse)(nil), + } + type x struct{} + out := protoimpl.TypeBuilder{ + File: protoimpl.DescBuilder{ + GoPackagePath: reflect.TypeOf(x{}).PkgPath(), + RawDescriptor: file_blockchainpb_synchronizerpb_synchronizerpb_proto_rawDesc, + NumEnums: 0, + NumMessages: 5, + NumExtensions: 0, + NumServices: 0, + }, + GoTypes: file_blockchainpb_synchronizerpb_synchronizerpb_proto_goTypes, + DependencyIndexes: file_blockchainpb_synchronizerpb_synchronizerpb_proto_depIdxs, + MessageInfos: file_blockchainpb_synchronizerpb_synchronizerpb_proto_msgTypes, + }.Build() + File_blockchainpb_synchronizerpb_synchronizerpb_proto = out.File + file_blockchainpb_synchronizerpb_synchronizerpb_proto_rawDesc = nil + file_blockchainpb_synchronizerpb_synchronizerpb_proto_goTypes = nil + file_blockchainpb_synchronizerpb_synchronizerpb_proto_depIdxs = nil +} diff --git a/pkg/pb/blockchainpb/synchronizerpb/synchronizerpb.pb.mir.go b/pkg/pb/blockchainpb/synchronizerpb/synchronizerpb.pb.mir.go new file mode 100644 index 000000000..304545144 --- /dev/null +++ b/pkg/pb/blockchainpb/synchronizerpb/synchronizerpb.pb.mir.go @@ -0,0 +1,20 @@ +// Code generated by Mir codegen. DO NOT EDIT. + +package synchronizerpb + +import ( + reflect "reflect" +) + +func (*Event) ReflectTypeOptions() []reflect.Type { + return []reflect.Type{ + reflect.TypeOf((*Event_SyncRequest)(nil)), + } +} + +func (*Message) ReflectTypeOptions() []reflect.Type { + return []reflect.Type{ + reflect.TypeOf((*Message_ChainRequest)(nil)), + reflect.TypeOf((*Message_ChainResponse)(nil)), + } +} diff --git a/pkg/pb/blockchainpb/synchronizerpb/types/types.mir.go b/pkg/pb/blockchainpb/synchronizerpb/types/types.mir.go new file mode 100644 index 000000000..9316ff3fd --- /dev/null +++ b/pkg/pb/blockchainpb/synchronizerpb/types/types.mir.go @@ -0,0 +1,300 @@ +// Code generated by Mir codegen. DO NOT EDIT. + +package synchronizerpbtypes + +import ( + mirreflect "github.com/filecoin-project/mir/codegen/mirreflect" + types1 "github.com/filecoin-project/mir/codegen/model/types" + blockchainpb "github.com/filecoin-project/mir/pkg/pb/blockchainpb" + synchronizerpb "github.com/filecoin-project/mir/pkg/pb/blockchainpb/synchronizerpb" + types "github.com/filecoin-project/mir/pkg/pb/blockchainpb/types" + reflectutil "github.com/filecoin-project/mir/pkg/util/reflectutil" +) + +type Event struct { + Type Event_Type +} + +type Event_Type interface { + mirreflect.GeneratedType + isEvent_Type() + Pb() synchronizerpb.Event_Type +} + +type Event_TypeWrapper[T any] interface { + Event_Type + Unwrap() *T +} + +func Event_TypeFromPb(pb synchronizerpb.Event_Type) Event_Type { + if pb == nil { + return nil + } + switch pb := pb.(type) { + case *synchronizerpb.Event_SyncRequest: + return &Event_SyncRequest{SyncRequest: SyncRequestFromPb(pb.SyncRequest)} + } + return nil +} + +type Event_SyncRequest struct { + SyncRequest *SyncRequest +} + +func (*Event_SyncRequest) isEvent_Type() {} + +func (w *Event_SyncRequest) Unwrap() *SyncRequest { + return w.SyncRequest +} + +func (w *Event_SyncRequest) Pb() synchronizerpb.Event_Type { + if w == nil { + return nil + } + if w.SyncRequest == nil { + return &synchronizerpb.Event_SyncRequest{} + } + return &synchronizerpb.Event_SyncRequest{SyncRequest: (w.SyncRequest).Pb()} +} + +func (*Event_SyncRequest) MirReflect() mirreflect.Type { + return mirreflect.TypeImpl{PbType_: reflectutil.TypeOf[*synchronizerpb.Event_SyncRequest]()} +} + +func EventFromPb(pb *synchronizerpb.Event) *Event { + if pb == nil { + return nil + } + return &Event{ + Type: Event_TypeFromPb(pb.Type), + } +} + +func (m *Event) Pb() *synchronizerpb.Event { + if m == nil { + return nil + } + pbMessage := &synchronizerpb.Event{} + { + if m.Type != nil { + pbMessage.Type = (m.Type).Pb() + } + } + + return pbMessage +} + +func (*Event) MirReflect() mirreflect.Type { + return mirreflect.TypeImpl{PbType_: reflectutil.TypeOf[*synchronizerpb.Event]()} +} + +type SyncRequest struct { + OrphanBlock *types.Block + LeaveNodeIds []uint64 +} + +func SyncRequestFromPb(pb *synchronizerpb.SyncRequest) *SyncRequest { + if pb == nil { + return nil + } + return &SyncRequest{ + OrphanBlock: types.BlockFromPb(pb.OrphanBlock), + LeaveNodeIds: pb.LeaveNodeIds, + } +} + +func (m *SyncRequest) Pb() *synchronizerpb.SyncRequest { + if m == nil { + return nil + } + pbMessage := &synchronizerpb.SyncRequest{} + { + if m.OrphanBlock != nil { + pbMessage.OrphanBlock = (m.OrphanBlock).Pb() + } + pbMessage.LeaveNodeIds = m.LeaveNodeIds + } + + return pbMessage +} + +func (*SyncRequest) MirReflect() mirreflect.Type { + return mirreflect.TypeImpl{PbType_: reflectutil.TypeOf[*synchronizerpb.SyncRequest]()} +} + +type Message struct { + Type Message_Type +} + +type Message_Type interface { + mirreflect.GeneratedType + isMessage_Type() + Pb() synchronizerpb.Message_Type +} + +type Message_TypeWrapper[T any] interface { + Message_Type + Unwrap() *T +} + +func Message_TypeFromPb(pb synchronizerpb.Message_Type) Message_Type { + if pb == nil { + return nil + } + switch pb := pb.(type) { + case *synchronizerpb.Message_ChainRequest: + return &Message_ChainRequest{ChainRequest: ChainRequestFromPb(pb.ChainRequest)} + case *synchronizerpb.Message_ChainResponse: + return &Message_ChainResponse{ChainResponse: ChainResponseFromPb(pb.ChainResponse)} + } + return nil +} + +type Message_ChainRequest struct { + ChainRequest *ChainRequest +} + +func (*Message_ChainRequest) isMessage_Type() {} + +func (w *Message_ChainRequest) Unwrap() *ChainRequest { + return w.ChainRequest +} + +func (w *Message_ChainRequest) Pb() synchronizerpb.Message_Type { + if w == nil { + return nil + } + if w.ChainRequest == nil { + return &synchronizerpb.Message_ChainRequest{} + } + return &synchronizerpb.Message_ChainRequest{ChainRequest: (w.ChainRequest).Pb()} +} + +func (*Message_ChainRequest) MirReflect() mirreflect.Type { + return mirreflect.TypeImpl{PbType_: reflectutil.TypeOf[*synchronizerpb.Message_ChainRequest]()} +} + +type Message_ChainResponse struct { + ChainResponse *ChainResponse +} + +func (*Message_ChainResponse) isMessage_Type() {} + +func (w *Message_ChainResponse) Unwrap() *ChainResponse { + return w.ChainResponse +} + +func (w *Message_ChainResponse) Pb() synchronizerpb.Message_Type { + if w == nil { + return nil + } + if w.ChainResponse == nil { + return &synchronizerpb.Message_ChainResponse{} + } + return &synchronizerpb.Message_ChainResponse{ChainResponse: (w.ChainResponse).Pb()} +} + +func (*Message_ChainResponse) MirReflect() mirreflect.Type { + return mirreflect.TypeImpl{PbType_: reflectutil.TypeOf[*synchronizerpb.Message_ChainResponse]()} +} + +func MessageFromPb(pb *synchronizerpb.Message) *Message { + if pb == nil { + return nil + } + return &Message{ + Type: Message_TypeFromPb(pb.Type), + } +} + +func (m *Message) Pb() *synchronizerpb.Message { + if m == nil { + return nil + } + pbMessage := &synchronizerpb.Message{} + { + if m.Type != nil { + pbMessage.Type = (m.Type).Pb() + } + } + + return pbMessage +} + +func (*Message) MirReflect() mirreflect.Type { + return mirreflect.TypeImpl{PbType_: reflectutil.TypeOf[*synchronizerpb.Message]()} +} + +type ChainRequest struct { + RequestId string + BlockId uint64 + LeaveNodeIds []uint64 +} + +func ChainRequestFromPb(pb *synchronizerpb.ChainRequest) *ChainRequest { + if pb == nil { + return nil + } + return &ChainRequest{ + RequestId: pb.RequestId, + BlockId: pb.BlockId, + LeaveNodeIds: pb.LeaveNodeIds, + } +} + +func (m *ChainRequest) Pb() *synchronizerpb.ChainRequest { + if m == nil { + return nil + } + pbMessage := &synchronizerpb.ChainRequest{} + { + pbMessage.RequestId = m.RequestId + pbMessage.BlockId = m.BlockId + pbMessage.LeaveNodeIds = m.LeaveNodeIds + } + + return pbMessage +} + +func (*ChainRequest) MirReflect() mirreflect.Type { + return mirreflect.TypeImpl{PbType_: reflectutil.TypeOf[*synchronizerpb.ChainRequest]()} +} + +type ChainResponse struct { + RequestId string + Found bool + Chain []*types.Block +} + +func ChainResponseFromPb(pb *synchronizerpb.ChainResponse) *ChainResponse { + if pb == nil { + return nil + } + return &ChainResponse{ + RequestId: pb.RequestId, + Found: pb.Found, + Chain: types1.ConvertSlice(pb.Chain, func(t *blockchainpb.Block) *types.Block { + return types.BlockFromPb(t) + }), + } +} + +func (m *ChainResponse) Pb() *synchronizerpb.ChainResponse { + if m == nil { + return nil + } + pbMessage := &synchronizerpb.ChainResponse{} + { + pbMessage.RequestId = m.RequestId + pbMessage.Found = m.Found + pbMessage.Chain = types1.ConvertSlice(m.Chain, func(t *types.Block) *blockchainpb.Block { + return (t).Pb() + }) + } + + return pbMessage +} + +func (*ChainResponse) MirReflect() mirreflect.Type { + return mirreflect.TypeImpl{PbType_: reflectutil.TypeOf[*synchronizerpb.ChainResponse]()} +} diff --git a/pkg/pb/blockchainpb/types/types.mir.go b/pkg/pb/blockchainpb/types/types.mir.go new file mode 100644 index 000000000..30f1979a7 --- /dev/null +++ b/pkg/pb/blockchainpb/types/types.mir.go @@ -0,0 +1,57 @@ +// Code generated by Mir codegen. DO NOT EDIT. + +package blockchainpbtypes + +import ( + mirreflect "github.com/filecoin-project/mir/codegen/mirreflect" + blockchainpb "github.com/filecoin-project/mir/pkg/pb/blockchainpb" + types "github.com/filecoin-project/mir/pkg/pb/blockchainpb/payloadpb/types" + types1 "github.com/filecoin-project/mir/pkg/types" + reflectutil "github.com/filecoin-project/mir/pkg/util/reflectutil" + timestamppb "google.golang.org/protobuf/types/known/timestamppb" +) + +type Block struct { + BlockId uint64 + PreviousBlockId uint64 + Payload *types.Payload + Timestamp *timestamppb.Timestamp + MinerId types1.NodeID +} + +func BlockFromPb(pb *blockchainpb.Block) *Block { + if pb == nil { + return nil + } + return &Block{ + BlockId: pb.BlockId, + PreviousBlockId: pb.PreviousBlockId, + Payload: types.PayloadFromPb(pb.Payload), + Timestamp: pb.Timestamp, + MinerId: (types1.NodeID)(pb.MinerId), + } +} + +func (m *Block) Pb() *blockchainpb.Block { + if m == nil { + return nil + } + pbMessage := &blockchainpb.Block{} + { + pbMessage.BlockId = m.BlockId + pbMessage.PreviousBlockId = m.PreviousBlockId + if m.Payload != nil { + pbMessage.Payload = (m.Payload).Pb() + } + if m.Timestamp != nil { + pbMessage.Timestamp = m.Timestamp + } + pbMessage.MinerId = (string)(m.MinerId) + } + + return pbMessage +} + +func (*Block) MirReflect() mirreflect.Type { + return mirreflect.TypeImpl{PbType_: reflectutil.TypeOf[*blockchainpb.Block]()} +} diff --git a/pkg/pb/checkpointpb/checkpointpb.pb.go b/pkg/pb/checkpointpb/checkpointpb.pb.go index c3e6da9de..de983d0e5 100644 --- a/pkg/pb/checkpointpb/checkpointpb.pb.go +++ b/pkg/pb/checkpointpb/checkpointpb.pb.go @@ -1,7 +1,7 @@ // Code generated by protoc-gen-go. DO NOT EDIT. // versions: -// protoc-gen-go v1.25.0-devel -// protoc v3.14.0 +// protoc-gen-go v1.31.0 +// protoc v4.25.2 // source: checkpointpb/checkpointpb.proto package checkpointpb @@ -29,6 +29,7 @@ type Message struct { unknownFields protoimpl.UnknownFields // Types that are assignable to Type: + // // *Message_Checkpoint Type isMessage_Type `protobuf_oneof:"type"` } @@ -166,6 +167,7 @@ type Event struct { unknownFields protoimpl.UnknownFields // Types that are assignable to Type: + // // *Event_EpochConfig // *Event_StableCheckpoint // *Event_EpochProgress diff --git a/pkg/pb/checkpointpb/chkpvalidatorpb/chkpvalidatorpb.pb.go b/pkg/pb/checkpointpb/chkpvalidatorpb/chkpvalidatorpb.pb.go index a3347588f..f6e90107c 100644 --- a/pkg/pb/checkpointpb/chkpvalidatorpb/chkpvalidatorpb.pb.go +++ b/pkg/pb/checkpointpb/chkpvalidatorpb/chkpvalidatorpb.pb.go @@ -1,7 +1,7 @@ // Code generated by protoc-gen-go. DO NOT EDIT. // versions: -// protoc-gen-go v1.25.0-devel -// protoc v3.14.0 +// protoc-gen-go v1.31.0 +// protoc v4.25.2 // source: checkpointpb/chkpvalidatorpb/chkpvalidatorpb.proto package chkpvalidatorpb @@ -31,6 +31,7 @@ type Event struct { unknownFields protoimpl.UnknownFields // Types that are assignable to Type: + // // *Event_ValidateCheckpoint // *Event_CheckpointValidated Type isEvent_Type `protobuf_oneof:"type"` @@ -238,6 +239,7 @@ type ValidateChkpOrigin struct { Module string `protobuf:"bytes,1,opt,name=module,proto3" json:"module,omitempty"` // Types that are assignable to Type: + // // *ValidateChkpOrigin_ContextStore // *ValidateChkpOrigin_Dsl Type isValidateChkpOrigin_Type `protobuf_oneof:"type"` diff --git a/pkg/pb/contextstorepb/contextstorepb.pb.go b/pkg/pb/contextstorepb/contextstorepb.pb.go index 91d4deb90..9ae54524e 100644 --- a/pkg/pb/contextstorepb/contextstorepb.pb.go +++ b/pkg/pb/contextstorepb/contextstorepb.pb.go @@ -1,7 +1,7 @@ // Code generated by protoc-gen-go. DO NOT EDIT. // versions: -// protoc-gen-go v1.25.0-devel -// protoc v3.14.0 +// protoc-gen-go v1.31.0 +// protoc v4.25.2 // source: contextstorepb/contextstorepb.proto package contextstorepb diff --git a/pkg/pb/cryptopb/cryptopb.pb.go b/pkg/pb/cryptopb/cryptopb.pb.go index 8c1406f2f..cd2d3a002 100644 --- a/pkg/pb/cryptopb/cryptopb.pb.go +++ b/pkg/pb/cryptopb/cryptopb.pb.go @@ -1,7 +1,7 @@ // Code generated by protoc-gen-go. DO NOT EDIT. // versions: -// protoc-gen-go v1.25.0-devel -// protoc v3.14.0 +// protoc-gen-go v1.31.0 +// protoc v4.25.2 // source: cryptopb/cryptopb.proto package cryptopb @@ -29,6 +29,7 @@ type Event struct { unknownFields protoimpl.UnknownFields // Types that are assignable to Type: + // // *Event_SignRequest // *Event_SignResult // *Event_VerifySig @@ -552,6 +553,7 @@ type SignOrigin struct { Module string `protobuf:"bytes,1,opt,name=module,proto3" json:"module,omitempty"` // Types that are assignable to Type: + // // *SignOrigin_ContextStore // *SignOrigin_Dsl Type isSignOrigin_Type `protobuf_oneof:"type"` @@ -640,6 +642,7 @@ type SigVerOrigin struct { Module string `protobuf:"bytes,1,opt,name=module,proto3" json:"module,omitempty"` // Types that are assignable to Type: + // // *SigVerOrigin_ContextStore // *SigVerOrigin_Dsl Type isSigVerOrigin_Type `protobuf_oneof:"type"` diff --git a/pkg/pb/dslpb/dslpb.pb.go b/pkg/pb/dslpb/dslpb.pb.go index 9080eddbb..e12dcfc65 100644 --- a/pkg/pb/dslpb/dslpb.pb.go +++ b/pkg/pb/dslpb/dslpb.pb.go @@ -1,7 +1,7 @@ // Code generated by protoc-gen-go. DO NOT EDIT. // versions: -// protoc-gen-go v1.25.0-devel -// protoc v3.14.0 +// protoc-gen-go v1.31.0 +// protoc v4.25.2 // source: dslpb/dslpb.proto package dslpb diff --git a/pkg/pb/eventpb/eventpb.pb.go b/pkg/pb/eventpb/eventpb.pb.go index 4fbd16948..0ecc7935e 100644 --- a/pkg/pb/eventpb/eventpb.pb.go +++ b/pkg/pb/eventpb/eventpb.pb.go @@ -1,7 +1,7 @@ // Code generated by protoc-gen-go. DO NOT EDIT. // versions: -// protoc-gen-go v1.25.0-devel -// protoc v3.14.0 +// protoc-gen-go v1.31.0 +// protoc v4.25.2 // source: eventpb/eventpb.proto package eventpb @@ -12,6 +12,12 @@ import ( batchdbpb "github.com/filecoin-project/mir/pkg/pb/availabilitypb/batchdbpb" batchfetcherpb "github.com/filecoin-project/mir/pkg/pb/batchfetcherpb" bcbpb "github.com/filecoin-project/mir/pkg/pb/bcbpb" + applicationpb "github.com/filecoin-project/mir/pkg/pb/blockchainpb/applicationpb" + bcmpb "github.com/filecoin-project/mir/pkg/pb/blockchainpb/bcmpb" + broadcastpb "github.com/filecoin-project/mir/pkg/pb/blockchainpb/broadcastpb" + interceptorpb "github.com/filecoin-project/mir/pkg/pb/blockchainpb/interceptorpb" + minerpb "github.com/filecoin-project/mir/pkg/pb/blockchainpb/minerpb" + synchronizerpb "github.com/filecoin-project/mir/pkg/pb/blockchainpb/synchronizerpb" checkpointpb "github.com/filecoin-project/mir/pkg/pb/checkpointpb" chkpvalidatorpb "github.com/filecoin-project/mir/pkg/pb/checkpointpb/chkpvalidatorpb" cryptopb "github.com/filecoin-project/mir/pkg/pb/cryptopb" @@ -48,6 +54,7 @@ type Event struct { DestModule string `protobuf:"bytes,1,opt,name=dest_module,json=destModule,proto3" json:"dest_module,omitempty"` // Types that are assignable to Type: + // // *Event_Init // *Event_Timer // *Event_Hasher @@ -67,6 +74,12 @@ type Event struct { // *Event_ChkpValidator // *Event_PprepValiadtor // *Event_PingPong + // *Event_Bcm + // *Event_Miner + // *Event_Broadcast + // *Event_Synchronizer + // *Event_Application + // *Event_Bcinterceptor // *Event_TestingString // *Event_TestingUint // *Event_Tester @@ -260,6 +273,48 @@ func (x *Event) GetPingPong() *pingpongpb.Event { return nil } +func (x *Event) GetBcm() *bcmpb.Event { + if x, ok := x.GetType().(*Event_Bcm); ok { + return x.Bcm + } + return nil +} + +func (x *Event) GetMiner() *minerpb.Event { + if x, ok := x.GetType().(*Event_Miner); ok { + return x.Miner + } + return nil +} + +func (x *Event) GetBroadcast() *broadcastpb.Event { + if x, ok := x.GetType().(*Event_Broadcast); ok { + return x.Broadcast + } + return nil +} + +func (x *Event) GetSynchronizer() *synchronizerpb.Event { + if x, ok := x.GetType().(*Event_Synchronizer); ok { + return x.Synchronizer + } + return nil +} + +func (x *Event) GetApplication() *applicationpb.Event { + if x, ok := x.GetType().(*Event_Application); ok { + return x.Application + } + return nil +} + +func (x *Event) GetBcinterceptor() *interceptorpb.Event { + if x, ok := x.GetType().(*Event_Bcinterceptor); ok { + return x.Bcinterceptor + } + return nil +} + func (x *Event) GetTestingString() *wrapperspb.StringValue { if x, ok := x.GetType().(*Event_TestingString); ok { return x.TestingString @@ -372,6 +427,32 @@ type Event_PingPong struct { PingPong *pingpongpb.Event `protobuf:"bytes,200,opt,name=ping_pong,json=pingPong,proto3,oneof"` } +type Event_Bcm struct { + // Events for blockchain + Bcm *bcmpb.Event `protobuf:"bytes,201,opt,name=bcm,proto3,oneof"` +} + +type Event_Miner struct { + Miner *minerpb.Event `protobuf:"bytes,202,opt,name=miner,proto3,oneof"` +} + +type Event_Broadcast struct { + Broadcast *broadcastpb.Event `protobuf:"bytes,203,opt,name=broadcast,proto3,oneof"` +} + +type Event_Synchronizer struct { + Synchronizer *synchronizerpb.Event `protobuf:"bytes,204,opt,name=synchronizer,proto3,oneof"` +} + +type Event_Application struct { + Application *applicationpb.Event `protobuf:"bytes,205,opt,name=application,proto3,oneof"` +} + +type Event_Bcinterceptor struct { + // Events for blockchain interceptor + Bcinterceptor *interceptorpb.Event `protobuf:"bytes,210,opt,name=bcinterceptor,proto3,oneof"` +} + type Event_TestingString struct { // for unit-tests TestingString *wrapperspb.StringValue `protobuf:"bytes,301,opt,name=testingString,proto3,oneof"` @@ -423,6 +504,18 @@ func (*Event_PprepValiadtor) isEvent_Type() {} func (*Event_PingPong) isEvent_Type() {} +func (*Event_Bcm) isEvent_Type() {} + +func (*Event_Miner) isEvent_Type() {} + +func (*Event_Broadcast) isEvent_Type() {} + +func (*Event_Synchronizer) isEvent_Type() {} + +func (*Event_Application) isEvent_Type() {} + +func (*Event_Bcinterceptor) isEvent_Type() {} + func (*Event_TestingString) isEvent_Type() {} func (*Event_TestingUint) isEvent_Type() {} @@ -473,6 +566,7 @@ type TimerEvent struct { unknownFields protoimpl.UnknownFields // Types that are assignable to Type: + // // *TimerEvent_Delay // *TimerEvent_Repeat // *TimerEvent_GarbageCollect @@ -567,7 +661,8 @@ type TimerDelay struct { unknownFields protoimpl.UnknownFields // TODO: The field name must not be `events`, since it conflicts with a package name in the generated code. - // This is a bug in the Mir code generator that should be fixed. + // + // This is a bug in the Mir code generator that should be fixed. EventsToDelay []*Event `protobuf:"bytes,1,rep,name=events_to_delay,json=eventsToDelay,proto3" json:"events_to_delay,omitempty"` Delay uint64 `protobuf:"varint,2,opt,name=delay,proto3" json:"delay,omitempty"` } @@ -770,141 +865,177 @@ var file_eventpb_eventpb_proto_rawDesc = []byte{ 0x73, 0x70, 0x6f, 0x72, 0x74, 0x70, 0x62, 0x2f, 0x74, 0x72, 0x61, 0x6e, 0x73, 0x70, 0x6f, 0x72, 0x74, 0x70, 0x62, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x1a, 0x17, 0x74, 0x65, 0x73, 0x74, 0x65, 0x72, 0x70, 0x62, 0x2f, 0x74, 0x65, 0x73, 0x74, 0x65, 0x72, 0x70, 0x62, 0x2e, 0x70, 0x72, 0x6f, - 0x74, 0x6f, 0x1a, 0x1c, 0x6d, 0x69, 0x72, 0x2f, 0x63, 0x6f, 0x64, 0x65, 0x67, 0x65, 0x6e, 0x5f, - 0x65, 0x78, 0x74, 0x65, 0x6e, 0x73, 0x69, 0x6f, 0x6e, 0x73, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, - 0x22, 0xf9, 0x09, 0x0a, 0x05, 0x45, 0x76, 0x65, 0x6e, 0x74, 0x12, 0x57, 0x0a, 0x0b, 0x64, 0x65, - 0x73, 0x74, 0x5f, 0x6d, 0x6f, 0x64, 0x75, 0x6c, 0x65, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x42, - 0x36, 0x82, 0xa6, 0x1d, 0x32, 0x67, 0x69, 0x74, 0x68, 0x75, 0x62, 0x2e, 0x63, 0x6f, 0x6d, 0x2f, - 0x66, 0x69, 0x6c, 0x65, 0x63, 0x6f, 0x69, 0x6e, 0x2d, 0x70, 0x72, 0x6f, 0x6a, 0x65, 0x63, 0x74, - 0x2f, 0x6d, 0x69, 0x72, 0x2f, 0x70, 0x6b, 0x67, 0x2f, 0x74, 0x79, 0x70, 0x65, 0x73, 0x2e, 0x4d, - 0x6f, 0x64, 0x75, 0x6c, 0x65, 0x49, 0x44, 0x52, 0x0a, 0x64, 0x65, 0x73, 0x74, 0x4d, 0x6f, 0x64, - 0x75, 0x6c, 0x65, 0x12, 0x23, 0x0a, 0x04, 0x69, 0x6e, 0x69, 0x74, 0x18, 0x02, 0x20, 0x01, 0x28, - 0x0b, 0x32, 0x0d, 0x2e, 0x65, 0x76, 0x65, 0x6e, 0x74, 0x70, 0x62, 0x2e, 0x49, 0x6e, 0x69, 0x74, - 0x48, 0x00, 0x52, 0x04, 0x69, 0x6e, 0x69, 0x74, 0x12, 0x2b, 0x0a, 0x05, 0x74, 0x69, 0x6d, 0x65, - 0x72, 0x18, 0x03, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x13, 0x2e, 0x65, 0x76, 0x65, 0x6e, 0x74, 0x70, - 0x62, 0x2e, 0x54, 0x69, 0x6d, 0x65, 0x72, 0x45, 0x76, 0x65, 0x6e, 0x74, 0x48, 0x00, 0x52, 0x05, - 0x74, 0x69, 0x6d, 0x65, 0x72, 0x12, 0x29, 0x0a, 0x06, 0x68, 0x61, 0x73, 0x68, 0x65, 0x72, 0x18, - 0x0a, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x0f, 0x2e, 0x68, 0x61, 0x73, 0x68, 0x65, 0x72, 0x70, 0x62, - 0x2e, 0x45, 0x76, 0x65, 0x6e, 0x74, 0x48, 0x00, 0x52, 0x06, 0x68, 0x61, 0x73, 0x68, 0x65, 0x72, - 0x12, 0x20, 0x0a, 0x03, 0x62, 0x63, 0x62, 0x18, 0x0b, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x0c, 0x2e, - 0x62, 0x63, 0x62, 0x70, 0x62, 0x2e, 0x45, 0x76, 0x65, 0x6e, 0x74, 0x48, 0x00, 0x52, 0x03, 0x62, - 0x63, 0x62, 0x12, 0x2c, 0x0a, 0x07, 0x6d, 0x65, 0x6d, 0x70, 0x6f, 0x6f, 0x6c, 0x18, 0x0c, 0x20, - 0x01, 0x28, 0x0b, 0x32, 0x10, 0x2e, 0x6d, 0x65, 0x6d, 0x70, 0x6f, 0x6f, 0x6c, 0x70, 0x62, 0x2e, - 0x45, 0x76, 0x65, 0x6e, 0x74, 0x48, 0x00, 0x52, 0x07, 0x6d, 0x65, 0x6d, 0x70, 0x6f, 0x6f, 0x6c, - 0x12, 0x3b, 0x0a, 0x0c, 0x61, 0x76, 0x61, 0x69, 0x6c, 0x61, 0x62, 0x69, 0x6c, 0x69, 0x74, 0x79, - 0x18, 0x0d, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x15, 0x2e, 0x61, 0x76, 0x61, 0x69, 0x6c, 0x61, 0x62, - 0x69, 0x6c, 0x69, 0x74, 0x79, 0x70, 0x62, 0x2e, 0x45, 0x76, 0x65, 0x6e, 0x74, 0x48, 0x00, 0x52, - 0x0c, 0x61, 0x76, 0x61, 0x69, 0x6c, 0x61, 0x62, 0x69, 0x6c, 0x69, 0x74, 0x79, 0x12, 0x2d, 0x0a, - 0x08, 0x62, 0x61, 0x74, 0x63, 0x68, 0x5f, 0x64, 0x62, 0x18, 0x0e, 0x20, 0x01, 0x28, 0x0b, 0x32, - 0x10, 0x2e, 0x62, 0x61, 0x74, 0x63, 0x68, 0x64, 0x62, 0x70, 0x62, 0x2e, 0x45, 0x76, 0x65, 0x6e, - 0x74, 0x48, 0x00, 0x52, 0x07, 0x62, 0x61, 0x74, 0x63, 0x68, 0x44, 0x62, 0x12, 0x3c, 0x0a, 0x0d, - 0x62, 0x61, 0x74, 0x63, 0x68, 0x5f, 0x66, 0x65, 0x74, 0x63, 0x68, 0x65, 0x72, 0x18, 0x0f, 0x20, - 0x01, 0x28, 0x0b, 0x32, 0x15, 0x2e, 0x62, 0x61, 0x74, 0x63, 0x68, 0x66, 0x65, 0x74, 0x63, 0x68, - 0x65, 0x72, 0x70, 0x62, 0x2e, 0x45, 0x76, 0x65, 0x6e, 0x74, 0x48, 0x00, 0x52, 0x0c, 0x62, 0x61, - 0x74, 0x63, 0x68, 0x46, 0x65, 0x74, 0x63, 0x68, 0x65, 0x72, 0x12, 0x3c, 0x0a, 0x0d, 0x74, 0x68, - 0x72, 0x65, 0x73, 0x68, 0x5f, 0x63, 0x72, 0x79, 0x70, 0x74, 0x6f, 0x18, 0x10, 0x20, 0x01, 0x28, - 0x0b, 0x32, 0x15, 0x2e, 0x74, 0x68, 0x72, 0x65, 0x73, 0x68, 0x63, 0x72, 0x79, 0x70, 0x74, 0x6f, - 0x70, 0x62, 0x2e, 0x45, 0x76, 0x65, 0x6e, 0x74, 0x48, 0x00, 0x52, 0x0c, 0x74, 0x68, 0x72, 0x65, - 0x73, 0x68, 0x43, 0x72, 0x79, 0x70, 0x74, 0x6f, 0x12, 0x35, 0x0a, 0x0a, 0x63, 0x68, 0x65, 0x63, - 0x6b, 0x70, 0x6f, 0x69, 0x6e, 0x74, 0x18, 0x11, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x13, 0x2e, 0x63, - 0x68, 0x65, 0x63, 0x6b, 0x70, 0x6f, 0x69, 0x6e, 0x74, 0x70, 0x62, 0x2e, 0x45, 0x76, 0x65, 0x6e, - 0x74, 0x48, 0x00, 0x52, 0x0a, 0x63, 0x68, 0x65, 0x63, 0x6b, 0x70, 0x6f, 0x69, 0x6e, 0x74, 0x12, - 0x2c, 0x0a, 0x07, 0x66, 0x61, 0x63, 0x74, 0x6f, 0x72, 0x79, 0x18, 0x12, 0x20, 0x01, 0x28, 0x0b, - 0x32, 0x10, 0x2e, 0x66, 0x61, 0x63, 0x74, 0x6f, 0x72, 0x79, 0x70, 0x62, 0x2e, 0x45, 0x76, 0x65, - 0x6e, 0x74, 0x48, 0x00, 0x52, 0x07, 0x66, 0x61, 0x63, 0x74, 0x6f, 0x72, 0x79, 0x12, 0x20, 0x0a, - 0x03, 0x69, 0x73, 0x73, 0x18, 0x13, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x0c, 0x2e, 0x69, 0x73, 0x73, - 0x70, 0x62, 0x2e, 0x45, 0x76, 0x65, 0x6e, 0x74, 0x48, 0x00, 0x52, 0x03, 0x69, 0x73, 0x73, 0x12, - 0x2c, 0x0a, 0x07, 0x6f, 0x72, 0x64, 0x65, 0x72, 0x65, 0x72, 0x18, 0x14, 0x20, 0x01, 0x28, 0x0b, - 0x32, 0x10, 0x2e, 0x6f, 0x72, 0x64, 0x65, 0x72, 0x65, 0x72, 0x70, 0x62, 0x2e, 0x45, 0x76, 0x65, - 0x6e, 0x74, 0x48, 0x00, 0x52, 0x07, 0x6f, 0x72, 0x64, 0x65, 0x72, 0x65, 0x72, 0x12, 0x29, 0x0a, - 0x06, 0x63, 0x72, 0x79, 0x70, 0x74, 0x6f, 0x18, 0x15, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x0f, 0x2e, - 0x63, 0x72, 0x79, 0x70, 0x74, 0x6f, 0x70, 0x62, 0x2e, 0x45, 0x76, 0x65, 0x6e, 0x74, 0x48, 0x00, - 0x52, 0x06, 0x63, 0x72, 0x79, 0x70, 0x74, 0x6f, 0x12, 0x20, 0x0a, 0x03, 0x61, 0x70, 0x70, 0x18, - 0x16, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x0c, 0x2e, 0x61, 0x70, 0x70, 0x70, 0x62, 0x2e, 0x45, 0x76, - 0x65, 0x6e, 0x74, 0x48, 0x00, 0x52, 0x03, 0x61, 0x70, 0x70, 0x12, 0x32, 0x0a, 0x09, 0x74, 0x72, - 0x61, 0x6e, 0x73, 0x70, 0x6f, 0x72, 0x74, 0x18, 0x17, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x12, 0x2e, - 0x74, 0x72, 0x61, 0x6e, 0x73, 0x70, 0x6f, 0x72, 0x74, 0x70, 0x62, 0x2e, 0x45, 0x76, 0x65, 0x6e, - 0x74, 0x48, 0x00, 0x52, 0x09, 0x74, 0x72, 0x61, 0x6e, 0x73, 0x70, 0x6f, 0x72, 0x74, 0x12, 0x3f, - 0x0a, 0x0e, 0x63, 0x68, 0x6b, 0x70, 0x5f, 0x76, 0x61, 0x6c, 0x69, 0x64, 0x61, 0x74, 0x6f, 0x72, - 0x18, 0x18, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x16, 0x2e, 0x63, 0x68, 0x6b, 0x70, 0x76, 0x61, 0x6c, - 0x69, 0x64, 0x61, 0x74, 0x6f, 0x72, 0x70, 0x62, 0x2e, 0x45, 0x76, 0x65, 0x6e, 0x74, 0x48, 0x00, - 0x52, 0x0d, 0x63, 0x68, 0x6b, 0x70, 0x56, 0x61, 0x6c, 0x69, 0x64, 0x61, 0x74, 0x6f, 0x72, 0x12, - 0x42, 0x0a, 0x0f, 0x70, 0x70, 0x72, 0x65, 0x70, 0x5f, 0x76, 0x61, 0x6c, 0x69, 0x61, 0x64, 0x74, - 0x6f, 0x72, 0x18, 0x19, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x17, 0x2e, 0x70, 0x70, 0x72, 0x65, 0x70, - 0x76, 0x61, 0x6c, 0x69, 0x64, 0x61, 0x74, 0x6f, 0x72, 0x70, 0x62, 0x2e, 0x45, 0x76, 0x65, 0x6e, - 0x74, 0x48, 0x00, 0x52, 0x0e, 0x70, 0x70, 0x72, 0x65, 0x70, 0x56, 0x61, 0x6c, 0x69, 0x61, 0x64, - 0x74, 0x6f, 0x72, 0x12, 0x31, 0x0a, 0x09, 0x70, 0x69, 0x6e, 0x67, 0x5f, 0x70, 0x6f, 0x6e, 0x67, - 0x18, 0xc8, 0x01, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x11, 0x2e, 0x70, 0x69, 0x6e, 0x67, 0x70, 0x6f, - 0x6e, 0x67, 0x70, 0x62, 0x2e, 0x45, 0x76, 0x65, 0x6e, 0x74, 0x48, 0x00, 0x52, 0x08, 0x70, 0x69, - 0x6e, 0x67, 0x50, 0x6f, 0x6e, 0x67, 0x12, 0x45, 0x0a, 0x0d, 0x74, 0x65, 0x73, 0x74, 0x69, 0x6e, - 0x67, 0x53, 0x74, 0x72, 0x69, 0x6e, 0x67, 0x18, 0xad, 0x02, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x1c, + 0x74, 0x6f, 0x1a, 0x1e, 0x62, 0x6c, 0x6f, 0x63, 0x6b, 0x63, 0x68, 0x61, 0x69, 0x6e, 0x70, 0x62, + 0x2f, 0x62, 0x63, 0x6d, 0x70, 0x62, 0x2f, 0x62, 0x63, 0x6d, 0x70, 0x62, 0x2e, 0x70, 0x72, 0x6f, + 0x74, 0x6f, 0x1a, 0x22, 0x62, 0x6c, 0x6f, 0x63, 0x6b, 0x63, 0x68, 0x61, 0x69, 0x6e, 0x70, 0x62, + 0x2f, 0x6d, 0x69, 0x6e, 0x65, 0x72, 0x70, 0x62, 0x2f, 0x6d, 0x69, 0x6e, 0x65, 0x72, 0x70, 0x62, + 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x1a, 0x2a, 0x62, 0x6c, 0x6f, 0x63, 0x6b, 0x63, 0x68, 0x61, + 0x69, 0x6e, 0x70, 0x62, 0x2f, 0x62, 0x72, 0x6f, 0x61, 0x64, 0x63, 0x61, 0x73, 0x74, 0x70, 0x62, + 0x2f, 0x62, 0x72, 0x6f, 0x61, 0x64, 0x63, 0x61, 0x73, 0x74, 0x70, 0x62, 0x2e, 0x70, 0x72, 0x6f, + 0x74, 0x6f, 0x1a, 0x30, 0x62, 0x6c, 0x6f, 0x63, 0x6b, 0x63, 0x68, 0x61, 0x69, 0x6e, 0x70, 0x62, + 0x2f, 0x73, 0x79, 0x6e, 0x63, 0x68, 0x72, 0x6f, 0x6e, 0x69, 0x7a, 0x65, 0x72, 0x70, 0x62, 0x2f, + 0x73, 0x79, 0x6e, 0x63, 0x68, 0x72, 0x6f, 0x6e, 0x69, 0x7a, 0x65, 0x72, 0x70, 0x62, 0x2e, 0x70, + 0x72, 0x6f, 0x74, 0x6f, 0x1a, 0x2e, 0x62, 0x6c, 0x6f, 0x63, 0x6b, 0x63, 0x68, 0x61, 0x69, 0x6e, + 0x70, 0x62, 0x2f, 0x61, 0x70, 0x70, 0x6c, 0x69, 0x63, 0x61, 0x74, 0x69, 0x6f, 0x6e, 0x70, 0x62, + 0x2f, 0x61, 0x70, 0x70, 0x6c, 0x69, 0x63, 0x61, 0x74, 0x69, 0x6f, 0x6e, 0x70, 0x62, 0x2e, 0x70, + 0x72, 0x6f, 0x74, 0x6f, 0x1a, 0x2e, 0x62, 0x6c, 0x6f, 0x63, 0x6b, 0x63, 0x68, 0x61, 0x69, 0x6e, + 0x70, 0x62, 0x2f, 0x69, 0x6e, 0x74, 0x65, 0x72, 0x63, 0x65, 0x70, 0x74, 0x6f, 0x72, 0x70, 0x62, + 0x2f, 0x69, 0x6e, 0x74, 0x65, 0x72, 0x63, 0x65, 0x70, 0x74, 0x6f, 0x72, 0x70, 0x62, 0x2e, 0x70, + 0x72, 0x6f, 0x74, 0x6f, 0x1a, 0x1c, 0x6d, 0x69, 0x72, 0x2f, 0x63, 0x6f, 0x64, 0x65, 0x67, 0x65, + 0x6e, 0x5f, 0x65, 0x78, 0x74, 0x65, 0x6e, 0x73, 0x69, 0x6f, 0x6e, 0x73, 0x2e, 0x70, 0x72, 0x6f, + 0x74, 0x6f, 0x22, 0xb2, 0x0c, 0x0a, 0x05, 0x45, 0x76, 0x65, 0x6e, 0x74, 0x12, 0x57, 0x0a, 0x0b, + 0x64, 0x65, 0x73, 0x74, 0x5f, 0x6d, 0x6f, 0x64, 0x75, 0x6c, 0x65, 0x18, 0x01, 0x20, 0x01, 0x28, + 0x09, 0x42, 0x36, 0x82, 0xa6, 0x1d, 0x32, 0x67, 0x69, 0x74, 0x68, 0x75, 0x62, 0x2e, 0x63, 0x6f, + 0x6d, 0x2f, 0x66, 0x69, 0x6c, 0x65, 0x63, 0x6f, 0x69, 0x6e, 0x2d, 0x70, 0x72, 0x6f, 0x6a, 0x65, + 0x63, 0x74, 0x2f, 0x6d, 0x69, 0x72, 0x2f, 0x70, 0x6b, 0x67, 0x2f, 0x74, 0x79, 0x70, 0x65, 0x73, + 0x2e, 0x4d, 0x6f, 0x64, 0x75, 0x6c, 0x65, 0x49, 0x44, 0x52, 0x0a, 0x64, 0x65, 0x73, 0x74, 0x4d, + 0x6f, 0x64, 0x75, 0x6c, 0x65, 0x12, 0x23, 0x0a, 0x04, 0x69, 0x6e, 0x69, 0x74, 0x18, 0x02, 0x20, + 0x01, 0x28, 0x0b, 0x32, 0x0d, 0x2e, 0x65, 0x76, 0x65, 0x6e, 0x74, 0x70, 0x62, 0x2e, 0x49, 0x6e, + 0x69, 0x74, 0x48, 0x00, 0x52, 0x04, 0x69, 0x6e, 0x69, 0x74, 0x12, 0x2b, 0x0a, 0x05, 0x74, 0x69, + 0x6d, 0x65, 0x72, 0x18, 0x03, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x13, 0x2e, 0x65, 0x76, 0x65, 0x6e, + 0x74, 0x70, 0x62, 0x2e, 0x54, 0x69, 0x6d, 0x65, 0x72, 0x45, 0x76, 0x65, 0x6e, 0x74, 0x48, 0x00, + 0x52, 0x05, 0x74, 0x69, 0x6d, 0x65, 0x72, 0x12, 0x29, 0x0a, 0x06, 0x68, 0x61, 0x73, 0x68, 0x65, + 0x72, 0x18, 0x0a, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x0f, 0x2e, 0x68, 0x61, 0x73, 0x68, 0x65, 0x72, + 0x70, 0x62, 0x2e, 0x45, 0x76, 0x65, 0x6e, 0x74, 0x48, 0x00, 0x52, 0x06, 0x68, 0x61, 0x73, 0x68, + 0x65, 0x72, 0x12, 0x20, 0x0a, 0x03, 0x62, 0x63, 0x62, 0x18, 0x0b, 0x20, 0x01, 0x28, 0x0b, 0x32, + 0x0c, 0x2e, 0x62, 0x63, 0x62, 0x70, 0x62, 0x2e, 0x45, 0x76, 0x65, 0x6e, 0x74, 0x48, 0x00, 0x52, + 0x03, 0x62, 0x63, 0x62, 0x12, 0x2c, 0x0a, 0x07, 0x6d, 0x65, 0x6d, 0x70, 0x6f, 0x6f, 0x6c, 0x18, + 0x0c, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x10, 0x2e, 0x6d, 0x65, 0x6d, 0x70, 0x6f, 0x6f, 0x6c, 0x70, + 0x62, 0x2e, 0x45, 0x76, 0x65, 0x6e, 0x74, 0x48, 0x00, 0x52, 0x07, 0x6d, 0x65, 0x6d, 0x70, 0x6f, + 0x6f, 0x6c, 0x12, 0x3b, 0x0a, 0x0c, 0x61, 0x76, 0x61, 0x69, 0x6c, 0x61, 0x62, 0x69, 0x6c, 0x69, + 0x74, 0x79, 0x18, 0x0d, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x15, 0x2e, 0x61, 0x76, 0x61, 0x69, 0x6c, + 0x61, 0x62, 0x69, 0x6c, 0x69, 0x74, 0x79, 0x70, 0x62, 0x2e, 0x45, 0x76, 0x65, 0x6e, 0x74, 0x48, + 0x00, 0x52, 0x0c, 0x61, 0x76, 0x61, 0x69, 0x6c, 0x61, 0x62, 0x69, 0x6c, 0x69, 0x74, 0x79, 0x12, + 0x2d, 0x0a, 0x08, 0x62, 0x61, 0x74, 0x63, 0x68, 0x5f, 0x64, 0x62, 0x18, 0x0e, 0x20, 0x01, 0x28, + 0x0b, 0x32, 0x10, 0x2e, 0x62, 0x61, 0x74, 0x63, 0x68, 0x64, 0x62, 0x70, 0x62, 0x2e, 0x45, 0x76, + 0x65, 0x6e, 0x74, 0x48, 0x00, 0x52, 0x07, 0x62, 0x61, 0x74, 0x63, 0x68, 0x44, 0x62, 0x12, 0x3c, + 0x0a, 0x0d, 0x62, 0x61, 0x74, 0x63, 0x68, 0x5f, 0x66, 0x65, 0x74, 0x63, 0x68, 0x65, 0x72, 0x18, + 0x0f, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x15, 0x2e, 0x62, 0x61, 0x74, 0x63, 0x68, 0x66, 0x65, 0x74, + 0x63, 0x68, 0x65, 0x72, 0x70, 0x62, 0x2e, 0x45, 0x76, 0x65, 0x6e, 0x74, 0x48, 0x00, 0x52, 0x0c, + 0x62, 0x61, 0x74, 0x63, 0x68, 0x46, 0x65, 0x74, 0x63, 0x68, 0x65, 0x72, 0x12, 0x3c, 0x0a, 0x0d, + 0x74, 0x68, 0x72, 0x65, 0x73, 0x68, 0x5f, 0x63, 0x72, 0x79, 0x70, 0x74, 0x6f, 0x18, 0x10, 0x20, + 0x01, 0x28, 0x0b, 0x32, 0x15, 0x2e, 0x74, 0x68, 0x72, 0x65, 0x73, 0x68, 0x63, 0x72, 0x79, 0x70, + 0x74, 0x6f, 0x70, 0x62, 0x2e, 0x45, 0x76, 0x65, 0x6e, 0x74, 0x48, 0x00, 0x52, 0x0c, 0x74, 0x68, + 0x72, 0x65, 0x73, 0x68, 0x43, 0x72, 0x79, 0x70, 0x74, 0x6f, 0x12, 0x35, 0x0a, 0x0a, 0x63, 0x68, + 0x65, 0x63, 0x6b, 0x70, 0x6f, 0x69, 0x6e, 0x74, 0x18, 0x11, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x13, + 0x2e, 0x63, 0x68, 0x65, 0x63, 0x6b, 0x70, 0x6f, 0x69, 0x6e, 0x74, 0x70, 0x62, 0x2e, 0x45, 0x76, + 0x65, 0x6e, 0x74, 0x48, 0x00, 0x52, 0x0a, 0x63, 0x68, 0x65, 0x63, 0x6b, 0x70, 0x6f, 0x69, 0x6e, + 0x74, 0x12, 0x2c, 0x0a, 0x07, 0x66, 0x61, 0x63, 0x74, 0x6f, 0x72, 0x79, 0x18, 0x12, 0x20, 0x01, + 0x28, 0x0b, 0x32, 0x10, 0x2e, 0x66, 0x61, 0x63, 0x74, 0x6f, 0x72, 0x79, 0x70, 0x62, 0x2e, 0x45, + 0x76, 0x65, 0x6e, 0x74, 0x48, 0x00, 0x52, 0x07, 0x66, 0x61, 0x63, 0x74, 0x6f, 0x72, 0x79, 0x12, + 0x20, 0x0a, 0x03, 0x69, 0x73, 0x73, 0x18, 0x13, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x0c, 0x2e, 0x69, + 0x73, 0x73, 0x70, 0x62, 0x2e, 0x45, 0x76, 0x65, 0x6e, 0x74, 0x48, 0x00, 0x52, 0x03, 0x69, 0x73, + 0x73, 0x12, 0x2c, 0x0a, 0x07, 0x6f, 0x72, 0x64, 0x65, 0x72, 0x65, 0x72, 0x18, 0x14, 0x20, 0x01, + 0x28, 0x0b, 0x32, 0x10, 0x2e, 0x6f, 0x72, 0x64, 0x65, 0x72, 0x65, 0x72, 0x70, 0x62, 0x2e, 0x45, + 0x76, 0x65, 0x6e, 0x74, 0x48, 0x00, 0x52, 0x07, 0x6f, 0x72, 0x64, 0x65, 0x72, 0x65, 0x72, 0x12, + 0x29, 0x0a, 0x06, 0x63, 0x72, 0x79, 0x70, 0x74, 0x6f, 0x18, 0x15, 0x20, 0x01, 0x28, 0x0b, 0x32, + 0x0f, 0x2e, 0x63, 0x72, 0x79, 0x70, 0x74, 0x6f, 0x70, 0x62, 0x2e, 0x45, 0x76, 0x65, 0x6e, 0x74, + 0x48, 0x00, 0x52, 0x06, 0x63, 0x72, 0x79, 0x70, 0x74, 0x6f, 0x12, 0x20, 0x0a, 0x03, 0x61, 0x70, + 0x70, 0x18, 0x16, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x0c, 0x2e, 0x61, 0x70, 0x70, 0x70, 0x62, 0x2e, + 0x45, 0x76, 0x65, 0x6e, 0x74, 0x48, 0x00, 0x52, 0x03, 0x61, 0x70, 0x70, 0x12, 0x32, 0x0a, 0x09, + 0x74, 0x72, 0x61, 0x6e, 0x73, 0x70, 0x6f, 0x72, 0x74, 0x18, 0x17, 0x20, 0x01, 0x28, 0x0b, 0x32, + 0x12, 0x2e, 0x74, 0x72, 0x61, 0x6e, 0x73, 0x70, 0x6f, 0x72, 0x74, 0x70, 0x62, 0x2e, 0x45, 0x76, + 0x65, 0x6e, 0x74, 0x48, 0x00, 0x52, 0x09, 0x74, 0x72, 0x61, 0x6e, 0x73, 0x70, 0x6f, 0x72, 0x74, + 0x12, 0x3f, 0x0a, 0x0e, 0x63, 0x68, 0x6b, 0x70, 0x5f, 0x76, 0x61, 0x6c, 0x69, 0x64, 0x61, 0x74, + 0x6f, 0x72, 0x18, 0x18, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x16, 0x2e, 0x63, 0x68, 0x6b, 0x70, 0x76, + 0x61, 0x6c, 0x69, 0x64, 0x61, 0x74, 0x6f, 0x72, 0x70, 0x62, 0x2e, 0x45, 0x76, 0x65, 0x6e, 0x74, + 0x48, 0x00, 0x52, 0x0d, 0x63, 0x68, 0x6b, 0x70, 0x56, 0x61, 0x6c, 0x69, 0x64, 0x61, 0x74, 0x6f, + 0x72, 0x12, 0x42, 0x0a, 0x0f, 0x70, 0x70, 0x72, 0x65, 0x70, 0x5f, 0x76, 0x61, 0x6c, 0x69, 0x61, + 0x64, 0x74, 0x6f, 0x72, 0x18, 0x19, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x17, 0x2e, 0x70, 0x70, 0x72, + 0x65, 0x70, 0x76, 0x61, 0x6c, 0x69, 0x64, 0x61, 0x74, 0x6f, 0x72, 0x70, 0x62, 0x2e, 0x45, 0x76, + 0x65, 0x6e, 0x74, 0x48, 0x00, 0x52, 0x0e, 0x70, 0x70, 0x72, 0x65, 0x70, 0x56, 0x61, 0x6c, 0x69, + 0x61, 0x64, 0x74, 0x6f, 0x72, 0x12, 0x31, 0x0a, 0x09, 0x70, 0x69, 0x6e, 0x67, 0x5f, 0x70, 0x6f, + 0x6e, 0x67, 0x18, 0xc8, 0x01, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x11, 0x2e, 0x70, 0x69, 0x6e, 0x67, + 0x70, 0x6f, 0x6e, 0x67, 0x70, 0x62, 0x2e, 0x45, 0x76, 0x65, 0x6e, 0x74, 0x48, 0x00, 0x52, 0x08, + 0x70, 0x69, 0x6e, 0x67, 0x50, 0x6f, 0x6e, 0x67, 0x12, 0x21, 0x0a, 0x03, 0x62, 0x63, 0x6d, 0x18, + 0xc9, 0x01, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x0c, 0x2e, 0x62, 0x63, 0x6d, 0x70, 0x62, 0x2e, 0x45, + 0x76, 0x65, 0x6e, 0x74, 0x48, 0x00, 0x52, 0x03, 0x62, 0x63, 0x6d, 0x12, 0x27, 0x0a, 0x05, 0x6d, + 0x69, 0x6e, 0x65, 0x72, 0x18, 0xca, 0x01, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x0e, 0x2e, 0x6d, 0x69, + 0x6e, 0x65, 0x72, 0x70, 0x62, 0x2e, 0x45, 0x76, 0x65, 0x6e, 0x74, 0x48, 0x00, 0x52, 0x05, 0x6d, + 0x69, 0x6e, 0x65, 0x72, 0x12, 0x33, 0x0a, 0x09, 0x62, 0x72, 0x6f, 0x61, 0x64, 0x63, 0x61, 0x73, + 0x74, 0x18, 0xcb, 0x01, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x12, 0x2e, 0x62, 0x72, 0x6f, 0x61, 0x64, + 0x63, 0x61, 0x73, 0x74, 0x70, 0x62, 0x2e, 0x45, 0x76, 0x65, 0x6e, 0x74, 0x48, 0x00, 0x52, 0x09, + 0x62, 0x72, 0x6f, 0x61, 0x64, 0x63, 0x61, 0x73, 0x74, 0x12, 0x3c, 0x0a, 0x0c, 0x73, 0x79, 0x6e, + 0x63, 0x68, 0x72, 0x6f, 0x6e, 0x69, 0x7a, 0x65, 0x72, 0x18, 0xcc, 0x01, 0x20, 0x01, 0x28, 0x0b, + 0x32, 0x15, 0x2e, 0x73, 0x79, 0x6e, 0x63, 0x68, 0x72, 0x6f, 0x6e, 0x69, 0x7a, 0x65, 0x72, 0x70, + 0x62, 0x2e, 0x45, 0x76, 0x65, 0x6e, 0x74, 0x48, 0x00, 0x52, 0x0c, 0x73, 0x79, 0x6e, 0x63, 0x68, + 0x72, 0x6f, 0x6e, 0x69, 0x7a, 0x65, 0x72, 0x12, 0x39, 0x0a, 0x0b, 0x61, 0x70, 0x70, 0x6c, 0x69, + 0x63, 0x61, 0x74, 0x69, 0x6f, 0x6e, 0x18, 0xcd, 0x01, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x14, 0x2e, + 0x61, 0x70, 0x70, 0x6c, 0x69, 0x63, 0x61, 0x74, 0x69, 0x6f, 0x6e, 0x70, 0x62, 0x2e, 0x45, 0x76, + 0x65, 0x6e, 0x74, 0x48, 0x00, 0x52, 0x0b, 0x61, 0x70, 0x70, 0x6c, 0x69, 0x63, 0x61, 0x74, 0x69, + 0x6f, 0x6e, 0x12, 0x3d, 0x0a, 0x0d, 0x62, 0x63, 0x69, 0x6e, 0x74, 0x65, 0x72, 0x63, 0x65, 0x70, + 0x74, 0x6f, 0x72, 0x18, 0xd2, 0x01, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x14, 0x2e, 0x69, 0x6e, 0x74, + 0x65, 0x72, 0x63, 0x65, 0x70, 0x74, 0x6f, 0x72, 0x70, 0x62, 0x2e, 0x45, 0x76, 0x65, 0x6e, 0x74, + 0x48, 0x00, 0x52, 0x0d, 0x62, 0x63, 0x69, 0x6e, 0x74, 0x65, 0x72, 0x63, 0x65, 0x70, 0x74, 0x6f, + 0x72, 0x12, 0x45, 0x0a, 0x0d, 0x74, 0x65, 0x73, 0x74, 0x69, 0x6e, 0x67, 0x53, 0x74, 0x72, 0x69, + 0x6e, 0x67, 0x18, 0xad, 0x02, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x1c, 0x2e, 0x67, 0x6f, 0x6f, 0x67, + 0x6c, 0x65, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x62, 0x75, 0x66, 0x2e, 0x53, 0x74, 0x72, 0x69, + 0x6e, 0x67, 0x56, 0x61, 0x6c, 0x75, 0x65, 0x48, 0x00, 0x52, 0x0d, 0x74, 0x65, 0x73, 0x74, 0x69, + 0x6e, 0x67, 0x53, 0x74, 0x72, 0x69, 0x6e, 0x67, 0x12, 0x41, 0x0a, 0x0b, 0x74, 0x65, 0x73, 0x74, + 0x69, 0x6e, 0x67, 0x55, 0x69, 0x6e, 0x74, 0x18, 0xae, 0x02, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x1c, 0x2e, 0x67, 0x6f, 0x6f, 0x67, 0x6c, 0x65, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x62, 0x75, 0x66, - 0x2e, 0x53, 0x74, 0x72, 0x69, 0x6e, 0x67, 0x56, 0x61, 0x6c, 0x75, 0x65, 0x48, 0x00, 0x52, 0x0d, - 0x74, 0x65, 0x73, 0x74, 0x69, 0x6e, 0x67, 0x53, 0x74, 0x72, 0x69, 0x6e, 0x67, 0x12, 0x41, 0x0a, - 0x0b, 0x74, 0x65, 0x73, 0x74, 0x69, 0x6e, 0x67, 0x55, 0x69, 0x6e, 0x74, 0x18, 0xae, 0x02, 0x20, - 0x01, 0x28, 0x0b, 0x32, 0x1c, 0x2e, 0x67, 0x6f, 0x6f, 0x67, 0x6c, 0x65, 0x2e, 0x70, 0x72, 0x6f, - 0x74, 0x6f, 0x62, 0x75, 0x66, 0x2e, 0x55, 0x49, 0x6e, 0x74, 0x36, 0x34, 0x56, 0x61, 0x6c, 0x75, - 0x65, 0x48, 0x00, 0x52, 0x0b, 0x74, 0x65, 0x73, 0x74, 0x69, 0x6e, 0x67, 0x55, 0x69, 0x6e, 0x74, - 0x12, 0x2b, 0x0a, 0x06, 0x74, 0x65, 0x73, 0x74, 0x65, 0x72, 0x18, 0xaf, 0x02, 0x20, 0x01, 0x28, - 0x0b, 0x32, 0x10, 0x2e, 0x74, 0x65, 0x73, 0x74, 0x65, 0x72, 0x70, 0x62, 0x2e, 0x54, 0x65, 0x73, - 0x74, 0x65, 0x72, 0x48, 0x00, 0x52, 0x06, 0x74, 0x65, 0x73, 0x74, 0x65, 0x72, 0x12, 0x29, 0x0a, - 0x04, 0x6e, 0x65, 0x78, 0x74, 0x18, 0x90, 0x03, 0x20, 0x03, 0x28, 0x0b, 0x32, 0x0e, 0x2e, 0x65, - 0x76, 0x65, 0x6e, 0x74, 0x70, 0x62, 0x2e, 0x45, 0x76, 0x65, 0x6e, 0x74, 0x42, 0x04, 0x90, 0xa6, - 0x1d, 0x01, 0x52, 0x04, 0x6e, 0x65, 0x78, 0x74, 0x3a, 0x04, 0x88, 0xa6, 0x1d, 0x01, 0x42, 0x0c, - 0x0a, 0x04, 0x74, 0x79, 0x70, 0x65, 0x12, 0x04, 0x80, 0xa6, 0x1d, 0x01, 0x22, 0x0c, 0x0a, 0x04, - 0x49, 0x6e, 0x69, 0x74, 0x3a, 0x04, 0x98, 0xa6, 0x1d, 0x01, 0x22, 0xc6, 0x01, 0x0a, 0x0a, 0x54, - 0x69, 0x6d, 0x65, 0x72, 0x45, 0x76, 0x65, 0x6e, 0x74, 0x12, 0x2b, 0x0a, 0x05, 0x64, 0x65, 0x6c, - 0x61, 0x79, 0x18, 0x01, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x13, 0x2e, 0x65, 0x76, 0x65, 0x6e, 0x74, - 0x70, 0x62, 0x2e, 0x54, 0x69, 0x6d, 0x65, 0x72, 0x44, 0x65, 0x6c, 0x61, 0x79, 0x48, 0x00, 0x52, - 0x05, 0x64, 0x65, 0x6c, 0x61, 0x79, 0x12, 0x2e, 0x0a, 0x06, 0x72, 0x65, 0x70, 0x65, 0x61, 0x74, - 0x18, 0x02, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x14, 0x2e, 0x65, 0x76, 0x65, 0x6e, 0x74, 0x70, 0x62, - 0x2e, 0x54, 0x69, 0x6d, 0x65, 0x72, 0x52, 0x65, 0x70, 0x65, 0x61, 0x74, 0x48, 0x00, 0x52, 0x06, - 0x72, 0x65, 0x70, 0x65, 0x61, 0x74, 0x12, 0x47, 0x0a, 0x0f, 0x67, 0x61, 0x72, 0x62, 0x61, 0x67, - 0x65, 0x5f, 0x63, 0x6f, 0x6c, 0x6c, 0x65, 0x63, 0x74, 0x18, 0x03, 0x20, 0x01, 0x28, 0x0b, 0x32, - 0x1c, 0x2e, 0x65, 0x76, 0x65, 0x6e, 0x74, 0x70, 0x62, 0x2e, 0x54, 0x69, 0x6d, 0x65, 0x72, 0x47, - 0x61, 0x72, 0x62, 0x61, 0x67, 0x65, 0x43, 0x6f, 0x6c, 0x6c, 0x65, 0x63, 0x74, 0x48, 0x00, 0x52, - 0x0e, 0x67, 0x61, 0x72, 0x62, 0x61, 0x67, 0x65, 0x43, 0x6f, 0x6c, 0x6c, 0x65, 0x63, 0x74, 0x3a, - 0x04, 0x90, 0xa6, 0x1d, 0x01, 0x42, 0x0c, 0x0a, 0x04, 0x54, 0x79, 0x70, 0x65, 0x12, 0x04, 0x80, - 0xa6, 0x1d, 0x01, 0x22, 0x9e, 0x01, 0x0a, 0x0a, 0x54, 0x69, 0x6d, 0x65, 0x72, 0x44, 0x65, 0x6c, - 0x61, 0x79, 0x12, 0x36, 0x0a, 0x0f, 0x65, 0x76, 0x65, 0x6e, 0x74, 0x73, 0x5f, 0x74, 0x6f, 0x5f, - 0x64, 0x65, 0x6c, 0x61, 0x79, 0x18, 0x01, 0x20, 0x03, 0x28, 0x0b, 0x32, 0x0e, 0x2e, 0x65, 0x76, - 0x65, 0x6e, 0x74, 0x70, 0x62, 0x2e, 0x45, 0x76, 0x65, 0x6e, 0x74, 0x52, 0x0d, 0x65, 0x76, 0x65, - 0x6e, 0x74, 0x73, 0x54, 0x6f, 0x44, 0x65, 0x6c, 0x61, 0x79, 0x12, 0x52, 0x0a, 0x05, 0x64, 0x65, - 0x6c, 0x61, 0x79, 0x18, 0x02, 0x20, 0x01, 0x28, 0x04, 0x42, 0x3c, 0x82, 0xa6, 0x1d, 0x38, 0x67, - 0x69, 0x74, 0x68, 0x75, 0x62, 0x2e, 0x63, 0x6f, 0x6d, 0x2f, 0x66, 0x69, 0x6c, 0x65, 0x63, 0x6f, - 0x69, 0x6e, 0x2d, 0x70, 0x72, 0x6f, 0x6a, 0x65, 0x63, 0x74, 0x2f, 0x6d, 0x69, 0x72, 0x2f, 0x70, - 0x6b, 0x67, 0x2f, 0x74, 0x69, 0x6d, 0x65, 0x72, 0x2f, 0x74, 0x79, 0x70, 0x65, 0x73, 0x2e, 0x44, - 0x75, 0x72, 0x61, 0x74, 0x69, 0x6f, 0x6e, 0x52, 0x05, 0x64, 0x65, 0x6c, 0x61, 0x79, 0x3a, 0x04, - 0x98, 0xa6, 0x1d, 0x01, 0x22, 0x90, 0x02, 0x0a, 0x0b, 0x54, 0x69, 0x6d, 0x65, 0x72, 0x52, 0x65, - 0x70, 0x65, 0x61, 0x74, 0x12, 0x38, 0x0a, 0x10, 0x65, 0x76, 0x65, 0x6e, 0x74, 0x73, 0x5f, 0x74, - 0x6f, 0x5f, 0x72, 0x65, 0x70, 0x65, 0x61, 0x74, 0x18, 0x01, 0x20, 0x03, 0x28, 0x0b, 0x32, 0x0e, - 0x2e, 0x65, 0x76, 0x65, 0x6e, 0x74, 0x70, 0x62, 0x2e, 0x45, 0x76, 0x65, 0x6e, 0x74, 0x52, 0x0e, - 0x65, 0x76, 0x65, 0x6e, 0x74, 0x73, 0x54, 0x6f, 0x52, 0x65, 0x70, 0x65, 0x61, 0x74, 0x12, 0x52, - 0x0a, 0x05, 0x64, 0x65, 0x6c, 0x61, 0x79, 0x18, 0x02, 0x20, 0x01, 0x28, 0x04, 0x42, 0x3c, 0x82, - 0xa6, 0x1d, 0x38, 0x67, 0x69, 0x74, 0x68, 0x75, 0x62, 0x2e, 0x63, 0x6f, 0x6d, 0x2f, 0x66, 0x69, - 0x6c, 0x65, 0x63, 0x6f, 0x69, 0x6e, 0x2d, 0x70, 0x72, 0x6f, 0x6a, 0x65, 0x63, 0x74, 0x2f, 0x6d, - 0x69, 0x72, 0x2f, 0x70, 0x6b, 0x67, 0x2f, 0x74, 0x69, 0x6d, 0x65, 0x72, 0x2f, 0x74, 0x79, 0x70, - 0x65, 0x73, 0x2e, 0x44, 0x75, 0x72, 0x61, 0x74, 0x69, 0x6f, 0x6e, 0x52, 0x05, 0x64, 0x65, 0x6c, - 0x61, 0x79, 0x12, 0x6d, 0x0a, 0x0f, 0x72, 0x65, 0x74, 0x65, 0x6e, 0x74, 0x69, 0x6f, 0x6e, 0x5f, - 0x69, 0x6e, 0x64, 0x65, 0x78, 0x18, 0x03, 0x20, 0x01, 0x28, 0x04, 0x42, 0x44, 0x82, 0xa6, 0x1d, - 0x40, 0x67, 0x69, 0x74, 0x68, 0x75, 0x62, 0x2e, 0x63, 0x6f, 0x6d, 0x2f, 0x66, 0x69, 0x6c, 0x65, - 0x63, 0x6f, 0x69, 0x6e, 0x2d, 0x70, 0x72, 0x6f, 0x6a, 0x65, 0x63, 0x74, 0x2f, 0x6d, 0x69, 0x72, - 0x2f, 0x70, 0x6b, 0x67, 0x2f, 0x74, 0x72, 0x61, 0x6e, 0x74, 0x6f, 0x72, 0x2f, 0x74, 0x79, 0x70, - 0x65, 0x73, 0x2e, 0x52, 0x65, 0x74, 0x65, 0x6e, 0x74, 0x69, 0x6f, 0x6e, 0x49, 0x6e, 0x64, 0x65, - 0x78, 0x52, 0x0e, 0x72, 0x65, 0x74, 0x65, 0x6e, 0x74, 0x69, 0x6f, 0x6e, 0x49, 0x6e, 0x64, 0x65, - 0x78, 0x3a, 0x04, 0x98, 0xa6, 0x1d, 0x01, 0x22, 0x8a, 0x01, 0x0a, 0x13, 0x54, 0x69, 0x6d, 0x65, - 0x72, 0x47, 0x61, 0x72, 0x62, 0x61, 0x67, 0x65, 0x43, 0x6f, 0x6c, 0x6c, 0x65, 0x63, 0x74, 0x12, - 0x6d, 0x0a, 0x0f, 0x72, 0x65, 0x74, 0x65, 0x6e, 0x74, 0x69, 0x6f, 0x6e, 0x5f, 0x69, 0x6e, 0x64, - 0x65, 0x78, 0x18, 0x01, 0x20, 0x01, 0x28, 0x04, 0x42, 0x44, 0x82, 0xa6, 0x1d, 0x40, 0x67, 0x69, + 0x2e, 0x55, 0x49, 0x6e, 0x74, 0x36, 0x34, 0x56, 0x61, 0x6c, 0x75, 0x65, 0x48, 0x00, 0x52, 0x0b, + 0x74, 0x65, 0x73, 0x74, 0x69, 0x6e, 0x67, 0x55, 0x69, 0x6e, 0x74, 0x12, 0x2b, 0x0a, 0x06, 0x74, + 0x65, 0x73, 0x74, 0x65, 0x72, 0x18, 0xaf, 0x02, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x10, 0x2e, 0x74, + 0x65, 0x73, 0x74, 0x65, 0x72, 0x70, 0x62, 0x2e, 0x54, 0x65, 0x73, 0x74, 0x65, 0x72, 0x48, 0x00, + 0x52, 0x06, 0x74, 0x65, 0x73, 0x74, 0x65, 0x72, 0x12, 0x29, 0x0a, 0x04, 0x6e, 0x65, 0x78, 0x74, + 0x18, 0x90, 0x03, 0x20, 0x03, 0x28, 0x0b, 0x32, 0x0e, 0x2e, 0x65, 0x76, 0x65, 0x6e, 0x74, 0x70, + 0x62, 0x2e, 0x45, 0x76, 0x65, 0x6e, 0x74, 0x42, 0x04, 0x90, 0xa6, 0x1d, 0x01, 0x52, 0x04, 0x6e, + 0x65, 0x78, 0x74, 0x3a, 0x04, 0x88, 0xa6, 0x1d, 0x01, 0x42, 0x0c, 0x0a, 0x04, 0x74, 0x79, 0x70, + 0x65, 0x12, 0x04, 0x80, 0xa6, 0x1d, 0x01, 0x22, 0x0c, 0x0a, 0x04, 0x49, 0x6e, 0x69, 0x74, 0x3a, + 0x04, 0x98, 0xa6, 0x1d, 0x01, 0x22, 0xc6, 0x01, 0x0a, 0x0a, 0x54, 0x69, 0x6d, 0x65, 0x72, 0x45, + 0x76, 0x65, 0x6e, 0x74, 0x12, 0x2b, 0x0a, 0x05, 0x64, 0x65, 0x6c, 0x61, 0x79, 0x18, 0x01, 0x20, + 0x01, 0x28, 0x0b, 0x32, 0x13, 0x2e, 0x65, 0x76, 0x65, 0x6e, 0x74, 0x70, 0x62, 0x2e, 0x54, 0x69, + 0x6d, 0x65, 0x72, 0x44, 0x65, 0x6c, 0x61, 0x79, 0x48, 0x00, 0x52, 0x05, 0x64, 0x65, 0x6c, 0x61, + 0x79, 0x12, 0x2e, 0x0a, 0x06, 0x72, 0x65, 0x70, 0x65, 0x61, 0x74, 0x18, 0x02, 0x20, 0x01, 0x28, + 0x0b, 0x32, 0x14, 0x2e, 0x65, 0x76, 0x65, 0x6e, 0x74, 0x70, 0x62, 0x2e, 0x54, 0x69, 0x6d, 0x65, + 0x72, 0x52, 0x65, 0x70, 0x65, 0x61, 0x74, 0x48, 0x00, 0x52, 0x06, 0x72, 0x65, 0x70, 0x65, 0x61, + 0x74, 0x12, 0x47, 0x0a, 0x0f, 0x67, 0x61, 0x72, 0x62, 0x61, 0x67, 0x65, 0x5f, 0x63, 0x6f, 0x6c, + 0x6c, 0x65, 0x63, 0x74, 0x18, 0x03, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x1c, 0x2e, 0x65, 0x76, 0x65, + 0x6e, 0x74, 0x70, 0x62, 0x2e, 0x54, 0x69, 0x6d, 0x65, 0x72, 0x47, 0x61, 0x72, 0x62, 0x61, 0x67, + 0x65, 0x43, 0x6f, 0x6c, 0x6c, 0x65, 0x63, 0x74, 0x48, 0x00, 0x52, 0x0e, 0x67, 0x61, 0x72, 0x62, + 0x61, 0x67, 0x65, 0x43, 0x6f, 0x6c, 0x6c, 0x65, 0x63, 0x74, 0x3a, 0x04, 0x90, 0xa6, 0x1d, 0x01, + 0x42, 0x0c, 0x0a, 0x04, 0x54, 0x79, 0x70, 0x65, 0x12, 0x04, 0x80, 0xa6, 0x1d, 0x01, 0x22, 0x9e, + 0x01, 0x0a, 0x0a, 0x54, 0x69, 0x6d, 0x65, 0x72, 0x44, 0x65, 0x6c, 0x61, 0x79, 0x12, 0x36, 0x0a, + 0x0f, 0x65, 0x76, 0x65, 0x6e, 0x74, 0x73, 0x5f, 0x74, 0x6f, 0x5f, 0x64, 0x65, 0x6c, 0x61, 0x79, + 0x18, 0x01, 0x20, 0x03, 0x28, 0x0b, 0x32, 0x0e, 0x2e, 0x65, 0x76, 0x65, 0x6e, 0x74, 0x70, 0x62, + 0x2e, 0x45, 0x76, 0x65, 0x6e, 0x74, 0x52, 0x0d, 0x65, 0x76, 0x65, 0x6e, 0x74, 0x73, 0x54, 0x6f, + 0x44, 0x65, 0x6c, 0x61, 0x79, 0x12, 0x52, 0x0a, 0x05, 0x64, 0x65, 0x6c, 0x61, 0x79, 0x18, 0x02, + 0x20, 0x01, 0x28, 0x04, 0x42, 0x3c, 0x82, 0xa6, 0x1d, 0x38, 0x67, 0x69, 0x74, 0x68, 0x75, 0x62, + 0x2e, 0x63, 0x6f, 0x6d, 0x2f, 0x66, 0x69, 0x6c, 0x65, 0x63, 0x6f, 0x69, 0x6e, 0x2d, 0x70, 0x72, + 0x6f, 0x6a, 0x65, 0x63, 0x74, 0x2f, 0x6d, 0x69, 0x72, 0x2f, 0x70, 0x6b, 0x67, 0x2f, 0x74, 0x69, + 0x6d, 0x65, 0x72, 0x2f, 0x74, 0x79, 0x70, 0x65, 0x73, 0x2e, 0x44, 0x75, 0x72, 0x61, 0x74, 0x69, + 0x6f, 0x6e, 0x52, 0x05, 0x64, 0x65, 0x6c, 0x61, 0x79, 0x3a, 0x04, 0x98, 0xa6, 0x1d, 0x01, 0x22, + 0x90, 0x02, 0x0a, 0x0b, 0x54, 0x69, 0x6d, 0x65, 0x72, 0x52, 0x65, 0x70, 0x65, 0x61, 0x74, 0x12, + 0x38, 0x0a, 0x10, 0x65, 0x76, 0x65, 0x6e, 0x74, 0x73, 0x5f, 0x74, 0x6f, 0x5f, 0x72, 0x65, 0x70, + 0x65, 0x61, 0x74, 0x18, 0x01, 0x20, 0x03, 0x28, 0x0b, 0x32, 0x0e, 0x2e, 0x65, 0x76, 0x65, 0x6e, + 0x74, 0x70, 0x62, 0x2e, 0x45, 0x76, 0x65, 0x6e, 0x74, 0x52, 0x0e, 0x65, 0x76, 0x65, 0x6e, 0x74, + 0x73, 0x54, 0x6f, 0x52, 0x65, 0x70, 0x65, 0x61, 0x74, 0x12, 0x52, 0x0a, 0x05, 0x64, 0x65, 0x6c, + 0x61, 0x79, 0x18, 0x02, 0x20, 0x01, 0x28, 0x04, 0x42, 0x3c, 0x82, 0xa6, 0x1d, 0x38, 0x67, 0x69, 0x74, 0x68, 0x75, 0x62, 0x2e, 0x63, 0x6f, 0x6d, 0x2f, 0x66, 0x69, 0x6c, 0x65, 0x63, 0x6f, 0x69, 0x6e, 0x2d, 0x70, 0x72, 0x6f, 0x6a, 0x65, 0x63, 0x74, 0x2f, 0x6d, 0x69, 0x72, 0x2f, 0x70, 0x6b, - 0x67, 0x2f, 0x74, 0x72, 0x61, 0x6e, 0x74, 0x6f, 0x72, 0x2f, 0x74, 0x79, 0x70, 0x65, 0x73, 0x2e, - 0x52, 0x65, 0x74, 0x65, 0x6e, 0x74, 0x69, 0x6f, 0x6e, 0x49, 0x6e, 0x64, 0x65, 0x78, 0x52, 0x0e, - 0x72, 0x65, 0x74, 0x65, 0x6e, 0x74, 0x69, 0x6f, 0x6e, 0x49, 0x6e, 0x64, 0x65, 0x78, 0x3a, 0x04, - 0x98, 0xa6, 0x1d, 0x01, 0x42, 0x30, 0x5a, 0x2e, 0x67, 0x69, 0x74, 0x68, 0x75, 0x62, 0x2e, 0x63, - 0x6f, 0x6d, 0x2f, 0x66, 0x69, 0x6c, 0x65, 0x63, 0x6f, 0x69, 0x6e, 0x2d, 0x70, 0x72, 0x6f, 0x6a, - 0x65, 0x63, 0x74, 0x2f, 0x6d, 0x69, 0x72, 0x2f, 0x70, 0x6b, 0x67, 0x2f, 0x70, 0x62, 0x2f, 0x65, - 0x76, 0x65, 0x6e, 0x74, 0x70, 0x62, 0x62, 0x06, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x33, + 0x67, 0x2f, 0x74, 0x69, 0x6d, 0x65, 0x72, 0x2f, 0x74, 0x79, 0x70, 0x65, 0x73, 0x2e, 0x44, 0x75, + 0x72, 0x61, 0x74, 0x69, 0x6f, 0x6e, 0x52, 0x05, 0x64, 0x65, 0x6c, 0x61, 0x79, 0x12, 0x6d, 0x0a, + 0x0f, 0x72, 0x65, 0x74, 0x65, 0x6e, 0x74, 0x69, 0x6f, 0x6e, 0x5f, 0x69, 0x6e, 0x64, 0x65, 0x78, + 0x18, 0x03, 0x20, 0x01, 0x28, 0x04, 0x42, 0x44, 0x82, 0xa6, 0x1d, 0x40, 0x67, 0x69, 0x74, 0x68, + 0x75, 0x62, 0x2e, 0x63, 0x6f, 0x6d, 0x2f, 0x66, 0x69, 0x6c, 0x65, 0x63, 0x6f, 0x69, 0x6e, 0x2d, + 0x70, 0x72, 0x6f, 0x6a, 0x65, 0x63, 0x74, 0x2f, 0x6d, 0x69, 0x72, 0x2f, 0x70, 0x6b, 0x67, 0x2f, + 0x74, 0x72, 0x61, 0x6e, 0x74, 0x6f, 0x72, 0x2f, 0x74, 0x79, 0x70, 0x65, 0x73, 0x2e, 0x52, 0x65, + 0x74, 0x65, 0x6e, 0x74, 0x69, 0x6f, 0x6e, 0x49, 0x6e, 0x64, 0x65, 0x78, 0x52, 0x0e, 0x72, 0x65, + 0x74, 0x65, 0x6e, 0x74, 0x69, 0x6f, 0x6e, 0x49, 0x6e, 0x64, 0x65, 0x78, 0x3a, 0x04, 0x98, 0xa6, + 0x1d, 0x01, 0x22, 0x8a, 0x01, 0x0a, 0x13, 0x54, 0x69, 0x6d, 0x65, 0x72, 0x47, 0x61, 0x72, 0x62, + 0x61, 0x67, 0x65, 0x43, 0x6f, 0x6c, 0x6c, 0x65, 0x63, 0x74, 0x12, 0x6d, 0x0a, 0x0f, 0x72, 0x65, + 0x74, 0x65, 0x6e, 0x74, 0x69, 0x6f, 0x6e, 0x5f, 0x69, 0x6e, 0x64, 0x65, 0x78, 0x18, 0x01, 0x20, + 0x01, 0x28, 0x04, 0x42, 0x44, 0x82, 0xa6, 0x1d, 0x40, 0x67, 0x69, 0x74, 0x68, 0x75, 0x62, 0x2e, + 0x63, 0x6f, 0x6d, 0x2f, 0x66, 0x69, 0x6c, 0x65, 0x63, 0x6f, 0x69, 0x6e, 0x2d, 0x70, 0x72, 0x6f, + 0x6a, 0x65, 0x63, 0x74, 0x2f, 0x6d, 0x69, 0x72, 0x2f, 0x70, 0x6b, 0x67, 0x2f, 0x74, 0x72, 0x61, + 0x6e, 0x74, 0x6f, 0x72, 0x2f, 0x74, 0x79, 0x70, 0x65, 0x73, 0x2e, 0x52, 0x65, 0x74, 0x65, 0x6e, + 0x74, 0x69, 0x6f, 0x6e, 0x49, 0x6e, 0x64, 0x65, 0x78, 0x52, 0x0e, 0x72, 0x65, 0x74, 0x65, 0x6e, + 0x74, 0x69, 0x6f, 0x6e, 0x49, 0x6e, 0x64, 0x65, 0x78, 0x3a, 0x04, 0x98, 0xa6, 0x1d, 0x01, 0x42, + 0x30, 0x5a, 0x2e, 0x67, 0x69, 0x74, 0x68, 0x75, 0x62, 0x2e, 0x63, 0x6f, 0x6d, 0x2f, 0x66, 0x69, + 0x6c, 0x65, 0x63, 0x6f, 0x69, 0x6e, 0x2d, 0x70, 0x72, 0x6f, 0x6a, 0x65, 0x63, 0x74, 0x2f, 0x6d, + 0x69, 0x72, 0x2f, 0x70, 0x6b, 0x67, 0x2f, 0x70, 0x62, 0x2f, 0x65, 0x76, 0x65, 0x6e, 0x74, 0x70, + 0x62, 0x62, 0x06, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x33, } var ( @@ -944,9 +1075,15 @@ var file_eventpb_eventpb_proto_goTypes = []interface{}{ (*chkpvalidatorpb.Event)(nil), // 20: chkpvalidatorpb.Event (*pprepvalidatorpb.Event)(nil), // 21: pprepvalidatorpb.Event (*pingpongpb.Event)(nil), // 22: pingpongpb.Event - (*wrapperspb.StringValue)(nil), // 23: google.protobuf.StringValue - (*wrapperspb.UInt64Value)(nil), // 24: google.protobuf.UInt64Value - (*testerpb.Tester)(nil), // 25: testerpb.Tester + (*bcmpb.Event)(nil), // 23: bcmpb.Event + (*minerpb.Event)(nil), // 24: minerpb.Event + (*broadcastpb.Event)(nil), // 25: broadcastpb.Event + (*synchronizerpb.Event)(nil), // 26: synchronizerpb.Event + (*applicationpb.Event)(nil), // 27: applicationpb.Event + (*interceptorpb.Event)(nil), // 28: interceptorpb.Event + (*wrapperspb.StringValue)(nil), // 29: google.protobuf.StringValue + (*wrapperspb.UInt64Value)(nil), // 30: google.protobuf.UInt64Value + (*testerpb.Tester)(nil), // 31: testerpb.Tester } var file_eventpb_eventpb_proto_depIdxs = []int32{ 1, // 0: eventpb.Event.init:type_name -> eventpb.Init @@ -968,20 +1105,26 @@ var file_eventpb_eventpb_proto_depIdxs = []int32{ 20, // 16: eventpb.Event.chkp_validator:type_name -> chkpvalidatorpb.Event 21, // 17: eventpb.Event.pprep_valiadtor:type_name -> pprepvalidatorpb.Event 22, // 18: eventpb.Event.ping_pong:type_name -> pingpongpb.Event - 23, // 19: eventpb.Event.testingString:type_name -> google.protobuf.StringValue - 24, // 20: eventpb.Event.testingUint:type_name -> google.protobuf.UInt64Value - 25, // 21: eventpb.Event.tester:type_name -> testerpb.Tester - 0, // 22: eventpb.Event.next:type_name -> eventpb.Event - 3, // 23: eventpb.TimerEvent.delay:type_name -> eventpb.TimerDelay - 4, // 24: eventpb.TimerEvent.repeat:type_name -> eventpb.TimerRepeat - 5, // 25: eventpb.TimerEvent.garbage_collect:type_name -> eventpb.TimerGarbageCollect - 0, // 26: eventpb.TimerDelay.events_to_delay:type_name -> eventpb.Event - 0, // 27: eventpb.TimerRepeat.events_to_repeat:type_name -> eventpb.Event - 28, // [28:28] is the sub-list for method output_type - 28, // [28:28] is the sub-list for method input_type - 28, // [28:28] is the sub-list for extension type_name - 28, // [28:28] is the sub-list for extension extendee - 0, // [0:28] is the sub-list for field type_name + 23, // 19: eventpb.Event.bcm:type_name -> bcmpb.Event + 24, // 20: eventpb.Event.miner:type_name -> minerpb.Event + 25, // 21: eventpb.Event.broadcast:type_name -> broadcastpb.Event + 26, // 22: eventpb.Event.synchronizer:type_name -> synchronizerpb.Event + 27, // 23: eventpb.Event.application:type_name -> applicationpb.Event + 28, // 24: eventpb.Event.bcinterceptor:type_name -> interceptorpb.Event + 29, // 25: eventpb.Event.testingString:type_name -> google.protobuf.StringValue + 30, // 26: eventpb.Event.testingUint:type_name -> google.protobuf.UInt64Value + 31, // 27: eventpb.Event.tester:type_name -> testerpb.Tester + 0, // 28: eventpb.Event.next:type_name -> eventpb.Event + 3, // 29: eventpb.TimerEvent.delay:type_name -> eventpb.TimerDelay + 4, // 30: eventpb.TimerEvent.repeat:type_name -> eventpb.TimerRepeat + 5, // 31: eventpb.TimerEvent.garbage_collect:type_name -> eventpb.TimerGarbageCollect + 0, // 32: eventpb.TimerDelay.events_to_delay:type_name -> eventpb.Event + 0, // 33: eventpb.TimerRepeat.events_to_repeat:type_name -> eventpb.Event + 34, // [34:34] is the sub-list for method output_type + 34, // [34:34] is the sub-list for method input_type + 34, // [34:34] is the sub-list for extension type_name + 34, // [34:34] is the sub-list for extension extendee + 0, // [0:34] is the sub-list for field type_name } func init() { file_eventpb_eventpb_proto_init() } @@ -1083,6 +1226,12 @@ func file_eventpb_eventpb_proto_init() { (*Event_ChkpValidator)(nil), (*Event_PprepValiadtor)(nil), (*Event_PingPong)(nil), + (*Event_Bcm)(nil), + (*Event_Miner)(nil), + (*Event_Broadcast)(nil), + (*Event_Synchronizer)(nil), + (*Event_Application)(nil), + (*Event_Bcinterceptor)(nil), (*Event_TestingString)(nil), (*Event_TestingUint)(nil), (*Event_Tester)(nil), diff --git a/pkg/pb/eventpb/eventpb.pb.mir.go b/pkg/pb/eventpb/eventpb.pb.mir.go index 8808e7d1a..f11c03e13 100644 --- a/pkg/pb/eventpb/eventpb.pb.mir.go +++ b/pkg/pb/eventpb/eventpb.pb.mir.go @@ -27,6 +27,12 @@ func (*Event) ReflectTypeOptions() []reflect.Type { reflect.TypeOf((*Event_ChkpValidator)(nil)), reflect.TypeOf((*Event_PprepValiadtor)(nil)), reflect.TypeOf((*Event_PingPong)(nil)), + reflect.TypeOf((*Event_Bcm)(nil)), + reflect.TypeOf((*Event_Miner)(nil)), + reflect.TypeOf((*Event_Broadcast)(nil)), + reflect.TypeOf((*Event_Synchronizer)(nil)), + reflect.TypeOf((*Event_Application)(nil)), + reflect.TypeOf((*Event_Bcinterceptor)(nil)), reflect.TypeOf((*Event_TestingString)(nil)), reflect.TypeOf((*Event_TestingUint)(nil)), reflect.TypeOf((*Event_Tester)(nil)), diff --git a/pkg/pb/eventpb/oneof_interfaces.mir.go b/pkg/pb/eventpb/oneof_interfaces.mir.go index 2baab82b9..ce2ad0918 100644 --- a/pkg/pb/eventpb/oneof_interfaces.mir.go +++ b/pkg/pb/eventpb/oneof_interfaces.mir.go @@ -8,6 +8,12 @@ import ( batchdbpb "github.com/filecoin-project/mir/pkg/pb/availabilitypb/batchdbpb" batchfetcherpb "github.com/filecoin-project/mir/pkg/pb/batchfetcherpb" bcbpb "github.com/filecoin-project/mir/pkg/pb/bcbpb" + applicationpb "github.com/filecoin-project/mir/pkg/pb/blockchainpb/applicationpb" + bcmpb "github.com/filecoin-project/mir/pkg/pb/blockchainpb/bcmpb" + broadcastpb "github.com/filecoin-project/mir/pkg/pb/blockchainpb/broadcastpb" + interceptorpb "github.com/filecoin-project/mir/pkg/pb/blockchainpb/interceptorpb" + minerpb "github.com/filecoin-project/mir/pkg/pb/blockchainpb/minerpb" + synchronizerpb "github.com/filecoin-project/mir/pkg/pb/blockchainpb/synchronizerpb" checkpointpb "github.com/filecoin-project/mir/pkg/pb/checkpointpb" chkpvalidatorpb "github.com/filecoin-project/mir/pkg/pb/checkpointpb/chkpvalidatorpb" cryptopb "github.com/filecoin-project/mir/pkg/pb/cryptopb" @@ -107,6 +113,30 @@ func (w *Event_PingPong) Unwrap() *pingpongpb.Event { return w.PingPong } +func (w *Event_Bcm) Unwrap() *bcmpb.Event { + return w.Bcm +} + +func (w *Event_Miner) Unwrap() *minerpb.Event { + return w.Miner +} + +func (w *Event_Broadcast) Unwrap() *broadcastpb.Event { + return w.Broadcast +} + +func (w *Event_Synchronizer) Unwrap() *synchronizerpb.Event { + return w.Synchronizer +} + +func (w *Event_Application) Unwrap() *applicationpb.Event { + return w.Application +} + +func (w *Event_Bcinterceptor) Unwrap() *interceptorpb.Event { + return w.Bcinterceptor +} + func (w *Event_TestingString) Unwrap() *wrapperspb.StringValue { return w.TestingString } diff --git a/pkg/pb/eventpb/types/types.mir.go b/pkg/pb/eventpb/types/types.mir.go index 119300d27..e71d8c8de 100644 --- a/pkg/pb/eventpb/types/types.mir.go +++ b/pkg/pb/eventpb/types/types.mir.go @@ -4,12 +4,18 @@ package eventpbtypes import ( mirreflect "github.com/filecoin-project/mir/codegen/mirreflect" - types19 "github.com/filecoin-project/mir/codegen/model/types" + types25 "github.com/filecoin-project/mir/codegen/model/types" types13 "github.com/filecoin-project/mir/pkg/pb/apppb/types" types5 "github.com/filecoin-project/mir/pkg/pb/availabilitypb/batchdbpb/types" types4 "github.com/filecoin-project/mir/pkg/pb/availabilitypb/types" types6 "github.com/filecoin-project/mir/pkg/pb/batchfetcherpb/types" types2 "github.com/filecoin-project/mir/pkg/pb/bcbpb/types" + types22 "github.com/filecoin-project/mir/pkg/pb/blockchainpb/applicationpb/types" + types18 "github.com/filecoin-project/mir/pkg/pb/blockchainpb/bcmpb/types" + types20 "github.com/filecoin-project/mir/pkg/pb/blockchainpb/broadcastpb/types" + types23 "github.com/filecoin-project/mir/pkg/pb/blockchainpb/interceptorpb/types" + types19 "github.com/filecoin-project/mir/pkg/pb/blockchainpb/minerpb/types" + types21 "github.com/filecoin-project/mir/pkg/pb/blockchainpb/synchronizerpb/types" types15 "github.com/filecoin-project/mir/pkg/pb/checkpointpb/chkpvalidatorpb/types" types8 "github.com/filecoin-project/mir/pkg/pb/checkpointpb/types" types12 "github.com/filecoin-project/mir/pkg/pb/cryptopb/types" @@ -21,11 +27,11 @@ import ( types16 "github.com/filecoin-project/mir/pkg/pb/ordererpb/pprepvalidatorpb/types" types11 "github.com/filecoin-project/mir/pkg/pb/ordererpb/types" types17 "github.com/filecoin-project/mir/pkg/pb/pingpongpb/types" - types18 "github.com/filecoin-project/mir/pkg/pb/testerpb/types" + types24 "github.com/filecoin-project/mir/pkg/pb/testerpb/types" types7 "github.com/filecoin-project/mir/pkg/pb/threshcryptopb/types" types14 "github.com/filecoin-project/mir/pkg/pb/transportpb/types" - types20 "github.com/filecoin-project/mir/pkg/timer/types" - types21 "github.com/filecoin-project/mir/pkg/trantor/types" + types26 "github.com/filecoin-project/mir/pkg/timer/types" + types27 "github.com/filecoin-project/mir/pkg/trantor/types" types "github.com/filecoin-project/mir/pkg/types" reflectutil "github.com/filecoin-project/mir/pkg/util/reflectutil" wrapperspb "google.golang.org/protobuf/types/known/wrapperspb" @@ -91,12 +97,24 @@ func Event_TypeFromPb(pb eventpb.Event_Type) Event_Type { return &Event_PprepValiadtor{PprepValiadtor: types16.EventFromPb(pb.PprepValiadtor)} case *eventpb.Event_PingPong: return &Event_PingPong{PingPong: types17.EventFromPb(pb.PingPong)} + case *eventpb.Event_Bcm: + return &Event_Bcm{Bcm: types18.EventFromPb(pb.Bcm)} + case *eventpb.Event_Miner: + return &Event_Miner{Miner: types19.EventFromPb(pb.Miner)} + case *eventpb.Event_Broadcast: + return &Event_Broadcast{Broadcast: types20.EventFromPb(pb.Broadcast)} + case *eventpb.Event_Synchronizer: + return &Event_Synchronizer{Synchronizer: types21.EventFromPb(pb.Synchronizer)} + case *eventpb.Event_Application: + return &Event_Application{Application: types22.EventFromPb(pb.Application)} + case *eventpb.Event_Bcinterceptor: + return &Event_Bcinterceptor{Bcinterceptor: types23.EventFromPb(pb.Bcinterceptor)} case *eventpb.Event_TestingString: return &Event_TestingString{TestingString: pb.TestingString} case *eventpb.Event_TestingUint: return &Event_TestingUint{TestingUint: pb.TestingUint} case *eventpb.Event_Tester: - return &Event_Tester{Tester: types18.TesterFromPb(pb.Tester)} + return &Event_Tester{Tester: types24.TesterFromPb(pb.Tester)} } return nil } @@ -557,6 +575,150 @@ func (*Event_PingPong) MirReflect() mirreflect.Type { return mirreflect.TypeImpl{PbType_: reflectutil.TypeOf[*eventpb.Event_PingPong]()} } +type Event_Bcm struct { + Bcm *types18.Event +} + +func (*Event_Bcm) isEvent_Type() {} + +func (w *Event_Bcm) Unwrap() *types18.Event { + return w.Bcm +} + +func (w *Event_Bcm) Pb() eventpb.Event_Type { + if w == nil { + return nil + } + if w.Bcm == nil { + return &eventpb.Event_Bcm{} + } + return &eventpb.Event_Bcm{Bcm: (w.Bcm).Pb()} +} + +func (*Event_Bcm) MirReflect() mirreflect.Type { + return mirreflect.TypeImpl{PbType_: reflectutil.TypeOf[*eventpb.Event_Bcm]()} +} + +type Event_Miner struct { + Miner *types19.Event +} + +func (*Event_Miner) isEvent_Type() {} + +func (w *Event_Miner) Unwrap() *types19.Event { + return w.Miner +} + +func (w *Event_Miner) Pb() eventpb.Event_Type { + if w == nil { + return nil + } + if w.Miner == nil { + return &eventpb.Event_Miner{} + } + return &eventpb.Event_Miner{Miner: (w.Miner).Pb()} +} + +func (*Event_Miner) MirReflect() mirreflect.Type { + return mirreflect.TypeImpl{PbType_: reflectutil.TypeOf[*eventpb.Event_Miner]()} +} + +type Event_Broadcast struct { + Broadcast *types20.Event +} + +func (*Event_Broadcast) isEvent_Type() {} + +func (w *Event_Broadcast) Unwrap() *types20.Event { + return w.Broadcast +} + +func (w *Event_Broadcast) Pb() eventpb.Event_Type { + if w == nil { + return nil + } + if w.Broadcast == nil { + return &eventpb.Event_Broadcast{} + } + return &eventpb.Event_Broadcast{Broadcast: (w.Broadcast).Pb()} +} + +func (*Event_Broadcast) MirReflect() mirreflect.Type { + return mirreflect.TypeImpl{PbType_: reflectutil.TypeOf[*eventpb.Event_Broadcast]()} +} + +type Event_Synchronizer struct { + Synchronizer *types21.Event +} + +func (*Event_Synchronizer) isEvent_Type() {} + +func (w *Event_Synchronizer) Unwrap() *types21.Event { + return w.Synchronizer +} + +func (w *Event_Synchronizer) Pb() eventpb.Event_Type { + if w == nil { + return nil + } + if w.Synchronizer == nil { + return &eventpb.Event_Synchronizer{} + } + return &eventpb.Event_Synchronizer{Synchronizer: (w.Synchronizer).Pb()} +} + +func (*Event_Synchronizer) MirReflect() mirreflect.Type { + return mirreflect.TypeImpl{PbType_: reflectutil.TypeOf[*eventpb.Event_Synchronizer]()} +} + +type Event_Application struct { + Application *types22.Event +} + +func (*Event_Application) isEvent_Type() {} + +func (w *Event_Application) Unwrap() *types22.Event { + return w.Application +} + +func (w *Event_Application) Pb() eventpb.Event_Type { + if w == nil { + return nil + } + if w.Application == nil { + return &eventpb.Event_Application{} + } + return &eventpb.Event_Application{Application: (w.Application).Pb()} +} + +func (*Event_Application) MirReflect() mirreflect.Type { + return mirreflect.TypeImpl{PbType_: reflectutil.TypeOf[*eventpb.Event_Application]()} +} + +type Event_Bcinterceptor struct { + Bcinterceptor *types23.Event +} + +func (*Event_Bcinterceptor) isEvent_Type() {} + +func (w *Event_Bcinterceptor) Unwrap() *types23.Event { + return w.Bcinterceptor +} + +func (w *Event_Bcinterceptor) Pb() eventpb.Event_Type { + if w == nil { + return nil + } + if w.Bcinterceptor == nil { + return &eventpb.Event_Bcinterceptor{} + } + return &eventpb.Event_Bcinterceptor{Bcinterceptor: (w.Bcinterceptor).Pb()} +} + +func (*Event_Bcinterceptor) MirReflect() mirreflect.Type { + return mirreflect.TypeImpl{PbType_: reflectutil.TypeOf[*eventpb.Event_Bcinterceptor]()} +} + type Event_TestingString struct { TestingString *wrapperspb.StringValue } @@ -606,12 +768,12 @@ func (*Event_TestingUint) MirReflect() mirreflect.Type { } type Event_Tester struct { - Tester *types18.Tester + Tester *types24.Tester } func (*Event_Tester) isEvent_Type() {} -func (w *Event_Tester) Unwrap() *types18.Tester { +func (w *Event_Tester) Unwrap() *types24.Tester { return w.Tester } @@ -636,7 +798,7 @@ func EventFromPb(pb *eventpb.Event) *Event { return &Event{ DestModule: (types.ModuleID)(pb.DestModule), Type: Event_TypeFromPb(pb.Type), - Next: types19.ConvertSlice(pb.Next, func(t *eventpb.Event) *Event { + Next: types25.ConvertSlice(pb.Next, func(t *eventpb.Event) *Event { return EventFromPb(t) }), } @@ -652,7 +814,7 @@ func (m *Event) Pb() *eventpb.Event { if m.Type != nil { pbMessage.Type = (m.Type).Pb() } - pbMessage.Next = types19.ConvertSlice(m.Next, func(t *Event) *eventpb.Event { + pbMessage.Next = types25.ConvertSlice(m.Next, func(t *Event) *eventpb.Event { return (t).Pb() }) } @@ -819,7 +981,7 @@ func (*TimerEvent) MirReflect() mirreflect.Type { type TimerDelay struct { EventsToDelay []*Event - Delay types20.Duration + Delay types26.Duration } func TimerDelayFromPb(pb *eventpb.TimerDelay) *TimerDelay { @@ -827,10 +989,10 @@ func TimerDelayFromPb(pb *eventpb.TimerDelay) *TimerDelay { return nil } return &TimerDelay{ - EventsToDelay: types19.ConvertSlice(pb.EventsToDelay, func(t *eventpb.Event) *Event { + EventsToDelay: types25.ConvertSlice(pb.EventsToDelay, func(t *eventpb.Event) *Event { return EventFromPb(t) }), - Delay: (types20.Duration)(pb.Delay), + Delay: (types26.Duration)(pb.Delay), } } @@ -840,7 +1002,7 @@ func (m *TimerDelay) Pb() *eventpb.TimerDelay { } pbMessage := &eventpb.TimerDelay{} { - pbMessage.EventsToDelay = types19.ConvertSlice(m.EventsToDelay, func(t *Event) *eventpb.Event { + pbMessage.EventsToDelay = types25.ConvertSlice(m.EventsToDelay, func(t *Event) *eventpb.Event { return (t).Pb() }) pbMessage.Delay = (uint64)(m.Delay) @@ -855,8 +1017,8 @@ func (*TimerDelay) MirReflect() mirreflect.Type { type TimerRepeat struct { EventsToRepeat []*Event - Delay types20.Duration - RetentionIndex types21.RetentionIndex + Delay types26.Duration + RetentionIndex types27.RetentionIndex } func TimerRepeatFromPb(pb *eventpb.TimerRepeat) *TimerRepeat { @@ -864,11 +1026,11 @@ func TimerRepeatFromPb(pb *eventpb.TimerRepeat) *TimerRepeat { return nil } return &TimerRepeat{ - EventsToRepeat: types19.ConvertSlice(pb.EventsToRepeat, func(t *eventpb.Event) *Event { + EventsToRepeat: types25.ConvertSlice(pb.EventsToRepeat, func(t *eventpb.Event) *Event { return EventFromPb(t) }), - Delay: (types20.Duration)(pb.Delay), - RetentionIndex: (types21.RetentionIndex)(pb.RetentionIndex), + Delay: (types26.Duration)(pb.Delay), + RetentionIndex: (types27.RetentionIndex)(pb.RetentionIndex), } } @@ -878,7 +1040,7 @@ func (m *TimerRepeat) Pb() *eventpb.TimerRepeat { } pbMessage := &eventpb.TimerRepeat{} { - pbMessage.EventsToRepeat = types19.ConvertSlice(m.EventsToRepeat, func(t *Event) *eventpb.Event { + pbMessage.EventsToRepeat = types25.ConvertSlice(m.EventsToRepeat, func(t *Event) *eventpb.Event { return (t).Pb() }) pbMessage.Delay = (uint64)(m.Delay) @@ -893,7 +1055,7 @@ func (*TimerRepeat) MirReflect() mirreflect.Type { } type TimerGarbageCollect struct { - RetentionIndex types21.RetentionIndex + RetentionIndex types27.RetentionIndex } func TimerGarbageCollectFromPb(pb *eventpb.TimerGarbageCollect) *TimerGarbageCollect { @@ -901,7 +1063,7 @@ func TimerGarbageCollectFromPb(pb *eventpb.TimerGarbageCollect) *TimerGarbageCol return nil } return &TimerGarbageCollect{ - RetentionIndex: (types21.RetentionIndex)(pb.RetentionIndex), + RetentionIndex: (types27.RetentionIndex)(pb.RetentionIndex), } } diff --git a/pkg/pb/factorypb/factorypb.pb.go b/pkg/pb/factorypb/factorypb.pb.go index a0bed354d..fbf3c61fe 100644 --- a/pkg/pb/factorypb/factorypb.pb.go +++ b/pkg/pb/factorypb/factorypb.pb.go @@ -1,7 +1,7 @@ // Code generated by protoc-gen-go. DO NOT EDIT. // versions: -// protoc-gen-go v1.25.0-devel -// protoc v3.14.0 +// protoc-gen-go v1.31.0 +// protoc v4.25.2 // source: factorypb/factorypb.proto package factorypb @@ -31,6 +31,7 @@ type Event struct { unknownFields protoimpl.UnknownFields // Types that are assignable to Type: + // // *Event_NewModule // *Event_GarbageCollect Type isEvent_Type `protobuf_oneof:"type"` @@ -227,6 +228,7 @@ type GeneratorParams struct { unknownFields protoimpl.UnknownFields // Types that are assignable to Type: + // // *GeneratorParams_MultisigCollector // *GeneratorParams_Checkpoint // *GeneratorParams_EchoTestModule diff --git a/pkg/pb/hasherpb/hasherpb.pb.go b/pkg/pb/hasherpb/hasherpb.pb.go index cdc0413ee..1265733ad 100644 --- a/pkg/pb/hasherpb/hasherpb.pb.go +++ b/pkg/pb/hasherpb/hasherpb.pb.go @@ -1,7 +1,7 @@ // Code generated by protoc-gen-go. DO NOT EDIT. // versions: -// protoc-gen-go v1.25.0-devel -// protoc v3.14.0 +// protoc-gen-go v1.31.0 +// protoc v4.25.2 // source: hasherpb/hasherpb.proto package hasherpb @@ -29,6 +29,7 @@ type Event struct { unknownFields protoimpl.UnknownFields // Types that are assignable to Type: + // // *Event_Request // *Event_Result // *Event_RequestOne @@ -358,6 +359,7 @@ type HashOrigin struct { Module string `protobuf:"bytes,1,opt,name=module,proto3" json:"module,omitempty"` // Types that are assignable to Type: + // // *HashOrigin_ContextStore // *HashOrigin_Dsl Type isHashOrigin_Type `protobuf_oneof:"type"` diff --git a/pkg/pb/isspb/isspb.pb.go b/pkg/pb/isspb/isspb.pb.go index 825142a0a..f9979d9f5 100644 --- a/pkg/pb/isspb/isspb.pb.go +++ b/pkg/pb/isspb/isspb.pb.go @@ -5,8 +5,8 @@ // Code generated by protoc-gen-go. DO NOT EDIT. // versions: -// protoc-gen-go v1.25.0-devel -// protoc v3.14.0 +// protoc-gen-go v1.31.0 +// protoc v4.25.2 // source: isspb/isspb.proto package isspb @@ -36,6 +36,7 @@ type ISSMessage struct { unknownFields protoimpl.UnknownFields // Types that are assignable to Type: + // // *ISSMessage_StableCheckpoint Type isISSMessage_Type `protobuf_oneof:"type"` } @@ -102,6 +103,7 @@ type Event struct { unknownFields protoimpl.UnknownFields // Types that are assignable to Type: + // // *Event_PushCheckpoint // *Event_SbDeliver // *Event_DeliverCert diff --git a/pkg/pb/mempoolpb/mempoolpb.pb.go b/pkg/pb/mempoolpb/mempoolpb.pb.go index 2bfc92bc6..699d6c4f7 100644 --- a/pkg/pb/mempoolpb/mempoolpb.pb.go +++ b/pkg/pb/mempoolpb/mempoolpb.pb.go @@ -1,7 +1,7 @@ // Code generated by protoc-gen-go. DO NOT EDIT. // versions: -// protoc-gen-go v1.25.0-devel -// protoc v3.14.0 +// protoc-gen-go v1.31.0 +// protoc v4.25.2 // source: mempoolpb/mempoolpb.proto package mempoolpb @@ -30,6 +30,7 @@ type Event struct { unknownFields protoimpl.UnknownFields // Types that are assignable to Type: + // // *Event_RequestBatch // *Event_NewBatch // *Event_RequestTransactions @@ -862,6 +863,7 @@ type RequestBatchOrigin struct { Module string `protobuf:"bytes,1,opt,name=module,proto3" json:"module,omitempty"` // Types that are assignable to Type: + // // *RequestBatchOrigin_ContextStore // *RequestBatchOrigin_Dsl Type isRequestBatchOrigin_Type `protobuf_oneof:"Type"` @@ -950,6 +952,7 @@ type RequestTransactionsOrigin struct { Module string `protobuf:"bytes,1,opt,name=module,proto3" json:"module,omitempty"` // Types that are assignable to Type: + // // *RequestTransactionsOrigin_ContextStore // *RequestTransactionsOrigin_Dsl Type isRequestTransactionsOrigin_Type `protobuf_oneof:"Type"` @@ -1038,6 +1041,7 @@ type RequestTransactionIDsOrigin struct { Module string `protobuf:"bytes,1,opt,name=module,proto3" json:"module,omitempty"` // Types that are assignable to Type: + // // *RequestTransactionIDsOrigin_ContextStore // *RequestTransactionIDsOrigin_Dsl Type isRequestTransactionIDsOrigin_Type `protobuf_oneof:"Type"` @@ -1126,6 +1130,7 @@ type RequestBatchIDOrigin struct { Module string `protobuf:"bytes,1,opt,name=module,proto3" json:"module,omitempty"` // Types that are assignable to Type: + // // *RequestBatchIDOrigin_ContextStore // *RequestBatchIDOrigin_Dsl Type isRequestBatchIDOrigin_Type `protobuf_oneof:"Type"` diff --git a/pkg/pb/messagepb/messagepb.pb.go b/pkg/pb/messagepb/messagepb.pb.go index f642796cf..e43cd0d2d 100644 --- a/pkg/pb/messagepb/messagepb.pb.go +++ b/pkg/pb/messagepb/messagepb.pb.go @@ -5,8 +5,8 @@ // Code generated by protoc-gen-go. DO NOT EDIT. // versions: -// protoc-gen-go v1.25.0-devel -// protoc v3.14.0 +// protoc-gen-go v1.31.0 +// protoc v4.25.2 // source: messagepb/messagepb.proto package messagepb @@ -14,6 +14,8 @@ package messagepb import ( mscpb "github.com/filecoin-project/mir/pkg/pb/availabilitypb/mscpb" bcbpb "github.com/filecoin-project/mir/pkg/pb/bcbpb" + broadcastpb "github.com/filecoin-project/mir/pkg/pb/blockchainpb/broadcastpb" + synchronizerpb "github.com/filecoin-project/mir/pkg/pb/blockchainpb/synchronizerpb" checkpointpb "github.com/filecoin-project/mir/pkg/pb/checkpointpb" isspb "github.com/filecoin-project/mir/pkg/pb/isspb" _ "github.com/filecoin-project/mir/pkg/pb/mir" @@ -40,12 +42,15 @@ type Message struct { DestModule string `protobuf:"bytes,1,opt,name=dest_module,json=destModule,proto3" json:"dest_module,omitempty"` // Types that are assignable to Type: + // // *Message_Iss // *Message_Bcb // *Message_MultisigCollector // *Message_Pingpong // *Message_Checkpoint // *Message_Orderer + // *Message_Broadcast + // *Message_Synchronizer Type isMessage_Type `protobuf_oneof:"type"` } @@ -137,6 +142,20 @@ func (x *Message) GetOrderer() *ordererpb.Message { return nil } +func (x *Message) GetBroadcast() *broadcastpb.Message { + if x, ok := x.GetType().(*Message_Broadcast); ok { + return x.Broadcast + } + return nil +} + +func (x *Message) GetSynchronizer() *synchronizerpb.Message { + if x, ok := x.GetType().(*Message_Synchronizer); ok { + return x.Synchronizer + } + return nil +} + type isMessage_Type interface { isMessage_Type() } @@ -165,6 +184,15 @@ type Message_Orderer struct { Orderer *ordererpb.Message `protobuf:"bytes,7,opt,name=orderer,proto3,oneof"` } +type Message_Broadcast struct { + // Messages for blockchain + Broadcast *broadcastpb.Message `protobuf:"bytes,8,opt,name=broadcast,proto3,oneof"` +} + +type Message_Synchronizer struct { + Synchronizer *synchronizerpb.Message `protobuf:"bytes,9,opt,name=synchronizer,proto3,oneof"` +} + func (*Message_Iss) isMessage_Type() {} func (*Message_Bcb) isMessage_Type() {} @@ -177,6 +205,10 @@ func (*Message_Checkpoint) isMessage_Type() {} func (*Message_Orderer) isMessage_Type() {} +func (*Message_Broadcast) isMessage_Type() {} + +func (*Message_Synchronizer) isMessage_Type() {} + var File_messagepb_messagepb_proto protoreflect.FileDescriptor var file_messagepb_messagepb_proto_rawDesc = []byte{ @@ -192,41 +224,55 @@ var file_messagepb_messagepb_proto_rawDesc = []byte{ 0x63, 0x6b, 0x70, 0x6f, 0x69, 0x6e, 0x74, 0x70, 0x62, 0x2f, 0x63, 0x68, 0x65, 0x63, 0x6b, 0x70, 0x6f, 0x69, 0x6e, 0x74, 0x70, 0x62, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x1a, 0x19, 0x6f, 0x72, 0x64, 0x65, 0x72, 0x65, 0x72, 0x70, 0x62, 0x2f, 0x6f, 0x72, 0x64, 0x65, 0x72, 0x65, 0x72, 0x70, - 0x62, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x1a, 0x1c, 0x6d, 0x69, 0x72, 0x2f, 0x63, 0x6f, 0x64, - 0x65, 0x67, 0x65, 0x6e, 0x5f, 0x65, 0x78, 0x74, 0x65, 0x6e, 0x73, 0x69, 0x6f, 0x6e, 0x73, 0x2e, - 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x1a, 0x1c, 0x6e, 0x65, 0x74, 0x2f, 0x63, 0x6f, 0x64, 0x65, 0x67, + 0x62, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x1a, 0x2a, 0x62, 0x6c, 0x6f, 0x63, 0x6b, 0x63, 0x68, + 0x61, 0x69, 0x6e, 0x70, 0x62, 0x2f, 0x62, 0x72, 0x6f, 0x61, 0x64, 0x63, 0x61, 0x73, 0x74, 0x70, + 0x62, 0x2f, 0x62, 0x72, 0x6f, 0x61, 0x64, 0x63, 0x61, 0x73, 0x74, 0x70, 0x62, 0x2e, 0x70, 0x72, + 0x6f, 0x74, 0x6f, 0x1a, 0x30, 0x62, 0x6c, 0x6f, 0x63, 0x6b, 0x63, 0x68, 0x61, 0x69, 0x6e, 0x70, + 0x62, 0x2f, 0x73, 0x79, 0x6e, 0x63, 0x68, 0x72, 0x6f, 0x6e, 0x69, 0x7a, 0x65, 0x72, 0x70, 0x62, + 0x2f, 0x73, 0x79, 0x6e, 0x63, 0x68, 0x72, 0x6f, 0x6e, 0x69, 0x7a, 0x65, 0x72, 0x70, 0x62, 0x2e, + 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x1a, 0x1c, 0x6d, 0x69, 0x72, 0x2f, 0x63, 0x6f, 0x64, 0x65, 0x67, 0x65, 0x6e, 0x5f, 0x65, 0x78, 0x74, 0x65, 0x6e, 0x73, 0x69, 0x6f, 0x6e, 0x73, 0x2e, 0x70, 0x72, - 0x6f, 0x74, 0x6f, 0x22, 0xad, 0x03, 0x0a, 0x07, 0x4d, 0x65, 0x73, 0x73, 0x61, 0x67, 0x65, 0x12, - 0x57, 0x0a, 0x0b, 0x64, 0x65, 0x73, 0x74, 0x5f, 0x6d, 0x6f, 0x64, 0x75, 0x6c, 0x65, 0x18, 0x01, - 0x20, 0x01, 0x28, 0x09, 0x42, 0x36, 0x82, 0xa6, 0x1d, 0x32, 0x67, 0x69, 0x74, 0x68, 0x75, 0x62, + 0x6f, 0x74, 0x6f, 0x1a, 0x1c, 0x6e, 0x65, 0x74, 0x2f, 0x63, 0x6f, 0x64, 0x65, 0x67, 0x65, 0x6e, + 0x5f, 0x65, 0x78, 0x74, 0x65, 0x6e, 0x73, 0x69, 0x6f, 0x6e, 0x73, 0x2e, 0x70, 0x72, 0x6f, 0x74, + 0x6f, 0x22, 0xa2, 0x04, 0x0a, 0x07, 0x4d, 0x65, 0x73, 0x73, 0x61, 0x67, 0x65, 0x12, 0x57, 0x0a, + 0x0b, 0x64, 0x65, 0x73, 0x74, 0x5f, 0x6d, 0x6f, 0x64, 0x75, 0x6c, 0x65, 0x18, 0x01, 0x20, 0x01, + 0x28, 0x09, 0x42, 0x36, 0x82, 0xa6, 0x1d, 0x32, 0x67, 0x69, 0x74, 0x68, 0x75, 0x62, 0x2e, 0x63, + 0x6f, 0x6d, 0x2f, 0x66, 0x69, 0x6c, 0x65, 0x63, 0x6f, 0x69, 0x6e, 0x2d, 0x70, 0x72, 0x6f, 0x6a, + 0x65, 0x63, 0x74, 0x2f, 0x6d, 0x69, 0x72, 0x2f, 0x70, 0x6b, 0x67, 0x2f, 0x74, 0x79, 0x70, 0x65, + 0x73, 0x2e, 0x4d, 0x6f, 0x64, 0x75, 0x6c, 0x65, 0x49, 0x44, 0x52, 0x0a, 0x64, 0x65, 0x73, 0x74, + 0x4d, 0x6f, 0x64, 0x75, 0x6c, 0x65, 0x12, 0x25, 0x0a, 0x03, 0x69, 0x73, 0x73, 0x18, 0x02, 0x20, + 0x01, 0x28, 0x0b, 0x32, 0x11, 0x2e, 0x69, 0x73, 0x73, 0x70, 0x62, 0x2e, 0x49, 0x53, 0x53, 0x4d, + 0x65, 0x73, 0x73, 0x61, 0x67, 0x65, 0x48, 0x00, 0x52, 0x03, 0x69, 0x73, 0x73, 0x12, 0x22, 0x0a, + 0x03, 0x62, 0x63, 0x62, 0x18, 0x03, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x0e, 0x2e, 0x62, 0x63, 0x62, + 0x70, 0x62, 0x2e, 0x4d, 0x65, 0x73, 0x73, 0x61, 0x67, 0x65, 0x48, 0x00, 0x52, 0x03, 0x62, 0x63, + 0x62, 0x12, 0x4e, 0x0a, 0x12, 0x6d, 0x75, 0x6c, 0x74, 0x69, 0x73, 0x69, 0x67, 0x5f, 0x63, 0x6f, + 0x6c, 0x6c, 0x65, 0x63, 0x74, 0x6f, 0x72, 0x18, 0x04, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x1d, 0x2e, + 0x61, 0x76, 0x61, 0x69, 0x6c, 0x61, 0x62, 0x69, 0x6c, 0x69, 0x74, 0x79, 0x70, 0x62, 0x2e, 0x6d, + 0x73, 0x63, 0x70, 0x62, 0x2e, 0x4d, 0x65, 0x73, 0x73, 0x61, 0x67, 0x65, 0x48, 0x00, 0x52, 0x11, + 0x6d, 0x75, 0x6c, 0x74, 0x69, 0x73, 0x69, 0x67, 0x43, 0x6f, 0x6c, 0x6c, 0x65, 0x63, 0x74, 0x6f, + 0x72, 0x12, 0x31, 0x0a, 0x08, 0x70, 0x69, 0x6e, 0x67, 0x70, 0x6f, 0x6e, 0x67, 0x18, 0x05, 0x20, + 0x01, 0x28, 0x0b, 0x32, 0x13, 0x2e, 0x70, 0x69, 0x6e, 0x67, 0x70, 0x6f, 0x6e, 0x67, 0x70, 0x62, + 0x2e, 0x4d, 0x65, 0x73, 0x73, 0x61, 0x67, 0x65, 0x48, 0x00, 0x52, 0x08, 0x70, 0x69, 0x6e, 0x67, + 0x70, 0x6f, 0x6e, 0x67, 0x12, 0x37, 0x0a, 0x0a, 0x63, 0x68, 0x65, 0x63, 0x6b, 0x70, 0x6f, 0x69, + 0x6e, 0x74, 0x18, 0x06, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x15, 0x2e, 0x63, 0x68, 0x65, 0x63, 0x6b, + 0x70, 0x6f, 0x69, 0x6e, 0x74, 0x70, 0x62, 0x2e, 0x4d, 0x65, 0x73, 0x73, 0x61, 0x67, 0x65, 0x48, + 0x00, 0x52, 0x0a, 0x63, 0x68, 0x65, 0x63, 0x6b, 0x70, 0x6f, 0x69, 0x6e, 0x74, 0x12, 0x2e, 0x0a, + 0x07, 0x6f, 0x72, 0x64, 0x65, 0x72, 0x65, 0x72, 0x18, 0x07, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x12, + 0x2e, 0x6f, 0x72, 0x64, 0x65, 0x72, 0x65, 0x72, 0x70, 0x62, 0x2e, 0x4d, 0x65, 0x73, 0x73, 0x61, + 0x67, 0x65, 0x48, 0x00, 0x52, 0x07, 0x6f, 0x72, 0x64, 0x65, 0x72, 0x65, 0x72, 0x12, 0x34, 0x0a, + 0x09, 0x62, 0x72, 0x6f, 0x61, 0x64, 0x63, 0x61, 0x73, 0x74, 0x18, 0x08, 0x20, 0x01, 0x28, 0x0b, + 0x32, 0x14, 0x2e, 0x62, 0x72, 0x6f, 0x61, 0x64, 0x63, 0x61, 0x73, 0x74, 0x70, 0x62, 0x2e, 0x4d, + 0x65, 0x73, 0x73, 0x61, 0x67, 0x65, 0x48, 0x00, 0x52, 0x09, 0x62, 0x72, 0x6f, 0x61, 0x64, 0x63, + 0x61, 0x73, 0x74, 0x12, 0x3d, 0x0a, 0x0c, 0x73, 0x79, 0x6e, 0x63, 0x68, 0x72, 0x6f, 0x6e, 0x69, + 0x7a, 0x65, 0x72, 0x18, 0x09, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x17, 0x2e, 0x73, 0x79, 0x6e, 0x63, + 0x68, 0x72, 0x6f, 0x6e, 0x69, 0x7a, 0x65, 0x72, 0x70, 0x62, 0x2e, 0x4d, 0x65, 0x73, 0x73, 0x61, + 0x67, 0x65, 0x48, 0x00, 0x52, 0x0c, 0x73, 0x79, 0x6e, 0x63, 0x68, 0x72, 0x6f, 0x6e, 0x69, 0x7a, + 0x65, 0x72, 0x3a, 0x04, 0xc0, 0xe4, 0x1d, 0x01, 0x42, 0x0c, 0x0a, 0x04, 0x74, 0x79, 0x70, 0x65, + 0x12, 0x04, 0xc8, 0xe4, 0x1d, 0x01, 0x42, 0x32, 0x5a, 0x30, 0x67, 0x69, 0x74, 0x68, 0x75, 0x62, 0x2e, 0x63, 0x6f, 0x6d, 0x2f, 0x66, 0x69, 0x6c, 0x65, 0x63, 0x6f, 0x69, 0x6e, 0x2d, 0x70, 0x72, - 0x6f, 0x6a, 0x65, 0x63, 0x74, 0x2f, 0x6d, 0x69, 0x72, 0x2f, 0x70, 0x6b, 0x67, 0x2f, 0x74, 0x79, - 0x70, 0x65, 0x73, 0x2e, 0x4d, 0x6f, 0x64, 0x75, 0x6c, 0x65, 0x49, 0x44, 0x52, 0x0a, 0x64, 0x65, - 0x73, 0x74, 0x4d, 0x6f, 0x64, 0x75, 0x6c, 0x65, 0x12, 0x25, 0x0a, 0x03, 0x69, 0x73, 0x73, 0x18, - 0x02, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x11, 0x2e, 0x69, 0x73, 0x73, 0x70, 0x62, 0x2e, 0x49, 0x53, - 0x53, 0x4d, 0x65, 0x73, 0x73, 0x61, 0x67, 0x65, 0x48, 0x00, 0x52, 0x03, 0x69, 0x73, 0x73, 0x12, - 0x22, 0x0a, 0x03, 0x62, 0x63, 0x62, 0x18, 0x03, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x0e, 0x2e, 0x62, - 0x63, 0x62, 0x70, 0x62, 0x2e, 0x4d, 0x65, 0x73, 0x73, 0x61, 0x67, 0x65, 0x48, 0x00, 0x52, 0x03, - 0x62, 0x63, 0x62, 0x12, 0x4e, 0x0a, 0x12, 0x6d, 0x75, 0x6c, 0x74, 0x69, 0x73, 0x69, 0x67, 0x5f, - 0x63, 0x6f, 0x6c, 0x6c, 0x65, 0x63, 0x74, 0x6f, 0x72, 0x18, 0x04, 0x20, 0x01, 0x28, 0x0b, 0x32, - 0x1d, 0x2e, 0x61, 0x76, 0x61, 0x69, 0x6c, 0x61, 0x62, 0x69, 0x6c, 0x69, 0x74, 0x79, 0x70, 0x62, - 0x2e, 0x6d, 0x73, 0x63, 0x70, 0x62, 0x2e, 0x4d, 0x65, 0x73, 0x73, 0x61, 0x67, 0x65, 0x48, 0x00, - 0x52, 0x11, 0x6d, 0x75, 0x6c, 0x74, 0x69, 0x73, 0x69, 0x67, 0x43, 0x6f, 0x6c, 0x6c, 0x65, 0x63, - 0x74, 0x6f, 0x72, 0x12, 0x31, 0x0a, 0x08, 0x70, 0x69, 0x6e, 0x67, 0x70, 0x6f, 0x6e, 0x67, 0x18, - 0x05, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x13, 0x2e, 0x70, 0x69, 0x6e, 0x67, 0x70, 0x6f, 0x6e, 0x67, - 0x70, 0x62, 0x2e, 0x4d, 0x65, 0x73, 0x73, 0x61, 0x67, 0x65, 0x48, 0x00, 0x52, 0x08, 0x70, 0x69, - 0x6e, 0x67, 0x70, 0x6f, 0x6e, 0x67, 0x12, 0x37, 0x0a, 0x0a, 0x63, 0x68, 0x65, 0x63, 0x6b, 0x70, - 0x6f, 0x69, 0x6e, 0x74, 0x18, 0x06, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x15, 0x2e, 0x63, 0x68, 0x65, - 0x63, 0x6b, 0x70, 0x6f, 0x69, 0x6e, 0x74, 0x70, 0x62, 0x2e, 0x4d, 0x65, 0x73, 0x73, 0x61, 0x67, - 0x65, 0x48, 0x00, 0x52, 0x0a, 0x63, 0x68, 0x65, 0x63, 0x6b, 0x70, 0x6f, 0x69, 0x6e, 0x74, 0x12, - 0x2e, 0x0a, 0x07, 0x6f, 0x72, 0x64, 0x65, 0x72, 0x65, 0x72, 0x18, 0x07, 0x20, 0x01, 0x28, 0x0b, - 0x32, 0x12, 0x2e, 0x6f, 0x72, 0x64, 0x65, 0x72, 0x65, 0x72, 0x70, 0x62, 0x2e, 0x4d, 0x65, 0x73, - 0x73, 0x61, 0x67, 0x65, 0x48, 0x00, 0x52, 0x07, 0x6f, 0x72, 0x64, 0x65, 0x72, 0x65, 0x72, 0x3a, - 0x04, 0xc0, 0xe4, 0x1d, 0x01, 0x42, 0x0c, 0x0a, 0x04, 0x74, 0x79, 0x70, 0x65, 0x12, 0x04, 0xc8, - 0xe4, 0x1d, 0x01, 0x42, 0x32, 0x5a, 0x30, 0x67, 0x69, 0x74, 0x68, 0x75, 0x62, 0x2e, 0x63, 0x6f, - 0x6d, 0x2f, 0x66, 0x69, 0x6c, 0x65, 0x63, 0x6f, 0x69, 0x6e, 0x2d, 0x70, 0x72, 0x6f, 0x6a, 0x65, - 0x63, 0x74, 0x2f, 0x6d, 0x69, 0x72, 0x2f, 0x70, 0x6b, 0x67, 0x2f, 0x70, 0x62, 0x2f, 0x6d, 0x65, - 0x73, 0x73, 0x61, 0x67, 0x65, 0x70, 0x62, 0x62, 0x06, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x33, + 0x6f, 0x6a, 0x65, 0x63, 0x74, 0x2f, 0x6d, 0x69, 0x72, 0x2f, 0x70, 0x6b, 0x67, 0x2f, 0x70, 0x62, + 0x2f, 0x6d, 0x65, 0x73, 0x73, 0x61, 0x67, 0x65, 0x70, 0x62, 0x62, 0x06, 0x70, 0x72, 0x6f, 0x74, + 0x6f, 0x33, } var ( @@ -243,13 +289,15 @@ func file_messagepb_messagepb_proto_rawDescGZIP() []byte { var file_messagepb_messagepb_proto_msgTypes = make([]protoimpl.MessageInfo, 1) var file_messagepb_messagepb_proto_goTypes = []interface{}{ - (*Message)(nil), // 0: messagepb.Message - (*isspb.ISSMessage)(nil), // 1: isspb.ISSMessage - (*bcbpb.Message)(nil), // 2: bcbpb.Message - (*mscpb.Message)(nil), // 3: availabilitypb.mscpb.Message - (*pingpongpb.Message)(nil), // 4: pingpongpb.Message - (*checkpointpb.Message)(nil), // 5: checkpointpb.Message - (*ordererpb.Message)(nil), // 6: ordererpb.Message + (*Message)(nil), // 0: messagepb.Message + (*isspb.ISSMessage)(nil), // 1: isspb.ISSMessage + (*bcbpb.Message)(nil), // 2: bcbpb.Message + (*mscpb.Message)(nil), // 3: availabilitypb.mscpb.Message + (*pingpongpb.Message)(nil), // 4: pingpongpb.Message + (*checkpointpb.Message)(nil), // 5: checkpointpb.Message + (*ordererpb.Message)(nil), // 6: ordererpb.Message + (*broadcastpb.Message)(nil), // 7: broadcastpb.Message + (*synchronizerpb.Message)(nil), // 8: synchronizerpb.Message } var file_messagepb_messagepb_proto_depIdxs = []int32{ 1, // 0: messagepb.Message.iss:type_name -> isspb.ISSMessage @@ -258,11 +306,13 @@ var file_messagepb_messagepb_proto_depIdxs = []int32{ 4, // 3: messagepb.Message.pingpong:type_name -> pingpongpb.Message 5, // 4: messagepb.Message.checkpoint:type_name -> checkpointpb.Message 6, // 5: messagepb.Message.orderer:type_name -> ordererpb.Message - 6, // [6:6] is the sub-list for method output_type - 6, // [6:6] is the sub-list for method input_type - 6, // [6:6] is the sub-list for extension type_name - 6, // [6:6] is the sub-list for extension extendee - 0, // [0:6] is the sub-list for field type_name + 7, // 6: messagepb.Message.broadcast:type_name -> broadcastpb.Message + 8, // 7: messagepb.Message.synchronizer:type_name -> synchronizerpb.Message + 8, // [8:8] is the sub-list for method output_type + 8, // [8:8] is the sub-list for method input_type + 8, // [8:8] is the sub-list for extension type_name + 8, // [8:8] is the sub-list for extension extendee + 0, // [0:8] is the sub-list for field type_name } func init() { file_messagepb_messagepb_proto_init() } @@ -291,6 +341,8 @@ func file_messagepb_messagepb_proto_init() { (*Message_Pingpong)(nil), (*Message_Checkpoint)(nil), (*Message_Orderer)(nil), + (*Message_Broadcast)(nil), + (*Message_Synchronizer)(nil), } type x struct{} out := protoimpl.TypeBuilder{ diff --git a/pkg/pb/messagepb/messagepb.pb.mir.go b/pkg/pb/messagepb/messagepb.pb.mir.go index 4a44aaad3..74be9d932 100644 --- a/pkg/pb/messagepb/messagepb.pb.mir.go +++ b/pkg/pb/messagepb/messagepb.pb.mir.go @@ -14,5 +14,7 @@ func (*Message) ReflectTypeOptions() []reflect.Type { reflect.TypeOf((*Message_Pingpong)(nil)), reflect.TypeOf((*Message_Checkpoint)(nil)), reflect.TypeOf((*Message_Orderer)(nil)), + reflect.TypeOf((*Message_Broadcast)(nil)), + reflect.TypeOf((*Message_Synchronizer)(nil)), } } diff --git a/pkg/pb/messagepb/oneof_interfaces.mir.go b/pkg/pb/messagepb/oneof_interfaces.mir.go index 9cd5cdcd6..182d68e0f 100644 --- a/pkg/pb/messagepb/oneof_interfaces.mir.go +++ b/pkg/pb/messagepb/oneof_interfaces.mir.go @@ -5,6 +5,8 @@ package messagepb import ( mscpb "github.com/filecoin-project/mir/pkg/pb/availabilitypb/mscpb" bcbpb "github.com/filecoin-project/mir/pkg/pb/bcbpb" + broadcastpb "github.com/filecoin-project/mir/pkg/pb/blockchainpb/broadcastpb" + synchronizerpb "github.com/filecoin-project/mir/pkg/pb/blockchainpb/synchronizerpb" checkpointpb "github.com/filecoin-project/mir/pkg/pb/checkpointpb" isspb "github.com/filecoin-project/mir/pkg/pb/isspb" ordererpb "github.com/filecoin-project/mir/pkg/pb/ordererpb" @@ -41,3 +43,11 @@ func (w *Message_Checkpoint) Unwrap() *checkpointpb.Message { func (w *Message_Orderer) Unwrap() *ordererpb.Message { return w.Orderer } + +func (w *Message_Broadcast) Unwrap() *broadcastpb.Message { + return w.Broadcast +} + +func (w *Message_Synchronizer) Unwrap() *synchronizerpb.Message { + return w.Synchronizer +} diff --git a/pkg/pb/messagepb/types/types.mir.go b/pkg/pb/messagepb/types/types.mir.go index 3d55bc14b..6497f709a 100644 --- a/pkg/pb/messagepb/types/types.mir.go +++ b/pkg/pb/messagepb/types/types.mir.go @@ -6,6 +6,8 @@ import ( mirreflect "github.com/filecoin-project/mir/codegen/mirreflect" types3 "github.com/filecoin-project/mir/pkg/pb/availabilitypb/mscpb/types" types2 "github.com/filecoin-project/mir/pkg/pb/bcbpb/types" + types7 "github.com/filecoin-project/mir/pkg/pb/blockchainpb/broadcastpb/types" + types8 "github.com/filecoin-project/mir/pkg/pb/blockchainpb/synchronizerpb/types" types5 "github.com/filecoin-project/mir/pkg/pb/checkpointpb/types" types1 "github.com/filecoin-project/mir/pkg/pb/isspb/types" messagepb "github.com/filecoin-project/mir/pkg/pb/messagepb" @@ -48,6 +50,10 @@ func Message_TypeFromPb(pb messagepb.Message_Type) Message_Type { return &Message_Checkpoint{Checkpoint: types5.MessageFromPb(pb.Checkpoint)} case *messagepb.Message_Orderer: return &Message_Orderer{Orderer: types6.MessageFromPb(pb.Orderer)} + case *messagepb.Message_Broadcast: + return &Message_Broadcast{Broadcast: types7.MessageFromPb(pb.Broadcast)} + case *messagepb.Message_Synchronizer: + return &Message_Synchronizer{Synchronizer: types8.MessageFromPb(pb.Synchronizer)} } return nil } @@ -196,6 +202,54 @@ func (*Message_Orderer) MirReflect() mirreflect.Type { return mirreflect.TypeImpl{PbType_: reflectutil.TypeOf[*messagepb.Message_Orderer]()} } +type Message_Broadcast struct { + Broadcast *types7.Message +} + +func (*Message_Broadcast) isMessage_Type() {} + +func (w *Message_Broadcast) Unwrap() *types7.Message { + return w.Broadcast +} + +func (w *Message_Broadcast) Pb() messagepb.Message_Type { + if w == nil { + return nil + } + if w.Broadcast == nil { + return &messagepb.Message_Broadcast{} + } + return &messagepb.Message_Broadcast{Broadcast: (w.Broadcast).Pb()} +} + +func (*Message_Broadcast) MirReflect() mirreflect.Type { + return mirreflect.TypeImpl{PbType_: reflectutil.TypeOf[*messagepb.Message_Broadcast]()} +} + +type Message_Synchronizer struct { + Synchronizer *types8.Message +} + +func (*Message_Synchronizer) isMessage_Type() {} + +func (w *Message_Synchronizer) Unwrap() *types8.Message { + return w.Synchronizer +} + +func (w *Message_Synchronizer) Pb() messagepb.Message_Type { + if w == nil { + return nil + } + if w.Synchronizer == nil { + return &messagepb.Message_Synchronizer{} + } + return &messagepb.Message_Synchronizer{Synchronizer: (w.Synchronizer).Pb()} +} + +func (*Message_Synchronizer) MirReflect() mirreflect.Type { + return mirreflect.TypeImpl{PbType_: reflectutil.TypeOf[*messagepb.Message_Synchronizer]()} +} + func MessageFromPb(pb *messagepb.Message) *Message { if pb == nil { return nil diff --git a/pkg/pb/mir/codegen_extensions.pb.go b/pkg/pb/mir/codegen_extensions.pb.go index 7e20985ec..bf200d1bf 100644 --- a/pkg/pb/mir/codegen_extensions.pb.go +++ b/pkg/pb/mir/codegen_extensions.pb.go @@ -1,7 +1,7 @@ // Code generated by protoc-gen-go. DO NOT EDIT. // versions: -// protoc-gen-go v1.25.0-devel -// protoc v3.14.0 +// protoc-gen-go v1.31.0 +// protoc v4.25.2 // source: mir/codegen_extensions.proto package mir diff --git a/pkg/pb/net/codegen_extensions.pb.go b/pkg/pb/net/codegen_extensions.pb.go index 8175c8679..962fb62fc 100644 --- a/pkg/pb/net/codegen_extensions.pb.go +++ b/pkg/pb/net/codegen_extensions.pb.go @@ -1,7 +1,7 @@ // Code generated by protoc-gen-go. DO NOT EDIT. // versions: -// protoc-gen-go v1.25.0-devel -// protoc v3.14.0 +// protoc-gen-go v1.31.0 +// protoc v4.25.2 // source: net/codegen_extensions.proto package net diff --git a/pkg/pb/ordererpb/ordererpb.pb.go b/pkg/pb/ordererpb/ordererpb.pb.go index 6be8f8e28..019a1b3a1 100644 --- a/pkg/pb/ordererpb/ordererpb.pb.go +++ b/pkg/pb/ordererpb/ordererpb.pb.go @@ -1,7 +1,7 @@ // Code generated by protoc-gen-go. DO NOT EDIT. // versions: -// protoc-gen-go v1.25.0-devel -// protoc v3.14.0 +// protoc-gen-go v1.31.0 +// protoc v4.25.2 // source: ordererpb/ordererpb.proto package ordererpb @@ -30,6 +30,7 @@ type Event struct { unknownFields protoimpl.UnknownFields // Types that are assignable to Type: + // // *Event_Pbft Type isEvent_Type `protobuf_oneof:"type"` } @@ -96,6 +97,7 @@ type Message struct { unknownFields protoimpl.UnknownFields // Types that are assignable to Type: + // // *Message_Pbft Type isMessage_Type `protobuf_oneof:"type"` } diff --git a/pkg/pb/ordererpb/pprepvalidatorpb/pprepvalidatorpb.pb.go b/pkg/pb/ordererpb/pprepvalidatorpb/pprepvalidatorpb.pb.go index 40f6d4855..98ca79826 100644 --- a/pkg/pb/ordererpb/pprepvalidatorpb/pprepvalidatorpb.pb.go +++ b/pkg/pb/ordererpb/pprepvalidatorpb/pprepvalidatorpb.pb.go @@ -1,7 +1,7 @@ // Code generated by protoc-gen-go. DO NOT EDIT. // versions: -// protoc-gen-go v1.25.0-devel -// protoc v3.14.0 +// protoc-gen-go v1.31.0 +// protoc v4.25.2 // source: ordererpb/pprepvalidatorpb/pprepvalidatorpb.proto package pprepvalidatorpb @@ -31,6 +31,7 @@ type Event struct { unknownFields protoimpl.UnknownFields // Types that are assignable to Type: + // // *Event_ValidatePreprepare // *Event_PreprepareValidated Type isEvent_Type `protobuf_oneof:"type"` @@ -222,6 +223,7 @@ type ValidatePreprepareOrigin struct { Module string `protobuf:"bytes,1,opt,name=module,proto3" json:"module,omitempty"` // Types that are assignable to Type: + // // *ValidatePreprepareOrigin_ContextStore // *ValidatePreprepareOrigin_Dsl Type isValidatePreprepareOrigin_Type `protobuf_oneof:"type"` diff --git a/pkg/pb/pbftpb/pbftpb.pb.go b/pkg/pb/pbftpb/pbftpb.pb.go index 62b472a49..5596be21b 100644 --- a/pkg/pb/pbftpb/pbftpb.pb.go +++ b/pkg/pb/pbftpb/pbftpb.pb.go @@ -1,7 +1,7 @@ // Code generated by protoc-gen-go. DO NOT EDIT. // versions: -// protoc-gen-go v1.25.0-devel -// protoc v3.14.0 +// protoc-gen-go v1.31.0 +// protoc v4.25.2 // source: pbftpb/pbftpb.proto package pbftpb @@ -28,6 +28,7 @@ type Message struct { unknownFields protoimpl.UnknownFields // Types that are assignable to Type: + // // *Message_Preprepare // *Message_Prepare // *Message_Commit @@ -994,6 +995,7 @@ type Event struct { unknownFields protoimpl.UnknownFields // Types that are assignable to Type: + // // *Event_ProposeTimeout // *Event_ViewChangeSnTimeout // *Event_ViewChangeSegTimeout diff --git a/pkg/pb/pingpongpb/pingpongpb.pb.go b/pkg/pb/pingpongpb/pingpongpb.pb.go index 2f88aec7c..fb7de322a 100644 --- a/pkg/pb/pingpongpb/pingpongpb.pb.go +++ b/pkg/pb/pingpongpb/pingpongpb.pb.go @@ -1,7 +1,7 @@ // Code generated by protoc-gen-go. DO NOT EDIT. // versions: -// protoc-gen-go v1.25.0-devel -// protoc v3.14.0 +// protoc-gen-go v1.31.0 +// protoc v4.25.2 // source: pingpongpb/pingpongpb.proto package pingpongpb @@ -28,6 +28,7 @@ type Event struct { unknownFields protoimpl.UnknownFields // Types that are assignable to Type: + // // *Event_PingTime Type isEvent_Type `protobuf_oneof:"type"` } @@ -132,6 +133,7 @@ type Message struct { unknownFields protoimpl.UnknownFields // Types that are assignable to Type: + // // *Message_Ping // *Message_Pong Type isMessage_Type `protobuf_oneof:"type"` diff --git a/pkg/pb/recordingpb/recordingpb.pb.go b/pkg/pb/recordingpb/recordingpb.pb.go index 2585b98fa..044bf710d 100644 --- a/pkg/pb/recordingpb/recordingpb.pb.go +++ b/pkg/pb/recordingpb/recordingpb.pb.go @@ -5,8 +5,8 @@ // Code generated by protoc-gen-go. DO NOT EDIT. // versions: -// protoc-gen-go v1.25.0-devel -// protoc v3.14.0 +// protoc-gen-go v1.31.0 +// protoc v4.25.2 // source: recordingpb/recordingpb.proto package recordingpb diff --git a/pkg/pb/testerpb/testerpb.pb.go b/pkg/pb/testerpb/testerpb.pb.go index 7dedd89c7..329766e11 100644 --- a/pkg/pb/testerpb/testerpb.pb.go +++ b/pkg/pb/testerpb/testerpb.pb.go @@ -1,7 +1,7 @@ // Code generated by protoc-gen-go. DO NOT EDIT. // versions: -// protoc-gen-go v1.25.0-devel -// protoc v3.14.0 +// protoc-gen-go v1.31.0 +// protoc v4.25.2 // source: testerpb/testerpb.proto package testerpb diff --git a/pkg/pb/threshcryptopb/threshcryptopb.pb.go b/pkg/pb/threshcryptopb/threshcryptopb.pb.go index 739438330..914e1e242 100644 --- a/pkg/pb/threshcryptopb/threshcryptopb.pb.go +++ b/pkg/pb/threshcryptopb/threshcryptopb.pb.go @@ -1,7 +1,7 @@ // Code generated by protoc-gen-go. DO NOT EDIT. // versions: -// protoc-gen-go v1.25.0-devel -// protoc v3.14.0 +// protoc-gen-go v1.31.0 +// protoc v4.25.2 // source: threshcryptopb/threshcryptopb.proto package threshcryptopb @@ -29,6 +29,7 @@ type Event struct { unknownFields protoimpl.UnknownFields // Types that are assignable to Type: + // // *Event_SignShare // *Event_SignShareResult // *Event_VerifyShare @@ -304,6 +305,7 @@ type SignShareOrigin struct { Module string `protobuf:"bytes,1,opt,name=module,proto3" json:"module,omitempty"` // Types that are assignable to Type: + // // *SignShareOrigin_ContextStore // *SignShareOrigin_Dsl Type isSignShareOrigin_Type `protobuf_oneof:"type"` @@ -526,6 +528,7 @@ type VerifyShareOrigin struct { Module string `protobuf:"bytes,1,opt,name=module,proto3" json:"module,omitempty"` // Types that are assignable to Type: + // // *VerifyShareOrigin_ContextStore // *VerifyShareOrigin_Dsl Type isVerifyShareOrigin_Type `protobuf_oneof:"type"` @@ -740,6 +743,7 @@ type VerifyFullOrigin struct { Module string `protobuf:"bytes,1,opt,name=module,proto3" json:"module,omitempty"` // Types that are assignable to Type: + // // *VerifyFullOrigin_ContextStore // *VerifyFullOrigin_Dsl Type isVerifyFullOrigin_Type `protobuf_oneof:"type"` @@ -962,6 +966,7 @@ type RecoverOrigin struct { Module string `protobuf:"bytes,1,opt,name=module,proto3" json:"module,omitempty"` // Types that are assignable to Type: + // // *RecoverOrigin_ContextStore // *RecoverOrigin_Dsl Type isRecoverOrigin_Type `protobuf_oneof:"type"` diff --git a/pkg/pb/transportpb/transportpb.pb.go b/pkg/pb/transportpb/transportpb.pb.go index ef42d1f2b..417771918 100644 --- a/pkg/pb/transportpb/transportpb.pb.go +++ b/pkg/pb/transportpb/transportpb.pb.go @@ -1,7 +1,7 @@ // Code generated by protoc-gen-go. DO NOT EDIT. // versions: -// protoc-gen-go v1.25.0-devel -// protoc v3.14.0 +// protoc-gen-go v1.31.0 +// protoc v4.25.2 // source: transportpb/transportpb.proto package transportpb @@ -28,6 +28,7 @@ type Event struct { unknownFields protoimpl.UnknownFields // Types that are assignable to Type: + // // *Event_SendMessage // *Event_MessageReceived Type isEvent_Type `protobuf_oneof:"Type"` diff --git a/pkg/pb/trantorpb/trantorpb.pb.go b/pkg/pb/trantorpb/trantorpb.pb.go index ad414366b..21b20e504 100644 --- a/pkg/pb/trantorpb/trantorpb.pb.go +++ b/pkg/pb/trantorpb/trantorpb.pb.go @@ -1,7 +1,7 @@ // Code generated by protoc-gen-go. DO NOT EDIT. // versions: -// protoc-gen-go v1.25.0-devel -// protoc v3.14.0 +// protoc-gen-go v1.31.0 +// protoc v4.25.2 // source: trantorpb/trantorpb.proto package trantorpb diff --git a/pkg/transactionreceiver/transactionreceiver.pb.go b/pkg/transactionreceiver/transactionreceiver.pb.go index c67b5b369..04dd3d8ec 100644 --- a/pkg/transactionreceiver/transactionreceiver.pb.go +++ b/pkg/transactionreceiver/transactionreceiver.pb.go @@ -5,8 +5,8 @@ // Code generated by protoc-gen-go. DO NOT EDIT. // versions: -// protoc-gen-go v1.25.0-devel -// protoc v3.14.0 +// protoc-gen-go v1.31.0 +// protoc v4.25.2 // source: transactionreceiver/transactionreceiver.proto package transactionreceiver diff --git a/pkg/transactionreceiver/transactionreceiver_grpc.pb.go b/pkg/transactionreceiver/transactionreceiver_grpc.pb.go index c088751b1..5e06ef7a6 100644 --- a/pkg/transactionreceiver/transactionreceiver_grpc.pb.go +++ b/pkg/transactionreceiver/transactionreceiver_grpc.pb.go @@ -1,4 +1,13 @@ +// +//Copyright IBM Corp. All Rights Reserved. +// +//SPDX-License-Identifier: Apache-2.0 + // Code generated by protoc-gen-go-grpc. DO NOT EDIT. +// versions: +// - protoc-gen-go-grpc v1.3.0 +// - protoc v4.25.2 +// source: transactionreceiver/transactionreceiver.proto package transactionreceiver @@ -15,6 +24,10 @@ import ( // Requires gRPC-Go v1.32.0 or later. const _ = grpc.SupportPackageIsVersion7 +const ( + TransactionReceiver_Listen_FullMethodName = "/receiver.TransactionReceiver/Listen" +) + // TransactionReceiverClient is the client API for TransactionReceiver service. // // For semantics around ctx use and closing/ending streaming RPCs, please refer to https://pkg.go.dev/google.golang.org/grpc/?tab=doc#ClientConn.NewStream. @@ -31,7 +44,7 @@ func NewTransactionReceiverClient(cc grpc.ClientConnInterface) TransactionReceiv } func (c *transactionReceiverClient) Listen(ctx context.Context, opts ...grpc.CallOption) (TransactionReceiver_ListenClient, error) { - stream, err := c.cc.NewStream(ctx, &TransactionReceiver_ServiceDesc.Streams[0], "/receiver.TransactionReceiver/Listen", opts...) + stream, err := c.cc.NewStream(ctx, &TransactionReceiver_ServiceDesc.Streams[0], TransactionReceiver_Listen_FullMethodName, opts...) if err != nil { return nil, err } diff --git a/protos/blockchainpb/applicationpb/applicationpb.proto b/protos/blockchainpb/applicationpb/applicationpb.proto new file mode 100644 index 000000000..b83368cc7 --- /dev/null +++ b/protos/blockchainpb/applicationpb/applicationpb.proto @@ -0,0 +1,71 @@ +syntax = "proto3"; + +package applicationpb; + +option go_package = "github.com/filecoin-project/mir/pkg/pb/blockchainpb/applicationpb"; + +import "mir/codegen_extensions.proto"; +import "blockchainpb/payloadpb/payloadpb.proto"; +import "blockchainpb/statepb/statepb.proto"; +import "blockchainpb/blockchainpb.proto"; + +message Event { + option (mir.event_class) = true; + + oneof type { + option (mir.event_type) = true; + + VerifyBlocksRequest verify_block_request = 1; + VerifyBlocksResponse verify_block_response = 2; + PayloadRequest payload_request = 3; + PayloadResponse payload_response = 4; + HeadChange head_change = 5; + + // Message input + MessageInput message_input = 10; + } +} + +message VerifyBlocksRequest { + option (mir.event) = true; + + statepb.State checkpoint_state = 1; + repeated blockchainpb.Block chain_checkpoint_to_start = 2; + repeated blockchainpb.Block chain_to_verify = 3; +} + +message VerifyBlocksResponse { + option (mir.event) = true; + + repeated blockchainpb.Block verified_blocks = 1; +} + +message HeadChange { + option (mir.event) = true; + + repeated blockchainpb.Block removed_chain = 1; + repeated blockchainpb.Block added_chain = 2; + repeated blockchainpb.Block checkpoint_to_fork_root = 3; + statepb.State checkpoint_state = 4; +} + +message PayloadRequest { + option (mir.event) = true; + + uint64 head_id = 1; +} + +message PayloadResponse { + option (mir.event) = true; + + uint64 head_id = 1; + payloadpb.Payload payload = 2; +} + +// Message input events + +message MessageInput { + option (mir.event) = true; + + string text = 1; +} \ No newline at end of file diff --git a/protos/blockchainpb/bcmpb/bcmpb.proto b/protos/blockchainpb/bcmpb/bcmpb.proto new file mode 100644 index 000000000..e7ec2f67f --- /dev/null +++ b/protos/blockchainpb/bcmpb/bcmpb.proto @@ -0,0 +1,86 @@ +syntax = "proto3"; + +package bcmpb; + +option go_package = "github.com/filecoin-project/mir/pkg/pb/blockchainpb/bcmpb"; + +import "blockchainpb/blockchainpb.proto"; +import "blockchainpb/statepb/statepb.proto"; + +import "mir/codegen_extensions.proto"; + +message Event { + option (mir.event_class) = true; + + oneof type { + option (mir.event_type) = true; + + NewBlock new_block = 1; + NewChain new_chain = 2; + + GetChainRequest get_chain_request = 5; + GetChainResponse get_chain_response = 6; + RegisterCheckpoint register_checkpoint = 7; + GetChainToHeadRequest get_chain_to_head_request = 8; + GetChainToHeadResponse get_chain_to_head_response = 9; + + InitBlockchain init_blockchain = 100; + } +} + +message NewBlock { + option (mir.event) = true; + + blockchainpb.Block block = 1; +} + +message NewChain { + option (mir.event) = true; + + // chain segment ordered blocks[0]<-blocks[1]<-blocks[2]... + repeated blockchainpb.Block blocks = 1; +} + +message GetChainRequest { + option (mir.event) = true; + + string request_id = 1; + string source_module = 2 [(mir.type) = "github.com/filecoin-project/mir/pkg/types.ModuleID"]; + + uint64 end_block_id = 3; + repeated uint64 source_block_ids = 4; +} + +message GetChainResponse { + option (mir.event) = true; + + string request_id = 1; + bool success = 2; + repeated blockchainpb.Block chain = 3; // sorted from oldest to youngest +} + +message GetChainToHeadRequest { + option (mir.event) = true; + string source_module = 1 [(mir.type) = "github.com/filecoin-project/mir/pkg/types.ModuleID"]; + +} + +message GetChainToHeadResponse { + option (mir.event) = true; + + repeated blockchainpb.Block chain = 1; // sorted from oldest to youngest + statepb.State checkpointState = 2; +} + +message RegisterCheckpoint { + option (mir.event) = true; + + uint64 block_id = 1; + statepb.State state = 2; +} + +message InitBlockchain { + option (mir.event) = true; + + statepb.State initial_state = 1; +} diff --git a/protos/blockchainpb/blockchainpb.proto b/protos/blockchainpb/blockchainpb.proto new file mode 100644 index 000000000..cb73faaca --- /dev/null +++ b/protos/blockchainpb/blockchainpb.proto @@ -0,0 +1,20 @@ +syntax = "proto3"; + +package blockchainpb; + +option go_package = "github.com/filecoin-project/mir/pkg/pb/blockchainpb"; + +import "mir/codegen_extensions.proto"; +import "blockchainpb/payloadpb/payloadpb.proto"; +import "google/protobuf/timestamp.proto"; + +message Block { + option (mir.struct) = true; + + uint64 block_id = 1; + uint64 previous_block_id = 2; + payloadpb.Payload payload = 3; + + google.protobuf.Timestamp timestamp = 4; + string miner_id = 5 [(mir.type) = "github.com/filecoin-project/mir/pkg/types.NodeID"]; +} \ No newline at end of file diff --git a/protos/blockchainpb/broadcastpb/broadcastpb.proto b/protos/blockchainpb/broadcastpb/broadcastpb.proto new file mode 100644 index 000000000..e73651120 --- /dev/null +++ b/protos/blockchainpb/broadcastpb/broadcastpb.proto @@ -0,0 +1,42 @@ +syntax = "proto3"; + +package broadcastpb; + +option go_package = "github.com/filecoin-project/mir/pkg/pb/blockchainpb/broadcastpb"; + +import "blockchainpb/blockchainpb.proto"; + +import "mir/codegen_extensions.proto"; +import "net/codegen_extensions.proto"; + +message Event { + option (mir.event_class) = true; + + oneof type { + option (mir.event_type) = true; + + NewBlock new_block = 1; + } +} + +message NewBlock { + option (mir.event) = true; + + blockchainpb.Block block = 1; +} + +message Message { + option (net.message_class) = true; + + oneof type { + option (net.message_type) = true; + + NewBlockMessage new_block = 1; + } +} + +message NewBlockMessage { + option (net.message) = true; + + blockchainpb.Block block = 1; +} diff --git a/protos/blockchainpb/interceptorpb/interceptorpb.proto b/protos/blockchainpb/interceptorpb/interceptorpb.proto new file mode 100644 index 000000000..e5f963c83 --- /dev/null +++ b/protos/blockchainpb/interceptorpb/interceptorpb.proto @@ -0,0 +1,33 @@ +syntax = "proto3"; + +package interceptorpb; + +option go_package = "github.com/filecoin-project/mir/pkg/pb/blockchainpb/interceptorpb"; + +import "blockchainpb/blockchainpb.proto"; +import "blockchainpb/statepb/statepb.proto"; +import "mir/codegen_extensions.proto"; + +message Event { + option (mir.event_class) = true; + + oneof type { + option (mir.event_type) = true; + + TreeUpdate tree_update = 1; + StateUpdate state_update = 2; + } +} + +message TreeUpdate { + option (mir.event) = true; + + repeated blockchainpb.Block blocks = 1; + uint64 head_id = 2; +} + +message StateUpdate { + option (mir.event) = true; + + statepb.State state = 1; +} \ No newline at end of file diff --git a/protos/blockchainpb/minerpb/minerpb.proto b/protos/blockchainpb/minerpb/minerpb.proto new file mode 100644 index 000000000..c72dc8edd --- /dev/null +++ b/protos/blockchainpb/minerpb/minerpb.proto @@ -0,0 +1,32 @@ +syntax = "proto3"; + +package minerpb; + +option go_package = "github.com/filecoin-project/mir/pkg/pb/blockchainpb/minerpb"; + +import "mir/codegen_extensions.proto"; +import "blockchainpb/payloadpb/payloadpb.proto"; + +message Event { + option (mir.event_class) = true; + + oneof type { + option (mir.event_type) = true; + + BlockRequest block_request = 1; + NewHead new_head = 2; + } +} + +message BlockRequest { + option (mir.event) = true; + + uint64 head_id = 1; + payloadpb.Payload payload = 2; +} + +message NewHead { + option (mir.event) = true; + + uint64 head_id = 1; +} \ No newline at end of file diff --git a/protos/blockchainpb/payloadpb/payloadpb.proto b/protos/blockchainpb/payloadpb/payloadpb.proto new file mode 100644 index 000000000..655249195 --- /dev/null +++ b/protos/blockchainpb/payloadpb/payloadpb.proto @@ -0,0 +1,18 @@ +syntax = "proto3"; + +package payloadpb; + +option go_package = "github.com/filecoin-project/mir/pkg/pb/blockchainpb/payloadpb"; + +import "mir/codegen_extensions.proto"; +import "google/protobuf/timestamp.proto"; + + +message Payload { + option (mir.struct) = true; + + // application specific payload + string message = 1; + google.protobuf.Timestamp timestamp = 2; + string sender = 3 [(mir.type) = "github.com/filecoin-project/mir/pkg/types.NodeID"]; +} \ No newline at end of file diff --git a/protos/blockchainpb/statepb/statepb.proto b/protos/blockchainpb/statepb/statepb.proto new file mode 100644 index 000000000..bde7fb3f8 --- /dev/null +++ b/protos/blockchainpb/statepb/statepb.proto @@ -0,0 +1,24 @@ +syntax = "proto3"; + +package statepb; + +option go_package = "github.com/filecoin-project/mir/pkg/pb/blockchainpb/statepb"; + +import "blockchainpb/payloadpb/payloadpb.proto"; +import "mir/codegen_extensions.proto"; +import "google/protobuf/timestamp.proto"; + +message State { + option (mir.struct) = true; + + // application specific state + repeated payloadpb.Payload history = 1; + repeated LastSentTimestamp last_sent_timestamps = 2; +} + +message LastSentTimestamp { + option (mir.struct) = true; + + string node_id = 1 [(mir.type) = "github.com/filecoin-project/mir/pkg/types.NodeID"]; + google.protobuf.Timestamp timestamp = 2; +} \ No newline at end of file diff --git a/protos/blockchainpb/synchronizerpb/synchronizerpb.proto b/protos/blockchainpb/synchronizerpb/synchronizerpb.proto new file mode 100644 index 000000000..5812bd0c8 --- /dev/null +++ b/protos/blockchainpb/synchronizerpb/synchronizerpb.proto @@ -0,0 +1,55 @@ +syntax = "proto3"; + +package synchronizerpb; + +option go_package = "github.com/filecoin-project/mir/pkg/pb/blockchainpb/synchronizerpb"; + +import "blockchainpb/blockchainpb.proto"; + +import "mir/codegen_extensions.proto"; +import "net/codegen_extensions.proto"; + +message Event { + option (mir.event_class) = true; + + oneof type { + option (mir.event_type) = true; + + SyncRequest sync_request = 1; + } +} + +message SyncRequest { + option (mir.event) = true; + + blockchainpb.Block orphan_block = 1; + repeated uint64 leave_node_ids = 2; +} + +message Message { + option (net.message_class) = true; + + oneof type { + option (net.message_type) = true; + + ChainRequest chain_request = 1; + ChainResponse chain_response = 2; + } +} + +message ChainRequest { + option (net.message) = true; + + string request_id = 1; + uint64 block_id = 2; + repeated uint64 leave_node_ids = 3; +} + +message ChainResponse { + option (net.message) = true; + + string request_id = 1; + bool found = 2; + repeated blockchainpb.Block chain = 3; // possibly undefined (proto3 spec no-longer supports optional/required...) + +} diff --git a/protos/eventpb/eventpb.proto b/protos/eventpb/eventpb.proto index 7e71e0fdf..6706544f4 100644 --- a/protos/eventpb/eventpb.proto +++ b/protos/eventpb/eventpb.proto @@ -23,6 +23,12 @@ import "hasherpb/hasherpb.proto"; import "cryptopb/cryptopb.proto"; import "transportpb/transportpb.proto"; import "testerpb/testerpb.proto"; +import "blockchainpb/bcmpb/bcmpb.proto"; +import "blockchainpb/minerpb/minerpb.proto"; +import "blockchainpb/broadcastpb/broadcastpb.proto"; +import "blockchainpb/synchronizerpb/synchronizerpb.proto"; +import "blockchainpb/applicationpb/applicationpb.proto"; +import "blockchainpb/interceptorpb/interceptorpb.proto"; import "mir/codegen_extensions.proto"; @@ -63,6 +69,16 @@ message Event { // Events for code samples pingpongpb.Event ping_pong = 200; + // Events for blockchain + bcmpb.Event bcm = 201; + minerpb.Event miner = 202; + broadcastpb.Event broadcast = 203; + synchronizerpb.Event synchronizer = 204; + applicationpb.Event application = 205; + + // Events for blockchain interceptor + interceptorpb.Event bcinterceptor = 210; + // for unit-tests google.protobuf.StringValue testingString = 301; google.protobuf.UInt64Value testingUint = 302; diff --git a/protos/generate.go b/protos/generate.go index b16ff152b..0edea1d97 100644 --- a/protos/generate.go +++ b/protos/generate.go @@ -44,6 +44,15 @@ package protos //go:generate protoc-events apppb/apppb.proto //go:generate protoc-events transportpb/transportpb.proto //go:generate protoc-events testerpb/testerpb.proto +//go:generate protoc-events blockchainpb/blockchainpb.proto +//go:generate protoc-events blockchainpb/bcmpb/bcmpb.proto +//go:generate protoc-events blockchainpb/minerpb/minerpb.proto +//go:generate protoc-events blockchainpb/broadcastpb/broadcastpb.proto +//go:generate protoc-events blockchainpb/synchronizerpb/synchronizerpb.proto +//go:generate protoc-events blockchainpb/applicationpb/applicationpb.proto +//go:generate protoc-events blockchainpb/payloadpb/payloadpb.proto +//go:generate protoc-events blockchainpb/statepb/statepb.proto +//go:generate protoc-events blockchainpb/interceptorpb/interceptorpb.proto // Build the custom code generators. //go:generate go build -o ../codegen/generators/mir-std-gen/mir-std-gen.bin ../codegen/generators/mir-std-gen @@ -75,6 +84,15 @@ package protos //go:generate std-gen "github.com/filecoin-project/mir/pkg/pb/transportpb" //go:generate std-gen "github.com/filecoin-project/mir/pkg/pb/testerpb" //go:generate std-gen "github.com/filecoin-project/mir/pkg/pb/pingpongpb" +//go:generate std-gen "github.com/filecoin-project/mir/pkg/pb/blockchainpb" +//go:generate std-gen "github.com/filecoin-project/mir/pkg/pb/blockchainpb/bcmpb" +//go:generate std-gen "github.com/filecoin-project/mir/pkg/pb/blockchainpb/minerpb" +//go:generate std-gen "github.com/filecoin-project/mir/pkg/pb/blockchainpb/broadcastpb" +//go:generate std-gen "github.com/filecoin-project/mir/pkg/pb/blockchainpb/synchronizerpb" +//go:generate std-gen "github.com/filecoin-project/mir/pkg/pb/blockchainpb/payloadpb" +//go:generate std-gen "github.com/filecoin-project/mir/pkg/pb/blockchainpb/statepb" +//go:generate std-gen "github.com/filecoin-project/mir/pkg/pb/blockchainpb/applicationpb" +//go:generate std-gen "github.com/filecoin-project/mir/pkg/pb/blockchainpb/interceptorpb" // Generate other things. //go:generate protoc --go_out=../pkg/ --go_opt=paths=source_relative --go-grpc_out=../pkg/ --go-grpc_opt=paths=source_relative transactionreceiver/transactionreceiver.proto diff --git a/protos/messagepb/messagepb.proto b/protos/messagepb/messagepb.proto index b440113e6..82873e8e8 100644 --- a/protos/messagepb/messagepb.proto +++ b/protos/messagepb/messagepb.proto @@ -16,6 +16,8 @@ import "availabilitypb/mscpb/mscpb.proto"; import "pingpongpb/pingpongpb.proto"; import "checkpointpb/checkpointpb.proto"; import "ordererpb/ordererpb.proto"; +import "blockchainpb/broadcastpb/broadcastpb.proto"; +import "blockchainpb/synchronizerpb/synchronizerpb.proto"; import "mir/codegen_extensions.proto"; import "net/codegen_extensions.proto"; @@ -34,5 +36,10 @@ message Message { pingpongpb.Message pingpong = 5; checkpointpb.Message checkpoint = 6; ordererpb.Message orderer = 7; + + // Messages for blockchain + broadcastpb.Message broadcast = 8; + synchronizerpb.Message synchronizer = 9; + } } diff --git a/protos/proto_converter_tmp_3294919200/generator.go b/protos/proto_converter_tmp_3294919200/generator.go new file mode 100644 index 000000000..ee8d5ba94 --- /dev/null +++ b/protos/proto_converter_tmp_3294919200/generator.go @@ -0,0 +1,50 @@ + +package main + +import ( + "log" + "os" + "reflect" + + generator_ "github.com/filecoin-project/mir/codegen/generators/mir-std-gen/generator" + pkg_ "github.com/filecoin-project/mir/pkg/pb/hasherpb" +) + +func main() { + var generator generator_.CombinedGenerator + err := generator.Run( + []reflect.Type{ + + reflect.TypeOf((*pkg_.Event)(nil)).Elem(), + + reflect.TypeOf((*pkg_.Event_Request)(nil)).Elem(), + + reflect.TypeOf((*pkg_.Event_Result)(nil)).Elem(), + + reflect.TypeOf((*pkg_.Event_RequestOne)(nil)).Elem(), + + reflect.TypeOf((*pkg_.Event_ResultOne)(nil)).Elem(), + + reflect.TypeOf((*pkg_.Request)(nil)).Elem(), + + reflect.TypeOf((*pkg_.Result)(nil)).Elem(), + + reflect.TypeOf((*pkg_.RequestOne)(nil)).Elem(), + + reflect.TypeOf((*pkg_.ResultOne)(nil)).Elem(), + + reflect.TypeOf((*pkg_.HashOrigin)(nil)).Elem(), + + reflect.TypeOf((*pkg_.HashOrigin_ContextStore)(nil)).Elem(), + + reflect.TypeOf((*pkg_.HashOrigin_Dsl)(nil)).Elem(), + + reflect.TypeOf((*pkg_.HashData)(nil)).Elem(), + + }) + + if err != nil { + log.Printf("Error: %v\n", err) + os.Exit(2) + } +} diff --git a/protos/proto_converter_tmp_83059537/generator.go b/protos/proto_converter_tmp_83059537/generator.go new file mode 100644 index 000000000..3223d160b --- /dev/null +++ b/protos/proto_converter_tmp_83059537/generator.go @@ -0,0 +1,40 @@ + +package main + +import ( + "log" + "os" + "reflect" + + generator_ "github.com/filecoin-project/mir/codegen/generators/mir-std-gen/generator" + pkg_ "github.com/filecoin-project/mir/pkg/pb/pingpongpb" +) + +func main() { + var generator generator_.CombinedGenerator + err := generator.Run( + []reflect.Type{ + + reflect.TypeOf((*pkg_.Event)(nil)).Elem(), + + reflect.TypeOf((*pkg_.Event_PingTime)(nil)).Elem(), + + reflect.TypeOf((*pkg_.PingTime)(nil)).Elem(), + + reflect.TypeOf((*pkg_.Message)(nil)).Elem(), + + reflect.TypeOf((*pkg_.Message_Ping)(nil)).Elem(), + + reflect.TypeOf((*pkg_.Message_Pong)(nil)).Elem(), + + reflect.TypeOf((*pkg_.Ping)(nil)).Elem(), + + reflect.TypeOf((*pkg_.Pong)(nil)).Elem(), + + }) + + if err != nil { + log.Printf("Error: %v\n", err) + os.Exit(2) + } +} diff --git a/samples/blockchain-chat-mobile/README.md b/samples/blockchain-chat-mobile/README.md new file mode 100644 index 000000000..dd5eff844 --- /dev/null +++ b/samples/blockchain-chat-mobile/README.md @@ -0,0 +1,3 @@ +# Blockchain Chat App + +See [Blockchain](../../pkg/blockchain/README.md) from documentation. diff --git a/samples/blockchain-chat-mobile/application/application.go b/samples/blockchain-chat-mobile/application/application.go new file mode 100644 index 000000000..aac7454e9 --- /dev/null +++ b/samples/blockchain-chat-mobile/application/application.go @@ -0,0 +1,237 @@ +package application + +// app module + +import ( + "fmt" + "time" + + "github.com/filecoin-project/mir/pkg/blockchain/utils" + "github.com/filecoin-project/mir/pkg/dsl" + "github.com/filecoin-project/mir/pkg/logging" + "github.com/filecoin-project/mir/pkg/modules" + applicationpbdsl "github.com/filecoin-project/mir/pkg/pb/blockchainpb/applicationpb/dsl" + bcmpbdsl "github.com/filecoin-project/mir/pkg/pb/blockchainpb/bcmpb/dsl" + interceptorpbdsl "github.com/filecoin-project/mir/pkg/pb/blockchainpb/interceptorpb/dsl" + payloadpbtypes "github.com/filecoin-project/mir/pkg/pb/blockchainpb/payloadpb/types" + statepbtypes "github.com/filecoin-project/mir/pkg/pb/blockchainpb/statepb/types" + blockchainpbtypes "github.com/filecoin-project/mir/pkg/pb/blockchainpb/types" + t "github.com/filecoin-project/mir/pkg/types" + "github.com/filecoin-project/mir/samples/blockchain-chat-mobile/application/payloads" + "github.com/filecoin-project/mir/samples/blockchain-chat-mobile/server" + "google.golang.org/protobuf/types/known/timestamppb" +) + +/** +* Application module - Mobile Chat Demo +* ================== +* +* Based on /samples/blockchain-chat/application/application.go +* + */ + +type ApplicationModule struct { + m *dsl.Module + pm *payloads.PayloadManager // store for payloads + nodeID t.NodeID // to set sender in payload + logger logging.Logger + mobileServer *server.Server +} + +// application-application events + +/** +* Helper functions + */ + +// helper function that applies a block's payload to the given state, thereby computing the new state +func applyBlockToState(state *statepbtypes.State, block *blockchainpbtypes.Block) *statepbtypes.State { + sender := block.Payload.Sender + timeStamps := state.LastSentTimestamps + history := state.History + + for i, lt := range timeStamps { + if lt.NodeId == sender { + ltTimestamp := lt.Timestamp.AsTime() + if ltTimestamp.After(block.Payload.Timestamp.AsTime()) { + panic("invalid ordering - there is a block that should never have been accepted") + } + + // remove old timestamp, if it exists + timeStamps[i] = timeStamps[len(state.LastSentTimestamps)-1] + timeStamps = timeStamps[:len(state.LastSentTimestamps)-1] + } + } + + timeStamps = append(timeStamps, &statepbtypes.LastSentTimestamp{ + NodeId: sender, + Timestamp: block.Payload.Timestamp, + }) + + // empty block, just skip + if block.Payload.Message != "" { + history = append(history, block.Payload) + } + + return &statepbtypes.State{ + History: history, + LastSentTimestamps: timeStamps, + } +} + +/** +* Mir event handlers + */ + +// TODO: rename - fork is confusing + +// Handler called by BCM when the head changes. +// It handles cases where the head changes because the canonical chain was extended as well as cases where the canonical chain changes because of a fork. +func (am *ApplicationModule) handleHeadChange(removedChain, addedChain, checkpointToForkRootChain []*blockchainpbtypes.Block, checkpointState *statepbtypes.State) error { + am.logger.Log(logging.LevelDebug, "Processing fork update", "poolSize", am.pm.PoolSize()) + + // add "remove chain" transactions to pool + for _, block := range removedChain { + am.pm.AddPayload(block.Payload) + } + + // remove "add chain" transactions from pool + for _, block := range addedChain { + am.pm.RemovePayload(block.Payload) + } + + state := checkpointState + // compute state at fork roo + // skip first as checkpoint state already 'included' its payload + for _, block := range checkpointToForkRootChain[1:] { + state = applyBlockToState(state, block) + } + // compute state at new head + for _, block := range addedChain { + state = applyBlockToState(state, block) + } + + am.logger.Log(logging.LevelDebug, "Pool after fork", "poolSize", am.pm.PoolSize()) + + // register checkpoint + blockId := addedChain[len(addedChain)-1].BlockId + bcmpbdsl.RegisterCheckpoint(*am.m, "bcm", blockId, state) + interceptorpbdsl.StateUpdate(*am.m, "devnull", state) + + // update state in mobile server + am.mobileServer.SetHistory(state.History) + + // print state + fmt.Printf("=== STATE ===\n") + for _, pl := range state.History { + fmt.Println(pl.Message) + } + fmt.Printf("=============\nEnter new message: \n") + + return nil +} + +// Handler called by BCM when a chain needs to be verified. +// The checks are purely at the application level. +// In this implementation, it simply checks that the timestamps are monotonically increasing for each sender. +func (am *ApplicationModule) handleVerifyBlocksRequest(checkpointState *statepbtypes.State, chainCheckpointToStart, chainToVerify []*blockchainpbtypes.Block) error { + am.logger.Log(logging.LevelDebug, "Processing verify blocks request", "checkpoint", utils.FormatBlockId(chainCheckpointToStart[0].BlockId), "first block to verify", utils.FormatBlockId(chainToVerify[0].BlockId), "last block to verify", utils.FormatBlockId(chainToVerify[len(chainToVerify)-1].BlockId)) + + timestampMap := make(map[t.NodeID]time.Time) + for _, lt := range checkpointState.LastSentTimestamps { + timestampMap[lt.NodeId] = lt.Timestamp.AsTime() + } + + chain := append(chainCheckpointToStart, chainToVerify...) // chainCheckpointToStart wouldn't need to be verified, but we need it to get the timestamps + + for _, block := range chain { + blockTs := block.Payload.Timestamp.AsTime() + // verify block + if ts, ok := timestampMap[block.Payload.Sender]; ok { + if ts.After(blockTs) { + // block in chain invalid, don't respond + return nil + } + } + + // update timestamp + timestampMap[block.Payload.Sender] = blockTs + } + + // if no blocks are invalid, responds with chain + applicationpbdsl.VerifyBlocksResponse(*am.m, "bcm", chainToVerify) + + return nil +} + +// Handler called by the miner when it needs a payload for the next block. +func (am *ApplicationModule) handlePayloadRequest(head_id uint64) error { + am.logger.Log(logging.LevelDebug, "Processing payload request", "headId", utils.FormatBlockId(head_id)) + + payload := am.pm.GetPayload() + + // if no payload is available, create empty payload + // this is important to ensure that all nodes are always mining new blocks + if payload == nil { + payload = &payloadpbtypes.Payload{ + Message: "", + Timestamp: timestamppb.Now(), + Sender: am.nodeID, + } + } + + applicationpbdsl.PayloadResponse(*am.m, "miner", head_id, payload) + + return nil +} + +func (am *ApplicationModule) addNewMessage(message string) { + am.pm.AddPayload(&payloadpbtypes.Payload{ + Message: message, + Timestamp: timestamppb.Now(), + Sender: am.nodeID, + }) +} + +func NewApplication(nodeID t.NodeID, logger logging.Logger) modules.Module { + + m := dsl.NewModule("application") + am := &ApplicationModule{ + m: &m, + logger: logger, + nodeID: nodeID, + pm: payloads.New(), + mobileServer: nil, + } + + am.mobileServer = server.NewServer(":818"+string(nodeID), am.addNewMessage) // janky port def but should be ok as we will never have >10 + + fmt.Println("===========================================") + go am.mobileServer.Run() + fmt.Println("===========================================") + + dsl.UponInit(m, func() error { + // init blockchain + bcmpbdsl.InitBlockchain(*am.m, "bcm", &statepbtypes.State{ + History: []*payloadpbtypes.Payload{}, + LastSentTimestamps: []*statepbtypes.LastSentTimestamp{}, + }) + + return nil + }) + + applicationpbdsl.UponPayloadRequest(m, am.handlePayloadRequest) + applicationpbdsl.UponHeadChange(m, am.handleHeadChange) + applicationpbdsl.UponVerifyBlocksRequest(m, am.handleVerifyBlocksRequest) + + applicationpbdsl.UponMessageInput(m, func(text string) error { + am.pm.AddPayload(&payloadpbtypes.Payload{ + Message: text, + Timestamp: timestamppb.Now(), + Sender: am.nodeID, + }) + return nil + }) + + return m +} diff --git a/samples/blockchain-chat-mobile/application/payloads/payloads.go b/samples/blockchain-chat-mobile/application/payloads/payloads.go new file mode 100644 index 000000000..51f0d6066 --- /dev/null +++ b/samples/blockchain-chat-mobile/application/payloads/payloads.go @@ -0,0 +1,90 @@ +package payloads + +import ( + "slices" + + payloadpbtypes "github.com/filecoin-project/mir/pkg/pb/blockchainpb/payloadpb/types" + "github.com/mitchellh/hashstructure" +) + +/** + * Payload manager + * =============== + * + * The payload manager is part of the application and responsible for managing payloads. + * It keeps track of all incoming payloads and provides the application with the oldest payload. + * If no payloads are available, it returns nil. + * The application can then use this payload to create a new block. + * Payloads can be added and removed from the payload manager. + * Equivalence of payloads is determined by their hash. + */ + +type storedPayload struct { + hash uint64 + payload *payloadpbtypes.Payload +} + +type PayloadManager struct { + payloads []storedPayload // sorted by timestamp +} + +func (tm *PayloadManager) PoolSize() int { + return len(tm.payloads) +} + +func New() *PayloadManager { + return &PayloadManager{ + payloads: []storedPayload{}, + } +} + +func (tm *PayloadManager) GetPayload() *payloadpbtypes.Payload { + // return oldest payload, where timestamp is a field in the payload + if len(tm.payloads) == 0 { + return nil + } + // sort by timestamp + // TODO: keep it sorted + slices.SortFunc(tm.payloads, func(i, j storedPayload) int { + return i.payload.Timestamp.AsTime().Compare(j.payload.Timestamp.AsTime()) + }) + return tm.payloads[0].payload +} + +func (tm *PayloadManager) AddPayload(payload *payloadpbtypes.Payload) error { + hash, err := hashstructure.Hash(payload, nil) + if err != nil { + return err + } + + if slices.ContainsFunc(tm.payloads, func(t storedPayload) bool { + return t.hash == hash + }) { + // already exists, ignore + return nil + } + + storedPaylod := storedPayload{ + hash: hash, + payload: payload, + } + + tm.payloads = append(tm.payloads, storedPaylod) + + return nil +} + +func (tm *PayloadManager) RemovePayload(payload *payloadpbtypes.Payload) error { + hash, err := hashstructure.Hash(payload, nil) + if err != nil { + return err + } + + // goes through all storedPayloads and removes the one with the matching hash + // NOTE: consider adding (hash) index to improve performance - not important rn + tm.payloads = slices.DeleteFunc(tm.payloads, func(t storedPayload) bool { + return t.hash == hash + }) + + return nil +} diff --git a/samples/blockchain-chat-mobile/main.go b/samples/blockchain-chat-mobile/main.go new file mode 100644 index 000000000..de3e85fac --- /dev/null +++ b/samples/blockchain-chat-mobile/main.go @@ -0,0 +1,170 @@ +package main + +import ( + "bufio" + "context" + "flag" + "fmt" + "os" + "strconv" + + "github.com/filecoin-project/mir" + "github.com/filecoin-project/mir/pkg/blockchain" + "github.com/filecoin-project/mir/pkg/blockchain/wsInterceptor" + "github.com/filecoin-project/mir/pkg/events" + "github.com/filecoin-project/mir/pkg/logging" + applicationpbevents "github.com/filecoin-project/mir/pkg/pb/blockchainpb/applicationpb/events" + "github.com/filecoin-project/mir/pkg/pb/eventpb" + t "github.com/filecoin-project/mir/pkg/types" + "github.com/filecoin-project/mir/samples/blockchain-chat-mobile/application" +) + +// Flags +var ( + disableMangle = flag.Bool("disableMangle", false, "Disable mangling of messages") + dropRate = flag.Float64("dropRate", 0.05, "The rate at which to drop messages") + minDelay = flag.Float64("minDelay", 0.001, "The minimum delay by which to delay messages between nodes [seconds]") + maxDelay = flag.Float64("maxDelay", 1, "The maximum delay by which to delay messages between nodes [seconds]") + exponentialMiningFactor = flag.Float64("expMiningFactor", 0.2, "Factor for exponential distribution for random mining duration") + numberOfNodes = flag.Int("numberOfNodes", -1, "The number of nodes in the network [1, inf] REQUIRED") + nodeID = flag.Int("nodeID", -1, "The ID of the node [0, numberOfNodes-1] REQUIRED") +) + +var idToUserMap = map[int]string{ + 0: "Alice", + 1: "Bob", + 2: "Charlie", + 3: "Donna", + 4: "Eve", +} + +func main() { + // Parse command line flags + flag.Parse() + + requiredFlags := []string{"numberOfNodes", "nodeID"} + flagsSet := make(map[string]bool) + missedRequiredFlags := false + + // Check which flags are set + flag.Visit(func(f *flag.Flag) { + flagsSet[f.Name] = true + }) + + // Check for missed required flags + for _, f := range requiredFlags { + if !flagsSet[f] { + fmt.Printf("Flag %s is required\n", f) + missedRequiredFlags = true + } + } + + // Exit if missing any required flag + if missedRequiredFlags { + os.Exit(2) + } + + // Check for valid flag values + if *numberOfNodes < 1 { + fmt.Printf("Number of nodes must be greater than 0.\n") + os.Exit(2) + } else if *nodeID < 0 || *nodeID >= *numberOfNodes { + fmt.Printf("Node ID must be between 0 and numberOfNodes-1.\n") + os.Exit(2) + } else if *minDelay < 0 { + fmt.Printf("Minimum delay must be greater than or equal to 0.\n") + os.Exit(2) + } else if *maxDelay < 0 { + fmt.Printf("Maximum delay must be greater than or equal to 0.\n") + os.Exit(2) + } else if *minDelay > *maxDelay { + fmt.Printf("Minimum delay must be less than or equal to maximum delay.\n") + os.Exit(2) + } else if *dropRate < 0 || *dropRate > 1 { + fmt.Printf("Drop rate must be between 0 and 1.\n") + os.Exit(2) + } else if *disableMangle && (flagsSet["dropRate"] || flagsSet["minDelay"] || flagsSet["maxDelay"]) { + fmt.Printf("WARNING: Settings for drop rate, minimum delay, and maximum delay are ignored when mangling is disabled.\n") + } + + ownNodeID := t.NodeID(strconv.Itoa(*nodeID)) + + // Setting up node + fmt.Println("Starting longest chain consensus protocol...") + + logger := logging.ConsoleInfoLogger + + system := blockchain.New( + ownNodeID, + application.NewApplication(ownNodeID, logging.Decorate(logger, "Application:\t")), + *disableMangle, + *dropRate, + *minDelay, + *maxDelay, + *exponentialMiningFactor, + *numberOfNodes, + logger, + logging.Decorate(logging.ConsoleInfoLogger, "Transport:\t")) + + // Instantiate Mir node. + node, err := mir.NewNode( + ownNodeID, + mir.DefaultNodeConfig(), + system.Modules(), + wsInterceptor.NewWsInterceptor( + func(e *eventpb.Event) bool { + switch e.Type.(type) { + case *eventpb.Event_Bcinterceptor: + return true + default: + return false + } + }, + 8080+*nodeID, + logging.Decorate(logger, "WSInter:\t"), + )) + if err != nil { + panic(err) + } + + fmt.Printf("Starting node %d: %s\n", *nodeID, idToUserMap[*nodeID]) + fmt.Printf("Interceptor exposed on port: %d\n", 8080+*nodeID) + fmt.Printf("Client server exposed on port: %d\n", 8180+*nodeID) + fmt.Printf("Access client under: http://k3-mbp:8280/?user=%s\n", idToUserMap[*nodeID]) + + ctx := context.Background() + + nodeError := make(chan error) + go func() { + nodeError <- node.Run(ctx) + }() + fmt.Println("Mir node running.") + + // ========================================================== + // Read chat messages from stdin and submit them as payloads. + // ========================================================== + + scanner := bufio.NewScanner(os.Stdin) + + // Prompt for chat message input. + fmt.Println("Type in your messages and press 'Enter' to send.") + + // Read chat message from stdin. + for scanner.Scan() { + // Submit the chat message as transaction payload to the mempool module. + if err := node.InjectEvents(ctx, events.ListOf( + applicationpbevents.MessageInput("application", scanner.Text()).Pb(), + )); err != nil { + // Print error if occurred. + fmt.Println(err) + } + + } + if err := scanner.Err(); err != nil { + fmt.Printf("Error reading input: %v\n", err) + } + + // Stop the node. + node.Stop() + fmt.Printf("Mir node stopped") +} diff --git a/samples/blockchain-chat-mobile/run.sh b/samples/blockchain-chat-mobile/run.sh new file mode 100755 index 000000000..ca89ab346 --- /dev/null +++ b/samples/blockchain-chat-mobile/run.sh @@ -0,0 +1,25 @@ +#!/bin/bash + +CONFIG="-numberOfNodes 4 -expMiningFactor 0.15 -dropRate 0.01 -minDelay 0.001 -maxDelay 0.5" + +NODE_0_LOG="./node_0.log" +NODE_1_LOG="./node_1.log" +NODE_2_LOG="./node_2.log" +NODE_3_LOG="./node_3.log" + +rm -rf ./node_*.log + +tmux kill-session -t demo +tmux new-session -d -s demo \; \ + \ + split-window -t demo:0 -v \; \ + split-window -t demo:0.0 -h \; \ + split-window -t "demo:0.2" -h \; \ + \ + send-keys -t "demo:0.0" "go run . -nodeID 0 $CONFIG 2>&1 | tee \"$NODE_0_LOG\"" Enter \; \ + send-keys -t "demo:0.1" "go run . -nodeID 1 $CONFIG 2>&1 | tee \"$NODE_0_LOG\"" Enter \; \ + send-keys -t "demo:0.2" "go run . -nodeID 2 $CONFIG 2>&1 | tee \"$NODE_0_LOG\"" Enter \; \ + send-keys -t "demo:0.3" "go run . -nodeID 3 $CONFIG 2>&1 | tee \"$NODE_0_LOG\"" Enter \; \ + attach-session -t "demo:0.0" +#!/usr/bin/env bash +set -e diff --git a/samples/blockchain-chat-mobile/server/server.go b/samples/blockchain-chat-mobile/server/server.go new file mode 100644 index 000000000..a6768136a --- /dev/null +++ b/samples/blockchain-chat-mobile/server/server.go @@ -0,0 +1,68 @@ +package server + +import ( + "encoding/json" + "fmt" + "io" + "net/http" + + payloadpbtypes "github.com/filecoin-project/mir/pkg/pb/blockchainpb/payloadpb/types" + "github.com/rs/cors" +) + +type Server struct { + history []*payloadpbtypes.Payload + port string + newMessageCallback func(message string) +} + +type postMsgPayload struct { + Message string `json:"message"` +} + +type getHistoryPayload struct { + Messages []*payloadpbtypes.Payload `json:"messages"` +} + +func (s *Server) handlePostMsg(w http.ResponseWriter, r *http.Request) { + if r.Method != http.MethodPost { + http.Error(w, "Method Not Allowed - Only POST", http.StatusMethodNotAllowed) + } + + var pl postMsgPayload + if err := json.NewDecoder(r.Body).Decode(&pl); err != nil { + http.Error(w, "Expected {\"message\": \"some string\"}", http.StatusBadRequest) + } + + // pass msg to application + s.newMessageCallback(pl.Message) + + io.WriteString(w, "Submitted") +} + +func (s *Server) handleGetHistory(w http.ResponseWriter, r *http.Request) { + if r.Method != http.MethodGet { + http.Error(w, "Method Not Allowed - Only GET", http.StatusMethodNotAllowed) + } + + json.NewEncoder(w).Encode(getHistoryPayload{s.history}) +} + +func (s *Server) SetHistory(history []*payloadpbtypes.Payload) { + s.history = history +} + +func (s *Server) Run() error { + http.HandleFunc("/sendMessage", s.handlePostMsg) + http.HandleFunc("/history", s.handleGetHistory) + fmt.Printf("===== Server running on port %s\n", s.port) + return http.ListenAndServe(s.port, cors.Default().Handler(http.DefaultServeMux)) +} + +func NewServer(port string, newMessageCallback func(message string)) *Server { + return &Server{ + history: []*payloadpbtypes.Payload{}, + port: port, + newMessageCallback: newMessageCallback, + } +} diff --git a/samples/blockchain-chat-mobile/test.sh b/samples/blockchain-chat-mobile/test.sh new file mode 100755 index 000000000..9cb4337c4 --- /dev/null +++ b/samples/blockchain-chat-mobile/test.sh @@ -0,0 +1,34 @@ +#!/bin/bash + +CONFIG="-numberOfNodes 4 -dropRate 0.05 -minDelay 0.01 -maxDelay 1" + +NODE_0_LOG="./node_0.log" +NODE_1_LOG="./node_1.log" +NODE_2_LOG="./node_2.log" +NODE_3_LOG="./node_3.log" + +rm -rf ./node_*.log + +tmux kill-session -t demo +tmux new-session -d -s demo \; \ + \ + split-window -t demo:0 -v \; \ + split-window -t demo:0.0 -h \; \ + split-window -t "demo:0.2" -h \; \ + \ + send-keys -t "demo:0.0" "go run . -nodeID 0 $CONFIG 2>&1 | tee \"$NODE_0_LOG\"" Enter \; \ + send-keys -t "demo:0.1" "go run . -nodeID 1 $CONFIG 2>&1 | tee \"$NODE_1_LOG\"" Enter \; \ + send-keys -t "demo:0.2" "go run . -nodeID 2 $CONFIG 2>&1 | tee \"$NODE_2_LOG\"" Enter \; \ + send-keys -t "demo:0.3" "go run . -nodeID 3 $CONFIG 2>&1 | tee \"$NODE_3_LOG\"" Enter \; + +sleep 5 # wait for it to start up +for i in {1..15}; do sleep 1; + tmux send-keys -t "demo:0.0" "0-$i" Enter \;; + tmux send-keys -t "demo:0.1" "1-$i" Enter \;; + tmux send-keys -t "demo:0.2" "2-$i" Enter \;; + tmux send-keys -t "demo:0.3" "3-$i" Enter \;; +done + +tmux attach-session -t "demo:0.0" +#!/usr/bin/env bash +set -e \ No newline at end of file diff --git a/samples/blockchain-chat/README.md b/samples/blockchain-chat/README.md new file mode 100644 index 000000000..dd5eff844 --- /dev/null +++ b/samples/blockchain-chat/README.md @@ -0,0 +1,3 @@ +# Blockchain Chat App + +See [Blockchain](../../pkg/blockchain/README.md) from documentation. diff --git a/samples/blockchain-chat/application/application.go b/samples/blockchain-chat/application/application.go new file mode 100644 index 000000000..c0d9edce5 --- /dev/null +++ b/samples/blockchain-chat/application/application.go @@ -0,0 +1,237 @@ +package application + +// app module + +import ( + "fmt" + "time" + + "github.com/filecoin-project/mir/pkg/blockchain/utils" + "github.com/filecoin-project/mir/pkg/dsl" + "github.com/filecoin-project/mir/pkg/logging" + "github.com/filecoin-project/mir/pkg/modules" + applicationpbdsl "github.com/filecoin-project/mir/pkg/pb/blockchainpb/applicationpb/dsl" + bcmpbdsl "github.com/filecoin-project/mir/pkg/pb/blockchainpb/bcmpb/dsl" + interceptorpbdsl "github.com/filecoin-project/mir/pkg/pb/blockchainpb/interceptorpb/dsl" + payloadpbtypes "github.com/filecoin-project/mir/pkg/pb/blockchainpb/payloadpb/types" + statepbtypes "github.com/filecoin-project/mir/pkg/pb/blockchainpb/statepb/types" + blockchainpbtypes "github.com/filecoin-project/mir/pkg/pb/blockchainpb/types" + t "github.com/filecoin-project/mir/pkg/types" + "github.com/filecoin-project/mir/samples/blockchain-chat/application/payloads" + "google.golang.org/protobuf/types/known/timestamppb" +) + +/** +* Application module +* ================== +* +* The application module is reponsible for performing the actual application logic and to interact with users or other applications. +* It does not hold any state, but instead relies on the blockchain manager module (BCM) to store the state. +* However, the application is responsible for computing the state given a chain of blocks and a state associated with the first block in the chain. +* Also, the application module manages payloads and must provide payloads for new blocks to the miner. +* +* The application module must perform the following tasks: +* 1. Initialize the blockchain by sending the initial state to the BCM in an InitBlockchain event. +* 2. When it receives a PayloadRequest event, it must provide a payload for the next block. +* Even if no payloads are available, a payload **must** be provided; however, this payload can be empty. +* 3. When it receives a HeadChange event, it must compute the state at the new head of the blockchain. +* This state is then registered with the BCM by sending it a RegisterCheckpoint event. +* (A checkpoint is a block stored by the BCM that has a state stored with it.) +* Additionally, the information provided in the _HeadChange_ event might be useful for the payload management. +* 4. When it receives a VerifyBlocksRequest event, it must verify that the given chain is valid at an application level and respond with a VerifyBlocksResponse event. +* Whether or not the blocks link together correctly is verified by the BCM. +* +* This application module implements a simple chat application. +* It takes new messages from the user (MessageInput event) and combines them with a sender id and "sent" timestamp as payloads. +* These payloads are stored in the payload manager (see applicaion/payloads/payloads.go). +* The state is the list of all messages that have been sent and timestamps for when each sender last sent a message. +* At the application level, a chain is valid if the timestamps are monotonically increasing for each sender. + */ + +type ApplicationModule struct { + m *dsl.Module + pm *payloads.PayloadManager // store for payloads + nodeID t.NodeID // to set sender in payload + logger logging.Logger +} + +// application-application events + +/** +* Helper functions + */ + +// helper function that applies a block's payload to the given state, thereby computing the new state +func applyBlockToState(state *statepbtypes.State, block *blockchainpbtypes.Block) *statepbtypes.State { + sender := block.Payload.Sender + timeStamps := state.LastSentTimestamps + msgHistory := state.MessageHistory + + for i, lt := range timeStamps { + if lt.NodeId == sender { + ltTimestamp := lt.Timestamp.AsTime() + if ltTimestamp.After(block.Payload.Timestamp.AsTime()) { + panic("invalid ordering - there is a block that should never have been accepted") + } + + // remove old timestamp, if it exists + timeStamps[i] = timeStamps[len(state.LastSentTimestamps)-1] + timeStamps = timeStamps[:len(state.LastSentTimestamps)-1] + } + } + + timeStamps = append(timeStamps, &statepbtypes.LastSentTimestamp{ + NodeId: sender, + Timestamp: block.Payload.Timestamp, + }) + + // empty block, just skip + if block.Payload.Message != "" { + msgHistory = append(msgHistory, block.Payload.Message) + } + + return &statepbtypes.State{ + MessageHistory: msgHistory, + LastSentTimestamps: timeStamps, + } +} + +/** +* Mir event handlers + */ + +// TODO: rename - fork is confusing + +// Handler called by BCM when the head changes. +// It handles cases where the head changes because the canonical chain was extended as well as cases where the canonical chain changes because of a fork. +func (am *ApplicationModule) handleHeadChange(removedChain, addedChain, checkpointToForkRootChain []*blockchainpbtypes.Block, checkpointState *statepbtypes.State) error { + am.logger.Log(logging.LevelDebug, "Processing fork update", "poolSize", am.pm.PoolSize()) + + // add "remove chain" transactions to pool + for _, block := range removedChain { + am.pm.AddPayload(block.Payload) + } + + // remove "add chain" transactions from pool + for _, block := range addedChain { + am.pm.RemovePayload(block.Payload) + } + + state := checkpointState + // compute state at fork roo + // skip first as checkpoint state already 'included' its payload + for _, block := range checkpointToForkRootChain[1:] { + state = applyBlockToState(state, block) + } + // compute state at new head + for _, block := range addedChain { + state = applyBlockToState(state, block) + } + + am.logger.Log(logging.LevelDebug, "Pool after fork", "poolSize", am.pm.PoolSize()) + + // register checkpoint + blockId := addedChain[len(addedChain)-1].BlockId + bcmpbdsl.RegisterCheckpoint(*am.m, "bcm", blockId, state) + interceptorpbdsl.StateUpdate(*am.m, "devnull", state) + + // print state + fmt.Printf("=== STATE ===\n") + for _, msg := range state.MessageHistory { + fmt.Println(msg) + } + fmt.Printf("=============\nEnter new message: \n") + + return nil +} + +// Handler called by BCM when a chain needs to be verified. +// The checks are purely at the application level. +// In this implementation, it simply checks that the timestamps are monotonically increasing for each sender. +func (am *ApplicationModule) handleVerifyBlocksRequest(checkpointState *statepbtypes.State, chainCheckpointToStart, chainToVerify []*blockchainpbtypes.Block) error { + am.logger.Log(logging.LevelDebug, "Processing verify blocks request", "checkpoint", utils.FormatBlockId(chainCheckpointToStart[0].BlockId), "first block to verify", utils.FormatBlockId(chainToVerify[0].BlockId), "last block to verify", utils.FormatBlockId(chainToVerify[len(chainToVerify)-1].BlockId)) + + timestampMap := make(map[t.NodeID]time.Time) + for _, lt := range checkpointState.LastSentTimestamps { + timestampMap[lt.NodeId] = lt.Timestamp.AsTime() + } + + chain := append(chainCheckpointToStart, chainToVerify...) // chainCheckpointToStart wouldn't need to be verified, but we need it to get the timestamps + + for _, block := range chain { + blockTs := block.Payload.Timestamp.AsTime() + // verify block + if ts, ok := timestampMap[block.Payload.Sender]; ok { + if ts.After(blockTs) { + // block in chain invalid, don't respond + return nil + } + } + + // update timestamp + timestampMap[block.Payload.Sender] = blockTs + } + + // if no blocks are invalid, responds with chain + applicationpbdsl.VerifyBlocksResponse(*am.m, "bcm", chainToVerify) + + return nil +} + +// Handler called by the miner when it needs a payload for the next block. +func (am *ApplicationModule) handlePayloadRequest(head_id uint64) error { + am.logger.Log(logging.LevelDebug, "Processing payload request", "headId", utils.FormatBlockId(head_id)) + + payload := am.pm.GetPayload() + + // if no payload is available, create empty payload + // this is important to ensure that all nodes are always mining new blocks + if payload == nil { + payload = &payloadpbtypes.Payload{ + Message: "", + Timestamp: timestamppb.Now(), + Sender: am.nodeID, + } + } + + applicationpbdsl.PayloadResponse(*am.m, "miner", head_id, payload) + + return nil +} + +func NewApplication(nodeID t.NodeID, logger logging.Logger) modules.Module { + + m := dsl.NewModule("application") + am := &ApplicationModule{ + m: &m, + logger: logger, + nodeID: nodeID, + pm: payloads.New(), + } + + dsl.UponInit(m, func() error { + // init blockchain + bcmpbdsl.InitBlockchain(*am.m, "bcm", &statepbtypes.State{ + MessageHistory: []string{}, + LastSentTimestamps: []*statepbtypes.LastSentTimestamp{}, + }) + + return nil + }) + + applicationpbdsl.UponPayloadRequest(m, am.handlePayloadRequest) + applicationpbdsl.UponHeadChange(m, am.handleHeadChange) + applicationpbdsl.UponVerifyBlocksRequest(m, am.handleVerifyBlocksRequest) + + applicationpbdsl.UponMessageInput(m, func(text string) error { + am.pm.AddPayload(&payloadpbtypes.Payload{ + Message: text, + Timestamp: timestamppb.Now(), + Sender: am.nodeID, + }) + + return nil + }) + + return m +} diff --git a/samples/blockchain-chat/application/payloads/payloads.go b/samples/blockchain-chat/application/payloads/payloads.go new file mode 100644 index 000000000..51f0d6066 --- /dev/null +++ b/samples/blockchain-chat/application/payloads/payloads.go @@ -0,0 +1,90 @@ +package payloads + +import ( + "slices" + + payloadpbtypes "github.com/filecoin-project/mir/pkg/pb/blockchainpb/payloadpb/types" + "github.com/mitchellh/hashstructure" +) + +/** + * Payload manager + * =============== + * + * The payload manager is part of the application and responsible for managing payloads. + * It keeps track of all incoming payloads and provides the application with the oldest payload. + * If no payloads are available, it returns nil. + * The application can then use this payload to create a new block. + * Payloads can be added and removed from the payload manager. + * Equivalence of payloads is determined by their hash. + */ + +type storedPayload struct { + hash uint64 + payload *payloadpbtypes.Payload +} + +type PayloadManager struct { + payloads []storedPayload // sorted by timestamp +} + +func (tm *PayloadManager) PoolSize() int { + return len(tm.payloads) +} + +func New() *PayloadManager { + return &PayloadManager{ + payloads: []storedPayload{}, + } +} + +func (tm *PayloadManager) GetPayload() *payloadpbtypes.Payload { + // return oldest payload, where timestamp is a field in the payload + if len(tm.payloads) == 0 { + return nil + } + // sort by timestamp + // TODO: keep it sorted + slices.SortFunc(tm.payloads, func(i, j storedPayload) int { + return i.payload.Timestamp.AsTime().Compare(j.payload.Timestamp.AsTime()) + }) + return tm.payloads[0].payload +} + +func (tm *PayloadManager) AddPayload(payload *payloadpbtypes.Payload) error { + hash, err := hashstructure.Hash(payload, nil) + if err != nil { + return err + } + + if slices.ContainsFunc(tm.payloads, func(t storedPayload) bool { + return t.hash == hash + }) { + // already exists, ignore + return nil + } + + storedPaylod := storedPayload{ + hash: hash, + payload: payload, + } + + tm.payloads = append(tm.payloads, storedPaylod) + + return nil +} + +func (tm *PayloadManager) RemovePayload(payload *payloadpbtypes.Payload) error { + hash, err := hashstructure.Hash(payload, nil) + if err != nil { + return err + } + + // goes through all storedPayloads and removes the one with the matching hash + // NOTE: consider adding (hash) index to improve performance - not important rn + tm.payloads = slices.DeleteFunc(tm.payloads, func(t storedPayload) bool { + return t.hash == hash + }) + + return nil +} diff --git a/samples/blockchain-chat/main.go b/samples/blockchain-chat/main.go new file mode 100644 index 000000000..46261e0f4 --- /dev/null +++ b/samples/blockchain-chat/main.go @@ -0,0 +1,157 @@ +package main + +import ( + "bufio" + "context" + "flag" + "fmt" + "os" + "strconv" + + "github.com/filecoin-project/mir" + "github.com/filecoin-project/mir/pkg/blockchain" + "github.com/filecoin-project/mir/pkg/blockchain/wsInterceptor" + "github.com/filecoin-project/mir/pkg/events" + "github.com/filecoin-project/mir/pkg/logging" + applicationpbevents "github.com/filecoin-project/mir/pkg/pb/blockchainpb/applicationpb/events" + "github.com/filecoin-project/mir/pkg/pb/eventpb" + t "github.com/filecoin-project/mir/pkg/types" + "github.com/filecoin-project/mir/samples/blockchain-chat/application" +) + +// Flags +var ( + disableMangle = flag.Bool("disableMangle", false, "Disable mangling of messages") + dropRate = flag.Float64("dropRate", 0.05, "The rate at which to drop messages") + minDelay = flag.Float64("minDelay", 0.001, "The minimum delay by which to delay messages between nodes [seconds]") + maxDelay = flag.Float64("maxDelay", 1, "The maximum delay by which to delay messages between nodes [seconds]") + exponentialMiningFactor = flag.Float64("expMiningFactor", 0.2, "Factor for exponential distribution for random mining duration") + numberOfNodes = flag.Int("numberOfNodes", -1, "The number of nodes in the network [1, inf] REQUIRED") + nodeID = flag.Int("nodeID", -1, "The ID of the node [0, numberOfNodes-1] REQUIRED") +) + +func main() { + // Parse command line flags + flag.Parse() + + requiredFlags := []string{"numberOfNodes", "nodeID"} + flagsSet := make(map[string]bool) + missedRequiredFlags := false + + // Check which flags are set + flag.Visit(func(f *flag.Flag) { + flagsSet[f.Name] = true + }) + + // Check for missed required flags + for _, f := range requiredFlags { + if !flagsSet[f] { + fmt.Printf("Flag %s is required\n", f) + missedRequiredFlags = true + } + } + + // Exit if missing any required flag + if missedRequiredFlags { + os.Exit(2) + } + + // Check for valid flag values + if *numberOfNodes < 1 { + fmt.Printf("Number of nodes must be greater than 0.\n") + os.Exit(2) + } else if *nodeID < 0 || *nodeID >= *numberOfNodes { + fmt.Printf("Node ID must be between 0 and numberOfNodes-1.\n") + os.Exit(2) + } else if *minDelay < 0 { + fmt.Printf("Minimum delay must be greater than or equal to 0.\n") + os.Exit(2) + } else if *maxDelay < 0 { + fmt.Printf("Maximum delay must be greater than or equal to 0.\n") + os.Exit(2) + } else if *minDelay > *maxDelay { + fmt.Printf("Minimum delay must be less than or equal to maximum delay.\n") + os.Exit(2) + } else if *dropRate < 0 || *dropRate > 1 { + fmt.Printf("Drop rate must be between 0 and 1.\n") + os.Exit(2) + } else if *disableMangle && (flagsSet["dropRate"] || flagsSet["minDelay"] || flagsSet["maxDelay"]) { + fmt.Printf("WARNING: Settings for drop rate, minimum delay, and maximum delay are ignored when mangling is disabled.\n") + } + + ownNodeID := t.NodeID(strconv.Itoa(*nodeID)) + + // Setting up node + fmt.Println("Starting longest chain consensus protocol...") + + logger := logging.ConsoleInfoLogger + + system := blockchain.New( + ownNodeID, + application.NewApplication(ownNodeID, logging.Decorate(logger, "Application:\t")), + *disableMangle, + *dropRate, + *minDelay, + *maxDelay, + *exponentialMiningFactor, + *numberOfNodes, + logger, + logging.Decorate(logging.ConsoleInfoLogger, "Transport:\t")) + + // Instantiate Mir node. + node, err := mir.NewNode( + ownNodeID, + mir.DefaultNodeConfig(), + system.Modules(), + wsInterceptor.NewWsInterceptor( + func(e *eventpb.Event) bool { + switch e.Type.(type) { + case *eventpb.Event_Bcinterceptor: + return true + default: + return false + } + }, + 8080+*nodeID, + logging.Decorate(logger, "WSInter:\t"), + )) + if err != nil { + panic(err) + } + + ctx := context.Background() + + nodeError := make(chan error) + go func() { + nodeError <- node.Run(ctx) + }() + fmt.Println("Mir node running.") + + // ========================================================== + // Read chat messages from stdin and submit them as payloads. + // ========================================================== + + scanner := bufio.NewScanner(os.Stdin) + + // Prompt for chat message input. + fmt.Println("Type in your messages and press 'Enter' to send.") + + // Read chat message from stdin. + for scanner.Scan() { + // Submit the chat message as transaction payload to the mempool module. + if err := node.InjectEvents(ctx, events.ListOf( + applicationpbevents.MessageInput("application", scanner.Text()).Pb(), + )); err != nil { + // Print error if occurred. + fmt.Println(err) + } + + } + if err := scanner.Err(); err != nil { + fmt.Printf("Error reading input: %v\n", err) + } + + // Stop the node. + node.Stop() + fmt.Printf("Mir node stopped") +} diff --git a/samples/blockchain-chat/run.sh b/samples/blockchain-chat/run.sh new file mode 100755 index 000000000..c84b5762b --- /dev/null +++ b/samples/blockchain-chat/run.sh @@ -0,0 +1,25 @@ +#!/bin/bash + +CONFIG="-numberOfNodes 4 -dropRate 0.05 -minDelay 0.01 -maxDelay 1" + +NODE_0_LOG="./node_0.log" +NODE_1_LOG="./node_1.log" +NODE_2_LOG="./node_2.log" +NODE_3_LOG="./node_3.log" + +rm -rf ./node_*.log + +tmux kill-session -t demo +tmux new-session -d -s demo \; \ + \ + split-window -t demo:0 -v \; \ + split-window -t demo:0.0 -h \; \ + split-window -t "demo:0.2" -h \; \ + \ + send-keys -t "demo:0.0" "go run . -nodeID 0 $CONFIG 2>&1 | tee \"$NODE_0_LOG\"" Enter \; \ + send-keys -t "demo:0.1" "go run . -nodeID 1 $CONFIG 2>&1 | tee \"$NODE_0_LOG\"" Enter \; \ + send-keys -t "demo:0.2" "go run . -nodeID 2 $CONFIG 2>&1 | tee \"$NODE_0_LOG\"" Enter \; \ + send-keys -t "demo:0.3" "go run . -nodeID 3 $CONFIG 2>&1 | tee \"$NODE_0_LOG\"" Enter \; \ + attach-session -t "demo:0.0" +#!/usr/bin/env bash +set -e diff --git a/samples/blockchain-chat/test.sh b/samples/blockchain-chat/test.sh new file mode 100755 index 000000000..9cb4337c4 --- /dev/null +++ b/samples/blockchain-chat/test.sh @@ -0,0 +1,34 @@ +#!/bin/bash + +CONFIG="-numberOfNodes 4 -dropRate 0.05 -minDelay 0.01 -maxDelay 1" + +NODE_0_LOG="./node_0.log" +NODE_1_LOG="./node_1.log" +NODE_2_LOG="./node_2.log" +NODE_3_LOG="./node_3.log" + +rm -rf ./node_*.log + +tmux kill-session -t demo +tmux new-session -d -s demo \; \ + \ + split-window -t demo:0 -v \; \ + split-window -t demo:0.0 -h \; \ + split-window -t "demo:0.2" -h \; \ + \ + send-keys -t "demo:0.0" "go run . -nodeID 0 $CONFIG 2>&1 | tee \"$NODE_0_LOG\"" Enter \; \ + send-keys -t "demo:0.1" "go run . -nodeID 1 $CONFIG 2>&1 | tee \"$NODE_1_LOG\"" Enter \; \ + send-keys -t "demo:0.2" "go run . -nodeID 2 $CONFIG 2>&1 | tee \"$NODE_2_LOG\"" Enter \; \ + send-keys -t "demo:0.3" "go run . -nodeID 3 $CONFIG 2>&1 | tee \"$NODE_3_LOG\"" Enter \; + +sleep 5 # wait for it to start up +for i in {1..15}; do sleep 1; + tmux send-keys -t "demo:0.0" "0-$i" Enter \;; + tmux send-keys -t "demo:0.1" "1-$i" Enter \;; + tmux send-keys -t "demo:0.2" "2-$i" Enter \;; + tmux send-keys -t "demo:0.3" "3-$i" Enter \;; +done + +tmux attach-session -t "demo:0.0" +#!/usr/bin/env bash +set -e \ No newline at end of file