-
Notifications
You must be signed in to change notification settings - Fork 2.1k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
evidence: cap evidence to an absolute number #4780
Conversation
👋 Thanks for creating a PR! Before we can merge this PR, please make sure that all the following items have been
Thank you for your contribution to Tendermint! 🚀 |
I'm not too sure how I feel about some of these tests - they seem to quite arbitrarily be testing basic math operations involving constants and I think serve mainly as a check when one of these constants change. |
types/params.go
Outdated
params.Evidence.MaxNumEvidence) | ||
} | ||
|
||
if params.Evidence.MaxNumEvidence > params.Block.MaxBytes { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
aren't these different things? pieces vs bytes
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
yes correct, do you think I should have some sort of catch here to stop people from picking a maxnum that multiplied by the max num of bytes ends up being greater than the block max bytes
types/params.go
Outdated
@@ -67,6 +67,11 @@ type EvidenceParams struct { | |||
// mechanism for handling [Nothing-At-Stake | |||
// attacks](https://github.com/ethereum/wiki/wiki/Proof-of-Stake-FAQ#what-is-the-nothing-at-stake-problem-and-how-can-it-be-fixed). | |||
MaxAgeDuration time.Duration `json:"max_age_duration"` | |||
|
|||
// Ratio for the max amount of evidence relative to the amount of validators to be included in a block |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
not a ratio
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Whoops I went from first trying as a ratio to switching it to just an absolute number so forgot to update the commenting
types/params.go
Outdated
// Ratio for the max amount of evidence relative to the amount of validators to be included in a block | ||
// i.e. MaxNumEvidence = ValSize * MaxEvidenceToValidatorsRatio | ||
// where MaxNumEvidence is always rounded up. Default is 1/3 of validator size | ||
MaxNumEvidence int64 `json:"max_num_evidence"` |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
can we make this uint16
?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
sure, I agree - does that mean I can remove the greater than 0 catch as well?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
the only problem I see with uint16 is that there will most likely need to be quite a few conversions
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Also I just discovered this:
json: cannot unmarshal string into Go value of type uint16)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
uint32 should work. could we try this?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
sure I can give it a go
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
this should be added to the abci consensusparams as well https://github.com/tendermint/tendermint/blob/master/abci/types/types.proto#L298
Two questions: should I be changing the abci ConsensusParams type as well and should the minimum number of evidence be 0 or 1 (being able to set 0 effectively bypasses the use of evidence) |
state/execution.go
Outdated
@@ -98,8 +98,7 @@ func (blockExec *BlockExecutor) CreateProposalBlock( | |||
maxBytes := state.ConsensusParams.Block.MaxBytes | |||
maxGas := state.ConsensusParams.Block.MaxGas | |||
|
|||
// Fetch a limited amount of valid evidence | |||
maxNumEvidence, _ := types.MaxEvidencePerBlock(maxBytes) | |||
maxNumEvidence := int64(state.ConsensusParams.Evidence.MaxNumEvidence) | |||
evidence := blockExec.evpool.PendingEvidence(maxNumEvidence) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
can we change PendingEvidence
to accept uint32
?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Okay but then we take away the functionality of passing -1 to return all evidence
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We could instead make it that PendingEvidence(0)
returns all the pending evidence
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
we're only using -1 in tests, so maybe instead we call PendingEvidence with a high number?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Sure - we also use -1 for listevidence in regards to going through all the pending evidence on startup
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Also I think it might be handy (I'm not sure in which case) if there is a function that you can easily pull all the pending evidence from
Do you mean should we expose this to the apps? I think so, yes. Also, we should update the ABCI spec https://github.com/tendermint/spec/blob/master/spec/abci/abci.md#evidenceparams
evidence is essential piece in PoS networks. but I don't think we should restrict users from setting it to 0. At least, we don't do it for other things. |
I will do this once this PR is merged |
# Conflicts: # state/helpers_test.go # state/services.go
proto/types/params.proto
Outdated
@@ -31,7 +31,8 @@ message EvidenceParams { | |||
option (gogoproto.equal) = true; | |||
// Note: must be greater than 0 | |||
int64 max_age_num_blocks = 1; | |||
google.protobuf.Duration max_age_duration = 2 | |||
google.protobuf.Duration max_age_duration = 2; | |||
uint32 max_num_evidence = 3 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
can we rename this to max_num
? why keep the evidence suffix if the struct called Evidence?
Also, spec (tendermint/spec) needs to be updated. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
👍
Codecov Report
@@ Coverage Diff @@
## master #4780 +/- ##
==========================================
- Coverage 64.05% 64.01% -0.05%
==========================================
Files 220 220
Lines 20426 20433 +7
==========================================
- Hits 13084 13080 -4
- Misses 6290 6298 +8
- Partials 1052 1055 +3
|
Description
Added the consensus param
MaxNumEvidence
to dictate the maximum number of evidence to be committed to a block. It is defaulted at 50There was some discussion around making it proportional to the validator set size which although makes sense has eventually been decided as something that the application can choose to do if they want.
Closes: #2590