Skip to content

add Argo revert_outbound_transfer extrinsic - #5158

Merged
kdembler merged 1 commit into
Joystream:petrafrom
kdembler:argo-revert
Jun 4, 2024
Merged

kdembler merged 1 commit into
Joystream:petrafrom
kdembler:argo-revert

Conversation

@kdembler

@kdembler kdembler commented Jun 2, 2024

Copy link
Copy Markdown
Collaborator

Based on #5155

Adds a new revert_outbound_transfer extrinsic. Functionally, the new extrinsic is almost the same as finalize_inbound_transfer:

  1. It verifies that the caller is the operator
  2. It checks mint allowance
  3. It mints new tokens

The only difference is in input arguments and the emitted event.

Todo:

  • Add proper benchmarks and weights

@kdembler kdembler changed the title WIP: argo bridge add Argo revert_outbound_transfer extrinsic Jun 2, 2024
@kdembler kdembler mentioned this pull request Jun 2, 2024

@freakstatic freakstatic left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM!
@kdembler do you want me to handle the benchmark tests for this or are you gonna do that as well?

@kdembler

kdembler commented Jun 2, 2024

Copy link
Copy Markdown
Collaborator Author

@freakstatic if you could do that, that'd be great

@dobertRowneySr
dobertRowneySr self-requested a review June 4, 2024 12:21

@dobertRowneySr dobertRowneySr left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Logic looks ok, I have just left a few points

#[weight = WeightInfoArgo::<T>::finalize_inbound_transfer()]
pub fn revert_outbound_transfer(
origin,
transfer_id: TransferId,

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I assume that this is an identifier whose validity is already confirmed by the squid.
Given that there are no checks on this...

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Namely the extr. assumes that transfer_id will refer to a pending transfer outbound request queued in the argo-squid

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Correct, likewise we don't check it any way when calling finaliza_inbound_transfer. It all assumes that the operator is acting correctly

let caller = ensure_signed(origin)?;
ensure!(caller == Self::operator_account().unwrap(), Error::<T>::NotOperatorAccount);

ensure!(Self::status() == BridgeStatus::Active, Error::<T>::BridgeNotActive);

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should this be present?
I am thinking about the following scenario:

  1. Transaction outbound exists
  2. Bridge is paused
  3. User tries to revert transaction

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, when the bridge is paused, nothing should be callable. Also it's not user that reverts the transaction, it's the operator

));
});
}

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Despite my previous comment I will point this out :
transfer revert failing test case for bridge status not active is missing

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, we should add this as well. Let me do this in next PR though, at this branch there are small issues with bridge status that I fixed on my next branch

@dobertRowneySr
dobertRowneySr self-requested a review June 4, 2024 12:48

@dobertRowneySr dobertRowneySr left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@kdembler
kdembler merged commit e193904 into Joystream:petra Jun 4, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants