You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

2680 lines
84 KiB

2 years ago
cleanup: Reduce and normalize import path aliasing. (#6975) The code in the Tendermint repository makes heavy use of import aliasing. This is made necessary by our extensive reuse of common base package names, and by repetition of similar names across different subdirectories. Unfortunately we have not been very consistent about which packages we alias in various circumstances, and the aliases we use vary. In the spirit of the advice in the style guide and https://github.com/golang/go/wiki/CodeReviewComments#imports, his change makes an effort to clean up and normalize import aliasing. This change makes no API or behavioral changes. It is a pure cleanup intended o help make the code more readable to developers (including myself) trying to understand what is being imported where. Only unexported names have been modified, and the changes were generated and applied mechanically with gofmt -r and comby, respecting the lexical and syntactic rules of Go. Even so, I did not fix every inconsistency. Where the changes would be too disruptive, I left it alone. The principles I followed in this cleanup are: - Remove aliases that restate the package name. - Remove aliases where the base package name is unambiguous. - Move overly-terse abbreviations from the import to the usage site. - Fix lexical issues (remove underscores, remove capitalization). - Fix import groupings to more closely match the style guide. - Group blank (side-effecting) imports and ensure they are commented. - Add aliases to multiple imports with the same base package name.
3 years ago
9 years ago
9 years ago
9 years ago
9 years ago
9 years ago
9 years ago
lint: Enable Golint (#4212) * Fix many golint errors * Fix golint errors in the 'lite' package * Don't export Pool.store * Fix typo * Revert unwanted changes * Fix errors in counter package * Fix linter errors in kvstore package * Fix linter error in example package * Fix error in tests package * Fix linter errors in v2 package * Fix linter errors in consensus package * Fix linter errors in evidence package * Fix linter error in fail package * Fix linter errors in query package * Fix linter errors in core package * Fix linter errors in node package * Fix linter errors in mempool package * Fix linter error in conn package * Fix linter errors in pex package * Rename PEXReactor export to Reactor * Fix linter errors in trust package * Fix linter errors in upnp package * Fix linter errors in p2p package * Fix linter errors in proxy package * Fix linter errors in mock_test package * Fix linter error in client_test package * Fix linter errors in coretypes package * Fix linter errors in coregrpc package * Fix linter errors in rpcserver package * Fix linter errors in rpctypes package * Fix linter errors in rpctest package * Fix linter error in json2wal script * Fix linter error in wal2json script * Fix linter errors in kv package * Fix linter error in state package * Fix linter error in grpc_client * Fix linter errors in types package * Fix linter error in version package * Fix remaining errors * Address review comments * Fix broken tests * Reconcile package coregrpc * Fix golangci bot error * Fix new golint errors * Fix broken reference * Enable golint linter * minor changes to bring golint into line * fix failing test * fix pex reactor naming * address PR comments
5 years ago
lint: Enable Golint (#4212) * Fix many golint errors * Fix golint errors in the 'lite' package * Don't export Pool.store * Fix typo * Revert unwanted changes * Fix errors in counter package * Fix linter errors in kvstore package * Fix linter error in example package * Fix error in tests package * Fix linter errors in v2 package * Fix linter errors in consensus package * Fix linter errors in evidence package * Fix linter error in fail package * Fix linter errors in query package * Fix linter errors in core package * Fix linter errors in node package * Fix linter errors in mempool package * Fix linter error in conn package * Fix linter errors in pex package * Rename PEXReactor export to Reactor * Fix linter errors in trust package * Fix linter errors in upnp package * Fix linter errors in p2p package * Fix linter errors in proxy package * Fix linter errors in mock_test package * Fix linter error in client_test package * Fix linter errors in coretypes package * Fix linter errors in coregrpc package * Fix linter errors in rpcserver package * Fix linter errors in rpctypes package * Fix linter errors in rpctest package * Fix linter error in json2wal script * Fix linter error in wal2json script * Fix linter errors in kv package * Fix linter error in state package * Fix linter error in grpc_client * Fix linter errors in types package * Fix linter error in version package * Fix remaining errors * Address review comments * Fix broken tests * Reconcile package coregrpc * Fix golangci bot error * Fix new golint errors * Fix broken reference * Enable golint linter * minor changes to bring golint into line * fix failing test * fix pex reactor naming * address PR comments
5 years ago
10 years ago
cleanup: Reduce and normalize import path aliasing. (#6975) The code in the Tendermint repository makes heavy use of import aliasing. This is made necessary by our extensive reuse of common base package names, and by repetition of similar names across different subdirectories. Unfortunately we have not been very consistent about which packages we alias in various circumstances, and the aliases we use vary. In the spirit of the advice in the style guide and https://github.com/golang/go/wiki/CodeReviewComments#imports, his change makes an effort to clean up and normalize import aliasing. This change makes no API or behavioral changes. It is a pure cleanup intended o help make the code more readable to developers (including myself) trying to understand what is being imported where. Only unexported names have been modified, and the changes were generated and applied mechanically with gofmt -r and comby, respecting the lexical and syntactic rules of Go. Even so, I did not fix every inconsistency. Where the changes would be too disruptive, I left it alone. The principles I followed in this cleanup are: - Remove aliases that restate the package name. - Remove aliases where the base package name is unambiguous. - Move overly-terse abbreviations from the import to the usage site. - Fix lexical issues (remove underscores, remove capitalization). - Fix import groupings to more closely match the style guide. - Group blank (side-effecting) imports and ensure they are commented. - Add aliases to multiple imports with the same base package name.
3 years ago
new pubsub package comment out failing consensus tests for now rewrite rpc httpclient to use new pubsub package import pubsub as tmpubsub, query as tmquery make event IDs constants EventKey -> EventTypeKey rename EventsPubsub to PubSub mempool does not use pubsub rename eventsSub to pubsub new subscribe API fix channel size issues and consensus tests bugs refactor rpc client add missing discardFromChan method add mutex rename pubsub to eventBus remove IsRunning from WSRPCConnection interface (not needed) add a comment in broadcastNewRoundStepsAndVotes rename registerEventCallbacks to broadcastNewRoundStepsAndVotes See https://dave.cheney.net/2014/03/19/channel-axioms stop eventBuses after reactor tests remove unnecessary Unsubscribe return subscribe helper function move discardFromChan to where it is used subscribe now returns an err this gives us ability to refuse to subscribe if pubsub is at its max capacity. use context for control overflow cache queries handle err when subscribing in replay_test rename testClientID to testSubscriber extract var set channel buffer capacity to 1 in replay_file fix byzantine_test unsubscribe from single event, not all events refactor httpclient to return events to appropriate channels return failing testReplayCrashBeforeWriteVote test fix TestValidatorSetChanges refactor code a bit fix testReplayCrashBeforeWriteVote add comment fix TestValidatorSetChanges fixes from Bucky's review update comment [ci skip] test TxEventBuffer update changelog fix TestValidatorSetChanges (2nd attempt) only do wg.Done when no errors benchmark event bus create pubsub server inside NewEventBus only expose config params (later if needed) set buffer capacity to 0 so we are not testing cache new tx event format: key = "Tx" plus a tag {"tx.hash": XYZ} This should allow to subscribe to all transactions! or a specific one using a query: "tm.events.type = Tx and tx.hash = '013ABF99434...'" use TimeoutCommit instead of afterPublishEventNewBlockTimeout TimeoutCommit is the time a node waits after committing a block, before it goes into the next height. So it will finish everything from the last block, but then wait a bit. The idea is this gives it time to hear more votes from other validators, to strengthen the commit it includes in the next block. But it also gives it time to hear about new transactions. waitForBlockWithUpdatedVals rewrite WAL crash tests Task: test that we can recover from any WAL crash. Solution: the old tests were relying on event hub being run in the same thread (we were injecting the private validator's last signature). when considering a rewrite, we considered two possible solutions: write a "fuzzy" testing system where WAL is crashing upon receiving a new message, or inject failures and trigger them in tests using something like https://github.com/coreos/gofail. remove sleep no cs.Lock around wal.Save test different cases (empty block, non-empty block, ...) comments add comments test 4 cases: empty block, non-empty block, non-empty block with smaller part size, many blocks fixes as per Bucky's last review reset subscriptions on UnsubscribeAll use a simple counter to track message for which we panicked also, set a smaller part size for all test cases
7 years ago
new pubsub package comment out failing consensus tests for now rewrite rpc httpclient to use new pubsub package import pubsub as tmpubsub, query as tmquery make event IDs constants EventKey -> EventTypeKey rename EventsPubsub to PubSub mempool does not use pubsub rename eventsSub to pubsub new subscribe API fix channel size issues and consensus tests bugs refactor rpc client add missing discardFromChan method add mutex rename pubsub to eventBus remove IsRunning from WSRPCConnection interface (not needed) add a comment in broadcastNewRoundStepsAndVotes rename registerEventCallbacks to broadcastNewRoundStepsAndVotes See https://dave.cheney.net/2014/03/19/channel-axioms stop eventBuses after reactor tests remove unnecessary Unsubscribe return subscribe helper function move discardFromChan to where it is used subscribe now returns an err this gives us ability to refuse to subscribe if pubsub is at its max capacity. use context for control overflow cache queries handle err when subscribing in replay_test rename testClientID to testSubscriber extract var set channel buffer capacity to 1 in replay_file fix byzantine_test unsubscribe from single event, not all events refactor httpclient to return events to appropriate channels return failing testReplayCrashBeforeWriteVote test fix TestValidatorSetChanges refactor code a bit fix testReplayCrashBeforeWriteVote add comment fix TestValidatorSetChanges fixes from Bucky's review update comment [ci skip] test TxEventBuffer update changelog fix TestValidatorSetChanges (2nd attempt) only do wg.Done when no errors benchmark event bus create pubsub server inside NewEventBus only expose config params (later if needed) set buffer capacity to 0 so we are not testing cache new tx event format: key = "Tx" plus a tag {"tx.hash": XYZ} This should allow to subscribe to all transactions! or a specific one using a query: "tm.events.type = Tx and tx.hash = '013ABF99434...'" use TimeoutCommit instead of afterPublishEventNewBlockTimeout TimeoutCommit is the time a node waits after committing a block, before it goes into the next height. So it will finish everything from the last block, but then wait a bit. The idea is this gives it time to hear more votes from other validators, to strengthen the commit it includes in the next block. But it also gives it time to hear about new transactions. waitForBlockWithUpdatedVals rewrite WAL crash tests Task: test that we can recover from any WAL crash. Solution: the old tests were relying on event hub being run in the same thread (we were injecting the private validator's last signature). when considering a rewrite, we considered two possible solutions: write a "fuzzy" testing system where WAL is crashing upon receiving a new message, or inject failures and trigger them in tests using something like https://github.com/coreos/gofail. remove sleep no cs.Lock around wal.Save test different cases (empty block, non-empty block, ...) comments add comments test 4 cases: empty block, non-empty block, non-empty block with smaller part size, many blocks fixes as per Bucky's last review reset subscriptions on UnsubscribeAll use a simple counter to track message for which we panicked also, set a smaller part size for all test cases
7 years ago
7 years ago
7 years ago
lint: Enable Golint (#4212) * Fix many golint errors * Fix golint errors in the 'lite' package * Don't export Pool.store * Fix typo * Revert unwanted changes * Fix errors in counter package * Fix linter errors in kvstore package * Fix linter error in example package * Fix error in tests package * Fix linter errors in v2 package * Fix linter errors in consensus package * Fix linter errors in evidence package * Fix linter error in fail package * Fix linter errors in query package * Fix linter errors in core package * Fix linter errors in node package * Fix linter errors in mempool package * Fix linter error in conn package * Fix linter errors in pex package * Rename PEXReactor export to Reactor * Fix linter errors in trust package * Fix linter errors in upnp package * Fix linter errors in p2p package * Fix linter errors in proxy package * Fix linter errors in mock_test package * Fix linter error in client_test package * Fix linter errors in coretypes package * Fix linter errors in coregrpc package * Fix linter errors in rpcserver package * Fix linter errors in rpctypes package * Fix linter errors in rpctest package * Fix linter error in json2wal script * Fix linter error in wal2json script * Fix linter errors in kv package * Fix linter error in state package * Fix linter error in grpc_client * Fix linter errors in types package * Fix linter error in version package * Fix remaining errors * Address review comments * Fix broken tests * Reconcile package coregrpc * Fix golangci bot error * Fix new golint errors * Fix broken reference * Enable golint linter * minor changes to bring golint into line * fix failing test * fix pex reactor naming * address PR comments
5 years ago
lint: Enable Golint (#4212) * Fix many golint errors * Fix golint errors in the 'lite' package * Don't export Pool.store * Fix typo * Revert unwanted changes * Fix errors in counter package * Fix linter errors in kvstore package * Fix linter error in example package * Fix error in tests package * Fix linter errors in v2 package * Fix linter errors in consensus package * Fix linter errors in evidence package * Fix linter error in fail package * Fix linter errors in query package * Fix linter errors in core package * Fix linter errors in node package * Fix linter errors in mempool package * Fix linter error in conn package * Fix linter errors in pex package * Rename PEXReactor export to Reactor * Fix linter errors in trust package * Fix linter errors in upnp package * Fix linter errors in p2p package * Fix linter errors in proxy package * Fix linter errors in mock_test package * Fix linter error in client_test package * Fix linter errors in coretypes package * Fix linter errors in coregrpc package * Fix linter errors in rpcserver package * Fix linter errors in rpctypes package * Fix linter errors in rpctest package * Fix linter error in json2wal script * Fix linter error in wal2json script * Fix linter errors in kv package * Fix linter error in state package * Fix linter error in grpc_client * Fix linter errors in types package * Fix linter error in version package * Fix remaining errors * Address review comments * Fix broken tests * Reconcile package coregrpc * Fix golangci bot error * Fix new golint errors * Fix broken reference * Enable golint linter * minor changes to bring golint into line * fix failing test * fix pex reactor naming * address PR comments
5 years ago
cleanup: Reduce and normalize import path aliasing. (#6975) The code in the Tendermint repository makes heavy use of import aliasing. This is made necessary by our extensive reuse of common base package names, and by repetition of similar names across different subdirectories. Unfortunately we have not been very consistent about which packages we alias in various circumstances, and the aliases we use vary. In the spirit of the advice in the style guide and https://github.com/golang/go/wiki/CodeReviewComments#imports, his change makes an effort to clean up and normalize import aliasing. This change makes no API or behavioral changes. It is a pure cleanup intended o help make the code more readable to developers (including myself) trying to understand what is being imported where. Only unexported names have been modified, and the changes were generated and applied mechanically with gofmt -r and comby, respecting the lexical and syntactic rules of Go. Even so, I did not fix every inconsistency. Where the changes would be too disruptive, I left it alone. The principles I followed in this cleanup are: - Remove aliases that restate the package name. - Remove aliases where the base package name is unambiguous. - Move overly-terse abbreviations from the import to the usage site. - Fix lexical issues (remove underscores, remove capitalization). - Fix import groupings to more closely match the style guide. - Group blank (side-effecting) imports and ensure they are commented. - Add aliases to multiple imports with the same base package name.
3 years ago
lint: Enable Golint (#4212) * Fix many golint errors * Fix golint errors in the 'lite' package * Don't export Pool.store * Fix typo * Revert unwanted changes * Fix errors in counter package * Fix linter errors in kvstore package * Fix linter error in example package * Fix error in tests package * Fix linter errors in v2 package * Fix linter errors in consensus package * Fix linter errors in evidence package * Fix linter error in fail package * Fix linter errors in query package * Fix linter errors in core package * Fix linter errors in node package * Fix linter errors in mempool package * Fix linter error in conn package * Fix linter errors in pex package * Rename PEXReactor export to Reactor * Fix linter errors in trust package * Fix linter errors in upnp package * Fix linter errors in p2p package * Fix linter errors in proxy package * Fix linter errors in mock_test package * Fix linter error in client_test package * Fix linter errors in coretypes package * Fix linter errors in coregrpc package * Fix linter errors in rpcserver package * Fix linter errors in rpctypes package * Fix linter errors in rpctest package * Fix linter error in json2wal script * Fix linter error in wal2json script * Fix linter errors in kv package * Fix linter error in state package * Fix linter error in grpc_client * Fix linter errors in types package * Fix linter error in version package * Fix remaining errors * Address review comments * Fix broken tests * Reconcile package coregrpc * Fix golangci bot error * Fix new golint errors * Fix broken reference * Enable golint linter * minor changes to bring golint into line * fix failing test * fix pex reactor naming * address PR comments
5 years ago
cleanup: Reduce and normalize import path aliasing. (#6975) The code in the Tendermint repository makes heavy use of import aliasing. This is made necessary by our extensive reuse of common base package names, and by repetition of similar names across different subdirectories. Unfortunately we have not been very consistent about which packages we alias in various circumstances, and the aliases we use vary. In the spirit of the advice in the style guide and https://github.com/golang/go/wiki/CodeReviewComments#imports, his change makes an effort to clean up and normalize import aliasing. This change makes no API or behavioral changes. It is a pure cleanup intended o help make the code more readable to developers (including myself) trying to understand what is being imported where. Only unexported names have been modified, and the changes were generated and applied mechanically with gofmt -r and comby, respecting the lexical and syntactic rules of Go. Even so, I did not fix every inconsistency. Where the changes would be too disruptive, I left it alone. The principles I followed in this cleanup are: - Remove aliases that restate the package name. - Remove aliases where the base package name is unambiguous. - Move overly-terse abbreviations from the import to the usage site. - Fix lexical issues (remove underscores, remove capitalization). - Fix import groupings to more closely match the style guide. - Group blank (side-effecting) imports and ensure they are commented. - Add aliases to multiple imports with the same base package name.
3 years ago
7 years ago
new pubsub package comment out failing consensus tests for now rewrite rpc httpclient to use new pubsub package import pubsub as tmpubsub, query as tmquery make event IDs constants EventKey -> EventTypeKey rename EventsPubsub to PubSub mempool does not use pubsub rename eventsSub to pubsub new subscribe API fix channel size issues and consensus tests bugs refactor rpc client add missing discardFromChan method add mutex rename pubsub to eventBus remove IsRunning from WSRPCConnection interface (not needed) add a comment in broadcastNewRoundStepsAndVotes rename registerEventCallbacks to broadcastNewRoundStepsAndVotes See https://dave.cheney.net/2014/03/19/channel-axioms stop eventBuses after reactor tests remove unnecessary Unsubscribe return subscribe helper function move discardFromChan to where it is used subscribe now returns an err this gives us ability to refuse to subscribe if pubsub is at its max capacity. use context for control overflow cache queries handle err when subscribing in replay_test rename testClientID to testSubscriber extract var set channel buffer capacity to 1 in replay_file fix byzantine_test unsubscribe from single event, not all events refactor httpclient to return events to appropriate channels return failing testReplayCrashBeforeWriteVote test fix TestValidatorSetChanges refactor code a bit fix testReplayCrashBeforeWriteVote add comment fix TestValidatorSetChanges fixes from Bucky's review update comment [ci skip] test TxEventBuffer update changelog fix TestValidatorSetChanges (2nd attempt) only do wg.Done when no errors benchmark event bus create pubsub server inside NewEventBus only expose config params (later if needed) set buffer capacity to 0 so we are not testing cache new tx event format: key = "Tx" plus a tag {"tx.hash": XYZ} This should allow to subscribe to all transactions! or a specific one using a query: "tm.events.type = Tx and tx.hash = '013ABF99434...'" use TimeoutCommit instead of afterPublishEventNewBlockTimeout TimeoutCommit is the time a node waits after committing a block, before it goes into the next height. So it will finish everything from the last block, but then wait a bit. The idea is this gives it time to hear more votes from other validators, to strengthen the commit it includes in the next block. But it also gives it time to hear about new transactions. waitForBlockWithUpdatedVals rewrite WAL crash tests Task: test that we can recover from any WAL crash. Solution: the old tests were relying on event hub being run in the same thread (we were injecting the private validator's last signature). when considering a rewrite, we considered two possible solutions: write a "fuzzy" testing system where WAL is crashing upon receiving a new message, or inject failures and trigger them in tests using something like https://github.com/coreos/gofail. remove sleep no cs.Lock around wal.Save test different cases (empty block, non-empty block, ...) comments add comments test 4 cases: empty block, non-empty block, non-empty block with smaller part size, many blocks fixes as per Bucky's last review reset subscriptions on UnsubscribeAll use a simple counter to track message for which we panicked also, set a smaller part size for all test cases
7 years ago
10 years ago
lint: Enable Golint (#4212) * Fix many golint errors * Fix golint errors in the 'lite' package * Don't export Pool.store * Fix typo * Revert unwanted changes * Fix errors in counter package * Fix linter errors in kvstore package * Fix linter error in example package * Fix error in tests package * Fix linter errors in v2 package * Fix linter errors in consensus package * Fix linter errors in evidence package * Fix linter error in fail package * Fix linter errors in query package * Fix linter errors in core package * Fix linter errors in node package * Fix linter errors in mempool package * Fix linter error in conn package * Fix linter errors in pex package * Rename PEXReactor export to Reactor * Fix linter errors in trust package * Fix linter errors in upnp package * Fix linter errors in p2p package * Fix linter errors in proxy package * Fix linter errors in mock_test package * Fix linter error in client_test package * Fix linter errors in coretypes package * Fix linter errors in coregrpc package * Fix linter errors in rpcserver package * Fix linter errors in rpctypes package * Fix linter errors in rpctest package * Fix linter error in json2wal script * Fix linter error in wal2json script * Fix linter errors in kv package * Fix linter error in state package * Fix linter error in grpc_client * Fix linter errors in types package * Fix linter error in version package * Fix remaining errors * Address review comments * Fix broken tests * Reconcile package coregrpc * Fix golangci bot error * Fix new golint errors * Fix broken reference * Enable golint linter * minor changes to bring golint into line * fix failing test * fix pex reactor naming * address PR comments
5 years ago
lint: Enable Golint (#4212) * Fix many golint errors * Fix golint errors in the 'lite' package * Don't export Pool.store * Fix typo * Revert unwanted changes * Fix errors in counter package * Fix linter errors in kvstore package * Fix linter error in example package * Fix error in tests package * Fix linter errors in v2 package * Fix linter errors in consensus package * Fix linter errors in evidence package * Fix linter error in fail package * Fix linter errors in query package * Fix linter errors in core package * Fix linter errors in node package * Fix linter errors in mempool package * Fix linter error in conn package * Fix linter errors in pex package * Rename PEXReactor export to Reactor * Fix linter errors in trust package * Fix linter errors in upnp package * Fix linter errors in p2p package * Fix linter errors in proxy package * Fix linter errors in mock_test package * Fix linter error in client_test package * Fix linter errors in coretypes package * Fix linter errors in coregrpc package * Fix linter errors in rpcserver package * Fix linter errors in rpctypes package * Fix linter errors in rpctest package * Fix linter error in json2wal script * Fix linter error in wal2json script * Fix linter errors in kv package * Fix linter error in state package * Fix linter error in grpc_client * Fix linter errors in types package * Fix linter error in version package * Fix remaining errors * Address review comments * Fix broken tests * Reconcile package coregrpc * Fix golangci bot error * Fix new golint errors * Fix broken reference * Enable golint linter * minor changes to bring golint into line * fix failing test * fix pex reactor naming * address PR comments
5 years ago
lint: Enable Golint (#4212) * Fix many golint errors * Fix golint errors in the 'lite' package * Don't export Pool.store * Fix typo * Revert unwanted changes * Fix errors in counter package * Fix linter errors in kvstore package * Fix linter error in example package * Fix error in tests package * Fix linter errors in v2 package * Fix linter errors in consensus package * Fix linter errors in evidence package * Fix linter error in fail package * Fix linter errors in query package * Fix linter errors in core package * Fix linter errors in node package * Fix linter errors in mempool package * Fix linter error in conn package * Fix linter errors in pex package * Rename PEXReactor export to Reactor * Fix linter errors in trust package * Fix linter errors in upnp package * Fix linter errors in p2p package * Fix linter errors in proxy package * Fix linter errors in mock_test package * Fix linter error in client_test package * Fix linter errors in coretypes package * Fix linter errors in coregrpc package * Fix linter errors in rpcserver package * Fix linter errors in rpctypes package * Fix linter errors in rpctest package * Fix linter error in json2wal script * Fix linter error in wal2json script * Fix linter errors in kv package * Fix linter error in state package * Fix linter error in grpc_client * Fix linter errors in types package * Fix linter error in version package * Fix remaining errors * Address review comments * Fix broken tests * Reconcile package coregrpc * Fix golangci bot error * Fix new golint errors * Fix broken reference * Enable golint linter * minor changes to bring golint into line * fix failing test * fix pex reactor naming * address PR comments
5 years ago
lint: Enable Golint (#4212) * Fix many golint errors * Fix golint errors in the 'lite' package * Don't export Pool.store * Fix typo * Revert unwanted changes * Fix errors in counter package * Fix linter errors in kvstore package * Fix linter error in example package * Fix error in tests package * Fix linter errors in v2 package * Fix linter errors in consensus package * Fix linter errors in evidence package * Fix linter error in fail package * Fix linter errors in query package * Fix linter errors in core package * Fix linter errors in node package * Fix linter errors in mempool package * Fix linter error in conn package * Fix linter errors in pex package * Rename PEXReactor export to Reactor * Fix linter errors in trust package * Fix linter errors in upnp package * Fix linter errors in p2p package * Fix linter errors in proxy package * Fix linter errors in mock_test package * Fix linter error in client_test package * Fix linter errors in coretypes package * Fix linter errors in coregrpc package * Fix linter errors in rpcserver package * Fix linter errors in rpctypes package * Fix linter errors in rpctest package * Fix linter error in json2wal script * Fix linter error in wal2json script * Fix linter errors in kv package * Fix linter error in state package * Fix linter error in grpc_client * Fix linter errors in types package * Fix linter error in version package * Fix remaining errors * Address review comments * Fix broken tests * Reconcile package coregrpc * Fix golangci bot error * Fix new golint errors * Fix broken reference * Enable golint linter * minor changes to bring golint into line * fix failing test * fix pex reactor naming * address PR comments
5 years ago
abci: localClient improvements & bugfixes & pubsub Unsubscribe issues (#2748) * use READ lock/unlock in ConsensusState#GetLastHeight Refs #2721 * do not use defers when there's no need * fix peer formatting (output its address instead of the pointer) ``` [54310]: E[11-02|11:59:39.851] Connection failed @ sendRoutine module=p2p peer=0xb78f00 conn=MConn{74.207.236.148:26656} err="pong timeout" ``` https://github.com/tendermint/tendermint/issues/2721#issuecomment-435326581 * panic if peer has no state https://github.com/tendermint/tendermint/issues/2721#issuecomment-435347165 It's confusing that sometimes we check if peer has a state, but most of the times we expect it to be there 1. https://github.com/tendermint/tendermint/blob/add79700b5fe84417538202b6c927c8cc5383672/mempool/reactor.go#L138 2. https://github.com/tendermint/tendermint/blob/add79700b5fe84417538202b6c927c8cc5383672/rpc/core/consensus.go#L196 (edited) I will change everything to always assume peer has a state and panic otherwise that should help identify issues earlier * abci/localclient: extend lock on app callback App callback should be protected by lock as well (note this was already done for InitChainAsync, why not for others???). Otherwise, when we execute the block, tx might come in and call the callback in the same time we're updating it in execBlockOnProxyApp => DATA RACE Fixes #2721 Consensus state is locked ``` goroutine 113333 [semacquire, 309 minutes]: sync.runtime_SemacquireMutex(0xc00180009c, 0xc0000c7e00) /usr/local/go/src/runtime/sema.go:71 +0x3d sync.(*RWMutex).RLock(0xc001800090) /usr/local/go/src/sync/rwmutex.go:50 +0x4e github.com/MinterTeam/minter-go-node/vendor/github.com/tendermint/tendermint/consensus.(*ConsensusState).GetRoundState(0xc001800000, 0x0) /root/go/src/github.com/MinterTeam/minter-go-node/vendor/github.com/tendermint/tendermint/consensus/state.go:218 +0x46 github.com/MinterTeam/minter-go-node/vendor/github.com/tendermint/tendermint/consensus.(*ConsensusReactor).queryMaj23Routine(0xc0017def80, 0x11104a0, 0xc0072488f0, 0xc007248 9c0) /root/go/src/github.com/MinterTeam/minter-go-node/vendor/github.com/tendermint/tendermint/consensus/reactor.go:735 +0x16d created by github.com/MinterTeam/minter-go-node/vendor/github.com/tendermint/tendermint/consensus.(*ConsensusReactor).AddPeer /root/go/src/github.com/MinterTeam/minter-go-node/vendor/github.com/tendermint/tendermint/consensus/reactor.go:172 +0x236 ``` because localClient is locked ``` goroutine 1899 [semacquire, 309 minutes]: sync.runtime_SemacquireMutex(0xc00003363c, 0xc0000cb500) /usr/local/go/src/runtime/sema.go:71 +0x3d sync.(*Mutex).Lock(0xc000033638) /usr/local/go/src/sync/mutex.go:134 +0xff github.com/MinterTeam/minter-go-node/vendor/github.com/tendermint/tendermint/abci/client.(*localClient).SetResponseCallback(0xc0001fb560, 0xc007868540) /root/go/src/github.com/MinterTeam/minter-go-node/vendor/github.com/tendermint/tendermint/abci/client/local_client.go:32 +0x33 github.com/MinterTeam/minter-go-node/vendor/github.com/tendermint/tendermint/proxy.(*appConnConsensus).SetResponseCallback(0xc00002f750, 0xc007868540) /root/go/src/github.com/MinterTeam/minter-go-node/vendor/github.com/tendermint/tendermint/proxy/app_conn.go:57 +0x40 github.com/MinterTeam/minter-go-node/vendor/github.com/tendermint/tendermint/state.execBlockOnProxyApp(0x1104e20, 0xc002ca0ba0, 0x11092a0, 0xc00002f750, 0xc0001fe960, 0xc000bfc660, 0x110cfe0, 0xc000090330, 0xc9d12, 0xc000d9d5a0, ...) /root/go/src/github.com/MinterTeam/minter-go-node/vendor/github.com/tendermint/tendermint/state/execution.go:230 +0x1fd github.com/MinterTeam/minter-go-node/vendor/github.com/tendermint/tendermint/state.(*BlockExecutor).ApplyBlock(0xc002c2a230, 0x7, 0x0, 0xc000eae880, 0x6, 0xc002e52c60, 0x16, 0x1f927, 0xc9d12, 0xc000d9d5a0, ...) /root/go/src/github.com/MinterTeam/minter-go-node/vendor/github.com/tendermint/tendermint/state/execution.go:96 +0x142 github.com/MinterTeam/minter-go-node/vendor/github.com/tendermint/tendermint/consensus.(*ConsensusState).finalizeCommit(0xc001800000, 0x1f928) /root/go/src/github.com/MinterTeam/minter-go-node/vendor/github.com/tendermint/tendermint/consensus/state.go:1339 +0xa3e github.com/MinterTeam/minter-go-node/vendor/github.com/tendermint/tendermint/consensus.(*ConsensusState).tryFinalizeCommit(0xc001800000, 0x1f928) /root/go/src/github.com/MinterTeam/minter-go-node/vendor/github.com/tendermint/tendermint/consensus/state.go:1270 +0x451 github.com/MinterTeam/minter-go-node/vendor/github.com/tendermint/tendermint/consensus.(*ConsensusState).enterCommit.func1(0xc001800000, 0x0, 0x1f928) /root/go/src/github.com/MinterTeam/minter-go-node/vendor/github.com/tendermint/tendermint/consensus/state.go:1218 +0x90 github.com/MinterTeam/minter-go-node/vendor/github.com/tendermint/tendermint/consensus.(*ConsensusState).enterCommit(0xc001800000, 0x1f928, 0x0) /root/go/src/github.com/MinterTeam/minter-go-node/vendor/github.com/tendermint/tendermint/consensus/state.go:1247 +0x6b8 github.com/MinterTeam/minter-go-node/vendor/github.com/tendermint/tendermint/consensus.(*ConsensusState).addVote(0xc001800000, 0xc003d8dea0, 0xc000cf4cc0, 0x28, 0xf1, 0xc003bc7ad0, 0xc003bc7b10) /root/go/src/github.com/MinterTeam/minter-go-node/vendor/github.com/tendermint/tendermint/consensus/state.go:1659 +0xbad github.com/MinterTeam/minter-go-node/vendor/github.com/tendermint/tendermint/consensus.(*ConsensusState).tryAddVote(0xc001800000, 0xc003d8dea0, 0xc000cf4cc0, 0x28, 0xf1, 0xf1, 0xf1) /root/go/src/github.com/MinterTeam/minter-go-node/vendor/github.com/tendermint/tendermint/consensus/state.go:1517 +0x59 github.com/MinterTeam/minter-go-node/vendor/github.com/tendermint/tendermint/consensus.(*ConsensusState).handleMsg(0xc001800000, 0xd98200, 0xc0070dbed0, 0xc000cf4cc0, 0x28) /root/go/src/github.com/MinterTeam/minter-go-node/vendor/github.com/tendermint/tendermint/consensus/state.go:660 +0x64b github.com/MinterTeam/minter-go-node/vendor/github.com/tendermint/tendermint/consensus.(*ConsensusState).receiveRoutine(0xc001800000, 0x0) /root/go/src/github.com/MinterTeam/minter-go-node/vendor/github.com/tendermint/tendermint/consensus/state.go:617 +0x670 created by github.com/MinterTeam/minter-go-node/vendor/github.com/tendermint/tendermint/consensus.(*ConsensusState).OnStart /root/go/src/github.com/MinterTeam/minter-go-node/vendor/github.com/tendermint/tendermint/consensus/state.go:311 +0x132 ``` tx comes in and CheckTx is executed right when we execute the block ``` goroutine 111044 [semacquire, 309 minutes]: sync.runtime_SemacquireMutex(0xc00003363c, 0x0) /usr/local/go/src/runtime/sema.go:71 +0x3d sync.(*Mutex).Lock(0xc000033638) /usr/local/go/src/sync/mutex.go:134 +0xff github.com/MinterTeam/minter-go-node/vendor/github.com/tendermint/tendermint/abci/client.(*localClient).CheckTxAsync(0xc0001fb0e0, 0xc002d94500, 0x13f, 0x280, 0x0) /root/go/src/github.com/MinterTeam/minter-go-node/vendor/github.com/tendermint/tendermint/abci/client/local_client.go:85 +0x47 github.com/MinterTeam/minter-go-node/vendor/github.com/tendermint/tendermint/proxy.(*appConnMempool).CheckTxAsync(0xc00002f720, 0xc002d94500, 0x13f, 0x280, 0x1) /root/go/src/github.com/MinterTeam/minter-go-node/vendor/github.com/tendermint/tendermint/proxy/app_conn.go:114 +0x51 github.com/MinterTeam/minter-go-node/vendor/github.com/tendermint/tendermint/mempool.(*Mempool).CheckTx(0xc002d3a320, 0xc002d94500, 0x13f, 0x280, 0xc0072355f0, 0x0, 0x0) /root/go/src/github.com/MinterTeam/minter-go-node/vendor/github.com/tendermint/tendermint/mempool/mempool.go:316 +0x17b github.com/MinterTeam/minter-go-node/vendor/github.com/tendermint/tendermint/rpc/core.BroadcastTxSync(0xc002d94500, 0x13f, 0x280, 0x0, 0x0, 0x0) /root/go/src/github.com/MinterTeam/minter-go-node/vendor/github.com/tendermint/tendermint/rpc/core/mempool.go:93 +0xb8 reflect.Value.call(0xd85560, 0x10326c0, 0x13, 0xec7b8b, 0x4, 0xc00663f180, 0x1, 0x1, 0xc00663f180, 0xc00663f188, ...) /usr/local/go/src/reflect/value.go:447 +0x449 reflect.Value.Call(0xd85560, 0x10326c0, 0x13, 0xc00663f180, 0x1, 0x1, 0x0, 0x0, 0xc005cc9344) /usr/local/go/src/reflect/value.go:308 +0xa4 github.com/MinterTeam/minter-go-node/vendor/github.com/tendermint/tendermint/rpc/lib/server.makeHTTPHandler.func2(0x1102060, 0xc00663f100, 0xc0082d7900) /root/go/src/github.com/MinterTeam/minter-go-node/vendor/github.com/tendermint/tendermint/rpc/lib/server/handlers.go:269 +0x188 net/http.HandlerFunc.ServeHTTP(0xc002c81f20, 0x1102060, 0xc00663f100, 0xc0082d7900) /usr/local/go/src/net/http/server.go:1964 +0x44 net/http.(*ServeMux).ServeHTTP(0xc002c81b60, 0x1102060, 0xc00663f100, 0xc0082d7900) /usr/local/go/src/net/http/server.go:2361 +0x127 github.com/MinterTeam/minter-go-node/vendor/github.com/tendermint/tendermint/rpc/lib/server.maxBytesHandler.ServeHTTP(0x10f8a40, 0xc002c81b60, 0xf4240, 0x1102060, 0xc00663f100, 0xc0082d7900) /root/go/src/github.com/MinterTeam/minter-go-node/vendor/github.com/tendermint/tendermint/rpc/lib/server/http_server.go:219 +0xcf github.com/MinterTeam/minter-go-node/vendor/github.com/tendermint/tendermint/rpc/lib/server.RecoverAndLogHandler.func1(0x1103220, 0xc00121e620, 0xc0082d7900) /root/go/src/github.com/MinterTeam/minter-go-node/vendor/github.com/tendermint/tendermint/rpc/lib/server/http_server.go:192 +0x394 net/http.HandlerFunc.ServeHTTP(0xc002c06ea0, 0x1103220, 0xc00121e620, 0xc0082d7900) /usr/local/go/src/net/http/server.go:1964 +0x44 net/http.serverHandler.ServeHTTP(0xc001a1aa90, 0x1103220, 0xc00121e620, 0xc0082d7900) /usr/local/go/src/net/http/server.go:2741 +0xab net/http.(*conn).serve(0xc00785a3c0, 0x11041a0, 0xc000f844c0) /usr/local/go/src/net/http/server.go:1847 +0x646 created by net/http.(*Server).Serve /usr/local/go/src/net/http/server.go:2851 +0x2f5 ``` * consensus: use read lock in Receive#VoteMessage * use defer to unlock mutex because application might panic * use defer in every method of the localClient * add a changelog entry * drain channels before Unsubscribe(All) Read https://github.com/tendermint/tendermint/blob/55362ed76630f3e1ebec159a598f6a9fb5892cb1/libs/pubsub/pubsub.go#L13 for the detailed explanation of the issue. We'll need to fix it someday. Make sure to keep an eye on https://github.com/tendermint/tendermint/blob/master/docs/architecture/adr-033-pubsub.md * retry instead of panic when peer has no state in reactors other than consensus in /dump_consensus_state RPC endpoint, skip a peer with no state * rpc/core/mempool: simplify error messages * rpc/core/mempool: use time.After instead of timer also, do not log DeliverTx result (to be consistent with other memthods) * unlock before calling the callback in reqRes#SetCallback
6 years ago
fix data race Closes #1442 ``` WARNING: DATA RACE Write at 0x00c4209de7c8 by goroutine 23: github.com/tendermint/tendermint/types.(*Block).fillHeader() /home/vagrant/go/src/github.com/tendermint/tendermint/types/block.go:88 +0x157 github.com/tendermint/tendermint/types.(*Block).Hash() /home/vagrant/go/src/github.com/tendermint/tendermint/types/block.go:104 +0x121 github.com/tendermint/tendermint/types.(*Block).HashesTo() /home/vagrant/go/src/github.com/tendermint/tendermint/types/block.go:135 +0x4f github.com/tendermint/tendermint/consensus.(*ConsensusState).enterPrecommit() /home/vagrant/go/src/github.com/tendermint/tendermint/consensus/state.go:1037 +0x182d github.com/tendermint/tendermint/consensus.(*ConsensusState).addVote() /home/vagrant/go/src/github.com/tendermint/tendermint/consensus/state.go:1425 +0x1a6c github.com/tendermint/tendermint/consensus.(*ConsensusState).tryAddVote() /home/vagrant/go/src/github.com/tendermint/tendermint/consensus/state.go:1318 +0x77 github.com/tendermint/tendermint/consensus.(*ConsensusState).handleMsg() /home/vagrant/go/src/github.com/tendermint/tendermint/consensus/state.go:581 +0x7a9 github.com/tendermint/tendermint/consensus.(*ConsensusState).receiveRoutine() /home/vagrant/go/src/github.com/tendermint/tendermint/consensus/state.go:539 +0x6c3 Previous read at 0x00c4209de7c8 by goroutine 47: github.com/tendermint/tendermint/vendor/github.com/tendermint/tmlibs/common.(*HexBytes).MarshalJSON() <autogenerated>:1 +0x52 github.com/tendermint/tendermint/vendor/github.com/tendermint/go-amino.invokeMarshalJSON() /home/vagrant/go/src/github.com/tendermint/tendermint/vendor/github.com/tendermint/go-amino/json-encode.go:433 +0x88 github.com/tendermint/tendermint/vendor/github.com/tendermint/go-amino.(*Codec)._encodeReflectJSON() /home/vagrant/go/src/github.com/tendermint/tendermint/vendor/github.com/tendermint/go-amino/json-encode.go:82 +0x8d2 github.com/tendermint/tendermint/vendor/github.com/tendermint/go-amino.(*Codec).encodeReflectJSON() /home/vagrant/go/src/github.com/tendermint/tendermint/vendor/github.com/tendermint/go-amino/json-encode.go:50 +0x10e github.com/tendermint/tendermint/vendor/github.com/tendermint/go-amino.(*Codec).encodeReflectJSONStruct() /home/vagrant/go/src/github.com/tendermint/tendermint/vendor/github.com/tendermint/go-amino/json-encode.go:348 +0x539 github.com/tendermint/tendermint/vendor/github.com/tendermint/go-amino.(*Codec)._encodeReflectJSON() /home/vagrant/go/src/github.com/tendermint/tendermint/vendor/github.com/tendermint/go-amino/json-encode.go:119 +0x83f github.com/tendermint/tendermint/vendor/github.com/tendermint/go-amino.(*Codec).encodeReflectJSON() /home/vagrant/go/src/github.com/tendermint/tendermint/vendor/github.com/tendermint/go-amino/json-encode.go:50 +0x10e github.com/tendermint/tendermint/vendor/github.com/tendermint/go-amino.(*Codec).encodeReflectJSONStruct() /home/vagrant/go/src/github.com/tendermint/tendermint/vendor/github.com/tendermint/go-amino/json-encode.go:348 +0x539 github.com/tendermint/tendermint/vendor/github.com/tendermint/go-amino.(*Codec)._encodeReflectJSON() /home/vagrant/go/src/github.com/tendermint/tendermint/vendor/github.com/tendermint/go-amino/json-encode.go:119 +0x83f github.com/tendermint/tendermint/vendor/github.com/tendermint/go-amino.(*Codec).encodeReflectJSON() /home/vagrant/go/src/github.com/tendermint/tendermint/vendor/github.com/tendermint/go-amino/json-encode.go:50 +0x10e github.com/tendermint/tendermint/vendor/github.com/tendermint/go-amino.(*Codec).encodeReflectJSONStruct() /home/vagrant/go/src/github.com/tendermint/tendermint/vendor/github.com/tendermint/go-amino/json-encode.go:348 +0x539 github.com/tendermint/tendermint/vendor/github.com/tendermint/go-amino.(*Codec)._encodeReflectJSON() /home/vagrant/go/src/github.com/tendermint/tendermint/vendor/github.com/tendermint/go-amino/json-encode.go:119 +0x83f github.com/tendermint/tendermint/vendor/github.com/tendermint/go-amino.(*Codec).encodeReflectJSON() /home/vagrant/go/src/github.com/tendermint/tendermint/vendor/github.com/tendermint/go-amino/json-encode.go:50 +0x10e github.com/tendermint/tendermint/vendor/github.com/tendermint/go-amino.(*Codec).encodeReflectJSONStruct() /home/vagrant/go/src/github.com/tendermint/tendermint/vendor/github.com/tendermint/go-amino/json-encode.go:348 +0x539 github.com/tendermint/tendermint/vendor/github.com/tendermint/go-amino.(*Codec)._encodeReflectJSON() /home/vagrant/go/src/github.com/tendermint/tendermint/vendor/github.com/tendermint/go-amino/json-encode.go:119 +0x83f github.com/tendermint/tendermint/vendor/github.com/tendermint/go-amino.(*Codec).encodeReflectJSON() /home/vagrant/go/src/github.com/tendermint/tendermint/vendor/github.com/tendermint/go-amino/json-encode.go:50 +0x10e github.com/tendermint/tendermint/vendor/github.com/tendermint/go-amino.(*Codec).MarshalJSON() /home/vagrant/go/src/github.com/tendermint/tendermint/vendor/github.com/tendermint/go-amino/amino.go:296 +0x182 github.com/tendermint/tendermint/rpc/lib/types.NewRPCSuccessResponse() /home/vagrant/go/src/github.com/tendermint/tendermint/rpc/lib/types/types.go:100 +0x12c github.com/tendermint/tendermint/rpc/lib/server.makeJSONRPCHandler.func1() /home/vagrant/go/src/github.com/tendermint/tendermint/rpc/lib/server/handlers.go:152 +0xab7 net/http.HandlerFunc.ServeHTTP() /usr/lib/go-1.9/src/net/http/server.go:1918 +0x51 net/http.(*ServeMux).ServeHTTP() /usr/lib/go-1.9/src/net/http/server.go:2254 +0xa2 github.com/tendermint/tendermint/rpc/lib/server.RecoverAndLogHandler.func1() /home/vagrant/go/src/github.com/tendermint/tendermint/rpc/lib/server/http_server.go:138 +0x4fa net/http.HandlerFunc.ServeHTTP() /usr/lib/go-1.9/src/net/http/server.go:1918 +0x51 net/http.serverHandler.ServeHTTP() /usr/lib/go-1.9/src/net/http/server.go:2619 +0xbc net/http.(*conn).serve() /usr/lib/go-1.9/src/net/http/server.go:1801 +0x83b Goroutine 23 (running) created at: github.com/tendermint/tendermint/consensus.(*ConsensusState).OnStart() /home/vagrant/go/src/github.com/tendermint/tendermint/consensus/state.go:250 +0x35b github.com/tendermint/tendermint/vendor/github.com/tendermint/tmlibs/common.(*BaseService).Start() /home/vagrant/go/src/github.com/tendermint/tendermint/vendor/github.com/tendermint/tmlibs/common/service.go:130 +0x5fc github.com/tendermint/tendermint/consensus.(*ConsensusReactor).OnStart() /home/vagrant/go/src/github.com/tendermint/tendermint/consensus/reactor.go:69 +0x1b4 github.com/tendermint/tendermint/vendor/github.com/tendermint/tmlibs/common.(*BaseService).Start() /home/vagrant/go/src/github.com/tendermint/tendermint/vendor/github.com/tendermint/tmlibs/common/service.go:130 +0x5fc github.com/tendermint/tendermint/consensus.(*ConsensusReactor).Start() <autogenerated>:1 +0x43 github.com/tendermint/tendermint/p2p.(*Switch).OnStart() /home/vagrant/go/src/github.com/tendermint/tendermint/p2p/switch.go:177 +0x124 github.com/tendermint/tendermint/vendor/github.com/tendermint/tmlibs/common.(*BaseService).Start() /home/vagrant/go/src/github.com/tendermint/tendermint/vendor/github.com/tendermint/tmlibs/common/service.go:130 +0x5fc github.com/tendermint/tendermint/node.(*Node).OnStart() /home/vagrant/go/src/github.com/tendermint/tendermint/node/node.go:416 +0xa1b github.com/tendermint/tendermint/vendor/github.com/tendermint/tmlibs/common.(*BaseService).Start() /home/vagrant/go/src/github.com/tendermint/tendermint/vendor/github.com/tendermint/tmlibs/common/service.go:130 +0x5fc github.com/tendermint/tendermint/rpc/test.StartTendermint() /home/vagrant/go/src/github.com/tendermint/tendermint/rpc/test/helpers.go:100 +0x5b github.com/tendermint/tendermint/rpc/client_test.TestMain() /home/vagrant/go/src/github.com/tendermint/tendermint/rpc/client/main_test.go:17 +0x4c main.main() github.com/tendermint/tendermint/rpc/client/_test/_testmain.go:76 +0x1cd Goroutine 47 (running) created at: net/http.(*Server).Serve() /usr/lib/go-1.9/src/net/http/server.go:2720 +0x37c net/http.Serve() /usr/lib/go-1.9/src/net/http/server.go:2323 +0xe2 github.com/tendermint/tendermint/rpc/lib/server.StartHTTPServer.func1() /home/vagrant/go/src/github.com/tendermint/tendermint/rpc/lib/server/http_server.go:35 +0xb3 ```
6 years ago
lint: Enable Golint (#4212) * Fix many golint errors * Fix golint errors in the 'lite' package * Don't export Pool.store * Fix typo * Revert unwanted changes * Fix errors in counter package * Fix linter errors in kvstore package * Fix linter error in example package * Fix error in tests package * Fix linter errors in v2 package * Fix linter errors in consensus package * Fix linter errors in evidence package * Fix linter error in fail package * Fix linter errors in query package * Fix linter errors in core package * Fix linter errors in node package * Fix linter errors in mempool package * Fix linter error in conn package * Fix linter errors in pex package * Rename PEXReactor export to Reactor * Fix linter errors in trust package * Fix linter errors in upnp package * Fix linter errors in p2p package * Fix linter errors in proxy package * Fix linter errors in mock_test package * Fix linter error in client_test package * Fix linter errors in coretypes package * Fix linter errors in coregrpc package * Fix linter errors in rpcserver package * Fix linter errors in rpctypes package * Fix linter errors in rpctest package * Fix linter error in json2wal script * Fix linter error in wal2json script * Fix linter errors in kv package * Fix linter error in state package * Fix linter error in grpc_client * Fix linter errors in types package * Fix linter error in version package * Fix remaining errors * Address review comments * Fix broken tests * Reconcile package coregrpc * Fix golangci bot error * Fix new golint errors * Fix broken reference * Enable golint linter * minor changes to bring golint into line * fix failing test * fix pex reactor naming * address PR comments
5 years ago
10 years ago
lint: Enable Golint (#4212) * Fix many golint errors * Fix golint errors in the 'lite' package * Don't export Pool.store * Fix typo * Revert unwanted changes * Fix errors in counter package * Fix linter errors in kvstore package * Fix linter error in example package * Fix error in tests package * Fix linter errors in v2 package * Fix linter errors in consensus package * Fix linter errors in evidence package * Fix linter error in fail package * Fix linter errors in query package * Fix linter errors in core package * Fix linter errors in node package * Fix linter errors in mempool package * Fix linter error in conn package * Fix linter errors in pex package * Rename PEXReactor export to Reactor * Fix linter errors in trust package * Fix linter errors in upnp package * Fix linter errors in p2p package * Fix linter errors in proxy package * Fix linter errors in mock_test package * Fix linter error in client_test package * Fix linter errors in coretypes package * Fix linter errors in coregrpc package * Fix linter errors in rpcserver package * Fix linter errors in rpctypes package * Fix linter errors in rpctest package * Fix linter error in json2wal script * Fix linter error in wal2json script * Fix linter errors in kv package * Fix linter error in state package * Fix linter error in grpc_client * Fix linter errors in types package * Fix linter error in version package * Fix remaining errors * Address review comments * Fix broken tests * Reconcile package coregrpc * Fix golangci bot error * Fix new golint errors * Fix broken reference * Enable golint linter * minor changes to bring golint into line * fix failing test * fix pex reactor naming * address PR comments
5 years ago
fix data race Closes #1442 ``` WARNING: DATA RACE Write at 0x00c4209de7c8 by goroutine 23: github.com/tendermint/tendermint/types.(*Block).fillHeader() /home/vagrant/go/src/github.com/tendermint/tendermint/types/block.go:88 +0x157 github.com/tendermint/tendermint/types.(*Block).Hash() /home/vagrant/go/src/github.com/tendermint/tendermint/types/block.go:104 +0x121 github.com/tendermint/tendermint/types.(*Block).HashesTo() /home/vagrant/go/src/github.com/tendermint/tendermint/types/block.go:135 +0x4f github.com/tendermint/tendermint/consensus.(*ConsensusState).enterPrecommit() /home/vagrant/go/src/github.com/tendermint/tendermint/consensus/state.go:1037 +0x182d github.com/tendermint/tendermint/consensus.(*ConsensusState).addVote() /home/vagrant/go/src/github.com/tendermint/tendermint/consensus/state.go:1425 +0x1a6c github.com/tendermint/tendermint/consensus.(*ConsensusState).tryAddVote() /home/vagrant/go/src/github.com/tendermint/tendermint/consensus/state.go:1318 +0x77 github.com/tendermint/tendermint/consensus.(*ConsensusState).handleMsg() /home/vagrant/go/src/github.com/tendermint/tendermint/consensus/state.go:581 +0x7a9 github.com/tendermint/tendermint/consensus.(*ConsensusState).receiveRoutine() /home/vagrant/go/src/github.com/tendermint/tendermint/consensus/state.go:539 +0x6c3 Previous read at 0x00c4209de7c8 by goroutine 47: github.com/tendermint/tendermint/vendor/github.com/tendermint/tmlibs/common.(*HexBytes).MarshalJSON() <autogenerated>:1 +0x52 github.com/tendermint/tendermint/vendor/github.com/tendermint/go-amino.invokeMarshalJSON() /home/vagrant/go/src/github.com/tendermint/tendermint/vendor/github.com/tendermint/go-amino/json-encode.go:433 +0x88 github.com/tendermint/tendermint/vendor/github.com/tendermint/go-amino.(*Codec)._encodeReflectJSON() /home/vagrant/go/src/github.com/tendermint/tendermint/vendor/github.com/tendermint/go-amino/json-encode.go:82 +0x8d2 github.com/tendermint/tendermint/vendor/github.com/tendermint/go-amino.(*Codec).encodeReflectJSON() /home/vagrant/go/src/github.com/tendermint/tendermint/vendor/github.com/tendermint/go-amino/json-encode.go:50 +0x10e github.com/tendermint/tendermint/vendor/github.com/tendermint/go-amino.(*Codec).encodeReflectJSONStruct() /home/vagrant/go/src/github.com/tendermint/tendermint/vendor/github.com/tendermint/go-amino/json-encode.go:348 +0x539 github.com/tendermint/tendermint/vendor/github.com/tendermint/go-amino.(*Codec)._encodeReflectJSON() /home/vagrant/go/src/github.com/tendermint/tendermint/vendor/github.com/tendermint/go-amino/json-encode.go:119 +0x83f github.com/tendermint/tendermint/vendor/github.com/tendermint/go-amino.(*Codec).encodeReflectJSON() /home/vagrant/go/src/github.com/tendermint/tendermint/vendor/github.com/tendermint/go-amino/json-encode.go:50 +0x10e github.com/tendermint/tendermint/vendor/github.com/tendermint/go-amino.(*Codec).encodeReflectJSONStruct() /home/vagrant/go/src/github.com/tendermint/tendermint/vendor/github.com/tendermint/go-amino/json-encode.go:348 +0x539 github.com/tendermint/tendermint/vendor/github.com/tendermint/go-amino.(*Codec)._encodeReflectJSON() /home/vagrant/go/src/github.com/tendermint/tendermint/vendor/github.com/tendermint/go-amino/json-encode.go:119 +0x83f github.com/tendermint/tendermint/vendor/github.com/tendermint/go-amino.(*Codec).encodeReflectJSON() /home/vagrant/go/src/github.com/tendermint/tendermint/vendor/github.com/tendermint/go-amino/json-encode.go:50 +0x10e github.com/tendermint/tendermint/vendor/github.com/tendermint/go-amino.(*Codec).encodeReflectJSONStruct() /home/vagrant/go/src/github.com/tendermint/tendermint/vendor/github.com/tendermint/go-amino/json-encode.go:348 +0x539 github.com/tendermint/tendermint/vendor/github.com/tendermint/go-amino.(*Codec)._encodeReflectJSON() /home/vagrant/go/src/github.com/tendermint/tendermint/vendor/github.com/tendermint/go-amino/json-encode.go:119 +0x83f github.com/tendermint/tendermint/vendor/github.com/tendermint/go-amino.(*Codec).encodeReflectJSON() /home/vagrant/go/src/github.com/tendermint/tendermint/vendor/github.com/tendermint/go-amino/json-encode.go:50 +0x10e github.com/tendermint/tendermint/vendor/github.com/tendermint/go-amino.(*Codec).encodeReflectJSONStruct() /home/vagrant/go/src/github.com/tendermint/tendermint/vendor/github.com/tendermint/go-amino/json-encode.go:348 +0x539 github.com/tendermint/tendermint/vendor/github.com/tendermint/go-amino.(*Codec)._encodeReflectJSON() /home/vagrant/go/src/github.com/tendermint/tendermint/vendor/github.com/tendermint/go-amino/json-encode.go:119 +0x83f github.com/tendermint/tendermint/vendor/github.com/tendermint/go-amino.(*Codec).encodeReflectJSON() /home/vagrant/go/src/github.com/tendermint/tendermint/vendor/github.com/tendermint/go-amino/json-encode.go:50 +0x10e github.com/tendermint/tendermint/vendor/github.com/tendermint/go-amino.(*Codec).MarshalJSON() /home/vagrant/go/src/github.com/tendermint/tendermint/vendor/github.com/tendermint/go-amino/amino.go:296 +0x182 github.com/tendermint/tendermint/rpc/lib/types.NewRPCSuccessResponse() /home/vagrant/go/src/github.com/tendermint/tendermint/rpc/lib/types/types.go:100 +0x12c github.com/tendermint/tendermint/rpc/lib/server.makeJSONRPCHandler.func1() /home/vagrant/go/src/github.com/tendermint/tendermint/rpc/lib/server/handlers.go:152 +0xab7 net/http.HandlerFunc.ServeHTTP() /usr/lib/go-1.9/src/net/http/server.go:1918 +0x51 net/http.(*ServeMux).ServeHTTP() /usr/lib/go-1.9/src/net/http/server.go:2254 +0xa2 github.com/tendermint/tendermint/rpc/lib/server.RecoverAndLogHandler.func1() /home/vagrant/go/src/github.com/tendermint/tendermint/rpc/lib/server/http_server.go:138 +0x4fa net/http.HandlerFunc.ServeHTTP() /usr/lib/go-1.9/src/net/http/server.go:1918 +0x51 net/http.serverHandler.ServeHTTP() /usr/lib/go-1.9/src/net/http/server.go:2619 +0xbc net/http.(*conn).serve() /usr/lib/go-1.9/src/net/http/server.go:1801 +0x83b Goroutine 23 (running) created at: github.com/tendermint/tendermint/consensus.(*ConsensusState).OnStart() /home/vagrant/go/src/github.com/tendermint/tendermint/consensus/state.go:250 +0x35b github.com/tendermint/tendermint/vendor/github.com/tendermint/tmlibs/common.(*BaseService).Start() /home/vagrant/go/src/github.com/tendermint/tendermint/vendor/github.com/tendermint/tmlibs/common/service.go:130 +0x5fc github.com/tendermint/tendermint/consensus.(*ConsensusReactor).OnStart() /home/vagrant/go/src/github.com/tendermint/tendermint/consensus/reactor.go:69 +0x1b4 github.com/tendermint/tendermint/vendor/github.com/tendermint/tmlibs/common.(*BaseService).Start() /home/vagrant/go/src/github.com/tendermint/tendermint/vendor/github.com/tendermint/tmlibs/common/service.go:130 +0x5fc github.com/tendermint/tendermint/consensus.(*ConsensusReactor).Start() <autogenerated>:1 +0x43 github.com/tendermint/tendermint/p2p.(*Switch).OnStart() /home/vagrant/go/src/github.com/tendermint/tendermint/p2p/switch.go:177 +0x124 github.com/tendermint/tendermint/vendor/github.com/tendermint/tmlibs/common.(*BaseService).Start() /home/vagrant/go/src/github.com/tendermint/tendermint/vendor/github.com/tendermint/tmlibs/common/service.go:130 +0x5fc github.com/tendermint/tendermint/node.(*Node).OnStart() /home/vagrant/go/src/github.com/tendermint/tendermint/node/node.go:416 +0xa1b github.com/tendermint/tendermint/vendor/github.com/tendermint/tmlibs/common.(*BaseService).Start() /home/vagrant/go/src/github.com/tendermint/tendermint/vendor/github.com/tendermint/tmlibs/common/service.go:130 +0x5fc github.com/tendermint/tendermint/rpc/test.StartTendermint() /home/vagrant/go/src/github.com/tendermint/tendermint/rpc/test/helpers.go:100 +0x5b github.com/tendermint/tendermint/rpc/client_test.TestMain() /home/vagrant/go/src/github.com/tendermint/tendermint/rpc/client/main_test.go:17 +0x4c main.main() github.com/tendermint/tendermint/rpc/client/_test/_testmain.go:76 +0x1cd Goroutine 47 (running) created at: net/http.(*Server).Serve() /usr/lib/go-1.9/src/net/http/server.go:2720 +0x37c net/http.Serve() /usr/lib/go-1.9/src/net/http/server.go:2323 +0xe2 github.com/tendermint/tendermint/rpc/lib/server.StartHTTPServer.func1() /home/vagrant/go/src/github.com/tendermint/tendermint/rpc/lib/server/http_server.go:35 +0xb3 ```
6 years ago
lint: Enable Golint (#4212) * Fix many golint errors * Fix golint errors in the 'lite' package * Don't export Pool.store * Fix typo * Revert unwanted changes * Fix errors in counter package * Fix linter errors in kvstore package * Fix linter error in example package * Fix error in tests package * Fix linter errors in v2 package * Fix linter errors in consensus package * Fix linter errors in evidence package * Fix linter error in fail package * Fix linter errors in query package * Fix linter errors in core package * Fix linter errors in node package * Fix linter errors in mempool package * Fix linter error in conn package * Fix linter errors in pex package * Rename PEXReactor export to Reactor * Fix linter errors in trust package * Fix linter errors in upnp package * Fix linter errors in p2p package * Fix linter errors in proxy package * Fix linter errors in mock_test package * Fix linter error in client_test package * Fix linter errors in coretypes package * Fix linter errors in coregrpc package * Fix linter errors in rpcserver package * Fix linter errors in rpctypes package * Fix linter errors in rpctest package * Fix linter error in json2wal script * Fix linter error in wal2json script * Fix linter errors in kv package * Fix linter error in state package * Fix linter error in grpc_client * Fix linter errors in types package * Fix linter error in version package * Fix remaining errors * Address review comments * Fix broken tests * Reconcile package coregrpc * Fix golangci bot error * Fix new golint errors * Fix broken reference * Enable golint linter * minor changes to bring golint into line * fix failing test * fix pex reactor naming * address PR comments
5 years ago
lint: Enable Golint (#4212) * Fix many golint errors * Fix golint errors in the 'lite' package * Don't export Pool.store * Fix typo * Revert unwanted changes * Fix errors in counter package * Fix linter errors in kvstore package * Fix linter error in example package * Fix error in tests package * Fix linter errors in v2 package * Fix linter errors in consensus package * Fix linter errors in evidence package * Fix linter error in fail package * Fix linter errors in query package * Fix linter errors in core package * Fix linter errors in node package * Fix linter errors in mempool package * Fix linter error in conn package * Fix linter errors in pex package * Rename PEXReactor export to Reactor * Fix linter errors in trust package * Fix linter errors in upnp package * Fix linter errors in p2p package * Fix linter errors in proxy package * Fix linter errors in mock_test package * Fix linter error in client_test package * Fix linter errors in coretypes package * Fix linter errors in coregrpc package * Fix linter errors in rpcserver package * Fix linter errors in rpctypes package * Fix linter errors in rpctest package * Fix linter error in json2wal script * Fix linter error in wal2json script * Fix linter errors in kv package * Fix linter error in state package * Fix linter error in grpc_client * Fix linter errors in types package * Fix linter error in version package * Fix remaining errors * Address review comments * Fix broken tests * Reconcile package coregrpc * Fix golangci bot error * Fix new golint errors * Fix broken reference * Enable golint linter * minor changes to bring golint into line * fix failing test * fix pex reactor naming * address PR comments
5 years ago
lint: Enable Golint (#4212) * Fix many golint errors * Fix golint errors in the 'lite' package * Don't export Pool.store * Fix typo * Revert unwanted changes * Fix errors in counter package * Fix linter errors in kvstore package * Fix linter error in example package * Fix error in tests package * Fix linter errors in v2 package * Fix linter errors in consensus package * Fix linter errors in evidence package * Fix linter error in fail package * Fix linter errors in query package * Fix linter errors in core package * Fix linter errors in node package * Fix linter errors in mempool package * Fix linter error in conn package * Fix linter errors in pex package * Rename PEXReactor export to Reactor * Fix linter errors in trust package * Fix linter errors in upnp package * Fix linter errors in p2p package * Fix linter errors in proxy package * Fix linter errors in mock_test package * Fix linter error in client_test package * Fix linter errors in coretypes package * Fix linter errors in coregrpc package * Fix linter errors in rpcserver package * Fix linter errors in rpctypes package * Fix linter errors in rpctest package * Fix linter error in json2wal script * Fix linter error in wal2json script * Fix linter errors in kv package * Fix linter error in state package * Fix linter error in grpc_client * Fix linter errors in types package * Fix linter error in version package * Fix remaining errors * Address review comments * Fix broken tests * Reconcile package coregrpc * Fix golangci bot error * Fix new golint errors * Fix broken reference * Enable golint linter * minor changes to bring golint into line * fix failing test * fix pex reactor naming * address PR comments
5 years ago
abci: localClient improvements & bugfixes & pubsub Unsubscribe issues (#2748) * use READ lock/unlock in ConsensusState#GetLastHeight Refs #2721 * do not use defers when there's no need * fix peer formatting (output its address instead of the pointer) ``` [54310]: E[11-02|11:59:39.851] Connection failed @ sendRoutine module=p2p peer=0xb78f00 conn=MConn{74.207.236.148:26656} err="pong timeout" ``` https://github.com/tendermint/tendermint/issues/2721#issuecomment-435326581 * panic if peer has no state https://github.com/tendermint/tendermint/issues/2721#issuecomment-435347165 It's confusing that sometimes we check if peer has a state, but most of the times we expect it to be there 1. https://github.com/tendermint/tendermint/blob/add79700b5fe84417538202b6c927c8cc5383672/mempool/reactor.go#L138 2. https://github.com/tendermint/tendermint/blob/add79700b5fe84417538202b6c927c8cc5383672/rpc/core/consensus.go#L196 (edited) I will change everything to always assume peer has a state and panic otherwise that should help identify issues earlier * abci/localclient: extend lock on app callback App callback should be protected by lock as well (note this was already done for InitChainAsync, why not for others???). Otherwise, when we execute the block, tx might come in and call the callback in the same time we're updating it in execBlockOnProxyApp => DATA RACE Fixes #2721 Consensus state is locked ``` goroutine 113333 [semacquire, 309 minutes]: sync.runtime_SemacquireMutex(0xc00180009c, 0xc0000c7e00) /usr/local/go/src/runtime/sema.go:71 +0x3d sync.(*RWMutex).RLock(0xc001800090) /usr/local/go/src/sync/rwmutex.go:50 +0x4e github.com/MinterTeam/minter-go-node/vendor/github.com/tendermint/tendermint/consensus.(*ConsensusState).GetRoundState(0xc001800000, 0x0) /root/go/src/github.com/MinterTeam/minter-go-node/vendor/github.com/tendermint/tendermint/consensus/state.go:218 +0x46 github.com/MinterTeam/minter-go-node/vendor/github.com/tendermint/tendermint/consensus.(*ConsensusReactor).queryMaj23Routine(0xc0017def80, 0x11104a0, 0xc0072488f0, 0xc007248 9c0) /root/go/src/github.com/MinterTeam/minter-go-node/vendor/github.com/tendermint/tendermint/consensus/reactor.go:735 +0x16d created by github.com/MinterTeam/minter-go-node/vendor/github.com/tendermint/tendermint/consensus.(*ConsensusReactor).AddPeer /root/go/src/github.com/MinterTeam/minter-go-node/vendor/github.com/tendermint/tendermint/consensus/reactor.go:172 +0x236 ``` because localClient is locked ``` goroutine 1899 [semacquire, 309 minutes]: sync.runtime_SemacquireMutex(0xc00003363c, 0xc0000cb500) /usr/local/go/src/runtime/sema.go:71 +0x3d sync.(*Mutex).Lock(0xc000033638) /usr/local/go/src/sync/mutex.go:134 +0xff github.com/MinterTeam/minter-go-node/vendor/github.com/tendermint/tendermint/abci/client.(*localClient).SetResponseCallback(0xc0001fb560, 0xc007868540) /root/go/src/github.com/MinterTeam/minter-go-node/vendor/github.com/tendermint/tendermint/abci/client/local_client.go:32 +0x33 github.com/MinterTeam/minter-go-node/vendor/github.com/tendermint/tendermint/proxy.(*appConnConsensus).SetResponseCallback(0xc00002f750, 0xc007868540) /root/go/src/github.com/MinterTeam/minter-go-node/vendor/github.com/tendermint/tendermint/proxy/app_conn.go:57 +0x40 github.com/MinterTeam/minter-go-node/vendor/github.com/tendermint/tendermint/state.execBlockOnProxyApp(0x1104e20, 0xc002ca0ba0, 0x11092a0, 0xc00002f750, 0xc0001fe960, 0xc000bfc660, 0x110cfe0, 0xc000090330, 0xc9d12, 0xc000d9d5a0, ...) /root/go/src/github.com/MinterTeam/minter-go-node/vendor/github.com/tendermint/tendermint/state/execution.go:230 +0x1fd github.com/MinterTeam/minter-go-node/vendor/github.com/tendermint/tendermint/state.(*BlockExecutor).ApplyBlock(0xc002c2a230, 0x7, 0x0, 0xc000eae880, 0x6, 0xc002e52c60, 0x16, 0x1f927, 0xc9d12, 0xc000d9d5a0, ...) /root/go/src/github.com/MinterTeam/minter-go-node/vendor/github.com/tendermint/tendermint/state/execution.go:96 +0x142 github.com/MinterTeam/minter-go-node/vendor/github.com/tendermint/tendermint/consensus.(*ConsensusState).finalizeCommit(0xc001800000, 0x1f928) /root/go/src/github.com/MinterTeam/minter-go-node/vendor/github.com/tendermint/tendermint/consensus/state.go:1339 +0xa3e github.com/MinterTeam/minter-go-node/vendor/github.com/tendermint/tendermint/consensus.(*ConsensusState).tryFinalizeCommit(0xc001800000, 0x1f928) /root/go/src/github.com/MinterTeam/minter-go-node/vendor/github.com/tendermint/tendermint/consensus/state.go:1270 +0x451 github.com/MinterTeam/minter-go-node/vendor/github.com/tendermint/tendermint/consensus.(*ConsensusState).enterCommit.func1(0xc001800000, 0x0, 0x1f928) /root/go/src/github.com/MinterTeam/minter-go-node/vendor/github.com/tendermint/tendermint/consensus/state.go:1218 +0x90 github.com/MinterTeam/minter-go-node/vendor/github.com/tendermint/tendermint/consensus.(*ConsensusState).enterCommit(0xc001800000, 0x1f928, 0x0) /root/go/src/github.com/MinterTeam/minter-go-node/vendor/github.com/tendermint/tendermint/consensus/state.go:1247 +0x6b8 github.com/MinterTeam/minter-go-node/vendor/github.com/tendermint/tendermint/consensus.(*ConsensusState).addVote(0xc001800000, 0xc003d8dea0, 0xc000cf4cc0, 0x28, 0xf1, 0xc003bc7ad0, 0xc003bc7b10) /root/go/src/github.com/MinterTeam/minter-go-node/vendor/github.com/tendermint/tendermint/consensus/state.go:1659 +0xbad github.com/MinterTeam/minter-go-node/vendor/github.com/tendermint/tendermint/consensus.(*ConsensusState).tryAddVote(0xc001800000, 0xc003d8dea0, 0xc000cf4cc0, 0x28, 0xf1, 0xf1, 0xf1) /root/go/src/github.com/MinterTeam/minter-go-node/vendor/github.com/tendermint/tendermint/consensus/state.go:1517 +0x59 github.com/MinterTeam/minter-go-node/vendor/github.com/tendermint/tendermint/consensus.(*ConsensusState).handleMsg(0xc001800000, 0xd98200, 0xc0070dbed0, 0xc000cf4cc0, 0x28) /root/go/src/github.com/MinterTeam/minter-go-node/vendor/github.com/tendermint/tendermint/consensus/state.go:660 +0x64b github.com/MinterTeam/minter-go-node/vendor/github.com/tendermint/tendermint/consensus.(*ConsensusState).receiveRoutine(0xc001800000, 0x0) /root/go/src/github.com/MinterTeam/minter-go-node/vendor/github.com/tendermint/tendermint/consensus/state.go:617 +0x670 created by github.com/MinterTeam/minter-go-node/vendor/github.com/tendermint/tendermint/consensus.(*ConsensusState).OnStart /root/go/src/github.com/MinterTeam/minter-go-node/vendor/github.com/tendermint/tendermint/consensus/state.go:311 +0x132 ``` tx comes in and CheckTx is executed right when we execute the block ``` goroutine 111044 [semacquire, 309 minutes]: sync.runtime_SemacquireMutex(0xc00003363c, 0x0) /usr/local/go/src/runtime/sema.go:71 +0x3d sync.(*Mutex).Lock(0xc000033638) /usr/local/go/src/sync/mutex.go:134 +0xff github.com/MinterTeam/minter-go-node/vendor/github.com/tendermint/tendermint/abci/client.(*localClient).CheckTxAsync(0xc0001fb0e0, 0xc002d94500, 0x13f, 0x280, 0x0) /root/go/src/github.com/MinterTeam/minter-go-node/vendor/github.com/tendermint/tendermint/abci/client/local_client.go:85 +0x47 github.com/MinterTeam/minter-go-node/vendor/github.com/tendermint/tendermint/proxy.(*appConnMempool).CheckTxAsync(0xc00002f720, 0xc002d94500, 0x13f, 0x280, 0x1) /root/go/src/github.com/MinterTeam/minter-go-node/vendor/github.com/tendermint/tendermint/proxy/app_conn.go:114 +0x51 github.com/MinterTeam/minter-go-node/vendor/github.com/tendermint/tendermint/mempool.(*Mempool).CheckTx(0xc002d3a320, 0xc002d94500, 0x13f, 0x280, 0xc0072355f0, 0x0, 0x0) /root/go/src/github.com/MinterTeam/minter-go-node/vendor/github.com/tendermint/tendermint/mempool/mempool.go:316 +0x17b github.com/MinterTeam/minter-go-node/vendor/github.com/tendermint/tendermint/rpc/core.BroadcastTxSync(0xc002d94500, 0x13f, 0x280, 0x0, 0x0, 0x0) /root/go/src/github.com/MinterTeam/minter-go-node/vendor/github.com/tendermint/tendermint/rpc/core/mempool.go:93 +0xb8 reflect.Value.call(0xd85560, 0x10326c0, 0x13, 0xec7b8b, 0x4, 0xc00663f180, 0x1, 0x1, 0xc00663f180, 0xc00663f188, ...) /usr/local/go/src/reflect/value.go:447 +0x449 reflect.Value.Call(0xd85560, 0x10326c0, 0x13, 0xc00663f180, 0x1, 0x1, 0x0, 0x0, 0xc005cc9344) /usr/local/go/src/reflect/value.go:308 +0xa4 github.com/MinterTeam/minter-go-node/vendor/github.com/tendermint/tendermint/rpc/lib/server.makeHTTPHandler.func2(0x1102060, 0xc00663f100, 0xc0082d7900) /root/go/src/github.com/MinterTeam/minter-go-node/vendor/github.com/tendermint/tendermint/rpc/lib/server/handlers.go:269 +0x188 net/http.HandlerFunc.ServeHTTP(0xc002c81f20, 0x1102060, 0xc00663f100, 0xc0082d7900) /usr/local/go/src/net/http/server.go:1964 +0x44 net/http.(*ServeMux).ServeHTTP(0xc002c81b60, 0x1102060, 0xc00663f100, 0xc0082d7900) /usr/local/go/src/net/http/server.go:2361 +0x127 github.com/MinterTeam/minter-go-node/vendor/github.com/tendermint/tendermint/rpc/lib/server.maxBytesHandler.ServeHTTP(0x10f8a40, 0xc002c81b60, 0xf4240, 0x1102060, 0xc00663f100, 0xc0082d7900) /root/go/src/github.com/MinterTeam/minter-go-node/vendor/github.com/tendermint/tendermint/rpc/lib/server/http_server.go:219 +0xcf github.com/MinterTeam/minter-go-node/vendor/github.com/tendermint/tendermint/rpc/lib/server.RecoverAndLogHandler.func1(0x1103220, 0xc00121e620, 0xc0082d7900) /root/go/src/github.com/MinterTeam/minter-go-node/vendor/github.com/tendermint/tendermint/rpc/lib/server/http_server.go:192 +0x394 net/http.HandlerFunc.ServeHTTP(0xc002c06ea0, 0x1103220, 0xc00121e620, 0xc0082d7900) /usr/local/go/src/net/http/server.go:1964 +0x44 net/http.serverHandler.ServeHTTP(0xc001a1aa90, 0x1103220, 0xc00121e620, 0xc0082d7900) /usr/local/go/src/net/http/server.go:2741 +0xab net/http.(*conn).serve(0xc00785a3c0, 0x11041a0, 0xc000f844c0) /usr/local/go/src/net/http/server.go:1847 +0x646 created by net/http.(*Server).Serve /usr/local/go/src/net/http/server.go:2851 +0x2f5 ``` * consensus: use read lock in Receive#VoteMessage * use defer to unlock mutex because application might panic * use defer in every method of the localClient * add a changelog entry * drain channels before Unsubscribe(All) Read https://github.com/tendermint/tendermint/blob/55362ed76630f3e1ebec159a598f6a9fb5892cb1/libs/pubsub/pubsub.go#L13 for the detailed explanation of the issue. We'll need to fix it someday. Make sure to keep an eye on https://github.com/tendermint/tendermint/blob/master/docs/architecture/adr-033-pubsub.md * retry instead of panic when peer has no state in reactors other than consensus in /dump_consensus_state RPC endpoint, skip a peer with no state * rpc/core/mempool: simplify error messages * rpc/core/mempool: use time.After instead of timer also, do not log DeliverTx result (to be consistent with other memthods) * unlock before calling the callback in reqRes#SetCallback
6 years ago
lint: Enable Golint (#4212) * Fix many golint errors * Fix golint errors in the 'lite' package * Don't export Pool.store * Fix typo * Revert unwanted changes * Fix errors in counter package * Fix linter errors in kvstore package * Fix linter error in example package * Fix error in tests package * Fix linter errors in v2 package * Fix linter errors in consensus package * Fix linter errors in evidence package * Fix linter error in fail package * Fix linter errors in query package * Fix linter errors in core package * Fix linter errors in node package * Fix linter errors in mempool package * Fix linter error in conn package * Fix linter errors in pex package * Rename PEXReactor export to Reactor * Fix linter errors in trust package * Fix linter errors in upnp package * Fix linter errors in p2p package * Fix linter errors in proxy package * Fix linter errors in mock_test package * Fix linter error in client_test package * Fix linter errors in coretypes package * Fix linter errors in coregrpc package * Fix linter errors in rpcserver package * Fix linter errors in rpctypes package * Fix linter errors in rpctest package * Fix linter error in json2wal script * Fix linter error in wal2json script * Fix linter errors in kv package * Fix linter error in state package * Fix linter error in grpc_client * Fix linter errors in types package * Fix linter error in version package * Fix remaining errors * Address review comments * Fix broken tests * Reconcile package coregrpc * Fix golangci bot error * Fix new golint errors * Fix broken reference * Enable golint linter * minor changes to bring golint into line * fix failing test * fix pex reactor naming * address PR comments
5 years ago
new pubsub package comment out failing consensus tests for now rewrite rpc httpclient to use new pubsub package import pubsub as tmpubsub, query as tmquery make event IDs constants EventKey -> EventTypeKey rename EventsPubsub to PubSub mempool does not use pubsub rename eventsSub to pubsub new subscribe API fix channel size issues and consensus tests bugs refactor rpc client add missing discardFromChan method add mutex rename pubsub to eventBus remove IsRunning from WSRPCConnection interface (not needed) add a comment in broadcastNewRoundStepsAndVotes rename registerEventCallbacks to broadcastNewRoundStepsAndVotes See https://dave.cheney.net/2014/03/19/channel-axioms stop eventBuses after reactor tests remove unnecessary Unsubscribe return subscribe helper function move discardFromChan to where it is used subscribe now returns an err this gives us ability to refuse to subscribe if pubsub is at its max capacity. use context for control overflow cache queries handle err when subscribing in replay_test rename testClientID to testSubscriber extract var set channel buffer capacity to 1 in replay_file fix byzantine_test unsubscribe from single event, not all events refactor httpclient to return events to appropriate channels return failing testReplayCrashBeforeWriteVote test fix TestValidatorSetChanges refactor code a bit fix testReplayCrashBeforeWriteVote add comment fix TestValidatorSetChanges fixes from Bucky's review update comment [ci skip] test TxEventBuffer update changelog fix TestValidatorSetChanges (2nd attempt) only do wg.Done when no errors benchmark event bus create pubsub server inside NewEventBus only expose config params (later if needed) set buffer capacity to 0 so we are not testing cache new tx event format: key = "Tx" plus a tag {"tx.hash": XYZ} This should allow to subscribe to all transactions! or a specific one using a query: "tm.events.type = Tx and tx.hash = '013ABF99434...'" use TimeoutCommit instead of afterPublishEventNewBlockTimeout TimeoutCommit is the time a node waits after committing a block, before it goes into the next height. So it will finish everything from the last block, but then wait a bit. The idea is this gives it time to hear more votes from other validators, to strengthen the commit it includes in the next block. But it also gives it time to hear about new transactions. waitForBlockWithUpdatedVals rewrite WAL crash tests Task: test that we can recover from any WAL crash. Solution: the old tests were relying on event hub being run in the same thread (we were injecting the private validator's last signature). when considering a rewrite, we considered two possible solutions: write a "fuzzy" testing system where WAL is crashing upon receiving a new message, or inject failures and trigger them in tests using something like https://github.com/coreos/gofail. remove sleep no cs.Lock around wal.Save test different cases (empty block, non-empty block, ...) comments add comments test 4 cases: empty block, non-empty block, non-empty block with smaller part size, many blocks fixes as per Bucky's last review reset subscriptions on UnsubscribeAll use a simple counter to track message for which we panicked also, set a smaller part size for all test cases
7 years ago
new pubsub package comment out failing consensus tests for now rewrite rpc httpclient to use new pubsub package import pubsub as tmpubsub, query as tmquery make event IDs constants EventKey -> EventTypeKey rename EventsPubsub to PubSub mempool does not use pubsub rename eventsSub to pubsub new subscribe API fix channel size issues and consensus tests bugs refactor rpc client add missing discardFromChan method add mutex rename pubsub to eventBus remove IsRunning from WSRPCConnection interface (not needed) add a comment in broadcastNewRoundStepsAndVotes rename registerEventCallbacks to broadcastNewRoundStepsAndVotes See https://dave.cheney.net/2014/03/19/channel-axioms stop eventBuses after reactor tests remove unnecessary Unsubscribe return subscribe helper function move discardFromChan to where it is used subscribe now returns an err this gives us ability to refuse to subscribe if pubsub is at its max capacity. use context for control overflow cache queries handle err when subscribing in replay_test rename testClientID to testSubscriber extract var set channel buffer capacity to 1 in replay_file fix byzantine_test unsubscribe from single event, not all events refactor httpclient to return events to appropriate channels return failing testReplayCrashBeforeWriteVote test fix TestValidatorSetChanges refactor code a bit fix testReplayCrashBeforeWriteVote add comment fix TestValidatorSetChanges fixes from Bucky's review update comment [ci skip] test TxEventBuffer update changelog fix TestValidatorSetChanges (2nd attempt) only do wg.Done when no errors benchmark event bus create pubsub server inside NewEventBus only expose config params (later if needed) set buffer capacity to 0 so we are not testing cache new tx event format: key = "Tx" plus a tag {"tx.hash": XYZ} This should allow to subscribe to all transactions! or a specific one using a query: "tm.events.type = Tx and tx.hash = '013ABF99434...'" use TimeoutCommit instead of afterPublishEventNewBlockTimeout TimeoutCommit is the time a node waits after committing a block, before it goes into the next height. So it will finish everything from the last block, but then wait a bit. The idea is this gives it time to hear more votes from other validators, to strengthen the commit it includes in the next block. But it also gives it time to hear about new transactions. waitForBlockWithUpdatedVals rewrite WAL crash tests Task: test that we can recover from any WAL crash. Solution: the old tests were relying on event hub being run in the same thread (we were injecting the private validator's last signature). when considering a rewrite, we considered two possible solutions: write a "fuzzy" testing system where WAL is crashing upon receiving a new message, or inject failures and trigger them in tests using something like https://github.com/coreos/gofail. remove sleep no cs.Lock around wal.Save test different cases (empty block, non-empty block, ...) comments add comments test 4 cases: empty block, non-empty block, non-empty block with smaller part size, many blocks fixes as per Bucky's last review reset subscriptions on UnsubscribeAll use a simple counter to track message for which we panicked also, set a smaller part size for all test cases
7 years ago
lint: Enable Golint (#4212) * Fix many golint errors * Fix golint errors in the 'lite' package * Don't export Pool.store * Fix typo * Revert unwanted changes * Fix errors in counter package * Fix linter errors in kvstore package * Fix linter error in example package * Fix error in tests package * Fix linter errors in v2 package * Fix linter errors in consensus package * Fix linter errors in evidence package * Fix linter error in fail package * Fix linter errors in query package * Fix linter errors in core package * Fix linter errors in node package * Fix linter errors in mempool package * Fix linter error in conn package * Fix linter errors in pex package * Rename PEXReactor export to Reactor * Fix linter errors in trust package * Fix linter errors in upnp package * Fix linter errors in p2p package * Fix linter errors in proxy package * Fix linter errors in mock_test package * Fix linter error in client_test package * Fix linter errors in coretypes package * Fix linter errors in coregrpc package * Fix linter errors in rpcserver package * Fix linter errors in rpctypes package * Fix linter errors in rpctest package * Fix linter error in json2wal script * Fix linter error in wal2json script * Fix linter errors in kv package * Fix linter error in state package * Fix linter error in grpc_client * Fix linter errors in types package * Fix linter error in version package * Fix remaining errors * Address review comments * Fix broken tests * Reconcile package coregrpc * Fix golangci bot error * Fix new golint errors * Fix broken reference * Enable golint linter * minor changes to bring golint into line * fix failing test * fix pex reactor naming * address PR comments
5 years ago
10 years ago
7 years ago
lint: Enable Golint (#4212) * Fix many golint errors * Fix golint errors in the 'lite' package * Don't export Pool.store * Fix typo * Revert unwanted changes * Fix errors in counter package * Fix linter errors in kvstore package * Fix linter error in example package * Fix error in tests package * Fix linter errors in v2 package * Fix linter errors in consensus package * Fix linter errors in evidence package * Fix linter error in fail package * Fix linter errors in query package * Fix linter errors in core package * Fix linter errors in node package * Fix linter errors in mempool package * Fix linter error in conn package * Fix linter errors in pex package * Rename PEXReactor export to Reactor * Fix linter errors in trust package * Fix linter errors in upnp package * Fix linter errors in p2p package * Fix linter errors in proxy package * Fix linter errors in mock_test package * Fix linter error in client_test package * Fix linter errors in coretypes package * Fix linter errors in coregrpc package * Fix linter errors in rpcserver package * Fix linter errors in rpctypes package * Fix linter errors in rpctest package * Fix linter error in json2wal script * Fix linter error in wal2json script * Fix linter errors in kv package * Fix linter error in state package * Fix linter error in grpc_client * Fix linter errors in types package * Fix linter error in version package * Fix remaining errors * Address review comments * Fix broken tests * Reconcile package coregrpc * Fix golangci bot error * Fix new golint errors * Fix broken reference * Enable golint linter * minor changes to bring golint into line * fix failing test * fix pex reactor naming * address PR comments
5 years ago
7 years ago
new pubsub package comment out failing consensus tests for now rewrite rpc httpclient to use new pubsub package import pubsub as tmpubsub, query as tmquery make event IDs constants EventKey -> EventTypeKey rename EventsPubsub to PubSub mempool does not use pubsub rename eventsSub to pubsub new subscribe API fix channel size issues and consensus tests bugs refactor rpc client add missing discardFromChan method add mutex rename pubsub to eventBus remove IsRunning from WSRPCConnection interface (not needed) add a comment in broadcastNewRoundStepsAndVotes rename registerEventCallbacks to broadcastNewRoundStepsAndVotes See https://dave.cheney.net/2014/03/19/channel-axioms stop eventBuses after reactor tests remove unnecessary Unsubscribe return subscribe helper function move discardFromChan to where it is used subscribe now returns an err this gives us ability to refuse to subscribe if pubsub is at its max capacity. use context for control overflow cache queries handle err when subscribing in replay_test rename testClientID to testSubscriber extract var set channel buffer capacity to 1 in replay_file fix byzantine_test unsubscribe from single event, not all events refactor httpclient to return events to appropriate channels return failing testReplayCrashBeforeWriteVote test fix TestValidatorSetChanges refactor code a bit fix testReplayCrashBeforeWriteVote add comment fix TestValidatorSetChanges fixes from Bucky's review update comment [ci skip] test TxEventBuffer update changelog fix TestValidatorSetChanges (2nd attempt) only do wg.Done when no errors benchmark event bus create pubsub server inside NewEventBus only expose config params (later if needed) set buffer capacity to 0 so we are not testing cache new tx event format: key = "Tx" plus a tag {"tx.hash": XYZ} This should allow to subscribe to all transactions! or a specific one using a query: "tm.events.type = Tx and tx.hash = '013ABF99434...'" use TimeoutCommit instead of afterPublishEventNewBlockTimeout TimeoutCommit is the time a node waits after committing a block, before it goes into the next height. So it will finish everything from the last block, but then wait a bit. The idea is this gives it time to hear more votes from other validators, to strengthen the commit it includes in the next block. But it also gives it time to hear about new transactions. waitForBlockWithUpdatedVals rewrite WAL crash tests Task: test that we can recover from any WAL crash. Solution: the old tests were relying on event hub being run in the same thread (we were injecting the private validator's last signature). when considering a rewrite, we considered two possible solutions: write a "fuzzy" testing system where WAL is crashing upon receiving a new message, or inject failures and trigger them in tests using something like https://github.com/coreos/gofail. remove sleep no cs.Lock around wal.Save test different cases (empty block, non-empty block, ...) comments add comments test 4 cases: empty block, non-empty block, non-empty block with smaller part size, many blocks fixes as per Bucky's last review reset subscriptions on UnsubscribeAll use a simple counter to track message for which we panicked also, set a smaller part size for all test cases
7 years ago
new pubsub package comment out failing consensus tests for now rewrite rpc httpclient to use new pubsub package import pubsub as tmpubsub, query as tmquery make event IDs constants EventKey -> EventTypeKey rename EventsPubsub to PubSub mempool does not use pubsub rename eventsSub to pubsub new subscribe API fix channel size issues and consensus tests bugs refactor rpc client add missing discardFromChan method add mutex rename pubsub to eventBus remove IsRunning from WSRPCConnection interface (not needed) add a comment in broadcastNewRoundStepsAndVotes rename registerEventCallbacks to broadcastNewRoundStepsAndVotes See https://dave.cheney.net/2014/03/19/channel-axioms stop eventBuses after reactor tests remove unnecessary Unsubscribe return subscribe helper function move discardFromChan to where it is used subscribe now returns an err this gives us ability to refuse to subscribe if pubsub is at its max capacity. use context for control overflow cache queries handle err when subscribing in replay_test rename testClientID to testSubscriber extract var set channel buffer capacity to 1 in replay_file fix byzantine_test unsubscribe from single event, not all events refactor httpclient to return events to appropriate channels return failing testReplayCrashBeforeWriteVote test fix TestValidatorSetChanges refactor code a bit fix testReplayCrashBeforeWriteVote add comment fix TestValidatorSetChanges fixes from Bucky's review update comment [ci skip] test TxEventBuffer update changelog fix TestValidatorSetChanges (2nd attempt) only do wg.Done when no errors benchmark event bus create pubsub server inside NewEventBus only expose config params (later if needed) set buffer capacity to 0 so we are not testing cache new tx event format: key = "Tx" plus a tag {"tx.hash": XYZ} This should allow to subscribe to all transactions! or a specific one using a query: "tm.events.type = Tx and tx.hash = '013ABF99434...'" use TimeoutCommit instead of afterPublishEventNewBlockTimeout TimeoutCommit is the time a node waits after committing a block, before it goes into the next height. So it will finish everything from the last block, but then wait a bit. The idea is this gives it time to hear more votes from other validators, to strengthen the commit it includes in the next block. But it also gives it time to hear about new transactions. waitForBlockWithUpdatedVals rewrite WAL crash tests Task: test that we can recover from any WAL crash. Solution: the old tests were relying on event hub being run in the same thread (we were injecting the private validator's last signature). when considering a rewrite, we considered two possible solutions: write a "fuzzy" testing system where WAL is crashing upon receiving a new message, or inject failures and trigger them in tests using something like https://github.com/coreos/gofail. remove sleep no cs.Lock around wal.Save test different cases (empty block, non-empty block, ...) comments add comments test 4 cases: empty block, non-empty block, non-empty block with smaller part size, many blocks fixes as per Bucky's last review reset subscriptions on UnsubscribeAll use a simple counter to track message for which we panicked also, set a smaller part size for all test cases
7 years ago
new pubsub package comment out failing consensus tests for now rewrite rpc httpclient to use new pubsub package import pubsub as tmpubsub, query as tmquery make event IDs constants EventKey -> EventTypeKey rename EventsPubsub to PubSub mempool does not use pubsub rename eventsSub to pubsub new subscribe API fix channel size issues and consensus tests bugs refactor rpc client add missing discardFromChan method add mutex rename pubsub to eventBus remove IsRunning from WSRPCConnection interface (not needed) add a comment in broadcastNewRoundStepsAndVotes rename registerEventCallbacks to broadcastNewRoundStepsAndVotes See https://dave.cheney.net/2014/03/19/channel-axioms stop eventBuses after reactor tests remove unnecessary Unsubscribe return subscribe helper function move discardFromChan to where it is used subscribe now returns an err this gives us ability to refuse to subscribe if pubsub is at its max capacity. use context for control overflow cache queries handle err when subscribing in replay_test rename testClientID to testSubscriber extract var set channel buffer capacity to 1 in replay_file fix byzantine_test unsubscribe from single event, not all events refactor httpclient to return events to appropriate channels return failing testReplayCrashBeforeWriteVote test fix TestValidatorSetChanges refactor code a bit fix testReplayCrashBeforeWriteVote add comment fix TestValidatorSetChanges fixes from Bucky's review update comment [ci skip] test TxEventBuffer update changelog fix TestValidatorSetChanges (2nd attempt) only do wg.Done when no errors benchmark event bus create pubsub server inside NewEventBus only expose config params (later if needed) set buffer capacity to 0 so we are not testing cache new tx event format: key = "Tx" plus a tag {"tx.hash": XYZ} This should allow to subscribe to all transactions! or a specific one using a query: "tm.events.type = Tx and tx.hash = '013ABF99434...'" use TimeoutCommit instead of afterPublishEventNewBlockTimeout TimeoutCommit is the time a node waits after committing a block, before it goes into the next height. So it will finish everything from the last block, but then wait a bit. The idea is this gives it time to hear more votes from other validators, to strengthen the commit it includes in the next block. But it also gives it time to hear about new transactions. waitForBlockWithUpdatedVals rewrite WAL crash tests Task: test that we can recover from any WAL crash. Solution: the old tests were relying on event hub being run in the same thread (we were injecting the private validator's last signature). when considering a rewrite, we considered two possible solutions: write a "fuzzy" testing system where WAL is crashing upon receiving a new message, or inject failures and trigger them in tests using something like https://github.com/coreos/gofail. remove sleep no cs.Lock around wal.Save test different cases (empty block, non-empty block, ...) comments add comments test 4 cases: empty block, non-empty block, non-empty block with smaller part size, many blocks fixes as per Bucky's last review reset subscriptions on UnsubscribeAll use a simple counter to track message for which we panicked also, set a smaller part size for all test cases
7 years ago
lint: Enable Golint (#4212) * Fix many golint errors * Fix golint errors in the 'lite' package * Don't export Pool.store * Fix typo * Revert unwanted changes * Fix errors in counter package * Fix linter errors in kvstore package * Fix linter error in example package * Fix error in tests package * Fix linter errors in v2 package * Fix linter errors in consensus package * Fix linter errors in evidence package * Fix linter error in fail package * Fix linter errors in query package * Fix linter errors in core package * Fix linter errors in node package * Fix linter errors in mempool package * Fix linter error in conn package * Fix linter errors in pex package * Rename PEXReactor export to Reactor * Fix linter errors in trust package * Fix linter errors in upnp package * Fix linter errors in p2p package * Fix linter errors in proxy package * Fix linter errors in mock_test package * Fix linter error in client_test package * Fix linter errors in coretypes package * Fix linter errors in coregrpc package * Fix linter errors in rpcserver package * Fix linter errors in rpctypes package * Fix linter errors in rpctest package * Fix linter error in json2wal script * Fix linter error in wal2json script * Fix linter errors in kv package * Fix linter error in state package * Fix linter error in grpc_client * Fix linter errors in types package * Fix linter error in version package * Fix remaining errors * Address review comments * Fix broken tests * Reconcile package coregrpc * Fix golangci bot error * Fix new golint errors * Fix broken reference * Enable golint linter * minor changes to bring golint into line * fix failing test * fix pex reactor naming * address PR comments
5 years ago
lint: Enable Golint (#4212) * Fix many golint errors * Fix golint errors in the 'lite' package * Don't export Pool.store * Fix typo * Revert unwanted changes * Fix errors in counter package * Fix linter errors in kvstore package * Fix linter error in example package * Fix error in tests package * Fix linter errors in v2 package * Fix linter errors in consensus package * Fix linter errors in evidence package * Fix linter error in fail package * Fix linter errors in query package * Fix linter errors in core package * Fix linter errors in node package * Fix linter errors in mempool package * Fix linter error in conn package * Fix linter errors in pex package * Rename PEXReactor export to Reactor * Fix linter errors in trust package * Fix linter errors in upnp package * Fix linter errors in p2p package * Fix linter errors in proxy package * Fix linter errors in mock_test package * Fix linter error in client_test package * Fix linter errors in coretypes package * Fix linter errors in coregrpc package * Fix linter errors in rpcserver package * Fix linter errors in rpctypes package * Fix linter errors in rpctest package * Fix linter error in json2wal script * Fix linter error in wal2json script * Fix linter errors in kv package * Fix linter error in state package * Fix linter error in grpc_client * Fix linter errors in types package * Fix linter error in version package * Fix remaining errors * Address review comments * Fix broken tests * Reconcile package coregrpc * Fix golangci bot error * Fix new golint errors * Fix broken reference * Enable golint linter * minor changes to bring golint into line * fix failing test * fix pex reactor naming * address PR comments
5 years ago
lint: Enable Golint (#4212) * Fix many golint errors * Fix golint errors in the 'lite' package * Don't export Pool.store * Fix typo * Revert unwanted changes * Fix errors in counter package * Fix linter errors in kvstore package * Fix linter error in example package * Fix error in tests package * Fix linter errors in v2 package * Fix linter errors in consensus package * Fix linter errors in evidence package * Fix linter error in fail package * Fix linter errors in query package * Fix linter errors in core package * Fix linter errors in node package * Fix linter errors in mempool package * Fix linter error in conn package * Fix linter errors in pex package * Rename PEXReactor export to Reactor * Fix linter errors in trust package * Fix linter errors in upnp package * Fix linter errors in p2p package * Fix linter errors in proxy package * Fix linter errors in mock_test package * Fix linter error in client_test package * Fix linter errors in coretypes package * Fix linter errors in coregrpc package * Fix linter errors in rpcserver package * Fix linter errors in rpctypes package * Fix linter errors in rpctest package * Fix linter error in json2wal script * Fix linter error in wal2json script * Fix linter errors in kv package * Fix linter error in state package * Fix linter error in grpc_client * Fix linter errors in types package * Fix linter error in version package * Fix remaining errors * Address review comments * Fix broken tests * Reconcile package coregrpc * Fix golangci bot error * Fix new golint errors * Fix broken reference * Enable golint linter * minor changes to bring golint into line * fix failing test * fix pex reactor naming * address PR comments
5 years ago
9 years ago
consensus: additional timing metrics (#7849) This change introduces an additional set of metrics aimed at helping operators understand the timing for consensus. This change adds the following metrics: ``` # HELP tendermint_consensus_round_duration Time spent in a round # TYPE tendermint_consensus_round_duration histogram tendermint_consensus_round_duration_bucket{chain_id="test-chain-IrF74Y",le="0.1"} 29 tendermint_consensus_round_duration_bucket{chain_id="test-chain-IrF74Y",le="0.2682695795279726"} 29 tendermint_consensus_round_duration_bucket{chain_id="test-chain-IrF74Y",le="0.7196856730011522"} 29 tendermint_consensus_round_duration_bucket{chain_id="test-chain-IrF74Y",le="1.9306977288832508"} 29 tendermint_consensus_round_duration_bucket{chain_id="test-chain-IrF74Y",le="5.1794746792312125"} 29 tendermint_consensus_round_duration_bucket{chain_id="test-chain-IrF74Y",le="13.894954943731381"} 29 tendermint_consensus_round_duration_bucket{chain_id="test-chain-IrF74Y",le="37.27593720314942"} 29 tendermint_consensus_round_duration_bucket{chain_id="test-chain-IrF74Y",le="100.00000000000006"} 29 tendermint_consensus_round_duration_bucket{chain_id="test-chain-IrF74Y",le="+Inf"} 29 tendermint_consensus_round_duration_sum{chain_id="test-chain-IrF74Y"} 0.028651869999999996 tendermint_consensus_round_duration_count{chain_id="test-chain-IrF74Y"} 29 ``` ``` # HELP tendermint_consensus_step_duration Time spent per step. # TYPE tendermint_consensus_step_duration histogram tendermint_consensus_step_duration_bucket{chain_id="test-chain-IrF74Y",step="Commit",le="0.1"} 29 tendermint_consensus_step_duration_bucket{chain_id="test-chain-IrF74Y",step="Commit",le="0.2682695795279726"} 29 tendermint_consensus_step_duration_bucket{chain_id="test-chain-IrF74Y",step="Commit",le="0.7196856730011522"} 29 tendermint_consensus_step_duration_bucket{chain_id="test-chain-IrF74Y",step="Commit",le="1.9306977288832508"} 29 tendermint_consensus_step_duration_bucket{chain_id="test-chain-IrF74Y",step="Commit",le="5.1794746792312125"} 29 tendermint_consensus_step_duration_bucket{chain_id="test-chain-IrF74Y",step="Commit",le="13.894954943731381"} 29 tendermint_consensus_step_duration_bucket{chain_id="test-chain-IrF74Y",step="Commit",le="37.27593720314942"} 29 tendermint_consensus_step_duration_bucket{chain_id="test-chain-IrF74Y",step="Commit",le="100.00000000000006"} 29 tendermint_consensus_step_duration_bucket{chain_id="test-chain-IrF74Y",step="Commit",le="+Inf"} 29 tendermint_consensus_step_duration_sum{chain_id="test-chain-IrF74Y",step="Commit"} 0.26650875 tendermint_consensus_step_duration_count{chain_id="test-chain-IrF74Y",step="Commit"} 29 tendermint_consensus_step_duration_bucket{chain_id="test-chain-IrF74Y",step="NewHeight",le="0.1"} 0 tendermint_consensus_step_duration_bucket{chain_id="test-chain-IrF74Y",step="NewHeight",le="0.2682695795279726"} 0 tendermint_consensus_step_duration_bucket{chain_id="test-chain-IrF74Y",step="NewHeight",le="0.7196856730011522"} 0 tendermint_consensus_step_duration_bucket{chain_id="test-chain-IrF74Y",step="NewHeight",le="1.9306977288832508"} 28 tendermint_consensus_step_duration_bucket{chain_id="test-chain-IrF74Y",step="NewHeight",le="5.1794746792312125"} 28 tendermint_consensus_step_duration_bucket{chain_id="test-chain-IrF74Y",step="NewHeight",le="13.894954943731381"} 28 tendermint_consensus_step_duration_bucket{chain_id="test-chain-IrF74Y",step="NewHeight",le="37.27593720314942"} 28 tendermint_consensus_step_duration_bucket{chain_id="test-chain-IrF74Y",step="NewHeight",le="100.00000000000006"} 28 tendermint_consensus_step_duration_bucket{chain_id="test-chain-IrF74Y",step="NewHeight",le="+Inf"} 28 tendermint_consensus_step_duration_sum{chain_id="test-chain-IrF74Y",step="NewHeight"} 27.773921702 tendermint_consensus_step_duration_count{chain_id="test-chain-IrF74Y",step="NewHeight"} 28 tendermint_consensus_step_duration_bucket{chain_id="test-chain-IrF74Y",step="NewRound",le="0.1"} 29 tendermint_consensus_step_duration_bucket{chain_id="test-chain-IrF74Y",step="NewRound",le="0.2682695795279726"} 29 tendermint_consensus_step_duration_bucket{chain_id="test-chain-IrF74Y",step="NewRound",le="0.7196856730011522"} 29 tendermint_consensus_step_duration_bucket{chain_id="test-chain-IrF74Y",step="NewRound",le="1.9306977288832508"} 29 tendermint_consensus_step_duration_bucket{chain_id="test-chain-IrF74Y",step="NewRound",le="5.1794746792312125"} 29 tendermint_consensus_step_duration_bucket{chain_id="test-chain-IrF74Y",step="NewRound",le="13.894954943731381"} 29 tendermint_consensus_step_duration_bucket{chain_id="test-chain-IrF74Y",step="NewRound",le="37.27593720314942"} 29 tendermint_consensus_step_duration_bucket{chain_id="test-chain-IrF74Y",step="NewRound",le="100.00000000000006"} 29 tendermint_consensus_step_duration_bucket{chain_id="test-chain-IrF74Y",step="NewRound",le="+Inf"} 29 tendermint_consensus_step_duration_sum{chain_id="test-chain-IrF74Y",step="NewRound"} 0.168961052 tendermint_consensus_step_duration_count{chain_id="test-chain-IrF74Y",step="NewRound"} 29 tendermint_consensus_step_duration_bucket{chain_id="test-chain-IrF74Y",step="Precommit",le="0.1"} 29 tendermint_consensus_step_duration_bucket{chain_id="test-chain-IrF74Y",step="Precommit",le="0.2682695795279726"} 29 tendermint_consensus_step_duration_bucket{chain_id="test-chain-IrF74Y",step="Precommit",le="0.7196856730011522"} 29 tendermint_consensus_step_duration_bucket{chain_id="test-chain-IrF74Y",step="Precommit",le="1.9306977288832508"} 29 tendermint_consensus_step_duration_bucket{chain_id="test-chain-IrF74Y",step="Precommit",le="5.1794746792312125"} 29 tendermint_consensus_step_duration_bucket{chain_id="test-chain-IrF74Y",step="Precommit",le="13.894954943731381"} 29 tendermint_consensus_step_duration_bucket{chain_id="test-chain-IrF74Y",step="Precommit",le="37.27593720314942"} 29 tendermint_consensus_step_duration_bucket{chain_id="test-chain-IrF74Y",step="Precommit",le="100.00000000000006"} 29 tendermint_consensus_step_duration_bucket{chain_id="test-chain-IrF74Y",step="Precommit",le="+Inf"} 29 tendermint_consensus_step_duration_sum{chain_id="test-chain-IrF74Y",step="Precommit"} 0.06414115999999999 tendermint_consensus_step_duration_count{chain_id="test-chain-IrF74Y",step="Precommit"} 29 tendermint_consensus_step_duration_bucket{chain_id="test-chain-IrF74Y",step="Prevote",le="0.1"} 29 tendermint_consensus_step_duration_bucket{chain_id="test-chain-IrF74Y",step="Prevote",le="0.2682695795279726"} 29 tendermint_consensus_step_duration_bucket{chain_id="test-chain-IrF74Y",step="Prevote",le="0.7196856730011522"} 29 tendermint_consensus_step_duration_bucket{chain_id="test-chain-IrF74Y",step="Prevote",le="1.9306977288832508"} 29 tendermint_consensus_step_duration_bucket{chain_id="test-chain-IrF74Y",step="Prevote",le="5.1794746792312125"} 29 tendermint_consensus_step_duration_bucket{chain_id="test-chain-IrF74Y",step="Prevote",le="13.894954943731381"} 29 tendermint_consensus_step_duration_bucket{chain_id="test-chain-IrF74Y",step="Prevote",le="37.27593720314942"} 29 tendermint_consensus_step_duration_bucket{chain_id="test-chain-IrF74Y",step="Prevote",le="100.00000000000006"} 29 tendermint_consensus_step_duration_bucket{chain_id="test-chain-IrF74Y",step="Prevote",le="+Inf"} 29 tendermint_consensus_step_duration_sum{chain_id="test-chain-IrF74Y",step="Prevote"} 0.177714525 tendermint_consensus_step_duration_count{chain_id="test-chain-IrF74Y",step="Prevote"} 29 tendermint_consensus_step_duration_bucket{chain_id="test-chain-IrF74Y",step="Propose",le="0.1"} 29 tendermint_consensus_step_duration_bucket{chain_id="test-chain-IrF74Y",step="Propose",le="0.2682695795279726"} 29 tendermint_consensus_step_duration_bucket{chain_id="test-chain-IrF74Y",step="Propose",le="0.7196856730011522"} 29 tendermint_consensus_step_duration_bucket{chain_id="test-chain-IrF74Y",step="Propose",le="1.9306977288832508"} 29 tendermint_consensus_step_duration_bucket{chain_id="test-chain-IrF74Y",step="Propose",le="5.1794746792312125"} 29 tendermint_consensus_step_duration_bucket{chain_id="test-chain-IrF74Y",step="Propose",le="13.894954943731381"} 29 tendermint_consensus_step_duration_bucket{chain_id="test-chain-IrF74Y",step="Propose",le="37.27593720314942"} 29 tendermint_consensus_step_duration_bucket{chain_id="test-chain-IrF74Y",step="Propose",le="100.00000000000006"} 29 tendermint_consensus_step_duration_bucket{chain_id="test-chain-IrF74Y",step="Propose",le="+Inf"} 29 tendermint_consensus_step_duration_sum{chain_id="test-chain-IrF74Y",step="Propose"} 0.221851927 tendermint_consensus_step_duration_count{chain_id="test-chain-IrF74Y",step="Propose"} 29 ``` ``` # HELP tendermint_consensus_block_gossip_receive_time Difference in seconds between when the validator learns of a new blockand when the validator receives the last piece of the block. # TYPE tendermint_consensus_block_gossip_receive_time histogram tendermint_consensus_block_gossip_receive_time_bucket{chain_id="test-chain-IrF74Y",le="0.1"} 29 tendermint_consensus_block_gossip_receive_time_bucket{chain_id="test-chain-IrF74Y",le="0.2682695795279726"} 29 tendermint_consensus_block_gossip_receive_time_bucket{chain_id="test-chain-IrF74Y",le="0.7196856730011522"} 29 tendermint_consensus_block_gossip_receive_time_bucket{chain_id="test-chain-IrF74Y",le="1.9306977288832508"} 29 tendermint_consensus_block_gossip_receive_time_bucket{chain_id="test-chain-IrF74Y",le="5.1794746792312125"} 29 tendermint_consensus_block_gossip_receive_time_bucket{chain_id="test-chain-IrF74Y",le="13.894954943731381"} 29 tendermint_consensus_block_gossip_receive_time_bucket{chain_id="test-chain-IrF74Y",le="37.27593720314942"} 29 tendermint_consensus_block_gossip_receive_time_bucket{chain_id="test-chain-IrF74Y",le="100.00000000000006"} 29 tendermint_consensus_block_gossip_receive_time_bucket{chain_id="test-chain-IrF74Y",le="+Inf"} 29 tendermint_consensus_block_gossip_receive_time_sum{chain_id="test-chain-IrF74Y"} 0.06380 ``` ``` # HELP tendermint_consensus_block_gossip_parts_received Number of block parts received by the node, labeled by whether thepart was relevant to the block the node was currently gathering or not # TYPE tendermint_consensus_block_gossip_parts_received counter tendermint_consensus_block_gossip_parts_received{chain_id="test-chain-IrF74Y",matches_current="true"} 29 ```
2 years ago
9 years ago
lint: Enable Golint (#4212) * Fix many golint errors * Fix golint errors in the 'lite' package * Don't export Pool.store * Fix typo * Revert unwanted changes * Fix errors in counter package * Fix linter errors in kvstore package * Fix linter error in example package * Fix error in tests package * Fix linter errors in v2 package * Fix linter errors in consensus package * Fix linter errors in evidence package * Fix linter error in fail package * Fix linter errors in query package * Fix linter errors in core package * Fix linter errors in node package * Fix linter errors in mempool package * Fix linter error in conn package * Fix linter errors in pex package * Rename PEXReactor export to Reactor * Fix linter errors in trust package * Fix linter errors in upnp package * Fix linter errors in p2p package * Fix linter errors in proxy package * Fix linter errors in mock_test package * Fix linter error in client_test package * Fix linter errors in coretypes package * Fix linter errors in coregrpc package * Fix linter errors in rpcserver package * Fix linter errors in rpctypes package * Fix linter errors in rpctest package * Fix linter error in json2wal script * Fix linter error in wal2json script * Fix linter errors in kv package * Fix linter error in state package * Fix linter error in grpc_client * Fix linter errors in types package * Fix linter error in version package * Fix remaining errors * Address review comments * Fix broken tests * Reconcile package coregrpc * Fix golangci bot error * Fix new golint errors * Fix broken reference * Enable golint linter * minor changes to bring golint into line * fix failing test * fix pex reactor naming * address PR comments
5 years ago
9 years ago
lint: Enable Golint (#4212) * Fix many golint errors * Fix golint errors in the 'lite' package * Don't export Pool.store * Fix typo * Revert unwanted changes * Fix errors in counter package * Fix linter errors in kvstore package * Fix linter error in example package * Fix error in tests package * Fix linter errors in v2 package * Fix linter errors in consensus package * Fix linter errors in evidence package * Fix linter error in fail package * Fix linter errors in query package * Fix linter errors in core package * Fix linter errors in node package * Fix linter errors in mempool package * Fix linter error in conn package * Fix linter errors in pex package * Rename PEXReactor export to Reactor * Fix linter errors in trust package * Fix linter errors in upnp package * Fix linter errors in p2p package * Fix linter errors in proxy package * Fix linter errors in mock_test package * Fix linter error in client_test package * Fix linter errors in coretypes package * Fix linter errors in coregrpc package * Fix linter errors in rpcserver package * Fix linter errors in rpctypes package * Fix linter errors in rpctest package * Fix linter error in json2wal script * Fix linter error in wal2json script * Fix linter errors in kv package * Fix linter error in state package * Fix linter error in grpc_client * Fix linter errors in types package * Fix linter error in version package * Fix remaining errors * Address review comments * Fix broken tests * Reconcile package coregrpc * Fix golangci bot error * Fix new golint errors * Fix broken reference * Enable golint linter * minor changes to bring golint into line * fix failing test * fix pex reactor naming * address PR comments
5 years ago
add support for block pruning via ABCI Commit response (#4588) * Added BlockStore.DeleteBlock() * Added initial block pruner prototype * wip * Added BlockStore.PruneBlocks() * Added consensus setting for block pruning * Added BlockStore base * Error on replay if base does not have blocks * Handle missing blocks when sending VoteSetMaj23Message * Error message tweak * Properly update blockstore state * Error message fix again * blockchain: ignore peer missing blocks * Added FIXME * Added test for block replay with truncated history * Handle peer base in blockchain reactor * Improved replay error handling * Added tests for Store.PruneBlocks() * Fix non-RPC handling of truncated block history * Panic on missing block meta in needProofBlock() * Updated changelog * Handle truncated block history in RPC layer * Added info about earliest block in /status RPC * Reorder height and base in blockchain reactor messages * Updated changelog * Fix tests * Appease linter * Minor review fixes * Non-empty BlockStores should always have base > 0 * Update code to assume base > 0 invariant * Added blockstore tests for pruning to 0 * Make sure we don't prune below the current base * Added BlockStore.Size() * config: added retain_blocks recommendations * Update v1 blockchain reactor to handle blockstore base * Added state database pruning * Propagate errors on missing validator sets * Comment tweaks * Improved error message Co-Authored-By: Anton Kaliaev <anton.kalyaev@gmail.com> * use ABCI field ResponseCommit.retain_height instead of retain-blocks config option * remove State.RetainHeight, return value instead * fix minor issues * rename pruneHeights() to pruneBlocks() * noop to fix GitHub borkage Co-authored-by: Anton Kaliaev <anton.kalyaev@gmail.com>
4 years ago
lint: Enable Golint (#4212) * Fix many golint errors * Fix golint errors in the 'lite' package * Don't export Pool.store * Fix typo * Revert unwanted changes * Fix errors in counter package * Fix linter errors in kvstore package * Fix linter error in example package * Fix error in tests package * Fix linter errors in v2 package * Fix linter errors in consensus package * Fix linter errors in evidence package * Fix linter error in fail package * Fix linter errors in query package * Fix linter errors in core package * Fix linter errors in node package * Fix linter errors in mempool package * Fix linter error in conn package * Fix linter errors in pex package * Rename PEXReactor export to Reactor * Fix linter errors in trust package * Fix linter errors in upnp package * Fix linter errors in p2p package * Fix linter errors in proxy package * Fix linter errors in mock_test package * Fix linter error in client_test package * Fix linter errors in coretypes package * Fix linter errors in coregrpc package * Fix linter errors in rpcserver package * Fix linter errors in rpctypes package * Fix linter errors in rpctest package * Fix linter error in json2wal script * Fix linter error in wal2json script * Fix linter errors in kv package * Fix linter error in state package * Fix linter error in grpc_client * Fix linter errors in types package * Fix linter error in version package * Fix remaining errors * Address review comments * Fix broken tests * Reconcile package coregrpc * Fix golangci bot error * Fix new golint errors * Fix broken reference * Enable golint linter * minor changes to bring golint into line * fix failing test * fix pex reactor naming * address PR comments
5 years ago
cs: check for SkipTimeoutCommit or wait timeout in handleTxsAvailable (#3928) * cs: check for SkipTimeoutCommit or wait timeout in handleTxsAvailable Previously, if create_empty_blocks was set to false, TM sometimes could create 2 consecutive blocks without actually waiting for timeoutCommit (1 sec. by default). ``` I[2019-08-29|07:32:43.874] Executed block module=state height=47 validTxs=10 invalidTxs=0 I[2019-08-29|07:32:43.876] Committed state module=state height=47 txs=10 appHash=F88C010000000000 I[2019-08-29|07:32:44.885] Executed block module=state height=48 validTxs=2 invalidTxs=0 I[2019-08-29|07:32:44.887] Committed state module=state height=48 txs=2 appHash=FC8C010000000000 I[2019-08-29|07:32:44.908] Executed block module=state height=49 validTxs=8 invalidTxs=0 I[2019-08-29|07:32:44.909] Committed state module=state height=49 txs=8 appHash=8C8D010000000000 I[2019-08-29|07:32:45.886] Executed block module=state height=50 validTxs=2 invalidTxs=0 I[2019-08-29|07:32:45.895] Committed state module=state height=50 txs=2 appHash=908D010000000000 I[2019-08-29|07:32:45.908] Executed block module=state height=51 validTxs=8 invalidTxs=0 I[2019-08-29|07:32:45.909] Committed state module=state height=51 txs=8 appHash=A08D010000000000 ``` This commit fixes that by adding a check to handleTxsAvailable. Fixes #3908 * update changelog * schedule timeoutCommit if StartTime is in the future or SkipTimeoutCommit=true && we DON'T have all the votes * fix TestReactorCreatesBlockWhenEmptyBlocksFalse by checking if we have LastCommit or not * address Ethan's comments
5 years ago
cs: reset triggered timeout precommit (#3310) * Reset TriggeredTimeoutPrecommit as part of updateToState * Add failing test and fix * fix DATA RACE in TestResetTimeoutPrecommitUponNewHeight ``` WARNING: DATA RACE Read at 0x00c001691d28 by goroutine 691: github.com/tendermint/tendermint/consensus.decideProposal() /go/src/github.com/tendermint/tendermint/consensus/common_test.go:133 +0x121 github.com/tendermint/tendermint/consensus.TestResetTimeoutPrecommitUponNewHeight() /go/src/github.com/tendermint/tendermint/consensus/state_test.go:1389 +0x958 testing.tRunner() /usr/local/go/src/testing/testing.go:827 +0x162 Previous write at 0x00c001691d28 by goroutine 931: github.com/tendermint/tendermint/consensus.(*ConsensusState).updateToState() /go/src/github.com/tendermint/tendermint/consensus/state.go:562 +0x5b2 github.com/tendermint/tendermint/consensus.(*ConsensusState).finalizeCommit() /go/src/github.com/tendermint/tendermint/consensus/state.go:1340 +0x141e github.com/tendermint/tendermint/consensus.(*ConsensusState).tryFinalizeCommit() /go/src/github.com/tendermint/tendermint/consensus/state.go:1255 +0x66e github.com/tendermint/tendermint/consensus.(*ConsensusState).enterCommit.func1() /go/src/github.com/tendermint/tendermint/consensus/state.go:1201 +0x135 github.com/tendermint/tendermint/consensus.(*ConsensusState).enterCommit() /go/src/github.com/tendermint/tendermint/consensus/state.go:1232 +0x94b github.com/tendermint/tendermint/consensus.(*ConsensusState).addVote() /go/src/github.com/tendermint/tendermint/consensus/state.go:1657 +0x132e github.com/tendermint/tendermint/consensus.(*ConsensusState).tryAddVote() /go/src/github.com/tendermint/tendermint/consensus/state.go:1503 +0x8f github.com/tendermint/tendermint/consensus.(*ConsensusState).handleMsg() /go/src/github.com/tendermint/tendermint/consensus/state.go:694 +0xa1e github.com/tendermint/tendermint/consensus.(*ConsensusState).receiveRoutine() /go/src/github.com/tendermint/tendermint/consensus/state.go:642 +0x948 github.com/tendermint/tendermint/consensus.(*ConsensusState).receiveRoutine() /go/src/github.com/tendermint/tendermint/consensus/state.go:642 +0x948 github.com/tendermint/tendermint/consensus.(*ConsensusState).receiveRoutine() /go/src/github.com/tendermint/tendermint/consensus/state.go:642 +0x948 github.com/tendermint/tendermint/consensus.(*ConsensusState).receiveRoutine() /go/src/github.com/tendermint/tendermint/consensus/state.go:655 +0x7dd github.com/tendermint/tendermint/consensus.(*ConsensusState).receiveRoutine() /go/src/github.com/tendermint/tendermint/consensus/state.go:642 +0x948 github.com/tendermint/tendermint/consensus.(*ConsensusState).receiveRoutine() /go/src/github.com/tendermint/tendermint/consensus/state.go:655 +0x7dd Goroutine 691 (running) created at: testing.(*T).Run() /usr/local/go/src/testing/testing.go:878 +0x659 testing.runTests.func1() /usr/local/go/src/testing/testing.go:1119 +0xa8 testing.tRunner() /usr/local/go/src/testing/testing.go:827 +0x162 testing.runTests() testing.(*M).Run() /usr/local/go/src/testing/testing.go:1034 +0x2ee main.main() _testmain.go:216 +0x332 ``` * fix another DATA RACE by locking consensus ``` WARNING: DATA RACE Read at 0x00c009b835a8 by goroutine 871: github.com/tendermint/tendermint/consensus.(*ConsensusState).createProposalBlock() /go/src/github.com/tendermint/tendermint/consensus/state.go:955 +0x7c github.com/tendermint/tendermint/consensus.decideProposal() /go/src/github.com/tendermint/tendermint/consensus/common_test.go:127 +0x53 github.com/tendermint/tendermint/consensus.TestResetTimeoutPrecommitUponNewHeight() /go/src/github.com/tendermint/tendermint/consensus/state_test.go:1389 +0x958 testing.tRunner() /usr/local/go/src/testing/testing.go:827 +0x162 Previous write at 0x00c009b835a8 by goroutine 931: github.com/tendermint/tendermint/consensus.(*ConsensusState).updateHeight() /go/src/github.com/tendermint/tendermint/consensus/state.go:446 +0xb7 github.com/tendermint/tendermint/consensus.(*ConsensusState).updateToState() /go/src/github.com/tendermint/tendermint/consensus/state.go:542 +0x22f github.com/tendermint/tendermint/consensus.(*ConsensusState).finalizeCommit() /go/src/github.com/tendermint/tendermint/consensus/state.go:1340 +0x141e github.com/tendermint/tendermint/consensus.(*ConsensusState).tryFinalizeCommit() /go/src/github.com/tendermint/tendermint/consensus/state.go:1255 +0x66e github.com/tendermint/tendermint/consensus.(*ConsensusState).enterCommit.func1() /go/src/github.com/tendermint/tendermint/consensus/state.go:1201 +0x135 github.com/tendermint/tendermint/consensus.(*ConsensusState).enterCommit() /go/src/github.com/tendermint/tendermint/consensus/state.go:1232 +0x94b github.com/tendermint/tendermint/consensus.(*ConsensusState).addVote() /go/src/github.com/tendermint/tendermint/consensus/state.go:1657 +0x132e github.com/tendermint/tendermint/consensus.(*ConsensusState).tryAddVote() /go/src/github.com/tendermint/tendermint/consensus/state.go:1503 +0x8f github.com/tendermint/tendermint/consensus.(*ConsensusState).handleMsg() /go/src/github.com/tendermint/tendermint/consensus/state.go:694 +0xa1e github.com/tendermint/tendermint/consensus.(*ConsensusState).receiveRoutine() /go/src/github.com/tendermint/tendermint/consensus/state.go:642 +0x948 github.com/tendermint/tendermint/consensus.(*ConsensusState).receiveRoutine() /go/src/github.com/tendermint/tendermint/consensus/state.go:642 +0x948 github.com/tendermint/tendermint/consensus.(*ConsensusState).receiveRoutine() /go/src/github.com/tendermint/tendermint/consensus/state.go:642 +0x948 github.com/tendermint/tendermint/consensus.(*ConsensusState).receiveRoutine() /go/src/github.com/tendermint/tendermint/consensus/state.go:655 +0x7dd github.com/tendermint/tendermint/consensus.(*ConsensusState).receiveRoutine() /go/src/github.com/tendermint/tendermint/consensus/state.go:642 +0x948 github.com/tendermint/tendermint/consensus.(*ConsensusState).receiveRoutine() /go/src/github.com/tendermint/tendermint/consensus/state.go:655 +0x7dd ``` * Fix failing test * Delete profile.out * fix data races
5 years ago
lint: Enable Golint (#4212) * Fix many golint errors * Fix golint errors in the 'lite' package * Don't export Pool.store * Fix typo * Revert unwanted changes * Fix errors in counter package * Fix linter errors in kvstore package * Fix linter error in example package * Fix error in tests package * Fix linter errors in v2 package * Fix linter errors in consensus package * Fix linter errors in evidence package * Fix linter error in fail package * Fix linter errors in query package * Fix linter errors in core package * Fix linter errors in node package * Fix linter errors in mempool package * Fix linter error in conn package * Fix linter errors in pex package * Rename PEXReactor export to Reactor * Fix linter errors in trust package * Fix linter errors in upnp package * Fix linter errors in p2p package * Fix linter errors in proxy package * Fix linter errors in mock_test package * Fix linter error in client_test package * Fix linter errors in coretypes package * Fix linter errors in coregrpc package * Fix linter errors in rpcserver package * Fix linter errors in rpctypes package * Fix linter errors in rpctest package * Fix linter error in json2wal script * Fix linter error in wal2json script * Fix linter errors in kv package * Fix linter error in state package * Fix linter error in grpc_client * Fix linter errors in types package * Fix linter error in version package * Fix remaining errors * Address review comments * Fix broken tests * Reconcile package coregrpc * Fix golangci bot error * Fix new golint errors * Fix broken reference * Enable golint linter * minor changes to bring golint into line * fix failing test * fix pex reactor naming * address PR comments
5 years ago
new pubsub package comment out failing consensus tests for now rewrite rpc httpclient to use new pubsub package import pubsub as tmpubsub, query as tmquery make event IDs constants EventKey -> EventTypeKey rename EventsPubsub to PubSub mempool does not use pubsub rename eventsSub to pubsub new subscribe API fix channel size issues and consensus tests bugs refactor rpc client add missing discardFromChan method add mutex rename pubsub to eventBus remove IsRunning from WSRPCConnection interface (not needed) add a comment in broadcastNewRoundStepsAndVotes rename registerEventCallbacks to broadcastNewRoundStepsAndVotes See https://dave.cheney.net/2014/03/19/channel-axioms stop eventBuses after reactor tests remove unnecessary Unsubscribe return subscribe helper function move discardFromChan to where it is used subscribe now returns an err this gives us ability to refuse to subscribe if pubsub is at its max capacity. use context for control overflow cache queries handle err when subscribing in replay_test rename testClientID to testSubscriber extract var set channel buffer capacity to 1 in replay_file fix byzantine_test unsubscribe from single event, not all events refactor httpclient to return events to appropriate channels return failing testReplayCrashBeforeWriteVote test fix TestValidatorSetChanges refactor code a bit fix testReplayCrashBeforeWriteVote add comment fix TestValidatorSetChanges fixes from Bucky's review update comment [ci skip] test TxEventBuffer update changelog fix TestValidatorSetChanges (2nd attempt) only do wg.Done when no errors benchmark event bus create pubsub server inside NewEventBus only expose config params (later if needed) set buffer capacity to 0 so we are not testing cache new tx event format: key = "Tx" plus a tag {"tx.hash": XYZ} This should allow to subscribe to all transactions! or a specific one using a query: "tm.events.type = Tx and tx.hash = '013ABF99434...'" use TimeoutCommit instead of afterPublishEventNewBlockTimeout TimeoutCommit is the time a node waits after committing a block, before it goes into the next height. So it will finish everything from the last block, but then wait a bit. The idea is this gives it time to hear more votes from other validators, to strengthen the commit it includes in the next block. But it also gives it time to hear about new transactions. waitForBlockWithUpdatedVals rewrite WAL crash tests Task: test that we can recover from any WAL crash. Solution: the old tests were relying on event hub being run in the same thread (we were injecting the private validator's last signature). when considering a rewrite, we considered two possible solutions: write a "fuzzy" testing system where WAL is crashing upon receiving a new message, or inject failures and trigger them in tests using something like https://github.com/coreos/gofail. remove sleep no cs.Lock around wal.Save test different cases (empty block, non-empty block, ...) comments add comments test 4 cases: empty block, non-empty block, non-empty block with smaller part size, many blocks fixes as per Bucky's last review reset subscriptions on UnsubscribeAll use a simple counter to track message for which we panicked also, set a smaller part size for all test cases
7 years ago
lint: Enable Golint (#4212) * Fix many golint errors * Fix golint errors in the 'lite' package * Don't export Pool.store * Fix typo * Revert unwanted changes * Fix errors in counter package * Fix linter errors in kvstore package * Fix linter error in example package * Fix error in tests package * Fix linter errors in v2 package * Fix linter errors in consensus package * Fix linter errors in evidence package * Fix linter error in fail package * Fix linter errors in query package * Fix linter errors in core package * Fix linter errors in node package * Fix linter errors in mempool package * Fix linter error in conn package * Fix linter errors in pex package * Rename PEXReactor export to Reactor * Fix linter errors in trust package * Fix linter errors in upnp package * Fix linter errors in p2p package * Fix linter errors in proxy package * Fix linter errors in mock_test package * Fix linter error in client_test package * Fix linter errors in coretypes package * Fix linter errors in coregrpc package * Fix linter errors in rpcserver package * Fix linter errors in rpctypes package * Fix linter errors in rpctest package * Fix linter error in json2wal script * Fix linter error in wal2json script * Fix linter errors in kv package * Fix linter error in state package * Fix linter error in grpc_client * Fix linter errors in types package * Fix linter error in version package * Fix remaining errors * Address review comments * Fix broken tests * Reconcile package coregrpc * Fix golangci bot error * Fix new golint errors * Fix broken reference * Enable golint linter * minor changes to bring golint into line * fix failing test * fix pex reactor naming * address PR comments
5 years ago
lint: Enable Golint (#4212) * Fix many golint errors * Fix golint errors in the 'lite' package * Don't export Pool.store * Fix typo * Revert unwanted changes * Fix errors in counter package * Fix linter errors in kvstore package * Fix linter error in example package * Fix error in tests package * Fix linter errors in v2 package * Fix linter errors in consensus package * Fix linter errors in evidence package * Fix linter error in fail package * Fix linter errors in query package * Fix linter errors in core package * Fix linter errors in node package * Fix linter errors in mempool package * Fix linter error in conn package * Fix linter errors in pex package * Rename PEXReactor export to Reactor * Fix linter errors in trust package * Fix linter errors in upnp package * Fix linter errors in p2p package * Fix linter errors in proxy package * Fix linter errors in mock_test package * Fix linter error in client_test package * Fix linter errors in coretypes package * Fix linter errors in coregrpc package * Fix linter errors in rpcserver package * Fix linter errors in rpctypes package * Fix linter errors in rpctest package * Fix linter error in json2wal script * Fix linter error in wal2json script * Fix linter errors in kv package * Fix linter error in state package * Fix linter error in grpc_client * Fix linter errors in types package * Fix linter error in version package * Fix remaining errors * Address review comments * Fix broken tests * Reconcile package coregrpc * Fix golangci bot error * Fix new golint errors * Fix broken reference * Enable golint linter * minor changes to bring golint into line * fix failing test * fix pex reactor naming * address PR comments
5 years ago
WAL: better errors and new fail point (#3246) * privval: more info in errors * wal: change Debug logs to Info * wal: log and return error on corrupted wal instead of panicing * fail: Exit right away instead of sending interupt * consensus: FAIL before handling our own vote allows to replicate #3089: - run using `FAIL_TEST_INDEX=0` - delete some bytes from the end of the WAL - start normally Results in logs like: ``` I[2019-02-03|18:12:58.225] Searching for height module=consensus wal=/Users/ethanbuchman/.tendermint/data/cs.wal/wal height=1 min=0 max=0 E[2019-02-03|18:12:58.225] Error on catchup replay. Proceeding to start ConsensusState anyway module=consensus err="failed to read data: EOF" I[2019-02-03|18:12:58.225] Started node module=main nodeInfo="{ProtocolVersion:{P2P:6 Block:9 App:1} ID_:35e87e93f2e31f305b65a5517fd2102331b56002 ListenAddr:tcp://0.0.0.0:26656 Network:test-chain-J8JvJH Version:0.29.1 Channels:4020212223303800 Moniker:Ethans-MacBook-Pro.local Other:{TxIndex:on RPCAddress:tcp://0.0.0.0:26657}}" E[2019-02-03|18:12:58.226] Couldn't connect to any seeds module=p2p I[2019-02-03|18:12:59.229] Timed out module=consensus dur=998.568ms height=1 round=0 step=RoundStepNewHeight I[2019-02-03|18:12:59.230] enterNewRound(1/0). Current: 1/0/RoundStepNewHeight module=consensus height=1 round=0 I[2019-02-03|18:12:59.230] enterPropose(1/0). Current: 1/0/RoundStepNewRound module=consensus height=1 round=0 I[2019-02-03|18:12:59.230] enterPropose: Our turn to propose module=consensus height=1 round=0 proposer=AD278B7767B05D7FBEB76207024C650988FA77D5 privValidator="PrivValidator{AD278B7767B05D7FBEB76207024C650988FA77D5 LH:1, LR:0, LS:2}" E[2019-02-03|18:12:59.230] enterPropose: Error signing proposal module=consensus height=1 round=0 err="Error signing proposal: Step regression at height 1 round 0. Got 1, last step 2" I[2019-02-03|18:13:02.233] Timed out module=consensus dur=3s height=1 round=0 step=RoundStepPropose I[2019-02-03|18:13:02.233] enterPrevote(1/0). Current: 1/0/RoundStepPropose module=consensus I[2019-02-03|18:13:02.233] enterPrevote: ProposalBlock is nil module=consensus height=1 round=0 E[2019-02-03|18:13:02.234] Error signing vote module=consensus height=1 round=0 vote="Vote{0:AD278B7767B0 1/00/1(Prevote) 000000000000 000000000000 @ 2019-02-04T02:13:02.233897Z}" err="Error signing vote: Conflicting data" ``` Notice the EOF, the step regression, and the conflicting data. * wal: change errors to be DataCorruptionError * exit on corrupt WAL * fix log * fix new line
5 years ago
cs: check for SkipTimeoutCommit or wait timeout in handleTxsAvailable (#3928) * cs: check for SkipTimeoutCommit or wait timeout in handleTxsAvailable Previously, if create_empty_blocks was set to false, TM sometimes could create 2 consecutive blocks without actually waiting for timeoutCommit (1 sec. by default). ``` I[2019-08-29|07:32:43.874] Executed block module=state height=47 validTxs=10 invalidTxs=0 I[2019-08-29|07:32:43.876] Committed state module=state height=47 txs=10 appHash=F88C010000000000 I[2019-08-29|07:32:44.885] Executed block module=state height=48 validTxs=2 invalidTxs=0 I[2019-08-29|07:32:44.887] Committed state module=state height=48 txs=2 appHash=FC8C010000000000 I[2019-08-29|07:32:44.908] Executed block module=state height=49 validTxs=8 invalidTxs=0 I[2019-08-29|07:32:44.909] Committed state module=state height=49 txs=8 appHash=8C8D010000000000 I[2019-08-29|07:32:45.886] Executed block module=state height=50 validTxs=2 invalidTxs=0 I[2019-08-29|07:32:45.895] Committed state module=state height=50 txs=2 appHash=908D010000000000 I[2019-08-29|07:32:45.908] Executed block module=state height=51 validTxs=8 invalidTxs=0 I[2019-08-29|07:32:45.909] Committed state module=state height=51 txs=8 appHash=A08D010000000000 ``` This commit fixes that by adding a check to handleTxsAvailable. Fixes #3908 * update changelog * schedule timeoutCommit if StartTime is in the future or SkipTimeoutCommit=true && we DON'T have all the votes * fix TestReactorCreatesBlockWhenEmptyBlocksFalse by checking if we have LastCommit or not * address Ethan's comments
5 years ago
cs: check for SkipTimeoutCommit or wait timeout in handleTxsAvailable (#3928) * cs: check for SkipTimeoutCommit or wait timeout in handleTxsAvailable Previously, if create_empty_blocks was set to false, TM sometimes could create 2 consecutive blocks without actually waiting for timeoutCommit (1 sec. by default). ``` I[2019-08-29|07:32:43.874] Executed block module=state height=47 validTxs=10 invalidTxs=0 I[2019-08-29|07:32:43.876] Committed state module=state height=47 txs=10 appHash=F88C010000000000 I[2019-08-29|07:32:44.885] Executed block module=state height=48 validTxs=2 invalidTxs=0 I[2019-08-29|07:32:44.887] Committed state module=state height=48 txs=2 appHash=FC8C010000000000 I[2019-08-29|07:32:44.908] Executed block module=state height=49 validTxs=8 invalidTxs=0 I[2019-08-29|07:32:44.909] Committed state module=state height=49 txs=8 appHash=8C8D010000000000 I[2019-08-29|07:32:45.886] Executed block module=state height=50 validTxs=2 invalidTxs=0 I[2019-08-29|07:32:45.895] Committed state module=state height=50 txs=2 appHash=908D010000000000 I[2019-08-29|07:32:45.908] Executed block module=state height=51 validTxs=8 invalidTxs=0 I[2019-08-29|07:32:45.909] Committed state module=state height=51 txs=8 appHash=A08D010000000000 ``` This commit fixes that by adding a check to handleTxsAvailable. Fixes #3908 * update changelog * schedule timeoutCommit if StartTime is in the future or SkipTimeoutCommit=true && we DON'T have all the votes * fix TestReactorCreatesBlockWhenEmptyBlocksFalse by checking if we have LastCommit or not * address Ethan's comments
5 years ago
cs: check for SkipTimeoutCommit or wait timeout in handleTxsAvailable (#3928) * cs: check for SkipTimeoutCommit or wait timeout in handleTxsAvailable Previously, if create_empty_blocks was set to false, TM sometimes could create 2 consecutive blocks without actually waiting for timeoutCommit (1 sec. by default). ``` I[2019-08-29|07:32:43.874] Executed block module=state height=47 validTxs=10 invalidTxs=0 I[2019-08-29|07:32:43.876] Committed state module=state height=47 txs=10 appHash=F88C010000000000 I[2019-08-29|07:32:44.885] Executed block module=state height=48 validTxs=2 invalidTxs=0 I[2019-08-29|07:32:44.887] Committed state module=state height=48 txs=2 appHash=FC8C010000000000 I[2019-08-29|07:32:44.908] Executed block module=state height=49 validTxs=8 invalidTxs=0 I[2019-08-29|07:32:44.909] Committed state module=state height=49 txs=8 appHash=8C8D010000000000 I[2019-08-29|07:32:45.886] Executed block module=state height=50 validTxs=2 invalidTxs=0 I[2019-08-29|07:32:45.895] Committed state module=state height=50 txs=2 appHash=908D010000000000 I[2019-08-29|07:32:45.908] Executed block module=state height=51 validTxs=8 invalidTxs=0 I[2019-08-29|07:32:45.909] Committed state module=state height=51 txs=8 appHash=A08D010000000000 ``` This commit fixes that by adding a check to handleTxsAvailable. Fixes #3908 * update changelog * schedule timeoutCommit if StartTime is in the future or SkipTimeoutCommit=true && we DON'T have all the votes * fix TestReactorCreatesBlockWhenEmptyBlocksFalse by checking if we have LastCommit or not * address Ethan's comments
5 years ago
10 years ago
10 years ago
9 years ago
9 years ago
7 years ago
7 years ago
lint: Enable Golint (#4212) * Fix many golint errors * Fix golint errors in the 'lite' package * Don't export Pool.store * Fix typo * Revert unwanted changes * Fix errors in counter package * Fix linter errors in kvstore package * Fix linter error in example package * Fix error in tests package * Fix linter errors in v2 package * Fix linter errors in consensus package * Fix linter errors in evidence package * Fix linter error in fail package * Fix linter errors in query package * Fix linter errors in core package * Fix linter errors in node package * Fix linter errors in mempool package * Fix linter error in conn package * Fix linter errors in pex package * Rename PEXReactor export to Reactor * Fix linter errors in trust package * Fix linter errors in upnp package * Fix linter errors in p2p package * Fix linter errors in proxy package * Fix linter errors in mock_test package * Fix linter error in client_test package * Fix linter errors in coretypes package * Fix linter errors in coregrpc package * Fix linter errors in rpcserver package * Fix linter errors in rpctypes package * Fix linter errors in rpctest package * Fix linter error in json2wal script * Fix linter error in wal2json script * Fix linter errors in kv package * Fix linter error in state package * Fix linter error in grpc_client * Fix linter errors in types package * Fix linter error in version package * Fix remaining errors * Address review comments * Fix broken tests * Reconcile package coregrpc * Fix golangci bot error * Fix new golint errors * Fix broken reference * Enable golint linter * minor changes to bring golint into line * fix failing test * fix pex reactor naming * address PR comments
5 years ago
add support for block pruning via ABCI Commit response (#4588) * Added BlockStore.DeleteBlock() * Added initial block pruner prototype * wip * Added BlockStore.PruneBlocks() * Added consensus setting for block pruning * Added BlockStore base * Error on replay if base does not have blocks * Handle missing blocks when sending VoteSetMaj23Message * Error message tweak * Properly update blockstore state * Error message fix again * blockchain: ignore peer missing blocks * Added FIXME * Added test for block replay with truncated history * Handle peer base in blockchain reactor * Improved replay error handling * Added tests for Store.PruneBlocks() * Fix non-RPC handling of truncated block history * Panic on missing block meta in needProofBlock() * Updated changelog * Handle truncated block history in RPC layer * Added info about earliest block in /status RPC * Reorder height and base in blockchain reactor messages * Updated changelog * Fix tests * Appease linter * Minor review fixes * Non-empty BlockStores should always have base > 0 * Update code to assume base > 0 invariant * Added blockstore tests for pruning to 0 * Make sure we don't prune below the current base * Added BlockStore.Size() * config: added retain_blocks recommendations * Update v1 blockchain reactor to handle blockstore base * Added state database pruning * Propagate errors on missing validator sets * Comment tweaks * Improved error message Co-Authored-By: Anton Kaliaev <anton.kalyaev@gmail.com> * use ABCI field ResponseCommit.retain_height instead of retain-blocks config option * remove State.RetainHeight, return value instead * fix minor issues * rename pruneHeights() to pruneBlocks() * noop to fix GitHub borkage Co-authored-by: Anton Kaliaev <anton.kalyaev@gmail.com>
4 years ago
10 years ago
lint: Enable Golint (#4212) * Fix many golint errors * Fix golint errors in the 'lite' package * Don't export Pool.store * Fix typo * Revert unwanted changes * Fix errors in counter package * Fix linter errors in kvstore package * Fix linter error in example package * Fix error in tests package * Fix linter errors in v2 package * Fix linter errors in consensus package * Fix linter errors in evidence package * Fix linter error in fail package * Fix linter errors in query package * Fix linter errors in core package * Fix linter errors in node package * Fix linter errors in mempool package * Fix linter error in conn package * Fix linter errors in pex package * Rename PEXReactor export to Reactor * Fix linter errors in trust package * Fix linter errors in upnp package * Fix linter errors in p2p package * Fix linter errors in proxy package * Fix linter errors in mock_test package * Fix linter error in client_test package * Fix linter errors in coretypes package * Fix linter errors in coregrpc package * Fix linter errors in rpcserver package * Fix linter errors in rpctypes package * Fix linter errors in rpctest package * Fix linter error in json2wal script * Fix linter error in wal2json script * Fix linter errors in kv package * Fix linter error in state package * Fix linter error in grpc_client * Fix linter errors in types package * Fix linter error in version package * Fix remaining errors * Address review comments * Fix broken tests * Reconcile package coregrpc * Fix golangci bot error * Fix new golint errors * Fix broken reference * Enable golint linter * minor changes to bring golint into line * fix failing test * fix pex reactor naming * address PR comments
5 years ago
10 years ago
cs: sync WAL more frequently (#3300) As per #3043, this adds a ticker to sync the WAL every 2s while the WAL is running. * Flush WAL every 2s This adds a ticker that flushes the WAL every 2s while the WAL is running. This is related to #3043. * Fix spelling * Increase timeout to 2mins for slower build environments * Make WAL sync interval configurable * Add TODO to replace testChan with more comprehensive testBus * Remove extraneous debug statement * Remove testChan in favour of using system time As per https://github.com/tendermint/tendermint/pull/3300#discussion_r255886586, this removes the `testChan` WAL member and replaces the approach with a system time-oriented one. In this new approach, we keep track of the system time at which each flush and periodic flush successfully occurred. The naming of the various functions is also updated here to be more consistent with "flushing" as opposed to "sync'ing". * Update naming convention and ensure lock for timestamp update * Add Flush method as part of WAL interface Adds a `Flush` method as part of the WAL interface to enforce the idea that we can manually trigger a WAL flush from outside of the WAL. This is employed in the consensus state management to flush the WAL prior to signing votes/proposals, as per https://github.com/tendermint/tendermint/issues/3043#issuecomment-453853630 * Update CHANGELOG_PENDING * Remove mutex approach and replace with DI The dependency injection approach to dealing with testing concerns could allow similar effects to some kind of "testing bus"-based approach. This commit introduces an example of this, where instead of relying on (potentially fragile) timing of things between the code and the test, we inject code into the function under test that can signal the test through a channel. This allows us to avoid the `time.Sleep()`-based approach previously employed. * Update comment on WAL flushing during vote signing Co-Authored-By: thanethomson <connect@thanethomson.com> * Simplify flush interval definition Co-Authored-By: thanethomson <connect@thanethomson.com> * Expand commentary on WAL disk flushing Co-Authored-By: thanethomson <connect@thanethomson.com> * Add broken test to illustrate WAL sync test problem Removes test-related state (dependency injection code) from the WAL data structure and adds test code to illustrate the problem with using `WALGenerateNBlocks` and `wal.SearchForEndHeight` to test periodic sync'ing. * Fix test error messages * Use WAL group buffer size to check for flush A function is added to `libs/autofile/group.go#Group` in order to return the size of the buffered data (i.e. data that has not yet been flushed to disk). The test now checks that, prior to a `time.Sleep`, the group buffer has data in it. After the `time.Sleep` (during which time the periodic flush should have been called), the buffer should be empty. * Remove config root dir removal from #3291 * Add godoc for NewWAL mentioning periodic sync
5 years ago
10 years ago
lint: Enable Golint (#4212) * Fix many golint errors * Fix golint errors in the 'lite' package * Don't export Pool.store * Fix typo * Revert unwanted changes * Fix errors in counter package * Fix linter errors in kvstore package * Fix linter error in example package * Fix error in tests package * Fix linter errors in v2 package * Fix linter errors in consensus package * Fix linter errors in evidence package * Fix linter error in fail package * Fix linter errors in query package * Fix linter errors in core package * Fix linter errors in node package * Fix linter errors in mempool package * Fix linter error in conn package * Fix linter errors in pex package * Rename PEXReactor export to Reactor * Fix linter errors in trust package * Fix linter errors in upnp package * Fix linter errors in p2p package * Fix linter errors in proxy package * Fix linter errors in mock_test package * Fix linter error in client_test package * Fix linter errors in coretypes package * Fix linter errors in coregrpc package * Fix linter errors in rpcserver package * Fix linter errors in rpctypes package * Fix linter errors in rpctest package * Fix linter error in json2wal script * Fix linter error in wal2json script * Fix linter errors in kv package * Fix linter error in state package * Fix linter error in grpc_client * Fix linter errors in types package * Fix linter error in version package * Fix remaining errors * Address review comments * Fix broken tests * Reconcile package coregrpc * Fix golangci bot error * Fix new golint errors * Fix broken reference * Enable golint linter * minor changes to bring golint into line * fix failing test * fix pex reactor naming * address PR comments
5 years ago
9 years ago
10 years ago
10 years ago
10 years ago
10 years ago
10 years ago
10 years ago
10 years ago
10 years ago
10 years ago
10 years ago
10 years ago
10 years ago
10 years ago
10 years ago
10 years ago
10 years ago
10 years ago
10 years ago
consensus: additional timing metrics (#7849) This change introduces an additional set of metrics aimed at helping operators understand the timing for consensus. This change adds the following metrics: ``` # HELP tendermint_consensus_round_duration Time spent in a round # TYPE tendermint_consensus_round_duration histogram tendermint_consensus_round_duration_bucket{chain_id="test-chain-IrF74Y",le="0.1"} 29 tendermint_consensus_round_duration_bucket{chain_id="test-chain-IrF74Y",le="0.2682695795279726"} 29 tendermint_consensus_round_duration_bucket{chain_id="test-chain-IrF74Y",le="0.7196856730011522"} 29 tendermint_consensus_round_duration_bucket{chain_id="test-chain-IrF74Y",le="1.9306977288832508"} 29 tendermint_consensus_round_duration_bucket{chain_id="test-chain-IrF74Y",le="5.1794746792312125"} 29 tendermint_consensus_round_duration_bucket{chain_id="test-chain-IrF74Y",le="13.894954943731381"} 29 tendermint_consensus_round_duration_bucket{chain_id="test-chain-IrF74Y",le="37.27593720314942"} 29 tendermint_consensus_round_duration_bucket{chain_id="test-chain-IrF74Y",le="100.00000000000006"} 29 tendermint_consensus_round_duration_bucket{chain_id="test-chain-IrF74Y",le="+Inf"} 29 tendermint_consensus_round_duration_sum{chain_id="test-chain-IrF74Y"} 0.028651869999999996 tendermint_consensus_round_duration_count{chain_id="test-chain-IrF74Y"} 29 ``` ``` # HELP tendermint_consensus_step_duration Time spent per step. # TYPE tendermint_consensus_step_duration histogram tendermint_consensus_step_duration_bucket{chain_id="test-chain-IrF74Y",step="Commit",le="0.1"} 29 tendermint_consensus_step_duration_bucket{chain_id="test-chain-IrF74Y",step="Commit",le="0.2682695795279726"} 29 tendermint_consensus_step_duration_bucket{chain_id="test-chain-IrF74Y",step="Commit",le="0.7196856730011522"} 29 tendermint_consensus_step_duration_bucket{chain_id="test-chain-IrF74Y",step="Commit",le="1.9306977288832508"} 29 tendermint_consensus_step_duration_bucket{chain_id="test-chain-IrF74Y",step="Commit",le="5.1794746792312125"} 29 tendermint_consensus_step_duration_bucket{chain_id="test-chain-IrF74Y",step="Commit",le="13.894954943731381"} 29 tendermint_consensus_step_duration_bucket{chain_id="test-chain-IrF74Y",step="Commit",le="37.27593720314942"} 29 tendermint_consensus_step_duration_bucket{chain_id="test-chain-IrF74Y",step="Commit",le="100.00000000000006"} 29 tendermint_consensus_step_duration_bucket{chain_id="test-chain-IrF74Y",step="Commit",le="+Inf"} 29 tendermint_consensus_step_duration_sum{chain_id="test-chain-IrF74Y",step="Commit"} 0.26650875 tendermint_consensus_step_duration_count{chain_id="test-chain-IrF74Y",step="Commit"} 29 tendermint_consensus_step_duration_bucket{chain_id="test-chain-IrF74Y",step="NewHeight",le="0.1"} 0 tendermint_consensus_step_duration_bucket{chain_id="test-chain-IrF74Y",step="NewHeight",le="0.2682695795279726"} 0 tendermint_consensus_step_duration_bucket{chain_id="test-chain-IrF74Y",step="NewHeight",le="0.7196856730011522"} 0 tendermint_consensus_step_duration_bucket{chain_id="test-chain-IrF74Y",step="NewHeight",le="1.9306977288832508"} 28 tendermint_consensus_step_duration_bucket{chain_id="test-chain-IrF74Y",step="NewHeight",le="5.1794746792312125"} 28 tendermint_consensus_step_duration_bucket{chain_id="test-chain-IrF74Y",step="NewHeight",le="13.894954943731381"} 28 tendermint_consensus_step_duration_bucket{chain_id="test-chain-IrF74Y",step="NewHeight",le="37.27593720314942"} 28 tendermint_consensus_step_duration_bucket{chain_id="test-chain-IrF74Y",step="NewHeight",le="100.00000000000006"} 28 tendermint_consensus_step_duration_bucket{chain_id="test-chain-IrF74Y",step="NewHeight",le="+Inf"} 28 tendermint_consensus_step_duration_sum{chain_id="test-chain-IrF74Y",step="NewHeight"} 27.773921702 tendermint_consensus_step_duration_count{chain_id="test-chain-IrF74Y",step="NewHeight"} 28 tendermint_consensus_step_duration_bucket{chain_id="test-chain-IrF74Y",step="NewRound",le="0.1"} 29 tendermint_consensus_step_duration_bucket{chain_id="test-chain-IrF74Y",step="NewRound",le="0.2682695795279726"} 29 tendermint_consensus_step_duration_bucket{chain_id="test-chain-IrF74Y",step="NewRound",le="0.7196856730011522"} 29 tendermint_consensus_step_duration_bucket{chain_id="test-chain-IrF74Y",step="NewRound",le="1.9306977288832508"} 29 tendermint_consensus_step_duration_bucket{chain_id="test-chain-IrF74Y",step="NewRound",le="5.1794746792312125"} 29 tendermint_consensus_step_duration_bucket{chain_id="test-chain-IrF74Y",step="NewRound",le="13.894954943731381"} 29 tendermint_consensus_step_duration_bucket{chain_id="test-chain-IrF74Y",step="NewRound",le="37.27593720314942"} 29 tendermint_consensus_step_duration_bucket{chain_id="test-chain-IrF74Y",step="NewRound",le="100.00000000000006"} 29 tendermint_consensus_step_duration_bucket{chain_id="test-chain-IrF74Y",step="NewRound",le="+Inf"} 29 tendermint_consensus_step_duration_sum{chain_id="test-chain-IrF74Y",step="NewRound"} 0.168961052 tendermint_consensus_step_duration_count{chain_id="test-chain-IrF74Y",step="NewRound"} 29 tendermint_consensus_step_duration_bucket{chain_id="test-chain-IrF74Y",step="Precommit",le="0.1"} 29 tendermint_consensus_step_duration_bucket{chain_id="test-chain-IrF74Y",step="Precommit",le="0.2682695795279726"} 29 tendermint_consensus_step_duration_bucket{chain_id="test-chain-IrF74Y",step="Precommit",le="0.7196856730011522"} 29 tendermint_consensus_step_duration_bucket{chain_id="test-chain-IrF74Y",step="Precommit",le="1.9306977288832508"} 29 tendermint_consensus_step_duration_bucket{chain_id="test-chain-IrF74Y",step="Precommit",le="5.1794746792312125"} 29 tendermint_consensus_step_duration_bucket{chain_id="test-chain-IrF74Y",step="Precommit",le="13.894954943731381"} 29 tendermint_consensus_step_duration_bucket{chain_id="test-chain-IrF74Y",step="Precommit",le="37.27593720314942"} 29 tendermint_consensus_step_duration_bucket{chain_id="test-chain-IrF74Y",step="Precommit",le="100.00000000000006"} 29 tendermint_consensus_step_duration_bucket{chain_id="test-chain-IrF74Y",step="Precommit",le="+Inf"} 29 tendermint_consensus_step_duration_sum{chain_id="test-chain-IrF74Y",step="Precommit"} 0.06414115999999999 tendermint_consensus_step_duration_count{chain_id="test-chain-IrF74Y",step="Precommit"} 29 tendermint_consensus_step_duration_bucket{chain_id="test-chain-IrF74Y",step="Prevote",le="0.1"} 29 tendermint_consensus_step_duration_bucket{chain_id="test-chain-IrF74Y",step="Prevote",le="0.2682695795279726"} 29 tendermint_consensus_step_duration_bucket{chain_id="test-chain-IrF74Y",step="Prevote",le="0.7196856730011522"} 29 tendermint_consensus_step_duration_bucket{chain_id="test-chain-IrF74Y",step="Prevote",le="1.9306977288832508"} 29 tendermint_consensus_step_duration_bucket{chain_id="test-chain-IrF74Y",step="Prevote",le="5.1794746792312125"} 29 tendermint_consensus_step_duration_bucket{chain_id="test-chain-IrF74Y",step="Prevote",le="13.894954943731381"} 29 tendermint_consensus_step_duration_bucket{chain_id="test-chain-IrF74Y",step="Prevote",le="37.27593720314942"} 29 tendermint_consensus_step_duration_bucket{chain_id="test-chain-IrF74Y",step="Prevote",le="100.00000000000006"} 29 tendermint_consensus_step_duration_bucket{chain_id="test-chain-IrF74Y",step="Prevote",le="+Inf"} 29 tendermint_consensus_step_duration_sum{chain_id="test-chain-IrF74Y",step="Prevote"} 0.177714525 tendermint_consensus_step_duration_count{chain_id="test-chain-IrF74Y",step="Prevote"} 29 tendermint_consensus_step_duration_bucket{chain_id="test-chain-IrF74Y",step="Propose",le="0.1"} 29 tendermint_consensus_step_duration_bucket{chain_id="test-chain-IrF74Y",step="Propose",le="0.2682695795279726"} 29 tendermint_consensus_step_duration_bucket{chain_id="test-chain-IrF74Y",step="Propose",le="0.7196856730011522"} 29 tendermint_consensus_step_duration_bucket{chain_id="test-chain-IrF74Y",step="Propose",le="1.9306977288832508"} 29 tendermint_consensus_step_duration_bucket{chain_id="test-chain-IrF74Y",step="Propose",le="5.1794746792312125"} 29 tendermint_consensus_step_duration_bucket{chain_id="test-chain-IrF74Y",step="Propose",le="13.894954943731381"} 29 tendermint_consensus_step_duration_bucket{chain_id="test-chain-IrF74Y",step="Propose",le="37.27593720314942"} 29 tendermint_consensus_step_duration_bucket{chain_id="test-chain-IrF74Y",step="Propose",le="100.00000000000006"} 29 tendermint_consensus_step_duration_bucket{chain_id="test-chain-IrF74Y",step="Propose",le="+Inf"} 29 tendermint_consensus_step_duration_sum{chain_id="test-chain-IrF74Y",step="Propose"} 0.221851927 tendermint_consensus_step_duration_count{chain_id="test-chain-IrF74Y",step="Propose"} 29 ``` ``` # HELP tendermint_consensus_block_gossip_receive_time Difference in seconds between when the validator learns of a new blockand when the validator receives the last piece of the block. # TYPE tendermint_consensus_block_gossip_receive_time histogram tendermint_consensus_block_gossip_receive_time_bucket{chain_id="test-chain-IrF74Y",le="0.1"} 29 tendermint_consensus_block_gossip_receive_time_bucket{chain_id="test-chain-IrF74Y",le="0.2682695795279726"} 29 tendermint_consensus_block_gossip_receive_time_bucket{chain_id="test-chain-IrF74Y",le="0.7196856730011522"} 29 tendermint_consensus_block_gossip_receive_time_bucket{chain_id="test-chain-IrF74Y",le="1.9306977288832508"} 29 tendermint_consensus_block_gossip_receive_time_bucket{chain_id="test-chain-IrF74Y",le="5.1794746792312125"} 29 tendermint_consensus_block_gossip_receive_time_bucket{chain_id="test-chain-IrF74Y",le="13.894954943731381"} 29 tendermint_consensus_block_gossip_receive_time_bucket{chain_id="test-chain-IrF74Y",le="37.27593720314942"} 29 tendermint_consensus_block_gossip_receive_time_bucket{chain_id="test-chain-IrF74Y",le="100.00000000000006"} 29 tendermint_consensus_block_gossip_receive_time_bucket{chain_id="test-chain-IrF74Y",le="+Inf"} 29 tendermint_consensus_block_gossip_receive_time_sum{chain_id="test-chain-IrF74Y"} 0.06380 ``` ``` # HELP tendermint_consensus_block_gossip_parts_received Number of block parts received by the node, labeled by whether thepart was relevant to the block the node was currently gathering or not # TYPE tendermint_consensus_block_gossip_parts_received counter tendermint_consensus_block_gossip_parts_received{chain_id="test-chain-IrF74Y",matches_current="true"} 29 ```
2 years ago
10 years ago
9 years ago
10 years ago
10 years ago
10 years ago
10 years ago
consensus: additional timing metrics (#7849) This change introduces an additional set of metrics aimed at helping operators understand the timing for consensus. This change adds the following metrics: ``` # HELP tendermint_consensus_round_duration Time spent in a round # TYPE tendermint_consensus_round_duration histogram tendermint_consensus_round_duration_bucket{chain_id="test-chain-IrF74Y",le="0.1"} 29 tendermint_consensus_round_duration_bucket{chain_id="test-chain-IrF74Y",le="0.2682695795279726"} 29 tendermint_consensus_round_duration_bucket{chain_id="test-chain-IrF74Y",le="0.7196856730011522"} 29 tendermint_consensus_round_duration_bucket{chain_id="test-chain-IrF74Y",le="1.9306977288832508"} 29 tendermint_consensus_round_duration_bucket{chain_id="test-chain-IrF74Y",le="5.1794746792312125"} 29 tendermint_consensus_round_duration_bucket{chain_id="test-chain-IrF74Y",le="13.894954943731381"} 29 tendermint_consensus_round_duration_bucket{chain_id="test-chain-IrF74Y",le="37.27593720314942"} 29 tendermint_consensus_round_duration_bucket{chain_id="test-chain-IrF74Y",le="100.00000000000006"} 29 tendermint_consensus_round_duration_bucket{chain_id="test-chain-IrF74Y",le="+Inf"} 29 tendermint_consensus_round_duration_sum{chain_id="test-chain-IrF74Y"} 0.028651869999999996 tendermint_consensus_round_duration_count{chain_id="test-chain-IrF74Y"} 29 ``` ``` # HELP tendermint_consensus_step_duration Time spent per step. # TYPE tendermint_consensus_step_duration histogram tendermint_consensus_step_duration_bucket{chain_id="test-chain-IrF74Y",step="Commit",le="0.1"} 29 tendermint_consensus_step_duration_bucket{chain_id="test-chain-IrF74Y",step="Commit",le="0.2682695795279726"} 29 tendermint_consensus_step_duration_bucket{chain_id="test-chain-IrF74Y",step="Commit",le="0.7196856730011522"} 29 tendermint_consensus_step_duration_bucket{chain_id="test-chain-IrF74Y",step="Commit",le="1.9306977288832508"} 29 tendermint_consensus_step_duration_bucket{chain_id="test-chain-IrF74Y",step="Commit",le="5.1794746792312125"} 29 tendermint_consensus_step_duration_bucket{chain_id="test-chain-IrF74Y",step="Commit",le="13.894954943731381"} 29 tendermint_consensus_step_duration_bucket{chain_id="test-chain-IrF74Y",step="Commit",le="37.27593720314942"} 29 tendermint_consensus_step_duration_bucket{chain_id="test-chain-IrF74Y",step="Commit",le="100.00000000000006"} 29 tendermint_consensus_step_duration_bucket{chain_id="test-chain-IrF74Y",step="Commit",le="+Inf"} 29 tendermint_consensus_step_duration_sum{chain_id="test-chain-IrF74Y",step="Commit"} 0.26650875 tendermint_consensus_step_duration_count{chain_id="test-chain-IrF74Y",step="Commit"} 29 tendermint_consensus_step_duration_bucket{chain_id="test-chain-IrF74Y",step="NewHeight",le="0.1"} 0 tendermint_consensus_step_duration_bucket{chain_id="test-chain-IrF74Y",step="NewHeight",le="0.2682695795279726"} 0 tendermint_consensus_step_duration_bucket{chain_id="test-chain-IrF74Y",step="NewHeight",le="0.7196856730011522"} 0 tendermint_consensus_step_duration_bucket{chain_id="test-chain-IrF74Y",step="NewHeight",le="1.9306977288832508"} 28 tendermint_consensus_step_duration_bucket{chain_id="test-chain-IrF74Y",step="NewHeight",le="5.1794746792312125"} 28 tendermint_consensus_step_duration_bucket{chain_id="test-chain-IrF74Y",step="NewHeight",le="13.894954943731381"} 28 tendermint_consensus_step_duration_bucket{chain_id="test-chain-IrF74Y",step="NewHeight",le="37.27593720314942"} 28 tendermint_consensus_step_duration_bucket{chain_id="test-chain-IrF74Y",step="NewHeight",le="100.00000000000006"} 28 tendermint_consensus_step_duration_bucket{chain_id="test-chain-IrF74Y",step="NewHeight",le="+Inf"} 28 tendermint_consensus_step_duration_sum{chain_id="test-chain-IrF74Y",step="NewHeight"} 27.773921702 tendermint_consensus_step_duration_count{chain_id="test-chain-IrF74Y",step="NewHeight"} 28 tendermint_consensus_step_duration_bucket{chain_id="test-chain-IrF74Y",step="NewRound",le="0.1"} 29 tendermint_consensus_step_duration_bucket{chain_id="test-chain-IrF74Y",step="NewRound",le="0.2682695795279726"} 29 tendermint_consensus_step_duration_bucket{chain_id="test-chain-IrF74Y",step="NewRound",le="0.7196856730011522"} 29 tendermint_consensus_step_duration_bucket{chain_id="test-chain-IrF74Y",step="NewRound",le="1.9306977288832508"} 29 tendermint_consensus_step_duration_bucket{chain_id="test-chain-IrF74Y",step="NewRound",le="5.1794746792312125"} 29 tendermint_consensus_step_duration_bucket{chain_id="test-chain-IrF74Y",step="NewRound",le="13.894954943731381"} 29 tendermint_consensus_step_duration_bucket{chain_id="test-chain-IrF74Y",step="NewRound",le="37.27593720314942"} 29 tendermint_consensus_step_duration_bucket{chain_id="test-chain-IrF74Y",step="NewRound",le="100.00000000000006"} 29 tendermint_consensus_step_duration_bucket{chain_id="test-chain-IrF74Y",step="NewRound",le="+Inf"} 29 tendermint_consensus_step_duration_sum{chain_id="test-chain-IrF74Y",step="NewRound"} 0.168961052 tendermint_consensus_step_duration_count{chain_id="test-chain-IrF74Y",step="NewRound"} 29 tendermint_consensus_step_duration_bucket{chain_id="test-chain-IrF74Y",step="Precommit",le="0.1"} 29 tendermint_consensus_step_duration_bucket{chain_id="test-chain-IrF74Y",step="Precommit",le="0.2682695795279726"} 29 tendermint_consensus_step_duration_bucket{chain_id="test-chain-IrF74Y",step="Precommit",le="0.7196856730011522"} 29 tendermint_consensus_step_duration_bucket{chain_id="test-chain-IrF74Y",step="Precommit",le="1.9306977288832508"} 29 tendermint_consensus_step_duration_bucket{chain_id="test-chain-IrF74Y",step="Precommit",le="5.1794746792312125"} 29 tendermint_consensus_step_duration_bucket{chain_id="test-chain-IrF74Y",step="Precommit",le="13.894954943731381"} 29 tendermint_consensus_step_duration_bucket{chain_id="test-chain-IrF74Y",step="Precommit",le="37.27593720314942"} 29 tendermint_consensus_step_duration_bucket{chain_id="test-chain-IrF74Y",step="Precommit",le="100.00000000000006"} 29 tendermint_consensus_step_duration_bucket{chain_id="test-chain-IrF74Y",step="Precommit",le="+Inf"} 29 tendermint_consensus_step_duration_sum{chain_id="test-chain-IrF74Y",step="Precommit"} 0.06414115999999999 tendermint_consensus_step_duration_count{chain_id="test-chain-IrF74Y",step="Precommit"} 29 tendermint_consensus_step_duration_bucket{chain_id="test-chain-IrF74Y",step="Prevote",le="0.1"} 29 tendermint_consensus_step_duration_bucket{chain_id="test-chain-IrF74Y",step="Prevote",le="0.2682695795279726"} 29 tendermint_consensus_step_duration_bucket{chain_id="test-chain-IrF74Y",step="Prevote",le="0.7196856730011522"} 29 tendermint_consensus_step_duration_bucket{chain_id="test-chain-IrF74Y",step="Prevote",le="1.9306977288832508"} 29 tendermint_consensus_step_duration_bucket{chain_id="test-chain-IrF74Y",step="Prevote",le="5.1794746792312125"} 29 tendermint_consensus_step_duration_bucket{chain_id="test-chain-IrF74Y",step="Prevote",le="13.894954943731381"} 29 tendermint_consensus_step_duration_bucket{chain_id="test-chain-IrF74Y",step="Prevote",le="37.27593720314942"} 29 tendermint_consensus_step_duration_bucket{chain_id="test-chain-IrF74Y",step="Prevote",le="100.00000000000006"} 29 tendermint_consensus_step_duration_bucket{chain_id="test-chain-IrF74Y",step="Prevote",le="+Inf"} 29 tendermint_consensus_step_duration_sum{chain_id="test-chain-IrF74Y",step="Prevote"} 0.177714525 tendermint_consensus_step_duration_count{chain_id="test-chain-IrF74Y",step="Prevote"} 29 tendermint_consensus_step_duration_bucket{chain_id="test-chain-IrF74Y",step="Propose",le="0.1"} 29 tendermint_consensus_step_duration_bucket{chain_id="test-chain-IrF74Y",step="Propose",le="0.2682695795279726"} 29 tendermint_consensus_step_duration_bucket{chain_id="test-chain-IrF74Y",step="Propose",le="0.7196856730011522"} 29 tendermint_consensus_step_duration_bucket{chain_id="test-chain-IrF74Y",step="Propose",le="1.9306977288832508"} 29 tendermint_consensus_step_duration_bucket{chain_id="test-chain-IrF74Y",step="Propose",le="5.1794746792312125"} 29 tendermint_consensus_step_duration_bucket{chain_id="test-chain-IrF74Y",step="Propose",le="13.894954943731381"} 29 tendermint_consensus_step_duration_bucket{chain_id="test-chain-IrF74Y",step="Propose",le="37.27593720314942"} 29 tendermint_consensus_step_duration_bucket{chain_id="test-chain-IrF74Y",step="Propose",le="100.00000000000006"} 29 tendermint_consensus_step_duration_bucket{chain_id="test-chain-IrF74Y",step="Propose",le="+Inf"} 29 tendermint_consensus_step_duration_sum{chain_id="test-chain-IrF74Y",step="Propose"} 0.221851927 tendermint_consensus_step_duration_count{chain_id="test-chain-IrF74Y",step="Propose"} 29 ``` ``` # HELP tendermint_consensus_block_gossip_receive_time Difference in seconds between when the validator learns of a new blockand when the validator receives the last piece of the block. # TYPE tendermint_consensus_block_gossip_receive_time histogram tendermint_consensus_block_gossip_receive_time_bucket{chain_id="test-chain-IrF74Y",le="0.1"} 29 tendermint_consensus_block_gossip_receive_time_bucket{chain_id="test-chain-IrF74Y",le="0.2682695795279726"} 29 tendermint_consensus_block_gossip_receive_time_bucket{chain_id="test-chain-IrF74Y",le="0.7196856730011522"} 29 tendermint_consensus_block_gossip_receive_time_bucket{chain_id="test-chain-IrF74Y",le="1.9306977288832508"} 29 tendermint_consensus_block_gossip_receive_time_bucket{chain_id="test-chain-IrF74Y",le="5.1794746792312125"} 29 tendermint_consensus_block_gossip_receive_time_bucket{chain_id="test-chain-IrF74Y",le="13.894954943731381"} 29 tendermint_consensus_block_gossip_receive_time_bucket{chain_id="test-chain-IrF74Y",le="37.27593720314942"} 29 tendermint_consensus_block_gossip_receive_time_bucket{chain_id="test-chain-IrF74Y",le="100.00000000000006"} 29 tendermint_consensus_block_gossip_receive_time_bucket{chain_id="test-chain-IrF74Y",le="+Inf"} 29 tendermint_consensus_block_gossip_receive_time_sum{chain_id="test-chain-IrF74Y"} 0.06380 ``` ``` # HELP tendermint_consensus_block_gossip_parts_received Number of block parts received by the node, labeled by whether thepart was relevant to the block the node was currently gathering or not # TYPE tendermint_consensus_block_gossip_parts_received counter tendermint_consensus_block_gossip_parts_received{chain_id="test-chain-IrF74Y",matches_current="true"} 29 ```
2 years ago
10 years ago
9 years ago
9 years ago
9 years ago
9 years ago
2 years ago
10 years ago
10 years ago
8 years ago
6 years ago
lint: Enable Golint (#4212) * Fix many golint errors * Fix golint errors in the 'lite' package * Don't export Pool.store * Fix typo * Revert unwanted changes * Fix errors in counter package * Fix linter errors in kvstore package * Fix linter error in example package * Fix error in tests package * Fix linter errors in v2 package * Fix linter errors in consensus package * Fix linter errors in evidence package * Fix linter error in fail package * Fix linter errors in query package * Fix linter errors in core package * Fix linter errors in node package * Fix linter errors in mempool package * Fix linter error in conn package * Fix linter errors in pex package * Rename PEXReactor export to Reactor * Fix linter errors in trust package * Fix linter errors in upnp package * Fix linter errors in p2p package * Fix linter errors in proxy package * Fix linter errors in mock_test package * Fix linter error in client_test package * Fix linter errors in coretypes package * Fix linter errors in coregrpc package * Fix linter errors in rpcserver package * Fix linter errors in rpctypes package * Fix linter errors in rpctest package * Fix linter error in json2wal script * Fix linter error in wal2json script * Fix linter errors in kv package * Fix linter error in state package * Fix linter error in grpc_client * Fix linter errors in types package * Fix linter error in version package * Fix remaining errors * Address review comments * Fix broken tests * Reconcile package coregrpc * Fix golangci bot error * Fix new golint errors * Fix broken reference * Enable golint linter * minor changes to bring golint into line * fix failing test * fix pex reactor naming * address PR comments
5 years ago
6 years ago
6 years ago
6 years ago
9 years ago
9 years ago
add support for block pruning via ABCI Commit response (#4588) * Added BlockStore.DeleteBlock() * Added initial block pruner prototype * wip * Added BlockStore.PruneBlocks() * Added consensus setting for block pruning * Added BlockStore base * Error on replay if base does not have blocks * Handle missing blocks when sending VoteSetMaj23Message * Error message tweak * Properly update blockstore state * Error message fix again * blockchain: ignore peer missing blocks * Added FIXME * Added test for block replay with truncated history * Handle peer base in blockchain reactor * Improved replay error handling * Added tests for Store.PruneBlocks() * Fix non-RPC handling of truncated block history * Panic on missing block meta in needProofBlock() * Updated changelog * Handle truncated block history in RPC layer * Added info about earliest block in /status RPC * Reorder height and base in blockchain reactor messages * Updated changelog * Fix tests * Appease linter * Minor review fixes * Non-empty BlockStores should always have base > 0 * Update code to assume base > 0 invariant * Added blockstore tests for pruning to 0 * Make sure we don't prune below the current base * Added BlockStore.Size() * config: added retain_blocks recommendations * Update v1 blockchain reactor to handle blockstore base * Added state database pruning * Propagate errors on missing validator sets * Comment tweaks * Improved error message Co-Authored-By: Anton Kaliaev <anton.kalyaev@gmail.com> * use ABCI field ResponseCommit.retain_height instead of retain-blocks config option * remove State.RetainHeight, return value instead * fix minor issues * rename pruneHeights() to pruneBlocks() * noop to fix GitHub borkage Co-authored-by: Anton Kaliaev <anton.kalyaev@gmail.com>
4 years ago
add support for block pruning via ABCI Commit response (#4588) * Added BlockStore.DeleteBlock() * Added initial block pruner prototype * wip * Added BlockStore.PruneBlocks() * Added consensus setting for block pruning * Added BlockStore base * Error on replay if base does not have blocks * Handle missing blocks when sending VoteSetMaj23Message * Error message tweak * Properly update blockstore state * Error message fix again * blockchain: ignore peer missing blocks * Added FIXME * Added test for block replay with truncated history * Handle peer base in blockchain reactor * Improved replay error handling * Added tests for Store.PruneBlocks() * Fix non-RPC handling of truncated block history * Panic on missing block meta in needProofBlock() * Updated changelog * Handle truncated block history in RPC layer * Added info about earliest block in /status RPC * Reorder height and base in blockchain reactor messages * Updated changelog * Fix tests * Appease linter * Minor review fixes * Non-empty BlockStores should always have base > 0 * Update code to assume base > 0 invariant * Added blockstore tests for pruning to 0 * Make sure we don't prune below the current base * Added BlockStore.Size() * config: added retain_blocks recommendations * Update v1 blockchain reactor to handle blockstore base * Added state database pruning * Propagate errors on missing validator sets * Comment tweaks * Improved error message Co-Authored-By: Anton Kaliaev <anton.kalyaev@gmail.com> * use ABCI field ResponseCommit.retain_height instead of retain-blocks config option * remove State.RetainHeight, return value instead * fix minor issues * rename pruneHeights() to pruneBlocks() * noop to fix GitHub borkage Co-authored-by: Anton Kaliaev <anton.kalyaev@gmail.com>
4 years ago
6 years ago
10 years ago
consensus: additional timing metrics (#7849) This change introduces an additional set of metrics aimed at helping operators understand the timing for consensus. This change adds the following metrics: ``` # HELP tendermint_consensus_round_duration Time spent in a round # TYPE tendermint_consensus_round_duration histogram tendermint_consensus_round_duration_bucket{chain_id="test-chain-IrF74Y",le="0.1"} 29 tendermint_consensus_round_duration_bucket{chain_id="test-chain-IrF74Y",le="0.2682695795279726"} 29 tendermint_consensus_round_duration_bucket{chain_id="test-chain-IrF74Y",le="0.7196856730011522"} 29 tendermint_consensus_round_duration_bucket{chain_id="test-chain-IrF74Y",le="1.9306977288832508"} 29 tendermint_consensus_round_duration_bucket{chain_id="test-chain-IrF74Y",le="5.1794746792312125"} 29 tendermint_consensus_round_duration_bucket{chain_id="test-chain-IrF74Y",le="13.894954943731381"} 29 tendermint_consensus_round_duration_bucket{chain_id="test-chain-IrF74Y",le="37.27593720314942"} 29 tendermint_consensus_round_duration_bucket{chain_id="test-chain-IrF74Y",le="100.00000000000006"} 29 tendermint_consensus_round_duration_bucket{chain_id="test-chain-IrF74Y",le="+Inf"} 29 tendermint_consensus_round_duration_sum{chain_id="test-chain-IrF74Y"} 0.028651869999999996 tendermint_consensus_round_duration_count{chain_id="test-chain-IrF74Y"} 29 ``` ``` # HELP tendermint_consensus_step_duration Time spent per step. # TYPE tendermint_consensus_step_duration histogram tendermint_consensus_step_duration_bucket{chain_id="test-chain-IrF74Y",step="Commit",le="0.1"} 29 tendermint_consensus_step_duration_bucket{chain_id="test-chain-IrF74Y",step="Commit",le="0.2682695795279726"} 29 tendermint_consensus_step_duration_bucket{chain_id="test-chain-IrF74Y",step="Commit",le="0.7196856730011522"} 29 tendermint_consensus_step_duration_bucket{chain_id="test-chain-IrF74Y",step="Commit",le="1.9306977288832508"} 29 tendermint_consensus_step_duration_bucket{chain_id="test-chain-IrF74Y",step="Commit",le="5.1794746792312125"} 29 tendermint_consensus_step_duration_bucket{chain_id="test-chain-IrF74Y",step="Commit",le="13.894954943731381"} 29 tendermint_consensus_step_duration_bucket{chain_id="test-chain-IrF74Y",step="Commit",le="37.27593720314942"} 29 tendermint_consensus_step_duration_bucket{chain_id="test-chain-IrF74Y",step="Commit",le="100.00000000000006"} 29 tendermint_consensus_step_duration_bucket{chain_id="test-chain-IrF74Y",step="Commit",le="+Inf"} 29 tendermint_consensus_step_duration_sum{chain_id="test-chain-IrF74Y",step="Commit"} 0.26650875 tendermint_consensus_step_duration_count{chain_id="test-chain-IrF74Y",step="Commit"} 29 tendermint_consensus_step_duration_bucket{chain_id="test-chain-IrF74Y",step="NewHeight",le="0.1"} 0 tendermint_consensus_step_duration_bucket{chain_id="test-chain-IrF74Y",step="NewHeight",le="0.2682695795279726"} 0 tendermint_consensus_step_duration_bucket{chain_id="test-chain-IrF74Y",step="NewHeight",le="0.7196856730011522"} 0 tendermint_consensus_step_duration_bucket{chain_id="test-chain-IrF74Y",step="NewHeight",le="1.9306977288832508"} 28 tendermint_consensus_step_duration_bucket{chain_id="test-chain-IrF74Y",step="NewHeight",le="5.1794746792312125"} 28 tendermint_consensus_step_duration_bucket{chain_id="test-chain-IrF74Y",step="NewHeight",le="13.894954943731381"} 28 tendermint_consensus_step_duration_bucket{chain_id="test-chain-IrF74Y",step="NewHeight",le="37.27593720314942"} 28 tendermint_consensus_step_duration_bucket{chain_id="test-chain-IrF74Y",step="NewHeight",le="100.00000000000006"} 28 tendermint_consensus_step_duration_bucket{chain_id="test-chain-IrF74Y",step="NewHeight",le="+Inf"} 28 tendermint_consensus_step_duration_sum{chain_id="test-chain-IrF74Y",step="NewHeight"} 27.773921702 tendermint_consensus_step_duration_count{chain_id="test-chain-IrF74Y",step="NewHeight"} 28 tendermint_consensus_step_duration_bucket{chain_id="test-chain-IrF74Y",step="NewRound",le="0.1"} 29 tendermint_consensus_step_duration_bucket{chain_id="test-chain-IrF74Y",step="NewRound",le="0.2682695795279726"} 29 tendermint_consensus_step_duration_bucket{chain_id="test-chain-IrF74Y",step="NewRound",le="0.7196856730011522"} 29 tendermint_consensus_step_duration_bucket{chain_id="test-chain-IrF74Y",step="NewRound",le="1.9306977288832508"} 29 tendermint_consensus_step_duration_bucket{chain_id="test-chain-IrF74Y",step="NewRound",le="5.1794746792312125"} 29 tendermint_consensus_step_duration_bucket{chain_id="test-chain-IrF74Y",step="NewRound",le="13.894954943731381"} 29 tendermint_consensus_step_duration_bucket{chain_id="test-chain-IrF74Y",step="NewRound",le="37.27593720314942"} 29 tendermint_consensus_step_duration_bucket{chain_id="test-chain-IrF74Y",step="NewRound",le="100.00000000000006"} 29 tendermint_consensus_step_duration_bucket{chain_id="test-chain-IrF74Y",step="NewRound",le="+Inf"} 29 tendermint_consensus_step_duration_sum{chain_id="test-chain-IrF74Y",step="NewRound"} 0.168961052 tendermint_consensus_step_duration_count{chain_id="test-chain-IrF74Y",step="NewRound"} 29 tendermint_consensus_step_duration_bucket{chain_id="test-chain-IrF74Y",step="Precommit",le="0.1"} 29 tendermint_consensus_step_duration_bucket{chain_id="test-chain-IrF74Y",step="Precommit",le="0.2682695795279726"} 29 tendermint_consensus_step_duration_bucket{chain_id="test-chain-IrF74Y",step="Precommit",le="0.7196856730011522"} 29 tendermint_consensus_step_duration_bucket{chain_id="test-chain-IrF74Y",step="Precommit",le="1.9306977288832508"} 29 tendermint_consensus_step_duration_bucket{chain_id="test-chain-IrF74Y",step="Precommit",le="5.1794746792312125"} 29 tendermint_consensus_step_duration_bucket{chain_id="test-chain-IrF74Y",step="Precommit",le="13.894954943731381"} 29 tendermint_consensus_step_duration_bucket{chain_id="test-chain-IrF74Y",step="Precommit",le="37.27593720314942"} 29 tendermint_consensus_step_duration_bucket{chain_id="test-chain-IrF74Y",step="Precommit",le="100.00000000000006"} 29 tendermint_consensus_step_duration_bucket{chain_id="test-chain-IrF74Y",step="Precommit",le="+Inf"} 29 tendermint_consensus_step_duration_sum{chain_id="test-chain-IrF74Y",step="Precommit"} 0.06414115999999999 tendermint_consensus_step_duration_count{chain_id="test-chain-IrF74Y",step="Precommit"} 29 tendermint_consensus_step_duration_bucket{chain_id="test-chain-IrF74Y",step="Prevote",le="0.1"} 29 tendermint_consensus_step_duration_bucket{chain_id="test-chain-IrF74Y",step="Prevote",le="0.2682695795279726"} 29 tendermint_consensus_step_duration_bucket{chain_id="test-chain-IrF74Y",step="Prevote",le="0.7196856730011522"} 29 tendermint_consensus_step_duration_bucket{chain_id="test-chain-IrF74Y",step="Prevote",le="1.9306977288832508"} 29 tendermint_consensus_step_duration_bucket{chain_id="test-chain-IrF74Y",step="Prevote",le="5.1794746792312125"} 29 tendermint_consensus_step_duration_bucket{chain_id="test-chain-IrF74Y",step="Prevote",le="13.894954943731381"} 29 tendermint_consensus_step_duration_bucket{chain_id="test-chain-IrF74Y",step="Prevote",le="37.27593720314942"} 29 tendermint_consensus_step_duration_bucket{chain_id="test-chain-IrF74Y",step="Prevote",le="100.00000000000006"} 29 tendermint_consensus_step_duration_bucket{chain_id="test-chain-IrF74Y",step="Prevote",le="+Inf"} 29 tendermint_consensus_step_duration_sum{chain_id="test-chain-IrF74Y",step="Prevote"} 0.177714525 tendermint_consensus_step_duration_count{chain_id="test-chain-IrF74Y",step="Prevote"} 29 tendermint_consensus_step_duration_bucket{chain_id="test-chain-IrF74Y",step="Propose",le="0.1"} 29 tendermint_consensus_step_duration_bucket{chain_id="test-chain-IrF74Y",step="Propose",le="0.2682695795279726"} 29 tendermint_consensus_step_duration_bucket{chain_id="test-chain-IrF74Y",step="Propose",le="0.7196856730011522"} 29 tendermint_consensus_step_duration_bucket{chain_id="test-chain-IrF74Y",step="Propose",le="1.9306977288832508"} 29 tendermint_consensus_step_duration_bucket{chain_id="test-chain-IrF74Y",step="Propose",le="5.1794746792312125"} 29 tendermint_consensus_step_duration_bucket{chain_id="test-chain-IrF74Y",step="Propose",le="13.894954943731381"} 29 tendermint_consensus_step_duration_bucket{chain_id="test-chain-IrF74Y",step="Propose",le="37.27593720314942"} 29 tendermint_consensus_step_duration_bucket{chain_id="test-chain-IrF74Y",step="Propose",le="100.00000000000006"} 29 tendermint_consensus_step_duration_bucket{chain_id="test-chain-IrF74Y",step="Propose",le="+Inf"} 29 tendermint_consensus_step_duration_sum{chain_id="test-chain-IrF74Y",step="Propose"} 0.221851927 tendermint_consensus_step_duration_count{chain_id="test-chain-IrF74Y",step="Propose"} 29 ``` ``` # HELP tendermint_consensus_block_gossip_receive_time Difference in seconds between when the validator learns of a new blockand when the validator receives the last piece of the block. # TYPE tendermint_consensus_block_gossip_receive_time histogram tendermint_consensus_block_gossip_receive_time_bucket{chain_id="test-chain-IrF74Y",le="0.1"} 29 tendermint_consensus_block_gossip_receive_time_bucket{chain_id="test-chain-IrF74Y",le="0.2682695795279726"} 29 tendermint_consensus_block_gossip_receive_time_bucket{chain_id="test-chain-IrF74Y",le="0.7196856730011522"} 29 tendermint_consensus_block_gossip_receive_time_bucket{chain_id="test-chain-IrF74Y",le="1.9306977288832508"} 29 tendermint_consensus_block_gossip_receive_time_bucket{chain_id="test-chain-IrF74Y",le="5.1794746792312125"} 29 tendermint_consensus_block_gossip_receive_time_bucket{chain_id="test-chain-IrF74Y",le="13.894954943731381"} 29 tendermint_consensus_block_gossip_receive_time_bucket{chain_id="test-chain-IrF74Y",le="37.27593720314942"} 29 tendermint_consensus_block_gossip_receive_time_bucket{chain_id="test-chain-IrF74Y",le="100.00000000000006"} 29 tendermint_consensus_block_gossip_receive_time_bucket{chain_id="test-chain-IrF74Y",le="+Inf"} 29 tendermint_consensus_block_gossip_receive_time_sum{chain_id="test-chain-IrF74Y"} 0.06380 ``` ``` # HELP tendermint_consensus_block_gossip_parts_received Number of block parts received by the node, labeled by whether thepart was relevant to the block the node was currently gathering or not # TYPE tendermint_consensus_block_gossip_parts_received counter tendermint_consensus_block_gossip_parts_received{chain_id="test-chain-IrF74Y",matches_current="true"} 29 ```
2 years ago
consensus: additional timing metrics (#7849) This change introduces an additional set of metrics aimed at helping operators understand the timing for consensus. This change adds the following metrics: ``` # HELP tendermint_consensus_round_duration Time spent in a round # TYPE tendermint_consensus_round_duration histogram tendermint_consensus_round_duration_bucket{chain_id="test-chain-IrF74Y",le="0.1"} 29 tendermint_consensus_round_duration_bucket{chain_id="test-chain-IrF74Y",le="0.2682695795279726"} 29 tendermint_consensus_round_duration_bucket{chain_id="test-chain-IrF74Y",le="0.7196856730011522"} 29 tendermint_consensus_round_duration_bucket{chain_id="test-chain-IrF74Y",le="1.9306977288832508"} 29 tendermint_consensus_round_duration_bucket{chain_id="test-chain-IrF74Y",le="5.1794746792312125"} 29 tendermint_consensus_round_duration_bucket{chain_id="test-chain-IrF74Y",le="13.894954943731381"} 29 tendermint_consensus_round_duration_bucket{chain_id="test-chain-IrF74Y",le="37.27593720314942"} 29 tendermint_consensus_round_duration_bucket{chain_id="test-chain-IrF74Y",le="100.00000000000006"} 29 tendermint_consensus_round_duration_bucket{chain_id="test-chain-IrF74Y",le="+Inf"} 29 tendermint_consensus_round_duration_sum{chain_id="test-chain-IrF74Y"} 0.028651869999999996 tendermint_consensus_round_duration_count{chain_id="test-chain-IrF74Y"} 29 ``` ``` # HELP tendermint_consensus_step_duration Time spent per step. # TYPE tendermint_consensus_step_duration histogram tendermint_consensus_step_duration_bucket{chain_id="test-chain-IrF74Y",step="Commit",le="0.1"} 29 tendermint_consensus_step_duration_bucket{chain_id="test-chain-IrF74Y",step="Commit",le="0.2682695795279726"} 29 tendermint_consensus_step_duration_bucket{chain_id="test-chain-IrF74Y",step="Commit",le="0.7196856730011522"} 29 tendermint_consensus_step_duration_bucket{chain_id="test-chain-IrF74Y",step="Commit",le="1.9306977288832508"} 29 tendermint_consensus_step_duration_bucket{chain_id="test-chain-IrF74Y",step="Commit",le="5.1794746792312125"} 29 tendermint_consensus_step_duration_bucket{chain_id="test-chain-IrF74Y",step="Commit",le="13.894954943731381"} 29 tendermint_consensus_step_duration_bucket{chain_id="test-chain-IrF74Y",step="Commit",le="37.27593720314942"} 29 tendermint_consensus_step_duration_bucket{chain_id="test-chain-IrF74Y",step="Commit",le="100.00000000000006"} 29 tendermint_consensus_step_duration_bucket{chain_id="test-chain-IrF74Y",step="Commit",le="+Inf"} 29 tendermint_consensus_step_duration_sum{chain_id="test-chain-IrF74Y",step="Commit"} 0.26650875 tendermint_consensus_step_duration_count{chain_id="test-chain-IrF74Y",step="Commit"} 29 tendermint_consensus_step_duration_bucket{chain_id="test-chain-IrF74Y",step="NewHeight",le="0.1"} 0 tendermint_consensus_step_duration_bucket{chain_id="test-chain-IrF74Y",step="NewHeight",le="0.2682695795279726"} 0 tendermint_consensus_step_duration_bucket{chain_id="test-chain-IrF74Y",step="NewHeight",le="0.7196856730011522"} 0 tendermint_consensus_step_duration_bucket{chain_id="test-chain-IrF74Y",step="NewHeight",le="1.9306977288832508"} 28 tendermint_consensus_step_duration_bucket{chain_id="test-chain-IrF74Y",step="NewHeight",le="5.1794746792312125"} 28 tendermint_consensus_step_duration_bucket{chain_id="test-chain-IrF74Y",step="NewHeight",le="13.894954943731381"} 28 tendermint_consensus_step_duration_bucket{chain_id="test-chain-IrF74Y",step="NewHeight",le="37.27593720314942"} 28 tendermint_consensus_step_duration_bucket{chain_id="test-chain-IrF74Y",step="NewHeight",le="100.00000000000006"} 28 tendermint_consensus_step_duration_bucket{chain_id="test-chain-IrF74Y",step="NewHeight",le="+Inf"} 28 tendermint_consensus_step_duration_sum{chain_id="test-chain-IrF74Y",step="NewHeight"} 27.773921702 tendermint_consensus_step_duration_count{chain_id="test-chain-IrF74Y",step="NewHeight"} 28 tendermint_consensus_step_duration_bucket{chain_id="test-chain-IrF74Y",step="NewRound",le="0.1"} 29 tendermint_consensus_step_duration_bucket{chain_id="test-chain-IrF74Y",step="NewRound",le="0.2682695795279726"} 29 tendermint_consensus_step_duration_bucket{chain_id="test-chain-IrF74Y",step="NewRound",le="0.7196856730011522"} 29 tendermint_consensus_step_duration_bucket{chain_id="test-chain-IrF74Y",step="NewRound",le="1.9306977288832508"} 29 tendermint_consensus_step_duration_bucket{chain_id="test-chain-IrF74Y",step="NewRound",le="5.1794746792312125"} 29 tendermint_consensus_step_duration_bucket{chain_id="test-chain-IrF74Y",step="NewRound",le="13.894954943731381"} 29 tendermint_consensus_step_duration_bucket{chain_id="test-chain-IrF74Y",step="NewRound",le="37.27593720314942"} 29 tendermint_consensus_step_duration_bucket{chain_id="test-chain-IrF74Y",step="NewRound",le="100.00000000000006"} 29 tendermint_consensus_step_duration_bucket{chain_id="test-chain-IrF74Y",step="NewRound",le="+Inf"} 29 tendermint_consensus_step_duration_sum{chain_id="test-chain-IrF74Y",step="NewRound"} 0.168961052 tendermint_consensus_step_duration_count{chain_id="test-chain-IrF74Y",step="NewRound"} 29 tendermint_consensus_step_duration_bucket{chain_id="test-chain-IrF74Y",step="Precommit",le="0.1"} 29 tendermint_consensus_step_duration_bucket{chain_id="test-chain-IrF74Y",step="Precommit",le="0.2682695795279726"} 29 tendermint_consensus_step_duration_bucket{chain_id="test-chain-IrF74Y",step="Precommit",le="0.7196856730011522"} 29 tendermint_consensus_step_duration_bucket{chain_id="test-chain-IrF74Y",step="Precommit",le="1.9306977288832508"} 29 tendermint_consensus_step_duration_bucket{chain_id="test-chain-IrF74Y",step="Precommit",le="5.1794746792312125"} 29 tendermint_consensus_step_duration_bucket{chain_id="test-chain-IrF74Y",step="Precommit",le="13.894954943731381"} 29 tendermint_consensus_step_duration_bucket{chain_id="test-chain-IrF74Y",step="Precommit",le="37.27593720314942"} 29 tendermint_consensus_step_duration_bucket{chain_id="test-chain-IrF74Y",step="Precommit",le="100.00000000000006"} 29 tendermint_consensus_step_duration_bucket{chain_id="test-chain-IrF74Y",step="Precommit",le="+Inf"} 29 tendermint_consensus_step_duration_sum{chain_id="test-chain-IrF74Y",step="Precommit"} 0.06414115999999999 tendermint_consensus_step_duration_count{chain_id="test-chain-IrF74Y",step="Precommit"} 29 tendermint_consensus_step_duration_bucket{chain_id="test-chain-IrF74Y",step="Prevote",le="0.1"} 29 tendermint_consensus_step_duration_bucket{chain_id="test-chain-IrF74Y",step="Prevote",le="0.2682695795279726"} 29 tendermint_consensus_step_duration_bucket{chain_id="test-chain-IrF74Y",step="Prevote",le="0.7196856730011522"} 29 tendermint_consensus_step_duration_bucket{chain_id="test-chain-IrF74Y",step="Prevote",le="1.9306977288832508"} 29 tendermint_consensus_step_duration_bucket{chain_id="test-chain-IrF74Y",step="Prevote",le="5.1794746792312125"} 29 tendermint_consensus_step_duration_bucket{chain_id="test-chain-IrF74Y",step="Prevote",le="13.894954943731381"} 29 tendermint_consensus_step_duration_bucket{chain_id="test-chain-IrF74Y",step="Prevote",le="37.27593720314942"} 29 tendermint_consensus_step_duration_bucket{chain_id="test-chain-IrF74Y",step="Prevote",le="100.00000000000006"} 29 tendermint_consensus_step_duration_bucket{chain_id="test-chain-IrF74Y",step="Prevote",le="+Inf"} 29 tendermint_consensus_step_duration_sum{chain_id="test-chain-IrF74Y",step="Prevote"} 0.177714525 tendermint_consensus_step_duration_count{chain_id="test-chain-IrF74Y",step="Prevote"} 29 tendermint_consensus_step_duration_bucket{chain_id="test-chain-IrF74Y",step="Propose",le="0.1"} 29 tendermint_consensus_step_duration_bucket{chain_id="test-chain-IrF74Y",step="Propose",le="0.2682695795279726"} 29 tendermint_consensus_step_duration_bucket{chain_id="test-chain-IrF74Y",step="Propose",le="0.7196856730011522"} 29 tendermint_consensus_step_duration_bucket{chain_id="test-chain-IrF74Y",step="Propose",le="1.9306977288832508"} 29 tendermint_consensus_step_duration_bucket{chain_id="test-chain-IrF74Y",step="Propose",le="5.1794746792312125"} 29 tendermint_consensus_step_duration_bucket{chain_id="test-chain-IrF74Y",step="Propose",le="13.894954943731381"} 29 tendermint_consensus_step_duration_bucket{chain_id="test-chain-IrF74Y",step="Propose",le="37.27593720314942"} 29 tendermint_consensus_step_duration_bucket{chain_id="test-chain-IrF74Y",step="Propose",le="100.00000000000006"} 29 tendermint_consensus_step_duration_bucket{chain_id="test-chain-IrF74Y",step="Propose",le="+Inf"} 29 tendermint_consensus_step_duration_sum{chain_id="test-chain-IrF74Y",step="Propose"} 0.221851927 tendermint_consensus_step_duration_count{chain_id="test-chain-IrF74Y",step="Propose"} 29 ``` ``` # HELP tendermint_consensus_block_gossip_receive_time Difference in seconds between when the validator learns of a new blockand when the validator receives the last piece of the block. # TYPE tendermint_consensus_block_gossip_receive_time histogram tendermint_consensus_block_gossip_receive_time_bucket{chain_id="test-chain-IrF74Y",le="0.1"} 29 tendermint_consensus_block_gossip_receive_time_bucket{chain_id="test-chain-IrF74Y",le="0.2682695795279726"} 29 tendermint_consensus_block_gossip_receive_time_bucket{chain_id="test-chain-IrF74Y",le="0.7196856730011522"} 29 tendermint_consensus_block_gossip_receive_time_bucket{chain_id="test-chain-IrF74Y",le="1.9306977288832508"} 29 tendermint_consensus_block_gossip_receive_time_bucket{chain_id="test-chain-IrF74Y",le="5.1794746792312125"} 29 tendermint_consensus_block_gossip_receive_time_bucket{chain_id="test-chain-IrF74Y",le="13.894954943731381"} 29 tendermint_consensus_block_gossip_receive_time_bucket{chain_id="test-chain-IrF74Y",le="37.27593720314942"} 29 tendermint_consensus_block_gossip_receive_time_bucket{chain_id="test-chain-IrF74Y",le="100.00000000000006"} 29 tendermint_consensus_block_gossip_receive_time_bucket{chain_id="test-chain-IrF74Y",le="+Inf"} 29 tendermint_consensus_block_gossip_receive_time_sum{chain_id="test-chain-IrF74Y"} 0.06380 ``` ``` # HELP tendermint_consensus_block_gossip_parts_received Number of block parts received by the node, labeled by whether thepart was relevant to the block the node was currently gathering or not # TYPE tendermint_consensus_block_gossip_parts_received counter tendermint_consensus_block_gossip_parts_received{chain_id="test-chain-IrF74Y",matches_current="true"} 29 ```
2 years ago
10 years ago
consensus: additional timing metrics (#7849) This change introduces an additional set of metrics aimed at helping operators understand the timing for consensus. This change adds the following metrics: ``` # HELP tendermint_consensus_round_duration Time spent in a round # TYPE tendermint_consensus_round_duration histogram tendermint_consensus_round_duration_bucket{chain_id="test-chain-IrF74Y",le="0.1"} 29 tendermint_consensus_round_duration_bucket{chain_id="test-chain-IrF74Y",le="0.2682695795279726"} 29 tendermint_consensus_round_duration_bucket{chain_id="test-chain-IrF74Y",le="0.7196856730011522"} 29 tendermint_consensus_round_duration_bucket{chain_id="test-chain-IrF74Y",le="1.9306977288832508"} 29 tendermint_consensus_round_duration_bucket{chain_id="test-chain-IrF74Y",le="5.1794746792312125"} 29 tendermint_consensus_round_duration_bucket{chain_id="test-chain-IrF74Y",le="13.894954943731381"} 29 tendermint_consensus_round_duration_bucket{chain_id="test-chain-IrF74Y",le="37.27593720314942"} 29 tendermint_consensus_round_duration_bucket{chain_id="test-chain-IrF74Y",le="100.00000000000006"} 29 tendermint_consensus_round_duration_bucket{chain_id="test-chain-IrF74Y",le="+Inf"} 29 tendermint_consensus_round_duration_sum{chain_id="test-chain-IrF74Y"} 0.028651869999999996 tendermint_consensus_round_duration_count{chain_id="test-chain-IrF74Y"} 29 ``` ``` # HELP tendermint_consensus_step_duration Time spent per step. # TYPE tendermint_consensus_step_duration histogram tendermint_consensus_step_duration_bucket{chain_id="test-chain-IrF74Y",step="Commit",le="0.1"} 29 tendermint_consensus_step_duration_bucket{chain_id="test-chain-IrF74Y",step="Commit",le="0.2682695795279726"} 29 tendermint_consensus_step_duration_bucket{chain_id="test-chain-IrF74Y",step="Commit",le="0.7196856730011522"} 29 tendermint_consensus_step_duration_bucket{chain_id="test-chain-IrF74Y",step="Commit",le="1.9306977288832508"} 29 tendermint_consensus_step_duration_bucket{chain_id="test-chain-IrF74Y",step="Commit",le="5.1794746792312125"} 29 tendermint_consensus_step_duration_bucket{chain_id="test-chain-IrF74Y",step="Commit",le="13.894954943731381"} 29 tendermint_consensus_step_duration_bucket{chain_id="test-chain-IrF74Y",step="Commit",le="37.27593720314942"} 29 tendermint_consensus_step_duration_bucket{chain_id="test-chain-IrF74Y",step="Commit",le="100.00000000000006"} 29 tendermint_consensus_step_duration_bucket{chain_id="test-chain-IrF74Y",step="Commit",le="+Inf"} 29 tendermint_consensus_step_duration_sum{chain_id="test-chain-IrF74Y",step="Commit"} 0.26650875 tendermint_consensus_step_duration_count{chain_id="test-chain-IrF74Y",step="Commit"} 29 tendermint_consensus_step_duration_bucket{chain_id="test-chain-IrF74Y",step="NewHeight",le="0.1"} 0 tendermint_consensus_step_duration_bucket{chain_id="test-chain-IrF74Y",step="NewHeight",le="0.2682695795279726"} 0 tendermint_consensus_step_duration_bucket{chain_id="test-chain-IrF74Y",step="NewHeight",le="0.7196856730011522"} 0 tendermint_consensus_step_duration_bucket{chain_id="test-chain-IrF74Y",step="NewHeight",le="1.9306977288832508"} 28 tendermint_consensus_step_duration_bucket{chain_id="test-chain-IrF74Y",step="NewHeight",le="5.1794746792312125"} 28 tendermint_consensus_step_duration_bucket{chain_id="test-chain-IrF74Y",step="NewHeight",le="13.894954943731381"} 28 tendermint_consensus_step_duration_bucket{chain_id="test-chain-IrF74Y",step="NewHeight",le="37.27593720314942"} 28 tendermint_consensus_step_duration_bucket{chain_id="test-chain-IrF74Y",step="NewHeight",le="100.00000000000006"} 28 tendermint_consensus_step_duration_bucket{chain_id="test-chain-IrF74Y",step="NewHeight",le="+Inf"} 28 tendermint_consensus_step_duration_sum{chain_id="test-chain-IrF74Y",step="NewHeight"} 27.773921702 tendermint_consensus_step_duration_count{chain_id="test-chain-IrF74Y",step="NewHeight"} 28 tendermint_consensus_step_duration_bucket{chain_id="test-chain-IrF74Y",step="NewRound",le="0.1"} 29 tendermint_consensus_step_duration_bucket{chain_id="test-chain-IrF74Y",step="NewRound",le="0.2682695795279726"} 29 tendermint_consensus_step_duration_bucket{chain_id="test-chain-IrF74Y",step="NewRound",le="0.7196856730011522"} 29 tendermint_consensus_step_duration_bucket{chain_id="test-chain-IrF74Y",step="NewRound",le="1.9306977288832508"} 29 tendermint_consensus_step_duration_bucket{chain_id="test-chain-IrF74Y",step="NewRound",le="5.1794746792312125"} 29 tendermint_consensus_step_duration_bucket{chain_id="test-chain-IrF74Y",step="NewRound",le="13.894954943731381"} 29 tendermint_consensus_step_duration_bucket{chain_id="test-chain-IrF74Y",step="NewRound",le="37.27593720314942"} 29 tendermint_consensus_step_duration_bucket{chain_id="test-chain-IrF74Y",step="NewRound",le="100.00000000000006"} 29 tendermint_consensus_step_duration_bucket{chain_id="test-chain-IrF74Y",step="NewRound",le="+Inf"} 29 tendermint_consensus_step_duration_sum{chain_id="test-chain-IrF74Y",step="NewRound"} 0.168961052 tendermint_consensus_step_duration_count{chain_id="test-chain-IrF74Y",step="NewRound"} 29 tendermint_consensus_step_duration_bucket{chain_id="test-chain-IrF74Y",step="Precommit",le="0.1"} 29 tendermint_consensus_step_duration_bucket{chain_id="test-chain-IrF74Y",step="Precommit",le="0.2682695795279726"} 29 tendermint_consensus_step_duration_bucket{chain_id="test-chain-IrF74Y",step="Precommit",le="0.7196856730011522"} 29 tendermint_consensus_step_duration_bucket{chain_id="test-chain-IrF74Y",step="Precommit",le="1.9306977288832508"} 29 tendermint_consensus_step_duration_bucket{chain_id="test-chain-IrF74Y",step="Precommit",le="5.1794746792312125"} 29 tendermint_consensus_step_duration_bucket{chain_id="test-chain-IrF74Y",step="Precommit",le="13.894954943731381"} 29 tendermint_consensus_step_duration_bucket{chain_id="test-chain-IrF74Y",step="Precommit",le="37.27593720314942"} 29 tendermint_consensus_step_duration_bucket{chain_id="test-chain-IrF74Y",step="Precommit",le="100.00000000000006"} 29 tendermint_consensus_step_duration_bucket{chain_id="test-chain-IrF74Y",step="Precommit",le="+Inf"} 29 tendermint_consensus_step_duration_sum{chain_id="test-chain-IrF74Y",step="Precommit"} 0.06414115999999999 tendermint_consensus_step_duration_count{chain_id="test-chain-IrF74Y",step="Precommit"} 29 tendermint_consensus_step_duration_bucket{chain_id="test-chain-IrF74Y",step="Prevote",le="0.1"} 29 tendermint_consensus_step_duration_bucket{chain_id="test-chain-IrF74Y",step="Prevote",le="0.2682695795279726"} 29 tendermint_consensus_step_duration_bucket{chain_id="test-chain-IrF74Y",step="Prevote",le="0.7196856730011522"} 29 tendermint_consensus_step_duration_bucket{chain_id="test-chain-IrF74Y",step="Prevote",le="1.9306977288832508"} 29 tendermint_consensus_step_duration_bucket{chain_id="test-chain-IrF74Y",step="Prevote",le="5.1794746792312125"} 29 tendermint_consensus_step_duration_bucket{chain_id="test-chain-IrF74Y",step="Prevote",le="13.894954943731381"} 29 tendermint_consensus_step_duration_bucket{chain_id="test-chain-IrF74Y",step="Prevote",le="37.27593720314942"} 29 tendermint_consensus_step_duration_bucket{chain_id="test-chain-IrF74Y",step="Prevote",le="100.00000000000006"} 29 tendermint_consensus_step_duration_bucket{chain_id="test-chain-IrF74Y",step="Prevote",le="+Inf"} 29 tendermint_consensus_step_duration_sum{chain_id="test-chain-IrF74Y",step="Prevote"} 0.177714525 tendermint_consensus_step_duration_count{chain_id="test-chain-IrF74Y",step="Prevote"} 29 tendermint_consensus_step_duration_bucket{chain_id="test-chain-IrF74Y",step="Propose",le="0.1"} 29 tendermint_consensus_step_duration_bucket{chain_id="test-chain-IrF74Y",step="Propose",le="0.2682695795279726"} 29 tendermint_consensus_step_duration_bucket{chain_id="test-chain-IrF74Y",step="Propose",le="0.7196856730011522"} 29 tendermint_consensus_step_duration_bucket{chain_id="test-chain-IrF74Y",step="Propose",le="1.9306977288832508"} 29 tendermint_consensus_step_duration_bucket{chain_id="test-chain-IrF74Y",step="Propose",le="5.1794746792312125"} 29 tendermint_consensus_step_duration_bucket{chain_id="test-chain-IrF74Y",step="Propose",le="13.894954943731381"} 29 tendermint_consensus_step_duration_bucket{chain_id="test-chain-IrF74Y",step="Propose",le="37.27593720314942"} 29 tendermint_consensus_step_duration_bucket{chain_id="test-chain-IrF74Y",step="Propose",le="100.00000000000006"} 29 tendermint_consensus_step_duration_bucket{chain_id="test-chain-IrF74Y",step="Propose",le="+Inf"} 29 tendermint_consensus_step_duration_sum{chain_id="test-chain-IrF74Y",step="Propose"} 0.221851927 tendermint_consensus_step_duration_count{chain_id="test-chain-IrF74Y",step="Propose"} 29 ``` ``` # HELP tendermint_consensus_block_gossip_receive_time Difference in seconds between when the validator learns of a new blockand when the validator receives the last piece of the block. # TYPE tendermint_consensus_block_gossip_receive_time histogram tendermint_consensus_block_gossip_receive_time_bucket{chain_id="test-chain-IrF74Y",le="0.1"} 29 tendermint_consensus_block_gossip_receive_time_bucket{chain_id="test-chain-IrF74Y",le="0.2682695795279726"} 29 tendermint_consensus_block_gossip_receive_time_bucket{chain_id="test-chain-IrF74Y",le="0.7196856730011522"} 29 tendermint_consensus_block_gossip_receive_time_bucket{chain_id="test-chain-IrF74Y",le="1.9306977288832508"} 29 tendermint_consensus_block_gossip_receive_time_bucket{chain_id="test-chain-IrF74Y",le="5.1794746792312125"} 29 tendermint_consensus_block_gossip_receive_time_bucket{chain_id="test-chain-IrF74Y",le="13.894954943731381"} 29 tendermint_consensus_block_gossip_receive_time_bucket{chain_id="test-chain-IrF74Y",le="37.27593720314942"} 29 tendermint_consensus_block_gossip_receive_time_bucket{chain_id="test-chain-IrF74Y",le="100.00000000000006"} 29 tendermint_consensus_block_gossip_receive_time_bucket{chain_id="test-chain-IrF74Y",le="+Inf"} 29 tendermint_consensus_block_gossip_receive_time_sum{chain_id="test-chain-IrF74Y"} 0.06380 ``` ``` # HELP tendermint_consensus_block_gossip_parts_received Number of block parts received by the node, labeled by whether thepart was relevant to the block the node was currently gathering or not # TYPE tendermint_consensus_block_gossip_parts_received counter tendermint_consensus_block_gossip_parts_received{chain_id="test-chain-IrF74Y",matches_current="true"} 29 ```
2 years ago
consensus: additional timing metrics (#7849) This change introduces an additional set of metrics aimed at helping operators understand the timing for consensus. This change adds the following metrics: ``` # HELP tendermint_consensus_round_duration Time spent in a round # TYPE tendermint_consensus_round_duration histogram tendermint_consensus_round_duration_bucket{chain_id="test-chain-IrF74Y",le="0.1"} 29 tendermint_consensus_round_duration_bucket{chain_id="test-chain-IrF74Y",le="0.2682695795279726"} 29 tendermint_consensus_round_duration_bucket{chain_id="test-chain-IrF74Y",le="0.7196856730011522"} 29 tendermint_consensus_round_duration_bucket{chain_id="test-chain-IrF74Y",le="1.9306977288832508"} 29 tendermint_consensus_round_duration_bucket{chain_id="test-chain-IrF74Y",le="5.1794746792312125"} 29 tendermint_consensus_round_duration_bucket{chain_id="test-chain-IrF74Y",le="13.894954943731381"} 29 tendermint_consensus_round_duration_bucket{chain_id="test-chain-IrF74Y",le="37.27593720314942"} 29 tendermint_consensus_round_duration_bucket{chain_id="test-chain-IrF74Y",le="100.00000000000006"} 29 tendermint_consensus_round_duration_bucket{chain_id="test-chain-IrF74Y",le="+Inf"} 29 tendermint_consensus_round_duration_sum{chain_id="test-chain-IrF74Y"} 0.028651869999999996 tendermint_consensus_round_duration_count{chain_id="test-chain-IrF74Y"} 29 ``` ``` # HELP tendermint_consensus_step_duration Time spent per step. # TYPE tendermint_consensus_step_duration histogram tendermint_consensus_step_duration_bucket{chain_id="test-chain-IrF74Y",step="Commit",le="0.1"} 29 tendermint_consensus_step_duration_bucket{chain_id="test-chain-IrF74Y",step="Commit",le="0.2682695795279726"} 29 tendermint_consensus_step_duration_bucket{chain_id="test-chain-IrF74Y",step="Commit",le="0.7196856730011522"} 29 tendermint_consensus_step_duration_bucket{chain_id="test-chain-IrF74Y",step="Commit",le="1.9306977288832508"} 29 tendermint_consensus_step_duration_bucket{chain_id="test-chain-IrF74Y",step="Commit",le="5.1794746792312125"} 29 tendermint_consensus_step_duration_bucket{chain_id="test-chain-IrF74Y",step="Commit",le="13.894954943731381"} 29 tendermint_consensus_step_duration_bucket{chain_id="test-chain-IrF74Y",step="Commit",le="37.27593720314942"} 29 tendermint_consensus_step_duration_bucket{chain_id="test-chain-IrF74Y",step="Commit",le="100.00000000000006"} 29 tendermint_consensus_step_duration_bucket{chain_id="test-chain-IrF74Y",step="Commit",le="+Inf"} 29 tendermint_consensus_step_duration_sum{chain_id="test-chain-IrF74Y",step="Commit"} 0.26650875 tendermint_consensus_step_duration_count{chain_id="test-chain-IrF74Y",step="Commit"} 29 tendermint_consensus_step_duration_bucket{chain_id="test-chain-IrF74Y",step="NewHeight",le="0.1"} 0 tendermint_consensus_step_duration_bucket{chain_id="test-chain-IrF74Y",step="NewHeight",le="0.2682695795279726"} 0 tendermint_consensus_step_duration_bucket{chain_id="test-chain-IrF74Y",step="NewHeight",le="0.7196856730011522"} 0 tendermint_consensus_step_duration_bucket{chain_id="test-chain-IrF74Y",step="NewHeight",le="1.9306977288832508"} 28 tendermint_consensus_step_duration_bucket{chain_id="test-chain-IrF74Y",step="NewHeight",le="5.1794746792312125"} 28 tendermint_consensus_step_duration_bucket{chain_id="test-chain-IrF74Y",step="NewHeight",le="13.894954943731381"} 28 tendermint_consensus_step_duration_bucket{chain_id="test-chain-IrF74Y",step="NewHeight",le="37.27593720314942"} 28 tendermint_consensus_step_duration_bucket{chain_id="test-chain-IrF74Y",step="NewHeight",le="100.00000000000006"} 28 tendermint_consensus_step_duration_bucket{chain_id="test-chain-IrF74Y",step="NewHeight",le="+Inf"} 28 tendermint_consensus_step_duration_sum{chain_id="test-chain-IrF74Y",step="NewHeight"} 27.773921702 tendermint_consensus_step_duration_count{chain_id="test-chain-IrF74Y",step="NewHeight"} 28 tendermint_consensus_step_duration_bucket{chain_id="test-chain-IrF74Y",step="NewRound",le="0.1"} 29 tendermint_consensus_step_duration_bucket{chain_id="test-chain-IrF74Y",step="NewRound",le="0.2682695795279726"} 29 tendermint_consensus_step_duration_bucket{chain_id="test-chain-IrF74Y",step="NewRound",le="0.7196856730011522"} 29 tendermint_consensus_step_duration_bucket{chain_id="test-chain-IrF74Y",step="NewRound",le="1.9306977288832508"} 29 tendermint_consensus_step_duration_bucket{chain_id="test-chain-IrF74Y",step="NewRound",le="5.1794746792312125"} 29 tendermint_consensus_step_duration_bucket{chain_id="test-chain-IrF74Y",step="NewRound",le="13.894954943731381"} 29 tendermint_consensus_step_duration_bucket{chain_id="test-chain-IrF74Y",step="NewRound",le="37.27593720314942"} 29 tendermint_consensus_step_duration_bucket{chain_id="test-chain-IrF74Y",step="NewRound",le="100.00000000000006"} 29 tendermint_consensus_step_duration_bucket{chain_id="test-chain-IrF74Y",step="NewRound",le="+Inf"} 29 tendermint_consensus_step_duration_sum{chain_id="test-chain-IrF74Y",step="NewRound"} 0.168961052 tendermint_consensus_step_duration_count{chain_id="test-chain-IrF74Y",step="NewRound"} 29 tendermint_consensus_step_duration_bucket{chain_id="test-chain-IrF74Y",step="Precommit",le="0.1"} 29 tendermint_consensus_step_duration_bucket{chain_id="test-chain-IrF74Y",step="Precommit",le="0.2682695795279726"} 29 tendermint_consensus_step_duration_bucket{chain_id="test-chain-IrF74Y",step="Precommit",le="0.7196856730011522"} 29 tendermint_consensus_step_duration_bucket{chain_id="test-chain-IrF74Y",step="Precommit",le="1.9306977288832508"} 29 tendermint_consensus_step_duration_bucket{chain_id="test-chain-IrF74Y",step="Precommit",le="5.1794746792312125"} 29 tendermint_consensus_step_duration_bucket{chain_id="test-chain-IrF74Y",step="Precommit",le="13.894954943731381"} 29 tendermint_consensus_step_duration_bucket{chain_id="test-chain-IrF74Y",step="Precommit",le="37.27593720314942"} 29 tendermint_consensus_step_duration_bucket{chain_id="test-chain-IrF74Y",step="Precommit",le="100.00000000000006"} 29 tendermint_consensus_step_duration_bucket{chain_id="test-chain-IrF74Y",step="Precommit",le="+Inf"} 29 tendermint_consensus_step_duration_sum{chain_id="test-chain-IrF74Y",step="Precommit"} 0.06414115999999999 tendermint_consensus_step_duration_count{chain_id="test-chain-IrF74Y",step="Precommit"} 29 tendermint_consensus_step_duration_bucket{chain_id="test-chain-IrF74Y",step="Prevote",le="0.1"} 29 tendermint_consensus_step_duration_bucket{chain_id="test-chain-IrF74Y",step="Prevote",le="0.2682695795279726"} 29 tendermint_consensus_step_duration_bucket{chain_id="test-chain-IrF74Y",step="Prevote",le="0.7196856730011522"} 29 tendermint_consensus_step_duration_bucket{chain_id="test-chain-IrF74Y",step="Prevote",le="1.9306977288832508"} 29 tendermint_consensus_step_duration_bucket{chain_id="test-chain-IrF74Y",step="Prevote",le="5.1794746792312125"} 29 tendermint_consensus_step_duration_bucket{chain_id="test-chain-IrF74Y",step="Prevote",le="13.894954943731381"} 29 tendermint_consensus_step_duration_bucket{chain_id="test-chain-IrF74Y",step="Prevote",le="37.27593720314942"} 29 tendermint_consensus_step_duration_bucket{chain_id="test-chain-IrF74Y",step="Prevote",le="100.00000000000006"} 29 tendermint_consensus_step_duration_bucket{chain_id="test-chain-IrF74Y",step="Prevote",le="+Inf"} 29 tendermint_consensus_step_duration_sum{chain_id="test-chain-IrF74Y",step="Prevote"} 0.177714525 tendermint_consensus_step_duration_count{chain_id="test-chain-IrF74Y",step="Prevote"} 29 tendermint_consensus_step_duration_bucket{chain_id="test-chain-IrF74Y",step="Propose",le="0.1"} 29 tendermint_consensus_step_duration_bucket{chain_id="test-chain-IrF74Y",step="Propose",le="0.2682695795279726"} 29 tendermint_consensus_step_duration_bucket{chain_id="test-chain-IrF74Y",step="Propose",le="0.7196856730011522"} 29 tendermint_consensus_step_duration_bucket{chain_id="test-chain-IrF74Y",step="Propose",le="1.9306977288832508"} 29 tendermint_consensus_step_duration_bucket{chain_id="test-chain-IrF74Y",step="Propose",le="5.1794746792312125"} 29 tendermint_consensus_step_duration_bucket{chain_id="test-chain-IrF74Y",step="Propose",le="13.894954943731381"} 29 tendermint_consensus_step_duration_bucket{chain_id="test-chain-IrF74Y",step="Propose",le="37.27593720314942"} 29 tendermint_consensus_step_duration_bucket{chain_id="test-chain-IrF74Y",step="Propose",le="100.00000000000006"} 29 tendermint_consensus_step_duration_bucket{chain_id="test-chain-IrF74Y",step="Propose",le="+Inf"} 29 tendermint_consensus_step_duration_sum{chain_id="test-chain-IrF74Y",step="Propose"} 0.221851927 tendermint_consensus_step_duration_count{chain_id="test-chain-IrF74Y",step="Propose"} 29 ``` ``` # HELP tendermint_consensus_block_gossip_receive_time Difference in seconds between when the validator learns of a new blockand when the validator receives the last piece of the block. # TYPE tendermint_consensus_block_gossip_receive_time histogram tendermint_consensus_block_gossip_receive_time_bucket{chain_id="test-chain-IrF74Y",le="0.1"} 29 tendermint_consensus_block_gossip_receive_time_bucket{chain_id="test-chain-IrF74Y",le="0.2682695795279726"} 29 tendermint_consensus_block_gossip_receive_time_bucket{chain_id="test-chain-IrF74Y",le="0.7196856730011522"} 29 tendermint_consensus_block_gossip_receive_time_bucket{chain_id="test-chain-IrF74Y",le="1.9306977288832508"} 29 tendermint_consensus_block_gossip_receive_time_bucket{chain_id="test-chain-IrF74Y",le="5.1794746792312125"} 29 tendermint_consensus_block_gossip_receive_time_bucket{chain_id="test-chain-IrF74Y",le="13.894954943731381"} 29 tendermint_consensus_block_gossip_receive_time_bucket{chain_id="test-chain-IrF74Y",le="37.27593720314942"} 29 tendermint_consensus_block_gossip_receive_time_bucket{chain_id="test-chain-IrF74Y",le="100.00000000000006"} 29 tendermint_consensus_block_gossip_receive_time_bucket{chain_id="test-chain-IrF74Y",le="+Inf"} 29 tendermint_consensus_block_gossip_receive_time_sum{chain_id="test-chain-IrF74Y"} 0.06380 ``` ``` # HELP tendermint_consensus_block_gossip_parts_received Number of block parts received by the node, labeled by whether thepart was relevant to the block the node was currently gathering or not # TYPE tendermint_consensus_block_gossip_parts_received counter tendermint_consensus_block_gossip_parts_received{chain_id="test-chain-IrF74Y",matches_current="true"} 29 ```
2 years ago
consensus: additional timing metrics (#7849) This change introduces an additional set of metrics aimed at helping operators understand the timing for consensus. This change adds the following metrics: ``` # HELP tendermint_consensus_round_duration Time spent in a round # TYPE tendermint_consensus_round_duration histogram tendermint_consensus_round_duration_bucket{chain_id="test-chain-IrF74Y",le="0.1"} 29 tendermint_consensus_round_duration_bucket{chain_id="test-chain-IrF74Y",le="0.2682695795279726"} 29 tendermint_consensus_round_duration_bucket{chain_id="test-chain-IrF74Y",le="0.7196856730011522"} 29 tendermint_consensus_round_duration_bucket{chain_id="test-chain-IrF74Y",le="1.9306977288832508"} 29 tendermint_consensus_round_duration_bucket{chain_id="test-chain-IrF74Y",le="5.1794746792312125"} 29 tendermint_consensus_round_duration_bucket{chain_id="test-chain-IrF74Y",le="13.894954943731381"} 29 tendermint_consensus_round_duration_bucket{chain_id="test-chain-IrF74Y",le="37.27593720314942"} 29 tendermint_consensus_round_duration_bucket{chain_id="test-chain-IrF74Y",le="100.00000000000006"} 29 tendermint_consensus_round_duration_bucket{chain_id="test-chain-IrF74Y",le="+Inf"} 29 tendermint_consensus_round_duration_sum{chain_id="test-chain-IrF74Y"} 0.028651869999999996 tendermint_consensus_round_duration_count{chain_id="test-chain-IrF74Y"} 29 ``` ``` # HELP tendermint_consensus_step_duration Time spent per step. # TYPE tendermint_consensus_step_duration histogram tendermint_consensus_step_duration_bucket{chain_id="test-chain-IrF74Y",step="Commit",le="0.1"} 29 tendermint_consensus_step_duration_bucket{chain_id="test-chain-IrF74Y",step="Commit",le="0.2682695795279726"} 29 tendermint_consensus_step_duration_bucket{chain_id="test-chain-IrF74Y",step="Commit",le="0.7196856730011522"} 29 tendermint_consensus_step_duration_bucket{chain_id="test-chain-IrF74Y",step="Commit",le="1.9306977288832508"} 29 tendermint_consensus_step_duration_bucket{chain_id="test-chain-IrF74Y",step="Commit",le="5.1794746792312125"} 29 tendermint_consensus_step_duration_bucket{chain_id="test-chain-IrF74Y",step="Commit",le="13.894954943731381"} 29 tendermint_consensus_step_duration_bucket{chain_id="test-chain-IrF74Y",step="Commit",le="37.27593720314942"} 29 tendermint_consensus_step_duration_bucket{chain_id="test-chain-IrF74Y",step="Commit",le="100.00000000000006"} 29 tendermint_consensus_step_duration_bucket{chain_id="test-chain-IrF74Y",step="Commit",le="+Inf"} 29 tendermint_consensus_step_duration_sum{chain_id="test-chain-IrF74Y",step="Commit"} 0.26650875 tendermint_consensus_step_duration_count{chain_id="test-chain-IrF74Y",step="Commit"} 29 tendermint_consensus_step_duration_bucket{chain_id="test-chain-IrF74Y",step="NewHeight",le="0.1"} 0 tendermint_consensus_step_duration_bucket{chain_id="test-chain-IrF74Y",step="NewHeight",le="0.2682695795279726"} 0 tendermint_consensus_step_duration_bucket{chain_id="test-chain-IrF74Y",step="NewHeight",le="0.7196856730011522"} 0 tendermint_consensus_step_duration_bucket{chain_id="test-chain-IrF74Y",step="NewHeight",le="1.9306977288832508"} 28 tendermint_consensus_step_duration_bucket{chain_id="test-chain-IrF74Y",step="NewHeight",le="5.1794746792312125"} 28 tendermint_consensus_step_duration_bucket{chain_id="test-chain-IrF74Y",step="NewHeight",le="13.894954943731381"} 28 tendermint_consensus_step_duration_bucket{chain_id="test-chain-IrF74Y",step="NewHeight",le="37.27593720314942"} 28 tendermint_consensus_step_duration_bucket{chain_id="test-chain-IrF74Y",step="NewHeight",le="100.00000000000006"} 28 tendermint_consensus_step_duration_bucket{chain_id="test-chain-IrF74Y",step="NewHeight",le="+Inf"} 28 tendermint_consensus_step_duration_sum{chain_id="test-chain-IrF74Y",step="NewHeight"} 27.773921702 tendermint_consensus_step_duration_count{chain_id="test-chain-IrF74Y",step="NewHeight"} 28 tendermint_consensus_step_duration_bucket{chain_id="test-chain-IrF74Y",step="NewRound",le="0.1"} 29 tendermint_consensus_step_duration_bucket{chain_id="test-chain-IrF74Y",step="NewRound",le="0.2682695795279726"} 29 tendermint_consensus_step_duration_bucket{chain_id="test-chain-IrF74Y",step="NewRound",le="0.7196856730011522"} 29 tendermint_consensus_step_duration_bucket{chain_id="test-chain-IrF74Y",step="NewRound",le="1.9306977288832508"} 29 tendermint_consensus_step_duration_bucket{chain_id="test-chain-IrF74Y",step="NewRound",le="5.1794746792312125"} 29 tendermint_consensus_step_duration_bucket{chain_id="test-chain-IrF74Y",step="NewRound",le="13.894954943731381"} 29 tendermint_consensus_step_duration_bucket{chain_id="test-chain-IrF74Y",step="NewRound",le="37.27593720314942"} 29 tendermint_consensus_step_duration_bucket{chain_id="test-chain-IrF74Y",step="NewRound",le="100.00000000000006"} 29 tendermint_consensus_step_duration_bucket{chain_id="test-chain-IrF74Y",step="NewRound",le="+Inf"} 29 tendermint_consensus_step_duration_sum{chain_id="test-chain-IrF74Y",step="NewRound"} 0.168961052 tendermint_consensus_step_duration_count{chain_id="test-chain-IrF74Y",step="NewRound"} 29 tendermint_consensus_step_duration_bucket{chain_id="test-chain-IrF74Y",step="Precommit",le="0.1"} 29 tendermint_consensus_step_duration_bucket{chain_id="test-chain-IrF74Y",step="Precommit",le="0.2682695795279726"} 29 tendermint_consensus_step_duration_bucket{chain_id="test-chain-IrF74Y",step="Precommit",le="0.7196856730011522"} 29 tendermint_consensus_step_duration_bucket{chain_id="test-chain-IrF74Y",step="Precommit",le="1.9306977288832508"} 29 tendermint_consensus_step_duration_bucket{chain_id="test-chain-IrF74Y",step="Precommit",le="5.1794746792312125"} 29 tendermint_consensus_step_duration_bucket{chain_id="test-chain-IrF74Y",step="Precommit",le="13.894954943731381"} 29 tendermint_consensus_step_duration_bucket{chain_id="test-chain-IrF74Y",step="Precommit",le="37.27593720314942"} 29 tendermint_consensus_step_duration_bucket{chain_id="test-chain-IrF74Y",step="Precommit",le="100.00000000000006"} 29 tendermint_consensus_step_duration_bucket{chain_id="test-chain-IrF74Y",step="Precommit",le="+Inf"} 29 tendermint_consensus_step_duration_sum{chain_id="test-chain-IrF74Y",step="Precommit"} 0.06414115999999999 tendermint_consensus_step_duration_count{chain_id="test-chain-IrF74Y",step="Precommit"} 29 tendermint_consensus_step_duration_bucket{chain_id="test-chain-IrF74Y",step="Prevote",le="0.1"} 29 tendermint_consensus_step_duration_bucket{chain_id="test-chain-IrF74Y",step="Prevote",le="0.2682695795279726"} 29 tendermint_consensus_step_duration_bucket{chain_id="test-chain-IrF74Y",step="Prevote",le="0.7196856730011522"} 29 tendermint_consensus_step_duration_bucket{chain_id="test-chain-IrF74Y",step="Prevote",le="1.9306977288832508"} 29 tendermint_consensus_step_duration_bucket{chain_id="test-chain-IrF74Y",step="Prevote",le="5.1794746792312125"} 29 tendermint_consensus_step_duration_bucket{chain_id="test-chain-IrF74Y",step="Prevote",le="13.894954943731381"} 29 tendermint_consensus_step_duration_bucket{chain_id="test-chain-IrF74Y",step="Prevote",le="37.27593720314942"} 29 tendermint_consensus_step_duration_bucket{chain_id="test-chain-IrF74Y",step="Prevote",le="100.00000000000006"} 29 tendermint_consensus_step_duration_bucket{chain_id="test-chain-IrF74Y",step="Prevote",le="+Inf"} 29 tendermint_consensus_step_duration_sum{chain_id="test-chain-IrF74Y",step="Prevote"} 0.177714525 tendermint_consensus_step_duration_count{chain_id="test-chain-IrF74Y",step="Prevote"} 29 tendermint_consensus_step_duration_bucket{chain_id="test-chain-IrF74Y",step="Propose",le="0.1"} 29 tendermint_consensus_step_duration_bucket{chain_id="test-chain-IrF74Y",step="Propose",le="0.2682695795279726"} 29 tendermint_consensus_step_duration_bucket{chain_id="test-chain-IrF74Y",step="Propose",le="0.7196856730011522"} 29 tendermint_consensus_step_duration_bucket{chain_id="test-chain-IrF74Y",step="Propose",le="1.9306977288832508"} 29 tendermint_consensus_step_duration_bucket{chain_id="test-chain-IrF74Y",step="Propose",le="5.1794746792312125"} 29 tendermint_consensus_step_duration_bucket{chain_id="test-chain-IrF74Y",step="Propose",le="13.894954943731381"} 29 tendermint_consensus_step_duration_bucket{chain_id="test-chain-IrF74Y",step="Propose",le="37.27593720314942"} 29 tendermint_consensus_step_duration_bucket{chain_id="test-chain-IrF74Y",step="Propose",le="100.00000000000006"} 29 tendermint_consensus_step_duration_bucket{chain_id="test-chain-IrF74Y",step="Propose",le="+Inf"} 29 tendermint_consensus_step_duration_sum{chain_id="test-chain-IrF74Y",step="Propose"} 0.221851927 tendermint_consensus_step_duration_count{chain_id="test-chain-IrF74Y",step="Propose"} 29 ``` ``` # HELP tendermint_consensus_block_gossip_receive_time Difference in seconds between when the validator learns of a new blockand when the validator receives the last piece of the block. # TYPE tendermint_consensus_block_gossip_receive_time histogram tendermint_consensus_block_gossip_receive_time_bucket{chain_id="test-chain-IrF74Y",le="0.1"} 29 tendermint_consensus_block_gossip_receive_time_bucket{chain_id="test-chain-IrF74Y",le="0.2682695795279726"} 29 tendermint_consensus_block_gossip_receive_time_bucket{chain_id="test-chain-IrF74Y",le="0.7196856730011522"} 29 tendermint_consensus_block_gossip_receive_time_bucket{chain_id="test-chain-IrF74Y",le="1.9306977288832508"} 29 tendermint_consensus_block_gossip_receive_time_bucket{chain_id="test-chain-IrF74Y",le="5.1794746792312125"} 29 tendermint_consensus_block_gossip_receive_time_bucket{chain_id="test-chain-IrF74Y",le="13.894954943731381"} 29 tendermint_consensus_block_gossip_receive_time_bucket{chain_id="test-chain-IrF74Y",le="37.27593720314942"} 29 tendermint_consensus_block_gossip_receive_time_bucket{chain_id="test-chain-IrF74Y",le="100.00000000000006"} 29 tendermint_consensus_block_gossip_receive_time_bucket{chain_id="test-chain-IrF74Y",le="+Inf"} 29 tendermint_consensus_block_gossip_receive_time_sum{chain_id="test-chain-IrF74Y"} 0.06380 ``` ``` # HELP tendermint_consensus_block_gossip_parts_received Number of block parts received by the node, labeled by whether thepart was relevant to the block the node was currently gathering or not # TYPE tendermint_consensus_block_gossip_parts_received counter tendermint_consensus_block_gossip_parts_received{chain_id="test-chain-IrF74Y",matches_current="true"} 29 ```
2 years ago
consensus: additional timing metrics (#7849) This change introduces an additional set of metrics aimed at helping operators understand the timing for consensus. This change adds the following metrics: ``` # HELP tendermint_consensus_round_duration Time spent in a round # TYPE tendermint_consensus_round_duration histogram tendermint_consensus_round_duration_bucket{chain_id="test-chain-IrF74Y",le="0.1"} 29 tendermint_consensus_round_duration_bucket{chain_id="test-chain-IrF74Y",le="0.2682695795279726"} 29 tendermint_consensus_round_duration_bucket{chain_id="test-chain-IrF74Y",le="0.7196856730011522"} 29 tendermint_consensus_round_duration_bucket{chain_id="test-chain-IrF74Y",le="1.9306977288832508"} 29 tendermint_consensus_round_duration_bucket{chain_id="test-chain-IrF74Y",le="5.1794746792312125"} 29 tendermint_consensus_round_duration_bucket{chain_id="test-chain-IrF74Y",le="13.894954943731381"} 29 tendermint_consensus_round_duration_bucket{chain_id="test-chain-IrF74Y",le="37.27593720314942"} 29 tendermint_consensus_round_duration_bucket{chain_id="test-chain-IrF74Y",le="100.00000000000006"} 29 tendermint_consensus_round_duration_bucket{chain_id="test-chain-IrF74Y",le="+Inf"} 29 tendermint_consensus_round_duration_sum{chain_id="test-chain-IrF74Y"} 0.028651869999999996 tendermint_consensus_round_duration_count{chain_id="test-chain-IrF74Y"} 29 ``` ``` # HELP tendermint_consensus_step_duration Time spent per step. # TYPE tendermint_consensus_step_duration histogram tendermint_consensus_step_duration_bucket{chain_id="test-chain-IrF74Y",step="Commit",le="0.1"} 29 tendermint_consensus_step_duration_bucket{chain_id="test-chain-IrF74Y",step="Commit",le="0.2682695795279726"} 29 tendermint_consensus_step_duration_bucket{chain_id="test-chain-IrF74Y",step="Commit",le="0.7196856730011522"} 29 tendermint_consensus_step_duration_bucket{chain_id="test-chain-IrF74Y",step="Commit",le="1.9306977288832508"} 29 tendermint_consensus_step_duration_bucket{chain_id="test-chain-IrF74Y",step="Commit",le="5.1794746792312125"} 29 tendermint_consensus_step_duration_bucket{chain_id="test-chain-IrF74Y",step="Commit",le="13.894954943731381"} 29 tendermint_consensus_step_duration_bucket{chain_id="test-chain-IrF74Y",step="Commit",le="37.27593720314942"} 29 tendermint_consensus_step_duration_bucket{chain_id="test-chain-IrF74Y",step="Commit",le="100.00000000000006"} 29 tendermint_consensus_step_duration_bucket{chain_id="test-chain-IrF74Y",step="Commit",le="+Inf"} 29 tendermint_consensus_step_duration_sum{chain_id="test-chain-IrF74Y",step="Commit"} 0.26650875 tendermint_consensus_step_duration_count{chain_id="test-chain-IrF74Y",step="Commit"} 29 tendermint_consensus_step_duration_bucket{chain_id="test-chain-IrF74Y",step="NewHeight",le="0.1"} 0 tendermint_consensus_step_duration_bucket{chain_id="test-chain-IrF74Y",step="NewHeight",le="0.2682695795279726"} 0 tendermint_consensus_step_duration_bucket{chain_id="test-chain-IrF74Y",step="NewHeight",le="0.7196856730011522"} 0 tendermint_consensus_step_duration_bucket{chain_id="test-chain-IrF74Y",step="NewHeight",le="1.9306977288832508"} 28 tendermint_consensus_step_duration_bucket{chain_id="test-chain-IrF74Y",step="NewHeight",le="5.1794746792312125"} 28 tendermint_consensus_step_duration_bucket{chain_id="test-chain-IrF74Y",step="NewHeight",le="13.894954943731381"} 28 tendermint_consensus_step_duration_bucket{chain_id="test-chain-IrF74Y",step="NewHeight",le="37.27593720314942"} 28 tendermint_consensus_step_duration_bucket{chain_id="test-chain-IrF74Y",step="NewHeight",le="100.00000000000006"} 28 tendermint_consensus_step_duration_bucket{chain_id="test-chain-IrF74Y",step="NewHeight",le="+Inf"} 28 tendermint_consensus_step_duration_sum{chain_id="test-chain-IrF74Y",step="NewHeight"} 27.773921702 tendermint_consensus_step_duration_count{chain_id="test-chain-IrF74Y",step="NewHeight"} 28 tendermint_consensus_step_duration_bucket{chain_id="test-chain-IrF74Y",step="NewRound",le="0.1"} 29 tendermint_consensus_step_duration_bucket{chain_id="test-chain-IrF74Y",step="NewRound",le="0.2682695795279726"} 29 tendermint_consensus_step_duration_bucket{chain_id="test-chain-IrF74Y",step="NewRound",le="0.7196856730011522"} 29 tendermint_consensus_step_duration_bucket{chain_id="test-chain-IrF74Y",step="NewRound",le="1.9306977288832508"} 29 tendermint_consensus_step_duration_bucket{chain_id="test-chain-IrF74Y",step="NewRound",le="5.1794746792312125"} 29 tendermint_consensus_step_duration_bucket{chain_id="test-chain-IrF74Y",step="NewRound",le="13.894954943731381"} 29 tendermint_consensus_step_duration_bucket{chain_id="test-chain-IrF74Y",step="NewRound",le="37.27593720314942"} 29 tendermint_consensus_step_duration_bucket{chain_id="test-chain-IrF74Y",step="NewRound",le="100.00000000000006"} 29 tendermint_consensus_step_duration_bucket{chain_id="test-chain-IrF74Y",step="NewRound",le="+Inf"} 29 tendermint_consensus_step_duration_sum{chain_id="test-chain-IrF74Y",step="NewRound"} 0.168961052 tendermint_consensus_step_duration_count{chain_id="test-chain-IrF74Y",step="NewRound"} 29 tendermint_consensus_step_duration_bucket{chain_id="test-chain-IrF74Y",step="Precommit",le="0.1"} 29 tendermint_consensus_step_duration_bucket{chain_id="test-chain-IrF74Y",step="Precommit",le="0.2682695795279726"} 29 tendermint_consensus_step_duration_bucket{chain_id="test-chain-IrF74Y",step="Precommit",le="0.7196856730011522"} 29 tendermint_consensus_step_duration_bucket{chain_id="test-chain-IrF74Y",step="Precommit",le="1.9306977288832508"} 29 tendermint_consensus_step_duration_bucket{chain_id="test-chain-IrF74Y",step="Precommit",le="5.1794746792312125"} 29 tendermint_consensus_step_duration_bucket{chain_id="test-chain-IrF74Y",step="Precommit",le="13.894954943731381"} 29 tendermint_consensus_step_duration_bucket{chain_id="test-chain-IrF74Y",step="Precommit",le="37.27593720314942"} 29 tendermint_consensus_step_duration_bucket{chain_id="test-chain-IrF74Y",step="Precommit",le="100.00000000000006"} 29 tendermint_consensus_step_duration_bucket{chain_id="test-chain-IrF74Y",step="Precommit",le="+Inf"} 29 tendermint_consensus_step_duration_sum{chain_id="test-chain-IrF74Y",step="Precommit"} 0.06414115999999999 tendermint_consensus_step_duration_count{chain_id="test-chain-IrF74Y",step="Precommit"} 29 tendermint_consensus_step_duration_bucket{chain_id="test-chain-IrF74Y",step="Prevote",le="0.1"} 29 tendermint_consensus_step_duration_bucket{chain_id="test-chain-IrF74Y",step="Prevote",le="0.2682695795279726"} 29 tendermint_consensus_step_duration_bucket{chain_id="test-chain-IrF74Y",step="Prevote",le="0.7196856730011522"} 29 tendermint_consensus_step_duration_bucket{chain_id="test-chain-IrF74Y",step="Prevote",le="1.9306977288832508"} 29 tendermint_consensus_step_duration_bucket{chain_id="test-chain-IrF74Y",step="Prevote",le="5.1794746792312125"} 29 tendermint_consensus_step_duration_bucket{chain_id="test-chain-IrF74Y",step="Prevote",le="13.894954943731381"} 29 tendermint_consensus_step_duration_bucket{chain_id="test-chain-IrF74Y",step="Prevote",le="37.27593720314942"} 29 tendermint_consensus_step_duration_bucket{chain_id="test-chain-IrF74Y",step="Prevote",le="100.00000000000006"} 29 tendermint_consensus_step_duration_bucket{chain_id="test-chain-IrF74Y",step="Prevote",le="+Inf"} 29 tendermint_consensus_step_duration_sum{chain_id="test-chain-IrF74Y",step="Prevote"} 0.177714525 tendermint_consensus_step_duration_count{chain_id="test-chain-IrF74Y",step="Prevote"} 29 tendermint_consensus_step_duration_bucket{chain_id="test-chain-IrF74Y",step="Propose",le="0.1"} 29 tendermint_consensus_step_duration_bucket{chain_id="test-chain-IrF74Y",step="Propose",le="0.2682695795279726"} 29 tendermint_consensus_step_duration_bucket{chain_id="test-chain-IrF74Y",step="Propose",le="0.7196856730011522"} 29 tendermint_consensus_step_duration_bucket{chain_id="test-chain-IrF74Y",step="Propose",le="1.9306977288832508"} 29 tendermint_consensus_step_duration_bucket{chain_id="test-chain-IrF74Y",step="Propose",le="5.1794746792312125"} 29 tendermint_consensus_step_duration_bucket{chain_id="test-chain-IrF74Y",step="Propose",le="13.894954943731381"} 29 tendermint_consensus_step_duration_bucket{chain_id="test-chain-IrF74Y",step="Propose",le="37.27593720314942"} 29 tendermint_consensus_step_duration_bucket{chain_id="test-chain-IrF74Y",step="Propose",le="100.00000000000006"} 29 tendermint_consensus_step_duration_bucket{chain_id="test-chain-IrF74Y",step="Propose",le="+Inf"} 29 tendermint_consensus_step_duration_sum{chain_id="test-chain-IrF74Y",step="Propose"} 0.221851927 tendermint_consensus_step_duration_count{chain_id="test-chain-IrF74Y",step="Propose"} 29 ``` ``` # HELP tendermint_consensus_block_gossip_receive_time Difference in seconds between when the validator learns of a new blockand when the validator receives the last piece of the block. # TYPE tendermint_consensus_block_gossip_receive_time histogram tendermint_consensus_block_gossip_receive_time_bucket{chain_id="test-chain-IrF74Y",le="0.1"} 29 tendermint_consensus_block_gossip_receive_time_bucket{chain_id="test-chain-IrF74Y",le="0.2682695795279726"} 29 tendermint_consensus_block_gossip_receive_time_bucket{chain_id="test-chain-IrF74Y",le="0.7196856730011522"} 29 tendermint_consensus_block_gossip_receive_time_bucket{chain_id="test-chain-IrF74Y",le="1.9306977288832508"} 29 tendermint_consensus_block_gossip_receive_time_bucket{chain_id="test-chain-IrF74Y",le="5.1794746792312125"} 29 tendermint_consensus_block_gossip_receive_time_bucket{chain_id="test-chain-IrF74Y",le="13.894954943731381"} 29 tendermint_consensus_block_gossip_receive_time_bucket{chain_id="test-chain-IrF74Y",le="37.27593720314942"} 29 tendermint_consensus_block_gossip_receive_time_bucket{chain_id="test-chain-IrF74Y",le="100.00000000000006"} 29 tendermint_consensus_block_gossip_receive_time_bucket{chain_id="test-chain-IrF74Y",le="+Inf"} 29 tendermint_consensus_block_gossip_receive_time_sum{chain_id="test-chain-IrF74Y"} 0.06380 ``` ``` # HELP tendermint_consensus_block_gossip_parts_received Number of block parts received by the node, labeled by whether thepart was relevant to the block the node was currently gathering or not # TYPE tendermint_consensus_block_gossip_parts_received counter tendermint_consensus_block_gossip_parts_received{chain_id="test-chain-IrF74Y",matches_current="true"} 29 ```
2 years ago
8 years ago
lint: Enable Golint (#4212) * Fix many golint errors * Fix golint errors in the 'lite' package * Don't export Pool.store * Fix typo * Revert unwanted changes * Fix errors in counter package * Fix linter errors in kvstore package * Fix linter error in example package * Fix error in tests package * Fix linter errors in v2 package * Fix linter errors in consensus package * Fix linter errors in evidence package * Fix linter error in fail package * Fix linter errors in query package * Fix linter errors in core package * Fix linter errors in node package * Fix linter errors in mempool package * Fix linter error in conn package * Fix linter errors in pex package * Rename PEXReactor export to Reactor * Fix linter errors in trust package * Fix linter errors in upnp package * Fix linter errors in p2p package * Fix linter errors in proxy package * Fix linter errors in mock_test package * Fix linter error in client_test package * Fix linter errors in coretypes package * Fix linter errors in coregrpc package * Fix linter errors in rpcserver package * Fix linter errors in rpctypes package * Fix linter errors in rpctest package * Fix linter error in json2wal script * Fix linter error in wal2json script * Fix linter errors in kv package * Fix linter error in state package * Fix linter error in grpc_client * Fix linter errors in types package * Fix linter error in version package * Fix remaining errors * Address review comments * Fix broken tests * Reconcile package coregrpc * Fix golangci bot error * Fix new golint errors * Fix broken reference * Enable golint linter * minor changes to bring golint into line * fix failing test * fix pex reactor naming * address PR comments
5 years ago
consensus: additional timing metrics (#7849) This change introduces an additional set of metrics aimed at helping operators understand the timing for consensus. This change adds the following metrics: ``` # HELP tendermint_consensus_round_duration Time spent in a round # TYPE tendermint_consensus_round_duration histogram tendermint_consensus_round_duration_bucket{chain_id="test-chain-IrF74Y",le="0.1"} 29 tendermint_consensus_round_duration_bucket{chain_id="test-chain-IrF74Y",le="0.2682695795279726"} 29 tendermint_consensus_round_duration_bucket{chain_id="test-chain-IrF74Y",le="0.7196856730011522"} 29 tendermint_consensus_round_duration_bucket{chain_id="test-chain-IrF74Y",le="1.9306977288832508"} 29 tendermint_consensus_round_duration_bucket{chain_id="test-chain-IrF74Y",le="5.1794746792312125"} 29 tendermint_consensus_round_duration_bucket{chain_id="test-chain-IrF74Y",le="13.894954943731381"} 29 tendermint_consensus_round_duration_bucket{chain_id="test-chain-IrF74Y",le="37.27593720314942"} 29 tendermint_consensus_round_duration_bucket{chain_id="test-chain-IrF74Y",le="100.00000000000006"} 29 tendermint_consensus_round_duration_bucket{chain_id="test-chain-IrF74Y",le="+Inf"} 29 tendermint_consensus_round_duration_sum{chain_id="test-chain-IrF74Y"} 0.028651869999999996 tendermint_consensus_round_duration_count{chain_id="test-chain-IrF74Y"} 29 ``` ``` # HELP tendermint_consensus_step_duration Time spent per step. # TYPE tendermint_consensus_step_duration histogram tendermint_consensus_step_duration_bucket{chain_id="test-chain-IrF74Y",step="Commit",le="0.1"} 29 tendermint_consensus_step_duration_bucket{chain_id="test-chain-IrF74Y",step="Commit",le="0.2682695795279726"} 29 tendermint_consensus_step_duration_bucket{chain_id="test-chain-IrF74Y",step="Commit",le="0.7196856730011522"} 29 tendermint_consensus_step_duration_bucket{chain_id="test-chain-IrF74Y",step="Commit",le="1.9306977288832508"} 29 tendermint_consensus_step_duration_bucket{chain_id="test-chain-IrF74Y",step="Commit",le="5.1794746792312125"} 29 tendermint_consensus_step_duration_bucket{chain_id="test-chain-IrF74Y",step="Commit",le="13.894954943731381"} 29 tendermint_consensus_step_duration_bucket{chain_id="test-chain-IrF74Y",step="Commit",le="37.27593720314942"} 29 tendermint_consensus_step_duration_bucket{chain_id="test-chain-IrF74Y",step="Commit",le="100.00000000000006"} 29 tendermint_consensus_step_duration_bucket{chain_id="test-chain-IrF74Y",step="Commit",le="+Inf"} 29 tendermint_consensus_step_duration_sum{chain_id="test-chain-IrF74Y",step="Commit"} 0.26650875 tendermint_consensus_step_duration_count{chain_id="test-chain-IrF74Y",step="Commit"} 29 tendermint_consensus_step_duration_bucket{chain_id="test-chain-IrF74Y",step="NewHeight",le="0.1"} 0 tendermint_consensus_step_duration_bucket{chain_id="test-chain-IrF74Y",step="NewHeight",le="0.2682695795279726"} 0 tendermint_consensus_step_duration_bucket{chain_id="test-chain-IrF74Y",step="NewHeight",le="0.7196856730011522"} 0 tendermint_consensus_step_duration_bucket{chain_id="test-chain-IrF74Y",step="NewHeight",le="1.9306977288832508"} 28 tendermint_consensus_step_duration_bucket{chain_id="test-chain-IrF74Y",step="NewHeight",le="5.1794746792312125"} 28 tendermint_consensus_step_duration_bucket{chain_id="test-chain-IrF74Y",step="NewHeight",le="13.894954943731381"} 28 tendermint_consensus_step_duration_bucket{chain_id="test-chain-IrF74Y",step="NewHeight",le="37.27593720314942"} 28 tendermint_consensus_step_duration_bucket{chain_id="test-chain-IrF74Y",step="NewHeight",le="100.00000000000006"} 28 tendermint_consensus_step_duration_bucket{chain_id="test-chain-IrF74Y",step="NewHeight",le="+Inf"} 28 tendermint_consensus_step_duration_sum{chain_id="test-chain-IrF74Y",step="NewHeight"} 27.773921702 tendermint_consensus_step_duration_count{chain_id="test-chain-IrF74Y",step="NewHeight"} 28 tendermint_consensus_step_duration_bucket{chain_id="test-chain-IrF74Y",step="NewRound",le="0.1"} 29 tendermint_consensus_step_duration_bucket{chain_id="test-chain-IrF74Y",step="NewRound",le="0.2682695795279726"} 29 tendermint_consensus_step_duration_bucket{chain_id="test-chain-IrF74Y",step="NewRound",le="0.7196856730011522"} 29 tendermint_consensus_step_duration_bucket{chain_id="test-chain-IrF74Y",step="NewRound",le="1.9306977288832508"} 29 tendermint_consensus_step_duration_bucket{chain_id="test-chain-IrF74Y",step="NewRound",le="5.1794746792312125"} 29 tendermint_consensus_step_duration_bucket{chain_id="test-chain-IrF74Y",step="NewRound",le="13.894954943731381"} 29 tendermint_consensus_step_duration_bucket{chain_id="test-chain-IrF74Y",step="NewRound",le="37.27593720314942"} 29 tendermint_consensus_step_duration_bucket{chain_id="test-chain-IrF74Y",step="NewRound",le="100.00000000000006"} 29 tendermint_consensus_step_duration_bucket{chain_id="test-chain-IrF74Y",step="NewRound",le="+Inf"} 29 tendermint_consensus_step_duration_sum{chain_id="test-chain-IrF74Y",step="NewRound"} 0.168961052 tendermint_consensus_step_duration_count{chain_id="test-chain-IrF74Y",step="NewRound"} 29 tendermint_consensus_step_duration_bucket{chain_id="test-chain-IrF74Y",step="Precommit",le="0.1"} 29 tendermint_consensus_step_duration_bucket{chain_id="test-chain-IrF74Y",step="Precommit",le="0.2682695795279726"} 29 tendermint_consensus_step_duration_bucket{chain_id="test-chain-IrF74Y",step="Precommit",le="0.7196856730011522"} 29 tendermint_consensus_step_duration_bucket{chain_id="test-chain-IrF74Y",step="Precommit",le="1.9306977288832508"} 29 tendermint_consensus_step_duration_bucket{chain_id="test-chain-IrF74Y",step="Precommit",le="5.1794746792312125"} 29 tendermint_consensus_step_duration_bucket{chain_id="test-chain-IrF74Y",step="Precommit",le="13.894954943731381"} 29 tendermint_consensus_step_duration_bucket{chain_id="test-chain-IrF74Y",step="Precommit",le="37.27593720314942"} 29 tendermint_consensus_step_duration_bucket{chain_id="test-chain-IrF74Y",step="Precommit",le="100.00000000000006"} 29 tendermint_consensus_step_duration_bucket{chain_id="test-chain-IrF74Y",step="Precommit",le="+Inf"} 29 tendermint_consensus_step_duration_sum{chain_id="test-chain-IrF74Y",step="Precommit"} 0.06414115999999999 tendermint_consensus_step_duration_count{chain_id="test-chain-IrF74Y",step="Precommit"} 29 tendermint_consensus_step_duration_bucket{chain_id="test-chain-IrF74Y",step="Prevote",le="0.1"} 29 tendermint_consensus_step_duration_bucket{chain_id="test-chain-IrF74Y",step="Prevote",le="0.2682695795279726"} 29 tendermint_consensus_step_duration_bucket{chain_id="test-chain-IrF74Y",step="Prevote",le="0.7196856730011522"} 29 tendermint_consensus_step_duration_bucket{chain_id="test-chain-IrF74Y",step="Prevote",le="1.9306977288832508"} 29 tendermint_consensus_step_duration_bucket{chain_id="test-chain-IrF74Y",step="Prevote",le="5.1794746792312125"} 29 tendermint_consensus_step_duration_bucket{chain_id="test-chain-IrF74Y",step="Prevote",le="13.894954943731381"} 29 tendermint_consensus_step_duration_bucket{chain_id="test-chain-IrF74Y",step="Prevote",le="37.27593720314942"} 29 tendermint_consensus_step_duration_bucket{chain_id="test-chain-IrF74Y",step="Prevote",le="100.00000000000006"} 29 tendermint_consensus_step_duration_bucket{chain_id="test-chain-IrF74Y",step="Prevote",le="+Inf"} 29 tendermint_consensus_step_duration_sum{chain_id="test-chain-IrF74Y",step="Prevote"} 0.177714525 tendermint_consensus_step_duration_count{chain_id="test-chain-IrF74Y",step="Prevote"} 29 tendermint_consensus_step_duration_bucket{chain_id="test-chain-IrF74Y",step="Propose",le="0.1"} 29 tendermint_consensus_step_duration_bucket{chain_id="test-chain-IrF74Y",step="Propose",le="0.2682695795279726"} 29 tendermint_consensus_step_duration_bucket{chain_id="test-chain-IrF74Y",step="Propose",le="0.7196856730011522"} 29 tendermint_consensus_step_duration_bucket{chain_id="test-chain-IrF74Y",step="Propose",le="1.9306977288832508"} 29 tendermint_consensus_step_duration_bucket{chain_id="test-chain-IrF74Y",step="Propose",le="5.1794746792312125"} 29 tendermint_consensus_step_duration_bucket{chain_id="test-chain-IrF74Y",step="Propose",le="13.894954943731381"} 29 tendermint_consensus_step_duration_bucket{chain_id="test-chain-IrF74Y",step="Propose",le="37.27593720314942"} 29 tendermint_consensus_step_duration_bucket{chain_id="test-chain-IrF74Y",step="Propose",le="100.00000000000006"} 29 tendermint_consensus_step_duration_bucket{chain_id="test-chain-IrF74Y",step="Propose",le="+Inf"} 29 tendermint_consensus_step_duration_sum{chain_id="test-chain-IrF74Y",step="Propose"} 0.221851927 tendermint_consensus_step_duration_count{chain_id="test-chain-IrF74Y",step="Propose"} 29 ``` ``` # HELP tendermint_consensus_block_gossip_receive_time Difference in seconds between when the validator learns of a new blockand when the validator receives the last piece of the block. # TYPE tendermint_consensus_block_gossip_receive_time histogram tendermint_consensus_block_gossip_receive_time_bucket{chain_id="test-chain-IrF74Y",le="0.1"} 29 tendermint_consensus_block_gossip_receive_time_bucket{chain_id="test-chain-IrF74Y",le="0.2682695795279726"} 29 tendermint_consensus_block_gossip_receive_time_bucket{chain_id="test-chain-IrF74Y",le="0.7196856730011522"} 29 tendermint_consensus_block_gossip_receive_time_bucket{chain_id="test-chain-IrF74Y",le="1.9306977288832508"} 29 tendermint_consensus_block_gossip_receive_time_bucket{chain_id="test-chain-IrF74Y",le="5.1794746792312125"} 29 tendermint_consensus_block_gossip_receive_time_bucket{chain_id="test-chain-IrF74Y",le="13.894954943731381"} 29 tendermint_consensus_block_gossip_receive_time_bucket{chain_id="test-chain-IrF74Y",le="37.27593720314942"} 29 tendermint_consensus_block_gossip_receive_time_bucket{chain_id="test-chain-IrF74Y",le="100.00000000000006"} 29 tendermint_consensus_block_gossip_receive_time_bucket{chain_id="test-chain-IrF74Y",le="+Inf"} 29 tendermint_consensus_block_gossip_receive_time_sum{chain_id="test-chain-IrF74Y"} 0.06380 ``` ``` # HELP tendermint_consensus_block_gossip_parts_received Number of block parts received by the node, labeled by whether thepart was relevant to the block the node was currently gathering or not # TYPE tendermint_consensus_block_gossip_parts_received counter tendermint_consensus_block_gossip_parts_received{chain_id="test-chain-IrF74Y",matches_current="true"} 29 ```
2 years ago
10 years ago
lint: Enable Golint (#4212) * Fix many golint errors * Fix golint errors in the 'lite' package * Don't export Pool.store * Fix typo * Revert unwanted changes * Fix errors in counter package * Fix linter errors in kvstore package * Fix linter error in example package * Fix error in tests package * Fix linter errors in v2 package * Fix linter errors in consensus package * Fix linter errors in evidence package * Fix linter error in fail package * Fix linter errors in query package * Fix linter errors in core package * Fix linter errors in node package * Fix linter errors in mempool package * Fix linter error in conn package * Fix linter errors in pex package * Rename PEXReactor export to Reactor * Fix linter errors in trust package * Fix linter errors in upnp package * Fix linter errors in p2p package * Fix linter errors in proxy package * Fix linter errors in mock_test package * Fix linter error in client_test package * Fix linter errors in coretypes package * Fix linter errors in coregrpc package * Fix linter errors in rpcserver package * Fix linter errors in rpctypes package * Fix linter errors in rpctest package * Fix linter error in json2wal script * Fix linter error in wal2json script * Fix linter errors in kv package * Fix linter error in state package * Fix linter error in grpc_client * Fix linter errors in types package * Fix linter error in version package * Fix remaining errors * Address review comments * Fix broken tests * Reconcile package coregrpc * Fix golangci bot error * Fix new golint errors * Fix broken reference * Enable golint linter * minor changes to bring golint into line * fix failing test * fix pex reactor naming * address PR comments
5 years ago
lint: Enable Golint (#4212) * Fix many golint errors * Fix golint errors in the 'lite' package * Don't export Pool.store * Fix typo * Revert unwanted changes * Fix errors in counter package * Fix linter errors in kvstore package * Fix linter error in example package * Fix error in tests package * Fix linter errors in v2 package * Fix linter errors in consensus package * Fix linter errors in evidence package * Fix linter error in fail package * Fix linter errors in query package * Fix linter errors in core package * Fix linter errors in node package * Fix linter errors in mempool package * Fix linter error in conn package * Fix linter errors in pex package * Rename PEXReactor export to Reactor * Fix linter errors in trust package * Fix linter errors in upnp package * Fix linter errors in p2p package * Fix linter errors in proxy package * Fix linter errors in mock_test package * Fix linter error in client_test package * Fix linter errors in coretypes package * Fix linter errors in coregrpc package * Fix linter errors in rpcserver package * Fix linter errors in rpctypes package * Fix linter errors in rpctest package * Fix linter error in json2wal script * Fix linter error in wal2json script * Fix linter errors in kv package * Fix linter error in state package * Fix linter error in grpc_client * Fix linter errors in types package * Fix linter error in version package * Fix remaining errors * Address review comments * Fix broken tests * Reconcile package coregrpc * Fix golangci bot error * Fix new golint errors * Fix broken reference * Enable golint linter * minor changes to bring golint into line * fix failing test * fix pex reactor naming * address PR comments
5 years ago
cs: sync WAL more frequently (#3300) As per #3043, this adds a ticker to sync the WAL every 2s while the WAL is running. * Flush WAL every 2s This adds a ticker that flushes the WAL every 2s while the WAL is running. This is related to #3043. * Fix spelling * Increase timeout to 2mins for slower build environments * Make WAL sync interval configurable * Add TODO to replace testChan with more comprehensive testBus * Remove extraneous debug statement * Remove testChan in favour of using system time As per https://github.com/tendermint/tendermint/pull/3300#discussion_r255886586, this removes the `testChan` WAL member and replaces the approach with a system time-oriented one. In this new approach, we keep track of the system time at which each flush and periodic flush successfully occurred. The naming of the various functions is also updated here to be more consistent with "flushing" as opposed to "sync'ing". * Update naming convention and ensure lock for timestamp update * Add Flush method as part of WAL interface Adds a `Flush` method as part of the WAL interface to enforce the idea that we can manually trigger a WAL flush from outside of the WAL. This is employed in the consensus state management to flush the WAL prior to signing votes/proposals, as per https://github.com/tendermint/tendermint/issues/3043#issuecomment-453853630 * Update CHANGELOG_PENDING * Remove mutex approach and replace with DI The dependency injection approach to dealing with testing concerns could allow similar effects to some kind of "testing bus"-based approach. This commit introduces an example of this, where instead of relying on (potentially fragile) timing of things between the code and the test, we inject code into the function under test that can signal the test through a channel. This allows us to avoid the `time.Sleep()`-based approach previously employed. * Update comment on WAL flushing during vote signing Co-Authored-By: thanethomson <connect@thanethomson.com> * Simplify flush interval definition Co-Authored-By: thanethomson <connect@thanethomson.com> * Expand commentary on WAL disk flushing Co-Authored-By: thanethomson <connect@thanethomson.com> * Add broken test to illustrate WAL sync test problem Removes test-related state (dependency injection code) from the WAL data structure and adds test code to illustrate the problem with using `WALGenerateNBlocks` and `wal.SearchForEndHeight` to test periodic sync'ing. * Fix test error messages * Use WAL group buffer size to check for flush A function is added to `libs/autofile/group.go#Group` in order to return the size of the buffered data (i.e. data that has not yet been flushed to disk). The test now checks that, prior to a `time.Sleep`, the group buffer has data in it. After the `time.Sleep` (during which time the periodic flush should have been called), the buffer should be empty. * Remove config root dir removal from #3291 * Add godoc for NewWAL mentioning periodic sync
5 years ago
lint: Enable Golint (#4212) * Fix many golint errors * Fix golint errors in the 'lite' package * Don't export Pool.store * Fix typo * Revert unwanted changes * Fix errors in counter package * Fix linter errors in kvstore package * Fix linter error in example package * Fix error in tests package * Fix linter errors in v2 package * Fix linter errors in consensus package * Fix linter errors in evidence package * Fix linter error in fail package * Fix linter errors in query package * Fix linter errors in core package * Fix linter errors in node package * Fix linter errors in mempool package * Fix linter error in conn package * Fix linter errors in pex package * Rename PEXReactor export to Reactor * Fix linter errors in trust package * Fix linter errors in upnp package * Fix linter errors in p2p package * Fix linter errors in proxy package * Fix linter errors in mock_test package * Fix linter error in client_test package * Fix linter errors in coretypes package * Fix linter errors in coregrpc package * Fix linter errors in rpcserver package * Fix linter errors in rpctypes package * Fix linter errors in rpctest package * Fix linter error in json2wal script * Fix linter error in wal2json script * Fix linter errors in kv package * Fix linter error in state package * Fix linter error in grpc_client * Fix linter errors in types package * Fix linter error in version package * Fix remaining errors * Address review comments * Fix broken tests * Reconcile package coregrpc * Fix golangci bot error * Fix new golint errors * Fix broken reference * Enable golint linter * minor changes to bring golint into line * fix failing test * fix pex reactor naming * address PR comments
5 years ago
10 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
  1. package consensus
  2. import (
  3. "bytes"
  4. "context"
  5. "encoding/json"
  6. "errors"
  7. "fmt"
  8. "io"
  9. "os"
  10. "runtime/debug"
  11. "sort"
  12. "sync"
  13. "time"
  14. "github.com/gogo/protobuf/proto"
  15. "github.com/tendermint/tendermint/config"
  16. "github.com/tendermint/tendermint/crypto"
  17. cstypes "github.com/tendermint/tendermint/internal/consensus/types"
  18. "github.com/tendermint/tendermint/internal/eventbus"
  19. "github.com/tendermint/tendermint/internal/jsontypes"
  20. "github.com/tendermint/tendermint/internal/libs/autofile"
  21. sm "github.com/tendermint/tendermint/internal/state"
  22. tmevents "github.com/tendermint/tendermint/libs/events"
  23. "github.com/tendermint/tendermint/libs/log"
  24. tmmath "github.com/tendermint/tendermint/libs/math"
  25. tmos "github.com/tendermint/tendermint/libs/os"
  26. "github.com/tendermint/tendermint/libs/service"
  27. tmtime "github.com/tendermint/tendermint/libs/time"
  28. "github.com/tendermint/tendermint/privval"
  29. tmgrpc "github.com/tendermint/tendermint/privval/grpc"
  30. tmproto "github.com/tendermint/tendermint/proto/tendermint/types"
  31. "github.com/tendermint/tendermint/types"
  32. )
  33. // Consensus sentinel errors
  34. var (
  35. ErrInvalidProposalSignature = errors.New("error invalid proposal signature")
  36. ErrInvalidProposalPOLRound = errors.New("error invalid proposal POL round")
  37. ErrAddingVote = errors.New("error adding vote")
  38. ErrSignatureFoundInPastBlocks = errors.New("found signature from the same key")
  39. errPubKeyIsNotSet = errors.New("pubkey is not set. Look for \"Can't get private validator pubkey\" errors")
  40. )
  41. var msgQueueSize = 1000
  42. // msgs from the reactor which may update the state
  43. type msgInfo struct {
  44. Msg Message
  45. PeerID types.NodeID
  46. ReceiveTime time.Time
  47. }
  48. func (msgInfo) TypeTag() string { return "tendermint/wal/MsgInfo" }
  49. type msgInfoJSON struct {
  50. Msg json.RawMessage `json:"msg"`
  51. PeerID types.NodeID `json:"peer_key"`
  52. ReceiveTime time.Time `json:"receive_time"`
  53. }
  54. func (m msgInfo) MarshalJSON() ([]byte, error) {
  55. msg, err := jsontypes.Marshal(m.Msg)
  56. if err != nil {
  57. return nil, err
  58. }
  59. return json.Marshal(msgInfoJSON{Msg: msg, PeerID: m.PeerID, ReceiveTime: m.ReceiveTime})
  60. }
  61. func (m *msgInfo) UnmarshalJSON(data []byte) error {
  62. var msg msgInfoJSON
  63. if err := json.Unmarshal(data, &msg); err != nil {
  64. return err
  65. }
  66. if err := jsontypes.Unmarshal(msg.Msg, &m.Msg); err != nil {
  67. return err
  68. }
  69. m.PeerID = msg.PeerID
  70. return nil
  71. }
  72. // internally generated messages which may update the state
  73. type timeoutInfo struct {
  74. Duration time.Duration `json:"duration,string"`
  75. Height int64 `json:"height,string"`
  76. Round int32 `json:"round"`
  77. Step cstypes.RoundStepType `json:"step"`
  78. }
  79. func (timeoutInfo) TypeTag() string { return "tendermint/wal/TimeoutInfo" }
  80. func (ti *timeoutInfo) String() string {
  81. return fmt.Sprintf("%v ; %d/%d %v", ti.Duration, ti.Height, ti.Round, ti.Step)
  82. }
  83. // interface to the mempool
  84. type txNotifier interface {
  85. TxsAvailable() <-chan struct{}
  86. }
  87. // interface to the evidence pool
  88. type evidencePool interface {
  89. // reports conflicting votes to the evidence pool to be processed into evidence
  90. ReportConflictingVotes(voteA, voteB *types.Vote)
  91. }
  92. // State handles execution of the consensus algorithm.
  93. // It processes votes and proposals, and upon reaching agreement,
  94. // commits blocks to the chain and executes them against the application.
  95. // The internal state machine receives input from peers, the internal validator, and from a timer.
  96. type State struct {
  97. service.BaseService
  98. logger log.Logger
  99. // config details
  100. config *config.ConsensusConfig
  101. privValidator types.PrivValidator // for signing votes
  102. privValidatorType types.PrivValidatorType
  103. // store blocks and commits
  104. blockStore sm.BlockStore
  105. stateStore sm.Store
  106. initialStatePopulated bool
  107. // create and execute blocks
  108. blockExec *sm.BlockExecutor
  109. // notify us if txs are available
  110. txNotifier txNotifier
  111. // add evidence to the pool
  112. // when it's detected
  113. evpool evidencePool
  114. // internal state
  115. mtx sync.RWMutex
  116. cstypes.RoundState
  117. state sm.State // State until height-1.
  118. // privValidator pubkey, memoized for the duration of one block
  119. // to avoid extra requests to HSM
  120. privValidatorPubKey crypto.PubKey
  121. // state changes may be triggered by: msgs from peers,
  122. // msgs from ourself, or by timeouts
  123. peerMsgQueue chan msgInfo
  124. internalMsgQueue chan msgInfo
  125. timeoutTicker TimeoutTicker
  126. // information about about added votes and block parts are written on this channel
  127. // so statistics can be computed by reactor
  128. statsMsgQueue chan msgInfo
  129. // we use eventBus to trigger msg broadcasts in the reactor,
  130. // and to notify external subscribers, eg. through a websocket
  131. eventBus *eventbus.EventBus
  132. // a Write-Ahead Log ensures we can recover from any kind of crash
  133. // and helps us avoid signing conflicting votes
  134. wal WAL
  135. replayMode bool // so we don't log signing errors during replay
  136. doWALCatchup bool // determines if we even try to do the catchup
  137. // for tests where we want to limit the number of transitions the state makes
  138. nSteps int
  139. // some functions can be overwritten for testing
  140. decideProposal func(ctx context.Context, height int64, round int32)
  141. doPrevote func(ctx context.Context, height int64, round int32)
  142. setProposal func(proposal *types.Proposal, t time.Time) error
  143. // closed when we finish shutting down
  144. done chan struct{}
  145. // synchronous pubsub between consensus state and reactor.
  146. // state only emits EventNewRoundStep, EventValidBlock, and EventVote
  147. evsw tmevents.EventSwitch
  148. // for reporting metrics
  149. metrics *Metrics
  150. // wait the channel event happening for shutting down the state gracefully
  151. onStopCh chan *cstypes.RoundState
  152. }
  153. // StateOption sets an optional parameter on the State.
  154. type StateOption func(*State)
  155. // NewState returns a new State.
  156. func NewState(
  157. ctx context.Context,
  158. logger log.Logger,
  159. cfg *config.ConsensusConfig,
  160. store sm.Store,
  161. blockExec *sm.BlockExecutor,
  162. blockStore sm.BlockStore,
  163. txNotifier txNotifier,
  164. evpool evidencePool,
  165. eventBus *eventbus.EventBus,
  166. options ...StateOption,
  167. ) (*State, error) {
  168. cs := &State{
  169. eventBus: eventBus,
  170. logger: logger,
  171. config: cfg,
  172. blockExec: blockExec,
  173. blockStore: blockStore,
  174. stateStore: store,
  175. txNotifier: txNotifier,
  176. peerMsgQueue: make(chan msgInfo, msgQueueSize),
  177. internalMsgQueue: make(chan msgInfo, msgQueueSize),
  178. timeoutTicker: NewTimeoutTicker(logger),
  179. statsMsgQueue: make(chan msgInfo, msgQueueSize),
  180. done: make(chan struct{}),
  181. doWALCatchup: true,
  182. wal: nilWAL{},
  183. evpool: evpool,
  184. evsw: tmevents.NewEventSwitch(logger),
  185. metrics: NopMetrics(),
  186. onStopCh: make(chan *cstypes.RoundState),
  187. }
  188. // set function defaults (may be overwritten before calling Start)
  189. cs.decideProposal = cs.defaultDecideProposal
  190. cs.doPrevote = cs.defaultDoPrevote
  191. cs.setProposal = cs.defaultSetProposal
  192. if err := cs.updateStateFromStore(ctx); err != nil {
  193. return nil, err
  194. }
  195. // NOTE: we do not call scheduleRound0 yet, we do that upon Start()
  196. cs.BaseService = *service.NewBaseService(logger, "State", cs)
  197. for _, option := range options {
  198. option(cs)
  199. }
  200. return cs, nil
  201. }
  202. func (cs *State) updateStateFromStore(ctx context.Context) error {
  203. if cs.initialStatePopulated {
  204. return nil
  205. }
  206. state, err := cs.stateStore.Load()
  207. if err != nil {
  208. return fmt.Errorf("loading state: %w", err)
  209. }
  210. if state.IsEmpty() {
  211. return nil
  212. }
  213. // We have no votes, so reconstruct LastCommit from SeenCommit.
  214. if state.LastBlockHeight > 0 {
  215. cs.reconstructLastCommit(state)
  216. }
  217. cs.updateToState(ctx, state)
  218. cs.initialStatePopulated = true
  219. return nil
  220. }
  221. // StateMetrics sets the metrics.
  222. func StateMetrics(metrics *Metrics) StateOption {
  223. return func(cs *State) { cs.metrics = metrics }
  224. }
  225. // String returns a string.
  226. func (cs *State) String() string {
  227. // better not to access shared variables
  228. return "ConsensusState"
  229. }
  230. // GetState returns a copy of the chain state.
  231. func (cs *State) GetState() sm.State {
  232. cs.mtx.RLock()
  233. defer cs.mtx.RUnlock()
  234. return cs.state.Copy()
  235. }
  236. // GetLastHeight returns the last height committed.
  237. // If there were no blocks, returns 0.
  238. func (cs *State) GetLastHeight() int64 {
  239. cs.mtx.RLock()
  240. defer cs.mtx.RUnlock()
  241. return cs.RoundState.Height - 1
  242. }
  243. // GetRoundState returns a shallow copy of the internal consensus state.
  244. func (cs *State) GetRoundState() *cstypes.RoundState {
  245. cs.mtx.RLock()
  246. defer cs.mtx.RUnlock()
  247. // NOTE: this might be dodgy, as RoundState itself isn't thread
  248. // safe as it contains a number of pointers and is explicitly
  249. // not thread safe.
  250. rs := cs.RoundState // copy
  251. return &rs
  252. }
  253. // GetRoundStateJSON returns a json of RoundState.
  254. func (cs *State) GetRoundStateJSON() ([]byte, error) {
  255. cs.mtx.RLock()
  256. defer cs.mtx.RUnlock()
  257. return json.Marshal(cs.RoundState)
  258. }
  259. // GetRoundStateSimpleJSON returns a json of RoundStateSimple
  260. func (cs *State) GetRoundStateSimpleJSON() ([]byte, error) {
  261. cs.mtx.RLock()
  262. defer cs.mtx.RUnlock()
  263. return json.Marshal(cs.RoundState.RoundStateSimple())
  264. }
  265. // GetValidators returns a copy of the current validators.
  266. func (cs *State) GetValidators() (int64, []*types.Validator) {
  267. cs.mtx.RLock()
  268. defer cs.mtx.RUnlock()
  269. return cs.state.LastBlockHeight, cs.state.Validators.Copy().Validators
  270. }
  271. // SetPrivValidator sets the private validator account for signing votes. It
  272. // immediately requests pubkey and caches it.
  273. func (cs *State) SetPrivValidator(ctx context.Context, priv types.PrivValidator) {
  274. cs.mtx.Lock()
  275. defer cs.mtx.Unlock()
  276. cs.privValidator = priv
  277. if priv != nil {
  278. switch t := priv.(type) {
  279. case *privval.RetrySignerClient:
  280. cs.privValidatorType = types.RetrySignerClient
  281. case *privval.FilePV:
  282. cs.privValidatorType = types.FileSignerClient
  283. case *privval.SignerClient:
  284. cs.privValidatorType = types.SignerSocketClient
  285. case *tmgrpc.SignerClient:
  286. cs.privValidatorType = types.SignerGRPCClient
  287. case types.MockPV:
  288. cs.privValidatorType = types.MockSignerClient
  289. case *types.ErroringMockPV:
  290. cs.privValidatorType = types.ErrorMockSignerClient
  291. default:
  292. cs.logger.Error("unsupported priv validator type", "err",
  293. fmt.Errorf("error privValidatorType %s", t))
  294. }
  295. }
  296. if err := cs.updatePrivValidatorPubKey(ctx); err != nil {
  297. cs.logger.Error("failed to get private validator pubkey", "err", err)
  298. }
  299. }
  300. // SetTimeoutTicker sets the local timer. It may be useful to overwrite for
  301. // testing.
  302. func (cs *State) SetTimeoutTicker(timeoutTicker TimeoutTicker) {
  303. cs.mtx.Lock()
  304. cs.timeoutTicker = timeoutTicker
  305. cs.mtx.Unlock()
  306. }
  307. // LoadCommit loads the commit for a given height.
  308. func (cs *State) LoadCommit(height int64) *types.Commit {
  309. cs.mtx.RLock()
  310. defer cs.mtx.RUnlock()
  311. if height == cs.blockStore.Height() {
  312. commit := cs.blockStore.LoadSeenCommit()
  313. // NOTE: Retrieving the height of the most recent block and retrieving
  314. // the most recent commit does not currently occur as an atomic
  315. // operation. We check the height and commit here in case a more recent
  316. // commit has arrived since retrieving the latest height.
  317. if commit != nil && commit.Height == height {
  318. return commit
  319. }
  320. }
  321. return cs.blockStore.LoadBlockCommit(height)
  322. }
  323. // OnStart loads the latest state via the WAL, and starts the timeout and
  324. // receive routines.
  325. func (cs *State) OnStart(ctx context.Context) error {
  326. if err := cs.updateStateFromStore(ctx); err != nil {
  327. return err
  328. }
  329. // We may set the WAL in testing before calling Start, so only OpenWAL if its
  330. // still the nilWAL.
  331. if _, ok := cs.wal.(nilWAL); ok {
  332. if err := cs.loadWalFile(ctx); err != nil {
  333. return err
  334. }
  335. }
  336. // we need the timeoutRoutine for replay so
  337. // we don't block on the tick chan.
  338. // NOTE: we will get a build up of garbage go routines
  339. // firing on the tockChan until the receiveRoutine is started
  340. // to deal with them (by that point, at most one will be valid)
  341. if err := cs.timeoutTicker.Start(ctx); err != nil {
  342. return err
  343. }
  344. // We may have lost some votes if the process crashed reload from consensus
  345. // log to catchup.
  346. if cs.doWALCatchup {
  347. repairAttempted := false
  348. LOOP:
  349. for {
  350. err := cs.catchupReplay(ctx, cs.Height)
  351. switch {
  352. case err == nil:
  353. break LOOP
  354. case !IsDataCorruptionError(err):
  355. cs.logger.Error("error on catchup replay; proceeding to start state anyway", "err", err)
  356. break LOOP
  357. case repairAttempted:
  358. return err
  359. }
  360. cs.logger.Error("the WAL file is corrupted; attempting repair", "err", err)
  361. // 1) prep work
  362. cs.wal.Stop()
  363. repairAttempted = true
  364. // 2) backup original WAL file
  365. corruptedFile := fmt.Sprintf("%s.CORRUPTED", cs.config.WalFile())
  366. if err := tmos.CopyFile(cs.config.WalFile(), corruptedFile); err != nil {
  367. return err
  368. }
  369. cs.logger.Debug("backed up WAL file", "src", cs.config.WalFile(), "dst", corruptedFile)
  370. // 3) try to repair (WAL file will be overwritten!)
  371. if err := repairWalFile(corruptedFile, cs.config.WalFile()); err != nil {
  372. cs.logger.Error("the WAL repair failed", "err", err)
  373. return err
  374. }
  375. cs.logger.Info("successful WAL repair")
  376. // reload WAL file
  377. if err := cs.loadWalFile(ctx); err != nil {
  378. return err
  379. }
  380. }
  381. }
  382. if err := cs.evsw.Start(ctx); err != nil {
  383. return err
  384. }
  385. // Double Signing Risk Reduction
  386. if err := cs.checkDoubleSigningRisk(cs.Height); err != nil {
  387. return err
  388. }
  389. // now start the receiveRoutine
  390. go cs.receiveRoutine(ctx, 0)
  391. // schedule the first round!
  392. // use GetRoundState so we don't race the receiveRoutine for access
  393. cs.scheduleRound0(cs.GetRoundState())
  394. return nil
  395. }
  396. // timeoutRoutine: receive requests for timeouts on tickChan and fire timeouts on tockChan
  397. // receiveRoutine: serializes processing of proposoals, block parts, votes; coordinates state transitions
  398. //
  399. // this is only used in tests.
  400. func (cs *State) startRoutines(ctx context.Context, maxSteps int) {
  401. err := cs.timeoutTicker.Start(ctx)
  402. if err != nil {
  403. cs.logger.Error("failed to start timeout ticker", "err", err)
  404. return
  405. }
  406. go cs.receiveRoutine(ctx, maxSteps)
  407. }
  408. // loadWalFile loads WAL data from file. It overwrites cs.wal.
  409. func (cs *State) loadWalFile(ctx context.Context) error {
  410. wal, err := cs.OpenWAL(ctx, cs.config.WalFile())
  411. if err != nil {
  412. cs.logger.Error("failed to load state WAL", "err", err)
  413. return err
  414. }
  415. cs.wal = wal
  416. return nil
  417. }
  418. // OnStop implements service.Service.
  419. func (cs *State) OnStop() {
  420. // If the node is committing a new block, wait until it is finished!
  421. if cs.GetRoundState().Step == cstypes.RoundStepCommit {
  422. select {
  423. case <-cs.onStopCh:
  424. case <-time.After(cs.config.TimeoutCommit):
  425. cs.logger.Error("OnStop: timeout waiting for commit to finish", "time", cs.config.TimeoutCommit)
  426. }
  427. }
  428. close(cs.onStopCh)
  429. if cs.evsw.IsRunning() {
  430. cs.evsw.Stop()
  431. }
  432. if cs.timeoutTicker.IsRunning() {
  433. cs.timeoutTicker.Stop()
  434. }
  435. // WAL is stopped in receiveRoutine.
  436. }
  437. // Wait waits for the the main routine to return.
  438. // NOTE: be sure to Stop() the event switch and drain
  439. // any event channels or this may deadlock
  440. func (cs *State) Wait() {
  441. cs.evsw.Wait()
  442. <-cs.done
  443. }
  444. // OpenWAL opens a file to log all consensus messages and timeouts for
  445. // deterministic accountability.
  446. func (cs *State) OpenWAL(ctx context.Context, walFile string) (WAL, error) {
  447. wal, err := NewWAL(ctx, cs.logger.With("wal", walFile), walFile)
  448. if err != nil {
  449. cs.logger.Error("failed to open WAL", "file", walFile, "err", err)
  450. return nil, err
  451. }
  452. if err := wal.Start(ctx); err != nil {
  453. cs.logger.Error("failed to start WAL", "err", err)
  454. return nil, err
  455. }
  456. return wal, nil
  457. }
  458. //------------------------------------------------------------
  459. // Public interface for passing messages into the consensus state, possibly causing a state transition.
  460. // If peerID == "", the msg is considered internal.
  461. // Messages are added to the appropriate queue (peer or internal).
  462. // If the queue is full, the function may block.
  463. // TODO: should these return anything or let callers just use events?
  464. // AddVote inputs a vote.
  465. func (cs *State) AddVote(ctx context.Context, vote *types.Vote, peerID types.NodeID) error {
  466. if peerID == "" {
  467. select {
  468. case <-ctx.Done():
  469. return ctx.Err()
  470. case cs.internalMsgQueue <- msgInfo{&VoteMessage{vote}, "", tmtime.Now()}:
  471. return nil
  472. }
  473. } else {
  474. select {
  475. case <-ctx.Done():
  476. return ctx.Err()
  477. case cs.peerMsgQueue <- msgInfo{&VoteMessage{vote}, peerID, tmtime.Now()}:
  478. return nil
  479. }
  480. }
  481. // TODO: wait for event?!
  482. }
  483. // SetProposal inputs a proposal.
  484. func (cs *State) SetProposal(ctx context.Context, proposal *types.Proposal, peerID types.NodeID) error {
  485. if peerID == "" {
  486. select {
  487. case <-ctx.Done():
  488. return ctx.Err()
  489. case cs.internalMsgQueue <- msgInfo{&ProposalMessage{proposal}, "", tmtime.Now()}:
  490. return nil
  491. }
  492. } else {
  493. select {
  494. case <-ctx.Done():
  495. return ctx.Err()
  496. case cs.peerMsgQueue <- msgInfo{&ProposalMessage{proposal}, peerID, tmtime.Now()}:
  497. return nil
  498. }
  499. }
  500. // TODO: wait for event?!
  501. }
  502. // AddProposalBlockPart inputs a part of the proposal block.
  503. func (cs *State) AddProposalBlockPart(ctx context.Context, height int64, round int32, part *types.Part, peerID types.NodeID) error {
  504. if peerID == "" {
  505. select {
  506. case <-ctx.Done():
  507. return ctx.Err()
  508. case cs.internalMsgQueue <- msgInfo{&BlockPartMessage{height, round, part}, "", tmtime.Now()}:
  509. return nil
  510. }
  511. } else {
  512. select {
  513. case <-ctx.Done():
  514. return ctx.Err()
  515. case cs.peerMsgQueue <- msgInfo{&BlockPartMessage{height, round, part}, peerID, tmtime.Now()}:
  516. return nil
  517. }
  518. }
  519. // TODO: wait for event?!
  520. }
  521. // SetProposalAndBlock inputs the proposal and all block parts.
  522. func (cs *State) SetProposalAndBlock(
  523. ctx context.Context,
  524. proposal *types.Proposal,
  525. block *types.Block,
  526. parts *types.PartSet,
  527. peerID types.NodeID,
  528. ) error {
  529. if err := cs.SetProposal(ctx, proposal, peerID); err != nil {
  530. return err
  531. }
  532. for i := 0; i < int(parts.Total()); i++ {
  533. part := parts.GetPart(i)
  534. if err := cs.AddProposalBlockPart(ctx, proposal.Height, proposal.Round, part, peerID); err != nil {
  535. return err
  536. }
  537. }
  538. return nil
  539. }
  540. //------------------------------------------------------------
  541. // internal functions for managing the state
  542. func (cs *State) updateHeight(height int64) {
  543. cs.metrics.Height.Set(float64(height))
  544. cs.Height = height
  545. }
  546. func (cs *State) updateRoundStep(round int32, step cstypes.RoundStepType) {
  547. if !cs.replayMode {
  548. if round != cs.Round || round == 0 && step == cstypes.RoundStepNewRound {
  549. cs.metrics.MarkRound(cs.Round, cs.StartTime)
  550. }
  551. if cs.Step != step {
  552. cs.metrics.MarkStep(cs.Step)
  553. }
  554. }
  555. cs.Round = round
  556. cs.Step = step
  557. }
  558. // enterNewRound(height, 0) at cs.StartTime.
  559. func (cs *State) scheduleRound0(rs *cstypes.RoundState) {
  560. // cs.logger.Info("scheduleRound0", "now", tmtime.Now(), "startTime", cs.StartTime)
  561. sleepDuration := rs.StartTime.Sub(tmtime.Now())
  562. cs.scheduleTimeout(sleepDuration, rs.Height, 0, cstypes.RoundStepNewHeight)
  563. }
  564. // Attempt to schedule a timeout (by sending timeoutInfo on the tickChan)
  565. func (cs *State) scheduleTimeout(duration time.Duration, height int64, round int32, step cstypes.RoundStepType) {
  566. cs.timeoutTicker.ScheduleTimeout(timeoutInfo{duration, height, round, step})
  567. }
  568. // send a msg into the receiveRoutine regarding our own proposal, block part, or vote
  569. func (cs *State) sendInternalMessage(ctx context.Context, mi msgInfo) {
  570. select {
  571. case <-ctx.Done():
  572. case cs.internalMsgQueue <- mi:
  573. default:
  574. // NOTE: using the go-routine means our votes can
  575. // be processed out of order.
  576. // TODO: use CList here for strict determinism and
  577. // attempt push to internalMsgQueue in receiveRoutine
  578. cs.logger.Debug("internal msg queue is full; using a go-routine")
  579. go func() {
  580. select {
  581. case <-ctx.Done():
  582. case cs.internalMsgQueue <- mi:
  583. }
  584. }()
  585. }
  586. }
  587. // Reconstruct LastCommit from SeenCommit, which we saved along with the block,
  588. // (which happens even before saving the state)
  589. func (cs *State) reconstructLastCommit(state sm.State) {
  590. commit := cs.blockStore.LoadSeenCommit()
  591. if commit == nil || commit.Height != state.LastBlockHeight {
  592. commit = cs.blockStore.LoadBlockCommit(state.LastBlockHeight)
  593. }
  594. if commit == nil {
  595. panic(fmt.Sprintf(
  596. "failed to reconstruct last commit; commit for height %v not found",
  597. state.LastBlockHeight,
  598. ))
  599. }
  600. lastPrecommits := types.CommitToVoteSet(state.ChainID, commit, state.LastValidators)
  601. if !lastPrecommits.HasTwoThirdsMajority() {
  602. panic("failed to reconstruct last commit; does not have +2/3 maj")
  603. }
  604. cs.LastCommit = lastPrecommits
  605. }
  606. // Updates State and increments height to match that of state.
  607. // The round becomes 0 and cs.Step becomes cstypes.RoundStepNewHeight.
  608. func (cs *State) updateToState(ctx context.Context, state sm.State) {
  609. if cs.CommitRound > -1 && 0 < cs.Height && cs.Height != state.LastBlockHeight {
  610. panic(fmt.Sprintf(
  611. "updateToState() expected state height of %v but found %v",
  612. cs.Height, state.LastBlockHeight,
  613. ))
  614. }
  615. if !cs.state.IsEmpty() {
  616. if cs.state.LastBlockHeight > 0 && cs.state.LastBlockHeight+1 != cs.Height {
  617. // This might happen when someone else is mutating cs.state.
  618. // Someone forgot to pass in state.Copy() somewhere?!
  619. panic(fmt.Sprintf(
  620. "inconsistent cs.state.LastBlockHeight+1 %v vs cs.Height %v",
  621. cs.state.LastBlockHeight+1, cs.Height,
  622. ))
  623. }
  624. if cs.state.LastBlockHeight > 0 && cs.Height == cs.state.InitialHeight {
  625. panic(fmt.Sprintf(
  626. "inconsistent cs.state.LastBlockHeight %v, expected 0 for initial height %v",
  627. cs.state.LastBlockHeight, cs.state.InitialHeight,
  628. ))
  629. }
  630. // If state isn't further out than cs.state, just ignore.
  631. // This happens when SwitchToConsensus() is called in the reactor.
  632. // We don't want to reset e.g. the Votes, but we still want to
  633. // signal the new round step, because other services (eg. txNotifier)
  634. // depend on having an up-to-date peer state!
  635. if state.LastBlockHeight <= cs.state.LastBlockHeight {
  636. cs.logger.Debug(
  637. "ignoring updateToState()",
  638. "new_height", state.LastBlockHeight+1,
  639. "old_height", cs.state.LastBlockHeight+1,
  640. )
  641. cs.newStep(ctx)
  642. return
  643. }
  644. }
  645. // Reset fields based on state.
  646. validators := state.Validators
  647. switch {
  648. case state.LastBlockHeight == 0: // Very first commit should be empty.
  649. cs.LastCommit = (*types.VoteSet)(nil)
  650. case cs.CommitRound > -1 && cs.Votes != nil: // Otherwise, use cs.Votes
  651. if !cs.Votes.Precommits(cs.CommitRound).HasTwoThirdsMajority() {
  652. panic(fmt.Sprintf(
  653. "wanted to form a commit, but precommits (H/R: %d/%d) didn't have 2/3+: %v",
  654. state.LastBlockHeight, cs.CommitRound, cs.Votes.Precommits(cs.CommitRound),
  655. ))
  656. }
  657. cs.LastCommit = cs.Votes.Precommits(cs.CommitRound)
  658. case cs.LastCommit == nil:
  659. // NOTE: when Tendermint starts, it has no votes. reconstructLastCommit
  660. // must be called to reconstruct LastCommit from SeenCommit.
  661. panic(fmt.Sprintf(
  662. "last commit cannot be empty after initial block (H:%d)",
  663. state.LastBlockHeight+1,
  664. ))
  665. }
  666. // Next desired block height
  667. height := state.LastBlockHeight + 1
  668. if height == 1 {
  669. height = state.InitialHeight
  670. }
  671. // RoundState fields
  672. cs.updateHeight(height)
  673. cs.updateRoundStep(0, cstypes.RoundStepNewHeight)
  674. if cs.CommitTime.IsZero() {
  675. // "Now" makes it easier to sync up dev nodes.
  676. // We add timeoutCommit to allow transactions
  677. // to be gathered for the first block.
  678. // And alternative solution that relies on clocks:
  679. // cs.StartTime = state.LastBlockTime.Add(timeoutCommit)
  680. cs.StartTime = cs.config.Commit(tmtime.Now())
  681. } else {
  682. cs.StartTime = cs.config.Commit(cs.CommitTime)
  683. }
  684. cs.Validators = validators
  685. cs.Proposal = nil
  686. cs.ProposalReceiveTime = time.Time{}
  687. cs.ProposalBlock = nil
  688. cs.ProposalBlockParts = nil
  689. cs.LockedRound = -1
  690. cs.LockedBlock = nil
  691. cs.LockedBlockParts = nil
  692. cs.ValidRound = -1
  693. cs.ValidBlock = nil
  694. cs.ValidBlockParts = nil
  695. cs.Votes = cstypes.NewHeightVoteSet(state.ChainID, height, validators)
  696. cs.CommitRound = -1
  697. cs.LastValidators = state.LastValidators
  698. cs.TriggeredTimeoutPrecommit = false
  699. cs.state = state
  700. // Finally, broadcast RoundState
  701. cs.newStep(ctx)
  702. }
  703. func (cs *State) newStep(ctx context.Context) {
  704. rs := cs.RoundStateEvent()
  705. if err := cs.wal.Write(rs); err != nil {
  706. cs.logger.Error("failed writing to WAL", "err", err)
  707. }
  708. cs.nSteps++
  709. // newStep is called by updateToState in NewState before the eventBus is set!
  710. if cs.eventBus != nil {
  711. if err := cs.eventBus.PublishEventNewRoundStep(ctx, rs); err != nil {
  712. cs.logger.Error("failed publishing new round step", "err", err)
  713. }
  714. cs.evsw.FireEvent(ctx, types.EventNewRoundStepValue, &cs.RoundState)
  715. }
  716. }
  717. //-----------------------------------------
  718. // the main go routines
  719. // receiveRoutine handles messages which may cause state transitions.
  720. // it's argument (n) is the number of messages to process before exiting - use 0 to run forever
  721. // It keeps the RoundState and is the only thing that updates it.
  722. // Updates (state transitions) happen on timeouts, complete proposals, and 2/3 majorities.
  723. // State must be locked before any internal state is updated.
  724. func (cs *State) receiveRoutine(ctx context.Context, maxSteps int) {
  725. onExit := func(cs *State) {
  726. // NOTE: the internalMsgQueue may have signed messages from our
  727. // priv_val that haven't hit the WAL, but its ok because
  728. // priv_val tracks LastSig
  729. // close wal now that we're done writing to it
  730. cs.wal.Stop()
  731. cs.wal.Wait()
  732. close(cs.done)
  733. }
  734. defer func() {
  735. if r := recover(); r != nil {
  736. cs.logger.Error("CONSENSUS FAILURE!!!", "err", r, "stack", string(debug.Stack()))
  737. // Make a best-effort attempt to close the WAL, but otherwise do not
  738. // attempt to gracefully terminate. Once consensus has irrecoverably
  739. // failed, any additional progress we permit the node to make may
  740. // complicate diagnosing and recovering from the failure.
  741. onExit(cs)
  742. // Re-panic to ensure the node terminates.
  743. //
  744. // TODO(creachadair): In ordinary operation, the WAL autofile should
  745. // never be closed. This only happens during shutdown and production
  746. // nodes usually halt by panicking. Many existing tests, however,
  747. // assume a clean shutdown is possible. Prior to #8111, we were
  748. // swallowing the panic in receiveRoutine, making that appear to
  749. // work. Filtering this specific error is slightly risky, but should
  750. // affect only unit tests. In any case, not re-panicking here only
  751. // preserves the pre-existing behavior for this one error type.
  752. if err, ok := r.(error); ok && errors.Is(err, autofile.ErrAutoFileClosed) {
  753. return
  754. }
  755. panic(r)
  756. }
  757. }()
  758. for {
  759. if maxSteps > 0 {
  760. if cs.nSteps >= maxSteps {
  761. cs.logger.Debug("reached max steps; exiting receive routine")
  762. cs.nSteps = 0
  763. return
  764. }
  765. }
  766. select {
  767. case <-cs.txNotifier.TxsAvailable():
  768. cs.handleTxsAvailable(ctx)
  769. case mi := <-cs.peerMsgQueue:
  770. if err := cs.wal.Write(mi); err != nil {
  771. cs.logger.Error("failed writing to WAL", "err", err)
  772. }
  773. // handles proposals, block parts, votes
  774. // may generate internal events (votes, complete proposals, 2/3 majorities)
  775. cs.handleMsg(ctx, mi)
  776. case mi := <-cs.internalMsgQueue:
  777. err := cs.wal.WriteSync(mi) // NOTE: fsync
  778. if err != nil {
  779. panic(fmt.Errorf(
  780. "failed to write %v msg to consensus WAL due to %w; check your file system and restart the node",
  781. mi, err,
  782. ))
  783. }
  784. // handles proposals, block parts, votes
  785. cs.handleMsg(ctx, mi)
  786. case ti := <-cs.timeoutTicker.Chan(): // tockChan:
  787. if err := cs.wal.Write(ti); err != nil {
  788. cs.logger.Error("failed writing to WAL", "err", err)
  789. }
  790. // if the timeout is relevant to the rs
  791. // go to the next step
  792. cs.handleTimeout(ctx, ti, cs.RoundState)
  793. case <-ctx.Done():
  794. onExit(cs)
  795. return
  796. }
  797. // TODO should we handle context cancels here?
  798. }
  799. }
  800. // state transitions on complete-proposal, 2/3-any, 2/3-one
  801. func (cs *State) handleMsg(ctx context.Context, mi msgInfo) {
  802. cs.mtx.Lock()
  803. defer cs.mtx.Unlock()
  804. var (
  805. added bool
  806. err error
  807. )
  808. msg, peerID := mi.Msg, mi.PeerID
  809. switch msg := msg.(type) {
  810. case *ProposalMessage:
  811. // will not cause transition.
  812. // once proposal is set, we can receive block parts
  813. err = cs.setProposal(msg.Proposal, mi.ReceiveTime)
  814. case *BlockPartMessage:
  815. // if the proposal is complete, we'll enterPrevote or tryFinalizeCommit
  816. added, err = cs.addProposalBlockPart(ctx, msg, peerID)
  817. if added {
  818. select {
  819. case cs.statsMsgQueue <- mi:
  820. case <-ctx.Done():
  821. return
  822. }
  823. }
  824. if err != nil && msg.Round != cs.Round {
  825. cs.logger.Debug(
  826. "received block part from wrong round",
  827. "height", cs.Height,
  828. "cs_round", cs.Round,
  829. "block_round", msg.Round,
  830. )
  831. err = nil
  832. }
  833. case *VoteMessage:
  834. // attempt to add the vote and dupeout the validator if its a duplicate signature
  835. // if the vote gives us a 2/3-any or 2/3-one, we transition
  836. added, err = cs.tryAddVote(ctx, msg.Vote, peerID)
  837. if added {
  838. select {
  839. case cs.statsMsgQueue <- mi:
  840. case <-ctx.Done():
  841. return
  842. }
  843. }
  844. // TODO: punish peer
  845. // We probably don't want to stop the peer here. The vote does not
  846. // necessarily comes from a malicious peer but can be just broadcasted by
  847. // a typical peer.
  848. // https://github.com/tendermint/tendermint/issues/1281
  849. // NOTE: the vote is broadcast to peers by the reactor listening
  850. // for vote events
  851. // TODO: If rs.Height == vote.Height && rs.Round < vote.Round,
  852. // the peer is sending us CatchupCommit precommits.
  853. // We could make note of this and help filter in broadcastHasVoteMessage().
  854. default:
  855. cs.logger.Error("unknown msg type", "type", fmt.Sprintf("%T", msg))
  856. return
  857. }
  858. if err != nil {
  859. cs.logger.Error(
  860. "failed to process message",
  861. "height", cs.Height,
  862. "round", cs.Round,
  863. "peer", peerID,
  864. "msg_type", fmt.Sprintf("%T", msg),
  865. "err", err,
  866. )
  867. }
  868. }
  869. func (cs *State) handleTimeout(
  870. ctx context.Context,
  871. ti timeoutInfo,
  872. rs cstypes.RoundState,
  873. ) {
  874. cs.logger.Debug("received tock", "timeout", ti.Duration, "height", ti.Height, "round", ti.Round, "step", ti.Step)
  875. // timeouts must be for current height, round, step
  876. if ti.Height != rs.Height || ti.Round < rs.Round || (ti.Round == rs.Round && ti.Step < rs.Step) {
  877. cs.logger.Debug("ignoring tock because we are ahead", "height", rs.Height, "round", rs.Round, "step", rs.Step)
  878. return
  879. }
  880. // the timeout will now cause a state transition
  881. cs.mtx.Lock()
  882. defer cs.mtx.Unlock()
  883. switch ti.Step {
  884. case cstypes.RoundStepNewHeight:
  885. // NewRound event fired from enterNewRound.
  886. // XXX: should we fire timeout here (for timeout commit)?
  887. cs.enterNewRound(ctx, ti.Height, 0)
  888. case cstypes.RoundStepNewRound:
  889. cs.enterPropose(ctx, ti.Height, 0)
  890. case cstypes.RoundStepPropose:
  891. if err := cs.eventBus.PublishEventTimeoutPropose(ctx, cs.RoundStateEvent()); err != nil {
  892. cs.logger.Error("failed publishing timeout propose", "err", err)
  893. }
  894. cs.enterPrevote(ctx, ti.Height, ti.Round)
  895. case cstypes.RoundStepPrevoteWait:
  896. if err := cs.eventBus.PublishEventTimeoutWait(ctx, cs.RoundStateEvent()); err != nil {
  897. cs.logger.Error("failed publishing timeout wait", "err", err)
  898. }
  899. cs.enterPrecommit(ctx, ti.Height, ti.Round)
  900. case cstypes.RoundStepPrecommitWait:
  901. if err := cs.eventBus.PublishEventTimeoutWait(ctx, cs.RoundStateEvent()); err != nil {
  902. cs.logger.Error("failed publishing timeout wait", "err", err)
  903. }
  904. cs.enterPrecommit(ctx, ti.Height, ti.Round)
  905. cs.enterNewRound(ctx, ti.Height, ti.Round+1)
  906. default:
  907. panic(fmt.Sprintf("invalid timeout step: %v", ti.Step))
  908. }
  909. }
  910. func (cs *State) handleTxsAvailable(ctx context.Context) {
  911. cs.mtx.Lock()
  912. defer cs.mtx.Unlock()
  913. // We only need to do this for round 0.
  914. if cs.Round != 0 {
  915. return
  916. }
  917. switch cs.Step {
  918. case cstypes.RoundStepNewHeight: // timeoutCommit phase
  919. if cs.needProofBlock(cs.Height) {
  920. // enterPropose will be called by enterNewRound
  921. return
  922. }
  923. // +1ms to ensure RoundStepNewRound timeout always happens after RoundStepNewHeight
  924. timeoutCommit := cs.StartTime.Sub(tmtime.Now()) + 1*time.Millisecond
  925. cs.scheduleTimeout(timeoutCommit, cs.Height, 0, cstypes.RoundStepNewRound)
  926. case cstypes.RoundStepNewRound: // after timeoutCommit
  927. cs.enterPropose(ctx, cs.Height, 0)
  928. }
  929. }
  930. //-----------------------------------------------------------------------------
  931. // State functions
  932. // Used internally by handleTimeout and handleMsg to make state transitions
  933. // Enter: `timeoutNewHeight` by startTime (commitTime+timeoutCommit),
  934. // or, if SkipTimeoutCommit==true, after receiving all precommits from (height,round-1)
  935. // Enter: `timeoutPrecommits` after any +2/3 precommits from (height,round-1)
  936. // Enter: +2/3 precommits for nil at (height,round-1)
  937. // Enter: +2/3 prevotes any or +2/3 precommits for block or any from (height, round)
  938. // NOTE: cs.StartTime was already set for height.
  939. func (cs *State) enterNewRound(ctx context.Context, height int64, round int32) {
  940. // TODO: remove panics in this function and return an error
  941. logger := cs.logger.With("height", height, "round", round)
  942. if cs.Height != height || round < cs.Round || (cs.Round == round && cs.Step != cstypes.RoundStepNewHeight) {
  943. logger.Debug(
  944. "entering new round with invalid args",
  945. "current", fmt.Sprintf("%v/%v/%v", cs.Height, cs.Round, cs.Step),
  946. )
  947. return
  948. }
  949. if now := tmtime.Now(); cs.StartTime.After(now) {
  950. logger.Debug("need to set a buffer and log message here for sanity", "start_time", cs.StartTime, "now", now)
  951. }
  952. logger.Debug("entering new round", "current", fmt.Sprintf("%v/%v/%v", cs.Height, cs.Round, cs.Step))
  953. // increment validators if necessary
  954. validators := cs.Validators
  955. if cs.Round < round {
  956. validators = validators.Copy()
  957. r, err := tmmath.SafeSubInt32(round, cs.Round)
  958. if err != nil {
  959. panic(err)
  960. }
  961. validators.IncrementProposerPriority(r)
  962. }
  963. // Setup new round
  964. // we don't fire newStep for this step,
  965. // but we fire an event, so update the round step first
  966. cs.updateRoundStep(round, cstypes.RoundStepNewRound)
  967. cs.Validators = validators
  968. if round == 0 {
  969. // We've already reset these upon new height,
  970. // and meanwhile we might have received a proposal
  971. // for round 0.
  972. } else {
  973. logger.Debug("resetting proposal info")
  974. cs.Proposal = nil
  975. cs.ProposalReceiveTime = time.Time{}
  976. cs.ProposalBlock = nil
  977. cs.ProposalBlockParts = nil
  978. }
  979. r, err := tmmath.SafeAddInt32(round, 1)
  980. if err != nil {
  981. panic(err)
  982. }
  983. cs.Votes.SetRound(r) // also track next round (round+1) to allow round-skipping
  984. cs.TriggeredTimeoutPrecommit = false
  985. if err := cs.eventBus.PublishEventNewRound(ctx, cs.NewRoundEvent()); err != nil {
  986. cs.logger.Error("failed publishing new round", "err", err)
  987. }
  988. // Wait for txs to be available in the mempool
  989. // before we enterPropose in round 0. If the last block changed the app hash,
  990. // we may need an empty "proof" block, and enterPropose immediately.
  991. waitForTxs := cs.config.WaitForTxs() && round == 0 && !cs.needProofBlock(height)
  992. if waitForTxs {
  993. if cs.config.CreateEmptyBlocksInterval > 0 {
  994. cs.scheduleTimeout(cs.config.CreateEmptyBlocksInterval, height, round,
  995. cstypes.RoundStepNewRound)
  996. }
  997. return
  998. }
  999. cs.enterPropose(ctx, height, round)
  1000. }
  1001. // needProofBlock returns true on the first height (so the genesis app hash is signed right away)
  1002. // and where the last block (height-1) caused the app hash to change
  1003. func (cs *State) needProofBlock(height int64) bool {
  1004. if height == cs.state.InitialHeight {
  1005. return true
  1006. }
  1007. lastBlockMeta := cs.blockStore.LoadBlockMeta(height - 1)
  1008. if lastBlockMeta == nil {
  1009. panic(fmt.Sprintf("needProofBlock: last block meta for height %d not found", height-1))
  1010. }
  1011. return !bytes.Equal(cs.state.AppHash, lastBlockMeta.Header.AppHash)
  1012. }
  1013. // Enter (CreateEmptyBlocks): from enterNewRound(height,round)
  1014. // Enter (CreateEmptyBlocks, CreateEmptyBlocksInterval > 0 ):
  1015. // after enterNewRound(height,round), after timeout of CreateEmptyBlocksInterval
  1016. // Enter (!CreateEmptyBlocks) : after enterNewRound(height,round), once txs are in the mempool
  1017. func (cs *State) enterPropose(ctx context.Context, height int64, round int32) {
  1018. logger := cs.logger.With("height", height, "round", round)
  1019. if cs.Height != height || round < cs.Round || (cs.Round == round && cstypes.RoundStepPropose <= cs.Step) {
  1020. logger.Debug(
  1021. "entering propose step with invalid args",
  1022. "current", fmt.Sprintf("%v/%v/%v", cs.Height, cs.Round, cs.Step),
  1023. )
  1024. return
  1025. }
  1026. // If this validator is the proposer of this round, and the previous block time is later than
  1027. // our local clock time, wait to propose until our local clock time has passed the block time.
  1028. if cs.privValidatorPubKey != nil && cs.isProposer(cs.privValidatorPubKey.Address()) {
  1029. proposerWaitTime := proposerWaitTime(tmtime.DefaultSource{}, cs.state.LastBlockTime)
  1030. if proposerWaitTime > 0 {
  1031. cs.scheduleTimeout(proposerWaitTime, height, round, cstypes.RoundStepNewRound)
  1032. return
  1033. }
  1034. }
  1035. logger.Debug("entering propose step", "current", fmt.Sprintf("%v/%v/%v", cs.Height, cs.Round, cs.Step))
  1036. defer func() {
  1037. // Done enterPropose:
  1038. cs.updateRoundStep(round, cstypes.RoundStepPropose)
  1039. cs.newStep(ctx)
  1040. // If we have the whole proposal + POL, then goto Prevote now.
  1041. // else, we'll enterPrevote when the rest of the proposal is received (in AddProposalBlockPart),
  1042. // or else after timeoutPropose
  1043. if cs.isProposalComplete() {
  1044. cs.enterPrevote(ctx, height, cs.Round)
  1045. }
  1046. }()
  1047. // If we don't get the proposal and all block parts quick enough, enterPrevote
  1048. cs.scheduleTimeout(cs.config.Propose(round), height, round, cstypes.RoundStepPropose)
  1049. // Nothing more to do if we're not a validator
  1050. if cs.privValidator == nil {
  1051. logger.Debug("propose step; not proposing since node is not a validator")
  1052. return
  1053. }
  1054. if cs.privValidatorPubKey == nil {
  1055. // If this node is a validator & proposer in the current round, it will
  1056. // miss the opportunity to create a block.
  1057. logger.Error("propose step; empty priv validator public key", "err", errPubKeyIsNotSet)
  1058. return
  1059. }
  1060. addr := cs.privValidatorPubKey.Address()
  1061. // if not a validator, we're done
  1062. if !cs.Validators.HasAddress(addr) {
  1063. logger.Debug("propose step; not proposing since node is not in the validator set",
  1064. "addr", addr,
  1065. "vals", cs.Validators)
  1066. return
  1067. }
  1068. if cs.isProposer(addr) {
  1069. logger.Debug(
  1070. "propose step; our turn to propose",
  1071. "proposer", addr,
  1072. )
  1073. cs.decideProposal(ctx, height, round)
  1074. } else {
  1075. logger.Debug(
  1076. "propose step; not our turn to propose",
  1077. "proposer", cs.Validators.GetProposer().Address,
  1078. )
  1079. }
  1080. }
  1081. func (cs *State) isProposer(address []byte) bool {
  1082. return bytes.Equal(cs.Validators.GetProposer().Address, address)
  1083. }
  1084. func (cs *State) defaultDecideProposal(ctx context.Context, height int64, round int32) {
  1085. var block *types.Block
  1086. var blockParts *types.PartSet
  1087. // Decide on block
  1088. if cs.ValidBlock != nil {
  1089. // If there is valid block, choose that.
  1090. block, blockParts = cs.ValidBlock, cs.ValidBlockParts
  1091. } else {
  1092. // Create a new proposal block from state/txs from the mempool.
  1093. var err error
  1094. block, blockParts, err = cs.createProposalBlock(ctx)
  1095. if block == nil || err != nil {
  1096. return
  1097. }
  1098. }
  1099. // Flush the WAL. Otherwise, we may not recompute the same proposal to sign,
  1100. // and the privValidator will refuse to sign anything.
  1101. if err := cs.wal.FlushAndSync(); err != nil {
  1102. cs.logger.Error("failed flushing WAL to disk")
  1103. }
  1104. // Make proposal
  1105. propBlockID := types.BlockID{Hash: block.Hash(), PartSetHeader: blockParts.Header()}
  1106. proposal := types.NewProposal(height, round, cs.ValidRound, propBlockID, block.Header.Time)
  1107. p := proposal.ToProto()
  1108. // wait the max amount we would wait for a proposal
  1109. ctxto, cancel := context.WithTimeout(ctx, cs.config.TimeoutPropose)
  1110. defer cancel()
  1111. if err := cs.privValidator.SignProposal(ctxto, cs.state.ChainID, p); err == nil {
  1112. proposal.Signature = p.Signature
  1113. // send proposal and block parts on internal msg queue
  1114. cs.sendInternalMessage(ctx, msgInfo{&ProposalMessage{proposal}, "", tmtime.Now()})
  1115. for i := 0; i < int(blockParts.Total()); i++ {
  1116. part := blockParts.GetPart(i)
  1117. cs.sendInternalMessage(ctx, msgInfo{&BlockPartMessage{cs.Height, cs.Round, part}, "", tmtime.Now()})
  1118. }
  1119. cs.logger.Debug("signed proposal", "height", height, "round", round, "proposal", proposal)
  1120. } else if !cs.replayMode {
  1121. cs.logger.Error("propose step; failed signing proposal", "height", height, "round", round, "err", err)
  1122. }
  1123. }
  1124. // Returns true if the proposal block is complete &&
  1125. // (if POLRound was proposed, we have +2/3 prevotes from there).
  1126. func (cs *State) isProposalComplete() bool {
  1127. if cs.Proposal == nil || cs.ProposalBlock == nil {
  1128. return false
  1129. }
  1130. // we have the proposal. if there's a POLRound,
  1131. // make sure we have the prevotes from it too
  1132. if cs.Proposal.POLRound < 0 {
  1133. return true
  1134. }
  1135. // if this is false the proposer is lying or we haven't received the POL yet
  1136. return cs.Votes.Prevotes(cs.Proposal.POLRound).HasTwoThirdsMajority()
  1137. }
  1138. // Create the next block to propose and return it. Returns nil block upon error.
  1139. //
  1140. // We really only need to return the parts, but the block is returned for
  1141. // convenience so we can log the proposal block.
  1142. //
  1143. // NOTE: keep it side-effect free for clarity.
  1144. // CONTRACT: cs.privValidator is not nil.
  1145. func (cs *State) createProposalBlock(ctx context.Context) (block *types.Block, blockParts *types.PartSet, err error) {
  1146. if cs.privValidator == nil {
  1147. return nil, nil, errors.New("entered createProposalBlock with privValidator being nil")
  1148. }
  1149. var commit *types.Commit
  1150. var votes []*types.Vote
  1151. switch {
  1152. case cs.Height == cs.state.InitialHeight:
  1153. // We're creating a proposal for the first block.
  1154. // The commit is empty, but not nil.
  1155. commit = types.NewCommit(0, 0, types.BlockID{}, nil)
  1156. case cs.LastCommit.HasTwoThirdsMajority():
  1157. // Make the commit from LastCommit
  1158. commit = cs.LastCommit.MakeCommit()
  1159. votes = cs.LastCommit.GetVotes()
  1160. default: // This shouldn't happen.
  1161. cs.logger.Error("propose step; cannot propose anything without commit for the previous block")
  1162. return
  1163. }
  1164. if cs.privValidatorPubKey == nil {
  1165. // If this node is a validator & proposer in the current round, it will
  1166. // miss the opportunity to create a block.
  1167. cs.logger.Error("propose step; empty priv validator public key", "err", errPubKeyIsNotSet)
  1168. return
  1169. }
  1170. proposerAddr := cs.privValidatorPubKey.Address()
  1171. return cs.blockExec.CreateProposalBlock(ctx, cs.Height, cs.state, commit, proposerAddr, votes)
  1172. }
  1173. // Enter: `timeoutPropose` after entering Propose.
  1174. // Enter: proposal block and POL is ready.
  1175. // If we received a valid proposal within this round and we are not locked on a block,
  1176. // we will prevote for block.
  1177. // Otherwise, if we receive a valid proposal that matches the block we are
  1178. // locked on or matches a block that received a POL in a round later than our
  1179. // locked round, prevote for the proposal, otherwise vote nil.
  1180. func (cs *State) enterPrevote(ctx context.Context, height int64, round int32) {
  1181. logger := cs.logger.With("height", height, "round", round)
  1182. if cs.Height != height || round < cs.Round || (cs.Round == round && cstypes.RoundStepPrevote <= cs.Step) {
  1183. logger.Debug(
  1184. "entering prevote step with invalid args",
  1185. "current", fmt.Sprintf("%v/%v/%v", cs.Height, cs.Round, cs.Step),
  1186. )
  1187. return
  1188. }
  1189. defer func() {
  1190. // Done enterPrevote:
  1191. cs.updateRoundStep(round, cstypes.RoundStepPrevote)
  1192. cs.newStep(ctx)
  1193. }()
  1194. logger.Debug("entering prevote step", "current", fmt.Sprintf("%v/%v/%v", cs.Height, cs.Round, cs.Step))
  1195. // Sign and broadcast vote as necessary
  1196. cs.doPrevote(ctx, height, round)
  1197. // Once `addVote` hits any +2/3 prevotes, we will go to PrevoteWait
  1198. // (so we have more time to try and collect +2/3 prevotes for a single block)
  1199. }
  1200. func (cs *State) proposalIsTimely() bool {
  1201. sp := types.SynchronyParams{
  1202. Precision: cs.state.ConsensusParams.Synchrony.Precision,
  1203. MessageDelay: cs.state.ConsensusParams.Synchrony.MessageDelay,
  1204. }
  1205. return cs.Proposal.IsTimely(cs.ProposalReceiveTime, sp, cs.Round)
  1206. }
  1207. func (cs *State) defaultDoPrevote(ctx context.Context, height int64, round int32) {
  1208. logger := cs.logger.With("height", height, "round", round)
  1209. // Check that a proposed block was not received within this round (and thus executing this from a timeout).
  1210. if cs.ProposalBlock == nil {
  1211. logger.Debug("prevote step: ProposalBlock is nil; prevoting nil")
  1212. cs.signAddVote(ctx, tmproto.PrevoteType, nil, types.PartSetHeader{})
  1213. return
  1214. }
  1215. if cs.Proposal == nil {
  1216. logger.Debug("prevote step: did not receive proposal; prevoting nil")
  1217. cs.signAddVote(ctx, tmproto.PrevoteType, nil, types.PartSetHeader{})
  1218. return
  1219. }
  1220. if !cs.Proposal.Timestamp.Equal(cs.ProposalBlock.Header.Time) {
  1221. logger.Debug("prevote step: proposal timestamp not equal; prevoting nil")
  1222. cs.signAddVote(ctx, tmproto.PrevoteType, nil, types.PartSetHeader{})
  1223. return
  1224. }
  1225. if cs.Proposal.POLRound == -1 && cs.LockedRound == -1 && !cs.proposalIsTimely() {
  1226. logger.Debug("prevote step: Proposal is not timely; prevoting nil",
  1227. "proposed",
  1228. tmtime.Canonical(cs.Proposal.Timestamp).Format(time.RFC3339Nano),
  1229. "received",
  1230. tmtime.Canonical(cs.ProposalReceiveTime).Format(time.RFC3339Nano),
  1231. "msg_delay",
  1232. cs.state.ConsensusParams.Synchrony.MessageDelay,
  1233. "precision",
  1234. cs.state.ConsensusParams.Synchrony.Precision)
  1235. cs.signAddVote(ctx, tmproto.PrevoteType, nil, types.PartSetHeader{})
  1236. return
  1237. }
  1238. // Validate proposal block, from Tendermint's perspective
  1239. err := cs.blockExec.ValidateBlock(ctx, cs.state, cs.ProposalBlock)
  1240. if err != nil {
  1241. // ProposalBlock is invalid, prevote nil.
  1242. logger.Error("prevote step: consensus deems this block invalid; prevoting nil",
  1243. "err", err)
  1244. cs.signAddVote(ctx, tmproto.PrevoteType, nil, types.PartSetHeader{})
  1245. return
  1246. }
  1247. /*
  1248. The block has now passed Tendermint's validation rules.
  1249. Before prevoting the block received from the proposer for the current round and height,
  1250. we request the Application, via the ProcessProposal, ABCI call to confirm that the block is
  1251. valid. If the Application does not accept the block, Tendermint prevotes nil.
  1252. WARNING: misuse of block rejection by the Application can seriously compromise Tendermint's
  1253. liveness properties. Please see PrepareProposal-ProcessProposal coherence and determinism
  1254. properties in the ABCI++ specification.
  1255. */
  1256. isAppValid, err := cs.blockExec.ProcessProposal(ctx, cs.ProposalBlock, cs.state)
  1257. if err != nil {
  1258. panic(fmt.Sprintf("ProcessProposal: %v", err))
  1259. }
  1260. // Vote nil if the Application rejected the block
  1261. if !isAppValid {
  1262. logger.Error("prevote step: state machine rejected a proposed block; this should not happen:"+
  1263. "the proposer may be misbehaving; prevoting nil", "err", err)
  1264. cs.signAddVote(ctx, tmproto.PrevoteType, nil, types.PartSetHeader{})
  1265. return
  1266. }
  1267. /*
  1268. 22: upon <PROPOSAL, h_p, round_p, v, 1> from proposer(h_p, round_p) while step_p = propose do
  1269. 23: if valid(v) && (lockedRound_p = 1 || lockedValue_p = v) then
  1270. 24: broadcast <PREVOTE, h_p, round_p, id(v)>
  1271. Here, cs.Proposal.POLRound corresponds to the -1 in the above algorithm rule.
  1272. This means that the proposer is producing a new proposal that has not previously
  1273. seen a 2/3 majority by the network.
  1274. If we have already locked on a different value that is different from the proposed value,
  1275. we prevote nil since we are locked on a different value. Otherwise, if we're not locked on a block
  1276. or the proposal matches our locked block, we prevote the proposal.
  1277. */
  1278. if cs.Proposal.POLRound == -1 {
  1279. if cs.LockedRound == -1 {
  1280. logger.Debug("prevote step: ProposalBlock is valid and there is no locked block; prevoting the proposal")
  1281. cs.signAddVote(ctx, tmproto.PrevoteType, cs.ProposalBlock.Hash(), cs.ProposalBlockParts.Header())
  1282. return
  1283. }
  1284. if cs.ProposalBlock.HashesTo(cs.LockedBlock.Hash()) {
  1285. logger.Debug("prevote step: ProposalBlock is valid and matches our locked block; prevoting the proposal")
  1286. cs.signAddVote(ctx, tmproto.PrevoteType, cs.ProposalBlock.Hash(), cs.ProposalBlockParts.Header())
  1287. return
  1288. }
  1289. }
  1290. /*
  1291. 28: upon <PROPOSAL, h_p, round_p, v, v_r> from proposer(h_p, round_p) AND 2f + 1 <PREVOTE, h_p, v_r, id(v)> while
  1292. step_p = propose && (v_r 0 && v_r < round_p) do
  1293. 29: if valid(v) && (lockedRound_p v_r || lockedValue_p = v) then
  1294. 30: broadcast <PREVOTE, h_p, round_p, id(v)>
  1295. This rule is a bit confusing but breaks down as follows:
  1296. If we see a proposal in the current round for value 'v' that lists its valid round as 'v_r'
  1297. AND this validator saw a 2/3 majority of the voting power prevote 'v' in round 'v_r', then we will
  1298. issue a prevote for 'v' in this round if 'v' is valid and either matches our locked value OR
  1299. 'v_r' is a round greater than or equal to our current locked round.
  1300. 'v_r' can be a round greater than to our current locked round if a 2/3 majority of
  1301. the network prevoted a value in round 'v_r' but we did not lock on it, possibly because we
  1302. missed the proposal in round 'v_r'.
  1303. */
  1304. blockID, ok := cs.Votes.Prevotes(cs.Proposal.POLRound).TwoThirdsMajority()
  1305. if ok && cs.ProposalBlock.HashesTo(blockID.Hash) && cs.Proposal.POLRound >= 0 && cs.Proposal.POLRound < cs.Round {
  1306. if cs.LockedRound <= cs.Proposal.POLRound {
  1307. logger.Debug("prevote step: ProposalBlock is valid and received a 2/3" +
  1308. "majority in a round later than the locked round; prevoting the proposal")
  1309. cs.signAddVote(ctx, tmproto.PrevoteType, cs.ProposalBlock.Hash(), cs.ProposalBlockParts.Header())
  1310. return
  1311. }
  1312. if cs.ProposalBlock.HashesTo(cs.LockedBlock.Hash()) {
  1313. logger.Debug("prevote step: ProposalBlock is valid and matches our locked block; prevoting the proposal")
  1314. cs.signAddVote(ctx, tmproto.PrevoteType, cs.ProposalBlock.Hash(), cs.ProposalBlockParts.Header())
  1315. return
  1316. }
  1317. }
  1318. logger.Debug("prevote step: ProposalBlock is valid but was not our locked block or " +
  1319. "did not receive a more recent majority; prevoting nil")
  1320. cs.signAddVote(ctx, tmproto.PrevoteType, nil, types.PartSetHeader{})
  1321. }
  1322. // Enter: any +2/3 prevotes at next round.
  1323. func (cs *State) enterPrevoteWait(ctx context.Context, height int64, round int32) {
  1324. logger := cs.logger.With("height", height, "round", round)
  1325. if cs.Height != height || round < cs.Round || (cs.Round == round && cstypes.RoundStepPrevoteWait <= cs.Step) {
  1326. logger.Debug(
  1327. "entering prevote wait step with invalid args",
  1328. "current", fmt.Sprintf("%v/%v/%v", cs.Height, cs.Round, cs.Step),
  1329. )
  1330. return
  1331. }
  1332. if !cs.Votes.Prevotes(round).HasTwoThirdsAny() {
  1333. panic(fmt.Sprintf(
  1334. "entering prevote wait step (%v/%v), but prevotes does not have any +2/3 votes",
  1335. height, round,
  1336. ))
  1337. }
  1338. logger.Debug("entering prevote wait step", "current", fmt.Sprintf("%v/%v/%v", cs.Height, cs.Round, cs.Step))
  1339. defer func() {
  1340. // Done enterPrevoteWait:
  1341. cs.updateRoundStep(round, cstypes.RoundStepPrevoteWait)
  1342. cs.newStep(ctx)
  1343. }()
  1344. // Wait for some more prevotes; enterPrecommit
  1345. cs.scheduleTimeout(cs.config.Prevote(round), height, round, cstypes.RoundStepPrevoteWait)
  1346. }
  1347. // Enter: `timeoutPrevote` after any +2/3 prevotes.
  1348. // Enter: `timeoutPrecommit` after any +2/3 precommits.
  1349. // Enter: +2/3 precomits for block or nil.
  1350. // Lock & precommit the ProposalBlock if we have enough prevotes for it (a POL in this round)
  1351. // else, precommit nil otherwise.
  1352. func (cs *State) enterPrecommit(ctx context.Context, height int64, round int32) {
  1353. logger := cs.logger.With("height", height, "round", round)
  1354. if cs.Height != height || round < cs.Round || (cs.Round == round && cstypes.RoundStepPrecommit <= cs.Step) {
  1355. logger.Debug(
  1356. "entering precommit step with invalid args",
  1357. "current", fmt.Sprintf("%v/%v/%v", cs.Height, cs.Round, cs.Step),
  1358. )
  1359. return
  1360. }
  1361. logger.Debug("entering precommit step", "current", fmt.Sprintf("%v/%v/%v", cs.Height, cs.Round, cs.Step))
  1362. defer func() {
  1363. // Done enterPrecommit:
  1364. cs.updateRoundStep(round, cstypes.RoundStepPrecommit)
  1365. cs.newStep(ctx)
  1366. }()
  1367. // check for a polka
  1368. blockID, ok := cs.Votes.Prevotes(round).TwoThirdsMajority()
  1369. // If we don't have a polka, we must precommit nil.
  1370. if !ok {
  1371. if cs.LockedBlock != nil {
  1372. logger.Debug("precommit step; no +2/3 prevotes during enterPrecommit while we are locked; precommitting nil")
  1373. } else {
  1374. logger.Debug("precommit step; no +2/3 prevotes during enterPrecommit; precommitting nil")
  1375. }
  1376. cs.signAddVote(ctx, tmproto.PrecommitType, nil, types.PartSetHeader{})
  1377. return
  1378. }
  1379. // At this point +2/3 prevoted for a particular block or nil.
  1380. if err := cs.eventBus.PublishEventPolka(ctx, cs.RoundStateEvent()); err != nil {
  1381. logger.Error("failed publishing polka", "err", err)
  1382. }
  1383. // the latest POLRound should be this round.
  1384. polRound, _ := cs.Votes.POLInfo()
  1385. if polRound < round {
  1386. panic(fmt.Sprintf("this POLRound should be %v but got %v", round, polRound))
  1387. }
  1388. // +2/3 prevoted nil. Precommit nil.
  1389. if blockID.IsNil() {
  1390. logger.Debug("precommit step: +2/3 prevoted for nil; precommitting nil")
  1391. cs.signAddVote(ctx, tmproto.PrecommitType, nil, types.PartSetHeader{})
  1392. return
  1393. }
  1394. // At this point, +2/3 prevoted for a particular block.
  1395. // If we never received a proposal for this block, we must precommit nil
  1396. if cs.Proposal == nil || cs.ProposalBlock == nil {
  1397. logger.Debug("precommit step; did not receive proposal, precommitting nil")
  1398. cs.signAddVote(ctx, tmproto.PrecommitType, nil, types.PartSetHeader{})
  1399. return
  1400. }
  1401. // If the proposal time does not match the block time, precommit nil.
  1402. if !cs.Proposal.Timestamp.Equal(cs.ProposalBlock.Header.Time) {
  1403. logger.Debug("precommit step: proposal timestamp not equal; precommitting nil")
  1404. cs.signAddVote(ctx, tmproto.PrecommitType, nil, types.PartSetHeader{})
  1405. return
  1406. }
  1407. // If we're already locked on that block, precommit it, and update the LockedRound
  1408. if cs.LockedBlock.HashesTo(blockID.Hash) {
  1409. logger.Debug("precommit step: +2/3 prevoted locked block; relocking")
  1410. cs.LockedRound = round
  1411. if err := cs.eventBus.PublishEventRelock(ctx, cs.RoundStateEvent()); err != nil {
  1412. logger.Error("precommit step: failed publishing event relock", "err", err)
  1413. }
  1414. cs.signAddVote(ctx, tmproto.PrecommitType, blockID.Hash, blockID.PartSetHeader)
  1415. return
  1416. }
  1417. // If greater than 2/3 of the voting power on the network prevoted for
  1418. // the proposed block, update our locked block to this block and issue a
  1419. // precommit vote for it.
  1420. if cs.ProposalBlock.HashesTo(blockID.Hash) {
  1421. logger.Debug("precommit step: +2/3 prevoted proposal block; locking", "hash", blockID.Hash)
  1422. // Validate the block.
  1423. if err := cs.blockExec.ValidateBlock(ctx, cs.state, cs.ProposalBlock); err != nil {
  1424. panic(fmt.Sprintf("precommit step: +2/3 prevoted for an invalid block %v; relocking", err))
  1425. }
  1426. cs.LockedRound = round
  1427. cs.LockedBlock = cs.ProposalBlock
  1428. cs.LockedBlockParts = cs.ProposalBlockParts
  1429. if err := cs.eventBus.PublishEventLock(ctx, cs.RoundStateEvent()); err != nil {
  1430. logger.Error("precommit step: failed publishing event lock", "err", err)
  1431. }
  1432. cs.signAddVote(ctx, tmproto.PrecommitType, blockID.Hash, blockID.PartSetHeader)
  1433. return
  1434. }
  1435. // There was a polka in this round for a block we don't have.
  1436. // Fetch that block, and precommit nil.
  1437. logger.Debug("precommit step: +2/3 prevotes for a block we do not have; voting nil", "block_id", blockID)
  1438. if !cs.ProposalBlockParts.HasHeader(blockID.PartSetHeader) {
  1439. cs.ProposalBlock = nil
  1440. cs.metrics.MarkBlockGossipStarted()
  1441. cs.ProposalBlockParts = types.NewPartSetFromHeader(blockID.PartSetHeader)
  1442. }
  1443. cs.signAddVote(ctx, tmproto.PrecommitType, nil, types.PartSetHeader{})
  1444. }
  1445. // Enter: any +2/3 precommits for next round.
  1446. func (cs *State) enterPrecommitWait(ctx context.Context, height int64, round int32) {
  1447. logger := cs.logger.With("height", height, "round", round)
  1448. if cs.Height != height || round < cs.Round || (cs.Round == round && cs.TriggeredTimeoutPrecommit) {
  1449. logger.Debug(
  1450. "entering precommit wait step with invalid args",
  1451. "triggered_timeout", cs.TriggeredTimeoutPrecommit,
  1452. "current", fmt.Sprintf("%v/%v", cs.Height, cs.Round),
  1453. )
  1454. return
  1455. }
  1456. if !cs.Votes.Precommits(round).HasTwoThirdsAny() {
  1457. panic(fmt.Sprintf(
  1458. "entering precommit wait step (%v/%v), but precommits does not have any +2/3 votes",
  1459. height, round,
  1460. ))
  1461. }
  1462. logger.Debug("entering precommit wait step", "current", fmt.Sprintf("%v/%v/%v", cs.Height, cs.Round, cs.Step))
  1463. defer func() {
  1464. // Done enterPrecommitWait:
  1465. cs.TriggeredTimeoutPrecommit = true
  1466. cs.newStep(ctx)
  1467. }()
  1468. // wait for some more precommits; enterNewRound
  1469. cs.scheduleTimeout(cs.config.Precommit(round), height, round, cstypes.RoundStepPrecommitWait)
  1470. }
  1471. // Enter: +2/3 precommits for block
  1472. func (cs *State) enterCommit(ctx context.Context, height int64, commitRound int32) {
  1473. logger := cs.logger.With("height", height, "commit_round", commitRound)
  1474. if cs.Height != height || cstypes.RoundStepCommit <= cs.Step {
  1475. logger.Debug(
  1476. "entering commit step with invalid args",
  1477. "current", fmt.Sprintf("%v/%v/%v", cs.Height, cs.Round, cs.Step),
  1478. )
  1479. return
  1480. }
  1481. logger.Debug("entering commit step", "current", fmt.Sprintf("%v/%v/%v", cs.Height, cs.Round, cs.Step))
  1482. defer func() {
  1483. // Done enterCommit:
  1484. // keep cs.Round the same, commitRound points to the right Precommits set.
  1485. cs.updateRoundStep(cs.Round, cstypes.RoundStepCommit)
  1486. cs.CommitRound = commitRound
  1487. cs.CommitTime = tmtime.Now()
  1488. cs.newStep(ctx)
  1489. // Maybe finalize immediately.
  1490. cs.tryFinalizeCommit(ctx, height)
  1491. }()
  1492. blockID, ok := cs.Votes.Precommits(commitRound).TwoThirdsMajority()
  1493. if !ok {
  1494. panic("RunActionCommit() expects +2/3 precommits")
  1495. }
  1496. // The Locked* fields no longer matter.
  1497. // Move them over to ProposalBlock if they match the commit hash,
  1498. // otherwise they'll be cleared in updateToState.
  1499. if cs.LockedBlock.HashesTo(blockID.Hash) {
  1500. logger.Debug("commit is for a locked block; set ProposalBlock=LockedBlock", "block_hash", blockID.Hash)
  1501. cs.ProposalBlock = cs.LockedBlock
  1502. cs.ProposalBlockParts = cs.LockedBlockParts
  1503. }
  1504. // If we don't have the block being committed, set up to get it.
  1505. if !cs.ProposalBlock.HashesTo(blockID.Hash) {
  1506. if !cs.ProposalBlockParts.HasHeader(blockID.PartSetHeader) {
  1507. logger.Info(
  1508. "commit is for a block we do not know about; set ProposalBlock=nil",
  1509. "proposal", cs.ProposalBlock.Hash(),
  1510. "commit", blockID.Hash,
  1511. )
  1512. // We're getting the wrong block.
  1513. // Set up ProposalBlockParts and keep waiting.
  1514. cs.ProposalBlock = nil
  1515. cs.metrics.MarkBlockGossipStarted()
  1516. cs.ProposalBlockParts = types.NewPartSetFromHeader(blockID.PartSetHeader)
  1517. if err := cs.eventBus.PublishEventValidBlock(ctx, cs.RoundStateEvent()); err != nil {
  1518. logger.Error("failed publishing valid block", "err", err)
  1519. }
  1520. cs.evsw.FireEvent(ctx, types.EventValidBlockValue, &cs.RoundState)
  1521. }
  1522. }
  1523. }
  1524. // If we have the block AND +2/3 commits for it, finalize.
  1525. func (cs *State) tryFinalizeCommit(ctx context.Context, height int64) {
  1526. logger := cs.logger.With("height", height)
  1527. if cs.Height != height {
  1528. panic(fmt.Sprintf("tryFinalizeCommit() cs.Height: %v vs height: %v", cs.Height, height))
  1529. }
  1530. blockID, ok := cs.Votes.Precommits(cs.CommitRound).TwoThirdsMajority()
  1531. if !ok || blockID.IsNil() {
  1532. logger.Error("failed attempt to finalize commit; there was no +2/3 majority or +2/3 was for nil")
  1533. return
  1534. }
  1535. if !cs.ProposalBlock.HashesTo(blockID.Hash) {
  1536. // TODO: this happens every time if we're not a validator (ugly logs)
  1537. // TODO: ^^ wait, why does it matter that we're a validator?
  1538. logger.Debug(
  1539. "failed attempt to finalize commit; we do not have the commit block",
  1540. "proposal_block", cs.ProposalBlock.Hash(),
  1541. "commit_block", blockID.Hash,
  1542. )
  1543. return
  1544. }
  1545. cs.finalizeCommit(ctx, height)
  1546. }
  1547. // Increment height and goto cstypes.RoundStepNewHeight
  1548. func (cs *State) finalizeCommit(ctx context.Context, height int64) {
  1549. logger := cs.logger.With("height", height)
  1550. if cs.Height != height || cs.Step != cstypes.RoundStepCommit {
  1551. logger.Debug(
  1552. "entering finalize commit step",
  1553. "current", fmt.Sprintf("%v/%v/%v", cs.Height, cs.Round, cs.Step),
  1554. )
  1555. return
  1556. }
  1557. cs.calculatePrevoteMessageDelayMetrics()
  1558. blockID, ok := cs.Votes.Precommits(cs.CommitRound).TwoThirdsMajority()
  1559. block, blockParts := cs.ProposalBlock, cs.ProposalBlockParts
  1560. if !ok {
  1561. panic("cannot finalize commit; commit does not have 2/3 majority")
  1562. }
  1563. if !blockParts.HasHeader(blockID.PartSetHeader) {
  1564. panic("expected ProposalBlockParts header to be commit header")
  1565. }
  1566. if !block.HashesTo(blockID.Hash) {
  1567. panic("cannot finalize commit; proposal block does not hash to commit hash")
  1568. }
  1569. if err := cs.blockExec.ValidateBlock(ctx, cs.state, block); err != nil {
  1570. panic(fmt.Errorf("+2/3 committed an invalid block: %w", err))
  1571. }
  1572. logger.Info(
  1573. "finalizing commit of block",
  1574. "hash", block.Hash(),
  1575. "root", block.AppHash,
  1576. "num_txs", len(block.Txs),
  1577. )
  1578. logger.Debug(fmt.Sprintf("%v", block))
  1579. // Save to blockStore.
  1580. if cs.blockStore.Height() < block.Height {
  1581. // NOTE: the seenCommit is local justification to commit this block,
  1582. // but may differ from the LastCommit included in the next block
  1583. precommits := cs.Votes.Precommits(cs.CommitRound)
  1584. seenCommit := precommits.MakeCommit()
  1585. cs.blockStore.SaveBlock(block, blockParts, seenCommit)
  1586. } else {
  1587. // Happens during replay if we already saved the block but didn't commit
  1588. logger.Debug("calling finalizeCommit on already stored block", "height", block.Height)
  1589. }
  1590. // Write EndHeightMessage{} for this height, implying that the blockstore
  1591. // has saved the block.
  1592. //
  1593. // If we crash before writing this EndHeightMessage{}, we will recover by
  1594. // running ApplyBlock during the ABCI handshake when we restart. If we
  1595. // didn't save the block to the blockstore before writing
  1596. // EndHeightMessage{}, we'd have to change WAL replay -- currently it
  1597. // complains about replaying for heights where an #ENDHEIGHT entry already
  1598. // exists.
  1599. //
  1600. // Either way, the State should not be resumed until we
  1601. // successfully call ApplyBlock (ie. later here, or in Handshake after
  1602. // restart).
  1603. endMsg := EndHeightMessage{height}
  1604. if err := cs.wal.WriteSync(endMsg); err != nil { // NOTE: fsync
  1605. panic(fmt.Errorf(
  1606. "failed to write %v msg to consensus WAL due to %w; check your file system and restart the node",
  1607. endMsg, err,
  1608. ))
  1609. }
  1610. // Create a copy of the state for staging and an event cache for txs.
  1611. stateCopy := cs.state.Copy()
  1612. // Execute and commit the block, update and save the state, and update the mempool.
  1613. // NOTE The block.AppHash wont reflect these txs until the next block.
  1614. stateCopy, err := cs.blockExec.ApplyBlock(ctx,
  1615. stateCopy,
  1616. types.BlockID{
  1617. Hash: block.Hash(),
  1618. PartSetHeader: blockParts.Header(),
  1619. },
  1620. block,
  1621. )
  1622. if err != nil {
  1623. logger.Error("failed to apply block", "err", err)
  1624. return
  1625. }
  1626. // must be called before we update state
  1627. cs.RecordMetrics(height, block)
  1628. // NewHeightStep!
  1629. cs.updateToState(ctx, stateCopy)
  1630. // Private validator might have changed it's key pair => refetch pubkey.
  1631. if err := cs.updatePrivValidatorPubKey(ctx); err != nil {
  1632. logger.Error("failed to get private validator pubkey", "err", err)
  1633. }
  1634. // cs.StartTime is already set.
  1635. // Schedule Round0 to start soon.
  1636. cs.scheduleRound0(&cs.RoundState)
  1637. // By here,
  1638. // * cs.Height has been increment to height+1
  1639. // * cs.Step is now cstypes.RoundStepNewHeight
  1640. // * cs.StartTime is set to when we will start round0.
  1641. }
  1642. func (cs *State) RecordMetrics(height int64, block *types.Block) {
  1643. cs.metrics.Validators.Set(float64(cs.Validators.Size()))
  1644. cs.metrics.ValidatorsPower.Set(float64(cs.Validators.TotalVotingPower()))
  1645. var (
  1646. missingValidators int
  1647. missingValidatorsPower int64
  1648. )
  1649. // height=0 -> MissingValidators and MissingValidatorsPower are both 0.
  1650. // Remember that the first LastCommit is intentionally empty, so it's not
  1651. // fair to increment missing validators number.
  1652. if height > cs.state.InitialHeight {
  1653. // Sanity check that commit size matches validator set size - only applies
  1654. // after first block.
  1655. var (
  1656. commitSize = block.LastCommit.Size()
  1657. valSetLen = len(cs.LastValidators.Validators)
  1658. address types.Address
  1659. )
  1660. if commitSize != valSetLen {
  1661. cs.logger.Error(fmt.Sprintf("commit size (%d) doesn't match valset length (%d) at height %d\n\n%v\n\n%v",
  1662. commitSize, valSetLen, block.Height, block.LastCommit.Signatures, cs.LastValidators.Validators))
  1663. return
  1664. }
  1665. if cs.privValidator != nil {
  1666. if cs.privValidatorPubKey == nil {
  1667. // Metrics won't be updated, but it's not critical.
  1668. cs.logger.Error("recordMetrics", "err", errPubKeyIsNotSet)
  1669. } else {
  1670. address = cs.privValidatorPubKey.Address()
  1671. }
  1672. }
  1673. for i, val := range cs.LastValidators.Validators {
  1674. commitSig := block.LastCommit.Signatures[i]
  1675. if commitSig.Absent() {
  1676. missingValidators++
  1677. missingValidatorsPower += val.VotingPower
  1678. }
  1679. if bytes.Equal(val.Address, address) {
  1680. label := []string{
  1681. "validator_address", val.Address.String(),
  1682. }
  1683. cs.metrics.ValidatorPower.With(label...).Set(float64(val.VotingPower))
  1684. if commitSig.ForBlock() {
  1685. cs.metrics.ValidatorLastSignedHeight.With(label...).Set(float64(height))
  1686. } else {
  1687. cs.metrics.ValidatorMissedBlocks.With(label...).Add(float64(1))
  1688. }
  1689. }
  1690. }
  1691. }
  1692. cs.metrics.MissingValidators.Set(float64(missingValidators))
  1693. cs.metrics.MissingValidatorsPower.Set(float64(missingValidatorsPower))
  1694. // NOTE: byzantine validators power and count is only for consensus evidence i.e. duplicate vote
  1695. var (
  1696. byzantineValidatorsPower int64
  1697. byzantineValidatorsCount int64
  1698. )
  1699. for _, ev := range block.Evidence {
  1700. if dve, ok := ev.(*types.DuplicateVoteEvidence); ok {
  1701. if _, val := cs.Validators.GetByAddress(dve.VoteA.ValidatorAddress); val != nil {
  1702. byzantineValidatorsCount++
  1703. byzantineValidatorsPower += val.VotingPower
  1704. }
  1705. }
  1706. }
  1707. cs.metrics.ByzantineValidators.Set(float64(byzantineValidatorsCount))
  1708. cs.metrics.ByzantineValidatorsPower.Set(float64(byzantineValidatorsPower))
  1709. if height > 1 {
  1710. lastBlockMeta := cs.blockStore.LoadBlockMeta(height - 1)
  1711. if lastBlockMeta != nil {
  1712. cs.metrics.BlockIntervalSeconds.Observe(
  1713. block.Time.Sub(lastBlockMeta.Header.Time).Seconds(),
  1714. )
  1715. }
  1716. }
  1717. cs.metrics.NumTxs.Set(float64(len(block.Data.Txs)))
  1718. cs.metrics.TotalTxs.Add(float64(len(block.Data.Txs)))
  1719. cs.metrics.BlockSizeBytes.Observe(float64(block.Size()))
  1720. cs.metrics.CommittedHeight.Set(float64(block.Height))
  1721. }
  1722. //-----------------------------------------------------------------------------
  1723. func (cs *State) defaultSetProposal(proposal *types.Proposal, recvTime time.Time) error {
  1724. // Already have one
  1725. // TODO: possibly catch double proposals
  1726. if cs.Proposal != nil || proposal == nil {
  1727. return nil
  1728. }
  1729. // Does not apply
  1730. if proposal.Height != cs.Height || proposal.Round != cs.Round {
  1731. return nil
  1732. }
  1733. // Verify POLRound, which must be -1 or in range [0, proposal.Round).
  1734. if proposal.POLRound < -1 ||
  1735. (proposal.POLRound >= 0 && proposal.POLRound >= proposal.Round) {
  1736. return ErrInvalidProposalPOLRound
  1737. }
  1738. p := proposal.ToProto()
  1739. // Verify signature
  1740. if !cs.Validators.GetProposer().PubKey.VerifySignature(
  1741. types.ProposalSignBytes(cs.state.ChainID, p), proposal.Signature,
  1742. ) {
  1743. return ErrInvalidProposalSignature
  1744. }
  1745. proposal.Signature = p.Signature
  1746. cs.Proposal = proposal
  1747. cs.ProposalReceiveTime = recvTime
  1748. cs.calculateProposalTimestampDifferenceMetric()
  1749. // We don't update cs.ProposalBlockParts if it is already set.
  1750. // This happens if we're already in cstypes.RoundStepCommit or if there is a valid block in the current round.
  1751. // TODO: We can check if Proposal is for a different block as this is a sign of misbehavior!
  1752. if cs.ProposalBlockParts == nil {
  1753. cs.metrics.MarkBlockGossipStarted()
  1754. cs.ProposalBlockParts = types.NewPartSetFromHeader(proposal.BlockID.PartSetHeader)
  1755. }
  1756. cs.logger.Info("received proposal", "proposal", proposal)
  1757. return nil
  1758. }
  1759. // NOTE: block is not necessarily valid.
  1760. // Asynchronously triggers either enterPrevote (before we timeout of propose) or tryFinalizeCommit,
  1761. // once we have the full block.
  1762. func (cs *State) addProposalBlockPart(
  1763. ctx context.Context,
  1764. msg *BlockPartMessage,
  1765. peerID types.NodeID,
  1766. ) (added bool, err error) {
  1767. height, round, part := msg.Height, msg.Round, msg.Part
  1768. // Blocks might be reused, so round mismatch is OK
  1769. if cs.Height != height {
  1770. cs.logger.Debug("received block part from wrong height", "height", height, "round", round)
  1771. cs.metrics.BlockGossipPartsReceived.With("matches_current", "false").Add(1)
  1772. return false, nil
  1773. }
  1774. // We're not expecting a block part.
  1775. if cs.ProposalBlockParts == nil {
  1776. cs.metrics.BlockGossipPartsReceived.With("matches_current", "false").Add(1)
  1777. // NOTE: this can happen when we've gone to a higher round and
  1778. // then receive parts from the previous round - not necessarily a bad peer.
  1779. cs.logger.Debug(
  1780. "received a block part when we are not expecting any",
  1781. "height", height,
  1782. "round", round,
  1783. "index", part.Index,
  1784. "peer", peerID,
  1785. )
  1786. return false, nil
  1787. }
  1788. added, err = cs.ProposalBlockParts.AddPart(part)
  1789. if err != nil {
  1790. if errors.Is(err, types.ErrPartSetInvalidProof) || errors.Is(err, types.ErrPartSetUnexpectedIndex) {
  1791. cs.metrics.BlockGossipPartsReceived.With("matches_current", "false").Add(1)
  1792. }
  1793. return added, err
  1794. }
  1795. cs.metrics.BlockGossipPartsReceived.With("matches_current", "true").Add(1)
  1796. if cs.ProposalBlockParts.ByteSize() > cs.state.ConsensusParams.Block.MaxBytes {
  1797. return added, fmt.Errorf("total size of proposal block parts exceeds maximum block bytes (%d > %d)",
  1798. cs.ProposalBlockParts.ByteSize(), cs.state.ConsensusParams.Block.MaxBytes,
  1799. )
  1800. }
  1801. if added && cs.ProposalBlockParts.IsComplete() {
  1802. cs.metrics.MarkBlockGossipComplete()
  1803. bz, err := io.ReadAll(cs.ProposalBlockParts.GetReader())
  1804. if err != nil {
  1805. return added, err
  1806. }
  1807. var pbb = new(tmproto.Block)
  1808. err = proto.Unmarshal(bz, pbb)
  1809. if err != nil {
  1810. return added, err
  1811. }
  1812. block, err := types.BlockFromProto(pbb)
  1813. if err != nil {
  1814. return added, err
  1815. }
  1816. cs.ProposalBlock = block
  1817. // NOTE: it's possible to receive complete proposal blocks for future rounds without having the proposal
  1818. cs.logger.Info("received complete proposal block", "height", cs.ProposalBlock.Height, "hash", cs.ProposalBlock.Hash())
  1819. if err := cs.eventBus.PublishEventCompleteProposal(ctx, cs.CompleteProposalEvent()); err != nil {
  1820. cs.logger.Error("failed publishing event complete proposal", "err", err)
  1821. }
  1822. // Update Valid* if we can.
  1823. prevotes := cs.Votes.Prevotes(cs.Round)
  1824. blockID, hasTwoThirds := prevotes.TwoThirdsMajority()
  1825. if hasTwoThirds && !blockID.IsNil() && (cs.ValidRound < cs.Round) {
  1826. if cs.ProposalBlock.HashesTo(blockID.Hash) {
  1827. cs.logger.Debug(
  1828. "updating valid block to new proposal block",
  1829. "valid_round", cs.Round,
  1830. "valid_block_hash", cs.ProposalBlock.Hash(),
  1831. )
  1832. cs.ValidRound = cs.Round
  1833. cs.ValidBlock = cs.ProposalBlock
  1834. cs.ValidBlockParts = cs.ProposalBlockParts
  1835. }
  1836. // TODO: In case there is +2/3 majority in Prevotes set for some
  1837. // block and cs.ProposalBlock contains different block, either
  1838. // proposer is faulty or voting power of faulty processes is more
  1839. // than 1/3. We should trigger in the future accountability
  1840. // procedure at this point.
  1841. }
  1842. if cs.Step <= cstypes.RoundStepPropose && cs.isProposalComplete() {
  1843. // Move onto the next step
  1844. cs.enterPrevote(ctx, height, cs.Round)
  1845. if hasTwoThirds { // this is optimisation as this will be triggered when prevote is added
  1846. cs.enterPrecommit(ctx, height, cs.Round)
  1847. }
  1848. } else if cs.Step == cstypes.RoundStepCommit {
  1849. // If we're waiting on the proposal block...
  1850. cs.tryFinalizeCommit(ctx, height)
  1851. }
  1852. return added, nil
  1853. }
  1854. return added, nil
  1855. }
  1856. // Attempt to add the vote. if its a duplicate signature, dupeout the validator
  1857. func (cs *State) tryAddVote(ctx context.Context, vote *types.Vote, peerID types.NodeID) (bool, error) {
  1858. added, err := cs.addVote(ctx, vote, peerID)
  1859. if err != nil {
  1860. // If the vote height is off, we'll just ignore it,
  1861. // But if it's a conflicting sig, add it to the cs.evpool.
  1862. // If it's otherwise invalid, punish peer.
  1863. // nolint: gocritic
  1864. if voteErr, ok := err.(*types.ErrVoteConflictingVotes); ok {
  1865. if cs.privValidatorPubKey == nil {
  1866. return false, errPubKeyIsNotSet
  1867. }
  1868. if bytes.Equal(vote.ValidatorAddress, cs.privValidatorPubKey.Address()) {
  1869. cs.logger.Error(
  1870. "found conflicting vote from ourselves; did you unsafe_reset a validator?",
  1871. "height", vote.Height,
  1872. "round", vote.Round,
  1873. "type", vote.Type,
  1874. )
  1875. return added, err
  1876. }
  1877. // report conflicting votes to the evidence pool
  1878. cs.evpool.ReportConflictingVotes(voteErr.VoteA, voteErr.VoteB)
  1879. cs.logger.Debug(
  1880. "found and sent conflicting votes to the evidence pool",
  1881. "vote_a", voteErr.VoteA,
  1882. "vote_b", voteErr.VoteB,
  1883. )
  1884. return added, err
  1885. } else if errors.Is(err, types.ErrVoteNonDeterministicSignature) {
  1886. cs.logger.Debug("vote has non-deterministic signature", "err", err)
  1887. } else {
  1888. // Either
  1889. // 1) bad peer OR
  1890. // 2) not a bad peer? this can also err sometimes with "Unexpected step" OR
  1891. // 3) tmkms use with multiple validators connecting to a single tmkms instance
  1892. // (https://github.com/tendermint/tendermint/issues/3839).
  1893. cs.logger.Info("failed attempting to add vote", "err", err)
  1894. return added, ErrAddingVote
  1895. }
  1896. }
  1897. return added, nil
  1898. }
  1899. func (cs *State) addVote(
  1900. ctx context.Context,
  1901. vote *types.Vote,
  1902. peerID types.NodeID,
  1903. ) (added bool, err error) {
  1904. cs.logger.Debug(
  1905. "adding vote",
  1906. "vote_height", vote.Height,
  1907. "vote_type", vote.Type,
  1908. "val_index", vote.ValidatorIndex,
  1909. "cs_height", cs.Height,
  1910. )
  1911. // A precommit for the previous height?
  1912. // These come in while we wait timeoutCommit
  1913. if vote.Height+1 == cs.Height && vote.Type == tmproto.PrecommitType {
  1914. if cs.Step != cstypes.RoundStepNewHeight {
  1915. // Late precommit at prior height is ignored
  1916. cs.logger.Debug("precommit vote came in after commit timeout and has been ignored", "vote", vote)
  1917. return
  1918. }
  1919. added, err = cs.LastCommit.AddVote(vote)
  1920. if !added {
  1921. return
  1922. }
  1923. cs.logger.Debug("added vote to last precommits", "last_commit", cs.LastCommit.StringShort())
  1924. if err := cs.eventBus.PublishEventVote(ctx, types.EventDataVote{Vote: vote}); err != nil {
  1925. return added, err
  1926. }
  1927. cs.evsw.FireEvent(ctx, types.EventVoteValue, vote)
  1928. // if we can skip timeoutCommit and have all the votes now,
  1929. if cs.config.SkipTimeoutCommit && cs.LastCommit.HasAll() {
  1930. // go straight to new round (skip timeout commit)
  1931. // cs.scheduleTimeout(time.Duration(0), cs.Height, 0, cstypes.RoundStepNewHeight)
  1932. cs.enterNewRound(ctx, cs.Height, 0)
  1933. }
  1934. return
  1935. }
  1936. // Height mismatch is ignored.
  1937. // Not necessarily a bad peer, but not favorable behavior.
  1938. if vote.Height != cs.Height {
  1939. cs.logger.Debug("vote ignored and not added", "vote_height", vote.Height, "cs_height", cs.Height, "peer", peerID)
  1940. return
  1941. }
  1942. // Verify VoteExtension if precommit
  1943. if vote.Type == tmproto.PrecommitType {
  1944. if err = cs.blockExec.VerifyVoteExtension(ctx, vote); err != nil {
  1945. return false, err
  1946. }
  1947. }
  1948. height := cs.Height
  1949. added, err = cs.Votes.AddVote(vote, peerID)
  1950. if !added {
  1951. // Either duplicate, or error upon cs.Votes.AddByIndex()
  1952. return
  1953. }
  1954. if err := cs.eventBus.PublishEventVote(ctx, types.EventDataVote{Vote: vote}); err != nil {
  1955. return added, err
  1956. }
  1957. cs.evsw.FireEvent(ctx, types.EventVoteValue, vote)
  1958. switch vote.Type {
  1959. case tmproto.PrevoteType:
  1960. prevotes := cs.Votes.Prevotes(vote.Round)
  1961. cs.logger.Debug("added vote to prevote", "vote", vote, "prevotes", prevotes.StringShort())
  1962. // Check to see if >2/3 of the voting power on the network voted for any non-nil block.
  1963. if blockID, ok := prevotes.TwoThirdsMajority(); ok && !blockID.IsNil() {
  1964. // Greater than 2/3 of the voting power on the network voted for some
  1965. // non-nil block
  1966. // Update Valid* if we can.
  1967. if cs.ValidRound < vote.Round && vote.Round == cs.Round {
  1968. if cs.ProposalBlock.HashesTo(blockID.Hash) {
  1969. cs.logger.Debug("updating valid block because of POL", "valid_round", cs.ValidRound, "pol_round", vote.Round)
  1970. cs.ValidRound = vote.Round
  1971. cs.ValidBlock = cs.ProposalBlock
  1972. cs.ValidBlockParts = cs.ProposalBlockParts
  1973. } else {
  1974. cs.logger.Debug(
  1975. "valid block we do not know about; set ProposalBlock=nil",
  1976. "proposal", cs.ProposalBlock.Hash(),
  1977. "block_id", blockID.Hash,
  1978. )
  1979. // we're getting the wrong block
  1980. cs.ProposalBlock = nil
  1981. }
  1982. if !cs.ProposalBlockParts.HasHeader(blockID.PartSetHeader) {
  1983. cs.metrics.MarkBlockGossipStarted()
  1984. cs.ProposalBlockParts = types.NewPartSetFromHeader(blockID.PartSetHeader)
  1985. }
  1986. cs.evsw.FireEvent(ctx, types.EventValidBlockValue, &cs.RoundState)
  1987. if err := cs.eventBus.PublishEventValidBlock(ctx, cs.RoundStateEvent()); err != nil {
  1988. return added, err
  1989. }
  1990. }
  1991. }
  1992. // If +2/3 prevotes for *anything* for future round:
  1993. switch {
  1994. case cs.Round < vote.Round && prevotes.HasTwoThirdsAny():
  1995. // Round-skip if there is any 2/3+ of votes ahead of us
  1996. cs.enterNewRound(ctx, height, vote.Round)
  1997. case cs.Round == vote.Round && cstypes.RoundStepPrevote <= cs.Step: // current round
  1998. blockID, ok := prevotes.TwoThirdsMajority()
  1999. if ok && (cs.isProposalComplete() || blockID.IsNil()) {
  2000. cs.enterPrecommit(ctx, height, vote.Round)
  2001. } else if prevotes.HasTwoThirdsAny() {
  2002. cs.enterPrevoteWait(ctx, height, vote.Round)
  2003. }
  2004. case cs.Proposal != nil && 0 <= cs.Proposal.POLRound && cs.Proposal.POLRound == vote.Round:
  2005. // If the proposal is now complete, enter prevote of cs.Round.
  2006. if cs.isProposalComplete() {
  2007. cs.enterPrevote(ctx, height, cs.Round)
  2008. }
  2009. }
  2010. case tmproto.PrecommitType:
  2011. precommits := cs.Votes.Precommits(vote.Round)
  2012. cs.logger.Debug("added vote to precommit",
  2013. "height", vote.Height,
  2014. "round", vote.Round,
  2015. "validator", vote.ValidatorAddress.String(),
  2016. "vote_timestamp", vote.Timestamp,
  2017. "data", precommits.LogString())
  2018. blockID, ok := precommits.TwoThirdsMajority()
  2019. if ok {
  2020. // Executed as TwoThirdsMajority could be from a higher round
  2021. cs.enterNewRound(ctx, height, vote.Round)
  2022. cs.enterPrecommit(ctx, height, vote.Round)
  2023. if !blockID.IsNil() {
  2024. cs.enterCommit(ctx, height, vote.Round)
  2025. if cs.config.SkipTimeoutCommit && precommits.HasAll() {
  2026. cs.enterNewRound(ctx, cs.Height, 0)
  2027. }
  2028. } else {
  2029. cs.enterPrecommitWait(ctx, height, vote.Round)
  2030. }
  2031. } else if cs.Round <= vote.Round && precommits.HasTwoThirdsAny() {
  2032. cs.enterNewRound(ctx, height, vote.Round)
  2033. cs.enterPrecommitWait(ctx, height, vote.Round)
  2034. }
  2035. default:
  2036. panic(fmt.Sprintf("unexpected vote type %v", vote.Type))
  2037. }
  2038. return added, err
  2039. }
  2040. // CONTRACT: cs.privValidator is not nil.
  2041. func (cs *State) signVote(
  2042. ctx context.Context,
  2043. msgType tmproto.SignedMsgType,
  2044. hash []byte,
  2045. header types.PartSetHeader,
  2046. ) (*types.Vote, error) {
  2047. // Flush the WAL. Otherwise, we may not recompute the same vote to sign,
  2048. // and the privValidator will refuse to sign anything.
  2049. if err := cs.wal.FlushAndSync(); err != nil {
  2050. return nil, err
  2051. }
  2052. if cs.privValidatorPubKey == nil {
  2053. return nil, errPubKeyIsNotSet
  2054. }
  2055. addr := cs.privValidatorPubKey.Address()
  2056. valIdx, _ := cs.Validators.GetByAddress(addr)
  2057. vote := &types.Vote{
  2058. ValidatorAddress: addr,
  2059. ValidatorIndex: valIdx,
  2060. Height: cs.Height,
  2061. Round: cs.Round,
  2062. Timestamp: tmtime.Now(),
  2063. Type: msgType,
  2064. BlockID: types.BlockID{Hash: hash, PartSetHeader: header},
  2065. }
  2066. // If the signedMessageType is for precommit,
  2067. // use our local precommit Timeout as the max wait time for getting a singed commit. The same goes for prevote.
  2068. var timeout time.Duration
  2069. switch msgType {
  2070. case tmproto.PrecommitType:
  2071. timeout = cs.config.TimeoutPrecommit
  2072. // if the signedMessage type is for a precommit, add VoteExtension
  2073. ext, err := cs.blockExec.ExtendVote(ctx, vote)
  2074. if err != nil {
  2075. return nil, err
  2076. }
  2077. vote.VoteExtension = ext
  2078. case tmproto.PrevoteType:
  2079. timeout = cs.config.TimeoutPrevote
  2080. default:
  2081. timeout = time.Second
  2082. }
  2083. v := vote.ToProto()
  2084. ctxto, cancel := context.WithTimeout(ctx, timeout)
  2085. defer cancel()
  2086. err := cs.privValidator.SignVote(ctxto, cs.state.ChainID, v)
  2087. vote.Signature = v.Signature
  2088. vote.Timestamp = v.Timestamp
  2089. return vote, err
  2090. }
  2091. // sign the vote and publish on internalMsgQueue
  2092. func (cs *State) signAddVote(
  2093. ctx context.Context,
  2094. msgType tmproto.SignedMsgType,
  2095. hash []byte,
  2096. header types.PartSetHeader,
  2097. ) *types.Vote {
  2098. if cs.privValidator == nil { // the node does not have a key
  2099. return nil
  2100. }
  2101. if cs.privValidatorPubKey == nil {
  2102. // Vote won't be signed, but it's not critical.
  2103. cs.logger.Error("signAddVote", "err", errPubKeyIsNotSet)
  2104. return nil
  2105. }
  2106. // If the node not in the validator set, do nothing.
  2107. if !cs.Validators.HasAddress(cs.privValidatorPubKey.Address()) {
  2108. return nil
  2109. }
  2110. // TODO: pass pubKey to signVote
  2111. vote, err := cs.signVote(ctx, msgType, hash, header)
  2112. if err == nil {
  2113. cs.sendInternalMessage(ctx, msgInfo{&VoteMessage{vote}, "", tmtime.Now()})
  2114. cs.logger.Debug("signed and pushed vote", "height", cs.Height, "round", cs.Round, "vote", vote)
  2115. return vote
  2116. }
  2117. cs.logger.Error("failed signing vote", "height", cs.Height, "round", cs.Round, "vote", vote, "err", err)
  2118. return nil
  2119. }
  2120. // updatePrivValidatorPubKey get's the private validator public key and
  2121. // memoizes it. This func returns an error if the private validator is not
  2122. // responding or responds with an error.
  2123. func (cs *State) updatePrivValidatorPubKey(rctx context.Context) error {
  2124. if cs.privValidator == nil {
  2125. return nil
  2126. }
  2127. var timeout time.Duration
  2128. if cs.config.TimeoutPrecommit > cs.config.TimeoutPrevote {
  2129. timeout = cs.config.TimeoutPrecommit
  2130. } else {
  2131. timeout = cs.config.TimeoutPrevote
  2132. }
  2133. // no GetPubKey retry beyond the proposal/voting in RetrySignerClient
  2134. if cs.Step >= cstypes.RoundStepPrecommit && cs.privValidatorType == types.RetrySignerClient {
  2135. timeout = 0
  2136. }
  2137. // set context timeout depending on the configuration and the State step,
  2138. // this helps in avoiding blocking of the remote signer connection.
  2139. ctxto, cancel := context.WithTimeout(rctx, timeout)
  2140. defer cancel()
  2141. pubKey, err := cs.privValidator.GetPubKey(ctxto)
  2142. if err != nil {
  2143. return err
  2144. }
  2145. cs.privValidatorPubKey = pubKey
  2146. return nil
  2147. }
  2148. // look back to check existence of the node's consensus votes before joining consensus
  2149. func (cs *State) checkDoubleSigningRisk(height int64) error {
  2150. if cs.privValidator != nil && cs.privValidatorPubKey != nil && cs.config.DoubleSignCheckHeight > 0 && height > 0 {
  2151. valAddr := cs.privValidatorPubKey.Address()
  2152. doubleSignCheckHeight := cs.config.DoubleSignCheckHeight
  2153. if doubleSignCheckHeight > height {
  2154. doubleSignCheckHeight = height
  2155. }
  2156. for i := int64(1); i < doubleSignCheckHeight; i++ {
  2157. lastCommit := cs.LoadCommit(height - i)
  2158. if lastCommit != nil {
  2159. for sigIdx, s := range lastCommit.Signatures {
  2160. if s.BlockIDFlag == types.BlockIDFlagCommit && bytes.Equal(s.ValidatorAddress, valAddr) {
  2161. cs.logger.Info("found signature from the same key", "sig", s, "idx", sigIdx, "height", height-i)
  2162. return ErrSignatureFoundInPastBlocks
  2163. }
  2164. }
  2165. }
  2166. }
  2167. }
  2168. return nil
  2169. }
  2170. func (cs *State) calculatePrevoteMessageDelayMetrics() {
  2171. if cs.Proposal == nil {
  2172. return
  2173. }
  2174. ps := cs.Votes.Prevotes(cs.Round)
  2175. pl := ps.List()
  2176. sort.Slice(pl, func(i, j int) bool {
  2177. return pl[i].Timestamp.Before(pl[j].Timestamp)
  2178. })
  2179. var votingPowerSeen int64
  2180. for _, v := range pl {
  2181. _, val := cs.Validators.GetByAddress(v.ValidatorAddress)
  2182. votingPowerSeen += val.VotingPower
  2183. if votingPowerSeen >= cs.Validators.TotalVotingPower()*2/3+1 {
  2184. cs.metrics.QuorumPrevoteMessageDelay.With("proposer_address", cs.Validators.GetProposer().Address.String()).Set(v.Timestamp.Sub(cs.Proposal.Timestamp).Seconds())
  2185. break
  2186. }
  2187. }
  2188. if ps.HasAll() {
  2189. cs.metrics.FullPrevoteMessageDelay.With("proposer_address", cs.Validators.GetProposer().Address.String()).Set(pl[len(pl)-1].Timestamp.Sub(cs.Proposal.Timestamp).Seconds())
  2190. }
  2191. }
  2192. //---------------------------------------------------------
  2193. func CompareHRS(h1 int64, r1 int32, s1 cstypes.RoundStepType, h2 int64, r2 int32, s2 cstypes.RoundStepType) int {
  2194. if h1 < h2 {
  2195. return -1
  2196. } else if h1 > h2 {
  2197. return 1
  2198. }
  2199. if r1 < r2 {
  2200. return -1
  2201. } else if r1 > r2 {
  2202. return 1
  2203. }
  2204. if s1 < s2 {
  2205. return -1
  2206. } else if s1 > s2 {
  2207. return 1
  2208. }
  2209. return 0
  2210. }
  2211. // repairWalFile decodes messages from src (until the decoder errors) and
  2212. // writes them to dst.
  2213. func repairWalFile(src, dst string) error {
  2214. in, err := os.Open(src)
  2215. if err != nil {
  2216. return err
  2217. }
  2218. defer in.Close()
  2219. out, err := os.Create(dst)
  2220. if err != nil {
  2221. return err
  2222. }
  2223. defer out.Close()
  2224. var (
  2225. dec = NewWALDecoder(in)
  2226. enc = NewWALEncoder(out)
  2227. )
  2228. // best-case repair (until first error is encountered)
  2229. for {
  2230. msg, err := dec.Decode()
  2231. if err != nil {
  2232. break
  2233. }
  2234. err = enc.Encode(msg)
  2235. if err != nil {
  2236. return fmt.Errorf("failed to encode msg: %w", err)
  2237. }
  2238. }
  2239. return nil
  2240. }
  2241. func (cs *State) calculateProposalTimestampDifferenceMetric() {
  2242. if cs.Proposal != nil && cs.Proposal.POLRound == -1 {
  2243. tp := types.SynchronyParams{
  2244. Precision: cs.state.ConsensusParams.Synchrony.Precision,
  2245. MessageDelay: cs.state.ConsensusParams.Synchrony.MessageDelay,
  2246. }
  2247. isTimely := cs.Proposal.IsTimely(cs.ProposalReceiveTime, tp, cs.Round)
  2248. cs.metrics.ProposalTimestampDifference.With("is_timely", fmt.Sprintf("%t", isTimely)).
  2249. Observe(cs.ProposalReceiveTime.Sub(cs.Proposal.Timestamp).Seconds())
  2250. }
  2251. }
  2252. // proposerWaitTime determines how long the proposer should wait to propose its next block.
  2253. // If the result is zero, a block can be proposed immediately.
  2254. //
  2255. // Block times must be monotonically increasing, so if the block time of the previous
  2256. // block is larger than the proposer's current time, then the proposer will sleep
  2257. // until its local clock exceeds the previous block time.
  2258. func proposerWaitTime(lt tmtime.Source, bt time.Time) time.Duration {
  2259. t := lt.Now()
  2260. if bt.After(t) {
  2261. return bt.Sub(t)
  2262. }
  2263. return 0
  2264. }