Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: add task manager #20

Closed
wants to merge 10 commits into from
Closed

feat: add task manager #20

wants to merge 10 commits into from

Conversation

trestinlsd
Copy link
Contributor

@trestinlsd trestinlsd commented Mar 25, 2024

Description

Add task manager to manage task with exocore chain


@trestinlsd trestinlsd changed the base branch from main to develop March 25, 2024 00:49
task := types.TaskInstance{
NumberToBeSquared: params.NumberToBeSquared,
QuorumThresholdPercentage: uint64(params.QuorumThresholdPercentage),
TaskCreatedBlock: uint64(params.TaskCreatedBlock),

Check failure

Code scanning / gosec

Potential integer overflow by integer type conversion Error

Potential integer overflow by integer type conversion
Task: &taskTypes.TaskContractInfo{
Name: args[0],
MetaInfo: args[1],
TaskContractId: uint64(taskId),

Check failure

Code scanning / gosec

Potential integer overflow by integer type conversion Error

Potential integer overflow by integer type conversion

import (
"fmt"
"reflect"

Check failure

Code scanning / gosec

Blocklisted import runtime Error

Blocklisted import reflect

func (k *Keeper) CreateNewTask(ctx sdk.Context, params *CreateNewTaskParams) (bool, error) {
// create a new task struct
k.SetTaskforAvs(ctx, params)

Check warning

Code scanning / gosec

Errors unhandled. Warning

Errors unhandled.

import (
"fmt"
"reflect"

Check notice

Code scanning / CodeQL

Sensitive package import Note

Certain system packages contain functions which may be a possible source of non-determinism
}
records, err := k.SetTaskforAvs(ctx, &task)
if err != nil {
panic(err)

Check warning

Code scanning / CodeQL

Panic in BeginBock or EndBlock consensus methods Warning

Possible panics in BeginBock- or EndBlock-related consensus methods could cause a chain halt
}
taskParams.NumberToBeSquared = uint64(numberToBeSquared)
taskParams.QuorumThresholdPercentage = args[1].(uint32)
qnums, ok := args[2].([]byte)

Check warning

Code scanning / CodeQL

Useless assignment to local variable Warning

This definition of ok is never used.
return true, nil
}

type CreateNewTaskParams struct {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The params struct should be defined in types/params.go

/// @title AVSTask Precompile Contract
/// @dev The interface through which solidity contracts will interact with AVSTask
/// @custom:address 0x0000000000000000000000000000000000000901
struct Task {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The line should be aligned


// String implements the Stringer interface.
func (p Params) String() string {
out, _ := yaml.Marshal(p)

Check warning

Code scanning / gosec

Returned error is not propagated up the stack. Warning

Returned error is not propagated up the stack.

// RegisterGRPCGatewayRoutes registers the gRPC Gateway routes for the module
func (AppModuleBasic) RegisterGRPCGatewayRoutes(clientCtx client.Context, mux *runtime.ServeMux) {
types.RegisterQueryHandlerClient(context.Background(), mux, types.NewQueryClient(clientCtx))

Check warning

Code scanning / gosec

Errors unhandled. Warning

Errors unhandled.
Address: p.Address(),
Topics: topics,
Data: packed,
BlockNumber: uint64(ctx.BlockHeight()),

Check failure

Code scanning / gosec

Potential integer overflow by integer type conversion Error

Potential integer overflow by integer type conversion

import (
"fmt"
"reflect"

Check failure

Code scanning / gosec

Blocklisted import runtime Error

Blocklisted import reflect

import (
"fmt"
"reflect"

Check notice

Code scanning / CodeQL

Sensitive package import Note

Certain system packages contain functions which may be a possible source of non-determinism
}
taskParams.NumberToBeSquared = uint64(numberToBeSquared)
taskParams.QuorumThresholdPercentage = args[1].(uint32)
qnums, ok := args[2].([]byte)

Check warning

Code scanning / CodeQL

Useless assignment to local variable Warning

This definition of ok is never used.
/// @dev The interface through which solidity contracts will interact with AVSTask
/// @custom:address 0x0000000000000000000000000000000000000901
struct Task {
uint256 numberToBeSquared;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is it a special task about calculating squared number? If not, why define the fields here.

// task is completed (and contract will accept its TaskResponse) when each quorumNumbers specified here
// are signed by at least quorumThresholdPercentage of the operators
// note that we set the quorumThresholdPercentage to be the same for all quorumNumbers, but this could be changed
bytes quorumNumbers;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What's the meaning of quorumNumbers, and why use bytes as the type?

return nil, fmt.Errorf(ErrNotYetRegistered, contract.CallerAddress)
}

return method.Outputs.Pack(true)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is this going to call the operator module to check if the operator has opted into the AVS? It seems to return true directly. Additionally, I am curious about why this interface needs to be provided in an AVSTask precompile contract.

pragma solidity >=0.8.17 .0;

/// @dev The BLS contract's address.
address constant BLS_PRECOMPILE_ADDRESS = 0x0000000000000000000000000000000000000902;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Same precompile contract address as AVS.

}
createNewTaskParams.ContractAddr = contract.CallerAddress.String()
createNewTaskParams.TaskCreatedBlock = ctx.BlockHeight()
_, err = p.taskKeeper.CreateNewTask(ctx, createNewTaskParams)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why does the implementation of RegisterBLSPublicKey need to create a task?

@@ -73,8 +72,7 @@ func (suite *BaseTestSuite) SetupTest() {
// of one consensus engine unit (10^6) in the default token of the simapp from first genesis
// account. A Nop logger is set in SimApp.
func (suite *BaseTestSuite) SetupWithGenesisValSet(valSet *tmtypes.ValidatorSet, genAccs []authtypes.GenesisAccount, balances ...banktypes.Balance) {
pruneOpts := pruningtypes.NewPruningOptionsFromString(pruningtypes.PruningOptionDefault)
appI, genesisState := exocoreapp.SetupTestingApp(utils.DefaultChainID, &pruneOpts, false)()
appI, genesisState := exocoreapp.SetupTestingApp(utils.DefaultChainID, false)()
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Removing the pruneOpts will cause a problem when performing tests related to getting the historical state.

cmd := &cobra.Command{
Use: "Set task params to taskManager module",
Short: "Set task params to taskManager module",
Args: cobra.ExactArgs(2),
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The exact argument number should be 4

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please use the generic basic test suit to reduce the redundant code.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The same comment as setup_test.go. This test file needs to be removed.

SpendableCoins(ctx sdk.Context, addr sdk.AccAddress) sdk.Coins
// Methods imported from bank should be defined here
}
type AvsKeeper struct{}
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is it a mock keeper for the test? If yes, please add some comments or rename it to be with mock. Will it be removed when it is integrated with the actual AVS keeper?

@mikebraver mikebraver mentioned this pull request Apr 9, 2024
@trestinlsd trestinlsd closed this Apr 10, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants