Skip to content

Commit

Permalink
temp: fix one client pk for payment, contracts setup
Browse files Browse the repository at this point in the history
  • Loading branch information
hopeyen committed Dec 13, 2024
1 parent a48c8bb commit edc9cb7
Show file tree
Hide file tree
Showing 4 changed files with 75 additions and 1 deletion.
52 changes: 51 additions & 1 deletion contracts/script/SetUpEigenDA.s.sol
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,8 @@ import {StakeRegistry} from "eigenlayer-middleware/StakeRegistry.sol";
import {IIndexRegistry} from "eigenlayer-middleware/interfaces/IIndexRegistry.sol";

import {EigenDAServiceManager} from "../src/core/EigenDAServiceManager.sol";
import {PaymentVault} from "../src/payments/PaymentVault.sol";
import {IPaymentVault} from "../src/interfaces/IPaymentVault.sol";
import {EigenDAHasher} from "../src/libraries/EigenDAHasher.sol";
import {EigenDADeployer} from "./EigenDADeployer.s.sol";
import {EigenLayerUtils} from "./EigenLayerUtils.s.sol";
Expand Down Expand Up @@ -111,9 +113,20 @@ contract SetupEigenDA is EigenDADeployer, EigenLayerUtils {
operatorETHAmounts[i] = 5 ether;
}

uint256[] memory clientPrivateKeys = stdJson.readUintArray(config_data, ".clientPrivateKeys");
address[] memory clients = new address[](clientPrivateKeys.length);
for (uint i = 0; i < clients.length; i++) {
clients[i] = vm.addr(clientPrivateKeys[i]);
}
uint256[] memory clientETHAmounts = new uint256[](clients.length);
// 0.5 eth each
for (uint i = 0; i < clientETHAmounts.length; i++) {
clientETHAmounts[i] = 0.5 ether;
}

vm.startBroadcast();

// Allocate eth to stakers and operators
// Allocate eth to stakers, operators, dispserser clients
_allocate(
IERC20(address(0)),
stakers,
Expand All @@ -126,6 +139,12 @@ contract SetupEigenDA is EigenDADeployer, EigenLayerUtils {
operatorETHAmounts
);

_allocate(
IERC20(address(0)),
clients,
clientETHAmounts
);

// Allocate tokens to stakers
for (uint8 i = 0; i < numStrategies; i++) {
_allocate(
Expand Down Expand Up @@ -156,6 +175,37 @@ contract SetupEigenDA is EigenDADeployer, EigenLayerUtils {
delegation.registerAsOperator(IDelegationManager.OperatorDetails(earningsReceiver, delegationApprover, stakerOptOutWindowBlocks), metadataURI);
}



// Register Reservations for client 0 and 1 as the eigenDACommunityMultisig
clientPrivateKeys[0] = 0x0123456789abcdef0123456789abcdef0123456789abcdef0123456789abcded;
IPaymentVault.Reservation memory reservation = IPaymentVault.Reservation({
symbolsPerSecond: 452198,
startTimestamp: uint64(block.timestamp),
endTimestamp: uint64(block.timestamp + 1000000000),
quorumNumbers: hex"0001",
quorumSplits: hex"3232"
});
vm.broadcast(clientPrivateKeys[0]);
address reservedClient = address(uint160(uint256(keccak256(abi.encodePacked(clientPrivateKeys[0])))));
// vm.prank(eigenDACommunityMultisig);
paymentVault.setReservation(reservedClient, reservation);

vm.broadcast(clientPrivateKeys[1]);
address reservedClient1 = address(uint160(uint256(keccak256(abi.encodePacked(clientPrivateKeys[1])))));
// vm.prank(eigenDACommunityMultisig);
paymentVault.setReservation(reservedClient1, reservation);

// Deposit OnDemand for client 0 and 2
vm.broadcast(operatorPrivateKeys[0]);
address ondemandClient = address(uint160(uint256(keccak256(abi.encodePacked(operatorPrivateKeys[0])))));
vm.prank(ondemandClient);
paymentVault.depositOnDemand{value: 0.1 ether}(ondemandClient);
// vm.broadcast(operatorPrivateKeys[2]);
// address ondemandClient2 = address(uint160(uint256(keccak256(abi.encodePacked(operatorPrivateKeys[2])))));
// vm.prank(ondemandClient2);
// PaymentVault.depositOnDemand{value: 1 ether}(ondemandClient2);

// Deposit stakers into EigenLayer and delegate to operators
for (uint256 i = 0; i < stakerPrivateKeys.length; i++) {
vm.startBroadcast(stakerPrivateKeys[i]);
Expand Down
14 changes: 14 additions & 0 deletions inabox/deploy/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -707,6 +707,20 @@ func (env *Config) GenerateAllVariables() {
filename, []string{grpcPort})
}

// // Payment clients
// for i := 0; i < env.Services.Counts.NumOpr; i++ {

// name := fmt.Sprintf("staker%v", i)
// key, address := env.getKey(name)

// // Create staker paritipants
// participant := Staker{
// Address: address,
// PrivateKey: key[2:],
// }
// env.Stakers = append(env.Stakers, participant)
// }

name = "retriever0"
key, _ = env.getKey(name)
logPath, _, _, envFile = env.getPaths(name)
Expand Down
2 changes: 2 additions & 0 deletions inabox/deploy/config_types.go
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,7 @@ type EigenDADeployConfig struct {
ConfirmerPrivateKey string `json:"confirmerPrivateKey"`
StakerTokenAmounts [][]string `json:"-"`
OperatorPrivateKeys []string `json:"-"`
ClientPrivateKeys []string `json:"clientPrivateKeys"`
}

func (cfg *EigenDADeployConfig) MarshalJSON() ([]byte, error) {
Expand Down Expand Up @@ -85,6 +86,7 @@ func (cfg *EigenDADeployConfig) MarshalJSON() ([]byte, error) {
"maxOperatorCount": cfg.MaxOperatorCount,
"stakerPrivateKeys": cfg.StakerPrivateKeys,
"confirmerPrivateKey": cfg.ConfirmerPrivateKey,
"clientPrivateKeys": cfg.ClientPrivateKeys,
}

remainingJSON, err := json.Marshal(remainingFields)
Expand Down
8 changes: 8 additions & 0 deletions inabox/deploy/deploy.go
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,7 @@ func (env *Config) generateEigenDADeployConfig() EigenDADeployConfig {

operators := make([]string, 0)
stakers := make([]string, 0)
clients := make([]string, 0)
maxOperatorCount := env.Services.Counts.NumMaxOperatorCount

numStrategies := len(env.Services.Stakes)
Expand Down Expand Up @@ -71,13 +72,20 @@ func (env *Config) generateEigenDADeployConfig() EigenDADeployConfig {
operators = append(operators, env.getKeyString(operatorName))
}

// 4 clients: with both, with reservations, with on-demand payments, without payments
for i := 0; i < 4; i++ {
clientName := fmt.Sprintf("client%d", i)
clients = append(clients, env.getKeyString(clientName))
}

config := EigenDADeployConfig{
UseDefaults: true,
NumStrategies: numStrategies,
MaxOperatorCount: maxOperatorCount,
StakerPrivateKeys: stakers,
StakerTokenAmounts: stakes,
OperatorPrivateKeys: operators,
ClientPrivateKeys: clients,
ConfirmerPrivateKey: env.getKeyString("batcher0"),
}

Expand Down

0 comments on commit edc9cb7

Please sign in to comment.