Commit a4f00f61 authored by Ethen Pociask's avatar Ethen Pociask

Merge branch 'develop' of https://github.com/epociask/optimism into indexer.client

parents ef98e305 c5732fc5
...@@ -89,10 +89,8 @@ devnet-up: ...@@ -89,10 +89,8 @@ devnet-up:
@if [ ! -e op-program/bin ]; then \ @if [ ! -e op-program/bin ]; then \
make cannon-prestate; \ make cannon-prestate; \
fi fi
$(shell ./ops/scripts/newer-file.sh .devnet/allocs-l1.json ./packages/contracts-bedrock) ./ops/scripts/newer-file.sh .devnet/allocs-l1.json ./packages/contracts-bedrock \
if [ $(.SHELLSTATUS) -ne 0 ]; then \ || make devnet-allocs
make devnet-allocs; \
fi
PYTHONPATH=./bedrock-devnet python3 ./bedrock-devnet/main.py --monorepo-dir=. PYTHONPATH=./bedrock-devnet python3 ./bedrock-devnet/main.py --monorepo-dir=.
.PHONY: devnet-up .PHONY: devnet-up
......
...@@ -10,5 +10,17 @@ LDFLAGS := -ldflags "$(LDFLAGSSTRING)" ...@@ -10,5 +10,17 @@ LDFLAGS := -ldflags "$(LDFLAGSSTRING)"
op-bootnode: op-bootnode:
env GO111MODULE=on GOOS=$(TARGETOS) GOARCH=$(TARGETARCH) go build -v $(LDFLAGS) -o ./bin/op-bootnode ./cmd env GO111MODULE=on GOOS=$(TARGETOS) GOARCH=$(TARGETARCH) go build -v $(LDFLAGS) -o ./bin/op-bootnode ./cmd
clean:
rm -f bin/op-bootnode
test:
go test -v ./...
lint: lint:
golangci-lint run -E goimports,sqlclosecheck,bodyclose,asciicheck,misspell,errorlint --timeout 5m -e "errors.As" -e "errors.Is" ./... golangci-lint run -E goimports,sqlclosecheck,bodyclose,asciicheck,misspell,errorlint --timeout 5m -e "errors.As" -e "errors.Is" ./...
.PHONY: \
op-bootnode \
clean \
test \
lint
...@@ -3,21 +3,16 @@ package main ...@@ -3,21 +3,16 @@ package main
import ( import (
"os" "os"
"github.com/ethereum-optimism/optimism/op-bootnode/bootnode"
"github.com/ethereum-optimism/optimism/op-bootnode/flags"
"github.com/ethereum/go-ethereum/log" "github.com/ethereum/go-ethereum/log"
"github.com/urfave/cli/v2" "github.com/urfave/cli/v2"
"github.com/ethereum-optimism/optimism/op-bootnode/bootnode"
"github.com/ethereum-optimism/optimism/op-bootnode/flags"
oplog "github.com/ethereum-optimism/optimism/op-service/log"
) )
func main() { func main() {
// Set up logger with a default INFO level in case we fail to parse flags, oplog.SetupDefaults()
// otherwise the final critical log won't show what the parsing error was.
log.Root().SetHandler(
log.LvlFilterHandler(
log.LvlInfo,
log.StreamHandler(os.Stdout, log.TerminalFormat(true)),
),
)
app := cli.NewApp() app := cli.NewApp()
app.Flags = flags.Flags app.Flags = flags.Flags
......
...@@ -51,23 +51,30 @@ type extendedClaim struct { ...@@ -51,23 +51,30 @@ type extendedClaim struct {
type gameState struct { type gameState struct {
agreeWithProposedOutput bool agreeWithProposedOutput bool
root claimEntry root claimEntry
claims map[claimEntry]*extendedClaim // contractIndicies maps a contract index to it's extended claim.
depth uint64 // This is used to perform O(1) parent lookups.
contractIndicies map[int]*extendedClaim
// claims maps a claim entry to it's extended claim.
claims map[claimEntry]*extendedClaim
depth uint64
} }
// NewGameState returns a new game state. // NewGameState returns a new game state.
// The provided [Claim] is used as the root node. // The provided [Claim] is used as the root node.
func NewGameState(agreeWithProposedOutput bool, root Claim, depth uint64) *gameState { func NewGameState(agreeWithProposedOutput bool, root Claim, depth uint64) *gameState {
claims := make(map[claimEntry]*extendedClaim) claims := make(map[claimEntry]*extendedClaim)
parents := make(map[int]*extendedClaim)
rootClaimEntry := makeClaimEntry(root) rootClaimEntry := makeClaimEntry(root)
claims[rootClaimEntry] = &extendedClaim{ claims[rootClaimEntry] = &extendedClaim{
self: root, self: root,
children: make([]claimEntry, 0), children: make([]claimEntry, 0),
} }
parents[root.ContractIndex] = claims[rootClaimEntry]
return &gameState{ return &gameState{
agreeWithProposedOutput: agreeWithProposedOutput, agreeWithProposedOutput: agreeWithProposedOutput,
root: rootClaimEntry, root: rootClaimEntry,
claims: claims, claims: claims,
contractIndicies: parents,
depth: depth, depth: depth,
} }
} }
...@@ -106,10 +113,12 @@ func (g *gameState) Put(claim Claim) error { ...@@ -106,10 +113,12 @@ func (g *gameState) Put(claim Claim) error {
return errors.New("no parent claim") return errors.New("no parent claim")
} }
parent.children = append(parent.children, makeClaimEntry(claim)) parent.children = append(parent.children, makeClaimEntry(claim))
g.claims[makeClaimEntry(claim)] = &extendedClaim{ claimWithExtension := &extendedClaim{
self: claim, self: claim,
children: make([]claimEntry, 0), children: make([]claimEntry, 0),
} }
g.claims[makeClaimEntry(claim)] = claimWithExtension
g.contractIndicies[claim.ContractIndex] = claimWithExtension
return nil return nil
} }
...@@ -150,11 +159,8 @@ func (g *gameState) getParent(claim Claim) *extendedClaim { ...@@ -150,11 +159,8 @@ func (g *gameState) getParent(claim Claim) *extendedClaim {
if claim.IsRoot() { if claim.IsRoot() {
return nil return nil
} }
// TODO(inphi): refactor gameState for faster parent lookups if parent, ok := g.contractIndicies[claim.ParentContractIndex]; ok {
for _, c := range g.claims { return parent
if c.self.ContractIndex == claim.ParentContractIndex {
return c
}
} }
return nil return nil
} }
......
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