Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .github/workflows/benchmark.yml
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,7 @@ jobs:
uses: actions-rs/toolchain@v1
with:
profile: minimal
toolchain: nightly-2022-08-05
toolchain: nightly-2022-10-30
components: rustfmt
target: wasm32-unknown-unknown
default: true
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/coverage.yml
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ jobs:
- name: Install toolchain
uses: dtolnay/rust-toolchain@nightly
with:
toolchain: nightly-2022-08-05
toolchain: nightly-2022-10-30
components: rustfmt
target: wasm32-unknown-unknown
- name: Setup cmake
Expand Down
8 changes: 4 additions & 4 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ jobs:
- name: Install toolchain
uses: dtolnay/rust-toolchain@nightly
with:
toolchain: nightly-2022-08-05
toolchain: nightly-2022-10-30
components: rustfmt
target: wasm32-unknown-unknown
- name: Setup cmake
Expand Down Expand Up @@ -69,7 +69,7 @@ jobs:
- name: Install toolchain
uses: dtolnay/rust-toolchain@nightly
with:
toolchain: nightly-2022-08-05
toolchain: nightly-2022-10-30
components: rustfmt
target: wasm32-unknown-unknown
- name: Setup cmake
Expand All @@ -89,7 +89,7 @@ jobs:
- name: Install toolchain
uses: dtolnay/rust-toolchain@nightly
with:
toolchain: nightly-2022-08-05
toolchain: nightly-2022-10-30
components: rustfmt
target: wasm32-unknown-unknown
- name: Setup cmake
Expand Down Expand Up @@ -117,7 +117,7 @@ jobs:
- name: Install toolchain
uses: dtolnay/rust-toolchain@nightly
with:
toolchain: nightly-2022-08-05
toolchain: nightly-2022-10-30
components: rustfmt
target: wasm32-unknown-unknown
- name: Setup cmake
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/test.yml.src
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ jobs:
name: Install toolchain
uses: dtolnay/rust-toolchain@nightly
with:
toolchain: nightly-2022-08-05
toolchain: nightly-2022-10-30
components: rustfmt
target: wasm32-unknown-unknown
- name: Check format
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/update-tokens.yml
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ jobs:
- name: Install toolchain
uses: dtolnay/rust-toolchain@nightly
with:
toolchain: nightly-2022-08-05
toolchain: nightly-2022-10-30
components: rustfmt
target: wasm32-unknown-unknown
- name: update tokens
Expand Down
6 changes: 3 additions & 3 deletions ecosystem-modules/ren/renvm-bridge/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -233,7 +233,7 @@ pub mod module {
sig,
} => {
// check if already exists
if Signatures::<T>::contains_key(&sig) {
if Signatures::<T>::contains_key(sig) {
return InvalidTransaction::Stale.into();
}

Expand All @@ -255,7 +255,7 @@ pub mod module {
}
Call::rotate_key { new_key, sig } => {
// check if already exists
if Signatures::<T>::contains_key(&sig) {
if Signatures::<T>::contains_key(sig) {
return InvalidTransaction::Stale.into();
}

Expand Down Expand Up @@ -287,7 +287,7 @@ impl<T: Config> Pallet<T> {

fn do_rotate_key(new_key: PublicKey, sig: EcdsaSignature) {
RenVmPublicKey::<T>::set(Some(new_key));
Signatures::<T>::insert(&sig, ());
Signatures::<T>::insert(sig, ());
}

// ABI-encode the values for creating the signature hash.
Expand Down
10 changes: 5 additions & 5 deletions modules/cdp-engine/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -899,7 +899,7 @@ impl<T: Config> Pallet<T> {
debit_adjustment: Amount,
) -> DispatchResult {
ensure!(
CollateralParams::<T>::contains_key(&currency_id),
CollateralParams::<T>::contains_key(currency_id),
Error::<T>::InvalidCollateralType,
);
<LoansOf<T>>::adjust_position(who, currency_id, collateral_adjustment, debit_adjustment)?;
Expand Down Expand Up @@ -978,7 +978,7 @@ impl<T: Config> Pallet<T> {
min_increase_collateral: Balance,
) -> DispatchResult {
ensure!(
CollateralParams::<T>::contains_key(&currency_id),
CollateralParams::<T>::contains_key(currency_id),
Error::<T>::InvalidCollateralType,
);
let loans_module_account = <LoansOf<T>>::account_id();
Expand Down Expand Up @@ -1037,7 +1037,7 @@ impl<T: Config> Pallet<T> {
let debit_adjustment = <LoansOf<T>>::amount_try_from_balance(increase_debit_balance)?;
<LoansOf<T>>::update_loan(who, currency_id, collateral_adjustment, debit_adjustment)?;

let Position { collateral, debit } = <LoansOf<T>>::positions(currency_id, &who);
let Position { collateral, debit } = <LoansOf<T>>::positions(currency_id, who);
// check the CDP if is still at valid risk
Self::check_position_valid(currency_id, collateral, debit, false)?;
// debit cap check due to new issued stable coin
Expand All @@ -1059,13 +1059,13 @@ impl<T: Config> Pallet<T> {
min_decrease_debit_value: Balance,
) -> DispatchResult {
ensure!(
CollateralParams::<T>::contains_key(&currency_id),
CollateralParams::<T>::contains_key(currency_id),
Error::<T>::InvalidCollateralType,
);

let loans_module_account = <LoansOf<T>>::account_id();
let stable_currency_id = T::GetStableCurrencyId::get();
let Position { collateral, debit } = <LoansOf<T>>::positions(currency_id, &who);
let Position { collateral, debit } = <LoansOf<T>>::positions(currency_id, who);

// ensure collateral of CDP is enough
ensure!(decrease_collateral <= collateral, Error::<T>::CollateralNotEnough);
Expand Down
10 changes: 5 additions & 5 deletions modules/collator-selection/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -251,8 +251,8 @@ pub mod pallet {
"genesis desired_candidates are more than T::MaxCandidates",
);

<DesiredCandidates<T>>::put(&self.desired_candidates);
<CandidacyBond<T>>::put(&self.candidacy_bond);
<DesiredCandidates<T>>::put(self.desired_candidates);
<CandidacyBond<T>>::put(self.candidacy_bond);
<Invulnerables<T>>::put(&bounded_invulnerables);
}
}
Expand Down Expand Up @@ -315,7 +315,7 @@ pub mod pallet {
if max > T::MaxCandidates::get() {
Err(Error::<T>::MaxCandidatesExceeded)?;
}
<DesiredCandidates<T>>::put(&max);
<DesiredCandidates<T>>::put(max);
Self::deposit_event(Event::NewDesiredCandidates {
new_desired_candidates: max,
});
Expand All @@ -326,7 +326,7 @@ pub mod pallet {
#[pallet::weight(T::WeightInfo::set_candidacy_bond())]
pub fn set_candidacy_bond(origin: OriginFor<T>, #[pallet::compact] bond: BalanceOf<T>) -> DispatchResult {
T::UpdateOrigin::ensure_origin(origin)?;
<CandidacyBond<T>>::put(&bond);
<CandidacyBond<T>>::put(bond);
Self::deposit_event(Event::NewCandidacyBond {
new_candidacy_bond: bond,
});
Expand Down Expand Up @@ -515,7 +515,7 @@ pub mod pallet {
candidates.iter().for_each(|candidate| {
if validators.contains(candidate) {
collators.push(candidate);
<SessionPoints<T>>::insert(&candidate, 0);
<SessionPoints<T>>::insert(candidate, 0);
}
});

Expand Down
16 changes: 8 additions & 8 deletions modules/dex-oracle/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -119,7 +119,7 @@ pub mod module {
let (pool_0, pool_1) = T::DEX::get_liquidity_pool(trading_pair.first(), trading_pair.second());
Self::try_update_cumulative(&trading_pair, pool_0, pool_1);

let (cumulative_0, cumulative_1, _) = Self::cumulatives(&trading_pair);
let (cumulative_0, cumulative_1, _) = Self::cumulatives(trading_pair);
let u256_elapsed_time: U256 = elapsed_time.saturated_into::<u128>().into();
let average_price_0 = ExchangeRate::from_inner(
cumulative_0
Expand All @@ -137,7 +137,7 @@ pub mod module {
);

AveragePrices::<T>::insert(
&trading_pair,
trading_pair,
(
average_price_0,
average_price_1,
Expand Down Expand Up @@ -179,7 +179,7 @@ pub mod module {
let trading_pair =
TradingPair::from_currency_ids(currency_id_a, currency_id_b).ok_or(Error::<T>::InvalidCurrencyId)?;
ensure!(
Self::average_prices(&trading_pair).is_none(),
Self::average_prices(trading_pair).is_none(),
Error::<T>::AveragePriceAlreadyEnabled
);
ensure!(!interval.is_zero(), Error::<T>::IntervalIsZero,);
Expand All @@ -191,7 +191,7 @@ pub mod module {
let initial_cumulative_1 = U256::zero();

AveragePrices::<T>::insert(
&trading_pair,
trading_pair,
(
initial_price_0,
initial_price_1,
Expand All @@ -201,7 +201,7 @@ pub mod module {
interval,
),
);
Cumulatives::<T>::insert(&trading_pair, (initial_cumulative_0, initial_cumulative_1, now));
Cumulatives::<T>::insert(trading_pair, (initial_cumulative_0, initial_cumulative_1, now));

Ok(())
}
Expand All @@ -224,8 +224,8 @@ pub mod module {

let trading_pair =
TradingPair::from_currency_ids(currency_id_a, currency_id_b).ok_or(Error::<T>::InvalidCurrencyId)?;
AveragePrices::<T>::take(&trading_pair).ok_or(Error::<T>::AveragePriceMustBeEnabled)?;
Cumulatives::<T>::remove(&trading_pair);
AveragePrices::<T>::take(trading_pair).ok_or(Error::<T>::AveragePriceMustBeEnabled)?;
Cumulatives::<T>::remove(trading_pair);

Ok(())
}
Expand All @@ -250,7 +250,7 @@ pub mod module {
let trading_pair =
TradingPair::from_currency_ids(currency_id_a, currency_id_b).ok_or(Error::<T>::InvalidCurrencyId)?;

AveragePrices::<T>::try_mutate_exists(&trading_pair, |maybe| -> DispatchResult {
AveragePrices::<T>::try_mutate_exists(trading_pair, |maybe| -> DispatchResult {
let (_, _, _, _, _, update_interval) = maybe.as_mut().ok_or(Error::<T>::AveragePriceMustBeEnabled)?;
ensure!(!new_interval.is_zero(), Error::<T>::IntervalIsZero);
*update_interval = new_interval;
Expand Down
2 changes: 1 addition & 1 deletion modules/dex/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -951,7 +951,7 @@ impl<T: Config> Pallet<T> {
Error::<T>::InvalidContributionIncrement
);

ProvisioningPool::<T>::try_mutate_exists(trading_pair, &who, |maybe_pool| -> DispatchResult {
ProvisioningPool::<T>::try_mutate_exists(trading_pair, who, |maybe_pool| -> DispatchResult {
let existed = maybe_pool.is_some();
let mut pool = maybe_pool.unwrap_or_default();
pool.0 = pool.0.checked_add(contribution_0).ok_or(ArithmeticError::Overflow)?;
Expand Down
4 changes: 2 additions & 2 deletions modules/evm-accounts/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -315,8 +315,8 @@ where
let addr = account_to_default_evm_address(account_id);

// create reverse mapping
Accounts::<T>::insert(&addr, &account_id);
EvmAddresses::<T>::insert(&account_id, &addr);
Accounts::<T>::insert(addr, account_id);
EvmAddresses::<T>::insert(account_id, addr);

Pallet::<T>::deposit_event(Event::ClaimAccount {
account_id: account_id.clone(),
Expand Down
26 changes: 13 additions & 13 deletions modules/evm/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1308,11 +1308,11 @@ impl<T: Config> Pallet<T> {
let account_info = account_info.as_mut().ok_or(Error::<T>::ContractNotFound)?;
let contract_info = account_info.contract_info.take().ok_or(Error::<T>::ContractNotFound)?;

CodeInfos::<T>::mutate_exists(&contract_info.code_hash, |maybe_code_info| {
CodeInfos::<T>::mutate_exists(contract_info.code_hash, |maybe_code_info| {
if let Some(code_info) = maybe_code_info.as_mut() {
code_info.ref_count = code_info.ref_count.saturating_sub(1);
if code_info.ref_count == 0 {
Codes::<T>::remove(&contract_info.code_hash);
Codes::<T>::remove(contract_info.code_hash);
*maybe_code_info = None;
}
} else {
Expand Down Expand Up @@ -1344,14 +1344,14 @@ impl<T: Config> Pallet<T> {
/// Only used in `remove_account_if_empty`
fn remove_account(address: &EvmAddress) -> DispatchResult {
// Deref code, and remove it if ref count is zero.
Accounts::<T>::mutate_exists(&address, |maybe_account| {
Accounts::<T>::mutate_exists(address, |maybe_account| {
if let Some(account) = maybe_account {
if let Some(ContractInfo { code_hash, .. }) = account.contract_info {
CodeInfos::<T>::mutate_exists(&code_hash, |maybe_code_info| {
CodeInfos::<T>::mutate_exists(code_hash, |maybe_code_info| {
if let Some(code_info) = maybe_code_info {
code_info.ref_count = code_info.ref_count.saturating_sub(1);
if code_info.ref_count == 0 {
Codes::<T>::remove(&code_hash);
Codes::<T>::remove(code_hash);
*maybe_code_info = None;
}
}
Expand Down Expand Up @@ -1403,7 +1403,7 @@ impl<T: Config> Pallet<T> {
published: publish,
};

CodeInfos::<T>::mutate_exists(&code_hash, |maybe_code_info| {
CodeInfos::<T>::mutate_exists(code_hash, |maybe_code_info| {
if let Some(code_info) = maybe_code_info.as_mut() {
code_info.ref_count = code_info.ref_count.saturating_add(1);
} else {
Expand All @@ -1413,7 +1413,7 @@ impl<T: Config> Pallet<T> {
};
*maybe_code_info = Some(new);

Codes::<T>::insert(&code_hash, bounded_code);
Codes::<T>::insert(code_hash, bounded_code);
}
});

Expand Down Expand Up @@ -1474,7 +1474,7 @@ impl<T: Config> Pallet<T> {

/// Get code at given address.
pub fn code_at_address(address: &EvmAddress) -> BoundedVec<u8, MaxCodeSize> {
Self::codes(&Self::code_hash_at_address(address))
Self::codes(Self::code_hash_at_address(address))
}

pub fn is_contract(address: &EvmAddress) -> bool {
Expand Down Expand Up @@ -1598,7 +1598,7 @@ impl<T: Config> Pallet<T> {
T::NetworkContractSource::get()
};

let old_code_info = Self::code_infos(&contract_info.code_hash).ok_or(Error::<T>::ContractNotFound)?;
let old_code_info = Self::code_infos(contract_info.code_hash).ok_or(Error::<T>::ContractNotFound)?;

let bounded_code: BoundedVec<u8, MaxCodeSize> =
code.try_into().map_err(|_| Error::<T>::ContractExceedsMaxCodeSize)?;
Expand All @@ -1621,17 +1621,17 @@ impl<T: Config> Pallet<T> {
Self::update_contract_storage_size(&contract, storage_size_changed);

// try remove old codes
CodeInfos::<T>::mutate_exists(&contract_info.code_hash, |maybe_code_info| -> DispatchResult {
CodeInfos::<T>::mutate_exists(contract_info.code_hash, |maybe_code_info| -> DispatchResult {
let code_info = maybe_code_info.as_mut().ok_or(Error::<T>::ContractNotFound)?;
code_info.ref_count = code_info.ref_count.saturating_sub(1);
if code_info.ref_count == 0 {
Codes::<T>::remove(&contract_info.code_hash);
Codes::<T>::remove(contract_info.code_hash);
*maybe_code_info = None;
}
Ok(())
})?;

CodeInfos::<T>::mutate_exists(&code_hash, |maybe_code_info| {
CodeInfos::<T>::mutate_exists(code_hash, |maybe_code_info| {
if let Some(code_info) = maybe_code_info.as_mut() {
code_info.ref_count = code_info.ref_count.saturating_add(1);
} else {
Expand All @@ -1641,7 +1641,7 @@ impl<T: Config> Pallet<T> {
};
*maybe_code_info = Some(new);

Codes::<T>::insert(&code_hash, bounded_code);
Codes::<T>::insert(code_hash, bounded_code);
}
});
// update code_hash
Expand Down
4 changes: 2 additions & 2 deletions modules/evm/src/runner/stack.rs
Original file line number Diff line number Diff line change
Expand Up @@ -674,7 +674,7 @@ impl<'vicinity, 'config, T: Config> BackendT for SubstrateStackState<'vicinity,
}

fn storage(&self, address: H160, index: H256) -> H256 {
AccountStorages::<T>::get(&address, index)
AccountStorages::<T>::get(address, index)
}

fn original_storage(&self, address: H160, index: H256) -> Option<H256> {
Expand Down Expand Up @@ -724,7 +724,7 @@ impl<'vicinity, 'config, T: Config> StackStateT<'config> for SubstrateStackState
}

fn inc_nonce(&mut self, address: H160) {
Accounts::<T>::mutate(&address, |maybe_account| {
Accounts::<T>::mutate(address, |maybe_account| {
if let Some(account) = maybe_account.as_mut() {
account.nonce += One::one()
} else {
Expand Down
2 changes: 1 addition & 1 deletion modules/evm/src/runner/state.rs
Original file line number Diff line number Diff line change
Expand Up @@ -711,7 +711,7 @@ impl<'config, 'precompiles, S: StackState<'config>, P: PrecompileSet> StackExecu
salt,
} => {
let mut hasher = Keccak256::new();
hasher.update(&[0xff]);
hasher.update([0xff]);
hasher.update(&caller[..]);
hasher.update(&salt[..]);
hasher.update(&code_hash[..]);
Expand Down
Loading