aligned_layer icon indicating copy to clipboard operation
aligned_layer copied to clipboard

chore: implement pausable in ServiceManager

Open JuArce opened this issue 1 year ago • 3 comments

How to test

  1. Addresses to export Note:
export RPC_URL=http://localhost:8545
export ALIGNED_SERVICE_MANAGER=0x851356ae760d987E095750cCeb3bC6014560891C
export BATCHER_PAYMENT_SERVICE=0x7bc06c482DEAd17c0e297aFbC32f6e63d3846650

And the Pauser's private keys Aligned Pauser Private Key:

export PRIVATE_KEY=0xac0974bec39a17e36ba4a6b4d238ff944bacb478cbed5efcae784d7bf4f2ff80

Batcher Pauser Private Key:

export PRIVATE_KEY=0x4bbbf85ce3377467afe5d46f804f221813b2bb87f24d81f60f1fcdbf7cbf4356
  1. Run anvil
make anvil_start_with_block_time
  1. If you run
make get_paused_state_aligned_service_manager

the response should be No functions are paused

  1. If you run
make pause_all_aligned_service_manager

You have paused the whole aligned layer service manager contract. Thus if you run

make get_paused_state_aligned_service_manager

the response should be All functions are paused 5. You can also run

make unpause_all_aligned_service_manager

To unpause the whole contract. 6. You can also run the following command, to pause or unpause specific functions, receiving a list of the functions to remain paused (this is how the Pausable parameter works in the contract). For example, if you want to pause functions 0, 2 and 3, you can run

contracts/scripts/pause_aligned_service_manager.sh 0 2 3

Then, if you want to unpause, say, function 2, you must run

contracts/scripts/unpause_aligned_service_manager.sh 0 3

Note: when executing a Pause, you can only ADD functions to the paused list, and when executing an Unpause, you can only REMOVE functions from the paused list. This is because the base pausable contract has different ACL for Pausers and Unpausers.

  1. Then, you can experiment Pausing and Unpausing different functions, and running different parts of the system (for example, try sending a proof with the createNewTask function paused, or send one with only the respondToTask function paused)

Note: the list of pausable functions and their numbers can be seen in the AlignedLayerServiceManager.sol contract. But the list is the following:

  1. createNewTask
  2. respondToTaskV2
  3. verifyBatchInclusion
  4. withdraw
  5. depositToBatcher
  6. receive

BatcherPayments is also pausable, but without so much detail. You can either pause or unpause the contract running the following:

make pause_batcher_payment_service
make unpause_batcher_payment_service

And this will either pause or unpause the following functions:

  • createNewTask
  • unlock
  • lock
  • withdraw

How to Deploy

New Deployments

For new deployments, just run

make deploy_aligned_contracts

PauserRegistry will be deployed and ServiceManager will be pausable

Existing deployments

  1. In order to use the EigenLayer pausable pattern with PauserRegistry contract, we have to deploy the PauserRegistry contract
make deploy_pauser_registry

Once deployed, update the output file with the "pauserRegistry" and the "alignedLayerPauser"

  1. Run
make upgrade_pauser_aligned_contracts

This will deploy a new ServiceManager with Pausable and will upgrade the Proxy. Also, it will run initializePaused()

JuArce avatar Jun 24 '24 21:06 JuArce

Changes to gas cost

Generated at commit: 38fa217aae887e4f10b8cf4d8e99883304c82286, compared to commit: 192a535aa39bbad8cada32b9460bf59e33081685

🧾 Summary (10% most significant diffs)

Contract Method Avg (+/-) %
AlignedLayerServiceManager batchesState
receive
+44 ❌
+2,231 ❌
+6.46%
+4.97%

Full diff report 👇
Contract Deployment Cost (+/-) Method Min (+/-) % Avg (+/-) % Median (+/-) % Max (+/-) % # Calls (+/-)
AlignedLayerServiceManager 5,335,578 (+564,365) batchesState
createNewTask
disableVerifier
enableVerifier
isVerifierDisabled
receive
setDisabledVerifiers
725 (+44)
56,700 (+2,765)
23,911 (+22)
23,803 (-67)
583 (+44)
23,318 (+2,149)
23,801 (+44)
+6.46%
+5.13%
+0.09%
-0.28%
+8.16%
+10.15%
+0.19%
725 (+44)
76,235 (+2,269)
35,504 (+22)
24,447 (-67)
1,249 (+44)
47,108 (+2,231)
34,808 (+44)
+6.46%
+3.07%
+0.06%
-0.27%
+3.65%
+4.97%
+0.13%
725 (+44)
76,231 (+2,180)
35,504 (+22)
24,447 (-67)
583 (+44)
47,202 (+2,138)
34,808 (+44)
+6.46%
+2.94%
+0.06%
-0.27%
+8.16%
+4.74%
+0.13%
725 (+44)
77,095 (+2,225)
47,097 (+22)
25,092 (-67)
2,583 (+44)
47,202 (+2,138)
45,815 (+44)
+6.46%
+2.97%
+0.05%
-0.27%
+1.73%
+4.74%
+0.10%
256 (0)
256 (0)
2 (0)
2 (0)
3 (0)
256 (0)
2 (0)

github-actions[bot] avatar Jun 24 '24 21:06 github-actions[bot]

I can't be a reviewer because I made big changes on it

uri-99 avatar Sep 30 '24 19:09 uri-99

@entropidelic could you do another round on this? I don't know enough Solidity to trust myself on reviewing this and Uri is tainted by being the author of a big part of the PR.

Oppen avatar Oct 04 '24 17:10 Oppen

waiting for a review of @JuArce before merge

uri-99 avatar Oct 15 '24 19:10 uri-99

I think BatcherPaymentService should have the logic to pause/unpase functions individually

I agree, i have created the issue and started the PR of this functionality.

Mauro has given thumbs up that the initial pausable version can not contain this, as it is Pausable as a whole.

Also, this PR is specifically of adding pausable to ServiceManager, and this feature is non trivial, with probably many file changes.

uri-99 avatar Oct 16 '24 18:10 uri-99

Unblock since Batcher individual pausing will be added in another PR

I'd suggest to block this until #1272 is merged

Oppen avatar Oct 24 '24 19:10 Oppen