Skip to content

Commit 06ebb48

Browse files
Redeploy soneium host (#377)
Co-authored-by: David Salami <wizdave97@gmail.com>
1 parent ae881ff commit 06ebb48

File tree

15 files changed

+593
-175
lines changed

15 files changed

+593
-175
lines changed

Cargo.lock

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

Cargo.toml

+1-1
Original file line numberDiff line numberDiff line change
@@ -114,7 +114,7 @@ inherits = "release"
114114
lto = "thin"
115115

116116
[workspace.dependencies]
117-
polkadot-sdk = { version = "0.7.0", default-features = false }
117+
polkadot-sdk = { version = "0.9.0", default-features = false }
118118

119119
# crates that can't be used in polkadot-sdk
120120
sp-core = { version = "34.0.0", default-features = false }

docs/pages/developers/evm/contracts/mainnet.mdx

+6-6
Original file line numberDiff line numberDiff line change
@@ -79,12 +79,12 @@ The ISMP solidity contracts are deployed on the following networks:
7979
## Soneium
8080

8181

82-
| `IsmpHost` | [`0xc6b03c129a30241Ea6a572284Ff1e9fD5c534Cb3`](https://soneium.blockscout.com/address/0xc6b03c129a30241Ea6a572284Ff1e9fD5c534Cb3) |
82+
| `IsmpHost` | [`0x7F0165140D0f3251c8f6465e94E9d12C7FD40711`](https://soneium.blockscout.com/address/0x7F0165140D0f3251c8f6465e94E9d12C7FD40711) |
8383
|:------------|:-----|
84-
| `HandlerV1` | [`0x7DDBfE2bC9216f830d241f7AfDd52747826A8a74`](https://soneium.blockscout.com/address/0x7DDBfE2bC9216f830d241f7AfDd52747826A8a74) |
85-
| `ConsensusClient` | [`0x1BE0224FA90cAc24Fc57066b4C87EeDF78Ca79fF`](https://soneium.blockscout.com/address/0x1BE0224FA90cAc24Fc57066b4C87EeDF78Ca79fF) |
86-
| `HostManager` | [`0x8e88e8BEc14aAf69090c226320FeF36C8eF2F85f`](https://soneium.blockscout.com/address/0x8e88e8BEc14aAf69090c226320FeF36C8eF2F85f) |
84+
| `HandlerV1` | [`0x59AaE0639Afd39d98d000f3c1E2b69Da359F1Def`](https://soneium.blockscout.com/address/0x59AaE0639Afd39d98d000f3c1E2b69Da359F1Def) |
85+
| `ConsensusClient` | [`0x08F44d5Fe9e9d9dfB435876A93ad0ddF75B2d795`](https://soneium.blockscout.com/address/0x08F44d5Fe9e9d9dfB435876A93ad0ddF75B2d795) |
86+
| `HostManager` | [`0xA083b2cb3262a90ED1DfaB1695C9611537658f3C`](https://soneium.blockscout.com/address/0xA083b2cb3262a90ED1DfaB1695C9611537658f3C) |
8787
| `FeeToken (USDC.e)` | [`0xbA9986D2381edf1DA03B0B9c1f8b00dc4AacC369`](https://soneium.blockscout.com/address/0xbA9986D2381edf1DA03B0B9c1f8b00dc4AacC369) |
8888
| `UniswapV2` | `0x0000000000000000000000000000000000000000` |
89-
| `Inscriptions` | [`0x9251C6B5f4e2CEE34269400CBB43AD5C813606F6`](https://soneium.blockscout.com/address/0x9251C6B5f4e2CEE34269400CBB43AD5C813606F6) |
90-
| `TokenGateway` | [`0xFd413e3AFe560182C4471F4d143A96d3e259B6dE`](https://soneium.blockscout.com/address/0xFd413e3AFe560182C4471F4d143A96d3e259B6dE) |
89+
| `Inscriptions` | [`0x146998790F54675391fE7ebE0bD80706239D3E43`](https://soneium.blockscout.com/address/0x146998790F54675391fE7ebE0bD80706239D3E43) |
90+
| `TokenGateway` | [`0xCe304770236f39F9911BfCC51afBdfF3b8635718`](https://soneium.blockscout.com/address/0xCe304770236f39F9911BfCC51afBdfF3b8635718) |

evm/abi/src/generated/host_manager.rs

+2-2
Large diffs are not rendered by default.

evm/abi/src/generated/ping_module.rs

+2-2
Large diffs are not rendered by default.

evm/script/DeployIsmp.s.sol

+15-1
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ import {PingModule} from "../examples/PingModule.sol";
2424
import {BscHost} from "../src/hosts/Bsc.sol";
2525
import {PolygonHost} from "../src/hosts/Polygon.sol";
2626

27-
import {SP1Verifier} from "@sp1-contracts/v3.0.0/SP1VerifierGroth16.sol";
27+
import {SP1Verifier} from "@sp1-contracts/v4.0.0-rc.3/SP1VerifierGroth16.sol";
2828
import {SP1Beefy} from "../src/consensus/SP1Beefy.sol";
2929
import {BeefyV1} from "../src/consensus/BeefyV1.sol";
3030
import {StateMachine} from "@polytope-labs/ismp-solidity/StateMachine.sol";
@@ -84,6 +84,20 @@ contract DeployScript is BaseScript {
8484
// set the host address on the host manager
8585
manager.setIsmpHost(hostAddress);
8686

87+
// Set the consensus state
88+
EvmHost(payable(hostAddress)).setConsensusState(
89+
hex"",
90+
StateMachineHeight({
91+
stateMachineId: paraId,
92+
height: 1
93+
}),
94+
StateCommitment({
95+
timestamp: block.timestamp,
96+
overlayRoot: bytes32(0),
97+
stateRoot: bytes32(0)
98+
})
99+
);
100+
87101
vm.stopBroadcast();
88102
}
89103

evm/src/hosts/EvmHost.sol

+4-4
Original file line numberDiff line numberDiff line change
@@ -736,6 +736,10 @@ abstract contract EvmHost is IIsmpHost, IHostManager, Context {
736736
if (balance != 0) revert CannotChangeFeeToken();
737737
}
738738

739+
// safe to emit here because invariants have already been checked
740+
// and don't want to store a temp variable for the old params
741+
emit HostParamsUpdated({oldParams: _hostParams, newParams: params});
742+
739743
// update all but .perByteFees, sigh solidity
740744
_hostParams.defaultTimeout = params.defaultTimeout;
741745
_hostParams.defaultPerByteFee = params.defaultPerByteFee;
@@ -753,10 +757,6 @@ abstract contract EvmHost is IIsmpHost, IHostManager, Context {
753757
// Error: Unimplemented feature: Copying of type struct PerByteFee memory[] memory to storage not yet supported.
754758
// _hostParams.perByteFees = params.perByteFees;
755759

756-
// safe to emit here because invariants have already been checked
757-
// and don't want to store a temp variable for the old params
758-
emit HostParamsUpdated({oldParams: _hostParams, newParams: params});
759-
760760
// Add the new per byte fees
761761
uint256 len = params.perByteFees.length;
762762
for (uint256 i = 0; i < len; ++i) {

evm/test/SP1BeefyTest.sol

+25
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,31 @@ contract SP1BeefyTest is Test {
2727
sp1 = new SP1Verifier();
2828
}
2929

30+
function testDecodeConsensusState() public view {
31+
bytes memory encodedState = hex"0000000000000000000000000000000000000000000000000000000001771a6a00000000000000000000000000000000000000000000000000000000012a5318000000000000000000000000000000000000000000000000000000000000083a00000000000000000000000000000000000000000000000000000000000001f442c444bf993527f25cdeb8cca93b6632fbcacb30cf3e037748e5ca8f39ef9ade000000000000000000000000000000000000000000000000000000000000083b00000000000000000000000000000000000000000000000000000000000001f442c444bf993527f25cdeb8cca93b6632fbcacb30cf3e037748e5ca8f39ef9ade";
32+
33+
BeefyConsensusState memory consensusState = abi.decode(encodedState, (BeefyConsensusState));
34+
35+
36+
console.log("latestHeight: ");
37+
console.log(consensusState.latestHeight);
38+
39+
console.log("currentAuthoritySet.id: ");
40+
console.log(consensusState.currentAuthoritySet.id);
41+
console.log("currentAuthoritySet.len: ");
42+
console.log(consensusState.currentAuthoritySet.len);
43+
console.log("currentAuthoritySet.root: ");
44+
console.logBytes32(consensusState.currentAuthoritySet.root);
45+
46+
console.log("nextAuthoritySet.id: ");
47+
console.log(consensusState.nextAuthoritySet.id);
48+
console.log("nextAuthoritySet.len: ");
49+
console.log(consensusState.nextAuthoritySet.len);
50+
console.log("nextAuthoritySet.root: ");
51+
console.logBytes32(consensusState.nextAuthoritySet.root);
52+
53+
}
54+
3055
function testPolkadotVerifier() public view {
3156
bytes
3257
memory proof = hex"11b6a09d0602783a739ff23a34879d0f31c9742293407605ad35b2ab9f2112445436251c2929a1f895ee9c0a7185734a57da30feaa42de756ef44ac2383ad0146f525ed41ea56e5485fe3d329cec126256c2c19918560e93fea6e69d6c1287aba55359e020f8368e1be185cabcaf87407e6e700be708bb4f0e3d800fea43e7e06f95d8a7141f29d97bbdec0ead4c051dc1a8ff931bf470e7f48bf8edba580d1a1e7f93bf2c7fc4b3124ccbbcaa0cb0243a3be77001d71fc4eb020bfce79d88ce520a9cf611b8032714b5f7429e0bd89c76474f67e0b8f02c0a1cc9fd3cbc8fdf6039a89904236d309f7153c388b5c66d5e5bdc484f4272b71aa246b121bbac05fd50bbe5";

modules/pallets/token-gateway/Cargo.toml

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
[package]
22
name = "pallet-token-gateway"
3-
version = "16.0.0"
3+
version = "16.1.0"
44
edition = "2021"
55
description = "A substrate implementation of the token gateway protocol"
66
authors = ["Polytope Labs <hello@polytope.technology>"]

modules/pallets/token-gateway/primitives/src/lib.rs

-4
Original file line numberDiff line numberDiff line change
@@ -41,10 +41,6 @@ pub struct AssetMetadata {
4141
pub name: BoundedVec<u8, ConstU32<50>>,
4242
/// The asset symbol
4343
pub symbol: BoundedVec<u8, ConstU32<20>>,
44-
/// The asset decimals of the ERC6160 or ERC20 counterpart of this asset
45-
pub decimals: u8,
46-
/// Asset's minimum balance, only used by substrate chains
47-
pub minimum_balance: Option<u128>,
4844
}
4945

5046
/// A struct for deregistering asset id on pallet-token-gateway

modules/pallets/token-gateway/src/lib.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -108,7 +108,7 @@ pub mod pallet {
108108

109109
/// Fungible asset implementation
110110
type Assets: fungibles::Mutate<Self::AccountId>
111-
+ fungibles::metadata::Mutate<Self::AccountId>;
111+
+ fungibles::metadata::Inspect<Self::AccountId>;
112112

113113
/// The native asset ID
114114
type NativeAssetId: Get<AssetId<Self>>;

modules/pallets/token-governor/src/impls.rs

+21-45
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,6 @@
1717

1818
use alloc::{collections::BTreeMap, vec};
1919
use alloy_sol_types::SolValue;
20-
use codec::Encode;
2120
use frame_support::{ensure, PalletId};
2221
use frame_system::{pallet_prelude::OriginFor, RawOrigin};
2322
use ismp::{
@@ -37,7 +36,7 @@ use crate::{
3736
TokenGatewayRequest, TokenRegistrarParams, UnsignedERC6160AssetRegistration, PALLET_ID,
3837
};
3938

40-
use token_gateway_primitives::{AssetMetadata, PALLET_TOKEN_GATEWAY_ID};
39+
use token_gateway_primitives::AssetMetadata;
4140

4241
impl<T: Config> Pallet<T>
4342
where
@@ -69,16 +68,11 @@ where
6968
Err(Error::<T>::AssetAlreadyExists)?
7069
}
7170

72-
let metadata = AssetMetadata {
73-
name: asset.name.clone(),
74-
symbol: asset.symbol.clone(),
75-
decimals: 18,
76-
minimum_balance: asset.minimum_balance,
77-
};
71+
let metadata = AssetMetadata { name: asset.name.clone(), symbol: asset.symbol.clone() };
7872

7973
for ChainWithSupply { chain, supply } in asset.chains.clone() {
8074
let address = if chain.is_substrate() {
81-
H160(PALLET_TOKEN_GATEWAY_ID)
75+
continue;
8276
} else {
8377
let GatewayParams { address, .. } = TokenGatewayParams::<T>::get(&chain)
8478
.ok_or_else(|| Error::<T>::UnknownTokenGateway)?;
@@ -93,9 +87,7 @@ where
9387
from: PALLET_ID.to_vec(),
9488
to: address.as_bytes().to_vec(),
9589
timeout: 0,
96-
body: if chain.is_substrate() {
97-
metadata.encode()
98-
} else {
90+
body: {
9991
let mut body: SolAssetMetadata =
10092
metadata.clone().try_into().map_err(|_| Error::<T>::InvalidUtf8)?;
10193

@@ -165,17 +157,13 @@ where
165157

166158
for ChainWithSupply { chain, supply } in update.add_chains {
167159
// skip if it already was dispatched to the provided chain
168-
if SupportedChains::<T>::get(&update.asset_id, &chain).is_some() {
160+
if SupportedChains::<T>::get(&update.asset_id, &chain).is_some() || chain.is_substrate()
161+
{
169162
continue;
170163
}
171164

172-
let address = if chain.is_substrate() {
173-
H160(PALLET_TOKEN_GATEWAY_ID)
174-
} else {
175-
let GatewayParams { address, .. } = TokenGatewayParams::<T>::get(&chain)
176-
.ok_or_else(|| Error::<T>::UnknownTokenGateway)?;
177-
address
178-
};
165+
let GatewayParams { address, .. } = TokenGatewayParams::<T>::get(&chain)
166+
.ok_or_else(|| Error::<T>::UnknownTokenGateway)?;
179167

180168
dispatcher
181169
.dispatch_request(
@@ -184,9 +172,7 @@ where
184172
from: PALLET_ID.to_vec(),
185173
to: address.as_bytes().to_vec(),
186174
timeout: 0,
187-
body: if chain.is_substrate() {
188-
metadata.encode()
189-
} else {
175+
body: {
190176
let mut body: SolAssetMetadata =
191177
metadata.clone().try_into().map_err(|_| Error::<T>::InvalidUtf8)?;
192178

@@ -207,17 +193,13 @@ where
207193

208194
for chain in update.remove_chains {
209195
// skip if it already was dispatched to the provided chain
210-
if SupportedChains::<T>::get(&update.asset_id, &chain).is_none() {
196+
if SupportedChains::<T>::get(&update.asset_id, &chain).is_none() || chain.is_substrate()
197+
{
211198
continue;
212199
}
213200

214-
let address = if chain.is_substrate() {
215-
H160(PALLET_TOKEN_GATEWAY_ID)
216-
} else {
217-
let GatewayParams { address, .. } = TokenGatewayParams::<T>::get(&chain)
218-
.ok_or_else(|| Error::<T>::UnknownTokenGateway)?;
219-
address
220-
};
201+
let GatewayParams { address, .. } = TokenGatewayParams::<T>::get(&chain)
202+
.ok_or_else(|| Error::<T>::UnknownTokenGateway)?;
221203

222204
dispatcher
223205
.dispatch_request(
@@ -226,12 +208,7 @@ where
226208
from: PALLET_ID.to_vec(),
227209
to: address.as_bytes().to_vec(),
228210
timeout: 0,
229-
body: if chain.is_substrate() {
230-
token_gateway_primitives::DeregisterAssets {
231-
asset_ids: vec![update.asset_id],
232-
}
233-
.encode()
234-
} else {
211+
body: {
235212
let body =
236213
SolDeregsiterAsset { assetIds: vec![update.asset_id.0.into()] };
237214
body.encode_request()
@@ -247,7 +224,8 @@ where
247224

248225
for (chain, admin) in update.new_admins {
249226
// skip if it doesn't exist on the provided chain
250-
if SupportedChains::<T>::get(&update.asset_id, &chain).is_none() {
227+
if SupportedChains::<T>::get(&update.asset_id, &chain).is_none() || chain.is_substrate()
228+
{
251229
continue;
252230
}
253231

@@ -397,15 +375,13 @@ where
397375
Err(Error::<T>::AssetAlreadyExists)?
398376
}
399377

400-
let mut metadata = AssetMetadata {
401-
name: asset.name.clone(),
402-
symbol: asset.symbol.clone(),
403-
..Default::default()
404-
};
378+
let metadata = AssetMetadata { name: asset.name.clone(), symbol: asset.symbol.clone() };
405379

406-
for AssetRegistration { chain, erc20, erc6160, decimals } in asset.chains {
380+
for AssetRegistration { chain, erc20, erc6160 } in asset.chains {
381+
if chain.is_substrate() {
382+
continue;
383+
}
407384
// Set the parent ERC20 asset's decimals value
408-
metadata.decimals = decimals;
409385
let mut body: SolAssetMetadata =
410386
metadata.clone().try_into().map_err(|_| Error::<T>::InvalidUtf8)?;
411387

modules/pallets/token-governor/src/lib.rs

+22
Original file line numberDiff line numberDiff line change
@@ -164,6 +164,8 @@ pub mod pallet {
164164
},
165165
/// Native asset IDs have been deregistered
166166
NativeAssetsDeregistered { assets: BTreeMap<StateMachine, BTreeSet<H256>> },
167+
/// Native asset IDs have been registered
168+
NativeAssetsRegistered { assets: BTreeMap<StateMachine, BTreeSet<H256>> },
167169
}
168170

169171
/// Errors that can be returned by this pallet.
@@ -350,6 +352,26 @@ pub mod pallet {
350352

351353
Ok(())
352354
}
355+
356+
/// Register the native token asset ids for standalone chains
357+
#[pallet::call_index(9)]
358+
#[pallet::weight(weight())]
359+
pub fn register_standalone_chain_native_assets(
360+
origin: OriginFor<T>,
361+
assets: BTreeMap<StateMachine, BTreeSet<H256>>,
362+
) -> DispatchResult {
363+
T::AdminOrigin::ensure_origin(origin)?;
364+
365+
for (state_machine, new_asset_ids) in assets.clone() {
366+
new_asset_ids
367+
.into_iter()
368+
.for_each(|id| StandaloneChainAssets::<T>::insert(state_machine, id, true))
369+
}
370+
371+
Self::deposit_event(Event::<T>::NativeAssetsRegistered { assets });
372+
373+
Ok(())
374+
}
353375
}
354376

355377
/// This allows users to create assets from any chain using the TokenRegistrar.

modules/pallets/token-governor/src/types.rs

-4
Original file line numberDiff line numberDiff line change
@@ -140,8 +140,6 @@ pub struct ERC20AssetRegistration {
140140
pub symbol: BoundedVec<u8, ConstU32<20>>,
141141
/// Chains to support as well as the current ERC20 address on that chain
142142
pub chains: Vec<AssetRegistration>,
143-
/// Minimum balance for the asset, for substrate chains,
144-
pub minimum_balance: Option<u128>,
145143
}
146144

147145
#[derive(Debug, Clone, Encode, Decode, scale_info::TypeInfo, PartialEq, Eq)]
@@ -152,8 +150,6 @@ pub struct AssetRegistration {
152150
pub erc20: Option<H160>,
153151
/// Optional ERC6160 address
154152
pub erc6160: Option<H160>,
155-
/// Current decimals value of the Erc20 asset on it's parent chain
156-
pub decimals: u8,
157153
}
158154

159155
/// Protocol Parameters for the TokenRegistrar contract

parachain/runtimes/nexus/src/lib.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -221,7 +221,7 @@ pub const VERSION: RuntimeVersion = RuntimeVersion {
221221
spec_name: create_runtime_str!("nexus"),
222222
impl_name: create_runtime_str!("nexus"),
223223
authoring_version: 1,
224-
spec_version: 2_300,
224+
spec_version: 2_400,
225225
impl_version: 0,
226226
apis: RUNTIME_API_VERSIONS,
227227
transaction_version: 1,

0 commit comments

Comments
 (0)