From 7324a965017070e6b5cbebad471cc621c2ae1316 Mon Sep 17 00:00:00 2001 From: jiangzehua <1092431698@qq.com> Date: Wed, 1 Nov 2023 11:51:51 +0800 Subject: [PATCH] feat(bpos): modify to show sc min gas price payload in getcrproposalstate correctly --- core/types/payload/crcproposal.go | 49 +++++++++++++++++++------------ servers/interfaces.go | 9 +++++- 2 files changed, 38 insertions(+), 20 deletions(-) diff --git a/core/types/payload/crcproposal.go b/core/types/payload/crcproposal.go index b74ee1cb2..3ad07341b 100644 --- a/core/types/payload/crcproposal.go +++ b/core/types/payload/crcproposal.go @@ -1483,25 +1483,26 @@ func (p *CRCProposal) Hash(payloadVersion byte) common.Uint256 { func (p *CRCProposal) ToProposalInfo(payloadVersion byte) CRCProposalInfo { info := CRCProposalInfo{ - ProposalType: p.ProposalType, - CategoryData: p.CategoryData, - OwnerPublicKey: p.OwnerKey, - DraftHash: p.DraftHash, - Budgets: p.Budgets, - Recipient: p.Recipient, - TargetProposalHash: p.TargetProposalHash, - ReservedCustomIDList: p.ReservedCustomIDList, - ReceivedCustomIDList: p.ReceivedCustomIDList, - ReceiverDID: p.ReceiverDID, - RateOfCustomIDFee: p.RateOfCustomIDFee, - EIDEffectiveHeight: p.EIDEffectiveHeight, - NewRecipient: p.NewRecipient, - NewOwnerPublicKey: p.NewOwnerKey, - SecretaryGeneralPublicKey: p.SecretaryGeneralPublicKey, - SecretaryGeneralDID: p.SecretaryGeneralDID, - CRCouncilMemberDID: p.CRCouncilMemberDID, - SideChainInfo: p.SideChainInfo, - Hash: p.Hash(payloadVersion), + ProposalType: p.ProposalType, + CategoryData: p.CategoryData, + OwnerPublicKey: p.OwnerKey, + DraftHash: p.DraftHash, + Budgets: p.Budgets, + Recipient: p.Recipient, + TargetProposalHash: p.TargetProposalHash, + ReservedCustomIDList: p.ReservedCustomIDList, + ReceivedCustomIDList: p.ReceivedCustomIDList, + ReceiverDID: p.ReceiverDID, + RateOfCustomIDFee: p.RateOfCustomIDFee, + EIDEffectiveHeight: p.EIDEffectiveHeight, + NewRecipient: p.NewRecipient, + NewOwnerPublicKey: p.NewOwnerKey, + SecretaryGeneralPublicKey: p.SecretaryGeneralPublicKey, + SecretaryGeneralDID: p.SecretaryGeneralDID, + CRCouncilMemberDID: p.CRCouncilMemberDID, + SideChainInfo: p.SideChainInfo, + ChangeSideChainMinGasPriceInfo: p.ChangeSideChainMinGasPriceInfo, + Hash: p.Hash(payloadVersion), } if info.Budgets == nil { @@ -1578,6 +1579,8 @@ type CRCProposalInfo struct { SideChainInfo + ChangeSideChainMinGasPriceInfo + // The proposal hash Hash common.Uint256 } @@ -1675,6 +1678,10 @@ func (p *CRCProposalInfo) Serialize(w io.Writer, version byte) error { return errors.New("failed to serialize SideChainInfo") } + if err := p.ChangeSideChainMinGasPriceInfo.Serialize(w); err != nil { + return errors.New("failed to serialize ChangeSideChainMinGasPriceInfo") + } + if err := p.Hash.Serialize(w); err != nil { return errors.New("failed to serialize Hash") } @@ -1786,6 +1793,10 @@ func (p *CRCProposalInfo) Deserialize(r io.Reader, version byte) error { return errors.New("failed to deserialize SideChainInfo") } + if err := p.ChangeSideChainMinGasPriceInfo.Deserialize(r); err != nil { + return errors.New("failed to deserialize ChangeSideChainMinGasPriceInfo") + } + if err := p.Hash.Deserialize(r); err != nil { return errors.New("failed to deserialize Hash") } diff --git a/servers/interfaces.go b/servers/interfaces.go index 969ead18b..4036efd69 100644 --- a/servers/interfaces.go +++ b/servers/interfaces.go @@ -2959,11 +2959,18 @@ func GetCRProposalState(param Params) map[string]interface{} { rpcProposal.SideChainInfo.MagicNumber = proposalState.Proposal.MagicNumber rpcProposal.SideChainInfo.GenesisHash = common.ToReversedString(proposalState.Proposal.GenesisHash) rpcProposal.SideChainInfo.ExchangeRate = proposalState.Proposal.ExchangeRate.String() - rpcProposal.SideChainInfo.EffectiveHeight = proposalState.Proposal.EffectiveHeight + rpcProposal.SideChainInfo.EffectiveHeight = proposalState.Proposal.SideChainInfo.EffectiveHeight rpcProposal.SideChainInfo.ResourcePath = proposalState.Proposal.ResourcePath did, _ := proposalState.Proposal.CRCouncilMemberDID.ToAddress() rpcProposal.CRCouncilMemberDID = did rpcProposalState.Proposal = rpcProposal + + case payload.ChangeSideChainMinGasPrice: + var rpcProposal CRCChangeSideChainMinGasPriceInfo + rpcProposal.GenesisBlockHash = proposalState.Proposal.ChangeSideChainMinGasPriceInfo.GenesisBlockHash.String() + rpcProposal.MinGasPrice = proposalState.Proposal.ChangeSideChainMinGasPriceInfo.MinGasPrice.String() + rpcProposal.EffectiveHeight = proposalState.Proposal.ChangeSideChainMinGasPriceInfo.EffectiveHeight + rpcProposalState.Proposal = rpcProposal } result := &RPCCRProposalStateInfo{ProposalState: rpcProposalState}