Skip to content

Commit

Permalink
Merge branch 'ontake_cleanup' into ontake_cleanup_followup
Browse files Browse the repository at this point in the history
  • Loading branch information
dantaik authored Sep 19, 2024
2 parents 65ab7ef + cf08eaf commit 283643d
Show file tree
Hide file tree
Showing 6 changed files with 43 additions and 22 deletions.
3 changes: 3 additions & 0 deletions .github/workflows/repo--vercel-deploy.yml
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,9 @@ jobs:
run: |
echo "Vercel Project ID: ${{ env.VERCEL_PROJECT_ID }}"
- name: Install Git
run: sudo apt-get update && sudo apt-get install -y git

- name: Checkout repository
uses: actions/checkout@v4

Expand Down
21 changes: 18 additions & 3 deletions packages/bridge-ui/src/libs/bridge/Bridge.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ import { routingContractsMap } from '$bridgeConfig';
import { MessageStatusError, ProcessMessageError, ReleaseError, WrongChainError, WrongOwnerError } from '$libs/error';
import type { BridgeProver } from '$libs/proof';
import { getConnectedWallet } from '$libs/util/getConnectedWallet';
import { isSmartContract } from '$libs/util/isSmartContract';
import { getLogger } from '$libs/util/logger';
import { config } from '$libs/wagmi';

Expand Down Expand Up @@ -262,6 +263,11 @@ export abstract class Bridge {
console.error('Failed to estimate gas, using fallback', error);
estimatedGas = 1_300_000n;
}

if (message.to && (await isSmartContract(message.to, Number(message.destChainId)))) {
log(`Recipient is a smart contract, increasing fees by 5 percent`);
estimatedGas = (estimatedGas * 105n) / 100n;
}
if (force) {
return await writeContract(config, {
address: bridgeContract.address,
Expand Down Expand Up @@ -293,10 +299,13 @@ export abstract class Bridge {

if (!message) throw new ProcessMessageError('Message is not defined');

const estimatedGas = await bridgeContract.estimateGas.retryMessage([message, isFinalAttempt], {
let estimatedGas = await bridgeContract.estimateGas.retryMessage([message, isFinalAttempt], {
account: client.account,
});

if (message.to && (await isSmartContract(message.to, Number(message.destChainId)))) {
log(`Recipient is a smart contract, increasing fees by 5 percent`);
estimatedGas = (estimatedGas * 105n) / 100n;
}
log('Estimated gas for retryMessage', estimatedGas);

const { request } = await simulateContract(config, {
Expand All @@ -319,9 +328,15 @@ export abstract class Bridge {

log('Estimating gas for recallMessage', bridgeContract.address, [message, proof]);

const estimatedGas = await bridgeContract.estimateGas.recallMessage([message, proof], { account: client.account });
let estimatedGas = await bridgeContract.estimateGas.recallMessage([message, proof], { account: client.account });
log('Estimated gas for recallMessage', estimatedGas);

if (message.from && (await isSmartContract(message.from, Number(message.srcChainId)))) {
log(`Sender is a smart contract, increasing fees by 5 percent`);
estimatedGas = (estimatedGas * 105n) / 100n;
}
log('Estimated gas for retryMessage', estimatedGas);

const { request } = await simulateContract(config, {
address: bridgeContract.address,
abi: bridgeContract.abi,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -133,7 +133,7 @@ If you've already deployed a ProverSet but would like to upgrade it through the
Execute the following command, filling in the values in the curly braces appropriately.

```bash
forge create --private-key {YOUR_PRIVATE_KEY} --chain-id 17000 --rpc-url {YOUR_RPC_URL} contracts/layer1/provers/ProverSet.sol:ProverSet
forge create --private-key {YOUR_PRIVATE_KEY} --chain-id {CHAIN_ID} --rpc-url {YOUR_RPC_URL} contracts/layer1/provers/ProverSet.sol:ProverSet
```

<Aside>
Expand Down Expand Up @@ -174,7 +174,7 @@ If you've already deployed a ProverSet but would like to upgrade it through the
Then, navigate to the `protocol` package in `taiko-mono` and execute the following command substituting values in curly braces as necessary.
```bash
forge verify-contract --chain-id 17000 --etherscan-api-key {GET-API-KEY-FROM-ETHERSCAN-FIRST} {PUT-CONTRACT-ADDRESS-HERE} contracts/team/proving/ProverSet.sol:ProverSet
forge verify-contract --chain-id {CHAIN_ID} --etherscan-api-key {GET-API-KEY-FROM-ETHERSCAN-FIRST} {PUT-CONTRACT-ADDRESS-HERE} contracts/layer1/provers/ProverSet.sol:ProverSet
```
You should get a success message and your contract should now show up as verified on Etherscan!
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,11 +10,6 @@ import { Aside, Card, CardGrid, Steps} from '@astrojs/starlight/components';
- You are already running a Taiko node [with Docker](/guides/node-operators/run-a-taiko-node-with-docker) or [from source](/guides/node-operators/build-a-taiko-node-from-source).
- You have [set up a prover](/guides/node-operators/enable-a-prover) or [configured a ProverSet](/guides/node-operators/deploy-a-proverset) with a third-party partner.

{/*## Using `stn`
1. Install [stn](https://github.com/d1onys1us/stn) if you haven't already.
2. Execute `stn config proposer` in your terminal and walk through the steps.*/}

## Using simple-taiko-node

<Aside type="caution">
Expand All @@ -35,7 +30,7 @@ You can choose to either use a ProverSet, or leave the `PROVER_SET` variable bla

6. Set `COMPOSE_PROFILES=proposer` or add proposer to the list.

7. Now that the proposer is configured properly, you can run it with `docker compose up -d`!
7. Now that the proposer is configured properly, you can run it with `docker compose up -d`! Please use `docker compose -f docker-compose-hekla.yml up -d` if you are running on Hekla.

</Steps>

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ import { Aside, Card, CardGrid, Steps } from "@astrojs/starlight/components";
## Enable a prover with simple-taiko-node

<Aside>
These are the bare minimum required settings along with a functional Taiko node to run a proposer, feel free to customize the rest of the variables in the `.env` file as you see fit!
These are the bare minimum required settings along with a functional Taiko node to run a prover, feel free to customize the rest of the variables in the `.env` file as you see fit!
</Aside>

<Steps>
Expand All @@ -24,16 +24,20 @@ These are the bare minimum required settings along with a functional Taiko node

3. Set the `L1_PROVER_PRIVATE_KEY` to an L1 account's private key which will send the Prove Block transactions.

4. You may optionally [deploy a `ProverSet` contract](/guides/node-operators/deploy-a-proverset) to run your proposer. If you are working with a third party prover, you will have to follow the guide with them to negotiate allowance and deposit of TAIKO/TTKOh. A ProverSet is recommended for a longer term stable setup to avoid nonce issues. For testing purposes, you may not feel the need to deploy a ProverSet.
4. You may optionally [deploy a `ProverSet` contract](/guides/node-operators/deploy-a-proverset) to run your prover. If you are working with a third party prover, you will have to follow the guide with them to negotiate allowance and deposit of TAIKO/TTKOh. A ProverSet is recommended for a longer term stable setup to avoid nonce issues. For testing purposes, you may not feel the need to deploy a ProverSet.

5. Finally set `ENABLE_PROVER` to `true` in simple-taiko-node `.env`.

6. Set `COMPOSE_PROFILES=prover` or add prover to the list.

7. You can then run your prover with `docker compose up -d`!
7. You can then run your prover with `docker compose up -d`! Please use `docker compose -f docker-compose-hekla.yml up -d` if you are running on Hekla.

</Steps>

<Aside>
The following steps can be done through the [ProverSet contract](/guides/node-operators/deploy-a-proverset/#deploying-a-proverset) if you have deployed one. We highly recommend this for a stable setup.
</Aside>

### Approve TaikoL1 as TAIKO spender (mainnet)

<Steps>
Expand Down Expand Up @@ -72,17 +76,21 @@ You will need TTKOh deposited on the TaikoL1 contract to secure the bond for the

3. Click the **approve** function and set the spender address to the TaikoL1 contract address: `0x79C9109b764609df928d16fC4a91e9081F7e87DB`.

4. Set the amount to at least the minimum bond amount of 125 TTKOh.
4. Set the amount to at least the minimum bond amount of 150 TTKOh.

You will need 125 TTKOh for each bond you sign. After entering 125, you need to set the 18 decimals that the TTKOh contract takes, you can click the plus button and then select 10^18.
You will need 150 TTKOh for each bond you sign. After entering 150, you need to set the 18 decimals that the TTKOh contract takes, you can click the plus button and then select 10^18.

5. Finally, click the **Write** button.
You will notice that the amount subtracted is separate in two transactions, 125 for the `proposeBlock` and 25 for `proveBlock`.

</Steps>
This is because the `livenessBond` (125) is taken when the block is proposed, and once the proof has been provided in the window is credited in TaikoL1; the `validityBond` (150) is then debited using the existing balance + an extra 25 TTKOh.

## Register the prover on the prover marketplace
If you have bonded TTKOh in the TaikoL1 contract, it will be used first before more is taken from your ProverSet.

Finally you can choose to register your prover endpoint on the <a href="https://dojonode.xyz/tatami" target="_blank">community prover marketplace</a> so other can use it to propose blocks.
For an explanation of the difference between these bonds, please refer to the terminology section [here](/resources/terminology).

5. Finally, click the **Write** button.

</Steps>

<Card title="Troubleshooting" icon="error">
If you run into any problems, please visit the [node troubleshooting page](/guides/node-operators/node-troubleshooting) for help.
Expand Down
4 changes: 2 additions & 2 deletions packages/docs-site/src/content/docs/resources/terminology.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,8 @@ This page is dedicated to explaining some terms relevant to the protocol that mi

In layman's terms, the above terms relate to the protocol in the following manner:

- A **Liveness Bond** is deposited when a prover gets assigned a block to prove; when the block gets verified it gets returned to the prover.
- A **Liveness Bond** is deposited when a prover gets assigned a block to prove (`proposeBlock` tx); when the block proof is provided within the proofWindow it gets debited to the prover.

- A **Validity Bond** is only handled when someone other than the original prover proves with a higher tier. The higher tier prover has to deposit it in TaikoL1. If the new proof is correct, it gets returned; otherwise it gets burned.
- A **Validity Bond** is deposited when a block proof is submitted (`proveBlock` tx), and the prover is ready to withstand a contest. If the proof gets verified (i.e. is not contested and is valid), the bond is returned to the prover. The prover can be different from the original assigned prover if the proof is outside the proofWindow, in which case the new prover has to provide the full validityBond amount.

- A **Contest Bond** is someone putting up a bond to say that a block should be contested and a higher tier should handle this case. If the higher tier proof is incorrect then contestBond is forfeited.

0 comments on commit 283643d

Please sign in to comment.