Skip to content

Commit 08a220c

Browse files
authored
Merge pull request #18 from lambdaclass/mina_holesky
Mina verifier using Holesky
2 parents db616f7 + ec48580 commit 08a220c

5 files changed

Lines changed: 22 additions & 4 deletions

File tree

.github/workflows/build-go.yml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,8 @@ jobs:
2828
run: make build_halo2_ipa_linux
2929
- name: Build Merkle Tree bindings
3030
run: make build_merkle_tree_linux
31+
- name: Build Mina bindings
32+
run: make build_mina_linux
3133
- name: Build operator
3234
run: go build operator/cmd/main.go
3335
- name: Build aggregator

aggregator/internal/pkg/aggregator.go

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -208,7 +208,7 @@ func (agg *Aggregator) handleBlsAggServiceResponse(blsAggServiceResp blsagg.BlsA
208208
if blsAggServiceResp.Err != nil {
209209
agg.taskMutex.Lock()
210210
batchMerkleRoot := agg.batchesRootByIdx[blsAggServiceResp.TaskIndex]
211-
agg.logger.Error("BlsAggregationServiceResponse contains an error", "err", blsAggServiceResp.Err, "merkleRoot", hex.EncodeToString(batchMerkleRoot[:]))
211+
agg.logger.Error("BlsAggregationServiceResponse contains an error", "err", blsAggServiceResp.Err, "merkleRoot", hex.EncodeToString(batchMerkleRoot[:]))
212212
agg.logger.Info("- Locking task mutex: Delete task from operator map", "taskIndex", blsAggServiceResp.TaskIndex)
213213

214214
// Remove task from the list of tasks
@@ -287,8 +287,10 @@ func (agg *Aggregator) handleBlsAggServiceResponse(blsAggServiceResp blsagg.BlsA
287287
"merkleRoot", hex.EncodeToString(batchMerkleRoot[:]))
288288

289289
for i := 0; i < MaxSentTxRetries; i++ {
290-
_, err = agg.sendAggregatedResponse(batchMerkleRoot, nonSignerStakesAndSignature)
290+
receipt, err := agg.sendAggregatedResponse(batchMerkleRoot, nonSignerStakesAndSignature)
291291
if err == nil {
292+
agg.logger.Info("Gas cost used to send aggregated response", "gasUsed", receipt.GasUsed)
293+
292294
agg.logger.Info("Aggregator successfully responded to task",
293295
"taskIndex", blsAggServiceResp.TaskIndex,
294296
"merkleRoot", hex.EncodeToString(batchMerkleRoot[:]))

batcher/aligned-batcher/src/lib.rs

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -649,7 +649,10 @@ impl Batcher {
649649
)
650650
.await
651651
{
652-
Ok(_) => {
652+
Ok(receipt) => {
653+
if let Some(gas_used) = receipt.gas_used {
654+
info!("Gas used to create new task: {}", gas_used);
655+
}
653656
info!("Batch verification task created on Aligned contract");
654657
Ok(())
655658
}

batcher/aligned-sdk/src/sdk.rs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -308,7 +308,8 @@ async fn _verify_proof_onchain(
308308
) -> Result<bool, errors::VerificationError> {
309309
let contract_address = match chain {
310310
Chain::Devnet => "0x1613beB3B2C4f22Ee086B2b38C1476A3cE7f78E8",
311-
Chain::Holesky => "0x58F280BeBE9B34c9939C3C39e0890C81f163B623",
311+
// If we re-deploy the Aligned SM contract we need to change this value to the new contract address
312+
Chain::Holesky => "0x0584313310bD52B77CF0b81b350Ca447B97Df5DF",
312313
Chain::HoleskyStage => "0x9C5231FC88059C086Ea95712d105A2026048c39B",
313314
};
314315

operator/mina/mina.go

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,14 +8,24 @@ package mina
88
*/
99
import "C"
1010
import (
11+
"fmt"
12+
"time"
1113
"unsafe"
1214
)
1315

1416
// TODO(xqft): check proof size
1517
const MAX_PROOF_SIZE = 16 * 1024
1618
const MAX_PUB_INPUT_SIZE = 6 * 1024
1719

20+
func timer() func() {
21+
start := time.Now()
22+
return func() {
23+
fmt.Printf("Mina block verification took %v\n", time.Since(start))
24+
}
25+
}
26+
1827
func VerifyProtocolStateProof(proofBuffer [MAX_PROOF_SIZE]byte, proofLen uint, pubInputBuffer [MAX_PUB_INPUT_SIZE]byte, pubInputLen uint) bool {
28+
defer timer()()
1929
proofPtr := (*C.uchar)(unsafe.Pointer(&proofBuffer[0]))
2030
pubInputPtr := (*C.uchar)(unsafe.Pointer(&pubInputBuffer[0]))
2131
return (bool)(C.verify_protocol_state_proof_ffi(proofPtr, (C.uint)(proofLen), pubInputPtr, (C.uint)(pubInputLen)))

0 commit comments

Comments
 (0)