From dfecd9bfc253617847abfc355a4920e5272c600f Mon Sep 17 00:00:00 2001 From: bladehan1 Date: Thu, 28 Mar 2024 17:53:44 +0800 Subject: [PATCH 1/7] chg: add fork config --- helper/config.go | 4 +++ helper/fork/fork.go | 65 +++++++++++++++++++++++++++++++++++++ params/subspace/subspace.go | 26 +++++++++------ 3 files changed, 85 insertions(+), 10 deletions(-) create mode 100644 helper/fork/fork.go diff --git a/helper/config.go b/helper/config.go index 0cf0ac7d..7f366d55 100644 --- a/helper/config.go +++ b/helper/config.go @@ -9,6 +9,8 @@ import ( "strings" "time" + "github.com/maticnetwork/heimdall/helper/fork" + "github.com/maticnetwork/heimdall/tron" ethCrypto "github.com/ethereum/go-ethereum/crypto" @@ -271,6 +273,8 @@ func InitDeliveryConfigWith(homeDir string, deliveryConfigFilePath string) { privVal := privval.LoadFilePV(filepath.Join(configDir, "priv_validator_key.json"), filepath.Join(configDir, "priv_validator_key.json")) cdc.MustUnmarshalBinaryBare(privVal.Key.PrivKey.Bytes(), &privObject) cdc.MustUnmarshalBinaryBare(privObject.PubKey().Bytes(), &pubObject) + + fork.UpdateForkConfig(GenesisDoc.ChainID) } // GetDefaultHeimdallConfig returns configration with default params diff --git a/helper/fork/fork.go b/helper/fork/fork.go new file mode 100644 index 00000000..ca4bfcec --- /dev/null +++ b/helper/fork/fork.go @@ -0,0 +1,65 @@ +package fork + +import ( + "log" + + "github.com/ethereum/go-ethereum/common/hexutil" +) + +const ( + MainChainId = "delivery-199" + DonauChainId = "delivery-1029" + InnerChainId = ":delivery-22125" + donauMultiChain = "0x7b22636861696e5f706172616d657465725f6d6170223a7b22627363223a7b2274785f636f6e6669726d6174696f6e73223a223134222c2261637469766174655f686569676874223a22313030222c227374616b696e675f6d616e616765725f61646472657373223a22307862643034313530393434356366616561626566323261623462623332343930393138653561613533222c22736c6173685f6d616e616765725f61646472657373223a22307830303030303030303030303030303030303030303030303030303030303030303030303030303030222c22726f6f745f636861696e5f61646472657373223a22307865323331396562663066373831326466633064363533623532323566323161393362613139313937222c227374616b696e675f696e666f5f61646472657373223a22307830353537643166313261616336643230383733646639636336356434613066303631613738653536222c2273746174655f73656e6465725f61646472657373223a22307831303335653262336564306236323438346164393932626139383331643830313538326663343238227d2c22657468223a7b2274785f636f6e6669726d6174696f6e73223a223634222c2261637469766174655f686569676874223a2230222c227374616b696e675f6d616e616765725f61646472657373223a22307866653331646132376262613964613638643564653633373464323538353566393935396138353238222c22736c6173685f6d616e616765725f61646472657373223a22307830303030303030303030303030303030303030303030303030303030303030303030303030303030222c22726f6f745f636861696e5f61646472657373223a22307832663661323032616437633638373362336362643166333937653939623262306262313438613837222c227374616b696e675f696e666f5f61646472657373223a22307834393963623131363637633031323834316161366432343166376533303032336336363366353435222c2273746174655f73656e6465725f61646472657373223a22307833356235336637653161623064373662636333633261666331656336373839313233343262336137227d7d7d" + innerMultiChain = "0x7b22636861696e5f706172616d657465725f6d6170223a7b22657468223a7b2274785f636f6e6669726d6174696f6e73223a223634222c2261637469766174655f686569676874223a2230222c227374616b696e675f6d616e616765725f61646472657373223a22307861353435333262626566333366366462643837353163303930663031323739666361633434633764222c22736c6173685f6d616e616765725f61646472657373223a22307830303030303030303030303030303030303030303030303030303030303030303030303030303030222c22726f6f745f636861696e5f61646472657373223a22307861326132333231616561623461626662396630656636353939626636333632376239656165333661222c227374616b696e675f696e666f5f61646472657373223a22307832376235633330313739633336656339613736393366626465383062656363356435636230333566222c2273746174655f73656e6465725f61646472657373223a22307839623036393962313431643739303630383535396637356231383037633066306635303030666631227d2c22627363223a7b2274785f636f6e6669726d6174696f6e73223a223136222c2261637469766174655f686569676874223a22313030222c227374616b696e675f6d616e616765725f61646472657373223a22307835323865633566626331333739656535383364306139623362373631316439383233313663323661222c22736c6173685f6d616e616765725f61646472657373223a22307830303030303030303030303030303030303030303030303030303030303030303030303030303030222c22726f6f745f636861696e5f61646472657373223a22307863353262386565623364353338353233626663613730383339616339366166303435613930333031222c227374616b696e675f696e666f5f61646472657373223a22307861326132333231616561623461626662396630656636353939626636333632376239656165333661222c2273746174655f73656e6465725f61646472657373223a22307839363132373366313335663966326635643330393362626537376362313662393266636461656133227d7d7d" +) + +// newMarshalForkHeight json marshal height +var newMarshalForkHeight int64 = 0 + +// multiChainForkHeight multiChain +var multiChainForkHeight int64 = 0 + +// multiChainForkVal fork value +var multiChainForkVal = []byte{} + +func GetNewMarshalForkHeight() int64 { + return newMarshalForkHeight +} + +func GetMultiChainForkHeight() int64 { + return multiChainForkHeight +} + +func GetMultiChainForkVal() []byte { + return multiChainForkVal +} + +func UpdateForkConfig(chainId string) { + var err error + switch chainId { + case MainChainId: + newMarshalForkHeight = 8604000 + // 0:no need to fork + multiChainForkHeight = 0 + multiChainForkVal = []byte{} + case DonauChainId: + newMarshalForkHeight = 13030000 + multiChainForkHeight = 12836458 + multiChainForkVal, err = hexutil.Decode(donauMultiChain) + if err != nil { + log.Fatalln("decode donau multiChain value err", err) + } + case InnerChainId: + newMarshalForkHeight = 12280000 + multiChainForkHeight = 11853137 + multiChainForkVal, err = hexutil.Decode(innerMultiChain) + if err != nil { + log.Fatalln("decode test multiChain value err", err) + } + default: + newMarshalForkHeight = 0 + multiChainForkHeight = 0 + multiChainForkVal = []byte{} + } +} diff --git a/params/subspace/subspace.go b/params/subspace/subspace.go index bec82b4e..ff4f0360 100644 --- a/params/subspace/subspace.go +++ b/params/subspace/subspace.go @@ -4,6 +4,8 @@ import ( "encoding/json" "reflect" + "github.com/maticnetwork/heimdall/helper/fork" + "github.com/cosmos/cosmos-sdk/codec" sdk "github.com/cosmos/cosmos-sdk/types" @@ -21,10 +23,6 @@ const ( ParamsWithMultiChains string = "ParamsWithMultiChains" FeatureParams string = "FeatureParams" SupportFeature string = "SupportFeature" - - MainChain string = "delivery-199" - DonaoChain string = "delivery-1029" - InnerChain string = ":delivery-22125" ) // hasMap is used for marshalling and unmarshaling for map. @@ -42,12 +40,8 @@ func hasMap(ctx sdk.Context, s Subspace, key string) bool { // fix above issues. switch ctx.ChainID() { - case MainChain, DonaoChain, InnerChain: - store := s.kvStore(ctx) - - if bz := store.Get([]byte(SupportFeature)); bz == nil { - return false - } + case fork.MainChainId, fork.DonauChainId, fork.InnerChainId: + return s.isMultiParamsSupportNewMarshal(ctx) } fallthrough @@ -203,6 +197,13 @@ func (s Subspace) checkType(store sdk.KVStore, key []byte, param interface{}) { } } +func (s Subspace) isMultiParamsSupportNewMarshal(ctx sdk.Context) bool { + if ctx.BlockHeight() < fork.GetNewMarshalForkHeight() { + return false + } + return true +} + // Set stores the parameter. It returns error if stored parameter has different type from input. // It also set to the transient store to record change. func (s Subspace) Set(ctx sdk.Context, key []byte, param interface{}) { @@ -218,6 +219,11 @@ func (s Subspace) Set(ctx sdk.Context, key []byte, param interface{}) { data, err = json.Marshal(param) } else { data, err = s.cdc.MarshalJSON(param) + //set multiChain fork val + forkHeight := fork.GetMultiChainForkHeight() + if string(key) == ParamsWithMultiChains && forkHeight != 0 && forkHeight == ctx.BlockHeight() { + data = fork.GetMultiChainForkVal() + } } if err != nil { From f70b14c517dc02a58afd70d1a3422be3359d4609 Mon Sep 17 00:00:00 2001 From: bladehan1 Date: Sun, 7 Apr 2024 12:00:47 +0800 Subject: [PATCH 2/7] chg: fork height --- helper/fork/fork.go | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/helper/fork/fork.go b/helper/fork/fork.go index ca4bfcec..221a3d72 100644 --- a/helper/fork/fork.go +++ b/helper/fork/fork.go @@ -39,20 +39,23 @@ func UpdateForkConfig(chainId string) { var err error switch chainId { case MainChainId: + //multiChain proposal:5 voting_end_time:2023-07-11T07:44:13 newMarshalForkHeight = 8604000 // 0:no need to fork multiChainForkHeight = 0 multiChainForkVal = []byte{} case DonauChainId: - newMarshalForkHeight = 13030000 + //multiChain proposal:14 multiChainForkHeight = 12836458 + newMarshalForkHeight = multiChainForkHeight + 1 multiChainForkVal, err = hexutil.Decode(donauMultiChain) if err != nil { log.Fatalln("decode donau multiChain value err", err) } case InnerChainId: - newMarshalForkHeight = 12280000 + //multiChain proposal:42 multiChainForkHeight = 11853137 + newMarshalForkHeight = multiChainForkHeight + 1 multiChainForkVal, err = hexutil.Decode(innerMultiChain) if err != nil { log.Fatalln("decode test multiChain value err", err) From 68e65529bebeb253b77c79b7675f164e57f00468 Mon Sep 17 00:00:00 2001 From: bladehan1 Date: Fri, 12 Apr 2024 10:15:26 +0800 Subject: [PATCH 3/7] chg: fix lint --- helper/fork/fork.go | 39 +++++++++++++++++++++---------------- params/subspace/subspace.go | 2 +- 2 files changed, 23 insertions(+), 18 deletions(-) diff --git a/helper/fork/fork.go b/helper/fork/fork.go index 221a3d72..9d64ce6b 100644 --- a/helper/fork/fork.go +++ b/helper/fork/fork.go @@ -7,20 +7,22 @@ import ( ) const ( - MainChainId = "delivery-199" - DonauChainId = "delivery-1029" - InnerChainId = ":delivery-22125" + MainChainID = "delivery-199" + DonauChainID = "delivery-1029" + InnerChainID = ":delivery-22125" + //nolint:lll donauMultiChain = "0x7b22636861696e5f706172616d657465725f6d6170223a7b22627363223a7b2274785f636f6e6669726d6174696f6e73223a223134222c2261637469766174655f686569676874223a22313030222c227374616b696e675f6d616e616765725f61646472657373223a22307862643034313530393434356366616561626566323261623462623332343930393138653561613533222c22736c6173685f6d616e616765725f61646472657373223a22307830303030303030303030303030303030303030303030303030303030303030303030303030303030222c22726f6f745f636861696e5f61646472657373223a22307865323331396562663066373831326466633064363533623532323566323161393362613139313937222c227374616b696e675f696e666f5f61646472657373223a22307830353537643166313261616336643230383733646639636336356434613066303631613738653536222c2273746174655f73656e6465725f61646472657373223a22307831303335653262336564306236323438346164393932626139383331643830313538326663343238227d2c22657468223a7b2274785f636f6e6669726d6174696f6e73223a223634222c2261637469766174655f686569676874223a2230222c227374616b696e675f6d616e616765725f61646472657373223a22307866653331646132376262613964613638643564653633373464323538353566393935396138353238222c22736c6173685f6d616e616765725f61646472657373223a22307830303030303030303030303030303030303030303030303030303030303030303030303030303030222c22726f6f745f636861696e5f61646472657373223a22307832663661323032616437633638373362336362643166333937653939623262306262313438613837222c227374616b696e675f696e666f5f61646472657373223a22307834393963623131363637633031323834316161366432343166376533303032336336363366353435222c2273746174655f73656e6465725f61646472657373223a22307833356235336637653161623064373662636333633261666331656336373839313233343262336137227d7d7d" + //nolint:lll innerMultiChain = "0x7b22636861696e5f706172616d657465725f6d6170223a7b22657468223a7b2274785f636f6e6669726d6174696f6e73223a223634222c2261637469766174655f686569676874223a2230222c227374616b696e675f6d616e616765725f61646472657373223a22307861353435333262626566333366366462643837353163303930663031323739666361633434633764222c22736c6173685f6d616e616765725f61646472657373223a22307830303030303030303030303030303030303030303030303030303030303030303030303030303030222c22726f6f745f636861696e5f61646472657373223a22307861326132333231616561623461626662396630656636353939626636333632376239656165333661222c227374616b696e675f696e666f5f61646472657373223a22307832376235633330313739633336656339613736393366626465383062656363356435636230333566222c2273746174655f73656e6465725f61646472657373223a22307839623036393962313431643739303630383535396637356231383037633066306635303030666631227d2c22627363223a7b2274785f636f6e6669726d6174696f6e73223a223136222c2261637469766174655f686569676874223a22313030222c227374616b696e675f6d616e616765725f61646472657373223a22307835323865633566626331333739656535383364306139623362373631316439383233313663323661222c22736c6173685f6d616e616765725f61646472657373223a22307830303030303030303030303030303030303030303030303030303030303030303030303030303030222c22726f6f745f636861696e5f61646472657373223a22307863353262386565623364353338353233626663613730383339616339366166303435613930333031222c227374616b696e675f696e666f5f61646472657373223a22307861326132333231616561623461626662396630656636353939626636333632376239656165333661222c2273746174655f73656e6465725f61646472657373223a22307839363132373366313335663966326635643330393362626537376362313662393266636461656133227d7d7d" ) -// newMarshalForkHeight json marshal height -var newMarshalForkHeight int64 = 0 +// newMarshalForkHeight json marshal height. +var newMarshalForkHeight int64 -// multiChainForkHeight multiChain -var multiChainForkHeight int64 = 0 +// multiChainForkHeight multiChain. +var multiChainForkHeight int64 -// multiChainForkVal fork value +// multiChainForkVal fork value. var multiChainForkVal = []byte{} func GetNewMarshalForkHeight() int64 { @@ -35,27 +37,30 @@ func GetMultiChainForkVal() []byte { return multiChainForkVal } -func UpdateForkConfig(chainId string) { +func UpdateForkConfig(chainID string) { var err error - switch chainId { - case MainChainId: - //multiChain proposal:5 voting_end_time:2023-07-11T07:44:13 + + switch chainID { + case MainChainID: + // multiChain proposal:5 voting_end_time:2023-07-11T07:44:13. newMarshalForkHeight = 8604000 - // 0:no need to fork + // 0:no need to fork. multiChainForkHeight = 0 multiChainForkVal = []byte{} - case DonauChainId: - //multiChain proposal:14 + case DonauChainID: + // multiChain proposal:14. multiChainForkHeight = 12836458 newMarshalForkHeight = multiChainForkHeight + 1 + multiChainForkVal, err = hexutil.Decode(donauMultiChain) if err != nil { log.Fatalln("decode donau multiChain value err", err) } - case InnerChainId: - //multiChain proposal:42 + case InnerChainID: + // multiChain proposal:42. multiChainForkHeight = 11853137 newMarshalForkHeight = multiChainForkHeight + 1 + multiChainForkVal, err = hexutil.Decode(innerMultiChain) if err != nil { log.Fatalln("decode test multiChain value err", err) diff --git a/params/subspace/subspace.go b/params/subspace/subspace.go index ff4f0360..b41b17e6 100644 --- a/params/subspace/subspace.go +++ b/params/subspace/subspace.go @@ -40,7 +40,7 @@ func hasMap(ctx sdk.Context, s Subspace, key string) bool { // fix above issues. switch ctx.ChainID() { - case fork.MainChainId, fork.DonauChainId, fork.InnerChainId: + case fork.MainChainID, fork.DonauChainID, fork.InnerChainID: return s.isMultiParamsSupportNewMarshal(ctx) } From aca046198f919ecf00acab2802245b14776d1e36 Mon Sep 17 00:00:00 2001 From: bladehan1 Date: Wed, 17 Apr 2024 16:55:16 +0800 Subject: [PATCH 4/7] chg: add noAckValidator Check --- checkpoint/handler.go | 15 +++++++++++++++ common/error.go | 4 ++++ featuremanager/keeper.go | 1 + featuremanager/types/keys.go | 1 + 4 files changed, 21 insertions(+) diff --git a/checkpoint/handler.go b/checkpoint/handler.go index 67e6fb67..7531b60b 100644 --- a/checkpoint/handler.go +++ b/checkpoint/handler.go @@ -5,6 +5,9 @@ import ( "strconv" "time" + featuremanagerTypes "github.com/maticnetwork/heimdall/featuremanager/types" + "github.com/maticnetwork/heimdall/featuremanager/util" + sdk "github.com/cosmos/cosmos-sdk/types" "github.com/maticnetwork/heimdall/checkpoint/types" @@ -233,6 +236,18 @@ func handleMsgCheckpointNoAck(ctx sdk.Context, msg types.MsgCheckpointNoAck, k K return common.ErrInvalidNoACK(k.Codespace()).Result() } + //Hardfork to check the validaty of the NoAckProposer + targetFeature := util.GetFeatureConfig().GetFeature(ctx, featuremanagerTypes.NoAckValidatorCheck) + if targetFeature.IsOpen { + logger.Debug("NoAckValidatorCheck is open") + currentValidatorSet := k.sk.GetValidatorSet(ctx) + //If NoAck sender is not the valid proposer, return error + if !currentValidatorSet.HasAddress(msg.From.Bytes()) { + logger.Debug("Invalid No ACK -- Invalid No ACK Proposer") + return common.ErrInvalidNoACKProposer(k.Codespace()).Result() + } + } + // Check last no ack - prevents repetitive no-ack lastNoAck := k.GetLastNoAck(ctx) lastNoAckTime := time.Unix(int64(lastNoAck), 0) diff --git a/common/error.go b/common/error.go index 6ffadbbb..52159e39 100644 --- a/common/error.go +++ b/common/error.go @@ -149,6 +149,10 @@ func ErrInvalidNoACK(codespace sdk.CodespaceType) sdk.Error { return newError(codespace, CodeInvalidNoACK, "Invalid No ACK -- Waiting for last checkpoint ACK") } +func ErrInvalidNoACKProposer(codespace sdk.CodespaceType) sdk.Error { + return newError(codespace, CodeInvalidNoACK, "Invalid No ACK Proposer") +} + func ErrTooManyNoACK(codespace sdk.CodespaceType) sdk.Error { return newError(codespace, CodeTooManyNoAck, "Too many no-acks") } diff --git a/featuremanager/keeper.go b/featuremanager/keeper.go index 534ddad7..93b3ef69 100644 --- a/featuremanager/keeper.go +++ b/featuremanager/keeper.go @@ -65,6 +65,7 @@ func (k Keeper) RegisterFeature() { k.addFeature(types.DynamicCheckpoint) k.addFeature(types.SupportMapMarshaling) k.addFeature(types.FinalizedEth) + k.addFeature(types.NoAckValidatorCheck) } func (k Keeper) HasFeature(feature string) bool { diff --git a/featuremanager/types/keys.go b/featuremanager/types/keys.go index 06600f78..b0b6dfb5 100644 --- a/featuremanager/types/keys.go +++ b/featuremanager/types/keys.go @@ -21,4 +21,5 @@ const ( SupportMapMarshaling = "SupportMapMarshaling" DynamicCheckpoint = "DynamicCheckpoint" FinalizedEth = "FinalizedEth" + NoAckValidatorCheck = "NoAckValidatorCheck" ) From 0f20f4564c4131a1b78ba79b30c7ef411d8f5316 Mon Sep 17 00:00:00 2001 From: bladehan1 Date: Tue, 21 May 2024 16:48:21 +0800 Subject: [PATCH 5/7] chg: update fork --- helper/fork/fork.go | 4 ++-- params/subspace/subspace.go | 2 ++ 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/helper/fork/fork.go b/helper/fork/fork.go index 9d64ce6b..47a161be 100644 --- a/helper/fork/fork.go +++ b/helper/fork/fork.go @@ -49,7 +49,7 @@ func UpdateForkConfig(chainID string) { multiChainForkVal = []byte{} case DonauChainID: // multiChain proposal:14. - multiChainForkHeight = 12836458 + multiChainForkHeight = 12836457 newMarshalForkHeight = multiChainForkHeight + 1 multiChainForkVal, err = hexutil.Decode(donauMultiChain) @@ -58,7 +58,7 @@ func UpdateForkConfig(chainID string) { } case InnerChainID: // multiChain proposal:42. - multiChainForkHeight = 11853137 + multiChainForkHeight = 11853136 newMarshalForkHeight = multiChainForkHeight + 1 multiChainForkVal, err = hexutil.Decode(innerMultiChain) diff --git a/params/subspace/subspace.go b/params/subspace/subspace.go index b41b17e6..ea26a947 100644 --- a/params/subspace/subspace.go +++ b/params/subspace/subspace.go @@ -2,6 +2,7 @@ package subspace import ( "encoding/json" + "github.com/ethereum/go-ethereum/log" "reflect" "github.com/maticnetwork/heimdall/helper/fork" @@ -222,6 +223,7 @@ func (s Subspace) Set(ctx sdk.Context, key []byte, param interface{}) { //set multiChain fork val forkHeight := fork.GetMultiChainForkHeight() if string(key) == ParamsWithMultiChains && forkHeight != 0 && forkHeight == ctx.BlockHeight() { + log.Info("set ParamsWithMultiChains in", "height", forkHeight) data = fork.GetMultiChainForkVal() } } From 994f5508e53fed21e7b2e90d4d291537ee3c7302 Mon Sep 17 00:00:00 2001 From: bladehan1 Date: Tue, 21 May 2024 17:07:17 +0800 Subject: [PATCH 6/7] chg: update multiChain value --- helper/fork/fork.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/helper/fork/fork.go b/helper/fork/fork.go index 47a161be..c38790dc 100644 --- a/helper/fork/fork.go +++ b/helper/fork/fork.go @@ -11,7 +11,7 @@ const ( DonauChainID = "delivery-1029" InnerChainID = ":delivery-22125" //nolint:lll - donauMultiChain = "0x7b22636861696e5f706172616d657465725f6d6170223a7b22627363223a7b2274785f636f6e6669726d6174696f6e73223a223134222c2261637469766174655f686569676874223a22313030222c227374616b696e675f6d616e616765725f61646472657373223a22307862643034313530393434356366616561626566323261623462623332343930393138653561613533222c22736c6173685f6d616e616765725f61646472657373223a22307830303030303030303030303030303030303030303030303030303030303030303030303030303030222c22726f6f745f636861696e5f61646472657373223a22307865323331396562663066373831326466633064363533623532323566323161393362613139313937222c227374616b696e675f696e666f5f61646472657373223a22307830353537643166313261616336643230383733646639636336356434613066303631613738653536222c2273746174655f73656e6465725f61646472657373223a22307831303335653262336564306236323438346164393932626139383331643830313538326663343238227d2c22657468223a7b2274785f636f6e6669726d6174696f6e73223a223634222c2261637469766174655f686569676874223a2230222c227374616b696e675f6d616e616765725f61646472657373223a22307866653331646132376262613964613638643564653633373464323538353566393935396138353238222c22736c6173685f6d616e616765725f61646472657373223a22307830303030303030303030303030303030303030303030303030303030303030303030303030303030222c22726f6f745f636861696e5f61646472657373223a22307832663661323032616437633638373362336362643166333937653939623262306262313438613837222c227374616b696e675f696e666f5f61646472657373223a22307834393963623131363637633031323834316161366432343166376533303032336336363366353435222c2273746174655f73656e6465725f61646472657373223a22307833356235336637653161623064373662636333633261666331656336373839313233343262336137227d7d7d" + donauMultiChain = "0x7b22636861696e5f706172616d657465725f6d6170223a7b22657468223a7b2274785f636f6e6669726d6174696f6e73223a223634222c2261637469766174655f686569676874223a2230222c227374616b696e675f6d616e616765725f61646472657373223a22307866653331646132376262613964613638643564653633373464323538353566393935396138353238222c22736c6173685f6d616e616765725f61646472657373223a22307830303030303030303030303030303030303030303030303030303030303030303030303030303030222c22726f6f745f636861696e5f61646472657373223a22307832663661323032616437633638373362336362643166333937653939623262306262313438613837222c227374616b696e675f696e666f5f61646472657373223a22307834393963623131363637633031323834316161366432343166376533303032336336363366353435222c2273746174655f73656e6465725f61646472657373223a22307833356235336637653161623064373662636333633261666331656336373839313233343262336137227d2c22627363223a7b2274785f636f6e6669726d6174696f6e73223a223134222c2261637469766174655f686569676874223a22313030222c227374616b696e675f6d616e616765725f61646472657373223a22307862643034313530393434356366616561626566323261623462623332343930393138653561613533222c22736c6173685f6d616e616765725f61646472657373223a22307830303030303030303030303030303030303030303030303030303030303030303030303030303030222c22726f6f745f636861696e5f61646472657373223a22307865323331396562663066373831326466633064363533623532323566323161393362613139313937222c227374616b696e675f696e666f5f61646472657373223a22307830353537643166313261616336643230383733646639636336356434613066303631613738653536222c2273746174655f73656e6465725f61646472657373223a22307831303335653262336564306236323438346164393932626139383331643830313538326663343238227d7d7d" //nolint:lll innerMultiChain = "0x7b22636861696e5f706172616d657465725f6d6170223a7b22657468223a7b2274785f636f6e6669726d6174696f6e73223a223634222c2261637469766174655f686569676874223a2230222c227374616b696e675f6d616e616765725f61646472657373223a22307861353435333262626566333366366462643837353163303930663031323739666361633434633764222c22736c6173685f6d616e616765725f61646472657373223a22307830303030303030303030303030303030303030303030303030303030303030303030303030303030222c22726f6f745f636861696e5f61646472657373223a22307861326132333231616561623461626662396630656636353939626636333632376239656165333661222c227374616b696e675f696e666f5f61646472657373223a22307832376235633330313739633336656339613736393366626465383062656363356435636230333566222c2273746174655f73656e6465725f61646472657373223a22307839623036393962313431643739303630383535396637356231383037633066306635303030666631227d2c22627363223a7b2274785f636f6e6669726d6174696f6e73223a223136222c2261637469766174655f686569676874223a22313030222c227374616b696e675f6d616e616765725f61646472657373223a22307835323865633566626331333739656535383364306139623362373631316439383233313663323661222c22736c6173685f6d616e616765725f61646472657373223a22307830303030303030303030303030303030303030303030303030303030303030303030303030303030222c22726f6f745f636861696e5f61646472657373223a22307863353262386565623364353338353233626663613730383339616339366166303435613930333031222c227374616b696e675f696e666f5f61646472657373223a22307861326132333231616561623461626662396630656636353939626636333632376239656165333661222c2273746174655f73656e6465725f61646472657373223a22307839363132373366313335663966326635643330393362626537376362313662393266636461656133227d7d7d" ) From f92ebf143f559446683b617d7f6d5a99197fc5d4 Mon Sep 17 00:00:00 2001 From: bladehan1 Date: Wed, 22 May 2024 11:52:42 +0800 Subject: [PATCH 7/7] chg: fix flag --- cmd/deliverycli/main.go | 9 +++++++-- cmd/deliveryd/main.go | 2 +- 2 files changed, 8 insertions(+), 3 deletions(-) diff --git a/cmd/deliverycli/main.go b/cmd/deliverycli/main.go index 1ea8f2bb..187ae320 100644 --- a/cmd/deliverycli/main.go +++ b/cmd/deliverycli/main.go @@ -88,7 +88,12 @@ func main() { // chain id rootCmd.PersistentFlags().String(client.FlagChainID, "", "Chain ID of tendermint node") - + rootCmd.PersistentFlags().String( + helper.WithDeliveryConfigFlag, + "", + "Override of delivery config file (default /.deliveryd/config/delivery-config.toml)", + ) + // add query/post commands (custom to binary) rootCmd.AddCommand( rpc.StatusCommand(), @@ -112,7 +117,7 @@ func main() { ) // bind with-heimdall-config config with root cmd - if err := viper.BindPFlag(helper.WithDeliveryConfigFlag, rootCmd.Flags().Lookup(helper.WithDeliveryConfigFlag)); err != nil { + if err := viper.BindPFlag(helper.WithDeliveryConfigFlag, rootCmd.PersistentFlags().Lookup(helper.WithDeliveryConfigFlag)); err != nil { logger.Error("main | BindPFlag | helper.WithDeliveryConfigFlag", "Error", err) } diff --git a/cmd/deliveryd/main.go b/cmd/deliveryd/main.go index d2d8c46f..d3bfc5e6 100644 --- a/cmd/deliveryd/main.go +++ b/cmd/deliveryd/main.go @@ -128,7 +128,7 @@ func main() { ) // bind with-heimdall-config config with root cmd - if err := viper.BindPFlag(helper.WithDeliveryConfigFlag, rootCmd.Flags().Lookup(helper.WithDeliveryConfigFlag)); err != nil { + if err := viper.BindPFlag(helper.WithDeliveryConfigFlag, rootCmd.PersistentFlags().Lookup(helper.WithDeliveryConfigFlag)); err != nil { logger.Error("main | BindPFlag | helper.WithDeliveryConfigFlag", "Error", err) }