Skip to content

Commit 4cafb9d

Browse files
committed
format
1 parent 49734ed commit 4cafb9d

3 files changed

Lines changed: 12 additions & 5 deletions

File tree

internal/api/dispute_game_handler.go

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@ package api
33
import (
44
"context"
55
"fmt"
6+
"math"
67
"math/big"
78
"net/http"
89

@@ -294,12 +295,14 @@ func (h DisputeGameHandler) GetClaimRoot(c *gin.Context) {
294295
}
295296

296297
func (h DisputeGameHandler) getClaimRoot(blockNumber int64) (string, error) {
297-
// 使用 RollupClient 替代 eth_getProof
298+
if blockNumber < 0 {
299+
return "", fmt.Errorf("block number cannot be negative: %d", blockNumber)
300+
}
301+
298302
output, err := h.RollupClient.OutputAtBlock(context.Background(), uint64(blockNumber))
299303
if err != nil {
300304
return "", fmt.Errorf("failed to get output at block %d: %w", blockNumber, err)
301305
}
302-
303306
return output.OutputRoot.String(), nil
304307
}
305308

@@ -365,7 +368,11 @@ func (h DisputeGameHandler) gamesClaimByPosition(req *CalculateClaim) (string, e
365368
outputBlock = poststateBlock.Uint64()
366369
}
367370

368-
root, err := h.getClaimRoot(cast.ToInt64(outputBlock))
371+
if outputBlock > math.MaxInt64 {
372+
return "", fmt.Errorf("output block number too large: %d", outputBlock)
373+
}
374+
375+
root, err := h.getClaimRoot(int64(outputBlock))
369376
if err != nil {
370377
return "", err
371378
}

internal/types/config.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ type Config struct {
1818
Blockchain string `env:"BLOCKCHAIN" envDefault:"sepolia"`
1919
L1RPCUrl string `env:"L1_RPC_URL" envDefault:"https://eth-sepolia.g.alchemy.com/v2/RT1mCGRyVMx1F-XlY4Es4Zz-Q8Jrasg6"`
2020
L2RPCUrl string `env:"L2_RPC_URL" envDefault:"https://opt-sepolia.g.alchemy.com/v2/RT1mCGRyVMx1F-XlY4Es4Zz-Q8Jrasg6"`
21-
NodeRpcUrl string `env:"NODE_RPC_URL" envDefault:"https://light-radial-slug.optimism-sepolia.quiknode.pro/e9329f699b371572a8cc5dd22d19d5940bb842a5/"`
21+
NodeRPCURL string `env:"NODE_RPCURL" envDefault:"https://light-radial-slug.optimism-sepolia.quiknode.pro/e9329f699b371572a8cc5dd22d19d5940bb842a5/"`
2222
RPCRateLimit int `env:"RPC_RATE_LIMIT" envDefault:"5"`
2323
RPCRateBurst int `env:"RPC_RATE_BURST" envDefault:"2"`
2424
FromBlockNumber int64 `env:"FROM_BLOCK_NUMBER" envDefault:"5515562"`

main.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -68,7 +68,7 @@ func main() {
6868

6969
// 新增:初始化 RollupClient 的函数
7070
func initRollupClient(cfg *types.Config) *sources.RollupClient {
71-
rpcClient, err := client.NewRPC(context.Background(), gethlog.New(), cfg.NodeRpcUrl)
71+
rpcClient, err := client.NewRPC(context.Background(), gethlog.New(), cfg.NodeRPCURL)
7272
if err != nil {
7373
disputeLog.Errorf("failed to connect to node RPC: %v", err)
7474
panic(err)

0 commit comments

Comments
 (0)