From 18fde18d58b6f85ec0e8b74c2d0ff0eb9d4108c7 Mon Sep 17 00:00:00 2001 From: "mergify[bot]" <37929162+mergify[bot]@users.noreply.github.com> Date: Sat, 1 Oct 2022 16:34:09 -0300 Subject: [PATCH] feat: Add eth merge pause flag (to main) (backport #376) (#377) * feat: Add eth merge pause flag (to main) (#376) * chore: modify eth block delay (#367) (#368) * chore: modify eth block delay * chore: modify eth block delay * fix test * fix test * changelog * changelog (cherry picked from commit 86ac6c45b06140ee144b7abc6a1420f878250518) Co-authored-by: Facundo Medica <14063057+facundomedica@users.noreply.github.com> * feat: reduce oracle noise msgs (#365) (#369) * update test scripts * reduce noise messages of pf * add more providers to default * add workflow for v1.0.x * fix branch name (cherry picked from commit 13fb428b9348590bb6f8ed05e16b4ce4185dce09) Co-authored-by: Rafael Tenfen Co-authored-by: Facundo Medica <14063057+facundomedica@users.noreply.github.com> * chore: prepare v1.1.0 release (#371) * chore: prepare v1.1.0 release * chore: prepare v1.1.0 release * feat: Add eth merge pause flag * fix * fix add flag to cmd * lint * fix mergify Co-authored-by: mergify[bot] <37929162+mergify[bot]@users.noreply.github.com> Co-authored-by: Rafael Tenfen (cherry picked from commit 8b19cf8fd3a50c52791c8d189faafc9803668912) # Conflicts: # CHANGELOG.md * fix cl Co-authored-by: Facundo Medica <14063057+facundomedica@users.noreply.github.com> Co-authored-by: Facundo Medica --- .mergify.yml | 2 +- CHANGELOG.md | 6 ++++++ cmd/peggo/flags.go | 1 + cmd/peggo/orchestrator.go | 2 ++ orchestrator/eth_event_watcher.go | 7 +++++++ orchestrator/eth_event_watcher_test.go | 5 +++++ orchestrator/main_loops.go | 18 ++++++++++++------ orchestrator/oracle_resync_test.go | 1 + orchestrator/orchestrator.go | 3 +++ 9 files changed, 38 insertions(+), 7 deletions(-) diff --git a/.mergify.yml b/.mergify.yml index 9d79ccb5..3f6557e2 100644 --- a/.mergify.yml +++ b/.mergify.yml @@ -61,4 +61,4 @@ pull_request_rules: actions: backport: branches: - - release/v1.x.x + - release/v1.x.x \ No newline at end of file diff --git a/CHANGELOG.md b/CHANGELOG.md index 4d2ea464..ba2dab3d 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -43,6 +43,12 @@ Ref: https://keepachangelog.com/en/1.0.0/ ## [Unreleased] +## [v1.2.0](https://github.com/umee-network/peggo/releases/tag/v1.2.0) - 2022-10-01 + +### Improvements + +- [#376] Add `eth-merge-pause` flag + ## [v1.1.0](https://github.com/umee-network/peggo/releases/tag/v1.1.0) - 2022-09-26 ### Improvements diff --git a/cmd/peggo/flags.go b/cmd/peggo/flags.go index 66db0251..4a6b9966 100644 --- a/cmd/peggo/flags.go +++ b/cmd/peggo/flags.go @@ -55,6 +55,7 @@ const ( flagRelayerLoopMultiplier = "relayer-loop-multiplier" flagRequesterLoopMultiplier = "requester-loop-multiplier" flagBridgeStartHeight = "bridge-start-height" + flagEthMergePause = "eth-merge-pause" // TODO: remove this after merge is completed ) func cosmosFlagSet() *pflag.FlagSet { diff --git a/cmd/peggo/orchestrator.go b/cmd/peggo/orchestrator.go index 47741992..ee3bc11b 100644 --- a/cmd/peggo/orchestrator.go +++ b/cmd/peggo/orchestrator.go @@ -252,6 +252,7 @@ func getOrchestratorCmd() *cobra.Command { konfig.Int64(flagBridgeStartHeight), symbolRetriever, o, + konfig.Bool(flagEthMergePause), ) g, errCtx := errgroup.WithContext(ctx) @@ -276,6 +277,7 @@ func getOrchestratorCmd() *cobra.Command { cmd.Flags().Bool(flagRelayBatches, false, "Relay transaction batches to Ethereum") cmd.Flags().Int64(flagEthBlocksPerLoop, 2000, "Number of Ethereum blocks to process per orchestrator loop") cmd.Flags().String(flagCoinGeckoAPI, "https://api.coingecko.com/api/v3", "Specify the coingecko API endpoint") + cmd.Flags().Bool(flagEthMergePause, false, "Pause some messages related to the adaptation of the Gravity Bridge to the merge") //nolint: lll defaultProviders := []string{ umeepfprovider.ProviderOsmosis.String(), diff --git a/orchestrator/eth_event_watcher.go b/orchestrator/eth_event_watcher.go index 46799afc..fe8752b2 100644 --- a/orchestrator/eth_event_watcher.go +++ b/orchestrator/eth_event_watcher.go @@ -202,6 +202,13 @@ func (p *gravityOrchestrator) CheckForEvents( valsetUpdates := filterValsetUpdateEventsByNonce(valsetUpdatedEvents, lastEventResp.EventNonce) deployedERC20Updates := filterERC20DeployedEventsByNonce(erc20DeployedEvents, lastEventResp.EventNonce) + // Don't send anything other than valsetUpdates + if p.ethMergePause { + deposits = []*wrappers.GravitySendToCosmosEvent{} + withdraws = []*wrappers.GravityTransactionBatchExecutedEvent{} + deployedERC20Updates = []*wrappers.GravityERC20DeployedEvent{} + } + if len(deposits) > 0 || len(withdraws) > 0 || len(valsetUpdates) > 0 || len(deployedERC20Updates) > 0 { if err := p.gravityBroadcastClient.SendEthereumClaims( diff --git a/orchestrator/eth_event_watcher_test.go b/orchestrator/eth_event_watcher_test.go index a42dc796..97e56d47 100644 --- a/orchestrator/eth_event_watcher_test.go +++ b/orchestrator/eth_event_watcher_test.go @@ -166,6 +166,7 @@ func TestCheckForEvents(t *testing.T) { 0, nil, nil, + false, ) currentBlock, err := orch.CheckForEvents(context.Background(), 1, 5) @@ -248,6 +249,7 @@ func TestCheckForEvents(t *testing.T) { 0, nil, nil, + false, ) currentBlock, err := orch.CheckForEvents(context.Background(), 1, 5) @@ -357,6 +359,7 @@ func TestCheckForEvents(t *testing.T) { 0, nil, nil, + false, ) currentBlock, err := orch.CheckForEvents(context.Background(), 1, 5) @@ -480,6 +483,7 @@ func TestCheckForEvents(t *testing.T) { 0, nil, nil, + false, ) currentBlock, err := orch.CheckForEvents(context.Background(), 1, 5) @@ -617,6 +621,7 @@ func TestCheckForEvents(t *testing.T) { 0, nil, nil, + false, ) currentBlock, err := orch.CheckForEvents(context.Background(), 1, 5) diff --git a/orchestrator/main_loops.go b/orchestrator/main_loops.go index 8c24e2a6..0c62bf1c 100644 --- a/orchestrator/main_loops.go +++ b/orchestrator/main_loops.go @@ -64,12 +64,14 @@ func (p *gravityOrchestrator) Start(ctx context.Context) error { return p.EthOracleMainLoop(ctx) }) - pg.Go(func() error { - // looks at the BatchFees on Cosmos and uses the query endpoint BatchFees - // to iterate over each token to see if it is profitable, if it is - // it will send an request batch for that denom - return p.BatchRequesterLoop(ctx) - }) + if !p.ethMergePause { + pg.Go(func() error { + // looks at the BatchFees on Cosmos and uses the query endpoint BatchFees + // to iterate over each token to see if it is profitable, if it is + // it will send an request batch for that denom + return p.BatchRequesterLoop(ctx) + }) + } pg.Go(func() error { // Gets the last pending valset to send an MsgValsetConfirm that sends @@ -81,6 +83,8 @@ func (p *gravityOrchestrator) Start(ctx context.Context) error { return p.EthSignerMainLoop(ctx) }) + // Let this function run as is. If we see errors caused by this loop, then + // we might need to enable batch confirms. pg.Go(func() error { // Gets the latest valset available and updating it on the ethereum // smartcontract if needed. Also gets all the pending transaction @@ -268,6 +272,8 @@ func (p *gravityOrchestrator) EthSignerMainLoop(ctx context.Context) (err error) } } + // Try to send batch confirms. If this fails, it means there are pending batches + // that we'll need to sign before the next upgrade. var oldestUnsignedTransactionBatch []types.OutgoingTxBatch if err := retry.Do(func() error { // sign the last unsigned batch, TODO check if we already have signed this diff --git a/orchestrator/oracle_resync_test.go b/orchestrator/oracle_resync_test.go index 9da776ab..40d0cb0a 100644 --- a/orchestrator/oracle_resync_test.go +++ b/orchestrator/oracle_resync_test.go @@ -160,6 +160,7 @@ func TestGetLastCheckedBlock(t *testing.T) { 0, nil, nil, + false, ) block, err := orch.GetLastCheckedBlock(context.Background(), 0) diff --git a/orchestrator/orchestrator.go b/orchestrator/orchestrator.go index 80b906a3..bacf7445 100644 --- a/orchestrator/orchestrator.go +++ b/orchestrator/orchestrator.go @@ -46,6 +46,7 @@ type gravityOrchestrator struct { mtx sync.Mutex erc20DenomCache map[string]string + ethMergePause bool } func NewGravityOrchestrator( @@ -64,6 +65,7 @@ func NewGravityOrchestrator( bridgeStartHeight int64, symbolRetriever relayer.SymbolRetriever, oracle relayer.Oracle, + ethMergePause bool, // TODO: remove this after merge is completed options ...func(GravityOrchestrator), ) GravityOrchestrator { @@ -84,6 +86,7 @@ func NewGravityOrchestrator( bridgeStartHeight: uint64(bridgeStartHeight), symbolRetriever: symbolRetriever, oracle: oracle, + ethMergePause: ethMergePause, } for _, option := range options {