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

fix: operator downtime #1073

Merged
Show file tree
Hide file tree
Changes from 24 commits
Commits
Show all changes
25 commits
Select commit Hold shift + click to select a range
187d73f
feat: store operator last verified block
MarcosNicolau Sep 24, 2024
bada32a
feat: basic missed block processing func
MarcosNicolau Sep 24, 2024
6ef381e
refactor: operator new field names
MarcosNicolau Sep 24, 2024
84e09ff
feat: avs_reader get tasks from a block number
MarcosNicolau Sep 25, 2024
bc85333
feat: avs_read in operator to retrive the missed logs
MarcosNicolau Sep 25, 2024
3796a85
fix: write to file through channel to prevent data races
MarcosNicolau Sep 25, 2024
8f991ba
feat: avs_read add check for responded task
MarcosNicolau Sep 25, 2024
836089e
fix: go ci
MarcosNicolau Sep 25, 2024
04e911d
feat: avs_subscriber return latest task if not responded only
MarcosNicolau Sep 25, 2024
2656930
fix: send batch handling to a goroutine when processing missed batches
MarcosNicolau Sep 25, 2024
1e38be7
docs: operator functions
MarcosNicolau Sep 25, 2024
4fac752
chore(operator): add logs and general comments
MarcosNicolau Sep 26, 2024
f3bafb3
reafactor(operator): general addressing some review comments
MarcosNicolau Oct 1, 2024
509dd93
reafactor(operator): afterHandlingBatch when sending to channel
MarcosNicolau Oct 1, 2024
54fbe38
refactor(operator): use bindings when quering logs
MarcosNicolau Oct 1, 2024
a6cccfc
refactor(operator): return err instead of logging on getLatestTask
MarcosNicolau Oct 1, 2024
8663848
chore(config): update operator last processed batch file path
MarcosNicolau Oct 1, 2024
2239b8f
fix(operator): overflow check when passing fromBlock in ProcessMissed…
MarcosNicolau Oct 1, 2024
7cbb30a
Merge branch 'staging' into 962-fixoperator-aggregator-aggregator-or-…
MarcosNicolau Oct 2, 2024
5dc4071
fix(operator): afterHandlingBatch defer
MarcosNicolau Oct 2, 2024
f399d96
refactor(operator): add 0 check before processing missed batches
MarcosNicolau Oct 2, 2024
082a984
chore(config): ignored last processed batch files
MarcosNicolau Oct 2, 2024
3e8572d
chore(operator): update avs_subscriber getLatestNotRespondedTaskFromE…
MarcosNicolau Oct 2, 2024
8a67cec
Merge branch 'staging' into 962-fixoperator-aggregator-aggregator-or-…
MarcosNicolau Oct 2, 2024
00c2b41
Merge branch 'staging' into 962-fixoperator-aggregator-aggregator-or-…
uri-99 Oct 3, 2024
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
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -11,5 +11,6 @@ batcher/aligned/batch_inclusion_responses/*
**/aligned_verification_data
**/broadcast
volume
config-files/*.last_processed_batch.json

nonce_*.bin
31 changes: 16 additions & 15 deletions config-files/config-operator-1.yaml
Original file line number Diff line number Diff line change
@@ -1,39 +1,40 @@
# Common variables for all the services
# 'production' only prints info and above. 'development' also prints debug
environment: "development"
aligned_layer_deployment_config_file_path: "./contracts/script/output/devnet/alignedlayer_deployment_output.json"
eigen_layer_deployment_config_file_path: "./contracts/script/output/devnet/eigenlayer_deployment_output.json"
eth_rpc_url: "http://localhost:8545"
eth_rpc_url_fallback: "http://localhost:8545"
eth_ws_url: "ws://localhost:8545"
eth_ws_url_fallback: "ws://localhost:8545"
eigen_metrics_ip_port_address: "localhost:9090"
environment: 'development'
aligned_layer_deployment_config_file_path: './contracts/script/output/devnet/alignedlayer_deployment_output.json'
eigen_layer_deployment_config_file_path: './contracts/script/output/devnet/eigenlayer_deployment_output.json'
eth_rpc_url: 'http://localhost:8545'
eth_rpc_url_fallback: 'http://localhost:8545'
eth_ws_url: 'ws://localhost:8545'
eth_ws_url_fallback: 'ws://localhost:8545'
eigen_metrics_ip_port_address: 'localhost:9090'

## ECDSA Configurations
ecdsa:
private_key_store_path: "config-files/devnet/keys/operator-1.ecdsa.key.json"
private_key_store_password: ""
private_key_store_path: 'config-files/devnet/keys/operator-1.ecdsa.key.json'
private_key_store_password: ''

## BLS Configurations
bls:
private_key_store_path: "config-files/devnet/keys/operator-1.bls.key.json"
private_key_store_password: ""
private_key_store_path: 'config-files/devnet/keys/operator-1.bls.key.json'
private_key_store_password: ''

## Operator Configurations
operator:
aggregator_rpc_server_ip_port_address: localhost:8090
operator_tracker_ip_port_address: http://localhost:3030
address: 0x70997970C51812dc3A010C7d01b50e0d17dc79C8
earnings_receiver_address: 0x70997970C51812dc3A010C7d01b50e0d17dc79C8
delegation_approver_address: "0x0000000000000000000000000000000000000000"
delegation_approver_address: '0x0000000000000000000000000000000000000000'
staker_opt_out_window_blocks: 0
metadata_url: "https://yetanotherco.github.io/operator_metadata/metadata.json"
metadata_url: 'https://yetanotherco.github.io/operator_metadata/metadata.json'
enable_metrics: true
metrics_ip_port_address: localhost:9092
max_batch_size: 268435456 # 256 MiB
last_processed_batch_filepath: 'config-files/operator-1.last_processed_batch.json'

# Operators variables needed for register it in EigenLayer
el_delegation_manager_address: "0xCf7Ed3AccA5a467e9e704C703E8D87F634fB0Fc9"
el_delegation_manager_address: '0xCf7Ed3AccA5a467e9e704C703E8D87F634fB0Fc9'
private_key_store_path: config-files/devnet/keys/operator-1.ecdsa.key.json
bls_private_key_store_path: config-files/devnet/keys/operator-1.bls.key.json
signer_type: local_keystore
Expand Down
31 changes: 16 additions & 15 deletions config-files/config-operator-2.yaml
Original file line number Diff line number Diff line change
@@ -1,37 +1,38 @@
# Common variables for all the services
# 'production' only prints info and above. 'development' also prints debug
environment: "development"
aligned_layer_deployment_config_file_path: "./contracts/script/output/devnet/alignedlayer_deployment_output.json"
eigen_layer_deployment_config_file_path: "./contracts/script/output/devnet/eigenlayer_deployment_output.json"
eth_rpc_url: "http://localhost:8545"
eth_rpc_url_fallback: "http://localhost:8545"
eth_ws_url: "ws://localhost:8545"
eth_ws_url_fallback: "ws://localhost:8545"
eigen_metrics_ip_port_address: "localhost:9090"
environment: 'development'
aligned_layer_deployment_config_file_path: './contracts/script/output/devnet/alignedlayer_deployment_output.json'
eigen_layer_deployment_config_file_path: './contracts/script/output/devnet/eigenlayer_deployment_output.json'
eth_rpc_url: 'http://localhost:8545'
eth_rpc_url_fallback: 'http://localhost:8545'
eth_ws_url: 'ws://localhost:8545'
eth_ws_url_fallback: 'ws://localhost:8545'
eigen_metrics_ip_port_address: 'localhost:9090'

## ECDSA Configurations
ecdsa:
private_key_store_path: "config-files/devnet/keys/operator-2.ecdsa.key.json"
private_key_store_password: ""
private_key_store_path: 'config-files/devnet/keys/operator-2.ecdsa.key.json'
private_key_store_password: ''

## BLS Configurations
bls:
private_key_store_path: "config-files/devnet/keys/operator-2.bls.key.json"
private_key_store_password: ""
private_key_store_path: 'config-files/devnet/keys/operator-2.bls.key.json'
private_key_store_password: ''

## Operator Configurations
operator:
aggregator_rpc_server_ip_port_address: localhost:8090
operator_tracker_ip_port_address: http://localhost:3030
address: 0x3C44CdDdB6a900fa2b585dd299e03d12FA4293BC
earnings_receiver_address: 0x3C44CdDdB6a900fa2b585dd299e03d12FA4293BC
delegation_approver_address: "0x0000000000000000000000000000000000000000"
delegation_approver_address: '0x0000000000000000000000000000000000000000'
staker_opt_out_window_blocks: 0
metadata_url: "https://yetanotherco.github.io/operator_metadata/metadata.json"
metadata_url: 'https://yetanotherco.github.io/operator_metadata/metadata.json'
max_batch_size: 268435456 # 256 MiB
last_processed_batch_filepath: 'config-files/operator-2.last_processed_batch.json'

# Operators variables needed for register it in EigenLayer
el_delegation_manager_address: "0xCf7Ed3AccA5a467e9e704C703E8D87F634fB0Fc9"
el_delegation_manager_address: '0xCf7Ed3AccA5a467e9e704C703E8D87F634fB0Fc9'
private_key_store_path: config-files/devnet/keys/operator-2.ecdsa.key.json
bls_private_key_store_path: config-files/devnet/keys/operator-2.bls.key.json
signer_type: local_keystore
Expand Down
31 changes: 16 additions & 15 deletions config-files/config-operator-3.yaml
Original file line number Diff line number Diff line change
@@ -1,37 +1,38 @@
# Common variables for all the services
# 'production' only prints info and above. 'development' also prints debug
environment: "development"
aligned_layer_deployment_config_file_path: "./contracts/script/output/devnet/alignedlayer_deployment_output.json"
eigen_layer_deployment_config_file_path: "./contracts/script/output/devnet/eigenlayer_deployment_output.json"
eth_rpc_url: "http://localhost:8545"
eth_rpc_url_fallback: "http://localhost:8545"
eth_ws_url: "ws://localhost:8545"
eth_ws_url_fallback: "ws://localhost:8545"
eigen_metrics_ip_port_address: "localhost:9090"
environment: 'development'
aligned_layer_deployment_config_file_path: './contracts/script/output/devnet/alignedlayer_deployment_output.json'
eigen_layer_deployment_config_file_path: './contracts/script/output/devnet/eigenlayer_deployment_output.json'
eth_rpc_url: 'http://localhost:8545'
eth_rpc_url_fallback: 'http://localhost:8545'
eth_ws_url: 'ws://localhost:8545'
eth_ws_url_fallback: 'ws://localhost:8545'
eigen_metrics_ip_port_address: 'localhost:9090'

## ECDSA Configurations
ecdsa:
private_key_store_path: "config-files/devnet/keys/operator-3.ecdsa.key.json"
private_key_store_password: ""
private_key_store_path: 'config-files/devnet/keys/operator-3.ecdsa.key.json'
private_key_store_password: ''

## BLS Configurations
bls:
private_key_store_path: "config-files/devnet/keys/operator-3.bls.key.json"
private_key_store_password: ""
private_key_store_path: 'config-files/devnet/keys/operator-3.bls.key.json'
private_key_store_password: ''

## Operator Configurations
operator:
aggregator_rpc_server_ip_port_address: localhost:8090
operator_tracker_ip_port_address: http://localhost:3030
address: 0x90F79bf6EB2c4f870365E785982E1f101E93b906
earnings_receiver_address: 0x90F79bf6EB2c4f870365E785982E1f101E93b906
delegation_approver_address: "0x0000000000000000000000000000000000000000"
delegation_approver_address: '0x0000000000000000000000000000000000000000'
staker_opt_out_window_blocks: 0
metadata_url: "https://yetanotherco.github.io/operator_metadata/metadata.json"
metadata_url: 'https://yetanotherco.github.io/operator_metadata/metadata.json'
max_batch_size: 268435456 # 256 MiB
last_processed_batch_filepath: 'config-files/operator-3.last_processed_batch.json'

# Operators variables needed for register it in EigenLayer
el_delegation_manager_address: "0xCf7Ed3AccA5a467e9e704C703E8D87F634fB0Fc9"
el_delegation_manager_address: '0xCf7Ed3AccA5a467e9e704C703E8D87F634fB0Fc9'
private_key_store_path: config-files/devnet/keys/operator-3.ecdsa.key.json
bls_private_key_store_path: config-files/devnet/keys/operator-3.bls.key.json
signer_type: local_keystore
Expand Down
33 changes: 17 additions & 16 deletions config-files/config-operator.yaml
Original file line number Diff line number Diff line change
@@ -1,33 +1,34 @@
# Common variables for all the services
# 'production' only prints info and above. 'development' also prints debug
environment: "production"
aligned_layer_deployment_config_file_path: "./contracts/script/output/holesky/alignedlayer_deployment_output.json"
eigen_layer_deployment_config_file_path: "./contracts/script/output/holesky/eigenlayer_deployment_output.json"
eth_rpc_url: "https://ethereum-holesky-rpc.publicnode.com"
eth_rpc_url_fallback: "https://ethereum-holesky-rpc.publicnode.com"
eth_ws_url: "wss://ethereum-holesky-rpc.publicnode.com"
eth_ws_url_fallback: "wss://ethereum-holesky-rpc.publicnode.com"
eigen_metrics_ip_port_address: "localhost:9090"
environment: 'production'
aligned_layer_deployment_config_file_path: './contracts/script/output/holesky/alignedlayer_deployment_output.json'
eigen_layer_deployment_config_file_path: './contracts/script/output/holesky/eigenlayer_deployment_output.json'
eth_rpc_url: 'https://ethereum-holesky-rpc.publicnode.com'
eth_rpc_url_fallback: 'https://ethereum-holesky-rpc.publicnode.com'
eth_ws_url: 'wss://ethereum-holesky-rpc.publicnode.com'
eth_ws_url_fallback: 'wss://ethereum-holesky-rpc.publicnode.com'
eigen_metrics_ip_port_address: 'localhost:9090'

## ECDSA Configurations
ecdsa:
private_key_store_path: "<ecdsa_key_store_location_path>"
private_key_store_password: "<ecdsa_key_store_password>"
private_key_store_path: '<ecdsa_key_store_location_path>'
private_key_store_password: '<ecdsa_key_store_password>'

## BLS Configurations
bls:
private_key_store_path: "<bls_key_store_location_path>"
private_key_store_password: "<bls_key_store_password>"
private_key_store_path: '<bls_key_store_location_path>'
private_key_store_password: '<bls_key_store_password>'

## Operator Configurations
operator:
aggregator_rpc_server_ip_port_address: aggregator.alignedlayer.com:8090
operator_tracker_ip_port_address: https://holesky.tracker.alignedlayer.com
address: "<operator_address>"
earnings_receiver_address: "<earnings_receiver_address>" #Can be the same as the operator.
delegation_approver_address: "0x0000000000000000000000000000000000000000"
address: '<operator_address>'
earnings_receiver_address: '<earnings_receiver_address>' #Can be the same as the operator.
delegation_approver_address: '0x0000000000000000000000000000000000000000'
staker_opt_out_window_blocks: 0
metadata_url: "https://yetanotherco.github.io/operator_metadata/metadata.json"
metadata_url: 'https://yetanotherco.github.io/operator_metadata/metadata.json'
enable_metrics: true
metrics_ip_port_address: localhost:9092
max_batch_size: 268435456 # 256 MiB
last_processed_batch_filepath: 'config-files/operator.last_processed_batch.json'
31 changes: 16 additions & 15 deletions config-files/config.yaml
Original file line number Diff line number Diff line change
@@ -1,23 +1,23 @@
# Common variables for all the services
# 'production' only prints info and above. 'development' also prints debug
environment: "production"
aligned_layer_deployment_config_file_path: "./contracts/script/output/devnet/alignedlayer_deployment_output.json"
eigen_layer_deployment_config_file_path: "./contracts/script/output/devnet/eigenlayer_deployment_output.json"
eth_rpc_url: "http://localhost:8545"
eth_rpc_url_fallback: "http://localhost:8545"
eth_ws_url: "ws://localhost:8545"
eth_ws_url_fallback: "ws://localhost:8545"
eigen_metrics_ip_port_address: "localhost:9090"
environment: 'production'
aligned_layer_deployment_config_file_path: './contracts/script/output/devnet/alignedlayer_deployment_output.json'
eigen_layer_deployment_config_file_path: './contracts/script/output/devnet/eigenlayer_deployment_output.json'
eth_rpc_url: 'http://localhost:8545'
eth_rpc_url_fallback: 'http://localhost:8545'
eth_ws_url: 'ws://localhost:8545'
eth_ws_url_fallback: 'ws://localhost:8545'
eigen_metrics_ip_port_address: 'localhost:9090'

## ECDSA Configurations
ecdsa:
private_key_store_path: "config-files/anvil.ecdsa.key.json"
private_key_store_password: ""
private_key_store_path: 'config-files/anvil.ecdsa.key.json'
private_key_store_password: ''

## BLS Configurations
bls:
private_key_store_path: "config-files/anvil.bls.key.json"
private_key_store_password: ""
private_key_store_path: 'config-files/anvil.bls.key.json'
private_key_store_password: ''

## Batcher configurations
batcher:
Expand All @@ -42,14 +42,15 @@ operator:
operator_tracker_ip_port_address: http://localhost:3030
address: 0xf39Fd6e51aad88F6F4ce6aB8827279cffFb92266
earnings_receiver_address: 0xf39Fd6e51aad88F6F4ce6aB8827279cffFb92266
delegation_approver_address: "0x0000000000000000000000000000000000000000"
delegation_approver_address: '0x0000000000000000000000000000000000000000'
staker_opt_out_window_blocks: 0
metadata_url: "https://yetanotherco.github.io/operator_metadata/metadata.json"
metadata_url: 'https://yetanotherco.github.io/operator_metadata/metadata.json'
enable_metrics: true
metrics_ip_port_address: localhost:9092
max_batch_size: 268435456 # 256 MiB
last_processed_batch_filepath: config-files/operator.last_processed_batch.json
# Operators variables needed for register it in EigenLayer
el_delegation_manager_address: "0xCf7Ed3AccA5a467e9e704C703E8D87F634fB0Fc9"
el_delegation_manager_address: '0xCf7Ed3AccA5a467e9e704C703E8D87F634fB0Fc9'
private_key_store_path: config-files/anvil.ecdsa.key.json
bls_private_key_store_path: config-files/anvil.bls.key.json
signer_type: local_keystore
Expand Down
56 changes: 48 additions & 8 deletions core/chainio/avs_reader.go
Original file line number Diff line number Diff line change
@@ -1,8 +1,12 @@
package chainio

import (
"context"

"github.com/ethereum/go-ethereum/accounts/abi/bind"
gethcommon "github.com/ethereum/go-ethereum/common"
ethcommon "github.com/ethereum/go-ethereum/common"
"github.com/ethereum/go-ethereum/crypto"
servicemanager "github.com/yetanotherco/aligned_layer/contracts/bindings/AlignedLayerServiceManager"
contractERC20Mock "github.com/yetanotherco/aligned_layer/contracts/bindings/ERC20Mock"
"github.com/yetanotherco/aligned_layer/core/config"

Expand All @@ -13,8 +17,9 @@ import (

type AvsReader struct {
*sdkavsregistry.ChainReader
AvsContractBindings *AvsServiceBindings
logger logging.Logger
AvsContractBindings *AvsServiceBindings
AlignedLayerServiceManagerAddr ethcommon.Address
logger logging.Logger
}

func NewAvsReaderFromConfig(baseConfig *config.BaseConfig, ecdsaConfig *config.EcdsaConfig) (*AvsReader, error) {
Expand All @@ -41,13 +46,14 @@ func NewAvsReaderFromConfig(baseConfig *config.BaseConfig, ecdsaConfig *config.E
}

return &AvsReader{
ChainReader: chainReader,
AvsContractBindings: avsServiceBindings,
logger: baseConfig.Logger,
ChainReader: chainReader,
AvsContractBindings: avsServiceBindings,
AlignedLayerServiceManagerAddr: baseConfig.AlignedLayerDeploymentConfig.AlignedLayerServiceManagerAddr,
logger: baseConfig.Logger,
}, nil
}

func (r *AvsReader) GetErc20Mock(tokenAddr gethcommon.Address) (*contractERC20Mock.ContractERC20Mock, error) {
func (r *AvsReader) GetErc20Mock(tokenAddr ethcommon.Address) (*contractERC20Mock.ContractERC20Mock, error) {
erc20Mock, err := contractERC20Mock.NewContractERC20Mock(tokenAddr, &r.AvsContractBindings.ethClient)
if err != nil {
// Retry with fallback client
Expand All @@ -59,6 +65,40 @@ func (r *AvsReader) GetErc20Mock(tokenAddr gethcommon.Address) (*contractERC20Mo
return erc20Mock, nil
}

func (r *AvsReader) IsOperatorRegistered(address gethcommon.Address) (bool, error) {
func (r *AvsReader) IsOperatorRegistered(address ethcommon.Address) (bool, error) {
return r.ChainReader.IsOperatorRegistered(&bind.CallOpts{}, address)
}

// Returns all the "NewBatchV3" logs that have not been responded starting from the given block number
func (r *AvsReader) GetNotRespondedTasksFrom(fromBlock uint64) ([]servicemanager.ContractAlignedLayerServiceManagerNewBatchV3, error) {
logs, err := r.AvsContractBindings.ServiceManager.FilterNewBatchV3(&bind.FilterOpts{Start: fromBlock, End: nil, Context: context.Background()}, nil)

if err != nil {
return nil, err
}

var tasks []servicemanager.ContractAlignedLayerServiceManagerNewBatchV3

for logs.Next() {
task, err := r.AvsContractBindings.ServiceManager.ParseNewBatchV3(logs.Event.Raw)
if err != nil {
return nil, err
}

// now check if its finalized or not before appending
batchIdentifier := append(task.BatchMerkleRoot[:], task.SenderAddress[:]...)
batchIdentifierHash := *(*[32]byte)(crypto.Keccak256(batchIdentifier))
state, err := r.AvsContractBindings.ServiceManager.ContractAlignedLayerServiceManagerCaller.BatchesState(nil, batchIdentifierHash)

if err != nil {
return nil, err
}

// append the task if not responded yet
if !state.Responded {
tasks = append(tasks, *task)
}
}

return tasks, nil
}
Loading