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

The Big Move: implementation -> solidity #538

Merged
merged 5 commits into from
Mar 24, 2020
Merged
Show file tree
Hide file tree
Changes from all 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
32 changes: 16 additions & 16 deletions .circleci/config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -21,12 +21,12 @@ jobs:
- checkout
- run:
name: Authenticate GitHub Package Registry
working_directory: ~/project/implementation
working_directory: ~/project/solidity
command: echo "//npm.pkg.github.com/:_authToken=$GITHUB_TOKEN" >> .npmrc
- persist_to_workspace:
root: .
paths:
- implementation/.npmrc
- solidity/.npmrc

compile_contracts:
executor: docker-node
Expand All @@ -38,23 +38,23 @@ jobs:
- restore_cache:
keys:
# When lock file changes, use increasingly general patterns to restore cache.
- v1-client-npm-deps-{{ .Branch }}-{{ checksum "implementation/package-lock.json" }}
- v1-client-npm-deps-{{ .Branch }}-{{ checksum "solidity/package-lock.json" }}
- v1-client-npm-deps-{{ .Branch }}-
- v1-client-npm-deps-
- run: cd implementation && npm install
- run: cd solidity && npm install
- save_cache:
key: v1-client-npm-deps-{{ .Branch }}-{{ checksum "implementation/package-lock.json" }}
key: v1-client-npm-deps-{{ .Branch }}-{{ checksum "solidity/package-lock.json" }}
paths:
- implementation/node_modules
- solidity/node_modules

- run: cd implementation && node_modules/.bin/truffle compile
- run: cd solidity && node_modules/.bin/truffle compile

# Persist for downstream use.
- persist_to_workspace:
root: .
paths:
- implementation/node_modules
- implementation/build/contracts
- solidity/node_modules
- solidity/build/contracts

lint:
executor: docker-node
Expand All @@ -64,7 +64,7 @@ jobs:
at: .
- run:
name: Lint Implementation
working_directory: ~/project/implementation
working_directory: ~/project/solidity
command: |
set -ex
npm run lint
Expand All @@ -77,12 +77,12 @@ jobs:
- run: sudo npm install -g ganache-cli@6.4.2
- run:
name: Running testrpc
working_directory: ~/project/implementation
working_directory: ~/project/solidity
command: ganache-cli
background: true
- run:
name: Run NPM tests
working_directory: ~/project/implementation
working_directory: ~/project/solidity
command: npm run test:quick
generate_pngs:
docker:
Expand Down Expand Up @@ -125,7 +125,7 @@ jobs:
- run:
name: Generate solidity docs
command: |
cd implementation/docs
cd solidity/docs
mkdir -p output
node generate-api-docs.js > output/index.adoc
Expand Down Expand Up @@ -187,7 +187,7 @@ jobs:
at: .
- run:
name: Remove Installed node_module
working_directory: ~/project/implementation
working_directory: ~/project/solidity
command: |
rm -rf node_modules
- run:
Expand All @@ -197,7 +197,7 @@ jobs:
gcloud auth activate-service-account --key-file ~/gcloud-service-key.json
export UNISWAP_CONTRACT_DATA="uniswap-contract-data.txt"
export BONDED_ECDSA_KEEP_VENDOR_CONTRACT_DATA="BondedECDSAKeepVendor.json"
implementation/scripts/circleci-provision-external-contracts.sh
solidity/scripts/circleci-provision-external-contracts.sh
- run:
name: Migrate Contracts
command: |
Expand All @@ -206,7 +206,7 @@ jobs:
export BUILD_TAG=$CIRCLE_SHA1
export TRUFFLE_NETWORK=$TRUFFLE_NETWORK
mkdir -p /tmp/tbtc/contracts
implementation/scripts/circleci-migrate-contracts.sh
solidity/scripts/circleci-migrate-contracts.sh
- persist_to_workspace:
root: /tmp/tbtc
paths:
Expand Down
4 changes: 2 additions & 2 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -6,13 +6,13 @@
hooks:
- id: lint-js
name: 'lint js'
entry: /usr/bin/env bash -c "cd implementation && npm run lint:js"
entry: /usr/bin/env bash -c "cd solidity && npm run lint:js"
files: '\.js$'
language: script
description: "Checks JS code according to the package's linter configuration"
- id: lint-sol
name: 'lint solidity'
entry: /usr/bin/env bash -c "cd implementation && npm run lint:sol"
entry: /usr/bin/env bash -c "cd solidity && npm run lint:sol"
files: '\.sol$'
language: script
description: "Checks Solidity code according to the package's linter configuration"
4 changes: 2 additions & 2 deletions README.adoc
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ federated sidechains like https://blockstream.com/liquid/[Liquid],
expanding use cases possible via today's Bitcoin network, while bringing
superior money to other chains.

This repo contains the Solidity link:implementation/[smart contracts]
This repo contains the Solidity link:solidity/[smart contracts]
and link:docs/[specification].

toc::[]
Expand Down Expand Up @@ -101,7 +101,7 @@ Clone and install dependencies:
[source,sh]
----
git clone https://github.com/keep-network/tbtc
cd tbtc/implementation
cd tbtc/solidity
npm install
----

Expand Down
4 changes: 2 additions & 2 deletions docs/introduction-to-tbtc.md
Original file line number Diff line number Diff line change
Expand Up @@ -87,8 +87,8 @@ The redemption flow is as follows:

The "happy paths" have been covered, but there hasn't been discussion of when *things fall apart*.

To disincentivise signers from stealing bitcoin, deposits are overcollateralised with ETH. The collateral is priced using an on-chain [ETH:BTC price feed](https://github.com/keep-network/tbtc/blob/master/implementation/contracts/price-feed/BTCETHPriceFeed.sol), which is operated by MakerDAO. This collateral also ensures guarantees of signer availability within the protocol.
To disincentivise signers from stealing bitcoin, deposits are overcollateralised with ETH. The collateral is priced using an on-chain [ETH:BTC price feed](https://github.com/keep-network/tbtc/blob/master/solidity/contracts/price-feed/BTCETHPriceFeed.sol), which is operated by MakerDAO. This collateral also ensures guarantees of signer availability within the protocol.

---

*If you have any questions, suggestions, improvements, don't hesitate to reach out via GitHub and/or [chat on Discord](https://discord.gg/4R6RGFf).*
*If you have any questions, suggestions, improvements, don't hesitate to reach out via GitHub and/or [chat on Discord](https://discord.gg/4R6RGFf).*
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
Original file line number Diff line number Diff line change
Expand Up @@ -12,15 +12,15 @@ toc::[]
`

let jsonFiles = [
"../../implementation/build/contracts/TBTCSystem.json",
// "../../implementation/build/contracts/TBTCConstants.json",
"../../implementation/build/contracts/Deposit.json",
"../../implementation/build/contracts/DepositStates.json",
"../../implementation/build/contracts/DepositFunding.json",
"../../implementation/build/contracts/DepositRedemption.json",
"../../implementation/build/contracts/DepositLiquidation.json",
"../../implementation/build/contracts/IBTCETHPriceFeed.json",
"../../implementation/build/contracts/IBondedECDSAKeep.json",
"../../solidity/build/contracts/TBTCSystem.json",
// "../../solidity/build/contracts/TBTCConstants.json",
"../../solidity/build/contracts/Deposit.json",
"../../solidity/build/contracts/DepositStates.json",
"../../solidity/build/contracts/DepositFunding.json",
"../../solidity/build/contracts/DepositRedemption.json",
"../../solidity/build/contracts/DepositLiquidation.json",
"../../solidity/build/contracts/IBTCETHPriceFeed.json",
"../../solidity/build/contracts/IBondedECDSAKeep.json",
]

jsonFiles.forEach(file => {
Expand Down
File renamed without changes.
Original file line number Diff line number Diff line change
Expand Up @@ -25,10 +25,10 @@ EOF
echo "<<<<<<START Prep Utility Box For Migration START<<<<<<"
echo "ssh utilitybox rm -rf /tmp/$BUILD_TAG"
echo "ssh utilitybox mkdir /tmp/$BUILD_TAG"
echo "scp -r ./implementation utilitybox:/tmp/$BUILD_TAG/"
echo "scp -r ./solidity utilitybox:/tmp/$BUILD_TAG/"
ssh utilitybox rm -rf /tmp/$BUILD_TAG
ssh utilitybox mkdir /tmp/$BUILD_TAG
scp -r ./implementation utilitybox:/tmp/$BUILD_TAG/
scp -r ./solidity utilitybox:/tmp/$BUILD_TAG/
echo ">>>>>>FINISH Prep Utility Box For Migration FINISH>>>>>>"

# Run migration
Expand All @@ -52,7 +52,7 @@ ssh utilitybox << EOF
echo ">>>>>>FINISH Setting Contract Owner Key FINISH>>>>>>"

echo "<<<<<<START Contract Migration START<<<<<<"
cd /tmp/$BUILD_TAG/implementation
cd /tmp/$BUILD_TAG/solidity
npm ci
./node_modules/.bin/truffle migrate --reset --network $TRUFFLE_NETWORK
echo ">>>>>>FINISH Contract Migration FINISH>>>>>>"
Expand All @@ -63,8 +63,8 @@ ssh utilitybox << EOF
EOF

echo "<<<<<<START Contract Copy START<<<<<<"
echo "scp utilitybox:/tmp/$BUILD_TAG/implementation/build/contracts/* /tmp/tbtc/contracts"
scp utilitybox:/tmp/$BUILD_TAG/implementation/build/contracts/* /tmp/tbtc/contracts
echo "scp utilitybox:/tmp/$BUILD_TAG/solidity/build/contracts/* /tmp/tbtc/contracts"
scp utilitybox:/tmp/$BUILD_TAG/solidity/build/contracts/* /tmp/tbtc/contracts
echo ">>>>>>FINISH Contract Copy>>>>>>"

echo "<<<<<<START Migration Dir Cleanup START<<<<<<"
Expand Down
Original file line number Diff line number Diff line change
@@ -1,19 +1,19 @@
#!/bin/bash
set -ex

# BondedECDSAKeepVendorAddress: Migration from keep-network/keep-tecdsa
# BondedECDSAKeepVendorAddress: Migration from keep-network/keep-ecdsa
# BONDED_ECDSA_KEEP_VENDOR_CONTRACT_DATA is set in the CircleCI job config
# ETH_NETWORK_ID is set in the CircleCI context for each deployed environment
BONDED_ECDSA_KEEP_VENDOR_ADDRESS=""

function fetch_bonded_keep_vendor_address() {
gsutil -q cp gs://${CONTRACT_DATA_BUCKET}/keep-tecdsa/${BONDED_ECDSA_KEEP_VENDOR_CONTRACT_DATA} ./
gsutil -q cp gs://${CONTRACT_DATA_BUCKET}/keep-ecdsa/${BONDED_ECDSA_KEEP_VENDOR_CONTRACT_DATA} ./
BONDED_ECDSA_KEEP_VENDOR_ADDRESS=$(cat ./${BONDED_ECDSA_KEEP_VENDOR_CONTRACT_DATA} | jq ".networks[\"${ETH_NETWORK_ID}\"].address" | tr -d '"')
}

function set_bonded_keep_vendor_address() {
# TODO: Replace file we store external addresses by a `json` file and use `jq` to update it.
sed -i -e "/BondedECDSAKeepVendorAddress/s/0x[a-zA-Z0-9]\{0,40\}/${BONDED_ECDSA_KEEP_VENDOR_ADDRESS}/" ./implementation/migrations/externals.js
sed -i -e "/BondedECDSAKeepVendorAddress/s/0x[a-zA-Z0-9]\{0,40\}/${BONDED_ECDSA_KEEP_VENDOR_ADDRESS}/" ./solidity/migrations/externals.js
}

fetch_bonded_keep_vendor_address
Expand Down
File renamed without changes.