Skip to content

Commit 5b437f2

Browse files
authored
Pull hotfixes from testnet (#1779)
2 parents eb0be8d + 101388a commit 5b437f2

File tree

5 files changed

+43
-5
lines changed

5 files changed

+43
-5
lines changed

aggregator/pkg/server.go

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@ package pkg
33
import (
44
"context"
55
"encoding/hex"
6+
"errors"
67
"fmt"
78
"net/http"
89
"net/rpc"
@@ -48,6 +49,17 @@ func (agg *Aggregator) ProcessOperatorSignedTaskResponseV2(signedTaskResponse *t
4849
"SenderAddress", "0x"+hex.EncodeToString(signedTaskResponse.SenderAddress[:]),
4950
"BatchIdentifierHash", "0x"+hex.EncodeToString(signedTaskResponse.BatchIdentifierHash[:]),
5051
"operatorId", hex.EncodeToString(signedTaskResponse.OperatorId[:]))
52+
53+
if signedTaskResponse.BlsSignature.G1Point == nil {
54+
agg.logger.Warn("invalid operator response with nil signature",
55+
"BatchMerkleRoot", "0x"+hex.EncodeToString(signedTaskResponse.BatchMerkleRoot[:]),
56+
"SenderAddress", "0x"+hex.EncodeToString(signedTaskResponse.SenderAddress[:]),
57+
"BatchIdentifierHash", "0x"+hex.EncodeToString(signedTaskResponse.BatchIdentifierHash[:]),
58+
"operatorId", hex.EncodeToString(signedTaskResponse.OperatorId[:]))
59+
*reply = 1
60+
return errors.New("invalid response: nil signature")
61+
}
62+
5163
taskIndex := uint32(0)
5264

5365
// The Aggregator may receive the Task Identifier after the operators.

batcher/aligned-batcher/src/lib.rs

Lines changed: 13 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -26,9 +26,9 @@ use std::time::Duration;
2626
use aligned_sdk::core::constants::{
2727
ADDITIONAL_SUBMISSION_GAS_COST_PER_PROOF, BATCHER_SUBMISSION_BASE_GAS_COST,
2828
BUMP_BACKOFF_FACTOR, BUMP_MAX_RETRIES, BUMP_MAX_RETRY_DELAY, BUMP_MIN_RETRY_DELAY,
29-
CONNECTION_TIMEOUT, DEFAULT_MAX_FEE_PER_PROOF, ETHEREUM_CALL_BACKOFF_FACTOR,
30-
ETHEREUM_CALL_MAX_RETRIES, ETHEREUM_CALL_MAX_RETRY_DELAY, ETHEREUM_CALL_MIN_RETRY_DELAY,
31-
GAS_PRICE_PERCENTAGE_MULTIPLIER, PERCENTAGE_DIVIDER,
29+
CBOR_ARRAY_MAX_OVERHEAD, CONNECTION_TIMEOUT, DEFAULT_MAX_FEE_PER_PROOF,
30+
ETHEREUM_CALL_BACKOFF_FACTOR, ETHEREUM_CALL_MAX_RETRIES, ETHEREUM_CALL_MAX_RETRY_DELAY,
31+
ETHEREUM_CALL_MIN_RETRY_DELAY, GAS_PRICE_PERCENTAGE_MULTIPLIER, PERCENTAGE_DIVIDER,
3232
RESPOND_TO_TASK_FEE_LIMIT_PERCENTAGE_MULTIPLIER,
3333
};
3434
use aligned_sdk::core::types::{
@@ -115,6 +115,16 @@ impl Batcher {
115115
let s3_client = s3::create_client(upload_endpoint).await;
116116

117117
let config = ConfigFromYaml::new(config_file);
118+
// Ensure max_batch_bytes_size can at least hold one proof of max_proof_size,
119+
// including the overhead introduced by serialization
120+
assert!(
121+
config.batcher.max_proof_size + CBOR_ARRAY_MAX_OVERHEAD
122+
<= config.batcher.max_batch_byte_size,
123+
"max_batch_bytes_size ({}) not big enough for one max_proof_size ({}) proof",
124+
config.batcher.max_batch_byte_size,
125+
config.batcher.max_proof_size
126+
);
127+
118128
let deployment_output =
119129
ContractDeploymentOutput::new(config.aligned_layer_deployment_config_file_path);
120130

batcher/aligned-batcher/src/types/batch_queue.rs

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,9 @@
11
use aligned_sdk::{
22
communication::serialization::cbor_serialize,
3-
core::types::{NoncedVerificationData, VerificationDataCommitment},
3+
core::{
4+
constants::CBOR_ARRAY_MAX_OVERHEAD,
5+
types::{NoncedVerificationData, VerificationDataCommitment},
6+
},
47
};
58
use ethers::types::{Address, Signature, U256};
69
use priority_queue::PriorityQueue;
@@ -132,7 +135,10 @@ pub(crate) fn calculate_batch_size(batch_queue: &BatchQueue) -> Result<usize, Ba
132135
});
133136

134137
if let ControlFlow::Continue(batch_size) = folded_result {
135-
Ok(batch_size)
138+
// We over-estimate the size of the batch by at most 8 bytes.
139+
// This saves us from a scenario where we actually try to send more
140+
// than the maximum allowed bytes and get rejected by operators.
141+
Ok(CBOR_ARRAY_MAX_OVERHEAD + batch_size)
136142
} else {
137143
Err(BatcherError::SerializationError(String::from(
138144
"Could not calculate size of batch",

batcher/aligned-sdk/src/core/constants.rs

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,15 @@ pub const DEFAULT_MAX_FEE_PER_PROOF: u128 =
1111
ADDITIONAL_SUBMISSION_GAS_COST_PER_PROOF * 100_000_000_000; // gas_price = 100 Gwei = 0.0000001 ether (high gas price)
1212
pub const CONNECTION_TIMEOUT: u64 = 30; // 30 secs
1313

14+
// According to:
15+
// - https://www.rfc-editor.org/rfc/rfc8949.html#section-3.1-2.10
16+
// - https://www.rfc-editor.org/rfc/rfc8949.html#section-3-3.2
17+
// - https://www.rfc-editor.org/rfc/rfc8949.html#section-3-3.4
18+
// 9 bytes are the maximum overhead from aggregating data into an array in CBOR
19+
// (it may be as little as just 1 byte, but it depends on the number of elements
20+
// and serialization parameters).
21+
pub const CBOR_ARRAY_MAX_OVERHEAD: usize = 9;
22+
1423
// % modifiers: (100% is x1, 10% is x0.1, 1000% is x10)
1524
pub const RESPOND_TO_TASK_FEE_LIMIT_PERCENTAGE_MULTIPLIER: u128 = 250; // fee_for_aggregator -> respondToTaskFeeLimit modifier
1625
pub const DEFAULT_AGGREGATOR_FEE_PERCENTAGE_MULTIPLIER: u128 = 125; // feeForAggregator modifier

docker/aggregator.Dockerfile

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@ COPY metrics ./metrics
1010
COPY contracts/bindings/ ./contracts/bindings
1111

1212
RUN go get github.com/ethereum/go-ethereum@latest
13+
RUN go get github.com/gorilla/[email protected]
1314
RUN go build -o ./aligned-layer-aggregator aggregator/cmd/main.go
1415

1516
FROM debian:bookworm-slim

0 commit comments

Comments
 (0)