Skip to content

Commit

Permalink
update proto (#10)
Browse files Browse the repository at this point in the history
* update proto

* Update README.md
  • Loading branch information
stevenlcf authored May 31, 2019
1 parent 122747c commit 0789836
Show file tree
Hide file tree
Showing 5 changed files with 15 additions and 15 deletions.
8 changes: 5 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -65,11 +65,11 @@ cChannel-eth is currently under active developments in our private repo. This pu

## Protocol Buffers Usage
[Protocol Buffers (protobuf)](https://developers.google.com/protocol-buffers/) are "a language-neutral, platform-neutral extensible mechanism for serializing structured data" developed by Google.
We leverage Protocol Buffers to define a series of blockchain-neutral generalized data structures, which can be seamlessly used in off-chain communication protocols and instantly extended to other blockchains that we plan to support.
We leverage Protocol Buffers to define a series of blockchain-neutral generalized data structures, which can be seamlessly used in off-chain communication protocols and instantly extended to other blockchains that we will support.

We also developed and open sourced a library generator of Solidity for decoding proto3 called [pb3-gen-sol](https://github.com/celer-network/pb3-gen-sol), which is listed in the official [Third-Party Add-ons for Protocol Buffers](https://github.com/protocolbuffers/protobuf/blob/master/docs/third_party.md).
We have also developed and open sourced a Solidity library generator of proto3 decoders called [pb3-gen-sol](https://github.com/celer-network/pb3-gen-sol), which is listed in protobuf's official [Third-Party Add-ons for Protocol Buffers](https://github.com/protocolbuffers/protobuf/blob/master/docs/third_party.md).

Two proto3 files are used in cChannel-eth, `chain.proto` and `entity.proto`, which are stored in `lib/data/proto/`. `chain.proto` defines data structures only used in on-chain contracts ("2" means version 2) while `entity.proto` defines data structures used both in on-chain contracts and off-chain communication protocols.
Two proto3 files are used in cChannel-eth, `chain.proto` and `entity.proto`, which are stored in `lib/data/proto/`. `chain.proto` defines data structures only used in on-chain contracts, while `entity.proto` defines data structures used both in on-chain contracts and off-chain communication protocols.

## Latest Deployments
### Ropsten
Expand Down Expand Up @@ -101,7 +101,9 @@ The following is the main code structure of cChannel-eth:

### test folder
* **channel**: unit test files for cChannel.
* **gas_measurement**: fine-granularity gas measurements for contract deployments and function calls.
* **helper**: assistant modules in unit tests including some modules for generating protobuf objects used in test cases.
* **EthPoolTest.js**: unit tests for EthPool.
* **PayRegistryTest.js**: unit tests for PayRegistry.
* **VirtContractResolverTest.js**: unit tests for Virtual Contract Resolver.

Expand Down
1 change: 0 additions & 1 deletion contracts/lib/data/PbChain.sol
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@
// source: chain.proto
pragma solidity ^0.5.0;
import "./Pb.sol";
import "./PbEntity.sol";

library PbChain {
using Pb for Pb.Buffer; // so we can call Pb funcs on Buffer obj
Expand Down
4 changes: 4 additions & 0 deletions contracts/lib/data/PbEntity.sol
Original file line number Diff line number Diff line change
Expand Up @@ -134,6 +134,7 @@ library PbEntity {
TokenTransfer transferToPeer; // tag: 4
PayHashList pendingPayHashes; // tag: 5
uint lastPayResolveDeadline; // tag: 6
uint256 totalPendingAmount; // tag: 7
} // end struct SimplexPaymentChannel

function decSimplexPaymentChannel(bytes memory raw) internal pure returns (SimplexPaymentChannel memory m) {
Expand Down Expand Up @@ -162,6 +163,9 @@ library PbEntity {
else if (tag == 6) {
m.lastPayResolveDeadline = uint(buf.decVarint());
}
else if (tag == 7) {
m.totalPendingAmount = Pb._uint256(buf.decBytes());
}
else { buf.skipValue(wire); } // skip value of unknown tag
}
} // end decoder SimplexPaymentChannel
Expand Down
7 changes: 0 additions & 7 deletions contracts/lib/data/proto/chain.proto
Original file line number Diff line number Diff line change
@@ -1,15 +1,8 @@
syntax = "proto3";
option go_package = "github.com/celer-network/goCeler/chain";

import "google/protobuf/descriptor.proto";
import "entity.proto";

package chain;

extend google.protobuf.FieldOptions {
string soltype = 1002;
}

// Next Tag: 3
message OpenChannelRequest {
// channel_initializer is serialized entity.PaymentChannelInitializer
Expand Down
10 changes: 6 additions & 4 deletions contracts/lib/data/proto/entity.proto
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ message TokenTransfer {
AccountAmtPair receiver = 2;
}

// Next Tag: 7
// Next Tag: 8
message SimplexPaymentChannel {
uint64 channel_id = 1;
// aka simplex channel owner.
Expand All @@ -50,10 +50,12 @@ message SimplexPaymentChannel {
// head of the hashlist chain of all pending conditional pays.
PayHashList pending_pay_hashes = 5;
// The last resolve deadline of all pending conditonal pays.
// confirmSettle must be called after all pending pays have been finalized,
// namely all pending pays have been resolved in the pay registry,
// confirmSettle must be called after all pending pays have been finalized,
// namely all pending pays have been resolved in the pay registry,
// or after the last_pay_resolve_deadline.
uint64 last_pay_resolve_deadline = 6 [(soltype) = "uint"];
// total amount of all pending pays.
bytes total_pending_amount = 7 [(soltype) = "uint256"];
}

// Next Tag: 3
Expand All @@ -75,7 +77,7 @@ enum TransferFunctionType {

// Next Tag: 3
message TransferFunction {
// Return transfer amount based on codition results.
// Return transfer amount based on condition results.
// TransferFunctionType is sufficient for simple functions such as
// BOOLEAN_AND, BOOLEAN_OR, NUMERIC_ADD, NUMERIC_MAX, and NUMERIC_MIN.
// When logic_type is NUMERIC_*, hashlock condition is always treated as BOOLEAN_AND
Expand Down

0 comments on commit 0789836

Please sign in to comment.