-
Notifications
You must be signed in to change notification settings - Fork 10
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat:Add implementation for task module
- Loading branch information
1 parent
3eb094d
commit 85151f0
Showing
37 changed files
with
3,691 additions
and
3 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,122 @@ | ||
[ | ||
{ | ||
"anonymous": false, | ||
"inputs": [ | ||
{ | ||
"indexed": true, | ||
"internalType": "address", | ||
"name": "operator", | ||
"type": "address" | ||
}, | ||
{ | ||
"indexed": false, | ||
"internalType": "bytes", | ||
"name": "pubkeyG1", | ||
"type": "bytes" | ||
} | ||
], | ||
"name": "NewPubkeyRegistration", | ||
"type": "event" | ||
}, | ||
{ | ||
"inputs": [ | ||
{ | ||
"internalType": "bytes32", | ||
"name": "msgHash", | ||
"type": "bytes32" | ||
}, | ||
{ | ||
"internalType": "bytes", | ||
"name": "signature", | ||
"type": "bytes" | ||
}, | ||
{ | ||
"internalType": "bytes", | ||
"name": "pubkey", | ||
"type": "bytes" | ||
} | ||
], | ||
"name": "checkSignatures", | ||
"outputs": [ | ||
{ | ||
"internalType": "bool", | ||
"name": "valid", | ||
"type": "bool" | ||
} | ||
], | ||
"stateMutability": "view", | ||
"type": "function" | ||
}, | ||
{ | ||
"inputs": [ | ||
{ | ||
"internalType": "address", | ||
"name": "operator", | ||
"type": "address" | ||
} | ||
], | ||
"name": "getRegisteredPubkey", | ||
"outputs": [ | ||
{ | ||
"internalType": "bytes32", | ||
"name": "", | ||
"type": "bytes32" | ||
} | ||
], | ||
"stateMutability": "nonpayable", | ||
"type": "function" | ||
}, | ||
{ | ||
"inputs": [ | ||
{ | ||
"internalType": "string", | ||
"name": "TaskContractAddress", | ||
"type": "string" | ||
}, | ||
{ | ||
"internalType": "string", | ||
"name": "Name", | ||
"type": "string" | ||
}, | ||
{ | ||
"internalType": "string", | ||
"name": "MetaInfo", | ||
"type": "string" | ||
} | ||
], | ||
"name": "registerAVSTask", | ||
"outputs": [ | ||
{ | ||
"internalType": "bool", | ||
"name": "success", | ||
"type": "bool" | ||
} | ||
], | ||
"stateMutability": "nonpayable", | ||
"type": "function" | ||
}, | ||
{ | ||
"inputs": [ | ||
{ | ||
"internalType": "string", | ||
"name": "operator", | ||
"type": "string" | ||
}, | ||
{ | ||
"internalType": "bytes", | ||
"name": "pubKey", | ||
"type": "bytes" | ||
} | ||
], | ||
"name": "registerBLSPublicKey", | ||
"outputs": [ | ||
{ | ||
"internalType": "bool", | ||
"name": "success", | ||
"type": "bool" | ||
} | ||
], | ||
"stateMutability": "nonpayable", | ||
"type": "function" | ||
} | ||
] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,53 @@ | ||
pragma solidity >=0.8.17 .0; | ||
|
||
/// @dev The AVSTask contract's address. | ||
address constant AVSTASK_PRECOMPILE_ADDRESS = 0x0000000000000000000000000000000000000901; | ||
|
||
/// @dev The AVSTask contract's instance. | ||
IAVSTask constant AVSTASK_CONTRACT = IAVSTask( | ||
AVSTASK_PRECOMPILE_ADDRESS | ||
); | ||
|
||
/// @author Exocore Team | ||
/// @title AVSTask Precompile Contract | ||
/// @dev The interface through which solidity contracts will interact with AVSTask | ||
/// @custom:address 0x0000000000000000000000000000000000000901 | ||
|
||
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 | ||
function registerAVSTask( | ||
string memory TaskContractAddress, | ||
string memory Name, | ||
string memory MetaInfo | ||
) external returns (bool success); | ||
|
||
/// TRANSACTIONS | ||
/// @dev Called by the avs manager service register an operator as the owner of a BLS public key. | ||
/// @param operator is the operator for whom the key is being registered | ||
/// @param pubKey the public keys of the operator | ||
function registerBLSPublicKey( | ||
string memory operator, | ||
bytes calldata pubKey | ||
) external returns (bool success); | ||
|
||
/// TRANSACTIONS | ||
/// @dev Returns the pubkey and pubkey hash of an operator,Reverts if the operator has not registered a valid pubkey | ||
/// @param operator is the operator for whom the key is being registered | ||
function getRegisteredPubkey(address operator) external returns (bytes32); | ||
|
||
/// TRANSACTIONS | ||
/// @dev Get the count of the current task | ||
function checkSignatures( | ||
bytes32 msgHash, | ||
bytes calldata signature, | ||
bytes calldata pubkey | ||
) external view returns (bool valid); | ||
|
||
// EVENTS | ||
/// @notice Emitted when `operator` registers with the public keys `pubkeyG1`. | ||
event NewPubkeyRegistration(address indexed operator, bytes pubkeyG1); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
package task | ||
|
||
const ( | ||
ErrContractInputParaOrType = "the contract input parameter type or value error,arg index:%d, type is:%s,value:%v" | ||
ErrContractCaller = "the caller doesn't have the permission to call this function,caller:%s,need:%s" | ||
ErrInputClientChainAddrLength = "the length of input client chain addr doesn't match,input:%d,need:%d" | ||
ErrNotYetRegistered = "this AVS has not been registered yet,input:%d" | ||
) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,52 @@ | ||
package task | ||
|
||
import ( | ||
sdk "github.com/cosmos/cosmos-sdk/types" | ||
"github.com/ethereum/go-ethereum/accounts/abi" | ||
"github.com/ethereum/go-ethereum/common" | ||
ethtypes "github.com/ethereum/go-ethereum/core/types" | ||
"github.com/ethereum/go-ethereum/core/vm" | ||
cmn "github.com/evmos/evmos/v14/precompiles/common" | ||
) | ||
|
||
const ( | ||
// EventTypeNewTaskCreated defines the event type for the task create transaction. | ||
EventTypeNewPubkeyRegistration = "NewPubkeyRegistration" | ||
) | ||
|
||
// EmitEventTypeNewPubkeyRegistration new bls pubkey reg | ||
func (p Precompile) EmitEventTypeNewPubkeyRegistration( | ||
ctx sdk.Context, | ||
stateDB vm.StateDB, | ||
operator string, | ||
pubkey []byte, | ||
) error { | ||
event := p.ABI.Events[EventTypeNewPubkeyRegistration] | ||
topics := make([]common.Hash, 3) | ||
|
||
// The first topic is always the signature of the event. | ||
topics[0] = event.ID | ||
|
||
var err error | ||
// sender and receiver are indexed | ||
topics[1], err = cmn.MakeTopic(operator) | ||
if err != nil { | ||
return err | ||
} | ||
|
||
// Prepare the event data: denom, amount, memo | ||
arguments := abi.Arguments{event.Inputs[2]} | ||
packed, err := arguments.Pack(pubkey) | ||
if err != nil { | ||
return err | ||
} | ||
|
||
stateDB.AddLog(ðtypes.Log{ | ||
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
|
||
}) | ||
|
||
return nil | ||
} |
Oops, something went wrong.