From 3ca8bc8b7f8093c0b4f0c2d6b13d1197b1923e0b Mon Sep 17 00:00:00 2001 From: gabrielbosio Date: Tue, 6 Aug 2024 13:21:07 -0300 Subject: [PATCH 1/7] Change Holesky Aligned contract address --- batcher/aligned-sdk/src/sdk.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/batcher/aligned-sdk/src/sdk.rs b/batcher/aligned-sdk/src/sdk.rs index adf29cf30..549f4ef04 100644 --- a/batcher/aligned-sdk/src/sdk.rs +++ b/batcher/aligned-sdk/src/sdk.rs @@ -272,7 +272,7 @@ async fn _verify_proof_onchain( ) -> Result { let contract_address = match chain { Chain::Devnet => "0x1613beB3B2C4f22Ee086B2b38C1476A3cE7f78E8", - Chain::Holesky => "0x58F280BeBE9B34c9939C3C39e0890C81f163B623", + Chain::Holesky => "0xe41Faf6446A94961096a1aeeec1268CA4A6D4a77", Chain::HoleskyStage => "0x9C5231FC88059C086Ea95712d105A2026048c39B", }; From b6022744e4bd9ad3cbd63d52ae95c93aab90825f Mon Sep 17 00:00:00 2001 From: gabrielbosio Date: Wed, 7 Aug 2024 15:56:34 -0300 Subject: [PATCH 2/7] Log batcher gas cost --- batcher/aligned-batcher/src/lib.rs | 13 ++++++++++--- 1 file changed, 10 insertions(+), 3 deletions(-) diff --git a/batcher/aligned-batcher/src/lib.rs b/batcher/aligned-batcher/src/lib.rs index cffde1fab..24eaf7e59 100644 --- a/batcher/aligned-batcher/src/lib.rs +++ b/batcher/aligned-batcher/src/lib.rs @@ -561,7 +561,7 @@ impl Batcher { .map(|(i, signature)| SignatureData::new(signature, nonces[i])) .collect(); - if let Err(e) = eth::create_new_task( + match eth::create_new_task( payment_service, *batch_merkle_root, batch_data_pointer, @@ -572,8 +572,15 @@ impl Batcher { ) .await { - error!("Failed to create batch verification task: {}", e); - return Err(BatcherError::TaskCreationError(e.to_string())); + Ok(receipt) => { + if let Some(gas_used) = receipt.gas_used { + info!("Gas used to create new task: {}", gas_used); + } + } + Err(e) => { + error!("Failed to create batch verification task: {}", e); + return Err(BatcherError::TaskCreationError(e.to_string())); + } } info!("Batch verification task created on Aligned contract"); From 8873369d8c6a1b0041a714c542a1a59bd3a2e8ab Mon Sep 17 00:00:00 2001 From: gabrielbosio Date: Wed, 7 Aug 2024 16:17:23 -0300 Subject: [PATCH 3/7] Log aggregator gas cost --- aggregator/internal/pkg/aggregator.go | 15 +++++++-------- 1 file changed, 7 insertions(+), 8 deletions(-) diff --git a/aggregator/internal/pkg/aggregator.go b/aggregator/internal/pkg/aggregator.go index 6ccd771ae..4799f674d 100644 --- a/aggregator/internal/pkg/aggregator.go +++ b/aggregator/internal/pkg/aggregator.go @@ -3,10 +3,11 @@ package pkg import ( "context" "encoding/hex" - gethtypes "github.com/ethereum/go-ethereum/core/types" "sync" "time" + gethtypes "github.com/ethereum/go-ethereum/core/types" + "github.com/prometheus/client_golang/prometheus" "github.com/yetanotherco/aligned_layer/metrics" @@ -215,7 +216,6 @@ func (agg *Aggregator) handleBlsAggServiceResponse(blsAggServiceResp blsagg.BlsA agg.logger.Info("Threshold reached", "taskIndex", blsAggServiceResp.TaskIndex, "merkleRoot", hex.EncodeToString(batchMerkleRoot[:])) - currentBlock, err := agg.AggregatorConfig.BaseConfig.EthRpcClient.BlockNumber(context.Background()) if err != nil { agg.logger.Error("Error getting current block number", "err", err) @@ -251,8 +251,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[:])) @@ -270,10 +272,8 @@ func (agg *Aggregator) handleBlsAggServiceResponse(blsAggServiceResp blsagg.BlsA "merkleRoot", hex.EncodeToString(batchMerkleRoot[:])) } - - -/// Sends response to contract and waits for transaction receipt -/// Returns error if it fails to send tx or receipt is not found +// / Sends response to contract and waits for transaction receipt +// / Returns error if it fails to send tx or receipt is not found func (agg *Aggregator) sendAggregatedResponse(batchMerkleRoot [32]byte, nonSignerStakesAndSignature servicemanager.IBLSSignatureCheckerNonSignerStakesAndSignature) (*gethtypes.Receipt, error) { agg.walletMutex.Lock() agg.logger.Infof("- Locked Wallet Resources: Sending aggregated response for batch %s", hex.EncodeToString(batchMerkleRoot[:])) @@ -299,7 +299,6 @@ func (agg *Aggregator) sendAggregatedResponse(batchMerkleRoot [32]byte, nonSigne return receipt, nil } - func (agg *Aggregator) AddNewTask(batchMerkleRoot [32]byte, taskCreatedBlock uint32) { agg.AggregatorConfig.BaseConfig.Logger.Info("Adding new task", "Batch merkle root", hex.EncodeToString(batchMerkleRoot[:])) From a47350df8213b2bd442981443a747aa79e6fc935 Mon Sep 17 00:00:00 2001 From: gabrielbosio Date: Mon, 12 Aug 2024 18:49:15 -0300 Subject: [PATCH 4/7] Update Holesky contract --- batcher/aligned-sdk/src/sdk.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/batcher/aligned-sdk/src/sdk.rs b/batcher/aligned-sdk/src/sdk.rs index 8cb284e4b..0474f4478 100644 --- a/batcher/aligned-sdk/src/sdk.rs +++ b/batcher/aligned-sdk/src/sdk.rs @@ -308,7 +308,7 @@ async fn _verify_proof_onchain( ) -> Result { let contract_address = match chain { Chain::Devnet => "0x1613beB3B2C4f22Ee086B2b38C1476A3cE7f78E8", - Chain::Holesky => "0xe41Faf6446A94961096a1aeeec1268CA4A6D4a77", + Chain::Holesky => "0x0584313310bD52B77CF0b81b350Ca447B97Df5DF", Chain::HoleskyStage => "0x9C5231FC88059C086Ea95712d105A2026048c39B", }; From 12ac9aae9606efb32952f2cc8df9b01989ffeba9 Mon Sep 17 00:00:00 2001 From: gabrielbosio Date: Wed, 14 Aug 2024 18:50:49 -0300 Subject: [PATCH 5/7] Add Mina build step --- .github/workflows/build-go.yml | 2 ++ 1 file changed, 2 insertions(+) diff --git a/.github/workflows/build-go.yml b/.github/workflows/build-go.yml index b581da925..420a54847 100644 --- a/.github/workflows/build-go.yml +++ b/.github/workflows/build-go.yml @@ -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 From b75e1e2988f741bcb0387a1219fe1c409f25da04 Mon Sep 17 00:00:00 2001 From: gabrielbosio Date: Thu, 15 Aug 2024 17:29:06 -0300 Subject: [PATCH 6/7] Measure block verification time --- operator/mina/mina.go | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/operator/mina/mina.go b/operator/mina/mina.go index 5e673b3bf..fe00fb24e 100644 --- a/operator/mina/mina.go +++ b/operator/mina/mina.go @@ -8,6 +8,8 @@ package mina */ import "C" import ( + "fmt" + "time" "unsafe" ) @@ -15,7 +17,15 @@ import ( 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))) From ec485800be18946dd62b063ca1ee7dace538b692 Mon Sep 17 00:00:00 2001 From: gabrielbosio Date: Fri, 16 Aug 2024 17:30:41 -0300 Subject: [PATCH 7/7] Add Holesky Aligned SM contract addr disclaimer --- batcher/aligned-sdk/src/sdk.rs | 1 + 1 file changed, 1 insertion(+) diff --git a/batcher/aligned-sdk/src/sdk.rs b/batcher/aligned-sdk/src/sdk.rs index 0474f4478..e29460d5f 100644 --- a/batcher/aligned-sdk/src/sdk.rs +++ b/batcher/aligned-sdk/src/sdk.rs @@ -308,6 +308,7 @@ async fn _verify_proof_onchain( ) -> Result { let contract_address = match chain { Chain::Devnet => "0x1613beB3B2C4f22Ee086B2b38C1476A3cE7f78E8", + // If we re-deploy the Aligned SM contract we need to change this value to the new contract address Chain::Holesky => "0x0584313310bD52B77CF0b81b350Ca447B97Df5DF", Chain::HoleskyStage => "0x9C5231FC88059C086Ea95712d105A2026048c39B", };