Skip to content

Commit

Permalink
feat: update NOR and updateTargetValidatorsLimits factory vote
Browse files Browse the repository at this point in the history
  • Loading branch information
avsetsin committed Jul 2, 2024
1 parent b418747 commit 1f8d9aa
Show file tree
Hide file tree
Showing 2 changed files with 68 additions and 0 deletions.
1 change: 1 addition & 0 deletions programs/omnibus-scripts/index.ts
Original file line number Diff line number Diff line change
@@ -1 +1,2 @@
export * from './staking-router-2';
export * from './staking-router-fix';
67 changes: 67 additions & 0 deletions programs/omnibus-scripts/staking-router-fix.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,67 @@
import { getAppProxyContract, norAddress } from '@contracts';
import { updateAragonApp, votingNewVote } from '@scripts';
import { CallScriptAction, encodeCallScript, forwardVoteFromTm } from '@utils';
import { concat, Interface } from 'ethers';

const NOR_IMPLEMENTATION = '0x41646708a7edbe22bd635cb838ff9c0cfa99a3be';
const NOR_CONTENT_URI = '0x' + '00'.repeat(51);
const NOR_VERSION = ['3', '0', '0'];

// Holesky testnet config
const EASYTRACK_ADDRESS = '0x1763b9ED3586B08AE796c7787811a2E1bc16163a';
const SDVT_MODULE_ADDRESS = '0x11a93807078f8BB880c1BD0ee4C387537de4b4b6';
const NEW_TARGET_LIMIT_FACTORY = '0x431a156BEba95803a95452441C1959c4479710e1';
const OLD_TARGET_LIMIT__FACTORY = '0xC91a676A69Eb49be9ECa1954fE6fc861AE07A9A2';

export const stakingRouterFix = async () => {
const iface = new Interface([
'function removeEVMScriptFactory(address)',
'function addEVMScriptFactory(address,bytes)',
]);

// 1, 2. Update NOR implementation
const norProxyContract = getAppProxyContract(async () => norAddress);
const norAppId = await norProxyContract.appId();
const [, norNewVersionBumpScript, norSetAppScript] = await updateAragonApp(
NOR_VERSION,
NOR_IMPLEMENTATION,
NOR_CONTENT_URI,
norAppId,
);

// 3. Remove old factory
const removeTargetLimitFactoryToETScript: CallScriptAction = {
to: EASYTRACK_ADDRESS,
data: iface.encodeFunctionData('removeEVMScriptFactory', [OLD_TARGET_LIMIT__FACTORY]),
};

// 4. Add new factory
const updateLimitIface = new Interface(['function updateTargetValidatorsLimits(uint256,uint256,uint256)']);
const updateLimitSelector = updateLimitIface.getFunction('updateTargetValidatorsLimits')?.selector;
if (!updateLimitSelector) throw new Error('updateLimitSelector not found');
const factoryPermissions = concat([SDVT_MODULE_ADDRESS, updateLimitSelector]);
const addTargetLimitFactoryToETScript: CallScriptAction = {
to: EASYTRACK_ADDRESS,
data: iface.encodeFunctionData('addEVMScriptFactory', [NEW_TARGET_LIMIT_FACTORY, factoryPermissions]),
};

// Collect all calls
const calls: CallScriptAction[] = [
norNewVersionBumpScript,
norSetAppScript,
removeTargetLimitFactoryToETScript,
addTargetLimitFactoryToETScript,
];

const description = [
`1. Create new NOR version with address ${NOR_IMPLEMENTATION}`,
`2. Update NOR app to new version ${NOR_VERSION.join('.')}`,
`3. Remove updateTargetValidatorsLimits with address ${OLD_TARGET_LIMIT__FACTORY} from EasyTrack`,
`4. Add updateTargetValidatorsLimits with address ${NEW_TARGET_LIMIT_FACTORY} to EasyTrack`,
].join('\n');

const voteEvmScript = encodeCallScript(calls);
const [newVoteCalldata] = votingNewVote(voteEvmScript, description);

await forwardVoteFromTm(newVoteCalldata);
};

0 comments on commit 1f8d9aa

Please sign in to comment.