mirror of
https://github.com/status-im/nimbus-eth2.git
synced 2025-01-11 14:54:12 +00:00
parent
f1963bf599
commit
565edfa351
@ -1256,7 +1256,7 @@ proc readValue*(r: var TomlReader, value: var GraffitiBytes)
|
||||
{.raises: [Defect, SerializationError, IOError].} =
|
||||
try:
|
||||
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")
|
||||
|
||||
proc readValue*(r: var TomlReader, val: var NatConfig)
|
||||
|
@ -151,7 +151,7 @@ proc getStateSSZ*(
|
||||
else: len
|
||||
|
||||
bytes = newSeqUninitialized[byte](wanted)
|
||||
let (_, written) = uncompressFramed(tmp, bytes).valueOr:
|
||||
discard uncompressFramed(tmp, bytes).valueOr:
|
||||
return err("State failed to decompress, era file corrupt?")
|
||||
|
||||
ok()
|
||||
@ -384,7 +384,7 @@ proc getPartialState(
|
||||
try:
|
||||
readSszBytes(tmp.toOpenArray(0, partialBytes - 1), output)
|
||||
true
|
||||
except CatchableError as exc:
|
||||
except CatchableError:
|
||||
# TODO log?
|
||||
false
|
||||
|
||||
|
@ -255,9 +255,6 @@ elif const_preset == "mainnet":
|
||||
{.compile: "network_metadata_mainnet.S".}
|
||||
|
||||
const
|
||||
eth2NetworksDir = vendorDir & "/eth2-networks"
|
||||
sepoliaDir = vendorDir & "/sepolia"
|
||||
|
||||
mainnetMetadata = loadCompileTimeNetworkMetadata(
|
||||
vendorDir & "/eth2-networks/shared/mainnet", some mainnet, not incbinEnabled)
|
||||
praterMetadata = loadCompileTimeNetworkMetadata(
|
||||
|
@ -45,7 +45,7 @@ type
|
||||
|
||||
SigningNodeError* = object of CatchableError
|
||||
|
||||
proc validate(key: string, value: string): int =
|
||||
func validate(key: string, value: string): int =
|
||||
case key
|
||||
of "{validator_key}":
|
||||
0
|
||||
|
@ -183,8 +183,6 @@ const
|
||||
"No Finalized Snapshot Available"
|
||||
NoImplementationError* =
|
||||
"Not implemented yet"
|
||||
KeystoreAdditionFailure =
|
||||
"Could not add some keystores"
|
||||
InvalidKeystoreObjects* =
|
||||
"Invalid keystore objects found"
|
||||
InvalidValidatorPublicKey* =
|
||||
|
@ -595,7 +595,7 @@ template makeLimitedUInt*(T: untyped, limit: SomeUnsignedInt) =
|
||||
template asUInt64*(x: T): uint64 = uint64(distinctBase(x))
|
||||
|
||||
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) =
|
||||
makeLimitedUInt(T, limit)
|
||||
|
@ -670,7 +670,7 @@ proc readValue*(reader: var JsonReader[RestJson],
|
||||
for e in reader.readArray(string):
|
||||
let parsed = try:
|
||||
parseBiggestUInt(e)
|
||||
except ValueError as err:
|
||||
except ValueError:
|
||||
reader.raiseUnexpectedValue(
|
||||
"A string-encoded 8-bit usigned integer value expected")
|
||||
|
||||
@ -2707,7 +2707,7 @@ proc readValue*(reader: var JsonReader[RestJson],
|
||||
let key =
|
||||
try:
|
||||
parseKeystore(item)
|
||||
except SerializationError as exc:
|
||||
except SerializationError:
|
||||
# TODO re-raise the exception by adjusting the column index, so the user
|
||||
# will get an accurate syntax error within the larger message
|
||||
reader.raiseUnexpectedValue("Invalid keystore format")
|
||||
@ -2722,7 +2722,7 @@ proc readValue*(reader: var JsonReader[RestJson],
|
||||
SPDIR,
|
||||
requireAllFields = true,
|
||||
allowUnknownFields = true)
|
||||
except SerializationError as exc:
|
||||
except SerializationError:
|
||||
reader.raiseUnexpectedValue("Invalid slashing protection format")
|
||||
some(db)
|
||||
else:
|
||||
|
@ -887,13 +887,6 @@ proc readValue*(reader: var JsonReader, value: var RemoteKeystore)
|
||||
if provenBlockProperties.isNone:
|
||||
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)
|
||||
of RemoteSignerType.Web3Signer:
|
||||
RemoteKeystore(
|
||||
|
@ -258,44 +258,6 @@ proc checkAndCreateDataDir*(dataDir: string): bool =
|
||||
|
||||
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 =
|
||||
## Check if ``filePath`` has only "(600) rw-------" permissions.
|
||||
## Procedure returns ``false`` if permissions are different and we can't
|
||||
@ -711,7 +673,6 @@ iterator listLoadableKeystores*(validatorsDir, secretsDir: string,
|
||||
let
|
||||
keyName = splitFile(file).name
|
||||
keystoreDir = validatorsDir / keyName
|
||||
keystoreFile = keystoreDir / KeystoreFileName
|
||||
|
||||
if not(checkKeyName(keyName)):
|
||||
# Skip folders which name do not satisfy "0x[a-fA-F0-9]{96, 96}".
|
||||
@ -722,7 +683,6 @@ iterator listLoadableKeystores*(validatorsDir, secretsDir: string,
|
||||
continue
|
||||
|
||||
let
|
||||
secretFile = secretsDir / keyName
|
||||
keystore = loadKeystore(validatorsDir, secretsDir, keyName,
|
||||
nonInteractive, cache).valueOr:
|
||||
fatal "Unable to load keystore", keystore = file
|
||||
@ -1282,14 +1242,6 @@ proc saveKeystore*(
|
||||
let remoteInfo = RemoteSignerInfo(url: url, id: 0)
|
||||
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,
|
||||
validatorsDir: string,
|
||||
keystore: RemoteKeystore): ImportResult[KeystoreData]
|
||||
@ -1298,7 +1250,6 @@ proc importKeystore*(pool: var ValidatorPool,
|
||||
publicKey = keystore.pubkey
|
||||
keyName = publicKey.fsName
|
||||
keystoreDir = validatorsDir / keyName
|
||||
keystoreFile = keystoreDir / RemoteKeystoreFileName
|
||||
|
||||
# We check `publicKey`.
|
||||
let cookedKey = publicKey.load().valueOr:
|
||||
@ -1340,9 +1291,7 @@ proc importKeystore*(pool: var ValidatorPool,
|
||||
let
|
||||
publicKey = privateKey.toPubKey()
|
||||
keyName = publicKey.fsName
|
||||
secretFile = secretsDir / keyName
|
||||
keystoreDir = validatorsDir / keyName
|
||||
keystoreFile = keystoreDir / KeystoreFileName
|
||||
|
||||
# We check `publicKey` in memory storage first.
|
||||
if publicKey.toPubKey() in pool:
|
||||
|
@ -779,7 +779,6 @@ proc registerSyncContribution*(
|
||||
participants: openArray[ValidatorIndex]) =
|
||||
let
|
||||
slot = contribution_and_proof.contribution.slot
|
||||
beacon_block_root = contribution_and_proof.contribution.beacon_block_root
|
||||
delay = seen_timestamp - slot.sync_contribution_deadline()
|
||||
|
||||
let aggregator_index = contribution_and_proof.aggregator_index
|
||||
|
@ -26,11 +26,6 @@ const
|
||||
SnappyBeaconBlock* = [byte 0x01, 0x00]
|
||||
SnappyBeaconState* = [byte 0x02, 0x00]
|
||||
|
||||
TypeFieldLen = 2
|
||||
LengthFieldLen = 4
|
||||
ReservedFieldLen = 2
|
||||
HeaderFieldLen = TypeFieldLen + LengthFieldLen + ReservedFieldLen
|
||||
|
||||
FAR_FUTURE_ERA* = Era(not 0'u64)
|
||||
|
||||
type
|
||||
|
Loading…
x
Reference in New Issue
Block a user