Skip to content

Commit

Permalink
Merge branch 'main' into bond_alt
Browse files Browse the repository at this point in the history
  • Loading branch information
dantaik authored Jul 4, 2024
2 parents 7cfb159 + 919cb4c commit 37f7267
Show file tree
Hide file tree
Showing 27 changed files with 127 additions and 439 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.

24 changes: 16 additions & 8 deletions packages/taiko-client/cmd/flags/proposer.go
Original file line number Diff line number Diff line change
Expand Up @@ -82,13 +82,27 @@ var (
Value: 0,
EnvVars: []string{"EPOCH_MIN_TX_LIST_BYTES"},
}
MinTip = &cli.Float64Flag{
Name: "epoch.minTip",
Usage: "Minimum tip (in GWei) for a transaction to propose",
Category: proposerCategory,
Value: 0,
EnvVars: []string{"EPOCH_MIN_TIP"},
}
MinProposingInternal = &cli.DurationFlag{
Name: "epoch.minProposingInterval",
Usage: "Minimum time interval to force proposing a block, even if there are no transaction in mempool",
Category: proposerCategory,
Value: 0,
EnvVars: []string{"EPOCH_MIN_PROPOSING_INTERNAL"},
}
AllowZeroInterval = &cli.Uint64Flag{
Name: "epoch.allowZeroInterval",
Usage: "If set, after this many epochs, proposer will allow propose zero tip transactions once",
Category: proposerCategory,
Value: 0,
EnvVars: []string{"EPOCH_ALLOW_ZERO_INTERVAL"},
}
// Proposing metadata related.
ExtraData = &cli.StringFlag{
Name: "extraData",
Expand Down Expand Up @@ -132,13 +146,6 @@ var (
Value: false,
EnvVars: []string{"L1_BLOB_ALLOWED"},
}
L1BlockBuilderTip = &cli.Uint64Flag{
Name: "l1.blockBuilderTip",
Usage: "Amount you wish to tip the L1 block builder",
Value: 0,
Category: proposerCategory,
EnvVars: []string{"L1_BLOCK_BUILDER_TIP"},
}
)

// ProposerFlags All proposer flags.
Expand All @@ -155,7 +162,9 @@ var ProposerFlags = MergeFlags(CommonFlags, []cli.Flag{
ExtraData,
MinGasUsed,
MinTxListBytes,
MinTip,
MinProposingInternal,
AllowZeroInterval,
MaxProposedTxListsPerEpoch,
ProverEndpoints,
OptimisticTierFee,
Expand All @@ -164,5 +173,4 @@ var ProposerFlags = MergeFlags(CommonFlags, []cli.Flag{
MaxTierFeePriceBumps,
ProposeBlockIncludeParentMetaHash,
BlobAllowed,
L1BlockBuilderTip,
}, TxmgrFlags)
8 changes: 8 additions & 0 deletions packages/taiko-client/cmd/flags/prover.go
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,13 @@ var (
Category: proverCategory,
EnvVars: []string{"RAIKO_JWT_PATH"},
}
RaikoRequestTimeout = &cli.DurationFlag{
Name: "raiko.requestTimeout",
Usage: "Timeout in minutes for raiko request",
Category: commonCategory,
Value: 10 * time.Minute,
EnvVars: []string{"RAIKO_REQUEST_TIMEOUT"},
}
StartingBlockID = &cli.Uint64Flag{
Name: "prover.startingBlockID",
Usage: "If set, prover will start proving blocks from the block with this ID",
Expand Down Expand Up @@ -235,4 +242,5 @@ var ProverFlags = MergeFlags(CommonFlags, []cli.Flag{
L1NodeVersion,
L2NodeVersion,
BlockConfirmations,
RaikoRequestTimeout,
}, TxmgrFlags)
Original file line number Diff line number Diff line change
Expand Up @@ -217,7 +217,6 @@ func (s *BlobSyncerTestSuite) initProposer() {
SgxTierFee: common.Big256,
MaxTierFeePriceBumps: 3,
TierFeePriceBump: common.Big2,
L1BlockBuilderTip: common.Big0,
TxmgrConfigs: &txmgr.CLIConfig{
L1RPCURL: os.Getenv("L1_NODE_WS_ENDPOINT"),
NumConfirmations: 0,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,6 @@ func (s *ChainSyncerTestSuite) SetupTest() {
MaxTierFeePriceBumps: 3,
TierFeePriceBump: common.Big2,
ExtraData: "test",
L1BlockBuilderTip: common.Big0,
TxmgrConfigs: &txmgr.CLIConfig{
L1RPCURL: os.Getenv("L1_NODE_WS_ENDPOINT"),
NumConfirmations: 0,
Expand Down
1 change: 0 additions & 1 deletion packages/taiko-client/driver/driver_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -313,7 +313,6 @@ func (s *DriverTestSuite) InitProposer() {
SgxTierFee: common.Big256,
MaxTierFeePriceBumps: 3,
TierFeePriceBump: common.Big2,
L1BlockBuilderTip: common.Big0,
TxmgrConfigs: &txmgr.CLIConfig{
L1RPCURL: os.Getenv("L1_NODE_WS_ENDPOINT"),
NumConfirmations: 0,
Expand Down
8 changes: 5 additions & 3 deletions packages/taiko-client/pkg/rpc/engine.go
Original file line number Diff line number Diff line change
Expand Up @@ -99,15 +99,16 @@ func (c *EngineClient) ExchangeTransitionConfiguration(
return result, nil
}

// TxPoolContent fetches the transaction pool content from the L2 execution engine.
func (c *EngineClient) TxPoolContent(
// TxPoolContentWithMinTip fetches the transaction pool content from the L2 execution engine.
func (c *EngineClient) TxPoolContentWithMinTip(
ctx context.Context,
beneficiary common.Address,
baseFee *big.Int,
blockMaxGasLimit uint64,
maxBytesPerTxList uint64,
locals []string,
maxTransactionsLists uint64,
minTip uint64,
) ([]*miner.PreBuiltTxList, error) {
timeoutCtx, cancel := context.WithTimeout(ctx, defaultTimeout)
defer cancel()
Expand All @@ -116,13 +117,14 @@ func (c *EngineClient) TxPoolContent(
if err := c.CallContext(
timeoutCtx,
&result,
"taikoAuth_txPoolContent",
"taikoAuth_txPoolContentWithMinTip",
beneficiary,
baseFee,
blockMaxGasLimit,
maxBytesPerTxList,
locals,
maxTransactionsLists,
minTip,
); err != nil {
return nil, err
}
Expand Down
4 changes: 3 additions & 1 deletion packages/taiko-client/pkg/rpc/methods.go
Original file line number Diff line number Diff line change
Expand Up @@ -255,6 +255,7 @@ func (c *Client) GetPoolContent(
maxBytesPerTxList uint64,
locals []common.Address,
maxTransactionsLists uint64,
minTip uint64,
) ([]*miner.PreBuiltTxList, error) {
ctxWithTimeout, cancel := CtxWithTimeoutOrDefault(ctx, defaultTimeout)
defer cancel()
Expand Down Expand Up @@ -285,14 +286,15 @@ func (c *Client) GetPoolContent(
localsArg = append(localsArg, local.Hex())
}

return c.L2Engine.TxPoolContent(
return c.L2Engine.TxPoolContentWithMinTip(
ctxWithTimeout,
beneficiary,
baseFeeInfo.Basefee,
uint64(blockMaxGasLimit),
maxBytesPerTxList,
localsArg,
maxTransactionsLists,
minTip,
)
}

Expand Down
11 changes: 9 additions & 2 deletions packages/taiko-client/proposer/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,9 @@ type Config struct {
LocalAddressesOnly bool
MinGasUsed uint64
MinTxListBytes uint64
MinTip uint64
MinProposingInternal time.Duration
AllowZeroInterval uint64
MaxProposedTxListsPerEpoch uint64
ProposeBlockTxGasLimit uint64
ProverEndpoints []*url.URL
Expand All @@ -43,7 +45,6 @@ type Config struct {
IncludeParentMetaHash bool
BlobAllowed bool
TxmgrConfigs *txmgr.CLIConfig
L1BlockBuilderTip *big.Int
}

// NewConfigFromCliContext initializes a Config instance from
Expand Down Expand Up @@ -93,6 +94,11 @@ func NewConfigFromCliContext(c *cli.Context) (*Config, error) {
return nil, err
}

minTip, err := utils.GWeiToWei(c.Float64(flags.MinTip.Name))
if err != nil {
return nil, err
}

return &Config{
ClientConfig: &rpc.ClientConfig{
L1Endpoint: c.String(flags.L1WSEndpoint.Name),
Expand All @@ -113,8 +119,10 @@ func NewConfigFromCliContext(c *cli.Context) (*Config, error) {
LocalAddressesOnly: c.Bool(flags.TxPoolLocalsOnly.Name),
MinGasUsed: c.Uint64(flags.MinGasUsed.Name),
MinTxListBytes: c.Uint64(flags.MinTxListBytes.Name),
MinTip: minTip.Uint64(),
MinProposingInternal: c.Duration(flags.MinProposingInternal.Name),
MaxProposedTxListsPerEpoch: c.Uint64(flags.MaxProposedTxListsPerEpoch.Name),
AllowZeroInterval: c.Uint64(flags.AllowZeroInterval.Name),
ProposeBlockTxGasLimit: c.Uint64(flags.TxGasLimit.Name),
ProverEndpoints: proverEndpoints,
OptimisticTierFee: optimisticTierFee,
Expand All @@ -123,7 +131,6 @@ func NewConfigFromCliContext(c *cli.Context) (*Config, error) {
MaxTierFeePriceBumps: c.Uint64(flags.MaxTierFeePriceBumps.Name),
IncludeParentMetaHash: c.Bool(flags.ProposeBlockIncludeParentMetaHash.Name),
BlobAllowed: c.Bool(flags.BlobAllowed.Name),
L1BlockBuilderTip: new(big.Int).SetUint64(c.Uint64(flags.L1BlockBuilderTip.Name)),
TxmgrConfigs: pkgFlags.InitTxmgrConfigsFromCli(
c.String(flags.L1WSEndpoint.Name),
l1ProposerPrivKey,
Expand Down
Loading

0 comments on commit 37f7267

Please sign in to comment.