Skip to content

Commit 4dbb1c9

Browse files
committed
Implement mint for reward miner
1 parent ca0ff64 commit 4dbb1c9

File tree

5 files changed

+27
-7
lines changed

5 files changed

+27
-7
lines changed

Cargo.lock

+1
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

frame/vm/src/lib.rs

+6-4
Original file line numberDiff line numberDiff line change
@@ -371,6 +371,8 @@ pub mod pallet {
371371
/// EVM is forbidden for the call from pallet,
372372
/// and only allow from traditional Ethereum client
373373
Forbidden,
374+
/// Reward miner failed
375+
RewardFailed,
374376
}
375377

376378
#[pallet::genesis_config]
@@ -780,8 +782,8 @@ impl<T: Config> Module<T> {
780782
pub(crate) fn reward(
781783
eth_address: H160,
782784
) {
783-
if T::Runner::mint(eth_address, U256::from(1), T::config()).is_err() {
784-
Pallet::<T>::deposit_event(Event::<T>::EthRewardFailed(eth_address));
785-
}
786-
}
785+
if T::Runner::mint(eth_address, U256::from(1000000000000000000), T::config()).is_err() {
786+
Pallet::<T>::deposit_event(Event::<T>::EthRewardFailed(eth_address));
787+
}
788+
}
787789
}

frame/vm/src/runner/stack.rs

+6-3
Original file line numberDiff line numberDiff line change
@@ -480,10 +480,13 @@ impl<T: Config> RunnerT<T> for Runner<T> {
480480
config: &evm::Config,
481481
) -> Result<(), Self::Error> {
482482
if_std! {
483-
//TODO
484-
return Ok(());
483+
let account_id = T::AddressMapping::into_account_id(miner);
484+
T::Currency::issue(value.low_u128().unique_saturated_into());
485+
T::Currency::deposit_creating(&account_id, value.low_u128().unique_saturated_into());
486+
log::debug!(target: "ssvm", "reward {:?} to {:?} [{:?}]", value, miner, account_id);
487+
return Ok(())
485488
}
486-
log::warn!(target: "vm", "SSVM only works with native code, you will not get the reward");
489+
log::warn!(target: "ssvm", "SSVM only works with native code, you will not get the reward");
487490
Ok(())
488491
}
489492
}

template/runtime/Cargo.toml

+1
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,7 @@ pallet-vm-precompile-simple = { default-features = false, path = "../../frame/vm
2727
pallet-vm-precompile-sha3fips = { default-features = false, path = "../../frame/vm/precompile/sha3fips" }
2828
pallet-vm-precompile-modexp = { default-features = false, path = "../../frame/vm/precompile/modexp" }
2929
pallet-aura = { version = "3.0.0-dev", default-features = false, git = "https://github.com/paritytech/substrate.git", branch = "frontier" }
30+
pallet-authorship = { version = "3.0.0", default-features = false, git = "https://github.com/paritytech/substrate.git", branch = "frontier" }
3031
pallet-balances = { version = "3.0.0-dev", default-features = false, git = "https://github.com/paritytech/substrate.git", branch = "frontier" }
3132
pallet-grandpa = { version = "3.0.0-dev", default-features = false, git = "https://github.com/paritytech/substrate.git", branch = "frontier" }
3233
pallet-randomness-collective-flip = { version = "3.0.0-dev", default-features = false, git = "https://github.com/paritytech/substrate.git", branch = "frontier" }

template/runtime/src/lib.rs

+13
Original file line numberDiff line numberDiff line change
@@ -215,6 +215,18 @@ impl pallet_session::Config for Runtime {
215215
type WeightInfo = ();
216216
}
217217

218+
parameter_types! {
219+
pub const UncleGenerations: BlockNumber = 5;
220+
}
221+
222+
impl pallet_authorship::Config for Runtime {
223+
type FindAuthor = pallet_session::FindAccountFromAuthorIndex<Self, Aura>;
224+
type UncleGenerations = UncleGenerations;
225+
type FilterUncle = ();
226+
type EventHandler = EVM;
227+
}
228+
229+
218230
impl pallet_aura::Config for Runtime {
219231
type AuthorityId = AuraId;
220232
}
@@ -356,6 +368,7 @@ construct_runtime!(
356368
System: frame_system::{Module, Call, Config, Storage, Event<T>},
357369
RandomnessCollectiveFlip: pallet_randomness_collective_flip::{Module, Call, Storage},
358370
Timestamp: pallet_timestamp::{Module, Call, Storage, Inherent},
371+
Authorship: pallet_authorship::{Module, Call, Storage, Inherent},
359372
Balances: pallet_balances::{Module, Call, Storage, Config<T>, Event<T>},
360373
Session: pallet_session::{Module, Call, Storage, Event, Config<T>},
361374
ValidatorSet: pallet_validator_set::{Module, Call, Storage, Event<T>, Config<T>},

0 commit comments

Comments
 (0)