-
Notifications
You must be signed in to change notification settings - Fork 118
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #3341 from Sifchain/mergeSmartContracts
Merge Peggy2 Smart Contracts into master
- Loading branch information
Showing
205 changed files
with
47,378 additions
and
70,936 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -17,16 +17,10 @@ jobs: | |
- name: Use Node.js | ||
uses: actions/[email protected] | ||
with: | ||
node-version: '14.x' | ||
node-version: '18.x' | ||
|
||
- name: Install dependencies | ||
run: npm install | ||
|
||
- name: Install truffle | ||
run: npm i -g truffle | ||
|
||
- name: Test Setup | ||
run: npm run test:setup | ||
|
||
- name: Run truffle tests | ||
run: npm run test | ||
- name: Run hardhat tests | ||
run: make tests |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -9,3 +9,8 @@ venv | |
/artifacts/ | ||
/cache/ | ||
/.idea/ | ||
relayerdb/ | ||
witnessdb/ | ||
*.pyc | ||
package-lock.json | ||
.hardhat-compile |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
{ | ||
"overrides": [ | ||
{ | ||
"files": "*.sol", | ||
"options": { | ||
"printWidth": 100, | ||
"tabWidth": 2, | ||
"useTabs": false, | ||
"singleQuote": false, | ||
"bracketSpacing": true, | ||
"explicitTypes": "always" | ||
} | ||
}, | ||
{ | ||
"files": "*.js", | ||
"options": { | ||
"printWidth": 100, | ||
"tabWidth": 2, | ||
"useTabs": false, | ||
"singleQuote": false | ||
} | ||
}, | ||
{ | ||
"files": "*.ts", | ||
"options": { | ||
"printWidth": 100, | ||
"tabWidth": 2, | ||
"useTabs": false, | ||
"singleQuote": false, | ||
"semi": true, | ||
"trailingComma": es5 | ||
} | ||
} | ||
] | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
module.exports = { | ||
skipFiles: [ | ||
'BridgeRegistry.sol', | ||
'Migrations.sol', | ||
'Mocks/TrollToken.sol', | ||
'MockUpgrade/MockCosmsosBridgeUpgrade.sol', | ||
'SifchainTestToken.sol', | ||
] | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,77 @@ | ||
# How to: Add IBC ERC20 tokens | ||
|
||
## Setup | ||
|
||
For a mainnet deployment, modify the .env file to include: | ||
|
||
``` | ||
MAINNET_URL=<mainnet_url> | ||
MAINNET_PRIVATE_KEY=<private_key> | ||
DEPLOYMENT_NAME=<deployment_name> | ||
TOKEN_FILE=data/ibc_mainnet_tokens.json | ||
TOKEN_ADDRESS_FILE=data/ibc_token_addresses.jsonl | ||
``` | ||
|
||
Where: | ||
|
||
| Item | Description | | ||
| ---------------------- | ------------------------------------------------------------ | | ||
| `<mainnet_url>` | Replace with the Infura Mainnet URL | | ||
| `<private_key>` | Replace with the ETH Private Key for the BridgeBank operator | | ||
| `<deployment_name>` | Replace with the deployment name like sifchain | | ||
| `<token_file>` | File with information on new tokens to be deployed | | ||
| `<token_address_file>` | File where new tokens that are created will be written to | | ||
|
||
# Overview | ||
|
||
There are two distinct steps to this script. | ||
|
||
One is creating the new bridge tokens. | ||
Two is attaching the bridge tokens to the bridgebank by calling addExistingBridgeToken on the bridgebank. | ||
|
||
The script to attach bridge tokens will be run by a user with priviledged access to the bridgebank with the owner role. | ||
|
||
## Mainnet Token Deployment | ||
|
||
This does not require any special permissions. Tokens will be handed off to another user | ||
before they're attached to the BridgeBank. | ||
|
||
cd smart-contracts | ||
npm install | ||
npx hardhat run scripts/create_ibc_matching_token.ts --network mainnet | grep -v 'No need to generate' | tee data/ibc_token_addresses.jsonl | ||
|
||
## Steps to Attach Tokens to BridgeBank | ||
|
||
This requires the private key of the BridgeBank owner. | ||
|
||
cd smart-contracts | ||
npm install | ||
npx hardhat run scripts/attach_ibc_matching_token.ts --network mainnet < data/ibc_token_addresses.jsonl | ||
|
||
## Testing with forked mainnnet | ||
|
||
Since you're running two scripts, you'll need a hardhat node running (otherwise the first script will run, execute transactions, then throw them away) | ||
|
||
Start a hardhat node in a shell: | ||
|
||
npx hardhat node --verbose | ||
|
||
Then run the two scripts in a different shell: | ||
|
||
npx hardhat run scripts/create_ibc_matching_token.ts --network localhost | grep -v 'No need to generate' | tee test_data/ibc_token_addresses.jsonl | ||
npx hardhat run scripts/attach_ibc_matching_token.ts --network localhost < test_data/ibc_token_addresses.jsonl | ||
|
||
or for ropsten | ||
|
||
npx hardhat run scripts/create_ibc_matching_token.ts --network ropsten | grep -v 'No need to generate' | tee test_data/ibc_token_addresses.jsonl | ||
npx hardhat run scripts/attach_ibc_matching_token.ts --network ropsten < test_data/ibc_token_addresses.jsonl | ||
|
||
# Updating dev and test deployments | ||
|
||
## Update symbol_translator.json | ||
|
||
Modify https://github.com/Sifchain/chainOps/blob/main/.github/workflows/variableMapping/ebrelayer.yaml | ||
with the new symbol_translation.json entries. It's a yaml file, so you need to escape json - you could | ||
use something like ```jq -aRs``` to do the quoting. | ||
|
||
To push that data out and restart the relayers, use https://github.com/Sifchain/chainOps/actions/workflows/peggy-ebrelayer-deployment.yml |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
artifacts=artifacts/contracts/Blocklist.sol/Blocklist.json artifacts/contracts/Valset.sol/Valset.json artifacts/contracts/ValsetStorage.sol/ValsetStorage.json artifacts/contracts/CosmosBridgeStorage.sol/CosmosBridgeStorage.json artifacts/contracts/BridgeBank/CosmosWhiteList.sol/CosmosWhiteList.json artifacts/contracts/BridgeBank/CosmosWhiteListStorage.sol/CosmosWhiteListStorage.json artifacts/contracts/BridgeBank/BankStorage.sol/BankStorage.json artifacts/contracts/BridgeBank/CosmosBank.sol/CosmosBank.json artifacts/contracts/BridgeBank/Rowan.sol/Rowan.json artifacts/contracts/BridgeBank/BridgeToken.sol/BridgeToken.json artifacts/contracts/BridgeBank/EthereumWhitelist.sol/EthereumWhiteList.json artifacts/contracts/BridgeBank/BridgeBank.sol/BridgeBank.json artifacts/contracts/BridgeBank/Pausable.sol/Pausable.json artifacts/contracts/BridgeBank/EthereumBankStorage.sol/EthereumBankStorage.json artifacts/contracts/BridgeBank/PauserRole.sol/PauserRole.json artifacts/contracts/BridgeBank/CosmosBankStorage.sol/CosmosBankStorage.json artifacts/contracts/OracleStorage.sol/OracleStorage.json artifacts/contracts/interfaces/IBlocklist.sol/IBlocklist.json artifacts/contracts/Oracle.sol/Oracle.json artifacts/contracts/CosmosBridge.sol/CosmosBridge.json artifacts/contracts/Mocks/FailHardToken.sol/FailHardToken.json artifacts/contracts/Mocks/Erowan.sol/Erowan.json artifacts/contracts/Mocks/ReentrancyToken.sol/ReentrancyToken.json artifacts/contracts/Mocks/FakeERC20.sol/FakeERC20.json artifacts/contracts/Mocks/ManyDecimalsToken.sol/ManyDecimalsToken.json artifacts/contracts/Mocks/TrollToken.sol/TrollToken.json artifacts/contracts/BridgeRegistry.sol/BridgeRegistry.json |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
smartContracts=contracts/Blocklist.sol contracts/Valset.sol contracts/ValsetStorage.sol contracts/CosmosBridgeStorage.sol contracts/BridgeBank/CosmosWhiteList.sol contracts/BridgeBank/CosmosWhiteListStorage.sol contracts/BridgeBank/BankStorage.sol contracts/BridgeBank/CosmosBank.sol contracts/BridgeBank/Rowan.sol contracts/BridgeBank/BridgeToken.sol contracts/BridgeBank/EthereumWhitelist.sol contracts/BridgeBank/BridgeBank.sol contracts/BridgeBank/Pausable.sol contracts/BridgeBank/EthereumBankStorage.sol contracts/BridgeBank/PauserRole.sol contracts/BridgeBank/CosmosBankStorage.sol contracts/OracleStorage.sol contracts/interfaces/IBlocklist.sol contracts/Oracle.sol contracts/CosmosBridge.sol contracts/Mocks/FailHardToken.sol contracts/Mocks/Erowan.sol contracts/Mocks/ReentrancyToken.sol contracts/Mocks/FakeERC20.sol contracts/Mocks/ManyDecimalsToken.sol contracts/Mocks/TrollToken.sol contracts/BridgeRegistry.sol |
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
All documentation related to smart contracts and peggy2 can be found in /docs/peggy/docs/ in this repo or online | ||
at https://peggy.sifchain.finance. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
To run unit tests that rely on devenv, start devenv in a terminal: | ||
|
||
npx hardhat run scripts/devenv.ts | ||
|
||
And then run the tests in another terminal: | ||
|
||
npx hardhat test test/devenv/test_lockburn.ts --network localhost | ||
|
||
The VERBOSE environment variable can be set to: | ||
|
||
* summary - only print summary lines | ||
* (not set) - no verbose output | ||
* any string other than summary - full json output |
Oops, something went wrong.