From 7d9189149805f3737512c2772bdd3a881ea67ac1 Mon Sep 17 00:00:00 2001 From: gavin Date: Thu, 18 Apr 2024 14:59:52 +0800 Subject: [PATCH] feat(cmd): default unit for all related flags / logs --- bindings/encoding/input_test.go | 2 +- cmd/flags/common.go | 24 +++++++-- cmd/flags/driver.go | 5 ++ cmd/flags/proposer.go | 29 +++++++++-- cmd/flags/prover.go | 41 ++++++++++++--- cmd/flags/txmgr.go | 11 ++++ driver/chain_syncer/calldata/syncer_test.go | 4 +- driver/chain_syncer/chain_syncer_test.go | 4 +- driver/config.go | 2 - driver/config_test.go | 4 +- driver/driver_test.go | 6 +-- integration_test/entrypoint.sh | 2 +- integration_test/test_env.sh | 2 +- internal/docker/docker_env.sh | 4 +- internal/testutils/suite.go | 4 +- pkg/rpc/blob_tx_test.go | 2 +- pkg/rpc/client_test.go | 4 +- pkg/utils/eth.go | 51 +++++++++++++++++++ proposer/config.go | 15 +++++- proposer/config_test.go | 2 +- proposer/proposer_test.go | 4 +- prover/config.go | 40 ++++++++++++--- prover/config_test.go | 2 +- .../event_handler/transition_proved_test.go | 6 +-- prover/init.go | 2 +- .../proof_submitter/proof_submitter_test.go | 6 +-- .../transaction/sender_test.go | 2 +- prover/prover.go | 2 +- prover/prover_test.go | 18 +++---- prover/server/api.go | 13 ++--- prover/server/server.go | 1 - prover/server/server_test.go | 2 +- 32 files changed, 241 insertions(+), 75 deletions(-) create mode 100644 pkg/utils/eth.go diff --git a/bindings/encoding/input_test.go b/bindings/encoding/input_test.go index 86b3f067a..75a693beb 100644 --- a/bindings/encoding/input_test.go +++ b/bindings/encoding/input_test.go @@ -65,7 +65,7 @@ func TestUnpackTxListBytes(t *testing.T) { ) require.ErrorContains(t, err, "no method with id") - cli, err := ethclient.Dial(os.Getenv("L1_NODE_WS_ENDPOINT")) + cli, err := ethclient.Dial(os.Getenv("L1_WS_ENDPOINT")) require.Nil(t, err) chainID, err := cli.ChainID(context.Background()) diff --git a/cmd/flags/common.go b/cmd/flags/common.go index 1aeeda8ee..4b2aa7070 100644 --- a/cmd/flags/common.go +++ b/cmd/flags/common.go @@ -24,59 +24,69 @@ var ( Usage: "Websocket RPC endpoint of a L1 ethereum node", Required: true, Category: commonCategory, + EnvVars: []string{"L1_WS_ENDPOINT"}, } L2WSEndpoint = &cli.StringFlag{ Name: "l2.ws", Usage: "Websocket RPC endpoint of a L2 taiko-geth execution engine", Required: true, Category: commonCategory, + EnvVars: []string{"L2_WS_ENDPOINT"}, } L1HTTPEndpoint = &cli.StringFlag{ Name: "l1.http", Usage: "HTTP RPC endpoint of a L1 ethereum node", Required: true, Category: commonCategory, + EnvVars: []string{"L1_HTTP_ENDPOINT"}, } L1BeaconEndpoint = &cli.StringFlag{ Name: "l1.beacon", Usage: "HTTP RPC endpoint of a L1 beacon node", Category: commonCategory, + EnvVars: []string{"L1_BEACON_ENDPOINT"}, } L2HTTPEndpoint = &cli.StringFlag{ Name: "l2.http", Usage: "HTTP RPC endpoint of a L2 taiko-geth execution engine", Required: true, Category: commonCategory, + EnvVars: []string{"L2_HTTP_ENDPOINT"}, } L2AuthEndpoint = &cli.StringFlag{ Name: "l2.auth", Usage: "Authenticated HTTP RPC endpoint of a L2 taiko-geth execution engine", Required: true, Category: commonCategory, + EnvVars: []string{"L2_AUTH_ENDPOINT"}, } JWTSecret = &cli.StringFlag{ Name: "jwtSecret", Usage: "Path to a JWT secret to use for authenticated RPC endpoints", Required: true, Category: commonCategory, + EnvVars: []string{"JWT_SECRET"}, } TaikoL1Address = &cli.StringFlag{ Name: "taikoL1", Usage: "TaikoL1 contract `address`", Required: true, Category: commonCategory, + EnvVars: []string{"TAIKO_L1_ADDRESS"}, } TaikoL2Address = &cli.StringFlag{ Name: "taikoL2", Usage: "TaikoL2 contract `address`", Required: true, Category: commonCategory, + EnvVars: []string{"TAIKO_L2_ADDRESS"}, } TaikoTokenAddress = &cli.StringFlag{ Name: "taikoToken", Usage: "TaikoToken contract `address`", Required: true, Category: commonCategory, + EnvVars: []string{"TAIKO_TOKEN_ADDRESS"}, } // Optional flags used by all client software. // Logging @@ -85,11 +95,13 @@ var ( Usage: "Logging verbosity: 0=silent, 1=error, 2=warn, 3=info, 4=debug, 5=detail", Value: 3, Category: loggingCategory, + EnvVars: []string{"VERBOSITY"}, } LogJSON = &cli.BoolFlag{ Name: "log.json", Usage: "Format logs with JSON", Category: loggingCategory, + EnvVars: []string{"LOG_JSON"}, } // Metrics MetricsEnabled = &cli.BoolFlag{ @@ -97,36 +109,42 @@ var ( Usage: "Enable metrics collection and reporting", Category: metricsCategory, Value: false, + EnvVars: []string{"METRICS_ENABLED"}, } MetricsAddr = &cli.StringFlag{ Name: "metrics.addr", Usage: "Metrics reporting server listening address", Category: metricsCategory, Value: "0.0.0.0", + EnvVars: []string{"METRICS_ADDR"}, } MetricsPort = &cli.IntFlag{ Name: "metrics.port", Usage: "Metrics reporting server listening port", Category: metricsCategory, Value: 6060, + EnvVars: []string{"METRICS_PORT"}, } - BackOffMaxRetrys = &cli.Uint64Flag{ - Name: "backoff.maxRetrys", + BackOffMaxRetries = &cli.Uint64Flag{ + Name: "backoff.maxRetries", Usage: "Max retry times when there is an error", Category: commonCategory, Value: 10, + EnvVars: []string{"BACKOFF_MAX_RETRIES"}, } BackOffRetryInterval = &cli.DurationFlag{ Name: "backoff.retryInterval", Usage: "Retry interval in seconds when there is an error", Category: commonCategory, Value: backoff.DefaultMaxInterval, + EnvVars: []string{"BACKOFF_RETRY_INTERVAL"}, } RPCTimeout = &cli.DurationFlag{ Name: "rpc.timeout", Usage: "Timeout in seconds for RPC calls", Category: commonCategory, Value: 12 * time.Second, + EnvVars: []string{"RPC_TIMEOUT"}, } ) @@ -142,7 +160,7 @@ var CommonFlags = []cli.Flag{ MetricsEnabled, MetricsAddr, MetricsPort, - BackOffMaxRetrys, + BackOffMaxRetries, BackOffRetryInterval, RPCTimeout, } diff --git a/cmd/flags/driver.go b/cmd/flags/driver.go index 8693f0366..48110f2f6 100644 --- a/cmd/flags/driver.go +++ b/cmd/flags/driver.go @@ -14,6 +14,7 @@ var ( "will be helpful to bring a new node online quickly", Value: false, Category: driverCategory, + EnvVars: []string{"P2P_SYNC_VERIFIED_BLOCKS"}, } P2PSyncTimeout = &cli.DurationFlag{ Name: "p2p.syncTimeout", @@ -21,11 +22,13 @@ var ( "driver will stop the P2P sync and insert all remaining L2 blocks one by one", Value: 1 * time.Hour, Category: driverCategory, + EnvVars: []string{"P2P_SYNC_TIMEOUT"}, } CheckPointSyncURL = &cli.StringFlag{ Name: "p2p.checkPointSyncUrl", Usage: "HTTP RPC endpoint of another synced L2 execution engine node", Category: driverCategory, + EnvVars: []string{"CHECK_POINT_SYNC_URL"}, } // syncer specific flag MaxExponent = &cli.Uint64Flag{ @@ -34,12 +37,14 @@ var ( "0 means that it is reset to the genesis height", Value: 0, Category: driverCategory, + EnvVars: []string{"MAX_EXPONENT"}, } // blob server endpoint BlobServerEndpoint = &cli.StringFlag{ Name: "blob.server", Usage: "Blob sidecar storage server", Category: driverCategory, + EnvVars: []string{"BLOB_SERVER_ENDPOINT"}, } ) diff --git a/cmd/flags/proposer.go b/cmd/flags/proposer.go index 80754460a..9349d226e 100644 --- a/cmd/flags/proposer.go +++ b/cmd/flags/proposer.go @@ -13,24 +13,28 @@ var ( Usage: "Private key of the L1 proposer, who will send TaikoL1.proposeBlock transactions", Required: true, Category: proposerCategory, + EnvVars: []string{"L1_PROPOSER_PRIV_KEY"}, } ProverEndpoints = &cli.StringFlag{ Name: "proverEndpoints", Usage: "Comma-delineated list of prover endpoints proposer should query when attempting to propose a block", Required: true, Category: proposerCategory, + EnvVars: []string{"PROVER_ENDPOINTS"}, } L2SuggestedFeeRecipient = &cli.StringFlag{ Name: "l2.suggestedFeeRecipient", Usage: "Address of the proposed block's suggested L2 fee recipient", Required: true, Category: proposerCategory, + EnvVars: []string{"L2_SUGGESTED_FEE_RECIPIENT"}, } ProposerAssignmentHookAddress = &cli.StringFlag{ Name: "assignmentHookAddress", Usage: "Address of the AssignmentHook contract", Required: true, Category: proposerCategory, + EnvVars: []string{"PROPOSER_ASSIGNMENT_HOOK_ADDRESS"}, } ) @@ -39,25 +43,29 @@ var ( // Tier fee related. OptimisticTierFee = &cli.Uint64Flag{ Name: "tierFee.optimistic", - Usage: "Initial tier fee (in wei) paid to prover to generate an optimistic proofs", + Usage: "Initial tier fee (in GWei) paid to prover to generate an optimistic proofs", Category: proposerCategory, + EnvVars: []string{"OPTIMISTIC_TIER_FEE"}, } SgxTierFee = &cli.Uint64Flag{ Name: "tierFee.sgx", - Usage: "Initial tier fee (in wei) paid to prover to generate a SGX proofs", + Usage: "Initial tier fee (in GWei) paid to prover to generate a SGX proofs", Category: proposerCategory, + EnvVars: []string{"SGX_TIER_FEE"}, } TierFeePriceBump = &cli.Uint64Flag{ Name: "tierFee.pricebump", Usage: "Price bump percentage when no prover wants to accept the block at initial fee", Value: 10, Category: proposerCategory, + EnvVars: []string{"TIER_FEE_PRICE_BUMP"}, } MaxTierFeePriceBumps = &cli.Uint64Flag{ Name: "tierFee.maxPriceBumps", Usage: "If nobody accepts block at initial tier fee, how many iterations to increase tier fee before giving up", Category: proposerCategory, Value: 3, + EnvVars: []string{"MAX_TIER_FEE_PRICE_BUMPS"}, } // Proposing epoch related. ProposeInterval = &cli.DurationFlag{ @@ -65,24 +73,28 @@ var ( Usage: "Time interval to propose L2 pending transactions", Category: proposerCategory, Value: 0, + EnvVars: []string{"PROPOSE_INTERVAL"}, } MinGasUsed = &cli.Uint64Flag{ Name: "epoch.minGasUsed", Usage: "Minimum gas used for a transactions list to propose", Category: proposerCategory, Value: 0, + EnvVars: []string{"MIN_GAS_USED"}, } MinTxListBytes = &cli.Uint64Flag{ Name: "epoch.minTxListBytes", Usage: "Minimum bytes for a transactions list to propose", Category: proposerCategory, Value: 0, + EnvVars: []string{"MIN_TX_LIST_BYTES"}, } MinProposingInternal = &cli.DurationFlag{ Name: "epoch.minProposingInterval", Usage: "Minimum time interval to force proposing a block, even if there are no transaction in mempool", Category: proposerCategory, Value: 0, + EnvVars: []string{"MIN_PROPOSING_INTERNAL"}, } // Proposing metadata related. ExtraData = &cli.StringFlag{ @@ -90,42 +102,49 @@ var ( Usage: "Block extra data set by the proposer (default = client version)", Value: version.CommitVersion(), Category: proposerCategory, + EnvVars: []string{"EXTRA_DATA"}, } // Transactions pool related. TxPoolLocals = &cli.StringSliceFlag{ Name: "txpool.locals", Usage: "Comma separated accounts to treat as locals (priority inclusion)", Category: proposerCategory, + EnvVars: []string{"TX_POOL_LOCALS"}, } TxPoolLocalsOnly = &cli.BoolFlag{ Name: "txpool.localsOnly", Usage: "If set to true, proposer will only propose transactions of local accounts", Value: false, Category: proposerCategory, + EnvVars: []string{"TX_POOL_LOCALS_ONLY"}, } MaxProposedTxListsPerEpoch = &cli.Uint64Flag{ Name: "txpool.maxTxListsPerEpoch", Usage: "Maximum number of transaction lists which will be proposed inside one proposing epoch", Value: 1, Category: proposerCategory, + EnvVars: []string{"MAX_PROPOSED_TX_LISTS_PER_EPOCH"}, } ProposeBlockIncludeParentMetaHash = &cli.BoolFlag{ Name: "includeParentMetaHash", Usage: "Include parent meta hash when proposing block", Value: false, Category: proposerCategory, + EnvVars: []string{"PROPOSE_BLOCK_INCLUDE_PARENT_METAHASH"}, } // Transaction related. BlobAllowed = &cli.BoolFlag{ - Name: "l1.blobAllowed", - Usage: "Send EIP-4844 blob transactions when proposing blocks", - Value: false, + Name: "l1.blobAllowed", + Usage: "Send EIP-4844 blob transactions when proposing blocks", + Value: false, + EnvVars: []string{"BLOB_ALLOWED"}, } L1BlockBuilderTip = &cli.Uint64Flag{ Name: "l1.blockBuilderTip", Usage: "Amount you wish to tip the L1 block builder", Value: 0, Category: proposerCategory, + EnvVars: []string{"L1_BLOCK_BUILDER_TIP"}, } ) diff --git a/cmd/flags/prover.go b/cmd/flags/prover.go index 1740db935..f934493f3 100644 --- a/cmd/flags/prover.go +++ b/cmd/flags/prover.go @@ -13,18 +13,21 @@ var ( Usage: "Private key of L1 prover, who will send TaikoL1.proveBlock transactions", Required: true, Category: proverCategory, + EnvVars: []string{"L1_PROVER_PRIV_KEY"}, } ProverCapacity = &cli.Uint64Flag{ Name: "prover.capacity", Usage: "Capacity of prover", Required: true, Category: proverCategory, + EnvVars: []string{"PROVER_CAPACITY"}, } ProverAssignmentHookAddress = &cli.StringFlag{ Name: "assignmentHook", Usage: "Address of the AssignmentHook contract", Required: true, Category: proverCategory, + EnvVars: []string{"PROVER_ASSIGNMENT_HOOK_ADDRESS"}, } ) @@ -34,32 +37,38 @@ var ( Name: "raiko.hostEndpoint", Usage: "RPC endpoint of a Raiko host service", Category: proverCategory, + EnvVars: []string{"RAIKO_HOST_ENDPOINT"}, } RaikoL1Endpoint = &cli.StringFlag{ Name: "raiko.l1Endpoint", Usage: "L1 RPC endpoint which will be sent to the Raiko service", Category: proverCategory, + EnvVars: []string{"RAIKO_L1_ENDPOINT"}, } RaikoL1BeaconEndpoint = &cli.StringFlag{ Name: "raiko.l1BeaconEndpoint", Usage: "L1 beacon RPC endpoint which will be sent to the Raiko service", Category: proverCategory, + EnvVars: []string{"RAIKO_L1_BEACON_ENDPOINT"}, } RaikoL2Endpoint = &cli.StringFlag{ Name: "raiko.l2Endpoint", Usage: "L2 RPC endpoint which will be sent to the Raiko service", Category: proverCategory, + EnvVars: []string{"RAIKO_L2_ENDPOINT"}, } StartingBlockID = &cli.Uint64Flag{ Name: "prover.startingBlockID", Usage: "If set, prover will start proving blocks from the block with this ID", Category: proverCategory, + EnvVars: []string{"STARTING_BLOCK_ID"}, } Graffiti = &cli.StringFlag{ Name: "prover.graffiti", Usage: "When string is passed, adds additional graffiti info to proof evidence", Category: proverCategory, Value: "", + EnvVars: []string{"GRAFFITI"}, } // Proving strategy. ProveUnassignedBlocks = &cli.BoolFlag{ @@ -67,46 +76,54 @@ var ( Usage: "Whether you want to prove unassigned blocks, or only work on assigned proofs", Category: proverCategory, Value: false, + EnvVars: []string{"PROVE_UNASSIGNED_BLOCKS"}, } - MinEthBalance = &cli.Uint64Flag{ + MinEthBalance = &cli.Float64Flag{ Name: "prover.minEthBalance", - Usage: "Minimum ETH balance (in wei) a prover wants to keep", + Usage: "Minimum ETH balance (in Ether) a prover wants to keep", Category: proverCategory, Value: 0, + EnvVars: []string{"MIN_ETH_BALANCE"}, } - MinTaikoTokenBalance = &cli.Uint64Flag{ + MinTaikoTokenBalance = &cli.Float64Flag{ Name: "prover.minTaikoTokenBalance", - Usage: "Minimum Taiko token balance a prover wants to keep", + Usage: "Minimum Taiko token balance (in Ether) a prover wants to keep", Category: proverCategory, Value: 0, + EnvVars: []string{"MIN_TAIKO_TOKEN_BALANCE"}, } // Tier fee related. MinOptimisticTierFee = &cli.Uint64Flag{ Name: "minTierFee.optimistic", Usage: "Minimum accepted fee for generating an optimistic proof", Category: proverCategory, + EnvVars: []string{"MIN_OPTIMISTIC_TIER_FEE"}, } MinSgxTierFee = &cli.Uint64Flag{ Name: "minTierFee.sgx", Usage: "Minimum accepted fee for generating a SGX proof", Category: proverCategory, + EnvVars: []string{"MIN_SGX_TIER_FEE"}, } MinSgxAndZkVMTierFee = &cli.Uint64Flag{ Name: "minTierFee.sgxAndZkvm", Usage: "Minimum accepted fee for generating a SGX + zkVM proof", Category: proverCategory, + EnvVars: []string{"MIN_SGX_AND_ZKVM_TIER_FEE"}, } // Guardian prover related. GuardianProver = &cli.StringFlag{ Name: "guardianProver", Usage: "GuardianProver contract `address`", Category: proverCategory, + EnvVars: []string{"GUARDIAN_PROVER"}, } GuardianProofSubmissionDelay = &cli.DurationFlag{ Name: "guardian.submissionDelay", Usage: "Guardian proof submission delay", Value: 0 * time.Second, Category: proverCategory, + EnvVars: []string{"GUARDIAN_PROOF_SUBMISSION_DELAY"}, } // Running mode ContesterMode = &cli.BoolFlag{ @@ -114,6 +131,7 @@ var ( Usage: "Whether you want to contest wrong transitions with higher tier proofs", Category: proverCategory, Value: false, + EnvVars: []string{"CONTESTER_MODE"}, } // HTTP server related. ProverHTTPServerPort = &cli.Uint64Flag{ @@ -121,12 +139,14 @@ var ( Usage: "Port to expose for http server", Category: proverCategory, Value: 9876, + EnvVars: []string{"PROVER_HTTP_SERVER_PORT"}, } MaxExpiry = &cli.DurationFlag{ Name: "http.maxExpiry", Usage: "Maximum accepted expiry in seconds for accepting proving a block", Value: 1 * time.Hour, Category: proverCategory, + EnvVars: []string{"MAX_EXPIRY"}, } // Special flags for testing. Dummy = &cli.BoolFlag{ @@ -134,6 +154,7 @@ var ( Usage: "Produce dummy proofs, testing purposes only", Value: false, Category: proverCategory, + EnvVars: []string{"DUMMY"}, } // Max slippage allowed MaxAcceptableBlockSlippage = &cli.Uint64Flag{ @@ -141,6 +162,7 @@ var ( Usage: "Maximum accepted slippage difference for blockID for accepting proving a block", Value: 1024, Category: proverCategory, + EnvVars: []string{"MAX_ACCEPTABLE_BLOCK_SLIPPAGE"}, } // Max amount of L1 blocks that can pass before block is invalid MaxProposedIn = &cli.Uint64Flag{ @@ -148,16 +170,19 @@ var ( Usage: "Maximum amount of L1 blocks that can pass before block can not be proposed. 0 means no limit.", Value: 0, Category: proverCategory, + EnvVars: []string{"MAX_PROPOSED_IN"}, } - Allowance = &cli.StringFlag{ + Allowance = &cli.Float64Flag{ Name: "prover.allowance", - Usage: "Amount to approve AssignmentHook contract for TaikoToken usage", + Usage: "Amount (in Ether) to approve AssignmentHook contract for TaikoToken usage", Category: proverCategory, + EnvVars: []string{"ALLOWANCE"}, } GuardianProverHealthCheckServerEndpoint = &cli.StringFlag{ Name: "prover.guardianProverHealthCheckServerEndpoint", Usage: "HTTP endpoint for main guardian prover health check server", Category: proverCategory, + EnvVars: []string{"GUARDIAN_PROVER_HEALTH_CHECK_SERVER_ENDPOINT"}, } // Guardian prover specific flag EnableLivenessBondProof = &cli.BoolFlag{ @@ -165,16 +190,19 @@ var ( Usage: "Toggles whether the proof is a dummy proof or returns keccak256(RETURN_LIVENESS_BOND) as proof", Value: false, Category: proverCategory, + EnvVars: []string{"ENABLE_LIVENESS_BOND_PROOF"}, } L1NodeVersion = &cli.StringFlag{ Name: "prover.l1NodeVersion", Usage: "Version or tag or the L1 Node Version used as an L1 RPC Url by this guardian prover", Category: proverCategory, + EnvVars: []string{"L1_NODE_VERSION"}, } L2NodeVersion = &cli.StringFlag{ Name: "prover.l2NodeVersion", Usage: "Version or tag or the L2 Node Version used as an L2 RPC Url by this guardian prover", Category: proverCategory, + EnvVars: []string{"L2_NODE_VERSION"}, } // Confirmations specific flag BlockConfirmations = &cli.Uint64Flag{ @@ -182,6 +210,7 @@ var ( Usage: "Confirmations to the latest L1 block before submitting a proof for a L2 block", Value: 6, Category: proverCategory, + EnvVars: []string{"BLOCK_CONFIRMATIONS"}, } ) diff --git a/cmd/flags/txmgr.go b/cmd/flags/txmgr.go index 852b80a8b..cf8812f14 100644 --- a/cmd/flags/txmgr.go +++ b/cmd/flags/txmgr.go @@ -12,6 +12,7 @@ var ( Usage: "Number of confirmations which we will wait after sending a transaction", Value: 0, Category: txmgrCategory, + EnvVars: []string{"NUM_CONFIRMATIONS"}, } SafeAbortNonceTooLowCount = &cli.Uint64Flag{ Name: "tx.safeAbortNonceTooLowCount", @@ -19,12 +20,14 @@ var ( "a tx at a particular nonce without receiving confirmation", Value: 3, Category: txmgrCategory, + EnvVars: []string{"SAFE_ABORT_NONCE_TOO_LOW_COUNT"}, } FeeLimitMultiplier = &cli.Uint64Flag{ Name: "tx.feeLimitMultiplier", Usage: "The multiplier applied to fee suggestions to put a hard limit on fee increases", Value: 10, Category: txmgrCategory, + EnvVars: []string{"FEE_LIMIT_MULTIPLIER"}, } FeeLimitThreshold = &cli.Float64Flag{ Name: "tx.feeLimitThreshold", @@ -32,48 +35,56 @@ var ( "Allows arbitrary fee bumps below this threshold.", Value: 100.0, Category: txmgrCategory, + EnvVars: []string{"FEE_LIMIT_THRESHOLD"}, } MinTipCap = &cli.Float64Flag{ Name: "tx.minTipCap", Usage: "Enforces a minimum tip cap (in GWei) to use when determining tx fees. 1 GWei by default.", Value: 1.0, Category: txmgrCategory, + EnvVars: []string{"MIN_TIP_CAP"}, } MinBaseFee = &cli.Float64Flag{ Name: "tx.minBaseFee", Usage: "Enforces a minimum base fee (in GWei) to assume when determining tx fees. 1 GWei by default.", Value: 1.0, Category: txmgrCategory, + EnvVars: []string{"MIN_BASE_FEE"}, } ResubmissionTimeout = &cli.DurationFlag{ Name: "tx.resubmissionTimeout", Usage: "Duration we will wait before resubmitting a transaction to L1", Value: 48 * time.Second, Category: txmgrCategory, + EnvVars: []string{"RESUBMISSION_TIMEOUT"}, } TxSendTimeout = &cli.DurationFlag{ Name: "tx.sendTimeout", Usage: "Timeout for sending transactions. If 0 it is disabled.", Value: 0, Category: txmgrCategory, + EnvVars: []string{"TX_SEND_TIMEOUT"}, } TxNotInMempoolTimeout = &cli.DurationFlag{ Name: "tx.notInMempoolTimeout", Usage: "Timeout for aborting a tx send if the tx does not make it to the mempool.", Value: 2 * time.Minute, Category: txmgrCategory, + EnvVars: []string{"TX_NOT_IN_MEMPOOL_TIMEOUT"}, } ReceiptQueryInterval = &cli.DurationFlag{ Name: "tx.receiptQueryInterval", Usage: "Frequency to poll for receipts", Value: 12 * time.Second, Category: txmgrCategory, + EnvVars: []string{"RECEIPT_QUERY_INTERVAL"}, } TxGasLimit = &cli.Uint64Flag{ Name: "tx.gasLimit", Usage: "Gas limit will be used for transactions (0 means using gas estimation)", Value: 0, Category: txmgrCategory, + EnvVars: []string{"TX_GAS_LIMIT"}, } ) diff --git a/driver/chain_syncer/calldata/syncer_test.go b/driver/chain_syncer/calldata/syncer_test.go index c06cce432..1f4df96ac 100644 --- a/driver/chain_syncer/calldata/syncer_test.go +++ b/driver/chain_syncer/calldata/syncer_test.go @@ -198,7 +198,7 @@ func (s *CalldataSyncerTestSuite) initProposer() { s.Nil(prop.InitFromConfig(context.Background(), &proposer.Config{ ClientConfig: &rpc.ClientConfig{ - L1Endpoint: os.Getenv("L1_NODE_WS_ENDPOINT"), + L1Endpoint: os.Getenv("L1_WS_ENDPOINT"), L2Endpoint: os.Getenv("L2_EXECUTION_ENGINE_WS_ENDPOINT"), L2EngineEndpoint: os.Getenv("L2_EXECUTION_ENGINE_AUTH_ENDPOINT"), JwtSecret: string(jwtSecret), @@ -218,7 +218,7 @@ func (s *CalldataSyncerTestSuite) initProposer() { TierFeePriceBump: common.Big2, L1BlockBuilderTip: common.Big0, TxmgrConfigs: &txmgr.CLIConfig{ - L1RPCURL: os.Getenv("L1_NODE_WS_ENDPOINT"), + L1RPCURL: os.Getenv("L1_WS_ENDPOINT"), NumConfirmations: 0, SafeAbortNonceTooLowCount: txmgr.DefaultBatcherFlagValues.SafeAbortNonceTooLowCount, PrivateKey: common.Bytes2Hex(crypto.FromECDSA(l1ProposerPrivKey)), diff --git a/driver/chain_syncer/chain_syncer_test.go b/driver/chain_syncer/chain_syncer_test.go index 975e2dd41..f053d432f 100644 --- a/driver/chain_syncer/chain_syncer_test.go +++ b/driver/chain_syncer/chain_syncer_test.go @@ -52,7 +52,7 @@ func (s *ChainSyncerTestSuite) SetupTest() { s.Nil(prop.InitFromConfig(context.Background(), &proposer.Config{ ClientConfig: &rpc.ClientConfig{ - L1Endpoint: os.Getenv("L1_NODE_WS_ENDPOINT"), + L1Endpoint: os.Getenv("L1_WS_ENDPOINT"), L2Endpoint: os.Getenv("L2_EXECUTION_ENGINE_WS_ENDPOINT"), TaikoL1Address: common.HexToAddress(os.Getenv("TAIKO_L1_ADDRESS")), TaikoL2Address: common.HexToAddress(os.Getenv("TAIKO_L2_ADDRESS")), @@ -71,7 +71,7 @@ func (s *ChainSyncerTestSuite) SetupTest() { ExtraData: "test", L1BlockBuilderTip: common.Big0, TxmgrConfigs: &txmgr.CLIConfig{ - L1RPCURL: os.Getenv("L1_NODE_WS_ENDPOINT"), + L1RPCURL: os.Getenv("L1_WS_ENDPOINT"), NumConfirmations: 0, SafeAbortNonceTooLowCount: txmgr.DefaultBatcherFlagValues.SafeAbortNonceTooLowCount, PrivateKey: common.Bytes2Hex(crypto.FromECDSA(l1ProposerPrivKey)), diff --git a/driver/config.go b/driver/config.go index 852578f3a..21d1382db 100644 --- a/driver/config.go +++ b/driver/config.go @@ -19,7 +19,6 @@ type Config struct { *rpc.ClientConfig P2PSyncVerifiedBlocks bool P2PSyncTimeout time.Duration - RPCTimeout time.Duration RetryInterval time.Duration MaxExponent uint64 BlobServerEndpoint *url.URL @@ -71,7 +70,6 @@ func NewConfigFromCliContext(c *cli.Context) (*Config, error) { RetryInterval: c.Duration(flags.BackOffRetryInterval.Name), P2PSyncVerifiedBlocks: p2pSyncVerifiedBlocks, P2PSyncTimeout: c.Duration(flags.P2PSyncTimeout.Name), - RPCTimeout: timeout, MaxExponent: c.Uint64(flags.MaxExponent.Name), BlobServerEndpoint: blobServerEndpoint, }, nil diff --git a/driver/config_test.go b/driver/config_test.go index 2d528cb72..48c7743dd 100644 --- a/driver/config_test.go +++ b/driver/config_test.go @@ -11,14 +11,13 @@ import ( ) var ( - l1Endpoint = os.Getenv("L1_NODE_WS_ENDPOINT") + l1Endpoint = os.Getenv("L1_WS_ENDPOINT") l1BeaconEndpoint = os.Getenv("L1_NODE_HTTP_ENDPOINT") l2Endpoint = os.Getenv("L2_EXECUTION_ENGINE_WS_ENDPOINT") l2CheckPoint = os.Getenv("L2_EXECUTION_ENGINE_HTTP_ENDPOINT") l2EngineEndpoint = os.Getenv("L2_EXECUTION_ENGINE_AUTH_ENDPOINT") taikoL1 = os.Getenv("TAIKO_L1_ADDRESS") taikoL2 = os.Getenv("TAIKO_L2_ADDRESS") - rpcTimeout = 5 * time.Second ) func (s *DriverTestSuite) TestNewConfigFromCliContext() { @@ -34,7 +33,6 @@ func (s *DriverTestSuite) TestNewConfigFromCliContext() { s.Equal(taikoL1, c.TaikoL1Address.String()) s.Equal(taikoL2, c.TaikoL2Address.String()) s.Equal(120*time.Second, c.P2PSyncTimeout) - s.Equal(rpcTimeout, c.RPCTimeout) s.NotEmpty(c.JwtSecret) s.True(c.P2PSyncVerifiedBlocks) s.Equal(l2CheckPoint, c.L2CheckPoint) diff --git a/driver/driver_test.go b/driver/driver_test.go index c6bdc67a9..0a80dd6f6 100644 --- a/driver/driver_test.go +++ b/driver/driver_test.go @@ -38,7 +38,7 @@ func (s *DriverTestSuite) SetupTest() { ctx, cancel := context.WithCancel(context.Background()) s.Nil(d.InitFromConfig(ctx, &Config{ ClientConfig: &rpc.ClientConfig{ - L1Endpoint: os.Getenv("L1_NODE_WS_ENDPOINT"), + L1Endpoint: os.Getenv("L1_WS_ENDPOINT"), L2Endpoint: os.Getenv("L2_EXECUTION_ENGINE_WS_ENDPOINT"), L2EngineEndpoint: os.Getenv("L2_EXECUTION_ENGINE_AUTH_ENDPOINT"), TaikoL1Address: common.HexToAddress(os.Getenv("TAIKO_L1_ADDRESS")), @@ -297,7 +297,7 @@ func (s *DriverTestSuite) InitProposer() { s.Nil(p.InitFromConfig(context.Background(), &proposer.Config{ ClientConfig: &rpc.ClientConfig{ - L1Endpoint: os.Getenv("L1_NODE_WS_ENDPOINT"), + L1Endpoint: os.Getenv("L1_WS_ENDPOINT"), L2Endpoint: os.Getenv("L2_EXECUTION_ENGINE_WS_ENDPOINT"), L2EngineEndpoint: os.Getenv("L2_EXECUTION_ENGINE_AUTH_ENDPOINT"), JwtSecret: string(jwtSecret), @@ -317,7 +317,7 @@ func (s *DriverTestSuite) InitProposer() { TierFeePriceBump: common.Big2, L1BlockBuilderTip: common.Big0, TxmgrConfigs: &txmgr.CLIConfig{ - L1RPCURL: os.Getenv("L1_NODE_WS_ENDPOINT"), + L1RPCURL: os.Getenv("L1_WS_ENDPOINT"), NumConfirmations: 0, SafeAbortNonceTooLowCount: txmgr.DefaultBatcherFlagValues.SafeAbortNonceTooLowCount, PrivateKey: common.Bytes2Hex(crypto.FromECDSA(l1ProposerPrivKey)), diff --git a/integration_test/entrypoint.sh b/integration_test/entrypoint.sh index abc478791..681ce99bd 100755 --- a/integration_test/entrypoint.sh +++ b/integration_test/entrypoint.sh @@ -23,7 +23,7 @@ source integration_test/test_env.sh # make sure environment variables are set check_env "TAIKO_MONO_DIR" check_env "L1_NODE_HTTP_ENDPOINT" -check_env "L1_NODE_WS_ENDPOINT" +check_env "L1_WS_ENDPOINT" check_env "L2_EXECUTION_ENGINE_HTTP_ENDPOINT" check_env "L2_EXECUTION_ENGINE_WS_ENDPOINT" check_env "L2_EXECUTION_ENGINE_AUTH_ENDPOINT" diff --git a/integration_test/test_env.sh b/integration_test/test_env.sh index b106695fd..6bbe7066a 100755 --- a/integration_test/test_env.sh +++ b/integration_test/test_env.sh @@ -28,7 +28,7 @@ export VERBOSITY=3 echo "RUN_TESTS=true TAIKO_MONO_DIR=$TAIKO_MONO_DIR L1_NODE_HTTP_ENDPOINT=$L1_NODE_HTTP_ENDPOINT -L1_NODE_WS_ENDPOINT=$L1_NODE_WS_ENDPOINT +L1_WS_ENDPOINT=$L1_NODE_WS_ENDPOINT L2_SUGGESTED_FEE_RECIPIENT=$L2_SUGGESTED_FEE_RECIPIENT L2_EXECUTION_ENGINE_HTTP_ENDPOINT=$L2_EXECUTION_ENGINE_HTTP_ENDPOINT L2_EXECUTION_ENGINE_WS_ENDPOINT=$L2_EXECUTION_ENGINE_WS_ENDPOINT diff --git a/internal/docker/docker_env.sh b/internal/docker/docker_env.sh index ccaab9a03..74d4fd215 100755 --- a/internal/docker/docker_env.sh +++ b/internal/docker/docker_env.sh @@ -16,7 +16,7 @@ done L1_NODE_PORT=$(docker port l1_node | grep '0.0.0.0' | awk -F ':' '{print $2}') export L1_NODE_HTTP_ENDPOINT=http://localhost:$L1_NODE_PORT -export L1_NODE_WS_ENDPOINT=ws://localhost:$L1_NODE_PORT +export L1_WS_ENDPOINT=ws://localhost:$L1_NODE_PORT export L2_EXECUTION_ENGINE_HTTP_ENDPOINT=http://localhost:$(docker port l2_node | grep "0.0.0.0" | awk -F ':' 'NR==1 {print $2}') export L2_EXECUTION_ENGINE_WS_ENDPOINT=ws://localhost:$(docker port l2_node | grep "0.0.0.0" | awk -F ':' 'NR==2 {print $2}') @@ -27,7 +27,7 @@ echo -e "L1_NODE PORTS: \n$(docker port l1_node)" echo -e "L2_NODE PORTS: \n$(docker port l2_node)" echo "L1_NODE_HTTP_ENDPOINT: $L1_NODE_HTTP_ENDPOINT" -echo "L1_NODE_WS_ENDPOINT: $L1_NODE_WS_ENDPOINT" +echo "L1_WS_ENDPOINT: $L1_NODE_WS_ENDPOINT" echo "L2_EXECUTION_ENGINE_HTTP_ENDPOINT: $L2_EXECUTION_ENGINE_HTTP_ENDPOINT" echo "L2_EXECUTION_ENGINE_WS_ENDPOINT: $L2_EXECUTION_ENGINE_WS_ENDPOINT" echo "L2_EXECUTION_ENGINE_AUTH_ENDPOINT: $L2_EXECUTION_ENGINE_AUTH_ENDPOINT" diff --git a/internal/testutils/suite.go b/internal/testutils/suite.go index 0e5e31fff..6362ee5f9 100644 --- a/internal/testutils/suite.go +++ b/internal/testutils/suite.go @@ -56,7 +56,7 @@ func (s *ClientTestSuite) SetupTest() { s.NotEmpty(jwtSecret) rpcCli, err := rpc.NewClient(context.Background(), &rpc.ClientConfig{ - L1Endpoint: os.Getenv("L1_NODE_WS_ENDPOINT"), + L1Endpoint: os.Getenv("L1_WS_ENDPOINT"), L2Endpoint: os.Getenv("L2_EXECUTION_ENGINE_WS_ENDPOINT"), TaikoL1Address: common.HexToAddress(os.Getenv("TAIKO_L1_ADDRESS")), TaikoL2Address: common.HexToAddress(os.Getenv("TAIKO_L2_ADDRESS")), @@ -109,7 +109,7 @@ func (s *ClientTestSuite) setAllowance(key *ecdsa.PrivateKey) { log.Root(), new(metrics.NoopTxMetrics), txmgr.CLIConfig{ - L1RPCURL: os.Getenv("L1_NODE_WS_ENDPOINT"), + L1RPCURL: os.Getenv("L1_WS_ENDPOINT"), NumConfirmations: 0, SafeAbortNonceTooLowCount: txmgr.DefaultBatcherFlagValues.SafeAbortNonceTooLowCount, PrivateKey: common.Bytes2Hex(crypto.FromECDSA(key)), diff --git a/pkg/rpc/blob_tx_test.go b/pkg/rpc/blob_tx_test.go index bcfb9103c..7dfe390d4 100644 --- a/pkg/rpc/blob_tx_test.go +++ b/pkg/rpc/blob_tx_test.go @@ -25,7 +25,7 @@ func TestSendingBlobTx(t *testing.T) { ctx, cancel := context.WithCancel(context.Background()) defer cancel() - url := os.Getenv("L1_NODE_WS_ENDPOINT") + url := os.Getenv("L1_WS_ENDPOINT") l1Client, err := NewEthClient(ctx, url, time.Second*20) assert.NoError(t, err) diff --git a/pkg/rpc/client_test.go b/pkg/rpc/client_test.go index 46b625d2a..f5000ab6a 100644 --- a/pkg/rpc/client_test.go +++ b/pkg/rpc/client_test.go @@ -12,7 +12,7 @@ import ( func newTestClient(t *testing.T) *Client { client, err := NewClient(context.Background(), &ClientConfig{ - L1Endpoint: os.Getenv("L1_NODE_WS_ENDPOINT"), + L1Endpoint: os.Getenv("L1_WS_ENDPOINT"), L2Endpoint: os.Getenv("L2_EXECUTION_ENGINE_WS_ENDPOINT"), TaikoL1Address: common.HexToAddress(os.Getenv("TAIKO_L1_ADDRESS")), TaikoL2Address: common.HexToAddress(os.Getenv("TAIKO_L2_ADDRESS")), @@ -29,7 +29,7 @@ func newTestClient(t *testing.T) *Client { func newTestClientWithTimeout(t *testing.T) *Client { client, err := NewClient(context.Background(), &ClientConfig{ - L1Endpoint: os.Getenv("L1_NODE_WS_ENDPOINT"), + L1Endpoint: os.Getenv("L1_WS_ENDPOINT"), L2Endpoint: os.Getenv("L2_EXECUTION_ENGINE_WS_ENDPOINT"), TaikoL1Address: common.HexToAddress(os.Getenv("TAIKO_L1_ADDRESS")), TaikoL2Address: common.HexToAddress(os.Getenv("TAIKO_L2_ADDRESS")), diff --git a/pkg/utils/eth.go b/pkg/utils/eth.go new file mode 100644 index 000000000..3a9ed6ff9 --- /dev/null +++ b/pkg/utils/eth.go @@ -0,0 +1,51 @@ +package utils + +import ( + "errors" + "fmt" + "math" + "math/big" + + "github.com/ethereum/go-ethereum/accounts/abi" + "github.com/ethereum/go-ethereum/params" +) + +func GWeiToWei(gwei float64) (*big.Int, error) { + if math.IsNaN(gwei) || math.IsInf(gwei, 0) { + return nil, fmt.Errorf("invalid gwei value: %v", gwei) + } + + // convert float GWei value into integer Wei value + wei, _ := new(big.Float).Mul( + big.NewFloat(gwei), + big.NewFloat(params.GWei)). + Int(nil) + + if wei.Cmp(abi.MaxUint256) == 1 { + return nil, errors.New("gwei value larger than max uint256") + } + + return wei, nil +} + +func EtherToWei(ether float64) (*big.Int, error) { + if math.IsNaN(ether) || math.IsInf(ether, 0) { + return nil, fmt.Errorf("invalid ether value: %v", ether) + } + + // convert float GWei value into integer Wei value + wei, _ := new(big.Float).Mul( + big.NewFloat(ether), + big.NewFloat(params.GWei)). + Int(nil) + + if wei.Cmp(abi.MaxUint256) == 1 { + return nil, errors.New("gwei value larger than max uint256") + } + + return wei, nil +} + +func WeiToEther(wei *big.Int) *big.Float { + return new(big.Float).Quo(new(big.Float).SetInt(wei), new(big.Float).SetInt(big.NewInt(params.Ether))) +} diff --git a/proposer/config.go b/proposer/config.go index bd5215abb..32497143f 100644 --- a/proposer/config.go +++ b/proposer/config.go @@ -11,6 +11,7 @@ import ( "github.com/ethereum-optimism/optimism/op-service/txmgr" "github.com/ethereum/go-ethereum/common" "github.com/ethereum/go-ethereum/crypto" + "github.com/taikoxyz/taiko-client/pkg/utils" "github.com/urfave/cli/v2" "github.com/taikoxyz/taiko-client/cmd/flags" @@ -84,6 +85,16 @@ func NewConfigFromCliContext(c *cli.Context) (*Config, error) { proverEndpoints = append(proverEndpoints, endpoint) } + optimisticTierFee, err := utils.GWeiToWei(c.Float64(flags.OptimisticTierFee.Name)) + if err != nil { + return nil, err + } + + sgxTierFee, err := utils.GWeiToWei(c.Float64(flags.SgxTierFee.Name)) + if err != nil { + return nil, err + } + return &Config{ ClientConfig: &rpc.ClientConfig{ L1Endpoint: c.String(flags.L1WSEndpoint.Name), @@ -108,8 +119,8 @@ func NewConfigFromCliContext(c *cli.Context) (*Config, error) { MaxProposedTxListsPerEpoch: c.Uint64(flags.MaxProposedTxListsPerEpoch.Name), ProposeBlockTxGasLimit: c.Uint64(flags.TxGasLimit.Name), ProverEndpoints: proverEndpoints, - OptimisticTierFee: new(big.Int).SetUint64(c.Uint64(flags.OptimisticTierFee.Name)), - SgxTierFee: new(big.Int).SetUint64(c.Uint64(flags.SgxTierFee.Name)), + OptimisticTierFee: optimisticTierFee, + SgxTierFee: sgxTierFee, TierFeePriceBump: new(big.Int).SetUint64(c.Uint64(flags.TierFeePriceBump.Name)), MaxTierFeePriceBumps: c.Uint64(flags.MaxTierFeePriceBumps.Name), IncludeParentMetaHash: c.Bool(flags.ProposeBlockIncludeParentMetaHash.Name), diff --git a/proposer/config_test.go b/proposer/config_test.go index 5b3d83eb1..5c3f4a770 100644 --- a/proposer/config_test.go +++ b/proposer/config_test.go @@ -16,7 +16,7 @@ import ( ) var ( - l1Endpoint = os.Getenv("L1_NODE_WS_ENDPOINT") + l1Endpoint = os.Getenv("L1_WS_ENDPOINT") l2Endpoint = os.Getenv("L2_EXECUTION_ENGINE_HTTP_ENDPOINT") taikoL1 = os.Getenv("TAIKO_L1_ADDRESS") taikoL2 = os.Getenv("TAIKO_L2_ADDRESS") diff --git a/proposer/proposer_test.go b/proposer/proposer_test.go index 9c6f954dd..bae6f3e68 100644 --- a/proposer/proposer_test.go +++ b/proposer/proposer_test.go @@ -63,7 +63,7 @@ func (s *ProposerTestSuite) SetupTest() { s.Nil(p.InitFromConfig(ctx, &Config{ ClientConfig: &rpc.ClientConfig{ - L1Endpoint: os.Getenv("L1_NODE_WS_ENDPOINT"), + L1Endpoint: os.Getenv("L1_WS_ENDPOINT"), L2Endpoint: os.Getenv("L2_EXECUTION_ENGINE_HTTP_ENDPOINT"), L2EngineEndpoint: os.Getenv("L2_EXECUTION_ENGINE_AUTH_ENDPOINT"), JwtSecret: string(jwtSecret), @@ -85,7 +85,7 @@ func (s *ProposerTestSuite) SetupTest() { ExtraData: "test", L1BlockBuilderTip: common.Big0, TxmgrConfigs: &txmgr.CLIConfig{ - L1RPCURL: os.Getenv("L1_NODE_WS_ENDPOINT"), + L1RPCURL: os.Getenv("L1_WS_ENDPOINT"), NumConfirmations: 0, SafeAbortNonceTooLowCount: txmgr.DefaultBatcherFlagValues.SafeAbortNonceTooLowCount, PrivateKey: common.Bytes2Hex(crypto.FromECDSA(l1ProposerPrivKey)), diff --git a/prover/config.go b/prover/config.go index de366e1d7..d0e7ab2f9 100644 --- a/prover/config.go +++ b/prover/config.go @@ -11,6 +11,7 @@ import ( "github.com/ethereum-optimism/optimism/op-service/txmgr" "github.com/ethereum/go-ethereum/common" "github.com/ethereum/go-ethereum/crypto" + "github.com/taikoxyz/taiko-client/pkg/utils" "github.com/urfave/cli/v2" "github.com/taikoxyz/taiko-client/cmd/flags" @@ -34,7 +35,7 @@ type Config struct { GuardianProverAddress common.Address GuardianProofSubmissionDelay time.Duration Graffiti string - BackOffMaxRetrys uint64 + BackOffMaxRetries uint64 BackOffRetryInterval time.Duration ProveUnassignedBlocks bool ContesterMode bool @@ -136,6 +137,31 @@ func NewConfigFromCliContext(c *cli.Context) (*Config, error) { raikoL2Endpoint = c.String(flags.L2HTTPEndpoint.Name) } + minOptimisticTierFee, err := utils.GWeiToWei(c.Float64(flags.MinOptimisticTierFee.Name)) + if err != nil { + return nil, err + } + + minSgxTierFee, err := utils.GWeiToWei(c.Float64(flags.MinSgxTierFee.Name)) + if err != nil { + return nil, err + } + + minSgxAndZkVMTierFee, err := utils.GWeiToWei(c.Float64(flags.MinSgxAndZkVMTierFee.Name)) + if err != nil { + return nil, err + } + + minEthBalance, err := utils.EtherToWei(c.Float64(flags.MinEthBalance.Name)) + if err != nil { + return nil, err + } + + minTaikoTokenBalance, err := utils.EtherToWei(c.Float64(flags.MinTaikoTokenBalance.Name)) + if err != nil { + return nil, err + } + return &Config{ L1WsEndpoint: c.String(flags.L1WSEndpoint.Name), L1HttpEndpoint: c.String(flags.L1HTTPEndpoint.Name), @@ -157,7 +183,7 @@ func NewConfigFromCliContext(c *cli.Context) (*Config, error) { GuardianProofSubmissionDelay: c.Duration(flags.GuardianProofSubmissionDelay.Name), GuardianProverHealthCheckServerEndpoint: guardianProverHealthCheckServerEndpoint, Graffiti: c.String(flags.Graffiti.Name), - BackOffMaxRetrys: c.Uint64(flags.BackOffMaxRetrys.Name), + BackOffMaxRetries: c.Uint64(flags.BackOffMaxRetries.Name), BackOffRetryInterval: c.Duration(flags.BackOffRetryInterval.Name), ProveUnassignedBlocks: c.Bool(flags.ProveUnassignedBlocks.Name), ContesterMode: c.Bool(flags.ContesterMode.Name), @@ -166,11 +192,11 @@ func NewConfigFromCliContext(c *cli.Context) (*Config, error) { ProveBlockGasLimit: c.Uint64(flags.TxGasLimit.Name), Capacity: c.Uint64(flags.ProverCapacity.Name), 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)), - MinSgxAndZkVMTierFee: new(big.Int).SetUint64(c.Uint64(flags.MinSgxAndZkVMTierFee.Name)), - MinEthBalance: new(big.Int).SetUint64(c.Uint64(flags.MinEthBalance.Name)), - MinTaikoTokenBalance: new(big.Int).SetUint64(c.Uint64(flags.MinTaikoTokenBalance.Name)), + MinOptimisticTierFee: minOptimisticTierFee, + MinSgxTierFee: minSgxTierFee, + MinSgxAndZkVMTierFee: minSgxAndZkVMTierFee, + MinEthBalance: minEthBalance, + MinTaikoTokenBalance: minTaikoTokenBalance, MaxExpiry: c.Duration(flags.MaxExpiry.Name), MaxBlockSlippage: c.Uint64(flags.MaxAcceptableBlockSlippage.Name), MaxProposedIn: c.Uint64(flags.MaxProposedIn.Name), diff --git a/prover/config_test.go b/prover/config_test.go index a6214060d..5cea9c899 100644 --- a/prover/config_test.go +++ b/prover/config_test.go @@ -13,7 +13,7 @@ import ( ) var ( - l1WsEndpoint = os.Getenv("L1_NODE_WS_ENDPOINT") + l1WsEndpoint = os.Getenv("L1_WS_ENDPOINT") l1HttpEndpoint = os.Getenv("L1_NODE_HTTP_ENDPOINT") l1BeaconEndpoint = os.Getenv("L1_NODE_HTTP_ENDPOINT") l2WsEndpoint = os.Getenv("L2_EXECUTION_ENGINE_WS_ENDPOINT") diff --git a/prover/event_handler/transition_proved_test.go b/prover/event_handler/transition_proved_test.go index edc5c15ba..a7cd2237a 100644 --- a/prover/event_handler/transition_proved_test.go +++ b/prover/event_handler/transition_proved_test.go @@ -41,7 +41,7 @@ func (s *EventHandlerTestSuite) SetupTest() { d := new(driver.Driver) s.Nil(d.InitFromConfig(context.Background(), &driver.Config{ ClientConfig: &rpc.ClientConfig{ - L1Endpoint: os.Getenv("L1_NODE_WS_ENDPOINT"), + L1Endpoint: os.Getenv("L1_WS_ENDPOINT"), L2Endpoint: os.Getenv("L2_EXECUTION_ENGINE_WS_ENDPOINT"), L2EngineEndpoint: os.Getenv("L2_EXECUTION_ENGINE_AUTH_ENDPOINT"), TaikoL1Address: common.HexToAddress(os.Getenv("TAIKO_L1_ADDRESS")), @@ -75,7 +75,7 @@ func (s *EventHandlerTestSuite) SetupTest() { s.Nil(prop.InitFromConfig(context.Background(), &proposer.Config{ ClientConfig: &rpc.ClientConfig{ - L1Endpoint: os.Getenv("L1_NODE_WS_ENDPOINT"), + L1Endpoint: os.Getenv("L1_WS_ENDPOINT"), L2Endpoint: os.Getenv("L2_EXECUTION_ENGINE_WS_ENDPOINT"), L2EngineEndpoint: os.Getenv("L2_EXECUTION_ENGINE_AUTH_ENDPOINT"), JwtSecret: string(jwtSecret), @@ -95,7 +95,7 @@ func (s *EventHandlerTestSuite) SetupTest() { TierFeePriceBump: common.Big2, L1BlockBuilderTip: common.Big0, TxmgrConfigs: &txmgr.CLIConfig{ - L1RPCURL: os.Getenv("L1_NODE_WS_ENDPOINT"), + L1RPCURL: os.Getenv("L1_WS_ENDPOINT"), NumConfirmations: 1, SafeAbortNonceTooLowCount: txmgr.DefaultBatcherFlagValues.SafeAbortNonceTooLowCount, PrivateKey: common.Bytes2Hex(crypto.FromECDSA(l1ProposerPrivKey)), diff --git a/prover/init.go b/prover/init.go index 389d0dc92..445924c55 100644 --- a/prover/init.go +++ b/prover/init.go @@ -204,7 +204,7 @@ func (p *Prover) initEventHandlers() { ProofSubmissionCh: p.proofSubmissionCh, ProofContestCh: p.proofContestCh, BackOffRetryInterval: p.cfg.BackOffRetryInterval, - BackOffMaxRetrys: p.cfg.BackOffMaxRetrys, + BackOffMaxRetrys: p.cfg.BackOffMaxRetries, ContesterMode: p.cfg.ContesterMode, ProveUnassignedBlocks: p.cfg.ProveUnassignedBlocks, } diff --git a/prover/proof_submitter/proof_submitter_test.go b/prover/proof_submitter/proof_submitter_test.go index 1a24c76c3..c486d5b98 100644 --- a/prover/proof_submitter/proof_submitter_test.go +++ b/prover/proof_submitter/proof_submitter_test.go @@ -55,7 +55,7 @@ func (s *ProofSubmitterTestSuite) SetupTest() { log.Root(), new(metrics.NoopTxMetrics), txmgr.CLIConfig{ - L1RPCURL: os.Getenv("L1_NODE_WS_ENDPOINT"), + L1RPCURL: os.Getenv("L1_WS_ENDPOINT"), NumConfirmations: 0, SafeAbortNonceTooLowCount: txmgr.DefaultBatcherFlagValues.SafeAbortNonceTooLowCount, PrivateKey: common.Bytes2Hex(crypto.FromECDSA(l1ProverPrivKey)), @@ -115,7 +115,7 @@ func (s *ProofSubmitterTestSuite) SetupTest() { s.Nil(prop.InitFromConfig(context.Background(), &proposer.Config{ ClientConfig: &rpc.ClientConfig{ - L1Endpoint: os.Getenv("L1_NODE_WS_ENDPOINT"), + L1Endpoint: os.Getenv("L1_WS_ENDPOINT"), L2Endpoint: os.Getenv("L2_EXECUTION_ENGINE_WS_ENDPOINT"), TaikoL1Address: common.HexToAddress(os.Getenv("TAIKO_L1_ADDRESS")), TaikoL2Address: common.HexToAddress(os.Getenv("TAIKO_L2_ADDRESS")), @@ -133,7 +133,7 @@ func (s *ProofSubmitterTestSuite) SetupTest() { TierFeePriceBump: common.Big2, L1BlockBuilderTip: common.Big0, TxmgrConfigs: &txmgr.CLIConfig{ - L1RPCURL: os.Getenv("L1_NODE_WS_ENDPOINT"), + L1RPCURL: os.Getenv("L1_WS_ENDPOINT"), NumConfirmations: 0, SafeAbortNonceTooLowCount: txmgr.DefaultBatcherFlagValues.SafeAbortNonceTooLowCount, PrivateKey: common.Bytes2Hex(crypto.FromECDSA(l1ProposerPrivKey)), diff --git a/prover/proof_submitter/transaction/sender_test.go b/prover/proof_submitter/transaction/sender_test.go index ac7d9fcad..77e0eeb05 100644 --- a/prover/proof_submitter/transaction/sender_test.go +++ b/prover/proof_submitter/transaction/sender_test.go @@ -50,7 +50,7 @@ func (s *TransactionTestSuite) SetupTest() { log.Root(), new(metrics.NoopTxMetrics), txmgr.CLIConfig{ - L1RPCURL: os.Getenv("L1_NODE_WS_ENDPOINT"), + L1RPCURL: os.Getenv("L1_WS_ENDPOINT"), NumConfirmations: 0, SafeAbortNonceTooLowCount: txmgr.DefaultBatcherFlagValues.SafeAbortNonceTooLowCount, PrivateKey: common.Bytes2Hex(crypto.FromECDSA(l1ProverPrivKey)), diff --git a/prover/prover.go b/prover/prover.go index f037f2b2d..225606c84 100644 --- a/prover/prover.go +++ b/prover/prover.go @@ -98,7 +98,7 @@ func InitFromConfig(ctx context.Context, p *Prover, cfg *Config) (err error) { p.backoff = backoff.WithContext( backoff.WithMaxRetries( backoff.NewConstantBackOff(p.cfg.BackOffRetryInterval), - p.cfg.BackOffMaxRetrys, + p.cfg.BackOffMaxRetries, ), p.ctx, ) diff --git a/prover/prover_test.go b/prover/prover_test.go index 8caf93479..f41a848e5 100644 --- a/prover/prover_test.go +++ b/prover/prover_test.go @@ -56,7 +56,7 @@ func (s *ProverTestSuite) SetupTest() { d := new(driver.Driver) s.Nil(d.InitFromConfig(context.Background(), &driver.Config{ ClientConfig: &rpc.ClientConfig{ - L1Endpoint: os.Getenv("L1_NODE_WS_ENDPOINT"), + L1Endpoint: os.Getenv("L1_WS_ENDPOINT"), L2Endpoint: os.Getenv("L2_EXECUTION_ENGINE_WS_ENDPOINT"), L2EngineEndpoint: os.Getenv("L2_EXECUTION_ENGINE_AUTH_ENDPOINT"), TaikoL1Address: common.HexToAddress(os.Getenv("TAIKO_L1_ADDRESS")), @@ -74,7 +74,7 @@ func (s *ProverTestSuite) SetupTest() { s.Nil(prop.InitFromConfig(context.Background(), &proposer.Config{ ClientConfig: &rpc.ClientConfig{ - L1Endpoint: os.Getenv("L1_NODE_WS_ENDPOINT"), + L1Endpoint: os.Getenv("L1_WS_ENDPOINT"), L2Endpoint: os.Getenv("L2_EXECUTION_ENGINE_WS_ENDPOINT"), L2EngineEndpoint: os.Getenv("L2_EXECUTION_ENGINE_AUTH_ENDPOINT"), JwtSecret: string(jwtSecret), @@ -94,7 +94,7 @@ func (s *ProverTestSuite) SetupTest() { TierFeePriceBump: common.Big2, L1BlockBuilderTip: common.Big0, TxmgrConfigs: &txmgr.CLIConfig{ - L1RPCURL: os.Getenv("L1_NODE_WS_ENDPOINT"), + L1RPCURL: os.Getenv("L1_WS_ENDPOINT"), NumConfirmations: 0, SafeAbortNonceTooLowCount: txmgr.DefaultBatcherFlagValues.SafeAbortNonceTooLowCount, PrivateKey: common.Bytes2Hex(crypto.FromECDSA(l1ProposerPrivKey)), @@ -126,7 +126,7 @@ func (s *ProverTestSuite) TestInitError() { p := new(Prover) s.NotNil(InitFromConfig(ctx, p, &Config{ - L1WsEndpoint: os.Getenv("L1_NODE_WS_ENDPOINT"), + L1WsEndpoint: os.Getenv("L1_WS_ENDPOINT"), L1HttpEndpoint: os.Getenv("L1_NODE_HTTP_ENDPOINT"), L2WsEndpoint: os.Getenv("L2_EXECUTION_ENGINE_WS_ENDPOINT"), L2HttpEndpoint: os.Getenv("L2_EXECUTION_ENGINE_HTTP_ENDPOINT"), @@ -139,9 +139,9 @@ func (s *ProverTestSuite) TestInitError() { ProveUnassignedBlocks: true, RPCTimeout: 10 * time.Minute, BackOffRetryInterval: 3 * time.Second, - BackOffMaxRetrys: 12, + BackOffMaxRetries: 12, TxmgrConfigs: &txmgr.CLIConfig{ - L1RPCURL: os.Getenv("L1_NODE_WS_ENDPOINT"), + L1RPCURL: os.Getenv("L1_WS_ENDPOINT"), NumConfirmations: 0, SafeAbortNonceTooLowCount: txmgr.DefaultBatcherFlagValues.SafeAbortNonceTooLowCount, PrivateKey: common.Bytes2Hex(crypto.FromECDSA(l1ProverPrivKey)), @@ -493,7 +493,7 @@ func (s *ProverTestSuite) initProver( p := new(Prover) s.Nil(InitFromConfig(ctx, p, &Config{ - L1WsEndpoint: os.Getenv("L1_NODE_WS_ENDPOINT"), + L1WsEndpoint: os.Getenv("L1_WS_ENDPOINT"), L1HttpEndpoint: os.Getenv("L1_NODE_HTTP_ENDPOINT"), L2WsEndpoint: os.Getenv("L2_EXECUTION_ENGINE_WS_ENDPOINT"), L2HttpEndpoint: os.Getenv("L2_EXECUTION_ENGINE_HTTP_ENDPOINT"), @@ -511,11 +511,11 @@ func (s *ProverTestSuite) initProver( Allowance: new(big.Int).Exp(big.NewInt(1_000_000_100), new(big.Int).SetUint64(uint64(decimal)), nil), RPCTimeout: 3 * time.Second, BackOffRetryInterval: 3 * time.Second, - BackOffMaxRetrys: 12, + BackOffMaxRetries: 12, L1NodeVersion: "1.0.0", L2NodeVersion: "0.1.0", TxmgrConfigs: &txmgr.CLIConfig{ - L1RPCURL: os.Getenv("L1_NODE_WS_ENDPOINT"), + L1RPCURL: os.Getenv("L1_WS_ENDPOINT"), NumConfirmations: 0, SafeAbortNonceTooLowCount: txmgr.DefaultBatcherFlagValues.SafeAbortNonceTooLowCount, PrivateKey: common.Bytes2Hex(crypto.FromECDSA(key)), diff --git a/prover/server/api.go b/prover/server/api.go index 2f1b8b4ea..a7b9a272c 100644 --- a/prover/server/api.go +++ b/prover/server/api.go @@ -11,6 +11,7 @@ import ( "github.com/ethereum/go-ethereum/crypto" "github.com/ethereum/go-ethereum/log" "github.com/labstack/echo/v4" + "github.com/taikoxyz/taiko-client/pkg/utils" "github.com/taikoxyz/taiko-client/bindings/encoding" "github.com/taikoxyz/taiko-client/pkg/rpc" @@ -244,7 +245,7 @@ func (s *ProverServer) checkMinEthAndToken(ctx context.Context) (bool, error) { log.Info( "Prover's ETH balance", - "balance", ethBalance, + "balance", utils.WeiToEther(ethBalance), "address", s.proverAddress.Hex(), ) @@ -252,8 +253,8 @@ func (s *ProverServer) checkMinEthAndToken(ctx context.Context) (bool, error) { log.Warn( "Prover does not have required minimum on-chain ETH balance", "providedProver", s.proverAddress.Hex(), - "ethBalance", ethBalance, - "minEthBalance", s.minEthBalance, + "ethBalance", utils.WeiToEther(ethBalance), + "minEthBalance", utils.WeiToEther(s.minEthBalance), ) return false, nil } @@ -266,7 +267,7 @@ func (s *ProverServer) checkMinEthAndToken(ctx context.Context) (bool, error) { log.Info( "Prover's Taiko token balance", - "balance", balance.String(), + "balance", utils.WeiToEther(balance), "address", s.proverAddress.Hex(), ) @@ -274,8 +275,8 @@ func (s *ProverServer) checkMinEthAndToken(ctx context.Context) (bool, error) { log.Warn( "Prover does not have required on-chain Taiko token balance", "providedProver", s.proverAddress.Hex(), - "taikoTokenBalance", balance, - "minTaikoTokenBalance", s.minTaikoTokenBalance, + "taikoTokenBalance", utils.WeiToEther(balance), + "minTaikoTokenBalance", utils.WeiToEther(s.minTaikoTokenBalance), ) return false, nil } diff --git a/prover/server/server.go b/prover/server/server.go index 5114633c8..636ace89d 100644 --- a/prover/server/server.go +++ b/prover/server/server.go @@ -12,7 +12,6 @@ import ( "github.com/ethereum/go-ethereum/crypto" "github.com/labstack/echo/v4" "github.com/labstack/echo/v4/middleware" - "github.com/taikoxyz/taiko-client/bindings" "github.com/taikoxyz/taiko-client/pkg/rpc" proofProducer "github.com/taikoxyz/taiko-client/prover/proof_producer" diff --git a/prover/server/server_test.go b/prover/server/server_test.go index c1910136a..ae154e348 100644 --- a/prover/server/server_test.go +++ b/prover/server/server_test.go @@ -32,7 +32,7 @@ func (s *ProverServerTestSuite) SetupTest() { s.Nil(err) rpcClient, err := rpc.NewClient(context.Background(), &rpc.ClientConfig{ - L1Endpoint: os.Getenv("L1_NODE_WS_ENDPOINT"), + L1Endpoint: os.Getenv("L1_WS_ENDPOINT"), L2Endpoint: os.Getenv("L2_EXECUTION_ENGINE_WS_ENDPOINT"), TaikoL1Address: common.HexToAddress(os.Getenv("TAIKO_L1_ADDRESS")), TaikoL2Address: common.HexToAddress(os.Getenv("TAIKO_L2_ADDRESS")),