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 <[email protected]>
  • 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.