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

SNO-565: Make parachain relayers use Gateway contract #888

Merged
merged 16 commits into from
Jul 20, 2023
Merged
Show file tree
Hide file tree
Changes from 13 commits
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: 3 additions & 3 deletions core/packages/test/config/parachain-relay.json
Original file line number Diff line number Diff line change
Expand Up @@ -11,18 +11,18 @@
},
"contracts": {
"BeefyClient": null,
"InboundQueue": null
"Gateway": null
},
"beefy-activation-block": 0,
"lane-id": 0
"channel-id": 0
},
"sink": {
"ethereum": {
"endpoint": "ws://127.0.0.1:8546",
"gas-limit": null
},
"contracts": {
"InboundQueue": null
"Gateway": null
}
}
}
6 changes: 4 additions & 2 deletions core/packages/test/scripts/set-env.sh
Original file line number Diff line number Diff line change
Expand Up @@ -77,10 +77,12 @@ export RANDAO_COMMIT_DELAY=3
export RANDAO_COMMIT_EXP=3

export BRIDGE_HUB_PARAID=$bridgehub_para_id
export BRIDGE_HUB_AGENT_ID=""
# TODO: update placeholder value
export BRIDGE_HUB_AGENT_ID="00000000000000000000000000000000000000000000000000000000000003f5"

export ASSET_HUB_PARAID=$statemine_para_id
export ASSET_HUB_AGENT_ID=""
# TODO: update placeholder value
export ASSET_HUB_AGENT_ID="00000000000000000000000000000000000000000000000000000000000003e8"

export DEFAULT_FEE=1
export DEFAULT_REWARD=1
Expand Down
24 changes: 12 additions & 12 deletions core/packages/test/scripts/start-relayer.sh
Original file line number Diff line number Diff line change
Expand Up @@ -19,37 +19,37 @@ config_relayer(){

# Configure parachain relay (bridge hub)
jq \
--arg k1 "$(address_for InboundQueue)" \
--arg k1 "$(address_for GatewayProxy)" \
--arg k2 "$(address_for BeefyClient)" \
--arg eth_endpoint_ws $eth_endpoint_ws \
--arg laneID $BRIDGE_HUB_PARAID \
--arg channelID $BRIDGE_HUB_PARAID \
--arg eth_gas_limit $eth_gas_limit \
'
.source.contracts.InboundQueue = $k1
.source.contracts.Gateway = $k1
| .source.contracts.BeefyClient = $k2
| .sink.contracts.InboundQueue = $k1
| .sink.contracts.Gateway = $k1
| .source.ethereum.endpoint = $eth_endpoint_ws
| .sink.ethereum.endpoint = $eth_endpoint_ws
| .sink.ethereum."gas-limit" = $eth_gas_limit
| .source."lane-id" = $laneID
| .source."channel-id" = $channelID
' \
config/parachain-relay.json > $output_dir/parachain-relay-bridge-hub.json

# Configure parachain relay (asset hub)
jq \
--arg k1 "$(address_for InboundQueue)" \
--arg k1 "$(address_for GatewayProxy)" \
--arg k2 "$(address_for BeefyClient)" \
--arg eth_endpoint_ws $eth_endpoint_ws \
--arg laneID $ASSET_HUB_PARAID \
--arg channelID $ASSET_HUB_PARAID \
--arg eth_gas_limit $eth_gas_limit \
'
.source.contracts.InboundQueue = $k1
.source.contracts.Gateway = $k1
| .source.contracts.BeefyClient = $k2
| .sink.contracts.InboundQueue = $k1
| .sink.contracts.Gateway = $k1
| .source.ethereum.endpoint = $eth_endpoint_ws
| .sink.ethereum.endpoint = $eth_endpoint_ws
| .sink.ethereum."gas-limit" = $eth_gas_limit
| .source."lane-id" = $laneID
| .source."channel-id" = $channelID
' \
config/parachain-relay.json > $output_dir/parachain-relay-asset-hub.json

Expand All @@ -67,11 +67,11 @@ config_relayer(){
jq \
--arg eth_endpoint_ws $eth_endpoint_ws \
--arg k1 "$(address_for OutboundQueue)" \
--arg laneID $ASSET_HUB_PARAID \
--arg channelID $ASSET_HUB_PARAID \
'
.source.ethereum.endpoint = $eth_endpoint_ws
| .source.contracts.OutboundQueue = $k1
| .source."lane-id" = $laneID
| .source."channel-id" = $channelID
' \
config/execution-relay.json > $output_dir/execution-relay.json
}
Expand Down
307 changes: 41 additions & 266 deletions relayer/contracts/beefy_client.go

Large diffs are not rendered by default.

1,598 changes: 1,598 additions & 0 deletions relayer/contracts/gateway.go

Large diffs are not rendered by default.

4 changes: 1 addition & 3 deletions relayer/contracts/generate.go
Original file line number Diff line number Diff line change
@@ -1,6 +1,4 @@
//go:generate bash -c "jq .abi ../../core/packages/contracts/out/OpaqueProof.sol/OpaqueProof.json | abigen --abi - --type OpaqueProof --pkg contracts --out opaque_proof.go"
//go:generate bash -c "jq .abi ../../core/packages/contracts/out/BeefyClient.sol/BeefyClient.json | abigen --abi - --type BeefyClient --pkg contracts --out beefy_client.go"
//go:generate bash -c "jq .abi ../../core/packages/contracts/out/InboundQueue.sol/InboundQueue.json | abigen --abi - --type InboundQueue --pkg contracts --out inbound_queue.go"
//go:generate bash -c "jq .abi ../../core/packages/contracts/out/OutboundQueue.sol/OutboundQueue.json | abigen --abi - --type OutboundQueue --pkg contracts --out outbound_queue.go"
//go:generate bash -c "jq .abi ../../core/packages/contracts/out/IGateway.sol/IGateway.json | abigen --abi - --type Gateway --pkg contracts --out gateway.go"

package contracts
2,113 changes: 0 additions & 2,113 deletions relayer/contracts/inbound_queue.go

This file was deleted.

251 changes: 0 additions & 251 deletions relayer/contracts/opaque_proof.go

This file was deleted.

9 changes: 5 additions & 4 deletions relayer/relays/parachain/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -9,17 +9,18 @@ type Config struct {
Sink SinkConfig `mapstructure:"sink"`
}

// TODO: check whether ChannelID should be uint32 (as in the parachain) or big.Int (uint256, as in the Gateway contract)
Copy link
Contributor Author

Choose a reason for hiding this comment

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

@vgeddes How big are the channelIDs?

Copy link
Contributor

Choose a reason for hiding this comment

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

Guess uint32 as ParaId should be enough. But remember Aidan mentioned last time we'll probably allow multiple channels for each Parachain?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Ah right, we can expand the channel id on Polkadot to get multiple channels per parachain

type SourceConfig struct {
Polkadot config.PolkadotConfig `mapstructure:"polkadot"`
Parachain config.ParachainConfig `mapstructure:"parachain"`
Ethereum config.EthereumConfig `mapstructure:"ethereum"`
Contracts SourceContractsConfig `mapstructure:"contracts"`
LaneID uint32 `mapstructure:"lane-id"`
ChannelID uint32 `mapstructure:"channel-id"`
}

type SourceContractsConfig struct {
BeefyClient string `mapstructure:"BeefyClient"`
InboundQueue string `mapstructure:"InboundQueue"`
BeefyClient string `mapstructure:"BeefyClient"`
Gateway string `mapstructure:"Gateway"`
}

type SinkConfig struct {
Expand All @@ -28,5 +29,5 @@ type SinkConfig struct {
}

type SinkContractsConfig struct {
InboundQueue string `mapstructure:"InboundQueue"`
Gateway string `mapstructure:"Gateway"`
}
Loading