Table of Contents
- 1. Channels & Peers Design
- 2. Bring Up the Mainchain & Plaschain
- 3. More Flexible Design Based on Previous L1 Network
- 4. Design L2 Gateway Code
- 4.1. 1. Launch two channels application at the same time
- 4.2. 2. Survey on Plasma (Implementation Details)
- 4.3. 3. Implement the Network based on Plasma MVP
- 4.3.1. DONE Able to fetch the newest block number, also get write sets from each transactions
- 4.3.2. DONE Gateway application should also be able to communicate with org01 chains.
- 4.3.3. DONE Implement root chain's chaincode, add a merkle root field.
- 4.3.4. DONE Gateway application should periodically check the newest block, and compute the merkle tree root to the Plasma Contract in the root chain
Build a simulated plasma-like Layer 2 network on an existing Hyperledger Fabric Layer 1 setup to achieve scalable transaction processing. This simplified simulation focuses on enhancing scalability without implementing features like challenge periods or Merkle trees.
1. Channels & Peers Design
1.1. Current Layer 1 Behavior
Lower BatchTimeouts are more stable and more beneficial at lower TPS; smaller block sizes excel at higher TPS levels. For more, see Layer 1 Benchmarking Results.
1.2. Channels
1.2.1. Plasma Chain (plaschains):
Optimized for high TPS with smaller block sizes to reduce latency.
1.2.2. Main Chain (chains):
Optimized for low TPS with minimal latency using a lower BatchTimeout.
1.3. Peers
1.3.1. Plasma Chain (plaschains):
Two peers – one operational and another that also participates in the main chain channel for chaincode invocation but does not endorse transactions.
1.3.2. Mainchain (chains):
- 1. Mainchain Peer
- Requirements for Cross-Channel Chaincode Calls (Design Choice):
- Membership in Both Channels
The peer making the InvokeChaincode call must be a member of both the source (calling) and the target channels. This ensures that the peer has the necessary permissions and access to interact with the chaincodes on both channels.
- Chaincode Installation
- Cross-Channel Peers:
Peers that are part of multiple channels where chaincode invocations will occur across these channels must have the relevant chaincode installed for all involved channels.
- Channel-Specific Peers:
Peers that only belong to a single channel need to have only the chaincode specific to that channel installed. They do not need chaincode for other channels.
- Cross-Channel Peers:
- Necessary Certs, TLS etc,.
- Membership in Both Channels
- Requirements for Cross-Channel Chaincode Calls (Design Choice):
2. Bring Up the Mainchain & Plaschain
2.1. 1. Generating Certificates
Do not enable TLS
2.2. 2. Bring up two networks together (Scripts)
2.3. Create Genesis Block (configtx)
plasconfig
anchor
2.3.1. July Issue: (TLS)
- Detailed Logs (Issue Log)
[lifecycle] ApproveChaincodeDefinitionForOrg -> Successfully endorsed chaincode approval with name 'basic', package ID 'basic1.0:1e8872e25b29e24db45630799acf8b5835e722a19c9a2\ 9a5eb121da40f0cd284', on channel 'chains' with definition {sequence: 1, endorsement info: (version: '1.0', plugin: 'escc', init required: false), validation info: (plugin: 'vscc', policy: '12202f4368616e6e656c2f41\ 70706c69636174696f6e2f456e646f7273656d656e74'), collections: ()} [endorser] callChaincode -> finished chaincode: _lifecycle duration: 0ms channel=chains txID=a3df9a52 [comm.grpc.server] 1 -> unary call completed grpc.service=protos.Endorser grpc.method=ProcessProposal grpc.peeraddress=172.25.0.1:43908 grpc.code=OK grpc.callduration=7.821944ms
SignatureSetToValidIdentities -> invalid identity error="the supplied identity is not valid: x509: certificate signed by unknown authority (possibly because of \"x509: ECDSA verification failure\" while trying to verify candidate authority certificate \"ca.main.chains\")" identity="(mspid=mainchainsMSP subject=CN=orderer.main.chains,OU=orderer,L=San Francisco,ST=California,C\ =US issuer=CN=ca.main.chains,O=main.chains,L=San Francisco,ST=California,C=US serialnumber=316238832132640519481742821703559526943)" [peer.blocksprovider] eliverBlocks -> Got error while attempting to receive blocks: block from orderer could not be verified: implicit policy evaluation failed - 0 sub-policies were satisfied, but this policy requires 1 of the 'Writers' sub-policies to be satisfied channel=chains orderer-address=orderer.main.chains:8001 [peer.blocksprovider] func1 -> Encountered an error reading from deliver stream: rpc error: code = Canceled desc = context canceled channel=chains orderer-address=orderer.main.chains:8001
- Detailed Logs (Normal Log)
[lifecycle] ApproveChaincodeDefinitionForOrg -> Successfully endorsed chaincode approval with name 'basic', package ID 'basic1.0:1e8872e25b29e24db45630799acf8b5835e722a19c9a2\ 9a5eb121da40f0cd284', on channel 'chains' with definition {sequence: 1, endorsement info: (version: '1.0', plugin: 'escc', init required: false), validation info: (plugin: 'vscc', policy: '12202f4368616e6e656c2f41\ 70706c69636174696f6e2f456e646f7273656d656e74'), collections: ()} [endorser] callChaincode -> finished chaincode: _lifecycle duration: 0ms channel=chains txID=fb4d4fad [comm.grpc.server] 1 -> unary call completed grpc.service=protos.Endorser grpc.method=ProcessProposal grpc.peeraddress=172.25.0.1:54224 grpc.code=OK grpc.callduration=3.8430\ 54ms
[gossip.privdata] StoreBlock -> Received block [5] from buffer channel=chains [committer.txvalidator] Validate -> [chains] Validated block [5] in 0ms [gossip.privdata] RetrievePvtdata -> Successfully fetched (or marked to reconcile later) all 1 eligible collection private write sets for block [5] (0 from local cache, 1 from\ transient store, 0 from other peers) channel=chains [kvledger] commit -> [chains] Committed block [5] with 1 transaction(s) in 3ms (statevalidation=0ms blockandpvtdatacommit=1ms statecommit=0ms) commitHash=[edb76edcb49efcb\ ce5f91e81b6c3acb49552f1ddcfce3fcd07048a52e9b44852]
Unkown TLS Issue, Leave it later Move to Arch Linux
3. More Flexible Design Based on Previous L1 Network
3.1. Layer 1 Network
3.1.1. slim/single-endorsement
- network name: chains
Design Layer 1 Network orderer1.ord01.chains peer1.org01.chains
3.2. Plasma Network
4. Design L2 Gateway Code
4.1. 1. Launch two channels application at the same time
Same chaincode
4.2. 2. Survey on Plasma (Implementation Details)
- Plasma Chains -> peer1.org02.chains
- Settlement Agents -> gateway application
syscontract := network.GetContract("qscc") // system chaincode syscontract.EvaluateTransaction("GetBlockByNumber", "chains02", number)
4.2.1. Focus on the SA (gateway) code
4.3. 3. Implement the Network based on Plasma MVP
file:///home/awang/benchains/applications/bench-l2-wrappers/main.go file:///home/awang/benchains/chaincodes/wrappers/currency/currency.go file:///home/awang/benchains/chaincodes/wrappers/types/types.go file:///home/awang/benchains/networks/fabric/scripts/fabric.sh