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

Implement solidity codecs on xcm::latest #1614

Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 5 additions & 1 deletion precompiles/src/solidity/codec/xcm.rs
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ use alloc::{string::String, vec::Vec};
use frame_support::{ensure, traits::ConstU32};
use sp_core::H256;
use sp_weights::Weight;
use xcm::lts::{Junction, Junctions, Location, NetworkId};
use xcm::latest::{Junction, Junctions, Location, NetworkId};

use crate::solidity::{
codec::{bytes::*, Codec, Reader, Writer},
Expand Down Expand Up @@ -76,6 +76,7 @@ pub(crate) fn network_id_to_bytes(network_id: Option<NetworkId>) -> Vec<u8> {
encoded.append(&mut block_hash.into());
encoded
}
/*
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This code commented can be removed entirely.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Addressed in 1217ef1

Some(NetworkId::Westend) => {
encoded.push(5u8);
encoded.push(4u8);
Expand All @@ -91,6 +92,7 @@ pub(crate) fn network_id_to_bytes(network_id: Option<NetworkId>) -> Vec<u8> {
encoded.push(6u8);
encoded
}
*/
Some(NetworkId::Ethereum { chain_id }) => {
encoded.push(8u8);
encoded.push(7u8);
Expand Down Expand Up @@ -152,9 +154,11 @@ pub(crate) fn network_id_from_bytes(encoded_bytes: Vec<u8>) -> MayRevert<Option<
block_hash,
}))
}
/*
5 => Ok(Some(NetworkId::Westend)),
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
5 => Ok(Some(NetworkId::Westend)),
5 => Ok(Some(NetworkId::ByGenesis(WESTEND_GENESIS_HASH))),

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Addressed in 7f7d587

6 => Ok(Some(NetworkId::Rococo)),
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
6 => Ok(Some(NetworkId::Rococo)),
6 => Ok(Some(NetworkId::ByGenesis(ROCOCO_GENESIS_HASH))),

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Addressed in 7f7d587

7 => Ok(Some(NetworkId::Wococo)),
Copy link
Contributor

@RomarQ RomarQ Feb 19, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Here, we can return an error

Suggested change
7 => Ok(Some(NetworkId::Wococo)),
7 => Err(RevertReason::custom("Wococo Network is no longer supported").into()),

or

Suggested change
7 => Ok(Some(NetworkId::Wococo)),
7 => Ok(Some(NetworkId::ByGenesis(DUMMY_GENESIS_HASH))),

As done here: paritytech/polkadot-sdk@81c420d

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Addressed in 7f7d587

*/
8 => {
let mut chain_id: [u8; 8] = Default::default();
chain_id.copy_from_slice(encoded_network_id.read_raw_bytes(8)?);
Expand Down
Loading