From a9098fb1e040789b945d1facb50f1aada237f7a2 Mon Sep 17 00:00:00 2001 From: SunTiebing <87381708+SunTiebing@users.noreply.github.com> Date: Fri, 22 Nov 2024 10:24:47 +0800 Subject: [PATCH] Bifrost v0.15.0 (#1485) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit * Bifrost v0.15.0 * Migrated benchmarking of asset-registry from v1 to v2. (#1486) * Feat/ban vbnc transfer (#1487) * Bifrost v0.14.0 * Feat/optimize salp (#1433) * Backup salp pallet * remove unused BancorHandler * remove unused Call of SALP * remove extra fee of bifrost_salp::Call::contribute in runtime * adjust test and benchmarking * remove unused interface type of SALP * fix clippy * Optimised calculation of evm fee (#1434) * Optimised calculation of evm fee * Update gas_fee_price to weth_price * Moved PalletId and AccountId to primitives. (#1437) * Bifrost v0.13.0 * Remove getter in buy-back. (#1354) * Bifrost v0.12.0 * remove old migrations * Fix vtokenVoting.removeDelegatorVote (#1288) * add PollClass type * add the calss parameter to the remove_delegator_vote method * Add metadata hash (#1299) * feat: 🎸 add buy-back * Bifrost v0.10.001 * feat: 🎸 benchmark * SLPx mint support commission id (#1261) * Add vtoken exchange rate rpc (#1260) * fix: πŸ› add event (#1263) * add update_currency_metadata function (#1259) * add update_currency_metadata function * fix: πŸ› correct update_currency_metadata weight * add the use of Vec (#1264) * Add vtoken exchange rate rpc * add the use of Vec * Upgrade to Polkadot-SDK v1.7.0 (#1262) * Bifrost v0.10.0 * fix: πŸ› clippy * Fix chain spec (#1243) * Upgrade to polkadot-v1.7.0 --------- Co-authored-by: SunTiebing <1045060705@qq.com> Co-authored-by: Edwin Wang * Fix compile * feat: 🎸 add metadata-hash-extension (#1265) * feat: 🎸 add metadata-hash-extension * Fix compile (#1266) * Fix/fix vtoken voting unlock (#1267) * update the exchange rate of vtokenminting of vtokenvoting test * Resolve the frozen anomaly when unlocking * Revert "feat: 🎸 add metadata-hash-extension (#1265)" (#1268) This reverts commit 489fc9c6adeae44d23edf449e74fde3d6aa40bc3. * rename the version number to 0.11.0 * Slp supports XCMv4 and reconstruct integration tests (#1272) * Fix compile * Reconstruct integration tests and slp supports XCMv4 * Fix slp construct_xcm_message * Feat/slpx mint add commission (#1273) * SLPx mint support commission id * remove the channel_id parameter from the mint method * add mint_with_channel_id method * perform data migration for OrderQueue storage * slpx: set the default value of channel_id to 0 * resolve conflicts * change the location of the old data structure during storage migration * Feat/add vtoken exchange rate rpc (#1274) * Add vtoken exchange rate rpc * add the use of Vec * supplement the RPC logic && fix bugs * adjust the RPC exchange rate precision to three decimal places * fix clippy * fix bug: storage migration anomaly (#1276) * SLPx mint support commission id * remove the channel_id parameter from the mint method * add mint_with_channel_id method * perform data migration for OrderQueue storage * slpx: set the default value of channel_id to 0 * resolve conflicts * change the location of the old data structure during storage migration * fix bug: storage migration anomaly * Slp removes refund (#1275) * Slp removes refund * Fix clippy * Feat/add vtoken exchange rate rpc (#1277) * Add vtoken exchange rate rpc * add the use of Vec * supplement the RPC logic && fix bugs * adjust the RPC exchange rate precision to three decimal places * fix clippy * supplement omissions: adjust the RPC exchange rate precision to three decimal places * Remove dmp queue (#1279) * fix: πŸ› CheckMetadataHash to false * fix: πŸ› update sp-api * refactor: πŸ’‘ fmt * fix: πŸ› add metadata-hash * fix: πŸ› add feature metadata-hash * fix: πŸ› rm metadata-hash feature --------- Co-authored-by: SunTiebing <1045060705@qq.com> Co-authored-by: SunTiebing <87381708+SunTiebing@users.noreply.github.com> Co-authored-by: NingBo Wang <2536935847@qq.com> Co-authored-by: Edwin Wang * refactor: πŸ’‘ update MaxTurnout and whitelisted_caller track (#1304) * Allow to receive and send Ethereum assets (#1305) * feat: 🎸 add buy-back * Bifrost v0.10.001 * feat: 🎸 benchmark * SLPx mint support commission id (#1261) * Add vtoken exchange rate rpc (#1260) * fix: πŸ› add event (#1263) * add update_currency_metadata function (#1259) * add update_currency_metadata function * fix: πŸ› correct update_currency_metadata weight * add the use of Vec (#1264) * Add vtoken exchange rate rpc * add the use of Vec * Upgrade to Polkadot-SDK v1.7.0 (#1262) * Bifrost v0.10.0 * fix: πŸ› clippy * Fix chain spec (#1243) * Upgrade to polkadot-v1.7.0 --------- Co-authored-by: SunTiebing <1045060705@qq.com> Co-authored-by: Edwin Wang * feat: 🎸 add metadata-hash-extension (#1265) * Fix compile (#1266) * Fix/fix vtoken voting unlock (#1267) * update the exchange rate of vtokenminting of vtokenvoting test * Resolve the frozen anomaly when unlocking * Revert "feat: 🎸 add metadata-hash-extension (#1265)" (#1268) This reverts commit 489fc9c6adeae44d23edf449e74fde3d6aa40bc3. * rename the version number to 0.11.0 * Slp supports XCMv4 and reconstruct integration tests (#1272) * Fix compile * Reconstruct integration tests and slp supports XCMv4 * Fix slp construct_xcm_message * Feat/slpx mint add commission (#1273) * SLPx mint support commission id * remove the channel_id parameter from the mint method * add mint_with_channel_id method * perform data migration for OrderQueue storage * slpx: set the default value of channel_id to 0 * resolve conflicts * change the location of the old data structure during storage migration * Feat/add vtoken exchange rate rpc (#1274) * Add vtoken exchange rate rpc * add the use of Vec * supplement the RPC logic && fix bugs * adjust the RPC exchange rate precision to three decimal places * fix clippy * fix bug: storage migration anomaly (#1276) * SLPx mint support commission id * remove the channel_id parameter from the mint method * add mint_with_channel_id method * perform data migration for OrderQueue storage * slpx: set the default value of channel_id to 0 * resolve conflicts * change the location of the old data structure during storage migration * fix bug: storage migration anomaly * Slp removes refund (#1275) * Slp removes refund * Fix clippy * Allow to receive and send Ethereum assets * Add constants --------- Co-authored-by: yooml Co-authored-by: SunTiebing <1045060705@qq.com> Co-authored-by: SunTiebing <87381708+SunTiebing@users.noreply.github.com> Co-authored-by: Edwin Wang * Disable supplement_fee_reserve (#1306) * Remove call_switchgear and add tx_pause (#1308) * Remove call_switchgear and add tx_pause * Fix clippy * Optimize flexible fee (#1307) * Optimize flexible fee * Fix bug * Fix bug * Add PalletId * Add error handle * feat: 🎸 add market-bond * fix: πŸ› test-all * fix: πŸ› try-runtime * Add the channel_id field to the Minted event * Upgrade to polkadot-v1.13.0 (#1312) * Upgrade to polkadot-v1.13.0 * remove the warning * Fix dep issues * Upgrade to polkadot-v1.13.0 * supplement and upgrade the code * Upgrade the new parts from v0.12.0 * Fix dep issues * format Cargo.toml * Modify the AddOrigin type of the fellowship in bifrost-polkadot * Cancel the cross-in-out migration. * fix clippy --------- Co-authored-by: hqwangningbo <2536935847@qq.com> * Use github dependencies (#1314) * Fix flexible_fee TransferTo (#1315) * Fix generate_genesis_state (#1317) * Optimize oracle (#1318) * refactor: πŸ’‘ optimize orml-oracle * fix: πŸ› MinimumTimestampInterval * style: πŸ’„ rename to MaximumValueInterval * Add some tests for ve-minting * Add some tests for ve-minting * Integrate evm (#1319) * Update dep * Ingrate EVM * Fix deps * Add precompiles.rs * Remove pallet-hotfix-sufficients * Add pallet-evm-accounts * Evm precompiles * EVM integration * Fix compile * Fix rpc * Fix `encode_evm_address` and `decode_evm_address` * Fix evm precompile multicurrency * Implementing Erc20Mapping using xc-20 standard * Compatible with BNC Decimal * Increase min_gas_price * feat: enable dev mode with manual seal & fix pending block problem * Add copyright and fix some bugs * Change native token to WETH * Support evm flexible fee * Add inner_swap_exact_assets_for_assets to evm withdraw fee * Remove swap * EVM migration from bifrost kusama to bifrost polkadot * Fix erc20 precompile * Use OraclePrice * Fix some errors * feat: add prices genesis config & optimize dev mode code * Fix conflicts * Fix some errors * Fix clippy * Format Cargo.toml * Remove unused code * Fix clippy * Fix some errors * Fix erc20 precompile --------- Co-authored-by: Edwin Wang Co-authored-by: Damian.lu * Fix try-runtime (#1323) * Fix manual seal * Fix manual seal (#1324) * fix: πŸ› fellowship collective data (#1325) * fix: add parachain mock inherent data provider * Fix ethereum transfer fee (#1328) * Add evm genesis migration (#1338) * Bifrost v0.12.0 (#1286) * Bifrost v0.12.0 * remove old migrations * Fix vtokenVoting.removeDelegatorVote (#1288) * add PollClass type * add the calss parameter to the remove_delegator_vote method * Add metadata hash (#1299) * feat: 🎸 add buy-back * Bifrost v0.10.001 * feat: 🎸 benchmark * SLPx mint support commission id (#1261) * Add vtoken exchange rate rpc (#1260) * fix: πŸ› add event (#1263) * add update_currency_metadata function (#1259) * add update_currency_metadata function * fix: πŸ› correct update_currency_metadata weight * add the use of Vec (#1264) * Add vtoken exchange rate rpc * add the use of Vec * Upgrade to Polkadot-SDK v1.7.0 (#1262) * Bifrost v0.10.0 * fix: πŸ› clippy * Fix chain spec (#1243) * Upgrade to polkadot-v1.7.0 --------- Co-authored-by: SunTiebing <1045060705@qq.com> Co-authored-by: Edwin Wang * Fix compile * feat: 🎸 add metadata-hash-extension (#1265) * feat: 🎸 add metadata-hash-extension * Fix compile (#1266) * Fix/fix vtoken voting unlock (#1267) * update the exchange rate of vtokenminting of vtokenvoting test * Resolve the frozen anomaly when unlocking * Revert "feat: 🎸 add metadata-hash-extension (#1265)" (#1268) This reverts commit 489fc9c6adeae44d23edf449e74fde3d6aa40bc3. * rename the version number to 0.11.0 * Slp supports XCMv4 and reconstruct integration tests (#1272) * Fix compile * Reconstruct integration tests and slp supports XCMv4 * Fix slp construct_xcm_message * Feat/slpx mint add commission (#1273) * SLPx mint support commission id * remove the channel_id parameter from the mint method * add mint_with_channel_id method * perform data migration for OrderQueue storage * slpx: set the default value of channel_id to 0 * resolve conflicts * change the location of the old data structure during storage migration * Feat/add vtoken exchange rate rpc (#1274) * Add vtoken exchange rate rpc * add the use of Vec * supplement the RPC logic && fix bugs * adjust the RPC exchange rate precision to three decimal places * fix clippy * fix bug: storage migration anomaly (#1276) * SLPx mint support commission id * remove the channel_id parameter from the mint method * add mint_with_channel_id method * perform data migration for OrderQueue storage * slpx: set the default value of channel_id to 0 * resolve conflicts * change the location of the old data structure during storage migration * fix bug: storage migration anomaly * Slp removes refund (#1275) * Slp removes refund * Fix clippy * Feat/add vtoken exchange rate rpc (#1277) * Add vtoken exchange rate rpc * add the use of Vec * supplement the RPC logic && fix bugs * adjust the RPC exchange rate precision to three decimal places * fix clippy * supplement omissions: adjust the RPC exchange rate precision to three decimal places * Remove dmp queue (#1279) * fix: πŸ› CheckMetadataHash to false * fix: πŸ› update sp-api * refactor: πŸ’‘ fmt * fix: πŸ› add metadata-hash * fix: πŸ› add feature metadata-hash * fix: πŸ› rm metadata-hash feature --------- Co-authored-by: SunTiebing <1045060705@qq.com> Co-authored-by: SunTiebing <87381708+SunTiebing@users.noreply.github.com> Co-authored-by: NingBo Wang <2536935847@qq.com> Co-authored-by: Edwin Wang * refactor: πŸ’‘ update MaxTurnout and whitelisted_caller track (#1304) * Allow to receive and send Ethereum assets (#1305) * feat: 🎸 add buy-back * Bifrost v0.10.001 * feat: 🎸 benchmark * SLPx mint support commission id (#1261) * Add vtoken exchange rate rpc (#1260) * fix: πŸ› add event (#1263) * add update_currency_metadata function (#1259) * add update_currency_metadata function * fix: πŸ› correct update_currency_metadata weight * add the use of Vec (#1264) * Add vtoken exchange rate rpc * add the use of Vec * Upgrade to Polkadot-SDK v1.7.0 (#1262) * Bifrost v0.10.0 * fix: πŸ› clippy * Fix chain spec (#1243) * Upgrade to polkadot-v1.7.0 --------- Co-authored-by: SunTiebing <1045060705@qq.com> Co-authored-by: Edwin Wang * feat: 🎸 add metadata-hash-extension (#1265) * Fix compile (#1266) * Fix/fix vtoken voting unlock (#1267) * update the exchange rate of vtokenminting of vtokenvoting test * Resolve the frozen anomaly when unlocking * Revert "feat: 🎸 add metadata-hash-extension (#1265)" (#1268) This reverts commit 489fc9c6adeae44d23edf449e74fde3d6aa40bc3. * rename the version number to 0.11.0 * Slp supports XCMv4 and reconstruct integration tests (#1272) * Fix compile * Reconstruct integration tests and slp supports XCMv4 * Fix slp construct_xcm_message * Feat/slpx mint add commission (#1273) * SLPx mint support commission id * remove the channel_id parameter from the mint method * add mint_with_channel_id method * perform data migration for OrderQueue storage * slpx: set the default value of channel_id to 0 * resolve conflicts * change the location of the old data structure during storage migration * Feat/add vtoken exchange rate rpc (#1274) * Add vtoken exchange rate rpc * add the use of Vec * supplement the RPC logic && fix bugs * adjust the RPC exchange rate precision to three decimal places * fix clippy * fix bug: storage migration anomaly (#1276) * SLPx mint support commission id * remove the channel_id parameter from the mint method * add mint_with_channel_id method * perform data migration for OrderQueue storage * slpx: set the default value of channel_id to 0 * resolve conflicts * change the location of the old data structure during storage migration * fix bug: storage migration anomaly * Slp removes refund (#1275) * Slp removes refund * Fix clippy * Allow to receive and send Ethereum assets * Add constants --------- Co-authored-by: yooml Co-authored-by: SunTiebing <1045060705@qq.com> Co-authored-by: SunTiebing <87381708+SunTiebing@users.noreply.github.com> Co-authored-by: Edwin Wang * Disable supplement_fee_reserve (#1306) * Remove call_switchgear and add tx_pause (#1308) * Remove call_switchgear and add tx_pause * Fix clippy * Optimize flexible fee (#1307) * Optimize flexible fee * Fix bug * Fix bug * Add PalletId * Add error handle * feat: 🎸 add market-bond * fix: πŸ› test-all * fix: πŸ› try-runtime * Add the channel_id field to the Minted event * Upgrade to polkadot-v1.13.0 (#1312) * Upgrade to polkadot-v1.13.0 * remove the warning * Fix dep issues * Upgrade to polkadot-v1.13.0 * supplement and upgrade the code * Upgrade the new parts from v0.12.0 * Fix dep issues * format Cargo.toml * Modify the AddOrigin type of the fellowship in bifrost-polkadot * Cancel the cross-in-out migration. * fix clippy --------- Co-authored-by: hqwangningbo <2536935847@qq.com> * Use github dependencies (#1314) * Fix flexible_fee TransferTo (#1315) * Fix generate_genesis_state (#1317) * Optimize oracle (#1318) * refactor: πŸ’‘ optimize orml-oracle * fix: πŸ› MinimumTimestampInterval * style: πŸ’„ rename to MaximumValueInterval * Add some tests for ve-minting * Add some tests for ve-minting * Integrate evm (#1319) * Update dep * Ingrate EVM * Fix deps * Add precompiles.rs * Remove pallet-hotfix-sufficients * Add pallet-evm-accounts * Evm precompiles * EVM integration * Fix compile * Fix rpc * Fix `encode_evm_address` and `decode_evm_address` * Fix evm precompile multicurrency * Implementing Erc20Mapping using xc-20 standard * Compatible with BNC Decimal * Increase min_gas_price * feat: enable dev mode with manual seal & fix pending block problem * Add copyright and fix some bugs * Change native token to WETH * Support evm flexible fee * Add inner_swap_exact_assets_for_assets to evm withdraw fee * Remove swap * EVM migration from bifrost kusama to bifrost polkadot * Fix erc20 precompile * Use OraclePrice * Fix some errors * feat: add prices genesis config & optimize dev mode code * Fix conflicts * Fix some errors * Fix clippy * Format Cargo.toml * Remove unused code * Fix clippy * Fix some errors * Fix erc20 precompile --------- Co-authored-by: Edwin Wang Co-authored-by: Damian.lu * Fix try-runtime (#1323) * Fix manual seal * Fix manual seal (#1324) * fix: πŸ› fellowship collective data (#1325) * fix: add parachain mock inherent data provider * Fix ethereum transfer fee (#1328) --------- Co-authored-by: Edwin Wang Co-authored-by: yooml Co-authored-by: NingBo Wang <2536935847@qq.com> Co-authored-by: Gemma Co-authored-by: Damian.lu * Add evm genesis storage * [skip ci] Add evmSince --------- Co-authored-by: SunTiebing <87381708+SunTiebing@users.noreply.github.com> Co-authored-by: Edwin Wang Co-authored-by: yooml Co-authored-by: Gemma Co-authored-by: Damian.lu * Bump version to 0.12.1 * Update Cargo.lock * Fix migration (#1341) * Bifrost v0.12.0 (#1286) * Bifrost v0.12.0 * remove old migrations * Fix vtokenVoting.removeDelegatorVote (#1288) * add PollClass type * add the calss parameter to the remove_delegator_vote method * Add metadata hash (#1299) * feat: 🎸 add buy-back * Bifrost v0.10.001 * feat: 🎸 benchmark * SLPx mint support commission id (#1261) * Add vtoken exchange rate rpc (#1260) * fix: πŸ› add event (#1263) * add update_currency_metadata function (#1259) * add update_currency_metadata function * fix: πŸ› correct update_currency_metadata weight * add the use of Vec (#1264) * Add vtoken exchange rate rpc * add the use of Vec * Upgrade to Polkadot-SDK v1.7.0 (#1262) * Bifrost v0.10.0 * fix: πŸ› clippy * Fix chain spec (#1243) * Upgrade to polkadot-v1.7.0 --------- Co-authored-by: SunTiebing <1045060705@qq.com> Co-authored-by: Edwin Wang * Fix compile * feat: 🎸 add metadata-hash-extension (#1265) * feat: 🎸 add metadata-hash-extension * Fix compile (#1266) * Fix/fix vtoken voting unlock (#1267) * update the exchange rate of vtokenminting of vtokenvoting test * Resolve the frozen anomaly when unlocking * Revert "feat: 🎸 add metadata-hash-extension (#1265)" (#1268) This reverts commit 489fc9c6adeae44d23edf449e74fde3d6aa40bc3. * rename the version number to 0.11.0 * Slp supports XCMv4 and reconstruct integration tests (#1272) * Fix compile * Reconstruct integration tests and slp supports XCMv4 * Fix slp construct_xcm_message * Feat/slpx mint add commission (#1273) * SLPx mint support commission id * remove the channel_id parameter from the mint method * add mint_with_channel_id method * perform data migration for OrderQueue storage * slpx: set the default value of channel_id to 0 * resolve conflicts * change the location of the old data structure during storage migration * Feat/add vtoken exchange rate rpc (#1274) * Add vtoken exchange rate rpc * add the use of Vec * supplement the RPC logic && fix bugs * adjust the RPC exchange rate precision to three decimal places * fix clippy * fix bug: storage migration anomaly (#1276) * SLPx mint support commission id * remove the channel_id parameter from the mint method * add mint_with_channel_id method * perform data migration for OrderQueue storage * slpx: set the default value of channel_id to 0 * resolve conflicts * change the location of the old data structure during storage migration * fix bug: storage migration anomaly * Slp removes refund (#1275) * Slp removes refund * Fix clippy * Feat/add vtoken exchange rate rpc (#1277) * Add vtoken exchange rate rpc * add the use of Vec * supplement the RPC logic && fix bugs * adjust the RPC exchange rate precision to three decimal places * fix clippy * supplement omissions: adjust the RPC exchange rate precision to three decimal places * Remove dmp queue (#1279) * fix: πŸ› CheckMetadataHash to false * fix: πŸ› update sp-api * refactor: πŸ’‘ fmt * fix: πŸ› add metadata-hash * fix: πŸ› add feature metadata-hash * fix: πŸ› rm metadata-hash feature --------- Co-authored-by: SunTiebing <1045060705@qq.com> Co-authored-by: SunTiebing <87381708+SunTiebing@users.noreply.github.com> Co-authored-by: NingBo Wang <2536935847@qq.com> Co-authored-by: Edwin Wang * refactor: πŸ’‘ update MaxTurnout and whitelisted_caller track (#1304) * Allow to receive and send Ethereum assets (#1305) * feat: 🎸 add buy-back * Bifrost v0.10.001 * feat: 🎸 benchmark * SLPx mint support commission id (#1261) * Add vtoken exchange rate rpc (#1260) * fix: πŸ› add event (#1263) * add update_currency_metadata function (#1259) * add update_currency_metadata function * fix: πŸ› correct update_currency_metadata weight * add the use of Vec (#1264) * Add vtoken exchange rate rpc * add the use of Vec * Upgrade to Polkadot-SDK v1.7.0 (#1262) * Bifrost v0.10.0 * fix: πŸ› clippy * Fix chain spec (#1243) * Upgrade to polkadot-v1.7.0 --------- Co-authored-by: SunTiebing <1045060705@qq.com> Co-authored-by: Edwin Wang * feat: 🎸 add metadata-hash-extension (#1265) * Fix compile (#1266) * Fix/fix vtoken voting unlock (#1267) * update the exchange rate of vtokenminting of vtokenvoting test * Resolve the frozen anomaly when unlocking * Revert "feat: 🎸 add metadata-hash-extension (#1265)" (#1268) This reverts commit 489fc9c6adeae44d23edf449e74fde3d6aa40bc3. * rename the version number to 0.11.0 * Slp supports XCMv4 and reconstruct integration tests (#1272) * Fix compile * Reconstruct integration tests and slp supports XCMv4 * Fix slp construct_xcm_message * Feat/slpx mint add commission (#1273) * SLPx mint support commission id * remove the channel_id parameter from the mint method * add mint_with_channel_id method * perform data migration for OrderQueue storage * slpx: set the default value of channel_id to 0 * resolve conflicts * change the location of the old data structure during storage migration * Feat/add vtoken exchange rate rpc (#1274) * Add vtoken exchange rate rpc * add the use of Vec * supplement the RPC logic && fix bugs * adjust the RPC exchange rate precision to three decimal places * fix clippy * fix bug: storage migration anomaly (#1276) * SLPx mint support commission id * remove the channel_id parameter from the mint method * add mint_with_channel_id method * perform data migration for OrderQueue storage * slpx: set the default value of channel_id to 0 * resolve conflicts * change the location of the old data structure during storage migration * fix bug: storage migration anomaly * Slp removes refund (#1275) * Slp removes refund * Fix clippy * Allow to receive and send Ethereum assets * Add constants --------- Co-authored-by: yooml Co-authored-by: SunTiebing <1045060705@qq.com> Co-authored-by: SunTiebing <87381708+SunTiebing@users.noreply.github.com> Co-authored-by: Edwin Wang * Disable supplement_fee_reserve (#1306) * Remove call_switchgear and add tx_pause (#1308) * Remove call_switchgear and add tx_pause * Fix clippy * Optimize flexible fee (#1307) * Optimize flexible fee * Fix bug * Fix bug * Add PalletId * Add error handle * feat: 🎸 add market-bond * fix: πŸ› test-all * fix: πŸ› try-runtime * Add the channel_id field to the Minted event * Upgrade to polkadot-v1.13.0 (#1312) * Upgrade to polkadot-v1.13.0 * remove the warning * Fix dep issues * Upgrade to polkadot-v1.13.0 * supplement and upgrade the code * Upgrade the new parts from v0.12.0 * Fix dep issues * format Cargo.toml * Modify the AddOrigin type of the fellowship in bifrost-polkadot * Cancel the cross-in-out migration. * fix clippy --------- Co-authored-by: hqwangningbo <2536935847@qq.com> * Use github dependencies (#1314) * Fix flexible_fee TransferTo (#1315) * Fix generate_genesis_state (#1317) * Optimize oracle (#1318) * refactor: πŸ’‘ optimize orml-oracle * fix: πŸ› MinimumTimestampInterval * style: πŸ’„ rename to MaximumValueInterval * Add some tests for ve-minting * Add some tests for ve-minting * Integrate evm (#1319) * Update dep * Ingrate EVM * Fix deps * Add precompiles.rs * Remove pallet-hotfix-sufficients * Add pallet-evm-accounts * Evm precompiles * EVM integration * Fix compile * Fix rpc * Fix `encode_evm_address` and `decode_evm_address` * Fix evm precompile multicurrency * Implementing Erc20Mapping using xc-20 standard * Compatible with BNC Decimal * Increase min_gas_price * feat: enable dev mode with manual seal & fix pending block problem * Add copyright and fix some bugs * Change native token to WETH * Support evm flexible fee * Add inner_swap_exact_assets_for_assets to evm withdraw fee * Remove swap * EVM migration from bifrost kusama to bifrost polkadot * Fix erc20 precompile * Use OraclePrice * Fix some errors * feat: add prices genesis config & optimize dev mode code * Fix conflicts * Fix some errors * Fix clippy * Format Cargo.toml * Remove unused code * Fix clippy * Fix some errors * Fix erc20 precompile --------- Co-authored-by: Edwin Wang Co-authored-by: Damian.lu * Fix try-runtime (#1323) * Fix manual seal * Fix manual seal (#1324) * fix: πŸ› fellowship collective data (#1325) * fix: add parachain mock inherent data provider * Fix ethereum transfer fee (#1328) --------- Co-authored-by: Edwin Wang Co-authored-by: yooml Co-authored-by: NingBo Wang <2536935847@qq.com> Co-authored-by: Gemma Co-authored-by: Damian.lu * Add evm genesis storage * [skip ci] Add evmSince * Fix migration * Fix migration * Remove unused code --------- Co-authored-by: SunTiebing <87381708+SunTiebing@users.noreply.github.com> Co-authored-by: Edwin Wang Co-authored-by: yooml Co-authored-by: Gemma Co-authored-by: Damian.lu * Remove getter in buy-back --------- Co-authored-by: SunTiebing <1045060705@qq.com> Co-authored-by: SunTiebing <87381708+SunTiebing@users.noreply.github.com> Co-authored-by: Edwin Wang Co-authored-by: yooml Co-authored-by: NingBo Wang <2536935847@qq.com> Co-authored-by: Damian.lu * Remove getters in xcm-interface (#1352) * Remove getters in salp. (#1351) * Remove getter in evm-accounts (#1350) * Remove getters in slp (#1353) * Remove getters in slpx (#1360) * Remove getters in vstoken-conversion. (#1362) * Remove getters in vtoken-minting. (#1363) * Remove getter in system-maker. (#1364) * Remove getter in fee-share (#1365) * Remove getters in prices (#1367) * Remove getters in lend-market (#1366) * Remove getters in ve-minting (#1368) * Optimize clippy (#1369) * Deprecated unused pallets (#1383) * Review format (#1386) * style: πŸ’„ format * style: πŸ’„ check-all * fix: πŸ› bench * Update buy back (#1387) * style: πŸ’„ format * style: πŸ’„ check-all * fix: πŸ› bench * feat: 🎸 add destruction_ratio * fix: πŸ› benchmark * EVM flexible fee logic optimization (#1370) * EVM flexible fee logic optimization * Add comments * Add support for handling different currency precisions & included error handling. * Adjust the gas_fee parameter in the get_balance_in_currency method to an exact value * fix clippy * add test code of flexiable-fee pallet * Update fee share (#1395) * feat: 🎸 add usd_cumulation * feat: 🎸 bench * fix: πŸ› fmt * docs: ✏️ add note * Feat/change evm address convert rule (#1396) * Change EVM Address convert rule * Change EVM Address convert rule * Remove the unused function:is_evm_account & rename truncated_account_id function to convert_account_id * fix clippy * refactor: πŸ’‘ move to TechAdmin (#1398) * refactor: πŸ’‘ transfer to BuyBackAccount (#1399) * Fix mint_with_channel_id weights (#1400) * Recoverd imgs of banner and logo (#1401) * feat: 🎸 add fn set_swap_out_min (#1389) * feat: 🎸 add fn set_swap_out_min * fix: πŸ› fmt * fix: πŸ› fmt * fix: πŸ› error * feat: 🎸 add bais * fix: πŸ› add test * fix: πŸ› rename field bias * Optimize the `channel-commission` code. (#1390) * Optimize the `channel-commission` code. * Replace the insert method with the mutate method * Added a result check for the clear_prefix method * Supplement the test code of `channel-commission`. * Handling Error cases in hooks. * Optimize the handling of the `check_removed_all` method. * Remove getters in cross-in-out (#1402) * Removed getters in channel-commission. (#1404) * Removed getters in flexible-fee. (#1405) * Removed getters in channel-commission. * Removed getters in flexible-fee. * Removed getters in parachain-staking. (#1406) * Removed getters in channel-commission. * Removed getters in flexible-fee. * Removed getterd in parachain-staking. * Update buy back (#1407) * fix: πŸ› add field last_buyback_cycle for accurate judgment * style: πŸ’„ fmt * Update ve minting (#1408) * refactor: πŸ’‘ transfer to BuyBackAccount * feat: 🎸 add auto notify_reward * Removed getters in stable-asset and system-staking. (#1409) * Removed getters in channel-commission. * Removed getters in flexible-fee. * Removed getterd in parachain-staking. * Removed getters in stable-asset. * Removed getters in stable-asset. * Removed getters in token-issuer. (#1410) * Removed getters in channel-commission. * Removed getters in flexible-fee. * Removed getterd in parachain-staking. * Removed getters in stable-asset. * Removed getters in stable-asset. * Removed getters in token-issuer. --------- Co-authored-by: Edwin * Moved PrarachainId to primitives. (#1394) * Moved PrarachainId to primitives * updated * bug fixed * Moved parachain ids to primitives. * bug fixed * Fixed error. * Removed getters in vsbond-auction. (#1412) * Fix evm TransferEvmFees (#1411) * Add slp v2 (#1397) * Add slp v2 * Add slp v2 weights * Optimize slp v2 * Optimize slp v2 * Remove operator * Feat/vbnc convert (#1413) * Add vbnc-convert pallet * add weights.rs of vbnc-convert pallet * update token id of VBNC_P * update weight of vbnc-convert pallet * Supplement the comments of `vbnc-convert`. * update VBNCConvert index in Runtime enum * Optimize vbnc-convert pallet pallet. * Updated (#1416) * Add more slp v2 docs (#1419) * Optimize xcm config (#1417) * Optimize xcm config * Fix moonbeam chain id * Update fee share (#1418) * refactor: πŸ’‘ for review * fix: πŸ› mv storage * fix: πŸ› bench * refactor: πŸ’‘ fmt --------- Co-authored-by: Edwin * Moved PalletId and AccountId to primitives * Optimize slp v2 (#1423) * Optimize slp v2 * Optimize weights * fix: πŸ› redefine system pool id (#1421) * fix: πŸ› redefine system pool id * fix: πŸ› auto_notify_reward * refactor: πŸ’‘ rename to bb-bnc * style: πŸ’„ clippy * fix: πŸ› rename error * refactor: πŸ’‘ rm BbBNCPalletId * fix: πŸ› UserFarmingPool bound limit * Moved CurrencyId to primitives. * Updated to the latest version. * change VBNC_P_TOKEN_ID to 5 (#1425) * updated * update * updated * updated --------- Co-authored-by: SunTiebing <1045060705@qq.com> Co-authored-by: SunTiebing <87381708+SunTiebing@users.noreply.github.com> Co-authored-by: Edwin Wang Co-authored-by: yooml Co-authored-by: NingBo Wang <2536935847@qq.com> Co-authored-by: Damian.lu * Optimize xcm interface (#1439) * Optimize xcm-interface pallet * Add weights * Add weights * Add weights * Optimize xcm-interface pallet * remove unnecessary call method of cross-in-out (#1440) && optimize cross-in-out pallet * Update bb bnc (#1436) * refactor: πŸ’‘ for review * docs: ✏️ add docs * fix: πŸ› docs * fix: πŸ› add event && addr rename * Optimize slpx pallet (#1444) * Moved palletId in runtime to primitives (#1443) * Optimize asset registry (#1445) * optimize asset-registry & remove unused call * backup asset-registry pallet * Removed getters in farming (#1446) * Removed getters in vesting. (#1447) * Removed getters in vesting * updated * updated * Feat/vtoken voting vbnc (#1442) * Bifrost v0.12.0 * remove old migrations * Fix vtokenVoting.removeDelegatorVote (#1288) * add PollClass type * add the calss parameter to the remove_delegator_vote method * Add metadata hash (#1299) * feat: 🎸 add buy-back * Bifrost v0.10.001 * feat: 🎸 benchmark * SLPx mint support commission id (#1261) * Add vtoken exchange rate rpc (#1260) * fix: πŸ› add event (#1263) * add update_currency_metadata function (#1259) * add update_currency_metadata function * fix: πŸ› correct update_currency_metadata weight * add the use of Vec (#1264) * Add vtoken exchange rate rpc * add the use of Vec * Upgrade to Polkadot-SDK v1.7.0 (#1262) * Bifrost v0.10.0 * fix: πŸ› clippy * Fix chain spec (#1243) * Upgrade to polkadot-v1.7.0 --------- Co-authored-by: SunTiebing <1045060705@qq.com> Co-authored-by: Edwin Wang * Fix compile * feat: 🎸 add metadata-hash-extension (#1265) * feat: 🎸 add metadata-hash-extension * Fix compile (#1266) * Fix/fix vtoken voting unlock (#1267) * update the exchange rate of vtokenminting of vtokenvoting test * Resolve the frozen anomaly when unlocking * Revert "feat: 🎸 add metadata-hash-extension (#1265)" (#1268) This reverts commit 489fc9c6adeae44d23edf449e74fde3d6aa40bc3. * rename the version number to 0.11.0 * Slp supports XCMv4 and reconstruct integration tests (#1272) * Fix compile * Reconstruct integration tests and slp supports XCMv4 * Fix slp construct_xcm_message * Feat/slpx mint add commission (#1273) * SLPx mint support commission id * remove the channel_id parameter from the mint method * add mint_with_channel_id method * perform data migration for OrderQueue storage * slpx: set the default value of channel_id to 0 * resolve conflicts * change the location of the old data structure during storage migration * Feat/add vtoken exchange rate rpc (#1274) * Add vtoken exchange rate rpc * add the use of Vec * supplement the RPC logic && fix bugs * adjust the RPC exchange rate precision to three decimal places * fix clippy * fix bug: storage migration anomaly (#1276) * SLPx mint support commission id * remove the channel_id parameter from the mint method * add mint_with_channel_id method * perform data migration for OrderQueue storage * slpx: set the default value of channel_id to 0 * resolve conflicts * change the location of the old data structure during storage migration * fix bug: storage migration anomaly * Slp removes refund (#1275) * Slp removes refund * Fix clippy * Feat/add vtoken exchange rate rpc (#1277) * Add vtoken exchange rate rpc * add the use of Vec * supplement the RPC logic && fix bugs * adjust the RPC exchange rate precision to three decimal places * fix clippy * supplement omissions: adjust the RPC exchange rate precision to three decimal places * Remove dmp queue (#1279) * fix: πŸ› CheckMetadataHash to false * fix: πŸ› update sp-api * refactor: πŸ’‘ fmt * fix: πŸ› add metadata-hash * fix: πŸ› add feature metadata-hash * fix: πŸ› rm metadata-hash feature --------- Co-authored-by: SunTiebing <1045060705@qq.com> Co-authored-by: SunTiebing <87381708+SunTiebing@users.noreply.github.com> Co-authored-by: NingBo Wang <2536935847@qq.com> Co-authored-by: Edwin Wang * refactor: πŸ’‘ update MaxTurnout and whitelisted_caller track (#1304) * Allow to receive and send Ethereum assets (#1305) * feat: 🎸 add buy-back * Bifrost v0.10.001 * feat: 🎸 benchmark * SLPx mint support commission id (#1261) * Add vtoken exchange rate rpc (#1260) * fix: πŸ› add event (#1263) * add update_currency_metadata function (#1259) * add update_currency_metadata function * fix: πŸ› correct update_currency_metadata weight * add the use of Vec (#1264) * Add vtoken exchange rate rpc * add the use of Vec * Upgrade to Polkadot-SDK v1.7.0 (#1262) * Bifrost v0.10.0 * fix: πŸ› clippy * Fix chain spec (#1243) * Upgrade to polkadot-v1.7.0 --------- Co-authored-by: SunTiebing <1045060705@qq.com> Co-authored-by: Edwin Wang * feat: 🎸 add metadata-hash-extension (#1265) * Fix compile (#1266) * Fix/fix vtoken voting unlock (#1267) * update the exchange rate of vtokenminting of vtokenvoting test * Resolve the frozen anomaly when unlocking * Revert "feat: 🎸 add metadata-hash-extension (#1265)" (#1268) This reverts commit 489fc9c6adeae44d23edf449e74fde3d6aa40bc3. * rename the version number to 0.11.0 * Slp supports XCMv4 and reconstruct integration tests (#1272) * Fix compile * Reconstruct integration tests and slp supports XCMv4 * Fix slp construct_xcm_message * Feat/slpx mint add commission (#1273) * SLPx mint support commission id * remove the channel_id parameter from the mint method * add mint_with_channel_id method * perform data migration for OrderQueue storage * slpx: set the default value of channel_id to 0 * resolve conflicts * change the location of the old data structure during storage migration * Feat/add vtoken exchange rate rpc (#1274) * Add vtoken exchange rate rpc * add the use of Vec * supplement the RPC logic && fix bugs * adjust the RPC exchange rate precision to three decimal places * fix clippy * fix bug: storage migration anomaly (#1276) * SLPx mint support commission id * remove the channel_id parameter from the mint method * add mint_with_channel_id method * perform data migration for OrderQueue storage * slpx: set the default value of channel_id to 0 * resolve conflicts * change the location of the old data structure during storage migration * fix bug: storage migration anomaly * Slp removes refund (#1275) * Slp removes refund * Fix clippy * Allow to receive and send Ethereum assets * Add constants --------- Co-authored-by: yooml Co-authored-by: SunTiebing <1045060705@qq.com> Co-authored-by: SunTiebing <87381708+SunTiebing@users.noreply.github.com> Co-authored-by: Edwin Wang * Disable supplement_fee_reserve (#1306) * Remove call_switchgear and add tx_pause (#1308) * Remove call_switchgear and add tx_pause * Fix clippy * Optimize flexible fee (#1307) * Optimize flexible fee * Fix bug * Fix bug * Add PalletId * Add error handle * feat: 🎸 add market-bond * fix: πŸ› test-all * fix: πŸ› try-runtime * Add the channel_id field to the Minted event * Upgrade to polkadot-v1.13.0 (#1312) * Upgrade to polkadot-v1.13.0 * remove the warning * Fix dep issues * Upgrade to polkadot-v1.13.0 * supplement and upgrade the code * Upgrade the new parts from v0.12.0 * Fix dep issues * format Cargo.toml * Modify the AddOrigin type of the fellowship in bifrost-polkadot * Cancel the cross-in-out migration. * fix clippy --------- Co-authored-by: hqwangningbo <2536935847@qq.com> * Use github dependencies (#1314) * Fix flexible_fee TransferTo (#1315) * Refactor code structure: extract the vote operation from the relaychain. * Refactor code structure: extract the remove_vote operation from the relaychain. * Move the XCM-related methods into the relaychain_agent. * Move the call.rs into the relaychain_agent. * vtokenvoting functionality supports vBNC * Bifrost v0.13.0 * Remove getter in buy-back. (#1354) * Bifrost v0.12.0 * remove old migrations * Fix vtokenVoting.removeDelegatorVote (#1288) * add PollClass type * add the calss parameter to the remove_delegator_vote method * Add metadata hash (#1299) * feat: 🎸 add buy-back * Bifrost v0.10.001 * feat: 🎸 benchmark * SLPx mint support commission id (#1261) * Add vtoken exchange rate rpc (#1260) * fix: πŸ› add event (#1263) * add update_currency_metadata function (#1259) * add update_currency_metadata function * fix: πŸ› correct update_currency_metadata weight * add the use of Vec (#1264) * Add vtoken exchange rate rpc * add the use of Vec * Upgrade to Polkadot-SDK v1.7.0 (#1262) * Bifrost v0.10.0 * fix: πŸ› clippy * Fix chain spec (#1243) * Upgrade to polkadot-v1.7.0 --------- Co-authored-by: SunTiebing <1045060705@qq.com> Co-authored-by: Edwin Wang * Fix compile * feat: 🎸 add metadata-hash-extension (#1265) * feat: 🎸 add metadata-hash-extension * Fix compile (#1266) * Fix/fix vtoken voting unlock (#1267) * update the exchange rate of vtokenminting of vtokenvoting test * Resolve the frozen anomaly when unlocking * Revert "feat: 🎸 add metadata-hash-extension (#1265)" (#1268) This reverts commit 489fc9c6adeae44d23edf449e74fde3d6aa40bc3. * rename the version number to 0.11.0 * Slp supports XCMv4 and reconstruct integration tests (#1272) * Fix compile * Reconstruct integration tests and slp supports XCMv4 * Fix slp construct_xcm_message * Feat/slpx mint add commission (#1273) * SLPx mint support commission id * remove the channel_id parameter from the mint method * add mint_with_channel_id method * perform data migration for OrderQueue storage * slpx: set the default value of channel_id to 0 * resolve conflicts * change the location of the old data structure during storage migration * Feat/add vtoken exchange rate rpc (#1274) * Add vtoken exchange rate rpc * add the use of Vec * supplement the RPC logic && fix bugs * adjust the RPC exchange rate precision to three decimal places * fix clippy * fix bug: storage migration anomaly (#1276) * SLPx mint support commission id * remove the channel_id parameter from the mint method * add mint_with_channel_id method * perform data migration for OrderQueue storage * slpx: set the default value of channel_id to 0 * resolve conflicts * change the location of the old data structure during storage migration * fix bug: storage migration anomaly * Slp removes refund (#1275) * Slp removes refund * Fix clippy * Feat/add vtoken exchange rate rpc (#1277) * Add vtoken exchange rate rpc * add the use of Vec * supplement the RPC logic && fix bugs * adjust the RPC exchange rate precision to three decimal places * fix clippy * supplement omissions: adjust the RPC exchange rate precision to three decimal places * Remove dmp queue (#1279) * fix: πŸ› CheckMetadataHash to false * fix: πŸ› update sp-api * refactor: πŸ’‘ fmt * fix: πŸ› add metadata-hash * fix: πŸ› add feature metadata-hash * fix: πŸ› rm metadata-hash feature --------- Co-authored-by: SunTiebing <1045060705@qq.com> Co-authored-by: SunTiebing <87381708+SunTiebing@users.noreply.github.com> Co-authored-by: NingBo Wang <2536935847@qq.com> Co-authored-by: Edwin Wang * refactor: πŸ’‘ update MaxTurnout and whitelisted_caller track (#1304) * Allow to receive and send Ethereum assets (#1305) * feat: 🎸 add buy-back * Bifrost v0.10.001 * feat: 🎸 benchmark * SLPx mint support commission id (#1261) * Add vtoken exchange rate rpc (#1260) * fix: πŸ› add event (#1263) * add update_currency_metadata function (#1259) * add update_currency_metadata function * fix: πŸ› correct update_currency_metadata weight * add the use of Vec (#1264) * Add vtoken exchange rate rpc * add the use of Vec * Upgrade to Polkadot-SDK v1.7.0 (#1262) * Bifrost v0.10.0 * fix: πŸ› clippy * Fix chain spec (#1243) * Upgrade to polkadot-v1.7.0 --------- Co-authored-by: SunTiebing <1045060705@qq.com> Co-authored-by: Edwin Wang * feat: 🎸 add metadata-hash-extension (#1265) * Fix compile (#1266) * Fix/fix vtoken voting unlock (#1267) * update the exchange rate of vtokenminting of vtokenvoting test * Resolve the frozen anomaly when unlocking * Revert "feat: 🎸 add metadata-hash-extension (#1265)" (#1268) This reverts commit 489fc9c6adeae44d23edf449e74fde3d6aa40bc3. * rename the version number to 0.11.0 * Slp supports XCMv4 and reconstruct integration tests (#1272) * Fix compile * Reconstruct integration tests and slp supports XCMv4 * Fix slp construct_xcm_message * Feat/slpx mint add commission (#1273) * SLPx mint support commission id * remove the channel_id parameter from the mint method * add mint_with_channel_id method * perform data migration for OrderQueue storage * slpx: set the default value of channel_id to 0 * resolve conflicts * change the location of the old data structure during storage migration * Feat/add vtoken exchange rate rpc (#1274) * Add vtoken exchange rate rpc * add the use of Vec * supplement the RPC logic && fix bugs * adjust the RPC exchange rate precision to three decimal places * fix clippy * fix bug: storage migration anomaly (#1276) * SLPx mint support commission id * remove the channel_id parameter from the mint method * add mint_with_channel_id method * perform data migration for OrderQueue storage * slpx: set the default value of channel_id to 0 * resolve conflicts * change the location of the old data structure during storage migration * fix bug: storage migration anomaly * Slp removes refund (#1275) * Slp removes refund * Fix clippy * Allow to receive and send Ethereum assets * Add constants --------- Co-authored-by: yooml Co-authored-by: SunTiebing <1045060705@qq.com> Co-authored-by: SunTiebing <87381708+SunTiebing@users.noreply.github.com> Co-authored-by: Edwin Wang * Disable supplement_fee_reserve (#1306) * Remove call_switchgear and add tx_pause (#1308) * Remove call_switchgear and add tx_pause * Fix clippy * Optimize flexible fee (#1307) * Optimize flexible fee * Fix bug * Fix bug * Add PalletId * Add error handle * feat: 🎸 add market-bond * fix: πŸ› test-all * fix: πŸ› try-runtime * Add the channel_id field to the Minted event * Upgrade to polkadot-v1.13.0 (#1312) * Upgrade to polkadot-v1.13.0 * remove the warning * Fix dep issues * Upgrade to polkadot-v1.13.0 * supplement and upgrade the code * Upgrade the new parts from v0.12.0 * Fix dep issues * format Cargo.toml * Modify the AddOrigin type of the fellowship in bifrost-polkadot * Cancel the cross-in-out migration. * fix clippy --------- Co-authored-by: hqwangningbo <2536935847@qq.com> * Use github dependencies (#1314) * Fix flexible_fee TransferTo (#1315) * Fix generate_genesis_state (#1317) * Optimize oracle (#1318) * refactor: πŸ’‘ optimize orml-oracle * fix: πŸ› MinimumTimestampInterval * style: πŸ’„ rename to MaximumValueInterval * Add some tests for ve-minting * Add some tests for ve-minting * Integrate evm (#1319) * Update dep * Ingrate EVM * Fix deps * Add precompiles.rs * Remove pallet-hotfix-sufficients * Add pallet-evm-accounts * Evm precompiles * EVM integration * Fix compile * Fix rpc * Fix `encode_evm_address` and `decode_evm_address` * Fix evm precompile multicurrency * Implementing Erc20Mapping using xc-20 standard * Compatible with BNC Decimal * Increase min_gas_price * feat: enable dev mode with manual seal & fix pending block problem * Add copyright and fix some bugs * Change native token to WETH * Support evm flexible fee * Add inner_swap_exact_assets_for_assets to evm withdraw fee * Remove swap * EVM migration from bifrost kusama to bifrost polkadot * Fix erc20 precompile * Use OraclePrice * Fix some errors * feat: add prices genesis config & optimize dev mode code * Fix conflicts * Fix some errors * Fix clippy * Format Cargo.toml * Remove unused code * Fix clippy * Fix some errors * Fix erc20 precompile --------- Co-authored-by: Edwin Wang Co-authored-by: Damian.lu * Fix try-runtime (#1323) * Fix manual seal * Fix manual seal (#1324) * fix: πŸ› fellowship collective data (#1325) * fix: add parachain mock inherent data provider * Fix ethereum transfer fee (#1328) * Add evm genesis migration (#1338) * Bifrost v0.12.0 (#1286) * Bifrost v0.12.0 * remove old migrations * Fix vtokenVoting.removeDelegatorVote (#1288) * add PollClass type * add the calss parameter to the remove_delegator_vote method * Add metadata hash (#1299) * feat: 🎸 add buy-back * Bifrost v0.10.001 * feat: 🎸 benchmark * SLPx mint support commission id (#1261) * Add vtoken exchange rate rpc (#1260) * fix: πŸ› add event (#1263) * add update_currency_metadata function (#1259) * add update_currency_metadata function * fix: πŸ› correct update_currency_metadata weight * add the use of Vec (#1264) * Add vtoken exchange rate rpc * add the use of Vec * Upgrade to Polkadot-SDK v1.7.0 (#1262) * Bifrost v0.10.0 * fix: πŸ› clippy * Fix chain spec (#1243) * Upgrade to polkadot-v1.7.0 --------- Co-authored-by: SunTiebing <1045060705@qq.com> Co-authored-by: Edwin Wang * Fix compile * feat: 🎸 add metadata-hash-extension (#1265) * feat: 🎸 add metadata-hash-extension * Fix compile (#1266) * Fix/fix vtoken voting unlock (#1267) * update the exchange rate of vtokenminting of vtokenvoting test * Resolve the frozen anomaly when unlocking * Revert "feat: 🎸 add metadata-hash-extension (#1265)" (#1268) This reverts commit 489fc9c6adeae44d23edf449e74fde3d6aa40bc3. * rename the version number to 0.11.0 * Slp supports XCMv4 and reconstruct integration tests (#1272) * Fix compile * Reconstruct integration tests and slp supports XCMv4 * Fix slp construct_xcm_message * Feat/slpx mint add commission (#1273) * SLPx mint support commission id * remove the channel_id parameter from the mint method * add mint_with_channel_id method * perform data migration for OrderQueue storage * slpx: set the default value of channel_id to 0 * resolve conflicts * change the location of the old data structure during storage migration * Feat/add vtoken exchange rate rpc (#1274) * Add vtoken exchange rate rpc * add the use of Vec * supplement the RPC logic && fix bugs * adjust the RPC exchange rate precision to three decimal places * fix clippy * fix bug: storage migration anomaly (#1276) * SLPx mint support commission id * remove the channel_id parameter from the mint method * add mint_with_channel_id method * perform data migration for OrderQueue storage * slpx: set the default value of channel_id to 0 * resolve conflicts * change the location of the old data structure during storage migration * fix bug: storage migration anomaly * Slp removes refund (#1275) * Slp removes refund * Fix clippy * Feat/add vtoken exchange rate rpc (#1277) * Add vtoken exchange rate rpc * add the use of Vec * supplement the RPC logic && fix bugs * adjust the RPC exchange rate precision to three decimal places * fix clippy * supplement omissions: adjust the RPC exchange rate precision to three decimal places * Remove dmp queue (#1279) * fix: πŸ› CheckMetadataHash to false * fix: πŸ› update sp-api * refactor: πŸ’‘ fmt * fix: πŸ› add metadata-hash * fix: πŸ› add feature metadata-hash * fix: πŸ› rm metadata-hash feature --------- Co-authored-by: SunTiebing <1045060705@qq.com> Co-authored-by: SunTiebing <87381708+SunTiebing@users.noreply.github.com> Co-authored-by: NingBo Wang <2536935847@qq.com> Co-authored-by: Edwin Wang * refactor: πŸ’‘ update MaxTurnout and whitelisted_caller track (#1304) * Allow to receive and send Ethereum assets (#1305) * feat: 🎸 add buy-back * Bifrost v0.10.001 * feat: 🎸 benchmark * SLPx mint support commission id (#1261) * Add vtoken exchange rate rpc (#1260) * fix: πŸ› add event (#1263) * add update_currency_metadata function (#1259) * add update_currency_metadata function * fix: πŸ› correct update_currency_metadata weight * add the use of Vec (#1264) * Add vtoken exchange rate rpc * add the use of Vec * Upgrade to Polkadot-SDK v1.7.0 (#1262) * Bifrost v0.10.0 * fix: πŸ› clippy * Fix chain spec (#1243) * Upgrade to polkadot-v1.7.0 --------- Co-authored-by: SunTiebing <1045060705@qq.com> Co-authored-by: Edwin Wang * feat: 🎸 add metadata-hash-extension (#1265) * Fix compile (#1266) * Fix/fix vtoken voting unlock (#1267) * update the exchange rate of vtokenminting of vtokenvoting test * Resolve the frozen anomaly when unlocking * Revert "feat: 🎸 add metadata-hash-extension (#1265)" (#1268) This reverts commit 489fc9c6adeae44d23edf449e74fde3d6aa40bc3. * rename the version number to 0.11.0 * Slp supports XCMv4 and reconstruct integration tests (#1272) * Fix compile * Reconstruct integration tests and slp supports XCMv4 * Fix slp construct_xcm_message * Feat/slpx mint add commission (#1273) * SLPx mint support commission id * remove the channel_id parameter from the mint method * add mint_with_channel_id method * perform data migration for OrderQueue storage * slpx: set the default value of channel_id to 0 * resolve conflicts * change the location of the old data structure during storage migration * Feat/add vtoken exchange rate rpc (#1274) * Add vtoken exchange rate rpc * add the use of Vec * supplement the RPC logic && fix bugs * adjust the RPC exchange rate precision to three decimal places * fix clippy * fix bug: storage migration anomaly (#1276) * SLPx mint support commission id * remove the channel_id parameter from the mint method * add mint_with_channel_id method * perform data migration for OrderQueue storage * slpx: set the default value of channel_id to 0 * resolve conflicts * change the location of the old data structure during storage migration * fix bug: storage migration anomaly * Slp removes refund (#1275) * Slp removes refund * Fix clippy * Allow to receive and send Ethereum assets * Add constants --------- Co-authored-by: yooml Co-authored-by: SunTiebing <1045060705@qq.com> Co-authored-by: SunTiebing <87381708+SunTiebing@users.noreply.github.com> Co-authored-by: Edwin Wang * Disable supplement_fee_reserve (#1306) * Remove call_switchgear and add tx_pause (#1308) * Remove call_switchgear and add tx_pause * Fix clippy * Optimize flexible fee (#1307) * Optimize flexible fee * Fix bug * Fix bug * Add PalletId * Add error handle * feat: 🎸 add market-bond * fix: πŸ› test-all * fix: πŸ› try-runtime * Add the channel_id field to the Minted event * Upgrade to polkadot-v1.13.0 (#1312) * Upgrade to polkadot-v1.13.0 * remove the warning * Fix dep issues * Upgrade to polkadot-v1.13.0 * supplement and upgrade the code * Upgrade the new parts from v0.12.0 * Fix dep issues * format Cargo.toml * Modify the AddOrigin type of the fellowship in bifrost-polkadot * Cancel the cross-in-out migration. * fix clippy --------- Co-authored-by: hqwangningbo <2536935847@qq.com> * Use github dependencies (#1314) * Fix flexible_fee TransferTo (#1315) * Fix generate_genesis_state (#1317) * Optimize oracle (#1318) * refactor: πŸ’‘ optimize orml-oracle * fix: πŸ› MinimumTimestampInterval * style: πŸ’„ rename to MaximumValueInterval * Add some tests for ve-minting * Add some tests for ve-minting * Integrate evm (#1319) * Update dep * Ingrate EVM * Fix deps * Add precompiles.rs * Remove pallet-hotfix-sufficients * Add pallet-evm-accounts * Evm precompiles * EVM integration * Fix compile * Fix rpc * Fix `encode_evm_address` and `decode_evm_address` * Fix evm precompile multicurrency * Implementing Erc20Mapping using xc-20 standard * Compatible with BNC Decimal * Increase min_gas_price * feat: enable dev mode with manual seal & fix pending block problem * Add copyright and fix some bugs * Change native token to WETH * Support evm flexible fee * Add inner_swap_exact_assets_for_assets to evm withdraw fee * Remove swap * EVM migration from bifrost kusama to bifrost polkadot * Fix erc20 precompile * Use OraclePrice * Fix some errors * feat: add prices genesis config & optimize dev mode code * Fix conflicts * Fix some errors * Fix clippy * Format Cargo.toml * Remove unused code * Fix clippy * Fix some errors * Fix erc20 precompile --------- Co-authored-by: Edwin Wang Co-authored-by: Damian.lu * Fix try-runtime (#1323) * Fix manual seal * Fix manual seal (#1324) * fix: πŸ› fellowship collective data (#1325) * fix: add parachain mock inherent data provider * Fix ethereum transfer fee (#1328) --------- Co-authored-by: Edwin Wang Co-authored-by: yooml Co-authored-by: NingBo Wang <2536935847@qq.com> Co-authored-by: Gemma Co-authored-by: Damian.lu * Add evm genesis storage * [skip ci] Add evmSince --------- Co-authored-by: SunTiebing <87381708+SunTiebing@users.noreply.github.com> Co-authored-by: Edwin Wang Co-authored-by: yooml Co-authored-by: Gemma Co-authored-by: Damian.lu * Bump version to 0.12.1 * Update Cargo.lock * Fix migration (#1341) * Bifrost v0.12.0 (#1286) * Bifrost v0.12.0 * remove old migrations * Fix vtokenVoting.removeDelegatorVote (#1288) * add PollClass type * add the calss parameter to the remove_delegator_vote method * Add metadata hash (#1299) * feat: 🎸 add buy-back * Bifrost v0.10.001 * feat: 🎸 benchmark * SLPx mint support commission id (#1261) * Add vtoken exchange rate rpc (#1260) * fix: πŸ› add event (#1263) * add update_currency_metadata function (#1259) * add update_currency_metadata function * fix: πŸ› correct update_currency_metadata weight * add the use of Vec (#1264) * Add vtoken exchange rate rpc * add the use of Vec * Upgrade to Polkadot-SDK v1.7.0 (#1262) * Bifrost v0.10.0 * fix: πŸ› clippy * Fix chain spec (#1243) * Upgrade to polkadot-v1.7.0 --------- Co-authored-by: SunTiebing <1045060705@qq.com> Co-authored-by: Edwin Wang * Fix compile * feat: 🎸 add metadata-hash-extension (#1265) * feat: 🎸 add metadata-hash-extension * Fix compile (#1266) * Fix/fix vtoken voting unlock (#1267) * update the exchange rate of vtokenminting of vtokenvoting test * Resolve the frozen anomaly when unlocking * Revert "feat: 🎸 add metadata-hash-extension (#1265)" (#1268) This reverts commit 489fc9c6adeae44d23edf449e74fde3d6aa40bc3. * rename the version number to 0.11.0 * Slp supports XCMv4 and reconstruct integration tests (#1272) * Fix compile * Reconstruct integration tests and slp supports XCMv4 * Fix slp construct_xcm_message * Feat/slpx mint add commission (#1273) * SLPx mint support commission id * remove the channel_id parameter from the mint method * add mint_with_channel_id method * perform data migration for OrderQueue storage * slpx: set the default value of channel_id to 0 * resolve conflicts * change the location of the old data structure during storage migration * Feat/add vtoken exchange rate rpc (#1274) * Add vtoken exchange rate rpc * add the use of Vec * supplement the RPC logic && fix bugs * adjust the RPC exchange rate precision to three decimal places * fix clippy * fix bug: storage migration anomaly (#1276) * SLPx mint support commission id * remove the channel_id parameter from the mint method * add mint_with_channel_id method * perform data migration for OrderQueue storage * slpx: set the default value of channel_id to 0 * resolve conflicts * change the location of the old data structure during storage migration * fix bug: storage migration anomaly * Slp removes refund (#1275) * Slp removes refund * Fix clippy * Feat/add vtoken exchange rate rpc (#1277) * Add vtoken exchange rate rpc * add the use of Vec * supplement the RPC logic && fix bugs * adjust the RPC exchange rate precision to three decimal places * fix clippy * supplement omissions: adjust the RPC exchange rate precision to three decimal places * Remove dmp queue (#1279) * fix: πŸ› CheckMetadataHash to false * fix: πŸ› update sp-api * refactor: πŸ’‘ fmt * fix: πŸ› add metadata-hash * fix: πŸ› add feature metadata-hash * fix: πŸ› rm metadata-hash feature --------- Co-authored-by: SunTiebing <1045060705@qq.com> Co-authored-by: SunTiebing <87381708+SunTiebing@users.noreply.github.com> Co-authored-by: NingBo Wang <2536935847@qq.com> Co-authored-by: Edwin Wang * refactor: πŸ’‘ update MaxTurnout and whitelisted_caller track (#1304) * Allow to receive and send Ethereum assets (#1305) * feat: 🎸 add buy-back * Bifrost v0.10.001 * feat: 🎸 benchmark * SLPx mint support commission id (#1261) * Add vtoken exchange rate rpc (#1260) * fix: πŸ› add event (#1263) * add update_currency_metadata function (#1259) * add update_currency_metadata function * fix: πŸ› correct update_currency_metadata weight * add the use of Vec (#1264) * Add vtoken exchange rate rpc * add the use of Vec * Upgrade to Polkadot-SDK v1.7.0 (#1262) * Bifrost v0.10.0 * fix: πŸ› clippy * Fix chain spec (#1243) * Upgrade to polkadot-v1.7.0 --------- Co-authored-by: SunTiebing <1045060705@qq.com> Co-authored-by: Edwin Wang * feat: 🎸 add metadata-hash-extension (#1265) * Fix compile (#1266) * Fix/fix vtoken voting unlock (#1267) * update the exchange rate of vtokenminting of vtokenvoting test * Resolve the frozen anomaly when unlocking * Revert "feat: 🎸 add metadata-hash-extension (#1265)" (#1268) This reverts commit 489fc9c6adeae44d23edf449e74fde3d6aa40bc3. * rename the version number to 0.11.0 * Slp supports XCMv4 and reconstruct integration tests (#1272) * Fix compile * Reconstruct integration tests and slp suppor… * Feat/flexible fee ban vbnc (#1488) * Prohibit setting VBNC as the default fee currency. * Modify code formatting. * Add data migration code. * Add XcmWeightTrader, XcmPaymentApi and DryRunApi #1484 (#1490) * Add XcmWeightTrader, XcmPaymentApi and DryRunApi #1484 * Update lib.rs * feat: change benefit receiving account (#1493) * Preparing for async backing support (#1491) * Preparing for async backing support * Preparing for async backing support(Phase 2) * Increase authoring_duration from 500 milliseconds to 1500 * Add parachain staking (#1494) * feat: 🎸 add buy-back * Bifrost v0.10.001 * feat: 🎸 benchmark * SLPx mint support commission id (#1261) * Add vtoken exchange rate rpc (#1260) * fix: πŸ› add event (#1263) * add update_currency_metadata function (#1259) * add update_currency_metadata function * fix: πŸ› correct update_currency_metadata weight * add the use of Vec (#1264) * Add vtoken exchange rate rpc * add the use of Vec * Upgrade to Polkadot-SDK v1.7.0 (#1262) * Bifrost v0.10.0 * fix: πŸ› clippy * Fix chain spec (#1243) * Upgrade to polkadot-v1.7.0 --------- Co-authored-by: SunTiebing <1045060705@qq.com> Co-authored-by: Edwin Wang * feat: 🎸 add metadata-hash-extension (#1265) * Fix compile (#1266) * Fix/fix vtoken voting unlock (#1267) * update the exchange rate of vtokenminting of vtokenvoting test * Resolve the frozen anomaly when unlocking * feat: 🎸 add parachain-staking * feat: 🎸 add bifrost-polkadot-testnet * refactor: πŸ’‘ rm pallet-collator-selection * fix: πŸ› rm collatorSelection * fix: πŸ› add parachainStaking into chain_spec * fix: πŸ› balances * [skip ci]: remove latest tag * feat: 🎸 add membership * [skip ci]:add chain-spec * [skip ci]Update Dockerfile for testnet * [skip ci] update chain spec * [skip ci] update chain spec * fix clippy * fix code fmt * Fix merge issues: update Dockerfile to use the main network configuration. * add bifrost_parachain_staking InitGenesisMigration * Update parameter configurations and implement data migration. * remove unused files * add latest tag --------- Co-authored-by: yooml Co-authored-by: NingBo Wang <2536935847@qq.com> Co-authored-by: Edwin Wang Co-authored-by: 战η₯žθ₯ΏηΊ’柿 <34213033+TomatoAres@users.noreply.github.com> Co-authored-by: TomatoAres * Migrated benchmarking from v1 to v2 for bb-bnc. (#1495) * Migrated benchmarking from v1 to v2 in bb-bnc. * format changed * format changed * fix: πŸ› notify_rewards (#1496) * fix: πŸ› notify_rewards * fix: πŸ› clippy * fix: πŸ› auto_notify_reward * Feat/flexible fee ban vbnc (#1497) * Prohibit setting VBNC as the default fee currency. * Modify code formatting. * Add data migration code. * flexible-fee: add polkadot migration * Optimize the CallFilter logic. (#1498) * Fix vtoken minting (#1500) * [skip ci] fix: bifrost-polkadot chain-spec (#1499) * [skip ci] fix: bifrost-polkadot chain-spec * Fix bifrost polkadot chain spec --------- Co-authored-by: hqwangningbo <2536935847@qq.com> * Vtoken-voting support vbnc. (#1501) * [skip ci] Update srtool (#1506) * Update srtool * [skip ci] Skip ci * [skip ci] Update release * Update slpx weight (#1507) * Add evm create order * Update Slpx weight * Feat/vtoken voting add vbnc (#1510) * Fix the bug related to the missing Ledger type. * Remove the BNC restriction from the DerivativeAccountTokenFilter. * Change the active logic of Ledger to total minus lesstotal. --------- Co-authored-by: MJLNSN <96321798+MJLNSN@users.noreply.github.com> Co-authored-by: NingBo Wang <2536935847@qq.com> Co-authored-by: Edwin Co-authored-by: yooml Co-authored-by: Damian.lu Co-authored-by: 战η₯žθ₯ΏηΊ’柿 <34213033+TomatoAres@users.noreply.github.com> Co-authored-by: TomatoAres --- .github/workflows/release.yml | 4 +- .github/workflows/srtool.yml | 5 +- Cargo.lock | 25 +- Cargo.toml | 3 +- node/cli/Cargo.toml | 2 +- .../src/chain_spec/bifrost_polkadot.rs | 88 ++- node/service/src/collator_kusama.rs | 33 +- node/service/src/collator_polkadot.rs | 39 +- pallets/asset-registry/src/benchmarking.rs | 139 ++-- pallets/asset-registry/src/lib.rs | 155 +---- pallets/asset-registry/src/mock.rs | 5 + pallets/bb-bnc/src/benchmarking.rs | 426 ++++++++++--- pallets/bb-bnc/src/incentive.rs | 4 +- pallets/bb-bnc/src/lib.rs | 6 +- pallets/bb-bnc/src/mock.rs | 7 +- pallets/bb-bnc/src/tests.rs | 5 +- pallets/bb-bnc/src/traits.rs | 34 +- pallets/bb-bnc/src/weights.rs | 601 ++++++++++-------- pallets/buy-back/src/lib.rs | 3 +- pallets/farming/src/lib.rs | 2 +- pallets/farming/src/mock.rs | 1 + pallets/farming/src/tests.rs | 21 +- pallets/flexible-fee/src/lib.rs | 12 +- pallets/flexible-fee/src/migrations/mod.rs | 3 + pallets/flexible-fee/src/migrations/v3.rs | 148 +++++ pallets/flexible-fee/src/tests.rs | 18 +- pallets/prices/src/lib.rs | 7 +- pallets/slp/src/lib.rs | 8 +- pallets/slpx/src/benchmarking.rs | 17 + pallets/slpx/src/lib.rs | 6 +- pallets/slpx/src/mock.rs | 4 +- pallets/slpx/src/weights.rs | 228 ++----- pallets/system-staking/src/lib.rs | 10 +- pallets/system-staking/src/mock.rs | 7 +- pallets/vtoken-minting/src/impls.rs | 27 +- pallets/vtoken-minting/src/mock.rs | 6 +- pallets/vtoken-voting/src/lib.rs | 2 +- pallets/vtoken-voting/src/tests/mod.rs | 4 +- pallets/xcm-interface/src/lib.rs | 10 +- primitives/src/currency.rs | 8 + primitives/src/traits.rs | 7 +- primitives/src/xcm.rs | 9 +- runtime/bifrost-kusama/Cargo.toml | 4 + runtime/bifrost-kusama/src/lib.rs | 208 ++++-- .../src/weights/bifrost_slpx.rs | 225 ++----- runtime/bifrost-kusama/src/xcm_config.rs | 158 +---- runtime/bifrost-polkadot/Cargo.toml | 12 +- runtime/bifrost-polkadot/src/lib.rs | 242 +++++-- .../src/weights/bifrost_slpx.rs | 225 ++----- runtime/bifrost-polkadot/src/xcm_config.rs | 62 +- runtime/common/Cargo.toml | 1 - runtime/common/src/constants.rs | 9 + runtime/common/src/currency_converter.rs | 6 +- runtime/common/src/lib.rs | 1 + runtime/common/src/xcm_weight_trader.rs | 162 +++++ 55 files changed, 1950 insertions(+), 1514 deletions(-) create mode 100644 pallets/flexible-fee/src/migrations/v3.rs create mode 100644 runtime/common/src/xcm_weight_trader.rs diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index 5e3de645a..461c4486c 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -46,8 +46,8 @@ jobs: make production-release mkdir -p ${{ github.workspace }}/artifacts mv ${{ github.workspace }}/target/production/bifrost ${{ github.workspace }}/artifacts/ - mv ${{ github.workspace }}/artifacts/runtime/bifrost-kusama/target/srtool/release/wbuild/bifrost-kusama-runtime/bifrost_kusama_runtime.compact.compressed.wasm ${{ github.workspace }}/artifacts/ - mv ${{ github.workspace }}/artifacts/runtime/bifrost-polkadot/target/srtool/release/wbuild/bifrost-polkadot-runtime/bifrost_polkadot_runtime.compact.compressed.wasm ${{ github.workspace }}/artifacts/ + mv ${{ github.workspace }}/artifacts/runtime/bifrost-kusama/target/srtool/production/wbuild/bifrost-kusama-runtime/bifrost_kusama_runtime.compact.compressed.wasm ${{ github.workspace }}/artifacts/ + mv ${{ github.workspace }}/artifacts/runtime/bifrost-polkadot/target/srtool/production/wbuild/bifrost-polkadot-runtime/bifrost_polkadot_runtime.compact.compressed.wasm ${{ github.workspace }}/artifacts/ pushd ${{ github.workspace }}/artifacts sha256sum bifrost | tee bifrost.sha256 shasum -c bifrost.sha256 diff --git a/.github/workflows/srtool.yml b/.github/workflows/srtool.yml index 44617bf37..2cdcacfa8 100644 --- a/.github/workflows/srtool.yml +++ b/.github/workflows/srtool.yml @@ -23,12 +23,11 @@ jobs: - name: Srtool build id: srtool_build - uses: chevdor/srtool-actions@v0.9.2 + uses: chevdor/srtool-actions@v0.8.0 env: BUILD_OPTS: "--features on-chain-release-build" - PARACHAIN_PALLET_ID: "0x05" - AUTHORIZE_UPGRADE_PREFIX: "0x02" with: + profile: production chain: ${{ matrix.chain }} runtime_dir: runtime/${{ matrix.chain }} - name: Summary diff --git a/Cargo.lock b/Cargo.lock index 04f18e77b..1a525cb65 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -1025,7 +1025,7 @@ dependencies = [ [[package]] name = "bifrost-cli" -version = "0.14.0" +version = "0.15.0" dependencies = [ "bifrost-primitives", "bifrost-service", @@ -1356,6 +1356,7 @@ dependencies = [ "cumulus-pallet-parachain-system", "cumulus-pallet-xcm", "cumulus-pallet-xcmp-queue", + "cumulus-primitives-aura", "cumulus-primitives-core", "cumulus-primitives-timestamp", "cumulus-primitives-utility", @@ -1443,6 +1444,7 @@ dependencies = [ "strum 0.26.3", "strum_macros 0.26.4", "substrate-wasm-builder", + "xcm-fee-payment-runtime-api", "zenlink-protocol", "zenlink-protocol-runtime-api", "zenlink-stable-amm", @@ -1491,6 +1493,7 @@ dependencies = [ "bifrost-fee-share", "bifrost-flexible-fee", "bifrost-flexible-fee-rpc-runtime-api", + "bifrost-parachain-staking", "bifrost-primitives", "bifrost-runtime-common", "bifrost-salp", @@ -1513,6 +1516,7 @@ dependencies = [ "cumulus-pallet-parachain-system", "cumulus-pallet-xcm", "cumulus-pallet-xcmp-queue", + "cumulus-primitives-aura", "cumulus-primitives-core", "cumulus-primitives-timestamp", "cumulus-primitives-utility", @@ -1551,7 +1555,6 @@ dependencies = [ "pallet-balances", "pallet-base-fee", "pallet-bounties", - "pallet-collator-selection", "pallet-collective", "pallet-conviction-voting", "pallet-democracy", @@ -1624,6 +1627,7 @@ dependencies = [ "strum 0.26.3", "strum_macros 0.26.4", "substrate-wasm-builder", + "xcm-fee-payment-runtime-api", "zenlink-protocol", "zenlink-protocol-runtime-api", ] @@ -1731,7 +1735,6 @@ dependencies = [ "orml-tokens", "orml-traits", "orml-xcm-support", - "pallet-collator-selection", "pallet-collective", "pallet-democracy", "pallet-membership", @@ -3962,9 +3965,9 @@ dependencies = [ [[package]] name = "cxx" -version = "1.0.124" +version = "1.0.106" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "273dcfd3acd4e1e276af13ed2a43eea7001318823e7a726a6b3ed39b4acc0b82" +checksum = "28403c86fc49e3401fdf45499ba37fad6493d9329449d6449d7f0e10f4654d28" dependencies = [ "cc", "cxxbridge-flags", @@ -3974,9 +3977,9 @@ dependencies = [ [[package]] name = "cxx-build" -version = "1.0.124" +version = "1.0.106" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d8b2766fbd92be34e9ed143898fce6c572dc009de39506ed6903e5a05b68914e" +checksum = "78da94fef01786dc3e0c76eafcd187abcaa9972c78e05ff4041e24fdf059c285" dependencies = [ "cc", "codespan-reporting", @@ -3989,15 +3992,15 @@ dependencies = [ [[package]] name = "cxxbridge-flags" -version = "1.0.124" +version = "1.0.106" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "839fcd5e43464614ffaa989eaf1c139ef1f0c51672a1ed08023307fa1b909ccd" +checksum = "e2a6f5e1dfb4b34292ad4ea1facbfdaa1824705b231610087b00b17008641809" [[package]] name = "cxxbridge-macro" -version = "1.0.124" +version = "1.0.106" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4b2c1c1776b986979be68bb2285da855f8d8a35851a769fca8740df7c3d07877" +checksum = "50c49547d73ba8dcfd4ad7325d64c6d5391ff4224d498fc39a6f3f49825a530d" dependencies = [ "proc-macro2", "quote", diff --git a/Cargo.toml b/Cargo.toml index d5a5891c1..ac5429758 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -159,6 +159,7 @@ cumulus-pallet-aura-ext = { git = "https://github.com/parityt cumulus-pallet-parachain-system = { git = "https://github.com/paritytech/polkadot-sdk", branch = "release-polkadot-v1.13.0", default-features = false } cumulus-pallet-xcm = { git = "https://github.com/paritytech/polkadot-sdk", branch = "release-polkadot-v1.13.0", default-features = false } cumulus-pallet-xcmp-queue = { git = "https://github.com/paritytech/polkadot-sdk", branch = "release-polkadot-v1.13.0", default-features = false } +cumulus-primitives-aura = { git = "https://github.com/paritytech/polkadot-sdk", branch = "release-polkadot-v1.13.0", default-features = false } cumulus-primitives-core = { git = "https://github.com/paritytech/polkadot-sdk", branch = "release-polkadot-v1.13.0", default-features = false } cumulus-primitives-parachain-inherent = { git = "https://github.com/paritytech/polkadot-sdk", branch = "release-polkadot-v1.13.0", default-features = false } cumulus-primitives-timestamp = { git = "https://github.com/paritytech/polkadot-sdk", branch = "release-polkadot-v1.13.0", default-features = false } @@ -179,7 +180,6 @@ pallet-authority-discovery = { git = "https://github.com/parityt pallet-authorship = { git = "https://github.com/paritytech/polkadot-sdk", branch = "release-polkadot-v1.13.0", default-features = false } pallet-balances = { git = "https://github.com/paritytech/polkadot-sdk", branch = "release-polkadot-v1.13.0", default-features = false } pallet-bounties = { git = "https://github.com/paritytech/polkadot-sdk", branch = "release-polkadot-v1.13.0", default-features = false } -pallet-collator-selection = { git = "https://github.com/paritytech/polkadot-sdk", branch = "release-polkadot-v1.13.0", default-features = false } pallet-collective = { git = "https://github.com/paritytech/polkadot-sdk", branch = "release-polkadot-v1.13.0", default-features = false } pallet-conviction-voting = { git = "https://github.com/paritytech/polkadot-sdk", branch = "release-polkadot-v1.13.0", default-features = false } pallet-democracy = { git = "https://github.com/paritytech/polkadot-sdk", branch = "release-polkadot-v1.13.0", default-features = false } @@ -253,6 +253,7 @@ substrate-fixed = { git = "https://github.com/encoint xcm = { git = "https://github.com/paritytech/polkadot-sdk", branch = "release-polkadot-v1.13.0", package = "staging-xcm", default-features = false } xcm-builder = { git = "https://github.com/paritytech/polkadot-sdk", branch = "release-polkadot-v1.13.0", package = "staging-xcm-builder", default-features = false } xcm-executor = { git = "https://github.com/paritytech/polkadot-sdk", branch = "release-polkadot-v1.13.0", package = "staging-xcm-executor", default-features = false } +xcm-fee-payment-runtime-api = { git = "https://github.com/paritytech/polkadot-sdk", branch = "release-polkadot-v1.13.0", default-features = false } # polkadot-sdk (client) cumulus-client-cli = { git = "https://github.com/paritytech/polkadot-sdk", branch = "release-polkadot-v1.13.0" } diff --git a/node/cli/Cargo.toml b/node/cli/Cargo.toml index 11b753212..8411d2a18 100644 --- a/node/cli/Cargo.toml +++ b/node/cli/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "bifrost-cli" -version = "0.14.0" +version = "0.15.0" authors = ["Liebi Technologies "] description = "Bifrost Parachain Node" build = "build.rs" diff --git a/node/service/src/chain_spec/bifrost_polkadot.rs b/node/service/src/chain_spec/bifrost_polkadot.rs index b52070fe5..2a0d91f38 100644 --- a/node/service/src/chain_spec/bifrost_polkadot.rs +++ b/node/service/src/chain_spec/bifrost_polkadot.rs @@ -17,6 +17,8 @@ // along with this program. If not, see . use crate::chain_spec::{get_account_id_from_seed, get_from_seed, RelayExtensions}; +use bifrost_kusama_runtime::constants::currency::Perbill; +use bifrost_parachain_staking::{InflationInfo, Range}; use bifrost_polkadot_runtime::{ constants::currency::DOLLARS, AccountId, Balance, BlockNumber, SS58Prefix, }; @@ -26,7 +28,7 @@ use bifrost_primitives::{ CurrencyId::*, TokenInfo, TokenSymbol, ASTR, BNC, DOT, DOT_TOKEN_ID, DOT_U, FIL, GLMR, MANTA, }; -use bifrost_runtime_common::AuraId; +use bifrost_runtime_common::{constants::time::HOURS, AuraId}; use cumulus_primitives_core::ParaId; use fp_evm::GenesisAccount; use frame_benchmarking::{account, whitelisted_caller}; @@ -34,7 +36,7 @@ use hex_literal::hex; use sc_chain_spec::Properties; use sc_service::ChainType; use sp_core::{crypto::UncheckedInto, sr25519, H160, U256}; -use sp_runtime::FixedU128; +use sp_runtime::{FixedU128, Percent}; use std::{collections::BTreeMap, str::FromStr}; const DEFAULT_PROTOCOL_ID: &str = "bifrost_polkadot"; @@ -47,6 +49,35 @@ pub fn ENDOWMENT() -> u128 { 1_000_000 * DOLLARS } +const COLLATOR_COMMISSION: Perbill = Perbill::from_percent(10); +const PARACHAIN_BOND_RESERVE_PERCENT: Percent = Percent::from_percent(0); +const BLOCKS_PER_ROUND: u32 = 2 * HOURS; + +pub fn inflation_config() -> InflationInfo { + fn to_round_inflation(annual: Range) -> Range { + use bifrost_parachain_staking::inflation::{ + perbill_annual_to_perbill_round, BLOCKS_PER_YEAR, + }; + perbill_annual_to_perbill_round( + annual, + // rounds per year + BLOCKS_PER_YEAR / BLOCKS_PER_ROUND, + ) + } + let annual = Range { + min: Perbill::from_percent(4), + ideal: Perbill::from_percent(5), + max: Perbill::from_percent(5), + }; + InflationInfo { + // staking expectations + expect: Range { min: 100_000 * DOLLARS, ideal: 200_000 * DOLLARS, max: 500_000 * DOLLARS }, + // annual inflation + annual, + round: to_round_inflation(annual), + } +} + fn bifrost_polkadot_properties() -> Properties { let mut properties = sc_chain_spec::Properties::new(); let mut token_symbol: Vec = vec![]; @@ -69,7 +100,8 @@ fn bifrost_polkadot_properties() -> Properties { } pub fn bifrost_polkadot_genesis( - invulnerables: Vec<(AccountId, AuraId)>, + candidates: Vec<(AccountId, AuraId, Balance)>, + delegations: Vec<(AccountId, AccountId, Balance)>, balances: Vec<(AccountId, Balance)>, vestings: Vec<(AccountId, BlockNumber, BlockNumber, Balance)>, id: ParaId, @@ -101,15 +133,11 @@ pub fn bifrost_polkadot_genesis( "parachainInfo": { "parachainId": id }, - "collatorSelection": { - "invulnerables": invulnerables.iter().cloned().map(|(acc, _)| acc).collect::>(), - "candidacyBond": 0 - }, "session": { - "keys": invulnerables + "keys": candidates .iter() .cloned() - .map(|(acc, aura)| { + .map(|(acc, aura, _)| { ( acc.clone(), // account id acc, // validator id @@ -141,6 +169,18 @@ pub fn bifrost_polkadot_genesis( // EVM compatibility "evmChainId": { "chainId": 996u64 }, "dynamicFee": { "minGasPrice": U256::from(560174200u64) }, + "parachainStaking": { + "candidates": candidates + .iter() + .cloned() + .map(|(account, _, bond)| (account, bond)) + .collect::>(), + "delegations": delegations, + "inflationConfig": inflation_config(), + "collatorCommission": COLLATOR_COMMISSION, + "parachainBondReservePercent": PARACHAIN_BOND_RESERVE_PERCENT, + "blocksPerRound": BLOCKS_PER_ROUND, + }, "evm": { "accounts": evm_accounts }, }) } @@ -239,9 +279,15 @@ pub fn local_testnet_config() -> ChainSpec { ( get_account_id_from_seed::("Alice"), get_from_seed::("Alice"), + ENDOWMENT() / 4, + ), + ( + get_account_id_from_seed::("Bob"), + get_from_seed::("Bob"), + ENDOWMENT() / 4, ), - (get_account_id_from_seed::("Bob"), get_from_seed::("Bob")), ], + vec![], balances, vec![], BifrostPolkadotChainId::get().into(), @@ -352,9 +398,15 @@ pub fn dev_config() -> ChainSpec { ( get_account_id_from_seed::("Alice"), get_from_seed::("Alice"), + ENDOWMENT() / 4, + ), + ( + get_account_id_from_seed::("Bob"), + get_from_seed::("Bob"), + ENDOWMENT() / 4, ), - (get_account_id_from_seed::("Bob"), get_from_seed::("Bob")), ], + vec![], balances, vec![], BifrostPolkadotChainId::get().into(), @@ -372,30 +424,34 @@ pub fn dev_config() -> ChainSpec { } pub fn paseo_config() -> ChainSpec { - let invulnerables: Vec<(AccountId, AuraId)> = vec![ + let invulnerables: Vec<(AccountId, AuraId, Balance)> = vec![ ( // e2s2dTSWe9kHebF2FCbPGbXftDT7fY5AMDfib3j86zSi3v7 hex!["66204aeda74f07f77a4b6945681296763706f98d0f8aebb1b9ccdf6e9b7ac13f"].into(), hex!["66204aeda74f07f77a4b6945681296763706f98d0f8aebb1b9ccdf6e9b7ac13f"] .unchecked_into(), + ENDOWMENT(), ), ( // fFjUFbokagaDRQUDzVhDcMZQaDwQvvha74RMZnyoSWNpiBQ hex!["9c2d45edb30d4bf0c285d6809e28c55e871f10578c5a3ea62da152d03761d266"].into(), hex!["9c2d45edb30d4bf0c285d6809e28c55e871f10578c5a3ea62da152d03761d266"] .unchecked_into(), + ENDOWMENT(), ), ( // fBAbVJAsbWsKTedTVYGrBB3Usm6Vx635z1N9PX2tZ2boT37 hex!["98b19fa5a3e98f693b7440de07b4744834ff0072cb704f1c6e33791953ac4924"].into(), hex!["98b19fa5a3e98f693b7440de07b4744834ff0072cb704f1c6e33791953ac4924"] .unchecked_into(), + ENDOWMENT(), ), ( // c9eHvgbxTFzijvY3AnAKiRTHhi2hzS5SLCPzCkb4jP79MLu hex!["12d3ab675d6503279133898efe246a63fdc8be685cc3f7bce079aac064108a7a"].into(), hex!["12d3ab675d6503279133898efe246a63fdc8be685cc3f7bce079aac064108a7a"] .unchecked_into(), + ENDOWMENT(), ), ]; @@ -442,6 +498,7 @@ pub fn paseo_config() -> ChainSpec { .with_chain_type(ChainType::Live) .with_genesis_config_patch(bifrost_polkadot_genesis( invulnerables, + vec![], balances, vec![], BifrostPolkadotChainId::get().into(), @@ -458,30 +515,34 @@ pub fn paseo_config() -> ChainSpec { .build() } pub fn chainspec_config() -> ChainSpec { - let invulnerables: Vec<(AccountId, AuraId)> = vec![ + let invulnerables: Vec<(AccountId, AuraId, Balance)> = vec![ ( // dpEZwz5nHxEjQXcm3sjy6NTz83EGcBRXMBSyuuWSguiVGJB hex!["5c7e9ccd1045cac7f8c5c77a79c87f44019d1dda4f5032713bda89c5d73cb36b"].into(), hex!["5c7e9ccd1045cac7f8c5c77a79c87f44019d1dda4f5032713bda89c5d73cb36b"] .unchecked_into(), + ENDOWMENT(), ), ( // duNwrtscWpfuTzRkjtt431kUj1gsfwbPi1bzdQL4cmk9QAa hex!["606b0aad375ae1715fbe6a07315136a8e9c1c84a91230f6a0c296c2953581335"].into(), hex!["606b0aad375ae1715fbe6a07315136a8e9c1c84a91230f6a0c296c2953581335"] .unchecked_into(), + ENDOWMENT(), ), ( // gPQG97HPe54fJpLoFePwm3fxdJaU2VV71hYbqd4RJcNeQfe hex!["ce42cea2dd0d4ac87ccdd5f0f2e1010955467f5a37587cf6af8ee2b4ba781034"].into(), hex!["ce42cea2dd0d4ac87ccdd5f0f2e1010955467f5a37587cf6af8ee2b4ba781034"] .unchecked_into(), + ENDOWMENT(), ), ( // frYfsZhdVuG6Ap6AyJQLSHVqtKmUyqxo6ohnrmGTDk2neXK hex!["b6ba81e73bd39203e006fc99cc1e41976745de2ea2007bf62ed7c9a48ccc5b1d"].into(), hex!["b6ba81e73bd39203e006fc99cc1e41976745de2ea2007bf62ed7c9a48ccc5b1d"] .unchecked_into(), + ENDOWMENT(), ), ]; @@ -503,6 +564,7 @@ pub fn chainspec_config() -> ChainSpec { invulnerables, vec![], vec![], + vec![], BifrostPolkadotChainId::get().into(), vec![], vec![], diff --git a/node/service/src/collator_kusama.rs b/node/service/src/collator_kusama.rs index 2d2e41cb3..17fbc8f42 100644 --- a/node/service/src/collator_kusama.rs +++ b/node/service/src/collator_kusama.rs @@ -19,25 +19,24 @@ //! Service implementation. Specialized wrapper over substrate service. use std::{sync::Arc, time::Duration}; +use crate::eth::EthConfiguration; #[cfg(any(feature = "with-bifrost-kusama-runtime", feature = "with-bifrost-runtime"))] pub use bifrost_kusama_runtime; use bifrost_kusama_runtime::RuntimeApi; +use bifrost_primitives::Block; use cumulus_client_cli::CollatorOptions; use cumulus_client_collator::service::CollatorService; -use cumulus_client_consensus_aura::collators::basic::{ - self as basic_aura, Params as BasicAuraParams, -}; - +use cumulus_client_consensus_aura::collators::lookahead::{self as aura, Params as AuraParams}; use cumulus_client_consensus_common::ParachainBlockImport as TParachainBlockImport; use cumulus_client_consensus_proposer::Proposer; - -use crate::eth::EthConfiguration; -use bifrost_primitives::Block; use cumulus_client_service::{ build_network, build_relay_chain_interface, prepare_node_config, start_relay_chain_tasks, BuildNetworkParams, CollatorSybilResistance, DARecoveryProfile, StartRelayChainTasksParams, }; -use cumulus_primitives_core::{relay_chain::Hash, ParaId}; +use cumulus_primitives_core::{ + relay_chain::{Hash, ValidationCode}, + ParaId, +}; use cumulus_relay_chain_interface::{OverseerHandle, RelayChainInterface}; use polkadot_primitives::CollatorPair; use sc_client_api::backend::Backend; @@ -199,6 +198,7 @@ fn build_import_queue( fn start_consensus( client: Arc, + backend: Arc, block_import: ParachainBlockImport, prometheus_registry: Option<&Registry>, telemetry: Option, @@ -230,11 +230,15 @@ fn start_consensus( client.clone(), ); - let params = BasicAuraParams { + let params = AuraParams { create_inherent_data_providers: move |_, ()| async move { Ok(()) }, block_import, - para_client: client, + para_client: client.clone(), + para_backend: backend.clone(), relay_client: relay_chain_interface, + code_hash_provider: move |block_hash| { + client.code_at(block_hash).ok().map(|c| ValidationCode::from(c).hash()) + }, sync_oracle, keystore, collator_key, @@ -244,12 +248,12 @@ fn start_consensus( proposer, collator_service, // Very limited proposal time. - authoring_duration: Duration::from_millis(500), - collation_request_receiver: None, + authoring_duration: Duration::from_millis(1500), + reinitialize: false, }; let fut = - basic_aura::run::( + aura::run::( params, ); task_manager.spawn_essential_handle().spawn("aura", None, fut); @@ -359,7 +363,7 @@ where task_manager: &mut task_manager, config: parachain_config, keystore: params.keystore_container.keystore(), - backend, + backend: backend.clone(), network: network.clone(), sync_service: sync_service.clone(), system_rpc_tx, @@ -411,6 +415,7 @@ where if validator { start_consensus( client.clone(), + backend.clone(), block_import, prometheus_registry.as_ref(), telemetry.as_ref().map(|t| t.handle()), diff --git a/node/service/src/collator_polkadot.rs b/node/service/src/collator_polkadot.rs index e1ec7e028..188c050f0 100644 --- a/node/service/src/collator_polkadot.rs +++ b/node/service/src/collator_polkadot.rs @@ -23,25 +23,28 @@ use std::{ time::Duration, }; +use crate::{ + chain_spec, eth, + eth::{EthConfiguration, FrontierBackend}, + IdentifyVariant, +}; #[cfg(any(feature = "with-bifrost-polkadot-runtime", feature = "with-bifrost-runtime"))] pub use bifrost_polkadot_runtime; use bifrost_polkadot_runtime::{RuntimeApi, TransactionConverter}; +use bifrost_primitives::Block; use cumulus_client_cli::CollatorOptions; use cumulus_client_collator::service::CollatorService; -use cumulus_client_consensus_aura::collators::basic::{ - self as basic_aura, Params as BasicAuraParams, -}; - +use cumulus_client_consensus_aura::collators::lookahead::{self as aura, Params as AuraParams}; use cumulus_client_consensus_common::ParachainBlockImport as TParachainBlockImport; use cumulus_client_consensus_proposer::Proposer; - -use crate::{chain_spec, eth, IdentifyVariant}; -use bifrost_primitives::Block; use cumulus_client_service::{ build_network, build_relay_chain_interface, prepare_node_config, start_relay_chain_tasks, BuildNetworkParams, CollatorSybilResistance, DARecoveryProfile, StartRelayChainTasksParams, }; -use cumulus_primitives_core::{relay_chain::Hash, ParaId}; +use cumulus_primitives_core::{ + relay_chain::{Hash, ValidationCode}, + ParaId, +}; use cumulus_relay_chain_interface::{OverseerHandle, RelayChainInterface}; use fc_rpc_core::types::{FeeHistoryCache, FilterPool}; use fc_storage::StorageOverrideHandler; @@ -57,8 +60,6 @@ use sc_transaction_pool_api::OffchainTransactionPoolFactory; use sp_keystore::KeystorePtr; use substrate_prometheus_endpoint::Registry; -use crate::eth::{EthConfiguration, FrontierBackend}; - #[cfg(not(feature = "runtime-benchmarks"))] type HostFunctions = cumulus_client_service::ParachainHostFunctions; @@ -239,6 +240,7 @@ fn build_import_queue( fn start_consensus( client: Arc, + backend: Arc, block_import: eth::BlockImport, prometheus_registry: Option<&Registry>, telemetry: Option, @@ -270,11 +272,15 @@ fn start_consensus( client.clone(), ); - let params = BasicAuraParams { + let params = AuraParams { create_inherent_data_providers: move |_, ()| async move { Ok(()) }, block_import, - para_client: client, + para_client: client.clone(), + para_backend: backend.clone(), relay_client: relay_chain_interface, + code_hash_provider: move |block_hash| { + client.code_at(block_hash).ok().map(|c| ValidationCode::from(c).hash()) + }, sync_oracle, keystore, collator_key, @@ -284,12 +290,12 @@ fn start_consensus( proposer, collator_service, // Very limited proposal time. - authoring_duration: Duration::from_millis(500), - collation_request_receiver: None, + authoring_duration: Duration::from_millis(1500), + reinitialize: false, }; let fut = - basic_aura::run::( + aura::run::( params, ); task_manager.spawn_essential_handle().spawn("aura", None, fut); @@ -473,7 +479,7 @@ where eth::spawn_frontier_tasks( &task_manager, client.clone(), - backend, + backend.clone(), frontier_backend, filter_pool, storage_override, @@ -527,6 +533,7 @@ where if validator { start_consensus( client.clone(), + backend.clone(), block_import, prometheus_registry.as_ref(), telemetry.as_ref().map(|t| t.handle()), diff --git a/pallets/asset-registry/src/benchmarking.rs b/pallets/asset-registry/src/benchmarking.rs index 5c5555516..87eed10a7 100644 --- a/pallets/asset-registry/src/benchmarking.rs +++ b/pallets/asset-registry/src/benchmarking.rs @@ -21,13 +21,18 @@ use super::*; use crate::Pallet as AssetRegistry; use bifrost_primitives::CurrencyId; -use frame_benchmarking::{benchmarks, v1::BenchmarkError}; +use frame_benchmarking::v2::*; use frame_support::{assert_ok, traits::UnfilteredDispatchable}; use sp_runtime::traits::UniqueSaturatedFrom; -benchmarks! { - register_token_metadata { - let origin = T::RegisterOrigin::try_successful_origin().map_err(|_| BenchmarkError::Weightless)?; +#[benchmarks] +mod benchmarks { + use super::*; + + #[benchmark] + fn register_token_metadata() -> Result<(), BenchmarkError> { + let origin = + T::RegisterOrigin::try_successful_origin().map_err(|_| BenchmarkError::Weightless)?; let metadata = AssetMetadata { name: b"Bifrost Native Coin".to_vec(), symbol: b"BNC".to_vec(), @@ -35,16 +40,21 @@ benchmarks! { minimal_balance: BalanceOf::::unique_saturated_from(0u128), }; - let call = Call::::register_token_metadata { - metadata: Box::new(metadata.clone()) - }; - }: {call.dispatch_bypass_filter(origin)?} - verify { - assert_eq!(CurrencyMetadatas::::get(Token2(0)), Some(metadata.clone())) + let call = Call::::register_token_metadata { metadata: Box::new(metadata.clone()) }; + + #[block] + { + call.dispatch_bypass_filter(origin)?; + } + + assert_eq!(CurrencyMetadatas::::get(Token2(0)), Some(metadata.clone())); + Ok(()) } - register_vtoken_metadata { - let origin = T::RegisterOrigin::try_successful_origin().map_err(|_| BenchmarkError::Weightless)?; + #[benchmark] + fn register_vtoken_metadata() -> Result<(), BenchmarkError> { + let origin = + T::RegisterOrigin::try_successful_origin().map_err(|_| BenchmarkError::Weightless)?; let metadata = AssetMetadata { name: b"Bifrost Native Coin".to_vec(), symbol: b"BNC".to_vec(), @@ -62,27 +72,28 @@ benchmarks! { Box::new(metadata.clone()) )); - let call = Call::::register_vtoken_metadata { - token_id: 0 - }; - }: {call.dispatch_bypass_filter(origin)?} - verify { - assert_eq!( - CurrencyMetadatas::::get(CurrencyId::VToken2(0)), - Some(v_metadata.clone()) - ) + let call = Call::::register_vtoken_metadata { token_id: 0 }; + + #[block] + { + call.dispatch_bypass_filter(origin)?; + } + + assert_eq!(CurrencyMetadatas::::get(CurrencyId::VToken2(0)), Some(v_metadata.clone())); + Ok(()) } - register_location { - let origin = T::RegisterOrigin::try_successful_origin().map_err(|_| BenchmarkError::Weightless)?; + #[benchmark] + fn register_location() -> Result<(), BenchmarkError> { + let origin = + T::RegisterOrigin::try_successful_origin().map_err(|_| BenchmarkError::Weightless)?; let metadata = AssetMetadata { name: b"Bifrost Native Coin".to_vec(), symbol: b"BNC".to_vec(), decimals: 12, minimal_balance: BalanceOf::::unique_saturated_from(0u128), }; - let versioned_location = VersionedLocation::V4(Location::new(1, [Parachain(2001)])); - + let versioned_location = VersionedLocation::V4(Location::new(1, [Parachain(2001)])); let location: xcm::v4::Location = versioned_location.clone().try_into().unwrap(); assert_ok!(AssetRegistry::::register_token_metadata( @@ -92,24 +103,28 @@ benchmarks! { let call = Call::::register_location { currency_id: Token2(0), - location:Box::new(versioned_location.clone()), - weight:Weight::from_parts(2000_000_000, u64::MAX), + location: Box::new(versioned_location.clone()), + weight: Weight::from_parts(2000_000_000, u64::MAX), }; - }: {call.dispatch_bypass_filter(origin)?} - verify { - assert_eq!( - LocationToCurrencyIds::::get(location.clone()), - Some(Token2(0)) - ); + + #[block] + { + call.dispatch_bypass_filter(origin)?; + } + + assert_eq!(LocationToCurrencyIds::::get(location.clone()), Some(Token2(0))); + assert_eq!(CurrencyIdToLocations::::get(Token2(0)), Some(location)); assert_eq!( - CurrencyIdToLocations::::get(Token2(0)), - Some(location) + CurrencyIdToWeights::::get(Token2(0)), + Some(Weight::from_parts(2000_000_000, u64::MAX)) ); - assert_eq!(CurrencyIdToWeights::::get(Token2(0)), Some(Weight::from_parts(2000_000_000, u64::MAX))); + Ok(()) } - force_set_location { - let origin = T::RegisterOrigin::try_successful_origin().map_err(|_| BenchmarkError::Weightless)?; + #[benchmark] + fn force_set_location() -> Result<(), BenchmarkError> { + let origin = + T::RegisterOrigin::try_successful_origin().map_err(|_| BenchmarkError::Weightless)?; let metadata = AssetMetadata { name: b"Bifrost Native Coin".to_vec(), symbol: b"BNC".to_vec(), @@ -118,8 +133,6 @@ benchmarks! { }; let versioned_location = VersionedLocation::V4(Location::new(1, [Parachain(2001)])); - let location: xcm::v3::Location = versioned_location.clone().try_into().unwrap(); - assert_ok!(AssetRegistry::::register_token_metadata( origin.clone(), Box::new(metadata.clone()) @@ -127,13 +140,22 @@ benchmarks! { let call = Call::::force_set_location { currency_id: Token2(0), - location:Box::new(versioned_location.clone()), - weight:Weight::from_parts(2000_000_000, u64::MAX), + location: Box::new(versioned_location.clone()), + weight: Weight::from_parts(2000_000_000, u64::MAX), }; - }: {call.dispatch_bypass_filter(origin)?} - update_currency_metadata { - let origin = T::RegisterOrigin::try_successful_origin().map_err(|_| BenchmarkError::Weightless)?; + #[block] + { + call.dispatch_bypass_filter(origin)?; + } + + Ok(()) + } + + #[benchmark] + fn update_currency_metadata() -> Result<(), BenchmarkError> { + let origin = + T::RegisterOrigin::try_successful_origin().map_err(|_| BenchmarkError::Weightless)?; assert_ok!(AssetRegistry::::register_token_metadata( origin.clone(), @@ -149,12 +171,15 @@ benchmarks! { currency_id: CurrencyId::Token2(0), asset_name: Some(b"Token Name".to_vec()), asset_symbol: Some(b"TN".to_vec()), - asset_decimals : Some(12), - asset_minimal_balance : Some(BalanceOf::::unique_saturated_from(1000u128)), + asset_decimals: Some(12), + asset_minimal_balance: Some(BalanceOf::::unique_saturated_from(1000u128)), }; - }: {call.dispatch_bypass_filter(origin)?} - verify { + #[block] + { + call.dispatch_bypass_filter(origin)?; + } + assert_eq!( CurrencyMetadatas::::get(CurrencyId::Token2(0)), Some(AssetMetadata { @@ -164,12 +189,16 @@ benchmarks! { minimal_balance: BalanceOf::::unique_saturated_from(1000u128), }) ); + Ok(()) } - impl_benchmark_test_suite!( - AssetRegistry, - crate::mock::ExtBuilder::default().build(), - crate::mock::Runtime -); - + // This line generates test cases for benchmarking, and could be run by: + // `cargo test -p pallet-example-basic --all-features`, you will see one line per case: + // `test benchmarking::bench_sort_vector ... ok` + // `test benchmarking::bench_accumulate_dummy ... ok` + // `test benchmarking::bench_set_dummy_benchmark ... ok` in the result. + // + // The line generates three steps per benchmark, with repeat=1 and the three steps are + // [low, mid, high] of the range. + impl_benchmark_test_suite!(Pallet, crate::mock::new_test_ext_benchmark(), crate::mock::Runtime); } diff --git a/pallets/asset-registry/src/lib.rs b/pallets/asset-registry/src/lib.rs index edf1ca0e4..63e760815 100644 --- a/pallets/asset-registry/src/lib.rs +++ b/pallets/asset-registry/src/lib.rs @@ -33,23 +33,19 @@ use frame_support::{ ensure, pallet_prelude::*, traits::{Currency, EnsureOrigin}, - weights::{constants::WEIGHT_REF_TIME_PER_SECOND, Weight}, + weights::Weight, }; use frame_system::pallet_prelude::*; use scale_info::{prelude::string::String, TypeInfo}; use sp_runtime::{ traits::{One, UniqueSaturatedFrom}, - ArithmeticError, FixedPointNumber, FixedU128, RuntimeDebug, + ArithmeticError, RuntimeDebug, }; use sp_std::{boxed::Box, vec::Vec}; use xcm::{ - opaque::lts::XcmContext, - v3::MultiLocation, - v4::{prelude::*, Asset, Location}, + v4::{prelude::*, Location}, VersionedLocation, }; -use xcm_builder::TakeRevenue; -use xcm_executor::{traits::WeightTrader, AssetsInHolding}; pub mod migrations; mod mock; @@ -423,13 +419,15 @@ impl Pallet { Ok(()) } + + pub fn asset_ids() -> Vec { + LocationToCurrencyIds::::iter_keys().map(|key| AssetId(key)).collect() + } } -pub struct AssetIdMaps(sp_std::marker::PhantomData); +pub struct AssetIdMaps(PhantomData); -impl CurrencyIdMapping>> - for AssetIdMaps -{ +impl CurrencyIdMapping>> for AssetIdMaps { fn get_asset_metadata(asset_ids: AssetIds) -> Option>> { AssetMetadatas::::get(asset_ids) } @@ -442,13 +440,12 @@ impl CurrencyIdMapping::iter_keys().collect() } - fn get_location(currency_id: CurrencyId) -> Option { - CurrencyIdToLocations::::get(currency_id).map(|location| location.try_into().ok())? + fn get_location(currency_id: &CurrencyId) -> Option { + CurrencyIdToLocations::::get(currency_id) } - fn get_currency_id(multi_location: Location) -> Option { - let v4_location = Location::try_from(multi_location).ok()?; - LocationToCurrencyIds::::get(v4_location) + fn get_currency_id(location: &Location) -> Option { + LocationToCurrencyIds::::get(location) } } @@ -586,129 +583,3 @@ impl CurrencyIdRegister for AssetIdMaps { ) } } - -/// Simple fee calculator that requires payment in a single fungible at a fixed rate. -/// -/// The constant `FixedRate` type parameter should be the concrete fungible ID and the amount of it -/// required for one second of weight. -pub struct FixedRateOfAsset, R: TakeRevenue> { - weight: u64, - amount: u128, - ed_ratio: FixedU128, - location: Option, - _marker: PhantomData<(T, FixedRate, R)>, -} - -impl, R: TakeRevenue> WeightTrader - for FixedRateOfAsset -where - BalanceOf: Into, -{ - fn new() -> Self { - Self { - weight: 0, - amount: 0, - ed_ratio: Default::default(), - location: None, - _marker: PhantomData, - } - } - - fn buy_weight( - &mut self, - weight: Weight, - payment: AssetsInHolding, - _context: &XcmContext, - ) -> Result { - log::trace!(target: "asset-registry::weight", "buy_weight weight: {:?}, payment: {:?}", weight, payment); - - // only support first fungible assets now. - let asset_id = payment - .fungible - .iter() - .next() - .map_or(Err(XcmError::TooExpensive), |v| Ok(v.0))?; - - let AssetId(ref location) = asset_id.clone(); - log::debug!(target: "asset-registry::weight", "buy_weight location: {:?}", location); - - let v4_location = - Location::try_from(location.clone()).map_err(|_| XcmError::InvalidLocation)?; - - if let Some(currency_id) = LocationToCurrencyIds::::get(v4_location) { - if let Some(currency_metadatas) = CurrencyMetadatas::::get(currency_id) { - // The integration tests can ensure the ed is non-zero. - let ed_ratio = FixedU128::saturating_from_rational( - currency_metadatas.minimal_balance.into(), - T::Currency::minimum_balance().into(), - ); - // The WEIGHT_REF_TIME_PER_SECOND is non-zero. - let weight_ratio = FixedU128::saturating_from_rational( - weight.ref_time(), - WEIGHT_REF_TIME_PER_SECOND, - ); - let amount = - ed_ratio.saturating_mul_int(weight_ratio.saturating_mul_int(FixedRate::get())); - - let required = Asset { id: asset_id.clone(), fun: Fungible(amount) }; - - log::trace!( - target: "asset-registry::weight", "buy_weight payment: {:?}, required: {:?}, fixed_rate: {:?}, ed_ratio: {:?}, weight_ratio: {:?}", - payment, required, FixedRate::get(), ed_ratio, weight_ratio - ); - let unused = - payment.clone().checked_sub(required).map_err(|_| XcmError::TooExpensive)?; - self.weight = self.weight.saturating_add(weight.ref_time()); - self.amount = self.amount.saturating_add(amount); - self.ed_ratio = ed_ratio; - self.location = Some(location.clone()); - return Ok(unused); - } - }; - - log::trace!(target: "asset-registry::weight", "no concrete fungible asset"); - Err(XcmError::TooExpensive) - } - - fn refund_weight(&mut self, weight: Weight, _context: &XcmContext) -> Option { - log::trace!( - target: "asset-registry::weight", "refund_weight weight: {:?}, weight: {:?}, amount: {:?}, ed_ratio: {:?}, location: {:?}", - weight, self.weight, self.amount, self.ed_ratio, self.location - ); - let weight = weight.min(Weight::from_parts(self.weight, 0)); - let weight_ratio = - FixedU128::saturating_from_rational(weight.ref_time(), WEIGHT_REF_TIME_PER_SECOND); - let amount = self - .ed_ratio - .saturating_mul_int(weight_ratio.saturating_mul_int(FixedRate::get())); - - self.weight = self.weight.saturating_sub(weight.ref_time()); - self.amount = self.amount.saturating_sub(amount); - - log::trace!(target: "asset-registry::weight", "refund_weight amount: {:?}", amount); - if amount > 0 && self.location.is_some() { - Some(Asset { - fun: Fungible(amount), - id: AssetId( - self.location.clone().expect("checked is non-empty; qed").try_into().unwrap(), - ), - }) - } else { - None - } - } -} - -impl, R: TakeRevenue> Drop for FixedRateOfAsset { - fn drop(&mut self) { - log::trace!(target: "asset-registry::weight", "take revenue, weight: {:?}, amount: {:?}, location: {:?}", self.weight, self.amount, self.location); - if self.amount > 0 && self.location.is_some() { - R::take_revenue(Asset { - fun: Fungible(self.amount), - id: AssetId( - self.location.clone().expect("checked is non-empty; qed").try_into().unwrap(), - ), - }); - } - } -} diff --git a/pallets/asset-registry/src/mock.rs b/pallets/asset-registry/src/mock.rs index a948e290c..67344b21b 100644 --- a/pallets/asset-registry/src/mock.rs +++ b/pallets/asset-registry/src/mock.rs @@ -107,3 +107,8 @@ impl ExtBuilder { ext } } + +#[cfg(feature = "runtime-benchmarks")] +pub fn new_test_ext_benchmark() -> sp_io::TestExternalities { + ExtBuilder::default().build() +} diff --git a/pallets/bb-bnc/src/benchmarking.rs b/pallets/bb-bnc/src/benchmarking.rs index 26dcebcfe..1e3eab9b5 100644 --- a/pallets/bb-bnc/src/benchmarking.rs +++ b/pallets/bb-bnc/src/benchmarking.rs @@ -19,55 +19,101 @@ // Ensure we're `no_std` when compiling for Wasm. #![cfg(feature = "runtime-benchmarks")] -use frame_benchmarking::{account, benchmarks, v1::BenchmarkError}; -use frame_support::{assert_ok, traits::EnsureOrigin}; - +use crate::{BalanceOf, Call, Config, Pallet as BbBNC, Pallet}; use bifrost_primitives::{CurrencyId, TokenSymbol}; +use frame_benchmarking::v2::*; +use frame_support::{assert_ok, traits::EnsureOrigin}; use frame_system::RawOrigin; +use orml_traits::MultiCurrency; use sp_runtime::traits::UniqueSaturatedFrom; use sp_std::vec; -use crate::{BalanceOf, Call, Config, Pallet as BbBNC, Pallet}; -use orml_traits::MultiCurrency; +#[benchmarks] +mod benchmarks { + use super::*; -benchmarks! { - set_config { - }: _(RawOrigin::Root, - Some((4 * 365 * 86400 / 12u32).into()), - Some((7 * 86400 / 12u32).into())) + #[benchmark] + fn set_config() -> Result<(), BenchmarkError> { + #[extrinsic_call] + _( + RawOrigin::Root, + Some((4 * 365 * 86400 / 12u32).into()), + Some((7 * 86400 / 12u32).into()), + ); + + Ok(()) + } + + #[benchmark] + fn create_lock() -> Result<(), BenchmarkError> { + let test_account: T::AccountId = account("seed", 1, 1); - create_lock { - let test_account: T::AccountId = account("seed",1,1); assert_ok!(BbBNC::::set_config( RawOrigin::Root.into(), Some((4 * 365 * 86400 / 12u32).into()), Some((7 * 86400 / 12u32).into()) )); - T::MultiCurrency::deposit(CurrencyId::Native(TokenSymbol::BNC), &test_account, BalanceOf::::unique_saturated_from(100_000_000_000_000u128))?; - T::MultiCurrency::deposit(CurrencyId::VToken(TokenSymbol::BNC), &test_account, BalanceOf::::unique_saturated_from(100_000_000_000_000u128))?; - let rewards = vec![(CurrencyId::Native(TokenSymbol::BNC), BalanceOf::::unique_saturated_from(10_000_000_000_000u128))]; + + T::MultiCurrency::deposit( + CurrencyId::Native(TokenSymbol::BNC), + &test_account, + BalanceOf::::unique_saturated_from(100_000_000_000_000u128), + )?; + + T::MultiCurrency::deposit( + CurrencyId::VToken(TokenSymbol::BNC), + &test_account, + BalanceOf::::unique_saturated_from(100_000_000_000_000u128), + )?; + + let rewards = vec![CurrencyId::Native(TokenSymbol::BNC)]; + assert_ok!(BbBNC::::notify_rewards( T::ControlOrigin::try_successful_origin().map_err(|_| BenchmarkError::Weightless)?, - account("seed",1,1), - Some((7 * 86400 / 12u32).into()),rewards + account("seed", 1, 1), + Some((7 * 86400 / 12u32).into()), + rewards )); - }: _(RawOrigin::Signed(test_account),BalanceOf::::unique_saturated_from(50000000000u128),(365 * 86400 / 12u32).into()) + #[extrinsic_call] + _( + RawOrigin::Signed(test_account), + BalanceOf::::unique_saturated_from(50000000000u128), + (365 * 86400 / 12u32).into(), + ); + + Ok(()) + } + + #[benchmark] + fn increase_amount() -> Result<(), BenchmarkError> { + let test_account: T::AccountId = account("seed", 1, 1); - increase_amount { - let test_account: T::AccountId = account("seed",1,1); assert_ok!(BbBNC::::set_config( RawOrigin::Root.into(), Some((4 * 365 * 86400 / 12u32).into()), Some((7 * 86400 / 12u32).into()) )); - T::MultiCurrency::deposit(CurrencyId::Native(TokenSymbol::BNC), &test_account, BalanceOf::::unique_saturated_from(100_000_000_000_000u128))?; - T::MultiCurrency::deposit(CurrencyId::VToken(TokenSymbol::BNC), &test_account, BalanceOf::::unique_saturated_from(100_000_000_000_000u128))?; - let rewards = vec![(CurrencyId::Native(TokenSymbol::BNC), BalanceOf::::unique_saturated_from(10_000_000_000_000u128))]; + + T::MultiCurrency::deposit( + CurrencyId::Native(TokenSymbol::BNC), + &test_account, + BalanceOf::::unique_saturated_from(100_000_000_000_000u128), + )?; + + T::MultiCurrency::deposit( + CurrencyId::VToken(TokenSymbol::BNC), + &test_account, + BalanceOf::::unique_saturated_from(100_000_000_000_000u128), + )?; + + let rewards = vec![CurrencyId::Native(TokenSymbol::BNC)]; + assert_ok!(BbBNC::::notify_rewards( T::ControlOrigin::try_successful_origin().map_err(|_| BenchmarkError::Weightless)?, - account("seed",1,1), - Some((7 * 86400 / 12u32).into()),rewards + account("seed", 1, 1), + Some((7 * 86400 / 12u32).into()), + rewards )); assert_ok!(BbBNC::::create_lock( @@ -76,22 +122,45 @@ benchmarks! { (365 * 86400 / 12u32).into() )); - }: _(RawOrigin::Signed(test_account),0,BalanceOf::::unique_saturated_from(50000000000u128)) + #[extrinsic_call] + _( + RawOrigin::Signed(test_account), + 0, + BalanceOf::::unique_saturated_from(50000000000u128), + ); + + Ok(()) + } + + #[benchmark] + fn increase_unlock_time() -> Result<(), BenchmarkError> { + let test_account: T::AccountId = account("seed", 1, 1); - increase_unlock_time { - let test_account: T::AccountId = account("seed",1,1); assert_ok!(BbBNC::::set_config( RawOrigin::Root.into(), Some((4 * 365 * 86400 / 12u32).into()), Some((7 * 86400 / 12u32).into()) )); - T::MultiCurrency::deposit(CurrencyId::Native(TokenSymbol::BNC), &test_account, BalanceOf::::unique_saturated_from(100_000_000_000_000u128))?; - T::MultiCurrency::deposit(CurrencyId::VToken(TokenSymbol::BNC), &test_account, BalanceOf::::unique_saturated_from(100_000_000_000_000u128))?; - let rewards = vec![(CurrencyId::Native(TokenSymbol::BNC), BalanceOf::::unique_saturated_from(10_000_000_000_000u128))]; + + T::MultiCurrency::deposit( + CurrencyId::Native(TokenSymbol::BNC), + &test_account, + BalanceOf::::unique_saturated_from(100_000_000_000_000u128), + )?; + + T::MultiCurrency::deposit( + CurrencyId::VToken(TokenSymbol::BNC), + &test_account, + BalanceOf::::unique_saturated_from(100_000_000_000_000u128), + )?; + + let rewards = vec![CurrencyId::Native(TokenSymbol::BNC)]; + assert_ok!(BbBNC::::notify_rewards( T::ControlOrigin::try_successful_origin().map_err(|_| BenchmarkError::Weightless)?, - account("seed",1,1), - Some((7 * 86400 / 12u32).into()),rewards + account("seed", 1, 1), + Some((7 * 86400 / 12u32).into()), + rewards )); assert_ok!(BbBNC::::create_lock( @@ -100,22 +169,41 @@ benchmarks! { (365 * 86400 / 12u32).into() )); - }: _(RawOrigin::Signed(test_account),0,(7 * 86400 / 12u32 + 365 * 86400 / 12u32).into()) + #[extrinsic_call] + _(RawOrigin::Signed(test_account), 0, (7 * 86400 / 12u32 + 365 * 86400 / 12u32).into()); + + Ok(()) + } + + #[benchmark] + fn withdraw() -> Result<(), BenchmarkError> { + let test_account: T::AccountId = account("seed", 1, 1); - withdraw { - let test_account: T::AccountId = account("seed",1,1); assert_ok!(BbBNC::::set_config( T::ControlOrigin::try_successful_origin().map_err(|_| BenchmarkError::Weightless)?, Some((4 * 365 * 86400 / 12u32).into()), Some((7 * 86400 / 12u32).into()) )); - T::MultiCurrency::deposit(CurrencyId::Native(TokenSymbol::BNC), &test_account, BalanceOf::::unique_saturated_from(100_000_000_000_000u128))?; - T::MultiCurrency::deposit(CurrencyId::VToken(TokenSymbol::BNC), &test_account, BalanceOf::::unique_saturated_from(100_000_000_000_000u128))?; - let rewards = vec![(CurrencyId::Native(TokenSymbol::BNC), BalanceOf::::unique_saturated_from(10_000_000_000_000u128))]; + + T::MultiCurrency::deposit( + CurrencyId::Native(TokenSymbol::BNC), + &test_account, + BalanceOf::::unique_saturated_from(100_000_000_000_000u128), + )?; + + T::MultiCurrency::deposit( + CurrencyId::VToken(TokenSymbol::BNC), + &test_account, + BalanceOf::::unique_saturated_from(100_000_000_000_000u128), + )?; + + let rewards = vec![CurrencyId::Native(TokenSymbol::BNC)]; + assert_ok!(BbBNC::::notify_rewards( T::ControlOrigin::try_successful_origin().map_err(|_| BenchmarkError::Weightless)?, - account("seed",1,1), - Some((7 * 86400 / 12u32).into()),rewards + account("seed", 1, 1), + Some((7 * 86400 / 12u32).into()), + rewards )); assert_ok!(BbBNC::::create_lock( @@ -126,22 +214,41 @@ benchmarks! { >::set_block_number((2 * 365 * 86400 / 12u32).into()); - }: _(RawOrigin::Signed(test_account),0) + #[extrinsic_call] + _(RawOrigin::Signed(test_account), 0); + + Ok(()) + } + + #[benchmark] + fn get_rewards() -> Result<(), BenchmarkError> { + let test_account: T::AccountId = account("seed", 1, 1); - get_rewards { - let test_account: T::AccountId = account("seed",1,1); assert_ok!(BbBNC::::set_config( RawOrigin::Root.into(), Some((4 * 365 * 86400 / 12u32).into()), Some((7 * 86400 / 12u32).into()) )); - T::MultiCurrency::deposit(CurrencyId::Native(TokenSymbol::BNC), &test_account, BalanceOf::::unique_saturated_from(100_000_000_000_000u128))?; - T::MultiCurrency::deposit(CurrencyId::VToken(TokenSymbol::BNC), &test_account, BalanceOf::::unique_saturated_from(100_000_000_000_000u128))?; - let rewards = vec![(CurrencyId::Native(TokenSymbol::BNC), BalanceOf::::unique_saturated_from(10_000_000_000_000u128))]; + + T::MultiCurrency::deposit( + CurrencyId::Native(TokenSymbol::BNC), + &test_account, + BalanceOf::::unique_saturated_from(100_000_000_000_000u128), + )?; + + T::MultiCurrency::deposit( + CurrencyId::VToken(TokenSymbol::BNC), + &test_account, + BalanceOf::::unique_saturated_from(100_000_000_000_000u128), + )?; + + let rewards = vec![CurrencyId::Native(TokenSymbol::BNC)]; + assert_ok!(BbBNC::::notify_rewards( T::ControlOrigin::try_successful_origin().map_err(|_| BenchmarkError::Weightless)?, - account("seed",1,1), - Some((7 * 86400 / 12u32).into()),rewards + account("seed", 1, 1), + Some((7 * 86400 / 12u32).into()), + rewards )); assert_ok!(BbBNC::::create_lock( @@ -152,41 +259,87 @@ benchmarks! { >::set_block_number((2 * 365 * 86400 / 12u32).into()); - }: _(RawOrigin::Signed(test_account)) + #[extrinsic_call] + _(RawOrigin::Signed(test_account)); - notify_rewards { + Ok(()) + } + #[benchmark] + fn notify_rewards() -> Result<(), BenchmarkError> { assert_ok!(BbBNC::::set_config( RawOrigin::Root.into(), Some((4 * 365 * 86400 / 12u32).into()), Some((7 * 86400 / 12u32).into()) )); - let rewards = vec![(CurrencyId::Native(TokenSymbol::BNC), BalanceOf::::unique_saturated_from(10_000_000_000_000u128))]; - T::MultiCurrency::deposit(CurrencyId::Native(TokenSymbol::BNC), &account("seed",1,1), BalanceOf::::unique_saturated_from(100_000_000_000_000u128))?; - }: _(RawOrigin::Root,account("seed",1,1),Some((7 * 86400 / 12u32).into()),rewards) - set_markup_coefficient { + let rewards = vec![CurrencyId::Native(TokenSymbol::BNC)]; + + T::MultiCurrency::deposit( + CurrencyId::Native(TokenSymbol::BNC), + &account("seed", 1, 1), + BalanceOf::::unique_saturated_from(100_000_000_000_000u128), + )?; + + #[extrinsic_call] + _(RawOrigin::Root, account("seed", 1, 1), Some((7 * 86400 / 12u32).into()), rewards); + + Ok(()) + } + + #[benchmark] + fn set_markup_coefficient() -> Result<(), BenchmarkError> { assert_ok!(BbBNC::::set_config( RawOrigin::Root.into(), Some((4 * 365 * 86400 / 12u32).into()), Some((7 * 86400 / 12u32).into()) )); - T::MultiCurrency::deposit(CurrencyId::Native(TokenSymbol::BNC), &account("seed",1,1), BalanceOf::::unique_saturated_from(100_000_000_000_000u128))?; - }: _(RawOrigin::Root, CurrencyId::VToken(TokenSymbol::BNC), 10_000.into(), 10_000_000_000_000.into()) - deposit_markup { - let test_account: T::AccountId = account("seed",1,1); + T::MultiCurrency::deposit( + CurrencyId::Native(TokenSymbol::BNC), + &account("seed", 1, 1), + BalanceOf::::unique_saturated_from(100_000_000_000_000u128), + )?; + + #[extrinsic_call] + _( + RawOrigin::Root, + CurrencyId::VToken(TokenSymbol::BNC), + 10_000.into(), + 10_000_000_000_000.into(), + ); + + Ok(()) + } + + #[benchmark] + fn deposit_markup() -> Result<(), BenchmarkError> { + let test_account: T::AccountId = account("seed", 1, 1); + assert_ok!(BbBNC::::set_config( RawOrigin::Root.into(), Some((4 * 365 * 86400 / 12u32).into()), Some((7 * 86400 / 12u32).into()) )); - T::MultiCurrency::deposit(CurrencyId::Native(TokenSymbol::BNC), &test_account, BalanceOf::::unique_saturated_from(100_000_000_000_000u128))?; - T::MultiCurrency::deposit(CurrencyId::VToken(TokenSymbol::BNC), &test_account, BalanceOf::::unique_saturated_from(100_000_000_000_000u128))?; - let rewards = vec![(CurrencyId::Native(TokenSymbol::BNC), BalanceOf::::unique_saturated_from(10_000_000_000_000u128))]; + + T::MultiCurrency::deposit( + CurrencyId::Native(TokenSymbol::BNC), + &test_account, + BalanceOf::::unique_saturated_from(100_000_000_000_000u128), + )?; + + T::MultiCurrency::deposit( + CurrencyId::VToken(TokenSymbol::BNC), + &test_account, + BalanceOf::::unique_saturated_from(100_000_000_000_000u128), + )?; + + let rewards = vec![CurrencyId::Native(TokenSymbol::BNC)]; + assert_ok!(BbBNC::::notify_rewards( T::ControlOrigin::try_successful_origin().map_err(|_| BenchmarkError::Weightless)?, - account("seed",1,1), - Some((7 * 86400 / 12u32).into()),rewards + account("seed", 1, 1), + Some((7 * 86400 / 12u32).into()), + rewards )); assert_ok!(BbBNC::::create_lock( @@ -194,30 +347,54 @@ benchmarks! { BalanceOf::::unique_saturated_from(10_000_000_000_000u128), (365 * 86400 / 12u32).into() )); + assert_ok!(BbBNC::::set_markup_coefficient( RawOrigin::Root.into(), CurrencyId::VToken(TokenSymbol::BNC), 1_000.into(), 10_000_000_000_000.into() )); + >::set_block_number((2 * 365 * 86400 / 12u32).into()); - }: _(RawOrigin::Signed(test_account), CurrencyId::VToken(TokenSymbol::BNC), BalanceOf::::unique_saturated_from(10_000_000_000_000u128)) + #[extrinsic_call] + _( + RawOrigin::Signed(test_account), + CurrencyId::VToken(TokenSymbol::BNC), + BalanceOf::::unique_saturated_from(10_000_000_000_000u128), + ); + + Ok(()) + } + #[benchmark] + fn withdraw_markup() -> Result<(), BenchmarkError> { + let test_account: T::AccountId = account("seed", 1, 1); - withdraw_markup { - let test_account: T::AccountId = account("seed",1,1); assert_ok!(BbBNC::::set_config( RawOrigin::Root.into(), Some((4 * 365 * 86400 / 12u32).into()), Some((7 * 86400 / 12u32).into()) )); - T::MultiCurrency::deposit(CurrencyId::Native(TokenSymbol::BNC), &test_account, BalanceOf::::unique_saturated_from(100_000_000_000_000u128))?; - T::MultiCurrency::deposit(CurrencyId::VToken(TokenSymbol::BNC), &test_account, BalanceOf::::unique_saturated_from(100_000_000_000_000u128))?; - let rewards = vec![(CurrencyId::Native(TokenSymbol::BNC), BalanceOf::::unique_saturated_from(10_000_000_000_000u128))]; + + T::MultiCurrency::deposit( + CurrencyId::Native(TokenSymbol::BNC), + &test_account, + BalanceOf::::unique_saturated_from(100_000_000_000_000u128), + )?; + + T::MultiCurrency::deposit( + CurrencyId::VToken(TokenSymbol::BNC), + &test_account, + BalanceOf::::unique_saturated_from(100_000_000_000_000u128), + )?; + + let rewards = vec![CurrencyId::Native(TokenSymbol::BNC)]; + assert_ok!(BbBNC::::notify_rewards( T::ControlOrigin::try_successful_origin().map_err(|_| BenchmarkError::Weightless)?, - account("seed",1,1), - Some((7 * 86400 / 12u32).into()),rewards + account("seed", 1, 1), + Some((7 * 86400 / 12u32).into()), + rewards )); assert_ok!(BbBNC::::create_lock( @@ -225,31 +402,57 @@ benchmarks! { BalanceOf::::unique_saturated_from(10_000_000_000_000u128), (365 * 86400 / 12u32).into() )); + assert_ok!(BbBNC::::set_markup_coefficient( RawOrigin::Root.into(), CurrencyId::VToken(TokenSymbol::BNC), 1_000.into(), 10_000_000_000_000.into() )); - assert_ok!(BbBNC::::deposit_markup(RawOrigin::Signed(test_account.clone()).into(), CurrencyId::VToken(TokenSymbol::BNC), BalanceOf::::unique_saturated_from(10_000_000_000_000u128))); + + assert_ok!(BbBNC::::deposit_markup( + RawOrigin::Signed(test_account.clone()).into(), + CurrencyId::VToken(TokenSymbol::BNC), + BalanceOf::::unique_saturated_from(10_000_000_000_000u128) + )); + >::set_block_number((2 * 365 * 86400 / 12u32).into()); - }: _(RawOrigin::Signed(test_account), CurrencyId::VToken(TokenSymbol::BNC)) + #[extrinsic_call] + _(RawOrigin::Signed(test_account), CurrencyId::VToken(TokenSymbol::BNC)); + + Ok(()) + } + + #[benchmark] + fn redeem_unlock() -> Result<(), BenchmarkError> { + let test_account: T::AccountId = account("seed", 1, 1); - redeem_unlock { - let test_account: T::AccountId = account("seed",1,1); assert_ok!(BbBNC::::set_config( RawOrigin::Root.into(), Some((4 * 365 * 86400 / 12u32).into()), Some((7 * 86400 / 12u32).into()) )); - T::MultiCurrency::deposit(CurrencyId::Native(TokenSymbol::BNC), &test_account, BalanceOf::::unique_saturated_from(100_000_000_000_000u128))?; - T::MultiCurrency::deposit(CurrencyId::VToken(TokenSymbol::BNC), &test_account, BalanceOf::::unique_saturated_from(100_000_000_000_000u128))?; - let rewards = vec![(CurrencyId::Native(TokenSymbol::BNC), BalanceOf::::unique_saturated_from(10_000_000_000_000u128))]; + + T::MultiCurrency::deposit( + CurrencyId::Native(TokenSymbol::BNC), + &test_account, + BalanceOf::::unique_saturated_from(100_000_000_000_000u128), + )?; + + T::MultiCurrency::deposit( + CurrencyId::VToken(TokenSymbol::BNC), + &test_account, + BalanceOf::::unique_saturated_from(100_000_000_000_000u128), + )?; + + let rewards = vec![CurrencyId::Native(TokenSymbol::BNC)]; + assert_ok!(BbBNC::::notify_rewards( T::ControlOrigin::try_successful_origin().map_err(|_| BenchmarkError::Weightless)?, - account("seed",1,1), - Some((7 * 86400 / 12u32).into()),rewards + account("seed", 1, 1), + Some((7 * 86400 / 12u32).into()), + rewards )); assert_ok!(BbBNC::::create_lock( @@ -257,31 +460,57 @@ benchmarks! { BalanceOf::::unique_saturated_from(10_000_000_000_000u128), (365 * 86400 / 12u32).into() )); + assert_ok!(BbBNC::::set_markup_coefficient( RawOrigin::Root.into(), CurrencyId::VToken(TokenSymbol::BNC), 1_000.into(), 10_000_000_000_000.into() )); - assert_ok!(BbBNC::::deposit_markup(RawOrigin::Signed(test_account.clone()).into(), CurrencyId::VToken(TokenSymbol::BNC), BalanceOf::::unique_saturated_from(10_000_000_000_000u128))); + + assert_ok!(BbBNC::::deposit_markup( + RawOrigin::Signed(test_account.clone()).into(), + CurrencyId::VToken(TokenSymbol::BNC), + BalanceOf::::unique_saturated_from(10_000_000_000_000u128) + )); + >::set_block_number((2 * 86400 / 12u32).into()); - }: _(RawOrigin::Signed(test_account), 0) + #[extrinsic_call] + _(RawOrigin::Signed(test_account), 0); + + Ok(()) + } + + #[benchmark] + fn refresh() -> Result<(), BenchmarkError> { + let test_account: T::AccountId = account("seed", 1, 1); - refresh { - let test_account: T::AccountId = account("seed",1,1); assert_ok!(BbBNC::::set_config( RawOrigin::Root.into(), Some((4 * 365 * 86400 / 12u32).into()), Some((7 * 86400 / 12u32).into()) )); - T::MultiCurrency::deposit(CurrencyId::Native(TokenSymbol::BNC), &test_account, BalanceOf::::unique_saturated_from(100_000_000_000_000u128))?; - T::MultiCurrency::deposit(CurrencyId::VToken(TokenSymbol::BNC), &test_account, BalanceOf::::unique_saturated_from(100_000_000_000_000u128))?; - let rewards = vec![(CurrencyId::Native(TokenSymbol::BNC), BalanceOf::::unique_saturated_from(10_000_000_000_000u128))]; + + T::MultiCurrency::deposit( + CurrencyId::Native(TokenSymbol::BNC), + &test_account, + BalanceOf::::unique_saturated_from(100_000_000_000_000u128), + )?; + + T::MultiCurrency::deposit( + CurrencyId::VToken(TokenSymbol::BNC), + &test_account, + BalanceOf::::unique_saturated_from(100_000_000_000_000u128), + )?; + + let rewards = vec![CurrencyId::Native(TokenSymbol::BNC)]; + assert_ok!(BbBNC::::notify_rewards( T::ControlOrigin::try_successful_origin().map_err(|_| BenchmarkError::Weightless)?, - account("seed",1,1), - Some((7 * 86400 / 12u32).into()),rewards + account("seed", 1, 1), + Some((7 * 86400 / 12u32).into()), + rewards )); assert_ok!(BbBNC::::create_lock( @@ -289,16 +518,27 @@ benchmarks! { BalanceOf::::unique_saturated_from(10_000_000_000_000u128), (365 * 86400 / 12u32).into() )); + assert_ok!(BbBNC::::set_markup_coefficient( RawOrigin::Root.into(), CurrencyId::VToken(TokenSymbol::BNC), 1_000.into(), 10_000_000_000_000.into() )); - assert_ok!(BbBNC::::deposit_markup(RawOrigin::Signed(test_account.clone()).into(), CurrencyId::VToken(TokenSymbol::BNC), BalanceOf::::unique_saturated_from(10_000_000_000_000u128))); + + assert_ok!(BbBNC::::deposit_markup( + RawOrigin::Signed(test_account.clone()).into(), + CurrencyId::VToken(TokenSymbol::BNC), + BalanceOf::::unique_saturated_from(10_000_000_000_000u128) + )); + >::set_block_number((2 * 86400 / 12u32).into()); - }: _(RawOrigin::Signed(test_account), CurrencyId::VToken(TokenSymbol::BNC)) + #[extrinsic_call] + _(RawOrigin::Signed(test_account), CurrencyId::VToken(TokenSymbol::BNC)); + + Ok(()) + } - impl_benchmark_test_suite!(BbBNC,crate::mock::ExtBuilder::default().build(),crate::mock::Runtime); + impl_benchmark_test_suite!(Pallet, crate::mock::new_test_ext_benchmark(), crate::mock::Runtime); } diff --git a/pallets/bb-bnc/src/incentive.rs b/pallets/bb-bnc/src/incentive.rs index ec082aedd..1906a23fb 100644 --- a/pallets/bb-bnc/src/incentive.rs +++ b/pallets/bb-bnc/src/incentive.rs @@ -37,7 +37,7 @@ pub struct IncentiveConfig { /// the system account. pub incentive_controller: Option, /// When a round is started, the value to be transferred will be obtained from this field. - pub last_reward: Vec<(CurrencyId, Balance)>, + pub last_reward: Vec, } impl Default @@ -254,7 +254,7 @@ impl Pallet { pub fn notify_reward_amount( pool_id: PoolId, who: &Option>, - rewards: Vec<(CurrencyIdOf, BalanceOf)>, + rewards: Vec>, ) -> DispatchResult { let account = match who { Some(who) => who, diff --git a/pallets/bb-bnc/src/lib.rs b/pallets/bb-bnc/src/lib.rs index a027655d5..cfffdf1e1 100644 --- a/pallets/bb-bnc/src/lib.rs +++ b/pallets/bb-bnc/src/lib.rs @@ -208,7 +208,7 @@ pub mod pallet { IncentiveConfig, BalanceOf, BlockNumberFor, AccountIdOf>, }, /// The rewards for this round have been added to the system account. - RewardAdded { rewards: Vec<(CurrencyIdOf, BalanceOf)> }, + RewardAdded { rewards: Vec> }, /// The user has received the reward. Rewarded { who: AccountIdOf, rewards: Vec<(CurrencyIdOf, BalanceOf)> }, /// This currency_id has been refreshed. @@ -216,7 +216,7 @@ pub mod pallet { /// This currency_id has been partially refreshed. PartiallyRefreshed { currency_id: CurrencyIdOf }, /// Notify reward failed. - NotifyRewardFailed { rewards: Vec<(CurrencyIdOf, BalanceOf)> }, + NotifyRewardFailed { rewards: Vec> }, /// Markup has been deposited. MarkupDeposited { /// The user who deposited @@ -524,7 +524,7 @@ pub mod pallet { origin: OriginFor, incentive_from: AccountIdOf, rewards_duration: Option>, - rewards: Vec<(CurrencyIdOf, BalanceOf)>, + rewards: Vec>, ) -> DispatchResult { T::ControlOrigin::ensure_origin(origin)?; Self::set_incentive( diff --git a/pallets/bb-bnc/src/mock.rs b/pallets/bb-bnc/src/mock.rs index 36d34a318..e82b13f68 100644 --- a/pallets/bb-bnc/src/mock.rs +++ b/pallets/bb-bnc/src/mock.rs @@ -412,7 +412,7 @@ impl ExtBuilder { self.balances(vec![ (ALICE, BNC, 1_000_000_000_000), (ALICE, VBNC, 1_000_000_000_000_000), - (ALICE, KSM, 1_000_000_000_000), + (ALICE, KSM, 1_000_000_000), (BOB, BNC, 1_000_000_000_000), (BOB, VBNC, 1_000_000_000_000_000), (BOB, VKSM, 1_000_000_000_000), @@ -450,3 +450,8 @@ impl ExtBuilder { t.into() } } + +#[cfg(feature = "runtime-benchmarks")] +pub fn new_test_ext_benchmark() -> sp_io::TestExternalities { + ExtBuilder::default().build() +} diff --git a/pallets/bb-bnc/src/tests.rs b/pallets/bb-bnc/src/tests.rs index 2948290d3..9cf05415a 100644 --- a/pallets/bb-bnc/src/tests.rs +++ b/pallets/bb-bnc/src/tests.rs @@ -240,7 +240,7 @@ fn notify_reward_amount() { assert_ok!(BbBNC::increase_amount(RuntimeOrigin::signed(BOB), 0, 80_000_000_000)); assert_eq!(BbBNC::balance_of(&BOB, None), Ok(99715627680)); - let rewards = vec![(KSM, 1_000_000_000)]; + let rewards = vec![KSM]; assert_ok!(BbBNC::notify_rewards( RuntimeOrigin::root(), ALICE, @@ -255,6 +255,7 @@ fn notify_reward_amount() { System::set_block_number(System::block_number() + 7 * 86400 / 12); assert_ok!(BbBNC::get_rewards_inner(BB_BNC_SYSTEM_POOL_ID, &BOB, None)); assert_eq!(Tokens::free_balance(KSM, &BOB), 999986398); + assert_ok!(Tokens::deposit(KSM, &ALICE, 1_000_000_000)); assert_ok!(BbBNC::notify_rewards( RuntimeOrigin::root(), ALICE, @@ -289,7 +290,7 @@ fn create_lock_to_withdraw() { Some(4 * 365 * 86400 / 12), Some(14 * 86400 / 12) )); - let rewards = vec![(KSM, 1000)]; + let rewards = vec![KSM]; assert_ok!(BbBNC::notify_rewards( RuntimeOrigin::root(), ALICE, diff --git a/pallets/bb-bnc/src/traits.rs b/pallets/bb-bnc/src/traits.rs index 8f6ac48a0..8c1833683 100644 --- a/pallets/bb-bnc/src/traits.rs +++ b/pallets/bb-bnc/src/traits.rs @@ -45,7 +45,7 @@ pub trait BbBNCInterface { fn auto_notify_reward( pool_id: PoolId, n: BlockNumber, - rewards: Vec<(CurrencyId, Balance)>, + rewards: Vec, ) -> DispatchResult; fn update_reward( pool_id: PoolId, @@ -65,13 +65,13 @@ pub trait BbBNCInterface { fn add_reward( who: &AccountId, conf: &mut IncentiveConfig, - rewards: &Vec<(CurrencyId, Balance)>, + rewards: &Vec, remaining: Balance, ) -> DispatchResult; fn notify_reward( pool_id: PoolId, who: &Option, - rewards: Vec<(CurrencyId, Balance)>, + rewards: Vec, ) -> DispatchResult; } @@ -285,10 +285,11 @@ impl BbBNCInterface, CurrencyIdOf, BalanceOf, Bl fn auto_notify_reward( pool_id: PoolId, n: BlockNumberFor, - rewards: Vec<(CurrencyIdOf, BalanceOf)>, + rewards: Vec>, ) -> DispatchResult { let conf = IncentiveConfigs::::get(pool_id); - if n == conf.period_finish { + // If the period is reached or not set, the reward will be notified. + if n == conf.period_finish || conf.period_finish == Default::default() { Self::notify_reward_amount(pool_id, &conf.incentive_controller, rewards)?; } Ok(()) @@ -335,11 +336,12 @@ impl BbBNCInterface, CurrencyIdOf, BalanceOf, Bl BlockNumberFor, AccountIdOf, >, - rewards: &Vec<(CurrencyIdOf, BalanceOf)>, + rewards: &Vec>, remaining: BalanceOf, ) -> DispatchResult { - rewards.iter().try_for_each(|(currency, reward)| -> DispatchResult { - let mut total_reward: BalanceOf = *reward; + rewards.iter().try_for_each(|currency| -> DispatchResult { + let reward = T::MultiCurrency::free_balance(*currency, who); + let mut total_reward: BalanceOf = reward; if remaining != BalanceOf::::zero() { let leftover: BalanceOf = conf .reward_rate @@ -356,7 +358,7 @@ impl BbBNCInterface, CurrencyIdOf, BalanceOf, Bl // Make sure the new reward is less than or equal to the reward owned by the // IncentivePalletId ensure!( - total_reward <= currency_amount.saturating_add(*reward), + total_reward <= currency_amount.saturating_add(reward), Error::::NotEnoughBalance ); let new_reward = total_reward @@ -368,11 +370,15 @@ impl BbBNCInterface, CurrencyIdOf, BalanceOf, Bl *total_reward = new_reward; }) .or_insert(new_reward); + // If the reward in this round is 0, it will only be recorded without transfer. + if reward == BalanceOf::::zero() { + return Ok(()); + } T::MultiCurrency::transfer( *currency, who, &T::IncentivePalletId::get().into_account_truncating(), - *reward, + reward, ) }) } @@ -380,7 +386,7 @@ impl BbBNCInterface, CurrencyIdOf, BalanceOf, Bl fn notify_reward( pool_id: PoolId, who: &Option>, - rewards: Vec<(CurrencyIdOf, BalanceOf)>, + rewards: Vec>, ) -> DispatchResult { Self::notify_reward_amount(pool_id, who, rewards) } @@ -441,7 +447,7 @@ where fn auto_notify_reward( _pool_id: PoolId, _n: BlockNumber, - _rewards: Vec<(CurrencyId, Balance)>, + _rewards: Vec, ) -> DispatchResult { Ok(()) } @@ -471,7 +477,7 @@ where fn add_reward( _who: &AccountId, _conf: &mut IncentiveConfig, - _rewards: &Vec<(CurrencyId, Balance)>, + _rewards: &Vec, _remaining: Balance, ) -> DispatchResult { Ok(()) @@ -479,7 +485,7 @@ where fn notify_reward( _pool_id: PoolId, _who: &Option, - _rewards: Vec<(CurrencyId, Balance)>, + _rewards: Vec, ) -> DispatchResult { Ok(()) } diff --git a/pallets/bb-bnc/src/weights.rs b/pallets/bb-bnc/src/weights.rs index aca971f2c..b54a417dd 100644 --- a/pallets/bb-bnc/src/weights.rs +++ b/pallets/bb-bnc/src/weights.rs @@ -24,9 +24,9 @@ //! Autogenerated weights for bb_bnc //! -//! THIS FILE WAS AUTO-GENERATED USING THE SUBSTRATE BENCHMARK CLI VERSION 4.0.0-dev -//! DATE: 2023-09-14, STEPS: `50`, REPEAT: 20, LOW RANGE: `[]`, HIGH RANGE: `[]` -//! HOSTNAME: `bifrost-jenkins`, CPU: `Intel(R) Xeon(R) CPU E5-26xx v4` +//! THIS FILE WAS AUTO-GENERATED USING THE SUBSTRATE BENCHMARK CLI VERSION 32.0.0 +//! DATE: 2024-11-06, STEPS: `50`, REPEAT: 20, LOW RANGE: `[]`, HIGH RANGE: `[]` +//! HOSTNAME: `mjl-legion`, CPU: `12th Gen Intel(R) Core(TM) i9-12900H` //! WASM-EXECUTION: Compiled, CHAIN: Some("bifrost-polkadot-local"), DB CACHE: 1024 // Executed Command: @@ -69,263 +69,289 @@ pub trait WeightInfo { // For backwards compatibility and tests impl WeightInfo for () { - /// Storage: BbBNC VeConfigs (r:1 w:1) - /// Proof Skipped: BbBNC VeConfigs (max_values: Some(1), max_size: None, mode: Measured) - /// Storage: System Number (r:1 w:0) - /// Proof: System Number (max_values: Some(1), max_size: Some(4), added: 499, mode: MaxEncodedLen) - /// Storage: System ExecutionPhase (r:1 w:0) - /// Proof: System ExecutionPhase (max_values: Some(1), max_size: Some(5), added: 500, mode: MaxEncodedLen) - /// Storage: System EventCount (r:1 w:1) - /// Proof: System EventCount (max_values: Some(1), max_size: Some(4), added: 499, mode: MaxEncodedLen) - /// Storage: System Events (r:1 w:1) - /// Proof Skipped: System Events (max_values: Some(1), max_size: None, mode: Measured) + /// Storage: `BbBNC::BbConfigs` (r:1 w:1) + /// Proof: `BbBNC::BbConfigs` (`max_values`: Some(1), `max_size`: None, mode: `Measured`) + /// Storage: `System::Number` (r:1 w:0) + /// Proof: `System::Number` (`max_values`: Some(1), `max_size`: Some(4), added: 499, mode: `MaxEncodedLen`) + /// Storage: `System::ExecutionPhase` (r:1 w:0) + /// Proof: `System::ExecutionPhase` (`max_values`: Some(1), `max_size`: Some(5), added: 500, mode: `MaxEncodedLen`) + /// Storage: `System::EventCount` (r:1 w:1) + /// Proof: `System::EventCount` (`max_values`: Some(1), `max_size`: Some(4), added: 499, mode: `MaxEncodedLen`) + /// Storage: `System::Events` (r:1 w:1) + /// Proof: `System::Events` (`max_values`: Some(1), `max_size`: None, mode: `Measured`) fn set_config() -> Weight { // Proof Size summary in bytes: - // Measured: `200` - // Estimated: `1685` - // Minimum execution time: 32_840_000 picoseconds. - Weight::from_parts(34_249_000, 1685) + // Measured: `134` + // Estimated: `1619` + // Minimum execution time: 6_981_000 picoseconds. + Weight::from_parts(7_592_000, 1619) .saturating_add(RocksDbWeight::get().reads(5_u64)) .saturating_add(RocksDbWeight::get().writes(3_u64)) } - /// Storage: BbBNC VeConfigs (r:1 w:0) - /// Proof Skipped: BbBNC VeConfigs (max_values: Some(1), max_size: None, mode: Measured) - /// Storage: BbBNC Locked (r:1 w:1) - /// Proof Skipped: BbBNC Locked (max_values: None, max_size: None, mode: Measured) - /// Storage: System Number (r:1 w:0) - /// Proof: System Number (max_values: Some(1), max_size: Some(4), added: 499, mode: MaxEncodedLen) - /// Storage: BbBNC Supply (r:1 w:1) - /// Proof Skipped: BbBNC Supply (max_values: Some(1), max_size: None, mode: Measured) - /// Storage: Tokens Accounts (r:2 w:2) - /// Proof: Tokens Accounts (max_values: None, max_size: Some(118), added: 2593, mode: MaxEncodedLen) - /// Storage: AssetRegistry CurrencyMetadatas (r:1 w:0) - /// Proof Skipped: AssetRegistry CurrencyMetadatas (max_values: None, max_size: None, mode: Measured) - /// Storage: System Account (r:2 w:1) - /// Proof: System Account (max_values: None, max_size: Some(128), added: 2603, mode: MaxEncodedLen) - /// Storage: System ExecutionPhase (r:1 w:0) - /// Proof: System ExecutionPhase (max_values: Some(1), max_size: Some(5), added: 500, mode: MaxEncodedLen) - /// Storage: System EventCount (r:1 w:1) - /// Proof: System EventCount (max_values: Some(1), max_size: Some(4), added: 499, mode: MaxEncodedLen) - /// Storage: System Events (r:1 w:1) - /// Proof Skipped: System Events (max_values: Some(1), max_size: None, mode: Measured) - /// Storage: BbBNC IncentiveConfigs (r:1 w:1) - /// Proof Skipped: BbBNC IncentiveConfigs (max_values: Some(1), max_size: None, mode: Measured) - /// Storage: BbBNC Epoch (r:1 w:1) - /// Proof Skipped: BbBNC Epoch (max_values: Some(1), max_size: None, mode: Measured) - /// Storage: BbBNC PointHistory (r:1 w:1) - /// Proof Skipped: BbBNC PointHistory (max_values: None, max_size: None, mode: Measured) - /// Storage: BbBNC UserPointEpoch (r:1 w:1) - /// Proof Skipped: BbBNC UserPointEpoch (max_values: None, max_size: None, mode: Measured) - /// Storage: BbBNC Rewards (r:1 w:0) - /// Proof Skipped: BbBNC Rewards (max_values: None, max_size: None, mode: Measured) - /// Storage: BbBNC SlopeChanges (r:2 w:1) - /// Proof Skipped: BbBNC SlopeChanges (max_values: None, max_size: None, mode: Measured) - /// Storage: BbBNC UserPointHistory (r:0 w:1) - /// Proof Skipped: BbBNC UserPointHistory (max_values: None, max_size: None, mode: Measured) - /// Storage: BbBNC UserRewardPerTokenPaid (r:0 w:1) - /// Proof Skipped: BbBNC UserRewardPerTokenPaid (max_values: None, max_size: None, mode: Measured) + /// Storage: `BbBNC::Position` (r:1 w:1) + /// Proof: `BbBNC::Position` (`max_values`: Some(1), `max_size`: None, mode: `Measured`) + /// Storage: `BbBNC::UserPositions` (r:1 w:1) + /// Proof: `BbBNC::UserPositions` (`max_values`: None, `max_size`: None, mode: `Measured`) + /// Storage: `BbBNC::BbConfigs` (r:1 w:0) + /// Proof: `BbBNC::BbConfigs` (`max_values`: Some(1), `max_size`: None, mode: `Measured`) + /// Storage: `System::Number` (r:1 w:0) + /// Proof: `System::Number` (`max_values`: Some(1), `max_size`: Some(4), added: 499, mode: `MaxEncodedLen`) + /// Storage: `BbBNC::Locked` (r:1 w:1) + /// Proof: `BbBNC::Locked` (`max_values`: None, `max_size`: None, mode: `Measured`) + /// Storage: `BbBNC::Supply` (r:1 w:1) + /// Proof: `BbBNC::Supply` (`max_values`: Some(1), `max_size`: None, mode: `Measured`) + /// Storage: `Tokens::Accounts` (r:1 w:1) + /// Proof: `Tokens::Accounts` (`max_values`: None, `max_size`: Some(118), added: 2593, mode: `MaxEncodedLen`) + /// Storage: `BbBNC::UserLocked` (r:1 w:1) + /// Proof: `BbBNC::UserLocked` (`max_values`: None, `max_size`: None, mode: `Measured`) + /// Storage: `Tokens::Locks` (r:1 w:1) + /// Proof: `Tokens::Locks` (`max_values`: None, `max_size`: Some(1271), added: 3746, mode: `MaxEncodedLen`) + /// Storage: `AssetRegistry::CurrencyMetadatas` (r:1 w:0) + /// Proof: `AssetRegistry::CurrencyMetadatas` (`max_values`: None, `max_size`: None, mode: `Measured`) + /// Storage: `System::Account` (r:1 w:1) + /// Proof: `System::Account` (`max_values`: None, `max_size`: Some(128), added: 2603, mode: `MaxEncodedLen`) + /// Storage: `System::ExecutionPhase` (r:1 w:0) + /// Proof: `System::ExecutionPhase` (`max_values`: Some(1), `max_size`: Some(5), added: 500, mode: `MaxEncodedLen`) + /// Storage: `System::EventCount` (r:1 w:1) + /// Proof: `System::EventCount` (`max_values`: Some(1), `max_size`: Some(4), added: 499, mode: `MaxEncodedLen`) + /// Storage: `System::Events` (r:1 w:1) + /// Proof: `System::Events` (`max_values`: Some(1), `max_size`: None, mode: `Measured`) + /// Storage: `BbBNC::UserMarkupInfos` (r:1 w:0) + /// Proof: `BbBNC::UserMarkupInfos` (`max_values`: None, `max_size`: None, mode: `Measured`) + /// Storage: `BbBNC::UserFarmingPool` (r:1 w:0) + /// Proof: `BbBNC::UserFarmingPool` (`max_values`: None, `max_size`: None, mode: `Measured`) + /// Storage: `BbBNC::IncentiveConfigs` (r:1 w:1) + /// Proof: `BbBNC::IncentiveConfigs` (`max_values`: None, `max_size`: None, mode: `Measured`) + /// Storage: `BbBNC::Epoch` (r:1 w:1) + /// Proof: `BbBNC::Epoch` (`max_values`: Some(1), `max_size`: None, mode: `Measured`) + /// Storage: `BbBNC::PointHistory` (r:1 w:1) + /// Proof: `BbBNC::PointHistory` (`max_values`: None, `max_size`: None, mode: `Measured`) + /// Storage: `BbBNC::UserPointEpoch` (r:1 w:1) + /// Proof: `BbBNC::UserPointEpoch` (`max_values`: None, `max_size`: None, mode: `Measured`) + /// Storage: `BbBNC::Rewards` (r:1 w:0) + /// Proof: `BbBNC::Rewards` (`max_values`: None, `max_size`: None, mode: `Measured`) + /// Storage: `BbBNC::SlopeChanges` (r:2 w:1) + /// Proof: `BbBNC::SlopeChanges` (`max_values`: None, `max_size`: None, mode: `Measured`) + /// Storage: `BbBNC::UserPointHistory` (r:0 w:1) + /// Proof: `BbBNC::UserPointHistory` (`max_values`: None, `max_size`: None, mode: `Measured`) + /// Storage: `BbBNC::UserRewardPerTokenPaid` (r:0 w:1) + /// Proof: `BbBNC::UserRewardPerTokenPaid` (`max_values`: None, `max_size`: None, mode: `Measured`) fn create_lock() -> Weight { // Proof Size summary in bytes: - // Measured: `1439` - // Estimated: `7379` - // Minimum execution time: 254_132_000 picoseconds. - Weight::from_parts(257_959_000, 7379) - .saturating_add(RocksDbWeight::get().reads(19_u64)) - .saturating_add(RocksDbWeight::get().writes(14_u64)) + // Measured: `1389` + // Estimated: `7329` + // Minimum execution time: 77_626_000 picoseconds. + Weight::from_parts(83_128_000, 7329) + .saturating_add(RocksDbWeight::get().reads(23_u64)) + .saturating_add(RocksDbWeight::get().writes(17_u64)) } - /// Storage: BbBNC VeConfigs (r:1 w:0) - /// Proof Skipped: BbBNC VeConfigs (max_values: Some(1), max_size: None, mode: Measured) - /// Storage: BbBNC Locked (r:1 w:1) - /// Proof Skipped: BbBNC Locked (max_values: None, max_size: None, mode: Measured) - /// Storage: System Number (r:1 w:0) - /// Proof: System Number (max_values: Some(1), max_size: Some(4), added: 499, mode: MaxEncodedLen) - /// Storage: BbBNC Supply (r:1 w:1) - /// Proof Skipped: BbBNC Supply (max_values: Some(1), max_size: None, mode: Measured) - /// Storage: Tokens Accounts (r:2 w:2) - /// Proof: Tokens Accounts (max_values: None, max_size: Some(118), added: 2593, mode: MaxEncodedLen) - /// Storage: AssetRegistry CurrencyMetadatas (r:1 w:0) - /// Proof Skipped: AssetRegistry CurrencyMetadatas (max_values: None, max_size: None, mode: Measured) - /// Storage: System Account (r:1 w:0) - /// Proof: System Account (max_values: None, max_size: Some(128), added: 2603, mode: MaxEncodedLen) - /// Storage: System ExecutionPhase (r:1 w:0) - /// Proof: System ExecutionPhase (max_values: Some(1), max_size: Some(5), added: 500, mode: MaxEncodedLen) - /// Storage: System EventCount (r:1 w:1) - /// Proof: System EventCount (max_values: Some(1), max_size: Some(4), added: 499, mode: MaxEncodedLen) - /// Storage: System Events (r:1 w:1) - /// Proof Skipped: System Events (max_values: Some(1), max_size: None, mode: Measured) - /// Storage: BbBNC IncentiveConfigs (r:1 w:1) - /// Proof Skipped: BbBNC IncentiveConfigs (max_values: Some(1), max_size: None, mode: Measured) - /// Storage: BbBNC Epoch (r:1 w:1) - /// Proof Skipped: BbBNC Epoch (max_values: Some(1), max_size: None, mode: Measured) - /// Storage: BbBNC PointHistory (r:1 w:1) - /// Proof Skipped: BbBNC PointHistory (max_values: None, max_size: None, mode: Measured) - /// Storage: BbBNC UserPointEpoch (r:1 w:1) - /// Proof Skipped: BbBNC UserPointEpoch (max_values: None, max_size: None, mode: Measured) - /// Storage: BbBNC UserPointHistory (r:1 w:1) - /// Proof Skipped: BbBNC UserPointHistory (max_values: None, max_size: None, mode: Measured) - /// Storage: BbBNC Rewards (r:1 w:1) - /// Proof Skipped: BbBNC Rewards (max_values: None, max_size: None, mode: Measured) - /// Storage: BbBNC UserRewardPerTokenPaid (r:1 w:1) - /// Proof Skipped: BbBNC UserRewardPerTokenPaid (max_values: None, max_size: None, mode: Measured) - /// Storage: BbBNC SlopeChanges (r:1 w:1) - /// Proof Skipped: BbBNC SlopeChanges (max_values: None, max_size: None, mode: Measured) + /// Storage: `BbBNC::UserPositions` (r:1 w:0) + /// Proof: `BbBNC::UserPositions` (`max_values`: None, `max_size`: None, mode: `Measured`) + /// Storage: `BbBNC::BbConfigs` (r:1 w:0) + /// Proof: `BbBNC::BbConfigs` (`max_values`: Some(1), `max_size`: None, mode: `Measured`) + /// Storage: `BbBNC::Locked` (r:1 w:1) + /// Proof: `BbBNC::Locked` (`max_values`: None, `max_size`: None, mode: `Measured`) + /// Storage: `System::Number` (r:1 w:0) + /// Proof: `System::Number` (`max_values`: Some(1), `max_size`: Some(4), added: 499, mode: `MaxEncodedLen`) + /// Storage: `BbBNC::Supply` (r:1 w:1) + /// Proof: `BbBNC::Supply` (`max_values`: Some(1), `max_size`: None, mode: `Measured`) + /// Storage: `Tokens::Accounts` (r:1 w:1) + /// Proof: `Tokens::Accounts` (`max_values`: None, `max_size`: Some(118), added: 2593, mode: `MaxEncodedLen`) + /// Storage: `BbBNC::UserLocked` (r:1 w:1) + /// Proof: `BbBNC::UserLocked` (`max_values`: None, `max_size`: None, mode: `Measured`) + /// Storage: `Tokens::Locks` (r:1 w:1) + /// Proof: `Tokens::Locks` (`max_values`: None, `max_size`: Some(1271), added: 3746, mode: `MaxEncodedLen`) + /// Storage: `AssetRegistry::CurrencyMetadatas` (r:1 w:0) + /// Proof: `AssetRegistry::CurrencyMetadatas` (`max_values`: None, `max_size`: None, mode: `Measured`) + /// Storage: `System::ExecutionPhase` (r:1 w:0) + /// Proof: `System::ExecutionPhase` (`max_values`: Some(1), `max_size`: Some(5), added: 500, mode: `MaxEncodedLen`) + /// Storage: `System::EventCount` (r:1 w:1) + /// Proof: `System::EventCount` (`max_values`: Some(1), `max_size`: Some(4), added: 499, mode: `MaxEncodedLen`) + /// Storage: `System::Events` (r:1 w:1) + /// Proof: `System::Events` (`max_values`: Some(1), `max_size`: None, mode: `Measured`) + /// Storage: `BbBNC::UserMarkupInfos` (r:1 w:0) + /// Proof: `BbBNC::UserMarkupInfos` (`max_values`: None, `max_size`: None, mode: `Measured`) + /// Storage: `BbBNC::UserFarmingPool` (r:1 w:0) + /// Proof: `BbBNC::UserFarmingPool` (`max_values`: None, `max_size`: None, mode: `Measured`) + /// Storage: `BbBNC::IncentiveConfigs` (r:1 w:1) + /// Proof: `BbBNC::IncentiveConfigs` (`max_values`: None, `max_size`: None, mode: `Measured`) + /// Storage: `BbBNC::Epoch` (r:1 w:1) + /// Proof: `BbBNC::Epoch` (`max_values`: Some(1), `max_size`: None, mode: `Measured`) + /// Storage: `BbBNC::PointHistory` (r:1 w:1) + /// Proof: `BbBNC::PointHistory` (`max_values`: None, `max_size`: None, mode: `Measured`) + /// Storage: `BbBNC::UserPointEpoch` (r:1 w:1) + /// Proof: `BbBNC::UserPointEpoch` (`max_values`: None, `max_size`: None, mode: `Measured`) + /// Storage: `BbBNC::UserPointHistory` (r:1 w:1) + /// Proof: `BbBNC::UserPointHistory` (`max_values`: None, `max_size`: None, mode: `Measured`) + /// Storage: `BbBNC::Rewards` (r:1 w:1) + /// Proof: `BbBNC::Rewards` (`max_values`: None, `max_size`: None, mode: `Measured`) + /// Storage: `BbBNC::UserRewardPerTokenPaid` (r:1 w:1) + /// Proof: `BbBNC::UserRewardPerTokenPaid` (`max_values`: None, `max_size`: None, mode: `Measured`) + /// Storage: `BbBNC::SlopeChanges` (r:1 w:1) + /// Proof: `BbBNC::SlopeChanges` (`max_values`: None, `max_size`: None, mode: `Measured`) fn increase_amount() -> Weight { // Proof Size summary in bytes: - // Measured: `2083` - // Estimated: `6176` - // Minimum execution time: 282_837_000 picoseconds. - Weight::from_parts(287_187_000, 6176) - .saturating_add(RocksDbWeight::get().reads(19_u64)) - .saturating_add(RocksDbWeight::get().writes(14_u64)) + // Measured: `2248` + // Estimated: `5713` + // Minimum execution time: 100_357_000 picoseconds. + Weight::from_parts(104_849_000, 5713) + .saturating_add(RocksDbWeight::get().reads(22_u64)) + .saturating_add(RocksDbWeight::get().writes(15_u64)) } - /// Storage: BbBNC VeConfigs (r:1 w:0) - /// Proof Skipped: BbBNC VeConfigs (max_values: Some(1), max_size: None, mode: Measured) - /// Storage: BbBNC Locked (r:1 w:1) - /// Proof Skipped: BbBNC Locked (max_values: None, max_size: None, mode: Measured) - /// Storage: System Number (r:1 w:0) - /// Proof: System Number (max_values: Some(1), max_size: Some(4), added: 499, mode: MaxEncodedLen) - /// Storage: BbBNC Supply (r:1 w:1) - /// Proof Skipped: BbBNC Supply (max_values: Some(1), max_size: None, mode: Measured) - /// Storage: BbBNC IncentiveConfigs (r:1 w:1) - /// Proof Skipped: BbBNC IncentiveConfigs (max_values: Some(1), max_size: None, mode: Measured) - /// Storage: BbBNC Epoch (r:1 w:1) - /// Proof Skipped: BbBNC Epoch (max_values: Some(1), max_size: None, mode: Measured) - /// Storage: BbBNC PointHistory (r:1 w:1) - /// Proof Skipped: BbBNC PointHistory (max_values: None, max_size: None, mode: Measured) - /// Storage: BbBNC UserPointEpoch (r:1 w:1) - /// Proof Skipped: BbBNC UserPointEpoch (max_values: None, max_size: None, mode: Measured) - /// Storage: BbBNC UserPointHistory (r:1 w:1) - /// Proof Skipped: BbBNC UserPointHistory (max_values: None, max_size: None, mode: Measured) - /// Storage: BbBNC Rewards (r:1 w:1) - /// Proof Skipped: BbBNC Rewards (max_values: None, max_size: None, mode: Measured) - /// Storage: BbBNC UserRewardPerTokenPaid (r:1 w:1) - /// Proof Skipped: BbBNC UserRewardPerTokenPaid (max_values: None, max_size: None, mode: Measured) - /// Storage: BbBNC SlopeChanges (r:2 w:2) - /// Proof Skipped: BbBNC SlopeChanges (max_values: None, max_size: None, mode: Measured) - /// Storage: Tokens Accounts (r:1 w:0) - /// Proof: Tokens Accounts (max_values: None, max_size: Some(118), added: 2593, mode: MaxEncodedLen) - /// Storage: System ExecutionPhase (r:1 w:0) - /// Proof: System ExecutionPhase (max_values: Some(1), max_size: Some(5), added: 500, mode: MaxEncodedLen) - /// Storage: System EventCount (r:1 w:1) - /// Proof: System EventCount (max_values: Some(1), max_size: Some(4), added: 499, mode: MaxEncodedLen) - /// Storage: System Events (r:1 w:1) - /// Proof Skipped: System Events (max_values: Some(1), max_size: None, mode: Measured) + /// Storage: `BbBNC::UserPositions` (r:1 w:0) + /// Proof: `BbBNC::UserPositions` (`max_values`: None, `max_size`: None, mode: `Measured`) + /// Storage: `BbBNC::BbConfigs` (r:1 w:0) + /// Proof: `BbBNC::BbConfigs` (`max_values`: Some(1), `max_size`: None, mode: `Measured`) + /// Storage: `BbBNC::Locked` (r:1 w:1) + /// Proof: `BbBNC::Locked` (`max_values`: None, `max_size`: None, mode: `Measured`) + /// Storage: `System::Number` (r:1 w:0) + /// Proof: `System::Number` (`max_values`: Some(1), `max_size`: Some(4), added: 499, mode: `MaxEncodedLen`) + /// Storage: `BbBNC::Supply` (r:1 w:1) + /// Proof: `BbBNC::Supply` (`max_values`: Some(1), `max_size`: None, mode: `Measured`) + /// Storage: `Tokens::Accounts` (r:1 w:0) + /// Proof: `Tokens::Accounts` (`max_values`: None, `max_size`: Some(118), added: 2593, mode: `MaxEncodedLen`) + /// Storage: `BbBNC::UserMarkupInfos` (r:1 w:0) + /// Proof: `BbBNC::UserMarkupInfos` (`max_values`: None, `max_size`: None, mode: `Measured`) + /// Storage: `BbBNC::UserFarmingPool` (r:1 w:0) + /// Proof: `BbBNC::UserFarmingPool` (`max_values`: None, `max_size`: None, mode: `Measured`) + /// Storage: `BbBNC::IncentiveConfigs` (r:1 w:1) + /// Proof: `BbBNC::IncentiveConfigs` (`max_values`: None, `max_size`: None, mode: `Measured`) + /// Storage: `BbBNC::Epoch` (r:1 w:1) + /// Proof: `BbBNC::Epoch` (`max_values`: Some(1), `max_size`: None, mode: `Measured`) + /// Storage: `BbBNC::PointHistory` (r:1 w:1) + /// Proof: `BbBNC::PointHistory` (`max_values`: None, `max_size`: None, mode: `Measured`) + /// Storage: `BbBNC::UserPointEpoch` (r:1 w:1) + /// Proof: `BbBNC::UserPointEpoch` (`max_values`: None, `max_size`: None, mode: `Measured`) + /// Storage: `BbBNC::UserPointHistory` (r:1 w:1) + /// Proof: `BbBNC::UserPointHistory` (`max_values`: None, `max_size`: None, mode: `Measured`) + /// Storage: `BbBNC::Rewards` (r:1 w:1) + /// Proof: `BbBNC::Rewards` (`max_values`: None, `max_size`: None, mode: `Measured`) + /// Storage: `BbBNC::UserRewardPerTokenPaid` (r:1 w:1) + /// Proof: `BbBNC::UserRewardPerTokenPaid` (`max_values`: None, `max_size`: None, mode: `Measured`) + /// Storage: `BbBNC::SlopeChanges` (r:2 w:2) + /// Proof: `BbBNC::SlopeChanges` (`max_values`: None, `max_size`: None, mode: `Measured`) + /// Storage: `System::ExecutionPhase` (r:1 w:0) + /// Proof: `System::ExecutionPhase` (`max_values`: Some(1), `max_size`: Some(5), added: 500, mode: `MaxEncodedLen`) + /// Storage: `System::EventCount` (r:1 w:1) + /// Proof: `System::EventCount` (`max_values`: Some(1), `max_size`: Some(4), added: 499, mode: `MaxEncodedLen`) + /// Storage: `System::Events` (r:1 w:1) + /// Proof: `System::Events` (`max_values`: Some(1), `max_size`: None, mode: `Measured`) fn increase_unlock_time() -> Weight { // Proof Size summary in bytes: - // Measured: `1589` - // Estimated: `7529` - // Minimum execution time: 225_251_000 picoseconds. - Weight::from_parts(229_018_000, 7529) - .saturating_add(RocksDbWeight::get().reads(17_u64)) + // Measured: `1519` + // Estimated: `7459` + // Minimum execution time: 80_873_000 picoseconds. + Weight::from_parts(82_372_000, 7459) + .saturating_add(RocksDbWeight::get().reads(20_u64)) .saturating_add(RocksDbWeight::get().writes(13_u64)) } - /// Storage: BbBNC Locked (r:1 w:1) - /// Proof Skipped: BbBNC Locked (max_values: None, max_size: None, mode: Measured) - /// Storage: System Number (r:1 w:0) - /// Proof: System Number (max_values: Some(1), max_size: Some(4), added: 499, mode: MaxEncodedLen) - /// Storage: BbBNC Supply (r:1 w:1) - /// Proof Skipped: BbBNC Supply (max_values: Some(1), max_size: None, mode: Measured) - /// Storage: Tokens Accounts (r:2 w:2) - /// Proof: Tokens Accounts (max_values: None, max_size: Some(118), added: 2593, mode: MaxEncodedLen) - /// Storage: AssetRegistry CurrencyMetadatas (r:1 w:0) - /// Proof Skipped: AssetRegistry CurrencyMetadatas (max_values: None, max_size: None, mode: Measured) - /// Storage: System Account (r:1 w:1) - /// Proof: System Account (max_values: None, max_size: Some(128), added: 2603, mode: MaxEncodedLen) - /// Storage: System ExecutionPhase (r:1 w:0) - /// Proof: System ExecutionPhase (max_values: Some(1), max_size: Some(5), added: 500, mode: MaxEncodedLen) - /// Storage: System EventCount (r:1 w:1) - /// Proof: System EventCount (max_values: Some(1), max_size: Some(4), added: 499, mode: MaxEncodedLen) - /// Storage: System Events (r:1 w:1) - /// Proof Skipped: System Events (max_values: Some(1), max_size: None, mode: Measured) - /// Storage: BbBNC IncentiveConfigs (r:1 w:1) - /// Proof Skipped: BbBNC IncentiveConfigs (max_values: Some(1), max_size: None, mode: Measured) - /// Storage: BbBNC Epoch (r:1 w:1) - /// Proof Skipped: BbBNC Epoch (max_values: Some(1), max_size: None, mode: Measured) - /// Storage: BbBNC PointHistory (r:1 w:105) - /// Proof Skipped: BbBNC PointHistory (max_values: None, max_size: None, mode: Measured) - /// Storage: BbBNC SlopeChanges (r:104 w:0) - /// Proof Skipped: BbBNC SlopeChanges (max_values: None, max_size: None, mode: Measured) - /// Storage: BbBNC UserPointEpoch (r:1 w:1) - /// Proof Skipped: BbBNC UserPointEpoch (max_values: None, max_size: None, mode: Measured) - /// Storage: BbBNC UserPointHistory (r:1 w:1) - /// Proof Skipped: BbBNC UserPointHistory (max_values: None, max_size: None, mode: Measured) - /// Storage: BbBNC Rewards (r:1 w:1) - /// Proof Skipped: BbBNC Rewards (max_values: None, max_size: None, mode: Measured) - /// Storage: BbBNC UserRewardPerTokenPaid (r:1 w:1) - /// Proof Skipped: BbBNC UserRewardPerTokenPaid (max_values: None, max_size: None, mode: Measured) + /// Storage: `BbBNC::UserPositions` (r:1 w:1) + /// Proof: `BbBNC::UserPositions` (`max_values`: None, `max_size`: None, mode: `Measured`) + /// Storage: `BbBNC::Locked` (r:1 w:1) + /// Proof: `BbBNC::Locked` (`max_values`: None, `max_size`: None, mode: `Measured`) + /// Storage: `System::Number` (r:1 w:0) + /// Proof: `System::Number` (`max_values`: Some(1), `max_size`: Some(4), added: 499, mode: `MaxEncodedLen`) + /// Storage: `BbBNC::Supply` (r:1 w:1) + /// Proof: `BbBNC::Supply` (`max_values`: Some(1), `max_size`: None, mode: `Measured`) + /// Storage: `BbBNC::UserLocked` (r:1 w:1) + /// Proof: `BbBNC::UserLocked` (`max_values`: None, `max_size`: None, mode: `Measured`) + /// Storage: `Tokens::Locks` (r:1 w:1) + /// Proof: `Tokens::Locks` (`max_values`: None, `max_size`: Some(1271), added: 3746, mode: `MaxEncodedLen`) + /// Storage: `Tokens::Accounts` (r:1 w:1) + /// Proof: `Tokens::Accounts` (`max_values`: None, `max_size`: Some(118), added: 2593, mode: `MaxEncodedLen`) + /// Storage: `AssetRegistry::CurrencyMetadatas` (r:1 w:0) + /// Proof: `AssetRegistry::CurrencyMetadatas` (`max_values`: None, `max_size`: None, mode: `Measured`) + /// Storage: `System::Account` (r:1 w:1) + /// Proof: `System::Account` (`max_values`: None, `max_size`: Some(128), added: 2603, mode: `MaxEncodedLen`) + /// Storage: `System::ExecutionPhase` (r:1 w:0) + /// Proof: `System::ExecutionPhase` (`max_values`: Some(1), `max_size`: Some(5), added: 500, mode: `MaxEncodedLen`) + /// Storage: `System::EventCount` (r:1 w:1) + /// Proof: `System::EventCount` (`max_values`: Some(1), `max_size`: Some(4), added: 499, mode: `MaxEncodedLen`) + /// Storage: `System::Events` (r:1 w:1) + /// Proof: `System::Events` (`max_values`: Some(1), `max_size`: None, mode: `Measured`) + /// Storage: `BbBNC::UserFarmingPool` (r:1 w:0) + /// Proof: `BbBNC::UserFarmingPool` (`max_values`: None, `max_size`: None, mode: `Measured`) + /// Storage: `BbBNC::IncentiveConfigs` (r:1 w:1) + /// Proof: `BbBNC::IncentiveConfigs` (`max_values`: None, `max_size`: None, mode: `Measured`) + /// Storage: `BbBNC::Epoch` (r:1 w:1) + /// Proof: `BbBNC::Epoch` (`max_values`: Some(1), `max_size`: None, mode: `Measured`) + /// Storage: `BbBNC::PointHistory` (r:1 w:105) + /// Proof: `BbBNC::PointHistory` (`max_values`: None, `max_size`: None, mode: `Measured`) + /// Storage: `BbBNC::SlopeChanges` (r:104 w:0) + /// Proof: `BbBNC::SlopeChanges` (`max_values`: None, `max_size`: None, mode: `Measured`) + /// Storage: `BbBNC::Rewards` (r:1 w:0) + /// Proof: `BbBNC::Rewards` (`max_values`: None, `max_size`: None, mode: `Measured`) + /// Storage: `BbBNC::UserPointHistory` (r:0 w:1) + /// Proof: `BbBNC::UserPointHistory` (`max_values`: None, `max_size`: None, mode: `Measured`) + /// Storage: `BbBNC::UserRewardPerTokenPaid` (r:0 w:1) + /// Proof: `BbBNC::UserRewardPerTokenPaid` (`max_values`: None, `max_size`: None, mode: `Measured`) + /// Storage: `BbBNC::UserPointEpoch` (r:0 w:1) + /// Proof: `BbBNC::UserPointEpoch` (`max_values`: None, `max_size`: None, mode: `Measured`) fn withdraw() -> Weight { // Proof Size summary in bytes: - // Measured: `2059` - // Estimated: `260449` - // Minimum execution time: 1_285_654_000 picoseconds. - Weight::from_parts(1_315_018_000, 260449) + // Measured: `2095` + // Estimated: `260485` + // Minimum execution time: 462_398_000 picoseconds. + Weight::from_parts(474_144_000, 260485) .saturating_add(RocksDbWeight::get().reads(121_u64)) - .saturating_add(RocksDbWeight::get().writes(118_u64)) + .saturating_add(RocksDbWeight::get().writes(119_u64)) } - /// Storage: BbBNC IncentiveConfigs (r:1 w:1) - /// Proof Skipped: BbBNC IncentiveConfigs (max_values: Some(1), max_size: None, mode: Measured) - /// Storage: System Number (r:1 w:0) - /// Proof: System Number (max_values: Some(1), max_size: Some(4), added: 499, mode: MaxEncodedLen) - /// Storage: BbBNC Epoch (r:1 w:0) - /// Proof Skipped: BbBNC Epoch (max_values: Some(1), max_size: None, mode: Measured) - /// Storage: BbBNC PointHistory (r:1 w:0) - /// Proof Skipped: BbBNC PointHistory (max_values: None, max_size: None, mode: Measured) - /// Storage: BbBNC SlopeChanges (r:104 w:0) - /// Proof Skipped: BbBNC SlopeChanges (max_values: None, max_size: None, mode: Measured) - /// Storage: BbBNC UserPointEpoch (r:1 w:0) - /// Proof Skipped: BbBNC UserPointEpoch (max_values: None, max_size: None, mode: Measured) - /// Storage: BbBNC UserPointHistory (r:1 w:0) - /// Proof Skipped: BbBNC UserPointHistory (max_values: None, max_size: None, mode: Measured) - /// Storage: BbBNC Rewards (r:1 w:1) - /// Proof Skipped: BbBNC Rewards (max_values: None, max_size: None, mode: Measured) - /// Storage: BbBNC UserRewardPerTokenPaid (r:1 w:1) - /// Proof Skipped: BbBNC UserRewardPerTokenPaid (max_values: None, max_size: None, mode: Measured) - /// Storage: Balances TotalIssuance (r:1 w:1) - /// Proof: Balances TotalIssuance (max_values: Some(1), max_size: Some(16), added: 511, mode: MaxEncodedLen) - /// Storage: System Account (r:3 w:3) - /// Proof: System Account (max_values: None, max_size: Some(128), added: 2603, mode: MaxEncodedLen) - /// Storage: System ExecutionPhase (r:1 w:0) - /// Proof: System ExecutionPhase (max_values: Some(1), max_size: Some(5), added: 500, mode: MaxEncodedLen) - /// Storage: System EventCount (r:1 w:1) - /// Proof: System EventCount (max_values: Some(1), max_size: Some(4), added: 499, mode: MaxEncodedLen) - /// Storage: System Events (r:1 w:1) - /// Proof Skipped: System Events (max_values: Some(1), max_size: None, mode: Measured) + /// Storage: `BbBNC::IncentiveConfigs` (r:1 w:1) + /// Proof: `BbBNC::IncentiveConfigs` (`max_values`: None, `max_size`: None, mode: `Measured`) + /// Storage: `System::Number` (r:1 w:0) + /// Proof: `System::Number` (`max_values`: Some(1), `max_size`: Some(4), added: 499, mode: `MaxEncodedLen`) + /// Storage: `BbBNC::Epoch` (r:1 w:0) + /// Proof: `BbBNC::Epoch` (`max_values`: Some(1), `max_size`: None, mode: `Measured`) + /// Storage: `BbBNC::PointHistory` (r:1 w:0) + /// Proof: `BbBNC::PointHistory` (`max_values`: None, `max_size`: None, mode: `Measured`) + /// Storage: `BbBNC::SlopeChanges` (r:104 w:0) + /// Proof: `BbBNC::SlopeChanges` (`max_values`: None, `max_size`: None, mode: `Measured`) + /// Storage: `BbBNC::UserPositions` (r:1 w:0) + /// Proof: `BbBNC::UserPositions` (`max_values`: None, `max_size`: None, mode: `Measured`) + /// Storage: `BbBNC::UserPointEpoch` (r:1 w:0) + /// Proof: `BbBNC::UserPointEpoch` (`max_values`: None, `max_size`: None, mode: `Measured`) + /// Storage: `BbBNC::UserPointHistory` (r:1 w:0) + /// Proof: `BbBNC::UserPointHistory` (`max_values`: None, `max_size`: None, mode: `Measured`) + /// Storage: `BbBNC::Rewards` (r:1 w:0) + /// Proof: `BbBNC::Rewards` (`max_values`: None, `max_size`: None, mode: `Measured`) + /// Storage: `BbBNC::UserRewardPerTokenPaid` (r:0 w:1) + /// Proof: `BbBNC::UserRewardPerTokenPaid` (`max_values`: None, `max_size`: None, mode: `Measured`) fn get_rewards() -> Weight { // Proof Size summary in bytes: - // Measured: `1384` - // Estimated: `259774` - // Minimum execution time: 752_030_000 picoseconds. - Weight::from_parts(778_014_000, 259774) - .saturating_add(RocksDbWeight::get().reads(119_u64)) - .saturating_add(RocksDbWeight::get().writes(9_u64)) + // Measured: `906` + // Estimated: `259296` + // Minimum execution time: 217_613_000 picoseconds. + Weight::from_parts(219_885_000, 259296) + .saturating_add(RocksDbWeight::get().reads(112_u64)) + .saturating_add(RocksDbWeight::get().writes(2_u64)) } - /// Storage: BbBNC IncentiveConfigs (r:1 w:1) - /// Proof Skipped: BbBNC IncentiveConfigs (max_values: Some(1), max_size: None, mode: Measured) - /// Storage: System Number (r:1 w:0) - /// Proof: System Number (max_values: Some(1), max_size: Some(4), added: 499, mode: MaxEncodedLen) - /// Storage: System ExecutionPhase (r:1 w:0) - /// Proof: System ExecutionPhase (max_values: Some(1), max_size: Some(5), added: 500, mode: MaxEncodedLen) - /// Storage: System EventCount (r:1 w:1) - /// Proof: System EventCount (max_values: Some(1), max_size: Some(4), added: 499, mode: MaxEncodedLen) - /// Storage: System Events (r:1 w:1) - /// Proof Skipped: System Events (max_values: Some(1), max_size: None, mode: Measured) - /// Storage: BbBNC Epoch (r:1 w:0) - /// Proof Skipped: BbBNC Epoch (max_values: Some(1), max_size: None, mode: Measured) - /// Storage: BbBNC PointHistory (r:1 w:0) - /// Proof Skipped: BbBNC PointHistory (max_values: None, max_size: None, mode: Measured) - /// Storage: System Account (r:2 w:2) - /// Proof: System Account (max_values: None, max_size: Some(128), added: 2603, mode: MaxEncodedLen) - /// Storage: Balances TotalIssuance (r:1 w:0) - /// Proof: Balances TotalIssuance (max_values: Some(1), max_size: Some(16), added: 511, mode: MaxEncodedLen) + /// Storage: `BbBNC::IncentiveConfigs` (r:1 w:1) + /// Proof: `BbBNC::IncentiveConfigs` (`max_values`: None, `max_size`: None, mode: `Measured`) + /// Storage: `System::Number` (r:1 w:0) + /// Proof: `System::Number` (`max_values`: Some(1), `max_size`: Some(4), added: 499, mode: `MaxEncodedLen`) + /// Storage: `System::ExecutionPhase` (r:1 w:0) + /// Proof: `System::ExecutionPhase` (`max_values`: Some(1), `max_size`: Some(5), added: 500, mode: `MaxEncodedLen`) + /// Storage: `System::EventCount` (r:1 w:1) + /// Proof: `System::EventCount` (`max_values`: Some(1), `max_size`: Some(4), added: 499, mode: `MaxEncodedLen`) + /// Storage: `System::Events` (r:1 w:1) + /// Proof: `System::Events` (`max_values`: Some(1), `max_size`: None, mode: `Measured`) + /// Storage: `BbBNC::Epoch` (r:1 w:0) + /// Proof: `BbBNC::Epoch` (`max_values`: Some(1), `max_size`: None, mode: `Measured`) + /// Storage: `BbBNC::PointHistory` (r:1 w:0) + /// Proof: `BbBNC::PointHistory` (`max_values`: None, `max_size`: None, mode: `Measured`) + /// Storage: `System::Account` (r:2 w:2) + /// Proof: `System::Account` (`max_values`: None, `max_size`: Some(128), added: 2603, mode: `MaxEncodedLen`) + /// Storage: `Balances::TotalIssuance` (r:1 w:0) + /// Proof: `Balances::TotalIssuance` (`max_values`: Some(1), `max_size`: Some(16), added: 511, mode: `MaxEncodedLen`) fn notify_rewards() -> Weight { // Proof Size summary in bytes: - // Measured: `508` + // Measured: `564` // Estimated: `6196` - // Minimum execution time: 175_754_000 picoseconds. - Weight::from_parts(179_695_000, 6196) + // Minimum execution time: 52_388_000 picoseconds. + Weight::from_parts(54_170_000, 6196) .saturating_add(RocksDbWeight::get().reads(10_u64)) .saturating_add(RocksDbWeight::get().writes(5_u64)) - } + } /// Storage: `BbBNC::TotalLock` (r:1 w:1) /// Proof: `BbBNC::TotalLock` (`max_values`: None, `max_size`: None, mode: `Measured`) /// Storage: `System::Number` (r:1 w:0) @@ -334,13 +360,12 @@ impl WeightInfo for () { /// Proof: `BbBNC::MarkupCoefficient` (`max_values`: None, `max_size`: None, mode: `Measured`) fn set_markup_coefficient() -> Weight { // Proof Size summary in bytes: - // Measured: `213` - // Estimated: `3678` - // Minimum execution time: 12_353_000 picoseconds. - Weight::from_parts(12_533_000, 0) - .saturating_add(Weight::from_parts(0, 3678)) - .saturating_add(RocksDbWeight::get().reads(2)) - .saturating_add(RocksDbWeight::get().writes(2)) + // Measured: `147` + // Estimated: `3612` + // Minimum execution time: 6_232_000 picoseconds. + Weight::from_parts(6_576_000, 3612) + .saturating_add(RocksDbWeight::get().reads(2_u64)) + .saturating_add(RocksDbWeight::get().writes(2_u64)) } /// Storage: `BbBNC::MarkupCoefficient` (r:1 w:0) /// Proof: `BbBNC::MarkupCoefficient` (`max_values`: None, `max_size`: None, mode: `Measured`) @@ -352,6 +377,8 @@ impl WeightInfo for () { /// Proof: `BbBNC::UserMarkupInfos` (`max_values`: None, `max_size`: None, mode: `Measured`) /// Storage: `BbBNC::LockedTokens` (r:1 w:1) /// Proof: `BbBNC::LockedTokens` (`max_values`: None, `max_size`: None, mode: `Measured`) + /// Storage: `Tokens::TotalIssuance` (r:1 w:0) + /// Proof: `Tokens::TotalIssuance` (`max_values`: None, `max_size`: Some(38), added: 2513, mode: `MaxEncodedLen`) /// Storage: `Tokens::Locks` (r:1 w:1) /// Proof: `Tokens::Locks` (`max_values`: None, `max_size`: Some(1271), added: 3746, mode: `MaxEncodedLen`) /// Storage: `Tokens::Accounts` (r:1 w:1) @@ -368,8 +395,10 @@ impl WeightInfo for () { /// Proof: `BbBNC::UserPositions` (`max_values`: None, `max_size`: None, mode: `Measured`) /// Storage: `BbBNC::Locked` (r:1 w:0) /// Proof: `BbBNC::Locked` (`max_values`: None, `max_size`: None, mode: `Measured`) + /// Storage: `BbBNC::UserFarmingPool` (r:1 w:0) + /// Proof: `BbBNC::UserFarmingPool` (`max_values`: None, `max_size`: None, mode: `Measured`) /// Storage: `BbBNC::IncentiveConfigs` (r:1 w:1) - /// Proof: `BbBNC::IncentiveConfigs` (`max_values`: Some(1), `max_size`: None, mode: `Measured`) + /// Proof: `BbBNC::IncentiveConfigs` (`max_values`: None, `max_size`: None, mode: `Measured`) /// Storage: `BbBNC::Epoch` (r:1 w:1) /// Proof: `BbBNC::Epoch` (`max_values`: Some(1), `max_size`: None, mode: `Measured`) /// Storage: `BbBNC::PointHistory` (r:1 w:105) @@ -380,21 +409,20 @@ impl WeightInfo for () { /// Proof: `BbBNC::UserPointEpoch` (`max_values`: None, `max_size`: None, mode: `Measured`) /// Storage: `BbBNC::UserPointHistory` (r:1 w:1) /// Proof: `BbBNC::UserPointHistory` (`max_values`: None, `max_size`: None, mode: `Measured`) - /// Storage: `BbBNC::Rewards` (r:1 w:1) + /// Storage: `BbBNC::Rewards` (r:1 w:0) /// Proof: `BbBNC::Rewards` (`max_values`: None, `max_size`: None, mode: `Measured`) - /// Storage: `BbBNC::UserRewardPerTokenPaid` (r:1 w:1) - /// Proof: `BbBNC::UserRewardPerTokenPaid` (`max_values`: None, `max_size`: None, mode: `Measured`) /// Storage: `BbBNC::Supply` (r:1 w:0) /// Proof: `BbBNC::Supply` (`max_values`: Some(1), `max_size`: None, mode: `Measured`) + /// Storage: `BbBNC::UserRewardPerTokenPaid` (r:0 w:1) + /// Proof: `BbBNC::UserRewardPerTokenPaid` (`max_values`: None, `max_size`: None, mode: `Measured`) fn deposit_markup() -> Weight { // Proof Size summary in bytes: - // Measured: `2260` - // Estimated: `260650` - // Minimum execution time: 820_796_000 picoseconds. - Weight::from_parts(831_306_000, 0) - .saturating_add(Weight::from_parts(0, 260650)) - .saturating_add(RocksDbWeight::get().reads(125)) - .saturating_add(RocksDbWeight::get().writes(118)) + // Measured: `2304` + // Estimated: `260694` + // Minimum execution time: 473_759_000 picoseconds. + Weight::from_parts(481_199_000, 260694) + .saturating_add(RocksDbWeight::get().reads(126_u64)) + .saturating_add(RocksDbWeight::get().writes(117_u64)) } /// Storage: `BbBNC::MarkupCoefficient` (r:1 w:0) /// Proof: `BbBNC::MarkupCoefficient` (`max_values`: None, `max_size`: None, mode: `Measured`) @@ -422,8 +450,10 @@ impl WeightInfo for () { /// Proof: `BbBNC::UserPositions` (`max_values`: None, `max_size`: None, mode: `Measured`) /// Storage: `BbBNC::Locked` (r:1 w:0) /// Proof: `BbBNC::Locked` (`max_values`: None, `max_size`: None, mode: `Measured`) + /// Storage: `BbBNC::UserFarmingPool` (r:1 w:0) + /// Proof: `BbBNC::UserFarmingPool` (`max_values`: None, `max_size`: None, mode: `Measured`) /// Storage: `BbBNC::IncentiveConfigs` (r:1 w:1) - /// Proof: `BbBNC::IncentiveConfigs` (`max_values`: Some(1), `max_size`: None, mode: `Measured`) + /// Proof: `BbBNC::IncentiveConfigs` (`max_values`: None, `max_size`: None, mode: `Measured`) /// Storage: `BbBNC::Epoch` (r:1 w:1) /// Proof: `BbBNC::Epoch` (`max_values`: Some(1), `max_size`: None, mode: `Measured`) /// Storage: `BbBNC::PointHistory` (r:1 w:105) @@ -442,13 +472,12 @@ impl WeightInfo for () { /// Proof: `BbBNC::Supply` (`max_values`: Some(1), `max_size`: None, mode: `Measured`) fn withdraw_markup() -> Weight { // Proof Size summary in bytes: - // Measured: `2725` - // Estimated: `261115` - // Minimum execution time: 813_232_000 picoseconds. - Weight::from_parts(823_401_000, 0) - .saturating_add(Weight::from_parts(0, 261115)) - .saturating_add(RocksDbWeight::get().reads(125)) - .saturating_add(RocksDbWeight::get().writes(118)) + // Measured: `2731` + // Estimated: `261121` + // Minimum execution time: 479_009_000 picoseconds. + Weight::from_parts(487_635_000, 261121) + .saturating_add(RocksDbWeight::get().reads(126_u64)) + .saturating_add(RocksDbWeight::get().writes(118_u64)) } /// Storage: `BbBNC::Locked` (r:1 w:1) /// Proof: `BbBNC::Locked` (`max_values`: None, `max_size`: None, mode: `Measured`) @@ -460,43 +489,46 @@ impl WeightInfo for () { /// Proof: `BbBNC::UserPositions` (`max_values`: None, `max_size`: None, mode: `Measured`) /// Storage: `BbBNC::UserLocked` (r:1 w:1) /// Proof: `BbBNC::UserLocked` (`max_values`: None, `max_size`: None, mode: `Measured`) + /// Storage: `Tokens::Locks` (r:1 w:1) + /// Proof: `Tokens::Locks` (`max_values`: None, `max_size`: Some(1271), added: 3746, mode: `MaxEncodedLen`) /// Storage: `Tokens::Accounts` (r:2 w:2) /// Proof: `Tokens::Accounts` (`max_values`: None, `max_size`: Some(118), added: 2593, mode: `MaxEncodedLen`) /// Storage: `AssetRegistry::CurrencyMetadatas` (r:1 w:0) /// Proof: `AssetRegistry::CurrencyMetadatas` (`max_values`: None, `max_size`: None, mode: `Measured`) - /// Storage: `System::Account` (r:2 w:1) - /// Proof: `System::Account` (`max_values`: None, `max_size`: Some(128), added: 2603, mode: `MaxEncodedLen`) /// Storage: `System::ExecutionPhase` (r:1 w:0) /// Proof: `System::ExecutionPhase` (`max_values`: Some(1), `max_size`: Some(5), added: 500, mode: `MaxEncodedLen`) /// Storage: `System::EventCount` (r:1 w:1) /// Proof: `System::EventCount` (`max_values`: Some(1), `max_size`: Some(4), added: 499, mode: `MaxEncodedLen`) /// Storage: `System::Events` (r:1 w:1) /// Proof: `System::Events` (`max_values`: Some(1), `max_size`: None, mode: `Measured`) + /// Storage: `System::Account` (r:2 w:1) + /// Proof: `System::Account` (`max_values`: None, `max_size`: Some(128), added: 2603, mode: `MaxEncodedLen`) + /// Storage: `BbBNC::UserFarmingPool` (r:1 w:0) + /// Proof: `BbBNC::UserFarmingPool` (`max_values`: None, `max_size`: None, mode: `Measured`) /// Storage: `BbBNC::IncentiveConfigs` (r:1 w:1) - /// Proof: `BbBNC::IncentiveConfigs` (`max_values`: Some(1), `max_size`: None, mode: `Measured`) + /// Proof: `BbBNC::IncentiveConfigs` (`max_values`: None, `max_size`: None, mode: `Measured`) /// Storage: `BbBNC::Epoch` (r:1 w:1) /// Proof: `BbBNC::Epoch` (`max_values`: Some(1), `max_size`: None, mode: `Measured`) - /// Storage: `BbBNC::PointHistory` (r:1 w:105) + /// Storage: `BbBNC::PointHistory` (r:1 w:1) /// Proof: `BbBNC::PointHistory` (`max_values`: None, `max_size`: None, mode: `Measured`) - /// Storage: `BbBNC::SlopeChanges` (r:104 w:0) - /// Proof: `BbBNC::SlopeChanges` (`max_values`: None, `max_size`: None, mode: `Measured`) /// Storage: `BbBNC::Rewards` (r:1 w:1) /// Proof: `BbBNC::Rewards` (`max_values`: None, `max_size`: None, mode: `Measured`) /// Storage: `BbBNC::UserRewardPerTokenPaid` (r:1 w:1) /// Proof: `BbBNC::UserRewardPerTokenPaid` (`max_values`: None, `max_size`: None, mode: `Measured`) + /// Storage: `BbBNC::SlopeChanges` (r:1 w:1) + /// Proof: `BbBNC::SlopeChanges` (`max_values`: None, `max_size`: None, mode: `Measured`) /// Storage: `BbBNC::UserPointHistory` (r:0 w:1) /// Proof: `BbBNC::UserPointHistory` (`max_values`: None, `max_size`: None, mode: `Measured`) /// Storage: `BbBNC::UserPointEpoch` (r:0 w:1) /// Proof: `BbBNC::UserPointEpoch` (`max_values`: None, `max_size`: None, mode: `Measured`) fn redeem_unlock() -> Weight { // Proof Size summary in bytes: - // Measured: `2525` - // Estimated: `260915` - // Minimum execution time: 818_341_000 picoseconds. - Weight::from_parts(827_248_000, 0) - .saturating_add(Weight::from_parts(0, 260915)) - .saturating_add(RocksDbWeight::get().reads(122)) - .saturating_add(RocksDbWeight::get().writes(120)) + // Measured: `2656` + // Estimated: `6196` + // Minimum execution time: 116_696_000 picoseconds. + Weight::from_parts(118_734_000, 6196) + .saturating_add(RocksDbWeight::get().reads(21_u64)) + .saturating_add(RocksDbWeight::get().writes(18_u64)) } /// Storage: `BbBNC::MarkupCoefficient` (r:1 w:0) /// Proof: `BbBNC::MarkupCoefficient` (`max_values`: None, `max_size`: None, mode: `Measured`) @@ -504,12 +536,18 @@ impl WeightInfo for () { /// Proof: `System::Number` (`max_values`: Some(1), `max_size`: Some(4), added: 499, mode: `MaxEncodedLen`) /// Storage: `BbBNC::LockedTokens` (r:2 w:1) /// Proof: `BbBNC::LockedTokens` (`max_values`: None, `max_size`: None, mode: `Measured`) + /// Storage: `BbBNC::TotalLock` (r:1 w:0) + /// Proof: `BbBNC::TotalLock` (`max_values`: None, `max_size`: None, mode: `Measured`) + /// Storage: `Tokens::TotalIssuance` (r:1 w:0) + /// Proof: `Tokens::TotalIssuance` (`max_values`: None, `max_size`: Some(38), added: 2513, mode: `MaxEncodedLen`) /// Storage: `BbBNC::UserMarkupInfos` (r:1 w:1) /// Proof: `BbBNC::UserMarkupInfos` (`max_values`: None, `max_size`: None, mode: `Measured`) /// Storage: `BbBNC::UserPositions` (r:1 w:0) /// Proof: `BbBNC::UserPositions` (`max_values`: None, `max_size`: None, mode: `Measured`) /// Storage: `BbBNC::Locked` (r:1 w:0) /// Proof: `BbBNC::Locked` (`max_values`: None, `max_size`: None, mode: `Measured`) + /// Storage: `BbBNC::UserFarmingPool` (r:1 w:0) + /// Proof: `BbBNC::UserFarmingPool` (`max_values`: None, `max_size`: None, mode: `Measured`) /// Storage: `BbBNC::IncentiveConfigs` (r:1 w:1) /// Proof: `BbBNC::IncentiveConfigs` (`max_values`: None, `max_size`: None, mode: `Measured`) /// Storage: `BbBNC::Epoch` (r:1 w:1) @@ -528,14 +566,19 @@ impl WeightInfo for () { /// Proof: `BbBNC::SlopeChanges` (`max_values`: None, `max_size`: None, mode: `Measured`) /// Storage: `BbBNC::Supply` (r:1 w:0) /// Proof: `BbBNC::Supply` (`max_values`: Some(1), `max_size`: None, mode: `Measured`) + /// Storage: `System::ExecutionPhase` (r:1 w:0) + /// Proof: `System::ExecutionPhase` (`max_values`: Some(1), `max_size`: Some(5), added: 500, mode: `MaxEncodedLen`) + /// Storage: `System::EventCount` (r:1 w:1) + /// Proof: `System::EventCount` (`max_values`: Some(1), `max_size`: Some(4), added: 499, mode: `MaxEncodedLen`) + /// Storage: `System::Events` (r:1 w:1) + /// Proof: `System::Events` (`max_values`: Some(1), `max_size`: None, mode: `Measured`) fn refresh() -> Weight { // Proof Size summary in bytes: - // Measured: `1687` - // Estimated: `7627` - // Minimum execution time: 129_204_000 picoseconds. - Weight::from_parts(130_316_000, 0) - .saturating_add(Weight::from_parts(0, 7627)) - .saturating_add(RocksDbWeight::get().reads(16)) - .saturating_add(RocksDbWeight::get().writes(10)) + // Measured: `1804` + // Estimated: `7744` + // Minimum execution time: 95_664_000 picoseconds. + Weight::from_parts(98_039_000, 7744) + .saturating_add(RocksDbWeight::get().reads(22_u64)) + .saturating_add(RocksDbWeight::get().writes(12_u64)) } } diff --git a/pallets/buy-back/src/lib.rs b/pallets/buy-back/src/lib.rs index 3c8445906..f7c609fe7 100644 --- a/pallets/buy-back/src/lib.rs +++ b/pallets/buy-back/src/lib.rs @@ -413,11 +413,10 @@ pub mod pallet { let destruction_amount = ratio * bnc_balance_before_burn; T::MultiCurrency::withdraw(BNC, &buyback_address, destruction_amount)?; } - let bnc_balance = T::MultiCurrency::free_balance(BNC, &buyback_address); T::BbBNC::notify_reward( BB_BNC_SYSTEM_POOL_ID, &Some(buyback_address.clone()), - vec![(BNC, bnc_balance)], + vec![BNC], ) } diff --git a/pallets/farming/src/lib.rs b/pallets/farming/src/lib.rs index b31125d1f..e3f9f0a2a 100644 --- a/pallets/farming/src/lib.rs +++ b/pallets/farming/src/lib.rs @@ -431,7 +431,7 @@ pub mod pallet { GaugePoolInfos::::iter().for_each(|(gid, gauge_pool_info)| { match gauge_pool_info.gauge_state { GaugeState::Bonded => { - let rewards = gauge_pool_info.gauge_basic_rewards.into_iter().collect(); + let rewards = gauge_pool_info.gauge_basic_rewards.into_keys().collect(); T::BbBNC::auto_notify_reward(gid, n, rewards).unwrap_or_default(); }, _ => (), diff --git a/pallets/farming/src/mock.rs b/pallets/farming/src/mock.rs index 28a443f84..848b5af19 100644 --- a/pallets/farming/src/mock.rs +++ b/pallets/farming/src/mock.rs @@ -222,6 +222,7 @@ impl ExtBuilder { } pub fn build(self) -> sp_io::TestExternalities { + env_logger::try_init().unwrap_or(()); let mut t = frame_system::GenesisConfig::::default().build_storage().unwrap(); pallet_balances::GenesisConfig:: { diff --git a/pallets/farming/src/tests.rs b/pallets/farming/src/tests.rs index f9eefcb4d..1218c3ba8 100644 --- a/pallets/farming/src/tests.rs +++ b/pallets/farming/src/tests.rs @@ -86,8 +86,8 @@ fn deposit() { gauge_state: GaugeState::Bonded, }; assert_eq!(GaugePoolInfos::::get(0), Some(gauge_pool_info2)); - Farming::on_initialize(0); - Farming::on_initialize(0); + Farming::on_initialize(1); + Farming::on_initialize(1); System::set_block_number(System::block_number() + 1000); }) } @@ -173,9 +173,9 @@ fn gauge_withdraw() { if let Some(gauge_pool_infos) = GaugePoolInfos::::get(0) { assert_eq!(gauge_pool_infos.gauge_amount, 0) }; - Farming::on_initialize(0); + Farming::on_initialize(1); System::set_block_number(System::block_number() + 1); - Farming::on_initialize(0); + Farming::on_initialize(1); assert_ok!(Farming::gauge_withdraw(RuntimeOrigin::signed(ALICE), pid)); assert_eq!(Tokens::free_balance(KSM, &ALICE), 2018); System::set_block_number(System::block_number() + 1000); @@ -262,7 +262,7 @@ fn reset() { assert_ok!(Farming::charge(RuntimeOrigin::signed(BOB), pid, charge_rewards, false)); assert_ok!(Farming::deposit(RuntimeOrigin::signed(ALICE), pid, 1)); assert_eq!(Tokens::free_balance(KSM, &ALICE), 4017); - Farming::on_initialize(0); + Farming::on_initialize(1); System::set_block_number(System::block_number() + 20); assert_ok!(Farming::claim(RuntimeOrigin::signed(ALICE), pid)); assert_eq!(Tokens::free_balance(KSM, &ALICE), 4396); @@ -277,6 +277,13 @@ fn init_gauge() -> (PoolId, BalanceOf) { let basic_rewards = vec![(KSM, 1000)]; let gauge_basic_rewards = vec![(KSM, 990_000)]; + let pid = 0; + + let gauge_reward_issuer: AccountId = + ::GaugeRewardIssuer::get().into_sub_account_truncating(pid); + assert_ok!(Tokens::deposit(KSM, &gauge_reward_issuer, 990_000)); + assert_eq!(Tokens::free_balance(KSM, &gauge_reward_issuer), 990_000); + assert_ok!(Farming::create_farming_pool( RuntimeOrigin::signed(ALICE), tokens_proportion.clone(), @@ -289,12 +296,10 @@ fn init_gauge() -> (PoolId, BalanceOf) { 5 )); - let pid = 0; let charge_rewards = vec![(KSM, 300000)]; assert_ok!(Farming::charge(RuntimeOrigin::signed(BOB), pid, charge_rewards, false)); assert_ok!(Farming::deposit(RuntimeOrigin::signed(ALICE), pid, tokens)); assert_ok!(BbBNC::set_config(RuntimeOrigin::signed(ALICE), Some(0), Some(7 * 86400 / 12))); - assert_ok!(BbBNC::notify_reward_amount(pid, &Some(CHARLIE), gauge_basic_rewards.clone())); assert_ok!(BbBNC::create_lock_inner( &ALICE, 100_000_000_000, @@ -498,8 +503,6 @@ fn start_boost_round() { #[test] fn vote() { ExtBuilder::default().one_hundred_for_alice_n_bob().build().execute_with(|| { - env_logger::try_init().unwrap_or(()); - BbBNC::set_incentive(0, Some(7 * 86400 / 12), Some(ALICE.clone())); let (pid, _tokens) = init_gauge(); diff --git a/pallets/flexible-fee/src/lib.rs b/pallets/flexible-fee/src/lib.rs index 48a065209..074b0e18d 100644 --- a/pallets/flexible-fee/src/lib.rs +++ b/pallets/flexible-fee/src/lib.rs @@ -159,7 +159,7 @@ pub mod pallet { } /// The current storage version, we set to 2 our new version. - const STORAGE_VERSION: StorageVersion = StorageVersion::new(2); + const STORAGE_VERSION: StorageVersion = StorageVersion::new(3); /// Universal fee currency order list for all users #[pallet::storage] @@ -188,12 +188,19 @@ pub mod pallet { #[pallet::error] pub enum Error { + /// The account does not have enough balance to perform the operation. NotEnoughBalance, + /// An error occurred during currency conversion. ConversionError, + /// No weight or fee information is available for the requested operation. WeightAndFeeNotExist, + /// The message cannot be weighed, possibly due to insufficient information. UnweighableMessage, + /// The XCM execution has failed. XcmExecutionFailed, + /// The specified currency is not supported by the system. CurrencyNotSupport, + /// The maximum number of currencies that can be handled has been reached. MaxCurrenciesReached, } @@ -212,6 +219,9 @@ pub mod pallet { let who = ensure_signed(origin)?; if let Some(fee_currency) = ¤cy_id { + // VBNC is not supported. + ensure!(fee_currency != &VBNC, Error::::CurrencyNotSupport); + UserDefaultFeeCurrency::::insert(&who, fee_currency); } else { UserDefaultFeeCurrency::::remove(&who); diff --git a/pallets/flexible-fee/src/migrations/mod.rs b/pallets/flexible-fee/src/migrations/mod.rs index 504be9301..0ec4683cc 100644 --- a/pallets/flexible-fee/src/migrations/mod.rs +++ b/pallets/flexible-fee/src/migrations/mod.rs @@ -18,3 +18,6 @@ /// Version 2. pub mod v2; + +/// Version 3. +pub mod v3; diff --git a/pallets/flexible-fee/src/migrations/v3.rs b/pallets/flexible-fee/src/migrations/v3.rs new file mode 100644 index 000000000..3aee0ee54 --- /dev/null +++ b/pallets/flexible-fee/src/migrations/v3.rs @@ -0,0 +1,148 @@ +// This file is part of Bifrost. + +// Copyright (C) Liebi Technologies PTE. LTD. +// SPDX-License-Identifier: GPL-3.0-or-later WITH Classpath-exception-2.0 + +// This program is free software: you can redistribute it and/or modify +// it under the terms of the GNU General Public License as published by +// the Free Software Foundation, either version 3 of the License, or +// (at your option) any later version. + +// This program is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. + +// You should have received a copy of the GNU General Public License +// along with this program. If not, see . + +use crate::*; +use bifrost_primitives::BNC; +use frame_support::traits::OnRuntimeUpgrade; +#[cfg(feature = "try-runtime")] +use sp_runtime::TryRuntimeError; + +const LOG_TARGET: &str = "flexible-fee::migration"; + +pub struct MigrateToV3(sp_std::marker::PhantomData); +impl OnRuntimeUpgrade for MigrateToV3 { + fn on_runtime_upgrade() -> frame_support::weights::Weight { + // Check the storage version + let onchain_version = Pallet::::on_chain_storage_version(); + if onchain_version < 3 { + log::info!(target: LOG_TARGET, "Start to migrate flexible-fee storage..."); + + let mut count: u64 = 0; + + // Traversal UserDefaultFeeCurrency storage + UserDefaultFeeCurrency::::iter().for_each(|(account_id, currency_id)| { + // If currency_id is vbnc, change it to bnc + if currency_id == VBNC { + count += 1; + UserDefaultFeeCurrency::::insert(account_id, BNC); + } + }); + + // Update the storage version + StorageVersion::new(3).put::>(); + + // Return the consumed weight + Weight::from(T::DbWeight::get().reads_writes(count + 1, count + 1)) + } else { + // We don't do anything here. + Weight::zero() + } + } + + #[cfg(feature = "try-runtime")] + fn pre_upgrade() -> Result, TryRuntimeError> { + let total_count = UserDefaultFeeCurrency::::iter().count(); + + let mut vbnc_count: u64 = 0; + UserDefaultFeeCurrency::::iter().for_each(|(_, currency_id)| { + if currency_id == VBNC { + vbnc_count += 1; + } + }); + + // print out the pre-migrate storage count + log::info!( + target: LOG_TARGET, + "UserDefaultFeeCurrency pre-migrate storage total count: {:?}", + total_count + ); + log::info!( + target: LOG_TARGET, + "UserDefaultFeeCurrency pre-migrate storage vbnc count: {:?}", + vbnc_count + ); + Ok((total_count as u64).encode()) + } + + #[cfg(feature = "try-runtime")] + fn post_upgrade(cnt: Vec) -> Result<(), TryRuntimeError> { + let old_total_count: u64 = Decode::decode(&mut cnt.as_slice()) + .expect("the state parameter should be something that was generated by pre_upgrade"); + + let new_total_count = UserDefaultFeeCurrency::::iter().count(); + + let mut new_vbnc_count: u64 = 0; + UserDefaultFeeCurrency::::iter().for_each(|(_, currency_id)| { + if currency_id == VBNC { + new_vbnc_count += 1; + } + }); + + // print out the post-migrate storage count + log::info!( + target: LOG_TARGET, + "UserDefaultFeeCurrency post-migrate storage total count: {:?}", + new_total_count + ); + log::info!( + target: LOG_TARGET, + "UserDefaultFeeCurrency post-migrate storage vbnc count: {:?}", + new_vbnc_count + ); + + ensure!( + new_total_count as u64 == old_total_count, + "Post-migration storage total count does not match pre-migration total count" + ); + ensure!( + new_vbnc_count == 0, + "Post-migration storage vbnc count does not match pre-migration vbnc count" + ); + Ok(()) + } +} + +pub struct PolkadotMigrateToV3(sp_std::marker::PhantomData); +impl OnRuntimeUpgrade for PolkadotMigrateToV3 { + fn on_runtime_upgrade() -> frame_support::weights::Weight { + // Check the storage version + let onchain_version = Pallet::::on_chain_storage_version(); + if onchain_version < 3 { + log::info!(target: LOG_TARGET, "In the Polkadot environment, no migration will be performed; only the version number will be updated.."); + + // Update the storage version + StorageVersion::new(3).put::>(); + + // Return the consumed weight + Weight::from(T::DbWeight::get().reads_writes(1, 1)) + } else { + // We don't do anything here. + Weight::zero() + } + } + + #[cfg(feature = "try-runtime")] + fn pre_upgrade() -> Result, TryRuntimeError> { + Ok(sp_std::vec![]) + } + + #[cfg(feature = "try-runtime")] + fn post_upgrade(_cnt: Vec) -> Result<(), TryRuntimeError> { + Ok(()) + } +} diff --git a/pallets/flexible-fee/src/tests.rs b/pallets/flexible-fee/src/tests.rs index ce373e01e..e7ffb47f1 100644 --- a/pallets/flexible-fee/src/tests.rs +++ b/pallets/flexible-fee/src/tests.rs @@ -21,10 +21,11 @@ #![cfg(test)] use crate::{ impls::on_charge_transaction::PaymentInfo, mock::*, BlockNumberFor, BoundedVec, Config, - DispatchError::BadOrigin, UserDefaultFeeCurrency, + DispatchError::BadOrigin, Error, UserDefaultFeeCurrency, }; use bifrost_primitives::{ - AccountFeeCurrency, BalanceCmp, CurrencyId, TryConvertFrom, BNC, DOT, KSM, MANTA, VDOT, WETH, + AccountFeeCurrency, BalanceCmp, CurrencyId, TryConvertFrom, BNC, DOT, KSM, MANTA, VBNC, VDOT, + WETH, }; use frame_support::{ assert_noop, assert_ok, @@ -151,6 +152,19 @@ fn set_user_default_fee_currency_should_work() { }); } +#[test] +fn set_user_default_fee_currency_should_fail_with_error_currency() { + new_test_ext().execute_with(|| { + let origin_signed_alice = RuntimeOrigin::signed(ALICE); + assert_noop!( + FlexibleFee::set_user_default_fee_currency(origin_signed_alice.clone(), Some(VBNC)), + Error::::CurrencyNotSupport + ); + + assert_eq!(UserDefaultFeeCurrency::::get(ALICE).is_none(), true); + }); +} + #[test] fn set_default_fee_currency_list_should_work() { new_test_ext().execute_with(|| { diff --git a/pallets/prices/src/lib.rs b/pallets/prices/src/lib.rs index a65516974..5ca2071f5 100644 --- a/pallets/prices/src/lib.rs +++ b/pallets/prices/src/lib.rs @@ -35,7 +35,6 @@ pub use pallet::*; use pallet_traits::*; use sp_runtime::{traits::CheckedDiv, FixedU128}; use sp_std::vec::Vec; -use xcm::v3::MultiLocation; #[cfg(test)] mod mock; @@ -79,11 +78,7 @@ pub mod pallet { type RelayCurrency: Get; /// Convert Location to `T::CurrencyId`. - type CurrencyIdConvert: CurrencyIdMapping< - CurrencyId, - MultiLocation, - AssetMetadata>, - >; + type CurrencyIdConvert: CurrencyIdMapping>>; /// Weight information type WeightInfo: WeightInfo; diff --git a/pallets/slp/src/lib.rs b/pallets/slp/src/lib.rs index 4ca0f422a..443002b58 100644 --- a/pallets/slp/src/lib.rs +++ b/pallets/slp/src/lib.rs @@ -167,11 +167,7 @@ pub mod pallet { >; // asset registry to get asset metadata - type AssetIdMaps: CurrencyIdMapping< - CurrencyId, - MultiLocation, - AssetMetadata>, - >; + type AssetIdMaps: CurrencyIdMapping>>; #[pallet::constant] type TreasuryAccount: Get; @@ -2290,6 +2286,8 @@ impl>> Self::get_multilocation(token, derivative_index).and_then(|location| { DelegatorLedgers::::get(token, location).and_then(|ledger| match ledger { Ledger::Substrate(l) if F::contains(&token) => Some((l.total, l.active)), + Ledger::ParachainStaking(l) if F::contains(&token) => + Some((l.total, l.total.checked_sub(&l.less_total).unwrap_or_default())), _ => None, }) }) diff --git a/pallets/slpx/src/benchmarking.rs b/pallets/slpx/src/benchmarking.rs index 8a43cd007..b20ced5ba 100644 --- a/pallets/slpx/src/benchmarking.rs +++ b/pallets/slpx/src/benchmarking.rs @@ -131,6 +131,23 @@ mod benchmarks { _(RawOrigin::Signed(caller), receiver, VKSM, TargetChain::Astar(receiver)); } + #[benchmark] + fn evm_create_order() { + let (caller, receiver) = init_whitelist::(); + #[extrinsic_call] + _( + RawOrigin::Signed(caller), + receiver, + 592, + 0, + KSM, + BalanceOf::::unique_saturated_from(100_000_000_000_000u128), + TargetChain::Astar(receiver), + BoundedVec::default(), + 0, + ); + } + // `cargo test -p pallet-example-basic --all-features`, you will see one line per case: impl_benchmark_test_suite!(Pallet, crate::mock::new_test_ext(), crate::mock::Test); } diff --git a/pallets/slpx/src/lib.rs b/pallets/slpx/src/lib.rs index 1e3fdb129..3d3f0d399 100644 --- a/pallets/slpx/src/lib.rs +++ b/pallets/slpx/src/lib.rs @@ -110,11 +110,7 @@ pub mod pallet { /// Send Xcm type XcmSender: SendXcm; /// Convert Location to `T::CurrencyId`. - type CurrencyIdConvert: CurrencyIdMapping< - CurrencyId, - xcm::v3::MultiLocation, - AssetMetadata>, - >; + type CurrencyIdConvert: CurrencyIdMapping>>; /// TreasuryAccount #[pallet::constant] type TreasuryAccount: Get>; diff --git a/pallets/slpx/src/mock.rs b/pallets/slpx/src/mock.rs index 12c3aa264..605c72a8c 100644 --- a/pallets/slpx/src/mock.rs +++ b/pallets/slpx/src/mock.rs @@ -248,13 +248,13 @@ parameter_types! { pub struct CurrencyIdConvert(sp_std::marker::PhantomData); impl> Convert> for CurrencyIdConvert { fn convert(id: CurrencyId) -> Option { - AssetIdMaps::::get_location(id) + AssetIdMaps::::get_location(&id) } } impl> Convert> for CurrencyIdConvert { fn convert(location: Location) -> Option { - AssetIdMaps::::get_currency_id(location) + AssetIdMaps::::get_currency_id(&location) } } diff --git a/pallets/slpx/src/weights.rs b/pallets/slpx/src/weights.rs index 33c9b0dce..4fe222cca 100644 --- a/pallets/slpx/src/weights.rs +++ b/pallets/slpx/src/weights.rs @@ -24,25 +24,27 @@ //! Autogenerated weights for bifrost_slpx //! -//! THIS FILE WAS AUTO-GENERATED USING THE SUBSTRATE BENCHMARK CLI VERSION 4.0.0-dev -//! DATE: 2023-09-14, STEPS: `50`, REPEAT: 20, LOW RANGE: `[]`, HIGH RANGE: `[]` +//! THIS FILE WAS AUTO-GENERATED USING THE SUBSTRATE BENCHMARK CLI VERSION 32.0.0 +//! DATE: 2024-11-20, STEPS: `50`, REPEAT: 20, LOW RANGE: `[]`, HIGH RANGE: `[]` //! HOSTNAME: `bifrost-jenkins`, CPU: `Intel(R) Xeon(R) CPU E5-26xx v4` //! WASM-EXECUTION: Compiled, CHAIN: Some("bifrost-kusama-local"), DB CACHE: 1024 // Executed Command: -// target/release/bifrost +// ./target/release/bifrost // benchmark // pallet // --chain=bifrost-kusama-local // --steps=50 // --repeat=20 -// --pallet=bifrost_slpx +// --pallet=bifrost-slpx // --extrinsic=* // --execution=wasm // --wasm-execution=compiled // --heap-pages=4096 -// --output=./pallets/slpx/src/weights.rs -// --template=./weight-template/pallet-weight-template.hbs +// --header=./HEADER-GPL3 +// --output=./weight.rs +// --template +// ./weight-template/pallet-weight-template.hbs #![cfg_attr(rustfmt, rustfmt_skip)] #![allow(unused_parens)] @@ -60,199 +62,103 @@ pub trait WeightInfo { fn mint() -> Weight; fn mint_with_channel_id() -> Weight; fn redeem() -> Weight; - fn zenlink_swap() -> Weight; - fn stable_pool_swap() -> Weight; + fn evm_create_order() -> Weight; } // For backwards compatibility and tests impl WeightInfo for () { - /// Storage: Slpx WhitelistAccountId (r:1 w:1) - /// Proof: Slpx WhitelistAccountId (max_values: None, max_size: Some(338), added: 2813, mode: MaxEncodedLen) + /// Storage: `Slpx::WhitelistAccountId` (r:1 w:1) + /// Proof: `Slpx::WhitelistAccountId` (`max_values`: None, `max_size`: Some(338), added: 2813, mode: `MaxEncodedLen`) fn add_whitelist() -> Weight { // Proof Size summary in bytes: // Measured: `4` // Estimated: `3803` - // Minimum execution time: 33_813_000 picoseconds. - Weight::from_parts(34_425_000, 3803) + // Minimum execution time: 25_376_000 picoseconds. + Weight::from_parts(26_123_000, 3803) .saturating_add(RocksDbWeight::get().reads(1_u64)) .saturating_add(RocksDbWeight::get().writes(1_u64)) } - /// Storage: Slpx WhitelistAccountId (r:1 w:1) - /// Proof: Slpx WhitelistAccountId (max_values: None, max_size: Some(338), added: 2813, mode: MaxEncodedLen) + /// Storage: `Slpx::WhitelistAccountId` (r:1 w:1) + /// Proof: `Slpx::WhitelistAccountId` (`max_values`: None, `max_size`: Some(338), added: 2813, mode: `MaxEncodedLen`) fn remove_whitelist() -> Weight { // Proof Size summary in bytes: // Measured: `81` // Estimated: `3803` - // Minimum execution time: 36_169_000 picoseconds. - Weight::from_parts(37_581_000, 3803) + // Minimum execution time: 27_460_000 picoseconds. + Weight::from_parts(28_054_000, 3803) .saturating_add(RocksDbWeight::get().reads(1_u64)) .saturating_add(RocksDbWeight::get().writes(1_u64)) } - /// Storage: Slpx ExecutionFee (r:0 w:1) - /// Proof: Slpx ExecutionFee (max_values: None, max_size: Some(46), added: 2521, mode: MaxEncodedLen) + /// Storage: `Slpx::ExecutionFee` (r:0 w:1) + /// Proof: `Slpx::ExecutionFee` (`max_values`: None, `max_size`: Some(46), added: 2521, mode: `MaxEncodedLen`) fn set_execution_fee() -> Weight { // Proof Size summary in bytes: // Measured: `0` // Estimated: `0` - // Minimum execution time: 24_261_000 picoseconds. - Weight::from_parts(25_400_000, 0) + // Minimum execution time: 15_854_000 picoseconds. + Weight::from_parts(16_280_000, 0) .saturating_add(RocksDbWeight::get().writes(1_u64)) } - /// Storage: Slpx TransferToFee (r:0 w:1) - /// Proof: Slpx TransferToFee (max_values: None, max_size: Some(33), added: 2508, mode: MaxEncodedLen) + /// Storage: `Slpx::TransferToFee` (r:0 w:1) + /// Proof: `Slpx::TransferToFee` (`max_values`: None, `max_size`: Some(33), added: 2508, mode: `MaxEncodedLen`) fn set_transfer_to_fee() -> Weight { // Proof Size summary in bytes: // Measured: `0` // Estimated: `0` - // Minimum execution time: 23_834_000 picoseconds. - Weight::from_parts(24_458_000, 0) + // Minimum execution time: 15_482_000 picoseconds. + Weight::from_parts(15_979_000, 0) .saturating_add(RocksDbWeight::get().writes(1_u64)) } - /// Storage: Slpx WhitelistAccountId (r:1 w:0) - /// Proof: Slpx WhitelistAccountId (max_values: None, max_size: Some(338), added: 2813, mode: MaxEncodedLen) - /// Storage: Tokens Accounts (r:4 w:4) - /// Proof: Tokens Accounts (max_values: None, max_size: Some(118), added: 2593, mode: MaxEncodedLen) - /// Storage: Slpx ExecutionFee (r:1 w:0) - /// Proof: Slpx ExecutionFee (max_values: None, max_size: Some(46), added: 2521, mode: MaxEncodedLen) - /// Storage: AssetRegistry CurrencyMetadatas (r:1 w:0) - /// Proof Skipped: AssetRegistry CurrencyMetadatas (max_values: None, max_size: None, mode: Measured) - /// Storage: System Account (r:3 w:2) - /// Proof: System Account (max_values: None, max_size: Some(128), added: 2603, mode: MaxEncodedLen) - /// Storage: VtokenMinting MinimumMint (r:1 w:0) - /// Proof: VtokenMinting MinimumMint (max_values: None, max_size: Some(38), added: 2513, mode: MaxEncodedLen) - /// Storage: VtokenMinting TokenPool (r:1 w:1) - /// Proof: VtokenMinting TokenPool (max_values: None, max_size: Some(38), added: 2513, mode: MaxEncodedLen) - /// Storage: Tokens TotalIssuance (r:1 w:1) - /// Proof: Tokens TotalIssuance (max_values: None, max_size: Some(38), added: 2513, mode: MaxEncodedLen) - /// Storage: VtokenMinting Fees (r:1 w:0) - /// Proof: VtokenMinting Fees (max_values: Some(1), max_size: Some(8), added: 503, mode: MaxEncodedLen) - /// Storage: AssetRegistry CurrencyIdToLocations (r:1 w:0) - /// Proof Skipped: AssetRegistry CurrencyIdToLocations (max_values: None, max_size: None, mode: Measured) - /// Storage: ParachainInfo ParachainId (r:1 w:0) - /// Proof: ParachainInfo ParachainId (max_values: Some(1), max_size: Some(4), added: 499, mode: MaxEncodedLen) + /// Storage: `Slpx::WhitelistAccountId` (r:1 w:0) + /// Proof: `Slpx::WhitelistAccountId` (`max_values`: None, `max_size`: Some(338), added: 2813, mode: `MaxEncodedLen`) + /// Storage: `Slpx::OrderQueue` (r:1 w:1) + /// Proof: `Slpx::OrderQueue` (`max_values`: Some(1), `max_size`: Some(113502), added: 113997, mode: `MaxEncodedLen`) fn mint() -> Weight { // Proof Size summary in bytes: - // Measured: `2442` - // Estimated: `11362` - // Minimum execution time: 357_850_000 picoseconds. - Weight::from_parts(367_522_000, 11362) - .saturating_add(RocksDbWeight::get().reads(16_u64)) - .saturating_add(RocksDbWeight::get().writes(8_u64)) + // Measured: `81` + // Estimated: `114987` + // Minimum execution time: 33_529_000 picoseconds. + Weight::from_parts(34_511_000, 114987) + .saturating_add(RocksDbWeight::get().reads(2_u64)) + .saturating_add(RocksDbWeight::get().writes(1_u64)) } - /// Storage: Slpx WhitelistAccountId (r:1 w:0) - /// Proof: Slpx WhitelistAccountId (max_values: None, max_size: Some(338), added: 2813, mode: MaxEncodedLen) - /// Storage: Tokens Accounts (r:4 w:4) - /// Proof: Tokens Accounts (max_values: None, max_size: Some(118), added: 2593, mode: MaxEncodedLen) - /// Storage: Slpx ExecutionFee (r:1 w:0) - /// Proof: Slpx ExecutionFee (max_values: None, max_size: Some(46), added: 2521, mode: MaxEncodedLen) - /// Storage: AssetRegistry CurrencyMetadatas (r:1 w:0) - /// Proof Skipped: AssetRegistry CurrencyMetadatas (max_values: None, max_size: None, mode: Measured) - /// Storage: System Account (r:3 w:2) - /// Proof: System Account (max_values: None, max_size: Some(128), added: 2603, mode: MaxEncodedLen) - /// Storage: VtokenMinting MinimumMint (r:1 w:0) - /// Proof: VtokenMinting MinimumMint (max_values: None, max_size: Some(38), added: 2513, mode: MaxEncodedLen) - /// Storage: VtokenMinting TokenPool (r:1 w:1) - /// Proof: VtokenMinting TokenPool (max_values: None, max_size: Some(38), added: 2513, mode: MaxEncodedLen) - /// Storage: Tokens TotalIssuance (r:1 w:1) - /// Proof: Tokens TotalIssuance (max_values: None, max_size: Some(38), added: 2513, mode: MaxEncodedLen) - /// Storage: VtokenMinting Fees (r:1 w:0) - /// Proof: VtokenMinting Fees (max_values: Some(1), max_size: Some(8), added: 503, mode: MaxEncodedLen) - /// Storage: AssetRegistry CurrencyIdToLocations (r:1 w:0) - /// Proof Skipped: AssetRegistry CurrencyIdToLocations (max_values: None, max_size: None, mode: Measured) - /// Storage: ParachainInfo ParachainId (r:1 w:0) - /// Proof: ParachainInfo ParachainId (max_values: Some(1), max_size: Some(4), added: 499, mode: MaxEncodedLen) + /// Storage: `Slpx::WhitelistAccountId` (r:1 w:0) + /// Proof: `Slpx::WhitelistAccountId` (`max_values`: None, `max_size`: Some(338), added: 2813, mode: `MaxEncodedLen`) + /// Storage: `Slpx::OrderQueue` (r:1 w:1) + /// Proof: `Slpx::OrderQueue` (`max_values`: Some(1), `max_size`: Some(113502), added: 113997, mode: `MaxEncodedLen`) fn mint_with_channel_id() -> Weight { // Proof Size summary in bytes: - // Measured: `2442` - // Estimated: `11362` - // Minimum execution time: 357_850_000 picoseconds. - Weight::from_parts(367_522_000, 11362) - .saturating_add(RocksDbWeight::get().reads(16_u64)) - .saturating_add(RocksDbWeight::get().writes(8_u64)) + // Measured: `81` + // Estimated: `114987` + // Minimum execution time: 32_901_000 picoseconds. + Weight::from_parts(33_851_000, 114987) + .saturating_add(RocksDbWeight::get().reads(2_u64)) + .saturating_add(RocksDbWeight::get().writes(1_u64)) } - /// Storage: Slpx WhitelistAccountId (r:1 w:0) - /// Proof: Slpx WhitelistAccountId (max_values: None, max_size: Some(338), added: 2813, mode: MaxEncodedLen) - /// Storage: Tokens Accounts (r:2 w:2) - /// Proof: Tokens Accounts (max_values: None, max_size: Some(118), added: 2593, mode: MaxEncodedLen) - /// Storage: Slpx ExecutionFee (r:1 w:0) - /// Proof: Slpx ExecutionFee (max_values: None, max_size: Some(46), added: 2521, mode: MaxEncodedLen) - /// Storage: AssetRegistry CurrencyMetadatas (r:2 w:0) - /// Proof Skipped: AssetRegistry CurrencyMetadatas (max_values: None, max_size: None, mode: Measured) - /// Storage: System Account (r:2 w:1) - /// Proof: System Account (max_values: None, max_size: Some(128), added: 2603, mode: MaxEncodedLen) - /// Storage: VtokenMinting MinimumRedeem (r:1 w:0) - /// Proof: VtokenMinting MinimumRedeem (max_values: None, max_size: Some(38), added: 2513, mode: MaxEncodedLen) - /// Storage: Slp DelegationsOccupied (r:1 w:0) - /// Proof Skipped: Slp DelegationsOccupied (max_values: None, max_size: None, mode: Measured) - /// Storage: VtokenMinting Fees (r:1 w:0) - /// Proof: VtokenMinting Fees (max_values: Some(1), max_size: Some(8), added: 503, mode: MaxEncodedLen) - /// Storage: VtokenMinting TokenPool (r:1 w:0) - /// Proof: VtokenMinting TokenPool (max_values: None, max_size: Some(38), added: 2513, mode: MaxEncodedLen) - /// Storage: Tokens TotalIssuance (r:1 w:0) - /// Proof: Tokens TotalIssuance (max_values: None, max_size: Some(38), added: 2513, mode: MaxEncodedLen) - /// Storage: VtokenMinting OngoingTimeUnit (r:1 w:0) - /// Proof: VtokenMinting OngoingTimeUnit (max_values: None, max_size: Some(27), added: 2502, mode: MaxEncodedLen) - /// Storage: AssetRegistry CurrencyIdToLocations (r:1 w:0) - /// Proof Skipped: AssetRegistry CurrencyIdToLocations (max_values: None, max_size: None, mode: Measured) - /// Storage: ParachainInfo ParachainId (r:1 w:0) - /// Proof: ParachainInfo ParachainId (max_values: Some(1), max_size: Some(4), added: 499, mode: MaxEncodedLen) + /// Storage: `Slpx::WhitelistAccountId` (r:1 w:0) + /// Proof: `Slpx::WhitelistAccountId` (`max_values`: None, `max_size`: Some(338), added: 2813, mode: `MaxEncodedLen`) + /// Storage: `Slpx::OrderQueue` (r:1 w:1) + /// Proof: `Slpx::OrderQueue` (`max_values`: Some(1), `max_size`: Some(113502), added: 113997, mode: `MaxEncodedLen`) fn redeem() -> Weight { // Proof Size summary in bytes: - // Measured: `2194` - // Estimated: `8134` - // Minimum execution time: 243_045_000 picoseconds. - Weight::from_parts(247_937_000, 8134) - .saturating_add(RocksDbWeight::get().reads(16_u64)) - .saturating_add(RocksDbWeight::get().writes(3_u64)) - } - /// Storage: Slpx WhitelistAccountId (r:1 w:0) - /// Proof: Slpx WhitelistAccountId (max_values: None, max_size: Some(338), added: 2813, mode: MaxEncodedLen) - /// Storage: ParachainInfo ParachainId (r:1 w:0) - /// Proof: ParachainInfo ParachainId (max_values: Some(1), max_size: Some(4), added: 499, mode: MaxEncodedLen) - /// Storage: Tokens Accounts (r:4 w:2) - /// Proof: Tokens Accounts (max_values: None, max_size: Some(118), added: 2593, mode: MaxEncodedLen) - /// Storage: Slpx ExecutionFee (r:1 w:0) - /// Proof: Slpx ExecutionFee (max_values: None, max_size: Some(46), added: 2521, mode: MaxEncodedLen) - /// Storage: AssetRegistry CurrencyMetadatas (r:1 w:0) - /// Proof Skipped: AssetRegistry CurrencyMetadatas (max_values: None, max_size: None, mode: Measured) - /// Storage: System Account (r:2 w:1) - /// Proof: System Account (max_values: None, max_size: Some(128), added: 2603, mode: MaxEncodedLen) - /// Storage: AssetRegistry CurrencyIdToLocations (r:1 w:0) - /// Proof Skipped: AssetRegistry CurrencyIdToLocations (max_values: None, max_size: None, mode: Measured) - fn zenlink_swap() -> Weight { - // Proof Size summary in bytes: - // Measured: `1819` - // Estimated: `11362` - // Minimum execution time: 221_285_000 picoseconds. - Weight::from_parts(225_387_000, 11362) - .saturating_add(RocksDbWeight::get().reads(11_u64)) - .saturating_add(RocksDbWeight::get().writes(3_u64)) + // Measured: `81` + // Estimated: `114987` + // Minimum execution time: 32_912_000 picoseconds. + Weight::from_parts(33_600_000, 114987) + .saturating_add(RocksDbWeight::get().reads(2_u64)) + .saturating_add(RocksDbWeight::get().writes(1_u64)) } - /// Storage: Slpx WhitelistAccountId (r:1 w:0) - /// Proof: Slpx WhitelistAccountId (max_values: None, max_size: Some(338), added: 2813, mode: MaxEncodedLen) - /// Storage: StableAsset Pools (r:1 w:0) - /// Proof Skipped: StableAsset Pools (max_values: None, max_size: None, mode: Measured) - /// Storage: Tokens Accounts (r:6 w:2) - /// Proof: Tokens Accounts (max_values: None, max_size: Some(118), added: 2593, mode: MaxEncodedLen) - /// Storage: Slpx ExecutionFee (r:1 w:0) - /// Proof: Slpx ExecutionFee (max_values: None, max_size: Some(46), added: 2521, mode: MaxEncodedLen) - /// Storage: AssetRegistry CurrencyMetadatas (r:1 w:0) - /// Proof Skipped: AssetRegistry CurrencyMetadatas (max_values: None, max_size: None, mode: Measured) - /// Storage: System Account (r:3 w:1) - /// Proof: System Account (max_values: None, max_size: Some(128), added: 2603, mode: MaxEncodedLen) - /// Storage: StableAsset TokenRateCaches (r:2 w:0) - /// Proof Skipped: StableAsset TokenRateCaches (max_values: None, max_size: None, mode: Measured) - /// Storage: AssetRegistry CurrencyIdToLocations (r:1 w:0) - /// Proof Skipped: AssetRegistry CurrencyIdToLocations (max_values: None, max_size: None, mode: Measured) - /// Storage: ParachainInfo ParachainId (r:1 w:0) - /// Proof: ParachainInfo ParachainId (max_values: Some(1), max_size: Some(4), added: 499, mode: MaxEncodedLen) - fn stable_pool_swap() -> Weight { + /// Storage: `Slpx::WhitelistAccountId` (r:1 w:0) + /// Proof: `Slpx::WhitelistAccountId` (`max_values`: None, `max_size`: Some(338), added: 2813, mode: `MaxEncodedLen`) + /// Storage: `Slpx::OrderQueue` (r:1 w:1) + /// Proof: `Slpx::OrderQueue` (`max_values`: Some(1), `max_size`: Some(113502), added: 113997, mode: `MaxEncodedLen`) + fn evm_create_order() -> Weight { // Proof Size summary in bytes: - // Measured: `2782` - // Estimated: `16548` - // Minimum execution time: 555_626_000 picoseconds. - Weight::from_parts(568_903_000, 16548) - .saturating_add(RocksDbWeight::get().reads(17_u64)) - .saturating_add(RocksDbWeight::get().writes(3_u64)) + // Measured: `81` + // Estimated: `114987` + // Minimum execution time: 32_556_000 picoseconds. + Weight::from_parts(33_884_000, 114987) + .saturating_add(RocksDbWeight::get().reads(2_u64)) + .saturating_add(RocksDbWeight::get().writes(1_u64)) } -} +} \ No newline at end of file diff --git a/pallets/system-staking/src/lib.rs b/pallets/system-staking/src/lib.rs index 9f6f8daee..13d32627c 100644 --- a/pallets/system-staking/src/lib.rs +++ b/pallets/system-staking/src/lib.rs @@ -87,7 +87,7 @@ pub mod pallet { >; #[pallet::constant] - type TreasuryAccount: Get; + type BenefitReceivingAccount: Get; /// Max token length 500 #[pallet::constant] @@ -509,7 +509,7 @@ pub mod pallet { Ok(().into()) } - /// payout to treasury + /// payout to receiving account #[pallet::call_index(3)] #[pallet::weight(::WeightInfo::payout())] pub fn payout(origin: OriginFor, token: CurrencyIdOf) -> DispatchResultWithPostInfo { @@ -539,11 +539,11 @@ pub mod pallet { token_amount, )?; - // Transfer vtoken(benefits) to TreasuryAccount + // Transfer vtoken(benefits) to BenefitReceivingAccount T::MultiCurrency::transfer( vtoken_id, &pallet_account, - &T::TreasuryAccount::get(), + &T::BenefitReceivingAccount::get(), vtoken_amount, ) .map_err(|_| Error::::PayoutFailed)?; @@ -552,7 +552,7 @@ pub mod pallet { token, vtoken: vtoken_id, from: pallet_account, - to: T::TreasuryAccount::get(), + to: T::BenefitReceivingAccount::get(), amount: vtoken_amount, vfree: vfree_amount, free: free_amount, diff --git a/pallets/system-staking/src/mock.rs b/pallets/system-staking/src/mock.rs index 4bd238afb..b70453057 100644 --- a/pallets/system-staking/src/mock.rs +++ b/pallets/system-staking/src/mock.rs @@ -59,6 +59,8 @@ pub const BOB: AccountId = AccountId32::new([1u8; 32]); pub const CHARLIE: AccountId = AccountId32::new([3u8; 32]); pub const TREASURY_ACCOUNT: AccountId32 = AccountId32::new([9u8; 32]); +pub const BENEFIT_RECEIVING_ACCOUNT: AccountId32 = AccountId32::new([9u8; 32]); + frame_support::construct_runtime!( pub enum Runtime { System: frame_system, @@ -79,6 +81,7 @@ type Block = frame_system::mocking::MockBlock; parameter_types! { pub const BlockHashCount: u64 = 250; + pub const TreasuryAccount: AccountId32 = TREASURY_ACCOUNT; } #[derive_impl(frame_system::config_preludes::TestDefaultConfig as frame_system::DefaultConfig)] @@ -296,7 +299,7 @@ impl bifrost_farming::Config for Runtime { } parameter_types! { - pub const TreasuryAccount: AccountId32 = TREASURY_ACCOUNT; + pub const BenefitReceivingAccount: AccountId32 = BENEFIT_RECEIVING_ACCOUNT; pub const BlocksPerRound: u32 = 5; pub const MaxTokenLen: u32 = 50; pub const MaxFarmingPoolIdLen: u32 = 100; @@ -309,7 +312,7 @@ impl system_staking::Config for Runtime { type WeightInfo = (); type FarmingInfo = Farming; type VtokenMintingInterface = VtokenMinting; - type TreasuryAccount = TreasuryAccount; + type BenefitReceivingAccount = BenefitReceivingAccount; type PalletId = SystemStakingPalletId; type BlocksPerRound = BlocksPerRound; type MaxTokenLen = MaxTokenLen; diff --git a/pallets/vtoken-minting/src/impls.rs b/pallets/vtoken-minting/src/impls.rs index d0315f99b..54efa07e5 100644 --- a/pallets/vtoken-minting/src/impls.rs +++ b/pallets/vtoken-minting/src/impls.rs @@ -376,6 +376,10 @@ impl Pallet { redeem_type, )?; + if redeem_currency_amount == Default::default() { + return Ok(()); + } + Self::update_unlock_ledger( &redeemer, &redeem_currency_id, @@ -523,17 +527,20 @@ impl Pallet { }; Ok((redeem_currency_amount, redeem_to)) } else { - redeem_currency_amount = entrance_account_balance; - let ed = T::MultiCurrency::minimum_balance(redeem_currency_id); - if redeem_currency_amount >= ed { - T::MultiCurrency::transfer( - redeem_currency_id, - &entrance_account, - &redeemer, - redeem_currency_amount, - )?; + if let RedeemType::Native = redeem_type { + redeem_currency_amount = entrance_account_balance; + let ed = T::MultiCurrency::minimum_balance(redeem_currency_id); + if redeem_currency_amount >= ed { + T::MultiCurrency::transfer( + redeem_currency_id, + &entrance_account, + &redeemer, + redeem_currency_amount, + )?; + } + return Ok((redeem_currency_amount, RedeemTo::Native(redeemer))); } - Ok((redeem_currency_amount, RedeemTo::Native(redeemer))) + Ok((Default::default(), RedeemTo::Native(redeemer))) } } diff --git a/pallets/vtoken-minting/src/mock.rs b/pallets/vtoken-minting/src/mock.rs index 46bffd730..1e8e4df82 100644 --- a/pallets/vtoken-minting/src/mock.rs +++ b/pallets/vtoken-minting/src/mock.rs @@ -338,7 +338,7 @@ impl BbBNCInterface for BbBNC { fn auto_notify_reward( _: u32, _: u64, - _: Vec<(CurrencyId, Balance)>, + _: Vec, ) -> Result<(), sp_runtime::DispatchError> { todo!() } @@ -368,7 +368,7 @@ impl BbBNCInterface for BbBNC { fn add_reward( _addr: &AccountId, _conf: &mut IncentiveConfig, - _rewards: &Vec<(CurrencyId, Balance)>, + _rewards: &Vec, _remaining: Balance, ) -> DispatchResult { Ok(()) @@ -376,7 +376,7 @@ impl BbBNCInterface for BbBNC { fn notify_reward( _pool_id: u32, _addr: &Option, - _rewards: Vec<(CurrencyId, Balance)>, + _rewards: Vec, ) -> DispatchResult { Ok(()) } diff --git a/pallets/vtoken-voting/src/lib.rs b/pallets/vtoken-voting/src/lib.rs index a8452f646..95d4bd80b 100644 --- a/pallets/vtoken-voting/src/lib.rs +++ b/pallets/vtoken-voting/src/lib.rs @@ -1211,7 +1211,7 @@ pub mod pallet { } fn ensure_vtoken(vtoken: &CurrencyIdOf) -> Result<(), DispatchError> { - ensure!([VKSM, VDOT].contains(vtoken), Error::::VTokenNotSupport); + ensure!([VKSM, VDOT, VBNC].contains(vtoken), Error::::VTokenNotSupport); Ok(()) } diff --git a/pallets/vtoken-voting/src/tests/mod.rs b/pallets/vtoken-voting/src/tests/mod.rs index aa137efcd..955f282ad 100644 --- a/pallets/vtoken-voting/src/tests/mod.rs +++ b/pallets/vtoken-voting/src/tests/mod.rs @@ -19,5 +19,5 @@ #[cfg(test)] mod common_test; -// #[cfg(test)] -// mod vbnc_test; +#[cfg(test)] +mod vbnc_test; diff --git a/pallets/xcm-interface/src/lib.rs b/pallets/xcm-interface/src/lib.rs index 1a9b609ca..1dbc6bba5 100644 --- a/pallets/xcm-interface/src/lib.rs +++ b/pallets/xcm-interface/src/lib.rs @@ -73,11 +73,7 @@ pub mod pallet { type AccountIdToLocation: Convert; /// Convert Location to `T::CurrencyId`. - type CurrencyIdConvert: CurrencyIdMapping< - CurrencyId, - xcm::v3::MultiLocation, - AssetMetadata>, - >; + type CurrencyIdConvert: CurrencyIdMapping>>; #[pallet::constant] type ParachainId: Get; @@ -170,8 +166,8 @@ pub mod pallet { to: H160, ) -> DispatchResult { let who = ensure_signed(origin.clone())?; - let asset_location = - T::CurrencyIdConvert::get_location(currency_id).ok_or(Error::::FailToConvert)?; + let asset_location = T::CurrencyIdConvert::get_location(¤cy_id) + .ok_or(Error::::FailToConvert)?; let asset: Asset = Asset { id: AssetId(asset_location), diff --git a/primitives/src/currency.rs b/primitives/src/currency.rs index e6d1e67f4..6f8f76b42 100644 --- a/primitives/src/currency.rs +++ b/primitives/src/currency.rs @@ -90,6 +90,14 @@ pub const LDOT: CurrencyId = CurrencyId::Lend(0); pub const LKSM: CurrencyId = CurrencyId::Lend(1); pub const LUSDT: CurrencyId = CurrencyId::Lend(2); pub const LVDOT: CurrencyId = CurrencyId::Lend(3); +pub const BLP_BNC_VBNC: CurrencyId = CurrencyId::BLP(2); +pub const LP_BNC_VBNC: CurrencyId = CurrencyId::LPToken(TokenSymbol::ASG, 0, TokenSymbol::BNC, 1); +pub const KUSAMA_VBNC_ASSET_INDEX: AssetId = + AssetId { chain_id: 2001, asset_type: 2, asset_index: 257 }; +pub const KUSAMA_VBNC_LP_ASSET_INDEX: AssetId = + AssetId { chain_id: 2001, asset_type: 2, asset_index: 1103806596608 }; +pub const KUSAMA_BNC_ASSET_INDEX: AssetId = + AssetId { chain_id: 2001, asset_type: 0, asset_index: 0 }; macro_rules! create_currency_id { ($(#[$meta:meta])* diff --git a/primitives/src/traits.rs b/primitives/src/traits.rs index e7d7e5d69..b29a588bf 100644 --- a/primitives/src/traits.rs +++ b/primitives/src/traits.rs @@ -34,6 +34,7 @@ use sp_runtime::{ BoundedVec, DispatchError, DispatchResult, TypeId, }; use sp_std::{cmp::Ordering, fmt::Debug, vec::Vec}; +use xcm::prelude::Location; pub trait TokenInfo { fn name(&self) -> Option<&str>; @@ -143,15 +144,15 @@ pub trait SlpxOperator { } /// A mapping between CurrencyId and AssetMetadata. -pub trait CurrencyIdMapping { +pub trait CurrencyIdMapping { /// Returns the AssetMetadata associated with a given `AssetIds`. fn get_asset_metadata(asset_ids: AssetIds) -> Option; /// Returns the AssetMetadata associated with a given `CurrencyId`. fn get_currency_metadata(currency_id: CurrencyId) -> Option; /// Returns the Location associated with a given CurrencyId. - fn get_location(currency_id: CurrencyId) -> Option; + fn get_location(currency_id: &CurrencyId) -> Option; /// Returns the CurrencyId associated with a given Location. - fn get_currency_id(multi_location: xcm::v4::Location) -> Option; + fn get_currency_id(location: &Location) -> Option; /// Returns all currencies in currencyMetadata. fn get_all_currency() -> Vec; } diff --git a/primitives/src/xcm.rs b/primitives/src/xcm.rs index efcb265a8..4bdfd8700 100644 --- a/primitives/src/xcm.rs +++ b/primitives/src/xcm.rs @@ -25,7 +25,7 @@ use sp_runtime::traits::Convert; use sp_std::marker::PhantomData; use xcm::{ latest::Asset, - prelude::{AccountId32, Ethereum, Fungible, GlobalConsensus, Parachain}, + prelude::{AccountId32, Ethereum, Fungible, GeneralKey, GlobalConsensus, Parachain}, v4::{AssetId, InteriorLocation, Location, NetworkId, Parent}, }; @@ -58,6 +58,13 @@ parameter_types! { pub SelfLocation: Location = Location::here(); pub AssetHubLocation: Location = Location::new(1, Parachain(AssetHubChainId::get())); pub EthereumLocation: Location = Location::new(2, [GlobalConsensus(Ethereum { chain_id: EthereumChainId::get() })]); + pub LocalBncLocation: Location = Location::new(0, [GeneralKey { + length: 2, + data: [ + 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0 + ], + }]); pub const KusamaNetwork: NetworkId = NetworkId::Kusama; pub const PolkadotNetwork: NetworkId = NetworkId::Polkadot; diff --git a/runtime/bifrost-kusama/Cargo.toml b/runtime/bifrost-kusama/Cargo.toml index 20bca7d5d..f5b09216e 100644 --- a/runtime/bifrost-kusama/Cargo.toml +++ b/runtime/bifrost-kusama/Cargo.toml @@ -78,6 +78,7 @@ cumulus-pallet-aura-ext = { workspace = true } cumulus-pallet-parachain-system = { workspace = true } cumulus-pallet-xcm = { workspace = true } cumulus-pallet-xcmp-queue = { workspace = true } +cumulus-primitives-aura = { workspace = true } cumulus-primitives-core = { workspace = true } cumulus-primitives-timestamp = { workspace = true } cumulus-primitives-utility = { workspace = true } @@ -92,6 +93,7 @@ polkadot-runtime-common = { workspace = true } xcm = { workspace = true } xcm-builder = { workspace = true } xcm-executor = { workspace = true } +xcm-fee-payment-runtime-api = { workspace = true } # orml orml-tokens = { workspace = true } @@ -212,6 +214,7 @@ std = [ "cumulus-pallet-parachain-system/std", "cumulus-pallet-xcm/std", "cumulus-pallet-xcmp-queue/std", + "cumulus-primitives-aura/std", "cumulus-primitives-core/std", "cumulus-primitives-timestamp/std", "cumulus-primitives-utility/std", @@ -223,6 +226,7 @@ std = [ "xcm/std", "xcm-builder/std", "xcm-executor/std", + "xcm-fee-payment-runtime-api/std", "orml-tokens/std", "orml-traits/std", diff --git a/runtime/bifrost-kusama/src/lib.rs b/runtime/bifrost-kusama/src/lib.rs index 9aa6c9f05..41fbea8ef 100644 --- a/runtime/bifrost-kusama/src/lib.rs +++ b/runtime/bifrost-kusama/src/lib.rs @@ -26,6 +26,9 @@ #[cfg(feature = "std")] include!(concat!(env!("OUT_DIR"), "/wasm_binary.rs")); +use bifrost_primitives::{ + BLP_BNC_VBNC, KUSAMA_VBNC_ASSET_INDEX, KUSAMA_VBNC_LP_ASSET_INDEX, LP_BNC_VBNC, VBNC, +}; use bifrost_slp::{DerivativeAccountProvider, QueryResponseManager}; use core::convert::TryInto; // A few exports that help ease life for downstream crates. @@ -34,9 +37,9 @@ use bifrost_primitives::{ BifrostCrowdloanId, BifrostVsbondAccount, BuybackPalletId, CommissionPalletId, FarmingBoostPalletId, FarmingGaugeRewardIssuerPalletId, FarmingKeeperPalletId, FarmingRewardIssuerPalletId, FeeSharePalletId, FlexibleFeePalletId, IncentivePoolAccount, - LendMarketPalletId, MerkleDirtributorPalletId, OraclePalletId, ParachainStakingPalletId, - SlpEntrancePalletId, SlpExitPalletId, SystemMakerPalletId, SystemStakingPalletId, - TreasuryPalletId, VBNCConvertPalletId, + LendMarketPalletId, LocalBncLocation, MerkleDirtributorPalletId, OraclePalletId, + ParachainStakingPalletId, SlpEntrancePalletId, SlpExitPalletId, SystemMakerPalletId, + SystemStakingPalletId, TreasuryPalletId, VBNCConvertPalletId, }; pub use frame_support::{ construct_runtime, match_types, parameter_types, @@ -94,7 +97,7 @@ pub use bifrost_runtime_common::{ }; use bifrost_slp::QueryId; use constants::currency::*; -use cumulus_pallet_parachain_system::{RelayNumberStrictlyIncreases, RelaychainDataProvider}; +use cumulus_pallet_parachain_system::{RelayNumberMonotonicallyIncreases, RelaychainDataProvider}; use cumulus_primitives_core::AggregateMessageOrigin; use frame_support::{ dispatch::DispatchClass, @@ -106,6 +109,7 @@ use frame_support::{ Currency, EitherOf, EitherOfDiverse, Get, Imbalance, InsideBoth, LinearStoragePrice, LockIdentifier, OnUnbalanced, }, + weights::WeightToFee as _, }; use frame_system::{EnsureRoot, EnsureRootWithSuccess, EnsureSigned}; use hex_literal::hex; @@ -130,16 +134,23 @@ use governance::{ // xcm config pub mod xcm_config; -use bifrost_primitives::MoonriverChainId; +use bifrost_primitives::{MoonriverChainId, OraclePriceProvider}; use bifrost_runtime_common::currency_converter::CurrencyIdConvert; use pallet_xcm::{EnsureResponse, QueryStatus}; use sp_runtime::traits::{IdentityLookup, Verify}; -use xcm::{v3::MultiLocation, v4::prelude::*}; +use xcm::{ + v3::MultiLocation, v4::prelude::*, IntoVersion, VersionedAssetId, VersionedAssets, + VersionedLocation, VersionedXcm, +}; pub use xcm_config::{ AccountId32Aliases, BifrostTreasuryAccount, ExistentialDeposits, MultiCurrency, Sibling, SiblingParachainConvertsVia, XcmConfig, XcmRouter, }; use xcm_executor::{traits::QueryHandler, XcmExecutor}; +use xcm_fee_payment_runtime_api::{ + dry_run::{CallDryRunEffects, Error as XcmDryRunApiError, XcmDryRunEffects}, + fees::Error as XcmPaymentApiError, +}; impl_opaque_keys! { pub struct SessionKeys { @@ -153,7 +164,7 @@ pub const VERSION: RuntimeVersion = RuntimeVersion { spec_name: create_runtime_str!("bifrost"), impl_name: create_runtime_str!("bifrost"), authoring_version: 1, - spec_version: 14000, + spec_version: 15000, impl_version: 0, apis: RUNTIME_API_VERSIONS, transaction_version: 1, @@ -220,11 +231,98 @@ parameter_types! { pub const StableAssetPalletId: PalletId = PalletId(*b"bf/stabl"); } +pub struct CallFilter; +impl Contains for CallFilter { + fn contains(call: &RuntimeCall) -> bool { + // Allow core system calls + if matches!( + call, + RuntimeCall::System(_) | RuntimeCall::Timestamp(_) | RuntimeCall::ParachainSystem(_) + ) { + return true; + } + + // Check for disabled transfer calls + if matches!( + call, + RuntimeCall::Tokens(_) | RuntimeCall::StablePool(_) | RuntimeCall::ZenlinkProtocol(_) + ) { + let is_disabled = match call { + // Disable specific `transfer`, `transfer_all`, and `transfer_keep_alive` calls for + // certain currencies + RuntimeCall::Tokens(orml_tokens::Call::transfer { currency_id, .. }) | + RuntimeCall::Tokens(orml_tokens::Call::transfer_all { currency_id, .. }) | + RuntimeCall::Tokens(orml_tokens::Call::transfer_keep_alive { + currency_id, .. + }) => [VBNC, BLP_BNC_VBNC, LP_BNC_VBNC].contains(currency_id), + + // Disable StablePool calls with pool_id equal to 2 + RuntimeCall::StablePool(bifrost_stable_pool::Call::add_liquidity { + pool_id, + .. + }) | + RuntimeCall::StablePool(bifrost_stable_pool::Call::swap { pool_id, .. }) | + RuntimeCall::StablePool(bifrost_stable_pool::Call::redeem_proportion { + pool_id, + .. + }) | + RuntimeCall::StablePool(bifrost_stable_pool::Call::redeem_single { + pool_id, + .. + }) | + RuntimeCall::StablePool(bifrost_stable_pool::Call::redeem_multi { + pool_id, + .. + }) => *pool_id == 2, + + // Disable ZenlinkProtocol calls involving specific VBNC assets + RuntimeCall::ZenlinkProtocol(zenlink_protocol::Call::transfer { + asset_id, .. + }) => *asset_id == KUSAMA_VBNC_ASSET_INDEX || *asset_id == KUSAMA_VBNC_LP_ASSET_INDEX, + + RuntimeCall::ZenlinkProtocol(zenlink_protocol::Call::add_liquidity { + asset_0, + asset_1, + .. + }) | + RuntimeCall::ZenlinkProtocol(zenlink_protocol::Call::remove_liquidity { + asset_0, + asset_1, + .. + }) | + RuntimeCall::ZenlinkProtocol(zenlink_protocol::Call::bootstrap_claim { + asset_0, + asset_1, + .. + }) => *asset_0 == KUSAMA_VBNC_ASSET_INDEX || *asset_1 == KUSAMA_VBNC_ASSET_INDEX, + + // Disable ZenlinkProtocol swap calls if the path contains VBNC assets + RuntimeCall::ZenlinkProtocol( + zenlink_protocol::Call::swap_exact_assets_for_assets { path, .. }, + ) | + RuntimeCall::ZenlinkProtocol( + zenlink_protocol::Call::swap_assets_for_exact_assets { path, .. }, + ) => path.contains(&KUSAMA_VBNC_ASSET_INDEX), + + _ => false, + }; + + // If the call is disabled, log it and return false + if is_disabled { + return false; + } + } + + // Allow all other calls + true + } +} + impl frame_system::Config for Runtime { type AccountData = pallet_balances::AccountData; /// The identifier used to distinguish between accounts. type AccountId = AccountId; - type BaseCallFilter = InsideBoth; + type BaseCallFilter = InsideBoth; /// Maximum number of block number to block hash mappings to keep (oldest pruned first). type BlockHashCount = BlockHashCount; type BlockLength = RuntimeBlockLength; @@ -857,6 +955,13 @@ parameter_types! { pub const RelayOrigin: AggregateMessageOrigin = AggregateMessageOrigin::Parent; } +type ConsensusHook = cumulus_pallet_aura_ext::FixedVelocityConsensusHook< + Runtime, + RELAY_CHAIN_SLOT_DURATION_MILLIS, + BLOCK_PROCESSING_VELOCITY, + UNINCLUDED_SEGMENT_CAPACITY, +>; + impl cumulus_pallet_parachain_system::Config for Runtime { type DmpQueue = frame_support::traits::EnqueueWithOrigin; type RuntimeEvent = RuntimeEvent; @@ -866,8 +971,8 @@ impl cumulus_pallet_parachain_system::Config for Runtime { type ReservedXcmpWeight = ReservedXcmpWeight; type SelfParaId = parachain_info::Pallet; type XcmpMessageHandler = XcmpQueue; - type CheckAssociatedRelayNumber = RelayNumberStrictlyIncreases; - type ConsensusHook = cumulus_pallet_parachain_system::ExpectParentIncluded; + type CheckAssociatedRelayNumber = RelayNumberMonotonicallyIncreases; + type ConsensusHook = ConsensusHook; type WeightInfo = cumulus_pallet_parachain_system::weights::SubstrateWeight; } @@ -1275,7 +1380,7 @@ impl bifrost_system_staking::Config for Runtime { type WeightInfo = weights::bifrost_system_staking::BifrostWeight; type FarmingInfo = Farming; type VtokenMintingInterface = VtokenMinting; - type TreasuryAccount = BifrostTreasuryAccount; + type BenefitReceivingAccount = BifrostTreasuryAccount; type PalletId = SystemStakingPalletId; type BlocksPerRound = BlocksPerRound; type MaxTokenLen = MaxTokenLen; @@ -1900,6 +2005,7 @@ pub mod migrations { >, // permanent migration, do not remove pallet_xcm::migration::MigrateToLatestXcmVersion, + bifrost_flexible_fee::migrations::v3::MigrateToV3, ); } @@ -2054,7 +2160,7 @@ impl_runtime_apis! { impl sp_consensus_aura::AuraApi for Runtime { fn slot_duration() -> sp_consensus_aura::SlotDuration { - sp_consensus_aura::SlotDuration::from_millis(Aura::slot_duration()) + sp_consensus_aura::SlotDuration::from_millis(SLOT_DURATION) } fn authorities() -> Vec { @@ -2062,6 +2168,58 @@ impl_runtime_apis! { } } + impl cumulus_primitives_aura::AuraUnincludedSegmentApi for Runtime { + fn can_build_upon( + included_hash: ::Hash, + slot: cumulus_primitives_aura::Slot, + ) -> bool { + ConsensusHook::can_build_upon(included_hash, slot) + } + } + + impl xcm_fee_payment_runtime_api::fees::XcmPaymentApi for Runtime { + fn query_acceptable_payment_assets(xcm_version: xcm::Version) -> Result, XcmPaymentApiError> { + let acceptable_assets = AssetRegistry::asset_ids(); + PolkadotXcm::query_acceptable_payment_assets(xcm_version, acceptable_assets) + } + + fn query_weight_to_asset_fee(weight: Weight, asset: VersionedAssetId) -> Result { + let asset = asset + .into_version(4) + .map_err(|_| XcmPaymentApiError::VersionedConversionFailed)?; + let bnc_asset = VersionedAssetId::V4(LocalBncLocation::get().into()); + + if asset == bnc_asset { + // for native token + Ok(WeightToFee::weight_to_fee(&weight)) + } else { + let native_fee = WeightToFee::weight_to_fee(&weight); + let asset_location = &asset.try_as::().map_err(|_| XcmPaymentApiError::VersionedConversionFailed)?.0; + let asset_currency = AssetIdMaps::::get_currency_id(&asset_location).ok_or(XcmPaymentApiError::AssetNotFound)?; + let asset_fee = Prices::get_oracle_amount_by_currency_and_amount_in(&bifrost_primitives::BNC, native_fee, &asset_currency).ok_or(XcmPaymentApiError::AssetNotFound)?.0; + Ok(asset_fee) + } + } + + fn query_xcm_weight(message: VersionedXcm<()>) -> Result { + PolkadotXcm::query_xcm_weight(message) + } + + fn query_delivery_fees(destination: VersionedLocation, message: VersionedXcm<()>) -> Result { + PolkadotXcm::query_delivery_fees(destination, message) + } + } + + impl xcm_fee_payment_runtime_api::dry_run::DryRunApi for Runtime { + fn dry_run_call(origin: OriginCaller, call: RuntimeCall) -> Result, XcmDryRunApiError> { + PolkadotXcm::dry_run_call::(origin, call) + } + + fn dry_run_xcm(origin_location: VersionedLocation, xcm: VersionedXcm) -> Result, XcmDryRunApiError> { + PolkadotXcm::dry_run_xcm::(origin_location, xcm) + } + } + impl bifrost_flexible_fee_rpc_runtime_api::FlexibleFeeRuntimeApi for Runtime { fn get_fee_token_and_amount(who: AccountId, fee: Balance,utx: ::Extrinsic) -> (CurrencyId, Balance) { let call = utx.function; @@ -2336,31 +2494,7 @@ impl_runtime_apis! { } } -struct CheckInherents; -#[allow(deprecated)] -impl cumulus_pallet_parachain_system::CheckInherents for CheckInherents { - fn check_inherents( - block: &Block, - relay_state_proof: &cumulus_pallet_parachain_system::RelayChainStateProof, - ) -> sp_inherents::CheckInherentsResult { - let relay_chain_slot = relay_state_proof - .read_slot() - .expect("Could not read the relay chain slot from the proof"); - - let inherent_data = - cumulus_primitives_timestamp::InherentDataProvider::from_relay_chain_slot_and_duration( - relay_chain_slot, - sp_std::time::Duration::from_secs(6), - ) - .create_inherent_data() - .expect("Could not create the timestamp inherent data"); - - inherent_data.check_extrinsics(&block) - } -} - cumulus_pallet_parachain_system::register_validate_block! { Runtime = Runtime, - BlockExecutor = cumulus_pallet_aura_ext::BlockExecutor::, - CheckInherents = CheckInherents, + BlockExecutor = cumulus_pallet_aura_ext::BlockExecutor:: } diff --git a/runtime/bifrost-kusama/src/weights/bifrost_slpx.rs b/runtime/bifrost-kusama/src/weights/bifrost_slpx.rs index cc9f6ce45..555e30e8f 100644 --- a/runtime/bifrost-kusama/src/weights/bifrost_slpx.rs +++ b/runtime/bifrost-kusama/src/weights/bifrost_slpx.rs @@ -24,25 +24,27 @@ //! Autogenerated weights for bifrost_slpx //! -//! THIS FILE WAS AUTO-GENERATED USING THE SUBSTRATE BENCHMARK CLI VERSION 4.0.0-dev -//! DATE: 2023-09-14, STEPS: `50`, REPEAT: 20, LOW RANGE: `[]`, HIGH RANGE: `[]` +//! THIS FILE WAS AUTO-GENERATED USING THE SUBSTRATE BENCHMARK CLI VERSION 32.0.0 +//! DATE: 2024-11-20, STEPS: `50`, REPEAT: 20, LOW RANGE: `[]`, HIGH RANGE: `[]` //! HOSTNAME: `bifrost-jenkins`, CPU: `Intel(R) Xeon(R) CPU E5-26xx v4` //! WASM-EXECUTION: Compiled, CHAIN: Some("bifrost-kusama-local"), DB CACHE: 1024 // Executed Command: -// target/release/bifrost +// ./target/release/bifrost // benchmark // pallet // --chain=bifrost-kusama-local // --steps=50 // --repeat=20 -// --pallet=bifrost_slpx +// --pallet=bifrost-slpx // --extrinsic=* // --execution=wasm // --wasm-execution=compiled // --heap-pages=4096 -// --output=./runtime/bifrost-kusama/src/weights/bifrost_slpx.rs -// --template=./weight-template/runtime-weight-template.hbs +// --header=./HEADER-GPL3 +// --output=./weight.rs +// --template +// ./weight-template/runtime-weight-template.hbs #![cfg_attr(rustfmt, rustfmt_skip)] #![allow(unused_parens)] @@ -54,193 +56,98 @@ use sp_std::marker::PhantomData; /// Weight functions for bifrost_slpx. pub struct BifrostWeight(PhantomData); impl bifrost_slpx::WeightInfo for BifrostWeight { - // Storage: Slpx WhitelistAccountId (r:1 w:1) - // Proof: Slpx WhitelistAccountId (max_values: None, max_size: Some(338), added: 2813, mode: MaxEncodedLen) + // Storage: `Slpx::WhitelistAccountId` (r:1 w:1) + // Proof: `Slpx::WhitelistAccountId` (`max_values`: None, `max_size`: Some(338), added: 2813, mode: `MaxEncodedLen`) fn add_whitelist() -> Weight { // Proof Size summary in bytes: // Measured: `4` // Estimated: `3803` - // Minimum execution time: 33_664 nanoseconds. - Weight::from_parts(34_525_000, 3803) + // Minimum execution time: 25_165 nanoseconds. + Weight::from_parts(26_022_000, 3803) .saturating_add(T::DbWeight::get().reads(1)) .saturating_add(T::DbWeight::get().writes(1)) } - // Storage: Slpx WhitelistAccountId (r:1 w:1) - // Proof: Slpx WhitelistAccountId (max_values: None, max_size: Some(338), added: 2813, mode: MaxEncodedLen) + // Storage: `Slpx::WhitelistAccountId` (r:1 w:1) + // Proof: `Slpx::WhitelistAccountId` (`max_values`: None, `max_size`: Some(338), added: 2813, mode: `MaxEncodedLen`) fn remove_whitelist() -> Weight { // Proof Size summary in bytes: // Measured: `81` // Estimated: `3803` - // Minimum execution time: 37_038 nanoseconds. - Weight::from_parts(38_028_000, 3803) + // Minimum execution time: 27_790 nanoseconds. + Weight::from_parts(28_537_000, 3803) .saturating_add(T::DbWeight::get().reads(1)) .saturating_add(T::DbWeight::get().writes(1)) } - // Storage: Slpx ExecutionFee (r:0 w:1) - // Proof: Slpx ExecutionFee (max_values: None, max_size: Some(46), added: 2521, mode: MaxEncodedLen) + // Storage: `Slpx::ExecutionFee` (r:0 w:1) + // Proof: `Slpx::ExecutionFee` (`max_values`: None, `max_size`: Some(46), added: 2521, mode: `MaxEncodedLen`) fn set_execution_fee() -> Weight { // Proof Size summary in bytes: // Measured: `0` // Estimated: `0` - // Minimum execution time: 24_630 nanoseconds. - Weight::from_parts(25_469_000, 0) + // Minimum execution time: 15_997 nanoseconds. + Weight::from_parts(16_309_000, 0) .saturating_add(T::DbWeight::get().writes(1)) } - // Storage: Slpx TransferToFee (r:0 w:1) - // Proof: Slpx TransferToFee (max_values: None, max_size: Some(33), added: 2508, mode: MaxEncodedLen) + // Storage: `Slpx::TransferToFee` (r:0 w:1) + // Proof: `Slpx::TransferToFee` (`max_values`: None, `max_size`: Some(33), added: 2508, mode: `MaxEncodedLen`) fn set_transfer_to_fee() -> Weight { // Proof Size summary in bytes: // Measured: `0` // Estimated: `0` - // Minimum execution time: 24_544 nanoseconds. - Weight::from_parts(25_336_000, 0) + // Minimum execution time: 15_990 nanoseconds. + Weight::from_parts(16_543_000, 0) .saturating_add(T::DbWeight::get().writes(1)) } - // Storage: Slpx WhitelistAccountId (r:1 w:0) - // Proof: Slpx WhitelistAccountId (max_values: None, max_size: Some(338), added: 2813, mode: MaxEncodedLen) - // Storage: Tokens Accounts (r:4 w:4) - // Proof: Tokens Accounts (max_values: None, max_size: Some(118), added: 2593, mode: MaxEncodedLen) - // Storage: Slpx ExecutionFee (r:1 w:0) - // Proof: Slpx ExecutionFee (max_values: None, max_size: Some(46), added: 2521, mode: MaxEncodedLen) - // Storage: AssetRegistry CurrencyMetadatas (r:1 w:0) - // Proof Skipped: AssetRegistry CurrencyMetadatas (max_values: None, max_size: None, mode: Measured) - // Storage: System Account (r:3 w:2) - // Proof: System Account (max_values: None, max_size: Some(128), added: 2603, mode: MaxEncodedLen) - // Storage: VtokenMinting MinimumMint (r:1 w:0) - // Proof: VtokenMinting MinimumMint (max_values: None, max_size: Some(38), added: 2513, mode: MaxEncodedLen) - // Storage: VtokenMinting TokenPool (r:1 w:1) - // Proof: VtokenMinting TokenPool (max_values: None, max_size: Some(38), added: 2513, mode: MaxEncodedLen) - // Storage: Tokens TotalIssuance (r:1 w:1) - // Proof: Tokens TotalIssuance (max_values: None, max_size: Some(38), added: 2513, mode: MaxEncodedLen) - // Storage: VtokenMinting Fees (r:1 w:0) - // Proof: VtokenMinting Fees (max_values: Some(1), max_size: Some(8), added: 503, mode: MaxEncodedLen) - // Storage: AssetRegistry CurrencyIdToLocations (r:1 w:0) - // Proof Skipped: AssetRegistry CurrencyIdToLocations (max_values: None, max_size: None, mode: Measured) - // Storage: ParachainInfo ParachainId (r:1 w:0) - // Proof: ParachainInfo ParachainId (max_values: Some(1), max_size: Some(4), added: 499, mode: MaxEncodedLen) + // Storage: `Slpx::WhitelistAccountId` (r:1 w:0) + // Proof: `Slpx::WhitelistAccountId` (`max_values`: None, `max_size`: Some(338), added: 2813, mode: `MaxEncodedLen`) + // Storage: `Slpx::OrderQueue` (r:1 w:1) + // Proof: `Slpx::OrderQueue` (`max_values`: Some(1), `max_size`: Some(113502), added: 113997, mode: `MaxEncodedLen`) fn mint() -> Weight { // Proof Size summary in bytes: - // Measured: `2442` - // Estimated: `11362` - // Minimum execution time: 355_230 nanoseconds. - Weight::from_parts(360_766_000, 11362) - .saturating_add(T::DbWeight::get().reads(16)) - .saturating_add(T::DbWeight::get().writes(8)) + // Measured: `81` + // Estimated: `114987` + // Minimum execution time: 33_327 nanoseconds. + Weight::from_parts(34_485_000, 114987) + .saturating_add(T::DbWeight::get().reads(2)) + .saturating_add(T::DbWeight::get().writes(1)) } - // Storage: Slpx WhitelistAccountId (r:1 w:0) - // Proof: Slpx WhitelistAccountId (max_values: None, max_size: Some(338), added: 2813, mode: MaxEncodedLen) - // Storage: Tokens Accounts (r:4 w:4) - // Proof: Tokens Accounts (max_values: None, max_size: Some(118), added: 2593, mode: MaxEncodedLen) - // Storage: Slpx ExecutionFee (r:1 w:0) - // Proof: Slpx ExecutionFee (max_values: None, max_size: Some(46), added: 2521, mode: MaxEncodedLen) - // Storage: AssetRegistry CurrencyMetadatas (r:1 w:0) - // Proof Skipped: AssetRegistry CurrencyMetadatas (max_values: None, max_size: None, mode: Measured) - // Storage: System Account (r:3 w:2) - // Proof: System Account (max_values: None, max_size: Some(128), added: 2603, mode: MaxEncodedLen) - // Storage: VtokenMinting MinimumMint (r:1 w:0) - // Proof: VtokenMinting MinimumMint (max_values: None, max_size: Some(38), added: 2513, mode: MaxEncodedLen) - // Storage: VtokenMinting TokenPool (r:1 w:1) - // Proof: VtokenMinting TokenPool (max_values: None, max_size: Some(38), added: 2513, mode: MaxEncodedLen) - // Storage: Tokens TotalIssuance (r:1 w:1) - // Proof: Tokens TotalIssuance (max_values: None, max_size: Some(38), added: 2513, mode: MaxEncodedLen) - // Storage: VtokenMinting Fees (r:1 w:0) - // Proof: VtokenMinting Fees (max_values: Some(1), max_size: Some(8), added: 503, mode: MaxEncodedLen) - // Storage: AssetRegistry CurrencyIdToLocations (r:1 w:0) - // Proof Skipped: AssetRegistry CurrencyIdToLocations (max_values: None, max_size: None, mode: Measured) - // Storage: ParachainInfo ParachainId (r:1 w:0) - // Proof: ParachainInfo ParachainId (max_values: Some(1), max_size: Some(4), added: 499, mode: MaxEncodedLen) + // Storage: `Slpx::WhitelistAccountId` (r:1 w:0) + // Proof: `Slpx::WhitelistAccountId` (`max_values`: None, `max_size`: Some(338), added: 2813, mode: `MaxEncodedLen`) + // Storage: `Slpx::OrderQueue` (r:1 w:1) + // Proof: `Slpx::OrderQueue` (`max_values`: Some(1), `max_size`: Some(113502), added: 113997, mode: `MaxEncodedLen`) fn mint_with_channel_id() -> Weight { // Proof Size summary in bytes: - // Measured: `2442` - // Estimated: `11362` - // Minimum execution time: 355_230 nanoseconds. - Weight::from_parts(360_766_000, 11362) - .saturating_add(T::DbWeight::get().reads(16)) - .saturating_add(T::DbWeight::get().writes(8)) + // Measured: `81` + // Estimated: `114987` + // Minimum execution time: 33_004 nanoseconds. + Weight::from_parts(33_780_000, 114987) + .saturating_add(T::DbWeight::get().reads(2)) + .saturating_add(T::DbWeight::get().writes(1)) } - // Storage: Slpx WhitelistAccountId (r:1 w:0) - // Proof: Slpx WhitelistAccountId (max_values: None, max_size: Some(338), added: 2813, mode: MaxEncodedLen) - // Storage: Tokens Accounts (r:2 w:2) - // Proof: Tokens Accounts (max_values: None, max_size: Some(118), added: 2593, mode: MaxEncodedLen) - // Storage: Slpx ExecutionFee (r:1 w:0) - // Proof: Slpx ExecutionFee (max_values: None, max_size: Some(46), added: 2521, mode: MaxEncodedLen) - // Storage: AssetRegistry CurrencyMetadatas (r:2 w:0) - // Proof Skipped: AssetRegistry CurrencyMetadatas (max_values: None, max_size: None, mode: Measured) - // Storage: System Account (r:2 w:1) - // Proof: System Account (max_values: None, max_size: Some(128), added: 2603, mode: MaxEncodedLen) - // Storage: VtokenMinting MinimumRedeem (r:1 w:0) - // Proof: VtokenMinting MinimumRedeem (max_values: None, max_size: Some(38), added: 2513, mode: MaxEncodedLen) - // Storage: Slp DelegationsOccupied (r:1 w:0) - // Proof Skipped: Slp DelegationsOccupied (max_values: None, max_size: None, mode: Measured) - // Storage: VtokenMinting Fees (r:1 w:0) - // Proof: VtokenMinting Fees (max_values: Some(1), max_size: Some(8), added: 503, mode: MaxEncodedLen) - // Storage: VtokenMinting TokenPool (r:1 w:0) - // Proof: VtokenMinting TokenPool (max_values: None, max_size: Some(38), added: 2513, mode: MaxEncodedLen) - // Storage: Tokens TotalIssuance (r:1 w:0) - // Proof: Tokens TotalIssuance (max_values: None, max_size: Some(38), added: 2513, mode: MaxEncodedLen) - // Storage: VtokenMinting OngoingTimeUnit (r:1 w:0) - // Proof: VtokenMinting OngoingTimeUnit (max_values: None, max_size: Some(27), added: 2502, mode: MaxEncodedLen) - // Storage: AssetRegistry CurrencyIdToLocations (r:1 w:0) - // Proof Skipped: AssetRegistry CurrencyIdToLocations (max_values: None, max_size: None, mode: Measured) - // Storage: ParachainInfo ParachainId (r:1 w:0) - // Proof: ParachainInfo ParachainId (max_values: Some(1), max_size: Some(4), added: 499, mode: MaxEncodedLen) + // Storage: `Slpx::WhitelistAccountId` (r:1 w:0) + // Proof: `Slpx::WhitelistAccountId` (`max_values`: None, `max_size`: Some(338), added: 2813, mode: `MaxEncodedLen`) + // Storage: `Slpx::OrderQueue` (r:1 w:1) + // Proof: `Slpx::OrderQueue` (`max_values`: Some(1), `max_size`: Some(113502), added: 113997, mode: `MaxEncodedLen`) fn redeem() -> Weight { // Proof Size summary in bytes: - // Measured: `2194` - // Estimated: `8134` - // Minimum execution time: 243_971 nanoseconds. - Weight::from_parts(250_684_000, 8134) - .saturating_add(T::DbWeight::get().reads(16)) - .saturating_add(T::DbWeight::get().writes(3)) - } - // Storage: Slpx WhitelistAccountId (r:1 w:0) - // Proof: Slpx WhitelistAccountId (max_values: None, max_size: Some(338), added: 2813, mode: MaxEncodedLen) - // Storage: ParachainInfo ParachainId (r:1 w:0) - // Proof: ParachainInfo ParachainId (max_values: Some(1), max_size: Some(4), added: 499, mode: MaxEncodedLen) - // Storage: Tokens Accounts (r:4 w:2) - // Proof: Tokens Accounts (max_values: None, max_size: Some(118), added: 2593, mode: MaxEncodedLen) - // Storage: Slpx ExecutionFee (r:1 w:0) - // Proof: Slpx ExecutionFee (max_values: None, max_size: Some(46), added: 2521, mode: MaxEncodedLen) - // Storage: AssetRegistry CurrencyMetadatas (r:1 w:0) - // Proof Skipped: AssetRegistry CurrencyMetadatas (max_values: None, max_size: None, mode: Measured) - // Storage: System Account (r:2 w:1) - // Proof: System Account (max_values: None, max_size: Some(128), added: 2603, mode: MaxEncodedLen) - // Storage: AssetRegistry CurrencyIdToLocations (r:1 w:0) - // Proof Skipped: AssetRegistry CurrencyIdToLocations (max_values: None, max_size: None, mode: Measured) - fn zenlink_swap() -> Weight { - // Proof Size summary in bytes: - // Measured: `1819` - // Estimated: `11362` - // Minimum execution time: 220_866 nanoseconds. - Weight::from_parts(223_033_000, 11362) - .saturating_add(T::DbWeight::get().reads(11)) - .saturating_add(T::DbWeight::get().writes(3)) + // Measured: `81` + // Estimated: `114987` + // Minimum execution time: 31_663 nanoseconds. + Weight::from_parts(33_722_000, 114987) + .saturating_add(T::DbWeight::get().reads(2)) + .saturating_add(T::DbWeight::get().writes(1)) } - // Storage: Slpx WhitelistAccountId (r:1 w:0) - // Proof: Slpx WhitelistAccountId (max_values: None, max_size: Some(338), added: 2813, mode: MaxEncodedLen) - // Storage: StableAsset Pools (r:1 w:0) - // Proof Skipped: StableAsset Pools (max_values: None, max_size: None, mode: Measured) - // Storage: Tokens Accounts (r:6 w:2) - // Proof: Tokens Accounts (max_values: None, max_size: Some(118), added: 2593, mode: MaxEncodedLen) - // Storage: Slpx ExecutionFee (r:1 w:0) - // Proof: Slpx ExecutionFee (max_values: None, max_size: Some(46), added: 2521, mode: MaxEncodedLen) - // Storage: AssetRegistry CurrencyMetadatas (r:1 w:0) - // Proof Skipped: AssetRegistry CurrencyMetadatas (max_values: None, max_size: None, mode: Measured) - // Storage: System Account (r:3 w:1) - // Proof: System Account (max_values: None, max_size: Some(128), added: 2603, mode: MaxEncodedLen) - // Storage: StableAsset TokenRateCaches (r:2 w:0) - // Proof Skipped: StableAsset TokenRateCaches (max_values: None, max_size: None, mode: Measured) - // Storage: AssetRegistry CurrencyIdToLocations (r:1 w:0) - // Proof Skipped: AssetRegistry CurrencyIdToLocations (max_values: None, max_size: None, mode: Measured) - // Storage: ParachainInfo ParachainId (r:1 w:0) - // Proof: ParachainInfo ParachainId (max_values: Some(1), max_size: Some(4), added: 499, mode: MaxEncodedLen) - fn stable_pool_swap() -> Weight { + // Storage: `Slpx::WhitelistAccountId` (r:1 w:0) + // Proof: `Slpx::WhitelistAccountId` (`max_values`: None, `max_size`: Some(338), added: 2813, mode: `MaxEncodedLen`) + // Storage: `Slpx::OrderQueue` (r:1 w:1) + // Proof: `Slpx::OrderQueue` (`max_values`: Some(1), `max_size`: Some(113502), added: 113997, mode: `MaxEncodedLen`) + fn evm_create_order() -> Weight { // Proof Size summary in bytes: - // Measured: `2782` - // Estimated: `16548` - // Minimum execution time: 552_131 nanoseconds. - Weight::from_parts(564_804_000, 16548) - .saturating_add(T::DbWeight::get().reads(17)) - .saturating_add(T::DbWeight::get().writes(3)) + // Measured: `81` + // Estimated: `114987` + // Minimum execution time: 32_494 nanoseconds. + Weight::from_parts(33_539_000, 114987) + .saturating_add(T::DbWeight::get().reads(2)) + .saturating_add(T::DbWeight::get().writes(1)) } -} +} \ No newline at end of file diff --git a/runtime/bifrost-kusama/src/xcm_config.rs b/runtime/bifrost-kusama/src/xcm_config.rs index 90b13211a..e4100406b 100644 --- a/runtime/bifrost-kusama/src/xcm_config.rs +++ b/runtime/bifrost-kusama/src/xcm_config.rs @@ -17,17 +17,15 @@ // along with this program. If not, see . use super::*; -use bifrost_asset_registry::{AssetIdMaps, FixedRateOfAsset}; +use bifrost_asset_registry::AssetIdMaps; use bifrost_primitives::{ - AccountId, AccountIdToLocation, AssetHubChainId, AssetHubLocation, AssetPrefixFrom, CurrencyId, - CurrencyIdMapping, EthereumLocation, KaruraChainId, KusamaNetwork, KusamaUniversalLocation, - NativeAssetFrom, PhalaChainId, SelfLocation, TokenSymbol, + AccountId, AccountIdToLocation, AssetHubLocation, AssetPrefixFrom, CurrencyId, + CurrencyIdMapping, EthereumLocation, KusamaNetwork, KusamaUniversalLocation, NativeAssetFrom, + SelfLocation, TokenSymbol, }; pub use cumulus_primitives_core::ParaId; use frame_support::{parameter_types, sp_runtime::traits::Convert, traits::Get}; -use parity_scale_codec::Encode; pub use polkadot_parachain_primitives::primitives::Sibling; -use sp_std::convert::TryFrom; pub use xcm_builder::{ AccountId32Aliases, AllowKnownQueryResponses, AllowSubscriptionsFrom, AllowTopLevelPaidExecutionFrom, DescribeAllTerminal, DescribeFamily, EnsureXcmOrigin, @@ -42,6 +40,7 @@ use bifrost_currencies::BasicCurrencyAdapter; use bifrost_runtime_common::{ currency_adapter::{BifrostDropAssets, DepositToAlternative, MultiCurrencyAdapter}, currency_converter::CurrencyIdConvert, + xcm_weight_trader::XcmWeightTrader, }; use cumulus_primitives_core::AggregateMessageOrigin; use frame_support::traits::TransformOrigin; @@ -51,7 +50,6 @@ use orml_xcm_support::{IsNativeConcrete, MultiNativeAsset}; use pallet_xcm::XcmPassthrough; use parachains_common::message_queue::{NarrowOriginToSibling, ParaIdToSibling}; use polkadot_runtime_common::xcm_sender::NoPriceForMessageDelivery; -use sp_core::bounded::BoundedVec; use xcm::v4::{prelude::*, Location}; use xcm_builder::{FrameTransactionalProcessor, TrailingSetTopicAsId, WithComputedOrigin}; @@ -66,7 +64,7 @@ parameter_types! { // XTokens pallet supports maximum number of assets to be transferred at a time pub const MaxAssetsForTransfer: usize = 2; // One XCM operation is 200_000_000 weight, cross-chain transfer ~= 2x of transfer = 3_000_000_000 - pub const UnitWeightCost: Weight = Weight::from_parts(200_000_000, 0); + pub const UnitWeightCost: Weight = Weight::from_parts(50_000_000, 0); // Maximum number of instructions that can be executed in one XCM message pub const MaxInstructions: u32 = 100; } @@ -137,128 +135,6 @@ pub type BifrostAssetTransactor = MultiCurrencyAdapter< DepositToAlternative, >; -parameter_types! { - pub KsmPerSecond: (AssetId, u128, u128) = (Location::parent().into(), ksm_per_second::(),0); - pub VksmPerSecond: (AssetId, u128,u128) = ( - Location::new( - 0, - [Junction::from(BoundedVec::try_from(CurrencyId::VToken(TokenSymbol::KSM).encode()).unwrap())], - ).into(), - ksm_per_second::(), - 0 - ); - pub VsksmPerSecond: (AssetId, u128,u128) = ( - Location::new( - 1, - [Parachain(SelfParaId::get()), Junction::from(BoundedVec::try_from(CurrencyId::VSToken(TokenSymbol::KSM).encode()).unwrap())] - ).into(), - ksm_per_second::(), - 0 - ); - pub VsksmNewPerSecond: (AssetId, u128,u128) = ( - Location::new( - 0, - [Junction::from(BoundedVec::try_from(CurrencyId::VSToken(TokenSymbol::KSM).encode()).unwrap())] - ).into(), - ksm_per_second::(), - 0 - ); - pub BncPerSecond: (AssetId, u128,u128) = ( - Location::new( - 1, - [Parachain(SelfParaId::get()), Junction::from(BoundedVec::try_from(NativeCurrencyId::get().encode()).unwrap())] - ).into(), - // BNC:KSM = 80:1 - ksm_per_second::() * 80, - 0 - ); - pub BncNewPerSecond: (AssetId, u128,u128) = ( - Location::new( - 0, - [Junction::from(BoundedVec::try_from(NativeCurrencyId::get().encode()).unwrap())] - ).into(), - // BNC:KSM = 80:1 - ksm_per_second::() * 80, - 0 - ); - - pub ZlkPerSecond: (AssetId, u128,u128) = ( - Location::new( - 1, - [Parachain(SelfParaId::get()), Junction::from(BoundedVec::try_from(CurrencyId::Token(TokenSymbol::ZLK).encode()).unwrap())] - ).into(), - // ZLK:KSM = 150:1 - //ZLK has a decimal of 18, while KSM is 12. - ksm_per_second::() * 150 * 1_000_000, - 0 - ); - pub ZlkNewPerSecond: (AssetId, u128,u128) = ( - Location::new( - 0, - [Junction::from(BoundedVec::try_from(CurrencyId::Token(TokenSymbol::ZLK).encode()).unwrap())] - ).into(), - // ZLK:KSM = 150:1 - //ZLK has a decimal of 18, while KSM is 12. - ksm_per_second::() * 150 * 1_000_000, - 0 - ); - pub KarPerSecond: (AssetId, u128,u128) = ( - Location::new( - 1, - [Parachain(KaruraChainId::get()), Junction::from(BoundedVec::try_from(vec![0,128u8]).unwrap())] - ).into(), - // KAR:KSM = 100:1 - ksm_per_second::() * 100, - 0 - ); - pub KusdPerSecond: (AssetId, u128,u128) = ( - Location::new( - 1, - [Parachain(KaruraChainId::get()), Junction::from(BoundedVec::try_from(vec![0,129u8]).unwrap())] - ).into(), - // kUSD:KSM = 400:1 - ksm_per_second::() * 400, - 0 - ); - pub PhaPerSecond: (AssetId, u128,u128) = ( - Location::new( - 1, - [Parachain(PhalaChainId::get())], - ).into(), - // PHA:KSM = 400:1 - ksm_per_second::() * 400, - 0 - ); - pub RmrkPerSecond: (AssetId, u128,u128) = ( - Location::new( - 1, - [Parachain(AssetHubChainId::get()), GeneralIndex(50)] - ).into(), - // rmrk:KSM = 10:1 - ksm_per_second::() * 10 / 100, //rmrk currency decimal as 10 - 0 - ); - pub RmrkNewPerSecond: (AssetId, u128,u128) = ( - Location::new( - 1, - [Parachain(AssetHubChainId::get()), PalletInstance(50), GeneralIndex(8)] - ).into(), - // rmrk:KSM = 10:1 - ksm_per_second::() * 10 / 100, //rmrk currency decimal as 10 - 0 - ); - pub MovrPerSecond: (AssetId, u128,u128) = ( - Location::new( - 1, - [Parachain(MoonriverChainId::get()), PalletInstance(10)] - ).into(), - // MOVR:KSM = 2.67:1 - ksm_per_second::() * 267 * 10_000, //movr currency decimal as 18 - 0 - ); - pub BasePerSecond: u128 = ksm_per_second::(); -} - pub struct ToTreasury; impl TakeRevenue for ToTreasury { fn take_revenue(revenue: Asset) { @@ -272,24 +148,6 @@ impl TakeRevenue for ToTreasury { } } -pub type Trader = ( - FixedRateOfFungible, - FixedRateOfFungible, - FixedRateOfFungible, - FixedRateOfFungible, - FixedRateOfFungible, - FixedRateOfFungible, - FixedRateOfFungible, - FixedRateOfFungible, - FixedRateOfFungible, - FixedRateOfFungible, - FixedRateOfFungible, - FixedRateOfFungible, - FixedRateOfFungible, - FixedRateOfFungible, - FixedRateOfAsset, -); - /// A call filter for the XCM Transact instruction. This is a temporary measure until we properly /// account for proof size weights. /// @@ -398,7 +256,9 @@ impl xcm_executor::Config for XcmConfig { type OriginConverter = XcmOriginToTransactDispatchOrigin; type ResponseHandler = PolkadotXcm; type SubscriptionService = PolkadotXcm; - type Trader = Trader; + type Trader = XcmWeightTrader, ToTreasury>; + // TODO: Implement XcmWeigher, using real Weight, currently per instruction Weight = + // Weight::from_parts(50_000_000, 0) type Weigher = FixedWeightBounds; type XcmSender = XcmRouter; type PalletInstancesInfo = AllPalletsWithSystem; diff --git a/runtime/bifrost-polkadot/Cargo.toml b/runtime/bifrost-polkadot/Cargo.toml index 0888dda20..80747c824 100644 --- a/runtime/bifrost-polkadot/Cargo.toml +++ b/runtime/bifrost-polkadot/Cargo.toml @@ -77,10 +77,10 @@ cumulus-pallet-aura-ext = { workspace = true } cumulus-pallet-parachain-system = { workspace = true } cumulus-pallet-xcm = { workspace = true } cumulus-pallet-xcmp-queue = { workspace = true } +cumulus-primitives-aura = { workspace = true } cumulus-primitives-core = { workspace = true } cumulus-primitives-timestamp = { workspace = true } cumulus-primitives-utility = { workspace = true } -pallet-collator-selection = { workspace = true } parachain-info = { workspace = true } parachains-common = { workspace = true } @@ -92,6 +92,7 @@ polkadot-runtime-common = { workspace = true } xcm = { workspace = true } xcm-builder = { workspace = true } xcm-executor = { workspace = true } +xcm-fee-payment-runtime-api = { workspace = true } # orml orml-tokens = { workspace = true } @@ -163,6 +164,7 @@ bifrost-vstoken-conversion = { workspace = true } bifrost-vtoken-minting = { workspace = true } bifrost-vtoken-voting = { workspace = true, features = [ "polkadot" ] } bifrost-xcm-interface = { workspace = true } +bifrost-parachain-staking = { workspace = true } lend-market = { workspace = true } lend-market-rpc-runtime-api = { workspace = true } pallet-prices = { workspace = true } @@ -191,7 +193,6 @@ std = [ "pallet-aura/std", "pallet-balances/std", "pallet-bounties/std", - "pallet-collator-selection/std", "pallet-collective/std", "pallet-conviction-voting/std", "pallet-democracy/std", @@ -232,6 +233,7 @@ std = [ "cumulus-pallet-parachain-system/std", "cumulus-pallet-xcm/std", "cumulus-pallet-xcmp-queue/std", + "cumulus-primitives-aura/std", "cumulus-primitives-core/std", "cumulus-primitives-timestamp/std", "cumulus-primitives-utility/std", @@ -241,6 +243,7 @@ std = [ "xcm-builder/std", "xcm-executor/std", "xcm/std", + "xcm-fee-payment-runtime-api/std", "orml-tokens/std", "orml-traits/std", @@ -305,7 +308,9 @@ std = [ "pallet-evm-accounts/std", "pallet-evm-accounts-rpc-runtime-api/std", "bifrost-clouds-convert/std", + "bifrost-vtoken-minting-rpc-runtime-api/std", + "bifrost-parachain-staking/std", "substrate-wasm-builder" ] @@ -349,6 +354,7 @@ runtime-benchmarks = [ "bifrost-channel-commission/runtime-benchmarks", "bifrost-clouds-convert/runtime-benchmarks", "bifrost-buy-back/runtime-benchmarks", + "bifrost-parachain-staking/runtime-benchmarks", ] try-runtime = [ @@ -396,7 +402,6 @@ try-runtime = [ "pallet-authorship/try-runtime", "pallet-balances/try-runtime", "pallet-bounties/try-runtime", - "pallet-collator-selection/try-runtime", "pallet-collective/try-runtime", "pallet-conviction-voting/try-runtime", "pallet-democracy/try-runtime", @@ -427,6 +432,7 @@ try-runtime = [ "pallet-evm/try-runtime", "pallet-evm-chain-id/try-runtime", "pallet-dynamic-fee/try-runtime", + "bifrost-parachain-staking/try-runtime", ] # Enable the metadata hash generation in the wasm builder. diff --git a/runtime/bifrost-polkadot/src/lib.rs b/runtime/bifrost-polkadot/src/lib.rs index 090fd2c31..9a046b485 100644 --- a/runtime/bifrost-polkadot/src/lib.rs +++ b/runtime/bifrost-polkadot/src/lib.rs @@ -30,15 +30,17 @@ use bifrost_slp::{DerivativeAccountProvider, QueryResponseManager}; use core::convert::TryInto; use pallet_traits::evm::InspectEvmAccounts; // A few exports that help ease life for downstream crates. +pub use bifrost_parachain_staking::{InflationInfo, Range}; use bifrost_primitives::{ BifrostCrowdloanId, BifrostVsbondAccount, BuyBackAccount, BuybackPalletId, CloudsPalletId, CommissionPalletId, FarmingBoostPalletId, FarmingGaugeRewardIssuerPalletId, FarmingKeeperPalletId, FarmingRewardIssuerPalletId, FeeSharePalletId, FlexibleFeePalletId, IncentivePalletId, IncentivePoolAccount, LendMarketPalletId, LiquidityAccount, - MerkleDirtributorPalletId, OraclePalletId, SlpEntrancePalletId, SlpExitPalletId, - SystemMakerPalletId, SystemStakingPalletId, TreasuryPalletId, + LocalBncLocation, MerkleDirtributorPalletId, OraclePalletId, ParachainStakingPalletId, + SlpEntrancePalletId, SlpExitPalletId, SystemMakerPalletId, SystemStakingPalletId, + TreasuryPalletId, BNC, }; -use cumulus_pallet_parachain_system::{RelayNumberStrictlyIncreases, RelaychainDataProvider}; +use cumulus_pallet_parachain_system::{RelayNumberMonotonicallyIncreases, RelaychainDataProvider}; pub use frame_support::{ construct_runtime, match_types, parameter_types, traits::{ @@ -78,7 +80,7 @@ mod evm; mod migration; pub mod weights; use bb_bnc::traits::BbBNCInterface; -use bifrost_asset_registry::{AssetIdMaps, FixedRateOfAsset}; +use bifrost_asset_registry::AssetIdMaps; pub use bifrost_primitives::{ traits::{ CheckSubAccount, FarmingInfo, VtokenMintingInterface, VtokenMintingOperator, @@ -128,16 +130,26 @@ use sp_runtime::{ transaction_validity::TransactionValidityError, }; use static_assertions::const_assert; -use xcm::{v3::MultiLocation, v4::prelude::*}; +use xcm::{ + v3::MultiLocation, v4::prelude::*, VersionedAssetId, VersionedAssets, VersionedLocation, + VersionedXcm, +}; pub use xcm_config::{BifrostTreasuryAccount, MultiCurrency}; use xcm_executor::{traits::QueryHandler, XcmExecutor}; pub mod governance; use crate::xcm_config::XcmRouter; +use bifrost_primitives::OraclePriceProvider; +use frame_support::weights::WeightToFee as _; use governance::{ custom_origins, CoreAdminOrCouncil, LiquidStaking, SALPAdmin, Spender, TechAdmin, TechAdminOrCouncil, }; +use xcm::IntoVersion; +use xcm_fee_payment_runtime_api::{ + dry_run::{CallDryRunEffects, Error as XcmDryRunApiError, XcmDryRunEffects}, + fees::Error as XcmPaymentApiError, +}; use bifrost_primitives::MoonbeamChainId; #[cfg(feature = "runtime-benchmarks")] @@ -176,7 +188,7 @@ pub const VERSION: RuntimeVersion = RuntimeVersion { spec_name: create_runtime_str!("bifrost_polkadot"), impl_name: create_runtime_str!("bifrost_polkadot"), authoring_version: 0, - spec_version: 14000, + spec_version: 15000, impl_version: 0, apis: RUNTIME_API_VERSIONS, transaction_version: 1, @@ -334,6 +346,7 @@ pub enum ProxyType { Governance = 2, CancelProxy = 3, IdentityJudgement = 4, + Staking = 5, } impl Default for ProxyType { @@ -368,8 +381,12 @@ impl InstanceFilter for ProxyType { // Specifically omitting Vesting `vested_transfer`, and `force_vested_transfer` RuntimeCall::Utility(..) | RuntimeCall::Proxy(..) | - RuntimeCall::Multisig(..) + RuntimeCall::Multisig(..) | + RuntimeCall::ParachainStaking(..) ), + ProxyType::Staking => { + matches!(c, RuntimeCall::ParachainStaking(..) | RuntimeCall::Utility(..)) + }, ProxyType::Governance => matches!( c, RuntimeCall::Democracy(..) | @@ -799,6 +816,13 @@ parameter_types! { pub const RelayOrigin: AggregateMessageOrigin = AggregateMessageOrigin::Parent; } +type ConsensusHook = cumulus_pallet_aura_ext::FixedVelocityConsensusHook< + Runtime, + RELAY_CHAIN_SLOT_DURATION_MILLIS, + BLOCK_PROCESSING_VELOCITY, + UNINCLUDED_SEGMENT_CAPACITY, +>; + impl cumulus_pallet_parachain_system::Config for Runtime { type DmpQueue = frame_support::traits::EnqueueWithOrigin; type RuntimeEvent = RuntimeEvent; @@ -808,8 +832,8 @@ impl cumulus_pallet_parachain_system::Config for Runtime { type ReservedXcmpWeight = ReservedXcmpWeight; type SelfParaId = parachain_info::Pallet; type XcmpMessageHandler = XcmpQueue; - type CheckAssociatedRelayNumber = RelayNumberStrictlyIncreases; - type ConsensusHook = cumulus_pallet_parachain_system::ExpectParentIncluded; + type CheckAssociatedRelayNumber = RelayNumberMonotonicallyIncreases; + type ConsensusHook = ConsensusHook; type WeightInfo = cumulus_pallet_parachain_system::weights::SubstrateWeight; } @@ -817,6 +841,75 @@ impl parachain_info::Config for Runtime {} impl cumulus_pallet_aura_ext::Config for Runtime {} +parameter_types! { + /// Minimum round length is 2 minutes (10 * 12 second block times) + pub const MinBlocksPerRound: u32 = 10; + /// Rounds before the collator leaving the candidates request can be executed + pub const LeaveCandidatesDelay: u32 = 84; + /// Rounds before the candidate bond increase/decrease can be executed + pub const CandidateBondLessDelay: u32 = 84; + /// Rounds before the delegator exit can be executed + pub const LeaveDelegatorsDelay: u32 = 84; + /// Rounds before the delegator revocation can be executed + pub const RevokeDelegationDelay: u32 = 84; + /// Rounds before the delegator bond increase/decrease can be executed + pub const DelegationBondLessDelay: u32 = 84; + /// Rounds before the reward is paid + pub const RewardPaymentDelay: u32 = 2; + /// Minimum collators selected per round, default at genesis and minimum forever after + pub const MinSelectedCandidates: u32 = prod_or_fast!(16,6); + /// Maximum top delegations per candidate + pub const MaxTopDelegationsPerCandidate: u32 = 300; + /// Maximum bottom delegations per candidate + pub const MaxBottomDelegationsPerCandidate: u32 = 50; + /// Maximum delegations per delegator + pub const MaxDelegationsPerDelegator: u32 = 100; + /// Minimum stake required to become a collator + pub MinCollatorStk: u128 = 5000 * BNCS; + /// Minimum stake required to be reserved to be a candidate + pub MinCandidateStk: u128 = 5000 * BNCS; + /// Minimum stake required to be reserved to be a delegator + pub MinDelegatorStk: u128 = 50 * BNCS; + pub AllowInflation: bool = false; + pub ToMigrateInvulnables: Vec = prod_or_fast!(vec![ + hex!["5c7e9ccd1045cac7f8c5c77a79c87f44019d1dda4f5032713bda89c5d73cb36b"].into(), + hex!["606b0aad375ae1715fbe6a07315136a8e9c1c84a91230f6a0c296c2953581335"].into(), + hex!["b6ba81e73bd39203e006fc99cc1e41976745de2ea2007bf62ed7c9a48ccc5b1d"].into(), + hex!["ce42cea2dd0d4ac87ccdd5f0f2e1010955467f5a37587cf6af8ee2b4ba781034"].into(), + ],vec![]); + pub PaymentInRound: u128 = 180 * BNCS; + pub InitSeedStk: u128 = 5000 * BNCS; +} +impl bifrost_parachain_staking::Config for Runtime { + type RuntimeEvent = RuntimeEvent; + type Currency = Balances; + type MonetaryGovernanceOrigin = + EitherOfDiverse; + type MinBlocksPerRound = MinBlocksPerRound; + type LeaveCandidatesDelay = LeaveCandidatesDelay; + type CandidateBondLessDelay = CandidateBondLessDelay; + type LeaveDelegatorsDelay = LeaveDelegatorsDelay; + type RevokeDelegationDelay = RevokeDelegationDelay; + type DelegationBondLessDelay = DelegationBondLessDelay; + type RewardPaymentDelay = RewardPaymentDelay; + type MinSelectedCandidates = MinSelectedCandidates; + type MaxTopDelegationsPerCandidate = MaxTopDelegationsPerCandidate; + type MaxBottomDelegationsPerCandidate = MaxBottomDelegationsPerCandidate; + type MaxDelegationsPerDelegator = MaxDelegationsPerDelegator; + type MinCollatorStk = MinCollatorStk; + type MinCandidateStk = MinCandidateStk; + type MinDelegation = MinDelegatorStk; + type MinDelegatorStk = MinDelegatorStk; + type AllowInflation = AllowInflation; + type PaymentInRound = PaymentInRound; + type ToMigrateInvulnables = ToMigrateInvulnables; + type PalletId = ParachainStakingPalletId; + type InitSeedStk = InitSeedStk; + type OnCollatorPayout = (); + type OnNewRound = (); + type WeightInfo = bifrost_parachain_staking::weights::SubstrateWeight; +} + parameter_types! { pub const Period: u32 = 6 * HOURS; pub const Offset: u32 = 0; @@ -825,20 +918,20 @@ parameter_types! { impl pallet_session::Config for Runtime { type RuntimeEvent = RuntimeEvent; type Keys = opaque::SessionKeys; - type NextSessionRotation = pallet_session::PeriodicSessions; + type NextSessionRotation = ParachainStaking; // Essentially just Aura, but lets be pedantic. type SessionHandler = ::KeyTypeIdProviders; - type SessionManager = CollatorSelection; - type ShouldEndSession = pallet_session::PeriodicSessions; + type SessionManager = ParachainStaking; + type ShouldEndSession = ParachainStaking; type ValidatorId = ::AccountId; // we don't have stash and controller, thus we don't need the convert as well. - type ValidatorIdOf = pallet_collator_selection::IdentityCollator; + type ValidatorIdOf = ConvertInto; type WeightInfo = pallet_session::weights::SubstrateWeight; } impl pallet_authorship::Config for Runtime { - type EventHandler = CollatorSelection; + type EventHandler = ParachainStaking; type FindAuthor = pallet_session::FindAccountFromAuthorIndex; } @@ -850,28 +943,6 @@ impl pallet_aura::Config for Runtime { type SlotDuration = ConstU64; } -parameter_types! { - pub const PotId: PalletId = PalletId(*b"PotStake"); - pub const SessionLength: BlockNumber = 6 * HOURS; - pub const MaxInvulnerables: u32 = 100; -} - -impl pallet_collator_selection::Config for Runtime { - type Currency = Balances; - type RuntimeEvent = RuntimeEvent; - // should be a multiple of session or things will get inconsistent - type KickThreshold = Period; - type MaxCandidates = MaxCandidates; - type MaxInvulnerables = MaxInvulnerables; - type PotId = PotId; - type UpdateOrigin = EnsureRoot; - type ValidatorId = ::AccountId; - type ValidatorIdOf = pallet_collator_selection::IdentityCollator; - type ValidatorRegistration = Session; - type WeightInfo = (); - type MinEligibleCollators = ConstU32<5>; -} - // culumus runtime end parameter_types! { @@ -1100,7 +1171,7 @@ impl bifrost_slp::Config for Runtime { type SubstrateResponseManager = SubstrateResponseManager; type MaxTypeEntryPerBlock = MaxTypeEntryPerBlock; type MaxRefundPerBlock = MaxRefundPerBlock; - type ParachainStaking = (); + type ParachainStaking = ParachainStaking; type XcmTransfer = XTokens; type MaxLengthLimit = MaxLengthLimit; type XcmWeightAndFeeHandler = XcmInterface; @@ -1149,6 +1220,7 @@ parameter_types! { pub const BlocksPerRound: u32 = prod_or_fast!(1500, 50); pub const MaxTokenLen: u32 = 500; pub const MaxFarmingPoolIdLen: u32 = 100; + pub BenefitReceivingAccount: AccountId = FeeSharePalletId::get().into_account_truncating(); } impl bifrost_system_staking::Config for Runtime { @@ -1158,7 +1230,7 @@ impl bifrost_system_staking::Config for Runtime { type WeightInfo = weights::bifrost_system_staking::BifrostWeight; type FarmingInfo = Farming; type VtokenMintingInterface = VtokenMinting; - type TreasuryAccount = BifrostTreasuryAccount; + type BenefitReceivingAccount = BenefitReceivingAccount; type PalletId = SystemStakingPalletId; type BlocksPerRound = BlocksPerRound; type MaxTokenLen = MaxTokenLen; @@ -1241,7 +1313,7 @@ parameter_types! { pub struct DerivativeAccountTokenFilter; impl Contains for DerivativeAccountTokenFilter { fn contains(token: &CurrencyId) -> bool { - *token == RelayCurrencyId::get() + *token == RelayCurrencyId::get() || *token == BNC } } @@ -1486,7 +1558,7 @@ impl leverage_staking::Config for Runtime { parameter_types! { pub const ClearingDuration: u32 = prod_or_fast!(1 * DAYS, 10 * MINUTES); pub const NameLengthLimit: u32 = 20; - pub BifrostCommissionReceiver: AccountId = TreasuryPalletId::get().into_account_truncating(); + pub BifrostCommissionReceiver: AccountId = FeeSharePalletId::get().into_account_truncating(); } impl bifrost_channel_commission::Config for Runtime { @@ -1658,10 +1730,10 @@ construct_runtime! { // Collator support. the order of these 4 are important and shall not change. Authorship: pallet_authorship = 20, - CollatorSelection: pallet_collator_selection = 21, Session: pallet_session = 22, Aura: pallet_aura = 23, AuraExt: cumulus_pallet_aura_ext = 24, + ParachainStaking: bifrost_parachain_staking = 25, // Governance stuff Democracy: pallet_democracy = 30, @@ -1818,7 +1890,7 @@ impl cumulus_pallet_xcmp_queue::migration::v5::V5Config for Runtime { pub type Migrations = migrations::Unreleased; parameter_types! { - pub const SystemMakerName: &'static str = "SystemMaker"; + pub const CollatorSelectionName: &'static str = "CollatorSelection"; } /// The runtime migrations per release. @@ -1827,7 +1899,13 @@ pub mod migrations { use super::*; /// Unreleased migrations. Add new ones here: - pub type Unreleased = pallet_xcm::migration::MigrateToLatestXcmVersion; + pub type Unreleased = ( + // permanent migration, do not remove + pallet_xcm::migration::MigrateToLatestXcmVersion, + bifrost_parachain_staking::migrations::InitGenesisMigration, + frame_support::migrations::RemovePallet, + bifrost_flexible_fee::migrations::v3::PolkadotMigrateToV3, + ); } /// Executive: handles dispatch to the various modules. @@ -2292,7 +2370,7 @@ impl fp_rpc::EthereumRuntimeRPCApi for Runtime { impl sp_consensus_aura::AuraApi for Runtime { fn slot_duration() -> sp_consensus_aura::SlotDuration { - sp_consensus_aura::SlotDuration::from_millis(Aura::slot_duration()) + sp_consensus_aura::SlotDuration::from_millis(SLOT_DURATION) } fn authorities() -> Vec { @@ -2300,6 +2378,58 @@ impl fp_rpc::EthereumRuntimeRPCApi for Runtime { } } + impl cumulus_primitives_aura::AuraUnincludedSegmentApi for Runtime { + fn can_build_upon( + included_hash: ::Hash, + slot: cumulus_primitives_aura::Slot, + ) -> bool { + ConsensusHook::can_build_upon(included_hash, slot) + } + } + + impl xcm_fee_payment_runtime_api::fees::XcmPaymentApi for Runtime { + fn query_acceptable_payment_assets(xcm_version: xcm::Version) -> Result, XcmPaymentApiError> { + let acceptable_assets = AssetRegistry::asset_ids(); + PolkadotXcm::query_acceptable_payment_assets(xcm_version, acceptable_assets) + } + + fn query_weight_to_asset_fee(weight: Weight, asset: VersionedAssetId) -> Result { + let asset = asset + .into_version(4) + .map_err(|_| XcmPaymentApiError::VersionedConversionFailed)?; + let bnc_asset = VersionedAssetId::V4(LocalBncLocation::get().into()); + + if asset == bnc_asset { + // for native token + Ok(WeightToFee::weight_to_fee(&weight)) + } else { + let native_fee = WeightToFee::weight_to_fee(&weight); + let asset_location = &asset.try_as::().map_err(|_| XcmPaymentApiError::VersionedConversionFailed)?.0; + let asset_currency = AssetIdMaps::::get_currency_id(&asset_location).ok_or(XcmPaymentApiError::AssetNotFound)?; + let asset_fee = Prices::get_oracle_amount_by_currency_and_amount_in(&bifrost_primitives::BNC, native_fee, &asset_currency).ok_or(XcmPaymentApiError::AssetNotFound)?.0; + Ok(asset_fee) + } + } + + fn query_xcm_weight(message: VersionedXcm<()>) -> Result { + PolkadotXcm::query_xcm_weight(message) + } + + fn query_delivery_fees(destination: VersionedLocation, message: VersionedXcm<()>) -> Result { + PolkadotXcm::query_delivery_fees(destination, message) + } + } + + impl xcm_fee_payment_runtime_api::dry_run::DryRunApi for Runtime { + fn dry_run_call(origin: OriginCaller, call: RuntimeCall) -> Result, XcmDryRunApiError> { + PolkadotXcm::dry_run_call::(origin, call) + } + + fn dry_run_xcm(origin_location: VersionedLocation, xcm: VersionedXcm) -> Result, XcmDryRunApiError> { + PolkadotXcm::dry_run_xcm::(origin_location, xcm) + } + } + impl bifrost_flexible_fee_rpc_runtime_api::FlexibleFeeRuntimeApi for Runtime { fn get_fee_token_and_amount(who: AccountId, fee: Balance,utx: ::Extrinsic) -> (CurrencyId, Balance) { let call = utx.0.function; @@ -2529,31 +2659,7 @@ impl fp_rpc::EthereumRuntimeRPCApi for Runtime { } } -struct CheckInherents; -#[allow(deprecated)] -impl cumulus_pallet_parachain_system::CheckInherents for CheckInherents { - fn check_inherents( - block: &Block, - relay_state_proof: &cumulus_pallet_parachain_system::RelayChainStateProof, - ) -> sp_inherents::CheckInherentsResult { - let relay_chain_slot = relay_state_proof - .read_slot() - .expect("Could not read the relay chain slot from the proof"); - - let inherent_data = - cumulus_primitives_timestamp::InherentDataProvider::from_relay_chain_slot_and_duration( - relay_chain_slot, - sp_std::time::Duration::from_secs(6), - ) - .create_inherent_data() - .expect("Could not create the timestamp inherent data"); - - inherent_data.check_extrinsics(&block) - } -} - cumulus_pallet_parachain_system::register_validate_block! { Runtime = Runtime, BlockExecutor = cumulus_pallet_aura_ext::BlockExecutor::, - CheckInherents = CheckInherents, } diff --git a/runtime/bifrost-polkadot/src/weights/bifrost_slpx.rs b/runtime/bifrost-polkadot/src/weights/bifrost_slpx.rs index cc9f6ce45..555e30e8f 100644 --- a/runtime/bifrost-polkadot/src/weights/bifrost_slpx.rs +++ b/runtime/bifrost-polkadot/src/weights/bifrost_slpx.rs @@ -24,25 +24,27 @@ //! Autogenerated weights for bifrost_slpx //! -//! THIS FILE WAS AUTO-GENERATED USING THE SUBSTRATE BENCHMARK CLI VERSION 4.0.0-dev -//! DATE: 2023-09-14, STEPS: `50`, REPEAT: 20, LOW RANGE: `[]`, HIGH RANGE: `[]` +//! THIS FILE WAS AUTO-GENERATED USING THE SUBSTRATE BENCHMARK CLI VERSION 32.0.0 +//! DATE: 2024-11-20, STEPS: `50`, REPEAT: 20, LOW RANGE: `[]`, HIGH RANGE: `[]` //! HOSTNAME: `bifrost-jenkins`, CPU: `Intel(R) Xeon(R) CPU E5-26xx v4` //! WASM-EXECUTION: Compiled, CHAIN: Some("bifrost-kusama-local"), DB CACHE: 1024 // Executed Command: -// target/release/bifrost +// ./target/release/bifrost // benchmark // pallet // --chain=bifrost-kusama-local // --steps=50 // --repeat=20 -// --pallet=bifrost_slpx +// --pallet=bifrost-slpx // --extrinsic=* // --execution=wasm // --wasm-execution=compiled // --heap-pages=4096 -// --output=./runtime/bifrost-kusama/src/weights/bifrost_slpx.rs -// --template=./weight-template/runtime-weight-template.hbs +// --header=./HEADER-GPL3 +// --output=./weight.rs +// --template +// ./weight-template/runtime-weight-template.hbs #![cfg_attr(rustfmt, rustfmt_skip)] #![allow(unused_parens)] @@ -54,193 +56,98 @@ use sp_std::marker::PhantomData; /// Weight functions for bifrost_slpx. pub struct BifrostWeight(PhantomData); impl bifrost_slpx::WeightInfo for BifrostWeight { - // Storage: Slpx WhitelistAccountId (r:1 w:1) - // Proof: Slpx WhitelistAccountId (max_values: None, max_size: Some(338), added: 2813, mode: MaxEncodedLen) + // Storage: `Slpx::WhitelistAccountId` (r:1 w:1) + // Proof: `Slpx::WhitelistAccountId` (`max_values`: None, `max_size`: Some(338), added: 2813, mode: `MaxEncodedLen`) fn add_whitelist() -> Weight { // Proof Size summary in bytes: // Measured: `4` // Estimated: `3803` - // Minimum execution time: 33_664 nanoseconds. - Weight::from_parts(34_525_000, 3803) + // Minimum execution time: 25_165 nanoseconds. + Weight::from_parts(26_022_000, 3803) .saturating_add(T::DbWeight::get().reads(1)) .saturating_add(T::DbWeight::get().writes(1)) } - // Storage: Slpx WhitelistAccountId (r:1 w:1) - // Proof: Slpx WhitelistAccountId (max_values: None, max_size: Some(338), added: 2813, mode: MaxEncodedLen) + // Storage: `Slpx::WhitelistAccountId` (r:1 w:1) + // Proof: `Slpx::WhitelistAccountId` (`max_values`: None, `max_size`: Some(338), added: 2813, mode: `MaxEncodedLen`) fn remove_whitelist() -> Weight { // Proof Size summary in bytes: // Measured: `81` // Estimated: `3803` - // Minimum execution time: 37_038 nanoseconds. - Weight::from_parts(38_028_000, 3803) + // Minimum execution time: 27_790 nanoseconds. + Weight::from_parts(28_537_000, 3803) .saturating_add(T::DbWeight::get().reads(1)) .saturating_add(T::DbWeight::get().writes(1)) } - // Storage: Slpx ExecutionFee (r:0 w:1) - // Proof: Slpx ExecutionFee (max_values: None, max_size: Some(46), added: 2521, mode: MaxEncodedLen) + // Storage: `Slpx::ExecutionFee` (r:0 w:1) + // Proof: `Slpx::ExecutionFee` (`max_values`: None, `max_size`: Some(46), added: 2521, mode: `MaxEncodedLen`) fn set_execution_fee() -> Weight { // Proof Size summary in bytes: // Measured: `0` // Estimated: `0` - // Minimum execution time: 24_630 nanoseconds. - Weight::from_parts(25_469_000, 0) + // Minimum execution time: 15_997 nanoseconds. + Weight::from_parts(16_309_000, 0) .saturating_add(T::DbWeight::get().writes(1)) } - // Storage: Slpx TransferToFee (r:0 w:1) - // Proof: Slpx TransferToFee (max_values: None, max_size: Some(33), added: 2508, mode: MaxEncodedLen) + // Storage: `Slpx::TransferToFee` (r:0 w:1) + // Proof: `Slpx::TransferToFee` (`max_values`: None, `max_size`: Some(33), added: 2508, mode: `MaxEncodedLen`) fn set_transfer_to_fee() -> Weight { // Proof Size summary in bytes: // Measured: `0` // Estimated: `0` - // Minimum execution time: 24_544 nanoseconds. - Weight::from_parts(25_336_000, 0) + // Minimum execution time: 15_990 nanoseconds. + Weight::from_parts(16_543_000, 0) .saturating_add(T::DbWeight::get().writes(1)) } - // Storage: Slpx WhitelistAccountId (r:1 w:0) - // Proof: Slpx WhitelistAccountId (max_values: None, max_size: Some(338), added: 2813, mode: MaxEncodedLen) - // Storage: Tokens Accounts (r:4 w:4) - // Proof: Tokens Accounts (max_values: None, max_size: Some(118), added: 2593, mode: MaxEncodedLen) - // Storage: Slpx ExecutionFee (r:1 w:0) - // Proof: Slpx ExecutionFee (max_values: None, max_size: Some(46), added: 2521, mode: MaxEncodedLen) - // Storage: AssetRegistry CurrencyMetadatas (r:1 w:0) - // Proof Skipped: AssetRegistry CurrencyMetadatas (max_values: None, max_size: None, mode: Measured) - // Storage: System Account (r:3 w:2) - // Proof: System Account (max_values: None, max_size: Some(128), added: 2603, mode: MaxEncodedLen) - // Storage: VtokenMinting MinimumMint (r:1 w:0) - // Proof: VtokenMinting MinimumMint (max_values: None, max_size: Some(38), added: 2513, mode: MaxEncodedLen) - // Storage: VtokenMinting TokenPool (r:1 w:1) - // Proof: VtokenMinting TokenPool (max_values: None, max_size: Some(38), added: 2513, mode: MaxEncodedLen) - // Storage: Tokens TotalIssuance (r:1 w:1) - // Proof: Tokens TotalIssuance (max_values: None, max_size: Some(38), added: 2513, mode: MaxEncodedLen) - // Storage: VtokenMinting Fees (r:1 w:0) - // Proof: VtokenMinting Fees (max_values: Some(1), max_size: Some(8), added: 503, mode: MaxEncodedLen) - // Storage: AssetRegistry CurrencyIdToLocations (r:1 w:0) - // Proof Skipped: AssetRegistry CurrencyIdToLocations (max_values: None, max_size: None, mode: Measured) - // Storage: ParachainInfo ParachainId (r:1 w:0) - // Proof: ParachainInfo ParachainId (max_values: Some(1), max_size: Some(4), added: 499, mode: MaxEncodedLen) + // Storage: `Slpx::WhitelistAccountId` (r:1 w:0) + // Proof: `Slpx::WhitelistAccountId` (`max_values`: None, `max_size`: Some(338), added: 2813, mode: `MaxEncodedLen`) + // Storage: `Slpx::OrderQueue` (r:1 w:1) + // Proof: `Slpx::OrderQueue` (`max_values`: Some(1), `max_size`: Some(113502), added: 113997, mode: `MaxEncodedLen`) fn mint() -> Weight { // Proof Size summary in bytes: - // Measured: `2442` - // Estimated: `11362` - // Minimum execution time: 355_230 nanoseconds. - Weight::from_parts(360_766_000, 11362) - .saturating_add(T::DbWeight::get().reads(16)) - .saturating_add(T::DbWeight::get().writes(8)) + // Measured: `81` + // Estimated: `114987` + // Minimum execution time: 33_327 nanoseconds. + Weight::from_parts(34_485_000, 114987) + .saturating_add(T::DbWeight::get().reads(2)) + .saturating_add(T::DbWeight::get().writes(1)) } - // Storage: Slpx WhitelistAccountId (r:1 w:0) - // Proof: Slpx WhitelistAccountId (max_values: None, max_size: Some(338), added: 2813, mode: MaxEncodedLen) - // Storage: Tokens Accounts (r:4 w:4) - // Proof: Tokens Accounts (max_values: None, max_size: Some(118), added: 2593, mode: MaxEncodedLen) - // Storage: Slpx ExecutionFee (r:1 w:0) - // Proof: Slpx ExecutionFee (max_values: None, max_size: Some(46), added: 2521, mode: MaxEncodedLen) - // Storage: AssetRegistry CurrencyMetadatas (r:1 w:0) - // Proof Skipped: AssetRegistry CurrencyMetadatas (max_values: None, max_size: None, mode: Measured) - // Storage: System Account (r:3 w:2) - // Proof: System Account (max_values: None, max_size: Some(128), added: 2603, mode: MaxEncodedLen) - // Storage: VtokenMinting MinimumMint (r:1 w:0) - // Proof: VtokenMinting MinimumMint (max_values: None, max_size: Some(38), added: 2513, mode: MaxEncodedLen) - // Storage: VtokenMinting TokenPool (r:1 w:1) - // Proof: VtokenMinting TokenPool (max_values: None, max_size: Some(38), added: 2513, mode: MaxEncodedLen) - // Storage: Tokens TotalIssuance (r:1 w:1) - // Proof: Tokens TotalIssuance (max_values: None, max_size: Some(38), added: 2513, mode: MaxEncodedLen) - // Storage: VtokenMinting Fees (r:1 w:0) - // Proof: VtokenMinting Fees (max_values: Some(1), max_size: Some(8), added: 503, mode: MaxEncodedLen) - // Storage: AssetRegistry CurrencyIdToLocations (r:1 w:0) - // Proof Skipped: AssetRegistry CurrencyIdToLocations (max_values: None, max_size: None, mode: Measured) - // Storage: ParachainInfo ParachainId (r:1 w:0) - // Proof: ParachainInfo ParachainId (max_values: Some(1), max_size: Some(4), added: 499, mode: MaxEncodedLen) + // Storage: `Slpx::WhitelistAccountId` (r:1 w:0) + // Proof: `Slpx::WhitelistAccountId` (`max_values`: None, `max_size`: Some(338), added: 2813, mode: `MaxEncodedLen`) + // Storage: `Slpx::OrderQueue` (r:1 w:1) + // Proof: `Slpx::OrderQueue` (`max_values`: Some(1), `max_size`: Some(113502), added: 113997, mode: `MaxEncodedLen`) fn mint_with_channel_id() -> Weight { // Proof Size summary in bytes: - // Measured: `2442` - // Estimated: `11362` - // Minimum execution time: 355_230 nanoseconds. - Weight::from_parts(360_766_000, 11362) - .saturating_add(T::DbWeight::get().reads(16)) - .saturating_add(T::DbWeight::get().writes(8)) + // Measured: `81` + // Estimated: `114987` + // Minimum execution time: 33_004 nanoseconds. + Weight::from_parts(33_780_000, 114987) + .saturating_add(T::DbWeight::get().reads(2)) + .saturating_add(T::DbWeight::get().writes(1)) } - // Storage: Slpx WhitelistAccountId (r:1 w:0) - // Proof: Slpx WhitelistAccountId (max_values: None, max_size: Some(338), added: 2813, mode: MaxEncodedLen) - // Storage: Tokens Accounts (r:2 w:2) - // Proof: Tokens Accounts (max_values: None, max_size: Some(118), added: 2593, mode: MaxEncodedLen) - // Storage: Slpx ExecutionFee (r:1 w:0) - // Proof: Slpx ExecutionFee (max_values: None, max_size: Some(46), added: 2521, mode: MaxEncodedLen) - // Storage: AssetRegistry CurrencyMetadatas (r:2 w:0) - // Proof Skipped: AssetRegistry CurrencyMetadatas (max_values: None, max_size: None, mode: Measured) - // Storage: System Account (r:2 w:1) - // Proof: System Account (max_values: None, max_size: Some(128), added: 2603, mode: MaxEncodedLen) - // Storage: VtokenMinting MinimumRedeem (r:1 w:0) - // Proof: VtokenMinting MinimumRedeem (max_values: None, max_size: Some(38), added: 2513, mode: MaxEncodedLen) - // Storage: Slp DelegationsOccupied (r:1 w:0) - // Proof Skipped: Slp DelegationsOccupied (max_values: None, max_size: None, mode: Measured) - // Storage: VtokenMinting Fees (r:1 w:0) - // Proof: VtokenMinting Fees (max_values: Some(1), max_size: Some(8), added: 503, mode: MaxEncodedLen) - // Storage: VtokenMinting TokenPool (r:1 w:0) - // Proof: VtokenMinting TokenPool (max_values: None, max_size: Some(38), added: 2513, mode: MaxEncodedLen) - // Storage: Tokens TotalIssuance (r:1 w:0) - // Proof: Tokens TotalIssuance (max_values: None, max_size: Some(38), added: 2513, mode: MaxEncodedLen) - // Storage: VtokenMinting OngoingTimeUnit (r:1 w:0) - // Proof: VtokenMinting OngoingTimeUnit (max_values: None, max_size: Some(27), added: 2502, mode: MaxEncodedLen) - // Storage: AssetRegistry CurrencyIdToLocations (r:1 w:0) - // Proof Skipped: AssetRegistry CurrencyIdToLocations (max_values: None, max_size: None, mode: Measured) - // Storage: ParachainInfo ParachainId (r:1 w:0) - // Proof: ParachainInfo ParachainId (max_values: Some(1), max_size: Some(4), added: 499, mode: MaxEncodedLen) + // Storage: `Slpx::WhitelistAccountId` (r:1 w:0) + // Proof: `Slpx::WhitelistAccountId` (`max_values`: None, `max_size`: Some(338), added: 2813, mode: `MaxEncodedLen`) + // Storage: `Slpx::OrderQueue` (r:1 w:1) + // Proof: `Slpx::OrderQueue` (`max_values`: Some(1), `max_size`: Some(113502), added: 113997, mode: `MaxEncodedLen`) fn redeem() -> Weight { // Proof Size summary in bytes: - // Measured: `2194` - // Estimated: `8134` - // Minimum execution time: 243_971 nanoseconds. - Weight::from_parts(250_684_000, 8134) - .saturating_add(T::DbWeight::get().reads(16)) - .saturating_add(T::DbWeight::get().writes(3)) - } - // Storage: Slpx WhitelistAccountId (r:1 w:0) - // Proof: Slpx WhitelistAccountId (max_values: None, max_size: Some(338), added: 2813, mode: MaxEncodedLen) - // Storage: ParachainInfo ParachainId (r:1 w:0) - // Proof: ParachainInfo ParachainId (max_values: Some(1), max_size: Some(4), added: 499, mode: MaxEncodedLen) - // Storage: Tokens Accounts (r:4 w:2) - // Proof: Tokens Accounts (max_values: None, max_size: Some(118), added: 2593, mode: MaxEncodedLen) - // Storage: Slpx ExecutionFee (r:1 w:0) - // Proof: Slpx ExecutionFee (max_values: None, max_size: Some(46), added: 2521, mode: MaxEncodedLen) - // Storage: AssetRegistry CurrencyMetadatas (r:1 w:0) - // Proof Skipped: AssetRegistry CurrencyMetadatas (max_values: None, max_size: None, mode: Measured) - // Storage: System Account (r:2 w:1) - // Proof: System Account (max_values: None, max_size: Some(128), added: 2603, mode: MaxEncodedLen) - // Storage: AssetRegistry CurrencyIdToLocations (r:1 w:0) - // Proof Skipped: AssetRegistry CurrencyIdToLocations (max_values: None, max_size: None, mode: Measured) - fn zenlink_swap() -> Weight { - // Proof Size summary in bytes: - // Measured: `1819` - // Estimated: `11362` - // Minimum execution time: 220_866 nanoseconds. - Weight::from_parts(223_033_000, 11362) - .saturating_add(T::DbWeight::get().reads(11)) - .saturating_add(T::DbWeight::get().writes(3)) + // Measured: `81` + // Estimated: `114987` + // Minimum execution time: 31_663 nanoseconds. + Weight::from_parts(33_722_000, 114987) + .saturating_add(T::DbWeight::get().reads(2)) + .saturating_add(T::DbWeight::get().writes(1)) } - // Storage: Slpx WhitelistAccountId (r:1 w:0) - // Proof: Slpx WhitelistAccountId (max_values: None, max_size: Some(338), added: 2813, mode: MaxEncodedLen) - // Storage: StableAsset Pools (r:1 w:0) - // Proof Skipped: StableAsset Pools (max_values: None, max_size: None, mode: Measured) - // Storage: Tokens Accounts (r:6 w:2) - // Proof: Tokens Accounts (max_values: None, max_size: Some(118), added: 2593, mode: MaxEncodedLen) - // Storage: Slpx ExecutionFee (r:1 w:0) - // Proof: Slpx ExecutionFee (max_values: None, max_size: Some(46), added: 2521, mode: MaxEncodedLen) - // Storage: AssetRegistry CurrencyMetadatas (r:1 w:0) - // Proof Skipped: AssetRegistry CurrencyMetadatas (max_values: None, max_size: None, mode: Measured) - // Storage: System Account (r:3 w:1) - // Proof: System Account (max_values: None, max_size: Some(128), added: 2603, mode: MaxEncodedLen) - // Storage: StableAsset TokenRateCaches (r:2 w:0) - // Proof Skipped: StableAsset TokenRateCaches (max_values: None, max_size: None, mode: Measured) - // Storage: AssetRegistry CurrencyIdToLocations (r:1 w:0) - // Proof Skipped: AssetRegistry CurrencyIdToLocations (max_values: None, max_size: None, mode: Measured) - // Storage: ParachainInfo ParachainId (r:1 w:0) - // Proof: ParachainInfo ParachainId (max_values: Some(1), max_size: Some(4), added: 499, mode: MaxEncodedLen) - fn stable_pool_swap() -> Weight { + // Storage: `Slpx::WhitelistAccountId` (r:1 w:0) + // Proof: `Slpx::WhitelistAccountId` (`max_values`: None, `max_size`: Some(338), added: 2813, mode: `MaxEncodedLen`) + // Storage: `Slpx::OrderQueue` (r:1 w:1) + // Proof: `Slpx::OrderQueue` (`max_values`: Some(1), `max_size`: Some(113502), added: 113997, mode: `MaxEncodedLen`) + fn evm_create_order() -> Weight { // Proof Size summary in bytes: - // Measured: `2782` - // Estimated: `16548` - // Minimum execution time: 552_131 nanoseconds. - Weight::from_parts(564_804_000, 16548) - .saturating_add(T::DbWeight::get().reads(17)) - .saturating_add(T::DbWeight::get().writes(3)) + // Measured: `81` + // Estimated: `114987` + // Minimum execution time: 32_494 nanoseconds. + Weight::from_parts(33_539_000, 114987) + .saturating_add(T::DbWeight::get().reads(2)) + .saturating_add(T::DbWeight::get().writes(1)) } -} +} \ No newline at end of file diff --git a/runtime/bifrost-polkadot/src/xcm_config.rs b/runtime/bifrost-polkadot/src/xcm_config.rs index 69ab3fa92..7bb1b2760 100644 --- a/runtime/bifrost-polkadot/src/xcm_config.rs +++ b/runtime/bifrost-polkadot/src/xcm_config.rs @@ -24,8 +24,9 @@ use bifrost_primitives::{ CurrencyId, CurrencyIdMapping, EthereumLocation, NativeAssetFrom, PolkadotNetwork, PolkadotUniversalLocation, SelfLocation, TokenSymbol, DOT_TOKEN_ID, }; -use bifrost_runtime_common::currency_adapter::{ - BifrostDropAssets, DepositToAlternative, MultiCurrencyAdapter, +use bifrost_runtime_common::{ + currency_adapter::{BifrostDropAssets, DepositToAlternative, MultiCurrencyAdapter}, + xcm_weight_trader::XcmWeightTrader, }; use cumulus_primitives_core::AggregateMessageOrigin; pub use cumulus_primitives_core::ParaId; @@ -37,11 +38,8 @@ pub use orml_traits::{location::AbsoluteReserveProvider, parameter_type_with_key use orml_xcm_support::{IsNativeConcrete, MultiNativeAsset}; use pallet_xcm::XcmPassthrough; use parachains_common::message_queue::{NarrowOriginToSibling, ParaIdToSibling}; -use parity_scale_codec::Encode; pub use polkadot_parachain_primitives::primitives::Sibling; use polkadot_runtime_common::xcm_sender::NoPriceForMessageDelivery; -use sp_core::bounded::BoundedVec; -use sp_std::convert::TryFrom; use xcm::v4::{Asset, AssetId, Location}; pub use xcm_builder::{ AccountId32Aliases, AllowKnownQueryResponses, AllowSubscriptionsFrom, @@ -66,7 +64,7 @@ parameter_types! { // XTokens pallet supports maximum number of assets to be transferred at a time pub const MaxAssetsForTransfer: usize = 2; // One XCM operation is 200_000_000 weight, cross-chain transfer ~= 2x of transfer = 3_000_000_000 - pub const UnitWeightCost: Weight = Weight::from_parts(200_000_000, 0); + pub const UnitWeightCost: Weight = Weight::from_parts(50_000_000, 0); // Maximum number of instructions that can be executed in one XCM message pub const MaxInstructions: u32 = 100; } @@ -139,47 +137,6 @@ pub type BifrostAssetTransactor = MultiCurrencyAdapter< DepositToAlternative, >; -parameter_types! { - pub DotPerSecond: (AssetId,u128, u128) = (Location::parent().into(), dot_per_second::(),0); - pub BncPerSecond: (AssetId,u128, u128) = ( - Location::new( - 1, - [xcm::v4::Junction::Parachain(SelfParaId::get()), xcm::v4::Junction::from(BoundedVec::try_from(NativeCurrencyId::get().encode()).unwrap())], - ).into(), - // BNC:DOT = 80:1 - dot_per_second::() * 80, - 0 - ); - pub BncNewPerSecond: (AssetId,u128, u128) = ( - Location::new( - 0, - [xcm::v4::Junction::from(BoundedVec::try_from(NativeCurrencyId::get().encode()).unwrap())] - ).into(), - // BNC:DOT = 80:1 - dot_per_second::() * 80, - 0 - ); - pub ZlkPerSecond: (AssetId, u128,u128) = ( - Location::new( - 1, - [xcm::v4::Junction::Parachain(SelfParaId::get()), xcm::v4::Junction::from(BoundedVec::try_from(CurrencyId::Token(TokenSymbol::ZLK).encode()).unwrap())] - ).into(), - // ZLK:KSM = 150:1 - dot_per_second::() * 150 * 1_000_000, - 0 - ); - pub ZlkNewPerSecond: (AssetId, u128,u128) = ( - Location::new( - 0, - [xcm::v4::Junction::from(BoundedVec::try_from(CurrencyId::Token(TokenSymbol::ZLK).encode()).unwrap())] - ).into(), - // ZLK:KSM = 150:1 - dot_per_second::() * 150 * 1_000_000, - 0 - ); - pub BasePerSecond: u128 = dot_per_second::(); -} - pub struct ToTreasury; impl TakeRevenue for ToTreasury { fn take_revenue(revenue: Asset) { @@ -193,13 +150,6 @@ impl TakeRevenue for ToTreasury { } } -pub type Trader = ( - FixedRateOfFungible, - FixedRateOfFungible, - FixedRateOfFungible, - FixedRateOfAsset, -); - /// A call filter for the XCM Transact instruction. This is a temporary measure until we properly /// account for proof size weights. /// @@ -305,7 +255,9 @@ impl xcm_executor::Config for XcmConfig { type OriginConverter = XcmOriginToTransactDispatchOrigin; type ResponseHandler = PolkadotXcm; type SubscriptionService = PolkadotXcm; - type Trader = Trader; + type Trader = XcmWeightTrader, ToTreasury>; + // TODO: Implement XcmWeigher, using real Weight, currently per instruction Weight = + // Weight::from_parts(50_000_000, 0) type Weigher = FixedWeightBounds; type XcmSender = XcmRouter; type PalletInstancesInfo = AllPalletsWithSystem; diff --git a/runtime/common/Cargo.toml b/runtime/common/Cargo.toml index 7937f5f93..c4907fdf9 100644 --- a/runtime/common/Cargo.toml +++ b/runtime/common/Cargo.toml @@ -51,7 +51,6 @@ cumulus-primitives-utility = { workspace = true } cumulus-pallet-xcmp-queue = { workspace = true } cumulus-pallet-xcm = { workspace = true } parachain-info = { workspace = true } -pallet-collator-selection = { workspace = true } # Polkadot dependencies polkadot-parachain-primitives = { workspace = true } diff --git a/runtime/common/src/constants.rs b/runtime/common/src/constants.rs index f53504944..cd88a48e1 100644 --- a/runtime/common/src/constants.rs +++ b/runtime/common/src/constants.rs @@ -42,6 +42,15 @@ pub mod time { pub const DAYS: BlockNumber = HOURS * 24; pub const WEEKS: BlockNumber = DAYS * 7; + /// Maximum number of blocks simultaneously accepted by the Runtime, not yet included into the + /// relay chain. + pub const UNINCLUDED_SEGMENT_CAPACITY: u32 = 1; + /// How many parachain blocks are processed by the relay chain per parent. Limits the number of + /// blocks authored per slot. + pub const BLOCK_PROCESSING_VELOCITY: u32 = 1; + /// Relay chain slot duration, in milliseconds. + pub const RELAY_CHAIN_SLOT_DURATION_MILLIS: u32 = 6000; + // The `LeasePeriod` defination from `polkadot`. pub const POLKA_LEASE_PERIOD: BlockNumber = 12 * WEEKS; pub const KUSAMA_LEASE_PERIOD: BlockNumber = 6 * WEEKS; diff --git a/runtime/common/src/currency_converter.rs b/runtime/common/src/currency_converter.rs index fd2276e04..eb7190d41 100644 --- a/runtime/common/src/currency_converter.rs +++ b/runtime/common/src/currency_converter.rs @@ -21,7 +21,7 @@ use bifrost_primitives::{CurrencyId, CurrencyIdMapping}; use cumulus_primitives_core::ParaId; use frame_support::traits::Get; use sp_runtime::traits::Convert; -use sp_std::{marker::PhantomData, prelude::*}; +use sp_std::marker::PhantomData; use xcm::{ latest::{AssetId, Location}, prelude::Fungible, @@ -34,7 +34,7 @@ impl, R: bifrost_asset_registry::Config> Convert { fn convert(id: CurrencyId) -> Option { - AssetIdMaps::::get_location(id) + AssetIdMaps::::get_location(&id) } } /// Convert Location to CurrencyId @@ -42,7 +42,7 @@ impl, R: bifrost_asset_registry::Config> Convert { fn convert(location: Location) -> Option { - AssetIdMaps::::get_currency_id(location.clone()) + AssetIdMaps::::get_currency_id(&location) } } /// Convert Asset to CurrencyId diff --git a/runtime/common/src/lib.rs b/runtime/common/src/lib.rs index c7fccfce8..9181be760 100644 --- a/runtime/common/src/lib.rs +++ b/runtime/common/src/lib.rs @@ -32,6 +32,7 @@ use sp_runtime::{traits::Bounded, FixedPointNumber, Perquintill}; pub mod constants; pub mod currency_adapter; pub mod currency_converter; +pub mod xcm_weight_trader; #[cfg(test)] mod tests; diff --git a/runtime/common/src/xcm_weight_trader.rs b/runtime/common/src/xcm_weight_trader.rs new file mode 100644 index 000000000..42bc9ba6e --- /dev/null +++ b/runtime/common/src/xcm_weight_trader.rs @@ -0,0 +1,162 @@ +// SPDX-License-Identifier: GPL-3.0-or-later WITH Classpath-exception-2.0 + +// This program is free software: you can redistribute it and/or modify +// it under the terms of the GNU General Public License as published by +// the Free Software Foundation, either version 3 of the License, or +// (at your option) any later version. + +// This program is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. + +// You should have received a copy of the GNU General Public License +// along with this program. If not, see . + +use bifrost_asset_registry::AssetMetadata; +use bifrost_primitives::{ + Balance, CurrencyId, CurrencyIdMapping, LocalBncLocation, OraclePriceProvider, BNC, +}; +use frame_support::weights::Weight; +use sp_std::marker::PhantomData; +use xcm::{ + latest::{Asset, AssetId, Location, XcmContext}, + prelude::{Fungible, XcmError}, +}; +use xcm_builder::TakeRevenue; +use xcm_executor::{traits::WeightTrader, AssetsInHolding}; + +pub struct XcmWeightTrader< + WeightToFee: frame_support::weights::WeightToFee, + Price: OraclePriceProvider, + CM: CurrencyIdMapping>, + R: TakeRevenue, +>(Weight, Option, PhantomData<(WeightToFee, Price, CM, R)>); + +impl< + WeightToFee: frame_support::weights::WeightToFee, + Price: OraclePriceProvider, + CM: CurrencyIdMapping>, + R: TakeRevenue, + > XcmWeightTrader +{ + fn compute_amount_to_charge( + weight: &Weight, + asset_location: &Location, + ) -> Result { + if *asset_location == LocalBncLocation::get() { + Ok(WeightToFee::weight_to_fee(weight)) + } else { + let bnc_amount = WeightToFee::weight_to_fee(weight); + let asset_currency_id = + CM::get_currency_id(asset_location).ok_or(XcmError::AssetNotFound)?; + let asset_amount = Price::get_oracle_amount_by_currency_and_amount_in( + &BNC, + bnc_amount, + &asset_currency_id, + ) + .ok_or(XcmError::Overflow)? + .0; + Ok(asset_amount) + } + } +} + +impl< + WeightToFee: frame_support::weights::WeightToFee, + Price: OraclePriceProvider, + CM: CurrencyIdMapping>, + R: TakeRevenue, + > WeightTrader for XcmWeightTrader +{ + fn new() -> Self { + Self(Weight::zero(), None, PhantomData) + } + + fn buy_weight( + &mut self, + weight: Weight, + payment: AssetsInHolding, + _context: &XcmContext, + ) -> Result { + log::trace!(target: "xcm-weight-trader", "buy_weight weight: {:?}, payment: {:?}", weight, payment); + + // only support first fungible assets now. + let first_asset = + payment.clone().fungible_assets_iter().next().ok_or(XcmError::AssetNotFound)?; + + match (first_asset.id, first_asset.fun) { + (AssetId(location), Fungible(_)) => { + log::trace!(target: "xcm::weight", "buy_weight location: {:?}", location); + let amount = Self::compute_amount_to_charge(&weight, &location)?; + + // We don't need to proceed if the amount is 0 + // For cases (specially tests) where the asset is very cheap with respect + // to the weight needed + if amount == 0 { + return Ok(payment); + } + + let required = Asset { fun: Fungible(amount), id: AssetId(location) }; + let unused = + payment.checked_sub(required.clone()).map_err(|_| XcmError::TooExpensive)?; + + self.0 = weight; + self.1 = Some(required); + + Ok(unused) + }, + _ => Err(XcmError::AssetNotFound), + } + } + + fn refund_weight(&mut self, actual_weight: Weight, context: &XcmContext) -> Option { + log::trace!( + target: "xcm-weight-trader", + "refund_weight weight: {:?}, context: {:?}, available weight: {:?}, asset: {:?}", + actual_weight, + context, + self.0, + self.1 + ); + + if let Some(Asset { fun: Fungible(initial_amount), id: AssetId(location) }) = self.1.take() + { + if actual_weight == self.0 { + self.1 = Some(Asset { fun: Fungible(initial_amount), id: AssetId(location) }); + None + } else { + let weight = actual_weight.min(self.0); + let amount = + Self::compute_amount_to_charge(&weight, &location).unwrap_or(Balance::MAX); + let final_amount = amount.min(initial_amount); + let amount_to_refund = initial_amount.saturating_sub(final_amount); + self.0 -= weight; + self.1 = Some(Asset { fun: Fungible(final_amount), id: AssetId(location.clone()) }); + log::trace!( + target: "xcm-weight-trader", + "refund_weight amount to refund: {:?}", + amount_to_refund + ); + Some(Asset { fun: Fungible(amount_to_refund), id: AssetId(location) }) + } + } else { + None + } + } +} + +impl< + WeightToFee: frame_support::weights::WeightToFee, + Price: OraclePriceProvider, + CM: CurrencyIdMapping>, + R: TakeRevenue, + > Drop for XcmWeightTrader +{ + fn drop(&mut self) { + log::trace!(target: "xcm-weight-trader", "take revenue, weight: {:?}, asset: {:?}", self.0, self.1); + if let Some(asset) = self.1.take() { + R::take_revenue(asset); + } + } +}