Skip to content
This repository has been archived by the owner on May 29, 2024. It is now read-only.

Commit

Permalink
Issue 6 fix (#18)
Browse files Browse the repository at this point in the history
Co-authored-by: Ethen Pociask <ethen.pociask@coinbase.com>
  • Loading branch information
anupsv-cb and Ethen Pociask authored Apr 14, 2023
1 parent ec617ef commit 34ff89f
Show file tree
Hide file tree
Showing 16 changed files with 1,141 additions and 138 deletions.
2 changes: 1 addition & 1 deletion .golangci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ linters-settings:
gocognit:
# Minimal code complexity to report.
# Default: 30
min-complexity: 20
min-complexity: 30

gocritic:
# Settings passed to gocritic.
Expand Down
42 changes: 19 additions & 23 deletions cmd/block_read_poc/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,13 +4,13 @@ import (
"context"
"sync"

"github.com/base-org/pessimism/internal/client"
"github.com/base-org/pessimism/internal/conduit/models"
"github.com/base-org/pessimism/internal/conduit/pipeline"
"github.com/base-org/pessimism/internal/conduit/registry"
"github.com/base-org/pessimism/internal/config"
"github.com/base-org/pessimism/internal/logger"
"github.com/base-org/pessimism/internal/logging"
"github.com/ethereum/go-ethereum/core/types"
"github.com/grpc-ecosystem/go-grpc-middleware/logging/zap/ctxzap"
"go.uber.org/zap"
)

Expand All @@ -35,14 +35,9 @@ func main() {

cfg := config.NewConfig("config.env")

logger, err := logger.NewLogger(cfg.LoggerConfig, cfg.IsProduction())
if err != nil {
panic("could not initialize logger")
}

appCtx = ctxzap.ToContext(appCtx, logger)
logging.NewLogger(cfg.LoggerConfig, cfg.IsProduction())

logger.Info("pessimism boot up")
logging.NoContext().Info("pessimism boot up")

l1OracleCfg := &config.OracleConfig{
RPCEndpoint: cfg.L1RpcEndpoint,
Expand All @@ -52,69 +47,70 @@ func main() {
// 1. Configure blackhole tx pipe component
createRegister, err := registry.GetRegister(registry.ContractCreateTX)
if err != nil {
logger.Fatal("error creating register", zap.Error(err))
logging.NoContext().Fatal("error creating register", zap.Error(err))
}

initPipe, success := createRegister.ComponentConstructor.(pipeline.PipeConstructorFunc)
if !success {
logger.Fatal("could not read component constructor Pipe constructor type")
logging.NoContext().Fatal("could not read component constructor Pipe constructor type")
}

inputChan := make(chan models.TransitData)

createTxPipe, err := initPipe(appCtx, inputChan)
if err != nil {
logger.Fatal("error during pipe initialization", zap.Error(err))
logging.NoContext().Fatal("error during pipe initialization", zap.Error(err))
}

register, err := registry.GetRegister(registry.GethBlock)
if err != nil {
logger.Fatal("error getting register", zap.String("type", string(registry.GethBlock)), zap.Error(err))
logging.NoContext().Fatal("error getting register", zap.String("type", string(registry.GethBlock)), zap.Error(err))
}

init, success := register.ComponentConstructor.(pipeline.OracleConstructor)
if !success {
logger.Fatal("Could not read constructor value")
logging.NoContext().Fatal("Could not read constructor value")
}

go func() {
if routineErr := createTxPipe.EventLoop(); routineErr != nil {
logger.Error("Error received from oracle event loop", zap.Error(routineErr))
logging.NoContext().Error("Error received from oracle event loop", zap.Error(routineErr))
}
}()

l1Oracle, err := init(appCtx, pipeline.LiveOracle, l1OracleCfg)
ethClient := client.EthClient{}
l1Oracle, err := init(appCtx, pipeline.LiveOracle, l1OracleCfg, &ethClient)
if err != nil {
logger.Fatal("error initializing oracle", zap.Error(err))
logging.NoContext().Fatal("error initializing oracle", zap.Error(err))
}

if err := l1Oracle.AddDirective(interChanID, inputChan); err != nil {
logger.Fatal("error adding directive", zap.Int("interChanID", interChanID), zap.Error(err))
logging.NoContext().Fatal("error adding directive", zap.Int("interChanID", interChanID), zap.Error(err))
}

outputChan := make(chan models.TransitData)

if err := createTxPipe.AddDirective(outChanID, outputChan); err != nil {
logger.Fatal("error adding directive", zap.Int("outChanID", outChanID), zap.Error(err))
logging.NoContext().Fatal("error adding directive", zap.Int("outChanID", outChanID), zap.Error(err))
}

wg := sync.WaitGroup{}
wg.Add(1)

go func() {
if routineErr := l1Oracle.EventLoop(); routineErr != nil {
logger.Error("Error received from oracle event loop", zap.Error(routineErr))
logging.NoContext().Error("Error received from oracle event loop", zap.Error(routineErr))
}
}()

for td := range outputChan {
logger.Info("Received Contract creation Transaction", zap.Any("transitData", td))
logging.NoContext().Info("Received Contract creation Transaction", zap.Any("transitData", td))

parsedTx, success := td.Value.(types.Transaction)
if !success {
logger.Error("Could not parse transaction value")
logging.NoContext().Error("Could not parse transaction value")
}

logger.Info("As parsed transaction", zap.Any("parsedTX", parsedTx))
logging.NoContext().Info("As parsed transaction", zap.Any("parsedTX", parsedTx))
}
}
31 changes: 29 additions & 2 deletions go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -11,27 +11,54 @@ require (
)

require (
github.com/DataDog/zstd v1.5.2 // indirect
github.com/StackExchange/wmi v0.0.0-20180116203802-5d049714c4a6 // indirect
github.com/VictoriaMetrics/fastcache v1.6.0 // indirect
github.com/beorn7/perks v1.0.1 // indirect
github.com/btcsuite/btcd/btcec/v2 v2.2.0 // indirect
github.com/cespare/xxhash/v2 v2.2.0 // indirect
github.com/cockroachdb/errors v1.9.1 // indirect
github.com/cockroachdb/logtags v0.0.0-20230118201751-21c54148d20b // indirect
github.com/cockroachdb/pebble v0.0.0-20230209160836-829675f94811 // indirect
github.com/cockroachdb/redact v1.1.3 // indirect
github.com/davecgh/go-spew v1.1.1 // indirect
github.com/deckarep/golang-set/v2 v2.1.0 // indirect
github.com/decred/dcrd/dcrec/secp256k1/v4 v4.0.1 // indirect
github.com/getsentry/sentry-go v0.18.0 // indirect
github.com/go-ole/go-ole v1.2.1 // indirect
github.com/go-stack/stack v1.8.1 // indirect
github.com/gofrs/flock v0.8.1 // indirect
github.com/gogo/protobuf v1.3.2 // indirect
github.com/golang/protobuf v1.5.2 // indirect
github.com/golang/snappy v0.0.4 // indirect
github.com/gorilla/websocket v1.4.2 // indirect
github.com/klauspost/compress v1.15.15 // indirect
github.com/kr/pretty v0.3.1 // indirect
github.com/kr/text v0.2.0 // indirect
github.com/mattn/go-runewidth v0.0.9 // indirect
github.com/matttproud/golang_protobuf_extensions v1.0.4 // indirect
github.com/olekukonko/tablewriter v0.0.5 // indirect
github.com/pkg/errors v0.9.1 // indirect
github.com/pmezard/go-difflib v1.0.0 // indirect
github.com/prometheus/client_golang v1.14.0 // indirect
github.com/prometheus/client_model v0.3.0 // indirect
github.com/prometheus/common v0.39.0 // indirect
github.com/prometheus/procfs v0.9.0 // indirect
github.com/rogpeppe/go-internal v1.9.0 // indirect
github.com/shirou/gopsutil v3.21.4-0.20210419000835-c7a38de76ee5+incompatible // indirect
github.com/stretchr/objx v0.5.0 // indirect
github.com/syndtr/goleveldb v1.0.1-0.20210819022825-2ae1ddf74ef7 // indirect
github.com/tklauser/go-sysconf v0.3.5 // indirect
github.com/tklauser/numcpus v0.2.2 // indirect
go.uber.org/atomic v1.7.0 // indirect
go.uber.org/multierr v1.6.0 // indirect
golang.org/x/crypto v0.1.0 // indirect
golang.org/x/exp v0.0.0-20230206171751-46f607a40771 // indirect
golang.org/x/net v0.7.0 // indirect
golang.org/x/sys v0.5.0 // indirect
golang.org/x/text v0.7.0 // indirect
google.golang.org/genproto v0.0.0-20200423170343-7949de9c1215 // indirect
google.golang.org/grpc v1.29.1 // indirect
google.golang.org/genproto v0.0.0-20210624195500-8bfb893ecb84 // indirect
google.golang.org/grpc v1.38.0 // indirect
google.golang.org/protobuf v1.28.1 // indirect
gopkg.in/natefinch/npipe.v2 v2.0.0-20160621034901-c1b8fa8bdcce // indirect
gopkg.in/yaml.v3 v3.0.1 // indirect
Expand Down
Loading

0 comments on commit 34ff89f

Please sign in to comment.