-
Notifications
You must be signed in to change notification settings - Fork 10
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
Conversation
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
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
|
||
import ( | ||
"fmt" | ||
"reflect" |
Check failure
Code scanning / gosec
Blocklisted import runtime Error
|
||
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
|
||
import ( | ||
"fmt" | ||
"reflect" |
Check notice
Code scanning / CodeQL
Sensitive package import Note
} | ||
records, err := k.SetTaskforAvs(ctx, &task) | ||
if err != nil { | ||
panic(err) |
Check warning
Code scanning / CodeQL
Panic in BeginBock or EndBlock consensus methods Warning
} | ||
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
return true, nil | ||
} | ||
|
||
type CreateNewTaskParams struct { |
There was a problem hiding this comment.
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 { |
There was a problem hiding this comment.
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
|
||
// 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
Address: p.Address(), | ||
Topics: topics, | ||
Data: packed, | ||
BlockNumber: uint64(ctx.BlockHeight()), |
Check failure
Code scanning / gosec
Potential integer overflow by integer type conversion Error
|
||
import ( | ||
"fmt" | ||
"reflect" |
Check failure
Code scanning / gosec
Blocklisted import runtime Error
|
||
import ( | ||
"fmt" | ||
"reflect" |
Check notice
Code scanning / CodeQL
Sensitive package import Note
} | ||
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
/// @dev The interface through which solidity contracts will interact with AVSTask | ||
/// @custom:address 0x0000000000000000000000000000000000000901 | ||
struct Task { | ||
uint256 numberToBeSquared; |
There was a problem hiding this comment.
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; |
There was a problem hiding this comment.
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) |
There was a problem hiding this comment.
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; |
There was a problem hiding this comment.
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) |
There was a problem hiding this comment.
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)() |
There was a problem hiding this comment.
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), |
There was a problem hiding this comment.
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
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
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{} |
There was a problem hiding this comment.
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?
Description
Add task manager to manage task with exocore chain