Add deployment of relay contract to migrations
Currently we set up Ropsten to deploy a Bitcoin testnet relay and
mainnet to deploy a Bitcoin mainnet relay. The main distinction are the
initialization parameters passed to the relay itself for the maintainer
to build on.
@@ -23,6 +23,8 @@ const BTCUSDPriceFeed = artifacts.require("BTCUSDPriceFeed")
const ETHUSDPriceFeed = artifacts.require("ETHUSDPriceFeed")
const prices = require("./prices")
+// Bitcoin difficulty relays.
+const Relay = artifacts.require("@summa-tx/relay-sol/contracts/Relay")
const MockRelay = artifacts.require("MockRelay")
// system
@@ -57,6 +59,22 @@ const all = [
FeeRebateToken,
]
+const bitcoinMain = {
+ genesis:
+ "0x00000020d208b5e50a8d3bd3a87f7a238e3f196621d0f9ffb5f302000000000000000000ee3af51ad3643a8a109935b45d9ca32b1003cda41df39dd75a17e13ba13aff4211aa585d39301c174a8ead73",
+ height: 590588,
+ epochStart:
+ "0x704de08dc5329269011b878835be108a8202a93a0a2a1c000000000000000000",
+}
+
+const bitcoinTest = {
+ genesis:
+ "0x0000ff3ffc663e3a0b12b4cc2c05a425bdaf51922ce090acd8fa3a8a180300000000000084080b23fc40476d284da49fedaea9f7cee3aba33a8bad1347fa54740a29f02752b4c45dfcff031a279c2b3a",
+ height: 1607272,
+ epochStart:
+ "0x84a9ec3b82556297ea36d1377901ecaef0bb5a5cf683f9f05103000000000000",
+}
+
module.exports = (deployer, network, accounts) => {
deployer.then(async () => {
// bitcoin-spv
@@ -95,9 +113,22 @@ module.exports = (deployer, network, accounts) => {
await btcPriceFeed.setValue(web3.utils.toWei(prices.BTCUSD))
await ethPriceFeed.setValue(web3.utils.toWei(prices.ETHUSD))
+ }
+
+ // On mainnet and Ropsten, we use the Summa-built, Keep-operated relay;
+ // see https://github.com/summa-tx/relays . On testnet, we use a local
+ // mock.
+ if (network === "mainnet") {
+ const {genesis, height, epochStart} = bitcoinMain
+
+ await deployer.deploy(Relay, genesis, height, epochStart)
+ difficultyRelay = await Relay.deployed()
+ } else if (network == "ropsten") {
+ const {genesis, height, epochStart} = bitcoinTest
- // On mainnet, we use the Summa-provided relay; see
- // https://github.com/summa-tx/relays . On testnet, we use a local mock.
+ await deployer.deploy(Relay, genesis, height, epochStart)
+ difficultyRelay = await Relay.deployed()
+ } else {
await deployer.deploy(MockRelay)
difficultyRelay = await MockRelay.deployed()
}
