Skip to content

Commit

Permalink
docs(docs-site,protocol): streamline ProverSet deployment (#17730)
Browse files Browse the repository at this point in the history
Co-authored-by: Roger <[email protected]>
  • Loading branch information
lagunovsky and RogerLamTd committed Jul 4, 2024
1 parent f8f796c commit 919cb4c
Show file tree
Hide file tree
Showing 3 changed files with 30 additions and 89 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ description: This guide will you help you deploy a ProverSet which enables you t
import { Aside, Card, Steps, Tabs, TabItem } from '@astrojs/starlight/components'

The recent protocol upgrade now requires that the address of the prover and proposer are the same. This can be achieved by simply using the same private keys to run the proposer and prover software,
but this is not recommended as it can cause nonce issues.
but this is not recommended as it can cause nonce issues.

This guide outlines how to achieve this with separate EOAs running prover and proposer through the ProverSet smart contract.

Expand Down Expand Up @@ -43,37 +43,28 @@ This guide outlines how to achieve this with separate EOAs running prover and pr
</TabItem>
</Tabs>

2. **Deploy the ProverSet implementation**
2. **Deploy the ProverSet**

Run the `DeployProverSetUtil.s.sol` script with your **proposer's private key**. You can find the script [here](https://github.com/taikoxyz/taiko-mono/tree/main/packages/protocol/script/DeployProverSetUtil.s.sol).
Set `ROLLUP_ADDRESS_MANAGER` to the address of the RollupAddressManager contract on the network you are deploying to. You can find these values in our network reference docs.

```bash
forge script --chain-id {CHAIN_ID} --broadcast --rpc-url {YOUR_RPC_URL} --private-key=$PRIVATE_KEY script/DeployProverSetUtil.s.sol:DeployProverSetUtil
```

The script should print your implementation address with the log:

`New impl address is: 0x....`

You will need the address for the next step.
Set `PROVER_SET_ADMIN` to the address of your **prover** EOA. You will be able to withdraw TAIKO/TTKOh from the contract to this address.

3. **Deploy the Proxy and init the ProverSet smart contract**

Fill in the implementation address, set the **prover** EOA as admin, and ensure that the `ROLLUP_ADDRESS_MANAGER` matches for the respective network. You can find these values in our network reference docs.

Run the `DeployProverSet.s.sol` script with your **proposer's private key** , altering the values in the script as necessary. You can find the script [here](https://github.com/taikoxyz/taiko-mono/tree/main/packages/protocol/script/DeployProverSet.s.sol).
Run the `DeployProverSet.s.sol` script with your **proposer's private key**. You can find the script [here](https://github.com/taikoxyz/taiko-mono/tree/main/packages/protocol/script/DeployProverSet.s.sol).

```bash
forge script --chain-id {CHAIN_ID} --rpc-url {YOUR_RPC_URL} --private-key=$PRIVATE_KEY --broadcast script/DeployProverSet.s.sol:DeployProverSet
ROLLUP_ADDRESS_MANAGER={ADDRESS} PROVER_SET_ADMIN={ADDRESS} forge script --chain-id {CHAIN_ID} --rpc-url {YOUR_RPC_URL} --private-key {PRIVATE_KEY} --broadcast script/DeployProverSet.s.sol:DeployProverSet
```

The script should print your proxy address with the log:
The script should print your implementation and proxy address with the log:

`Proxy Address: 0x....`
```
Deployed ProverSet impl at address: 0x....
Deployed ProverSet proxy at address: 0x....
```

Use this address for the following steps.
Use proxy address for the following steps.

4. **Verify the contract as a proxy on Etherscan**
3. **Verify the contract as a proxy on Etherscan**

Navigate to the `proxyAddress` logged as output of the script above in Etherscan.

Expand All @@ -83,7 +74,7 @@ This guide outlines how to achieve this with separate EOAs running prover and pr

Select the `Is this a proxy?` option and follow the instructions. This should verify the contract as a proxy to your `ProverSet` implementation.

5. **Write to the Proxy to `enableProver()`**
4. **Write to the Proxy to `enableProver()`**

If the above step was completed correctly, you should be able to see the `Write as Proxy` option in the `Contract` tab.

Expand All @@ -95,19 +86,19 @@ This guide outlines how to achieve this with separate EOAs running prover and pr

This will allow both EOAs to send transactions to your ProverSet implementation which will act as a proxy to TaikoL1.

6. **Configure the contract as necessary**
5. **Configure the contract as necessary**

Manage the contract's allowance with [approveAllowance()](https://github.com/taikoxyz/taiko-mono/blob/116d3f4886dea01333b829677ec9b6d4492479c6/packages/protocol/contracts/team/proving/ProverSet.sol#L63). TaikoL1's contract allowance is by default set to `UINT256.MAX` in the init function.

7. **Deposit your tokens and run your proposer + prover as usual!**
6. **Deposit your tokens and run your proposer + prover as usual!**

If you've followed the instructions, send your TAIKO/TTKOh to the ProverSet proxy and begin running your prover and proposer as usual.

<Aside>
Make sure to set your `$PROVER_SET` in your `simple-taiko-node` .env file as the proxy address.
Make sure to set your `$PROVER_SET` in your `simple-taiko-node` .env file as the proxy address.
</Aside>

Ensure that you have set up the EOAs correctly to avoid problems.
Ensure that you have set up the EOAs correctly to avoid problems.

<Aside>
You can withdraw the deposited tokens to the `admin` address with [withdrawToAdmin()](https://github.com/taikoxyz/taiko-mono/blob/116d3f4886dea01333b829677ec9b6d4492479c6/packages/protocol/contracts/team/proving/ProverSet.sol#L76).
Expand Down
55 changes: 12 additions & 43 deletions packages/protocol/script/DeployProverSet.s.sol
Original file line number Diff line number Diff line change
Expand Up @@ -5,63 +5,32 @@ import "../contracts/team/proving/ProverSet.sol";
import "../test/DeployCapability.sol";

contract DeployProverSet is DeployCapability {
// FOR HEKLA, change to mainnet ROLLUP_ADDRESS_MANAGER if deploying on mainnet.
address public constant ROLLUP_ADDRESS_MANAGER = 0x1F027871F286Cf4B7F898B21298E7B3e090a8403;

modifier broadcast() {
vm.startBroadcast();
_;
vm.stopBroadcast();
}

function run() external broadcast {
// User should run the following command from proposer EOA before running this script:
// `forge script --chain-id 17000 --broadcast --rpc-url {YOUR_RPC_URL}
// --private-key=$PRIVATE_KEY script/DeployProverSetUtil.s.sol:DeployProverSetUtil`
// Take the output and replace the following address.
address proverSet = 0x2623ee5c74CB532EE1CAA47B5624DCe9b14ec51A;

// Then run the script as follows
// `forge script --chain-id 17000 --rpc-url {YOUR_RPC_URL} --private-key=$PRIVATE_KEY
// --broadcast script/DeployProverSet.s.sol:DeployProverSet`

// check that a contract is present at address
uint256 codeSize;
assembly {
codeSize := extcodesize(proverSet)
}
require(codeSize > 0, "proverSet is not a contract");
address owner = vm.envOr("PROVER_SET_OWNER", msg.sender);
address admin = vm.envOr("PROVER_SET_ADMIN", msg.sender);
address addressManager = vm.envAddress("ROLLUP_ADDRESS_MANAGER");

// If you are working with a third party prover, this will likely need to be set to their
// prover address.
// This gives this address the authorization to withdraw their deposited TAIKO should they
// choose to.
address admin = msg.sender;
addressNotNull(owner, "invalid owner address");
addressNotNull(admin, "invalid admin address");
addressNotNull(addressManager, "invalid rollup address manager address");

address proxyAddy = deployProverSetWithProxy(msg.sender, admin, proverSet);
// With the following address you can register as proxy on Etherscan and access the
// implementation contract.
// Check the implementation, addressManager and admin address match the expected values.
console2.log("Proxy Address: %s", proxyAddy);
}

function deployProverSetWithProxy(
address owner,
address admin,
address proverSet
)
internal
returns (address proxyAddress)
{
addressNotNull(owner, "owner");
addressNotNull(proverSet, "proverSet");
address proverSet = address(new ProverSet());

address proxy = deployProxy({
name: "prover_set",
impl: proverSet,
data: abi.encodeCall(ProverSet.init, (owner, admin, ROLLUP_ADDRESS_MANAGER))
data: abi.encodeCall(ProverSet.init, (owner, admin, addressManager))
});
return proxy;

console2.log();
console2.log("Deployed ProverSet impl at address: %s", proverSet);
console2.log("Deployed ProverSet proxy at address: %s", proxy);
}

function addressNotNull(address addr, string memory err) private pure {
Expand Down
19 changes: 0 additions & 19 deletions packages/protocol/script/DeployProverSetUtil.s.sol

This file was deleted.

0 comments on commit 919cb4c

Please sign in to comment.