Skip to content

Commit

Permalink
fix: fix lint bugs
Browse files Browse the repository at this point in the history
  • Loading branch information
trestinlsd committed Apr 11, 2024
1 parent b52cda6 commit 417f4f1
Show file tree
Hide file tree
Showing 31 changed files with 131 additions and 143 deletions.
11 changes: 6 additions & 5 deletions app/app.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,15 +4,16 @@ import (
"context"
"encoding/json"
"fmt"
"github.com/ExocoreNetwork/exocore/x/avs_task"
avsTaskKeeper "github.com/ExocoreNetwork/exocore/x/avs_task/keeper"
avsTaskTypes "github.com/ExocoreNetwork/exocore/x/avs_task/types"
"io"
"net/http"
"os"
"path/filepath"
"sort"

"github.com/ExocoreNetwork/exocore/x/avstask"
avsTaskKeeper "github.com/ExocoreNetwork/exocore/x/avstask/keeper"
avsTaskTypes "github.com/ExocoreNetwork/exocore/x/avstask/types"

"github.com/ExocoreNetwork/exocore/x/avs"
"github.com/ExocoreNetwork/exocore/x/operator"
operatorKeeper "github.com/ExocoreNetwork/exocore/x/operator/keeper"
Expand Down Expand Up @@ -277,7 +278,7 @@ var (
reward.AppModuleBasic{},
exoslash.AppModuleBasic{},
avs.AppModuleBasic{},
avs_task.AppModuleBasic{},
avstask.AppModuleBasic{},
)

// module account permissions
Expand Down Expand Up @@ -853,7 +854,7 @@ func NewExocoreApp(
reward.NewAppModule(appCodec, app.RewardKeeper),
exoslash.NewAppModule(appCodec, app.ExoSlashKeeper),
avs.NewAppModule(appCodec, app.AVSManagerKeeper),
avs_task.NewAppModule(appCodec, app.TaskKeeper),
avstask.NewAppModule(appCodec, app.TaskKeeper),
)

// During begin block slashing happens after reward.BeginBlocker so that
Expand Down
2 changes: 1 addition & 1 deletion go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ require (
github.com/armon/go-metrics v0.4.1
github.com/cometbft/cometbft v0.37.2
github.com/cometbft/cometbft-db v0.8.0
github.com/cosmos/btcutil v1.0.5
github.com/cosmos/cosmos-proto v1.0.0-beta.3
github.com/cosmos/cosmos-sdk v0.47.5
github.com/cosmos/go-bip39 v1.0.0
Expand Down Expand Up @@ -83,7 +84,6 @@ require (
github.com/cockroachdb/apd/v2 v2.0.2 // indirect
github.com/coinbase/rosetta-sdk-go/types v1.0.0 // indirect
github.com/confio/ics23/go v0.9.0 // indirect
github.com/cosmos/btcutil v1.0.5 // indirect
github.com/cosmos/gogogateway v1.2.0 // indirect
github.com/cosmos/iavl v0.20.0 // indirect
github.com/cosmos/ics23/go v0.10.0 // indirect
Expand Down
8 changes: 4 additions & 4 deletions precompiles/avsTask/avsTask.sol
Original file line number Diff line number Diff line change
Expand Up @@ -16,9 +16,9 @@ IAVSTask constant AVSTASK_CONTRACT = IAVSTask(
interface IAVSTask {
/// TRANSACTIONS
/// @dev IAVSTask the oprator, that will change the state in AVSTask module
/// @param TaskContractAddress task Contract Address
/// @param Name task name
/// @param MetaInfo task desc
/// @param TaskContractAddress avstask Contract Address
/// @param Name avstask name
/// @param MetaInfo avstask desc
function registerAVSTask(
string memory TaskContractAddress,
string memory Name,
Expand All @@ -40,7 +40,7 @@ interface IAVSTask {
function getRegisteredPubkey(address operator) external returns (bytes32);

/// TRANSACTIONS
/// @dev Get the count of the current task
/// @dev Get the count of the current avstask
function checkSignatures(
bytes32 msgHash,
bytes calldata signature,
Expand Down
2 changes: 1 addition & 1 deletion precompiles/avsTask/events.go
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ import (
)

const (
// EventTypeNewTaskCreated defines the event type for the task create transaction.
// EventTypeNewTaskCreated defines the event type for the avstask create transaction.
EventTypeNewPubkeyRegistration = "NewPubkeyRegistration"
)

Expand Down
19 changes: 10 additions & 9 deletions precompiles/avsTask/methods.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ package task

import (
"fmt"

exocmn "github.com/ExocoreNetwork/exocore/precompiles/common"
"github.com/cosmos/btcutil/bech32"
sdk "github.com/cosmos/cosmos-sdk/types"
Expand All @@ -13,15 +14,15 @@ import (
)

const (
// MethodRegisterAVSTask defines the ABI method name for the task
// MethodRegisterAVSTask defines the ABI method name for the avstask
// transaction.
MethodRegisterAVSTask = "registerAVSTask"
MethodRegisterBLSPublicKey = "registerBLSPublicKey"
MethodIGetRegisteredPubkey = "getRegisteredPubkey"
MethodICheckSignatures = "checkSignatures"
)

// RegisterAVSTask Middleware uses exocore's default task template to create tasks in task module.
// RegisterAVSTask Middleware uses exocore's default avstask template to create tasks in avstask module.
func (p Precompile) RegisterAVSTask(
ctx sdk.Context,
_ common.Address,
Expand Down Expand Up @@ -62,13 +63,13 @@ func (p Precompile) RegisterBLSPublicKey(
}

addr, ok := args[0].(string)
if !ok {
return nil, xerrors.Errorf(exocmn.ErrContractInputParaOrType, 0, "string")
if !ok || addr == "" {
return nil, xerrors.Errorf(exocmn.ErrContractInputParaOrType, 0, "string", addr)
}

pubkeyBz, ok := args[1].([]byte)
if !ok {
return nil, xerrors.Errorf(exocmn.ErrContractInputParaOrType, 0, "string")
return nil, xerrors.Errorf(exocmn.ErrContractInputParaOrType, 0, "[]byte", pubkeyBz)
}

err := p.taskKeeper.SetOperatorPubKey(ctx, addr, pubkeyBz)
Expand All @@ -87,8 +88,8 @@ func (p Precompile) RegisterBLSPublicKey(
}

func (p Precompile) CheckSignatures(
ctx sdk.Context,
contract *vm.Contract,
_ sdk.Context,
_ *vm.Contract,
method *abi.Method,
args []interface{},
) ([]byte, error) {
Expand All @@ -101,7 +102,7 @@ func (p Precompile) CheckSignatures(
// GetRegisteredPubkey
func (p Precompile) GetRegisteredPubkey(
ctx sdk.Context,
contract *vm.Contract,
_ *vm.Contract,
method *abi.Method,
args []interface{},
) ([]byte, error) {
Expand All @@ -111,7 +112,7 @@ func (p Precompile) GetRegisteredPubkey(

addr, ok := args[0].(string)
if !ok {
return nil, xerrors.Errorf(exocmn.ErrContractInputParaOrType, 0, "string")
return nil, xerrors.Errorf(exocmn.ErrContractInputParaOrType, 0, "string", addr)
}

pubkey, err := p.taskKeeper.GetOperatorPubKey(ctx, addr)
Expand Down
5 changes: 3 additions & 2 deletions precompiles/avsTask/parser.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,14 +2,15 @@ package task

import (
"fmt"

exocmn "github.com/ExocoreNetwork/exocore/precompiles/common"
types "github.com/ExocoreNetwork/exocore/x/avs_task/types"
types "github.com/ExocoreNetwork/exocore/x/avstask/types"
sdk "github.com/cosmos/cosmos-sdk/types"
cmn "github.com/evmos/evmos/v14/precompiles/common"
"golang.org/x/xerrors"
)

func (p Precompile) GetTaskParamsFromInputs(ctx sdk.Context, args []interface{}) (*types.RegisterAVSTaskReq, error) {
func (p Precompile) GetTaskParamsFromInputs(_ sdk.Context, args []interface{}) (*types.RegisterAVSTaskReq, error) {
if len(args) != 3 {
return nil, fmt.Errorf(cmn.ErrInvalidNumberOfArgs, 3, len(args))
}
Expand Down
3 changes: 2 additions & 1 deletion precompiles/avsTask/setup_test.go
Original file line number Diff line number Diff line change
@@ -1,9 +1,10 @@
package task_test

import (
"testing"

"github.com/ExocoreNetwork/exocore/precompiles/avsTask"
"github.com/ExocoreNetwork/exocore/testutil"
"testing"

. "github.com/onsi/ginkgo/v2"
. "github.com/onsi/gomega"
Expand Down
15 changes: 8 additions & 7 deletions precompiles/avsTask/task.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,9 @@ import (
"bytes"
"embed"
"fmt"

"github.com/ExocoreNetwork/exocore/x/avs/keeper"
taskKeeper "github.com/ExocoreNetwork/exocore/x/avs_task/keeper"
taskKeeper "github.com/ExocoreNetwork/exocore/x/avstask/keeper"
"github.com/cometbft/cometbft/libs/log"
storetypes "github.com/cosmos/cosmos-sdk/store/types"
sdk "github.com/cosmos/cosmos-sdk/types"
Expand All @@ -23,14 +24,14 @@ var _ vm.PrecompiledContract = &Precompile{}
//go:embed abi.json
var f embed.FS

// Precompile defines the precompiled contract for task.
// Precompile defines the precompiled contract for avstask.
type Precompile struct {
cmn.Precompile
taskKeeper taskKeeper.Keeper
avsKeeper keeper.Keeper
}

// NewPrecompile creates a new task Precompile instance as a
// NewPrecompile creates a new avstask Precompile instance as a
// PrecompiledContract interface.
func NewPrecompile(
authzKeeper authzkeeper.Keeper,
Expand All @@ -39,7 +40,7 @@ func NewPrecompile(
) (*Precompile, error) {
abiBz, err := f.ReadFile("abi.json")
if err != nil {
return nil, fmt.Errorf("error loading the task ABI %s", err)
return nil, fmt.Errorf("error loading the avstask ABI %s", err)
}

newAbi, err := abi.JSON(bytes.NewReader(abiBz))
Expand All @@ -60,7 +61,7 @@ func NewPrecompile(
}, nil
}

// Address defines the address of the task compile contract.
// Address defines the address of the avstask compile contract.
// address: 0x0000000000000000000000000000000000000901
func (p Precompile) Address() common.Address {
return common.HexToAddress("0x0000000000000000000000000000000000000901")
Expand Down Expand Up @@ -116,7 +117,7 @@ func (p Precompile) Run(evm *vm.EVM, contract *vm.Contract, readOnly bool) (bz [

// IsTransaction checks if the given methodID corresponds to a transaction or query.
//
// Available task transactions are:
// Available avstask transactions are:
func (Precompile) IsTransaction(methodID string) bool {
switch methodID {
case MethodRegisterAVSTask:
Expand All @@ -128,5 +129,5 @@ func (Precompile) IsTransaction(methodID string) bool {

// Logger returns a precompile-specific logger.
func (p Precompile) Logger(ctx sdk.Context) log.Logger {
return ctx.Logger().With("ExoCore module", "task")
return ctx.Logger().With("ExoCore module", "avstask")
}
11 changes: 6 additions & 5 deletions precompiles/avsTask/task_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@ package task_test

import (
"encoding/hex"
"math/big"

"github.com/ExocoreNetwork/exocore/app"
"github.com/ExocoreNetwork/exocore/precompiles/avsTask"
"github.com/cosmos/btcutil/bech32"
Expand All @@ -10,7 +12,6 @@ import (
"github.com/ethereum/go-ethereum/core/vm"
"github.com/evmos/evmos/v14/x/evm/statedb"
evmtypes "github.com/evmos/evmos/v14/x/evm/types"
"math/big"
)

func (s *TaskPrecompileTestSuite) TestIsTransaction() {
Expand Down Expand Up @@ -38,7 +39,7 @@ func (s *TaskPrecompileTestSuite) TestIsTransaction() {
}
}

// TestRun tests the precompiles Run method reg task.
// TestRun tests the precompiles Run method reg avstask.
func (s *TaskPrecompileTestSuite) TestRunRegTaskinfo() {
avsName, avsAddres, operatorAddress, assetID := "avsTest", "exo13h6xg79g82e2g2vhjwg7j4r2z2hlncelwutkjr", "exo18h6xg79g82e2g2vhjwg7j4r2z2hlncelwutkjr", ""
_, byteData, _ := bech32.DecodeToBase256(avsAddres)
Expand All @@ -51,8 +52,8 @@ func (s *TaskPrecompileTestSuite) TestRunRegTaskinfo() {
input, err := s.precompile.Pack(
task.MethodRegisterAVSTask,
"exo1j9ly7f0jynscjgvct0enevaa659te58k3xztc8",
"test-task",
"test-task-url",
"test-avstask",
"test-avstask-url",
)
s.Require().NoError(err, "failed to pack input")
return common.HexToAddress(caller), input
Expand All @@ -68,7 +69,7 @@ func (s *TaskPrecompileTestSuite) TestRunRegTaskinfo() {
returnBytes []byte
}{
{
name: "pass - task via pre-compiles",
name: "pass - avstask via pre-compiles",
malleate: func() (common.Address, []byte) {
s.Require().NoError(err)
registerAvs()
Expand Down
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
syntax = "proto3";
package exocore.task.v1;
package exocore.avstask.v1;

import "cosmos_proto/cosmos.proto";
import "exocore/task/v1/tx.proto";
import "exocore/avstask/v1/tx.proto";
import "google/api/annotations.proto";

option go_package = "github.com/ExocoreNetwork/exocore/x/avs_task/types";
option go_package = "github.com/ExocoreNetwork/exocore/x/avstask/types";

// QueryAVSTaskInfoReq is the request to obtain the task information.
message GetAVSTaskInfoReq {
Expand All @@ -19,6 +19,6 @@ message GetAVSTaskInfoReq {
service Query {
// TaskInfo queries the task information.
rpc GetAVSTaskInfo(GetAVSTaskInfoReq) returns(TaskContractInfo){
option (google.api.http).get = "/exocore/task/v1/GetAVSTaskInfoReq";
option (google.api.http).get = "/exocore/avstask/v1/GetAVSTaskInfoReq";
}
}
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
syntax = "proto3";
package exocore.task.v1;
package exocore.avstask.v1;

import "amino/amino.proto";
import "cosmos/msg/v1/msg.proto";
import "cosmos_proto/cosmos.proto";
import "gogoproto/gogo.proto";

option go_package = "github.com/ExocoreNetwork/exocore/x/avs_task/types";
option go_package = "github.com/ExocoreNetwork/exocore/x/avstask/types";
// TaskContractInfo is the task info.
message TaskContractInfo {
string task_contract_address = 1;
Expand Down
23 changes: 9 additions & 14 deletions x/avs_task/client/cli/query.go → x/avstask/client/cli/query.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,26 +3,21 @@ package cli
import (
"context"
"fmt"
tasktypes "github.com/ExocoreNetwork/exocore/x/avs_task/types"
"github.com/cosmos/cosmos-sdk/client/flags"

// "strings"
avstasktypes "github.com/ExocoreNetwork/exocore/x/avstask/types"
"github.com/cosmos/cosmos-sdk/client/flags"

"github.com/spf13/cobra"

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

"github.com/ExocoreNetwork/exocore/x/avs_task/types"
)

// GetQueryCmd returns the cli query commands for this module

func GetQueryCmd() *cobra.Command {
cmd := &cobra.Command{
Use: types.ModuleName,
Short: fmt.Sprintf("Querying commands for the %s module", types.ModuleName),
Use: avstasktypes.ModuleName,
Short: fmt.Sprintf("Querying commands for the %s module", avstasktypes.ModuleName),
DisableFlagParsing: true,
SuggestionsMinimumDistance: 2,
RunE: client.ValidateCmd,
Expand All @@ -35,18 +30,18 @@ func GetQueryCmd() *cobra.Command {
// GetTaskInfo queries operator info
func GetTaskInfo() *cobra.Command {
cmd := &cobra.Command{
Use: "GetTaskInfo task info",
Short: "Get task info",
Long: "Get task info",
Use: "GetTaskInfo avstask info",
Short: "Get avstask info",
Long: "Get avstask info",
Args: cobra.ExactArgs(1),
RunE: func(cmd *cobra.Command, args []string) error {
clientCtx, err := client.GetClientQueryContext(cmd)
if err != nil {
return err
}

queryClient := tasktypes.NewQueryClient(clientCtx)
req := &tasktypes.GetAVSTaskInfoReq{
queryClient := avstasktypes.NewQueryClient(clientCtx)
req := &avstasktypes.GetAVSTaskInfoReq{
TaskAddr: args[0],
}
res, err := queryClient.GetAVSTaskInfo(context.Background(), req)
Expand Down
Loading

0 comments on commit 417f4f1

Please sign in to comment.