Skip to content

Commit

Permalink
Merge pull request #29 from BoltzExchange/rif
Browse files Browse the repository at this point in the history
RIF relay
  • Loading branch information
michael1011 authored Jul 31, 2024
2 parents de88751 + 1c65e7a commit a050c02
Show file tree
Hide file tree
Showing 9 changed files with 152 additions and 2 deletions.
2 changes: 2 additions & 0 deletions .env
Original file line number Diff line number Diff line change
Expand Up @@ -10,3 +10,5 @@ BITCOIN_CORE_IMAGE=boltz/bitcoin-core:latest
ELEMENTS_IMAGE=ghcr.io/vulpemventures/elements:latest
ELECTRS_IMAGE=boltz/electrs:latest
ESPLORA_IMAGE=boltz/esplora:latest
OTTERSCAN_IMAGE=otterscan/otterscan:latest
RIF_RELAY_IMAGE=boltz/rif-relay:latest
2 changes: 2 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -38,3 +38,5 @@ Or alternatively, you can `source aliases.sh` to have these convenience scripts

- Bitcoin: [http://localhost:4002](http://localhost:4002)
- Elements: [http://localhost:4003](http://localhost:4003)

[Otterscan](https://github.com/otterscan/otterscan) is used as block explorer for Anvil: [http://localhost:5100](http://localhost:5100)
6 changes: 6 additions & 0 deletions build.py
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,12 @@ class Image:
UBUNTU_VERSION,
],
),
"rif-relay": Image(
tag="latest",
arguments=[
NODE_VERSION
],
),
"scripts": Image(
tag="latest",
arguments=[
Expand Down
4 changes: 2 additions & 2 deletions data/backend/boltz.conf
Original file line number Diff line number Diff line change
Expand Up @@ -106,8 +106,8 @@ maxZeroConfAmount = 40_294_967
[rsk]
providerEndpoint = "http://anvil:8545"

etherSwapAddress = "0x5fbdb2315678afecb367f032d93f642f64180aa3"
erc20SwapAddress = "0xe7f1725e7734ce288f8367e1bb143e90bb3f0512"
etherSwapAddress = "0x7a2088a1bFc9d81c55368AE168C2C02570cB814F"
erc20SwapAddress = "0x09635F643e140090A9A8Dcd712eD6285858ceBef"

[[rsk.tokens]]
symbol = "RBTC"
Expand Down
33 changes: 33 additions & 0 deletions docker-compose.yml
Original file line number Diff line number Diff line change
Expand Up @@ -158,6 +158,8 @@ services:
hostname: anvil
container_name: boltz-anvil
image: ${FOUNDRY_IMAGE}
# Chain ID 33 is the regtest of Rootstock
entrypoint: "anvil --host 0.0.0.0 --chain-id 33"
ports:
- 8545:8545
healthcheck:
Expand All @@ -167,6 +169,22 @@ services:
interval: 1s
start_period: 0s

rif-relay:
hostname: rif-relay
container_name: boltz-rif-relay
image: ${RIF_RELAY_IMAGE}
depends_on:
anvil:
condition: service_healthy
healthcheck:
test: [ "CMD-SHELL", "curl -s localhost:8090/chain-info" ]
timeout: 1s
retries: 10
interval: 2s
start_period: 15s
ports:
- 8090:8090

bitcoind:
container_name: boltz-bitcoind
hostname: bitcoind
Expand Down Expand Up @@ -286,6 +304,8 @@ services:
condition: service_healthy
anvil:
condition: service_healthy
rif-relay:
condition: service_healthy

scripts:
<<: *base-scripts
Expand Down Expand Up @@ -377,6 +397,19 @@ services:
- 4002:4002
- 4003:4003

otterscan:
hostname: otterscan
container_name: boltz-otterscan
restart: always
image: ${OTTERSCAN_IMAGE}
environment:
- OTTERSCAN_CONFIG={"erigonURL":"http://localhost:8545","chainInfo":{"name":"Anvil","faucets":[],"nativeCurrency":{"name":"Rootstock BTC","symbol":"RBTC","decimals":18}}}
depends_on:
anvil:
condition: service_healthy
ports:
- 5100:80

volumes:
boltz-data:
name: boltz-backend-data
Expand Down
28 changes: 28 additions & 0 deletions images/rif-relay/Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
ARG NODE_VERSION=lts-bookworm-slim

FROM node:${NODE_VERSION} AS builder

RUN git clone https://github.com/rsksmart/rif-relay-contracts.git

WORKDIR /rif-relay-contracts

RUN git checkout 59b67d6ccd901f8e2320e3aea5a5fc937956f34b
COPY contracts.patch .
RUN git apply contracts.patch

RUN npm ci

WORKDIR /
RUN git clone https://github.com/rsksmart/rif-relay-server.git

WORKDIR /rif-relay-server

RUN git checkout a4807e557d8205ab285b8891cef58e8b5fb2994a
COPY server.patch .
RUN git apply server.patch

RUN npm ci

COPY start.sh /

ENTRYPOINT ["/bin/bash", "/start.sh"]
22 changes: 22 additions & 0 deletions images/rif-relay/contracts.patch
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
diff --git a/hardhat.config.ts b/hardhat.config.ts
index 0115432..162c704 100644
--- a/hardhat.config.ts
+++ b/hardhat.config.ts
@@ -54,7 +54,7 @@ if (PK) {
sharedNetworkConfig.accounts = [PK];
} else {
sharedNetworkConfig.accounts = {
- mnemonic: MNEMONIC || DEFAULT_MNEMONIC,
+ mnemonic: 'test test test test test test test test test test test junk' || MNEMONIC || DEFAULT_MNEMONIC,
};
}

@@ -79,7 +79,7 @@ const config: HardhatUserConfig = {
},
networks: {
regtest: {
- url: 'http://localhost:4444',
+ url: 'http://anvil:8545',
chainId: 33,
},
testnet: {
41 changes: 41 additions & 0 deletions images/rif-relay/server.patch
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
diff --git a/config/default.json5 b/config/default.json5
index b2d355c..52ec78b 100644
--- a/config/default.json5
+++ b/config/default.json5
@@ -5,12 +5,12 @@
Server
*/
app: {
- url: "http://127.0.0.1", // URL where the relay server will be deployed, it could be localhost or the IP of the host machine.
+ url: "http://127.0.0.1:8090", // URL where the relay server will be deployed, it could be localhost or the IP of the host machine.
port: 8090, // port where the relay server will be hosted.
devMode: false, // indicates to the server if we are in development mode or not.
customReplenish: false, // set if the server uses a custom replenish function or not.

- logLevel: 4 /* The log level for the relay server. Available levels:
+ logLevel: 1 /* The log level for the relay server. Available levels:
{
TRACE: 0;
DEBUG: 1;
@@ -58,7 +58,7 @@
Blockchain node
*/
blockchain: {
- rskNodeUrl: "http://127.0.0.1:4444", // RSK node endpoint URL, where the RSK node is located.
+ rskNodeUrl: "http://anvil:8545", // RSK node endpoint URL, where the RSK node is located.
gasPriceFactor: 1,
alertedBlockDelay: 0,
minAlertedDelayMS: 0,
@@ -85,9 +85,9 @@
Relay contracts addresses
*/
contracts: {
- relayHubAddress: "0x0000000000000000000000000000000000000000", // relay hub contract address, you can retrieve this from the contract summary.
- relayVerifierAddress: "0x0000000000000000000000000000000000000000", // relay verifier contract address, you can retrieve this from the contract summary.
- deployVerifierAddress: "0x0000000000000000000000000000000000000000", // deploy verifier contract address, you can retrieve this from the contract summary.
+ relayHubAddress: "0xe7f1725E7734CE288F8367e1Bb143E90bb3F0512", // relay hub contract address, you can retrieve this from the contract summary.
+ relayVerifierAddress: "0x5FC8d32690cc91D4c39d9d3abcBD16989F875707", // relay verifier contract address, you can retrieve this from the contract summary.
+ deployVerifierAddress: "0xDc64a140Aa3E981100a9becA4E685f962f0cF6C9", // deploy verifier contract address, you can retrieve this from the contract summary.
feesReceiver: "0x0000000000000000000000000000000000000000",
trustedVerifiers: [],
},
16 changes: 16 additions & 0 deletions images/rif-relay/start.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
#!/bin/bash

register_relay() {
# We can sleep for a while; this can happen in the background
sleep 15
cd /rif-relay-server
npm run register
}

cd /rif-relay-contracts
npx hardhat deploy --network regtest

cd /rif-relay-server

register_relay &
npm run start

0 comments on commit a050c02

Please sign in to comment.