Skip to content

Commit

Permalink
Merge pull request #350 from grindytech/dev
Browse files Browse the repository at this point in the history
Dev
  • Loading branch information
mutobui authored Oct 5, 2023
2 parents 3857b0c + 7aeb77f commit d1ac6ff
Show file tree
Hide file tree
Showing 35 changed files with 2,240 additions and 218 deletions.
78 changes: 58 additions & 20 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 @@ -11,7 +11,8 @@ members = [
'pallets/pallet-faucet',
'pallets/pallet-cache',
'game/pallet-game',
'game/randomness',
'game/offchain-worker-randomness',
'game/oracle-randomness',
'gafi-node/runtime',
'gafi-node/node',
'pallets/template',
Expand Down
17 changes: 2 additions & 15 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,8 @@ run:
--rpc-port 9944 \
--rpc-cors all \
--rpc-methods=Unsafe \
--rpc-external
--rpc-external \
--execution Native

.PHONY: check-benchmark
check-benchmark:
Expand Down Expand Up @@ -47,19 +48,6 @@ benchmark-game:
--repeat 10 \
--output ./benchmarking/pallet-game/weights.rs

.PHONY: randomness-weights
randomness-weights:
./target/release/gafi-node benchmark pallet \
--chain dev \
--wasm-execution compiled \
--pallet game_randomness \
--extrinsic '*' \
--steps 50 \
--repeat 20 \
--execution wasm \
--output ./benchmarking/randomness/weights.rs \
--template .maintain/frame-weight-template.hbs

.PHONY: pallet-game-weights
pallet-game-weights:
./target/release/gafi-node benchmark pallet \
Expand All @@ -69,6 +57,5 @@ pallet-game-weights:
--extrinsic '*' \
--steps 50 \
--repeat 20 \
--execution wasm \
--output ./benchmarking/pallet-game/weights.rs \
--template .maintain/frame-weight-template.hbs
17 changes: 15 additions & 2 deletions gafi-node/node/src/chain_spec.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
use gafi_runtime::{
AccountId, AuraConfig, BalancesConfig, FaucetConfig, GrandpaConfig, RuntimeGenesisConfig,
Signature, SudoConfig, SystemConfig, WASM_BINARY,
AccountId, AuraConfig, BalancesConfig, FaucetConfig, GrandpaConfig, OracleRandomnessConfig,
RuntimeGenesisConfig, Signature, SudoConfig, SystemConfig, WASM_BINARY,
};
use gafi_support::common::{unit, NativeToken::GAFI};
use sc_service::ChainType;
Expand Down Expand Up @@ -209,5 +209,18 @@ fn testnet_genesis(
faucet: FaucetConfig {
genesis_accounts: endowed_accounts.iter().map(|x| (x.0.clone())).collect(),
},
oracle_randomness: OracleRandomnessConfig {
default_urls: [
"https://api.drand.sh/public/latest",
"https://api2.drand.sh/public/latest",
"https://api3.drand.sh/public/latest",
"https://drand.cloudflare.com/public/latest",
]
.iter()
.map(|s| s.as_bytes().to_vec())
.collect(),

..Default::default()
},
}
}
7 changes: 4 additions & 3 deletions gafi-node/runtime/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@ pallet-template = { version = "4.0.0-dev", default-features = false, path = "../
gafi-support = { version = "4.0.0-dev", default-features = false, path = "../../support" }
pallet-cache = { version = "4.0.0-dev", default-features = false, path = "../../pallets/pallet-cache" }
pallet-faucet = { version = "4.0.0-dev", default-features = false, path = "../../pallets/pallet-faucet" }
game-randomness = { version = "4.0.0-dev", default-features = false, path = "../../game/randomness" }
oracle-randomness = { version = "4.0.0-dev", default-features = false, path = "../../game/oracle-randomness" }
pallet-game = { version = "4.0.0-dev", default-features = false, path = "../../game/pallet-game" }

[build-dependencies]
Expand Down Expand Up @@ -117,7 +117,7 @@ std = [
"gafi-support/std",
"pallet-cache/std",
"pallet-faucet/std",
"game-randomness/std",
"oracle-randomness/std",
"pallet-game/std",
]
runtime-benchmarks = [
Expand All @@ -137,7 +137,7 @@ runtime-benchmarks = [
"pallet-faucet/runtime-benchmarks",
"pallet-game/runtime-benchmarks",
"pallet-faucet/runtime-benchmarks",
"game-randomness/runtime-benchmarks",
"oracle-randomness/runtime-benchmarks",
]
try-runtime = [
"frame-try-runtime/try-runtime",
Expand All @@ -159,4 +159,5 @@ try-runtime = [
"pallet-cache/try-runtime",
"pallet-faucet/try-runtime",
"pallet-game/try-runtime",
"oracle-randomness/try-runtime",
]
57 changes: 31 additions & 26 deletions gafi-node/runtime/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,10 @@
#[cfg(feature = "std")]
include!(concat!(env!("OUT_DIR"), "/wasm_binary.rs"));

use frame_support::{traits::AsEnsureOriginWithArg, PalletId};
use frame_support::{traits::AsEnsureOriginWithArg};
use pallet_grandpa::AuthorityId as GrandpaId;
use pallet_nfts::{weights::SubstrateWeight as NftsWeight, PalletFeatures};
use polkadot_runtime_common::SlowAdjustingFeeUpdate;
use sp_api::impl_runtime_apis;
use sp_consensus_aura::sr25519::AuthorityId as AuraId;
use sp_core::{crypto::KeyTypeId, OpaqueMetadata};
Expand All @@ -24,7 +25,6 @@ use sp_std::prelude::*;
#[cfg(feature = "std")]
use sp_version::NativeVersion;
use sp_version::RuntimeVersion;
use polkadot_runtime_common::SlowAdjustingFeeUpdate;
// A few exports that help ease life for downstream crates.
use codec::Encode;
pub use frame_support::{
Expand All @@ -43,6 +43,7 @@ pub use frame_support::{
};
pub use frame_system::Call as SystemCall;
use gafi_support::common::{unit, NativeToken::GAFI};
use oracle_randomness::SubstrateWeight as OracleRandomnessWeight;
pub use pallet_balances::Call as BalancesCall;
use pallet_game::SubstrateWeight as PalletGameWeight;
pub use pallet_timestamp::Call as TimestampCall;
Expand Down Expand Up @@ -389,7 +390,7 @@ impl pallet_nfts::Config for Runtime {
type MetadataDepositBase = ConstU128<1>;
type AttributeDepositBase = ConstU128<1>;
type DepositPerByte = ConstU128<1>;
type StringLimit = ConstU32<50>;
type StringLimit = ConstU32<300>;
type KeyLimit = ConstU32<50>;
type ValueLimit = ConstU32<50>;
type ApprovalsLimit = ConstU32<10>;
Expand All @@ -408,23 +409,6 @@ impl pallet_nfts::Config for Runtime {
type Helper = ();
}

parameter_types! {
pub PalletGameId: PalletId = PalletId(*b"gamernds");
pub RandomnessUnsignedPriority: u32 = 50;
pub RandomAttemps: u32 = 10;
pub UnsignedInterval: u32 = 1;
}

impl game_randomness::Config for Runtime {
type RuntimeEvent = RuntimeEvent;
type PalletId = PalletGameId;
type WeightInfo = ();
type Randomness = RandomnessCollectiveFlip;
type UnsignedPriority = RandomnessUnsignedPriority;
type RandomAttemps = RandomAttemps;
type UnsignedInterval = UnsignedInterval;
}

parameter_types! {
pub GameDeposit: u128 = 3 * unit(GAFI);
pub UpgradeDeposit: u128 = 1 * unit(GAFI);
Expand Down Expand Up @@ -463,11 +447,31 @@ impl pallet_game::Config for Runtime {
type MaxLoot = MaxLoot;
type MaxMintRequest = MaxMintRequest;
type MintInterval = MintInterval;
type GameRandomness = GameRandomness;
type GameRandomness = OracleRandomness;
#[cfg(feature = "runtime-benchmarks")]
type Helper = ();
}

parameter_types! {
pub OracleRandomAttemps: u32 = 5;
pub SeedLength: u32 = 64;
pub MaxRandomURL: u32 = 5;
pub RandomURLLength: u32 = 60;
pub OracleRandomnessUnsignedPriority: u32 = 50;
pub OracleRandomnessUnsignedInterval: u32 = 1;
}

impl oracle_randomness::Config for Runtime {
type RuntimeEvent = RuntimeEvent;
type WeightInfo = OracleRandomnessWeight<Runtime>;
type RandomAttemps = OracleRandomAttemps;
type SeedLength = SeedLength;
type MaxRandomURL = MaxRandomURL;
type RandomURLLength = RandomURLLength;
type UnsignedPriority = OracleRandomnessUnsignedPriority;
type UnsignedInterval = OracleRandomnessUnsignedInterval;
}

// Create the runtime by composing the FRAME pallets that were previously configured.
construct_runtime!(
pub struct Runtime {
Expand All @@ -486,7 +490,7 @@ construct_runtime!(
Faucet: pallet_faucet,
PalletCache: pallet_cache,
Game: pallet_game,
GameRandomness: game_randomness,
OracleRandomness: oracle_randomness,
}
);

Expand Down Expand Up @@ -718,14 +722,15 @@ impl_runtime_apis! {

use pallet_game::Pallet as GameBench;
use pallet_faucet::Pallet as FaucetBench;
use game_randomness::Pallet as GameRandomnessBench;
use oracle_randomness::Pallet as OracleRandomnessBench;


let mut list = Vec::<BenchmarkList>::new();
list_benchmarks!(list, extra);

list_benchmark!(list, extra, pallet_game, GameBench::<Runtime>);
list_benchmark!(list, extra, pallet_faucet, FaucetBench::<Runtime>);
list_benchmark!(list, extra, game_randomness, GameRandomnessBench::<Runtime>);
list_benchmark!(list, extra, oracle_randomness, OracleRandomnessBench::<Runtime>);

let storage_info = AllPalletsWithSystem::storage_info();

Expand All @@ -748,7 +753,7 @@ impl_runtime_apis! {

use pallet_game::Pallet as GameBench;
use pallet_faucet::Pallet as FaucetBench;
use game_randomness::Pallet as GameRandomnessBench;
use oracle_randomness::Pallet as OracleRandomnessBench;



Expand All @@ -757,7 +762,7 @@ impl_runtime_apis! {
add_benchmarks!(params, batches);
add_benchmark!(params, batches, pallet_game, GameBench::<Runtime>);
add_benchmark!(params, batches, pallet_faucet, FaucetBench::<Runtime>);
add_benchmark!(params, batches, game_randomness, GameRandomnessBench::<Runtime>);
add_benchmark!(params, batches, oracle_randomness, OracleRandomnessBench::<Runtime>);

Ok(batches)
}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
[package]
name = "game-randomness"
name = "offchain-worker-randomness"
description = "A pallet for dealing with randomness"
authors = { workspace = true }
license = { workspace = true }
Expand Down
Loading

0 comments on commit d1ac6ff

Please sign in to comment.