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

Commit

Permalink
feat(prover): refactor of guardian prover heartbeat signing / sending (
Browse files Browse the repository at this point in the history
  • Loading branch information
cyberhorsey authored Dec 14, 2023
1 parent 657f0e4 commit 630924e
Show file tree
Hide file tree
Showing 10 changed files with 380 additions and 277 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
bin
coverage.out
prover/dbPath
dbdata

# Test binary, built with `go test -c`
*.test
Expand Down
6 changes: 6 additions & 0 deletions cmd/flags/prover.go
Original file line number Diff line number Diff line change
Expand Up @@ -173,6 +173,11 @@ var (
Usage: "Amount to approve TaikoL1 contract for TaikoToken usage",
Category: proverCategory,
}
GuardianProverHealthCheckServerEndpoint = &cli.StringFlag{
Name: "prover.guardianProverHealthCheckServerEndpoint",
Usage: "HTTP endpoint for main guardian prover health check server",
Category: proverCategory,
}
)

// All prover flags.
Expand All @@ -191,6 +196,7 @@ var ProverFlags = MergeFlags(CommonFlags, []cli.Flag{
Dummy,
GuardianProver,
GuardianProofSubmissionDelay,
GuardianProverHealthCheckServerEndpoint,
ProofSubmissionMaxRetry,
ProveBlockTxReplacementMultiplier,
ProveBlockMaxTxGasTipCap,
Expand Down
163 changes: 87 additions & 76 deletions prover/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import (
"crypto/ecdsa"
"fmt"
"math/big"
"net/url"
"time"

"github.com/ethereum/go-ethereum/common"
Expand All @@ -14,44 +15,45 @@ import (

// Config contains the configurations to initialize a Taiko prover.
type Config struct {
L1WsEndpoint string
L1HttpEndpoint string
L2WsEndpoint string
L2HttpEndpoint string
TaikoL1Address common.Address
TaikoL2Address common.Address
TaikoTokenAddress common.Address
AssignmentHookAddress common.Address
L1ProverPrivKey *ecdsa.PrivateKey
ZKEvmRpcdEndpoint string
ZkEvmRpcdParamsPath string
StartingBlockID *big.Int
Dummy bool
GuardianProverAddress common.Address
GuardianProofSubmissionDelay time.Duration
ProofSubmissionMaxRetry uint64
Graffiti string
BackOffMaxRetrys uint64
BackOffRetryInterval time.Duration
ProveUnassignedBlocks bool
ContesterMode bool
RPCTimeout *time.Duration
WaitReceiptTimeout time.Duration
ProveBlockGasLimit *uint64
ProveBlockTxReplacementMultiplier uint64
ProveBlockMaxTxGasTipCap *big.Int
HTTPServerPort uint64
Capacity uint64
MinOptimisticTierFee *big.Int
MinSgxTierFee *big.Int
MinPseZkevmTierFee *big.Int
MinSgxAndPseZkevmTierFee *big.Int
MaxExpiry time.Duration
MaxProposedIn uint64
MaxBlockSlippage uint64
DatabasePath string
DatabaseCacheSize uint64
Allowance *big.Int
L1WsEndpoint string
L1HttpEndpoint string
L2WsEndpoint string
L2HttpEndpoint string
TaikoL1Address common.Address
TaikoL2Address common.Address
TaikoTokenAddress common.Address
AssignmentHookAddress common.Address
L1ProverPrivKey *ecdsa.PrivateKey
ZKEvmRpcdEndpoint string
ZkEvmRpcdParamsPath string
StartingBlockID *big.Int
Dummy bool
GuardianProverAddress common.Address
GuardianProofSubmissionDelay time.Duration
ProofSubmissionMaxRetry uint64
Graffiti string
BackOffMaxRetrys uint64
BackOffRetryInterval time.Duration
ProveUnassignedBlocks bool
ContesterMode bool
RPCTimeout *time.Duration
WaitReceiptTimeout time.Duration
ProveBlockGasLimit *uint64
ProveBlockTxReplacementMultiplier uint64
ProveBlockMaxTxGasTipCap *big.Int
HTTPServerPort uint64
Capacity uint64
MinOptimisticTierFee *big.Int
MinSgxTierFee *big.Int
MinPseZkevmTierFee *big.Int
MinSgxAndPseZkevmTierFee *big.Int
MaxExpiry time.Duration
MaxProposedIn uint64
MaxBlockSlippage uint64
DatabasePath string
DatabaseCacheSize uint64
Allowance *big.Int
GuardianProverHealthCheckServerEndpoint *url.URL
}

// NewConfigFromCliContext creates a new config instance from command line flags.
Expand Down Expand Up @@ -103,44 +105,53 @@ func NewConfigFromCliContext(c *cli.Context) (*Config, error) {
allowance = amt
}

var guardianProverHealthCheckServerEndpoint *url.URL
if c.IsSet(flags.GuardianProverHealthCheckServerEndpoint.Name) {
guardianProverHealthCheckServerEndpoint, err = url.Parse(c.String(flags.GuardianProverHealthCheckServerEndpoint.Name))
if err != nil {
return nil, err
}
}

return &Config{
L1WsEndpoint: c.String(flags.L1WSEndpoint.Name),
L1HttpEndpoint: c.String(flags.L1HTTPEndpoint.Name),
L2WsEndpoint: c.String(flags.L2WSEndpoint.Name),
L2HttpEndpoint: c.String(flags.L2HTTPEndpoint.Name),
TaikoL1Address: common.HexToAddress(c.String(flags.TaikoL1Address.Name)),
TaikoL2Address: common.HexToAddress(c.String(flags.TaikoL2Address.Name)),
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),
StartingBlockID: startingBlockID,
Dummy: c.Bool(flags.Dummy.Name),
GuardianProverAddress: common.HexToAddress(c.String(flags.GuardianProver.Name)),
GuardianProofSubmissionDelay: c.Duration(flags.GuardianProofSubmissionDelay.Name),
ProofSubmissionMaxRetry: c.Uint64(flags.ProofSubmissionMaxRetry.Name),
Graffiti: c.String(flags.Graffiti.Name),
BackOffMaxRetrys: c.Uint64(flags.BackOffMaxRetrys.Name),
BackOffRetryInterval: c.Duration(flags.BackOffRetryInterval.Name),
ProveUnassignedBlocks: c.Bool(flags.ProveUnassignedBlocks.Name),
ContesterMode: c.Bool(flags.ContesterMode.Name),
RPCTimeout: timeout,
WaitReceiptTimeout: c.Duration(flags.WaitReceiptTimeout.Name),
ProveBlockGasLimit: proveBlockTxGasLimit,
Capacity: c.Uint64(flags.ProverCapacity.Name),
ProveBlockTxReplacementMultiplier: proveBlockTxReplacementMultiplier,
ProveBlockMaxTxGasTipCap: proveBlockMaxTxGasTipCap,
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),
DatabasePath: c.String(flags.DatabasePath.Name),
DatabaseCacheSize: c.Uint64(flags.DatabaseCacheSize.Name),
Allowance: allowance,
L1WsEndpoint: c.String(flags.L1WSEndpoint.Name),
L1HttpEndpoint: c.String(flags.L1HTTPEndpoint.Name),
L2WsEndpoint: c.String(flags.L2WSEndpoint.Name),
L2HttpEndpoint: c.String(flags.L2HTTPEndpoint.Name),
TaikoL1Address: common.HexToAddress(c.String(flags.TaikoL1Address.Name)),
TaikoL2Address: common.HexToAddress(c.String(flags.TaikoL2Address.Name)),
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),
StartingBlockID: startingBlockID,
Dummy: c.Bool(flags.Dummy.Name),
GuardianProverAddress: common.HexToAddress(c.String(flags.GuardianProver.Name)),
GuardianProofSubmissionDelay: c.Duration(flags.GuardianProofSubmissionDelay.Name),
GuardianProverHealthCheckServerEndpoint: guardianProverHealthCheckServerEndpoint,
ProofSubmissionMaxRetry: c.Uint64(flags.ProofSubmissionMaxRetry.Name),
Graffiti: c.String(flags.Graffiti.Name),
BackOffMaxRetrys: c.Uint64(flags.BackOffMaxRetrys.Name),
BackOffRetryInterval: c.Duration(flags.BackOffRetryInterval.Name),
ProveUnassignedBlocks: c.Bool(flags.ProveUnassignedBlocks.Name),
ContesterMode: c.Bool(flags.ContesterMode.Name),
RPCTimeout: timeout,
WaitReceiptTimeout: c.Duration(flags.WaitReceiptTimeout.Name),
ProveBlockGasLimit: proveBlockTxGasLimit,
Capacity: c.Uint64(flags.ProverCapacity.Name),
ProveBlockTxReplacementMultiplier: proveBlockTxReplacementMultiplier,
ProveBlockMaxTxGasTipCap: proveBlockMaxTxGasTipCap,
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),
DatabasePath: c.String(flags.DatabasePath.Name),
DatabaseCacheSize: c.Uint64(flags.DatabaseCacheSize.Name),
Allowance: allowance,
}, nil
}
Loading

0 comments on commit 630924e

Please sign in to comment.