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

Commit

Permalink
feat(prover): clean up PSE_ZKEVM related code (#582)
Browse files Browse the repository at this point in the history
  • Loading branch information
davidtaikocha authored Feb 28, 2024
1 parent 13f896a commit ffcc2b2
Show file tree
Hide file tree
Showing 32 changed files with 116 additions and 839 deletions.
29 changes: 0 additions & 29 deletions bindings/encoding/input.go
Original file line number Diff line number Diff line change
Expand Up @@ -206,27 +206,11 @@ var (
Type: "uint256",
},
}
zkEvmProofComponents = []abi.ArgumentMarshaling{
{
Name: "verifierId",
Type: "uint16",
},
{
Name: "zkp",
Type: "bytes",
},
{
Name: "pointProof",
Type: "bytes",
},
}
)

var (
assignmentHookInputType, _ = abi.NewType("tuple", "AssignmentHook.Input", assignmentHookInputComponents)
assignmentHookInputArgs = abi.Arguments{{Name: "AssignmentHook.Input", Type: assignmentHookInputType}}
zkEvmProofType, _ = abi.NewType("tuple", "ZkEvmProof", zkEvmProofComponents)
zkEvmProofArgs = abi.Arguments{{Name: "ZkEvmProof", Type: zkEvmProofType}}
blockParamsComponentsType, _ = abi.NewType("tuple", "TaikoData.BlockParams", blockParamsComponents)
blockParamsComponentsArgs = abi.Arguments{{Name: "TaikoData.BlockParams", Type: blockParamsComponentsType}}
// ProverAssignmentPayload
Expand Down Expand Up @@ -348,19 +332,6 @@ func EncodeBlockParams(params *BlockParams) ([]byte, error) {
return b, nil
}

// EncodeBlockParams performs the solidity `abi.encode` for the given blockParams.
func EncodeZKEvmProof(proof []byte) ([]byte, error) {
b, err := zkEvmProofArgs.Pack(&ZKEvmProof{
VerifierId: 0,
Zkp: proof,
PointProof: []byte{},
})
if err != nil {
return nil, fmt.Errorf("failed to abi.encode ZkEvmProof, %w", err)
}
return b, nil
}

// EncodeAssignmentHookInput performs the solidity `abi.encode` for the given input
func EncodeAssignmentHookInput(input *AssignmentHookInput) ([]byte, error) {
b, err := assignmentHookInputArgs.Pack(input)
Expand Down
20 changes: 6 additions & 14 deletions bindings/encoding/struct.go
Original file line number Diff line number Diff line change
Expand Up @@ -10,13 +10,12 @@ import (

// Tier IDs defined in protocol.
var (
TierOptimisticID uint16 = 100
TierSgxID uint16 = 200
TierPseZkevmID uint16 = 300
TierSgxAndPseZkevmID uint16 = 400
TierGuardianID uint16 = 1000
ProtocolTiers = []uint16{TierOptimisticID, TierSgxID, TierSgxAndPseZkevmID, TierGuardianID}
GoldenTouchPrivKey = "92954368afd3caa1f3ce3ead0069c1af414054aefe1ef9aeacc1bf426222ce38"
TierOptimisticID uint16 = 100
TierSgxID uint16 = 200
TierSgxAndZkVMID uint16 = 300
TierGuardianID uint16 = 1000
ProtocolTiers = []uint16{TierOptimisticID, TierSgxID, TierSgxAndZkVMID, TierGuardianID}
GoldenTouchPrivKey = "92954368afd3caa1f3ce3ead0069c1af414054aefe1ef9aeacc1bf426222ce38"
)

// HookCall should be same with TaikoData.HookCall
Expand Down Expand Up @@ -62,13 +61,6 @@ type AssignmentHookInput struct {
Tip *big.Int
}

// ZKEvmProof should be same as PseZkVerifier.ZkEvmProof
type ZKEvmProof struct {
VerifierId uint16 // nolint: revive, stylecheck
Zkp []byte
PointProof []byte
}

// ToExecutableData converts a GETH *types.Header to *engine.ExecutableData.
func ToExecutableData(header *types.Header) *engine.ExecutableData {
executableData := &engine.ExecutableData{
Expand Down
12 changes: 0 additions & 12 deletions cmd/flags/proposer.go
Original file line number Diff line number Diff line change
Expand Up @@ -47,16 +47,6 @@ var (
Usage: "Initial tier fee (in wei) paid to prover to generate a SGX proofs",
Category: proposerCategory,
}
PseZkevmTierFee = &cli.Uint64Flag{
Name: "tierFee.pseZKEvm",
Usage: "Initial tier fee (in wei) paid to prover to generate a PSE zkEVM proofs",
Category: proposerCategory,
}
SgxAndPseZkevmTierFee = &cli.Uint64Flag{
Name: "tierFee.sgxAndPseZKEvm",
Usage: "Initial tier fee (in wei) paid to prover to generate a SGX + PSE zkEVM proofs",
Category: proposerCategory,
}
TierFeePriceBump = &cli.Uint64Flag{
Name: "tierFee.pricebump",
Usage: "Price bump percentage when no prover wants to accept the block at initial fee",
Expand Down Expand Up @@ -159,8 +149,6 @@ var ProposerFlags = MergeFlags(CommonFlags, []cli.Flag{
ProverEndpoints,
OptimisticTierFee,
SgxTierFee,
PseZkevmTierFee,
SgxAndPseZkevmTierFee,
TierFeePriceBump,
MaxTierFeePriceBumps,
ProposeBlockIncludeParentMetaHash,
Expand Down
24 changes: 0 additions & 24 deletions cmd/flags/prover.go
Original file line number Diff line number Diff line change
Expand Up @@ -30,16 +30,6 @@ var (

// Optional flags used by prover.
var (
ZkEvmRpcdEndpoint = &cli.StringFlag{
Name: "zkevm.rpcdEndpoint",
Usage: "RPC endpoint of a ZKEVM RPCD service",
Category: proverCategory,
}
ZkEvmRpcdParamsPath = &cli.StringFlag{
Name: "zkevm.rpcdParamsPath",
Usage: "Path of ZKEVM parameters file to use",
Category: proverCategory,
}
RaikoHostEndpoint = &cli.StringFlag{
Name: "raiko.hostEndpoint",
Usage: "RPC endpoint of a Raiko host service",
Expand Down Expand Up @@ -74,16 +64,6 @@ var (
Usage: "Minimum accepted fee for generating a SGX proof",
Category: proverCategory,
}
MinPseZkevmTierFee = &cli.Uint64Flag{
Name: "minTierFee.pseZKEvm",
Usage: "Minimum accepted fee for generating a PSE zkEVM proof",
Category: proverCategory,
}
MinSgxAndPseZkevmTierFee = &cli.Uint64Flag{
Name: "minTierFee.sgxAndPseZKEvm",
Usage: "Minimum accepted fee for generating a SGX + PSE zkEVM proof",
Category: proverCategory,
}
// Guardian prover related.
GuardianProver = &cli.StringFlag{
Name: "guardianProver",
Expand Down Expand Up @@ -208,14 +188,10 @@ var ProverFlags = MergeFlags(CommonFlags, []cli.Flag{
L1BeaconEndpoint,
L2WSEndpoint,
L2HTTPEndpoint,
ZkEvmRpcdEndpoint,
ZkEvmRpcdParamsPath,
RaikoHostEndpoint,
L1ProverPrivKey,
MinOptimisticTierFee,
MinSgxTierFee,
MinPseZkevmTierFee,
MinSgxAndPseZkevmTierFee,
StartingBlockID,
Dummy,
GuardianProver,
Expand Down
3 changes: 0 additions & 3 deletions docs/docs.go
Original file line number Diff line number Diff line change
Expand Up @@ -148,9 +148,6 @@ const docTemplate = `{
"minOptimisticTierFee": {
"type": "integer"
},
"minPseZkevmTierFee": {
"type": "integer"
},
"minSgxTierFee": {
"type": "integer"
},
Expand Down
3 changes: 0 additions & 3 deletions docs/swagger.json
Original file line number Diff line number Diff line change
Expand Up @@ -139,9 +139,6 @@
"minOptimisticTierFee": {
"type": "integer"
},
"minPseZkevmTierFee": {
"type": "integer"
},
"minSgxTierFee": {
"type": "integer"
},
Expand Down
2 changes: 0 additions & 2 deletions docs/swagger.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -42,8 +42,6 @@ definitions:
type: integer
minOptimisticTierFee:
type: integer
minPseZkevmTierFee:
type: integer
minSgxTierFee:
type: integer
prover:
Expand Down
2 changes: 0 additions & 2 deletions driver/chain_syncer/calldata/syncer_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -64,8 +64,6 @@ func (s *CalldataSyncerTestSuite) SetupTest() {
ProverEndpoints: s.ProverEndpoints,
OptimisticTierFee: common.Big256,
SgxTierFee: common.Big256,
PseZkevmTierFee: common.Big256,
SgxAndPseZkevmTierFee: common.Big256,
MaxTierFeePriceBumps: 3,
TierFeePriceBump: common.Big2,
L1BlockBuilderTip: common.Big0,
Expand Down
2 changes: 0 additions & 2 deletions driver/chain_syncer/chain_syncer_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -65,8 +65,6 @@ func (s *ChainSyncerTestSuite) SetupTest() {
ProverEndpoints: s.ProverEndpoints,
OptimisticTierFee: common.Big256,
SgxTierFee: common.Big256,
PseZkevmTierFee: common.Big256,
SgxAndPseZkevmTierFee: common.Big256,
MaxTierFeePriceBumps: 3,
TierFeePriceBump: common.Big2,
ExtraData: "test",
Expand Down
2 changes: 0 additions & 2 deletions driver/driver_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -72,8 +72,6 @@ func (s *DriverTestSuite) SetupTest() {
ProverEndpoints: s.ProverEndpoints,
OptimisticTierFee: common.Big256,
SgxTierFee: common.Big256,
PseZkevmTierFee: common.Big256,
SgxAndPseZkevmTierFee: common.Big256,
MaxTierFeePriceBumps: 3,
TierFeePriceBump: common.Big2,
L1BlockBuilderTip: common.Big0,
Expand Down
24 changes: 11 additions & 13 deletions internal/testutils/helper.go
Original file line number Diff line number Diff line change
Expand Up @@ -162,19 +162,17 @@ func (s *ClientTestSuite) NewTestProverServer(
s.Nil(err)

srv, err := server.New(&server.NewProverServerOpts{
ProverPrivateKey: proverPrivKey,
MinOptimisticTierFee: common.Big1,
MinSgxTierFee: common.Big1,
MinPseZkevmTierFee: common.Big1,
MinSgxAndPseZkevmTierFee: common.Big1,
MaxExpiry: 24 * time.Hour,
TaikoL1Address: common.HexToAddress(os.Getenv("TAIKO_L1_ADDRESS")),
AssignmentHookAddress: common.HexToAddress(os.Getenv("ASSIGNMENT_HOOK_ADDRESS")),
ProposeConcurrencyGuard: make(chan struct{}, 1024),
RPC: s.RPCClient,
ProtocolConfigs: &protocolConfig,
LivenessBond: protocolConfig.LivenessBond,
IsGuardian: true,
ProverPrivateKey: proverPrivKey,
MinOptimisticTierFee: common.Big1,
MinSgxTierFee: common.Big1,
MaxExpiry: 24 * time.Hour,
TaikoL1Address: common.HexToAddress(os.Getenv("TAIKO_L1_ADDRESS")),
AssignmentHookAddress: common.HexToAddress(os.Getenv("ASSIGNMENT_HOOK_ADDRESS")),
ProposeConcurrencyGuard: make(chan struct{}, 1024),
RPC: s.RPCClient,
ProtocolConfigs: &protocolConfig,
LivenessBond: protocolConfig.LivenessBond,
IsGuardian: true,
})
s.Nil(err)

Expand Down
4 changes: 0 additions & 4 deletions proposer/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -35,8 +35,6 @@ type Config struct {
ProverEndpoints []*url.URL
OptimisticTierFee *big.Int
SgxTierFee *big.Int
PseZkevmTierFee *big.Int
SgxAndPseZkevmTierFee *big.Int
TierFeePriceBump *big.Int
MaxTierFeePriceBumps uint64
IncludeParentMetaHash bool
Expand Down Expand Up @@ -130,8 +128,6 @@ func NewConfigFromCliContext(c *cli.Context) (*Config, error) {
ProverEndpoints: proverEndpoints,
OptimisticTierFee: new(big.Int).SetUint64(c.Uint64(flags.OptimisticTierFee.Name)),
SgxTierFee: new(big.Int).SetUint64(c.Uint64(flags.SgxTierFee.Name)),
PseZkevmTierFee: new(big.Int).SetUint64(c.Uint64(flags.PseZkevmTierFee.Name)),
SgxAndPseZkevmTierFee: new(big.Int).SetUint64(c.Uint64(flags.SgxAndPseZkevmTierFee.Name)),
TierFeePriceBump: new(big.Int).SetUint64(c.Uint64(flags.TierFeePriceBump.Name)),
MaxTierFeePriceBumps: c.Uint64(flags.MaxTierFeePriceBumps.Name),
IncludeParentMetaHash: c.Bool(flags.ProposeBlockIncludeParentMetaHash.Name),
Expand Down
6 changes: 0 additions & 6 deletions proposer/config_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -51,8 +51,6 @@ func (s *ProposerTestSuite) TestNewConfigFromCliContext() {
s.Equal(10*time.Second, c.WaitReceiptTimeout)
s.Equal(uint64(tierFee), c.OptimisticTierFee.Uint64())
s.Equal(uint64(tierFee), c.SgxTierFee.Uint64())
s.Equal(uint64(tierFee), c.PseZkevmTierFee.Uint64())
s.Equal(uint64(tierFee), c.SgxAndPseZkevmTierFee.Uint64())
s.Equal(uint64(15), c.TierFeePriceBump.Uint64())
s.Equal(uint64(5), c.MaxTierFeePriceBumps)
s.Equal(true, c.IncludeParentMetaHash)
Expand Down Expand Up @@ -84,8 +82,6 @@ func (s *ProposerTestSuite) TestNewConfigFromCliContext() {
"--" + flags.ProverEndpoints.Name, proverEndpoints,
"--" + flags.OptimisticTierFee.Name, fmt.Sprint(tierFee),
"--" + flags.SgxTierFee.Name, fmt.Sprint(tierFee),
"--" + flags.PseZkevmTierFee.Name, fmt.Sprint(tierFee),
"--" + flags.SgxAndPseZkevmTierFee.Name, fmt.Sprint(tierFee),
"--" + flags.TierFeePriceBump.Name, "15",
"--" + flags.MaxTierFeePriceBumps.Name, "5",
"--" + flags.ProposeBlockIncludeParentMetaHash.Name, "true",
Expand Down Expand Up @@ -162,8 +158,6 @@ func (s *ProposerTestSuite) SetupApp() *cli.App {
&cli.StringFlag{Name: flags.ProverEndpoints.Name},
&cli.Uint64Flag{Name: flags.OptimisticTierFee.Name},
&cli.Uint64Flag{Name: flags.SgxTierFee.Name},
&cli.Uint64Flag{Name: flags.PseZkevmTierFee.Name},
&cli.Uint64Flag{Name: flags.SgxAndPseZkevmTierFee.Name},
&cli.Uint64Flag{Name: flags.ProposeBlockTxReplacementMultiplier.Name},
&cli.DurationFlag{Name: flags.RPCTimeout.Name},
&cli.DurationFlag{Name: flags.WaitReceiptTimeout.Name},
Expand Down
4 changes: 0 additions & 4 deletions proposer/proposer.go
Original file line number Diff line number Diff line change
Expand Up @@ -557,10 +557,6 @@ func (p *Proposer) initTierFees() error {
p.tierFees = append(p.tierFees, encoding.TierFee{Tier: tier.ID, Fee: p.OptimisticTierFee})
case encoding.TierSgxID:
p.tierFees = append(p.tierFees, encoding.TierFee{Tier: tier.ID, Fee: p.SgxTierFee})
case encoding.TierPseZkevmID:
p.tierFees = append(p.tierFees, encoding.TierFee{Tier: tier.ID, Fee: p.PseZkevmTierFee})
case encoding.TierSgxAndPseZkevmID:
p.tierFees = append(p.tierFees, encoding.TierFee{Tier: tier.ID, Fee: p.SgxAndPseZkevmTierFee})
case encoding.TierGuardianID:
// Guardian prover should not charge any fee.
p.tierFees = append(p.tierFees, encoding.TierFee{Tier: tier.ID, Fee: common.Big0})
Expand Down
2 changes: 0 additions & 2 deletions proposer/proposer_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -53,8 +53,6 @@ func (s *ProposerTestSuite) SetupTest() {
ProverEndpoints: s.ProverEndpoints,
OptimisticTierFee: common.Big256,
SgxTierFee: common.Big256,
PseZkevmTierFee: common.Big256,
SgxAndPseZkevmTierFee: common.Big256,
TierFeePriceBump: common.Big2,
MaxTierFeePriceBumps: 3,
ExtraData: "test",
Expand Down
2 changes: 0 additions & 2 deletions proposer/prover_selector/eth_fee_eoa_selector_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -54,8 +54,6 @@ func (s *ProverSelectorTestSuite) TestProverAssignProver() {
sig, _, fee, err := s.s.AssignProver(context.Background(), []encoding.TierFee{
{Tier: encoding.TierOptimisticID, Fee: common.Big256},
{Tier: encoding.TierSgxID, Fee: common.Big256},
{Tier: encoding.TierPseZkevmID, Fee: common.Big256},
{Tier: encoding.TierSgxAndPseZkevmID, Fee: common.Big256},
}, testutils.RandomHash())
s.NotEmpty(sig)
s.True(fee.Cmp(common.Big0) > 0)
Expand Down
8 changes: 0 additions & 8 deletions prover/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -27,8 +27,6 @@ type Config struct {
TaikoTokenAddress common.Address
AssignmentHookAddress common.Address
L1ProverPrivKey *ecdsa.PrivateKey
ZKEvmRpcdEndpoint string
ZkEvmRpcdParamsPath string
StartingBlockID *big.Int
Dummy bool
GuardianProverAddress common.Address
Expand All @@ -49,8 +47,6 @@ type Config struct {
Capacity uint64
MinOptimisticTierFee *big.Int
MinSgxTierFee *big.Int
MinPseZkevmTierFee *big.Int
MinSgxAndPseZkevmTierFee *big.Int
MaxExpiry time.Duration
MaxProposedIn uint64
MaxBlockSlippage uint64
Expand Down Expand Up @@ -152,8 +148,6 @@ func NewConfigFromCliContext(c *cli.Context) (*Config, error) {
TaikoTokenAddress: common.HexToAddress(c.String(flags.TaikoTokenAddress.Name)),
AssignmentHookAddress: common.HexToAddress(c.String(flags.ProverAssignmentHookAddress.Name)),
L1ProverPrivKey: l1ProverPrivKey,
ZKEvmRpcdEndpoint: c.String(flags.ZkEvmRpcdEndpoint.Name),
ZkEvmRpcdParamsPath: c.String(flags.ZkEvmRpcdParamsPath.Name),
RaikoHostEndpoint: c.String(flags.RaikoHostEndpoint.Name),
StartingBlockID: startingBlockID,
Dummy: c.Bool(flags.Dummy.Name),
Expand All @@ -176,8 +170,6 @@ func NewConfigFromCliContext(c *cli.Context) (*Config, error) {
HTTPServerPort: c.Uint64(flags.ProverHTTPServerPort.Name),
MinOptimisticTierFee: new(big.Int).SetUint64(c.Uint64(flags.MinOptimisticTierFee.Name)),
MinSgxTierFee: new(big.Int).SetUint64(c.Uint64(flags.MinSgxTierFee.Name)),
MinPseZkevmTierFee: new(big.Int).SetUint64(c.Uint64(flags.MinPseZkevmTierFee.Name)),
MinSgxAndPseZkevmTierFee: new(big.Int).SetUint64(c.Uint64(flags.MinSgxAndPseZkevmTierFee.Name)),
MaxExpiry: c.Duration(flags.MaxExpiry.Name),
MaxBlockSlippage: c.Uint64(flags.MaxAcceptableBlockSlippage.Name),
MaxProposedIn: c.Uint64(flags.MaxProposedIn.Name),
Expand Down
3 changes: 0 additions & 3 deletions prover/config_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,6 @@ func (s *ProverTestSuite) TestNewConfigFromCliContextGuardianProver() {
s.Equal(uint64(8), c.Capacity)
s.Equal(uint64(minTierFee), c.MinOptimisticTierFee.Uint64())
s.Equal(uint64(minTierFee), c.MinSgxTierFee.Uint64())
s.Equal(uint64(minTierFee), c.MinPseZkevmTierFee.Uint64())
s.Equal(uint64(3), c.ProveBlockTxReplacementMultiplier)
s.Equal(uint64(256), c.ProveBlockMaxTxGasTipCap.Uint64())
s.Equal(c.L1NodeVersion, l1NodeVersion)
Expand Down Expand Up @@ -83,7 +82,6 @@ func (s *ProverTestSuite) TestNewConfigFromCliContextGuardianProver() {
"--" + flags.Dummy.Name,
"--" + flags.MinOptimisticTierFee.Name, fmt.Sprint(minTierFee),
"--" + flags.MinSgxTierFee.Name, fmt.Sprint(minTierFee),
"--" + flags.MinPseZkevmTierFee.Name, fmt.Sprint(minTierFee),
"--" + flags.ProverCapacity.Name, "8",
"--" + flags.GuardianProver.Name, os.Getenv("GUARDIAN_PROVER_CONTRACT_ADDRESS"),
"--" + flags.ProverAssignmentHookAddress.Name, os.Getenv("ASSIGNMENT_HOOK_ADDRESS"),
Expand Down Expand Up @@ -131,7 +129,6 @@ func (s *ProverTestSuite) SetupApp() *cli.App {
&cli.Uint64Flag{Name: flags.ProverCapacity.Name},
&cli.Uint64Flag{Name: flags.MinOptimisticTierFee.Name},
&cli.Uint64Flag{Name: flags.MinSgxTierFee.Name},
&cli.Uint64Flag{Name: flags.MinPseZkevmTierFee.Name},
&cli.Uint64Flag{Name: flags.ProveBlockTxGasLimit.Name},
&cli.StringFlag{Name: flags.DatabasePath.Name},
&cli.Uint64Flag{Name: flags.DatabaseCacheSize.Name},
Expand Down
1 change: 0 additions & 1 deletion prover/proof_producer/dummy_producer.go
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,6 @@ func (o *DummyProofProducer) RequestProof(
Meta: meta,
Header: header,
Proof: bytes.Repeat([]byte{0xff}, 100),
Degree: CircuitsIdx,
Opts: opts,
Tier: tier,
}, nil
Expand Down
1 change: 0 additions & 1 deletion prover/proof_producer/guardian_producer.go
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,6 @@ func (g *GuardianProofProducer) RequestProof(
Meta: meta,
Header: header,
Proof: crypto.Keccak256([]byte("RETURN_LIVENESS_BOND")),
Degree: CircuitsIdx,
Opts: opts,
Tier: g.Tier(),
}, nil
Expand Down
Loading

0 comments on commit ffcc2b2

Please sign in to comment.