generated from flashbots/go-template
-
Notifications
You must be signed in to change notification settings - Fork 118
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'main' into batch-set-known-validators
# Conflicts: # services/housekeeper/housekeeper.go
- Loading branch information
Showing
8 changed files
with
316 additions
and
127 deletions.
There are no files selected for viewing
This file contains 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 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 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
53 changes: 53 additions & 0 deletions
53
internal/investigations/validator-registration-signature-check/main.go
This file contains 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,53 @@ | ||
package main | ||
|
||
// | ||
// Script to create a signed validator registration | ||
// | ||
|
||
import ( | ||
"fmt" | ||
|
||
"github.com/flashbots/go-boost-utils/bls" | ||
boostTypes "github.com/flashbots/go-boost-utils/types" | ||
"github.com/flashbots/mev-boost-relay/common" | ||
) | ||
|
||
var ( | ||
gasLimit = 30000000 | ||
feeRecipient = "0xdb65fEd33dc262Fe09D9a2Ba8F80b329BA25f941" | ||
timestamp = 1606824043 | ||
) | ||
|
||
func Perr(err error) { | ||
if err != nil { | ||
panic(err) | ||
} | ||
} | ||
|
||
func main() { | ||
mainnetDetails, err := common.NewEthNetworkDetails(common.EthNetworkMainnet) | ||
Perr(err) | ||
|
||
sk, pubkey, err := bls.GenerateNewKeypair() | ||
Perr(err) | ||
|
||
pk, err := boostTypes.BlsPublicKeyToPublicKey(pubkey) | ||
Perr(err) | ||
|
||
// Fill in validator registration details | ||
validatorRegistration := boostTypes.RegisterValidatorRequestMessage{ //nolint:exhaustruct | ||
GasLimit: uint64(gasLimit), | ||
Timestamp: uint64(timestamp), | ||
} | ||
|
||
validatorRegistration.Pubkey, err = boostTypes.HexToPubkey(pk.String()) | ||
Perr(err) | ||
validatorRegistration.FeeRecipient, err = boostTypes.HexToAddress(feeRecipient) | ||
Perr(err) | ||
|
||
sig, err := boostTypes.SignMessage(&validatorRegistration, mainnetDetails.DomainBuilder, sk) | ||
Perr(err) | ||
fmt.Println("privkey:", sk.String()) | ||
fmt.Println("pubkey: ", pk.String()) | ||
fmt.Println("sig: ", sig.String()) | ||
} |
42 changes: 42 additions & 0 deletions
42
internal/investigations/validator-registration-signature-check/main_test.go
This file contains 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,42 @@ | ||
package main | ||
|
||
import ( | ||
"testing" | ||
|
||
boostTypes "github.com/flashbots/go-boost-utils/types" | ||
"github.com/flashbots/mev-boost-relay/common" | ||
"github.com/stretchr/testify/require" | ||
) | ||
|
||
// TestValidatorRegistrationSignature can be used to validate the signature of an arbitrary validator registration | ||
func TestValidatorRegistrationSignature(t *testing.T) { | ||
// Fill in validator registration details | ||
pubkey := "0x84e975405f8691ad7118527ee9ee4ed2e4e8bae973f6e29aa9ca9ee4aea83605ae3536d22acc9aa1af0545064eacf82e" | ||
gasLimit := 30000000 | ||
feeRecipient := "0xdb65fed33dc262fe09d9a2ba8f80b329ba25f941" | ||
timestamp := 1606824043 | ||
signature := "0xaf12df007a0c78abb5575067e5f8b089cfcc6227e4a91db7dd8cf517fe86fb944ead859f0781277d9b78c672e4a18c5d06368b603374673cf2007966cece9540f3a1b3f6f9e1bf421d779c4e8010368e6aac134649c7a009210780d401a778a5" | ||
|
||
// Constructing the object | ||
payload := boostTypes.SignedValidatorRegistration{ | ||
Message: &boostTypes.RegisterValidatorRequestMessage{ | ||
GasLimit: uint64(gasLimit), | ||
Timestamp: uint64(timestamp), | ||
}, | ||
} | ||
|
||
var err error | ||
payload.Message.Pubkey, err = boostTypes.HexToPubkey(pubkey) | ||
require.NoError(t, err) | ||
payload.Signature, err = boostTypes.HexToSignature(signature) | ||
require.NoError(t, err) | ||
payload.Message.FeeRecipient, err = boostTypes.HexToAddress(feeRecipient) | ||
require.NoError(t, err) | ||
|
||
mainnetDetails, err := common.NewEthNetworkDetails(common.EthNetworkMainnet) | ||
require.NoError(t, err) | ||
|
||
ok, err := boostTypes.VerifySignature(payload.Message, mainnetDetails.DomainBuilder, payload.Message.Pubkey[:], payload.Signature[:]) | ||
require.NoError(t, err) | ||
require.True(t, ok) | ||
} |
Oops, something went wrong.