Skip to content

Commit

Permalink
Bump geth and minor testnet changes (#439)
Browse files Browse the repository at this point in the history
* set cache-control to no-cache

* set cache-control to no-cache on test

* set cache-control to no-cache on prod

* Redeploy testnet (#438)

* Use PRIVATEKEY_OWNER_ETH account on test/eth

* PrimaryTokensDeploy should skip NOT primary tokens

* Remove upgrade code

* Redeploy testnet

* Update testnet addresses in relay

* Write a little documentation for contracts

* Update provider urls in relay cfg;
Delete unused cfgs

* Add more info to error

* Temporary print to investigate weird bug

* Update ambFaucet address on bsc-test

* Temporary print to investigate weird bug

* Temporary print to investigate weird bug

* add decimals value for bsc network in USDT

* Bump geth version to properly calc sepolia block hash

---------

Co-authored-by: november-pain <[email protected]>
Co-authored-by: Igor Kishko <[email protected]>
  • Loading branch information
3 people authored Apr 16, 2023
1 parent b1541b7 commit 1cdd2c9
Show file tree
Hide file tree
Showing 62 changed files with 1,948 additions and 4,408 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/upload_config_dev.yml
Original file line number Diff line number Diff line change
Expand Up @@ -28,4 +28,4 @@ jobs:

- name: Upload config
run: |
aws s3 cp contracts/configs/dev.json s3://bridge-config.ambrosus-dev.io/index.html --content-type application/json
aws s3 cp contracts/configs/dev.json s3://bridge-config.ambrosus-dev.io/index.html --content-type application/json --cache-control no-cache
2 changes: 1 addition & 1 deletion .github/workflows/upload_config_prod.yml
Original file line number Diff line number Diff line change
Expand Up @@ -27,4 +27,4 @@ jobs:

- name: Upload config
run: |
aws s3 cp contracts/configs/main.json s3://bridge-config.ambrosus.io/index.html --content-type application/json
aws s3 cp contracts/configs/main.json s3://bridge-config.ambrosus.io/index.html --content-type application/json --cache-control no-cache
2 changes: 1 addition & 1 deletion .github/workflows/upload_config_test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -28,4 +28,4 @@ jobs:

- name: Upload config
run: |
aws s3 cp contracts/configs/test.json s3://bridge-config.ambrosus-test.io/index.html --content-type application/json
aws s3 cp contracts/configs/test.json s3://bridge-config.ambrosus-test.io/index.html --content-type application/json --cache-control no-cache
48 changes: 25 additions & 23 deletions contracts/configs/test.json
Original file line number Diff line number Diff line change
@@ -1,15 +1,15 @@
{
"bridges": {
"eth": {
"amb": "0xcdea3ECb85D0F386Ea5D498D39c9c127380F254a",
"side": "0xACf183fB8C6382d7cB0D5e9832528AEafC151Fcf"
"amb": "0xb08cFc95eEA0F1d9Bb79002d23FA204B8836A536",
"side": "0xFCE5b5ca100e58E5635B15b79F0163be4CbD258b"
},
"bsc": {
"amb": "0xa09De74437D2453Df47deF3F5C2d14Cd3f0cF8c0",
"side": "0x4a69003c355656Acf4860Ff3e7cdd6f37CdC3248"
"amb": "0xdC103bf9a3789f78958f365321F3BA07e369667A",
"side": "0x8619f5E8315aff3E7Eba238492906329414084Da"
}
},
"ambFaucetAddress": "0x7b8A17Fc98711db0870c7F37A45d069f2B750637",
"ambFaucetAddress": "0xE2Fb2d9014B4c7b2705F81D21a6693219Cc518Ba",
"tokens": {
"SAMB": {
"isActive": true,
Expand All @@ -25,9 +25,9 @@
"amb"
],
"addresses": {
"amb": "0xDA9BB33F9E3334781f3e4fce310288D7dB3eD29a",
"eth": "0xfc277855999cF6452F9027BbdC1B56264A736E3A",
"bsc": "0xDAA9Ee2aB371E31a75Faf93D0b859561a5D8a58f"
"amb": "0x7cee2ae3042D2C646Aa24FACfA92dfeE589046f0",
"eth": "0x9Ba7ef7E1C6C5EF4fe7e2A32d4527497D6B12Ff2",
"bsc": "0xC61D0CfaDc9bE2EF05288D04EbCC8ec8035D7aC6"
},
"nativeAnalog": "AMB"
},
Expand All @@ -44,8 +44,8 @@
"eth"
],
"addresses": {
"amb": "0x075dE66D19CA867387c75C880CffddBA9A3E9763",
"eth": "0xd67A7CE611C1b33A549712c0FcbFE8436A917b71",
"amb": "",
"eth": "0x5ECfeaD3d77F6814D189F6209ea27eCD1c00D45a",
"bsc": ""
},
"nativeAnalog": "ETH"
Expand All @@ -63,9 +63,9 @@
"bsc"
],
"addresses": {
"amb": "0xD52F6e6aD16904a23E5cA0309098652502CA97E8",
"amb": "",
"eth": "",
"bsc": "0x8601876F8A6DCcAE5Ce8Cf154f710E09c3f0f2c8"
"bsc": "0x3050A5cBe1ec89917933476a99962A40e802B89C"
},
"nativeAnalog": "BNB"
},
Expand All @@ -84,9 +84,9 @@
"bsc"
],
"addresses": {
"amb": "0x56a79d39fc414Ff11EbB30d6a5367ea5da8c6fE9",
"eth": "0x1D335E8B7787fB6c51F98713df5BCb56884FD023",
"bsc": "0x3a5633bAE0243bB360e25624DC6dFd241333B575"
"amb": "0x952b98DBDa3319BF0e339cC9CC574fF768F80f3c",
"eth": "0xB841C5707DA4B43eD915B707158010bd2FaF3B46",
"bsc": "0x9CE86a22E9a89a4d716Ee23d057389c3df3E26A5"
},
"nativeAnalog": ""
},
Expand All @@ -96,16 +96,18 @@
"symbol": "USDT",
"denomination": 18,
"decimals": {
"eth": 6
"eth": 6,
"bsc": 18
},
"logo": "https://etherscan.io/token/images/tether_32.png",
"primaryNets": [
"eth"
"eth",
"bsc"
],
"addresses": {
"amb": "0xa945ec3B3227731f8df905424041D9ab23778D8E",
"eth": "0xd3c82866DD68CBDD292db2A82cd6f41B5c93A9C6",
"bsc": ""
"amb": "0x1bB13b68DbA3571415B4092802777B5cA15de897",
"eth": "0x05875578a63C7E26245c7CBa3cF460fF6a613c6B",
"bsc": "0x62c6e4534594aD39307FE654D5260f12010A297E"
},
"nativeAnalog": ""
},
Expand All @@ -122,11 +124,11 @@
"bsc"
],
"addresses": {
"amb": "0x9F9B96F8d33B58c85f0E5bB4BE53164c0Fe77cD9",
"amb": "0xfB069aFFe6e75674FaBf67108e9094fb988A31D9",
"eth": "",
"bsc": "0x7E0F09c8c2aAf4743B57355edb051F5E5ED6F73d"
"bsc": "0x446c2daE148049E53D0489A8cc0D7E55CF3Da5df"
},
"nativeAnalog": ""
}
}
}
}
36 changes: 36 additions & 0 deletions contracts/contracts/contracts.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
## Contracts

### Networks
**Entry point for bridge contracts**
Contains a pair of 2 contracts for each bridge.
These contracts are inherited from `common/CommonBridge.sol` and some check from `checks` (currently all contracts are `CheckUntrustless2`)

### Common
Common structs and code for bridges

### Checks
Functions that validate information submitted in bridge.
- `CheckUntrustless` - is like onchain multisig for relays - relays push their data into `checkUntrustless_` method and
when all relays signs are collected - this function return `true` and the data is considered valid.
Currently not used in favor of `CheckUntrustless2`
- `CheckUntrustless2` - just empty contract. There is no checks, coz relays must create MPC signature
which will indicate their consensus and will be accepted by the contract (coz it address has RELAY role)
- `SignatureCheck` - utility function to check ECDSA sign.

### Tokens
- `IWrapper` - interface for wrapper contracts for native coins (like WETH in ethereum network and SAMB in ambrosus)
- `sAMB` - ERC20 wrapper for native amb coin
- `BridgeERC20` - contract for **synthetic tokens** (i.e. bridge can mint and burn them) for network != AMB
- `BridgeERC20_Amb` - contract for **synthetic tokens** (i.e. bridge can mint and burn them) for AMB network.
It different from the `BridgeERC20` in that **it can have different decimals** depending on which bridge
(ex: ETH or BSC) are using for transferring him.
For example, if USDT has 6 decimals in ETH network and 18 decimals in BSC and AMB networks, it will works like this:
- `ETH -> AMB: 1 USDT (1e6 ) -> 1 USDT (1e18)`
- `AMB -> BSC: 1 USDT (1e18) -> 1 USDT (1e18)`
- `ETH -> ETH: 1 USDT (1e6 ) -> 1 USDT (1e6 )`
- `BridgeERC20_Amb_OLD` - like previous one, but has unpleasant feature: allowance need to be set with
ANOTHER token denomination and user will see counterintuitive amount in increaseAllowance() function

## Contracts_For_Test
Wrappers for contracts with some methods has their public `Test`-suffixed version.
- `MintableERC20` - deployed in testnets instead of primary (i.e. not synthetics) tokens. Has `mint()` method
2 changes: 1 addition & 1 deletion contracts/deploy/00_PrimaryTokensTestnets.ts
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ const func: DeployFunction = async function (hre: HardhatRuntimeEnvironment) {
console.log(token.symbol, "already or should not be deployed.");
continue;
}
if (isTokenPrimary(token, netName)) {
if (!isTokenPrimary(token, netName)) {
console.log(token.symbol, "is synthetic token, skip it.");
continue;
}
Expand Down
18 changes: 1 addition & 17 deletions contracts/deploy/03_BSC_AmbBridge.ts
Original file line number Diff line number Diff line change
Expand Up @@ -19,24 +19,9 @@ const func: DeployFunction = async function (hre: HardhatRuntimeEnvironment) {
timeframeSeconds: isMainNet ? 60 * 60 * 4 : 60,
lockTime: isMainNet ? 60 * 10 : 60,
minSafetyBlocks: 10,
}, [],
}, []
);

// upgrade to untrustless-mpc; set watchdogs and fee_provider roles; remove DEFAULT_ADMIN_ROLE from deployer; remove RELAY_ROLE from old relay
let {owner} = await hre.getNamedAccounts();
const prod_addresses = getAddresses(BRIDGE_NAME);
deployOptions.proxy.execute.onUpgrade = {
methodName: "upgrade",
args: [
prod_addresses.watchdogsAddresses, // grand WATCHDOG_ROLEs
isMainNet ? prod_addresses.feeProviderAddress : owner, // grand FEE_PROVIDER_ROLE
isMainNet ? prod_addresses.relayAddress : owner, // grand RELAY_ROLE to new mpc relay

isMainNet ? prod_addresses.adminAddress : owner, // remove DEFAULT_ADMIN_ROLE from this address
isMainNet ? prod_addresses.feeProviderAddress : owner // remove RELAY_ROLE from this address (it's old relay address)
]
};


if (isMainNet) {
console.log("To update prod contract remove this if statement :)");
Expand All @@ -54,7 +39,6 @@ const func: DeployFunction = async function (hre: HardhatRuntimeEnvironment) {
console.log('Call this cmd second time to set sideBridgeAddress or update tokens')
return;
}

}

// set sideBridgeAddress
Expand Down
20 changes: 2 additions & 18 deletions contracts/deploy/03_ETH_AmbBridge.ts
Original file line number Diff line number Diff line change
Expand Up @@ -20,27 +20,12 @@ const func: DeployFunction = async function (hre: HardhatRuntimeEnvironment) {
lockTime: isMainNet ? 60 * 10 : 60,
minSafetyBlocks: 10,
}, []
)

// upgrade to untrustless-mpc; set watchdogs and fee_provider roles; remove DEFAULT_ADMIN_ROLE from deployer; remove RELAY_ROLE from old relay
let {owner} = await hre.getNamedAccounts();
const prod_addresses = getAddresses(BRIDGE_NAME);
deployOptions.proxy.execute.onUpgrade = {
methodName: "upgrade",
args: [
prod_addresses.watchdogsAddresses, // grand WATCHDOG_ROLEs
isMainNet ? prod_addresses.feeProviderAddress: owner, // grand FEE_PROVIDER_ROLE
isMainNet ? prod_addresses.relayAddress : owner, // grand RELAY_ROLE to new mpc relay

isMainNet ? prod_addresses.adminAddress : owner, // remove DEFAULT_ADMIN_ROLE from this address
isMainNet ? prod_addresses.feeProviderAddress: owner // remove RELAY_ROLE from this address (it's old relay address)
]
};
);


if (isMainNet) {
console.log("To update prod contract remove this if statement :)");
} else {
} else {

const deployResult = await hre.deployments.deploy(BRIDGE_NAME, {
contract: BRIDGE_NAME,
Expand All @@ -54,7 +39,6 @@ const func: DeployFunction = async function (hre: HardhatRuntimeEnvironment) {
console.log('Call this cmd second time to set sideBridgeAddress or update tokens')
return;
}

}

// set sideBridgeAddress
Expand Down
21 changes: 2 additions & 19 deletions contracts/deploy/04_BSC_BscBridge.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ const func: DeployFunction = async function (hre: HardhatRuntimeEnvironment) {
const ambNet = hre.companionNetworks['amb']
const ambBridge = await ambNet.deployments.get('BSC_AmbBridge');

const deployOptions = await options(hre, BRIDGE_NAME, tokenPairs,
const deployOptions: any = await options(hre, BRIDGE_NAME, tokenPairs,
{
sideBridgeAddress: ambBridge.address,
wrappingTokenAddress: configFile.tokens.WBNB.addresses.bsc,
Expand All @@ -24,26 +24,9 @@ const func: DeployFunction = async function (hre: HardhatRuntimeEnvironment) {
}, []
);

// upgrade to untrustless-mpc; set watchdogs and fee_provider roles; remove DEFAULT_ADMIN_ROLE from deployer; remove RELAY_ROLE from old relay
let {owner} = await hre.getNamedAccounts();
const prod_addresses = getAddresses(BRIDGE_NAME);
// @ts-ignore
deployOptions.proxy.execute.onUpgrade = {
methodName: "upgrade",
args: [
prod_addresses.watchdogsAddresses, // grand WATCHDOG_ROLEs
isMainNet ? prod_addresses.feeProviderAddress: owner, // grand FEE_PROVIDER_ROLE
isMainNet ? prod_addresses.relayAddress : owner, // grand RELAY_ROLE to new mpc relay

isMainNet ? prod_addresses.adminAddress : owner, // remove DEFAULT_ADMIN_ROLE from this address
isMainNet ? prod_addresses.feeProviderAddress: owner // remove RELAY_ROLE from this address (it's old relay address)
]
};


if (isMainNet) {
console.log("To update prod contract remove this if statement :)");
} else {
} else {

const deployResult = await hre.deployments.deploy(BRIDGE_NAME, {
contract: BRIDGE_NAME,
Expand Down
Loading

0 comments on commit 1cdd2c9

Please sign in to comment.