forked from Hyperledger-TWGC/tape
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
generate Proposals to peer and observe endorsement ProposalResponse
Skip process if orderer is null Skip observer if committer is null Fixs Hyperledger-TWGC#56 Signed-off-by: SamYuan1990 <yy19902439@126.com>
- Loading branch information
1 parent
f1353c4
commit 8d9a006
Showing
12 changed files
with
369 additions
and
30 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
# Here is high level desgin for stupid | ||
|
||
## "Bit Map" | ||
As description in #56, often we need to **spot network bottleneck** by testing 3 phases `Endorsement - Order - Commitment` **separately**: | ||
- generate `Proposals` to peer and observe endorsement `ProposalResponse` | ||
- generate `Envelope` to orderers and observe ordered `Block` | ||
- generate `Block` to peer and observed committed `Block` (this is the most tricky one) | ||
|
||
This could help us benchmarking fabric components in finer-grained manners. | ||
|
||
So here is a bit map designed in `/cmd/stupid/main.go` | ||
|
||
| generate `Proposals` | generate `Envelope` | generate `Block` | Bit number | Comments| | ||
| ---- | ---- | ---- | ---- | ---- | | ||
| Lowest | -> | Highet | | from left to right is the lowest to highest bit | ||
| 1 | 0 | 0 | 1 | test generate `Proposals` to peer and observe endorsement `ProposalResponse` | ||
| 0 | 1 | 0 | 2 | test generate `Envelope` to orderers and observe ordered `Block` | ||
| 0 | 0 | 1 | 4 | test generate `Block` to peer and observed committed `Block` | ||
| 1 | 1 | 1 | 7 | test all process to target fabric network | ||
|
||
## Producer, Consumer mode |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
package process | ||
|
||
import ( | ||
"time" | ||
|
||
"github.com/guoger/stupid/pkg/infra" | ||
log "github.com/sirupsen/logrus" | ||
) | ||
|
||
type BlockProcess struct { | ||
//Producer *infra.Assembler | ||
Consumer *infra.Observer | ||
//Communication chan *infra.Elements | ||
} | ||
|
||
func CreateBlockProcessProcess(config infra.Config, crypto *infra.Crypto, logger *log.Logger) *BlockProcess { | ||
observer := infra.CreateObserver(config.Channel, config.Committer, crypto, logger) | ||
return &BlockProcess{ | ||
//Producer: assember, | ||
Consumer: observer, | ||
//Communication: envs, | ||
} | ||
} | ||
|
||
func (process *BlockProcess) Produce() { | ||
// start producert to produce data into channel | ||
// the productor of broadcaster | ||
} | ||
|
||
func (process *BlockProcess) Consume(N int, start time.Time) { | ||
// the consume don't do nothing but start and listening the Communication channel | ||
go process.Consumer.Start(N, start) | ||
//go process.Consumer.Wait() | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,86 @@ | ||
package process | ||
|
||
import ( | ||
"github.com/guoger/stupid/pkg/infra" | ||
"github.com/hyperledger/fabric-protos-go/common" | ||
"github.com/hyperledger/fabric/protoutil" | ||
log "github.com/sirupsen/logrus" | ||
) | ||
|
||
type BroadcasterProcess struct { | ||
Producer *infra.Assembler | ||
Consumer infra.Broadcasters | ||
Communication chan *infra.Elements | ||
} | ||
|
||
func CreateBroadcasterProcessProcess(row_length int, config infra.Config, crypto *infra.Crypto, logger *log.Logger) *BroadcasterProcess { | ||
envs := make(chan *infra.Elements, row_length) | ||
assember := &infra.Assembler{Signer: crypto} | ||
broadcaster := infra.CreateBroadcasters(config.NumOfConn, config.Orderer, logger) | ||
return &BroadcasterProcess{ | ||
Producer: assember, | ||
Consumer: broadcaster, | ||
Communication: envs, | ||
} | ||
} | ||
|
||
func createTestHeader(channelId string) *common.Header { | ||
nonce := []byte("nonce-abc-12345") | ||
creator := []byte("nonce-abc-12345") | ||
txid := protoutil.ComputeTxID(nonce, creator) | ||
|
||
txType := common.HeaderType_ENDORSER_TRANSACTION | ||
chdr := &common.ChannelHeader{ | ||
Type: int32(txType), | ||
ChannelId: channelId, | ||
TxId: txid, | ||
Epoch: uint64(0), | ||
} | ||
|
||
shdr := &common.SignatureHeader{ | ||
Creator: creator, | ||
Nonce: nonce, | ||
} | ||
|
||
return &common.Header{ | ||
ChannelHeader: protoutil.MarshalOrPanic(chdr), | ||
SignatureHeader: protoutil.MarshalOrPanic(shdr), | ||
} | ||
} | ||
|
||
func createTestEnvelope(channelId string, signer *infra.Crypto) *common.Envelope { | ||
payload := &common.Payload{ | ||
Header: createTestHeader(channelId), | ||
Data: []byte("data"), | ||
} | ||
payloadBytes, _ := protoutil.GetBytesPayload(payload) | ||
|
||
signature, _ := signer.Sign(payloadBytes) | ||
|
||
return &common.Envelope{ | ||
Payload: payloadBytes, | ||
Signature: signature, | ||
} | ||
} | ||
|
||
func (process *BroadcasterProcess) MockProduce(N int, crypto *infra.Crypto, config infra.Config) { | ||
for i := 0; i < N; i++ { | ||
env := createTestEnvelope(config.Channel, crypto) | ||
process.Communication <- &infra.Elements{ | ||
Envelope: env, | ||
} | ||
} | ||
} | ||
|
||
func (process *BroadcasterProcess) Produce(processed chan *infra.Elements, done <-chan struct{}) { | ||
// start producert to produce data into channel | ||
// the productor of broadcaster | ||
for i := 0; i < 5; i++ { | ||
go process.Producer.StartIntegrator(processed, process.Communication, done) | ||
} | ||
} | ||
|
||
func (process *BroadcasterProcess) Consume(done <-chan struct{}) { | ||
// the consume don't do nothing but start and listening the Communication channel | ||
go process.Consumer.Start(process.Communication, done) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,49 @@ | ||
package process | ||
|
||
import ( | ||
log "github.com/sirupsen/logrus" | ||
|
||
"github.com/guoger/stupid/pkg/infra" | ||
) | ||
|
||
type EndorsementProcess struct { | ||
Producer *infra.Assembler | ||
Consumer *infra.Proposers | ||
Config infra.Config | ||
Communication []chan *infra.Elements | ||
Output chan *infra.Elements | ||
} | ||
|
||
func CreateEndorsementProcess(row_length int, config infra.Config, crypto *infra.Crypto, logger *log.Logger) *EndorsementProcess { | ||
assember := &infra.Assembler{Signer: crypto} | ||
proposor := infra.CreateProposers(config.NumOfConn, config.ClientPerConn, config.Endorsers, logger) | ||
processed := make(chan *infra.Elements, row_length) | ||
signed := make([]chan *infra.Elements, len(config.Endorsers)) | ||
for i := 0; i < len(config.Endorsers); i++ { | ||
signed[i] = make(chan *infra.Elements, row_length) | ||
} | ||
return &EndorsementProcess{ | ||
Config: config, | ||
Producer: assember, | ||
Consumer: proposor, | ||
Communication: signed, | ||
Output: processed, | ||
} | ||
} | ||
|
||
func (process *EndorsementProcess) SetCommunication(communication []chan *infra.Elements) { | ||
process.Communication = communication | ||
} | ||
|
||
func (process *EndorsementProcess) SetOutput(output chan *infra.Elements) { | ||
process.Output = output | ||
} | ||
|
||
func (process *EndorsementProcess) Produce() { | ||
// start producert to produce data into channel | ||
} | ||
|
||
func (process *EndorsementProcess) Consume(done <-chan struct{}) { | ||
process.Consumer.Start(process.Communication, process.Output, done, process.Config) | ||
// the consume don't do nothing but start and listening the Communication channel | ||
} |
Oops, something went wrong.