diff --git a/common/config/config.go b/common/config/config.go index a48b29785..1aa3ad3a4 100644 --- a/common/config/config.go +++ b/common/config/config.go @@ -157,17 +157,17 @@ func GetDefaultParams() *Configuration { CRAssetsRectifyTransactionHeight: 751400, ProposalCRVotingPeriod: 7 * 720, ProposalPublicVotingPeriod: 7 * 720, - VoterRejectPercentage: 10, - MaxCommitteeProposalCount: 128, - MaxCRAssetsAddressUTXOCount: 800, - MinCRAssetsAddressUTXOCount: 720, - RectifyTxFee: 10000, - RealWithdrawSingleFee: 10000, - NewP2PProtocolVersionHeight: 751400, - ChangeCommitteeNewCRHeight: 932530, - CheckVoteCRCountHeight: 658930, - CRClaimPeriod: 720 * 14, - ChangeESCMinGasPriceHeight: math.MaxUint32, // todo complete me + VoterRejectPercentage: 10, + MaxCommitteeProposalCount: 128, + MaxCRAssetsAddressUTXOCount: 800, + MinCRAssetsAddressUTXOCount: 720, + RectifyTxFee: 10000, + RealWithdrawSingleFee: 10000, + NewP2PProtocolVersionHeight: 751400, + ChangeCommitteeNewCRHeight: 932530, + CheckVoteCRCountHeight: 658930, + CRClaimPeriod: 720 * 14, + ChangeSideChainMinGasPriceHeight: math.MaxUint32, // todo complete me }, DPoSConfiguration: DPoSConfiguration{ @@ -400,7 +400,7 @@ func (p *Configuration) TestNet() *Configuration { p.MemoryPoolTxMaximumStayHeight = 10 - p.CRConfiguration.ChangeESCMinGasPriceHeight = math.MaxUint32 // todo complete me + p.CRConfiguration.ChangeSideChainMinGasPriceHeight = math.MaxUint32 // todo complete me return p } @@ -523,7 +523,7 @@ func (p *Configuration) RegNet() *Configuration { p.MultiExchangeVotesStartHeight = math.MaxUint32 // todo complete me p.DPoSConfiguration.DexStartHeight = math.MaxUint32 // todo complete me - p.CRConfiguration.ChangeESCMinGasPriceHeight = math.MaxUint32 // todo complete me + p.CRConfiguration.ChangeSideChainMinGasPriceHeight = math.MaxUint32 // todo complete me p.MemoryPoolTxMaximumStayHeight = 10 @@ -815,8 +815,8 @@ type CRConfiguration struct { CRCProposalDraftDataStartHeight uint32 `screw:"--crcproposaldraftdatastartheight" usage:"defines the proposal draft data start height"` // CRClaimPeriod defines the duration of CR claim DPoS node period which measured by block height CRClaimPeriod uint32 `screw:"--crclaimperiod" usage:"defines the duration of CR claim DPoS node"` - // ChangeESCMinGasPriceHeight defines the height to use CR proposal to change gas price of side chain - ChangeESCMinGasPriceHeight uint32 `screw:"--changesidechainfeeheight" usage:"defines the height to use CR proposal to change gas price of side chain"` + // ChangeSideChainMinGasPriceHeight defines the height to use CR proposal to change gas price of side chain + ChangeSideChainMinGasPriceHeight uint32 `screw:"--changesidechainfeeheight" usage:"defines the height to use CR proposal to change gas price of side chain"` } // PowConfiguration defines the Proof-of-Work parameters. diff --git a/core/transaction/crcproposaltransaction.go b/core/transaction/crcproposaltransaction.go index 558abe75e..f913954af 100644 --- a/core/transaction/crcproposaltransaction.go +++ b/core/transaction/crcproposaltransaction.go @@ -73,10 +73,10 @@ func (t *CRCProposalTransaction) HeightVersionCheck() error { return errors.New(fmt.Sprintf("not support %s CRCProposal"+ " transaction before NewCrossChainStartHeight", p.ProposalType.Name())) } - case payload.ChangeESCMinGasPrice: - if blockHeight < chainParams.CRConfiguration.ChangeESCMinGasPriceHeight { + case payload.ChangeESCMinGasPrice, payload.ChangeEIDMinGasPrice: + if blockHeight < chainParams.CRConfiguration.ChangeSideChainMinGasPriceHeight { return errors.New(fmt.Sprintf("not support %s CRCProposal"+ - " transaction before ChangeESCMinGasPriceHeight", p.ProposalType.Name())) + " transaction before ChangeSideChainMinGasPriceHeight", p.ProposalType.Name())) } default: if blockHeight < chainParams.CRConfiguration.CRCommitteeStartHeight { @@ -169,8 +169,11 @@ func (t *CRCProposalTransaction) SpecialContextCheck() (result elaerr.ELAError, if err != nil { return elaerr.Simple(elaerr.ErrTxPayload, err), true } - case payload.ChangeESCMinGasPrice: - + case payload.ChangeESCMinGasPrice, payload.ChangeEIDMinGasPrice: + err := t.checkChangeSideChainGasPriceProposal(proposal, t.PayloadVersion()) + if err != nil { + return elaerr.Simple(elaerr.ErrTxPayload, err), true + } default: err := t.checkNormalOrELIPProposal(t.parameters, proposal, t.parameters.ProposalsUsedAmount, t.PayloadVersion()) if err != nil { @@ -589,7 +592,7 @@ func (t *CRCProposalTransaction) checkRegisterSideChainProposal(params *Transact return t.checkOwnerAndCRCouncilMemberSign(proposal, crMember.Info.Code, payloadVersion) } -func (t *CRCProposalTransaction) checkChangeSideChainFeeProposal(proposal *payload.CRCProposal, payloadVersion byte) error { +func (t *CRCProposalTransaction) checkChangeSideChainGasPriceProposal(proposal *payload.CRCProposal, payloadVersion byte) error { _, err := crypto.DecodePoint(proposal.OwnerKey) if err != nil { return errors.New("DecodePoint from OwnerKey error") diff --git a/core/types/payload/crcproposal.go b/core/types/payload/crcproposal.go index 8ea8b10f6..c209ff03b 100644 --- a/core/types/payload/crcproposal.go +++ b/core/types/payload/crcproposal.go @@ -64,6 +64,7 @@ const ( // 0x06 Change side chain transaction fee // change ESC side chain min gas price ChangeESCMinGasPrice CRCProposalType = 0x0600 + ChangeEIDMinGasPrice CRCProposalType = 0x0601 ) type CRCProposalType uint16 @@ -97,6 +98,8 @@ func (pt CRCProposalType) Name() string { return "ChangeCustomIDFee" case ChangeESCMinGasPrice: return "ChangeESCMinGasPrice" + case ChangeEIDMinGasPrice: + return "ChangeEIDMinGasPrice" default: return "Unknown" } @@ -182,7 +185,7 @@ type CRCProposal struct { CustomIDFeeRateInfo - ChangeESCMinGasPriceInfo + ChangeSideChainMinGasPriceInfo // The specified ELA address where the funds are to be sent. NewRecipient common.Uint168 @@ -399,7 +402,7 @@ func (sc *CustomIDFeeRateInfo) Deserialize(r io.Reader) error { return nil } -type ChangeESCMinGasPriceInfo struct { +type ChangeSideChainMinGasPriceInfo struct { // The min gas price of ESC side chain MinGasPrice common.Fixed64 @@ -407,7 +410,7 @@ type ChangeESCMinGasPriceInfo struct { EffectiveHeight uint32 } -func (sc *ChangeESCMinGasPriceInfo) Serialize(w io.Writer) error { +func (sc *ChangeSideChainMinGasPriceInfo) Serialize(w io.Writer) error { if err := sc.MinGasPrice.Serialize(w); err != nil { return errors.New("failed to serialize MinGasPrice") } @@ -419,7 +422,7 @@ func (sc *ChangeESCMinGasPriceInfo) Serialize(w io.Writer) error { return nil } -func (sc *ChangeESCMinGasPriceInfo) Deserialize(r io.Reader) error { +func (sc *ChangeSideChainMinGasPriceInfo) Deserialize(r io.Reader) error { var err error if err = sc.MinGasPrice.Deserialize(r); err != nil { return errors.New("failed to deserialize MinGasPrice") @@ -459,7 +462,7 @@ func (p *CRCProposal) SerializeUnsigned(w io.Writer, version byte) error { return p.SerializeUnsignedChangeCustomIDFee(w, version) case RegisterSideChain: return p.SerializeUnsignedRegisterSideChain(w, version) - case ChangeESCMinGasPrice: + case ChangeESCMinGasPrice, ChangeEIDMinGasPrice: return p.SerializeChangeSideChainFee(w, version) default: return p.SerializeUnsignedNormalOrELIP(w, version) @@ -648,7 +651,7 @@ func (p *CRCProposal) SerializeChangeSideChainFee(w io.Writer, version byte) err } } - if err := p.ChangeESCMinGasPriceInfo.Serialize(w); err != nil { + if err := p.ChangeSideChainMinGasPriceInfo.Serialize(w); err != nil { return err } @@ -945,7 +948,7 @@ func (p *CRCProposal) DeserializeUnSigned(r io.Reader, version byte) error { return p.DeserializeUnSignedChangeCustomIDFee(r, version) case RegisterSideChain: return p.DeserializeUnsignedRegisterSideChain(r, version) - case ChangeESCMinGasPrice: + case ChangeESCMinGasPrice, ChangeEIDMinGasPrice: return p.DeserializeChangeSideChainFee(r, version) default: return p.DeserializeUnSignedNormalOrELIP(r, version) @@ -1097,7 +1100,7 @@ func (p *CRCProposal) DeserializeChangeSideChainFee(r io.Reader, version byte) e } } - if err = p.ChangeESCMinGasPriceInfo.Deserialize(r); err != nil { + if err = p.ChangeSideChainMinGasPriceInfo.Deserialize(r); err != nil { return err } diff --git a/cr/state/proposalmanager.go b/cr/state/proposalmanager.go index da3a608e9..992d373e4 100644 --- a/cr/state/proposalmanager.go +++ b/cr/state/proposalmanager.go @@ -284,7 +284,7 @@ func recordPartProposalResult(results *[]payload.ProposalResult, case payload.ReserveCustomID, payload.ReceiveCustomID, payload.ChangeCustomIDFee: needRecordResult = true - case payload.ChangeESCMinGasPrice: + case payload.ChangeESCMinGasPrice, payload.ChangeEIDMinGasPrice: needRecordResult = true default: