Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Mina verifier using Holesky #18

Merged
merged 9 commits into from
Aug 16, 2024
Merged
Show file tree
Hide file tree
Changes from 8 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
2 changes: 2 additions & 0 deletions .github/workflows/build-go.yml
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,8 @@ jobs:
run: make build_halo2_ipa_linux
- name: Build Merkle Tree bindings
run: make build_merkle_tree_linux
- name: Build Mina bindings
run: make build_mina_linux
- name: Build operator
run: go build operator/cmd/main.go
- name: Build aggregator
Expand Down
6 changes: 4 additions & 2 deletions aggregator/internal/pkg/aggregator.go
Original file line number Diff line number Diff line change
Expand Up @@ -208,7 +208,7 @@ func (agg *Aggregator) handleBlsAggServiceResponse(blsAggServiceResp blsagg.BlsA
if blsAggServiceResp.Err != nil {
agg.taskMutex.Lock()
batchMerkleRoot := agg.batchesRootByIdx[blsAggServiceResp.TaskIndex]
agg.logger.Error("BlsAggregationServiceResponse contains an error", "err", blsAggServiceResp.Err, "merkleRoot", hex.EncodeToString(batchMerkleRoot[:]))
agg.logger.Error("BlsAggregationServiceResponse contains an error", "err", blsAggServiceResp.Err, "merkleRoot", hex.EncodeToString(batchMerkleRoot[:]))
agg.logger.Info("- Locking task mutex: Delete task from operator map", "taskIndex", blsAggServiceResp.TaskIndex)

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

for i := 0; i < MaxSentTxRetries; i++ {
_, err = agg.sendAggregatedResponse(batchMerkleRoot, nonSignerStakesAndSignature)
receipt, err := agg.sendAggregatedResponse(batchMerkleRoot, nonSignerStakesAndSignature)
if err == nil {
agg.logger.Info("Gas cost used to send aggregated response", "gasUsed", receipt.GasUsed)

agg.logger.Info("Aggregator successfully responded to task",
"taskIndex", blsAggServiceResp.TaskIndex,
"merkleRoot", hex.EncodeToString(batchMerkleRoot[:]))
Expand Down
5 changes: 4 additions & 1 deletion batcher/aligned-batcher/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -649,7 +649,10 @@ impl Batcher {
)
.await
{
Ok(_) => {
Ok(receipt) => {
if let Some(gas_used) = receipt.gas_used {
info!("Gas used to create new task: {}", gas_used);
}
info!("Batch verification task created on Aligned contract");
Ok(())
}
Expand Down
2 changes: 1 addition & 1 deletion batcher/aligned-sdk/src/sdk.rs
Original file line number Diff line number Diff line change
Expand Up @@ -308,7 +308,7 @@ async fn _verify_proof_onchain(
) -> Result<bool, errors::VerificationError> {
let contract_address = match chain {
Chain::Devnet => "0x1613beB3B2C4f22Ee086B2b38C1476A3cE7f78E8",
Chain::Holesky => "0x58F280BeBE9B34c9939C3C39e0890C81f163B623",
Chain::Holesky => "0x0584313310bD52B77CF0b81b350Ca447B97Df5DF",
gabrielbosio marked this conversation as resolved.
Show resolved Hide resolved
Chain::HoleskyStage => "0x9C5231FC88059C086Ea95712d105A2026048c39B",
};

Expand Down
10 changes: 10 additions & 0 deletions operator/mina/mina.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,14 +8,24 @@ package mina
*/
import "C"
import (
"fmt"
"time"
"unsafe"
)

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

func timer() func() {
start := time.Now()
return func() {
fmt.Printf("Mina block verification took %v\n", time.Since(start))
}
}

func VerifyProtocolStateProof(proofBuffer [MAX_PROOF_SIZE]byte, proofLen uint, pubInputBuffer [MAX_PUB_INPUT_SIZE]byte, pubInputLen uint) bool {
defer timer()()
proofPtr := (*C.uchar)(unsafe.Pointer(&proofBuffer[0]))
pubInputPtr := (*C.uchar)(unsafe.Pointer(&pubInputBuffer[0]))
return (bool)(C.verify_protocol_state_proof_ffi(proofPtr, (C.uint)(proofLen), pubInputPtr, (C.uint)(pubInputLen)))
Expand Down
Loading