Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
37 commits
Select commit Hold shift + click to select a range
11e811e
Update runtimes
ukint-vs Jul 16, 2023
c11776e
TypeInfo HandleKind
ukint-vs Jul 16, 2023
9bd481e
Update node/service
ukint-vs Jul 16, 2023
2e3d63b
Use verify instead of removed verify_weak
ukint-vs Jul 16, 2023
efd7867
gear-replay-cli update
ukint-vs Jul 16, 2023
6d410f3
gsdk update
ukint-vs Jul 16, 2023
7375023
Update mocks
ukint-vs Jul 17, 2023
84a7943
misc update fuzzer, integration tests
ukint-vs Jul 18, 2023
3fe0ebb
update mocks
ukint-vs Aug 26, 2023
a2f99e1
fix resume_program_works: account ED
ukint-vs Aug 26, 2023
bee0dee
update gsdk metadata
ukint-vs Aug 26, 2023
4a56958
update gclient
ukint-vs Aug 26, 2023
4478c1e
impl Credit Dust handler in pallet-staking-rewards
ukint-vs Oct 23, 2023
9b6b8e3
fix gcli test
ukint-vs Oct 24, 2023
1bb8bd9
revert gossip_duration
ukint-vs Oct 29, 2023
6ab55d4
fix typo
ukint-vs Oct 29, 2023
843b3a9
build our own executor
ukint-vs Oct 29, 2023
1e33cb7
Fix gsdk wasm strategy
ukint-vs Oct 24, 2023
7707053
Update node/service
ukint-vs Oct 24, 2023
c2c9444
Update runtime params
ukint-vs Oct 24, 2023
8f2a0e9
Update gsdk
ukint-vs Oct 24, 2023
63bc50b
Update staking-rewards
ukint-vs Oct 24, 2023
7453fef
fix staking-rewards tests
ukint-vs Oct 29, 2023
851e0ed
clippy node
ukint-vs Oct 29, 2023
9eb48d2
update gsdk metadata
ukint-vs Oct 29, 2023
a44ed16
resolve comments
ukint-vs Oct 30, 2023
127f95b
disable hw benches for dev node
ukint-vs Oct 31, 2023
135b775
ws-port -> rpc-port
ukint-vs Oct 31, 2023
9f3f7d4
set correct pallets storage version via migration
ukint-vs Nov 7, 2023
8b34a1f
use new logic flag
ukint-vs Dec 1, 2023
3512f0a
Update substrate branch 0.9.43
ukint-vs Dec 12, 2023
461fa25
fix tests
ukint-vs Dec 12, 2023
6d36afd
resolve comments
ukint-vs Dec 14, 2023
83d413b
StakingCurrency -> CurrencyOf
ukint-vs Dec 14, 2023
7faa2bd
Update weights
ukint-vs Dec 14, 2023
8fdb424
fix migration weight
ukint-vs Dec 14, 2023
3b577ea
Merge branch 'release-v1.0.3' into vs/substrate-0.9.43-v1.0.3
breathx Dec 14, 2023
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
4,307 changes: 2,354 additions & 1,953 deletions Cargo.lock

Large diffs are not rendered by default.

237 changes: 119 additions & 118 deletions Cargo.toml

Large diffs are not rendered by default.

8 changes: 6 additions & 2 deletions gcli/src/keystore/key.rs
Original file line number Diff line number Diff line change
Expand Up @@ -105,10 +105,14 @@ impl Key {
}

/// Verify messages
pub fn verify<P>(sig: &[u8], message: &[u8], pubkey: &[u8]) -> Result<bool>
pub fn verify<'a, P>(sig: &'a [u8], message: &[u8], pubkey: &'a [u8]) -> Result<bool>
where
P: Pair,
<P as gsdk::ext::sp_core::Pair>::Signature: TryFrom<&'a [u8]>,
<P as gsdk::ext::sp_core::Pair>::Public: TryFrom<&'a [u8]>,
{
Ok(P::verify_weak(sig, message, pubkey))
let pubkey = P::Public::try_from(pubkey).map_err(|_| Error::InvalidPublic)?;
let sig = P::Signature::try_from(sig).map_err(|_| Error::InvalidSignature)?;
Ok(P::verify(&sig, message, &pubkey))
}
}
2 changes: 2 additions & 0 deletions gcli/src/result.rs
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,8 @@ pub enum Error {
InvalidPassword,
#[error("Invalid public key")]
InvalidPublic,
#[error("Invalid signature")]
InvalidSignature,
#[error("Invalid secret key")]
InvalidSecret,
#[error(transparent)]
Expand Down
8 changes: 6 additions & 2 deletions gcli/tests/cmd/info.rs
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,8 @@ use crate::common::{
Args, Result,
};

// ExtraFlags is hardcoded
// const IS_NEW_LOGIC: u128 = 0x80000000_00000000_00000000_00000000u128;
const EXPECTED_BALANCE: &str = r#"
AccountInfo {
nonce: 0,
Expand All @@ -32,8 +34,10 @@ AccountInfo {
data: AccountData {
free: 1000000000000000000,
reserved: 0,
misc_frozen: 0,
fee_frozen: 0,
frozen: 0,
flags: ExtraFlags(
170141183460469231731687303715884105728,
),
},
}
"#;
Expand Down
57 changes: 26 additions & 31 deletions gclient/src/api/calls.rs
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ use gsdk::{
event::{CodeChangeKind, MessageEntry},
ActiveProgram,
},
pallet_balances::{pallet::Call as BalancesCall, AccountData},
pallet_balances::{pallet::Call as BalancesCall, types::AccountData},
pallet_gear::pallet::Call as GearCall,
pallet_gear_bank::pallet::BankAccount,
sp_weights::weight_v2::Weight,
Expand Down Expand Up @@ -289,8 +289,10 @@ impl GearApi {
Ok(AccountData {
free: 0u128,
reserved: 0,
misc_frozen: 0,
fee_frozen: 0,
frozen: 0,
flags: gsdk::metadata::runtime_types::pallet_balances::types::ExtraFlags(
170141183460469231731687303715884105728,
),
})
} else {
Err(e)
Expand All @@ -316,8 +318,10 @@ impl GearApi {
Ok(AccountData {
free: 0u128,
reserved: 0,
misc_frozen: 0,
fee_frozen: 0,
frozen: 0,
flags: gsdk::metadata::runtime_types::pallet_balances::types::ExtraFlags(
170141183460469231731687303715884105728,
),
})
} else {
Err(e)
Expand Down Expand Up @@ -378,19 +382,14 @@ impl GearApi {

// Apply data to the target program
dest_node_api
.set_balance(
.force_set_balance(
dest_program_id.into_account_id(),
src_program_account_data.free,
src_program_account_data.reserved,
)
.await?;

dest_node_api
.set_balance(
crate::bank_address(),
src_bank_account_data.free,
src_bank_account_data.reserved,
)
.force_set_balance(crate::bank_address(), src_bank_account_data.free)
.await?;

dest_node_api
Expand Down Expand Up @@ -421,9 +420,6 @@ impl GearApi {
.await?;

for account_with_reserved_funds in accounts_with_reserved_funds {
let src_account_data = self
.account_data_at(account_with_reserved_funds, src_block_hash)
.await?;
let src_account_bank_data = self
.bank_data_at(account_with_reserved_funds, src_block_hash)
.await
Expand All @@ -443,8 +439,11 @@ impl GearApi {
Ok(AccountData {
free: 0u128,
reserved: 0,
misc_frozen: 0,
fee_frozen: 0,
frozen: 0,
flags:
gsdk::metadata::runtime_types::pallet_balances::types::ExtraFlags(
170141183460469231731687303715884105728,
),
})
} else {
Err(e)
Expand All @@ -462,12 +461,9 @@ impl GearApi {
})?;

dest_node_api
.set_balance(
.force_set_balance(
account_with_reserved_funds.into_account_id(),
dest_account_data.free,
dest_account_data
.reserved
.saturating_add(src_account_data.reserved),
)
.await?;

Expand Down Expand Up @@ -565,8 +561,11 @@ impl GearApi {
Ok(AccountData {
free: 0u128,
reserved: 0,
misc_frozen: 0,
fee_frozen: 0,
frozen: 0,
flags:
gsdk::metadata::runtime_types::pallet_balances::types::ExtraFlags(
170141183460469231731687303715884105728,
),
})
} else {
Err(e)
Expand Down Expand Up @@ -597,10 +596,9 @@ impl GearApi {
.map(|(page_number, page_data)| (page_number.raw(), page_data.encode()))
.collect::<HashMap<_, _>>();

self.set_balance(
self.force_set_balance(
MultiAddress::Id(program_id.into_account_id()),
memory_dump.balance,
memory_dump.reserved_balance,
)
.await?;

Expand Down Expand Up @@ -1302,24 +1300,21 @@ impl GearApi {
self.set_code_without_checks(code).await
}

/// Set the free and reserved balance of the `to` account to `new_free` and
/// `new_reserved` respectively.
/// Set the free balance of the `to` account to `new_free`.
///
/// Sends the [`pallet_balances::set_balance`](https://crates.parity.io/pallet_balances/pallet/struct.Pallet.html#method.set_balance) extrinsic.
pub async fn set_balance(
pub async fn force_set_balance(
&self,
to: impl Into<MultiAddress<AccountId32, ()>>,
new_free: u128,
new_reserved: u128,
) -> Result<H256> {
let events = self
.0
.calls
.sudo_unchecked_weight(
RuntimeCall::Balances(BalancesCall::set_balance {
RuntimeCall::Balances(BalancesCall::force_set_balance {
who: to.into().convert(),
new_free,
new_reserved,
}),
Weight {
ref_time: 0,
Expand Down
2 changes: 1 addition & 1 deletion gclient/src/api/storage/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ use gsdk::{
ext::sp_core::{crypto::Ss58Codec, H256},
metadata::runtime_types::{
gear_common::storage::primitives::Interval, gear_core::message::user,
pallet_balances::AccountData, pallet_gear_bank::pallet::BankAccount,
pallet_balances::types::AccountData, pallet_gear_bank::pallet::BankAccount,
},
};

Expand Down
15 changes: 13 additions & 2 deletions gsdk/api-gen/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -94,18 +94,29 @@ fn main() -> Result<()> {
/// Get the metadata of vara runtime.
fn metadata() -> Vec<u8> {
use gear_runtime_interface as gear_ri;
use sc_executor::WasmExecutionMethod;
use sc_executor::{WasmExecutionMethod, WasmtimeInstantiationStrategy};
use sc_executor_common::runtime_blob::RuntimeBlob;

// 1. Get the wasm binary of `RUNTIME_WASM`.
let path = env::var(RUNTIME_WASM).expect("Missing RUNTIME_WASM env var.");
let code = fs::read(path).expect("Failed to read runtime wasm");

let heap_pages =
sc_executor_common::wasm_runtime::HeapAllocStrategy::Static { extra_pages: 1024 };

// 2. Create wasm executor.
let executor = sc_executor::WasmExecutor::<(
gear_ri::gear_ri::HostFunctions,
sp_io::SubstrateHostFunctions,
)>::new(WasmExecutionMethod::Interpreted, Some(1024), 8, None, 2);
)>::builder()
.with_execution_method(WasmExecutionMethod::Compiled {
instantiation_strategy: WasmtimeInstantiationStrategy::PoolingCopyOnWrite,
})
.with_onchain_heap_alloc_strategy(heap_pages)
.with_offchain_heap_alloc_strategy(heap_pages)
.with_max_runtime_instances(8)
.with_runtime_cache_size(2)
.build();

// 3. Extract metadata.
executor
Expand Down
Loading