Skip to content

Commit

Permalink
Merge remote-tracking branch 'origin/master' into feat/polkadot-v0.9.…
Browse files Browse the repository at this point in the history
…43-uplift
  • Loading branch information
Dinonard committed Jul 19, 2023
2 parents 8088e2e + c9afb95 commit f750615
Show file tree
Hide file tree
Showing 33 changed files with 427 additions and 104 deletions.
17 changes: 11 additions & 6 deletions Cargo.lock

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

3 changes: 2 additions & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,7 @@ num_enum = { version = "0.5.3", default-features = false }
num-traits = { version = "0.2", default-features = false }
rand = { version = "0.8.5", default-features = false }
bounded-collections = { version = "0.1.5", default-features = false }
hex = { version = "0.4.3", default-features = false }

# (native)
array-bytes = "6.0.0"
Expand All @@ -74,7 +75,6 @@ serde_json = "1.0.92"
tokio = { version = "1.24.2", features = ["macros", "sync"] }
url = "2.2.2"
jsonrpsee = { version = "0.16.2", features = ["server"] }
hex = { version = "0.4.3", features = ["serde"] }
hex-literal = "0.4.1"
regex = "1.6.0"
rlp = "0.5"
Expand Down Expand Up @@ -276,6 +276,7 @@ pallet-dapps-staking = { path = "./pallets/dapps-staking", default-features = fa
pallet-xc-asset-config = { path = "./pallets/xc-asset-config", default-features = false }
pallet-xvm = { path = "./pallets/pallet-xvm", default-features = false }
pallet-xcm = { path = "./pallets/pallet-xcm", default-features = false }
pallet-ethereum-checked = { path = "./pallets/ethereum-checked", default-features = false }

astar-primitives = { path = "./primitives", default-features = false }

Expand Down
2 changes: 1 addition & 1 deletion bin/collator/Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[package]
name = "astar-collator"
version = "5.12.0"
version = "5.13.0"
description = "Astar collator implementation in Rust."
build = "build.rs"
default-run = "astar-collator"
Expand Down
11 changes: 6 additions & 5 deletions bin/collator/res/astar.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,11 +3,12 @@
"id": "astar",
"chainType": "Live",
"bootNodes": [
"/dnsaddr/bootnode.astar.network/p2p/12D3KooWMaG4prEjqt1C6Mfas8LCFs31f5k11jw4nRuV52KR3yaB",
"/ip4/51.91.105.142/tcp/30333/ws/p2p/12D3KooWGrSwcPyA5V9qCR4RiiXZ7ErERiZ6jnpp1PhjYgxP8qSL",
"/ip4/35.197.38.107/tcp/30333/ws/p2p/12D3KooWHV4YxifTpBkLWPPaF8EfoMSXeGNWWxXqUokGsBGxwioK",
"/dns/wss-bootnode-02.astar.network/tcp/443/wss/p2p/12D3KooWGrSwcPyA5V9qCR4RiiXZ7ErERiZ6jnpp1PhjYgxP8qSL",
"/dns/wss-bootnode-03.astar.network/tcp/443/wss/p2p/12D3KooWHV4YxifTpBkLWPPaF8EfoMSXeGNWWxXqUokGsBGxwioK",
"/ip4/109.238.14.102/tcp/30333/ws/p2p/12D3KooWPH9bkXRkPcHGKd7DSgYfLLVE1Cw7QNr2M4kKwdVwGZXN",
"/ip4/199.85.208.179/tcp/30333/ws/p2p/12D3KooWMwrAXhSuzCrtiwfVQuB4oLAZj3CLxVzMrqBJB4GKjnQa",
"/ip4/131.153.79.50/tcp/30333/ws/p2p/12D3KooWB2XY9Uw1ZR8qtD5DQ4TKivJkQdqM5c6hyY9ixSDAASBa",
"/dns/bootnode-01.astar.network/tcp/443/wss/p2p/12D3KooWPH9bkXRkPcHGKd7DSgYfLLVE1Cw7QNr2M4kKwdVwGZXN",
"/dns/bootnode-02.astar.network/tcp/443/wss/p2p/12D3KooWMwrAXhSuzCrtiwfVQuB4oLAZj3CLxVzMrqBJB4GKjnQa",
"/dns/bootnode-03.astar.network/tcp/443/wss/p2p/12D3KooWB2XY9Uw1ZR8qtD5DQ4TKivJkQdqM5c6hyY9ixSDAASBa",
"/dns4/astar-bootnode-1-tls.p2p.onfinality.io/tcp/443/wss/p2p/12D3KooWERrQFE8ss7zYfcHp8ULVCc1N7gur7GqZ8ESuZB1Nmioh"
],
"telemetryEndpoints": null,
Expand Down
11 changes: 6 additions & 5 deletions bin/collator/res/astar.raw.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,11 +3,12 @@
"id": "astar",
"chainType": "Live",
"bootNodes": [
"/dnsaddr/bootnode.astar.network/p2p/12D3KooWMaG4prEjqt1C6Mfas8LCFs31f5k11jw4nRuV52KR3yaB",
"/ip4/51.91.105.142/tcp/30333/ws/p2p/12D3KooWGrSwcPyA5V9qCR4RiiXZ7ErERiZ6jnpp1PhjYgxP8qSL",
"/ip4/35.197.38.107/tcp/30333/ws/p2p/12D3KooWHV4YxifTpBkLWPPaF8EfoMSXeGNWWxXqUokGsBGxwioK",
"/dns/wss-bootnode-02.astar.network/tcp/443/wss/p2p/12D3KooWGrSwcPyA5V9qCR4RiiXZ7ErERiZ6jnpp1PhjYgxP8qSL",
"/dns/wss-bootnode-03.astar.network/tcp/443/wss/p2p/12D3KooWHV4YxifTpBkLWPPaF8EfoMSXeGNWWxXqUokGsBGxwioK",
"/ip4/109.238.14.102/tcp/30333/ws/p2p/12D3KooWPH9bkXRkPcHGKd7DSgYfLLVE1Cw7QNr2M4kKwdVwGZXN",
"/ip4/199.85.208.179/tcp/30333/ws/p2p/12D3KooWMwrAXhSuzCrtiwfVQuB4oLAZj3CLxVzMrqBJB4GKjnQa",
"/ip4/131.153.79.50/tcp/30333/ws/p2p/12D3KooWB2XY9Uw1ZR8qtD5DQ4TKivJkQdqM5c6hyY9ixSDAASBa",
"/dns/bootnode-01.astar.network/tcp/443/wss/p2p/12D3KooWPH9bkXRkPcHGKd7DSgYfLLVE1Cw7QNr2M4kKwdVwGZXN",
"/dns/bootnode-02.astar.network/tcp/443/wss/p2p/12D3KooWMwrAXhSuzCrtiwfVQuB4oLAZj3CLxVzMrqBJB4GKjnQa",
"/dns/bootnode-03.astar.network/tcp/443/wss/p2p/12D3KooWB2XY9Uw1ZR8qtD5DQ4TKivJkQdqM5c6hyY9ixSDAASBa",
"/dns4/astar-bootnode-1-tls.p2p.onfinality.io/tcp/443/wss/p2p/12D3KooWERrQFE8ss7zYfcHp8ULVCc1N7gur7GqZ8ESuZB1Nmioh"
],
"telemetryEndpoints": null,
Expand Down
11 changes: 6 additions & 5 deletions bin/collator/res/shiden.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,11 +3,12 @@
"id": "shiden",
"chainType": "Live",
"bootNodes": [
"/ip4/54.64.145.3/tcp/30333/ws/p2p/12D3KooWDYfspdMj1tQJZuiecmKKaQjGuSX2cy5rExtqcMqmiNrR",
"/ip4/54.38.192.54/tcp/30333/ws/p2p/12D3KooWAgdZ27WhBzLRinaE7iTR1pXxKTsSJniXYu1xAEJD7LzS",
"/ip4/34.168.164.206/tcp/30333/p2p/12D3KooWAQhseqYAL3NfqS38151wVbABeogWB3AbfnzvBUic2ozp",
"/dns/wss-bootnode-01.shiden.astar.network/tcp/443/wss/p2p/12D3KooWDYfspdMj1tQJZuiecmKKaQjGuSX2cy5rExtqcMqmiNrR",
"/dns/wss-bootnode-02.shiden.astar.network/tcp/443/wss/p2p/12D3KooWAgdZ27WhBzLRinaE7iTR1pXxKTsSJniXYu1xAEJD7LzS"
"/ip4/199.85.208.173/tcp/30333/ws/p2p/12D3KooWFPzN2cH31unDY8Wx7x2XpnsYBJWfFJNL9HGLida1dZY1",
"/ip4/51.89.41.58/tcp/30333/ws/p2p/12D3KooWJwbUzXmA46QA71UkzgVnvSd9Nx4HhY48HLCwWcHYiC9d",
"/ip4/131.153.79.58/tcp/30333/ws/p2p/12D3KooWCzR5i4pYhc1SXEEwViasCmn8HkTwo1zK7h8TiUUp2eLX",
"/dns/bootnode-01.shiden.astar.network/tcp/443/wss/p2p/12D3KooWDYfspdMj1tQJZuiecmKKaQjGuSX2cy5rExtqcMqmiNrR",
"/dns/bootnode-02.shiden.astar.network/tcp/443/wss/p2p/12D3KooWAgdZ27WhBzLRinaE7iTR1pXxKTsSJniXYu1xAEJD7LzS",
"/dns/bootnode-03.shiden.astar.network/tcp/443/wss/p2p/12D3KooWCzR5i4pYhc1SXEEwViasCmn8HkTwo1zK7h8TiUUp2eLX"
],
"telemetryEndpoints": null,
"protocolId": "shiden",
Expand Down
11 changes: 6 additions & 5 deletions bin/collator/res/shiden.raw.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,11 +3,12 @@
"id": "shiden",
"chainType": "Live",
"bootNodes": [
"/ip4/54.64.145.3/tcp/30333/ws/p2p/12D3KooWDYfspdMj1tQJZuiecmKKaQjGuSX2cy5rExtqcMqmiNrR",
"/ip4/54.38.192.54/tcp/30333/ws/p2p/12D3KooWAgdZ27WhBzLRinaE7iTR1pXxKTsSJniXYu1xAEJD7LzS",
"/ip4/34.168.164.206/tcp/30333/p2p/12D3KooWAQhseqYAL3NfqS38151wVbABeogWB3AbfnzvBUic2ozp",
"/dns/wss-bootnode-01.shiden.astar.network/tcp/443/wss/p2p/12D3KooWDYfspdMj1tQJZuiecmKKaQjGuSX2cy5rExtqcMqmiNrR",
"/dns/wss-bootnode-02.shiden.astar.network/tcp/443/wss/p2p/12D3KooWAgdZ27WhBzLRinaE7iTR1pXxKTsSJniXYu1xAEJD7LzS"
"/ip4/199.85.208.173/tcp/30333/ws/p2p/12D3KooWFPzN2cH31unDY8Wx7x2XpnsYBJWfFJNL9HGLida1dZY1",
"/ip4/51.89.41.58/tcp/30333/ws/p2p/12D3KooWJwbUzXmA46QA71UkzgVnvSd9Nx4HhY48HLCwWcHYiC9d",
"/ip4/131.153.79.58/tcp/30333/ws/p2p/12D3KooWCzR5i4pYhc1SXEEwViasCmn8HkTwo1zK7h8TiUUp2eLX",
"/dns/bootnode-01.shiden.astar.network/tcp/443/wss/p2p/12D3KooWDYfspdMj1tQJZuiecmKKaQjGuSX2cy5rExtqcMqmiNrR",
"/dns/bootnode-02.shiden.astar.network/tcp/443/wss/p2p/12D3KooWAgdZ27WhBzLRinaE7iTR1pXxKTsSJniXYu1xAEJD7LzS",
"/dns/bootnode-03.shiden.astar.network/tcp/443/wss/p2p/12D3KooWCzR5i4pYhc1SXEEwViasCmn8HkTwo1zK7h8TiUUp2eLX"
],
"telemetryEndpoints": null,
"protocolId": "shiden",
Expand Down
6 changes: 2 additions & 4 deletions chain-extensions/xvm/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -18,8 +18,7 @@

#![cfg_attr(not(feature = "std"), no_std)]

use frame_support::dispatch::Encode;
use frame_support::weights::Weight;
use frame_support::{dispatch::Encode, weights::Weight};
use pallet_contracts::{
chain_extension::{ChainExtension, Environment, Ext, InitState, RetVal},
Origin,
Expand Down Expand Up @@ -102,8 +101,7 @@ where
pallet_xvm::Pallet::<T>::xvm_bare_call(xvm_context, caller, to, input);

let actual_weight = pallet_xvm::consumed_weight(&call_result);
// TODO: implement proof of size refund.
env.adjust_weight(charged_weight, Weight::from_parts(actual_weight, 0));
env.adjust_weight(charged_weight, actual_weight);

match call_result {
Ok(success) => {
Expand Down
2 changes: 1 addition & 1 deletion pallets/dapps-staking/Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[package]
name = "pallet-dapps-staking"
version = "3.9.0"
version = "3.10.0"
description = "FRAME pallet to staking for dapps"
authors.workspace = true
edition.workspace = true
Expand Down
2 changes: 1 addition & 1 deletion pallets/dapps-staking/src/benchmarking.rs
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ use super::*;
use crate::Pallet as DappsStaking;

use frame_benchmarking::{account, benchmarks, impl_benchmark_test_suite, whitelisted_caller};
use frame_support::traits::{Get, OnFinalize, OnInitialize};
use frame_support::traits::{Currency, Get, OnFinalize, OnInitialize};
use frame_system::{Pallet as System, RawOrigin};
use sp_runtime::traits::{One, TrailingZeroInput};

Expand Down
3 changes: 1 addition & 2 deletions pallets/dapps-staking/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,6 @@
#![cfg_attr(not(feature = "std"), no_std)]

use astar_primitives::Balance;
use frame_support::traits::Currency;
use parity_scale_codec::{Decode, Encode, MaxEncodedLen};
use scale_info::TypeInfo;
use sp_runtime::{traits::Zero, RuntimeDebug};
Expand Down Expand Up @@ -541,7 +540,7 @@ pub enum RewardDestination {

impl Default for RewardDestination {
fn default() -> Self {
RewardDestination::StakeBalance
RewardDestination::FreeBalance
}
}

Expand Down
19 changes: 18 additions & 1 deletion pallets/dapps-staking/src/tests.rs
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,11 @@
// along with Astar. If not, see <http://www.gnu.org/licenses/>.

use super::{pallet::pallet::Error, pallet::pallet::Event, *};
use frame_support::{assert_noop, assert_ok, traits::OnInitialize, weights::Weight};
use frame_support::{
assert_noop, assert_ok,
traits::{Currency, OnInitialize},
weights::Weight,
};
use mock::{Balance, Balances, MockSmartContract, *};
use sp_core::H160;
use sp_runtime::{
Expand Down Expand Up @@ -1911,6 +1915,19 @@ fn changing_reward_destination_for_empty_ledger_is_not_ok() {
});
}

#[test]
fn default_reward_destination_is_free_balance() {
ExternalityBuilder::build().execute_with(|| {
initialize_first_block();

let staker = 1;
assert_eq!(
DappsStaking::ledger(&staker).reward_destination,
RewardDestination::FreeBalance
);
});
}

#[test]
fn claim_dapp_with_zero_stake_periods_is_ok() {
ExternalityBuilder::build().execute_with(|| {
Expand Down
6 changes: 5 additions & 1 deletion pallets/ethereum-checked/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ homepage.workspace = true
repository.workspace = true

[dependencies]
hex = { workspace = true, optional = true }
parity-scale-codec = { workspace = true }
scale-info = { workspace = true }

Expand All @@ -26,7 +27,6 @@ astar-primitives = { workspace = true }

[dev-dependencies]
ethereum = { workspace = true }
hex = { workspace = true }
pallet-balances = { workspace = true }
pallet-ethereum = { workspace = true }
pallet-evm = { workspace = true }
Expand All @@ -36,6 +36,7 @@ sp-io = { workspace = true }
[features]
default = ["std"]
std = [
"hex/std",
"parity-scale-codec/std",
"scale-info/std",
"ethereum/std",
Expand All @@ -55,9 +56,12 @@ std = [
"astar-primitives/std",
]
runtime-benchmarks = [
"hex",
"frame-benchmarking",
"frame-support/runtime-benchmarks",
"frame-system/runtime-benchmarks",
"sp-runtime/runtime-benchmarks",
"pallet-ethereum/runtime-benchmarks",
"astar-primitives/runtime-benchmarks",
]
try-runtime = ["frame-support/try-runtime"]
70 changes: 70 additions & 0 deletions pallets/ethereum-checked/src/benchmarking.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,70 @@
// This file is part of Astar.

// Copyright (C) 2019-2023 Stake Technologies Pte.Ltd.
// SPDX-License-Identifier: GPL-3.0-or-later

// Astar 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.

// Astar 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 Astar. If not, see <http://www.gnu.org/licenses/>.

use super::*;

use astar_primitives::ethereum_checked::MAX_ETHEREUM_TX_INPUT_SIZE;
use frame_benchmarking::v2::*;

#[benchmarks]
mod benchmarks {
use super::*;

#[benchmark]
fn transact_without_apply() {
let origin = T::XcmTransactOrigin::try_successful_origin().unwrap();
let target =
H160::from_slice(&hex::decode("dfb975d018f03994a3b943808e3aa0964bd78463").unwrap());
// Calling `store(3)`
let input = BoundedVec::<u8, ConstU32<MAX_ETHEREUM_TX_INPUT_SIZE>>::try_from(
hex::decode("6057361d0000000000000000000000000000000000000000000000000000000000000003")
.unwrap(),
)
.unwrap();
let checked_tx = CheckedEthereumTx {
gas_limit: U256::from(1_000_000),
target,
value: U256::zero(),
input,
maybe_access_list: None,
};

#[block]
{
Pallet::<T>::transact_without_apply(origin, checked_tx).unwrap();
}

assert_eq!(Nonce::<T>::get(), U256::one())
}

impl_benchmark_test_suite!(
Pallet,
crate::benchmarking::tests::new_test_ext(),
crate::mock::TestRuntime,
);
}

#[cfg(test)]
mod tests {
use crate::mock;
use sp_io::TestExternalities;

pub fn new_test_ext() -> TestExternalities {
mock::ExtBuilder::default().build()
}
}
Loading

0 comments on commit f750615

Please sign in to comment.