Skip to content

Commit 81b290d

Browse files
uri-99JuArcetaturosati
authored
refactor: 'V2' functionalities to aggregator and operator (#875)
Co-authored-by: JuArce <[email protected]> Co-authored-by: taturosati <“[email protected]”>
1 parent c6d8459 commit 81b290d

File tree

16 files changed

+147
-92
lines changed

16 files changed

+147
-92
lines changed

Makefile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ OS := $(shell uname -s)
55
CONFIG_FILE?=config-files/config.yaml
66
AGG_CONFIG_FILE?=config-files/config-aggregator.yaml
77

8-
OPERATOR_VERSION=v0.4.1
8+
OPERATOR_VERSION=v0.5.2
99

1010
ifeq ($(OS),Linux)
1111
BUILD_ALL_FFI = $(MAKE) build_all_ffi_linux

aggregator/internal/pkg/aggregator.go

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,7 @@ type BatchData struct {
4242

4343
type Aggregator struct {
4444
AggregatorConfig *config.AggregatorConfig
45-
NewBatchChan chan *servicemanager.ContractAlignedLayerServiceManagerNewBatch
45+
NewBatchChan chan *servicemanager.ContractAlignedLayerServiceManagerNewBatchV2
4646
avsReader *chainio.AvsReader
4747
avsSubscriber *chainio.AvsSubscriber
4848
avsWriter *chainio.AvsWriter
@@ -91,7 +91,7 @@ type Aggregator struct {
9191
}
9292

9393
func NewAggregator(aggregatorConfig config.AggregatorConfig) (*Aggregator, error) {
94-
newBatchChan := make(chan *servicemanager.ContractAlignedLayerServiceManagerNewBatch)
94+
newBatchChan := make(chan *servicemanager.ContractAlignedLayerServiceManagerNewBatchV2)
9595

9696
avsReader, err := chainio.NewAvsReaderFromConfig(aggregatorConfig.BaseConfig, aggregatorConfig.EcdsaConfig)
9797
if err != nil {
@@ -333,7 +333,6 @@ func (agg *Aggregator) sendAggregatedResponse(batchMerkleRoot [32]byte, senderAd
333333
}
334334

335335
func (agg *Aggregator) AddNewTask(batchMerkleRoot [32]byte, senderAddress [20]byte, taskCreatedBlock uint32) {
336-
337336
batchIdentifier := append(batchMerkleRoot[:], senderAddress[:]...)
338337
var batchIdentifierHash = *(*[32]byte)(crypto.Keccak256(batchIdentifier))
339338

aggregator/internal/pkg/server.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,7 @@ func (agg *Aggregator) ServeOperators() error {
4848
// Returns:
4949
// - 0: Success
5050
// - 1: Error
51-
func (agg *Aggregator) ProcessOperatorSignedTaskResponse(signedTaskResponse *types.SignedTaskResponse, reply *uint8) error {
51+
func (agg *Aggregator) ProcessOperatorSignedTaskResponseV2(signedTaskResponse *types.SignedTaskResponse, reply *uint8) error {
5252
agg.AggregatorConfig.BaseConfig.Logger.Info("New task response",
5353
"BatchMerkleRoot", "0x"+hex.EncodeToString(signedTaskResponse.BatchMerkleRoot[:]),
5454
"SenderAddress", "0x"+hex.EncodeToString(signedTaskResponse.SenderAddress[:]),

aggregator/internal/pkg/subscriber.go

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,16 +10,15 @@ func (agg *Aggregator) SubscribeToNewTasks() error {
1010
select {
1111
case err := <-agg.taskSubscriber:
1212
agg.AggregatorConfig.BaseConfig.Logger.Info("Failed to subscribe to new tasks", "err", err)
13-
1413
err = agg.subscribeToNewTasks()
1514
if err != nil {
1615
return err
1716
}
1817
case newBatch := <-agg.NewBatchChan:
18+
agg.AggregatorConfig.BaseConfig.Logger.Info("Adding new task")
1919
agg.AddNewTask(newBatch.BatchMerkleRoot, newBatch.SenderAddress, newBatch.TaskCreatedBlock)
2020
}
2121
}
22-
2322
}
2423

2524
func (agg *Aggregator) subscribeToNewTasks() error {

config-files/config-operator.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ bls:
2222
## Operator Configurations
2323
operator:
2424
aggregator_rpc_server_ip_port_address: aggregator.alignedlayer.com:8090
25-
operator_tracker_ip_port_address: holesky.tracker.alignedlayer.com
25+
operator_tracker_ip_port_address: https://holesky.tracker.alignedlayer.com
2626
address: "<operator_address>"
2727
earnings_receiver_address: "<earnings_receiver_address>" #Can be the same as the operator.
2828
delegation_approver_address: "0x0000000000000000000000000000000000000000"

contracts/bindings/AlignedLayerServiceManager/binding.go

Lines changed: 71 additions & 40 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

contracts/scripts/anvil/state/alignedlayer-deployed-anvil-state.json

Lines changed: 1 addition & 1 deletion
Large diffs are not rendered by default.

contracts/src/core/AlignedLayerServiceManager.sol

Lines changed: 39 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -51,12 +51,12 @@ contract AlignedLayerServiceManager is
5151
bytes32 batchMerkleRoot,
5252
string calldata batchDataPointer
5353
) external payable {
54-
bytes32 batchIdentifierHash = keccak256(
54+
bytes32 batchIdentifier = keccak256(
5555
abi.encodePacked(batchMerkleRoot, msg.sender)
5656
);
5757

58-
if (batchesState[batchIdentifierHash].taskCreatedBlock != 0) {
59-
revert BatchAlreadySubmitted(batchIdentifierHash);
58+
if (batchesState[batchIdentifier].taskCreatedBlock != 0) {
59+
revert BatchAlreadySubmitted(batchIdentifier);
6060
}
6161

6262
if (msg.value > 0) {
@@ -76,17 +76,17 @@ contract AlignedLayerServiceManager is
7676
batchState.taskCreatedBlock = uint32(block.number);
7777
batchState.responded = false;
7878

79-
batchesState[batchIdentifierHash] = batchState;
79+
batchesState[batchIdentifier] = batchState;
8080

81-
emit NewBatch(
81+
emit NewBatchV2(
8282
batchMerkleRoot,
8383
msg.sender,
8484
uint32(block.number),
8585
batchDataPointer
8686
);
8787
}
8888

89-
function respondToTask(
89+
function respondToTaskV2(
9090
// (batchMerkleRoot,senderAddress) is signed as a way to verify the batch was right
9191
bytes32 batchMerkleRoot,
9292
address senderAddress,
@@ -174,15 +174,20 @@ contract AlignedLayerServiceManager is
174174
uint256 verificationDataBatchIndex,
175175
address senderAddress
176176
) external view returns (bool) {
177-
bytes32 batchIdentifierHash = keccak256(
178-
abi.encodePacked(batchMerkleRoot, senderAddress)
179-
);
177+
bytes32 batchIdentifier;
178+
if (senderAddress == address(0)) {
179+
batchIdentifier = batchMerkleRoot;
180+
} else {
181+
batchIdentifier = keccak256(
182+
abi.encodePacked(batchMerkleRoot, senderAddress)
183+
);
184+
}
180185

181-
if (batchesState[batchIdentifierHash].taskCreatedBlock == 0) {
186+
if (batchesState[batchIdentifier].taskCreatedBlock == 0) {
182187
return false;
183188
}
184189

185-
if (!batchesState[batchIdentifierHash].responded) {
190+
if (!batchesState[batchIdentifier].responded) {
186191
return false;
187192
}
188193

@@ -198,12 +203,34 @@ contract AlignedLayerServiceManager is
198203
return
199204
Merkle.verifyInclusionKeccak(
200205
merkleProof,
201-
batchIdentifierHash,
206+
batchMerkleRoot,
202207
hashedLeaf,
203208
verificationDataBatchIndex
204209
);
205210
}
206211

212+
// Old function signature for backwards compatibility
213+
function verifyBatchInclusion(
214+
bytes32 proofCommitment,
215+
bytes32 pubInputCommitment,
216+
bytes32 provingSystemAuxDataCommitment,
217+
bytes20 proofGeneratorAddr,
218+
bytes32 batchMerkleRoot,
219+
bytes memory merkleProof,
220+
uint256 verificationDataBatchIndex
221+
) external view returns (bool) {
222+
return this.verifyBatchInclusion(
223+
proofCommitment,
224+
pubInputCommitment,
225+
provingSystemAuxDataCommitment,
226+
proofGeneratorAddr,
227+
batchMerkleRoot,
228+
merkleProof,
229+
verificationDataBatchIndex,
230+
address(0)
231+
);
232+
}
233+
207234
function withdraw(uint256 amount) external {
208235
if (batchersBalances[msg.sender] < amount) {
209236
revert InsufficientFunds(

contracts/src/core/IAlignedLayerServiceManager.sol

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ import {IBLSSignatureChecker} from "eigenlayer-middleware/interfaces/IBLSSignatu
55

66
interface IAlignedLayerServiceManager {
77
// EVENTS
8-
event NewBatch(
8+
event NewBatchV2(
99
bytes32 indexed batchMerkleRoot,
1010
address senderAddress,
1111
uint32 taskCreatedBlock,
@@ -33,7 +33,7 @@ interface IAlignedLayerServiceManager {
3333
string calldata batchDataPointer
3434
) external payable;
3535

36-
function respondToTask(
36+
function respondToTaskV2(
3737
bytes32 batchMerkleRoot,
3838
address senderAddress,
3939
IBLSSignatureChecker.NonSignerStakesAndSignature

contracts/test/AlignedLayerServiceManager.t.sol

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ contract AlignedLayerServiceManagerTest is BLSMockAVSDeployer {
1616

1717
using stdStorage for StdStorage;
1818

19-
event NewBatch(
19+
event NewBatchV2(
2020
bytes32 indexed batchMerkleRoot,
2121
address senderAddress,
2222
uint32 taskCreatedBlock,
@@ -62,7 +62,7 @@ contract AlignedLayerServiceManagerTest is BLSMockAVSDeployer {
6262
address(alignedLayerServiceManager).call{value: 0.1 ether}("");
6363

6464
vm.expectEmit(true, true, true, true);
65-
emit NewBatch(batchMerkleRoot, batcher, uint32(block.number), batchDataPointer);
65+
emit NewBatchV2(batchMerkleRoot, batcher, uint32(block.number), batchDataPointer);
6666

6767
vm.prank(batcher);
6868
alignedLayerServiceManager.createNewTask(

0 commit comments

Comments
 (0)