Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat(taiko-client): remove prover server package #17748

Merged
merged 6 commits into from
Jul 5, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
149 changes: 2 additions & 147 deletions packages/taiko-client/bindings/encoding/input.go
Original file line number Diff line number Diff line change
@@ -1,14 +1,10 @@
package encoding

import (
"bytes"
"encoding/binary"
"errors"
"fmt"

"github.com/ethereum/go-ethereum/accounts/abi"
"github.com/ethereum/go-ethereum/common"
"github.com/ethereum/go-ethereum/crypto"
"github.com/ethereum/go-ethereum/log"

"github.com/taikoxyz/taiko-mono/packages/taiko-client/bindings"
Expand Down Expand Up @@ -138,95 +134,11 @@ var (
Type: "bytes",
},
}
proverAssignmentComponents = []abi.ArgumentMarshaling{
{
Name: "feeToken",
Type: "address",
},
{
Name: "expiry",
Type: "uint64",
},
{
Name: "maxBlockId",
Type: "uint64",
},
{
Name: "maxProposedIn",
Type: "uint64",
},
{
Name: "metaHash",
Type: "bytes32",
},
{
Name: "parentMetaHash",
Type: "bytes32",
},
{
Name: "tierFees",
Type: "tuple[]",
Components: []abi.ArgumentMarshaling{
{
Name: "tier",
Type: "uint16",
},
{
Name: "fee",
Type: "uint128",
},
},
},
{
Name: "signature",
Type: "bytes",
},
}
assignmentHookInputComponents = []abi.ArgumentMarshaling{
{
Name: "assignment",
Type: "tuple",
Components: proverAssignmentComponents,
},
{
Name: "tip",
Type: "uint256",
},
}
)

var (
assignmentHookInputType, _ = abi.NewType("tuple", "AssignmentHook.Input", assignmentHookInputComponents)
assignmentHookInputArgs = abi.Arguments{{Name: "AssignmentHook.Input", Type: assignmentHookInputType}}
blockParamsComponentsType, _ = abi.NewType("tuple", "TaikoData.BlockParams", blockParamsComponents)
blockParamsComponentsArgs = abi.Arguments{{Name: "TaikoData.BlockParams", Type: blockParamsComponentsType}}
// ProverAssignmentPayload
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: "uint128",
},
},
)
proverAssignmentHashPayloadArgs = abi.Arguments{
{Name: "_assignment.metaHash", Type: bytes32Type},
{Name: "_assignment.parentMetaHash", Type: bytes32Type},
{Name: "_assignment.feeToken", Type: addressType},
{Name: "_assignment.expiry", Type: uint64Type},
{Name: "_assignment.maxBlockId", Type: uint64Type},
{Name: "_assignment.maxProposedIn", Type: uint64Type},
{Name: "_assignment.tierFees", Type: tierFeesType},
}
blockParamsComponentsType, _ = abi.NewType("tuple", "TaikoData.BlockParams", blockParamsComponents)
blockParamsComponentsArgs = abi.Arguments{{Name: "TaikoData.BlockParams", Type: blockParamsComponentsType}}
blockMetadataComponentsType, _ = abi.NewType("tuple", "TaikoData.BlockMetadata", blockMetadataComponents)
transitionComponentsType, _ = abi.NewType("tuple", "TaikoData.Transition", transitionComponents)
tierProofComponentsType, _ = abi.NewType("tuple", "TaikoData.TierProof", tierProofComponents)
Expand All @@ -247,7 +159,6 @@ var (
LibProvingABI *abi.ABI
LibUtilsABI *abi.ABI
LibVerifyingABI *abi.ABI
AssignmentHookABI *abi.ABI
SGXVerifierABI *abi.ABI
GuardianVerifierABI *abi.ABI
ProverSetABI *abi.ABI
Expand Down Expand Up @@ -290,10 +201,6 @@ func init() {
log.Crit("Get LibVerifying ABI error", "error", err)
}

if AssignmentHookABI, err = bindings.AssignmentHookMetaData.GetAbi(); err != nil {
log.Crit("Get AssignmentHook ABI error", "error", err)
}

if SGXVerifierABI, err = bindings.SgxVerifierMetaData.GetAbi(); err != nil {
log.Crit("Get SGXVerifier ABI error", err)
}
Expand All @@ -314,7 +221,6 @@ func init() {
LibProvingABI.Errors,
LibUtilsABI.Errors,
LibVerifyingABI.Errors,
AssignmentHookABI.Errors,
SGXVerifierABI.Errors,
GuardianVerifierABI.Errors,
ProverSetABI.Errors,
Expand All @@ -330,57 +236,6 @@ func EncodeBlockParams(params *BlockParams) ([]byte, error) {
return b, nil
}

// EncodeAssignmentHookInput performs the solidity `abi.encode` for the given input
func EncodeAssignmentHookInput(input *AssignmentHookInput) ([]byte, error) {
b, err := assignmentHookInputArgs.Pack(input)
if err != nil {
return nil, fmt.Errorf("failed to abi.encode assignment hook input params, %w", err)
}
return b, nil
}

// EncodeProverAssignmentPayload performs the solidity `abi.encode` for the given proverAssignment payload.
func EncodeProverAssignmentPayload(
chainID uint64,
taikoAddress common.Address,
assignmentHookAddress common.Address,
blockProposer common.Address,
assignedProver common.Address,
blobHash common.Hash,
feeToken common.Address,
expiry uint64,
maxBlockID uint64,
maxProposedIn uint64,
tierFees []TierFee,
) ([]byte, error) {
hashBytesPayload, err := proverAssignmentHashPayloadArgs.Pack(
common.Hash{},
common.Hash{},
feeToken,
expiry,
maxBlockID,
maxProposedIn,
tierFees,
)
if err != nil {
return nil, fmt.Errorf("failed to abi.encode prover assignment hash payload, %w", err)
}

chainIDBytes := make([]byte, 8)
binary.BigEndian.PutUint64(chainIDBytes, chainID)

return bytes.Join([][]byte{
common.RightPadBytes([]byte("PROVER_ASSIGNMENT"), 32),
chainIDBytes,
taikoAddress.Bytes(),
blockProposer.Bytes(),
assignedProver.Bytes(),
blobHash.Bytes(),
crypto.Keccak256Hash(hashBytesPayload).Bytes(),
assignmentHookAddress.Bytes(),
}, nil), nil
}

// EncodeProveBlockInput performs the solidity `abi.encode` for the given TaikoL1.proveBlock input.
func EncodeProveBlockInput(
meta *bindings.TaikoDataBlockMetadata,
Expand Down
38 changes: 0 additions & 38 deletions packages/taiko-client/bindings/encoding/input_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@ package encoding

import (
"context"
"math/big"
"os"
"testing"

Expand All @@ -16,43 +15,6 @@ import (
"github.com/taikoxyz/taiko-mono/packages/taiko-client/bindings"
)

func TestEncodeProverAssignmentPayload(t *testing.T) {
encoded, err := EncodeProverAssignmentPayload(
randomHash().Big().Uint64(),
common.BytesToAddress(randomBytes(20)),
common.BytesToAddress(randomBytes(20)),
common.BytesToAddress(randomBytes(20)),
common.BytesToAddress(randomBytes(20)),
common.BytesToHash(randomBytes(32)),
common.BytesToAddress(randomBytes(20)),
120,
1024,
0,
[]TierFee{{Tier: 0, Fee: common.Big1}},
)

require.Nil(t, err)
require.NotNil(t, encoded)
}

func TestEncodeAssignmentHookInput(t *testing.T) {
encoded, err := EncodeAssignmentHookInput(&AssignmentHookInput{
Assignment: &ProverAssignment{
FeeToken: common.Address{},
Expiry: 1,
MaxBlockId: 1,
MaxProposedIn: 1,
MetaHash: [32]byte{0xff},
TierFees: []TierFee{{Tier: 0, Fee: common.Big1}},
Signature: []byte{0xff},
},
Tip: big.NewInt(1),
})

require.Nil(t, err)
require.NotNil(t, encoded)
}

func TestUnpackTxListBytes(t *testing.T) {
_, err := UnpackTxListBytes(randomBytes(1024))
require.NotNil(t, err)
Expand Down
18 changes: 0 additions & 18 deletions packages/taiko-client/bindings/encoding/struct.go
Original file line number Diff line number Diff line change
Expand Up @@ -47,24 +47,6 @@ type TierFee struct {
Fee *big.Int
}

// ProverAssignment should be same with TaikoData.ProverAssignment.
type ProverAssignment struct {
FeeToken common.Address
Expiry uint64
MaxBlockId uint64 // nolint: revive,stylecheck
MaxProposedIn uint64
MetaHash [32]byte
ParentMetaHash [32]byte
TierFees []TierFee
Signature []byte
}

// AssignmentHookInput should be same as AssignmentHook.Input
type AssignmentHookInput struct {
Assignment *ProverAssignment
Tip *big.Int
}

// ToExecutableData converts a GETH *types.Header to *engine.ExecutableData.
func ToExecutableData(header *types.Header) *engine.ExecutableData {
executableData := &engine.ExecutableData{
Expand Down
Loading
Loading