Skip to content

Commit

Permalink
empty data field of MsgUpdateOracle of oracle tx and send converted b…
Browse files Browse the repository at this point in the history
…lock bytes to DA
  • Loading branch information
sh-cha committed Aug 5, 2024
1 parent 6320e66 commit efcc1f5
Show file tree
Hide file tree
Showing 5 changed files with 163 additions and 112 deletions.
7 changes: 6 additions & 1 deletion executor/batch/batch.go
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ import (

opchildtypes "github.com/initia-labs/OPinit/x/opchild/types"
ophosttypes "github.com/initia-labs/OPinit/x/ophost/types"
"github.com/initia-labs/opinit-bots-go/executor/child"
executortypes "github.com/initia-labs/opinit-bots-go/executor/types"
nodetypes "github.com/initia-labs/opinit-bots-go/node/types"
"github.com/initia-labs/opinit-bots-go/types"
Expand Down Expand Up @@ -62,7 +63,11 @@ type BatchSubmitter struct {

func NewBatchSubmitter(version uint8, cfg nodetypes.NodeConfig, batchCfg executortypes.BatchConfig, db types.DB, logger *zap.Logger, homePath string) *BatchSubmitter {
cfg.Account = ""
node, err := node.NewNode(nodetypes.PROCESS_TYPE_RAW, cfg, db, logger, nil, nil, homePath, "", "", nil)
appCodec, txConfig, bech32Prefix, err := child.GetCodec(cfg.ChainID)
if err != nil {
panic(err)
}
node, err := node.NewNode(nodetypes.PROCESS_TYPE_RAW, cfg, db, logger, appCodec, txConfig, homePath, bech32Prefix, "", nil)
if err != nil {
panic(err)
}
Expand Down
43 changes: 42 additions & 1 deletion executor/batch/handler.go
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ import (

cmtproto "github.com/cometbft/cometbft/proto/tendermint/types"
"github.com/cosmos/gogoproto/proto"
opchildtypes "github.com/initia-labs/OPinit/x/opchild/types"
ophosttypes "github.com/initia-labs/OPinit/x/ophost/types"
)

Expand All @@ -36,7 +37,12 @@ func (bs *BatchSubmitter) rawBlockHandler(args nodetypes.RawBlockArgs) error {
return errors.Wrap(err, "failed to prepare batch")
}

err = bs.handleBatch(args.BlockBytes)
blockBytes, err := bs.convertBlock(pbb)
if err != nil {
return err
}

err = bs.handleBatch(blockBytes)
if err != nil {
return errors.Wrap(err, "failed to handle batch")
}
Expand Down Expand Up @@ -283,3 +289,38 @@ func (bs *BatchSubmitter) DequeueBatchInfo() {

bs.batchInfos = bs.batchInfos[1:]
}

func (bs *BatchSubmitter) convertBlock(pbb *cmtproto.Block) ([]byte, error) {
for i, txBytes := range pbb.Data.GetTxs() {
tx, err := bs.node.DecodeTx(txBytes)
if err != nil {
// ignore not registered tx in codec
continue
}

msgs := tx.GetMsgs()
if len(msgs) != 1 {
continue
}

if msg, ok := msgs[0].(*opchildtypes.MsgUpdateOracle); ok {
msg.Data = []byte{}
tx, err := bs.node.ChangeMsgsFromTx(tx, []sdk.Msg{msg})
if err != nil {
return nil, err
}
convertedTxBytes, err := bs.node.EncodeTx(tx)
if err != nil {
return nil, err
}
pbb.Data.Txs[i] = convertedTxBytes
}
}

// convert block to bytes
blockBytes, err := proto.Marshal(pbb)
if err != nil {
return nil, err
}
return blockBytes, nil
}
69 changes: 34 additions & 35 deletions go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -4,26 +4,25 @@ go 1.22.5

require (
github.com/celestiaorg/go-square/v2 v2.0.0-rc0
github.com/cometbft/cometbft v0.38.9
github.com/cometbft/cometbft v0.38.10
github.com/cosmos/cosmos-sdk v0.50.8
github.com/gofiber/fiber/v2 v2.52.5
github.com/initia-labs/OPinit v0.4.0
github.com/initia-labs/initia v0.4.0
github.com/spf13/cobra v1.8.0
github.com/spf13/viper v1.18.2
github.com/initia-labs/OPinit v0.4.1
github.com/initia-labs/initia v0.4.1
github.com/spf13/cobra v1.8.1
github.com/spf13/viper v1.19.0
gopkg.in/yaml.v2 v2.4.0
)

require (
cloud.google.com/go v0.112.1 // indirect
cloud.google.com/go/compute v1.25.1 // indirect
cloud.google.com/go/compute/metadata v0.2.3 // indirect
cloud.google.com/go/compute/metadata v0.3.0 // indirect
cloud.google.com/go/iam v1.1.6 // indirect
cloud.google.com/go/storage v1.38.0 // indirect
cosmossdk.io/client/v2 v2.0.0-beta.1.0.20240124105859-5ad1805d0e79 // indirect
cosmossdk.io/x/evidence v0.1.0 // indirect
cosmossdk.io/x/feegrant v0.1.0 // indirect
cosmossdk.io/x/upgrade v0.1.1 // indirect
cosmossdk.io/x/upgrade v0.1.3 // indirect
github.com/DataDog/datadog-go v3.2.0+incompatible // indirect
github.com/IGLOU-EU/go-wildcard v1.0.3 // indirect
github.com/andybalholm/brotli v1.0.5 // indirect
Expand All @@ -34,11 +33,13 @@ require (
github.com/celestiaorg/nmt v0.22.0 // indirect
github.com/chzyer/readline v1.5.1 // indirect
github.com/cockroachdb/apd/v2 v2.0.2 // indirect
github.com/cockroachdb/fifo v0.0.0-20240606204812-0bbfbd93a7ce // indirect
github.com/cosmos/gogogateway v1.2.0 // indirect
github.com/cosmos/ibc-apps/middleware/packet-forward-middleware/v8 v8.0.2 // indirect
github.com/cosmos/ibc-apps/modules/rate-limiting/v8 v8.0.0 // indirect
github.com/cosmos/ibc-go/modules/capability v1.0.0 // indirect
github.com/cosmos/ibc-go/v8 v8.2.1 // indirect
github.com/cosmos/interchain-security/v5 v5.0.0-rc0 // indirect
github.com/cosmos/ibc-go/v8 v8.4.0 // indirect
github.com/cosmos/interchain-security/v5 v5.0.0 // indirect
github.com/desertbit/timer v0.0.0-20180107155436-c41aec40b27f // indirect
github.com/go-logr/logr v1.4.1 // indirect
github.com/go-logr/stdr v1.2.2 // indirect
Expand All @@ -50,14 +51,14 @@ require (
github.com/google/s2a-go v0.1.7 // indirect
github.com/google/uuid v1.6.0 // indirect
github.com/googleapis/enterprise-certificate-proxy v0.3.2 // indirect
github.com/googleapis/gax-go/v2 v2.12.2 // indirect
github.com/googleapis/gax-go/v2 v2.12.3 // indirect
github.com/grpc-ecosystem/go-grpc-middleware v1.4.0 // indirect
github.com/hashicorp/go-cleanhttp v0.5.2 // indirect
github.com/hashicorp/go-getter v1.7.4 // indirect
github.com/hashicorp/go-getter v1.7.5 // indirect
github.com/hashicorp/go-hclog v1.5.0 // indirect
github.com/hashicorp/go-plugin v1.5.2 // indirect
github.com/hashicorp/go-safetemp v1.0.0 // indirect
github.com/hashicorp/go-version v1.6.0 // indirect
github.com/hashicorp/go-version v1.7.0 // indirect
github.com/hashicorp/golang-lru/v2 v2.0.7 // indirect
github.com/hashicorp/yamux v0.1.1 // indirect
github.com/huandu/skiplist v1.2.0 // indirect
Expand All @@ -72,13 +73,13 @@ require (
github.com/minio/highwayhash v1.0.2 // indirect
github.com/mitchellh/go-homedir v1.1.0 // indirect
github.com/mitchellh/go-testing-interface v1.14.1 // indirect
github.com/noble-assets/forwarding/v2 v2.0.0-20240514101621-172acc02aac6 // indirect
github.com/noble-assets/forwarding/v2 v2.0.0-20240521090705-86712c4c9e43 // indirect
github.com/oklog/run v1.1.0 // indirect
github.com/rakyll/statik v0.1.7 // indirect
github.com/rivo/uniseg v0.4.4 // indirect
github.com/rs/cors v1.8.3 // indirect
github.com/skip-mev/block-sdk/v2 v2.1.2 // indirect
github.com/skip-mev/slinky v0.4.3 // indirect
github.com/skip-mev/slinky v1.0.5 // indirect
github.com/ugorji/go/codec v1.2.12 // indirect
github.com/ulikunitz/xz v0.5.11 // indirect
github.com/valyala/bytebufferpool v1.0.0 // indirect
Expand All @@ -90,18 +91,17 @@ require (
go.opentelemetry.io/otel v1.24.0 // indirect
go.opentelemetry.io/otel/metric v1.24.0 // indirect
go.opentelemetry.io/otel/trace v1.24.0 // indirect
golang.org/x/oauth2 v0.18.0 // indirect
golang.org/x/oauth2 v0.20.0 // indirect
golang.org/x/time v0.5.0 // indirect
google.golang.org/api v0.169.0 // indirect
google.golang.org/appengine v1.6.8 // indirect
google.golang.org/api v0.171.0 // indirect
nhooyr.io/websocket v1.8.6 // indirect
)

require (
cosmossdk.io/api v0.7.5 // indirect
cosmossdk.io/collections v0.4.0 // indirect
cosmossdk.io/core v0.11.0
cosmossdk.io/depinject v1.0.0-alpha.4 // indirect
cosmossdk.io/depinject v1.0.0 // indirect
cosmossdk.io/errors v1.0.1
cosmossdk.io/log v1.3.1 // indirect
cosmossdk.io/math v1.3.0
Expand All @@ -117,9 +117,9 @@ require (
github.com/cenkalti/backoff/v4 v4.2.1 // indirect
github.com/cespare/xxhash v1.1.0 // indirect
github.com/cespare/xxhash/v2 v2.3.0 // indirect
github.com/cockroachdb/errors v1.11.1 // indirect
github.com/cockroachdb/errors v1.11.3 // indirect
github.com/cockroachdb/logtags v0.0.0-20230118201751-21c54148d20b // indirect
github.com/cockroachdb/pebble v1.1.0 // indirect
github.com/cockroachdb/pebble v1.1.1 // indirect
github.com/cockroachdb/redact v1.1.5 // indirect
github.com/cockroachdb/tokenbucket v0.0.0-20230807174530-cc333fc44b06 // indirect
github.com/cometbft/cometbft-db v0.10.0 // indirect
Expand All @@ -140,7 +140,7 @@ require (
github.com/dustin/go-humanize v1.0.1 // indirect
github.com/dvsekhvalnov/jose2go v1.6.0 // indirect
github.com/emicklei/dot v1.6.1 // indirect
github.com/fatih/color v1.16.0 // indirect
github.com/fatih/color v1.17.0 // indirect
github.com/felixge/httpsnoop v1.0.4 // indirect
github.com/fsnotify/fsnotify v1.7.0 // indirect
github.com/getsentry/sentry-go v0.27.0 // indirect
Expand All @@ -149,14 +149,14 @@ require (
github.com/go-logfmt/logfmt v0.6.0 // indirect
github.com/godbus/dbus v0.0.0-20190726142602-4481cbc300e2 // indirect
github.com/gogo/protobuf v1.3.3 // indirect
github.com/golang/glog v1.2.0 // indirect
github.com/golang/glog v1.2.1 // indirect
github.com/golang/protobuf v1.5.4 // indirect
github.com/golang/snappy v0.0.5-0.20220116011046-fa5810519dcb // indirect
github.com/google/btree v1.1.2 // indirect
github.com/google/go-cmp v0.6.0 // indirect
github.com/gorilla/handlers v1.5.2 // indirect
github.com/gorilla/mux v1.8.1 // indirect
github.com/gorilla/websocket v1.5.1 // indirect
github.com/gorilla/websocket v1.5.3 // indirect
github.com/grpc-ecosystem/grpc-gateway v1.16.0 // indirect
github.com/gsterjov/go-libsecret v0.0.0-20161001094733-a6f4afe4910c // indirect
github.com/hashicorp/go-immutable-radix v1.3.1 // indirect
Expand All @@ -167,10 +167,9 @@ require (
github.com/iancoleman/strcase v0.3.0 // indirect
github.com/inconshreveable/mousetrap v1.1.0 // indirect
github.com/jmhodges/levigo v1.0.0 // indirect
github.com/klauspost/compress v1.17.8 // 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/libp2p/go-buffer-pool v0.1.0 // indirect
github.com/linxGnu/grocksdb v1.8.14 // indirect
github.com/magiconair/properties v1.8.7 // indirect
github.com/mattn/go-colorable v0.1.13 // indirect
Expand Down Expand Up @@ -206,17 +205,17 @@ require (
go.etcd.io/bbolt v1.3.8 // indirect
go.uber.org/multierr v1.11.0 // indirect
go.uber.org/zap v1.27.0
golang.org/x/crypto v0.24.0
golang.org/x/exp v0.0.0-20240404231335-c0f41cb1a7a0 // indirect
golang.org/x/net v0.26.0 // indirect
golang.org/x/sync v0.7.0 // indirect
golang.org/x/sys v0.21.0 // indirect
golang.org/x/term v0.21.0 // indirect
golang.org/x/crypto v0.25.0
golang.org/x/exp v0.0.0-20240506185415-9bf2ced13842 // indirect
golang.org/x/net v0.27.0 // indirect
golang.org/x/sync v0.7.0
golang.org/x/sys v0.22.0 // indirect
golang.org/x/term v0.22.0 // indirect
golang.org/x/text v0.16.0 // indirect
google.golang.org/genproto v0.0.0-20240227224415-6ceb2ff114de // indirect
google.golang.org/genproto/googleapis/api v0.0.0-20240318140521-94a12d6c2237 // indirect
google.golang.org/genproto/googleapis/rpc v0.0.0-20240401170217-c3f982113cda // indirect
google.golang.org/grpc v1.64.0
google.golang.org/genproto/googleapis/api v0.0.0-20240528184218-531527333157 // indirect
google.golang.org/genproto/googleapis/rpc v0.0.0-20240709173604-40e1e62336c5 // indirect
google.golang.org/grpc v1.65.0
google.golang.org/protobuf v1.34.2 // indirect
gopkg.in/ini.v1 v1.67.0 // indirect
gopkg.in/yaml.v3 v3.0.1 // indirect
Expand Down
Loading

0 comments on commit efcc1f5

Please sign in to comment.