Skip to content

Commit

Permalink
Merge remote-tracking branch 'origin/main' into bug/set-range-order-z…
Browse files Browse the repository at this point in the history
…ero-liquidity

* origin/main:
  fix: disable try-state checks (#4576)
  chore: debug solana in CI 🐛 (#4580)
  refactor: pass tx_ref as an extrinsic parameter (#4579)
  fix: remove bounded balance check (#4575)
  Solana: update image to latest tag (#4574)
  feat: add boost lp account to bouncer and fund it on setup_swaps (#4552)
  feat: Expose tx_hash on BroadcastSuccess event (#4561)
  feat: Relative Slippage Limits (PRO-1207) (#4547)
  chore: disable localnet solana in CI ⏱️ (#4569)
  feat: store prewitnessed deposits with id (#4496)
  Feat: Scheduled Swaps Subscription (#4525)

# Conflicts:
#	state-chain/pallets/cf-pools/src/tests.rs
  • Loading branch information
syan095 committed Feb 28, 2024
2 parents 232186d + 79419cb commit 7dccae6
Show file tree
Hide file tree
Showing 59 changed files with 1,742 additions and 477 deletions.
2 changes: 1 addition & 1 deletion .cargo/config.toml
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
CF_ETH_CONTRACT_ABI_ROOT = { value = "contract-interfaces/eth-contract-abis", relative = true }
CF_ETH_CONTRACT_ABI_TAG = "v1.0.0"
CF_SOL_PROGRAM_IDL_ROOT = { value = "contract-interfaces/sol-program-idls", relative = true }
CF_SOL_PROGRAM_IDL_TAG = "test-tag-10"
CF_SOL_PROGRAM_IDL_TAG = "v0.1.1"
CF_TEST_CONFIG_ROOT = { value = "engine/config/testing", relative = true }

# Note: If you just want to save typing command commands, you can install tab completions for most shells. Type
Expand Down
24 changes: 15 additions & 9 deletions .github/workflows/_40_post_check.yml
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ on:

env:
FORCE_COLOR: 1
SOLANA_VERSION: v1.17.22
SOLANA_VERSION: v1.18.3

permissions:
packages: read
Expand Down Expand Up @@ -43,7 +43,7 @@ jobs:
scope: "@chainflip-io"
cache-dependency-path: "bouncer/pnpm-lock.yaml"

- name: Set NPM registry
- name: Set NPM registry 🔧
run: |
pnpm set @chainflip-io:registry=https://npm.pkg.github.com/
pnpm set //npm.pkg.github.com/:_authToken=${{ secrets.GITHUB_TOKEN }}
Expand All @@ -66,7 +66,7 @@ jobs:
working-directory: bouncer
run: pnpm install

- name: Install solana
- name: Install solana ☀️
run: |
sh -c "$(curl -sSfL https://release.solana.com/$SOLANA_VERSION/install)"
Expand Down Expand Up @@ -98,32 +98,38 @@ jobs:
./run.sh
- name: Print chainflip-engine logs 🚗
if: failure()
if: always()
continue-on-error: true
run: |
cat /tmp/chainflip/*/chainflip-engine.log
- name: Print chainflip-node logs 📡
if: failure()
if: always()
continue-on-error: true
run: |
cat /tmp/chainflip/*/chainflip-node.log
- name: Print chainflip-broker-api logs 💼
if: failure()
if: always()
continue-on-error: true
run: |
cat /tmp/chainflip/chainflip-broker-api.log
- name: Print chainflip-lp-api logs 🤑
if: failure()
if: always()
continue-on-error: true
run: |
cat /tmp/chainflip/chainflip-lp-api.log
- name: Print localnet init debug logs 🕵️‍♂️
if: failure()
if: always()
continue-on-error: true
run: |
cat /tmp/chainflip/debug.log
- name: Print solana logs ☀️
if: failure()
if: always()
continue-on-error: true
run: |
cat /tmp/solana/solana.log
Expand Down
4 changes: 4 additions & 0 deletions Cargo.lock

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

Original file line number Diff line number Diff line change
Expand Up @@ -541,6 +541,7 @@ mod tests {
contract: H160::from([0; 20]),
gas_limit: None,
},
transaction_ref: Default::default(),
},
),
&mut store,
Expand Down
9 changes: 9 additions & 0 deletions bouncer/commands/setup_swaps.ts
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,15 @@ async function main(): Promise<void> {
// provideLiquidity('ARBUSDC', deposits.get('ARBUSDC')!),
]);

// also fund the boost account
await Promise.all([
provideLiquidity('USDC', deposits.get('USDC')!, false, '//LP_BOOST'),
provideLiquidity('ETH', deposits.get('ETH')!, false, '//LP_BOOST'),
provideLiquidity('DOT', deposits.get('DOT')!, false, '//LP_BOOST'),
provideLiquidity('BTC', deposits.get('BTC')!, false, '//LP_BOOST'),
provideLiquidity('FLIP', deposits.get('FLIP')!, false, '//LP_BOOST'),
]);

await Promise.all([
rangeOrder('ETH', deposits.get('ETH')! * 0.9999),
rangeOrder('DOT', deposits.get('DOT')! * 0.9999),
Expand Down
9 changes: 7 additions & 2 deletions bouncer/shared/provide_liquidity.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,13 +15,18 @@ import {
} from '../shared/utils';
import { send } from '../shared/send';

export async function provideLiquidity(ccy: Asset, amount: number, waitForFinalization = false) {
export async function provideLiquidity(
ccy: Asset,
amount: number,
waitForFinalization = false,
lpKey?: string,
) {
const chainflip = await getChainflipApi();
await cryptoWaitReady();
const chain = assetToChain(ccy);

const keyring = new Keyring({ type: 'sr25519' });
const lpUri = process.env.LP_URI || '//LP_1';
const lpUri = lpKey ?? (process.env.LP_URI || '//LP_1');
const lp = keyring.createFromUri(lpUri);

// If no liquidity refund address is registered, then do that now
Expand Down
3 changes: 2 additions & 1 deletion bouncer/shared/try_runtime_upgrade.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,8 @@ function tryRuntimeCommand(runtimePath: string, blockParam: string, networkUrl:
const stderrFile = path.join(os.tmpdir(), `cmd-stderr-${Date.now()}`);
try {
execSync(
`try-runtime --runtime ${runtimePath} on-runtime-upgrade --disable-spec-version-check --disable-idempotency-checks --checks all ${blockParam} --uri ${networkUrl} 2> ${stderrFile}`,
// TODO: Replace pre-and-post with all after the SDK issue paritytech/polkadot-sdk#2560 is merged.
`try-runtime --runtime ${runtimePath} on-runtime-upgrade --disable-spec-version-check --disable-idempotency-checks --checks pre-and-post ${blockParam} --uri ${networkUrl} 2> ${stderrFile}`,
{ env: { ...process.env, RUST_LOG: 'runtime::executive=debug' } },
);
console.log(`try-runtime success for blockParam ${blockParam}`);
Expand Down
16 changes: 3 additions & 13 deletions bouncer/tests/broker_fee_collection_test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -36,14 +36,7 @@ const maxDepositFee = {
[Assets.DOT]: BigInt(197300000),
[Assets.FLIP]: BigInt('20000000000000000'),
[Assets.BTC]: BigInt(190),
[Assets.USDC]: BigInt(0), // Fee is too low for localnet, it rounds to 0
};
const maxWithdrawalFee = {
[Assets.ETH]: BigInt(490000),
[Assets.DOT]: BigInt(197450000),
[Assets.FLIP]: BigInt(300000000),
[Assets.BTC]: BigInt(100),
[Assets.USDC]: BigInt(0),
[Assets.USDC]: BigInt(400000), // Fee is too low for localnet, it rounds to 0
};
const chainflip = await getChainflipApi();

Expand Down Expand Up @@ -189,8 +182,6 @@ async function testBrokerFees(asset: Asset, seed?: string): Promise<void> {
const balanceBeforeWithdrawalBigInt = BigInt(
amountToFineAmount(balanceBeforeWithdrawal, assetDecimals[asset]),
);
const detectWithdrawalGasFee =
balanceBeforeWithdrawalBigInt + earnedBrokerFeesAfter - balanceAfterWithdrawalBigInt;
// Log the chain state for Ethereum assets to help debugging.
if (['FLIP', 'ETH', 'USDC'].includes(asset.toString())) {
const chainState = JSON.stringify(
Expand All @@ -199,9 +190,8 @@ async function testBrokerFees(asset: Asset, seed?: string): Promise<void> {
console.log('Ethereum chain tracking state:', chainState);
}
assert(
detectWithdrawalGasFee <= maxWithdrawalFee[asset] &&
balanceAfterWithdrawalBigInt <= balanceBeforeWithdrawalBigInt + earnedBrokerFeesAfter,
`Unexpected ${asset} balance after withdrawal, amount ${balanceAfterWithdrawalBigInt}, did gas fees change? Max expected gas fee is ${maxWithdrawalFee[asset]}, detected gas fee: ${detectWithdrawalGasFee}`,
balanceAfterWithdrawalBigInt <= balanceBeforeWithdrawalBigInt + earnedBrokerFeesAfter,
`Unexpected ${asset} balance after withdrawal, amount ${balanceAfterWithdrawalBigInt}, did gas fees change?`,
);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@ gh release download \

unzip -u ${ZIP_FILE} \
'vault.json' \
'cf_tester.json' \
-d $TARGET_DIR

rm ${ZIP_FILE}
140 changes: 140 additions & 0 deletions contract-interfaces/sol-program-idls/v0.1.1/cf_tester.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,140 @@
{
"version": "0.1.0",
"name": "cf_tester",
"instructions": [
{
"name": "cfReceiveToken",
"accounts": [
{
"name": "cfPdaSigner",
"isMut": false,
"isSigner": true
},
{
"name": "receiverTokenAccount",
"isMut": true,
"isSigner": false
},
{
"name": "tokenProgram",
"isMut": false,
"isSigner": false
},
{
"name": "mint",
"isMut": false,
"isSigner": false
}
],
"args": [
{
"name": "sourceChain",
"type": "u32"
},
{
"name": "sourceAddress",
"type": "bytes"
},
{
"name": "message",
"type": "bytes"
},
{
"name": "amount",
"type": "u64"
}
]
},
{
"name": "cfReceiveNative",
"accounts": [
{
"name": "cfPdaSigner",
"isMut": false,
"isSigner": true
},
{
"name": "receiverNative",
"isMut": true,
"isSigner": false
},
{
"name": "systemProgram",
"isMut": false,
"isSigner": false
}
],
"args": [
{
"name": "sourceChain",
"type": "u32"
},
{
"name": "sourceAddress",
"type": "bytes"
},
{
"name": "message",
"type": "bytes"
},
{
"name": "amount",
"type": "u64"
}
]
}
],
"events": [
{
"name": "ReceivedCCM",
"fields": [
{
"name": "signer",
"type": "publicKey",
"index": false
},
{
"name": "sourceChain",
"type": "u32",
"index": false
},
{
"name": "sourceAddress",
"type": "bytes",
"index": false
},
{
"name": "message",
"type": "bytes",
"index": false
},
{
"name": "amount",
"type": "u64",
"index": false
},
{
"name": "remainingPubkeys",
"type": {
"vec": "publicKey"
},
"index": false
},
{
"name": "remainingIsSigner",
"type": {
"vec": "bool"
},
"index": false
},
{
"name": "remainingIsWritable",
"type": {
"vec": "bool"
},
"index": false
}
]
}
]
}
Loading

0 comments on commit 7dccae6

Please sign in to comment.