Skip to content

Commit

Permalink
removed misleading comments
Browse files Browse the repository at this point in the history
  • Loading branch information
swelf19 committed Jul 11, 2024
1 parent 039d33c commit a4f48d1
Showing 1 changed file with 1 addition and 30 deletions.
31 changes: 1 addition & 30 deletions contracts/neutron_interchain_txs/src/contract.rs
Original file line number Diff line number Diff line change
Expand Up @@ -405,25 +405,18 @@ fn sudo_response(deps: DepsMut, request: RequestPacket, data: Binary) -> StdResu
.as_str(),
);

// WARNING: RETURNING THIS ERROR CLOSES THE CHANNEL.
// AN ALTERNATIVE IS TO MAINTAIN AN ERRORS QUEUE AND PUT THE FAILED REQUEST THERE
// FOR LATER INSPECTION.
// In this particular case, we return an error because not having the sequence id
// in the request value implies that a fatal error occurred on Neutron side.
let seq_id = request
.sequence
.ok_or_else(|| StdError::generic_err("sequence not found"))?;

// WARNING: RETURNING THIS ERROR CLOSES THE CHANNEL.
// AN ALTERNATIVE IS TO MAINTAIN AN ERRORS QUEUE AND PUT THE FAILED REQUEST THERE
// FOR LATER INSPECTION.
// In this particular case, we return an error because not having the sequence id
// in the request value implies that a fatal error occurred on Neutron side.
let channel_id = request
.source_channel
.ok_or_else(|| StdError::generic_err("channel_id not found"))?;

// NOTE: NO ERROR IS RETURNED HERE. THE CHANNEL LIVES ON.
// In this particular example, this is a matter of developer's choice. Not being able to read
// the payload here means that there was a problem with the contract while submitting an
// interchain transaction. You can decide that this is not worth killing the channel,
Expand All @@ -440,9 +433,6 @@ fn sudo_response(deps: DepsMut, request: RequestPacket, data: Binary) -> StdResu
deps.api
.debug(format!("WASMDEBUG: sudo_response: sudo payload: {:?}", payload).as_str());

// WARNING: RETURNING THIS ERROR CLOSES THE CHANNEL.
// AN ALTERNATIVE IS TO MAINTAIN AN ERRORS QUEUE AND PUT THE FAILED REQUEST THERE
// FOR LATER INSPECTION.
// In this particular case, we return an error because not being able to parse this data
// that a fatal error occurred on Neutron side, or that the remote chain sent us unexpected data.
// Both cases require immediate attention.
Expand All @@ -454,14 +444,10 @@ fn sudo_response(deps: DepsMut, request: RequestPacket, data: Binary) -> StdResu
item_types.push(item_type.to_string());
match item_type {
"/cosmos.staking.v1beta1.MsgUndelegate" => {
// WARNING: RETURNING THIS ERROR CLOSES THE CHANNEL.
// AN ALTERNATIVE IS TO MAINTAIN AN ERRORS QUEUE AND PUT THE FAILED REQUEST THERE
// FOR LATER INSPECTION.
// In this particular case, a mismatch between the string message type and the
// serialised data layout looks like a fatal error that has to be investigated.
let out: MsgUndelegateResponse = decode_message_response(&item.value)?;

// NOTE: NO ERROR IS RETURNED HERE. THE CHANNEL LIVES ON.
// In this particular case, we demonstrate that minor errors should not
// close the channel, and should be treated in a forgiving manner.
let completion_time = out.completion_time.or_else(|| {
Expand All @@ -475,9 +461,6 @@ fn sudo_response(deps: DepsMut, request: RequestPacket, data: Binary) -> StdResu
.debug(format!("Undelegation completion time: {:?}", completion_time).as_str());
}
"/cosmos.staking.v1beta1.MsgDelegateResponse" => {
// WARNING: RETURNING THIS ERROR CLOSES THE CHANNEL.
// AN ALTERNATIVE IS TO MAINTAIN AN ERRORS QUEUE AND PUT THE FAILED REQUEST THERE
// FOR LATER INSPECTION.
// In this particular case, a mismatch between the string message type and the
// serialised data layout looks like a fatal error that has to be investigated.
let _out: MsgDelegateResponse = decode_message_response(&item.value)?;
Expand Down Expand Up @@ -515,26 +498,19 @@ fn sudo_timeout(deps: DepsMut, _env: Env, request: RequestPacket) -> StdResult<R
deps.api
.debug(format!("WASMDEBUG: sudo timeout request: {:?}", request).as_str());

// WARNING: RETURNING THIS ERROR CLOSES THE CHANNEL.
// AN ALTERNATIVE IS TO MAINTAIN AN ERRORS QUEUE AND PUT THE FAILED REQUEST THERE
// FOR LATER INSPECTION.
// In this particular case, we return an error because not having the sequence id
// in the request value implies that a fatal error occurred on Neutron side.
let seq_id = request
.sequence
.ok_or_else(|| StdError::generic_err("sequence not found"))?;

// WARNING: RETURNING THIS ERROR CLOSES THE CHANNEL.
// AN ALTERNATIVE IS TO MAINTAIN AN ERRORS QUEUE AND PUT THE FAILED REQUEST THERE
// FOR LATER INSPECTION.
// In this particular case, we return an error because not having the sequence id
// in the request value implies that a fatal error occurred on Neutron side.
let channel_id = request
.source_channel
.ok_or_else(|| StdError::generic_err("channel_id not found"))?;

// update but also check that we don't update same seq_id twice
// NOTE: NO ERROR IS RETURNED HERE. THE CHANNEL LIVES ON.
// In this particular example, this is a matter of developer's choice. Not being able to read
// the payload here means that there was a problem with the contract while submitting an
// interchain transaction. You can decide that this is not worth killing the channel,
Expand Down Expand Up @@ -570,18 +546,13 @@ fn sudo_error(deps: DepsMut, request: RequestPacket, details: String) -> StdResu
deps.api
.debug(format!("WASMDEBUG: request packet: {:?}", request).as_str());

// WARNING: RETURNING THIS ERROR CLOSES THE CHANNEL.
// AN ALTERNATIVE IS TO MAINTAIN AN ERRORS QUEUE AND PUT THE FAILED REQUEST THERE
// FOR LATER INSPECTION.

// In this particular case, we return an error because not having the sequence id
// in the request value implies that a fatal error occurred on Neutron side.
let seq_id = request
.sequence
.ok_or_else(|| StdError::generic_err("sequence not found"))?;

// WARNING: RETURNING THIS ERROR CLOSES THE CHANNEL.
// AN ALTERNATIVE IS TO MAINTAIN AN ERRORS QUEUE AND PUT THE FAILED REQUEST THERE
// FOR LATER INSPECTION.
// In this particular case, we return an error because not having the sequence id
// in the request value implies that a fatal error occurred on Neutron side.
let channel_id = request
Expand Down

0 comments on commit a4f48d1

Please sign in to comment.