Skip to content

Commit

Permalink
Paseo Support (#168)
Browse files Browse the repository at this point in the history
Co-authored-by: David Salami <[email protected]>
  • Loading branch information
seunlanlege and Wizdave97 authored Apr 15, 2024
1 parent 46aac63 commit 313e891
Show file tree
Hide file tree
Showing 39 changed files with 67,830 additions and 11,163 deletions.
11 changes: 5 additions & 6 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,6 @@ on:
- main
pull_request_target:
types: [ opened, synchronize ]
pull_request:
branches:
- main

concurrency:
group: ci-${{ github.head_ref || github.ref_name }}
Expand Down Expand Up @@ -263,9 +260,11 @@ jobs:
# install polkadot binary
cd ../
mkdir -p polkadot-sdk/target/release
wget -O ./polkadot.tar.gz -q --show-progress 'https://dl.dropbox.com/scl/fi/onsvsex4w9vf5vghqe23j/polkadot.tar.gz?rlkey=17e3gq0n82v8hhar4nzlynruu&dl=0'
tar xvzf ./polkadot.tar.gz
mv bins/* polkadot-sdk/target/release
cd polkadot-sdk/target/release
wget -O ./polkadot -q --show-progress 'https://github.com/paritytech/polkadot-sdk/releases/download/polkadot-v1.10.0/polkadot'
wget -O ./polkadot-execute-worker -q --show-progress 'https://github.com/paritytech/polkadot-sdk/releases/download/polkadot-v1.10.0/polkadot-execute-worker'
wget -O ./polkadot-prepare-worker -q --show-progress 'https://github.com/paritytech/polkadot-sdk/releases/download/polkadot-v1.10.0/polkadot-prepare-worker'
cd ../../../
ls -la polkadot-sdk/target/release
# build hyperbridge binary
Expand Down
2 changes: 1 addition & 1 deletion Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

24 changes: 22 additions & 2 deletions evm/abi/src/conversions.rs
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,10 @@ use ismp::{host::StateMachine, router};
use crate::evm_host::PostRequestEventFilter;
#[cfg(feature = "beefy")]
pub use beefy::*;
use ismp::events::{StateMachineUpdated, TimeoutHandled};
use ismp::{
consensus::StateMachineId,
events::{StateCommitmentVetoed, StateMachineUpdated, TimeoutHandled},
};
use primitive_types::H256;
use std::str::FromStr;

Expand Down Expand Up @@ -303,7 +306,10 @@ impl TryFrom<EvmHostEvents> for ismp::events::Event {
EvmHostEvents::StateMachineUpdatedFilter(filter) =>
Ok(ismp::events::Event::StateMachineUpdated(StateMachineUpdated {
state_machine_id: ismp::consensus::StateMachineId {
state_id: StateMachine::Kusama(filter.state_machine_id.low_u64() as u32),
state_id: StateMachine::from_str(&String::from_utf8(
filter.state_machine_id.to_vec(),
)?)
.map_err(|e| anyhow!("{}", e))?,
consensus_state_id: Default::default(),
},
latest_height: filter.height.low_u64(),
Expand All @@ -320,6 +326,20 @@ impl TryFrom<EvmHostEvents> for ismp::events::Event {
Ok(ismp::events::Event::GetRequestTimeoutHandled(TimeoutHandled {
commitment: handled.commitment.into(),
})),
EvmHostEvents::StateCommitmentVetoedFilter(vetoed) =>
Ok(ismp::events::Event::StateCommitmentVetoed(StateCommitmentVetoed {
height: ismp::consensus::StateMachineHeight {
id: StateMachineId {
state_id: StateMachine::from_str(&String::from_utf8(
vetoed.state_machine_id.to_vec(),
)?)
.map_err(|e| anyhow!("{}", e))?,
consensus_state_id: Default::default(),
},
height: vetoed.height.low_u64(),
},
fisherman: vetoed.fisherman.as_bytes().to_vec(),
})),
}
}
}
Expand Down
371 changes: 333 additions & 38 deletions evm/abi/src/generated/evm_host.rs

Large diffs are not rendered by default.

9 changes: 3 additions & 6 deletions evm/abi/src/generated/host_manager.rs

Large diffs are not rendered by default.

4 changes: 2 additions & 2 deletions evm/abi/src/generated/ping_module.rs

Large diffs are not rendered by default.

6 changes: 3 additions & 3 deletions evm/integration-tests/src/tests/host_manager.rs
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ async fn test_host_manager_withdraw() -> Result<(), anyhow::Error> {

// create post request object
let post = Post {
source: StateMachine::Polkadot(2000),
source: StateMachine::Kusama(2000),
dest: StateMachine::Ethereum(Ethereum::ExecutionLayer),
nonce: 0,
from: contract.runner.sender.as_bytes().to_vec(),
Expand Down Expand Up @@ -95,7 +95,7 @@ async fn test_host_manager_insufficient_balance() -> Result<(), anyhow::Error> {

// create post request object
let post = Post {
source: StateMachine::Polkadot(2000),
source: StateMachine::Kusama(2000),
dest: StateMachine::Ethereum(Ethereum::ExecutionLayer),
nonce: 0,
from: contract.runner.sender.as_bytes().to_vec(),
Expand Down Expand Up @@ -132,7 +132,7 @@ async fn test_host_manager_set_host_params() -> Result<(), anyhow::Error> {

// create post request object
let post = Post {
source: StateMachine::Polkadot(2000),
source: StateMachine::Kusama(2000),
dest: StateMachine::Ethereum(Ethereum::ExecutionLayer),
nonce: 0,
from: contract.runner.sender.as_bytes().to_vec(),
Expand Down
6 changes: 2 additions & 4 deletions evm/integration-tests/src/tests/post_response.rs
Original file line number Diff line number Diff line change
Expand Up @@ -108,8 +108,7 @@ async fn test_post_response_timeout() -> Result<(), anyhow::Error> {
let base_dir = env::current_dir()?.parent().unwrap().display().to_string();
let mut runner = Runner::new(PathBuf::from(&base_dir));
let mut contract = runner.deploy("PostResponseTest").await;
let storage_prefix =
hex!("103895530afb23bb607661426d55eb8b554b72b7162725f9457d35ecafb8b02f").to_vec();
let storage_prefix = hex!("526573706f6e73655265636569707473").to_vec();
let destination = contract.call::<_, Address>("module", ()).await?;

// create post request object
Expand Down Expand Up @@ -197,8 +196,7 @@ async fn test_post_response_malicious_timeout() -> Result<(), anyhow::Error> {
let base_dir = env::current_dir()?.parent().unwrap().display().to_string();
let mut runner = Runner::new(PathBuf::from(&base_dir));
let mut contract = runner.deploy("PostResponseTest").await;
let storage_prefix =
hex!("103895530afb23bb607661426d55eb8b554b72b7162725f9457d35ecafb8b02f").to_vec();
let storage_prefix = hex!("526573706f6e73655265636569707473").to_vec();
let destination = contract.call::<_, Address>("module", ()).await?;

// create post request object
Expand Down
3 changes: 1 addition & 2 deletions evm/integration-tests/src/tests/post_timeout.rs
Original file line number Diff line number Diff line change
Expand Up @@ -26,8 +26,7 @@ async fn test_post_timeout_proof() -> Result<(), anyhow::Error> {
let mut contract = runner.deploy("PostRequestTest").await;

let module = contract.call::<_, Address>("module", ()).await?;
let storage_prefix =
hex!("103895530afb23bb607661426d55eb8b0484aecefe882c3ce64e6f82507f715a").to_vec();
let storage_prefix = hex!("526571756573745265636569707473").to_vec();

// create post request object
let post = Post {
Expand Down
2 changes: 1 addition & 1 deletion evm/lib/ismp-solidity
File renamed without changes.
7 changes: 1 addition & 6 deletions evm/script/DeployGateway.s.sol
Original file line number Diff line number Diff line change
Expand Up @@ -83,12 +83,7 @@ contract DeployScript is Script {

gateway.init(
TokenGatewayParamsExt({
params: TokenGatewayParams({
hyperbridge: StateMachine.kusama(paraId),
host: host,
uniswapV2: uniRouter,
dispatcher: callDispatcher
}),
params: TokenGatewayParams({host: host, uniswapV2: uniRouter, dispatcher: callDispatcher}),
assets: assets
})
);
Expand Down
13 changes: 5 additions & 8 deletions evm/script/DeployIsmp.s.sol
Original file line number Diff line number Diff line change
Expand Up @@ -58,13 +58,14 @@ contract DeployScript is Script {
HandlerV1 handler = new HandlerV1{salt: salt}();

// Host manager
HostManager manager =
new HostManager{salt: salt}(HostManagerParams({admin: admin, host: address(0), governorStateMachineId : paraId}));
HostManager manager = new HostManager{salt: salt}(HostManagerParams({admin: admin, host: address(0)}));
uint256[] memory stateMachineWhitelist = new uint256[](1);
stateMachineWhitelist[0] = paraId;

// EvmHost
address[] memory fishermen = new address[](0);
HostParams memory params = HostParams({
fishermen: fishermen,
admin: admin,
hostManager: address(manager),
handler: address(handler),
Expand All @@ -78,6 +79,7 @@ contract DeployScript is Script {
consensusUpdateTimestamp: 0,
consensusState: new bytes(0),
perByteFee: 3 * 1e15, // $0.003/byte
hyperbridge: StateMachine.kusama(paraId),
feeToken: address(feeToken),
stateMachineWhitelist: stateMachineWhitelist
});
Expand Down Expand Up @@ -146,12 +148,7 @@ contract DeployScript is Script {
// initialize gateway
gateway.init(
TokenGatewayParamsExt({
params: TokenGatewayParams({
hyperbridge: StateMachine.kusama(paraId),
host: hostAddress,
uniswapV2: address(1),
dispatcher: dispatcher
}),
params: TokenGatewayParams({host: hostAddress, uniswapV2: address(1), dispatcher: dispatcher}),
assets: assets
})
);
Expand Down
Loading

0 comments on commit 313e891

Please sign in to comment.