Support of EIP-7044 in exit verify cmd

This commit is contained in:
s. rannou
2025-04-01 23:23:55 +02:00
parent 25a5bd917f
commit e4f0b934d7

View File

@@ -72,32 +72,35 @@ In quiet mode this will return 0 if the exit is verified correctly, otherwise 1.
errCheck(err, "Failed to obtain beacon chain genesis") errCheck(err, "Failed to obtain beacon chain genesis")
genesis := genesisResponse.Data genesis := genesisResponse.Data
response, err := eth2Client.(consensusclient.ForkProvider).Fork(ctx, &api.ForkOpts{State: "head"}) response, err := eth2Client.(consensusclient.SpecProvider).Spec(ctx, &api.SpecOpts{})
errCheck(err, "Failed to obtain fork information") errCheck(err, "Failed to obtain spec information")
// Check against current and prior fork versions. // Check against Capella fork version (EIP-7044)
signatureBytes := make([]byte, 96) signatureBytes := make([]byte, 96)
copy(signatureBytes, signedOp.Signature[:]) copy(signatureBytes, signedOp.Signature[:])
sig, err := e2types.BLSSignatureFromBytes(signatureBytes) sig, err := e2types.BLSSignatureFromBytes(signatureBytes)
errCheck(err, "Invalid signature") errCheck(err, "Invalid signature")
verified := false
// Try with the current fork.
domain := phase0.Domain{} domain := phase0.Domain{}
currentExitDomain, err := e2types.ComputeDomain(e2types.DomainVoluntaryExit, response.Data.CurrentVersion[:], genesis.GenesisValidatorsRoot[:]) forkRaw, ok := response.Data["CAPELLA_FORK_VERSION"]
errCheck(err, "Failed to compute domain") if !ok {
copy(domain[:], currentExitDomain) err = errors.New("failed to obtain Capella fork version")
verified, err = util.VerifyRoot(account, opRoot, domain, sig)
errCheck(err, "Failed to verify voluntary exit")
if !verified {
// Try again with the previous fork.
previousExitDomain, err := e2types.ComputeDomain(e2types.DomainVoluntaryExit, response.Data.PreviousVersion[:], genesis.GenesisValidatorsRoot[:])
copy(domain[:], previousExitDomain)
errCheck(err, "Failed to compute domain")
verified, err = util.VerifyRoot(account, opRoot, domain, sig)
errCheck(err, "Failed to verify voluntary exit")
} }
errCheck(err, "Failed to obtain fork version")
fork, ok := forkRaw.(phase0.Version)
if !ok {
err = errors.New("fork version is not of a valid type")
}
errCheck(err, "Failed to obtain fork version")
exitDomain, err := e2types.ComputeDomain(e2types.DomainVoluntaryExit, fork[:], genesis.GenesisValidatorsRoot[:])
errCheck(err, "Failed to compute domain")
copy(domain[:], exitDomain)
verified, err := util.VerifyRoot(account, opRoot, domain, sig)
errCheck(err, "Failed to verify voluntary exit")
assert(verified, "Voluntary exit failed to verify against current and previous fork versions") assert(verified, "Voluntary exit failed to verify against current and previous fork versions")
outputIf(viper.GetBool("verbose"), "Verified") outputIf(viper.GetBool("verbose"), "Verified")