Skip to content
This repository has been archived by the owner on May 11, 2024. It is now read-only.

feat(all): changes based on contestable zkRollup protocol design #414

Merged
merged 66 commits into from
Oct 16, 2023
Merged
Show file tree
Hide file tree
Changes from 58 commits
Commits
Show all changes
66 commits
Select commit Hold shift + click to select a range
b33d725
feat: update bindings
davidtaikocha Sep 28, 2023
28f660f
feat: update `encoding` package
davidtaikocha Sep 29, 2023
1dc851d
feat(cmd): update flags
davidtaikocha Sep 29, 2023
7cb6d70
feat: update configs
davidtaikocha Sep 29, 2023
11fa6f6
feat(prover): update prover server
davidtaikocha Sep 29, 2023
8a59293
test(prover): update tests
davidtaikocha Sep 29, 2023
330b92f
feat(proposer): update proposer based on protocol changes
davidtaikocha Sep 29, 2023
e58ace7
feat: update `pkg` package
davidtaikocha Sep 29, 2023
3267dab
feat: update `testutils` package
davidtaikocha Sep 29, 2023
b71d0b1
feat: update `proof_producer` package
davidtaikocha Sep 29, 2023
c0720a5
feat(driver): update driver based on protocol changes
davidtaikocha Sep 29, 2023
739affa
feat(protocol): add `minTier` to `BlockProposed` event
davidtaikocha Sep 29, 2023
2be2c8c
feat(prover): update prover based on protocol changes
davidtaikocha Sep 29, 2023
920c7b7
feat(integration_test): update test scripts
davidtaikocha Oct 1, 2023
d66a268
Merge branch 'main' into contestable-zkrollup
davidtaikocha Oct 1, 2023
4c24265
test: update encoding tests
davidtaikocha Oct 1, 2023
355ced6
feat(all): rename oracle prover to guardian prover
davidtaikocha Oct 1, 2023
34765da
feat(encoding): implement `EncodeProverAssignmentPayload()`
davidtaikocha Oct 1, 2023
666ff72
test: update tests
davidtaikocha Oct 1, 2023
9744475
feat(bindings): update bindings
davidtaikocha Oct 6, 2023
66f2701
feat(prover): update `onBlockProven` handler
davidtaikocha Oct 6, 2023
e3dd1bf
Merge branch 'main' into contestable-zkrollup
davidtaikocha Oct 6, 2023
4dd63c3
feat(prover): add `getProvingWindow`
davidtaikocha Oct 6, 2023
994b2e4
feat(prover): add `onProvingWindowExpired`
davidtaikocha Oct 6, 2023
2ff237e
feat(proposer): update `ETHFeeEOASelector`
davidtaikocha Oct 7, 2023
c2347e9
feat(prover): update prover server
davidtaikocha Oct 7, 2023
8e766af
feat(prover): update prover server
davidtaikocha Oct 7, 2023
412e23d
chore: update ci
davidtaikocha Oct 7, 2023
74176a2
feat(driver): handle extra data
davidtaikocha Oct 7, 2023
8eecf1d
Merge branch 'main' into contestable-zkrollup
davidtaikocha Oct 7, 2023
3a3f7d1
test(driver): test `block.extraData`
davidtaikocha Oct 8, 2023
da658f4
feat(prover): improve proof submitter
davidtaikocha Oct 8, 2023
ef82501
feat(prover): remove unused fields
davidtaikocha Oct 8, 2023
eb28b05
feat(prover): rename some variables
davidtaikocha Oct 8, 2023
422728d
feat(prover): improve submitters
davidtaikocha Oct 8, 2023
eb88749
feat(prover): update `requestProofByBlockID`
davidtaikocha Oct 8, 2023
dc6802d
test(prover): add more tests for `capacityManager`
davidtaikocha Oct 9, 2023
9ac14c2
chore(prover): add more comments
davidtaikocha Oct 9, 2023
5d64321
test(prover): more tests
davidtaikocha Oct 9, 2023
2979cf8
test(prover): more prover tests
davidtaikocha Oct 9, 2023
b73c227
test(prover): more prover tests
davidtaikocha Oct 9, 2023
0bc65cc
test(prover): more prover tests
davidtaikocha Oct 9, 2023
f3c3960
test(prover): more tests
davidtaikocha Oct 9, 2023
c25845a
test(prover): more tests
davidtaikocha Oct 9, 2023
f8f09dd
test(prover): rename some variables
davidtaikocha Oct 9, 2023
ad9ca1a
feat(cmd): update flags
davidtaikocha Oct 9, 2023
468e5f4
feat(bindings): update bindings
davidtaikocha Oct 10, 2023
6ff40bb
feat(prover): introduce `evidence.Assembler`
davidtaikocha Oct 10, 2023
b34d353
feat(bindings): update bindings
davidtaikocha Oct 10, 2023
e34bde9
feat(prover): introduce `txBuild` && `txSender`
davidtaikocha Oct 10, 2023
1c56cd1
test(testutils): improve testutils
davidtaikocha Oct 11, 2023
86cfbb5
feat(cmd): remove unused flags
davidtaikocha Oct 11, 2023
d0952d4
feat(cmd): rename some flags
davidtaikocha Oct 11, 2023
c7cd1e9
feat(prover): introduce `ProofContester`
davidtaikocha Oct 11, 2023
fd1a146
feat(prover): more listeners
davidtaikocha Oct 12, 2023
5dc59d3
feat: update some flags
davidtaikocha Oct 12, 2023
478a799
chore: update ci
davidtaikocha Oct 12, 2023
c688fb7
chore: update ci
davidtaikocha Oct 12, 2023
01b7d37
feat: changes based on feedbacks
davidtaikocha Oct 13, 2023
acc4722
feat: update bindings
davidtaikocha Oct 13, 2023
2157a9c
add test
RogerLamTd Oct 13, 2023
a550452
Update cmd/flags/common.go
davidtaikocha Oct 16, 2023
d202aa4
Update driver/state/l1_current.go
davidtaikocha Oct 16, 2023
b3cd23b
Update driver/state/state.go
davidtaikocha Oct 16, 2023
e7f30bf
Update proposer/proposer.go
davidtaikocha Oct 16, 2023
0801636
feat: changes based on feedbacks
davidtaikocha Oct 16, 2023
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,7 @@ jobs:
with:
repository: taikoxyz/taiko-mono
path: ${{ env.TAIKO_MONO_DIR }}
ref: contestable-zkrollup

- name: Install Foundry
uses: foundry-rs/foundry-toolchain@v1
Expand Down
8 changes: 3 additions & 5 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -54,8 +54,6 @@ Then, run the integration tests:
2. Perform a `pnpm install` in `taiko-mono/packages/protocol`
3. Replace `<PATH_TO_TAIKO_MONO_REPO>` and execute:

```bash
TAIKO_MONO_DIR=<PATH_TO_TAIKO_MONO_REPO> \
COMPILE_PROTOCOL=true \
make test
```
```sh
TAIKO_MONO_DIR=<PATH_TO_TAIKO_MONO_REPO> make test
```
2 changes: 1 addition & 1 deletion bindings/.githead
Original file line number Diff line number Diff line change
@@ -1 +1 @@
ee2688156733d49cbf43c5178211db95a7079b26
2bcf2bf4b43456484ac3974d7360e5007accd741
254 changes: 60 additions & 194 deletions bindings/encoding/input.go
Original file line number Diff line number Diff line change
@@ -1,103 +1,17 @@
package encoding

import (
"bytes"
"errors"
"fmt"

"github.com/ethereum/go-ethereum/accounts/abi"
"github.com/ethereum/go-ethereum/common"
"github.com/ethereum/go-ethereum/core/types"
"github.com/ethereum/go-ethereum/crypto"
"github.com/ethereum/go-ethereum/log"
"github.com/ethereum/go-ethereum/rlp"
"github.com/taikoxyz/taiko-client/bindings"
)

// ABI arguments marshaling components.
var (
blockMetadataInputComponents = []abi.ArgumentMarshaling{
{
Name: "txListHash",
Type: "bytes32",
},
{
Name: "proposer",
Type: "address",
},
{
Name: "txListByteStart",
Type: "uint24",
},
{
Name: "txListByteEnd",
Type: "uint24",
},
{
Name: "cacheTxListInfo",
Type: "bool",
},
}
blockMetadataComponents = []abi.ArgumentMarshaling{
{
Name: "id",
Type: "uint64",
},
{
Name: "timestamp",
Type: "uint64",
},
{
Name: "l1Height",
Type: "uint64",
},
{
Name: "l1Hash",
Type: "bytes32",
},
{
Name: "mixHash",
Type: "bytes32",
},
{
Name: "txListHash",
Type: "bytes32",
},
{
Name: "txListByteStart",
Type: "uint24",
},
{
Name: "txListByteEnd",
Type: "uint24",
},
{
Name: "gasLimit",
Type: "uint32",
},
{
Name: "proposer",
Type: "address",
},
{
Name: "depositsProcessed",
Type: "tuple[]",
Components: []abi.ArgumentMarshaling{
{
Name: "recipient",
Type: "address",
},
{
Name: "amount",
Type: "uint96",
},
{
Name: "id",
Type: "uint64",
},
},
},
}
evidenceComponents = []abi.ArgumentMarshaling{
{
Name: "metaHash",
Expand All @@ -120,11 +34,11 @@ var (
Type: "bytes32",
},
{
Name: "prover",
Type: "address",
Name: "tier",
Type: "uint16",
},
{
Name: "proofs",
Name: "proof",
Type: "bytes",
},
}
Expand All @@ -134,48 +48,67 @@ var (
Type: "address",
},
{
Name: "expiry",
Type: "uint64",
},
{
Name: "data",
Type: "bytes",
},
}
proposeBlockDataComponents = []abi.ArgumentMarshaling{
{
Name: "input",
Type: "tuple",
Components: blockMetadataInputComponents,
Name: "feeToken",
Type: "address",
},
{
Name: "fee",
Type: "uint256",
Name: "tierFees",
Type: "tuple[]",
Components: []abi.ArgumentMarshaling{
{
Name: "tier",
Type: "uint16",
},
{
Name: "fee",
Type: "uint256",
},
},
},

{
Name: "expiry",
Type: "uint64",
},
{
Name: "signature",
Type: "bytes",
},
}
)

var (
// BlockMetadataInput
blockMetadataInputType, _ = abi.NewType("tuple", "TaikoData.BlockMetadataInput", blockMetadataInputComponents)
blockMetadataInputArgs = abi.Arguments{{Name: "BlockMetadataInput", Type: blockMetadataInputType}}
// BlockMetadata
blockMetadataType, _ = abi.NewType("tuple", "TaikoData.BlockMetadata", blockMetadataComponents)
blockMetadataArgs = abi.Arguments{{Name: "BlockMetadata", Type: blockMetadataType}}
// Evidence
EvidenceType, _ = abi.NewType("tuple", "TaikoData.BlockEvidence", evidenceComponents)
EvidenceArgs = abi.Arguments{{Name: "Evidence", Type: EvidenceType}}
evidenceType, _ = abi.NewType("tuple", "TaikoData.BlockEvidence", evidenceComponents)
evidenceArgs = abi.Arguments{{Name: "Evidence", Type: evidenceType}}
// ProverAssignment
proverAssignmentType, _ = abi.NewType("tuple", "ProverAssignment", proverAssignmentComponents)
proverAssignmentArgs = abi.Arguments{{Name: "ProverAssignment", Type: proverAssignmentType}}
// ProposeBlockData
proposeBlockDataType, _ = abi.NewType("tuple", "ProposeBlockData", proposeBlockDataComponents)
proposeBlockDataArgs = abi.Arguments{{Name: "ProposeBlockData", Type: proposeBlockDataType}}
// ProverAssignmentPayload
stringType, _ = abi.NewType("string", "", nil)
bytes32Type, _ = abi.NewType("bytes32", "", nil)
addressType, _ = abi.NewType("address", "", nil)
uint64Type, _ = abi.NewType("uint64", "", nil)
tierFeesType, _ = abi.NewType(
"tuple[]",
"",
[]abi.ArgumentMarshaling{
{
Name: "tier",
Type: "uint16",
},
{
Name: "fee",
Type: "uint256",
},
},
)
proverAssignmentPayloadArgs = abi.Arguments{
{Name: "PROVER_ASSIGNMENT", Type: stringType},
{Name: "txListHash", Type: bytes32Type},
{Name: "assignment.feeToken", Type: addressType},
{Name: "assignment.expiry", Type: uint64Type},
{Name: "assignment.tierFees", Type: tierFeesType},
}
)

// Contract ABIs.
Expand All @@ -196,24 +129,6 @@ func init() {
}
}

// EncodeBlockMetadataInput performs the solidity `abi.encode` for the given blockMetadataInput.
func EncodeBlockMetadataInput(meta *TaikoL1BlockMetadataInput) ([]byte, error) {
b, err := blockMetadataInputArgs.Pack(meta)
if err != nil {
return nil, fmt.Errorf("failed to abi.encode block metadata input, %w", err)
}
return b, nil
}

// EncodeBlockMetadata performs the solidity `abi.encode` for the given blockMetadata.
func EncodeBlockMetadata(meta *bindings.TaikoDataBlockMetadata) ([]byte, error) {
b, err := blockMetadataArgs.Pack(meta)
if err != nil {
return nil, fmt.Errorf("failed to abi.encode block metadata, %w", err)
}
return b, nil
}

// EncodeProverAssignment performs the solidity `abi.encode` for the given proverAssignment.
func EncodeProverAssignment(assignment *ProverAssignment) ([]byte, error) {
b, err := proverAssignmentArgs.Pack(assignment)
Expand All @@ -223,76 +138,27 @@ func EncodeProverAssignment(assignment *ProverAssignment) ([]byte, error) {
return b, nil
}

// EncodeProposeBlockData performs the solidity `abi.encode` for the given proposeBlockData.
func EncodeProposeBlockData(data *ProposeBlockData) ([]byte, error) {
b, err := proposeBlockDataArgs.Pack(data)
if err != nil {
return nil, fmt.Errorf("failed to abi.encode proposeBlock data, %w", err)
}
return b, nil
}

// EncodeEvidence performs the solidity `abi.encode` for the given evidence.
func EncodeEvidence(e *TaikoL1Evidence) ([]byte, error) {
b, err := EvidenceArgs.Pack(e)
func EncodeEvidence(e *BlockEvidence) ([]byte, error) {
b, err := evidenceArgs.Pack(e)
if err != nil {
return nil, fmt.Errorf("failed to abi.encode evidence, %w", err)
}
return b, nil
}

// EncodeCommitHash performs the solidity `abi.encodePacked` for the given
// commitHash components.
func EncodeCommitHash(beneficiary common.Address, txListHash [32]byte) []byte {
// keccak256(abi.encodePacked(beneficiary, txListHash));
return crypto.Keccak256(
bytes.Join([][]byte{beneficiary.Bytes(), txListHash[:]}, nil),
)
}

// EncodeProposeBlockInput encodes the input params for TaikoL1.proposeBlock.
func EncodeProposeBlockInput(metadataInput *TaikoL1BlockMetadataInput) ([]byte, error) {
metaBytes, err := EncodeBlockMetadataInput(metadataInput)
if err != nil {
return nil, err
}
return metaBytes, nil
}

// EncodeProveBlockInput encodes the input params for TaikoL1.proveBlock.
func EncodeProveBlockInput(
evidence *TaikoL1Evidence,
// EncodeProverAssignmentPayload performs the solidity `abi.encode` for the given proverAssignment payload.
func EncodeProverAssignmentPayload(
txListHash common.Hash,
feeToken common.Address,
expiry uint64,
tierFees []TierFee,
) ([]byte, error) {
evidenceBytes, err := EncodeEvidence(evidence)
b, err := proverAssignmentPayloadArgs.Pack("PROVER_ASSIGNMENT", txListHash, feeToken, expiry, tierFees)
if err != nil {
return nil, err
return nil, fmt.Errorf("failed to abi.encode prover assignment hash payload, %w", err)
}

return evidenceBytes, nil
}

// EncodeProveBlockInvalidInput encodes the input params for TaikoL1.proveBlockInvalid.
func EncodeProveBlockInvalidInput(
evidence *TaikoL1Evidence,
target *bindings.TaikoDataBlockMetadata,
receipt *types.Receipt,
) ([][]byte, error) {
evidenceBytes, err := EncodeEvidence(evidence)
if err != nil {
return nil, err
}

metaBytes, err := EncodeBlockMetadata(target)
if err != nil {
return nil, err
}

receiptBytes, err := rlp.EncodeToBytes(receipt)
if err != nil {
return nil, err
}

return [][]byte{evidenceBytes, metaBytes, receiptBytes}, nil
return b, nil
}

// UnpackTxListBytes unpacks the input data of a TaikoL1.proposeBlock transaction, and returns the txList bytes.
Expand Down
Loading