Commit d5ebf81a authored by refcell's avatar refcell

use native uint64 big int check

parent 9c380bee
...@@ -5,8 +5,6 @@ import ( ...@@ -5,8 +5,6 @@ import (
"encoding/json" "encoding/json"
"errors" "errors"
"fmt" "fmt"
"math"
"math/big"
"os" "os"
"path/filepath" "path/filepath"
...@@ -91,7 +89,7 @@ func (p *CannonTraceProvider) SetMaxDepth(gameDepth uint64) { ...@@ -91,7 +89,7 @@ func (p *CannonTraceProvider) SetMaxDepth(gameDepth uint64) {
func (p *CannonTraceProvider) Get(ctx context.Context, pos types.Position) (common.Hash, error) { func (p *CannonTraceProvider) Get(ctx context.Context, pos types.Position) (common.Hash, error) {
traceIndex := pos.TraceIndex(int(p.gameDepth)) traceIndex := pos.TraceIndex(int(p.gameDepth))
if traceIndex.Cmp(new(big.Int).SetUint64(math.MaxUint64)) > 0 { if !traceIndex.IsUint64() {
return common.Hash{}, errors.New("trace index out of bounds") return common.Hash{}, errors.New("trace index out of bounds")
} }
proof, err := p.loadProof(ctx, traceIndex.Uint64()) proof, err := p.loadProof(ctx, traceIndex.Uint64())
...@@ -108,7 +106,7 @@ func (p *CannonTraceProvider) Get(ctx context.Context, pos types.Position) (comm ...@@ -108,7 +106,7 @@ func (p *CannonTraceProvider) Get(ctx context.Context, pos types.Position) (comm
func (p *CannonTraceProvider) GetStepData(ctx context.Context, pos types.Position) ([]byte, []byte, *types.PreimageOracleData, error) { func (p *CannonTraceProvider) GetStepData(ctx context.Context, pos types.Position) ([]byte, []byte, *types.PreimageOracleData, error) {
traceIndex := pos.TraceIndex(int(p.gameDepth)) traceIndex := pos.TraceIndex(int(p.gameDepth))
if traceIndex.Cmp(new(big.Int).SetUint64(math.MaxUint64)) > 0 { if !traceIndex.IsUint64() {
return nil, nil, nil, errors.New("trace index out of bounds") return nil, nil, nil, errors.New("trace index out of bounds")
} }
proof, err := p.loadProof(ctx, traceIndex.Uint64()) proof, err := p.loadProof(ctx, traceIndex.Uint64())
......
...@@ -3,8 +3,6 @@ package outputs ...@@ -3,8 +3,6 @@ package outputs
import ( import (
"context" "context"
"fmt" "fmt"
"math"
"math/big"
"github.com/ethereum-optimism/optimism/op-challenger/game/fault/types" "github.com/ethereum-optimism/optimism/op-challenger/game/fault/types"
"github.com/ethereum-optimism/optimism/op-service/client" "github.com/ethereum-optimism/optimism/op-service/client"
...@@ -55,7 +53,7 @@ func NewTraceProviderFromInputs(logger log.Logger, rollupClient OutputRollupClie ...@@ -55,7 +53,7 @@ func NewTraceProviderFromInputs(logger log.Logger, rollupClient OutputRollupClie
func (o *OutputTraceProvider) Get(ctx context.Context, pos types.Position) (common.Hash, error) { func (o *OutputTraceProvider) Get(ctx context.Context, pos types.Position) (common.Hash, error) {
traceIndex := pos.TraceIndex(int(o.gameDepth)) traceIndex := pos.TraceIndex(int(o.gameDepth))
if traceIndex.Cmp(new(big.Int).SetUint64(math.MaxUint64)) > 0 { if !traceIndex.IsUint64() {
return common.Hash{}, fmt.Errorf("trace index %v is greater than max uint64", traceIndex) return common.Hash{}, fmt.Errorf("trace index %v is greater than max uint64", traceIndex)
} }
outputBlock := traceIndex.Uint64() + o.prestateBlock + 1 outputBlock := traceIndex.Uint64() + o.prestateBlock + 1
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment