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

Node: Gateway relayer can ignore already attested return #4052

Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 6 additions & 1 deletion node/pkg/gwrelayer/gwrelayer.go
Original file line number Diff line number Diff line change
Expand Up @@ -424,7 +424,7 @@ func SubmitVAAToContract(
return txResp, fmt.Errorf("out of gas: %s", txResp.TxResponse.RawLog)
}

if strings.Contains(txResp.TxResponse.RawLog, "failed") && !strings.Contains(txResp.TxResponse.RawLog, "VaaAlreadyExecuted") {
if strings.Contains(txResp.TxResponse.RawLog, "failed") && !canIgnoreFailure(txResp.TxResponse.RawLog) {
return txResp, fmt.Errorf("submit failed: %s", txResp.TxResponse.RawLog)
}

Expand All @@ -441,3 +441,8 @@ func SubmitVAAToContract(

return txResp, nil
}

// canIgnoreFailure checks for returns from the contract that aren't really errors.
func canIgnoreFailure(rawLog string) bool {
return strings.Contains(rawLog, "VaaAlreadyExecuted") || strings.Contains(rawLog, "this asset has already been attested")
}
6 changes: 6 additions & 0 deletions node/pkg/gwrelayer/gwrelayer_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -180,3 +180,9 @@ func Test_shouldPublishToIbcTranslatorShouldIgnoreUnknownEmitter(t *testing.T) {
assert.NoError(t, err)
assert.False(t, shouldPub)
}

func Test_canIgnoreFailure(t *testing.T) {
assert.True(t, canIgnoreFailure("failed to execute message; message index: 0: Generic error: VaaAlreadyExecuted: execute wasm contract failed"))
assert.True(t, canIgnoreFailure("failed to execute message; message index: 0: Generic error: this asset has already been attested: execute wasm contract failed"))
assert.False(t, canIgnoreFailure("failed to execute message; message index: 0: Generic error: some other failure: execute wasm contract failed"))
}
Loading