Skip to content

make ConsensusParams.EvidenceParams.MaxAge time.Duration#2606

Closed
melekes wants to merge 9 commits intodevelopfrom
2565-max-age-duration
Closed

make ConsensusParams.EvidenceParams.MaxAge time.Duration#2606
melekes wants to merge 9 commits intodevelopfrom
2565-max-age-duration

Conversation

@melekes
Copy link
Contributor

@melekes melekes commented Oct 11, 2018

Refs #2565

  • Updated all relevant documentation in docs
  • Updated all code comments where relevant
  • Wrote tests
  • Updated CHANGELOG_PENDING.md

TODO

  • Ensure we record LastBlockTime in PeerState
  • Make MaxAge nonnullable

@melekes melekes requested review from ebuchman and xla as code owners October 11, 2018 12:23
@codecov-io
Copy link

codecov-io commented Oct 11, 2018

Codecov Report

Merging #2606 into develop will decrease coverage by 0.06%.
The diff coverage is 40%.

@@             Coverage Diff             @@
##           develop    #2606      +/-   ##
===========================================
- Coverage    61.33%   61.26%   -0.07%     
===========================================
  Files          203      204       +1     
  Lines        16781    16792      +11     
===========================================
- Hits         10292    10287       -5     
- Misses        5621     5634      +13     
- Partials       868      871       +3
Impacted Files Coverage Δ
consensus/reactor.go 71.48% <ø> (-0.91%) ⬇️
evidence/pool.go 56.14% <0%> (ø) ⬆️
evidence/reactor.go 67.44% <100%> (+1.5%) ⬆️
state/validation.go 63.63% <50%> (-0.3%) ⬇️
types/time/duration.go 50% <50%> (ø)
libs/events/events.go 93.2% <0%> (-4.86%) ⬇️
node/id.go 0% <0%> (ø) ⬆️
p2p/pex/pex_reactor.go 74.33% <0%> (+0.33%) ⬆️

@melekes melekes requested a review from zramsay as a code owner October 15, 2018 08:21
@melekes melekes changed the title [WIP] make ConsensusParams.EvidenceParams.MaxAge time.Duration make ConsensusParams.EvidenceParams.MaxAge time.Duration Oct 15, 2018

// GetLastBlockTime returns an atomic snapshot of the PeerRoundState's last
// block time used by the evidence reactor when sending evidence.
func (ps *PeerState) GetLastBlockTime() time.Time {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Its not clear to me why they need the last block time? Why doesn't knowledge of the previous block hash suffice, if you already have the block?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

if you already have the block?

what if we don't?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

But if they don't have the latest block, shouldn't I be tracking by block height which blocks to send to them?

if rs.Step == cstypes.RoundStepCommit {
csMsg = &CommitStepMessage{
Height: rs.Height,
Time: rs.CommitTime,
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why did we need to add this?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I was confused by this as well

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

mostly for #2606 (comment)

evidence/pool.go Outdated
evpool.removeEvidence(height, maxAge, blockEvidenceMap)

evpool.removeEvidence(
height,
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think if we pass in the Header to MarkEvidenceAsCommitted instead of just the height (or maybe the timestamp, along with the height, without the full header), we can pass it in here too and avoid the need to get the LastBlockTime from the state ... then we don't need the Time field in those consensus msgs.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

True, but what about checkSendEvidenceMessage in evidenceReactor? where we decide whenever we should send an evidence to a peer based on its state.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ok, what if we remove the check 3ab2107 ?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

another alternative is to pass blockstore and load block header?

maxAge := evR.evpool.State().ConsensusParams.EvidenceParams.MaxAge
	// peerLastBlockTime := blockStore.LoadBlockMeta(peerHeight).Header.Time
	if peerLastBlockTime.Sub(ev.Time()) > maxAge {
		// evidence is too old, skip
		// NOTE: if evidence is too old for an honest peer,
		// then we're behind and either it already got committed or it never will!
		evR.Logger.Info("Not sending peer old evidence", "peerHeight", peerHeight, "evHeight", evHeight, "maxAge", maxAge, "peer", peer)
		return nil, false
	}

@melekes melekes force-pushed the 2565-max-age-duration branch from 220d525 to 3ab2107 Compare October 16, 2018 07:20
@melekes melekes force-pushed the 2565-max-age-duration branch from 3ab2107 to e9f30e1 Compare October 16, 2018 09:20
@melekes
Copy link
Contributor Author

melekes commented Oct 18, 2018

Maybe we should hold off merging this until #2653 is resolved.

@melekes melekes closed this Oct 22, 2018
tac0turtle added a commit that referenced this pull request Dec 16, 2019
- add time.duration to evidence
- this pr is taking pr #2606 and updating it to use both time and height

- closes #2565

Signed-off-by: Marko Baricevic <marbar3778@yahoo.com>
tac0turtle added a commit that referenced this pull request Jan 8, 2020
* evidence: introduce time.Duration to evidence params

- add time.duration to evidence
- this pr is taking pr #2606 and updating it to use both time and height

- closes #2565

Signed-off-by: Marko Baricevic <marbar3778@yahoo.com>

* fix testing and genesis cfg in signer harness

* remove debugging fmt

* change maxageheight to maxagenumblocks, rename other things to block instead of height

* further check of duration

* check duration to not send peers outdated evidence

* change some lines, onward and upward

* refactor evidence package

* add a changelog pending entry

* make mockbadevidence have time and use it

* add what could possibly be called a test case

* remove mockbadevidence and mockgoodevidence in favor of mockevidence

* add a comment for err that is returned

* add a changelog for removal of good & bad evidence

* add a test for adding evidence

* fix test

* add ev to types in testcase

* Update evidence/pool_test.go

Co-Authored-By: Anton Kaliaev <anton.kalyaev@gmail.com>

* Update evidence/pool_test.go

Co-Authored-By: Anton Kaliaev <anton.kalyaev@gmail.com>

* fix tests

* fix linting

Co-authored-by: Anton Kaliaev <anton.kalyaev@gmail.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants