Skip to content

Commit

Permalink
fix: added back authz message handler in worker (#121)
Browse files Browse the repository at this point in the history
<!-- < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < ☺
v                               ✰  Thanks for creating a PR! ✰
v    Before smashing the submit button please review the checkboxes.
v If a checkbox is n/a - please still include it but + a little note why
☺ > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > >  -->

## Description
<!-- Small description -->
This PR added back missing authz message handler in worker.

## Checklist
- [ ] Targeted PR against correct branch.
- [ ] Linked to Github issue with discussion and accepted design OR link
to spec that describes this work.
- [ ] Wrote unit tests.
- [ ] Re-reviewed `Files changed` in the Github PR explorer.

(cherry picked from commit 7327795)

# Conflicts:
#	node/builder/builder.go
#	types/config/config.go
  • Loading branch information
dadamu authored and mergify[bot] committed Jun 24, 2024
1 parent e0578b0 commit 433ce0d
Show file tree
Hide file tree
Showing 5 changed files with 56 additions and 5 deletions.
10 changes: 9 additions & 1 deletion .mergify.yml
Original file line number Diff line number Diff line change
Expand Up @@ -15,4 +15,12 @@ pull_request_rules:
commit_message_template: >
{{ title }} (#{{ number }})
{{ body }}
{{ body }}
- name: backport patches to v0.47.x branch
conditions:
- base=cosmos/v0.50.x
- label=backport/v0.47.x
actions:
backport:
branches:
- cosmos/v0.47.x
5 changes: 1 addition & 4 deletions modules/module.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,11 +4,8 @@ import (
"encoding/json"
"strings"

"github.com/cosmos/cosmos-sdk/x/authz"

tmctypes "github.com/cometbft/cometbft/rpc/core/types"
tmtypes "github.com/cometbft/cometbft/types"
sdk "github.com/cosmos/cosmos-sdk/types"
"github.com/go-co-op/gocron"

"github.com/forbole/juno/v5/types"
Expand Down Expand Up @@ -106,5 +103,5 @@ type AuthzMessageModule interface {
// are passed as well.
// NOTE. The returned error will be logged using the MsgError method. All other modules' handlers
// will still be called.
HandleMsgExec(index int, msgExec *authz.MsgExec, authzMsgIndex int, executedMsg sdk.Msg, tx *types.Transaction) error
HandleMsgExec(index int, authzMsgIndex int, executedMsg types.Message, tx *types.Transaction) error
}
8 changes: 8 additions & 0 deletions node/builder/builder.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,10 +5,18 @@ import (

"github.com/cosmos/cosmos-sdk/client"
"github.com/cosmos/cosmos-sdk/codec"
<<<<<<< HEAD

Check failure on line 8 in node/builder/builder.go

View workflow job for this annotation

GitHub Actions / golangci-lint

missing import path (typecheck)

Check failure on line 8 in node/builder/builder.go

View workflow job for this annotation

GitHub Actions / Unit-tests

missing import path
"github.com/forbole/juno/v5/node"
nodeconfig "github.com/forbole/juno/v5/node/config"
"github.com/forbole/juno/v5/node/local"
"github.com/forbole/juno/v5/node/remote"
=======

Check failure on line 13 in node/builder/builder.go

View workflow job for this annotation

GitHub Actions / golangci-lint

missing import path (typecheck)

"github.com/forbole/juno/v6/node"
nodeconfig "github.com/forbole/juno/v6/node/config"
"github.com/forbole/juno/v6/node/local"
"github.com/forbole/juno/v6/node/remote"
>>>>>>> 7327795 (fix: added back authz message handler in worker (#121))

Check failure on line 19 in node/builder/builder.go

View workflow job for this annotation

GitHub Actions / golangci-lint

missing import path (typecheck)
)

func BuildNode(cfg nodeconfig.Config, txConfig client.TxConfig, codec codec.Codec) (node.Node, error) {
Expand Down
29 changes: 29 additions & 0 deletions parser/worker.go
Original file line number Diff line number Diff line change
Expand Up @@ -295,6 +295,35 @@ func (w Worker) handleMessage(index int, msg types.Message, tx *types.Transactio
w.logger.MsgError(module, tx, msg, err)
}
}

// If it's a MsgExecute, we need to make sure the included messages are handled as well
if msg.GetType() == "/cosmos.authz.v1beta1.MsgExec" {
var msgExec struct {
Msgs []json.RawMessage `json:"msgs"`
}

err := json.Unmarshal(msg.GetBytes(), &msgExec)
if err != nil {
w.logger.Error("unable to unmarshal MsgExec inner messages", "error", err)
return
}

for authzIndex, msgAny := range msgExec.Msgs {
executedMsg, err := types.UnmarshalMessage(authzIndex, msgAny)
if err != nil {
w.logger.Error("unable to unpack MsgExec inner message", "index", authzIndex, "error", err)
}

for _, module := range w.modules {
if messageModule, ok := module.(modules.AuthzMessageModule); ok {
err = messageModule.HandleMsgExec(index, authzIndex, executedMsg, tx)
if err != nil {
w.logger.MsgError(module, tx, executedMsg, err)
}
}
}
}
}
}
}

Expand Down
9 changes: 9 additions & 0 deletions types/config/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,11 +3,20 @@ package config
import (
"strings"

<<<<<<< HEAD

Check failure on line 6 in types/config/config.go

View workflow job for this annotation

GitHub Actions / golangci-lint

missing import path (typecheck)

Check failure on line 6 in types/config/config.go

View workflow job for this annotation

GitHub Actions / Unit-tests

missing import path
databaseconfig "github.com/forbole/juno/v5/database/config"
loggingconfig "github.com/forbole/juno/v5/logging/config"
nodeconfig "github.com/forbole/juno/v5/node/config"
parserconfig "github.com/forbole/juno/v5/parser/config"
"gopkg.in/yaml.v3"
=======

Check failure on line 12 in types/config/config.go

View workflow job for this annotation

GitHub Actions / golangci-lint

missing import path (typecheck)
"gopkg.in/yaml.v3"

databaseconfig "github.com/forbole/juno/v6/database/config"
loggingconfig "github.com/forbole/juno/v6/logging/config"
nodeconfig "github.com/forbole/juno/v6/node/config"
parserconfig "github.com/forbole/juno/v6/parser/config"
>>>>>>> 7327795 (fix: added back authz message handler in worker (#121))

Check failure on line 19 in types/config/config.go

View workflow job for this annotation

GitHub Actions / golangci-lint

missing import path (typecheck)
)

var (

Check failure on line 22 in types/config/config.go

View workflow job for this annotation

GitHub Actions / golangci-lint

missing import path (typecheck)
Expand Down

0 comments on commit 433ce0d

Please sign in to comment.