Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Alpha launch chainspec #870

Merged
merged 12 commits into from
Dec 16, 2024
259 changes: 245 additions & 14 deletions rollup/node/src/chain_spec.rs
Original file line number Diff line number Diff line change
@@ -1,9 +1,10 @@
use crate::command::{EvmChain, InitialSequencersSet};
use frame_benchmarking::benchmarking::current_time;
use rand::{thread_rng, Rng};
use rollup_runtime::{
config::orml_asset_registry::AssetMetadataOf, tokens::RX_TOKEN_ID, AccountId, AuraConfig,
CustomMetadata, GrandpaConfig, L1Asset, RuntimeGenesisConfig, Signature, SudoConfig,
SystemConfig, XcmMetadata, WASM_BINARY,
config::orml_asset_registry::AssetMetadataOf, currency, tokens::RX_TOKEN_ID, AccountId,
AuraConfig, CustomMetadata, GrandpaConfig, L1Asset, RuntimeGenesisConfig, Signature,
SudoConfig, SystemConfig, XcmMetadata, WASM_BINARY,
};
use sc_service::ChainType;
use sp_consensus_aura::sr25519::AuthorityId as AuraId;
Expand Down Expand Up @@ -138,7 +139,7 @@ pub fn rollup_local_config(
.iter()
.flatten()
.cloned()
.map(|account_id| (0u32, 300_000_000__000_000_000_000_000_000u128, account_id))
.map(|account_id| (0u32, 100u128 * currency::DOLLARS, account_id))
.collect::<Vec<_>>();

rollup_genesis(
Expand Down Expand Up @@ -241,6 +242,222 @@ pub fn rollup_local_config(
)
}

pub fn ethereum_mainnet(decode_url: Option<String>) -> ChainSpec {
let (_gasp_token_address, eth_chain_id) = ([0u8; 20], 1u64);
let chain_genesis_salt_arr: [u8; 32] =
hex_literal::hex!("0011001100110011001100110011001100110011001100110011001100110011");

let collator01 = hex_literal::hex!("b9fcA08B9cA327a1dE90FDB4d51aa5ae6Ffe512a");
let collator01_sr25519 =
hex_literal::hex!("b6bcce45d0431d7cf3b23cf270e60fab48290cc2e129a62bcac04f6eab20e61f");
let collator01_ed25519 =
hex_literal::hex!("efc45e2afccbe0f53cab042438aebb6bcfc78585625c2a1b5517f3b258dd1cf8");

let collator02 = hex_literal::hex!("1f4E3f24d1ad7fE108c6eB3BA6F83ebe8cF0eD20");
let collator02_sr25519 =
hex_literal::hex!("860a476d36782b7e2854ab4e93287e67618a835741b84bd7cad0740a83275f3c");
let collator02_ed25519 =
hex_literal::hex!("2227445cd1b97943e1ba5c3cf3a94cadabd4494ff4394667be13ff755bae1abe");

let collator03 = hex_literal::hex!("7F7c7b782fBdAd01Fe33ca8FC647c867ee29deD2");
let collator03_sr25519 =
hex_literal::hex!("4899a218a591b9345b92de354b4d251eabd205bc64c787386fdccfe1f2147625");
let collator03_ed25519 =
hex_literal::hex!("d59387884193c920e0cef94770d74cc2cef0d534b1ebf5a5d1eb5033fb58746a");

let collator04 = hex_literal::hex!("4691A9BB90e20a7708182fD881fb723f9845460E");
let collator04_sr25519 =
hex_literal::hex!("b0c2a16a1acecd3e05a243d9bf8881f5d64a70b40864701dba01cfd1ee53c85a");
let collator04_ed25519 =
hex_literal::hex!("172165647a152929e2bb0af97f55ea0c0deaa087479be8eab7448c2dc8cd0dfe");

let sudo = hex_literal::hex!("E73e1Bb7B07f6bf447ED71252A5ad08C7ebE5bE5");

// Give your base currency a unit name and decimal places
let mut properties = sc_chain_spec::Properties::new();
properties.insert("tokenSymbol".into(), "GASP".into());
properties.insert("tokenDecimals".into(), 18u32.into());
properties.insert("ss58Format".into(), 42u32.into());
properties.insert("isEthereum".into(), true.into());
// This is quite useless here :/
properties.insert(
"chainGenesisSalt".into(),
array_bytes::bytes2hex("0x", chain_genesis_salt_arr).into(),
);

let decode_url = decode_url.expect("polkadot url is provided");
// todo builder
ChainSpec::from_genesis(
// Name
"Mainnet",
// ID
"mainnet",
ChainType::Live,
move || {
let eth_sequencers: Vec<AccountId> = vec![
hex_literal::hex!("dFD7f828689FbF00995BAA40d2DE93Eb400Cf60b").into(),
hex_literal::hex!("88bbb08aF77987D86E9559491fE7cC5910D68f2D").into(),
hex_literal::hex!("8d3CD208aa5592CF510eB24D8a2376bbF840bb63").into(),
];
let arb_sequencers: Vec<AccountId> = vec![
hex_literal::hex!("b67CB37E9d114731B5624B6E919c007f4ddEa582").into(),
hex_literal::hex!("71403bFc37f031b60BD7a5B9597115708E391410").into(),
hex_literal::hex!("25CeF43c3F52db02ae52D951936b390C4B6A998F").into(),
];
let base_sequencers: Vec<AccountId> = vec![
hex_literal::hex!("A395bBE2de17B488a578b972D96EE38933eE3c85").into(),
hex_literal::hex!("6f52f2D60AdFC152ac561287b754A56A7933F1ae").into(),
hex_literal::hex!("a7196AF761942A10126165B2c727eFCD46c254e0").into(),
];

let sequencers_endownment =
[eth_sequencers.clone(), arb_sequencers.clone(), base_sequencers.clone()]
.iter()
.flatten()
.cloned()
.map(|account_id| (0u32, 100u128 * currency::DOLLARS, account_id))
.collect::<Vec<_>>();

let tokens_endowment = sequencers_endownment;

rollup_genesis(
// chain genesis salt
H256::from(chain_genesis_salt_arr),
// initial collators.
vec![
(
collator01.into(),
(
AuraId::from_slice(collator01_sr25519.as_slice()).unwrap(),
GrandpaId::from_slice(collator01_ed25519.as_slice()).unwrap(),
),
),
(
collator02.into(),
(
AuraId::from_slice(collator02_sr25519.as_slice()).unwrap(),
GrandpaId::from_slice(collator02_ed25519.as_slice()).unwrap(),
),
),
(
collator03.into(),
(
AuraId::from_slice(collator03_sr25519.as_slice()).unwrap(),
GrandpaId::from_slice(collator03_ed25519.as_slice()).unwrap(),
),
),
(
collator04.into(),
(
AuraId::from_slice(collator04_sr25519.as_slice()).unwrap(),
GrandpaId::from_slice(collator04_ed25519.as_slice()).unwrap(),
),
),
],
// Sudo account
sudo.into(),
// Tokens endowment
tokens_endowment,
// Config for Staking
// Make sure it works with initial-authorities as staking uses both
(
vec![
(
// Who gets to stake initially
collator01.into(),
// Id of MGA token,
0u32,
// How much mangata they stake
2__000_000u128 * currency::DOLLARS,
),
(
// Who gets to stake initially
collator02.into(),
// Id of MGA token,
0u32,
// How much mangata they stake
2__000_000u128 * currency::DOLLARS,
),
(
// Who gets to stake initially
collator03.into(),
// Id of MGA token,
0u32,
// How much mangata they stake
2__000_000u128 * currency::DOLLARS,
),
(
// Who gets to stake initially
collator04.into(),
// Id of MGA token,
0u32,
// How much mangata they stake
2__000_000u128 * currency::DOLLARS,
),
],
vec![
// Who gets to stake initially
// Id of MGA token,
// How much mangata they pool
// Id of the dummy token,
// How many dummy tokens they pool,
// Id of the liquidity token that is generated
// How many liquidity tokens they stake,
],
),
vec![
(
RX_TOKEN_ID,
AssetMetadataOf {
decimals: 18,
name: BoundedVec::truncate_from(b"Gasp".to_vec()),
symbol: BoundedVec::truncate_from(b"GASP".to_vec()),
additional: Default::default(),
existential_deposit: Default::default(),
},
Some(L1Asset::Ethereum(hex_literal::hex!(
"0000000000000000000000000000000000000000"
))),
),
(
1,
AssetMetadataOf {
decimals: 18,
name: BoundedVec::truncate_from(b"Gasp Ethereum".to_vec()),
symbol: BoundedVec::truncate_from(b"GETH".to_vec()),
additional: Default::default(),
existential_deposit: Default::default(),
},
Some(L1Asset::Ethereum(
array_bytes::hex2array("0x0000000000000000000000000000000000000001")
.unwrap(),
)),
),
],
eth_sequencers,
arb_sequencers,
base_sequencers,
eth_chain_id,
decode_url.clone(),
)
},
// Bootnodes
Vec::new(),
// Telemetry
None,
// Protocol ID
None,
// ForkId
None,
// Properties
Some(properties),
// Extensions
None,
// code
rollup_runtime::WASM_BINARY.expect("WASM binary was not build, please build it!"),
)
}

/// Configure initial storage state for FRAME modules.
fn rollup_genesis(
chain_genesis_salt: H256,
Expand Down Expand Up @@ -365,8 +582,8 @@ fn rollup_genesis(
},
fee_lock: rollup_runtime::FeeLockConfig {
period_length: Some(10),
fee_lock_amount: Some(50__000_000_000_000_000_000u128),
swap_value_threshold: Some(1000__000_000_000_000_000_000u128),
fee_lock_amount: Some(50u128 * currency::DOLLARS),
swap_value_threshold: Some(50u128 * currency::DOLLARS),
whitelisted_tokens: Default::default(),
},
council: Default::default(),
Expand All @@ -387,20 +604,34 @@ fn rollup_genesis(
},
vesting: Default::default(),
sequencer_staking: rollup_runtime::SequencerStakingConfig {
minimal_stake_amount: 1_000_000_u128,
slash_fine_amount: 100_000_u128,
minimal_stake_amount: 100u128 * currency::DOLLARS,
slash_fine_amount: 1u128 * currency::DOLLARS,
sequencers_stake: [
eth_initial_sequencers
.into_iter()
.map(|seq| (seq, pallet_rolldown::messages::Chain::Ethereum, 10_000_000_u128))
.map(|seq| {
(
seq,
pallet_rolldown::messages::Chain::Ethereum,
100u128 * currency::DOLLARS,
)
})
.collect::<Vec<_>>(),
arb_initial_sequencers
.into_iter()
.map(|seq| (seq, pallet_rolldown::messages::Chain::Arbitrum, 10_000_000_u128))
.map(|seq| {
(
seq,
pallet_rolldown::messages::Chain::Arbitrum,
100u128 * currency::DOLLARS,
)
})
.collect::<Vec<_>>(),
base_initial_sequencers
.into_iter()
.map(|seq| (seq, pallet_rolldown::messages::Chain::Base, 10_000_000_u128))
.map(|seq| {
(seq, pallet_rolldown::messages::Chain::Base, 100u128 * currency::DOLLARS)
})
.collect::<Vec<_>>(),
]
.iter()
Expand All @@ -412,9 +643,9 @@ fn rollup_genesis(
rolldown: rollup_runtime::RolldownConfig {
_phantom: Default::default(),
dispute_periods: [
(pallet_rolldown::messages::Chain::Ethereum, 300u128),
(pallet_rolldown::messages::Chain::Arbitrum, 600u128),
(pallet_rolldown::messages::Chain::Base, 600u128),
(pallet_rolldown::messages::Chain::Ethereum, 200u128),
(pallet_rolldown::messages::Chain::Arbitrum, 200u128),
(pallet_rolldown::messages::Chain::Base, 200u128),
]
.iter()
.cloned()
Expand Down
2 changes: 2 additions & 0 deletions rollup/node/src/command.rs
Original file line number Diff line number Diff line change
Expand Up @@ -106,6 +106,8 @@ impl SubstrateCli for Cli {
"holesky" => Box::new(chain_spec::rollup_local_config(self.randomize_chain_genesis_salt, self.chain_genesis_salt.clone(), eth_sequencers, arb_sequencers, base_sequencers, EvmChain::Holesky,
Some(String::from("https://polkadot.js.org/apps/?rpc=wss%3A%2F%2Frollup-holesky-rpc.gasp.xyz#/extrinsics/decode/"))
)),
"ethereum-mainnet" => Box::new(chain_spec::ethereum_mainnet( Some(String::from("https://polkadot.js.org/apps/?rpc=wss%3A%2F%2Frollup-holesky-rpc.gasp.xyz#/extrinsics/decode/"))
mateuszaaa marked this conversation as resolved.
Show resolved Hide resolved
)),
path =>
Box::new(chain_spec::ChainSpec::from_json_file(std::path::PathBuf::from(path))?),
})
Expand Down
2 changes: 1 addition & 1 deletion rollup/runtime/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -813,7 +813,7 @@ impl pallet_sequencer_staking::Config for Runtime {
type MinimumSequencers = frame_support::traits::ConstU32<2>;
type RolldownProvider = Rolldown;
type NoOfPastSessionsForEligibility = frame_support::traits::ConstU32<10>;
type MaxSequencers = frame_support::traits::ConstU32<10>;
type MaxSequencers = frame_support::traits::ConstU32<3>;
type BlocksForSequencerUpdate = frame_support::traits::ConstU32<10>;
type CancellerRewardPercentage = cfg::pallet_sequencer_staking::CancellerRewardPercentage;
type ChainId = pallet_rolldown::messages::Chain;
Expand Down
14 changes: 7 additions & 7 deletions rollup/runtime/src/runtime_config.rs
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@ pub mod tokens {
pub const RxTokenId: TokenId = RX_TOKEN_ID;
pub const EthTokenId: TokenId = ETH_TOKEN_ID;
pub ArbitrageBotAddr: AccountId = sp_runtime::AccountId20::from(
hex_literal::hex!["fc741134c82b81b7ab7efbf334b0c90ff8dbf22c"]
hex_literal::hex!["0286Ffa54213778E064179E9B6F083ecb584E862"]
);
}
}
Expand Down Expand Up @@ -980,7 +980,7 @@ pub mod config {
1 * currency::DOLLARS
} else {
// ACTUAL
1_500_000 * currency::DOLLARS
1_000_000 * currency::DOLLARS
};
/// Minimum stake required to be reserved to be a delegator
pub const MinDelegatorStk: u128 = 1 * currency::CENTS;
Expand Down Expand Up @@ -1323,17 +1323,17 @@ pub mod config {

#[cfg(not(feature = "fast-runtime"))]
parameter_types! {
pub const MerkleRootAutomaticBatchPeriod: u128 = 1200;
pub const MerkleRootAutomaticBatchSize: u128 = 1024;
pub const MerkleRootAutomaticBatchPeriod: u128 = 600;
pub const MerkleRootAutomaticBatchSize: u128 = 500;
}

pub struct WithdrawFee;
impl Convert<::pallet_rolldown::messages::Chain, Balance> for WithdrawFee {
fn convert(chain: ::pallet_rolldown::messages::Chain) -> Balance {
match chain {
::pallet_rolldown::messages::Chain::Ethereum => 50 * currency::DOLLARS,
::pallet_rolldown::messages::Chain::Arbitrum => 50 * currency::DOLLARS,
::pallet_rolldown::messages::Chain::Base => 50 * currency::DOLLARS,
::pallet_rolldown::messages::Chain::Ethereum => 5 * currency::DOLLARS,
::pallet_rolldown::messages::Chain::Arbitrum => 5 * currency::DOLLARS,
::pallet_rolldown::messages::Chain::Base => 5 * currency::DOLLARS,
}
}
}
Expand Down
Loading