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

Slashing #171

Draft
wants to merge 73 commits into
base: main
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
73 commits
Select commit Hold shift + click to select a range
e64e5de
add get staker shares method
TomasArrachea Nov 14, 2024
7f4378f
add get_delegated_operator method
TomasArrachea Nov 14, 2024
caca28e
change eigen middleware submodule to slashing branch
TomasArrachea Nov 19, 2024
f4afa71
upload updated bindings
TomasArrachea Nov 20, 2024
eb006a0
update middleware rev
Nov 21, 2024
e513be2
working bindings
TomasArrachea Nov 21, 2024
d4c0a26
restore deleted bindings
TomasArrachea Nov 21, 2024
37696a4
update get_staker_shares method
TomasArrachea Nov 21, 2024
fb4babf
remove deprecated methods and update ElChainReader attributes
TomasArrachea Nov 21, 2024
8b348dc
add mockavsservicemanager binding
TomasArrachea Nov 21, 2024
cac51e8
update ElContract Reader tests
TomasArrachea Nov 21, 2024
c9ef2a4
wip scripts
Nov 22, 2024
177ed4c
port scripts from incredible squaring
Nov 22, 2024
349b40d
update elcontracts writer
TomasArrachea Nov 22, 2024
277d61d
add elcontracts reader build method
TomasArrachea Nov 22, 2024
29afec5
add bindings
TomasArrachea Nov 22, 2024
1903878
add missing bindings
TomasArrachea Nov 22, 2024
7fc3b85
fix examples
TomasArrachea Nov 22, 2024
6f1c5ba
cargo fmt
TomasArrachea Nov 22, 2024
75ccd80
remove added bindings
TomasArrachea Nov 22, 2024
4fae355
fix bindings lib
TomasArrachea Nov 22, 2024
70e1e05
remove more bindings
TomasArrachea Nov 22, 2024
403f027
wip : scripts
Nov 25, 2024
651460e
ignore failing tests due to anvil state not updated
TomasArrachea Nov 25, 2024
bbd91dc
Merge branch 'main' into slashing_methods
TomasArrachea Nov 25, 2024
b48ecce
ignore tests
TomasArrachea Nov 25, 2024
b490ed0
add get_operators_for_operator_set method
TomasArrachea Nov 25, 2024
65db644
add updated bindings
TomasArrachea Nov 25, 2024
ceb82ef
wip : state load issue
Nov 26, 2024
cccec71
remove extra bindings
TomasArrachea Nov 22, 2024
21d812c
Merge branch 'slashing_methods' into add_slashing_methods
TomasArrachea Nov 26, 2024
ba83e54
fix getAllocatedSets return type
TomasArrachea Nov 26, 2024
f12f366
add get_strategies_for_operator_set method
TomasArrachea Nov 26, 2024
72f9650
pin anvil version
TomasArrachea Nov 26, 2024
7ab4a89
add get_operators_sets_for_operator method
TomasArrachea Nov 26, 2024
7d5a3f0
add get_delegated_and_slashable_shares_for_operator_sets_before method
TomasArrachea Nov 26, 2024
90947bf
add get_registered_sets method
TomasArrachea Nov 26, 2024
562413c
add get_allocation_delay method
TomasArrachea Nov 26, 2024
e3ec1e9
add get_slashable_shares_for_operator_sets method
TomasArrachea Nov 26, 2024
10060f5
add get_num_operators_for_operator_set method
TomasArrachea Nov 26, 2024
d80b4c5
add is_operator_registered_with_operator_set method
TomasArrachea Nov 26, 2024
148257c
add get_num_operator_sets_for_operator method
TomasArrachea Nov 26, 2024
dc9c6d9
add get_operators_shares method
TomasArrachea Nov 26, 2024
1e8e4a2
add get_operator_shares method
TomasArrachea Nov 26, 2024
e43ef8c
add get_allocation_info method
TomasArrachea Nov 26, 2024
7334a26
add get_max_magnitudes method
TomasArrachea Nov 26, 2024
4115a47
add get_allocatable_magnitude method
TomasArrachea Nov 26, 2024
6524f07
cargo fmt
TomasArrachea Nov 26, 2024
2c18682
Merge branch 'slashing_methods' into add_slashing_methods
TomasArrachea Nov 26, 2024
ca80e80
fix anvil version
TomasArrachea Nov 26, 2024
864ca99
clippy
TomasArrachea Nov 26, 2024
186f517
Merge branch 'slashing_methods' into add_slashing_methods
TomasArrachea Nov 26, 2024
d988583
restore anvil version to latest
TomasArrachea Nov 27, 2024
ef89f17
add updated anvil state
TomasArrachea Nov 27, 2024
7c0fc7b
update solc version of foyndry.toml
TomasArrachea Nov 27, 2024
ed1eba3
format solidity scripts
TomasArrachea Nov 27, 2024
a334e80
get_cumulative_claimed_for_root
pablodeymo Nov 27, 2024
2fbf75a
udpated CoreDeploymentLib.sol for slashing contracts
TomasArrachea Nov 27, 2024
e3272b4
add test_is_operator_registered
TomasArrachea Nov 27, 2024
cbb22f4
add test_get_staker_shares
TomasArrachea Nov 27, 2024
2379dd5
add test_get_delegated_operator
TomasArrachea Nov 27, 2024
bbe92d2
fix deploy eigenlayer
TomasArrachea Nov 28, 2024
09ae574
add forge script broadcast flag
TomasArrachea Nov 28, 2024
ffe9ed4
fix deploy avs
TomasArrachea Nov 28, 2024
e1eaa73
update anvil state
TomasArrachea Nov 28, 2024
876b862
test_get_registered_sets
pablodeymo Nov 28, 2024
ff30d78
update anvil state
TomasArrachea Nov 28, 2024
d4fa852
remove ignore on tests
TomasArrachea Nov 28, 2024
c439589
Add slashing bindings (#163)
TomasArrachea Nov 29, 2024
09e2b37
Merge branch 'anvil_state_for_slashing' into slashing
TomasArrachea Nov 29, 2024
9d127cb
Merge branch 'add_slashing_methods' into slashing
TomasArrachea Nov 29, 2024
e337eb5
clippy
TomasArrachea Nov 29, 2024
8d59985
changes from the PR with rewards methods
pablodeymo Nov 29, 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
4 changes: 4 additions & 0 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -104,7 +104,7 @@ serde_json = "1.0"
serial_test = "3.1"
syn = "2.0"
tempfile = "3.13"
testcontainers = "0.23"
testcontainers = "0.23.1"
thiserror = "1.0"
tokio = { version = "1.41", features = ["test-util", "full", "sync"] }
tracing = "0.1"
Expand Down
11 changes: 11 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,17 @@ start-anvil-chain-with-contracts-deployed: ##
deploy-contracts-to-anvil-and-save-state: ##
./crates/contracts/anvil/deploy-contracts-save-anvil-state.sh

deploy-eigenlayer:
./crates/contracts/anvil/deploy-eigenlayer.sh

deploy-avs:
chmod +x ./crates/contracts/anvil/deploy-avs.sh
./crates/contracts/anvil/deploy-avs.sh

dump-state:
chmod +x ./crates/contracts/anvil/dump-state.sh
./crates/contracts/anvil/dump-state.sh

__TESTING__: ##

reset-anvil:
Expand Down
62 changes: 41 additions & 21 deletions crates/chainio/clients/avsregistry/src/writer.rs
Original file line number Diff line number Diff line change
Expand Up @@ -188,7 +188,6 @@ impl AvsRegistryChainWriter {
.sign_hash(&msg_to_sign)
.await
.map_err(|_| AvsRegistryError::InvalidSignature)?;

let operator_signature_with_salt_and_expiry = SignatureWithSaltAndExpiry {
signature: operator_signature.as_bytes().into(),
salt: operator_to_avs_registration_sig_salt,
Expand Down Expand Up @@ -220,8 +219,7 @@ impl AvsRegistryChainWriter {
.send()
.await
.map_err(AvsRegistryError::AlloyContractError)?;

info!(tx_hash = ?tx,"Sent transaction to register operator in the AVS's registry coordinator" );
info!(tx_hash = ?tx.tx_hash(),"Sent transaction to register operator in the AVS's registry coordinator" );
Ok(*tx.tx_hash())
}

Expand Down Expand Up @@ -336,19 +334,21 @@ mod tests {
use eigen_testing_utils::anvil::start_anvil_container;
use eigen_testing_utils::anvil_constants::{
get_operator_state_retriever_address, get_registry_coordinator_address,
register_operator_to_el_if_not_registered,
};
use eigen_testing_utils::transaction::wait_transaction;
use std::str::FromStr;
use eigen_utils::delegationmanager::IDelegationManagerTypes::OperatorDetails;

async fn build_avs_registry_chain_writer(
http_endpoint: String,
private_key: String,
) -> AvsRegistryChainWriter {
let registry_coordinator_address =
get_registry_coordinator_address(http_endpoint.clone()).await;
println!("reg_coordinator{:?}", registry_coordinator_address);
let operator_state_retriever_address =
get_operator_state_retriever_address(http_endpoint.clone()).await;

println!("op_state{:?}", operator_state_retriever_address);
AvsRegistryChainWriter::build_avs_registry_chain_writer(
get_test_logger(),
http_endpoint,
Expand All @@ -361,35 +361,52 @@ mod tests {
}

#[tokio::test]
#[ignore] // TODO: fix problems with anvil new version
async fn test_avs_writer_methods() {
let (_container, http_endpoint, _ws_endpoint) = start_anvil_container().await;

// start_anvil_docker().await;
// let http_endpoint = "http://localhost:8545";
let bls_key =
"1371012690269088913462269866874713266643928125698382731338806296762673180359922"
.to_string();
let private_key =
"8b3a350cf5c34c9194ca85829a2df0ec3153be0318b5e2d3348e872092edffba".to_string();
let avs_writer = build_avs_registry_chain_writer(http_endpoint.clone(), private_key).await;
let operator_addr = Address::from_str("9965507D1a55bcC2695C58ba16FB37d819B0A4dc").unwrap();
let operator_details = OperatorDetails {
__deprecated_earningsReceiver: Address::ZERO,
delegationApprover: Address::ZERO,
__deprecated_stakerOptOutWindowBlocks: 0,
};
register_operator_to_el_if_not_registered(
&private_key,
&http_endpoint,
operator_details,
"uri",
)
.await
.unwrap();
let avs_writer =
build_avs_registry_chain_writer(http_endpoint.clone().to_string(), private_key).await;
let quorum_nums = Bytes::from([0]);

test_register_operator(
&avs_writer,
bls_key,
quorum_nums.clone(),
http_endpoint.clone(),
http_endpoint.clone().to_string(),
)
.await;
test_update_stake_of_operator_subset(&avs_writer, operator_addr, http_endpoint.clone())
.await;
test_update_stake_of_entire_operator_set(
&avs_writer,
operator_addr,
quorum_nums.clone(),
http_endpoint.clone(),
)
.await;
test_deregister_operator(&avs_writer, quorum_nums, http_endpoint).await;

//let operator_addr = Address::from_str("9965507D1a55bcC2695C58ba16FB37d819B0A4dc").unwrap();
// test_update_stake_of_operator_subset(&avs_writer, operator_addr, http_endpoint.clone())
// .await;
// test_update_stake_of_entire_operator_set(
// &avs_writer,
// operator_addr,
// quorum_nums.clone(),
// http_endpoint.clone(),
// )
// .await;
// test_deregister_operator(&avs_writer, quorum_nums, http_endpoint).await;
}

// this function is caller from test_avs_writer_methods
Expand Down Expand Up @@ -435,6 +452,9 @@ mod tests {

// this is set to U256::MAX so that the registry does not take the signature as expired.
let signature_expiry = U256::MAX;
//use std::str::FromStr;
//use alloy::transports::http::reqwest::Url;
//let url = Url::from_str(&http_url).unwrap();
let tx_hash = avs_writer
.register_operator_in_quorum_with_avs_registry_coordinator(
bls_key_pair,
Expand All @@ -444,8 +464,8 @@ mod tests {
"".into(),
)
.await
.unwrap();

.expect("regg");
println!("tx_hash{:?}", tx_hash);
let tx_status = wait_transaction(&http_url, tx_hash).await.unwrap().status();
assert!(tx_status);
}
Expand Down
3 changes: 3 additions & 0 deletions crates/chainio/clients/elcontracts/src/error.rs
Original file line number Diff line number Diff line change
Expand Up @@ -72,4 +72,7 @@ pub enum ElContractsError {

#[error("Alloy pending Transaction error {0}")]
AlloyPendingTransactionError(#[from] PendingTransactionError),

#[error("Allocation delay not set for operator")]
AllocationDelayNotSet,
}
Loading
Loading