Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Default to RAFT enabled #146

Merged
merged 1 commit into from
Jun 4, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,6 @@
.vscode

microfabd

_mfcfg
microfab
_*cfg

8 changes: 8 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -17,3 +17,11 @@ unit:

integration:
go run github.com/onsi/ginkgo/ginkgo integration

binary:
go build -o microfabd cmd/microfabd/main.go
go build -o microfab cmd/microfab/main.go

.PHONY: docker
docker:
docker build -t microfab -f Dockerfile2 .
3 changes: 3 additions & 0 deletions internal/app/microfabd/microfabd.go
Original file line number Diff line number Diff line change
Expand Up @@ -239,6 +239,9 @@ func (m *Microfab) Start() error {
}
}()

// wait for the orderer to wakeup
time.Sleep(8 * time.Second)

// Create and join all of the channels.
if m.state == nil {
for i := range m.config.Channels {
Expand Down
45 changes: 40 additions & 5 deletions internal/pkg/orderer/runtime.go
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ import (
"github.com/hyperledger-labs/microfab/internal/pkg/util"
"github.com/hyperledger/fabric-protos-go/common"
"github.com/hyperledger/fabric-protos-go/orderer"
"github.com/hyperledger/fabric-protos-go/orderer/etcdraft"
"github.com/pkg/errors"
)

Expand Down Expand Up @@ -186,6 +187,44 @@ func (o *Orderer) hasStarted() bool {
func (o *Orderer) createGenesisBlock(consortium []*organization.Organization) error {
txID := txid.New(o.mspID, o.identity)
header := protoutil.BuildHeader(common.HeaderType_CONFIG, "testchainid", txID)

var consensusType *orderer.ConsensusType

if o.tls != nil {
// can either create a SOLO or full RAFT orderering service
consensusType = &orderer.ConsensusType{
// Metadata: nil,
// State: orderer.ConsensusType_STATE_NORMAL,
// Type: "solo",
Metadata: util.MarshalOrPanic(&etcdraft.ConfigMetadata{
Consenters: []*etcdraft.Consenter{
{
Host: o.apiURL.Host,
Port: uint32(o.apiPort),
// TODO: errr... what certificates?!
ClientTlsCert: o.tls.Certificate().Bytes(),
ServerTlsCert: o.tls.Certificate().Bytes(),
},
},
Options: &etcdraft.Options{
TickInterval: "2500ms",
ElectionTick: 5,
HeartbeatTick: 1,
MaxInflightBlocks: 5,
SnapshotIntervalSize: 1048576,
},
}),
State: orderer.ConsensusType_STATE_NORMAL,
Type: "etcdraft",
}
} else {
consensusType = &orderer.ConsensusType{
Metadata: nil,
State: orderer.ConsensusType_STATE_NORMAL,
Type: "solo",
}
}

config := &common.Config{
ChannelGroup: &common.ConfigGroup{
Groups: map[string]*common.ConfigGroup{
Expand Down Expand Up @@ -263,11 +302,7 @@ func (o *Orderer) createGenesisBlock(consortium []*organization.Organization) er
},
"ConsensusType": {
ModPolicy: "Admins",
Value: util.MarshalOrPanic(&orderer.ConsensusType{
Metadata: nil,
State: orderer.ConsensusType_STATE_NORMAL,
Type: "solo",
}),
Value: util.MarshalOrPanic(consensusType),
},
},
},
Expand Down
Loading