Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
35 changes: 18 additions & 17 deletions contracts/bindings/AlignedLayerServiceManager/binding.go

Large diffs are not rendered by default.

Large diffs are not rendered by default.

Original file line numberDiff line numberDiff line change
Expand Up@@ -243,10 +243,10 @@
},
"0xf39fd6e51aad88f6f4ce6ab8827279cfffb92266": {
"nonce": 26,
"balance": "0x21e19bd9d103aa1a969",
"balance": "0x21e19c0b7d6968ad67a",
"code": "0x",
"storage": {}
}
},
"best_block_number": "0x14"
"best_block_number": "0x15"
}
Original file line numberDiff line numberDiff line change
Expand Up@@ -265,7 +265,7 @@
},
"0xf39fd6e51aad88f6f4ce6ab8827279cfffb92266": {
"nonce": 29,
"balance": "0x21e19ba13cec12aad3d",
"balance": "0x21e19bd2e951d13da4e",
"code": "0x",
"storage": {}
}
Expand Down
11 changes: 9 additions & 2 deletions contracts/src/core/AlignedLayerServiceManager.sol
Original file line numberDiff line numberDiff line change
Expand Up@@ -34,6 +34,7 @@ contract AlignedLayerServiceManager is ServiceManagerBase, BLSSignatureChecker {
uint32 taskCreatedBlock;
bytes quorumNumbers;
bytes quorumThresholdPercentages;
uint256 fee;
}

// Task Response
Expand DownExpand Up@@ -96,7 +97,9 @@ contract AlignedLayerServiceManager is ServiceManagerBase, BLSSignatureChecker {
bytes calldata verificationKey,
bytes calldata quorumNumbers,
bytes calldata quorumThresholdPercentages
) external {
) external payable {
require(msg.value > 0, "fee must be greater than 0");

Task memory newTask;

newTask.provingSystemId = provingSystemId;
Expand All@@ -106,6 +109,8 @@ contract AlignedLayerServiceManager is ServiceManagerBase, BLSSignatureChecker {
newTask.taskCreatedBlock = uint32(block.number);
newTask.quorumNumbers = quorumNumbers;
newTask.quorumThresholdPercentages = quorumThresholdPercentages;
newTask.fee = msg.value;

taskHashes[latestTaskIndexPlusOne] = keccak256(abi.encode(newTask));

emit NewTaskCreated(latestTaskIndexPlusOne, newTask);
Expand All@@ -116,7 +121,7 @@ contract AlignedLayerServiceManager is ServiceManagerBase, BLSSignatureChecker {
function respondToTask(
Task calldata task,
TaskResponse calldata taskResponse,
NonSignerStakesAndSignature memory nonSignerStakesAndSignature // TODO: aggregated signature field
NonSignerStakesAndSignature memory nonSignerStakesAndSignature
) external {
/* CHECKING SIGNATURES & WHETHER THRESHOLD IS MET OR NOT */
uint32 taskCreatedBlock = task.taskCreatedBlock;
Expand DownExpand Up@@ -161,6 +166,8 @@ contract AlignedLayerServiceManager is ServiceManagerBase, BLSSignatureChecker {
);
}

payable(aggregator).transfer(task.fee);

emit TaskResponded(
taskResponse.taskIndex,
TaskResponse(taskResponse.taskIndex, taskResponse.proofIsCorrect)
Expand Down
6 changes: 5 additions & 1 deletion core/chainio/avs_writer.go
Original file line numberDiff line numberDiff line change
Expand Up@@ -14,6 +14,7 @@ import (
servicemanager "github.com/yetanotherco/aligned_layer/contracts/bindings/AlignedLayerServiceManager"
"github.com/yetanotherco/aligned_layer/core/config"
"github.com/yetanotherco/aligned_layer/core/utils"
"math/big"
)

type AvsWriter struct {
Expand DownExpand Up@@ -66,8 +67,11 @@ func NewAvsWriterFromConfig(baseConfig *config.BaseConfig, ecdsaConfig *config.E
}, nil
}

func (w *AvsWriter) SendTask(context context.Context, provingSystemId common.ProvingSystemId, proof []byte, publicInput []byte, verificationKey []byte, quorumNumbers types.QuorumNums, quorumThresholdPercentages types.QuorumThresholdPercentages) (servicemanager.AlignedLayerServiceManagerTask, uint32, error) {
func (w *AvsWriter) SendTask(context context.Context, provingSystemId common.ProvingSystemId, proof []byte, publicInput []byte, verificationKey []byte, quorumNumbers types.QuorumNums, quorumThresholdPercentages types.QuorumThresholdPercentages, fee *big.Int) (servicemanager.AlignedLayerServiceManagerTask, uint32, error) {
txOpts := w.Signer.GetTxOpts()

txOpts.Value = fee

tx, err := w.AvsContractBindings.ServiceManager.CreateNewTask(
txOpts,
uint16(provingSystemId),
Expand Down
13 changes: 12 additions & 1 deletion task_sender/cmd/main.go
Original file line numberDiff line numberDiff line change
Expand Up@@ -3,6 +3,7 @@ package main
import (
"fmt"
"log"
"math/big"
"os"
"strings"
"time"
Expand DownExpand Up@@ -46,6 +47,12 @@ var (
Value: 1,
Usage: "the `INTERVAL` in seconds to send tasks",
}
feeFlag = &cli.IntFlag{
Name: "fee",
Required: false,
Value: 1,
Usage: "the `FEE` in wei to send when sending a task",
}
quorumThresholdFlag = &cli.UintFlag{
Name: "quorum-threshold",
Aliases: []string{"q"},
Expand All@@ -60,6 +67,7 @@ var sendTaskFlags = []cli.Flag{
publicInputFlag,
verificationKeyFlag,
config.ConfigFileFlag,
feeFlag,
quorumThresholdFlag,
}

Expand All@@ -70,6 +78,7 @@ var loopTasksFlags = []cli.Flag{
verificationKeyFlag,
config.ConfigFileFlag,
intervalFlag,
feeFlag,
quorumThresholdFlag,
}

Expand DownExpand Up@@ -127,6 +136,8 @@ func taskSenderMain(c *cli.Context) error {
}
}

fee := big.NewInt(int64(c.Int(feeFlag.Name)))

taskSenderConfig := config.NewTaskSenderConfig(c.String(config.ConfigFileFlag.Name))
avsWriter, err := chainio.NewAvsWriterFromConfig(taskSenderConfig.BaseConfig, taskSenderConfig.EcdsaConfig)
if err != nil {
Expand All@@ -139,7 +150,7 @@ func taskSenderMain(c *cli.Context) error {
// Hardcoded value for `quorumNumbers` - should we get this information from another source? Maybe configuration or CLI parameters?
quorumNumbers := eigentypes.QuorumNums{0}
quorumThresholdPercentages := []eigentypes.QuorumThresholdPercentage{eigentypes.QuorumThresholdPercentage(quorumThresholdPercentage)}
task := pkg.NewTask(provingSystem, proofFile, publicInputFile, verificationKeyFile, quorumNumbers, quorumThresholdPercentages)
task := pkg.NewTask(provingSystem, proofFile, publicInputFile, verificationKeyFile, quorumNumbers, quorumThresholdPercentages, fee)

err = taskSender.SendTask(task)
if err != nil {
Expand Down
6 changes: 5 additions & 1 deletion task_sender/pkg/task_sender.go
Original file line numberDiff line numberDiff line change
Expand Up@@ -3,6 +3,7 @@ package pkg
import (
"context"
"log"
"math/big"

"github.com/Layr-Labs/eigensdk-go/types"
"github.com/yetanotherco/aligned_layer/common"
Expand All@@ -16,16 +17,18 @@ type Task struct {
VerificationKey []byte
QuorumNumbers types.QuorumNums
QuorumThresholdPercentages types.QuorumThresholdPercentages
Fee *big.Int
}

func NewTask(provingSystemId common.ProvingSystemId, proof []byte, publicInput []byte, verificationKey []byte, quorumNumbers types.QuorumNums, quorumThresholdPercentages types.QuorumThresholdPercentages) *Task {
func NewTask(provingSystemId common.ProvingSystemId, proof []byte, publicInput []byte, verificationKey []byte, quorumNumbers types.QuorumNums, quorumThresholdPercentages types.QuorumThresholdPercentages, fee *big.Int) *Task {
return &Task{
ProvingSystem: provingSystemId,
Proof: proof,
PublicInput: publicInput,
VerificationKey: verificationKey,
QuorumNumbers: quorumNumbers,
QuorumThresholdPercentages: quorumThresholdPercentages,
Fee: fee,
}
}

Expand All@@ -49,6 +52,7 @@ func (ts *TaskSender) SendTask(task *Task) error {
task.VerificationKey,
task.QuorumNumbers,
task.QuorumThresholdPercentages,
task.Fee,
)
if err != nil {
return err
Expand Down