pull/334/head
Trevor Porter 3 years ago
parent 3673557082
commit 6a171803ef
  1. 5
      solidity/core/contracts/validator-manager/MultisigValidatorManager.sol
  2. 4
      solidity/core/test/validator-manager/multisigValidatorManager.test.ts
  3. 49
      typescript/hardhat/src/TestAbacusDeploy.ts
  4. 7
      typescript/sdk/src/core/contracts.ts

@ -211,7 +211,10 @@ abstract contract MultisigValidatorManager is Ownable {
* @param _validator The validator to remove from the validator set. * @param _validator The validator to remove from the validator set.
*/ */
function _unenrollValidator(address _validator) internal { function _unenrollValidator(address _validator) internal {
require(validators.length() > quorumThreshold, "violates quorum threshold"); require(
validators.length() > quorumThreshold,
"violates quorum threshold"
);
require(validators.remove(_validator), "!enrolled"); require(validators.remove(_validator), "!enrolled");
emit UnenrollValidator(_validator); emit UnenrollValidator(_validator);
} }

@ -131,8 +131,8 @@ describe('MultisigValidatorManager', async () => {
await validatorManager.setQuorumThreshold(2); await validatorManager.setQuorumThreshold(2);
await expect( await expect(
validatorManager.unenrollValidator(validator1.address) validatorManager.unenrollValidator(validator1.address),
).to.be.revertedWith("violates quorum threshold"); ).to.be.revertedWith('violates quorum threshold');
}); });
it('reverts if the validator is not already enrolled', async () => { it('reverts if the validator is not already enrolled', async () => {

@ -28,8 +28,11 @@ export type TestAbacusInstance = {
upgradeBeaconController: UpgradeBeaconController; upgradeBeaconController: UpgradeBeaconController;
inboxes: Record<types.Domain, TestInbox>; inboxes: Record<types.Domain, TestInbox>;
interchainGasPaymaster: InterchainGasPaymaster; interchainGasPaymaster: InterchainGasPaymaster;
outboxMultisigValidatorManager: OutboxMultisigValidatorManager, outboxMultisigValidatorManager: OutboxMultisigValidatorManager;
inboxMultisigValidatorManagers: Record<types.Domain, InboxMultisigValidatorManager>, inboxMultisigValidatorManagers: Record<
types.Domain,
InboxMultisigValidatorManager
>;
}; };
export class TestAbacusDeploy extends TestDeploy< export class TestAbacusDeploy extends TestDeploy<
@ -54,23 +57,30 @@ export class TestAbacusDeploy extends TestDeploy<
const signer = this.config.signer[domain]; const signer = this.config.signer[domain];
const signerAddress = await signer.getAddress(); const signerAddress = await signer.getAddress();
const outboxMultisigValidatorManagerFactory = new OutboxMultisigValidatorManager__factory(signer); const outboxMultisigValidatorManagerFactory =
const outboxMultisigValidatorManager = await outboxMultisigValidatorManagerFactory.deploy( new OutboxMultisigValidatorManager__factory(signer);
const outboxMultisigValidatorManager =
await outboxMultisigValidatorManagerFactory.deploy(
domain, domain,
[signerAddress], [signerAddress],
1, 1
); );
const inboxMultisigValidatorManagerFactory = new InboxMultisigValidatorManager__factory(signer); const inboxMultisigValidatorManagerFactory =
const inboxMultisigValidatorManagers: Record<types.Domain, InboxMultisigValidatorManager> = {}; new InboxMultisigValidatorManager__factory(signer);
const inboxMultisigValidatorManagers: Record<
types.Domain,
InboxMultisigValidatorManager
> = {};
// this.remotes reads this.instances which has not yet been set. // this.remotes reads this.instances which has not yet been set.
const remotes = Object.keys(this.config.signer).map((d) => parseInt(d)); const remotes = Object.keys(this.config.signer).map((d) => parseInt(d));
const inboxMultisigValidatorManagerDeploys = remotes.map(async (remote) => { const inboxMultisigValidatorManagerDeploys = remotes.map(async (remote) => {
const inboxMultisigValidatorManager = await inboxMultisigValidatorManagerFactory.deploy( const inboxMultisigValidatorManager =
await inboxMultisigValidatorManagerFactory.deploy(
remote, remote,
[signerAddress], [signerAddress],
1, 1
); );
inboxMultisigValidatorManagers[remote] = inboxMultisigValidatorManager; inboxMultisigValidatorManagers[remote] = inboxMultisigValidatorManager;
}); });
@ -105,7 +115,8 @@ export class TestAbacusDeploy extends TestDeploy<
// this.remotes reads this.instances which has not yet been set. // this.remotes reads this.instances which has not yet been set.
// const remotes = Object.keys(this.config.signer).map((d) => parseInt(d)); // const remotes = Object.keys(this.config.signer).map((d) => parseInt(d));
const inboxDeploys = remotes.map(async (remote) => { const inboxDeploys = remotes.map(async (remote) => {
const inboxMultisigValidatorManager = inboxMultisigValidatorManagers[remote]; const inboxMultisigValidatorManager =
inboxMultisigValidatorManagers[remote];
const inbox = await inboxFactory.deploy(domain); const inbox = await inboxFactory.deploy(domain);
await inbox.initialize( await inbox.initialize(
remote, remote,
@ -132,9 +143,14 @@ export class TestAbacusDeploy extends TestDeploy<
await this.outbox(domain).transferOwnership(address); await this.outbox(domain).transferOwnership(address);
await this.upgradeBeaconController(domain).transferOwnership(address); await this.upgradeBeaconController(domain).transferOwnership(address);
await this.xAppConnectionManager(domain).transferOwnership(address); await this.xAppConnectionManager(domain).transferOwnership(address);
await this.outboxMultisigValidatorManager(domain).transferOwnership(address); await this.outboxMultisigValidatorManager(domain).transferOwnership(
address
);
for (const remote of this.remotes(domain)) { for (const remote of this.remotes(domain)) {
await this.inboxMultisigValidatorManager(domain, remote).transferOwnership(address); await this.inboxMultisigValidatorManager(
domain,
remote
).transferOwnership(address);
await this.inbox(domain, remote).transferOwnership(address); await this.inbox(domain, remote).transferOwnership(address);
} }
} }
@ -159,11 +175,16 @@ export class TestAbacusDeploy extends TestDeploy<
return this.instances[domain].xAppConnectionManager; return this.instances[domain].xAppConnectionManager;
} }
outboxMultisigValidatorManager(domain: types.Domain): OutboxMultisigValidatorManager { outboxMultisigValidatorManager(
domain: types.Domain
): OutboxMultisigValidatorManager {
return this.instances[domain].outboxMultisigValidatorManager; return this.instances[domain].outboxMultisigValidatorManager;
} }
inboxMultisigValidatorManager(local: types.Domain, remote: types.Domain): InboxMultisigValidatorManager { inboxMultisigValidatorManager(
local: types.Domain,
remote: types.Domain
): InboxMultisigValidatorManager {
return this.instances[local].inboxMultisigValidatorManagers[remote]; return this.instances[local].inboxMultisigValidatorManagers[remote];
} }

@ -38,8 +38,11 @@ export class CoreContracts extends AbacusAppContracts<CoreContractAddresses> {
return Inbox__factory.connect(inbox.proxy, this.connection); return Inbox__factory.connect(inbox.proxy, this.connection);
} }
inboxMultisigValidatorManager(chain: ChainName): InboxMultisigValidatorManager { inboxMultisigValidatorManager(
const inboxMultisigValidatorManager = this.addresses.inboxMultisigValidatorManagers[chain]; chain: ChainName,
): InboxMultisigValidatorManager {
const inboxMultisigValidatorManager =
this.addresses.inboxMultisigValidatorManagers[chain];
if (!inboxMultisigValidatorManager) { if (!inboxMultisigValidatorManager) {
throw new Error(`No inboxMultisigValidatorManager for ${chain}`); throw new Error(`No inboxMultisigValidatorManager for ${chain}`);
} }

Loading…
Cancel
Save