mirror of
https://github.com/vacp2p/nimbus-eth2-experimental.git
synced 2026-01-09 13:27:55 -05:00
@@ -1256,7 +1256,7 @@ proc readValue*(r: var TomlReader, value: var GraffitiBytes)
|
|||||||
{.raises: [Defect, SerializationError, IOError].} =
|
{.raises: [Defect, SerializationError, IOError].} =
|
||||||
try:
|
try:
|
||||||
value = GraffitiBytes.init(r.readValue(string))
|
value = GraffitiBytes.init(r.readValue(string))
|
||||||
except ValueError as err:
|
except ValueError:
|
||||||
r.raiseUnexpectedValue("A printable string or 0x-prefixed hex-encoded raw bytes expected")
|
r.raiseUnexpectedValue("A printable string or 0x-prefixed hex-encoded raw bytes expected")
|
||||||
|
|
||||||
proc readValue*(r: var TomlReader, val: var NatConfig)
|
proc readValue*(r: var TomlReader, val: var NatConfig)
|
||||||
|
|||||||
@@ -151,7 +151,7 @@ proc getStateSSZ*(
|
|||||||
else: len
|
else: len
|
||||||
|
|
||||||
bytes = newSeqUninitialized[byte](wanted)
|
bytes = newSeqUninitialized[byte](wanted)
|
||||||
let (_, written) = uncompressFramed(tmp, bytes).valueOr:
|
discard uncompressFramed(tmp, bytes).valueOr:
|
||||||
return err("State failed to decompress, era file corrupt?")
|
return err("State failed to decompress, era file corrupt?")
|
||||||
|
|
||||||
ok()
|
ok()
|
||||||
@@ -384,7 +384,7 @@ proc getPartialState(
|
|||||||
try:
|
try:
|
||||||
readSszBytes(tmp.toOpenArray(0, partialBytes - 1), output)
|
readSszBytes(tmp.toOpenArray(0, partialBytes - 1), output)
|
||||||
true
|
true
|
||||||
except CatchableError as exc:
|
except CatchableError:
|
||||||
# TODO log?
|
# TODO log?
|
||||||
false
|
false
|
||||||
|
|
||||||
|
|||||||
@@ -255,9 +255,6 @@ elif const_preset == "mainnet":
|
|||||||
{.compile: "network_metadata_mainnet.S".}
|
{.compile: "network_metadata_mainnet.S".}
|
||||||
|
|
||||||
const
|
const
|
||||||
eth2NetworksDir = vendorDir & "/eth2-networks"
|
|
||||||
sepoliaDir = vendorDir & "/sepolia"
|
|
||||||
|
|
||||||
mainnetMetadata = loadCompileTimeNetworkMetadata(
|
mainnetMetadata = loadCompileTimeNetworkMetadata(
|
||||||
vendorDir & "/eth2-networks/shared/mainnet", some mainnet, not incbinEnabled)
|
vendorDir & "/eth2-networks/shared/mainnet", some mainnet, not incbinEnabled)
|
||||||
praterMetadata = loadCompileTimeNetworkMetadata(
|
praterMetadata = loadCompileTimeNetworkMetadata(
|
||||||
|
|||||||
@@ -45,7 +45,7 @@ type
|
|||||||
|
|
||||||
SigningNodeError* = object of CatchableError
|
SigningNodeError* = object of CatchableError
|
||||||
|
|
||||||
proc validate(key: string, value: string): int =
|
func validate(key: string, value: string): int =
|
||||||
case key
|
case key
|
||||||
of "{validator_key}":
|
of "{validator_key}":
|
||||||
0
|
0
|
||||||
|
|||||||
@@ -183,8 +183,6 @@ const
|
|||||||
"No Finalized Snapshot Available"
|
"No Finalized Snapshot Available"
|
||||||
NoImplementationError* =
|
NoImplementationError* =
|
||||||
"Not implemented yet"
|
"Not implemented yet"
|
||||||
KeystoreAdditionFailure =
|
|
||||||
"Could not add some keystores"
|
|
||||||
InvalidKeystoreObjects* =
|
InvalidKeystoreObjects* =
|
||||||
"Invalid keystore objects found"
|
"Invalid keystore objects found"
|
||||||
InvalidValidatorPublicKey* =
|
InvalidValidatorPublicKey* =
|
||||||
|
|||||||
@@ -595,7 +595,7 @@ template makeLimitedUInt*(T: untyped, limit: SomeUnsignedInt) =
|
|||||||
template asUInt64*(x: T): uint64 = uint64(distinctBase(x))
|
template asUInt64*(x: T): uint64 = uint64(distinctBase(x))
|
||||||
|
|
||||||
template toSszType(x: T): uint64 =
|
template toSszType(x: T): uint64 =
|
||||||
{.error: "Limited types should not be used with SSZ (abi differences)".}
|
{.error: "Limited types should not be used with SSZ (ABI differences)".}
|
||||||
|
|
||||||
template makeLimitedU8*(T: untyped, limit: uint8) =
|
template makeLimitedU8*(T: untyped, limit: uint8) =
|
||||||
makeLimitedUInt(T, limit)
|
makeLimitedUInt(T, limit)
|
||||||
|
|||||||
@@ -670,7 +670,7 @@ proc readValue*(reader: var JsonReader[RestJson],
|
|||||||
for e in reader.readArray(string):
|
for e in reader.readArray(string):
|
||||||
let parsed = try:
|
let parsed = try:
|
||||||
parseBiggestUInt(e)
|
parseBiggestUInt(e)
|
||||||
except ValueError as err:
|
except ValueError:
|
||||||
reader.raiseUnexpectedValue(
|
reader.raiseUnexpectedValue(
|
||||||
"A string-encoded 8-bit usigned integer value expected")
|
"A string-encoded 8-bit usigned integer value expected")
|
||||||
|
|
||||||
@@ -2707,7 +2707,7 @@ proc readValue*(reader: var JsonReader[RestJson],
|
|||||||
let key =
|
let key =
|
||||||
try:
|
try:
|
||||||
parseKeystore(item)
|
parseKeystore(item)
|
||||||
except SerializationError as exc:
|
except SerializationError:
|
||||||
# TODO re-raise the exception by adjusting the column index, so the user
|
# TODO re-raise the exception by adjusting the column index, so the user
|
||||||
# will get an accurate syntax error within the larger message
|
# will get an accurate syntax error within the larger message
|
||||||
reader.raiseUnexpectedValue("Invalid keystore format")
|
reader.raiseUnexpectedValue("Invalid keystore format")
|
||||||
@@ -2722,7 +2722,7 @@ proc readValue*(reader: var JsonReader[RestJson],
|
|||||||
SPDIR,
|
SPDIR,
|
||||||
requireAllFields = true,
|
requireAllFields = true,
|
||||||
allowUnknownFields = true)
|
allowUnknownFields = true)
|
||||||
except SerializationError as exc:
|
except SerializationError:
|
||||||
reader.raiseUnexpectedValue("Invalid slashing protection format")
|
reader.raiseUnexpectedValue("Invalid slashing protection format")
|
||||||
some(db)
|
some(db)
|
||||||
else:
|
else:
|
||||||
|
|||||||
@@ -887,13 +887,6 @@ proc readValue*(reader: var JsonReader, value: var RemoteKeystore)
|
|||||||
if provenBlockProperties.isNone:
|
if provenBlockProperties.isNone:
|
||||||
reader.raiseUnexpectedValue("The required field `proven_block_properties` is missing")
|
reader.raiseUnexpectedValue("The required field `proven_block_properties` is missing")
|
||||||
|
|
||||||
let keystoreFlags =
|
|
||||||
block:
|
|
||||||
var res: set[RemoteKeystoreFlag]
|
|
||||||
if ignoreSslVerification.isSome():
|
|
||||||
res.incl(RemoteKeystoreFlag.IgnoreSSLVerification)
|
|
||||||
res
|
|
||||||
|
|
||||||
value = case remoteType.get(RemoteSignerType.Web3Signer)
|
value = case remoteType.get(RemoteSignerType.Web3Signer)
|
||||||
of RemoteSignerType.Web3Signer:
|
of RemoteSignerType.Web3Signer:
|
||||||
RemoteKeystore(
|
RemoteKeystore(
|
||||||
|
|||||||
@@ -258,44 +258,6 @@ proc checkAndCreateDataDir*(dataDir: string): bool =
|
|||||||
|
|
||||||
return true
|
return true
|
||||||
|
|
||||||
proc checkSensitivePathPermissions(dirFilePath: string): bool =
|
|
||||||
## If ``dirFilePath`` is file, then check if file has only
|
|
||||||
##
|
|
||||||
## - "(600) rwx------" permissions on Posix (Linux, MacOS, BSD)
|
|
||||||
## - current user only ACL on Windows
|
|
||||||
##
|
|
||||||
## If ``dirFilePath`` is directory, then check if directory has only
|
|
||||||
##
|
|
||||||
## - "(700) rwx------" permissions on Posix (Linux, MacOS, BSD)
|
|
||||||
## - current user only ACL on Windows
|
|
||||||
##
|
|
||||||
## Procedure returns ``true`` if directory/file is present and all required
|
|
||||||
## permissions are set.
|
|
||||||
let r1 = isDir(dirFilePath)
|
|
||||||
let r2 = isFile(dirFilePath)
|
|
||||||
if r1 or r2:
|
|
||||||
when defined(windows):
|
|
||||||
let res = checkCurrentUserOnlyACL(dirFilePath)
|
|
||||||
if res.isErr():
|
|
||||||
false
|
|
||||||
else:
|
|
||||||
if res.get() == false:
|
|
||||||
false
|
|
||||||
else:
|
|
||||||
true
|
|
||||||
else:
|
|
||||||
let requiredPermissions = if r1: 0o700 else: 0o600
|
|
||||||
let res = getPermissions(dirFilePath)
|
|
||||||
if res.isErr():
|
|
||||||
false
|
|
||||||
else:
|
|
||||||
if res.get() != requiredPermissions:
|
|
||||||
false
|
|
||||||
else:
|
|
||||||
true
|
|
||||||
else:
|
|
||||||
false
|
|
||||||
|
|
||||||
proc checkSensitiveFilePermissions*(filePath: string): bool =
|
proc checkSensitiveFilePermissions*(filePath: string): bool =
|
||||||
## Check if ``filePath`` has only "(600) rw-------" permissions.
|
## Check if ``filePath`` has only "(600) rw-------" permissions.
|
||||||
## Procedure returns ``false`` if permissions are different and we can't
|
## Procedure returns ``false`` if permissions are different and we can't
|
||||||
@@ -711,7 +673,6 @@ iterator listLoadableKeystores*(validatorsDir, secretsDir: string,
|
|||||||
let
|
let
|
||||||
keyName = splitFile(file).name
|
keyName = splitFile(file).name
|
||||||
keystoreDir = validatorsDir / keyName
|
keystoreDir = validatorsDir / keyName
|
||||||
keystoreFile = keystoreDir / KeystoreFileName
|
|
||||||
|
|
||||||
if not(checkKeyName(keyName)):
|
if not(checkKeyName(keyName)):
|
||||||
# Skip folders which name do not satisfy "0x[a-fA-F0-9]{96, 96}".
|
# Skip folders which name do not satisfy "0x[a-fA-F0-9]{96, 96}".
|
||||||
@@ -722,7 +683,6 @@ iterator listLoadableKeystores*(validatorsDir, secretsDir: string,
|
|||||||
continue
|
continue
|
||||||
|
|
||||||
let
|
let
|
||||||
secretFile = secretsDir / keyName
|
|
||||||
keystore = loadKeystore(validatorsDir, secretsDir, keyName,
|
keystore = loadKeystore(validatorsDir, secretsDir, keyName,
|
||||||
nonInteractive, cache).valueOr:
|
nonInteractive, cache).valueOr:
|
||||||
fatal "Unable to load keystore", keystore = file
|
fatal "Unable to load keystore", keystore = file
|
||||||
@@ -1282,14 +1242,6 @@ proc saveKeystore*(
|
|||||||
let remoteInfo = RemoteSignerInfo(url: url, id: 0)
|
let remoteInfo = RemoteSignerInfo(url: url, id: 0)
|
||||||
saveKeystore(validatorsDir, publicKey, @[remoteInfo], 1)
|
saveKeystore(validatorsDir, publicKey, @[remoteInfo], 1)
|
||||||
|
|
||||||
proc saveLockedKeystore(
|
|
||||||
validatorsDir: string,
|
|
||||||
publicKey: ValidatorPubKey,
|
|
||||||
url: HttpHostUri
|
|
||||||
): Result[FileLockHandle, KeystoreGenerationError] {.raises: [Defect].} =
|
|
||||||
let remoteInfo = RemoteSignerInfo(url: url, id: 0)
|
|
||||||
saveLockedKeystore(validatorsDir, publicKey, @[remoteInfo], 1)
|
|
||||||
|
|
||||||
proc importKeystore*(pool: var ValidatorPool,
|
proc importKeystore*(pool: var ValidatorPool,
|
||||||
validatorsDir: string,
|
validatorsDir: string,
|
||||||
keystore: RemoteKeystore): ImportResult[KeystoreData]
|
keystore: RemoteKeystore): ImportResult[KeystoreData]
|
||||||
@@ -1298,7 +1250,6 @@ proc importKeystore*(pool: var ValidatorPool,
|
|||||||
publicKey = keystore.pubkey
|
publicKey = keystore.pubkey
|
||||||
keyName = publicKey.fsName
|
keyName = publicKey.fsName
|
||||||
keystoreDir = validatorsDir / keyName
|
keystoreDir = validatorsDir / keyName
|
||||||
keystoreFile = keystoreDir / RemoteKeystoreFileName
|
|
||||||
|
|
||||||
# We check `publicKey`.
|
# We check `publicKey`.
|
||||||
let cookedKey = publicKey.load().valueOr:
|
let cookedKey = publicKey.load().valueOr:
|
||||||
@@ -1340,9 +1291,7 @@ proc importKeystore*(pool: var ValidatorPool,
|
|||||||
let
|
let
|
||||||
publicKey = privateKey.toPubKey()
|
publicKey = privateKey.toPubKey()
|
||||||
keyName = publicKey.fsName
|
keyName = publicKey.fsName
|
||||||
secretFile = secretsDir / keyName
|
|
||||||
keystoreDir = validatorsDir / keyName
|
keystoreDir = validatorsDir / keyName
|
||||||
keystoreFile = keystoreDir / KeystoreFileName
|
|
||||||
|
|
||||||
# We check `publicKey` in memory storage first.
|
# We check `publicKey` in memory storage first.
|
||||||
if publicKey.toPubKey() in pool:
|
if publicKey.toPubKey() in pool:
|
||||||
|
|||||||
@@ -779,7 +779,6 @@ proc registerSyncContribution*(
|
|||||||
participants: openArray[ValidatorIndex]) =
|
participants: openArray[ValidatorIndex]) =
|
||||||
let
|
let
|
||||||
slot = contribution_and_proof.contribution.slot
|
slot = contribution_and_proof.contribution.slot
|
||||||
beacon_block_root = contribution_and_proof.contribution.beacon_block_root
|
|
||||||
delay = seen_timestamp - slot.sync_contribution_deadline()
|
delay = seen_timestamp - slot.sync_contribution_deadline()
|
||||||
|
|
||||||
let aggregator_index = contribution_and_proof.aggregator_index
|
let aggregator_index = contribution_and_proof.aggregator_index
|
||||||
|
|||||||
@@ -26,11 +26,6 @@ const
|
|||||||
SnappyBeaconBlock* = [byte 0x01, 0x00]
|
SnappyBeaconBlock* = [byte 0x01, 0x00]
|
||||||
SnappyBeaconState* = [byte 0x02, 0x00]
|
SnappyBeaconState* = [byte 0x02, 0x00]
|
||||||
|
|
||||||
TypeFieldLen = 2
|
|
||||||
LengthFieldLen = 4
|
|
||||||
ReservedFieldLen = 2
|
|
||||||
HeaderFieldLen = TypeFieldLen + LengthFieldLen + ReservedFieldLen
|
|
||||||
|
|
||||||
FAR_FUTURE_ERA* = Era(not 0'u64)
|
FAR_FUTURE_ERA* = Era(not 0'u64)
|
||||||
|
|
||||||
type
|
type
|
||||||
|
|||||||
Reference in New Issue
Block a user