From 48a8d7052750cdfdc79a7aa49d1087057bfa258a Mon Sep 17 00:00:00 2001 From: 1xstj <106580853+1xstj@users.noreply.github.com> Date: Wed, 22 Jan 2025 17:58:55 +0400 Subject: [PATCH] Code cleanup v2 (#895) * HAL-20 : fix enum comment * HAL-20 : fix merge_schedules * HAL-20 : fix setCommission * HAL-20 : fix erasTotalRewardPoints * (HAL-13) : remove unit8 return type * fix transferred * fix comment * fix tangle lst comments * fix comments * add workspace * clean todos --- Cargo.toml | 2 + client/rpc/trace/src/lib.rs | 3 - frost/frost-secp256k1-tr/src/lib.rs | 1 - frost/src/scalar_mul.rs | 2 - pallets/multi-asset-delegation/src/lib.rs | 1 - pallets/multi-asset-delegation/src/mock.rs | 2 +- pallets/services/src/lib.rs | 14 +-- precompiles/assets-erc20/ERC20.sol | 2 +- precompiles/assets-erc20/src/tests.rs | 72 ++++++++-------- precompiles/balances-erc20/ERC20.sol | 4 +- precompiles/balances-erc20/src/tests.rs | 86 +++++++++---------- precompiles/batch/src/lib.rs | 2 +- precompiles/call-permit/CallPermit.sol | 2 +- precompiles/call-permit/src/tests.rs | 12 +-- .../pallet-democracy/DemocracyInterface.sol | 1 - precompiles/pallet-democracy/src/mock.rs | 2 +- precompiles/pallet-democracy/src/tests.rs | 12 ++- precompiles/precompile-registry/src/lib.rs | 9 +- precompiles/staking/src/lib.rs | 5 +- precompiles/tangle-lst/Cargo.toml | 2 +- precompiles/tangle-lst/TangleLst.sol | 23 +++-- precompiles/tangle-lst/src/lib.rs | 20 ++--- precompiles/vesting/Vesting.sol | 8 +- precompiles/vesting/src/lib.rs | 9 +- 24 files changed, 138 insertions(+), 158 deletions(-) diff --git a/Cargo.toml b/Cargo.toml index 6ae37ceff..1dddd8710 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -45,6 +45,8 @@ members = [ "precompiles/services", "precompiles/tangle-lst", "precompiles/assets", + "precompiles/vesting", + "precompiles/staking", "tangle-subxt", "evm-tracer", ] diff --git a/client/rpc/trace/src/lib.rs b/client/rpc/trace/src/lib.rs index 7c5cb141f..73ba8aacc 100644 --- a/client/rpc/trace/src/lib.rs +++ b/client/rpc/trace/src/lib.rs @@ -689,9 +689,6 @@ where // In some cases it might be possible to receive traces of a block // that has no entry in the cache because it was removed of the pool // and received a permit concurrently. We just ignore it. - // - // TODO : Should we add it back ? Should it have an active_batch_count - // of 1 then ? if let Some(block_cache) = self.cached_blocks.get_mut(&block_hash) { if let CacheBlockState::Pooled { ref mut waiting_requests, .. } = block_cache.state { tracing::trace!( diff --git a/frost/frost-secp256k1-tr/src/lib.rs b/frost/frost-secp256k1-tr/src/lib.rs index 0a82729be..34aa0d1c7 100644 --- a/frost/frost-secp256k1-tr/src/lib.rs +++ b/frost/frost-secp256k1-tr/src/lib.rs @@ -212,7 +212,6 @@ fn negate_nonce(nonce: &frost_core::round1::Nonce) -> frost_core::round1::Non // Negate a SigningNonces fn negate_nonces(signing_nonces: &round1::SigningNonces) -> round1::SigningNonces { - // TODO: this recomputes commitments which is expensive, and not needed. // Create an `internals` SigningNonces::from_nonces_and_commitments or // something similar. round1::SigningNonces::from_nonces( diff --git a/frost/src/scalar_mul.rs b/frost/src/scalar_mul.rs index 130578dc7..2dcef6d39 100644 --- a/frost/src/scalar_mul.rs +++ b/frost/src/scalar_mul.rs @@ -22,8 +22,6 @@ use crate::{Ciphersuite, Element, Field, Group, Scalar}; /// /// This function is similar to `div_ceil` that is [available on /// Nightly](https://github.com/rust-lang/rust/issues/88581). -// TODO: remove this function and use `div_ceil()` instead when `int_roundings` -// is stabilized. const fn div_ceil(lhs: usize, rhs: usize) -> usize { let d = lhs / rhs; let r = lhs % rhs; diff --git a/pallets/multi-asset-delegation/src/lib.rs b/pallets/multi-asset-delegation/src/lib.rs index c2aef9d1d..c83a00c82 100644 --- a/pallets/multi-asset-delegation/src/lib.rs +++ b/pallets/multi-asset-delegation/src/lib.rs @@ -69,7 +69,6 @@ mod tests; pub mod weights; // #[cfg(feature = "runtime-benchmarks")] -// TODO(@1xstj): Fix benchmarking and re-enable // mod benchmarking; pub mod functions; diff --git a/pallets/multi-asset-delegation/src/mock.rs b/pallets/multi-asset-delegation/src/mock.rs index c645f4468..bf6c4eb33 100644 --- a/pallets/multi-asset-delegation/src/mock.rs +++ b/pallets/multi-asset-delegation/src/mock.rs @@ -293,7 +293,7 @@ impl tangle_primitives::traits::ServiceManager for MockServi } fn get_blueprints_by_operator(_account: &AccountId) -> Vec { - todo!(); // we don't care + unimplemented!(); // we don't care } } diff --git a/pallets/services/src/lib.rs b/pallets/services/src/lib.rs index 77cab2216..c1693a1cd 100644 --- a/pallets/services/src/lib.rs +++ b/pallets/services/src/lib.rs @@ -709,7 +709,6 @@ pub mod module { NextBlueprintId::::set(blueprint_id.saturating_add(1)); Self::deposit_event(Event::BlueprintCreated { owner, blueprint_id }); - // TODO: update weight for the creation of the blueprint. Ok(PostDispatchInfo { actual_weight: None, pays_fee: Pays::Yes }) } @@ -853,7 +852,6 @@ pub mod module { registration_args, }); - // TODO: update weight for the registration. Ok(PostDispatchInfo { actual_weight: None, pays_fee: Pays::Yes }) } @@ -887,10 +885,8 @@ pub mod module { let (allowed, _weight) = Self::on_unregister_hook(&blueprint, blueprint_id, &preferences)?; ensure!(allowed, Error::::NotAllowedToUnregister); - // TODO: check if the caller is not providing any service for the blueprint. Operators::::remove(blueprint_id, &caller); - // TODO: also remove all the services that uses this blueprint? let removed = OperatorsProfile::::try_mutate_exists(&caller, |profile| { profile .as_mut() @@ -900,7 +896,6 @@ pub mod module { ensure!(removed, Error::::NotRegistered); Self::deposit_event(Event::Unregistered { operator: caller.clone(), blueprint_id }); - // TODO: update weight for the unregistration. Ok(PostDispatchInfo { actual_weight: None, pays_fee: Pays::Yes }) } @@ -1119,7 +1114,6 @@ pub mod module { assets: assets.to_vec(), }); - // TODO: add weight for the request to the total weight. Ok(PostDispatchInfo { actual_weight: None, pays_fee: Pays::Yes }) } @@ -1405,7 +1399,6 @@ pub mod module { StagingServicePayments::::remove(request_id); } - // TODO: make use of the returned weight from the hook. Ok(PostDispatchInfo { actual_weight: None, pays_fee: Pays::Yes }) } @@ -1433,7 +1426,6 @@ pub mod module { ) -> DispatchResultWithPostInfo { let caller = ensure_signed(origin)?; let service = Self::services(service_id)?; - // TODO: allow permissioned callers to terminate the service? ensure!(service.owner == caller, DispatchError::BadOrigin); let removed = UserServices::::try_mutate(&caller, |service_ids| { Result::<_, Error>::Ok(service_ids.remove(&service_id)) @@ -1526,7 +1518,7 @@ pub mod module { job, args, }); - // TODO: add weight for the call to the total weight. + Ok(PostDispatchInfo { actual_weight: None, pays_fee: Pays::Yes }) } @@ -1600,7 +1592,7 @@ pub mod module { job: job_call.job, result, }); - // TODO: add weight for the call to the total weight. + Ok(PostDispatchInfo { actual_weight: None, pays_fee: Pays::Yes }) } @@ -1659,7 +1651,7 @@ pub mod module { .collect::>(); let total_slash = others_slash.iter().fold(exposed_stake, |acc, (_, slash)| acc + *slash); - // TODO: take into account the delegators' asset kind. + // for now, we treat all assets equally, which is not the case in reality. let unapplied_slash = UnappliedSlash { service_id, diff --git a/precompiles/assets-erc20/ERC20.sol b/precompiles/assets-erc20/ERC20.sol index ceb693a08..5461f7fd7 100644 --- a/precompiles/assets-erc20/ERC20.sol +++ b/precompiles/assets-erc20/ERC20.sol @@ -71,7 +71,7 @@ interface IERC20 { /// @custom:selector ddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef /// @param from address The address sending the tokens /// @param to address The address receiving the tokens. - /// @param value uint256 The amount of tokens transfered. + /// @param value uint256 The amount of tokens transferred. event Transfer(address indexed from, address indexed to, uint256 value); /// @dev Event emited when an approval has been registered. diff --git a/precompiles/assets-erc20/src/tests.rs b/precompiles/assets-erc20/src/tests.rs index 7152d4c41..a7c65f767 100644 --- a/precompiles/assets-erc20/src/tests.rs +++ b/precompiles/assets-erc20/src/tests.rs @@ -131,7 +131,7 @@ fn get_total_supply() { precompiles() .prepare_test(CryptoAlith, ForeignAssetId(0u128), ForeignPCall::total_supply {}) - .expect_cost(0) // TODO: Test db read/write costs + .expect_cost(0) .expect_no_logs() .execute_returns(U256::from(1000u64)); }); @@ -163,7 +163,7 @@ fn get_balances_known_user() { ForeignAssetId(0u128), ForeignPCall::balance_of { who: Address(CryptoAlith.into()) }, ) - .expect_cost(0) // TODO: Test db read/write costs + .expect_cost(0) .expect_no_logs() .execute_returns(U256::from(1000u64)); }); @@ -189,7 +189,7 @@ fn get_balances_unknown_user() { ForeignAssetId(0u128), ForeignPCall::balance_of { who: Address(Bob.into()) }, ) - .expect_cost(0) // TODO: Test db read/write costs + .expect_cost(0) .expect_no_logs() .execute_returns(U256::from(0u64)); }); @@ -321,7 +321,7 @@ fn check_allowance_existing() { spender: Address(Bob.into()), }, ) - .expect_cost(0) // TODO: Test db read/write costs + .expect_cost(0) .expect_no_logs() .execute_returns(U256::from(500u64)); }); @@ -350,7 +350,7 @@ fn check_allowance_not_existing() { spender: Address(Bob.into()), }, ) - .expect_cost(0) // TODO: Test db read/write costs + .expect_cost(0) .expect_no_logs() .execute_returns(U256::from(0u64)); }); @@ -398,7 +398,7 @@ fn transfer() { ForeignAssetId(0u128), ForeignPCall::balance_of { who: Address(Bob.into()) }, ) - .expect_cost(0) // TODO: Test db read/write costs + .expect_cost(0) .expect_no_logs() .execute_returns(U256::from(400)); @@ -408,7 +408,7 @@ fn transfer() { ForeignAssetId(0u128), ForeignPCall::balance_of { who: Address(CryptoAlith.into()) }, ) - .expect_cost(0) // TODO: Test db read/write costs + .expect_cost(0) .expect_no_logs() .execute_returns(U256::from(600)); }); @@ -475,7 +475,6 @@ fn transfer_from() { ) .execute_some(); - // TODO: Duplicate approve (noop)? precompiles() .prepare_test( CryptoAlith, @@ -510,7 +509,7 @@ fn transfer_from() { ForeignAssetId(0u128), ForeignPCall::balance_of { who: Address(CryptoAlith.into()) }, ) - .expect_cost(0) // TODO: Test db read/write costs + .expect_cost(0) .expect_no_logs() .execute_returns(U256::from(600)); @@ -520,7 +519,7 @@ fn transfer_from() { ForeignAssetId(0u128), ForeignPCall::balance_of { who: Address(Bob.into()) }, ) - .expect_cost(0) // TODO: Test db read/write costs + .expect_cost(0) .expect_no_logs() .execute_returns(U256::from(0)); @@ -530,7 +529,7 @@ fn transfer_from() { ForeignAssetId(0u128), ForeignPCall::balance_of { who: Address(Charlie.into()) }, ) - .expect_cost(0) // TODO: Test db read/write costs + .expect_cost(0) .expect_no_logs() .execute_returns(U256::from(400)); }); @@ -705,7 +704,7 @@ fn transfer_from_self() { ForeignAssetId(0u128), ForeignPCall::balance_of { who: Address(CryptoAlith.into()) }, ) - .expect_cost(0) // TODO: Test db read/write costs + .expect_cost(0) .expect_no_logs() .execute_returns(U256::from(600)); @@ -715,7 +714,7 @@ fn transfer_from_self() { ForeignAssetId(0u128), ForeignPCall::balance_of { who: Address(Bob.into()) }, ) - .expect_cost(0) // TODO: Test db read/write costs + .expect_cost(0) .expect_no_logs() .execute_returns(U256::from(400)); }); @@ -745,19 +744,19 @@ fn get_metadata() { precompiles() .prepare_test(CryptoAlith, ForeignAssetId(0u128), ForeignPCall::name {}) - .expect_cost(0) // TODO: Test db read/write costs + .expect_cost(0) .expect_no_logs() .execute_returns(UnboundedBytes::from("TestToken")); precompiles() .prepare_test(CryptoAlith, ForeignAssetId(0u128), ForeignPCall::symbol {}) - .expect_cost(0) // TODO: Test db read/write costs + .expect_cost(0) .expect_no_logs() .execute_returns(UnboundedBytes::from("Test")); precompiles() .prepare_test(CryptoAlith, ForeignAssetId(0u128), ForeignPCall::decimals {}) - .expect_cost(0) // TODO: Test db read/write costs + .expect_cost(0) .expect_no_logs() .execute_returns(12u8); }); @@ -802,7 +801,7 @@ fn transfer_amount_overflow() { ForeignAssetId(0u128), ForeignPCall::balance_of { who: Address(Bob.into()) }, ) - .expect_cost(0) // TODO: Test db read/write costs + .expect_cost(0) .expect_no_logs() .execute_returns(U256::from(0)); @@ -812,7 +811,7 @@ fn transfer_amount_overflow() { ForeignAssetId(0u128), ForeignPCall::balance_of { who: Address(CryptoAlith.into()) }, ) - .expect_cost(0) // TODO: Test db read/write costs + .expect_cost(0) .expect_no_logs() .execute_returns(U256::from(1000)); }); @@ -846,7 +845,6 @@ fn transfer_from_overflow() { ) .execute_some(); - // TODO: Duplicate approve of same value (noop?) precompiles() .prepare_test( CryptoAlith, @@ -894,7 +892,7 @@ fn permit_valid() { let owner: H160 = CryptoAlith.into(); let spender: H160 = Bob.into(); let value: U256 = 500u16.into(); - let deadline: U256 = 0u8.into(); // todo: proper timestamp + let deadline: U256 = 0u8.into(); let permit = Eip2612::::generate_permit( ForeignAssetId(0u128).into(), @@ -916,7 +914,7 @@ fn permit_valid() { ForeignAssetId(0u128), ForeignPCall::eip2612_nonces { owner: Address(CryptoAlith.into()) }, ) - .expect_cost(0) // TODO: Test db read/write costs + .expect_cost(0) .expect_no_logs() .execute_returns(U256::from(0u8)); @@ -953,7 +951,7 @@ fn permit_valid() { spender: Address(Bob.into()), }, ) - .expect_cost(0) // TODO: Test db read/write costs + .expect_cost(0) .expect_no_logs() .execute_returns(U256::from(500u16)); @@ -963,7 +961,7 @@ fn permit_valid() { ForeignAssetId(0u128), ForeignPCall::eip2612_nonces { owner: Address(CryptoAlith.into()) }, ) - .expect_cost(0) // TODO: Test db read/write costs + .expect_cost(0) .expect_no_logs() .execute_returns(U256::from(1u8)); }); @@ -999,7 +997,7 @@ fn permit_valid_named_asset() { let owner: H160 = CryptoAlith.into(); let spender: H160 = Bob.into(); let value: U256 = 500u16.into(); - let deadline: U256 = 0u8.into(); // todo: proper timestamp + let deadline: U256 = 0u8.into(); let permit = Eip2612::::generate_permit( ForeignAssetId(0u128).into(), @@ -1021,7 +1019,7 @@ fn permit_valid_named_asset() { ForeignAssetId(0u128), ForeignPCall::eip2612_nonces { owner: Address(CryptoAlith.into()) }, ) - .expect_cost(0) // TODO: Test db read/write costs + .expect_cost(0) .expect_no_logs() .execute_returns(U256::from(0u8)); @@ -1058,7 +1056,7 @@ fn permit_valid_named_asset() { spender: Address(Bob.into()), }, ) - .expect_cost(0) // TODO: Test db read/write costs + .expect_cost(0) .expect_no_logs() .execute_returns(U256::from(500u16)); @@ -1068,7 +1066,7 @@ fn permit_valid_named_asset() { ForeignAssetId(0u128), ForeignPCall::eip2612_nonces { owner: Address(CryptoAlith.into()) }, ) - .expect_cost(0) // TODO: Test db read/write costs + .expect_cost(0) .expect_no_logs() .execute_returns(U256::from(1u8)); }); @@ -1119,7 +1117,7 @@ fn permit_invalid_nonce() { ForeignAssetId(0u128), ForeignPCall::eip2612_nonces { owner: Address(CryptoAlith.into()) }, ) - .expect_cost(0) // TODO: Test db read/write costs + .expect_cost(0) .expect_no_logs() .execute_returns(U256::from(0u8)); @@ -1148,7 +1146,7 @@ fn permit_invalid_nonce() { spender: Address(Bob.into()), }, ) - .expect_cost(0) // TODO: Test db read/write costs + .expect_cost(0) .expect_no_logs() .execute_returns(U256::from(0u16)); @@ -1158,7 +1156,7 @@ fn permit_invalid_nonce() { ForeignAssetId(0u128), ForeignPCall::eip2612_nonces { owner: Address(CryptoAlith.into()) }, ) - .expect_cost(0) // TODO: Test db read/write costs + .expect_cost(0) .expect_no_logs() .execute_returns(U256::from(0u8)); }); @@ -1195,7 +1193,7 @@ fn permit_invalid_signature() { ForeignAssetId(0u128), ForeignPCall::eip2612_nonces { owner: Address(CryptoAlith.into()) }, ) - .expect_cost(0) // TODO: Test db read/write costs + .expect_cost(0) .expect_no_logs() .execute_returns(U256::from(0u8)); @@ -1224,7 +1222,7 @@ fn permit_invalid_signature() { spender: Address(Bob.into()), }, ) - .expect_cost(0) // TODO: Test db read/write costs + .expect_cost(0) .expect_no_logs() .execute_returns(U256::from(0u16)); @@ -1234,7 +1232,7 @@ fn permit_invalid_signature() { ForeignAssetId(0u128), ForeignPCall::eip2612_nonces { owner: Address(CryptoAlith.into()) }, ) - .expect_cost(0) // TODO: Test db read/write costs + .expect_cost(0) .expect_no_logs() .execute_returns(U256::from(0u8)); }); @@ -1287,7 +1285,7 @@ fn permit_invalid_deadline() { ForeignAssetId(0u128), ForeignPCall::eip2612_nonces { owner: Address(CryptoAlith.into()) }, ) - .expect_cost(0) // TODO: Test db read/write costs + .expect_cost(0) .expect_no_logs() .execute_returns(U256::from(0u8)); @@ -1316,7 +1314,7 @@ fn permit_invalid_deadline() { spender: Address(Bob.into()), }, ) - .expect_cost(0) // TODO: Test db read/write costs + .expect_cost(0) .expect_no_logs() .execute_returns(U256::from(0u16)); @@ -1326,7 +1324,7 @@ fn permit_invalid_deadline() { ForeignAssetId(0u128), ForeignPCall::eip2612_nonces { owner: Address(CryptoAlith.into()) }, ) - .expect_cost(0) // TODO: Test db read/write costs + .expect_cost(0) .expect_no_logs() .execute_returns(U256::from(0u8)); }); @@ -1356,7 +1354,7 @@ fn permit_valid_with_metamask_signed_data() { let owner: H160 = CryptoAlith.into(); let spender: H160 = Bob.into(); let value: U256 = 1000u16.into(); - let deadline: U256 = 1u16.into(); // todo: proper timestamp + let deadline: U256 = 1u16.into(); let rsv = hex!( "3aac886f06729d76067b6b0dbae23978fe48224b10b5648265b8f0e8c4cf25ff7625965d64bf9a6069d diff --git a/precompiles/balances-erc20/ERC20.sol b/precompiles/balances-erc20/ERC20.sol index d49ea5db0..7c4ec8b47 100644 --- a/precompiles/balances-erc20/ERC20.sol +++ b/precompiles/balances-erc20/ERC20.sol @@ -85,14 +85,14 @@ interface IERC20 { /// @custom:selector ddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef /// @param from address The address sending the tokens /// @param to address The address receiving the tokens. - /// @param value uint256 The amount of tokens transfered. + /// @param value uint256 The amount of tokens transferred. event Transfer(address indexed from, address indexed to, uint256 value); /// @dev Event emited when a native transfer has been performed. /// @custom:selector 252d1c824457d58ee034ca5279c879eea06e3cf5f3d0df73d9f6939f9d081c8c /// @param from address The address sending the tokens /// @param to bytes32 The accountId32 receiving the tokens. - /// @param value uint256 The amount of tokens transfered. + /// @param value uint256 The amount of tokens transferred. event TransferNative(address indexed from, bytes32 indexed to, uint256 value); /// @dev Event emited when an approval has been registered. diff --git a/precompiles/balances-erc20/src/tests.rs b/precompiles/balances-erc20/src/tests.rs index c245fe3e1..e02f66fa6 100644 --- a/precompiles/balances-erc20/src/tests.rs +++ b/precompiles/balances-erc20/src/tests.rs @@ -97,7 +97,7 @@ fn get_total_supply() { .execute_with(|| { precompiles() .prepare_test(CryptoAlith, Precompile1, PCall::total_supply {}) - .expect_cost(0) // TODO: Test db read/write costs + .expect_cost(0) .expect_no_logs() .execute_returns(U256::from(3500u64)); }); @@ -115,7 +115,7 @@ fn get_balances_known_user() { Precompile1, PCall::balance_of { owner: Address(CryptoAlith.into()) }, ) - .expect_cost(0) // TODO: Test db read/write costs + .expect_cost(0) .expect_no_logs() .execute_returns(U256::from(1000u64)); }); @@ -133,7 +133,7 @@ fn get_balances_unknown_user() { Precompile1, PCall::balance_of { owner: Address(Bob.into()) }, ) - .expect_cost(0) // TODO: Test db read/write costs + .expect_cost(0) .expect_no_logs() .execute_returns(U256::from(0u64)); }); @@ -223,7 +223,7 @@ fn check_allowance_existing() { spender: Address(Bob.into()), }, ) - .expect_cost(0) // TODO: Test db read/write costs + .expect_cost(0) .expect_no_logs() .execute_returns(U256::from(500u64)); }); @@ -244,7 +244,7 @@ fn check_allowance_not_existing() { spender: Address(Bob.into()), }, ) - .expect_cost(0) // TODO: Test db read/write costs + .expect_cost(0) .expect_no_logs() .execute_returns(U256::from(0u64)); }); @@ -278,7 +278,7 @@ fn transfer() { Precompile1, PCall::balance_of { owner: Address(CryptoAlith.into()) }, ) - .expect_cost(0) // TODO: Test db read/write costs + .expect_cost(0) .expect_no_logs() .execute_returns(U256::from(600)); @@ -288,7 +288,7 @@ fn transfer() { Precompile1, PCall::balance_of { owner: Address(Bob.into()) }, ) - .expect_cost(0) // TODO: Test db read/write costs + .expect_cost(0) .expect_no_logs() .execute_returns(U256::from(400)); }); @@ -353,7 +353,7 @@ fn transfer_from() { Precompile1, PCall::balance_of { owner: Address(CryptoAlith.into()) }, ) - .expect_cost(0) // TODO: Test db read/write costs + .expect_cost(0) .expect_no_logs() .execute_returns(U256::from(600)); @@ -363,7 +363,7 @@ fn transfer_from() { Precompile1, PCall::balance_of { owner: Address(Bob.into()) }, ) - .expect_cost(0) // TODO: Test db read/write costs + .expect_cost(0) .expect_no_logs() .execute_returns(U256::from(400)); @@ -376,7 +376,7 @@ fn transfer_from() { spender: Address(Bob.into()), }, ) - .expect_cost(0) // TODO: Test db read/write costs + .expect_cost(0) .expect_no_logs() .execute_returns(U256::from(100u64)); }); @@ -443,7 +443,7 @@ fn transfer_from_self() { Precompile1, PCall::balance_of { owner: Address(CryptoAlith.into()) }, ) - .expect_cost(0) // TODO: Test db read/write costs + .expect_cost(0) .expect_no_logs() .execute_returns(U256::from(600)); @@ -453,7 +453,7 @@ fn transfer_from_self() { Precompile1, PCall::balance_of { owner: Address(Bob.into()) }, ) - .expect_cost(0) // TODO: Test db read/write costs + .expect_cost(0) .expect_no_logs() .execute_returns(U256::from(400)); }); @@ -467,7 +467,7 @@ fn get_metadata_name() { .execute_with(|| { precompiles() .prepare_test(CryptoAlith, Precompile1, PCall::name {}) - .expect_cost(0) // TODO: Test db read/write costs + .expect_cost(0) .expect_no_logs() .execute_returns(UnboundedBytes::from("Mock token")); }); @@ -481,7 +481,7 @@ fn get_metadata_symbol() { .execute_with(|| { precompiles() .prepare_test(CryptoAlith, Precompile1, PCall::symbol {}) - .expect_cost(0) // TODO: Test db read/write costs + .expect_cost(0) .expect_no_logs() .execute_returns(UnboundedBytes::from("MOCK")); }); @@ -495,7 +495,7 @@ fn get_metadata_decimals() { .execute_with(|| { precompiles() .prepare_test(CryptoAlith, Precompile1, PCall::decimals {}) - .expect_cost(0) // TODO: Test db read/write costs + .expect_cost(0) .expect_no_logs() .execute_returns(18u8); }); @@ -513,7 +513,7 @@ fn deposit(data: Vec) { Precompile1, PCall::balance_of { owner: Address(Precompile1.into()) }, ) - .expect_cost(0) // TODO: Test db read/write costs + .expect_cost(0) .expect_no_logs() .execute_returns(U256::from(0)); @@ -584,7 +584,7 @@ fn deposit(data: Vec) { Precompile1, PCall::balance_of { owner: Address(Precompile1.into()) }, ) - .expect_cost(0) // TODO: Test db read/write costs + .expect_cost(0) .expect_no_logs() .execute_returns(U256::from(0)); @@ -595,7 +595,7 @@ fn deposit(data: Vec) { Precompile1, PCall::balance_of { owner: Address(CryptoAlith.into()) }, ) - .expect_cost(0) // TODO: Test db read/write costs + .expect_cost(0) .expect_no_logs() .execute_returns(U256::from(1000)); }); @@ -629,7 +629,7 @@ fn deposit_zero() { Precompile1, PCall::balance_of { owner: Address(Precompile1.into()) }, ) - .expect_cost(0) // TODO: Test db read/write costs + .expect_cost(0) .expect_no_logs() .execute_returns(U256::from(0)); @@ -664,7 +664,7 @@ fn deposit_zero() { Precompile1, PCall::balance_of { owner: Address(Precompile1.into()) }, ) - .expect_cost(0) // TODO: Test db read/write costs + .expect_cost(0) .expect_no_logs() .execute_returns(U256::from(0)); @@ -675,7 +675,7 @@ fn deposit_zero() { Precompile1, PCall::balance_of { owner: Address(CryptoAlith.into()) }, ) - .expect_cost(0) // TODO: Test db read/write costs + .expect_cost(0) .expect_no_logs() .execute_returns(U256::from(1000)); }); @@ -694,7 +694,7 @@ fn withdraw() { Precompile1, PCall::balance_of { owner: Address(Precompile1.into()) }, ) - .expect_cost(0) // TODO: Test db read/write costs + .expect_cost(0) .expect_no_logs() .execute_returns(U256::from(0)); @@ -717,7 +717,7 @@ fn withdraw() { Precompile1, PCall::balance_of { owner: Address(CryptoAlith.into()) }, ) - .expect_cost(0) // TODO: Test db read/write costs + .expect_cost(0) .expect_no_logs() .execute_returns(U256::from(1000)); }); @@ -736,7 +736,7 @@ fn withdraw_more_than_owned() { Precompile1, PCall::balance_of { owner: Address(Precompile1.into()) }, ) - .expect_cost(0) // TODO: Test db read/write costs + .expect_cost(0) .expect_no_logs() .execute_returns(U256::from(0)); @@ -752,7 +752,7 @@ fn withdraw_more_than_owned() { Precompile1, PCall::balance_of { owner: Address(CryptoAlith.into()) }, ) - .expect_cost(0) // TODO: Test db read/write costs + .expect_cost(0) .expect_no_logs() .execute_returns(U256::from(1000)); }); @@ -767,7 +767,7 @@ fn permit_valid() { let owner: H160 = CryptoAlith.into(); let spender: H160 = Bob.into(); let value: U256 = 500u16.into(); - let deadline: U256 = 0u8.into(); // todo: proper timestamp + let deadline: U256 = 0u8.into(); let permit = Eip2612::::generate_permit( Precompile1.into(), @@ -788,7 +788,7 @@ fn permit_valid() { Precompile1, PCall::eip2612_nonces { owner: Address(CryptoAlith.into()) }, ) - .expect_cost(0) // TODO: Test db read/write costs + .expect_cost(0) .expect_no_logs() .execute_returns(U256::from(0u8)); @@ -806,7 +806,7 @@ fn permit_valid() { s: rs.s.b32().into(), }, ) - .expect_cost(0) // TODO: Test db read/write costs + .expect_cost(0) .expect_log(log3( Precompile1, SELECTOR_LOG_APPROVAL, @@ -825,7 +825,7 @@ fn permit_valid() { spender: Address(Bob.into()), }, ) - .expect_cost(0) // TODO: Test db read/write costs + .expect_cost(0) .expect_no_logs() .execute_returns(U256::from(500u16)); @@ -835,7 +835,7 @@ fn permit_valid() { Precompile1, PCall::eip2612_nonces { owner: Address(CryptoAlith.into()) }, ) - .expect_cost(0) // TODO: Test db read/write costs + .expect_cost(0) .expect_no_logs() .execute_returns(U256::from(1u8)); }); @@ -871,7 +871,7 @@ fn permit_invalid_nonce() { Precompile1, PCall::eip2612_nonces { owner: Address(CryptoAlith.into()) }, ) - .expect_cost(0) // TODO: Test db read/write costs + .expect_cost(0) .expect_no_logs() .execute_returns(U256::from(0u8)); @@ -900,7 +900,7 @@ fn permit_invalid_nonce() { spender: Address(Bob.into()), }, ) - .expect_cost(0) // TODO: Test db read/write costs + .expect_cost(0) .expect_no_logs() .execute_returns(U256::from(0u16)); @@ -910,7 +910,7 @@ fn permit_invalid_nonce() { Precompile1, PCall::eip2612_nonces { owner: Address(CryptoAlith.into()) }, ) - .expect_cost(0) // TODO: Test db read/write costs + .expect_cost(0) .expect_no_logs() .execute_returns(U256::from(0u8)); }); @@ -933,7 +933,7 @@ fn permit_invalid_signature() { Precompile1, PCall::eip2612_nonces { owner: Address(CryptoAlith.into()) }, ) - .expect_cost(0) // TODO: Test db read/write costs + .expect_cost(0) .expect_no_logs() .execute_returns(U256::from(0u8)); @@ -962,7 +962,7 @@ fn permit_invalid_signature() { spender: Address(Bob.into()), }, ) - .expect_cost(0) // TODO: Test db read/write costs + .expect_cost(0) .expect_no_logs() .execute_returns(U256::from(0u16)); @@ -972,7 +972,7 @@ fn permit_invalid_signature() { Precompile1, PCall::eip2612_nonces { owner: Address(CryptoAlith.into()) }, ) - .expect_cost(0) // TODO: Test db read/write costs + .expect_cost(0) .expect_no_logs() .execute_returns(U256::from(0u8)); }); @@ -1010,7 +1010,7 @@ fn permit_invalid_deadline() { Precompile1, PCall::eip2612_nonces { owner: Address(CryptoAlith.into()) }, ) - .expect_cost(0) // TODO: Test db read/write costs + .expect_cost(0) .expect_no_logs() .execute_returns(U256::from(0u8)); @@ -1039,7 +1039,7 @@ fn permit_invalid_deadline() { spender: Address(Bob.into()), }, ) - .expect_cost(0) // TODO: Test db read/write costs + .expect_cost(0) .expect_no_logs() .execute_returns(U256::from(0u16)); @@ -1049,7 +1049,7 @@ fn permit_invalid_deadline() { Precompile1, PCall::eip2612_nonces { owner: Address(CryptoAlith.into()) }, ) - .expect_cost(0) // TODO: Test db read/write costs + .expect_cost(0) .expect_no_logs() .execute_returns(U256::from(0u8)); }); @@ -1184,7 +1184,7 @@ fn permit_valid_with_metamask_signed_data() { let owner: H160 = CryptoAlith.into(); let spender: H160 = Bob.into(); let value: U256 = 1000u16.into(); - let deadline: U256 = 1u16.into(); // todo: proper timestamp + let deadline: U256 = 1u16.into(); let rsv = hex_literal::hex!( "612960858951e133d05483804be5456a030be4ce6c000a855d865c0be75a8fc11d89ca96d5a153e8c @@ -1211,7 +1211,7 @@ fn permit_valid_with_metamask_signed_data() { s: s_real.into(), }, ) - .expect_cost(0) // TODO: Test db read/write costs + .expect_cost(0) .expect_log(log3( Precompile1, SELECTOR_LOG_APPROVAL, @@ -1263,7 +1263,7 @@ fn transfer_native() { Precompile1, PCall::balance_of { owner: Address(CryptoAlith.into()) }, ) - .expect_cost(0) // TODO: Test db read/write costs + .expect_cost(0) .expect_no_logs() .execute_returns(U256::from(600)); @@ -1273,7 +1273,7 @@ fn transfer_native() { Precompile1, PCall::balance_of { owner: account_id_h160.into() }, ) - .expect_cost(0) // TODO: Test db read/write costs + .expect_cost(0) .expect_no_logs() .execute_returns(U256::from(400)); }); diff --git a/precompiles/batch/src/lib.rs b/precompiles/batch/src/lib.rs index 4102b6834..881e061ba 100644 --- a/precompiles/batch/src/lib.rs +++ b/precompiles/batch/src/lib.rs @@ -58,7 +58,7 @@ pub fn log_subcall_failed(address: impl Into, index: usize) -> Log { #[derive(Debug, Clone)] pub struct BatchPrecompile(PhantomData); -// No funds are transfered to the precompile address. +// No funds are transferred to the precompile address. // Transfers will directly be made on the behalf of the user by the precompile. #[precompile_utils::precompile] impl BatchPrecompile diff --git a/precompiles/call-permit/CallPermit.sol b/precompiles/call-permit/CallPermit.sol index 2dece6886..7b4050a12 100644 --- a/precompiles/call-permit/CallPermit.sol +++ b/precompiles/call-permit/CallPermit.sol @@ -20,7 +20,7 @@ interface CallPermit { /// If successful the EIP712 nonce is increased to prevent this permit to be replayed. /// @param from Who made the permit and want its call to be dispatched on their behalf. /// @param to Which address the call is made to. - /// @param value Value being transfered from the "from" account. + /// @param value Value being transferred from the "from" account. /// @param data Call data /// @param gaslimit Gaslimit the dispatched call requires. /// Providing it prevents the dispatcher to manipulate the gaslimit. diff --git a/precompiles/call-permit/src/tests.rs b/precompiles/call-permit/src/tests.rs index 73b8e80e7..0c090c5e0 100644 --- a/precompiles/call-permit/src/tests.rs +++ b/precompiles/call-permit/src/tests.rs @@ -89,7 +89,7 @@ fn valid_permit_returns() { CallPermit, PCall::nonces { owner: Address(CryptoAlith.into()) }, ) - .expect_cost(0) // TODO: Test db read/write costs + .expect_cost(0) .expect_no_logs() .execute_returns(U256::from(0u8)); @@ -180,7 +180,7 @@ fn valid_permit_reverts() { CallPermit, PCall::nonces { owner: Address(CryptoAlith.into()) }, ) - .expect_cost(0) // TODO: Test db read/write costs + .expect_cost(0) .expect_no_logs() .execute_returns(U256::from(0u8)); @@ -270,7 +270,7 @@ fn invalid_permit_nonce() { CallPermit, PCall::nonces { owner: Address(CryptoAlith.into()) }, ) - .expect_cost(0) // TODO: Test db read/write costs + .expect_cost(0) .expect_no_logs() .execute_returns(U256::from(0u8)); @@ -334,7 +334,7 @@ fn invalid_permit_gas_limit_too_low() { CallPermit, PCall::nonces { owner: Address(CryptoAlith.into()) }, ) - .expect_cost(0) // TODO: Test db read/write costs + .expect_cost(0) .expect_no_logs() .execute_returns(U256::from(0u8)); @@ -400,7 +400,7 @@ fn invalid_permit_gas_limit_overflow() { CallPermit, PCall::nonces { owner: Address(CryptoAlith.into()) }, ) - .expect_cost(0) // TODO: Test db read/write costs + .expect_cost(0) .expect_no_logs() .execute_returns(U256::from(0u8)); @@ -586,7 +586,7 @@ fn valid_permit_returns_with_metamask_signed_data() { CallPermit, PCall::nonces { owner: Address(CryptoAlith.into()) }, ) - .expect_cost(0) // TODO: Test db read/write costs + .expect_cost(0) .expect_no_logs() .execute_returns(U256::from(0u8)); diff --git a/precompiles/pallet-democracy/DemocracyInterface.sol b/precompiles/pallet-democracy/DemocracyInterface.sol index bb0b596b1..c112f0d8a 100644 --- a/precompiles/pallet-democracy/DemocracyInterface.sol +++ b/precompiles/pallet-democracy/DemocracyInterface.sol @@ -28,7 +28,6 @@ interface Democracy { /// Get details about all public porposals. /// @custom:selector /// @return (prop index, proposal hash, proposer) - /// TODO This is supposed to be a vec. Let's save this one for later. // function publicProps() // external // view diff --git a/precompiles/pallet-democracy/src/mock.rs b/precompiles/pallet-democracy/src/mock.rs index 8ac848350..d01260a03 100644 --- a/precompiles/pallet-democracy/src/mock.rs +++ b/precompiles/pallet-democracy/src/mock.rs @@ -209,7 +209,7 @@ impl pallet_scheduler::Config for Runtime { type ScheduleOrigin = EnsureRoot; type MaxScheduledPerBlock = (); type WeightInfo = (); - type OriginPrivilegeCmp = EqualPrivilegeOnly; // TODO : Simplest type, maybe there is better ? + type OriginPrivilegeCmp = EqualPrivilegeOnly; type Preimages = (); } diff --git a/precompiles/pallet-democracy/src/tests.rs b/precompiles/pallet-democracy/src/tests.rs index 697eae1b4..568dd0d40 100644 --- a/precompiles/pallet-democracy/src/tests.rs +++ b/precompiles/pallet-democracy/src/tests.rs @@ -92,8 +92,6 @@ fn selectors() { assert!(PCall::standard_vote_selectors().contains(&0x6cd18b0d)); assert!(PCall::un_delegate_selectors().contains(&0x1eef225c)); assert!(PCall::unlock_selectors().contains(&0x2f6c493c)); - - // TODO also test logs once we have them } #[test] @@ -122,7 +120,7 @@ fn prop_count_zero() { // Assert that no props have been opened. precompiles() .prepare_test(Alice, Precompile1, PCall::public_prop_count {}) - .expect_cost(0) // TODO: Test db read/write costs + .expect_cost(0) .expect_no_logs() .execute_returns(U256::zero()) }); @@ -145,7 +143,7 @@ fn prop_count_non_zero() { precompiles() .prepare_test(Alice, Precompile1, PCall::public_prop_count {}) - .expect_cost(0) // TODO: Test db read/write costs + .expect_cost(0) .expect_no_logs() .execute_returns(1u32); }); @@ -170,7 +168,7 @@ fn deposit_of_non_zero() { precompiles() .prepare_test(Alice, Precompile1, PCall::deposit_of { prop_index: 0.into() }) - .expect_cost(0) // TODO: Test db read/write costs + .expect_cost(0) .expect_no_logs() .execute_returns(1000u32); }); @@ -190,7 +188,7 @@ fn lowest_unbaked_zero() { ExtBuilder::default().build().execute_with(|| { precompiles() .prepare_test(Alice, Precompile1, PCall::lowest_unbaked {}) - .expect_cost(0) // TODO: Test db read/write costs + .expect_cost(0) .expect_no_logs() .execute_returns(0u32); }); @@ -251,7 +249,7 @@ fn lowest_unbaked_non_zero() { precompiles() .prepare_test(Alice, Precompile1, PCall::lowest_unbaked {}) - .expect_cost(0) // TODO: Test db read/write costs + .expect_cost(0) .expect_no_logs() .execute_returns(1u32); }); diff --git a/precompiles/precompile-registry/src/lib.rs b/precompiles/precompile-registry/src/lib.rs index ab994e0fc..7c1dfeb7e 100644 --- a/precompiles/precompile-registry/src/lib.rs +++ b/precompiles/precompile-registry/src/lib.rs @@ -45,8 +45,7 @@ where #[precompile::view] fn is_precompile(handle: &mut impl PrecompileHandle, address: Address) -> EvmResult { // We consider the precompile set is optimized to do at most one storage read. - // In the case of , the storage item that can be read is pallet_asset::Asset - // (TODO make it more generic, maybe add a const generic on PrecompileRegistry type) + // In the case of tangle, the storage item that can be read is pallet_asset::Asset // Storage item: Asset: // Blake2_128(16) + AssetId(16) + AssetDetails((4 * AccountId(20)) + (3 * Balance(16)) + 15) handle.record_db_read::(175)?; @@ -60,8 +59,7 @@ where address: Address, ) -> EvmResult { // We consider the precompile set is optimized to do at most one storage read. - // In the case of , the storage item that can be read is pallet_asset::Asset - // (TODO make it more generic, maybe add a const generic on PrecompileRegistry type) + // In the case of tangle, the storage item that can be read is pallet_asset::Asset // Storage item: Asset: // Blake2_128(16) + AssetId(16) + AssetDetails((4 * AccountId(20)) + (3 * Balance(16)) + 15) handle.record_db_read::(175)?; @@ -80,8 +78,7 @@ where // Prevent touching addresses that are not precompiles. // // We consider the precompile set is optimized to do at most one storage read. - // In the case of , the storage item that can be read is pallet_asset::Asset - // (TODO make it more generic, maybe add a const generic on PrecompileRegistry type) + // In the case of tangle, the storage item that can be read is pallet_asset::Asset // Storage item: Asset: // Blake2_128(16) + AssetId(16) + AssetDetails((4 * AccountId(20)) + (3 * Balance(16)) + 15) handle.record_db_read::(175)?; diff --git a/precompiles/staking/src/lib.rs b/precompiles/staking/src/lib.rs index cd2416859..b02ad828e 100644 --- a/precompiles/staking/src/lib.rs +++ b/precompiles/staking/src/lib.rs @@ -219,6 +219,7 @@ where } #[precompile::public("eras_total_reward_points(uint32)")] + #[precompile::public("erasTotalRewardPoints(uint32)")] #[precompile::view] fn eras_total_reward_points( handle: &mut impl PrecompileHandle, @@ -513,8 +514,8 @@ where let reward_destination = match payee { 0 => pallet_staking::RewardDestination::Staked, 1 => pallet_staking::RewardDestination::Stash, - 3 => pallet_staking::RewardDestination::Account(controller.clone()), - 4 => pallet_staking::RewardDestination::None, + 2 => pallet_staking::RewardDestination::Account(controller.clone()), + 3 => pallet_staking::RewardDestination::None, _ => return Err(revert("Invalid reward destination")), }; diff --git a/precompiles/tangle-lst/Cargo.toml b/precompiles/tangle-lst/Cargo.toml index 83b7d7b6d..c7855d528 100644 --- a/precompiles/tangle-lst/Cargo.toml +++ b/precompiles/tangle-lst/Cargo.toml @@ -3,7 +3,7 @@ name = "pallet-evm-precompile-tangle-lst" version = "0.1.0" authors = { workspace = true } edition = "2021" -description = "A Precompile to make pallet-multi-asset-delegation calls encoding accessible to pallet-evm" +description = "A Precompile to make pallet-tangle-lst calls encoding accessible to pallet-evm" [dependencies] diff --git a/precompiles/tangle-lst/TangleLst.sol b/precompiles/tangle-lst/TangleLst.sol index 68ca5c5dc..db2f47c4a 100644 --- a/precompiles/tangle-lst/TangleLst.sol +++ b/precompiles/tangle-lst/TangleLst.sol @@ -17,7 +17,7 @@ interface TangleLst { uint256 poolId, uint8 extraType, uint256 extra - ) external returns (uint8); + ) external; /// @dev Unbond from a pool. /// @param memberAccount The account of the member. @@ -27,7 +27,7 @@ interface TangleLst { bytes32 memberAccount, uint256 poolId, uint256 unbondingPoints - ) external returns (uint8); + ) external; /// @dev Withdraw unbonded funds from a pool. /// @param poolId The ID of the pool. @@ -35,7 +35,7 @@ interface TangleLst { function poolWithdrawUnbonded( uint256 poolId, uint32 numSlashingSpans - ) external returns (uint8); + ) external; /// @dev Withdraw unbonded funds for a member. /// @param memberAccount The account of the member. @@ -45,7 +45,7 @@ interface TangleLst { bytes32 memberAccount, uint256 poolId, uint32 numSlashingSpans - ) external returns (uint8); + ) external; /// @dev Create a new pool. /// @param amount The initial amount to create the pool with. @@ -61,7 +61,7 @@ interface TangleLst { bytes32 bouncer, bytes calldata name, bytes calldata icon - ) external returns (uint8); + ) external; /// @dev Nominate validators for a pool. /// @param poolId The ID of the pool. @@ -69,12 +69,12 @@ interface TangleLst { function nominate( uint256 poolId, bytes32[] calldata validators - ) external returns (uint8); + ) external; /// @dev Set the state of a pool. /// @param poolId The ID of the pool. /// @param state The new state (0 for Open, 1 for Blocked, 2 for Destroying). - function setState(uint256 poolId, uint8 state) external returns (uint8); + function setState(uint256 poolId, uint8 state) external; /// @dev Set metadata for a pool. /// @param poolId The ID of the pool. @@ -82,7 +82,7 @@ interface TangleLst { function setMetadata( uint256 poolId, bytes calldata metadata - ) external returns (uint8); + ) external; /// @dev Set global configurations (only callable by root). /// @param minJoinBond The minimum bond required to join a pool (0 for no change). @@ -94,7 +94,7 @@ interface TangleLst { uint256 minCreateBond, uint32 maxPools, uint32 globalMaxCommission - ) external returns (uint8); + ) external; /// @dev Update roles for a pool. /// @param poolId The ID of the pool. @@ -106,7 +106,7 @@ interface TangleLst { bytes32 root, bytes32 nominator, bytes32 bouncer - ) external returns (uint8); + ) external; /// @dev Stop nominating for a pool /// @param poolId The ID of the pool to chill @@ -121,8 +121,7 @@ interface TangleLst { /// @dev Set commission for a pool /// @param poolId The ID of the pool /// @param newCommission The new commission value - /// @param payee The account to receive commission payments - function setCommission(uint256 poolId, uint256 newCommission, bytes32 payee) external; + function setCommission(uint256 poolId, uint256 newCommission) external; /// @dev Set maximum commission for a pool /// @param poolId The ID of the pool diff --git a/precompiles/tangle-lst/src/lib.rs b/precompiles/tangle-lst/src/lib.rs index df36cbd8b..9a848f03b 100644 --- a/precompiles/tangle-lst/src/lib.rs +++ b/precompiles/tangle-lst/src/lib.rs @@ -1,7 +1,7 @@ // This file is part of Tangle. // Copyright (C) 2022-2024 Tangle Foundation. // -// This file is part of pallet-evm-precompile-multi-asset-delegation package. +// This file is part of pallet-evm-precompile-tangle-lst package. // Licensed under the Apache License, Version 2.0 (the "License"); // you may not use this file except in compliance with the License. // You may obtain a copy of the License at @@ -14,21 +14,21 @@ // See the License for the specific language governing permissions and // limitations under the License. -//! This file contains the implementation of the MultiAssetDelegationPrecompile struct which -//! provides an interface between the EVM and the native MultiAssetDelegation pallet of the runtime. -//! It allows EVM contracts to call functions of the MultiAssetDelegation pallet, in order to enable -//! EVM accounts to interact with the delegation system. +//! This file contains the implementation of the TangleLstPrecompile struct which +//! provides an interface between the EVM and the native TangleLst pallet of the runtime. +//! It allows EVM contracts to call functions of the TangleLst pallet, in order to enable +//! EVM accounts to interact with the liquid staking system. //! -//! The MultiAssetDelegationPrecompile struct implements core methods that correspond to the -//! functions of the MultiAssetDelegation pallet. These methods can be called from EVM contracts. +//! The TangleLstPrecompile struct implements core methods that correspond to the +//! functions of the TangleLst pallet. These methods can be called from EVM contracts. //! They include functions to join as an operator, delegate assets, withdraw assets, etc. //! //! Each method records the gas cost for the operation, performs the requested operation, and //! returns the result in a format that can be used by the EVM. //! -//! The MultiAssetDelegationPrecompile struct is generic over the Runtime type, which is the type of -//! the runtime that includes the MultiAssetDelegation pallet. This allows the precompile to work -//! with any runtime that includes the MultiAssetDelegation pallet and meets the other trait bounds +//! The TangleLstPrecompile struct is generic over the Runtime type, which is the type of +//! the runtime that includes the TangleLst pallet. This allows the precompile to work +//! with any runtime that includes the TangleLst pallet and meets the other trait bounds //! required by the precompile. #![cfg_attr(not(feature = "std"), no_std)] diff --git a/precompiles/vesting/Vesting.sol b/precompiles/vesting/Vesting.sol index 83b2503db..7411a935c 100644 --- a/precompiles/vesting/Vesting.sol +++ b/precompiles/vesting/Vesting.sol @@ -13,19 +13,19 @@ Vesting constant VESTING_CONTRACT = Vesting(VESTING_ADDRESS); /// @custom:address 0x0000000000000000000000000000000000000801 interface Vesting { /// @dev Unlock any vested funds of the sender account. - function vest() external returns (uint8); + function vest() external; /// @dev Unlock any vested funds of a `target` account. /// @param target The address of the account to unlock vested funds for. - function vestOther(bytes32 target) external returns (uint8); + function vestOther(bytes32 target) external; /// @dev Create a vested transfer. /// @param target The address of the account to transfer funds to. /// @param index The index of the vesting schedule to transfer. - function vestedTransfer(bytes32 target, uint8 index) external returns (uint8); + function vestedTransfer(bytes32 target, uint8 index) external; /// @dev Merge two vesting schedules together. /// @param schedule1Index The index of the first vesting schedule. /// @param schedule2Index The index of the second vesting schedule. - function mergeSchedules(uint32 schedule1Index, uint32 schedule2Index) external returns (uint8); + function mergeSchedules(uint32 schedule1Index, uint32 schedule2Index) external; } diff --git a/precompiles/vesting/src/lib.rs b/precompiles/vesting/src/lib.rs index c1e68e940..b19356c4a 100644 --- a/precompiles/vesting/src/lib.rs +++ b/precompiles/vesting/src/lib.rs @@ -1,8 +1,8 @@ // This file is part of Tangle. // Copyright (C) 2022-2024 Tangle Foundation. // -// This file is part of pallet-evm-precompile-staking package, originally developed by Purestake -// Inc. Pallet-evm-precompile-staking package used in Tangle Network in terms of GPLv3. +// This file is part of pallet-evm-precompile-vesting package, originally developed by Purestake +// Inc. Pallet-evm-precompile-vesting package used in Tangle Network in terms of GPLv3. // Licensed under the Apache License, Version 2.0 (the "License"); // you may not use this file except in compliance with the License. @@ -29,8 +29,8 @@ //! returns the result in a format that can be used by the EVM. //! //! The VestingPrecompile struct is generic over the Runtime type, which is the type of the runtime -//! that includes the staking pallet. This allows the precompile to work with any runtime that -//! includes the staking pallet and meets the other trait bounds required by the precompile. +//! that includes the vesting pallet. This allows the precompile to work with any runtime that +//! includes the vesting pallet and meets the other trait bounds required by the precompile. #![cfg_attr(not(feature = "std"), no_std)] @@ -179,6 +179,7 @@ where schedule1_index: u32, schedule2_index: u32, ) -> EvmResult { + handle.record_cost(RuntimeHelper::::db_read_gas_cost())?; let caller = handle.context().caller; let caller_account = Runtime::AddressMapping::into_account_id(caller);