-
Notifications
You must be signed in to change notification settings - Fork 736
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
node: Extend flow cancel by configuring allow-list of chain ID pairs ("pipes") #4229
Open
johnsaigle
wants to merge
12
commits into
wormhole-foundation:main
Choose a base branch
from
johnsaigle:flow-cancel-pipes
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
+433
−83
Open
Changes from all commits
Commits
Show all changes
12 commits
Select commit
Hold shift + click to select a range
4a31e15
node: Add ability to limit Flow Cancel to pairs of chains
johnsaigle 23b5270
node: Call pipe.valid() when adding a flow cancel transfer
johnsaigle b40f457
node: Add unit tests for Governor pipes. Modify pipe equality check
johnsaigle 55bc7c1
Fix linter errors
johnsaigle b106d10
Restore continue on error. Improve comments and error messages
johnsaigle 8e6cfc3
Fix lint
johnsaigle b880108
Remove redundant validity check, add comment
johnsaigle 2dd942f
Add unit test for mainnet deployment of flow cancel pipes
johnsaigle a24d86d
Remove continue statement when flow cancel returns error
johnsaigle 4635b83
Improve unit test coverage for pipes
johnsaigle 22935fa
lint
johnsaigle 413f394
re-order error checking; avoid early return if flow cancel fails
johnsaigle File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
package governor | ||
|
||
import ( | ||
"github.com/wormhole-foundation/wormhole/sdk/vaa" | ||
) | ||
|
||
// FlowCancelPipes returns a list of `pipe`s representing a pair of chains for which flow canceling is enabled. | ||
// In practice this list should contain pairs of chains that have a large amount of volume between each other. | ||
// These are more likely to cause chronic congestion which flow canceling can help to alleviate. | ||
// Pairs of chains that are not frequently congested do not need to enable flow canceling as they should have | ||
// plenty of regular Governor capacity to work with. | ||
func FlowCancelPipes() []pipe { | ||
return []pipe{ | ||
{first: vaa.ChainIDEthereum, second: vaa.ChainIDSui}, | ||
} | ||
} | ||
|
||
func Valid(input []pipe) bool { | ||
seen := make([]pipe, 10) | ||
for _, p := range input { | ||
// This check is needed when there is exactly one pipe. Otherwise, the seen loop detects this. | ||
if !p.valid() { | ||
return false | ||
} | ||
for _, s := range seen { | ||
// Note that equals() also checks that both pipes are valid. | ||
if p.equals(&s) { | ||
return false | ||
} | ||
} | ||
|
||
seen = append(seen, p) | ||
} | ||
return true | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,109 @@ | ||
package governor | ||
|
||
import ( | ||
"testing" | ||
|
||
"github.com/stretchr/testify/require" | ||
"github.com/wormhole-foundation/wormhole/sdk/vaa" | ||
) | ||
|
||
func TestFlowCancelPipesMainnetDeployment(t *testing.T) { | ||
|
||
tests := map[string][]pipe{ | ||
"expected mainnet values": { | ||
{ | ||
vaa.ChainIDEthereum, | ||
vaa.ChainIDSui, | ||
}, | ||
}, | ||
} | ||
for name, expected := range tests { | ||
t.Run(name, func(t *testing.T) { | ||
got := FlowCancelPipes() | ||
// Basic validity check. | ||
require.True(t, Valid(got)) | ||
|
||
// Check that values are what we expected. | ||
require.Equal(t, 1, len(got)) | ||
require.True(t, got[0].equals(&expected[0])) | ||
}) | ||
} | ||
} | ||
|
||
func TestValid(t *testing.T) { | ||
tests := []struct { | ||
name string | ||
args []pipe | ||
want bool | ||
}{ | ||
{ | ||
name: "error: duplicate pipes", | ||
args: []pipe{ | ||
{ | ||
first: vaa.ChainIDEthereum, | ||
second: vaa.ChainIDSolana, | ||
}, | ||
{ | ||
first: vaa.ChainIDEthereum, | ||
second: vaa.ChainIDSolana, | ||
}, | ||
}, | ||
want: false, | ||
}, | ||
{ | ||
name: "error: duplicate pipes, different order", | ||
args: []pipe{ | ||
{ | ||
first: vaa.ChainIDEthereum, | ||
second: vaa.ChainIDSolana, | ||
}, | ||
{ | ||
first: vaa.ChainIDSolana, | ||
second: vaa.ChainIDEthereum, | ||
}, | ||
}, | ||
want: false, | ||
}, | ||
{ | ||
name: "error: invalid pipe (ends are the same)", | ||
args: []pipe{ | ||
{ | ||
first: vaa.ChainIDEthereum, | ||
second: vaa.ChainIDEthereum, | ||
}, | ||
}, | ||
want: false, | ||
}, | ||
{ | ||
name: "error: invalid pipe (unset)", | ||
args: []pipe{ | ||
{ | ||
first: vaa.ChainIDEthereum, | ||
second: vaa.ChainIDUnset, | ||
}, | ||
}, | ||
want: false, | ||
}, | ||
{ | ||
name: "happy path", | ||
args: []pipe{ | ||
{ | ||
first: vaa.ChainIDEthereum, | ||
second: vaa.ChainIDSui, | ||
}, | ||
{ | ||
first: vaa.ChainIDEthereum, | ||
second: vaa.ChainIDSolana, | ||
}, | ||
}, | ||
want: true, | ||
}, | ||
} | ||
for _, tt := range tests { | ||
t.Run(tt.name, func(t *testing.T) { | ||
if got := Valid(tt.args); got != tt.want { | ||
require.Equal(t, tt.want, got, "want %v got %v value %v", tt.want, got, tt.args) | ||
} | ||
}) | ||
} | ||
} |
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Just a question. Does it make sense to have Sui here when the governor is not enabled for it in the devnet config?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Probably not, thanks for catching this.