From e1eb4e588c3a07778678c619ba07cbb91a7e523d Mon Sep 17 00:00:00 2001 From: Orlando Date: Tue, 22 Aug 2023 11:57:55 +0100 Subject: [PATCH] fix: eth relayer --- starknet/src/execution_strategies.cairo | 2 ++ .../execution_strategies/eth_relayer.cairo | 34 +++++++++++++------ 2 files changed, 25 insertions(+), 11 deletions(-) diff --git a/starknet/src/execution_strategies.cairo b/starknet/src/execution_strategies.cairo index b0973e0c..907558a8 100644 --- a/starknet/src/execution_strategies.cairo +++ b/starknet/src/execution_strategies.cairo @@ -1,3 +1,5 @@ mod vanilla; mod simple_quorum; + +mod eth_relayer; diff --git a/starknet/src/execution_strategies/eth_relayer.cairo b/starknet/src/execution_strategies/eth_relayer.cairo index ccf5344a..aa73c10c 100644 --- a/starknet/src/execution_strategies/eth_relayer.cairo +++ b/starknet/src/execution_strategies/eth_relayer.cairo @@ -1,10 +1,17 @@ #[starknet::contract] mod EthRelayerExecutionStrategy { + use array::ArrayTrait; + use option::OptionTrait; + use traits::TryInto; + use serde::Serde; use starknet::syscalls::send_message_to_l1_syscall; use starknet::info::get_caller_address; use sx::interfaces::IExecutionStrategy; use sx::types::{Proposal}; + #[storage] + struct Storage {} + #[external(v0)] impl EthRelayerExecutionStrategy of IExecutionStrategy { fn execute( @@ -18,19 +25,24 @@ mod EthRelayerExecutionStrategy { let space = get_caller_address(); // Decode payload - let l1_destination = payload[0]; - // keccak hash of the proposal execution payload - let execution_hash = u256 { low: payload[2], high: payload[1] }; + let mut payload = payload; + // L1 destination contract address + let l1_destination = payload.pop_front().unwrap(); + // keccak hash of the L1 proposal execution payload + let l1_execution_hash = u256 { + low: payload.pop_front().unwrap().try_into().unwrap(), + high: payload.pop_front().unwrap().try_into().unwrap() + }; - let mut message_payload = array![]; - space.serialize(mut message_payload); - proposal.serialize(mut message_payload); - votes_for.serialize(mut message_payload); - votes_against.serialize(mut message_payload); - votes_abstain.serialize(mut message_payload); - execution_hash.serialize(mut message_payload); + let mut l1_payload = array![]; + space.serialize(ref l1_payload); + proposal.serialize(ref l1_payload); + votes_for.serialize(ref l1_payload); + votes_against.serialize(ref l1_payload); + votes_abstain.serialize(ref l1_payload); + l1_execution_hash.serialize(ref l1_payload); - send_message_to_l1_syscall(l1_destination, message_payload); + send_message_to_l1_syscall(l1_destination, l1_payload.span()); } } }