aligned_layer icon indicating copy to clipboard operation
aligned_layer copied to clipboard

fix: frontrunning createNewTask on servicemanager

Open uri-99 opened this issue 1 year ago • 1 comments

Changes

ServiceManager

  • RespondToTask has new parameter: address senderAddress:
bytes32 batchMerkleRoot,
address senderAddress,
  • NewBatch event has new parameter: address senderAddress:
event NewBatch(
    bytes32 indexed batchMerkleRoot,
    address senderAddress,
    uint32 taskCreatedBlock,
    string batchDataPointer
);
  • BatchVerified event has new parameter: address senderAddress:
event BatchVerified(
    bytes32 indexed batchMerkleRoot,
    address senderAddress
);

Explorer

  • Reading correctly the NewBatch event
    • storing it in new sender_address column of batches table
  • Reading correctly the BatchVerified event

Operator

  • Is reading NewBatch's new paramenter
    • calculates BatchIdentifierHash = hash(merkleRoot, senderAddress)
    • no longer use merkleRoot to identify batches, now using BatchIdentifierHash
    • submitting response to Aggregator with signature of (merkleRoot, senderAddress)

Aggregator

  • Recieving signature of (merkleRoot, senderAddress) from Operator
  • Making correct new respondToTask

Batcher

  • No changes needed, can still submit batches

uri-99 avatar Aug 19 '24 14:08 uri-99

Changes to gas cost

Generated at commit: 8d25318c8c582422fdba95ef718e8a187cd0f6cc, compared to commit: a128af6b3e4c97392d97fb1bc29eafdda27d7c3b

🧾 Summary (10% most significant diffs)

Contract Method Avg (+/-) %
AlignedLayerServiceManager batchesState
createNewTask
-52 ✅
+429 ❌
-7.84%
+0.84%

Full diff report 👇
Contract Deployment Cost (+/-) Method Min (+/-) % Avg (+/-) % Median (+/-) % Max (+/-) % # Calls (+/-)
AlignedLayerServiceManager 4,325,106 (+11,945) batchesState
createNewTask
611 (-52)
51,116 (+430)
-7.84%
+0.85%
611 (-52)
51,286 (+429)
-7.84%
+0.84%
611 (-52)
51,206 (+430)
-7.84%
+0.85%
611 (-52)
51,830 (+430)
-7.84%
+0.84%
256 (0)
256 (0)

github-actions[bot] avatar Aug 21 '24 19:08 github-actions[bot]

lgtm, I agree on tatu's comments but aside from that everything looks good.

entropidelic avatar Aug 22 '24 19:08 entropidelic