pull/334/head
Trevor Porter 3 years ago
parent b59c63d69f
commit 9d9431d7ed
  1. 27
      typescript/infra/src/core/check.ts
  2. 9
      typescript/infra/src/core/govern.ts
  3. 4
      typescript/infra/src/utils/utils.ts
  4. 5
      typescript/sdk/src/core/app.ts

@ -60,7 +60,9 @@ export class AbacusCoreChecker extends AbacusAppChecker<
];
this.app.remoteDomainNumbers(domain).map((remote) => {
owners.push(this.app.mustGetInbox(remote, domain).owner());
owners.push(this.app.mustGetInboxMultisigValidatorManager(remote, domain).owner());
owners.push(
this.app.mustGetInboxMultisigValidatorManager(remote, domain).owner(),
);
});
const actual = await Promise.all(owners);
actual.map((_) => expect(_).to.equal(owner));
@ -90,10 +92,12 @@ export class AbacusCoreChecker extends AbacusAppChecker<
let multisigValidatorManager: MultisigValidatorManager;
// Check the outboxMultisigValidatorManager
if (domain === outboxDomain) {
multisigValidatorManager = this.app.mustGetContracts(domain).outboxMultisigValidatorManager;
multisigValidatorManager =
this.app.mustGetContracts(domain).outboxMultisigValidatorManager;
} else {
// Check an inboxMultisigValidatorManager
multisigValidatorManager = this.app.mustGetInboxMultisigValidatorManager(outboxDomain, domain);
multisigValidatorManager =
this.app.mustGetInboxMultisigValidatorManager(outboxDomain, domain);
}
return this.checkMultisigValidatorManager(
domain,
@ -115,7 +119,8 @@ export class AbacusCoreChecker extends AbacusAppChecker<
multisigValidatorManager: MultisigValidatorManager,
): Promise<void> {
const outboxDomainName = this.app.mustResolveDomainName(outboxDomain);
const expected = this.config.multisigValidatorManagers[outboxDomainName]?.validatorSet;
const expected =
this.config.multisigValidatorManagers[outboxDomainName]?.validatorSet;
expect(expected).to.not.be.undefined;
const actual = await multisigValidatorManager.validatorSet();
@ -124,17 +129,11 @@ export class AbacusCoreChecker extends AbacusAppChecker<
const expectedSet = new Set<string>(expected);
const actualSet = new Set<string>(actual);
const toEnroll = setDifference(
expectedSet,
actualSet,
);
const toUnenroll = setDifference(
actualSet,
expectedSet,
);
const toEnroll = setDifference(expectedSet, actualSet);
const toUnenroll = setDifference(actualSet, expectedSet);
// Validators that should be enrolled
for (const [validatorToEnroll] of toEnroll.entries()) {
for (const validatorToEnroll of toEnroll) {
const violation: ValidatorViolation = {
domain: localDomain,
type: CoreViolationType.Validator,
@ -148,7 +147,7 @@ export class AbacusCoreChecker extends AbacusAppChecker<
}
// Validators that should be unenrolled
for (const [validatorToUnenroll] of toUnenroll.entries()) {
for (const validatorToUnenroll of toUnenroll) {
const violation: ValidatorViolation = {
domain: localDomain,
type: CoreViolationType.Validator,

@ -84,14 +84,19 @@ export class AbacusCoreGovernor extends AbacusCoreChecker {
tx = await multisigValidatorManager.populateTransaction.enrollValidator(
violation.expected,
);
} else if (violation.actual !== undefined && violation.expected === undefined) {
} else if (
violation.actual !== undefined &&
violation.expected === undefined
) {
// Unenrolling an existing validator
tx = await multisigValidatorManager.populateTransaction.unenrollValidator(
violation.actual,
);
} else {
// Invalid state
throw new Error(`Expected exactly one of actual ${violation.actual} or expected ${violation.expected} to be undefined`);
throw new Error(
`Expected exactly one of actual ${violation.actual} or expected ${violation.expected} to be undefined`,
);
}
if (tx.to === undefined) throw new Error('undefined tx.to');

@ -161,8 +161,8 @@ export function writeJSON(directory: string, filename: string, obj: any) {
// Returns a \ b
export function setDifference<T>(a: Set<T>, b: Set<T>) {
let diff = new Set(a);
for (const elem of diff) {
diff.delete(elem);
for (const element of b) {
diff.delete(element);
}
return diff;
}

@ -26,7 +26,10 @@ export class AbacusCore extends AbacusApp<
return contracts.inbox(srcName);
}
mustGetInboxMultisigValidatorManager(src: NameOrDomain, dest: NameOrDomain): InboxMultisigValidatorManager {
mustGetInboxMultisigValidatorManager(
src: NameOrDomain,
dest: NameOrDomain,
): InboxMultisigValidatorManager {
const contracts = this.mustGetContracts(dest);
const srcName = this.mustGetDomain(src).name;
return contracts.inboxMultisigValidatorManager(srcName);

Loading…
Cancel
Save