mirror of
https://github.com/sigp/lighthouse.git
synced 2026-03-06 10:11:44 +00:00
Extract get_domain for VoluntaryExit (#7454)
N/A Extract get_domain for VoluntaryExit so it can be used in Anchor with a different signing process.
This commit is contained in:
@@ -40,6 +40,16 @@ impl VoluntaryExit {
|
|||||||
genesis_validators_root: Hash256,
|
genesis_validators_root: Hash256,
|
||||||
spec: &ChainSpec,
|
spec: &ChainSpec,
|
||||||
) -> SignedVoluntaryExit {
|
) -> SignedVoluntaryExit {
|
||||||
|
let domain = self.get_domain(genesis_validators_root, spec);
|
||||||
|
|
||||||
|
let message = self.signing_root(domain);
|
||||||
|
SignedVoluntaryExit {
|
||||||
|
message: self,
|
||||||
|
signature: secret_key.sign(message),
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
pub fn get_domain(&self, genesis_validators_root: Hash256, spec: &ChainSpec) -> Hash256 {
|
||||||
let fork_name = spec.fork_name_at_epoch(self.epoch);
|
let fork_name = spec.fork_name_at_epoch(self.epoch);
|
||||||
let fork_version = if fork_name.deneb_enabled() {
|
let fork_version = if fork_name.deneb_enabled() {
|
||||||
// EIP-7044
|
// EIP-7044
|
||||||
@@ -47,14 +57,7 @@ impl VoluntaryExit {
|
|||||||
} else {
|
} else {
|
||||||
spec.fork_version_for_name(fork_name)
|
spec.fork_version_for_name(fork_name)
|
||||||
};
|
};
|
||||||
let domain =
|
spec.compute_domain(Domain::VoluntaryExit, fork_version, genesis_validators_root)
|
||||||
spec.compute_domain(Domain::VoluntaryExit, fork_version, genesis_validators_root);
|
|
||||||
|
|
||||||
let message = self.signing_root(domain);
|
|
||||||
SignedVoluntaryExit {
|
|
||||||
message: self,
|
|
||||||
signature: secret_key.sign(message),
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user