Skip to content

Commit

Permalink
Update
Browse files Browse the repository at this point in the history
  • Loading branch information
wcgcyx committed Nov 21, 2023
1 parent 0a24fd6 commit f1c8948
Show file tree
Hide file tree
Showing 5 changed files with 40 additions and 0 deletions.
6 changes: 6 additions & 0 deletions scripts/bootstrap/.env.example
Original file line number Diff line number Diff line change
Expand Up @@ -77,6 +77,12 @@ RATE_LIMIT_IMX_CAPACITY=
RATE_LIMIT_IMX_REFILL_RATE=
## The large threshold of the rate limit policy of IMX token, unit is in 10^18.
RATE_LIMIT_IMX_LARGE_THRESHOLD=
## The capacity of the rate limit policy of ETH token, unit is in 10^18.
RATE_LIMIT_ETH_CAPACITY=
## The refill rate of the rate limit policy of ETH token, unit is in 10^18.
RATE_LIMIT_ETH_REFILL_RATE=
## The large threshold of the rate limit policy of ETH token, unit is in 10^18.
RATE_LIMIT_ETH_LARGE_THRESHOLD=

# Set prior to 2_deployment_validation.js
CHILD_GATEWAY_ADDRESS=
Expand Down
12 changes: 12 additions & 0 deletions scripts/bootstrap/8_root_initialisation.js
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,9 @@ async function run() {
let rateLimitIMXCap = helper.requireEnv("RATE_LIMIT_IMX_CAPACITY");
let rateLimitIMXRefill = helper.requireEnv("RATE_LIMIT_IMX_REFILL_RATE");
let rateLimitIMXLargeThreshold = helper.requireEnv("RATE_LIMIT_IMX_LARGE_THRESHOLD");
let rateLimitETHCap = helper.requireEnv("RATE_LIMIT_ETH_CAPACITY");
let rateLimitETHRefill = helper.requireEnv("RATE_LIMIT_ETH_REFILL_RATE");
let rateLimitETHLargeThreshold = helper.requireEnv("RATE_LIMIT_ETH_LARGE_THRESHOLD");

// Read from contract file.
let data = fs.readFileSync(".child.bridge.contracts.json", 'utf-8');
Expand Down Expand Up @@ -100,6 +103,15 @@ async function run() {
);
await helper.waitForReceipt(resp.hash, rootProvider);

// ETH
resp = await rootBridge.connect(rateAdminWallet).setRateControlThreshold(
await rootBridge.NATIVE_ETH(),
ethers.utils.parseEther(rateLimitETHCap),
ethers.utils.parseEther(rateLimitETHRefill),
ethers.utils.parseEther(rateLimitETHLargeThreshold)
);
await helper.waitForReceipt(resp.hash, rootProvider);

// Initialise root adaptor
let rootAdaptorObj = JSON.parse(fs.readFileSync('../../out/RootAxelarBridgeAdaptor.sol/RootAxelarBridgeAdaptor.json', 'utf8'));
console.log("Initialise root adaptor...");
Expand Down
6 changes: 6 additions & 0 deletions scripts/bootstrap/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -102,6 +102,12 @@ RATE_LIMIT_IMX_CAPACITY=
RATE_LIMIT_IMX_REFILL_RATE=
## The large threshold of the rate limit policy of IMX token, unit is in 10^18.
RATE_LIMIT_IMX_LARGE_THRESHOLD=
## The capacity of the rate limit policy of ETH token, unit is in 10^18.
RATE_LIMIT_ETH_CAPACITY=
## The refill rate of the rate limit policy of ETH token, unit is in 10^18.
RATE_LIMIT_ETH_REFILL_RATE=
## The large threshold of the rate limit policy of ETH token, unit is in 10^18.
RATE_LIMIT_ETH_LARGE_THRESHOLD=
```
3. Fund deployer
```
Expand Down
10 changes: 10 additions & 0 deletions scripts/e2e/e2e.js
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@ describe("Bridge e2e test", () => {
let rootChainID = helper.requireEnv("ROOT_CHAIN_ID");
let childRPCURL = helper.requireEnv("CHILD_RPC_URL");
let childChainID = helper.requireEnv("CHILD_CHAIN_ID");
let rootRateAdminSecret = helper.requireEnv("ROOT_BRIDGE_RATE_ADMIN_SECRET");
let testAccountKey = helper.requireEnv("TEST_ACCOUNT_SECRET");
let rootIMXAddr = helper.requireEnv("ROOT_IMX_ADDR");
let rootWETHAddr = helper.requireEnv("ROOT_WETH_ADDR");
Expand All @@ -46,6 +47,7 @@ describe("Bridge e2e test", () => {
childProvider = new ethers.providers.JsonRpcProvider(childRPCURL, Number(childChainID));
rootTestWallet = new ethers.Wallet(testAccountKey, rootProvider);
childTestWallet = new ethers.Wallet(testAccountKey, childProvider);
let rootRateAdminWallet = new ethers.Wallet(rootRateAdminSecret, rootProvider);

let rootBridgeObj = JSON.parse(fs.readFileSync('../../out/RootERC20BridgeFlowRate.sol/RootERC20BridgeFlowRate.json', 'utf8'));
rootBridge = new ethers.Contract(rootBridgeAddr, rootBridgeObj.abi, rootProvider);
Expand Down Expand Up @@ -73,6 +75,14 @@ describe("Bridge e2e test", () => {
// Mint tokens
let resp = await rootCustomToken.connect(rootTestWallet).mint(rootTestWallet.address, ethers.utils.parseEther("1000.0").toBigInt());
await helper.waitForReceipt(resp.hash, rootProvider);
// Set rate control
resp = await rootBridge.connect(rootRateAdminWallet).setRateControlThreshold(
rootCustomToken.address,
ethers.utils.parseEther("20016.0"),
ethers.utils.parseEther("5.56"),
ethers.utils.parseEther("10008.0")
);
await helper.waitForReceipt(resp.hash, rootProvider);
})

it("should successfully deposit IMX to self from L1 to L2", async() => {
Expand Down
6 changes: 6 additions & 0 deletions scripts/localdev/.env.local
Original file line number Diff line number Diff line change
Expand Up @@ -77,6 +77,12 @@ RATE_LIMIT_IMX_CAPACITY=15516
RATE_LIMIT_IMX_REFILL_RATE=4.31
## The large threshold of the rate limit policy of IMX token, unit is in 10^18.
RATE_LIMIT_IMX_LARGE_THRESHOLD=7758
## The capacity of the rate limit policy of ETH token, unit is in 10^18.
RATE_LIMIT_ETH_CAPACITY=10.08
## The refill rate of the rate limit policy of ETH token, unit is in 10^18.
RATE_LIMIT_ETH_REFILL_RATE=0.0028
## The large threshold of the rate limit policy of ETH token, unit is in 10^18.
RATE_LIMIT_ETH_LARGE_THRESHOLD=5.04

# Set prior to 2_deployment_validation.js
CHILD_GATEWAY_ADDRESS=0xcf27F781841484d5CF7e155b44954D7224caF1dD
Expand Down

0 comments on commit f1c8948

Please sign in to comment.