-
Notifications
You must be signed in to change notification settings - Fork 7
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Rebroadcast already signed messages from WAL
Previously, rebroadcast functioned by keeping track of message templates and calling `RequestBroadcast` again to re-broadcast them. This approach can cause erroneous behaviour when messages are re-signed in conjunction with participant churn. To avoid this category of errors treat broadcast final: Every broadcasted message is recorded in WAL and once recorded the same message is used for re-broadcast; no re-signing. A dedicated re-broadcast API is introduced to take instance, round and phase and use it to then look up broadcast messages. Note that as a result of the changes above, failures are also sicky. In that, if signing of a message fails at the time of original broadcast, future requests to rebroadcast it will have no effect. The changes here also include a series of WAL functionality refactors to make it easier to traverse write-ahead log entries. Fixes #474
- Loading branch information
Showing
15 changed files
with
363 additions
and
159 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,39 @@ | ||
package emulator | ||
|
||
import "github.com/filecoin-project/go-f3/gpbft" | ||
|
||
type MessageKey struct { | ||
Instance, Round uint64 | ||
Phase gpbft.Phase | ||
} | ||
|
||
// MessageCache is a repository of messages keyed by their instance, round and | ||
// phase. This cache is used for testing purposes only and has no eviction | ||
// strategy. It is primarily used to store messages from self for rebroadcast. | ||
type MessageCache map[MessageKey]*gpbft.GMessage | ||
|
||
func NewMessageCache() MessageCache { | ||
return make(map[MessageKey]*gpbft.GMessage) | ||
} | ||
|
||
func (mc MessageCache) Get(instance, round uint64, phase gpbft.Phase) (*gpbft.GMessage, bool) { | ||
msg, found := mc[MessageKey{ | ||
Instance: instance, | ||
Round: round, | ||
Phase: phase, | ||
}] | ||
return msg, found | ||
} | ||
|
||
func (mc MessageCache) PutIfAbsent(msg *gpbft.GMessage) bool { | ||
key := MessageKey{ | ||
Instance: msg.Vote.Instance, | ||
Round: msg.Vote.Round, | ||
Phase: msg.Vote.Phase, | ||
} | ||
if _, found := mc[key]; found { | ||
return false | ||
} | ||
mc[key] = msg | ||
return true | ||
} |
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
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
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
Oops, something went wrong.