Skip to content

Commit

Permalink
Merge branch 'main' into update-system-tests
Browse files Browse the repository at this point in the history
  • Loading branch information
tomaszslabon authored Oct 26, 2023
2 parents 03838af + f5aff67 commit c2db098
Show file tree
Hide file tree
Showing 48 changed files with 1,188 additions and 823 deletions.
35 changes: 28 additions & 7 deletions .github/workflows/contracts.yml
Original file line number Diff line number Diff line change
Expand Up @@ -27,8 +27,8 @@ on:
workflow_dispatch:
inputs:
environment:
description: "Environment (network) for workflow execution, e.g. `goerli`"
required: false
description: "Environment (network) for workflow execution, e.g. `sepolia`"
required: true
upstream_builds:
description: "Upstream builds"
required: false
Expand Down Expand Up @@ -185,8 +185,15 @@ jobs:

- name: Deploy contracts
env:
CHAIN_API_URL: ${{ secrets.GOERLI_ETH_HOSTNAME_HTTP }}
ACCOUNTS_PRIVATE_KEYS: ${{ secrets.GOERLI_ETH_CONTRACT_OWNER_PRIVATE_KEY }}
# Using fake ternary expression to decide which credentials to use,
# depending on chosen environment. Note: if `GOERLI_ETH_HOSTNAME_HTTP`
# is empty, the expression will be evaluated to
# `SEPOLIA_ETH_HOSTNAME_HTTP`'s value.
CHAIN_API_URL: |
${{ inputs.github.event.inputs.environment == 'goerli'
&& secrets.GOERLI_ETH_HOSTNAME_HTTP
|| secrets.SEPOLIA_ETH_HOSTNAME_HTTP }}
ACCOUNTS_PRIVATE_KEYS: ${{ secrets.TESTNET_ETH_CONTRACT_OWNER_PRIVATE_KEY }}
run: yarn deploy --network ${{ github.event.inputs.environment }}

- name: Bump up package version
Expand Down Expand Up @@ -268,7 +275,14 @@ jobs:
- name: Verify contracts on Etherscan
env:
ETHERSCAN_API_KEY: ${{ secrets.ETHERSCAN_API_KEY }}
CHAIN_API_URL: ${{ secrets.GOERLI_ETH_HOSTNAME_HTTP }}
# Using fake ternary expression to decide which credentials to use,
# depending on chosen environment. Note: if `GOERLI_ETH_HOSTNAME_HTTP`
# is empty, the expression will be evaluated to
# `SEPOLIA_ETH_HOSTNAME_HTTP`'s value.
CHAIN_API_URL: |
${{ inputs.github.event.inputs.environment == 'goerli'
&& secrets.GOERLI_ETH_HOSTNAME_HTTP
|| secrets.SEPOLIA_ETH_HOSTNAME_HTTP }}
run: yarn run hardhat --network ${{ github.event.inputs.environment }} etherscan-verify

# This job is responsible for publishing packackes with slightly modified
Expand Down Expand Up @@ -326,8 +340,15 @@ jobs:
- name: Deploy contracts
env:
CHAIN_API_URL: ${{ secrets.GOERLI_ETH_HOSTNAME_HTTP }}
ACCOUNTS_PRIVATE_KEYS: ${{ secrets.DAPP_DEV_GOERLI_ETH_CONTRACT_OWNER_PRIVATE_KEY }}
# Using fake ternary expression to decide which credentials to use,
# depending on chosen environment. Note: if `GOERLI_ETH_HOSTNAME_HTTP`
# is empty, the expression will be evaluated to
# `SEPOLIA_ETH_HOSTNAME_HTTP`'s value.
CHAIN_API_URL: |
${{ inputs.github.event.inputs.environment == 'goerli'
&& secrets.GOERLI_ETH_HOSTNAME_HTTP
|| secrets.SEPOLIA_ETH_HOSTNAME_HTTP }}
ACCOUNTS_PRIVATE_KEYS: ${{ secrets.DAPP_DEV_TESTNET_ETH_CONTRACT_OWNER_PRIVATE_KEY }}
run: yarn deploy --network ${{ github.event.inputs.environment }}

- name: Bump up package version
Expand Down
6 changes: 3 additions & 3 deletions .github/workflows/typescript.yml
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,8 @@ on:
workflow_dispatch:
inputs:
environment:
description: "Environment (network) for workflow execution, e.g. `goerli`"
required: false
description: "Environment (network) for workflow execution, e.g. `sepolia`"
required: true
upstream_builds:
description: "Upstream builds"
required: false
Expand Down Expand Up @@ -139,7 +139,7 @@ jobs:
env:
GITHUB_TOKEN: ${{ secrets.CI_GITHUB_TOKEN }}
with:
module: "github.com/keep-network/tbtc-v2.ts"
module: "github.com/keep-network/typescript"
url: https://github.com/${{ github.repository }}/actions/runs/${{ github.run_id }}
environment: ${{ github.event.inputs.environment }}
upstream_builds: ${{ github.event.inputs.upstream_builds }}
Expand Down
1 change: 1 addition & 0 deletions cross-chain/arbitrum/.gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
!/deployments/mainnet/
!/deployments/arbitrumOne/
!/deployments/arbitrumGoerli/
!/deployments/arbitrumSepolia/

# OZ
/.openzeppelin/unknown-*.json
Expand Down
48 changes: 48 additions & 0 deletions solidity/contracts/test/SepoliaLightRelay.sol
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
// SPDX-License-Identifier: GPL-3.0-only

// ██████████████ ▐████▌ ██████████████
// ██████████████ ▐████▌ ██████████████
// ▐████▌ ▐████▌
// ▐████▌ ▐████▌
// ██████████████ ▐████▌ ██████████████
// ██████████████ ▐████▌ ██████████████
// ▐████▌ ▐████▌
// ▐████▌ ▐████▌
// ▐████▌ ▐████▌
// ▐████▌ ▐████▌
// ▐████▌ ▐████▌
// ▐████▌ ▐████▌

pragma solidity 0.8.17;

import {BTCUtils} from "@keep-network/bitcoin-spv-sol/contracts/BTCUtils.sol";

import "../relay/LightRelay.sol";

/// @title Sepolia Light Relay
/// @notice SepoliaLightRelay is a stub version of LightRelay intended to be
/// used on the Sepolia test network. It allows to set the relay's
/// difficulty based on arbitrary Bitcoin headers thus effectively
/// bypass the validation of difficulties of Bitcoin testnet blocks.
/// Since difficulty in Bitcoin testnet often falls to `1` it would not
/// be possible to validate blocks with the real LightRelay.
/// @dev Notice that SepoliaLightRelay is derived from LightRelay so that the two
/// contracts have the same API and correct bindings can be generated.
contract SepoliaLightRelay is LightRelay {
using BTCUtils for bytes;
using BTCUtils for uint256;

/// @notice Sets the current and previous difficulty based on the difficulty
/// inferred from the provided Bitcoin headers.
function setDifficultyFromHeaders(bytes memory bitcoinHeaders)
external
onlyOwner
{
uint256 firstHeaderDiff = bitcoinHeaders
.extractTarget()
.calculateDifficulty();

currentEpochDifficulty = firstHeaderDiff;
prevEpochDifficulty = firstHeaderDiff;
}
}
3 changes: 3 additions & 0 deletions solidity/deploy/01_deploy_light_relay.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,9 @@ const func: DeployFunction = async function (hre: HardhatRuntimeEnvironment) {
if (hre.network.name === "goerli") {
return "GoerliLightRelay"
}
if (hre.network.name === "sepolia") {
return "SepoliaLightRelay"
}
if (hre.network.name === "system_tests") {
return "SystemTestRelay"
}
Expand Down
7 changes: 5 additions & 2 deletions solidity/deploy/09_deploy_bridge_governance.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,11 @@ const func: DeployFunction = async function (hre: HardhatRuntimeEnvironment) {
}
)

// 60 seconds for Goerli. 48 hours otherwise.
const GOVERNANCE_DELAY = hre.network.name === "goerli" ? 60 : 172800
// 60 seconds for Goerli/Sepolia. 48 hours otherwise.
const GOVERNANCE_DELAY =
hre.network.name === "goerli" || hre.network.name === "sepolia"
? 60
: 172800

const bridgeGovernance = await deploy("BridgeGovernance", {
contract: "BridgeGovernance",
Expand Down
6 changes: 3 additions & 3 deletions solidity/deploy/19_authorize_spv_maintainer_in_bridge.ts
Original file line number Diff line number Diff line change
Expand Up @@ -21,9 +21,9 @@ func.tags = ["AuthorizeSpvMaintainer"]
func.dependencies = ["Bridge"]

// SPV maintainer can submit SPV proofs to the Bridge. We authorize spvMaintainer
// account for Hardhat network (unit tests) and Goerli (testnet) but we DO NOT
// want to authorize it for Mainnet deployment. SPV maintainer will be authorized
// separately by the Governance when sweeping will be activated.
// account for Hardhat network (unit tests) and Goerli/Sepolia (testnets) but we
// DO NOT want to authorize it for Mainnet deployment. SPV maintainer will be
// authorized separately by the Governance when sweeping will be activated.
//
// Note that at this point MaintainerProxy contract is already authorized in the
// Bridge (see AuthorizeMaintainerProxyInBridge tag).
Expand Down
2 changes: 1 addition & 1 deletion solidity/deploy/24_transfer_tbtc_ownership.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ const func: DeployFunction = async function (hre: HardhatRuntimeEnvironment) {
// In unit tests we cover VendingMachine, VendingMachineV2, and TBTCVault
// contracts. All those tests require minting TBTC. To make the test setup
// easier, we leave the responsibility of transferring the TBTC ownership
// to the test. In system tests and on Goerli, TBTCVault is the owner of TBTC
// to the test. In system tests and on testnet, TBTCVault is the owner of TBTC
// token, just like on v1.0 mainnet, after transferring the ownership from the
// VendingMachine.
if (hre.network.name !== "hardhat") {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,6 @@ func.dependencies = ["ReimbursementPool", "Bridge"]
// On mainnet, the ReimbursementPool ownership is passed to the Threshold
// Council / DAO and that address is not controlled by the dev team.
// Hence, this step can be executed only for non-mainnet networks such as
// Hardhat (unit tests) and Goerli (testnet).
// Hardhat (unit tests) and Goerli or Sepolia (testnets).
func.skip = async (hre: HardhatRuntimeEnvironment): Promise<boolean> =>
hre.network.name === "mainnet"
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,6 @@ func.dependencies = ["ReimbursementPool", "LightRelayMaintainerProxy"]
// On mainnet, the ReimbursementPool ownership is passed to the Threshold
// Council / DAO and that address is not controlled by the dev team.
// Hence, this step can be executed only for non-mainnet networks such as
// Hardhat (unit tests) and Goerli (testnet).
// Hardhat (unit tests) and Goerli or Sepolia (testnets).
func.skip = async (hre: HardhatRuntimeEnvironment): Promise<boolean> =>
hre.network.name === "mainnet"
Original file line number Diff line number Diff line change
Expand Up @@ -24,4 +24,6 @@ func.tags = ["AuthorizeLightRelayMaintainerProxyInLightRelay"]
func.dependencies = ["LightRelay", "LightRelayMaintainerProxy"]

func.skip = async (hre: HardhatRuntimeEnvironment): Promise<boolean> =>
hre.network.name === "goerli" || hre.network.name === "system_tests"
hre.network.name === "goerli" ||
hre.network.name === "sepolia" ||
hre.network.name === "system_tests"
23 changes: 23 additions & 0 deletions solidity/hardhat.config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -117,6 +117,14 @@ const config: HardhatUserConfig = {
: undefined,
tags: ["tenderly"],
},
sepolia: {
url: process.env.CHAIN_API_URL || "",
chainId: 11155111,
accounts: process.env.ACCOUNTS_PRIVATE_KEYS
? process.env.ACCOUNTS_PRIVATE_KEYS.split(",")
: undefined,
tags: ["tenderly"],
},
mainnet: {
url: process.env.CHAIN_API_URL || "",
chainId: 1,
Expand Down Expand Up @@ -172,6 +180,11 @@ const config: HardhatUserConfig = {
"node_modules/@keep-network/random-beacon/artifacts",
"node_modules/@keep-network/ecdsa/artifacts",
],
sepolia: [
"node_modules/@keep-network/tbtc/artifacts",
"node_modules/@keep-network/random-beacon/artifacts",
"node_modules/@keep-network/ecdsa/artifacts",
],
mainnet: ["./external/mainnet"],
},
},
Expand All @@ -180,53 +193,63 @@ const config: HardhatUserConfig = {
deployer: {
default: 1,
goerli: 0,
sepolia: 0,
mainnet: 0, // "0x123694886DBf5Ac94DDA07135349534536D14cAf"
},
governance: {
default: 2,
goerli: 0,
sepolia: 0,
mainnet: "0x9f6e831c8f8939dc0c830c6e492e7cef4f9c2f5f", // Threshold Council
},
chaosnetOwner: {
default: 3,
goerli: 0,
sepolia: 0,
// Not used for mainnet deployment scripts of `@keepn-network/tbtc-v2`.
// Used by `@keep-network/random-beacon` and `@keep-network/ecdsa`
// when deploying `SortitionPool`s.
},
esdm: {
default: 4,
goerli: 0,
sepolia: 0,
mainnet: "0x9f6e831c8f8939dc0c830c6e492e7cef4f9c2f5f", // Threshold Council
},
keepTechnicalWalletTeam: {
default: 5,
goerli: 0,
sepolia: 0,
mainnet: "0xB3726E69Da808A689F2607939a2D9E958724FC2A",
},
keepCommunityMultiSig: {
default: 6,
goerli: 0,
sepolia: 0,
mainnet: "0x19FcB32347ff4656E4E6746b4584192D185d640d",
},
treasury: {
default: 7,
goerli: 0,
sepolia: 0,
mainnet: "0x87F005317692D05BAA4193AB0c961c69e175f45f", // Token Holder DAO
},
spvMaintainer: {
default: 8,
goerli: 0,
sepolia: 0,
// We are not setting SPV maintainer for mainnet in deployment scripts.
},
coordinator: {
default: 9,
goerli: "0x4815cd81fFc21039a25aCFbD97CE75cCE8579042",
sepolia: "0x4815cd81fFc21039a25aCFbD97CE75cCE8579042",
mainnet: "0x0595acCca29654c43Bd67E18578b30a405265234",
},
v1Redeemer: {
default: 10,
goerli: 0,
sepolia: 0,
mainnet: "0x8Bac178fA95Cb56D11A94d4f1b2B1F5Fc48A30eA",
},
},
Expand Down
11 changes: 6 additions & 5 deletions typescript/scripts/refund.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ import {
DepositScript,
ElectrumClient,
ElectrumCredentials,
Hex,
} from "../src"

program
Expand Down Expand Up @@ -60,15 +61,15 @@ const depositJson = JSON.parse(fs.readFileSync(depositJsonPath, "utf-8"))

const deposit: DepositReceipt = {
depositor: depositJson.depositor,
walletPublicKeyHash: depositJson.walletPublicKeyHash,
refundPublicKeyHash: depositJson.refundPublicKeyHash,
blindingFactor: depositJson.blindingFactor,
refundLocktime: depositJson.refundLocktime,
walletPublicKeyHash: Hex.from(depositJson.walletPublicKeyHash),
refundPublicKeyHash: Hex.from(depositJson.refundPublicKeyHash),
blindingFactor: Hex.from(depositJson.blindingFactor),
refundLocktime: Hex.from(depositJson.refundLocktime),
}
const recoveryAddress = depositJson.btcRecoveryAddress

console.log("======= refund provided data ========")
console.log("deposit JSON: ", deposit)
console.log("deposit JSON: ", depositJson)
console.log("deposit recovery amount: ", refundAmount)
console.log("deposit transaction ID: ", transactionId)
console.log("deposit transaction index: ", transactionIndex)
Expand Down
3 changes: 0 additions & 3 deletions typescript/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,3 @@ export * from "./services/redemptions"

// Export the entrypoint module.
export * from "./services/tbtc"

// TODO: Replace all properties that are expected to be un-prefixed hexadecimal
// strings with a Hex type to increase API consistency.
Loading

0 comments on commit c2db098

Please sign in to comment.