-
Notifications
You must be signed in to change notification settings - Fork 3
feat: support EigenLayer middleware v1.0.3 #21
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
Open
uri-lightblocks
wants to merge
16
commits into
develop
Choose a base branch
from
testnet
base: develop
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from 7 commits
Commits
Show all changes
16 commits
Select commit
Hold shift + click to select a range
1723489
fix dev-3913
flaviusburca 879be36
fix dev-3956
flaviusburca a17e79a
fix dev-4052
flaviusburca 6d337c8
fix dev-4052
flaviusburca 9b690aa
Merge remote-tracking branch 'origin/testnet' into testnet
flaviusburca 4067693
fix: add missing profile configs
flaviusburca 844bb9d
fix: update bindings for latest contracts
flaviusburca 78cc45d
fix: goreleaser build
uri-lightblocks 5d1cf49
fix: use proper go version
uri-lightblocks 77d1078
fix: add missing params
flaviusburca f19a9d9
Merge remote-tracking branch 'origin/testnet' into testnet
flaviusburca edab637
fix: update gas limit
flaviusburca d1c1091
fix: decoding alias wallet
flaviusburca ec90eb0
fix: decoding alias wallet
flaviusburca 08f5379
merge develop to testnet
uri-lightblocks fa9f38d
DEV-0000-eigenlayer-v0.3.0 (#22)
uri-lightblocks File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -29,3 +29,4 @@ go.work | |
| # configuration | ||
| .docker | ||
| .env | ||
| .idea | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,21 @@ | ||
| package cmd | ||
|
|
||
| import ( | ||
| "github.com/Layr-Labs/eigensdk-go/logging" | ||
| gethcommon "github.com/ethereum/go-ethereum/common" | ||
| ) | ||
|
|
||
| var ( | ||
| profile *NetworkProfile | ||
| logger, _ = logging.NewZapLogger(logging.Production) | ||
| ) | ||
|
|
||
| type NetworkProfile struct { | ||
| NetworkName string | ||
|
|
||
| EOConfigAddress gethcommon.Address | ||
| RegistryCoordinatorAddress gethcommon.Address | ||
|
|
||
| EOChainRPCEndpoint string | ||
| EthRPCEndpoint string | ||
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,110 @@ | ||
| package cmd | ||
|
|
||
| import ( | ||
| "context" | ||
| "crypto/ecdsa" | ||
| "github.com/Layr-Labs/eigensdk-go/chainio/clients/wallet" | ||
| "github.com/Layr-Labs/eigensdk-go/chainio/txmgr" | ||
| "github.com/Layr-Labs/eigensdk-go/signerv2" | ||
| eoconfig "github.com/eoracle/eoracle-operator-cli/contracts/bindings/EOConfig" | ||
| "github.com/ethereum/go-ethereum/cmd/utils" | ||
| "github.com/ethereum/go-ethereum/crypto" | ||
| "github.com/urfave/cli/v2" | ||
| ) | ||
|
|
||
| func NewDeclareAliasCommand() *cli.Command { | ||
| return &cli.Command{ | ||
| Name: "declare-alias", | ||
| Description: "Declare the alias in the eochain", | ||
| Before: setProfile, | ||
| Action: runDeclareAlias, | ||
| Flags: []cli.Flag{ | ||
| ProfileFlag, | ||
| PassphraseFlag, | ||
| KeyStorePathFlag, | ||
| EOChainRPCFlag, | ||
| EOConfigAddressFlag, | ||
| }, | ||
| } | ||
| } | ||
|
|
||
| func runDeclareAlias(c *cli.Context) error { | ||
| if !c.IsSet(PassphraseFlag.Name) || !c.IsSet(KeyStorePathFlag.Name) { | ||
| utils.Fatalf("passphrase and keystore-path are required") | ||
| } | ||
|
|
||
| ethEcdsaPair, aliasEcdsaPair, err := getOperatorAndAliasKeys(c) | ||
| if err != nil { | ||
| return err | ||
| } | ||
|
|
||
| txMgr, contractEOConfig, err := getTxMgrForEOChain(ethEcdsaPair) | ||
| if err != nil { | ||
| return err | ||
| } | ||
|
|
||
| noSendTxOpts, err := txMgr.GetNoSendTxOpts() | ||
| if err != nil { | ||
| utils.Fatalf("Error creating transaction object %v", err) | ||
| } | ||
|
|
||
| tx, err := contractEOConfig.DeclareAlias( | ||
| noSendTxOpts, | ||
| crypto.PubkeyToAddress(aliasEcdsaPair.PublicKey), | ||
| ) | ||
| if err != nil { | ||
| utils.Fatalf("Failed to create EOConfig.declareAlias transaction %v", err) | ||
| } | ||
|
|
||
| ctx := context.Background() | ||
| receipt, err := txMgr.Send(ctx, tx, true) | ||
| if err != nil { | ||
| utils.Fatalf("declareAlias transaction failed %s", err) | ||
| } | ||
|
|
||
| if receipt.Status != 1 { | ||
| utils.Fatalf( | ||
| "declareAlias transaction %v for operator %v on Ethereum mainnet/Holesky (%v) reverted", | ||
| receipt.TxHash.Hex(), | ||
| crypto.PubkeyToAddress(ethEcdsaPair.PublicKey), | ||
| profile.EOChainRPCEndpoint, | ||
| ) | ||
| } | ||
|
|
||
| logger.Info( | ||
| "successfully declared an alias in the eochain", | ||
| "Ethereum address", crypto.PubkeyToAddress(ethEcdsaPair.PublicKey), | ||
| "eochain address", crypto.PubkeyToAddress(aliasEcdsaPair.PublicKey), | ||
| "tx hash", receipt.TxHash.Hex(), | ||
| ) | ||
| return nil | ||
| } | ||
|
|
||
| func getTxMgrForEOChain(ethEcdsaPair *ecdsa.PrivateKey) (*txmgr.SimpleTxManager, *eoconfig.EOConfig, error) { | ||
| ethClient, err := createEthClient(profile.EOChainRPCEndpoint) | ||
| if err != nil { | ||
| return nil, nil, err | ||
| } | ||
|
|
||
| chainIDBigInt, err := ethClient.ChainID(context.Background()) | ||
| if err != nil { | ||
| utils.Fatalf("cannot get chainId (%v): %v", profile.EOChainRPCEndpoint, err) | ||
| } | ||
|
|
||
| signerV2, signerAddr, err := signerv2.SignerFromConfig(signerv2.Config{PrivateKey: ethEcdsaPair}, chainIDBigInt) | ||
| if err != nil { | ||
| utils.Fatalf("Error creating the signer function for %v %v", crypto.PubkeyToAddress(ethEcdsaPair.PublicKey), err) | ||
| } | ||
| txSender, err := wallet.NewPrivateKeyWallet(ethClient, signerV2, signerAddr, logger) | ||
| if err != nil { | ||
| utils.Fatalf("Failed to create transaction sender for declaring alias of operator %v on eoChain (%v) %v", | ||
| crypto.PubkeyToAddress(ethEcdsaPair.PublicKey), profile.EOChainRPCEndpoint, err) | ||
| } | ||
|
|
||
| contractEOConfig, err := eoconfig.NewEOConfig(profile.EOConfigAddress, ethClient) | ||
| if err != nil { | ||
| utils.Fatalf("Failed to bind the eoconfig contract %v", err) | ||
| } | ||
|
|
||
| return txmgr.NewSimpleTxManager(txSender, ethClient, logger, signerAddr), contractEOConfig, nil | ||
| } | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,52 @@ | ||
| package cmd | ||
|
|
||
| import ( | ||
| "encoding/hex" | ||
| "errors" | ||
| "fmt" | ||
| eigensdkecdsa "github.com/Layr-Labs/eigensdk-go/crypto/ecdsa" | ||
| "github.com/ethereum/go-ethereum/cmd/utils" | ||
| "github.com/ethereum/go-ethereum/crypto" | ||
| "github.com/urfave/cli/v2" | ||
| "os" | ||
| "path/filepath" | ||
| ) | ||
|
|
||
| func NewDecryptCommand() *cli.Command { | ||
| return &cli.Command{ | ||
| Name: "decrypt", | ||
| Description: "Decrypt the ecdsa and bls private keys", | ||
| Action: runDecrypt, | ||
| Flags: []cli.Flag{ | ||
| PassphraseFlag, | ||
| KeyStorePathFlag, | ||
| }, | ||
| } | ||
| } | ||
|
|
||
| func runDecrypt(c *cli.Context) error { | ||
| ecdsaPair, err := getECDSAPrivateKey(c) | ||
| if err != nil { | ||
| utils.Fatalf("Error reading the ecdsaEncryptedWallet.json file %v", err) | ||
| } | ||
| fmt.Println("ecdsa address ", crypto.PubkeyToAddress(ecdsaPair.PublicKey), "private key", hex.EncodeToString(ecdsaPair.D.Bytes())) | ||
|
|
||
| ecdsaEOChainPair, err := eigensdkecdsa.ReadKey(filepath.Join(c.String(KeyStorePathFlag.Name), "ecdsaAliasedEncryptedWallet.json"), c.String(PassphraseFlag.Name)) | ||
| if err != nil { | ||
| if errors.Is(err, os.ErrNotExist) { | ||
| fmt.Println("eochain alias was not set in the system") | ||
| return nil | ||
| } | ||
| utils.Fatalf("Error reading the ecdsaAliasedEncryptedWallet.json file %v", err) | ||
| } | ||
| fmt.Println("EOChain ecdsa address ", crypto.PubkeyToAddress(ecdsaEOChainPair.PublicKey), "private key", hex.EncodeToString(ecdsaEOChainPair.D.Bytes())) | ||
|
|
||
| blsKeyPair, err := getBLSPrivateKey(c) | ||
| if err != nil { | ||
| utils.Fatalf("Error reading the blsEncryptedWallet.json file %v", err) | ||
| } | ||
|
|
||
| fmt.Println("bls address G1, G2 ", blsKeyPair.GetPubKeyG1().String(), ", ", blsKeyPair.GetPubKeyG2().String(), "private key", blsKeyPair.PrivKey.String()) | ||
|
|
||
| return nil | ||
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,122 @@ | ||
| package cmd | ||
|
|
||
| import ( | ||
| "context" | ||
| "github.com/Layr-Labs/eigensdk-go/chainio/clients/wallet" | ||
| "github.com/Layr-Labs/eigensdk-go/chainio/txmgr" | ||
| "github.com/Layr-Labs/eigensdk-go/signerv2" | ||
| "github.com/ethereum/go-ethereum/cmd/utils" | ||
| "github.com/ethereum/go-ethereum/crypto" | ||
| "github.com/urfave/cli/v2" | ||
| ) | ||
|
|
||
| func NewDeregisterCommand() *cli.Command { | ||
| return &cli.Command{ | ||
| Name: "deregister", | ||
| Description: "Deregister the operator", | ||
| Before: setProfile, | ||
| Action: runDeregister, | ||
| Flags: []cli.Flag{ | ||
| ProfileFlag, | ||
| EthRPCFlag, | ||
| RegistryCoordinatorFlag, | ||
| PassphraseFlag, | ||
| KeyStorePathFlag, | ||
| EcdsaPrivateKeyFlag, | ||
| QuorumNumberFlag, | ||
| }, | ||
| } | ||
| } | ||
|
|
||
| func runDeregister(c *cli.Context) error { | ||
| if !c.IsSet(PassphraseFlag.Name) || !c.IsSet(KeyStorePathFlag.Name) { | ||
| utils.Fatalf("passphrase and keystore-path are required") | ||
| } | ||
|
|
||
| ecdsaPair, err := getECDSAPrivateKey(c) | ||
| if err != nil { | ||
| return err | ||
| } | ||
|
|
||
| ethClient, err := createEthClient(profile.EthRPCEndpoint) | ||
| if err != nil { | ||
| return err | ||
| } | ||
|
|
||
| chainIDBigInt, err := ethClient.ChainID(context.Background()) | ||
| if err != nil { | ||
| utils.Fatalf("cannot get chainId (%v): %v", profile.EthRPCEndpoint, err) | ||
| } | ||
|
|
||
| avsClient, err := buildAVSClient(ethClient) | ||
| if err != nil { | ||
| utils.Fatalf("Error creating AVS client %v", err) | ||
| } | ||
|
|
||
| signerV2, signerAddr, err := signerv2.SignerFromConfig(signerv2.Config{PrivateKey: ecdsaPair}, chainIDBigInt) | ||
| if err != nil { | ||
| utils.Fatalf( | ||
| "Error creating the deregister transaction signer for operator %v on Ethereum mainnet/Holesky (%v) %v", | ||
| crypto.PubkeyToAddress(ecdsaPair.PublicKey), | ||
| profile.EthRPCEndpoint, | ||
| err, | ||
| ) | ||
| } | ||
|
|
||
| txSender, err := wallet.NewPrivateKeyWallet(ethClient, signerV2, signerAddr, logger) | ||
| if err != nil { | ||
| utils.Fatalf( | ||
| "Error creating the deregister transaction sender for operator %v on Ethereum mainnet/Holesky (%v) %v", | ||
| crypto.PubkeyToAddress(ecdsaPair.PublicKey), | ||
| profile.EthRPCEndpoint, | ||
| err, | ||
| ) | ||
| } | ||
|
|
||
| txMgr := txmgr.NewSimpleTxManager(txSender, ethClient, logger, signerAddr) | ||
| noSendTxOpts, err := txMgr.GetNoSendTxOpts() | ||
| if err != nil { | ||
| utils.Fatalf("Error creating transaction object %v", err) | ||
| } | ||
|
|
||
| tx, err := avsClient.registryCoordinator.DeregisterOperator( | ||
| noSendTxOpts, | ||
| crypto.PubkeyToAddress(ecdsaPair.PublicKey), | ||
| []uint32{0}, | ||
| ) | ||
| if err != nil { | ||
| utils.Fatalf( | ||
| "Error creating the deregister transaction for operator %v on Ethereum mainnet/Holesky (%v) %v", | ||
| crypto.PubkeyToAddress(ecdsaPair.PublicKey), | ||
| profile.EthRPCEndpoint, | ||
| err, | ||
| ) | ||
| } | ||
|
|
||
| ctx := context.Background() | ||
| receipt, err := txMgr.Send(ctx, tx, true) | ||
| if err != nil { | ||
| utils.Fatalf( | ||
| "deregister transaction for operator %v on Ethereum mainnet/Holesky (%v) failed %v", | ||
| crypto.PubkeyToAddress(ecdsaPair.PublicKey), | ||
| profile.EthRPCEndpoint, | ||
| err, | ||
| ) | ||
| } | ||
| if receipt.Status != 1 { | ||
| utils.Fatalf( | ||
| "deregister transaction %v for operator %v on Ethereum mainnet/Holesky (%v) reverted", | ||
| receipt.TxHash.Hex(), | ||
| crypto.PubkeyToAddress(ecdsaPair.PublicKey), | ||
| profile.EthRPCEndpoint, | ||
| ) | ||
| } | ||
|
|
||
| logger.Info( | ||
| "successfully deregistered from eoracle AVS", | ||
| "address", signerAddr, | ||
| "tx hash", receipt.TxHash.Hex(), | ||
| ) | ||
|
|
||
| return nil | ||
| } |
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.