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

[NTRN-142] feat: enhance contract failure with error #352

Merged
merged 11 commits into from
Nov 14, 2023
2 changes: 2 additions & 0 deletions proto/neutron/contractmanager/failure.proto
Original file line number Diff line number Diff line change
Expand Up @@ -15,4 +15,6 @@ message Failure {
uint64 id = 2;
// Serialized MessageSudoCallback with Packet and Ack(if exists)
bytes sudo_payload = 3;
// Redacted error response of the sudo call. Full error is emitted as an event
string error = 4;
}
17 changes: 14 additions & 3 deletions proto/neutron/contractmanager/query.proto
Original file line number Diff line number Diff line change
Expand Up @@ -16,13 +16,19 @@ service Query {
rpc Params(QueryParamsRequest) returns (QueryParamsResponse) {
option (google.api.http).get = "/neutron/contractmanager/params";
}
// Queries a Failure by address.

// Queries a Failure by contract address and failure ID.
rpc AddressFailure(QueryFailuresRequest) returns (QueryFailuresResponse) {
option (google.api.http).get = "/neutron/contractmanager/failures/{address}/{failure_id}";
}

// Queries Failures by contract address.
rpc AddressFailures(QueryFailuresRequest) returns (QueryFailuresResponse) {
option (google.api.http).get =
"/neutron/contractmanager/failures/{address}";
}

// Queries a list of Failure items.
// Queries a list of Failures occurred on the network.
rpc Failures(QueryFailuresRequest) returns (QueryFailuresResponse) {
option (google.api.http).get = "/neutron/contractmanager/failures";
}
Expand All @@ -39,11 +45,16 @@ message QueryParamsResponse {
Params params = 1 [ (gogoproto.nullable) = false ];
}

// QueryFailuresRequest is request type for the Query/Failures RPC method.
message QueryFailuresRequest {
// address of the contract which Sudo call failed.
string address = 1;
cosmos.base.query.v1beta1.PageRequest pagination = 2;
// ID of the failure for the given contract.
uint64 failure_id = 2;
cosmos.base.query.v1beta1.PageRequest pagination = 3;
}

// QueryFailuresResponse is response type for the Query/Failures RPC method.
message QueryFailuresResponse {
repeated Failure failures = 1 [ (gogoproto.nullable) = false ];
cosmos.base.query.v1beta1.PageResponse pagination = 2;
Expand Down
43 changes: 27 additions & 16 deletions testutil/mocks/contractmanager/types/expected_keepers.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

68 changes: 39 additions & 29 deletions testutil/mocks/interchaintxs/types/expected_keepers.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

6 changes: 3 additions & 3 deletions wasmbinding/test/custom_message_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -637,7 +637,7 @@ func (suite *CustomMessengerTestSuite) TestResubmitFailureAck() {
payload, err := keeper2.PrepareSudoCallbackMessage(packet, &ack)
require.NoError(suite.T(), err)
failureID := suite.messenger.ContractmanagerKeeper.GetNextFailureIDKey(suite.ctx, suite.contractAddress.String())
suite.messenger.ContractmanagerKeeper.AddContractFailure(suite.ctx, suite.contractAddress.String(), payload)
suite.messenger.ContractmanagerKeeper.AddContractFailure(suite.ctx, suite.contractAddress.String(), payload, "test error")

// Craft message
msg, err := json.Marshal(bindings.NeutronMsg{
Expand Down Expand Up @@ -669,7 +669,7 @@ func (suite *CustomMessengerTestSuite) TestResubmitFailureTimeout() {
payload, err := keeper2.PrepareSudoCallbackMessage(packet, nil)
require.NoError(suite.T(), err)
failureID := suite.messenger.ContractmanagerKeeper.GetNextFailureIDKey(suite.ctx, suite.contractAddress.String())
suite.messenger.ContractmanagerKeeper.AddContractFailure(suite.ctx, suite.contractAddress.String(), payload)
suite.messenger.ContractmanagerKeeper.AddContractFailure(suite.ctx, suite.contractAddress.String(), payload, "test error")

// Craft message
msg, err := json.Marshal(bindings.NeutronMsg{
Expand Down Expand Up @@ -704,7 +704,7 @@ func (suite *CustomMessengerTestSuite) TestResubmitFailureFromDifferentContract(
failureID := suite.messenger.ContractmanagerKeeper.GetNextFailureIDKey(suite.ctx, testutil.TestOwnerAddress)
payload, err := keeper2.PrepareSudoCallbackMessage(packet, &ack)
require.NoError(suite.T(), err)
suite.messenger.ContractmanagerKeeper.AddContractFailure(suite.ctx, testutil.TestOwnerAddress, payload)
suite.messenger.ContractmanagerKeeper.AddContractFailure(suite.ctx, testutil.TestOwnerAddress, payload, "test error")

// Craft message
msg, err := json.Marshal(bindings.NeutronMsg{
Expand Down
1 change: 1 addition & 0 deletions x/contractmanager/client/cli/query.go
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ func GetQueryCmd(_ string) *cobra.Command {

cmd.AddCommand(CmdQueryParams())
cmd.AddCommand(CmdFailures())
cmd.AddCommand(CmdFailureDetails())
// this line is used by starport scaffolding # 1

return cmd
Expand Down
Loading
Loading