-
Notifications
You must be signed in to change notification settings - Fork 15
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Restore simulator recordings [#3593]
- Loading branch information
1 parent
3a6fe26
commit daec34b
Showing
24 changed files
with
3,542 additions
and
270 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
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,22 @@ | ||
messageType: | ||
StartBlock: | ||
value: 0x10 | ||
ProposeLeader: | ||
value: 0x11 | ||
ProposeBlock: | ||
value: 0x12 | ||
AcceptBlockProposal: | ||
value: 0x13 | ||
FinalizedBlock: | ||
value: 0x14 | ||
CommittedBlock: | ||
value: 0x15 | ||
ExecutedBlock: | ||
value: 0x16 | ||
|
||
SubmitEnvelope: | ||
value: 0x20 | ||
AcceptedSubmission: | ||
value: 0x21 | ||
EnvelopeSubmitted: | ||
value: 0x22 |
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,134 @@ | ||
// Copyright 2024 The Accumulate Authors | ||
// | ||
// Use of this source code is governed by an MIT-style | ||
// license that can be found in the LICENSE file or at | ||
// https://opensource.org/licenses/MIT. | ||
|
||
package consensus | ||
|
||
// GENERATED BY go run ./tools/cmd/gen-enum. DO NOT EDIT. | ||
|
||
import ( | ||
"encoding/json" | ||
"fmt" | ||
"strings" | ||
) | ||
|
||
// messageTypeStartBlock . | ||
const messageTypeStartBlock messageType = 16 | ||
|
||
// messageTypeProposeLeader . | ||
const messageTypeProposeLeader messageType = 17 | ||
|
||
// messageTypeProposeBlock . | ||
const messageTypeProposeBlock messageType = 18 | ||
|
||
// messageTypeAcceptBlockProposal . | ||
const messageTypeAcceptBlockProposal messageType = 19 | ||
|
||
// messageTypeFinalizedBlock . | ||
const messageTypeFinalizedBlock messageType = 20 | ||
|
||
// messageTypeCommittedBlock . | ||
const messageTypeCommittedBlock messageType = 21 | ||
|
||
// messageTypeExecutedBlock . | ||
const messageTypeExecutedBlock messageType = 22 | ||
|
||
// messageTypeSubmitEnvelope . | ||
const messageTypeSubmitEnvelope messageType = 32 | ||
|
||
// messageTypeAcceptedSubmission . | ||
const messageTypeAcceptedSubmission messageType = 33 | ||
|
||
// messageTypeEnvelopeSubmitted . | ||
const messageTypeEnvelopeSubmitted messageType = 34 | ||
|
||
// GetEnumValue returns the value of the message Type | ||
func (v messageType) GetEnumValue() uint64 { return uint64(v) } | ||
|
||
// SetEnumValue sets the value. SetEnumValue returns false if the value is invalid. | ||
func (v *messageType) SetEnumValue(id uint64) bool { | ||
u := messageType(id) | ||
switch u { | ||
case messageTypeStartBlock, messageTypeProposeLeader, messageTypeProposeBlock, messageTypeAcceptBlockProposal, messageTypeFinalizedBlock, messageTypeCommittedBlock, messageTypeExecutedBlock, messageTypeSubmitEnvelope, messageTypeAcceptedSubmission, messageTypeEnvelopeSubmitted: | ||
*v = u | ||
return true | ||
} | ||
return false | ||
} | ||
|
||
// String returns the name of the message Type. | ||
func (v messageType) String() string { | ||
switch v { | ||
case messageTypeStartBlock: | ||
return "startBlock" | ||
case messageTypeProposeLeader: | ||
return "proposeLeader" | ||
case messageTypeProposeBlock: | ||
return "proposeBlock" | ||
case messageTypeAcceptBlockProposal: | ||
return "acceptBlockProposal" | ||
case messageTypeFinalizedBlock: | ||
return "finalizedBlock" | ||
case messageTypeCommittedBlock: | ||
return "committedBlock" | ||
case messageTypeExecutedBlock: | ||
return "executedBlock" | ||
case messageTypeSubmitEnvelope: | ||
return "submitEnvelope" | ||
case messageTypeAcceptedSubmission: | ||
return "acceptedSubmission" | ||
case messageTypeEnvelopeSubmitted: | ||
return "envelopeSubmitted" | ||
} | ||
return fmt.Sprintf("messageType:%d", v) | ||
} | ||
|
||
// messageTypeByName returns the named message Type. | ||
func messageTypeByName(name string) (messageType, bool) { | ||
switch strings.ToLower(name) { | ||
case "startblock": | ||
return messageTypeStartBlock, true | ||
case "proposeleader": | ||
return messageTypeProposeLeader, true | ||
case "proposeblock": | ||
return messageTypeProposeBlock, true | ||
case "acceptblockproposal": | ||
return messageTypeAcceptBlockProposal, true | ||
case "finalizedblock": | ||
return messageTypeFinalizedBlock, true | ||
case "committedblock": | ||
return messageTypeCommittedBlock, true | ||
case "executedblock": | ||
return messageTypeExecutedBlock, true | ||
case "submitenvelope": | ||
return messageTypeSubmitEnvelope, true | ||
case "acceptedsubmission": | ||
return messageTypeAcceptedSubmission, true | ||
case "envelopesubmitted": | ||
return messageTypeEnvelopeSubmitted, true | ||
} | ||
return 0, false | ||
} | ||
|
||
// MarshalJSON marshals the message Type to JSON as a string. | ||
func (v messageType) MarshalJSON() ([]byte, error) { | ||
return json.Marshal(v.String()) | ||
} | ||
|
||
// UnmarshalJSON unmarshals the message Type from JSON as a string. | ||
func (v *messageType) UnmarshalJSON(data []byte) error { | ||
var s string | ||
err := json.Unmarshal(data, &s) | ||
if err != nil { | ||
return err | ||
} | ||
|
||
var ok bool | ||
*v, ok = messageTypeByName(s) | ||
if !ok || strings.ContainsRune(v.String(), ':') { | ||
return fmt.Errorf("invalid message Type %q", s) | ||
} | ||
return nil | ||
} |
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,51 @@ | ||
// Copyright 2024 The Accumulate Authors | ||
// | ||
// Use of this source code is governed by an MIT-style | ||
// license that can be found in the LICENSE file or at | ||
// https://opensource.org/licenses/MIT. | ||
package consensus | ||
|
||
import "gitlab.com/accumulatenetwork/accumulate/pkg/types/encoding" | ||
|
||
//go:generate go run gitlab.com/accumulatenetwork/accumulate/tools/cmd/gen-enum --package consensus --out enums_gen.go enums.yml | ||
//go:generate go run gitlab.com/accumulatenetwork/accumulate/tools/cmd/gen-types --package consensus messages.yml | ||
//go:generate go run gitlab.com/accumulatenetwork/accumulate/tools/cmd/gen-types --package consensus --language go-union --out unions_gen.go messages.yml | ||
|
||
type messageType int | ||
|
||
// A Message is a message sent between modules. | ||
type Message interface { | ||
encoding.UnionValue | ||
isMsg() | ||
Type() messageType | ||
} | ||
|
||
// A NetworkMessage is a message that is specific to a network. | ||
type NetworkMessage interface { | ||
Message | ||
PartitionID() string | ||
} | ||
|
||
// nodeMessages are passed between nodes. | ||
type NodeMessage interface { | ||
NetworkMessage | ||
SenderID() [32]byte | ||
} | ||
|
||
func (*baseNodeMessage) isMsg() {} | ||
func (*SubmitEnvelope) isMsg() {} | ||
func (*EnvelopeSubmitted) isMsg() {} | ||
func (*StartBlock) isMsg() {} | ||
func (*ExecutedBlock) isMsg() {} | ||
|
||
func (m *baseNodeMessage) PartitionID() string { return m.Network } | ||
func (s *SubmitEnvelope) PartitionID() string { return s.Network } | ||
|
||
func (m *baseNodeMessage) SenderID() [32]byte { return m.PubKeyHash } | ||
|
||
var _ NodeMessage = (*proposeLeader)(nil) | ||
var _ NodeMessage = (*proposeBlock)(nil) | ||
var _ NodeMessage = (*acceptBlockProposal)(nil) | ||
var _ NodeMessage = (*finalizedBlock)(nil) | ||
var _ NodeMessage = (*committedBlock)(nil) | ||
var _ NetworkMessage = (*SubmitEnvelope)(nil) |
Oops, something went wrong.