-
Notifications
You must be signed in to change notification settings - Fork 68
feat: symbiotic setup and slash tests #1507
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Open
rackstar
wants to merge
7
commits into
release-candidate
Choose a base branch
from
feat/symbiotic-setup-and-slash-tests
base: release-candidate
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from 5 commits
Commits
Show all changes
7 commits
Select commit
Hold shift + click to select a range
559378d
feat: add symbiotic-setup
rackstar b26f646
test: add symbiotic tests
rackstar 94adf1e
test: clean up symbiotic-setup and slash tests
rackstar 9dd8c24
feat: add symbiotic-setup-safe-tx fork test
rackstar ee83c50
test: add isOptedIn assertions
rackstar 59cd5cf
test: clean up and fix flaky tests in symbiotic setup/tests
rackstar b81e4fa
chore: update deployments to 3.3.0
rackstar File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,92 @@ | ||
| const { ethers, network } = require('hardhat'); | ||
| const { expect } = require('chai'); | ||
| const { takeSnapshot } = require('@nomicfoundation/hardhat-network-helpers'); | ||
|
|
||
| const { createSafeExecutor, revertToSnapshot } = require('../utils'); | ||
|
|
||
| const SAFE_MULTISIG_NETWORK_OPERATOR_MIDDLEWARE = '0xF99aA6479Eb153dcA93fd243A06caCD11f3268f9'; | ||
| const OPERATOR_REGISTRY = '0xAd817a6Bc954F678451A71363f04150FDD81Af9F'; | ||
| const NETWORK_REGISTRY = '0xC773b1011461e7314CF05f97d95aa8e92C1Fd8aA'; | ||
| const OPERATOR_NETWORK_OPTIN = '0x7133415b33B438843D581013f98A08704316633c'; | ||
| const NETWORK_MIDDLEWARE_SERVICE = '0xD7dC9B366c027743D90761F71858BCa83C6899Ad'; | ||
|
|
||
| const NETWORK_REGISTRY_ABI = [ | ||
| 'function registerNetwork() external', | ||
| 'function isEntity(address) external view returns (bool)', | ||
| ]; | ||
| const OPERATOR_REGISTRY_ABI = [ | ||
| 'function registerOperator() external', | ||
| 'function isEntity(address) external view returns (bool)', | ||
| ]; | ||
| const NETWORK_MIDDLEWARE_ABI = [ | ||
| 'function setMiddleware(address middleware) external', | ||
| 'function middleware(address network) external view returns (address)', | ||
| ]; | ||
| const OPTIN_ABI = [ | ||
| 'function optIn(address where) external', | ||
| 'function isOptedIn(address who,address where) external view returns (bool)', | ||
| ]; | ||
|
|
||
| describe('Symbiotic setup via Safe multisend', function () { | ||
| before('Tenderly snapshot', async function () { | ||
| console.info('Network:', network.name); | ||
| if (network.name !== 'tenderly') { | ||
| return; | ||
| } | ||
|
|
||
| const { TENDERLY_SNAPSHOT_ID } = process.env; | ||
| if (TENDERLY_SNAPSHOT_ID) { | ||
| console.info('Reverting to snapshot:', TENDERLY_SNAPSHOT_ID); | ||
| await revertToSnapshot(TENDERLY_SNAPSHOT_ID); | ||
| return; | ||
| } | ||
|
|
||
| const { snapshotId } = await takeSnapshot(); | ||
| console.info('Snapshot ID:', snapshotId); | ||
| }); | ||
|
|
||
| before('Load contracts', async function () { | ||
| this.networkRegistry = await ethers.getContractAt(NETWORK_REGISTRY_ABI, NETWORK_REGISTRY); | ||
| this.operatorRegistry = await ethers.getContractAt(OPERATOR_REGISTRY_ABI, OPERATOR_REGISTRY); | ||
| this.middlewareService = await ethers.getContractAt(NETWORK_MIDDLEWARE_ABI, NETWORK_MIDDLEWARE_SERVICE); | ||
| this.operatorNetworkOptIn = await ethers.getContractAt(OPTIN_ABI, OPERATOR_NETWORK_OPTIN); | ||
| this.executeSafeTransaction = await createSafeExecutor(SAFE_MULTISIG_NETWORK_OPERATOR_MIDDLEWARE); | ||
| }); | ||
|
|
||
| it('executes register/setMiddleware/optIn through Safe in one multisend', async function () { | ||
| const registerNetworkData = this.networkRegistry.interface.encodeFunctionData('registerNetwork'); | ||
| const registerOperatorData = this.operatorRegistry.interface.encodeFunctionData('registerOperator'); | ||
| const setMiddlewareData = this.middlewareService.interface.encodeFunctionData('setMiddleware', [ | ||
| SAFE_MULTISIG_NETWORK_OPERATOR_MIDDLEWARE, | ||
| ]); | ||
| const operatorNetworkOptInData = this.operatorNetworkOptIn.interface.encodeFunctionData('optIn', [ | ||
| SAFE_MULTISIG_NETWORK_OPERATOR_MIDDLEWARE, | ||
| ]); | ||
|
|
||
| const safeInnerTxs = [ | ||
| { to: NETWORK_REGISTRY, data: registerNetworkData }, | ||
| { to: OPERATOR_REGISTRY, data: registerOperatorData }, | ||
| { to: NETWORK_MIDDLEWARE_SERVICE, data: setMiddlewareData }, | ||
| { to: OPERATOR_NETWORK_OPTIN, data: operatorNetworkOptInData }, | ||
| ]; | ||
|
|
||
| console.log('Safe inner txs:', safeInnerTxs); | ||
|
|
||
| const safeTx = await this.executeSafeTransaction(safeInnerTxs); | ||
| const safeReceipt = await safeTx.wait(); | ||
| expect(safeReceipt.status).to.equal(1n); | ||
| console.log('Safe execution tx hash:', safeTx.hash); | ||
|
|
||
| const middlewareAddress = await this.middlewareService.middleware(SAFE_MULTISIG_NETWORK_OPERATOR_MIDDLEWARE); | ||
| const operator1Address = SAFE_MULTISIG_NETWORK_OPERATOR_MIDDLEWARE; | ||
| const optedIn = await this.operatorNetworkOptIn.isOptedIn( | ||
| operator1Address, | ||
| SAFE_MULTISIG_NETWORK_OPERATOR_MIDDLEWARE, | ||
| ); | ||
|
|
||
| expect(middlewareAddress).to.equal(SAFE_MULTISIG_NETWORK_OPERATOR_MIDDLEWARE); | ||
| expect(optedIn).to.equal(true); | ||
| expect(await this.networkRegistry.isEntity(SAFE_MULTISIG_NETWORK_OPERATOR_MIDDLEWARE)).to.equal(true); | ||
| expect(await this.operatorRegistry.isEntity(SAFE_MULTISIG_NETWORK_OPERATOR_MIDDLEWARE)).to.equal(true); | ||
| }); | ||
| }); | ||
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.