Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: Add eth merge pause flag (to main) #376

Merged
merged 11 commits into from
Oct 1, 2022
2 changes: 1 addition & 1 deletion .mergify.yml
Original file line number Diff line number Diff line change
Expand Up @@ -61,4 +61,4 @@ pull_request_rules:
actions:
backport:
branches:
- release/v1.x.x
- release/v1.x.x
39 changes: 27 additions & 12 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -45,24 +45,39 @@ Ref: https://keepachangelog.com/en/1.0.0/

### Improvements

[#367] Set ETH block delay to 96 blocks
[#362](https://github.com/umee-network/peggo/pull/362) Update umeed to v3.
[#343](https://github.com/umee-network/peggo/pull/343) Upgrade to cosmos-sdk v0.46.1.
[#341](https://github.com/umee-network/peggo/pull/341) Fix linter.
[#334](https://github.com/umee-network/peggo/pull/334) Update to go 1.18.
[#326](https://github.com/umee-network/peggo/pull/326) Refactory of eth `getCurrentBlock`.
[#311](https://github.com/umee-network/peggo/pull/311) Add valset update at each 2000 eth blocks.
- [#376] Add `eth-merge-pause` flag

### Bug Fixes
## [v1.1.0](https://github.com/umee-network/peggo/releases/tag/v1.1.0) - 2022-09-26

### Improvements

- [#367] Set ETH block delay to 96 blocks

## [v1.0.1](https://github.com/umee-network/peggo/releases/tag/v1.0.1) - 2022-09-21

### Improvements

- [#365] Reduce oracle noise msgs

## [v1.0.0](https://github.com/umee-network/peggo/releases/tag/v1.0.0) - 2022-09-14

### Improvements

- [#362](https://github.com/umee-network/peggo/pull/362) Update umeed to v3.
- [#343](https://github.com/umee-network/peggo/pull/343) Upgrade to cosmos-sdk v0.46.1.
- [#341](https://github.com/umee-network/peggo/pull/341) Fix linter.
- [#334](https://github.com/umee-network/peggo/pull/334) Update to go 1.18.
- [#326](https://github.com/umee-network/peggo/pull/326) Refactory of eth `getCurrentBlock`.
- [#311](https://github.com/umee-network/peggo/pull/311) Add valset update at each 2000 eth blocks.

## [v0.4.0](https://github.com/umee-network/peggo/releases/tag/v0.4.0) - 2022-07-14

### Improvements

[#308](https://github.com/umee-network/peggo/pull/308) Change stablecoin from UST to DAI.
[#299](https://github.com/umee-network/peggo/pull/299) Fix lint warnings.
[#297](https://github.com/umee-network/peggo/pull/297) Update dependabot reviewers.
[#275](https://github.com/umee-network/peggo/pull/275) Add diagrams of main loops.
- [#308](https://github.com/umee-network/peggo/pull/308) Change stablecoin from UST to DAI.
- [#299](https://github.com/umee-network/peggo/pull/299) Fix lint warnings.
- [#297](https://github.com/umee-network/peggo/pull/297) Update dependabot reviewers.
- [#275](https://github.com/umee-network/peggo/pull/275) Add diagrams of main loops.

### Bug Fixes

Expand Down
1 change: 1 addition & 0 deletions cmd/peggo/flags.go
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down
2 changes: 2 additions & 0 deletions cmd/peggo/orchestrator.go
Original file line number Diff line number Diff line change
Expand Up @@ -252,6 +252,7 @@ func getOrchestratorCmd() *cobra.Command {
konfig.Int64(flagBridgeStartHeight),
symbolRetriever,
o,
konfig.Bool(flagEthMergePause),
)

g, errCtx := errgroup.WithContext(ctx)
Expand All @@ -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(),
Expand Down
7 changes: 7 additions & 0 deletions orchestrator/eth_event_watcher.go
Original file line number Diff line number Diff line change
Expand Up @@ -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(
Expand Down
5 changes: 5 additions & 0 deletions orchestrator/eth_event_watcher_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -166,6 +166,7 @@ func TestCheckForEvents(t *testing.T) {
0,
nil,
nil,
false,
)

currentBlock, err := orch.CheckForEvents(context.Background(), 1, 5)
Expand Down Expand Up @@ -248,6 +249,7 @@ func TestCheckForEvents(t *testing.T) {
0,
nil,
nil,
false,
)

currentBlock, err := orch.CheckForEvents(context.Background(), 1, 5)
Expand Down Expand Up @@ -357,6 +359,7 @@ func TestCheckForEvents(t *testing.T) {
0,
nil,
nil,
false,
)

currentBlock, err := orch.CheckForEvents(context.Background(), 1, 5)
Expand Down Expand Up @@ -480,6 +483,7 @@ func TestCheckForEvents(t *testing.T) {
0,
nil,
nil,
false,
)

currentBlock, err := orch.CheckForEvents(context.Background(), 1, 5)
Expand Down Expand Up @@ -617,6 +621,7 @@ func TestCheckForEvents(t *testing.T) {
0,
nil,
nil,
false,
)

currentBlock, err := orch.CheckForEvents(context.Background(), 1, 5)
Expand Down
18 changes: 12 additions & 6 deletions orchestrator/main_loops.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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
Expand Down Expand Up @@ -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
Expand Down
1 change: 1 addition & 0 deletions orchestrator/oracle_resync_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -160,6 +160,7 @@ func TestGetLastCheckedBlock(t *testing.T) {
0,
nil,
nil,
false,
)

block, err := orch.GetLastCheckedBlock(context.Background(), 0)
Expand Down
3 changes: 3 additions & 0 deletions orchestrator/orchestrator.go
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,7 @@ type gravityOrchestrator struct {

mtx sync.Mutex
erc20DenomCache map[string]string
ethMergePause bool
}

func NewGravityOrchestrator(
Expand All @@ -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 {

Expand All @@ -84,6 +86,7 @@ func NewGravityOrchestrator(
bridgeStartHeight: uint64(bridgeStartHeight),
symbolRetriever: symbolRetriever,
oracle: oracle,
ethMergePause: ethMergePause,
}

for _, option := range options {
Expand Down