Set a functioning recipient for kathy (#280)

pull/281/head
Nam Chu Hoai 3 years ago committed by GitHub
parent 535fc17378
commit fae4152221
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
  1. 56
      rust/chains/abacus-ethereum/abis/Inbox.abi.json
  2. 24
      typescript/deploy/config/environments/local/chains.ts
  3. 11
      typescript/deploy/config/environments/local/core.ts
  4. 36
      typescript/deploy/hardhat.config.ts
  5. 2
      typescript/deploy/package.json

@ -5,16 +5,6 @@
"internalType": "uint32",
"name": "_localDomain",
"type": "uint32"
},
{
"internalType": "uint256",
"name": "_processGas",
"type": "uint256"
},
{
"internalType": "uint256",
"name": "_reserveGas",
"type": "uint256"
}
],
"stateMutability": "nonpayable",
@ -79,49 +69,11 @@
"internalType": "bytes32",
"name": "messageHash",
"type": "bytes32"
},
{
"indexed": true,
"internalType": "bool",
"name": "success",
"type": "bool"
},
{
"indexed": true,
"internalType": "bytes",
"name": "returnData",
"type": "bytes"
}
],
"name": "Process",
"type": "event"
},
{
"inputs": [],
"name": "PROCESS_GAS",
"outputs": [
{
"internalType": "uint256",
"name": "",
"type": "uint256"
}
],
"stateMutability": "view",
"type": "function"
},
{
"inputs": [],
"name": "RESERVE_GAS",
"outputs": [
{
"internalType": "uint256",
"name": "",
"type": "uint256"
}
],
"stateMutability": "view",
"type": "function"
},
{
"inputs": [],
"name": "VERSION",
@ -290,13 +242,7 @@
}
],
"name": "process",
"outputs": [
{
"internalType": "bool",
"name": "_success",
"type": "bool"
}
],
"outputs": [],
"stateMutability": "nonpayable",
"type": "function"
},

@ -0,0 +1,24 @@
import { ethers } from 'ethers';
import { NonceManager } from '@ethersproject/experimental';
import {
alfajores,
kovan,
mumbai,
fuji,
} from '../../../config/networks/testnets';
export const getChains = () => {
// Hardhat account 0
const key =
'0xac0974bec39a17e36ba4a6b4d238ff944bacb478cbed5efcae784d7bf4f2ff80';
const provider = new ethers.providers.JsonRpcProvider(
'http://127.0.0.1:8545/',
);
const wallet = new ethers.Wallet(key, provider);
const signer = new NonceManager(wallet);
return [alfajores, kovan, fuji, mumbai].map((partial) => {
partial.overrides = {};
partial.confirmations = 1;
return { ...partial, signer };
});
};

@ -0,0 +1,11 @@
import { CoreConfig } from '../../../src/core';
export const core: CoreConfig = {
validators: {
// Hardhat accounts 1-4
alfajores: '0x70997970c51812dc3a010c7d01b50e0d17dc79c8',
fuji: '0x3c44cdddb6a900fa2b585dd299e03d12fa4293bc',
kovan: '0x90f79bf6eb2c4f870365e785982e1f101e93b906',
mumbai: '0x15d34aaf54267db7d7c367839aaf71a00a2c6a65',
},
};

@ -2,6 +2,7 @@ import '@nomiclabs/hardhat-waffle';
import '@nomiclabs/hardhat-etherscan';
import { task } from 'hardhat/config';
import { types, utils } from '@abacus-network/utils';
import { TestRecipient__factory } from '@abacus-network/core';
import { sleep } from './src/utils/utils';
import {
@ -12,6 +13,7 @@ import {
} from './scripts/utils';
import { CoreDeploy } from './src/core';
import { ContractVerifier } from './src/verification';
import { HardhatRuntimeEnvironment } from 'hardhat/types';
const domainSummary = async (deploy: CoreDeploy, domain: types.Domain) => {
const outbox = deploy.outbox(domain);
@ -69,25 +71,39 @@ task('kathy', 'Dispatches random abacus messages')
'environment',
'The name of the environment from which to read configs',
)
.setAction(async (args: any) => {
.setAction(async (args: any, hre: HardhatRuntimeEnvironment) => {
const environment = args.environment;
const deploy = await getCoreDeploy(environment);
const randomElement = (list: types.Domain[]) =>
list[Math.floor(Math.random() * list.length)];
// Deploy a recipient
const [signer] = await hre.ethers.getSigners();
const recipientF = new TestRecipient__factory(signer);
const recipient = await recipientF.deploy();
await recipient.deployTransaction.wait();
// Generate artificial traffic
while (true) {
const local = randomElement(deploy.domains);
const local = deploy.domains[0];
const remote = randomElement(deploy.remotes(local));
const outbox = deploy.outbox(local);
// Values for recipient and message don't matter
await outbox.dispatch(
remote,
utils.addressToBytes32(outbox.address),
'0x1234',
);
console.log(await domainSummary(deploy, local));
await sleep(5000);
// Send a batch of messages to the remote domain to test
// the checkpointer/relayer submitting only greedily
for (let i = 0; i < 10; i++) {
await outbox.dispatch(
remote,
utils.addressToBytes32(recipient.address),
'0x1234',
);
console.log(
`send to ${recipient.address} on ${remote} at index ${
(await outbox.count()).toNumber() - 1
}`,
);
console.log(await domainSummary(deploy, local));
await sleep(5000);
}
}
});

@ -25,7 +25,7 @@
"check": "tsc --noEmit",
"node": "hardhat node",
"abacus": "hardhat abacus --environment local",
"kathy": "hardhat kathy --environment local",
"kathy": "hardhat kathy --environment local --network localhost",
"prettier": "prettier --write *.ts ./src ./config ./scripts ./test"
},
"license": "MIT OR Apache-2.0",

Loading…
Cancel
Save