Skip to content

Commit

Permalink
feat: Span Batch Query Server (#77)
Browse files Browse the repository at this point in the history
* add

* fix

* add main test

* fix

* fix

* fix

* add gh action

* fix

* fix

* fix

* fix

* fix

* fix
  • Loading branch information
ratankaliani authored Aug 28, 2024
1 parent 06ec2f3 commit b1405d5
Show file tree
Hide file tree
Showing 12 changed files with 1,172 additions and 2 deletions.
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
name: Compile Native Programs
name: OP Succinct

on:
pull_request:
Expand All @@ -17,4 +17,4 @@ jobs:
working-directory: client-programs/fault-proof
- name: Compile the range program
run: cargo build --profile release-client-lto
working-directory: client-programs/range
working-directory: client-programs/range
27 changes: 27 additions & 0 deletions .github/workflows/op_proposer.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
name: OP Proposer [Go]

on:
pull_request:
branches:
- main
paths:
- 'op-proposer-go/**'

jobs:
test_op_proposer_go:
runs-on: ubuntu-latest
steps:
- name: Checkout code
uses: actions/checkout@v3
- name: Set up Go
uses: actions/setup-go@v2
with:
go-version: '1.22'
- name: Run main_test.go
run: go test -v ./server/main_test.go
working-directory: op-proposer-go
env:
L2_RPC: ${{ secrets.L2_RPC }}
L2_NODE_RPC: ${{ secrets.L2_NODE_RPC }}
L1_RPC: ${{ secrets.L1_RPC }}
L1_BEACON_RPC: ${{ secrets.L1_BEACON_RPC }}
Binary file modified elf/aggregation-elf
Binary file not shown.
Binary file modified elf/fault-proof-elf
Binary file not shown.
Binary file modified elf/range-elf
Binary file not shown.
1 change: 1 addition & 0 deletions op-proposer-go/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
vendor/
94 changes: 94 additions & 0 deletions op-proposer-go/cmd/main.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,94 @@
package main

import (
"fmt"
"log"
"os"

"github.com/joho/godotenv"
"github.com/succinctlabs/op-succinct-go/server/utils"
"github.com/urfave/cli/v2"
)

func main() {
// Load environment variables from .env file
if err := godotenv.Load(); err != nil {
log.Println("No .env file found, proceeding with default values.")
}

app := &cli.App{
Name: "get-range",
Usage: "For a given L2 block number, gets the full range of the span batch that it's a part of",
Flags: []cli.Flag{
&cli.Uint64Flag{
Name: "start",
Usage: "The L2 block number to start at",
},
&cli.Uint64Flag{
Name: "end",
Usage: "The L2 block number to end at",
},
&cli.StringFlag{
Name: "l2",
Required: false,
Usage: "L2 RPC URL",
EnvVars: []string{"L2_RPC"},
},
&cli.StringFlag{
Name: "l2.node",
Required: false,
Usage: "L2 node URL",
EnvVars: []string{"L2_NODE_RPC"},
},
&cli.StringFlag{
Name: "l1",
Required: false,
Usage: "L1 RPC URL",
EnvVars: []string{"L1_RPC"},
},
&cli.StringFlag{
Name: "l1.beacon",
Required: false,
Usage: "Address of L1 Beacon-node HTTP endpoint to use",
EnvVars: []string{"L1_BEACON_RPC"},
},
&cli.StringFlag{
Name: "sender",
Required: false,
Usage: "Batch Sender Address",
},
},
Action: func(cliCtx *cli.Context) error {
rollupCfg, err := utils.GetRollupConfigFromL2Rpc(cliCtx.String("l2"))
if err != nil {
log.Fatal(err)
}

config := utils.BatchDecoderConfig{
L2GenesisTime: rollupCfg.Genesis.L2Time,
L2GenesisBlock: rollupCfg.Genesis.L2.Number,
L2BlockTime: rollupCfg.BlockTime,
BatchInboxAddress: rollupCfg.BatchInboxAddress,
L2StartBlock: cliCtx.Uint64("start"),
L2EndBlock: cliCtx.Uint64("end"),
L2ChainID: rollupCfg.L2ChainID,
L2Node: cliCtx.String("l2.node"),
L1RPC: cliCtx.String("l1"),
L1Beacon: cliCtx.String("l1.beacon"),
BatchSender: rollupCfg.Genesis.SystemConfig.BatcherAddr,
DataDir: fmt.Sprintf("/tmp/batch_decoder/%d/transactions_cache", rollupCfg.L2ChainID),
}

ranges, err := utils.GetAllSpanBatchesInBlockRange(config)
if err != nil {
log.Fatal(err)
}
fmt.Printf("Span batch ranges: %v\n", ranges)
return nil
},
}

if err := app.Run(os.Args); err != nil {
log.Fatal(err)
}
}
112 changes: 112 additions & 0 deletions op-proposer-go/go.mod
Original file line number Diff line number Diff line change
@@ -0,0 +1,112 @@
module github.com/succinctlabs/op-succinct-go

go 1.22

require (
github.com/ethereum-optimism/optimism v1.9.0
github.com/ethereum/go-ethereum v1.13.15
github.com/gorilla/mux v1.8.1
github.com/joho/godotenv v1.5.1
github.com/urfave/cli/v2 v2.27.3
)

// v1.9.0 tag on ethereum-optimism uses a fork of go-ethereum
// https://github.com/ethereum-optimism/optimism/blob/ec45f6634ab2855a4ae5d30c4e240d79f081d689/go.mod#L231
replace github.com/ethereum/go-ethereum => github.com/ethereum-optimism/op-geth v1.101315.3-rc.2

require (
github.com/BurntSushi/toml v1.4.0 // indirect
github.com/DataDog/zstd v1.5.5 // indirect
github.com/Microsoft/go-winio v0.6.1 // indirect
github.com/VictoriaMetrics/fastcache v1.12.1 // indirect
github.com/andybalholm/brotli v1.1.0 // indirect
github.com/beorn7/perks v1.0.1 // indirect
github.com/bits-and-blooms/bitset v1.10.0 // indirect
github.com/btcsuite/btcd v0.24.2 // indirect
github.com/btcsuite/btcd/btcec/v2 v2.3.2 // indirect
github.com/btcsuite/btcd/btcutil v1.1.5 // indirect
github.com/btcsuite/btcd/chaincfg/chainhash v1.1.0 // indirect
github.com/cespare/xxhash/v2 v2.2.0 // indirect
github.com/cockroachdb/errors v1.11.1 // indirect
github.com/cockroachdb/logtags v0.0.0-20230118201751-21c54148d20b // indirect
github.com/cockroachdb/pebble v0.0.0-20231018212520-f6cde3fc2fa4 // indirect
github.com/cockroachdb/redact v1.1.5 // indirect
github.com/cockroachdb/tokenbucket v0.0.0-20230807174530-cc333fc44b06 // indirect
github.com/consensys/bavard v0.1.13 // indirect
github.com/consensys/gnark-crypto v0.12.1 // indirect
github.com/cpuguy83/go-md2man/v2 v2.0.4 // indirect
github.com/crate-crypto/go-ipa v0.0.0-20231025140028-3c0104f4b233 // indirect
github.com/crate-crypto/go-kzg-4844 v0.7.0 // indirect
github.com/davecgh/go-spew v1.1.2-0.20180830191138-d8f796af33cc // indirect
github.com/deckarep/golang-set/v2 v2.3.0 // indirect
github.com/decred/dcrd/dcrec/secp256k1/v4 v4.3.0 // indirect
github.com/ethereum-optimism/go-ethereum-hdwallet v0.1.3 // indirect
github.com/ethereum-optimism/superchain-registry/superchain v0.0.0-20240803025447-c92ef420eec2 // indirect
github.com/ethereum/c-kzg-4844 v0.4.0 // indirect
github.com/fjl/memsize v0.0.2 // indirect
github.com/fsnotify/fsnotify v1.7.0 // indirect
github.com/gballet/go-libpcsclite v0.0.0-20191108122812-4678299bea08 // indirect
github.com/gballet/go-verkle v0.1.1-0.20231031103413-a67434b50f46 // indirect
github.com/getsentry/sentry-go v0.20.0 // indirect
github.com/go-ole/go-ole v1.3.0 // indirect
github.com/gofrs/flock v0.8.1 // indirect
github.com/gogo/protobuf v1.3.2 // indirect
github.com/golang-jwt/jwt/v4 v4.5.0 // indirect
github.com/golang/snappy v0.0.5-0.20220116011046-fa5810519dcb // indirect
github.com/google/uuid v1.6.0 // indirect
github.com/gorilla/websocket v1.5.1 // indirect
github.com/hashicorp/errwrap v1.1.0 // indirect
github.com/hashicorp/go-bexpr v0.1.11 // indirect
github.com/hashicorp/go-multierror v1.1.1 // indirect
github.com/hashicorp/golang-lru/v2 v2.0.7 // indirect
github.com/holiman/billy v0.0.0-20240216141850-2abb0c79d3c4 // indirect
github.com/holiman/bloomfilter/v2 v2.0.3 // indirect
github.com/holiman/uint256 v1.3.1 // indirect
github.com/huin/goupnp v1.3.0 // indirect
github.com/jackpal/go-nat-pmp v1.0.2 // indirect
github.com/klauspost/compress v1.17.9 // indirect
github.com/kr/pretty v0.3.1 // indirect
github.com/kr/text v0.2.0 // indirect
github.com/mattn/go-colorable v0.1.13 // indirect
github.com/mattn/go-isatty v0.0.20 // indirect
github.com/mattn/go-runewidth v0.0.14 // indirect
github.com/mitchellh/mapstructure v1.5.0 // indirect
github.com/mitchellh/pointerstructure v1.2.1 // indirect
github.com/mmcloughlin/addchain v0.4.0 // indirect
github.com/olekukonko/tablewriter v0.0.5 // indirect
github.com/pkg/errors v0.9.1 // indirect
github.com/pmezard/go-difflib v1.0.1-0.20181226105442-5d4384ee4fb2 // indirect
github.com/prometheus/client_golang v1.19.1 // indirect
github.com/prometheus/client_model v0.6.1 // indirect
github.com/prometheus/common v0.48.0 // indirect
github.com/prometheus/procfs v0.12.0 // indirect
github.com/rivo/uniseg v0.4.4 // indirect
github.com/rogpeppe/go-internal v1.10.0 // indirect
github.com/rs/cors v1.11.0 // indirect
github.com/russross/blackfriday/v2 v2.1.0 // indirect
github.com/shirou/gopsutil v3.21.11+incompatible // indirect
github.com/status-im/keycard-go v0.2.0 // indirect
github.com/stretchr/objx v0.5.2 // indirect
github.com/stretchr/testify v1.9.0 // indirect
github.com/supranational/blst v0.3.11 // indirect
github.com/syndtr/goleveldb v1.0.1-0.20220614013038-64ee5596c38a // indirect
github.com/tklauser/go-sysconf v0.3.12 // indirect
github.com/tklauser/numcpus v0.6.1 // indirect
github.com/tyler-smith/go-bip39 v1.1.0 // indirect
github.com/xrash/smetrics v0.0.0-20240521201337-686a1a2994c1 // indirect
github.com/yusufpapurcu/wmi v1.2.3 // indirect
golang.org/x/crypto v0.25.0 // indirect
golang.org/x/exp v0.0.0-20240719175910-8a7402abbf56 // indirect
golang.org/x/mod v0.19.0 // indirect
golang.org/x/net v0.27.0 // indirect
golang.org/x/sync v0.8.0 // indirect
golang.org/x/sys v0.22.0 // indirect
golang.org/x/term v0.22.0 // indirect
golang.org/x/text v0.16.0 // indirect
golang.org/x/time v0.6.0 // indirect
golang.org/x/tools v0.23.0 // indirect
google.golang.org/protobuf v1.34.1 // indirect
gopkg.in/natefinch/lumberjack.v2 v2.0.0 // indirect
gopkg.in/yaml.v3 v3.0.1 // indirect
rsc.io/tmplfunc v0.0.3 // indirect
)
Loading

0 comments on commit b1405d5

Please sign in to comment.