Skip to content

Commit

Permalink
fix(rpc): panic on block_results when consensus params change
Browse files Browse the repository at this point in the history
  • Loading branch information
lklimek committed Sep 19, 2024
1 parent 099afee commit 79c4540
Showing 1 changed file with 24 additions and 9 deletions.
33 changes: 24 additions & 9 deletions types/params.go
Original file line number Diff line number Diff line change
Expand Up @@ -458,23 +458,35 @@ func (params *ConsensusParams) ToProto() tmproto.ConsensusParams {
}

func ConsensusParamsFromProto(pbParams tmproto.ConsensusParams) ConsensusParams {
c := ConsensusParams{
Block: BlockParams{

c := ConsensusParams{}
if pbParams.Block != nil {
c.Block = BlockParams{
MaxBytes: pbParams.Block.MaxBytes,
MaxGas: pbParams.Block.MaxGas,
},
Evidence: EvidenceParams{
}
}

if pbParams.Evidence != nil {
c.Evidence = EvidenceParams{
MaxAgeNumBlocks: pbParams.Evidence.MaxAgeNumBlocks,
MaxAgeDuration: pbParams.Evidence.MaxAgeDuration,
MaxBytes: pbParams.Evidence.MaxBytes,
},
Validator: ValidatorParams{
}
}

if pbParams.Validator != nil {
c.Validator = ValidatorParams{
PubKeyTypes: pbParams.Validator.PubKeyTypes,
},
Version: VersionParams{
}
}

if pbParams.Version != nil {
c.Version = VersionParams{
AppVersion: pbParams.Version.AppVersion,
},
}
}

if pbParams.Synchrony != nil {
if pbParams.Synchrony.MessageDelay != nil {
c.Synchrony.MessageDelay = *pbParams.Synchrony.GetMessageDelay()
Expand All @@ -483,6 +495,7 @@ func ConsensusParamsFromProto(pbParams tmproto.ConsensusParams) ConsensusParams
c.Synchrony.Precision = *pbParams.Synchrony.GetPrecision()
}
}

if pbParams.Timeout != nil {
if pbParams.Timeout.Propose != nil {
c.Timeout.Propose = *pbParams.Timeout.GetPropose()
Expand All @@ -497,8 +510,10 @@ func ConsensusParamsFromProto(pbParams tmproto.ConsensusParams) ConsensusParams
c.Timeout.VoteDelta = *pbParams.Timeout.GetVoteDelta()
}
}

if pbParams.Abci != nil {
c.ABCI.RecheckTx = pbParams.Abci.GetRecheckTx()
}

return c
}

0 comments on commit 79c4540

Please sign in to comment.