Skip to content

Commit

Permalink
feat(fast-usdc): skipAdvance when preconditions fail (#11005)
Browse files Browse the repository at this point in the history
closes #10994

## Description

If any of the preconditions throw for making the advance, set the state to `ADVANCE_SKIPPED` rather than `OBSERVED`. This makes it more obvious that the contract has actively chosen to not advance, rather than getting stuck on `OBSERVED` for some reason.

### Security Considerations
N/A

### Scaling Considerations
N/A

### Documentation Considerations
I don't think we have any docs that go this granular on the flow.

### Testing Considerations
Updated tests

### Upgrade Considerations
N/A
  • Loading branch information
mergify[bot] authored Feb 18, 2025
2 parents b962ad8 + cfe0954 commit 7b582c1
Show file tree
Hide file tree
Showing 3 changed files with 32 additions and 12 deletions.
4 changes: 2 additions & 2 deletions multichain-testing/test/fast-usdc/fast-usdc.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -658,7 +658,7 @@ test.serial('insufficient LP funds; forward path', async t => {
await useChain(eudChain).getRestEndpoint(),
);

await assertTxStatus(evidence.txHash, 'OBSERVED');
await assertTxStatus(evidence.txHash, 'ADVANCE_SKIPPED');

nobleTools.mockCctpMint(mintAmt, userForwardingAddr);

Expand Down Expand Up @@ -788,7 +788,7 @@ test.serial('insufficient LP funds and forward failed', async t => {
// submit evidences
await Promise.all(txOracles.map(async o => o.submit(evidence)));

await assertTxStatus(evidence.txHash, 'OBSERVED');
await assertTxStatus(evidence.txHash, 'ADVANCE_SKIPPED');

nobleTools.mockCctpMint(mintAmt, userForwardingAddr);

Expand Down
2 changes: 1 addition & 1 deletion packages/fast-usdc/src/exos/advancer.js
Original file line number Diff line number Diff line change
Expand Up @@ -217,7 +217,7 @@ export const prepareAdvancerKit = (
});
} catch (error) {
log('Advancer error:', error);
statusManager.observe(evidence);
statusManager.skipAdvance(evidence, [error.message]);
}
},
/** @param {ChainAddress} intermediateRecipient */
Expand Down
38 changes: 29 additions & 9 deletions packages/fast-usdc/test/exos/advancer.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -275,7 +275,7 @@ test('updates status to ADVANCING in happy path', async t => {
]);
});

test('updates status to OBSERVED on insufficient pool funds', async t => {
test('updates status to ADVANCE_SKIPPED on insufficient pool funds', async t => {
const {
brands: { usdc },
bootstrap: { storage },
Expand Down Expand Up @@ -310,8 +310,16 @@ test('updates status to OBSERVED on insufficient pool funds', async t => {

t.deepEqual(
storage.getDeserialized(`fun.txns.${evidence.txHash}`),
[{ evidence, status: PendingTxStatus.Observed }],
'OBSERVED status on insufficient pool funds',
[
{ evidence, status: PendingTxStatus.Observed },
{
risksIdentified: [
'Cannot borrow. Requested {"brand":"[Alleged: USDC brand]","value":"[293999999n]"} must be less than pool balance {"brand":"[Alleged: USDC brand]","value":"[1n]"}.',
],
status: 'ADVANCE_SKIPPED',
},
],
'ADVANCE_SKIPPED status on insufficient pool funds',
);

t.deepEqual(inspectLogs(), [
Expand All @@ -325,7 +333,7 @@ test('updates status to OBSERVED on insufficient pool funds', async t => {
]);
});

test('updates status to OBSERVED if makeChainAddress fails', async t => {
test('updates status to ADVANCE_SKIPPED if makeChainAddress fails', async t => {
const {
bootstrap: { storage },
extensions: {
Expand All @@ -340,8 +348,14 @@ test('updates status to OBSERVED if makeChainAddress fails', async t => {

t.deepEqual(
storage.getDeserialized(`fun.txns.${evidence.txHash}`),
[{ evidence, status: PendingTxStatus.Observed }],
'OBSERVED status on makeChainAddress failure',
[
{ evidence, status: PendingTxStatus.Observed },
{
risksIdentified: ['Chain info not found for bech32Prefix "random"'],
status: 'ADVANCE_SKIPPED',
},
],
'ADVANCE_SKIPPED status on makeChainAddress failure',
);

t.deepEqual(inspectLogs(), [
Expand Down Expand Up @@ -531,7 +545,7 @@ test('logs error if returnToPool fails during AdvanceFailed recovery', async t =
]);
});

test('updates status to OBSERVED if pre-condition checks fail', async t => {
test('updates status to ADVANCE_SKIPPED if pre-condition checks fail', async t => {
const {
bootstrap: { storage },
extensions: {
Expand All @@ -547,8 +561,14 @@ test('updates status to OBSERVED if pre-condition checks fail', async t => {

t.deepEqual(
storage.getDeserialized(`fun.txns.${evidence.txHash}`),
[{ evidence, status: PendingTxStatus.Observed }],
'tx is recorded as OBSERVED',
[
{ evidence, status: PendingTxStatus.Observed },
{
risksIdentified: ['query: {} - Must have missing properties ["EUD"]'],
status: 'ADVANCE_SKIPPED',
},
],
'tx is recorded as ADVANCE_SKIPPED',
);

t.deepEqual(inspectLogs(), [
Expand Down

0 comments on commit 7b582c1

Please sign in to comment.