Skip to content

Commit 97720eb

Browse files
committed
Merge branch 'devnet-ready' into feat/proxy-precompile-extension
2 parents d581823 + 7e068e6 commit 97720eb

File tree

4 files changed

+94
-70
lines changed

4 files changed

+94
-70
lines changed

Cargo.lock

Lines changed: 24 additions & 24 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Cargo.toml

Lines changed: 22 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -166,32 +166,32 @@ sc-network-sync = { git = "https://github.com/paritytech/polkadot-sdk.git", tag
166166
substrate-prometheus-endpoint = { git = "https://github.com/paritytech/polkadot-sdk.git", tag = "polkadot-stable2409", default-features = false }
167167

168168
# Frontier
169-
fp-evm = { git = "https://github.com/gztensor/frontier", rev = "b9c606f9", default-features = false }
170-
fp-rpc = { git = "https://github.com/gztensor/frontier", rev = "b9c606f9", default-features = false }
171-
fp-self-contained = { git = "https://github.com/gztensor/frontier", rev = "b9c606f9", default-features = false, features = [
169+
fp-evm = { git = "https://github.com/opentensor/frontier", rev = "635bdac882", default-features = false }
170+
fp-rpc = { git = "https://github.com/opentensor/frontier", rev = "635bdac882", default-features = false }
171+
fp-self-contained = { git = "https://github.com/opentensor/frontier", rev = "635bdac882", default-features = false, features = [
172172
"serde",
173173
] }
174-
fp-account = { git = "https://github.com/gztensor/frontier", rev = "b9c606f9", default-features = false }
175-
fc-storage = { git = "https://github.com/gztensor/frontier", rev = "b9c606f9", default-features = false }
176-
fc-db = { git = "https://github.com/gztensor/frontier", rev = "b9c606f9", default-features = false }
177-
fc-consensus = { git = "https://github.com/gztensor/frontier", rev = "b9c606f9", default-features = false }
178-
fp-consensus = { git = "https://github.com/gztensor/frontier", rev = "b9c606f9", default-features = false }
179-
fp-dynamic-fee = { git = "https://github.com/gztensor/frontier", rev = "b9c606f9", default-features = false }
180-
fc-api = { git = "https://github.com/gztensor/frontier", rev = "b9c606f9", default-features = false }
181-
fc-rpc = { git = "https://github.com/gztensor/frontier", rev = "b9c606f9", default-features = false }
182-
fc-rpc-core = { git = "https://github.com/gztensor/frontier", rev = "b9c606f9", default-features = false }
183-
fc-mapping-sync = { git = "https://github.com/gztensor/frontier", rev = "b9c606f9", default-features = false }
174+
fp-account = { git = "https://github.com/opentensor/frontier", rev = "635bdac882", default-features = false }
175+
fc-storage = { git = "https://github.com/opentensor/frontier", rev = "635bdac882", default-features = false }
176+
fc-db = { git = "https://github.com/opentensor/frontier", rev = "635bdac882", default-features = false }
177+
fc-consensus = { git = "https://github.com/opentensor/frontier", rev = "635bdac882", default-features = false }
178+
fp-consensus = { git = "https://github.com/opentensor/frontier", rev = "635bdac882", default-features = false }
179+
fp-dynamic-fee = { git = "https://github.com/opentensor/frontier", rev = "635bdac882", default-features = false }
180+
fc-api = { git = "https://github.com/opentensor/frontier", rev = "635bdac882", default-features = false }
181+
fc-rpc = { git = "https://github.com/opentensor/frontier", rev = "635bdac882", default-features = false }
182+
fc-rpc-core = { git = "https://github.com/opentensor/frontier", rev = "635bdac882", default-features = false }
183+
fc-mapping-sync = { git = "https://github.com/opentensor/frontier", rev = "635bdac882", default-features = false }
184184

185185
# Frontier FRAME
186-
pallet-base-fee = { git = "https://github.com/gztensor/frontier", rev = "b9c606f9", default-features = false }
187-
pallet-dynamic-fee = { git = "https://github.com/gztensor/frontier", rev = "b9c606f9", default-features = false }
188-
pallet-ethereum = { git = "https://github.com/gztensor/frontier", rev = "b9c606f9", default-features = false }
189-
pallet-evm = { git = "https://github.com/gztensor/frontier", rev = "b9c606f9", default-features = false }
190-
pallet-evm-chain-id = { git = "https://github.com/gztensor/frontier", rev = "b9c606f9", default-features = false }
191-
pallet-evm-precompile-modexp = { git = "https://github.com/gztensor/frontier", rev = "b9c606f9", default-features = false }
192-
pallet-evm-precompile-sha3fips = { git = "https://github.com/gztensor/frontier", rev = "b9c606f9", default-features = false }
193-
pallet-evm-precompile-simple = { git = "https://github.com/gztensor/frontier", rev = "b9c606f9", default-features = false }
194-
pallet-hotfix-sufficients = { git = "https://github.com/gztensor/frontier", rev = "b9c606f9", default-features = false }
186+
pallet-base-fee = { git = "https://github.com/opentensor/frontier", rev = "635bdac882", default-features = false }
187+
pallet-dynamic-fee = { git = "https://github.com/opentensor/frontier", rev = "635bdac882", default-features = false }
188+
pallet-ethereum = { git = "https://github.com/opentensor/frontier", rev = "635bdac882", default-features = false }
189+
pallet-evm = { git = "https://github.com/opentensor/frontier", rev = "635bdac882", default-features = false }
190+
pallet-evm-chain-id = { git = "https://github.com/opentensor/frontier", rev = "635bdac882", default-features = false }
191+
pallet-evm-precompile-modexp = { git = "https://github.com/opentensor/frontier", rev = "635bdac882", default-features = false }
192+
pallet-evm-precompile-sha3fips = { git = "https://github.com/opentensor/frontier", rev = "635bdac882", default-features = false }
193+
pallet-evm-precompile-simple = { git = "https://github.com/opentensor/frontier", rev = "635bdac882", default-features = false }
194+
pallet-hotfix-sufficients = { git = "https://github.com/opentensor/frontier", rev = "635bdac882", default-features = false }
195195

196196
#DRAND
197197
pallet-drand = { path = "pallets/drand", default-features = false }

node/src/chain_spec/localnet.rs

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -120,5 +120,8 @@ fn localnet_genesis(
120120
"senateMembers": {
121121
"members": senate_members,
122122
},
123+
"evmChainId": {
124+
"chainId": 42,
125+
},
123126
})
124127
}

runtime/src/lib.rs

Lines changed: 45 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -1194,37 +1194,57 @@ parameter_types! {
11941194
/// The difference between EVM decimals and Substrate decimals.
11951195
/// Substrate balances has 9 decimals, while EVM has 18, so the
11961196
/// difference factor is 9 decimals, or 10^9
1197-
const EVM_DECIMALS_FACTOR: u64 = 1_000_000_000_u64;
1197+
const EVM_TO_SUBSTRATE_DECIMALS: u64 = 1_000_000_000_u64;
11981198

11991199
pub struct SubtensorEvmBalanceConverter;
12001200

12011201
impl BalanceConverter for SubtensorEvmBalanceConverter {
12021202
/// Convert from Substrate balance (u64) to EVM balance (U256)
12031203
fn into_evm_balance(value: U256) -> Option<U256> {
1204-
value
1205-
.checked_mul(U256::from(EVM_DECIMALS_FACTOR))
1206-
.and_then(|evm_value| {
1207-
// Ensure the result fits within the maximum U256 value
1208-
if evm_value <= U256::MAX {
1209-
Some(evm_value)
1210-
} else {
1211-
None
1212-
}
1213-
})
1204+
if let Some(evm_value) = value.checked_mul(U256::from(EVM_TO_SUBSTRATE_DECIMALS)) {
1205+
// Ensure the result fits within the maximum U256 value
1206+
if evm_value <= U256::MAX {
1207+
Some(evm_value)
1208+
} else {
1209+
// Log value too large
1210+
log::debug!(
1211+
"SubtensorEvmBalanceConverter::into_evm_balance( {:?} ) larger than U256::MAX",
1212+
value
1213+
);
1214+
None
1215+
}
1216+
} else {
1217+
// Log overflow
1218+
log::debug!(
1219+
"SubtensorEvmBalanceConverter::into_evm_balance( {:?} ) overflow",
1220+
value
1221+
);
1222+
None
1223+
}
12141224
}
12151225

12161226
/// Convert from EVM balance (U256) to Substrate balance (u64)
12171227
fn into_substrate_balance(value: U256) -> Option<U256> {
1218-
value
1219-
.checked_div(U256::from(EVM_DECIMALS_FACTOR))
1220-
.and_then(|substrate_value| {
1221-
// Ensure the result fits within the TAO balance type (u64)
1222-
if substrate_value <= U256::from(u64::MAX) {
1223-
Some(substrate_value)
1224-
} else {
1225-
None
1226-
}
1227-
})
1228+
if let Some(substrate_value) = value.checked_div(U256::from(EVM_TO_SUBSTRATE_DECIMALS)) {
1229+
// Ensure the result fits within the TAO balance type (u64)
1230+
if substrate_value <= U256::from(u64::MAX) {
1231+
Some(substrate_value)
1232+
} else {
1233+
// Log value too large
1234+
log::debug!(
1235+
"SubtensorEvmBalanceConverter::into_substrate_balance( {:?} ) larger than u64::MAX",
1236+
value
1237+
);
1238+
None
1239+
}
1240+
} else {
1241+
// Log overflow
1242+
log::debug!(
1243+
"SubtensorEvmBalanceConverter::into_substrate_balance( {:?} ) overflow",
1244+
value
1245+
);
1246+
None
1247+
}
12281248
}
12291249
}
12301250

@@ -2141,7 +2161,7 @@ fn test_into_substrate_balance_valid() {
21412161
#[test]
21422162
fn test_into_substrate_balance_large_value() {
21432163
// Maximum valid balance for u64
2144-
let evm_balance = U256::from(u64::MAX) * U256::from(EVM_DECIMALS_FACTOR); // Max u64 TAO in EVM
2164+
let evm_balance = U256::from(u64::MAX) * U256::from(EVM_TO_SUBSTRATE_DECIMALS); // Max u64 TAO in EVM
21452165
let expected_substrate_balance = U256::from(u64::MAX);
21462166

21472167
let result = SubtensorEvmBalanceConverter::into_substrate_balance(evm_balance);
@@ -2151,7 +2171,8 @@ fn test_into_substrate_balance_large_value() {
21512171
#[test]
21522172
fn test_into_substrate_balance_exceeds_u64() {
21532173
// EVM balance that exceeds u64 after conversion
2154-
let evm_balance = (U256::from(u64::MAX) + U256::from(1)) * U256::from(EVM_DECIMALS_FACTOR);
2174+
let evm_balance =
2175+
(U256::from(u64::MAX) + U256::from(1)) * U256::from(EVM_TO_SUBSTRATE_DECIMALS);
21552176

21562177
let result = SubtensorEvmBalanceConverter::into_substrate_balance(evm_balance);
21572178
assert_eq!(result, None); // Exceeds u64, should return None
@@ -2191,7 +2212,7 @@ fn test_into_evm_balance_valid() {
21912212
fn test_into_evm_balance_overflow() {
21922213
// Substrate balance larger than u64::MAX but valid within U256
21932214
let substrate_balance = U256::from(u64::MAX) + U256::from(1); // Large balance
2194-
let expected_evm_balance = substrate_balance * U256::from(EVM_DECIMALS_FACTOR);
2215+
let expected_evm_balance = substrate_balance * U256::from(EVM_TO_SUBSTRATE_DECIMALS);
21952216

21962217
let result = SubtensorEvmBalanceConverter::into_evm_balance(substrate_balance);
21972218
assert_eq!(result, Some(expected_evm_balance)); // Should return the scaled value

0 commit comments

Comments
 (0)