Skip to content

types: Incorrect overwrite of ConsensusParams #3444

@ebuchman

Description

@ebuchman

The docs read:

Each field that is not empty will be applied in full. For instance, if updating the BlockSize.MaxBytes, applications must also set the other BlockSize fields (like BlockSize.MaxGas), even if they are unchanged, as they will otherwise cause the value to be updated to 0.

But in the code, we do this:

func (pb2tm) ConsensusParams(csp *abci.ConsensusParams) ConsensusParams {
params := ConsensusParams{
Block: BlockParams{},
Evidence: EvidenceParams{},
Validator: ValidatorParams{},
}
// we must defensively consider any structs may be nil
if csp.Block != nil {
params.Block = BlockParams{
MaxBytes: csp.Block.MaxBytes,
MaxGas: csp.Block.MaxGas,
}
}
if csp.Evidence != nil {
params.Evidence = EvidenceParams{
MaxAge: csp.Evidence.MaxAge,
}
}
if csp.Validator != nil {
params.Validator = ValidatorParams{
PubKeyTypes: csp.Validator.PubKeyTypes,
}
}
return params

Which means all the non-specified fields will be over written.

Also, we're still referring to BlockSize, which should be Block as of v0.31.0

Metadata

Metadata

Assignees

Labels

C:abciComponent: Application Blockchain InterfaceC:consensusComponent: Consensus

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions