Skip to content

Commit

Permalink
feat: update the juno version (#244)
Browse files Browse the repository at this point in the history
  • Loading branch information
constwz authored Mar 24, 2023
1 parent 989c526 commit c6ebd0b
Show file tree
Hide file tree
Showing 5 changed files with 34 additions and 38 deletions.
8 changes: 4 additions & 4 deletions go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -6,18 +6,18 @@ replace (
cosmossdk.io/math => github.com/bnb-chain/greenfield-cosmos-sdk/math v0.0.0-20230228075616-68ac309b432c
github.com/bnb-chain/greenfield => github.com/bnb-chain/greenfield v0.0.9
github.com/confio/ics23/go => github.com/cosmos/cosmos-sdk/ics23/go v0.8.0
github.com/cosmos/cosmos-sdk => github.com/bnb-chain/greenfield-cosmos-sdk v0.0.2-0.20230316090342-debd6c0c82a7
github.com/forbole/juno/v4 => github.com/bnb-chain/juno/v4 v4.0.0-20230315120403-3093b5ed5267
github.com/cosmos/cosmos-sdk => github.com/bnb-chain/greenfield-cosmos-sdk v0.0.11
github.com/forbole/juno/v4 => github.com/bnb-chain/juno/v4 v4.0.0-20230323095415-6b0a61c851ae
github.com/gogo/protobuf => github.com/regen-network/protobuf v1.3.3-alpha.regen.1
github.com/tendermint/tendermint => github.com/bnb-chain/gnfd-tendermint v0.0.2
)

require (
cosmossdk.io/math v1.0.0-beta.6
github.com/aws/aws-sdk-go v1.44.159
github.com/bnb-chain/greenfield v0.0.7
github.com/bnb-chain/greenfield v0.0.9
github.com/bnb-chain/greenfield-common/go v0.0.0-20230310033112-2d379fdc2987
github.com/bnb-chain/greenfield-go-sdk v0.0.0-20230314083410-f0d6dbbec179
github.com/bnb-chain/greenfield-go-sdk v0.0.7
github.com/bytedance/gopkg v0.0.0-20221122125632-68358b8ecec6
github.com/cloudflare/cfssl v1.6.3
github.com/cosmos/cosmos-sdk v0.46.7
Expand Down
12 changes: 6 additions & 6 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -212,14 +212,14 @@ github.com/bnb-chain/greenfield v0.0.9 h1:nU3TgGloyysyyrbW/t9X2gdEvllxfIBudhuOdZ
github.com/bnb-chain/greenfield v0.0.9/go.mod h1:uH3iyy7RfTaO+qM34AF1XN4CrCPcoUSTJs3zvaIWIf4=
github.com/bnb-chain/greenfield-common/go v0.0.0-20230310033112-2d379fdc2987 h1:+SOlI4dfp5y/2srTBdAEOujoJboMx+m22zvj5xuBLgU=
github.com/bnb-chain/greenfield-common/go v0.0.0-20230310033112-2d379fdc2987/go.mod h1:Nzpqn+BK8P1Ub3Tgn300bHmWMUk9R6cBwvmasVY25J8=
github.com/bnb-chain/greenfield-cosmos-sdk v0.0.2-0.20230316090342-debd6c0c82a7 h1:CRZHHzInXLUvulik180alYKa2omtu+rCwk2q+J2h02w=
github.com/bnb-chain/greenfield-cosmos-sdk v0.0.2-0.20230316090342-debd6c0c82a7/go.mod h1:C0poOez5FBpH4Y/oa9jmco2fRojeMsJZGOZEX+GOv8w=
github.com/bnb-chain/greenfield-cosmos-sdk v0.0.11 h1:8Vb57cJUoMVv9EL5ce43V8ZCPOvjNjrxs9+KyJw6JOg=
github.com/bnb-chain/greenfield-cosmos-sdk v0.0.11/go.mod h1:C0poOez5FBpH4Y/oa9jmco2fRojeMsJZGOZEX+GOv8w=
github.com/bnb-chain/greenfield-cosmos-sdk/math v0.0.0-20230228075616-68ac309b432c h1:BLmdYaj7Dx0YOhfk77+KPPJSMCwpQl6f4Y30+801bf0=
github.com/bnb-chain/greenfield-cosmos-sdk/math v0.0.0-20230228075616-68ac309b432c/go.mod h1:u/MXvf8wbUbCsAEyQSSYXXMsczAsFX48e2D6JI86T4o=
github.com/bnb-chain/greenfield-go-sdk v0.0.0-20230314083410-f0d6dbbec179 h1:9WC+Wl/6BOrhXi9/OxSC7N7R3FLuvLfy9eLkGIo8UGM=
github.com/bnb-chain/greenfield-go-sdk v0.0.0-20230314083410-f0d6dbbec179/go.mod h1:FwNxlpMZfHvs/oKt4vJttgsEkxSyjou6IUG42Nu/zD0=
github.com/bnb-chain/juno/v4 v4.0.0-20230315120403-3093b5ed5267 h1:HCDTRmGYyP4Fj5PRjmVwfbw2CXon431D0Tnpl03u23E=
github.com/bnb-chain/juno/v4 v4.0.0-20230315120403-3093b5ed5267/go.mod h1:oQZkgavrYEz5hPchQg7TO4kK68PhyFIs0F3s5ev60bY=
github.com/bnb-chain/greenfield-go-sdk v0.0.7 h1:uqsZClp8/CdsWxaTSA9ed0JlfNcwMFUXDdua52ry35w=
github.com/bnb-chain/greenfield-go-sdk v0.0.7/go.mod h1:0/EP4qwa/8Ok87tHGrk8k/hakxMKsYLA75DD+jd+aTE=
github.com/bnb-chain/juno/v4 v4.0.0-20230323095415-6b0a61c851ae h1:26GOg5sArORy1viLIWdAElG30S9e+9c3QzKcuZUuhHA=
github.com/bnb-chain/juno/v4 v4.0.0-20230323095415-6b0a61c851ae/go.mod h1:K7eL/kwPovSav7UYxoP1nWEF6QKabm3DEWneclV5Pf0=
github.com/boltdb/bolt v1.3.1/go.mod h1:clJnj/oiGkjum5o1McbSZDSLxVThjynRyGBgiAx27Ps=
github.com/bradfitz/go-smtpd v0.0.0-20170404230938-deb6d6237625/go.mod h1:HYsPBTaaSFSlLx/70C2HPIMNZpVV8+vt/A+FMnYP11g=
github.com/bradfitz/gomemcache v0.0.0-20170208213004-1952afaa557d/go.mod h1:PmM6Mmwb0LSuEubjR8N7PtNe1KxZLtOUHtbeikc5h60=
Expand Down
1 change: 1 addition & 0 deletions service/blocksyncer/block_syncer.go
Original file line number Diff line number Diff line change
Expand Up @@ -96,6 +96,7 @@ func (s *BlockSyncer) initDB() error {
if module, ok := module.(modules.PrepareTablesModule); ok {
err = module.PrepareTables()
if err != nil {
log.Errorw("failed to prepare tables", "error", err)
return err
}
}
Expand Down
34 changes: 23 additions & 11 deletions service/blocksyncer/block_syncer_indexer.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,11 +4,12 @@ import (
"context"
"encoding/json"

"github.com/forbole/juno/v4/common"

"github.com/bnb-chain/greenfield-storage-provider/pkg/log"

"github.com/cosmos/cosmos-sdk/codec"
sdk "github.com/cosmos/cosmos-sdk/types"
"github.com/ethereum/go-ethereum/common"
"github.com/forbole/juno/v4/database"
"github.com/forbole/juno/v4/models"
"github.com/forbole/juno/v4/modules"
Expand Down Expand Up @@ -42,12 +43,13 @@ func (i *Impl) ExportBlock(block *coretypes.ResultBlock, events *coretypes.Resul
}

// HandleEvent accepts the transaction and handles events contained inside the transaction.
func (i *Impl) HandleEvent(ctx context.Context, block *coretypes.ResultBlock, index int, event sdk.Event) {
func (i *Impl) HandleEvent(ctx context.Context, block *coretypes.ResultBlock, event sdk.Event) {
for _, module := range i.Modules {
if eventModule, ok := module.(modules.EventModule); ok {
err := eventModule.HandleEvent(ctx, block, index, event)
log.Infof("module name :%s event type: %s, height: %d", module.Name(), event.Type, block.Block.Height)
err := eventModule.HandleEvent(ctx, block, event)
if err != nil {
log.Errorw("failed to handle event", "module", module, "event", event, "error", err)
log.Errorw("failed to handle event", "module", module.Name(), "event", event, "error", err)
}
}
}
Expand Down Expand Up @@ -89,7 +91,7 @@ func (i *Impl) Process(height uint64) error {
func (i *Impl) ExportEpoch(block *coretypes.ResultBlock) error {
// Save the block
err := i.DB.SaveEpoch(context.Background(), &models.Epoch{
ID: 1,
OneRowId: true,
BlockHeight: block.Block.Height,
BlockHash: common.HexToHash(block.BlockID.Hash.String()),
UpdateTime: block.Block.Time.Unix(),
Expand All @@ -104,7 +106,7 @@ func (i *Impl) ExportEpoch(block *coretypes.ResultBlock) error {

// ExportTxs accepts a slice of transactions and persists then inside the database.
// An error is returned if write fails.
func (i *Impl) ExportTxs(txs []*types.Tx) error {
func (i *Impl) ExportTxs(block *coretypes.ResultBlock, txs []*types.Tx) error {
return nil
}

Expand All @@ -131,10 +133,9 @@ func (i *Impl) ExportEvents(ctx context.Context, block *coretypes.ResultBlock, e
// get all events in order from the txs within the block
for _, tx := range events.TxsResults {
// handle all events contained inside the transaction
events := filterEventsByType(tx)
// call the event handlers
for idx, event := range events {
i.HandleEvent(ctx, block, idx, event)
for _, event := range tx.Events {
i.HandleEvent(ctx, block, sdk.Event(event))
}
}
return nil
Expand All @@ -159,10 +160,21 @@ func (i *Impl) HandleBlock(block *coretypes.ResultBlock, events *coretypes.Resul

// HandleTx accepts the transaction and calls the tx handlers.
func (i *Impl) HandleTx(tx *types.Tx) {
log.Infof("HandleTx")
log.Info("HandleTx")
}

// HandleMessage accepts the transaction and handles messages contained inside the transaction.
func (i *Impl) HandleMessage(index int, msg sdk.Msg, tx *types.Tx) {
log.Infof("HandleMessage")
log.Info("HandleMessage")
}

// Processed tells whether the current Indexer has already processed the given height of Block
// An error is returned if the operation fails.
func (i *Impl) Processed(ctx context.Context, height uint64) (bool, error) {
ep, err := i.DB.GetEpoch(context.Background())
if err != nil {
return false, err
}
log.Infof("epoch height:%d, cur height: %d", ep.BlockHeight, height)
return ep.BlockHeight > int64(height), nil
}
17 changes: 0 additions & 17 deletions service/blocksyncer/block_syncer_service.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,14 +8,9 @@ import (

"github.com/bnb-chain/greenfield-storage-provider/pkg/log"

sdk "github.com/cosmos/cosmos-sdk/types"

"github.com/forbole/juno/v4/parser"
"github.com/forbole/juno/v4/types"
"github.com/forbole/juno/v4/types/config"
eventutil "github.com/forbole/juno/v4/types/event"

abci "github.com/tendermint/tendermint/abci/types"
)

// enqueueMissingBlocks enqueues jobs (block heights) for missed blocks starting
Expand Down Expand Up @@ -71,15 +66,3 @@ func mustGetLatestHeight(ctx *parser.Context) uint64 {

return 0
}

// filterEventsByType filter the event by types we are interested in.
// Current we handle storage/payment/permission related events.
func filterEventsByType(tx *abci.ResponseDeliverTx) []sdk.Event {
filteredEvents := make([]sdk.Event, 0)
for _, event := range tx.Events {
if _, ok := eventutil.EventProcessedMap[event.Type]; ok {
filteredEvents = append(filteredEvents, sdk.Event(event))
}
}
return filteredEvents
}

0 comments on commit c6ebd0b

Please sign in to comment.