Use proper ISM in ICA contracts (#2128)
### Description Currently, ICAs are configured without an ISM, which results in them falling back to the mailbox default. Instead, they should delegate security to whichever ISM was specified in the message. This PR updates the deployer to deploy the proper ISM by default, and the checker/governor with code that will allow the existing deployments to move to that ISM. ### Drive-by changes - My formatter seems to be making changes to src/sdk/index.ts ### Backward compatibility _Are these changes backward compatible?_ Yes _Are there any infrastructure implications, e.g. changes that would prohibit deploying older commits using this infra tooling?_ None ### Testing _What kind of testing have these changes undergone?_ Noneasaj/ci-try
parent
60f7737a46
commit
e756732964
@ -1,25 +0,0 @@ |
|||||||
import { |
|
||||||
ChainMap, |
|
||||||
InterchainAccount, |
|
||||||
InterchainAccountChecker, |
|
||||||
InterchainAccountConfig, |
|
||||||
} from '@hyperlane-xyz/sdk'; |
|
||||||
import { types } from '@hyperlane-xyz/utils'; |
|
||||||
|
|
||||||
import { HyperlaneAppGovernor } from './HyperlaneAppGovernor'; |
|
||||||
|
|
||||||
export class InterchainAccountGovernor extends HyperlaneAppGovernor< |
|
||||||
InterchainAccount, |
|
||||||
InterchainAccountConfig |
|
||||||
> { |
|
||||||
constructor( |
|
||||||
checker: InterchainAccountChecker, |
|
||||||
owners: ChainMap<types.Address>, |
|
||||||
) { |
|
||||||
super(checker, owners); |
|
||||||
} |
|
||||||
|
|
||||||
protected async mapViolationsToCalls() { |
|
||||||
throw new Error('governor not implemented for account middleware'); |
|
||||||
} |
|
||||||
} |
|
@ -1,25 +0,0 @@ |
|||||||
import { |
|
||||||
ChainMap, |
|
||||||
InterchainQuery, |
|
||||||
InterchainQueryChecker, |
|
||||||
InterchainQueryConfig, |
|
||||||
} from '@hyperlane-xyz/sdk'; |
|
||||||
import { types } from '@hyperlane-xyz/utils'; |
|
||||||
|
|
||||||
import { HyperlaneAppGovernor } from './HyperlaneAppGovernor'; |
|
||||||
|
|
||||||
export class InterchainQueryGovernor extends HyperlaneAppGovernor< |
|
||||||
InterchainQuery, |
|
||||||
InterchainQueryConfig |
|
||||||
> { |
|
||||||
constructor( |
|
||||||
checker: InterchainQueryChecker, |
|
||||||
owners: ChainMap<types.Address>, |
|
||||||
) { |
|
||||||
super(checker, owners); |
|
||||||
} |
|
||||||
|
|
||||||
protected async mapViolationsToCalls() { |
|
||||||
throw new Error('governor not implemented for query middleware'); |
|
||||||
} |
|
||||||
} |
|
@ -0,0 +1,47 @@ |
|||||||
|
import { |
||||||
|
ChainMap, |
||||||
|
ConnectionClientViolation, |
||||||
|
ConnectionClientViolationType, |
||||||
|
HyperlaneAppChecker, |
||||||
|
RouterApp, |
||||||
|
RouterConfig, |
||||||
|
} from '@hyperlane-xyz/sdk'; |
||||||
|
import { types } from '@hyperlane-xyz/utils'; |
||||||
|
|
||||||
|
import { HyperlaneAppGovernor } from './HyperlaneAppGovernor'; |
||||||
|
|
||||||
|
export class ProxiedRouterGovernor< |
||||||
|
App extends RouterApp<any>, |
||||||
|
Config extends RouterConfig, |
||||||
|
> extends HyperlaneAppGovernor<App, Config> { |
||||||
|
constructor( |
||||||
|
checker: HyperlaneAppChecker<App, Config>, |
||||||
|
owners: ChainMap<types.Address>, |
||||||
|
) { |
||||||
|
super(checker, owners); |
||||||
|
} |
||||||
|
|
||||||
|
protected async mapViolationsToCalls() { |
||||||
|
for (const violation of this.checker.violations) { |
||||||
|
if ( |
||||||
|
violation.type === |
||||||
|
ConnectionClientViolationType.InterchainSecurityModule |
||||||
|
) { |
||||||
|
this.handleIsmViolation(violation as ConnectionClientViolation); |
||||||
|
} else { |
||||||
|
throw new Error(`Unsupported violation type ${violation.type}`); |
||||||
|
} |
||||||
|
} |
||||||
|
} |
||||||
|
|
||||||
|
protected handleIsmViolation(violation: ConnectionClientViolation) { |
||||||
|
this.pushCall(violation.chain, { |
||||||
|
to: violation.contract.address, |
||||||
|
data: violation.contract.interface.encodeFunctionData( |
||||||
|
'setInterchainSecurityModule', |
||||||
|
[violation.expected], |
||||||
|
), |
||||||
|
description: `Set ISM of ${violation.contract.address} to ${violation.expected}`, |
||||||
|
}); |
||||||
|
} |
||||||
|
} |
Loading…
Reference in new issue