diff --git a/CHANGELOG.md b/CHANGELOG.md index e37ab67cc..883576bb4 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1283,7 +1283,7 @@ This release contains a minor enhancement to the ABCI and some breaking changes - [p2p] [\#3338](https://github.com/tendermint/tendermint/issues/3338) Prevent "sent next PEX request too soon" errors by not calling ensurePeers outside of ensurePeersRoutine -- [behaviour] [\3772](https://github.com/tendermint/tendermint/pull/3772) Return correct reason in MessageOutOfOrder (@jim380) +- [behavior] [\3772](https://github.com/tendermint/tendermint/pull/3772) Return correct reason in MessageOutOfOrder (@jim380) - [config] [\#3723](https://github.com/tendermint/tendermint/issues/3723) Add consensus_params to testnet config generation; document time_iota_ms (@ashleyvega) @@ -1603,7 +1603,7 @@ It brings back `NetAddress()` to `NodeInfo` and uses it instead of `SocketAddr` Additionally, it improves response time on the `/validators` or `/status` RPC endpoints. As a side-effect it makes these RPC endpoint more difficult to DoS and fixes a performance degradation in `ExecCommitBlock`. Also, it contains an [ADR](https://github.com/tendermint/tendermint/pull/3539) that proposes decoupling the -responsibility for peer behaviour from the `p2p.Switch` (by @brapse). +responsibility for peer behavior from the `p2p.Switch` (by @brapse). Special thanks to external contributors on this release: @brapse, @guagualvcha, @mydring @@ -2271,8 +2271,8 @@ Special thanks to external contributors on this release: - [blockchain] [\#2731](https://github.com/tendermint/tendermint/issues/2731) Retry both blocks if either is bad to avoid getting stuck during fast sync (@goolAdapter) - [consensus] [\#2893](https://github.com/tendermint/tendermint/issues/2893) Use genDoc.Validators instead of state.NextValidators on replay when appHeight==0 (@james-ray) - [log] [\#2868](https://github.com/tendermint/tendermint/issues/2868) Fix `module=main` setting overriding all others - - NOTE: this changes the default logging behaviour to be much less verbose. - Set `log_level="info"` to restore the previous behaviour. + - NOTE: this changes the default logging behavior to be much less verbose. + Set `log_level="info"` to restore the previous behavior. - [rpc] [\#2808](https://github.com/tendermint/tendermint/issues/2808) Fix `accum` field in `/validators` by calling `IncrementAccum` if necessary - [rpc] [\#2811](https://github.com/tendermint/tendermint/issues/2811) Allow integer IDs in JSON-RPC requests (@tomtau) - [txindex/kv] [\#2759](https://github.com/tendermint/tendermint/issues/2759) Fix tx.height range queries @@ -2403,7 +2403,7 @@ increasing attention to backwards compatibility. Thanks for bearing with us! * [state] [\#2644](https://github.com/tendermint/tendermint/issues/2644) Add Version field to State, breaking the format of State as encoded on disk. * [rpc] [\#2298](https://github.com/tendermint/tendermint/issues/2298) `/abci_query` takes `prove` argument instead of `trusted` and switches the default - behaviour to `prove=false` + behavior to `prove=false` * [rpc] [\#2654](https://github.com/tendermint/tendermint/issues/2654) Remove all `node_info.other.*_version` fields in `/status` and `/net_info` * [rpc] [\#2636](https://github.com/tendermint/tendermint/issues/2636) Remove @@ -2548,7 +2548,7 @@ FEATURES: - [libs] [\#2286](https://github.com/tendermint/tendermint/issues/2286) Panic if `autofile` or `db/fsdb` permissions change from 0600. IMPROVEMENTS: -- [libs/db] [\#2371](https://github.com/tendermint/tendermint/issues/2371) Output error instead of panic when the given `db_backend` is not initialised (@bradyjoestar) +- [libs/db] [\#2371](https://github.com/tendermint/tendermint/issues/2371) Output error instead of panic when the given `db_backend` is not initialized (@bradyjoestar) - [mempool] [\#2399](https://github.com/tendermint/tendermint/issues/2399) Make mempool cache a proper LRU (@bradyjoestar) - [p2p] [\#2126](https://github.com/tendermint/tendermint/issues/2126) Introduce PeerTransport interface to improve isolation of concerns - [libs/common] [\#2326](https://github.com/tendermint/tendermint/issues/2326) Service returns ErrNotStarted diff --git a/CHANGELOG_PENDING.md b/CHANGELOG_PENDING.md index b88d1cbd1..a7a1b134f 100644 --- a/CHANGELOG_PENDING.md +++ b/CHANGELOG_PENDING.md @@ -1,6 +1,6 @@ # Unreleased Changes -## v0.34.21 +## v0.37.0 Special thanks to external contributors on this release: @@ -16,6 +16,9 @@ Friendly reminder, we have a [bug bounty program](https://hackerone.com/tendermi - Go API + - [all] [#9144] Change spelling from British English to American (@cmwaters) + - Rename "Subscription.Cancelled()" to "Subscription.Canceled()" in libs/pubsub + - Blockchain Protocol ### FEATURES diff --git a/CODE_OF_CONDUCT.md b/CODE_OF_CONDUCT.md index d51bf3ed5..21cf736ba 100644 --- a/CODE_OF_CONDUCT.md +++ b/CODE_OF_CONDUCT.md @@ -27,7 +27,7 @@ and hence to Tendermint. want to experiment with, make a fork and see how it works. * We will exclude you from interaction if you insult, demean or harass anyone. - That is not welcome behaviour. We interpret the term “harassment” as including + That is not welcome behavior. We interpret the term “harassment” as including the definition in the [Citizen Code of Conduct][ccoc]; if you have any lack of clarity about what might be included in that concept, please read their definition. In particular, we don’t tolerate behavior that excludes people in @@ -40,7 +40,7 @@ and hence to Tendermint. making this community a safe place for you and we’ve got your back. * Likewise any spamming, trolling, flaming, baiting or other attention-stealing - behaviour is not welcome. + behavior is not welcome. ---- diff --git a/UPGRADING.md b/UPGRADING.md index da2b4661b..87d5a0a7e 100644 --- a/UPGRADING.md +++ b/UPGRADING.md @@ -437,7 +437,7 @@ use `make build_c` / `make install_c` (full instructions can be found at ## v0.31.0 -This release contains a breaking change to the behaviour of the pubsub system. +This release contains a breaking change to the behavior of the pubsub system. It also contains some minor breaking changes in the Go API and ABCI. There are no changes to the block or p2p protocols, so v0.31.0 should work fine with blockchains created from the v0.30 series. @@ -455,7 +455,7 @@ In this case, the WS client will receive an error with description: "error": { "code": -32000, "msg": "Server error", - "data": "subscription was cancelled (reason: client is not pulling messages fast enough)" // or "subscription was cancelled (reason: Tendermint exited)" + "data": "subscription was canceled (reason: client is not pulling messages fast enough)" // or "subscription was canceled (reason: Tendermint exited)" } } @@ -636,7 +636,7 @@ to `timeout_propose = "3s"`. ### RPC Changes -The default behaviour of `/abci_query` has been changed to not return a proof, +The default behavior of `/abci_query` has been changed to not return a proof, and the name of the parameter that controls this has been changed from `trusted` to `prove`. To get proofs with your queries, ensure you set `prove=true`. diff --git a/behaviour/doc.go b/behavior/doc.go similarity index 77% rename from behaviour/doc.go rename to behavior/doc.go index 40061e095..c4bd06cce 100644 --- a/behaviour/doc.go +++ b/behavior/doc.go @@ -1,10 +1,10 @@ /* -Package Behaviour provides a mechanism for reactors to report behaviour of peers. +Package Behavior provides a mechanism for reactors to report behavior of peers. -Instead of a reactor calling the switch directly it will call the behaviour module which will +Instead of a reactor calling the switch directly it will call the behavior module which will handle the stoping and marking peer as good on behalf of the reactor. -There are four different behaviours a reactor can report. +There are four different behaviors a reactor can report. 1. bad message @@ -39,4 +39,4 @@ type blockPart struct { This message will request the peer be marked as good */ -package behaviour +package behavior diff --git a/behavior/peer_behavior.go b/behavior/peer_behavior.go new file mode 100644 index 000000000..c58ef9aca --- /dev/null +++ b/behavior/peer_behavior.go @@ -0,0 +1,49 @@ +package behavior + +import ( + "github.com/tendermint/tendermint/p2p" +) + +// PeerBehavior is a struct describing a behavior a peer performed. +// `peerID` identifies the peer and reason characterizes the specific +// behavior performed by the peer. +type PeerBehavior struct { + peerID p2p.ID + reason interface{} +} + +type badMessage struct { + explanation string +} + +// BadMessage returns a badMessage PeerBehavior. +func BadMessage(peerID p2p.ID, explanation string) PeerBehavior { + return PeerBehavior{peerID: peerID, reason: badMessage{explanation}} +} + +type messageOutOfOrder struct { + explanation string +} + +// MessageOutOfOrder returns a messagOutOfOrder PeerBehavior. +func MessageOutOfOrder(peerID p2p.ID, explanation string) PeerBehavior { + return PeerBehavior{peerID: peerID, reason: messageOutOfOrder{explanation}} +} + +type consensusVote struct { + explanation string +} + +// ConsensusVote returns a consensusVote PeerBehavior. +func ConsensusVote(peerID p2p.ID, explanation string) PeerBehavior { + return PeerBehavior{peerID: peerID, reason: consensusVote{explanation}} +} + +type blockPart struct { + explanation string +} + +// BlockPart returns blockPart PeerBehavior. +func BlockPart(peerID p2p.ID, explanation string) PeerBehavior { + return PeerBehavior{peerID: peerID, reason: blockPart{explanation}} +} diff --git a/behaviour/reporter.go b/behavior/reporter.go similarity index 62% rename from behaviour/reporter.go rename to behavior/reporter.go index 8dc10389e..b85c88437 100644 --- a/behaviour/reporter.go +++ b/behavior/reporter.go @@ -1,4 +1,4 @@ -package behaviour +package behavior import ( "errors" @@ -7,13 +7,13 @@ import ( "github.com/tendermint/tendermint/p2p" ) -// Reporter provides an interface for reactors to report the behaviour +// Reporter provides an interface for reactors to report the behavior // of peers synchronously to other components. type Reporter interface { - Report(behaviour PeerBehaviour) error + Report(behavior PeerBehavior) error } -// SwitchReporter reports peer behaviour to an internal Switch. +// SwitchReporter reports peer behavior to an internal Switch. type SwitchReporter struct { sw *p2p.Switch } @@ -25,14 +25,14 @@ func NewSwitchReporter(sw *p2p.Switch) *SwitchReporter { } } -// Report reports the behaviour of a peer to the Switch. -func (spbr *SwitchReporter) Report(behaviour PeerBehaviour) error { - peer := spbr.sw.Peers().Get(behaviour.peerID) +// Report reports the behavior of a peer to the Switch. +func (spbr *SwitchReporter) Report(behavior PeerBehavior) error { + peer := spbr.sw.Peers().Get(behavior.peerID) if peer == nil { return errors.New("peer not found") } - switch reason := behaviour.reason.(type) { + switch reason := behavior.reason.(type) { case consensusVote, blockPart: spbr.sw.MarkPeerAsGood(peer) case badMessage: @@ -48,39 +48,39 @@ func (spbr *SwitchReporter) Report(behaviour PeerBehaviour) error { // MockReporter is a concrete implementation of the Reporter // interface used in reactor tests to ensure reactors report the correct -// behaviour in manufactured scenarios. +// behavior in manufactured scenarios. type MockReporter struct { mtx tmsync.RWMutex - pb map[p2p.ID][]PeerBehaviour + pb map[p2p.ID][]PeerBehavior } // NewMockReporter returns a Reporter which records all reported -// behaviours in memory. +// behaviors in memory. func NewMockReporter() *MockReporter { return &MockReporter{ - pb: map[p2p.ID][]PeerBehaviour{}, + pb: map[p2p.ID][]PeerBehavior{}, } } -// Report stores the PeerBehaviour produced by the peer identified by peerID. -func (mpbr *MockReporter) Report(behaviour PeerBehaviour) error { +// Report stores the PeerBehavior produced by the peer identified by peerID. +func (mpbr *MockReporter) Report(behavior PeerBehavior) error { mpbr.mtx.Lock() defer mpbr.mtx.Unlock() - mpbr.pb[behaviour.peerID] = append(mpbr.pb[behaviour.peerID], behaviour) + mpbr.pb[behavior.peerID] = append(mpbr.pb[behavior.peerID], behavior) return nil } -// GetBehaviours returns all behaviours reported on the peer identified by peerID. -func (mpbr *MockReporter) GetBehaviours(peerID p2p.ID) []PeerBehaviour { +// GetBehaviours returns all behaviors reported on the peer identified by peerID. +func (mpbr *MockReporter) GetBehaviours(peerID p2p.ID) []PeerBehavior { mpbr.mtx.RLock() defer mpbr.mtx.RUnlock() if items, ok := mpbr.pb[peerID]; ok { - result := make([]PeerBehaviour, len(items)) + result := make([]PeerBehavior, len(items)) copy(result, items) return result } - return []PeerBehaviour{} + return []PeerBehavior{} } diff --git a/behavior/reporter_test.go b/behavior/reporter_test.go new file mode 100644 index 000000000..ed07310bd --- /dev/null +++ b/behavior/reporter_test.go @@ -0,0 +1,205 @@ +package behavior_test + +import ( + "sync" + "testing" + + bh "github.com/tendermint/tendermint/behavior" + "github.com/tendermint/tendermint/p2p" +) + +// TestMockReporter tests the MockReporter's ability to store reported +// peer behavior in memory indexed by the peerID. +func TestMockReporter(t *testing.T) { + var peerID p2p.ID = "MockPeer" + pr := bh.NewMockReporter() + + behaviors := pr.GetBehaviours(peerID) + if len(behaviors) != 0 { + t.Error("Expected to have no behaviors reported") + } + + badMessage := bh.BadMessage(peerID, "bad message") + if err := pr.Report(badMessage); err != nil { + t.Error(err) + } + behaviors = pr.GetBehaviours(peerID) + if len(behaviors) != 1 { + t.Error("Expected the peer have one reported behavior") + } + + if behaviors[0] != badMessage { + t.Error("Expected Bad Message to have been reported") + } +} + +type scriptItem struct { + peerID p2p.ID + behavior bh.PeerBehavior +} + +// equalBehaviours returns true if a and b contain the same PeerBehaviors with +// the same freequencies and otherwise false. +func equalBehaviours(a []bh.PeerBehavior, b []bh.PeerBehavior) bool { + aHistogram := map[bh.PeerBehavior]int{} + bHistogram := map[bh.PeerBehavior]int{} + + for _, behavior := range a { + aHistogram[behavior]++ + } + + for _, behavior := range b { + bHistogram[behavior]++ + } + + if len(aHistogram) != len(bHistogram) { + return false + } + + for _, behavior := range a { + if aHistogram[behavior] != bHistogram[behavior] { + return false + } + } + + for _, behavior := range b { + if bHistogram[behavior] != aHistogram[behavior] { + return false + } + } + + return true +} + +// TestEqualPeerBehaviors tests that equalBehaviours can tell that two slices +// of peer behaviors can be compared for the behaviors they contain and the +// freequencies that those behaviors occur. +func TestEqualPeerBehaviors(t *testing.T) { + var ( + peerID p2p.ID = "MockPeer" + consensusVote = bh.ConsensusVote(peerID, "voted") + blockPart = bh.BlockPart(peerID, "blocked") + equals = []struct { + left []bh.PeerBehavior + right []bh.PeerBehavior + }{ + // Empty sets + {[]bh.PeerBehavior{}, []bh.PeerBehavior{}}, + // Single behaviors + {[]bh.PeerBehavior{consensusVote}, []bh.PeerBehavior{consensusVote}}, + // Equal Frequencies + {[]bh.PeerBehavior{consensusVote, consensusVote}, + []bh.PeerBehavior{consensusVote, consensusVote}}, + // Equal frequencies different orders + {[]bh.PeerBehavior{consensusVote, blockPart}, + []bh.PeerBehavior{blockPart, consensusVote}}, + } + unequals = []struct { + left []bh.PeerBehavior + right []bh.PeerBehavior + }{ + // Comparing empty sets to non empty sets + {[]bh.PeerBehavior{}, []bh.PeerBehavior{consensusVote}}, + // Different behaviors + {[]bh.PeerBehavior{consensusVote}, []bh.PeerBehavior{blockPart}}, + // Same behavior with different frequencies + {[]bh.PeerBehavior{consensusVote}, + []bh.PeerBehavior{consensusVote, consensusVote}}, + } + ) + + for _, test := range equals { + if !equalBehaviours(test.left, test.right) { + t.Errorf("expected %#v and %#v to be equal", test.left, test.right) + } + } + + for _, test := range unequals { + if equalBehaviours(test.left, test.right) { + t.Errorf("expected %#v and %#v to be unequal", test.left, test.right) + } + } +} + +// TestPeerBehaviorConcurrency constructs a scenario in which +// multiple goroutines are using the same MockReporter instance. +// This test reproduces the conditions in which MockReporter will +// be used within a Reactor `Receive` method tests to ensure thread safety. +func TestMockPeerBehaviorReporterConcurrency(t *testing.T) { + var ( + behaviorScript = []struct { + peerID p2p.ID + behaviors []bh.PeerBehavior + }{ + {"1", []bh.PeerBehavior{bh.ConsensusVote("1", "")}}, + {"2", []bh.PeerBehavior{bh.ConsensusVote("2", ""), bh.ConsensusVote("2", ""), bh.ConsensusVote("2", "")}}, + { + "3", + []bh.PeerBehavior{bh.BlockPart("3", ""), + bh.ConsensusVote("3", ""), + bh.BlockPart("3", ""), + bh.ConsensusVote("3", "")}}, + { + "4", + []bh.PeerBehavior{bh.ConsensusVote("4", ""), + bh.ConsensusVote("4", ""), + bh.ConsensusVote("4", ""), + bh.ConsensusVote("4", "")}}, + { + "5", + []bh.PeerBehavior{bh.BlockPart("5", ""), + bh.ConsensusVote("5", ""), + bh.BlockPart("5", ""), + bh.ConsensusVote("5", "")}}, + } + ) + + var receiveWg sync.WaitGroup + pr := bh.NewMockReporter() + scriptItems := make(chan scriptItem) + done := make(chan int) + numConsumers := 3 + for i := 0; i < numConsumers; i++ { + receiveWg.Add(1) + go func() { + defer receiveWg.Done() + for { + select { + case pb := <-scriptItems: + if err := pr.Report(pb.behavior); err != nil { + t.Error(err) + } + case <-done: + return + } + } + }() + } + + var sendingWg sync.WaitGroup + sendingWg.Add(1) + go func() { + defer sendingWg.Done() + for _, item := range behaviorScript { + for _, reason := range item.behaviors { + scriptItems <- scriptItem{item.peerID, reason} + } + } + }() + + sendingWg.Wait() + + for i := 0; i < numConsumers; i++ { + done <- 1 + } + + receiveWg.Wait() + + for _, items := range behaviorScript { + reported := pr.GetBehaviours(items.peerID) + if !equalBehaviours(reported, items.behaviors) { + t.Errorf("expected peer %s to have behaved \nExpected: %#v \nGot %#v \n", + items.peerID, items.behaviors, reported) + } + } +} diff --git a/behaviour/peer_behaviour.go b/behaviour/peer_behaviour.go deleted file mode 100644 index f7cfd00f0..000000000 --- a/behaviour/peer_behaviour.go +++ /dev/null @@ -1,49 +0,0 @@ -package behaviour - -import ( - "github.com/tendermint/tendermint/p2p" -) - -// PeerBehaviour is a struct describing a behaviour a peer performed. -// `peerID` identifies the peer and reason characterizes the specific -// behaviour performed by the peer. -type PeerBehaviour struct { - peerID p2p.ID - reason interface{} -} - -type badMessage struct { - explanation string -} - -// BadMessage returns a badMessage PeerBehaviour. -func BadMessage(peerID p2p.ID, explanation string) PeerBehaviour { - return PeerBehaviour{peerID: peerID, reason: badMessage{explanation}} -} - -type messageOutOfOrder struct { - explanation string -} - -// MessageOutOfOrder returns a messagOutOfOrder PeerBehaviour. -func MessageOutOfOrder(peerID p2p.ID, explanation string) PeerBehaviour { - return PeerBehaviour{peerID: peerID, reason: messageOutOfOrder{explanation}} -} - -type consensusVote struct { - explanation string -} - -// ConsensusVote returns a consensusVote PeerBehaviour. -func ConsensusVote(peerID p2p.ID, explanation string) PeerBehaviour { - return PeerBehaviour{peerID: peerID, reason: consensusVote{explanation}} -} - -type blockPart struct { - explanation string -} - -// BlockPart returns blockPart PeerBehaviour. -func BlockPart(peerID p2p.ID, explanation string) PeerBehaviour { - return PeerBehaviour{peerID: peerID, reason: blockPart{explanation}} -} diff --git a/behaviour/reporter_test.go b/behaviour/reporter_test.go deleted file mode 100644 index 330505bd2..000000000 --- a/behaviour/reporter_test.go +++ /dev/null @@ -1,205 +0,0 @@ -package behaviour_test - -import ( - "sync" - "testing" - - bh "github.com/tendermint/tendermint/behaviour" - "github.com/tendermint/tendermint/p2p" -) - -// TestMockReporter tests the MockReporter's ability to store reported -// peer behaviour in memory indexed by the peerID. -func TestMockReporter(t *testing.T) { - var peerID p2p.ID = "MockPeer" - pr := bh.NewMockReporter() - - behaviours := pr.GetBehaviours(peerID) - if len(behaviours) != 0 { - t.Error("Expected to have no behaviours reported") - } - - badMessage := bh.BadMessage(peerID, "bad message") - if err := pr.Report(badMessage); err != nil { - t.Error(err) - } - behaviours = pr.GetBehaviours(peerID) - if len(behaviours) != 1 { - t.Error("Expected the peer have one reported behaviour") - } - - if behaviours[0] != badMessage { - t.Error("Expected Bad Message to have been reported") - } -} - -type scriptItem struct { - peerID p2p.ID - behaviour bh.PeerBehaviour -} - -// equalBehaviours returns true if a and b contain the same PeerBehaviours with -// the same freequencies and otherwise false. -func equalBehaviours(a []bh.PeerBehaviour, b []bh.PeerBehaviour) bool { - aHistogram := map[bh.PeerBehaviour]int{} - bHistogram := map[bh.PeerBehaviour]int{} - - for _, behaviour := range a { - aHistogram[behaviour]++ - } - - for _, behaviour := range b { - bHistogram[behaviour]++ - } - - if len(aHistogram) != len(bHistogram) { - return false - } - - for _, behaviour := range a { - if aHistogram[behaviour] != bHistogram[behaviour] { - return false - } - } - - for _, behaviour := range b { - if bHistogram[behaviour] != aHistogram[behaviour] { - return false - } - } - - return true -} - -// TestEqualPeerBehaviours tests that equalBehaviours can tell that two slices -// of peer behaviours can be compared for the behaviours they contain and the -// freequencies that those behaviours occur. -func TestEqualPeerBehaviours(t *testing.T) { - var ( - peerID p2p.ID = "MockPeer" - consensusVote = bh.ConsensusVote(peerID, "voted") - blockPart = bh.BlockPart(peerID, "blocked") - equals = []struct { - left []bh.PeerBehaviour - right []bh.PeerBehaviour - }{ - // Empty sets - {[]bh.PeerBehaviour{}, []bh.PeerBehaviour{}}, - // Single behaviours - {[]bh.PeerBehaviour{consensusVote}, []bh.PeerBehaviour{consensusVote}}, - // Equal Frequencies - {[]bh.PeerBehaviour{consensusVote, consensusVote}, - []bh.PeerBehaviour{consensusVote, consensusVote}}, - // Equal frequencies different orders - {[]bh.PeerBehaviour{consensusVote, blockPart}, - []bh.PeerBehaviour{blockPart, consensusVote}}, - } - unequals = []struct { - left []bh.PeerBehaviour - right []bh.PeerBehaviour - }{ - // Comparing empty sets to non empty sets - {[]bh.PeerBehaviour{}, []bh.PeerBehaviour{consensusVote}}, - // Different behaviours - {[]bh.PeerBehaviour{consensusVote}, []bh.PeerBehaviour{blockPart}}, - // Same behaviour with different frequencies - {[]bh.PeerBehaviour{consensusVote}, - []bh.PeerBehaviour{consensusVote, consensusVote}}, - } - ) - - for _, test := range equals { - if !equalBehaviours(test.left, test.right) { - t.Errorf("expected %#v and %#v to be equal", test.left, test.right) - } - } - - for _, test := range unequals { - if equalBehaviours(test.left, test.right) { - t.Errorf("expected %#v and %#v to be unequal", test.left, test.right) - } - } -} - -// TestPeerBehaviourConcurrency constructs a scenario in which -// multiple goroutines are using the same MockReporter instance. -// This test reproduces the conditions in which MockReporter will -// be used within a Reactor `Receive` method tests to ensure thread safety. -func TestMockPeerBehaviourReporterConcurrency(t *testing.T) { - var ( - behaviourScript = []struct { - peerID p2p.ID - behaviours []bh.PeerBehaviour - }{ - {"1", []bh.PeerBehaviour{bh.ConsensusVote("1", "")}}, - {"2", []bh.PeerBehaviour{bh.ConsensusVote("2", ""), bh.ConsensusVote("2", ""), bh.ConsensusVote("2", "")}}, - { - "3", - []bh.PeerBehaviour{bh.BlockPart("3", ""), - bh.ConsensusVote("3", ""), - bh.BlockPart("3", ""), - bh.ConsensusVote("3", "")}}, - { - "4", - []bh.PeerBehaviour{bh.ConsensusVote("4", ""), - bh.ConsensusVote("4", ""), - bh.ConsensusVote("4", ""), - bh.ConsensusVote("4", "")}}, - { - "5", - []bh.PeerBehaviour{bh.BlockPart("5", ""), - bh.ConsensusVote("5", ""), - bh.BlockPart("5", ""), - bh.ConsensusVote("5", "")}}, - } - ) - - var receiveWg sync.WaitGroup - pr := bh.NewMockReporter() - scriptItems := make(chan scriptItem) - done := make(chan int) - numConsumers := 3 - for i := 0; i < numConsumers; i++ { - receiveWg.Add(1) - go func() { - defer receiveWg.Done() - for { - select { - case pb := <-scriptItems: - if err := pr.Report(pb.behaviour); err != nil { - t.Error(err) - } - case <-done: - return - } - } - }() - } - - var sendingWg sync.WaitGroup - sendingWg.Add(1) - go func() { - defer sendingWg.Done() - for _, item := range behaviourScript { - for _, reason := range item.behaviours { - scriptItems <- scriptItem{item.peerID, reason} - } - } - }() - - sendingWg.Wait() - - for i := 0; i < numConsumers; i++ { - done <- 1 - } - - receiveWg.Wait() - - for _, items := range behaviourScript { - reported := pr.GetBehaviours(items.peerID) - if !equalBehaviours(reported, items.behaviours) { - t.Errorf("expected peer %s to have behaved \nExpected: %#v \nGot %#v \n", - items.peerID, items.behaviours, reported) - } - } -} diff --git a/blockchain/v1/reactor.go b/blockchain/v1/reactor.go index c4c61ec51..2eb4e7618 100644 --- a/blockchain/v1/reactor.go +++ b/blockchain/v1/reactor.go @@ -5,7 +5,7 @@ import ( "reflect" "time" - "github.com/tendermint/tendermint/behaviour" + "github.com/tendermint/tendermint/behavior" bc "github.com/tendermint/tendermint/blockchain" "github.com/tendermint/tendermint/libs/log" "github.com/tendermint/tendermint/p2p" @@ -66,7 +66,7 @@ type BlockchainReactor struct { // the switch. eventsFromFSMCh chan bcFsmMessage - swReporter *behaviour.SwitchReporter + swReporter *behavior.SwitchReporter } // NewBlockchainReactor returns new reactor instance. @@ -100,7 +100,7 @@ func NewBlockchainReactor(state sm.State, blockExec *sm.BlockExecutor, store *st fsm := NewFSM(startHeight, bcR) bcR.fsm = fsm bcR.BaseReactor = *p2p.NewBaseReactor("BlockchainReactor", bcR) - // bcR.swReporter = behaviour.NewSwitchReporter(bcR.BaseReactor.Switch) + // bcR.swReporter = behavior.NewSwitchReporter(bcR.BaseReactor.Switch) return bcR } @@ -138,7 +138,7 @@ func (bcR *BlockchainReactor) SetLogger(l log.Logger) { // OnStart implements service.Service. func (bcR *BlockchainReactor) OnStart() error { - bcR.swReporter = behaviour.NewSwitchReporter(bcR.BaseReactor.Switch) + bcR.swReporter = behavior.NewSwitchReporter(bcR.BaseReactor.Switch) if bcR.fastSync { go bcR.poolRoutine() } @@ -254,13 +254,13 @@ func (bcR *BlockchainReactor) Receive(chID byte, src p2p.Peer, msgBytes []byte) msg, err := bc.DecodeMsg(msgBytes) if err != nil { bcR.Logger.Error("error decoding message", "src", src, "chId", chID, "err", err) - _ = bcR.swReporter.Report(behaviour.BadMessage(src.ID(), err.Error())) + _ = bcR.swReporter.Report(behavior.BadMessage(src.ID(), err.Error())) return } if err = bc.ValidateMsg(msg); err != nil { bcR.Logger.Error("peer sent us invalid msg", "peer", src, "msg", msg, "err", err) - _ = bcR.swReporter.Report(behaviour.BadMessage(src.ID(), err.Error())) + _ = bcR.swReporter.Report(behavior.BadMessage(src.ID(), err.Error())) return } @@ -451,7 +451,7 @@ ForLoop: func (bcR *BlockchainReactor) reportPeerErrorToSwitch(err error, peerID p2p.ID) { peer := bcR.Switch.Peers().Get(peerID) if peer != nil { - _ = bcR.swReporter.Report(behaviour.BadMessage(peerID, err.Error())) + _ = bcR.swReporter.Report(behavior.BadMessage(peerID, err.Error())) } } diff --git a/blockchain/v2/processor_test.go b/blockchain/v2/processor_test.go index 6bc36b2d3..04ce05b6e 100644 --- a/blockchain/v2/processor_test.go +++ b/blockchain/v2/processor_test.go @@ -82,7 +82,7 @@ func executeProcessorTests(t *testing.T, tests []testFields) { } }() - // First step must always initialise the currentState as state. + // First step must always initialize the currentState as state. if step.currentState != nil { state = makeState(step.currentState) } diff --git a/blockchain/v2/reactor.go b/blockchain/v2/reactor.go index 9dea749d7..e091182eb 100644 --- a/blockchain/v2/reactor.go +++ b/blockchain/v2/reactor.go @@ -5,7 +5,7 @@ import ( "fmt" "time" - "github.com/tendermint/tendermint/behaviour" + "github.com/tendermint/tendermint/behavior" bc "github.com/tendermint/tendermint/blockchain" "github.com/tendermint/tendermint/libs/log" tmsync "github.com/tendermint/tendermint/libs/sync" @@ -42,7 +42,7 @@ type BlockchainReactor struct { syncHeight int64 events chan Event // non-nil during a fast sync - reporter behaviour.Reporter + reporter behavior.Reporter io iIO store blockStore } @@ -57,7 +57,7 @@ type blockApplier interface { } // XXX: unify naming in this package around tmState -func newReactor(state state.State, store blockStore, reporter behaviour.Reporter, +func newReactor(state state.State, store blockStore, reporter behavior.Reporter, blockApplier blockApplier, fastSync bool) *BlockchainReactor { initHeight := state.LastBlockHeight + 1 if initHeight == 1 { @@ -85,7 +85,7 @@ func NewBlockchainReactor( blockApplier blockApplier, store blockStore, fastSync bool) *BlockchainReactor { - reporter := behaviour.NewMockReporter() + reporter := behavior.NewMockReporter() return newReactor(state, store, reporter, blockApplier, fastSync) } @@ -129,7 +129,7 @@ func (r *BlockchainReactor) SetLogger(logger log.Logger) { // Start implements cmn.Service interface func (r *BlockchainReactor) Start() error { - r.reporter = behaviour.NewSwitchReporter(r.BaseReactor.Switch) + r.reporter = behavior.NewSwitchReporter(r.BaseReactor.Switch) if r.fastSync { err := r.startSync(nil) if err != nil { @@ -139,7 +139,7 @@ func (r *BlockchainReactor) Start() error { return nil } -// startSync begins a fast sync, signalled by r.events being non-nil. If state is non-nil, +// startSync begins a fast sync, signaled by r.events being non-nil. If state is non-nil, // the scheduler and processor is updated with this state on startup. func (r *BlockchainReactor) startSync(state *state.State) error { r.mtx.Lock() @@ -376,7 +376,7 @@ func (r *BlockchainReactor) demux(events <-chan Event) { r.processor.send(event) case scPeerError: r.processor.send(event) - if err := r.reporter.Report(behaviour.BadMessage(event.peerID, "scPeerError")); err != nil { + if err := r.reporter.Report(behavior.BadMessage(event.peerID, "scPeerError")); err != nil { r.logger.Error("Error reporting peer", "err", err) } case scBlockRequest: @@ -460,13 +460,13 @@ func (r *BlockchainReactor) Receive(chID byte, src p2p.Peer, msgBytes []byte) { if err != nil { r.logger.Error("error decoding message", "src", src.ID(), "chId", chID, "msg", msg, "err", err) - _ = r.reporter.Report(behaviour.BadMessage(src.ID(), err.Error())) + _ = r.reporter.Report(behavior.BadMessage(src.ID(), err.Error())) return } if err = bc.ValidateMsg(msg); err != nil { r.logger.Error("peer sent us invalid msg", "peer", src, "msg", msg, "err", err) - _ = r.reporter.Report(behaviour.BadMessage(src.ID(), err.Error())) + _ = r.reporter.Report(behavior.BadMessage(src.ID(), err.Error())) return } diff --git a/blockchain/v2/reactor_test.go b/blockchain/v2/reactor_test.go index c2792d58b..ba59b31c1 100644 --- a/blockchain/v2/reactor_test.go +++ b/blockchain/v2/reactor_test.go @@ -14,7 +14,7 @@ import ( dbm "github.com/tendermint/tm-db" abci "github.com/tendermint/tendermint/abci/types" - "github.com/tendermint/tendermint/behaviour" + "github.com/tendermint/tendermint/behavior" bc "github.com/tendermint/tendermint/blockchain" cfg "github.com/tendermint/tendermint/config" "github.com/tendermint/tendermint/libs/log" @@ -144,7 +144,7 @@ type testReactorParams struct { func newTestReactor(p testReactorParams) *BlockchainReactor { store, state, _ := newReactorStore(p.genDoc, p.privVals, p.startHeight) - reporter := behaviour.NewMockReporter() + reporter := behavior.NewMockReporter() var appl blockApplier @@ -301,7 +301,7 @@ func newTestReactor(p testReactorParams) *BlockchainReactor { // t.Run(tt.name, func(t *testing.T) { // reactor := newTestReactor(params) // reactor.Start() -// reactor.reporter = behaviour.NewMockReporter() +// reactor.reporter = behavior.NewMockReporter() // mockSwitch := &mockSwitchIo{switchedToConsensus: false} // reactor.io = mockSwitch // // time for go routines to start diff --git a/blockchain/v2/scheduler_test.go b/blockchain/v2/scheduler_test.go index 762ffd2c5..5d4ebd976 100644 --- a/blockchain/v2/scheduler_test.go +++ b/blockchain/v2/scheduler_test.go @@ -2225,7 +2225,7 @@ func TestScHandle(t *testing.T) { t.Run(tt.name, func(t *testing.T) { var sc *scheduler for i, step := range tt.steps { - // First step must always initialise the currentState as state. + // First step must always initialize the currentState as state. if step.currentSc != nil { sc = newTestScheduler(*step.currentSc) } diff --git a/cmd/tendermint/commands/init.go b/cmd/tendermint/commands/init.go index 5d80a41ca..e2eae6eef 100644 --- a/cmd/tendermint/commands/init.go +++ b/cmd/tendermint/commands/init.go @@ -14,7 +14,7 @@ import ( tmtime "github.com/tendermint/tendermint/types/time" ) -// InitFilesCmd initialises a fresh Tendermint Core instance. +// InitFilesCmd initializes a fresh Tendermint Core instance. var InitFilesCmd = &cobra.Command{ Use: "init", Short: "Initialize Tendermint", diff --git a/cmd/tendermint/commands/light.go b/cmd/tendermint/commands/light.go index d98b8cded..2bab77213 100644 --- a/cmd/tendermint/commands/light.go +++ b/cmd/tendermint/commands/light.go @@ -101,7 +101,7 @@ func init() { } func runProxy(cmd *cobra.Command, args []string) error { - // Initialise logger. + // Initialize logger. logger := log.NewTMLogger(log.NewSyncWriter(os.Stdout)) var option log.Option if verbose { diff --git a/config/config.go b/config/config.go index d052b40ae..cdd384dd0 100644 --- a/config/config.go +++ b/config/config.go @@ -370,7 +370,7 @@ type RPCConfig struct { // // Enabling this parameter will cause the WebSocket connection to be closed // instead if it cannot read fast enough, allowing for greater - // predictability in subscription behaviour. + // predictability in subscription behavior. CloseOnSlowClient bool `mapstructure:"experimental_close_on_slow_client"` // How long to wait for a tx to be committed during /broadcast_tx_commit diff --git a/config/toml.go b/config/toml.go index ad40b1efc..c57b4db84 100644 --- a/config/toml.go +++ b/config/toml.go @@ -230,7 +230,7 @@ experimental_websocket_write_buffer_size = {{ .RPC.WebSocketWriteBufferSize }} # # Enabling this experimental parameter will cause the WebSocket connection to # be closed instead if it cannot read fast enough, allowing for greater -# predictability in subscription behaviour. +# predictability in subscription behavior. experimental_close_on_slow_client = {{ .RPC.CloseOnSlowClient }} # How long to wait for a tx to be committed during /broadcast_tx_commit. diff --git a/consensus/byzantine_test.go b/consensus/byzantine_test.go index dd5febcbd..3dce0b604 100644 --- a/consensus/byzantine_test.go +++ b/consensus/byzantine_test.go @@ -446,8 +446,8 @@ func TestByzantineConflictingProposalsWithPartition(t *testing.T) { case <-done: case <-tick.C: for i, reactor := range reactors { - t.Log(fmt.Sprintf("Consensus Reactor %v", i)) - t.Log(fmt.Sprintf("%v", reactor)) + t.Logf("Consensus Reactor %v", i) + t.Logf("%v", reactor) } t.Fatalf("Timed out waiting for all validators to commit first block") } diff --git a/consensus/replay.go b/consensus/replay.go index 9fd59a40e..8e378113e 100644 --- a/consensus/replay.go +++ b/consensus/replay.go @@ -55,7 +55,7 @@ func (cs *State) readReplayMessage(msg *TimedWALMessage, newStepSub types.Subscr return fmt.Errorf("roundState mismatch. Got %v; Expected %v", m2, m) } case <-newStepSub.Cancelled(): - return fmt.Errorf("failed to read off newStepSub.Out(). newStepSub was cancelled") + return fmt.Errorf("failed to read off newStepSub.Out(). newStepSub was canceled") case <-ticker: return fmt.Errorf("failed to read off newStepSub.Out()") } diff --git a/consensus/replay_test.go b/consensus/replay_test.go index 2970f15ed..a081e262e 100644 --- a/consensus/replay_test.go +++ b/consensus/replay_test.go @@ -98,7 +98,7 @@ func startNewStateAndWaitForBlock(t *testing.T, consensusReplayConfig *cfg.Confi select { case <-newBlockSub.Out(): case <-newBlockSub.Cancelled(): - t.Fatal("newBlockSub was cancelled") + t.Fatal("newBlockSub was canceled") case <-time.After(120 * time.Second): t.Fatal("Timed out waiting for new block (see trace above)") } diff --git a/consensus/state.go b/consensus/state.go index 9e6d980a3..2eee62166 100644 --- a/consensus/state.go +++ b/consensus/state.go @@ -821,7 +821,7 @@ func (cs *State) handleMsg(mi msgInfo) { // We unlock here to yield to any routines that need to read the the RoundState. // Previously, this code held the lock from the point at which the final block - // part was recieved until the block executed against the application. + // part was received until the block executed against the application. // This prevented the reactor from being able to retrieve the most updated // version of the RoundState. The reactor needs the updated RoundState to // gossip the now completed block. @@ -2034,7 +2034,7 @@ func (cs *State) addVote(vote *types.Vote, peerID p2p.ID) (added bool, err error } // Height mismatch is ignored. - // Not necessarily a bad peer, but not favourable behaviour. + // Not necessarily a bad peer, but not favorable behavior. if vote.Height != cs.Height { cs.Logger.Debug("vote ignored and not added", "vote_height", vote.Height, "cs_height", cs.Height, "peer", peerID) return diff --git a/docs/architecture/README.md b/docs/architecture/README.md index e75896f38..9e1219060 100644 --- a/docs/architecture/README.md +++ b/docs/architecture/README.md @@ -77,7 +77,7 @@ Note the context/background should be written in the present tense. - [ADR-006: Trust-Metric](./adr-006-trust-metric.md) - [ADR-024: Sign-Bytes](./adr-024-sign-bytes.md) - [ADR-035: Documentation](./adr-035-documentation.md) -- [ADR-039: Peer-Behaviour](./adr-039-peer-behaviour.md) +- [ADR-039: Peer-Behaviour](./adr-039-peer-behavior.md) - [ADR-060: Go-API-Stability](./adr-060-go-api-stability.md) - [ADR-061: P2P-Refactor-Scope](./adr-061-p2p-refactor-scope.md) - [ADR-065: Custom Event Indexing](./adr-065-custom-event-indexing.md) diff --git a/docs/architecture/adr-007-trust-metric-usage.md b/docs/architecture/adr-007-trust-metric-usage.md index de3a088cb..0daa4bb33 100644 --- a/docs/architecture/adr-007-trust-metric-usage.md +++ b/docs/architecture/adr-007-trust-metric-usage.md @@ -10,8 +10,8 @@ As the node becomes well connected to the rest of the network, it can dial lesse quality peers and help assess their quality. Similarly, when queried for peers, a node should make sure they dont return low quality peers. -Peer quality can be tracked using a trust metric that flags certain behaviours as good or bad. When enough -bad behaviour accumulates, we can mark the peer as bad and disconnect. +Peer quality can be tracked using a trust metric that flags certain behaviors as good or bad. When enough +bad behavior accumulates, we can mark the peer as bad and disconnect. For example, when the PEXReactor makes a request for peers network addresses from an already known peer, and the returned network addresses are unreachable, this undesirable behavior should be tracked. Returning a few bad network addresses probably shouldn’t cause a peer to be dropped, while excessive amounts of this behavior does qualify the peer for removal. The originally proposed approach and design document for the trust metric can be found in the [ADR 006](adr-006-trust-metric.md) document. The trust metric implementation allows a developer to obtain a peer's trust metric from a trust metric store, and track good and bad events relevant to a peer's behavior, and at any time, the peer's metric can be queried for a current trust value. The current trust value is calculated with a formula that utilizes current behavior, previous behavior, and change between the two. Current behavior is calculated as the percentage of good behavior within a time interval. The time interval is short; probably set between 30 seconds and 5 minutes. On the other hand, the historic data can estimate a peer's behavior over days worth of tracking. At the end of a time interval, the current behavior becomes part of the historic data, and a new time interval begins with the good and bad counters reset to zero. @@ -77,7 +77,7 @@ When a peer receives a pexRequestMessage, it returns a random sample of high qua Peer quality is tracked in the connection and across the reactors by storing the TrustMetric in the peer's thread safe Data store. -Peer behaviour is then defined as one of the following: +Peer behavior is then defined as one of the following: - Fatal - something outright malicious that causes us to disconnect the peer and ban it from the address book for some amount of time - Bad - Any kind of timeout, messages that don't unmarshal, fail other validity checks, or messages we didn't ask for or aren't expecting (usually worth one bad event) @@ -85,7 +85,7 @@ Peer behaviour is then defined as one of the following: - Correct - Normal correct behavior (worth one good event) - Good - some random majority of peers per reactor sending us useful messages (worth more than one good event). -Note that Fatal behaviour causes us to remove the peer, and neutral behaviour does not affect the score. +Note that Fatal behavior causes us to remove the peer, and neutral behavior does not affect the score. ## Status diff --git a/docs/architecture/adr-009-ABCI-design.md b/docs/architecture/adr-009-ABCI-design.md index 6acd31991..c1ad3a614 100644 --- a/docs/architecture/adr-009-ABCI-design.md +++ b/docs/architecture/adr-009-ABCI-design.md @@ -74,7 +74,7 @@ convenient to work with address information, and for it to be simple to do so. ### AbsentValidators Tendermint also provides a list of validators in BeginBlock who did not sign the -last block. This allows applications to reflect availability behaviour in the +last block. This allows applications to reflect availability behavior in the application, for instance by punishing validators for not having votes included in commits. diff --git a/docs/architecture/adr-016-protocol-versions.md b/docs/architecture/adr-016-protocol-versions.md index 3a2351a56..e52743e5c 100644 --- a/docs/architecture/adr-016-protocol-versions.md +++ b/docs/architecture/adr-016-protocol-versions.md @@ -75,14 +75,14 @@ to connect to peers with older version. ### P2PVersion -- All p2p and reactor messaging (messages, detectable behaviour) +- All p2p and reactor messaging (messages, detectable behavior) - Will change gradually as reactors evolve to improve performance and support new features - eg proposed new message types BatchTx in the mempool and HasBlockPart in the consensus - It's easy to determine the version of a peer from its first serialized message/s - New versions must be compatible with at least one old version to allow gradual upgrades ### AppVersion -- The ABCI state machine (txs, begin/endblock behaviour, commit hashing) +- The ABCI state machine (txs, begin/endblock behavior, commit hashing) - Behaviour and message types will change abruptly in the course of the life of a chain - Need to minimize complexity of the code for supporting different AppVersions at different heights - Ideally, each version of the software supports only a _single_ AppVersion at one time diff --git a/docs/architecture/adr-023-ABCI-propose-tx.md b/docs/architecture/adr-023-ABCI-propose-tx.md index 34963b1ba..af8ea8b8f 100644 --- a/docs/architecture/adr-023-ABCI-propose-tx.md +++ b/docs/architecture/adr-023-ABCI-propose-tx.md @@ -28,14 +28,14 @@ Due to the requirements of [Minimal Viable Plasma (MVP)](https://ethresear.ch/t/ `exit` transactions may also be treated in a similar manner, wherein the input is the UTXO being exited on the Root Chain, and the output belongs to - a reserved "burn" address, e.g., `0x0`. In such cases, it is favourable for + a reserved "burn" address, e.g., `0x0`. In such cases, it is favorable for the containing block to only hold a single transaction that may receive special treatment. 2. Other "internal" transactions on the child chain, which may be initiated unilaterally. The most basic example of is a coinbase transaction implementing validator node incentives, but may also be app-specific. In - these cases, it may be favourable for such transactions to + these cases, it may be favorable for such transactions to be ordered in a specific manner, e.g., coinbase transactions will always be at index 0. In general, such strategies increase the determinism and predictability of blockchain applications. diff --git a/docs/architecture/adr-039-peer-behaviour.md b/docs/architecture/adr-039-peer-behaviour.md index 4ad051a35..2fb63f4b2 100644 --- a/docs/architecture/adr-039-peer-behaviour.md +++ b/docs/architecture/adr-039-peer-behaviour.md @@ -6,20 +6,20 @@ ## Context -The responsibility for signaling and acting upon peer behaviour lacks a single +The responsibility for signaling and acting upon peer behavior lacks a single owning component and is heavily coupled with the network stack[1](#references). Reactors maintain a reference to the `p2p.Switch` which they use to call `switch.StopPeerForError(...)` when a peer misbehaves and `switch.MarkAsGood(...)` when a peer contributes in some meaningful way. While the switch handles `StopPeerForError` internally, the `MarkAsGood` method delegates to another component, `p2p.AddrBook`. This scheme of delegation -across Switch obscures the responsibility for handling peer behaviour +across Switch obscures the responsibility for handling peer behavior and ties up the reactors in a larger dependency graph when testing. ## Decision Introduce a `PeerBehaviour` interface and concrete implementations which -provide methods for reactors to signal peer behaviour without direct +provide methods for reactors to signal peer behavior without direct coupling `p2p.Switch`. Introduce a ErrorBehaviourPeer to provide concrete reasons for stopping peers. Introduce GoodBehaviourPeer to provide concrete ways in which a peer contributes. @@ -139,10 +139,10 @@ Accepted ### Positive - * De-couple signaling from acting upon peer behaviour. + * De-couple signaling from acting upon peer behavior. * Reduce the coupling of reactors and the Switch and the network stack - * The responsibility of managing peer behaviour can be migrated to + * The responsibility of managing peer behavior can be migrated to a single component instead of split between the switch and the address book. diff --git a/docs/architecture/adr-042-state-sync.md b/docs/architecture/adr-042-state-sync.md index 72d71ae22..a15893183 100644 --- a/docs/architecture/adr-042-state-sync.md +++ b/docs/architecture/adr-042-state-sync.md @@ -146,7 +146,7 @@ subjectivity](https://github.com/tendermint/tendermint/pull/3795)) and can compare any subset of keys called a chunk against the merkle root. The advantage of light client validation is that the block headers are signed by validators which have something to lose for malicious -behaviour. If a validator were to provide an invalid proof, they can be +behavior. If a validator were to provide an invalid proof, they can be slashed. Majority of peer validation: A manifest file containing a list of chunks diff --git a/docs/architecture/adr-045-abci-evidence.md b/docs/architecture/adr-045-abci-evidence.md index a88039824..abdc0aba3 100644 --- a/docs/architecture/adr-045-abci-evidence.md +++ b/docs/architecture/adr-045-abci-evidence.md @@ -22,7 +22,7 @@ main chain - so called Fork-Lite. See the document for more details. For a sequential lite client, this can happen via equivocation or amnesia attacks. For a skipping lite client this can also happen via lunatic validator attacks. There must be some way for applications to punish -all forms of misbehaviour. +all forms of misbehavior. The essential question is whether Tendermint should manage the evidence verification, or whether it should treat evidence more like a transaction (ie. @@ -52,7 +52,7 @@ Arguments in favor of leaving evidence handling in Tendermint: currently](https://github.com/tendermint/tendermint/blob/c67154232ca8be8f5c21dff65d154127adc4f7bb/docs/spec/consensus/fork-detection.md) is via a centralized monitor service that is trusted for liveness to aggregate data from - current and past validators, but which produces a proof of misbehaviour (ie. + current and past validators, but which produces a proof of misbehavior (ie. via amnesia) that can be verified by anyone, including the blockchain. Validators must submit all the votes they saw for the relevant consensus height to justify their precommits. This is quite specific to the Tendermint diff --git a/docs/architecture/adr-059-evidence-composition-and-lifecycle.md b/docs/architecture/adr-059-evidence-composition-and-lifecycle.md index 521dee257..e38b39089 100644 --- a/docs/architecture/adr-059-evidence-composition-and-lifecycle.md +++ b/docs/architecture/adr-059-evidence-composition-and-lifecycle.md @@ -189,7 +189,7 @@ After verification we persist the evidence with the key `height/hash` to the pen #### ABCI Evidence -Both evidence structures contain data (such as timestamp) that are necessary to be passed to the application but do not strictly constitute evidence of misbehaviour. As such, these fields are verified last. If any of these fields are invalid to a node i.e. they don't correspond with their state, nodes will reconstruct a new evidence struct from the existing fields and repopulate the abci specific fields with their own state data. +Both evidence structures contain data (such as timestamp) that are necessary to be passed to the application but do not strictly constitute evidence of misbehavior. As such, these fields are verified last. If any of these fields are invalid to a node i.e. they don't correspond with their state, nodes will reconstruct a new evidence struct from the existing fields and repopulate the abci specific fields with their own state data. #### Broadcasting and receiving evidence diff --git a/docs/architecture/adr-075-rpc-subscription.md b/docs/architecture/adr-075-rpc-subscription.md index 1ca48e712..1bb53f337 100644 --- a/docs/architecture/adr-075-rpc-subscription.md +++ b/docs/architecture/adr-075-rpc-subscription.md @@ -48,7 +48,7 @@ to the node. Unlike the other methods of the service, for which each call is serviced by a short-lived HTTP round trip, subscription delivers a continuous stream of events to the client by hijacking the HTTP channel for a websocket. The stream (and hence the HTTP request) persists until either the subscription -is explicitly cancelled, or the connection is closed. +is explicitly canceled, or the connection is closed. There are several problems with this API: diff --git a/docs/introduction/what-is-tendermint.md b/docs/introduction/what-is-tendermint.md index 9cff48a2a..88dc2c1fa 100644 --- a/docs/introduction/what-is-tendermint.md +++ b/docs/introduction/what-is-tendermint.md @@ -67,7 +67,7 @@ configuration, service discovery, locking, leader-election, and so on. Tendermint is in essence similar software, but with two key differences: - It is Byzantine Fault Tolerant, meaning it can only tolerate up to a - 1/3 of failures, but those failures can include arbitrary behaviour - + 1/3 of failures, but those failures can include arbitrary behavior - including hacking and malicious attacks. - It does not specify a particular application, like a fancy key-value store. Instead, it focuses on arbitrary state machine replication, so developers can build @@ -101,13 +101,13 @@ Another example of a cryptocurrency application built on Tendermint is [Fabric](https://github.com/hyperledger/fabric) takes a similar approach to Tendermint, but is more opinionated about how the state is managed, -and requires that all application behaviour runs in potentially many +and requires that all application behavior runs in potentially many docker containers, modules it calls "chaincode". It uses an implementation of [PBFT](http://pmg.csail.mit.edu/papers/osdi99.pdf). from a team at IBM that is [augmented to handle potentially non-deterministic chaincode](https://www.zurich.ibm.com/~cca/papers/sieve.pdf) It is -possible to implement this docker-based behaviour as a ABCI app in +possible to implement this docker-based behavior as a ABCI app in Tendermint, though extending Tendermint to handle non-determinism remains for future work. diff --git a/docs/tendermint-core/running-in-production.md b/docs/tendermint-core/running-in-production.md index 41f40641e..7e7dae549 100644 --- a/docs/tendermint-core/running-in-production.md +++ b/docs/tendermint-core/running-in-production.md @@ -17,7 +17,7 @@ Tendermint keeps multiple distinct databases in the `$TMROOT/data`: - `blockstore.db`: Keeps the entire blockchain - stores blocks, block commits, and block meta data, each indexed by height. Used to sync new peers. -- `evidence.db`: Stores all verified evidence of misbehaviour. +- `evidence.db`: Stores all verified evidence of misbehavior. - `state.db`: Stores the current blockchain state (ie. height, validators, consensus params). Only grows if consensus params or validators change. Also used to temporarily store intermediate results during block processing. diff --git a/light/provider/http/http.go b/light/provider/http/http.go index 665fcbe70..dcf1b0d10 100644 --- a/light/provider/http/http.go +++ b/light/provider/http/http.go @@ -193,7 +193,7 @@ func (p *http) signedHeader(ctx context.Context, height *int64) (*types.SignedHe time.Sleep(backoffTimeout(uint16(attempt))) continue - // either context was cancelled or connection refused. + // either context was canceled or connection refused. default: return nil, err } diff --git a/node/node_test.go b/node/node_test.go index 9b82d6ca2..b62e79fe4 100644 --- a/node/node_test.go +++ b/node/node_test.go @@ -52,7 +52,7 @@ func TestNodeStartStop(t *testing.T) { select { case <-blocksSub.Out(): case <-blocksSub.Cancelled(): - t.Fatal("blocksSub was cancelled") + t.Fatal("blocksSub was canceled") case <-time.After(10 * time.Second): t.Fatal("timed out waiting for the node to produce a block") } @@ -123,7 +123,7 @@ func TestNodeSetAppVersion(t *testing.T) { require.NoError(t, err) // default config uses the kvstore app - var appVersion uint64 = kvstore.ProtocolVersion + var appVersion = kvstore.ProtocolVersion // check version is set in state state, err := n.stateStore.Load() diff --git a/p2p/netaddress.go b/p2p/netaddress.go index b42d325c8..e3daa1a87 100644 --- a/p2p/netaddress.go +++ b/p2p/netaddress.go @@ -329,7 +329,7 @@ func (na *NetAddress) ReachabilityTo(o *NetAddress) int { case o.IP.To4() != nil: return Ipv4 case tunneled: - // only prioritise ipv6 if we aren't tunnelling it. + // only prioritize ipv6 if we aren't tunneling it. return Ipv6Weak } return Ipv6Strong diff --git a/p2p/pex/addrbook_test.go b/p2p/pex/addrbook_test.go index ad41d5562..c04ad9c3a 100644 --- a/p2p/pex/addrbook_test.go +++ b/p2p/pex/addrbook_test.go @@ -771,7 +771,7 @@ func countOldAndNewAddrsInSelection(addrs []*p2p.NetAddress, book *addrBook) (nO return } -// Analyse the layout of the selection specified by 'addrs' +// Analyze the layout of the selection specified by 'addrs' // Returns: // - seqLens - the lengths of the sequences of addresses of same type // - seqTypes - the types of sequences in selection diff --git a/p2p/pex/pex_reactor.go b/p2p/pex/pex_reactor.go index a13e3170e..0c3ba218d 100644 --- a/p2p/pex/pex_reactor.go +++ b/p2p/pex/pex_reactor.go @@ -489,7 +489,7 @@ func (r *Reactor) ensurePeers() { } // TODO: consider moving some checks from toDial into here // so we don't even consider dialing peers that we want to wait - // before dialling again, or have dialed too many times already + // before dialing again, or have dialed too many times already toDial[try.ID] = try } diff --git a/p2p/transport.go b/p2p/transport.go index 1257f38b3..e6e19a901 100644 --- a/p2p/transport.go +++ b/p2p/transport.go @@ -20,7 +20,7 @@ const ( defaultHandshakeTimeout = 3 * time.Second ) -// IPResolver is a behaviour subset of net.Resolver. +// IPResolver is a behavior subset of net.Resolver. type IPResolver interface { LookupIPAddr(context.Context, string) ([]net.IPAddr, error) } @@ -70,7 +70,7 @@ type Transport interface { } // transportLifecycle bundles the methods for callers to control start and stop -// behaviour. +// behavior. type transportLifecycle interface { Close() error Listen(NetAddress) error diff --git a/p2p/transport_test.go b/p2p/transport_test.go index 7638de4cb..90b074256 100644 --- a/p2p/transport_test.go +++ b/p2p/transport_test.go @@ -79,8 +79,8 @@ func TestTransportMultiplexConnFilter(t *testing.T) { } _, err = mt.Accept(peerConfig{}) - if err, ok := err.(ErrRejected); ok { - if !err.IsFiltered() { + if e, ok := err.(ErrRejected); ok { + if !e.IsFiltered() { t.Errorf("expected peer to be filtered, got %v", err) } } else { @@ -386,8 +386,8 @@ func TestTransportMultiplexValidateNodeInfo(t *testing.T) { } _, err := mt.Accept(peerConfig{}) - if err, ok := err.(ErrRejected); ok { - if !err.IsNodeInfoInvalid() { + if e, ok := err.(ErrRejected); ok { + if !e.IsNodeInfoInvalid() { t.Errorf("expected NodeInfo to be invalid, got %v", err) } } else { @@ -425,9 +425,9 @@ func TestTransportMultiplexRejectMissmatchID(t *testing.T) { } _, err := mt.Accept(peerConfig{}) - if err, ok := err.(ErrRejected); ok { - if !err.IsAuthFailure() { - t.Errorf("expected auth failure, got %v", err) + if e, ok := err.(ErrRejected); ok { + if !e.IsAuthFailure() { + t.Errorf("expected auth failure, got %v", e) } } else { t.Errorf("expected ErrRejected, got %v", err) @@ -453,9 +453,9 @@ func TestTransportMultiplexDialRejectWrongID(t *testing.T) { _, err := dialer.Dial(*addr, peerConfig{}) if err != nil { t.Logf("connection failed: %v", err) - if err, ok := err.(ErrRejected); ok { - if !err.IsAuthFailure() { - t.Errorf("expected auth failure, got %v", err) + if e, ok := err.(ErrRejected); ok { + if !e.IsAuthFailure() { + t.Errorf("expected auth failure, got %v", e) } } else { t.Errorf("expected ErrRejected, got %v", err) @@ -490,9 +490,9 @@ func TestTransportMultiplexRejectIncompatible(t *testing.T) { }() _, err := mt.Accept(peerConfig{}) - if err, ok := err.(ErrRejected); ok { - if !err.IsIncompatible() { - t.Errorf("expected to reject incompatible, got %v", err) + if e, ok := err.(ErrRejected); ok { + if !e.IsIncompatible() { + t.Errorf("expected to reject incompatible, got %v", e) } } else { t.Errorf("expected ErrRejected, got %v", err) @@ -517,9 +517,9 @@ func TestTransportMultiplexRejectSelf(t *testing.T) { }() if err := <-errc; err != nil { - if err, ok := err.(ErrRejected); ok { - if !err.IsSelf() { - t.Errorf("expected to reject self, got: %v", err) + if e, ok := err.(ErrRejected); ok { + if !e.IsSelf() { + t.Errorf("expected to reject self, got: %v", e) } } else { t.Errorf("expected ErrRejected, got %v", err) diff --git a/rpc/client/interface.go b/rpc/client/interface.go index cda5c541c..36dc2f7d1 100644 --- a/rpc/client/interface.go +++ b/rpc/client/interface.go @@ -138,7 +138,7 @@ type MempoolClient interface { } // EvidenceClient is used for submitting an evidence of the malicious -// behaviour. +// behavior. type EvidenceClient interface { BroadcastEvidence(context.Context, types.Evidence) (*ctypes.ResultBroadcastEvidence, error) } diff --git a/rpc/client/local/local.go b/rpc/client/local/local.go index 62c8415a7..d0dfc3723 100644 --- a/rpc/client/local/local.go +++ b/rpc/client/local/local.go @@ -259,7 +259,7 @@ func (c *Local) eventsRoutine( return } - c.Logger.Error("subscription was cancelled, resubscribing...", "err", sub.Err(), "query", q.String()) + c.Logger.Error("subscription was canceled, resubscribing...", "err", sub.Err(), "query", q.String()) sub = c.resubscribe(subscriber, q) if sub == nil { // client was stopped return diff --git a/rpc/core/events.go b/rpc/core/events.go index ae4577650..1b4e6d778 100644 --- a/rpc/core/events.go +++ b/rpc/core/events.go @@ -66,7 +66,7 @@ func Subscribe(ctx *rpctypes.Context, query string) (*ctypes.ResultSubscribe, er if closeIfSlow { var ( - err = errors.New("subscription was cancelled (reason: slow client)") + err = errors.New("subscription was canceled (reason: slow client)") resp = rpctypes.RPCServerError(subscriptionID, err) ) if !ctx.WSConn.TryWriteRPCResponse(resp) { @@ -85,7 +85,7 @@ func Subscribe(ctx *rpctypes.Context, query string) (*ctypes.ResultSubscribe, er reason = sub.Err().Error() } var ( - err = fmt.Errorf("subscription was cancelled (reason: %s)", reason) + err = fmt.Errorf("subscription was canceled (reason: %s)", reason) resp = rpctypes.RPCServerError(subscriptionID, err) ) if !ctx.WSConn.TryWriteRPCResponse(resp) { diff --git a/rpc/core/mempool.go b/rpc/core/mempool.go index f9fa4b37e..8e8dbdcf2 100644 --- a/rpc/core/mempool.go +++ b/rpc/core/mempool.go @@ -128,7 +128,7 @@ func BroadcastTxCommit(ctx *rpctypes.Context, tx types.Tx) (*ctypes.ResultBroadc } else { reason = deliverTxSub.Err().Error() } - err = fmt.Errorf("deliverTxSub was cancelled (reason: %s)", reason) + err = fmt.Errorf("deliverTxSub was canceled (reason: %s)", reason) env.Logger.Error("Error on broadcastTxCommit", "err", err) return &ctypes.ResultBroadcastTxCommit{ CheckTx: *checkTxRes, diff --git a/rpc/jsonrpc/server/ws_handler.go b/rpc/jsonrpc/server/ws_handler.go index e4e5d7504..f8a89714e 100644 --- a/rpc/jsonrpc/server/ws_handler.go +++ b/rpc/jsonrpc/server/ws_handler.go @@ -49,7 +49,7 @@ func NewWebsocketManager( CheckOrigin: func(r *http.Request) bool { // TODO ??? // - // The default behaviour would be relevant to browser-based clients, + // The default behavior would be relevant to browser-based clients, // afaik. I suppose having a pass-through is a workaround for allowing // for more complex security schemes, shifting the burden of // AuthN/AuthZ outside the Tendermint RPC. diff --git a/spec/abci/abci.md b/spec/abci/abci.md index edcb4ff83..634daec68 100644 --- a/spec/abci/abci.md +++ b/spec/abci/abci.md @@ -161,8 +161,8 @@ Example: ## EvidenceType Tendermint's security model relies on the use of "evidence". Evidence is proof of -malicious behaviour by a network participant. It is the responsibility of Tendermint -to detect such malicious behaviour. When malicious behavior is detected, Tendermint +malicious behavior by a network participant. It is the responsibility of Tendermint +to detect such malicious behavior. When malicious behavior is detected, Tendermint will gossip evidence of the behavior to other nodes and commit the evidence to the chain once it is verified by all validators. This evidence will then be passed it on to the application through the ABCI. It is the responsibility of the @@ -734,7 +734,7 @@ Most of the data structures used in ABCI are shared [common data structures](../ | Name | Type | Description | Field Number | |-----------|---------------------------------------------------------------|------------------------------------------------------------------------------|--------------| | block | [BlockParams](../core/data_structures.md#blockparams) | Parameters limiting the size of a block and time between consecutive blocks. | 1 | - | evidence | [EvidenceParams](../core/data_structures.md#evidenceparams) | Parameters limiting the validity of evidence of byzantine behaviour. | 2 | + | evidence | [EvidenceParams](../core/data_structures.md#evidenceparams) | Parameters limiting the validity of evidence of byzantine behavior. | 2 | | validator | [ValidatorParams](../core/data_structures.md#validatorparams) | Parameters limiting the types of public keys validators can use. | 3 | | version | [VersionsParams](../core/data_structures.md#versionparams) | The ABCI application version. | 4 | diff --git a/spec/core/data_structures.md b/spec/core/data_structures.md index 87bea298f..eea150d68 100644 --- a/spec/core/data_structures.md +++ b/spec/core/data_structures.md @@ -130,7 +130,7 @@ the data in the current block, the previous block, and the results returned by t | ConsensusHash | slice of bytes (`[]byte`) | Hash of the protobuf encoded consensus parameters. | Must be of length 32 | | AppHash | slice of bytes (`[]byte`) | Arbitrary byte array returned by the application after executing and commiting the previous block. It serves as the basis for validating any merkle proofs that comes from the ABCI application and represents the state of the actual application rather than the state of the blockchain itself. The first block's `block.Header.AppHash` is given by `ResponseInitChain.app_hash`. | This hash is determined by the application, Tendermint can not perform validation on it. | | LastResultHash | slice of bytes (`[]byte`) | `LastResultsHash` is the root hash of a Merkle tree built from `ResponseDeliverTx` responses (`Log`,`Info`, `Codespace` and `Events` fields are ignored). | Must be of length 32. The first block has `block.Header.ResultsHash == MerkleRoot(nil)`, i.e. the hash of an empty input, for RFC-6962 conformance. | -| EvidenceHash | slice of bytes (`[]byte`) | MerkleRoot of the evidence of Byzantine behaviour included in this block. | Must be of length 32 | +| EvidenceHash | slice of bytes (`[]byte`) | MerkleRoot of the evidence of Byzantine behavior included in this block. | Must be of length 32 | | ProposerAddress | slice of bytes (`[]byte`) | Address of the original proposer of the block. Validator must be in the current validatorSet. | Must be of length 20 | ## Version @@ -415,7 +415,7 @@ func SumTruncated(bz []byte) []byte { | Name | Type | Description | Field Number | |-----------|-------------------------------------|------------------------------------------------------------------------------|--------------| | block | [BlockParams](#blockparams) | Parameters limiting the size of a block and time between consecutive blocks. | 1 | -| evidence | [EvidenceParams](#evidenceparams) | Parameters limiting the validity of evidence of byzantine behaviour. | 2 | +| evidence | [EvidenceParams](#evidenceparams) | Parameters limiting the validity of evidence of byzantine behavior. | 2 | | validator | [ValidatorParams](#validatorparams) | Parameters limiting the types of public keys validators can use. | 3 | | version | [BlockParams](#blockparams) | The ABCI application version. | 4 | diff --git a/spec/light-client/accountability/TendermintAcc_004_draft.tla b/spec/light-client/accountability/TendermintAcc_004_draft.tla index 9d3a543d4..952d8c569 100644 --- a/spec/light-client/accountability/TendermintAcc_004_draft.tla +++ b/spec/light-client/accountability/TendermintAcc_004_draft.tla @@ -21,7 +21,7 @@ Byzantine processes can demonstrate arbitrary behavior, including no communication. We show that if agreement is violated, then the Byzantine - processes demonstrate one of the two behaviours: + processes demonstrate one of the two behaviors: - Equivocation: a Byzantine process may send two different values in the same round. diff --git a/spec/light-client/detection/draft-functions.md b/spec/light-client/detection/draft-functions.md index c56594a53..6512d733f 100644 --- a/spec/light-client/detection/draft-functions.md +++ b/spec/light-client/detection/draft-functions.md @@ -14,7 +14,7 @@ submitting proof of fork in the IBC context #### [TAG-IBC-MISBEHAVIOR.1] ```go -func checkMisbehaviourAndUpdateState(cs: ClientState, PoF: LightNodeProofOfFork) +func checkMisbehaviorAndUpdateState(cs: ClientState, PoF: LightNodeProofOfFork) ``` **TODO:** finish conditions @@ -113,7 +113,7 @@ func SubmitIBCProofOfFork( ibc IBCComponent) (Error) { if ibc.queryChainConsensusState(PoF.TrustedBlock.Height) = PoF.TrustedBlock { // IBC component has root of PoF on store, we can just submit - ibc.submitMisbehaviourToClient(ibc.id,PoF) + ibc.submitMisbehaviorToClient(ibc.id,PoF) return Success // note sure about the id parameter } @@ -127,7 +127,7 @@ func SubmitIBCProofOfFork( if result = Success { newPoF = extendPoF(ibcLightBlock, lblock, lightStore, PoF) - ibc.submitMisbehaviourToClient(ibc.id, newPoF) + ibc.submitMisbehaviorToClient(ibc.id, newPoF) return Success } else{ diff --git a/spec/light-client/detection/req-ibc-detection.md b/spec/light-client/detection/req-ibc-detection.md index 439ca26b6..9d82a279b 100644 --- a/spec/light-client/detection/req-ibc-detection.md +++ b/spec/light-client/detection/req-ibc-detection.md @@ -24,7 +24,7 @@ In the following, I distilled what I considered relevant from | `Height` | (no epochs) | (epoch,height) pair in lexicographical order (`compare`) | | `Header` | ~signed header | validatorSet explicit (no hash); nextValidators missing | | `Evidence` | t.b.d. | definition unclear "which the light client would have considered valid". Data structure will need to change | -| `verify` | `ValidAndVerified` | signature does not match perfectly (ClientState vs. LightBlock) + in `checkMisbehaviourAndUpdateState` it is unclear whether it uses traces or goes to h1 and h2 in one step | +| `verify` | `ValidAndVerified` | signature does not match perfectly (ClientState vs. LightBlock) + in `checkMisbehaviorAndUpdateState` it is unclear whether it uses traces or goes to h1 and h2 in one step | #### Some IBC links @@ -32,14 +32,14 @@ In the following, I distilled what I considered relevant from #### Required Changes in ICS 007 -- `assert(height > 0)` in definition of `initialise` doesn't match +- `assert(height > 0)` in definition of `initialize` doesn't match definition of `Height` as *(epoch,height)* pair. -- `initialise` needs to be updated to new data structures +- `initialize` needs to be updated to new data structures - `clientState.frozenHeight` semantics seem not totally consistent in document. E.g., `min` needs to be defined over optional value in - `checkMisbehaviourAndUpdateState`. Also, if you are frozen, why do + `checkMisbehaviorAndUpdateState`. Also, if you are frozen, why do you accept more evidence. - `checkValidityAndUpdateState` @@ -53,7 +53,7 @@ In the following, I distilled what I considered relevant from - clienstState needs to be updated according to complete data structure -- `checkMisbehaviourAndUpdateState`: as evidence will contain a trace +- `checkMisbehaviorAndUpdateState`: as evidence will contain a trace (or two), the assertion that uses verify will need to change. - ICS 002 states w.r.t. `queryChainConsensusState` that "Note that @@ -68,7 +68,7 @@ In the following, I distilled what I considered relevant from - `upgradeClientState` what is the semantics (in particular what is `height` doing?). -- `checkMisbehaviourAndUpdateState(cs: ClientState, PoF: +- `checkMisbehaviorAndUpdateState(cs: ClientState, PoF: LightNodeProofOfFork)` needs to be adapted #### Handler @@ -104,7 +104,7 @@ type checkValidityAndUpdateState = (Header) => Void will need to make precise eventually) to a handler ```go -type checkMisbehaviourAndUpdateState = (bytes) => Void +type checkMisbehaviorAndUpdateState = (bytes) => Void ``` We have to design this, and the data that the handler can use to @@ -126,7 +126,7 @@ type queryChainConsensusState = (height: uint64) => ConsensusState - the relayer send headers and data to the handler to invoke `checkValidityAndUpdateState` and - `checkMisbehaviourAndUpdateState`. It may also query + `checkMisbehaviorAndUpdateState`. It may also query `queryChainConsensusState`. - multiple relayers may talk to one handler. Some relayers might be @@ -187,7 +187,7 @@ relayer can figure that out: headers (tagged as verified). - eventually, a handler should be informed - (`checkMisbehaviourAndUpdateState`) + (`checkMisbehaviorAndUpdateState`) by some relayer that it has verified a header from a fork. Then the handler should do what is required by IBC in this case (stop?) diff --git a/spec/light-client/verification/README.md b/spec/light-client/verification/README.md index 8777374ac..dd9e0bb21 100644 --- a/spec/light-client/verification/README.md +++ b/spec/light-client/verification/README.md @@ -323,8 +323,8 @@ from `trustedState` to `newTrustedState` happened during the trusted period of In case `VerifyHeaderAtHeight` returns with an error, then either (i) the full node we are talking to is faulty or (ii) the trusted header has expired (it is outside its trusted period). In case (i) the full node is faulty so -light client should disconnect and reinitialise with new peer. In the case (ii) as the trusted header has expired, -we need to reinitialise light client with a new trusted header (that is within its trusted period), +light client should disconnect and reinitialize with new peer. In the case (ii) as the trusted header has expired, +we need to reinitialize light client with a new trusted header (that is within its trusted period), but we don't necessarily need to disconnect from the full node we are talking to (as we haven't observed full node misbehavior in this case). **VerifyBisection.** The function `VerifyBisection` implements @@ -459,10 +459,10 @@ We consider the following set-up: - the light client communicates with one full node - the light client locally stores all the headers that has passed basic verification and that are within light client trust period. In the pseudo code below we write *Store.Add(header)* for this. If a header failed to verify, then -the full node we are talking to is faulty and we should disconnect from it and reinitialise with new peer. +the full node we are talking to is faulty and we should disconnect from it and reinitialize with new peer. - If `CanTrust` returns *error*, then the light client has seen a forged header or the trusted header has expired (it is outside its trusted period). - - In case of forged header, the full node is faulty so light client should disconnect and reinitialise with new peer. If the trusted header has expired, - we need to reinitialise light client with new trusted header (that is within its trusted period), but we don't necessarily need to disconnect from the full node + - In case of forged header, the full node is faulty so light client should disconnect and reinitialize with new peer. If the trusted header has expired, + we need to reinitialize light client with new trusted header (that is within its trusted period), but we don't necessarily need to disconnect from the full node we are talking to (as we haven't observed full node misbehavior in this case). ## Correctness of the Light Client Protocols diff --git a/state/execution_test.go b/state/execution_test.go index 3d7fa93ab..a8aeffe93 100644 --- a/state/execution_test.go +++ b/state/execution_test.go @@ -408,7 +408,7 @@ func TestEndBlockValidatorUpdates(t *testing.T) { assert.EqualValues(t, 10, event.ValidatorUpdates[0].VotingPower) } case <-updatesSub.Cancelled(): - t.Fatalf("updatesSub was cancelled (reason: %v)", updatesSub.Err()) + t.Fatalf("updatesSub was canceled (reason: %v)", updatesSub.Err()) case <-time.After(1 * time.Second): t.Fatal("Did not receive EventValidatorSetUpdates within 1 sec.") } diff --git a/state/state_test.go b/state/state_test.go index b4e33626a..3f27efe42 100644 --- a/state/state_test.go +++ b/state/state_test.go @@ -41,7 +41,7 @@ func setupTestCase(t *testing.T) (func(t *testing.T), dbm.DB, sm.State) { return tearDown, stateDB, state } -// TestStateCopy tests the correct copying behaviour of State. +// TestStateCopy tests the correct copying behavior of State. func TestStateCopy(t *testing.T) { tearDown, _, state := setupTestCase(t) defer tearDown(t) diff --git a/statesync/syncer.go b/statesync/syncer.go index e4c02988b..e1c46a634 100644 --- a/statesync/syncer.go +++ b/statesync/syncer.go @@ -267,7 +267,7 @@ func (s *syncer) Sync(snapshot *snapshot, chunks *chunkQueue) (sm.State, *types. return sm.State{}, nil, err } - // Spawn chunk fetchers. They will terminate when the chunk queue is closed or context cancelled. + // Spawn chunk fetchers. They will terminate when the chunk queue is closed or context canceled. fetchCtx, cancel := context.WithCancel(context.TODO()) defer cancel() for i := int32(0); i < s.chunkFetchers; i++ { diff --git a/test/e2e/README.md b/test/e2e/README.md index 09b6d554e..4f89d2885 100644 --- a/test/e2e/README.md +++ b/test/e2e/README.md @@ -54,7 +54,7 @@ Auxiliary commands: * `logs`: outputs all node logs. -* `tail`: tails (follows) node logs until cancelled. +* `tail`: tails (follows) node logs until canceled. ## Tests diff --git a/test/maverick/consensus/replay.go b/test/maverick/consensus/replay.go index 227030595..6b8bf06c1 100644 --- a/test/maverick/consensus/replay.go +++ b/test/maverick/consensus/replay.go @@ -56,7 +56,7 @@ func (cs *State) readReplayMessage(msg *tmcon.TimedWALMessage, newStepSub types. return fmt.Errorf("roundState mismatch. Got %v; Expected %v", m2, m) } case <-newStepSub.Cancelled(): - return fmt.Errorf("failed to read off newStepSub.Out(). newStepSub was cancelled") + return fmt.Errorf("failed to read off newStepSub.Out(). newStepSub was canceled") case <-ticker: return fmt.Errorf("failed to read off newStepSub.Out()") } diff --git a/test/maverick/consensus/state.go b/test/maverick/consensus/state.go index e67868214..803ba0140 100644 --- a/test/maverick/consensus/state.go +++ b/test/maverick/consensus/state.go @@ -396,7 +396,7 @@ func (cs *State) addVote( } // Height mismatch is ignored. - // Not necessarily a bad peer, but not favourable behaviour. + // Not necessarily a bad peer, but not favorable behavior. if vote.Height != cs.Height { cs.Logger.Debug("vote ignored and not added", "voteHeight", vote.Height, "csHeight", cs.Height, "peerID", peerID) return diff --git a/version/version.go b/version/version.go index 79295b5a7..f7f0ddd17 100644 --- a/version/version.go +++ b/version/version.go @@ -15,7 +15,7 @@ const ( ) var ( - // P2PProtocol versions all p2p behaviour and msgs. + // P2PProtocol versions all p2p behavior and msgs. // This includes proposer selection. P2PProtocol uint64 = 8