Skip to content
This repository has been archived by the owner on Mar 13, 2023. It is now read-only.

Refactor suggestions regarding relay modules #188

Closed
hackfisher opened this issue Jul 15, 2020 · 4 comments · Fixed by #230, #232 or #250
Closed

Refactor suggestions regarding relay modules #188

hackfisher opened this issue Jul 15, 2020 · 4 comments · Fixed by #230, #232 or #250
Assignees

Comments

@hackfisher
Copy link
Contributor

  1. EthereumRelay implements EthereumRelayabe
  2. Dispatch calls are all put into EthereumRelay, relay_header(EthereumHeaderThing). The parameter EthereumHeaderThing uses EthereumRelayabe codec into vec and is passed to RelayerGame’s submit_proposals. When using it, adjust the EthereumRelayabe interface. In this way, both apps and explorer can easily analyze the EthereumHeaderThing Type
  3. As a more general and closed module, RelayerGame can manage its own storage, events and on_initialize/on_finalize, which are related to verifying the game sub-protocol.
  4. EthereumRelay Dispatch Call calls RelayerGame to complete tasks related to verifying game sub-protocols.
@hackfisher
Copy link
Contributor Author

ConfirmBlockManagementError should be a Error, not a event.

@aurexav
Copy link
Member

aurexav commented Aug 19, 2020

Currently, the implementation is ugly, very inefficiency.

Relay encode the header things pass to Game, then Game call Relay to decode them. Such as verify_raw_header_thing, verify_raw_header_things are unnecessary under this architecture.

We should eventually separate the APIs. Refactor the Game's protocol.

Is possible to make Game an actual protocol? Like phragmen which defined in primitives.

@clearloop
Copy link
Contributor

It might be a solution to implement a struct named Relayable:

struct Relayable {}

struct EthereumHeaderThing {}
struct TronHeaderThing{}

impl Into<Relayable> for EthereumHeaderThing{}
impl Into<Relayable> for TronHeaderThing{}

Or use a trait and proc_macro

struct Relayable {
  header: String,
  mmr: H256,
}

trait RelayableTrait {
   fn relayable() -> Relayable
}

/// -snippet-
/// a proc macro

#[derive(Relayable)]
struct EthHeaderThing{}

#[derive(Relayable)]
struct TronHeaderThing{}

@hackfisher
Copy link
Contributor Author

Currently, the implementation is ugly, very inefficiency.

Relay encode the header things pass to Game, then Game call Relay to decode them. Such as verify_raw_header_thing, verify_raw_header_things are unnecessary under this architecture.

We should eventually separate the APIs. Refactor the Game's protocol.

Is possible to make Game an actual protocol? Like phragmen which defined in primitives.

Can we remove RawHeaderThing and make HeaderThing an associate type for both Relay and RelayerGame?

Then for EthereumRelay, we can assign EthereumHeaderThing to this associate type, for TronRelay, we can assign TronHeaderThing.

We will not need encode/decode process between them then.

Currently RelayerGame has chain storages, it's more like a pallet than a primitives library.

@hackfisher hackfisher linked a pull request Aug 19, 2020 that will close this issue
@aurexav aurexav linked a pull request Aug 27, 2020 that will close this issue
9 tasks
@aurexav aurexav closed this as completed Aug 27, 2020
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.