Skip to content

Commit

Permalink
Merge branch 'main' into feat/on-chain-swaps
Browse files Browse the repository at this point in the history
  • Loading branch information
msgmaxim committed Feb 12, 2025
2 parents 2153e74 + f5aff96 commit 2fab474
Show file tree
Hide file tree
Showing 114 changed files with 2,760 additions and 2,919 deletions.
12 changes: 0 additions & 12 deletions .github/workflows/upgrade-test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -173,21 +173,9 @@ jobs:
echo "/usr/lib after copy of .so files"
ls -l /usr/lib
touch ./localnet/.setup_complete
# TODO: This is a temporary fix to allow the localnet docker-compose.yml from an older commit to run the latest solana programs version. Remove after 1.8 is released.
sed -i 's|ghcr.io/chainflip-io/solana-localnet-ledger:v[0-9.]*|ghcr.io/chainflip-io/solana-localnet-ledger:${{ env.SOLANA_PROGRAMS_VERSION }}|g' localnet/docker-compose.yml
./localnet/manage.sh
git reset --hard
# TODO: This is a temporary workaround to insert the 1.8 image nonces. Remove after 1.8 is released.
- name: Nonce workaround
if: inputs.run-job
run: |
git checkout ${{ github.sha }}
git rev-parse HEAD
cd bouncer
pnpm install --frozen-lockfile
./shared/force_sol_nonces.ts
- name: Run bouncer on upgrade-from version 🙅‍♂️
if: inputs.run-job
id: pre-upgrade-bouncer
Expand Down
27 changes: 14 additions & 13 deletions Cargo.lock

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

2 changes: 1 addition & 1 deletion api/bin/chainflip-broker-api/Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
[package]
authors = ["Chainflip team <https://github.com/chainflip-io>"]
name = "chainflip-broker-api"
version = "1.8.0"
version = "1.9.0"
edition = "2021"

[package.metadata.deb]
Expand Down
2 changes: 1 addition & 1 deletion api/bin/chainflip-broker-api/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -232,7 +232,7 @@ impl RpcServer for RpcServerImpl {
Ok(self
.api
.raw_client()
.cf_get_vault_swap_details(
.cf_request_swap_parameter_encoding(
self.api.state_chain_client.account_id(),
source_asset,
destination_asset,
Expand Down
7 changes: 5 additions & 2 deletions api/bin/chainflip-cli/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ authors = ["Chainflip team <https://github.com/chainflip-io>"]
edition = "2021"
build = "build.rs"
name = "chainflip-cli"
version = "1.8.0"
version = "1.9.0"

[lints]
workspace = true
Expand All @@ -15,7 +15,10 @@ clap = { workspace = true, features = ["derive", "env"] }
config = { workspace = true }
futures = { workspace = true }
hex = { workspace = true, default-features = true, features = ["serde"] }
serde = { workspace = true, default-features = true, features = ["derive", "rc"] }
serde = { workspace = true, default-features = true, features = [
"derive",
"rc",
] }
tokio = { workspace = true, features = ["full"] }
serde_json = { workspace = true }

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ use crate::{
utils::get_broadcast_id,
};
use cf_chains::{
address::EncodedAddress,
address::{EncodedAddress, IntoForeignChainAddress},
dot::{PolkadotExtrinsicIndex, PolkadotTransactionId},
evm::{SchnorrVerificationComponents, H256},
instances::ChainInstanceFor,
Expand Down Expand Up @@ -288,7 +288,11 @@ where
.collect::<Vec<Beneficiary<AccountId32>>>()
.try_into()
.expect("We collect into the same Affiliates type we started with, so the Vec bound is the same."),
refund_params: self.refund_params.map(|params| params.map_address(|a| TrackerAddress::from(a.to_encoded_address(network)))),
refund_params: self.refund_params.map(
|params| params.map_address(
|a| TrackerAddress::from(a.into_foreign_chain_address().to_encoded_address(network))
)
),
dca_params: self.dca_params,
max_boost_fee: self.boost_fee,
}
Expand Down Expand Up @@ -887,7 +891,6 @@ mod tests {

#[tokio::test]
async fn test_handle_vault_deposit_calls() {
use cf_chains::ChannelRefundParametersDecoded;
chainflip_api::use_chainflip_account_id_encoding();
let (eth_address, _) = parse_eth_address("0x541f563237A309B3A61E33BDf07a8930Bdba8D99");
let affiliate_short_id = AffiliateShortId::from(69);
Expand Down Expand Up @@ -942,8 +945,8 @@ mod tests {
bps: 10
}])
.unwrap(),
refund_params: Some(ChannelRefundParametersDecoded {
refund_address: ForeignChainAddress::Eth(eth_address),
refund_params: Some(ChannelRefundParameters {
refund_address: eth_address,
retry_duration: Default::default(),
min_price: Default::default(),
}),
Expand Down
2 changes: 1 addition & 1 deletion api/bin/chainflip-lp-api/Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
[package]
authors = ["Chainflip team <https://github.com/chainflip-io>"]
name = "chainflip-lp-api"
version = "1.8.0"
version = "1.9.0"
edition = "2021"

[package.metadata.deb]
Expand Down
4 changes: 2 additions & 2 deletions api/lib/Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[package]
name = "chainflip-api"
version = "1.8.0"
version = "1.9.0"
edition = "2021"

[lints]
Expand All @@ -12,7 +12,7 @@ async-trait = { workspace = true }
bs58 = { workspace = true, default-features = true }
ed25519-dalek = { workspace = true }
futures = { workspace = true }
hex = { workspace = true, default-features = true}
hex = { workspace = true, default-features = true }
hmac-sha512 = { workspace = true }
libsecp256k1 = { workspace = true, default-features = true }
rand = { workspace = true, default-features = true }
Expand Down
2 changes: 1 addition & 1 deletion bouncer/shared/btc_vault_swap.ts
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ export async function buildAndSendBtcVaultSwap(
};

const BtcVaultSwapDetails = (await chainflip.rpc(
`cf_get_vault_swap_details`,
`cf_request_swap_parameter_encoding`,
brokerFees.account,
{ chain: 'Bitcoin', asset: stateChainAssetFromAsset('Btc') },
{ chain: chainFromAsset(destinationAsset), asset: stateChainAssetFromAsset(destinationAsset) },
Expand Down
2 changes: 1 addition & 1 deletion bouncer/shared/evm_vault_swap.ts
Original file line number Diff line number Diff line change
Expand Up @@ -88,7 +88,7 @@ export async function executeEvmVaultSwap(
};

const vaultSwapDetails = (await chainflip.rpc(
`cf_get_vault_swap_details`,
`cf_request_swap_parameter_encoding`,
brokerAddress,
{ chain: srcChain, asset: stateChainAssetFromAsset(sourceAsset) },
{ chain: destChain, asset: stateChainAssetFromAsset(destAsset) },
Expand Down
12 changes: 2 additions & 10 deletions bouncer/shared/sol_vault_swap.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@ import {
Transaction,
AccountMeta,
} from '@solana/web3.js';
import { getAssociatedTokenAddressSync } from '@solana/spl-token';
import BigNumber from 'bignumber.js';
import {
getContractAddress,
Expand Down Expand Up @@ -108,18 +107,11 @@ export async function executeSolVaultSwap(
event_data_account: decodeSolAddress(newEventAccountKeypair.publicKey.toBase58()),
input_amount: '0x' + new BigNumber(amountToSwap).toString(16),
refund_parameters: refundParams,
from_token_account:
srcAsset === 'Sol'
? undefined
: getAssociatedTokenAddressSync(
new PublicKey(getContractAddress('Solana', 'SolUsdc')),
whaleKeypair.publicKey,
false,
).toString(),
from_token_account: undefined,
};

const vaultSwapDetails = (await chainflip.rpc(
`cf_get_vault_swap_details`,
`cf_request_swap_parameter_encoding`,
brokerFees.account,
{ chain: chainFromAsset(srcAsset), asset: stateChainAssetFromAsset(srcAsset) },
{ chain: chainFromAsset(destAsset), asset: stateChainAssetFromAsset(destAsset) },
Expand Down
10 changes: 10 additions & 0 deletions bouncer/tests/lp_api_test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,9 @@ import {
assetDecimals,
stateChainAssetFromAsset,
Chain,
handleSubstrateError,
shortChainFromAsset,
newAddress,
} from '../shared/utils';
import { lpApiRpc } from '../shared/json_rpc';
import { depositLiquidity } from '../shared/deposit_liquidity';
Expand Down Expand Up @@ -151,6 +154,13 @@ async function testTransferAsset() {
const sourceLpAccount = keyring.createFromUri('//LP_API');
const destinationLpAccount = keyring.createFromUri('//LP_2');

// Destination account needs a refund address too.
const chain = shortChainFromAsset(testAsset);
const refundAddress = await newAddress(testAsset, '//LP_2');
await chainflip.tx.liquidityProvider
.registerLiquidityRefundAddress({ [chain]: refundAddress })
.signAndSend(destinationLpAccount, { nonce: -1 }, handleSubstrateError(chainflip));

const oldBalanceSource = await getLpBalance(sourceLpAccount.address);
const oldBalanceDestination = await getLpBalance(destinationLpAccount.address);

Expand Down
3 changes: 1 addition & 2 deletions bouncer/tests/swap_after_temp_disconnecting_chains.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ export const testSwapAfterDisconnection = new ExecutableTest(
// Testing a swap after temporarily disconnecting external nodes
async function main() {
const networkName = 'chainflip-localnet_default';
const allExternalNodes = ['bitcoin', 'geth', 'polkadot1'];
const allExternalNodes = ['bitcoin', 'geth'];

await Promise.all(
allExternalNodes.map((container) => disconnectContainerFromNetwork(container, networkName)),
Expand All @@ -27,7 +27,6 @@ async function main() {
);

await Promise.all([
testSwap('Dot', 'Btc', undefined, undefined, testSwapAfterDisconnection.swapContext),
testSwap('Btc', 'Flip', undefined, undefined, testSwapAfterDisconnection.swapContext),
testSwap('Eth', 'Usdc', undefined, undefined, testSwapAfterDisconnection.swapContext),
]);
Expand Down
2 changes: 1 addition & 1 deletion bouncer/tests/vault_swap_fee_collection.ts
Original file line number Diff line number Diff line change
Expand Up @@ -129,7 +129,7 @@ async function testFeeCollection(inputAsset: Asset): Promise<[KeyringPair, strin
testVaultSwapFeeCollection.debugLog('Earned affiliate fees after:', earnedAffiliateFeesAfter);
assert(
earnedBrokerFeesAfter > earnedBrokerFeesBefore,
`No increase in earned broker fees after ${inputAsset} swap`,
`No increase in earned broker fees after ${tag}(${inputAsset} -> ${destAsset}) vault swap: ${{ account: broker.address, commissionBps }}, ${earnedBrokerFeesBefore} -> ${earnedBrokerFeesAfter}`,
);
assert(
earnedAffiliateFeesAfter > earnedAffiliateFeesBefore,
Expand Down
4 changes: 2 additions & 2 deletions engine-dylib/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -3,11 +3,11 @@ authors = ["Chainflip team <https://github.com/chainflip-io>"]
build = "build.rs"
edition = "2021"
name = "cf-engine-dylib"
version = "1.8.0"
version = "1.9.0"

[lib]
crate-type = ["cdylib"]
name = "chainflip_engine_v1_8_0"
name = "chainflip_engine_v1_9_0"
path = "src/lib.rs"

[dependencies]
Expand Down
2 changes: 1 addition & 1 deletion engine-proc-macros/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ edition = "2021"
name = "engine-proc-macros"
# The version here is the version that will be used for the generated code, and therefore will be the
# suffix of the generated engine entrypoint. TODO: Fix this.
version = "1.8.0"
version = "1.9.0"

[lib]
proc-macro = true
Expand Down
Loading

0 comments on commit 2fab474

Please sign in to comment.