Example #1
0
 private void Client_ApplicationMessageReceived(object sender, MqttApplicationMessageReceivedEventArgs e)
 {
     LogDebug?.Invoke($"ApplicationMessageReceived Topic {e.ApplicationMessage.Topic}  QualityOfServiceLevel:{e.ApplicationMessage.QualityOfServiceLevel} Retain:{e.ApplicationMessage.Retain} ");
     try
     {
         if (e.ApplicationMessage.Topic.StartsWith($"/devices/") && e.ApplicationMessage.Topic.Contains("/response/"))
         {
             ReceiveAttributes(e);
         }
         else if (e.ApplicationMessage.Topic.StartsWith($"/devices/") && e.ApplicationMessage.Topic.Contains("/rpc/request/"))
         {
             var tps           = e.ApplicationMessage.Topic.Split(new char[] { '/' }, StringSplitOptions.RemoveEmptyEntries);
             var rpcmethodname = tps[4];
             var rpcdevicename = tps[1];
             var rpcrequestid  = tps[5];
             LogInformation?.Invoke($"rpcmethodname={rpcmethodname} ");
             LogInformation?.Invoke($"rpcdevicename={rpcdevicename } ");
             LogInformation?.Invoke($"rpcrequestid={rpcrequestid}   ");
             if (!string.IsNullOrEmpty(rpcmethodname) && !string.IsNullOrEmpty(rpcdevicename) && !string.IsNullOrEmpty(rpcrequestid))
             {
                 OnExcRpc?.Invoke(Client, new RpcRequest()
                 {
                     Method    = rpcmethodname,
                     DeviceId  = rpcdevicename,
                     RequestId = rpcrequestid,
                     Params    = e.ApplicationMessage.ConvertPayloadToString()
                 });
             }
         }
     }
     catch (Exception ex)
     {
         LogError?.Invoke($"ClientId:{e.ClientId} Topic:{e.ApplicationMessage.Topic},Payload:{e.ApplicationMessage.ConvertPayloadToString()}", ex);
     }
 }
Example #2
0
        public void Save()
        {
            // check path
            if (!Directory.Exists(DataPath))
            {
                Directory.CreateDirectory(DataPath);
            }

            XmlTextWriter xml = new XmlTextWriter(Path.Combine(DataPath, ConfigFile), Encoding.UTF8);

            xml.WriteStartDocument(true);
            xml.WriteStartElement("wowace");
            xml.WriteStartElement("aptget");

            WriteSetting(xml, "UseExternals", UseExternals.ToString());
            WriteSetting(xml, "KeepZips", KeepZips.ToString());
            WriteSetting(xml, "DeleteBeforeExtract", DeleteBeforeExtract.ToString());
            WriteSetting(xml, "CreateFullBackupBeforeUpgrade", CreateFullBackupBeforeUpgrade.ToString());
            WriteSetting(xml, "UnpackPackages", UnpackPackages.ToString());
            WriteSetting(xml, "FetchRequiredDeps", FetchRequiredDeps.ToString());
            WriteSetting(xml, "FetchOptionalDeps", FetchOptionalDeps.ToString());
            WriteSetting(xml, "DebugEnabled", DebugEnabled.ToString());
            WriteSetting(xml, "SilentMode", SilentMode.ToString());
            WriteSetting(xml, "AutoDetectWoW", AutoDetectWoW.ToString());
            WriteSetting(xml, "WoWInstallPath", WoWInstallPath);
            WriteSetting(xml, "Log", Log.ToString());
            WriteSetting(xml, "LogDebug", LogDebug.ToString());
            WriteSetting(xml, "AutoUpdateIndex", AutoUpdateIndex.ToString());

            xml.WriteEndElement();
            xml.WriteEndElement();

            xml.Close();
        }
Example #3
0
        // ReSharper disable once InconsistentNaming
        // ReSharper disable once IdentifierTypo
        public async Task <IActionResult> GetAsync([FromQuery] byte[] validator_pubkey, [FromQuery] uint poc_bit,
                                                   [FromQuery] ulong slot, [FromQuery] ulong index,
                                                   CancellationToken cancellationToken)
        {
            if (_logger.IsDebug())
            {
                LogDebug.NewAttestationRequested(_logger, slot, index, Bytes.ToHexString(validator_pubkey), null);
            }

            BlsPublicKey validatorPublicKey = new BlsPublicKey(validator_pubkey);
            bool         proofOfCustodyBit  = poc_bit > 0;
            Slot         targetSlot         = new Slot(slot);

            // NOTE: Spec 0.10.1 still has old Shard references in OAPI, although the spec has changed to Index;
            // use Index as it is easier to understand (i.e. the spec OAPI in 0.10.1 is wrong)
            CommitteeIndex targetIndex = new CommitteeIndex(index);

            ApiResponse <Attestation> apiResponse =
                await _beaconNode
                .NewAttestationAsync(validatorPublicKey, proofOfCustodyBit, targetSlot, targetIndex,
                                     cancellationToken).ConfigureAwait(false);

            return(apiResponse.StatusCode switch
            {
                Core2.Api.StatusCode.Success => Ok(apiResponse.Content),
                Core2.Api.StatusCode.InvalidRequest => Problem("Invalid request syntax.",
                                                               statusCode: (int)apiResponse.StatusCode),
                Core2.Api.StatusCode.CurrentlySyncing => Problem("Beacon node is currently syncing, try again later.",
                                                                 statusCode: (int)apiResponse.StatusCode),
                _ => Problem("Beacon node internal error.", statusCode: (int)apiResponse.StatusCode)
            });
Example #4
0
 /// <summary>
 /// Write the device configuration to the  ASCOM  Profile store
 /// </summary>
 internal void WriteProfile()
 {
     using (Profile driverProfile = new Profile())
     {
         driverProfile.DeviceType = "Telescope";
         driverProfile.WriteValue(driverID, traceStateProfileName, LogDebug.ToString());
         if (comPort != null)
         {
             driverProfile.WriteValue(driverID, comPortProfileName, comPort.ToString());
         }
     }
 }
Example #5
0
 public static void RmEvent(string _key, Action <EventArg> _event)
 {
     if (eventsMap.ContainsKey(_key))
     {
         if (eventsMap[_key].CallbackLst.Contains(_event))
         {
             eventsMap[_key].CallbackLst.Remove(_event);
         }
     }
     else
     {
         LogDebug.Log("Event Key Not Exist!!!");
     }
 }
Example #6
0
    public static EventStruct GetEventByKey(string _key)
    {
        EventStruct tEventStruct = null;

        if (eventsMap.ContainsKey(_key))
        {
            tEventStruct = eventsMap[_key];
        }
        if (null == tEventStruct)
        {
            LogDebug.Log("Event Not Exist!!!");
        }
        return(tEventStruct);
    }
Example #7
0
        private DepositData BuildAndSignDepositData(ulong validatorIndex, Gwei amount, SignatureDomains signatureDomains)
        {
            InitialValues initialValues = _initialValueOptions.CurrentValue;

            byte[] privateKey = GeneratePrivateKey(validatorIndex);

            // Public Key
            BLSParameters blsParameters = new BLSParameters
            {
                PrivateKey = privateKey
            };

            using BLS bls = BLS.Create(blsParameters);
            byte[] publicKeyBytes = new byte[BlsPublicKey.Length];
            bls.TryExportBlsPublicKey(publicKeyBytes, out int publicKeyBytesWritten);
            BlsPublicKey publicKey = new BlsPublicKey(publicKeyBytes);

            // Withdrawal Credentials
            Bytes32 withdrawalCredentials = _crypto.Hash(publicKey.AsSpan());

            withdrawalCredentials.Unwrap()[0] = initialValues.BlsWithdrawalPrefix;

            // Build deposit data
            DepositData depositData = new DepositData(publicKey, withdrawalCredentials, amount, BlsSignature.Zero);

            // Sign deposit data
            Domain         domain         = _beaconChainUtility.ComputeDomain(signatureDomains.Deposit);
            DepositMessage depositMessage = new DepositMessage(
                depositData.PublicKey,
                depositData.WithdrawalCredentials,
                depositData.Amount);

            Root depositMessageRoot     = _crypto.HashTreeRoot(depositMessage);
            Root depositDataSigningRoot = _beaconChainUtility.ComputeSigningRoot(depositMessageRoot, domain);

            byte[] signatureBytes = new byte[96];
            bls.TrySignData(depositDataSigningRoot.AsSpan(), signatureBytes, out int bytesWritten);

            BlsSignature depositDataSignature = new BlsSignature(signatureBytes);

            depositData.SetSignature(depositDataSignature);

            if (_logger.IsEnabled(LogLevel.Debug))
            {
                LogDebug.QuickStartAddValidator(_logger, validatorIndex, publicKey.ToString().Substring(0, 12),
                                                null);
            }

            return(depositData);
        }
        public async Task <IActionResult> GetAsync(CancellationToken cancellationToken)
        {
            if (_logger.IsDebug())
            {
                LogDebug.NodeForkRequested(_logger, null);
            }

            ApiResponse <Fork> apiResponse = await _beaconNode.GetNodeForkAsync(cancellationToken).ConfigureAwait(false);

            if (apiResponse.StatusCode == Core2.Api.StatusCode.Success)
            {
                ForkInformation forkInformation = new ForkInformation(0, apiResponse.Content);
                return(Ok(forkInformation));
            }

            return(Problem("Beacon node internal error.", statusCode: (int)apiResponse.StatusCode));
        }
Example #9
0
        public async Task <IActionResult> GetAsync(CancellationToken cancellationToken)
        {
            if (_logger.IsDebug())
            {
                LogDebug.NodeGenesisTimeRequested(_logger, null);
            }

            ApiResponse <ulong> apiResponse =
                await _beaconNode.GetGenesisTimeAsync(cancellationToken).ConfigureAwait(false);

            if (apiResponse.StatusCode == Core2.Api.StatusCode.Success)
            {
                return(Ok(apiResponse.Content));
            }

            return(Problem("Beacon node internal error.", statusCode: (int)apiResponse.StatusCode));
        }
Example #10
0
    public static void AddEvent(string _key, Action <EventArg> _event, Object _source)
    {
        EventStruct tEventStruct;

        if (eventsMap.ContainsKey(_key))
        {
            tEventStruct = null /*GetEventById(_key)*/;
            if (tEventStruct.CallbackLst.Contains(_event))
            {
                LogDebug.Log("重复添加事件");
                return;
            }
            tEventStruct.CallbackLst.Add(_event);
            return;
        }
        tEventStruct = new EventStruct(_key, _source);
        tEventStruct.CallbackLst.Add(_event);
        eventsMap.Add(_key, tEventStruct);
    }
Example #11
0
        public async Task <IActionResult> GetAsync([FromBody] Attestation signedAttestation,
                                                   CancellationToken cancellationToken)
        {
            if (_logger.IsDebug())
            {
                string?aggregationBits = null;
                if (signedAttestation.AggregationBits != null)
                {
                    aggregationBits = string.Create(signedAttestation.AggregationBits.Length,
                                                    signedAttestation.AggregationBits,
                                                    ((span, bitArray) =>
                    {
                        for (int index = 0; index < bitArray.Length; index++)
                        {
                            span[index] = bitArray[index] ? '1' : '0';
                        }
                    }));
                }

                LogDebug.AttestationPublished(_logger, signedAttestation.Data?.Slot,
                                              signedAttestation.Data?.Index,
                                              aggregationBits,
                                              signedAttestation.Signature,
                                              null);
            }

            ApiResponse apiResponse =
                await _beaconNode.PublishAttestationAsync(signedAttestation, cancellationToken).ConfigureAwait(false);

            return(apiResponse.StatusCode switch
            {
                // "The attestation was validated successfully and has been broadcast. It has also been integrated into the beacon node's database."
                Core2.Api.StatusCode.Success => Ok(),
                // "The attestation failed validation, but was successfully broadcast anyway. It was not integrated into the beacon node's database."
                Core2.Api.StatusCode.BroadcastButFailedValidation => Accepted(),
                Core2.Api.StatusCode.InvalidRequest => Problem("Invalid request syntax.",
                                                               statusCode: (int)apiResponse.StatusCode),
                Core2.Api.StatusCode.CurrentlySyncing => Problem("Beacon node is currently syncing, try again later.",
                                                                 statusCode: (int)apiResponse.StatusCode),
                _ => Problem("Beacon node internal error.", statusCode: (int)apiResponse.StatusCode)
            });
Example #12
0
 private void DestroySelf(EventArg _arg)
 {
     LogDebug.Log(_arg.ContentStr);
 }
Example #13
0
        public string Parser(string dt)
        {
            try
            {
                string tmpdata  = dt.Replace("\u0000", System.String.Empty);
                string fulldata = "";

                int lng = tmpdata.Length;
                foreach (char dd in tmpdata)
                {
                    int  number   = 0;
                    bool isnumber = false;
                    try
                    {
                        number   = int.Parse(dd + "");
                        isnumber = true;
                    }
                    catch { isnumber = false; }

                    if (!isnumber)
                    {
                        int  pos   = 0;
                        bool found = false;
                        for (int x = 0; x < key_f.Length; x++)
                        {
                            if (dd == key_f[x])
                            {
                                pos   = x;
                                found = true;
                                break;
                            }
                        }
                        if (found)
                        {
                            int  key = key_shift[lng];
                            int  bf  = key_f.Length - pos;
                            char nwt = ' ';
                            if ((bf - key) <= 0)
                            {
                                int find = bf - key;
                                if (find < 0)
                                {
                                    int nff = Math.Abs(find);
                                    nwt = key_f[nff];
                                }
                                else
                                {
                                    nwt = key_f[find];
                                }
                            }
                            else
                            {
                                nwt = key_f[pos + key];
                            }
                            fulldata += nwt;
                        }
                        else
                        {
                            fulldata += dd;
                        }
                    }
                    else
                    {
                        int pos = 0;
                        for (int x = 0; x < key_i.Length; x++)
                        {
                            if (dd == key_i[x])
                            {
                                pos = x;
                                break;
                            }
                        }
                        int  key = key_shifi[lng];
                        int  bf  = key_i.Length - pos;
                        char nwt = ' ';
                        if ((bf - key) <= 0)
                        {
                            int find = bf - key;
                            if (find < 0)
                            {
                                int nff = Math.Abs(find);
                                nwt = key_i[nff];
                            }
                            else
                            {
                                nwt = key_i[find];
                            }
                        }
                        else
                        {
                            if ((pos + key) < 0)
                            {
                                int nff = Math.Abs(pos + key);
                                nwt = key_i[nff];
                            }
                            else
                            {
                                nwt = key_i[pos + key];
                            }
                        }
                        fulldata += nwt;
                    }
                }
                return(fulldata);
            }
            catch (Exception ep)
            {
                LogDebug.Show(ep.ToString());
            }
            return(dt);
        }
Example #14
0
 /// <summary>
 /// Print Debug message.
 /// </summary>
 public static void Debug(object message, object context = null)
 {
     LogDebug.Raise(message.ToString(), context);
 }
Example #15
0
 /// <summary>
 /// Called when the <see cref="Session"/> <see cref="CloudSpatialAnchorSession.LogDebug">LogDebug</see> event is fired.
 /// </summary>
 /// <param name="sender">
 /// The <see cref="Session"/>.
 /// </param>
 /// <param name="args">
 /// The event data.
 /// </param>
 protected virtual void OnLogDebug(object sender, OnLogDebugEventArgs args)
 {
     LogDebug?.Invoke(this, args);
 }
Example #16
0
        public Task <Eth1GenesisData> GetEth1GenesisDataAsync(CancellationToken cancellationToken)
        {
            QuickStartParameters quickStartParameters = _quickStartParameterOptions.CurrentValue;

            if (_logger.IsWarn())
            {
                Log.MockedQuickStart(_logger, quickStartParameters.GenesisTime, quickStartParameters.ValidatorCount,
                                     null);
            }

            GweiValues       gweiValues       = _gweiValueOptions.CurrentValue;
            TimeParameters   timeParameters   = _timeParameterOptions.CurrentValue;
            SignatureDomains signatureDomains = _signatureDomainOptions.CurrentValue;

            // Fixed amount
            Gwei amount = gweiValues.MaximumEffectiveBalance;

            for (ulong validatorIndex = 0uL; validatorIndex < quickStartParameters.ValidatorCount; validatorIndex++)
            {
                DepositData depositData = BuildAndSignDepositData(
                    validatorIndex,
                    amount,
                    signatureDomains);

                _depositStore.Place(depositData);
            }

            ulong eth1Timestamp = quickStartParameters.Eth1Timestamp;

            if (eth1Timestamp == 0)
            {
                eth1Timestamp = quickStartParameters.GenesisTime - (ulong)(1.5 * timeParameters.MinimumGenesisDelay);
            }
            else
            {
                ulong minimumEth1TimestampInclusive =
                    quickStartParameters.GenesisTime - 2 * timeParameters.MinimumGenesisDelay;
                ulong maximumEth1TimestampInclusive =
                    quickStartParameters.GenesisTime - timeParameters.MinimumGenesisDelay - 1;
                if (eth1Timestamp < minimumEth1TimestampInclusive)
                {
                    if (_logger.IsEnabled(LogLevel.Warning))
                    {
                        Log.QuickStartEth1TimestampTooLow(_logger, eth1Timestamp, quickStartParameters.GenesisTime,
                                                          minimumEth1TimestampInclusive, null);
                    }
                    eth1Timestamp = minimumEth1TimestampInclusive;
                }
                else if (eth1Timestamp > maximumEth1TimestampInclusive)
                {
                    if (_logger.IsEnabled(LogLevel.Warning))
                    {
                        Log.QuickStartEth1TimestampTooHigh(_logger, eth1Timestamp, quickStartParameters.GenesisTime,
                                                           maximumEth1TimestampInclusive, null);
                    }
                    eth1Timestamp = maximumEth1TimestampInclusive;
                }
            }

            var eth1GenesisData = new Eth1GenesisData(quickStartParameters.Eth1BlockHash, eth1Timestamp);

            if (_logger.IsEnabled(LogLevel.Debug))
            {
                LogDebug.QuickStartGenesisDataCreated(_logger, eth1GenesisData.BlockHash, eth1GenesisData.Timestamp,
                                                      (uint)_depositStore.Deposits.Count, null);
            }

            return(Task.FromResult(eth1GenesisData));
        }
Example #17
0
 protected void Debug(string text)
 {
     LogDebug?.Invoke(this, text);
 }
Example #18
0
 internal static void WriteLogDebug(string LogLine) => LogDebug?.Invoke(null, new SingleInstanceLogEventArgs(LogLine));
Example #19
0
 public static void Debug(string log)
 {
     Logger.Debug(log);
     LogDebug?.Invoke(null, log);
 }
Example #20
0
        public void QuickStartGenesis()
        {
            QuickStartParameters quickStartParameters = _quickStartParameterOptions.CurrentValue;

            if (_logger.IsWarn())
            {
                Log.MockedQuickStart(_logger, quickStartParameters.GenesisTime, quickStartParameters.ValidatorCount, null);
            }

            GweiValues       gweiValues       = _gweiValueOptions.CurrentValue;
            InitialValues    initialValues    = _initialValueOptions.CurrentValue;
            SignatureDomains signatureDomains = _signatureDomainOptions.CurrentValue;

            // Fixed amount
            Gwei amount = gweiValues.MaximumEffectiveBalance;

            // Build deposits
            List <DepositData> depositDataList = new List <DepositData>();
            List <Deposit>     deposits        = new List <Deposit>();

            for (ulong validatorIndex = 0uL; validatorIndex < quickStartParameters.ValidatorCount; validatorIndex++)
            {
                byte[] privateKey = GeneratePrivateKey(validatorIndex);

                // Public Key
                BLSParameters blsParameters = new BLSParameters()
                {
                    PrivateKey = privateKey
                };
                using BLS bls = BLS.Create(blsParameters);
                byte[] publicKeyBytes = new byte[BlsPublicKey.Length];
                bls.TryExportBLSPublicKey(publicKeyBytes, out int publicKeyBytesWritten);
                BlsPublicKey publicKey = new BlsPublicKey(publicKeyBytes);

                // Withdrawal Credentials
                byte[] withdrawalCredentialBytes = _cryptographyService.Hash(publicKey.AsSpan()).AsSpan().ToArray();
                withdrawalCredentialBytes[0] = initialValues.BlsWithdrawalPrefix;
                Hash32 withdrawalCredentials = new Hash32(withdrawalCredentialBytes);

                // Build deposit data
                DepositData depositData = new DepositData(publicKey, withdrawalCredentials, amount);

                // Sign deposit data
                Hash32 depositDataSigningRoot = _cryptographyService.SigningRoot(depositData);
                Domain domain      = _beaconChainUtility.ComputeDomain(signatureDomains.Deposit);
                byte[] destination = new byte[96];
                bls.TrySignHash(depositDataSigningRoot.AsSpan(), destination, out int bytesWritten, domain.AsSpan());
                BlsSignature depositDataSignature = new BlsSignature(destination);
                depositData.SetSignature(depositDataSignature);

                // Deposit

                // TODO: This seems a very inefficient way (copied from tests) as it recalculates the merkle tree each time
                // (you only need to add one node)

                // TODO: Add some tests around quick start, then improve

                int index = depositDataList.Count;
                depositDataList.Add(depositData);
                //int depositDataLength = (ulong) 1 << _chainConstants.DepositContractTreeDepth;
                Hash32 root = _cryptographyService.HashTreeRoot(depositDataList);
                IEnumerable <Hash32>    allLeaves = depositDataList.Select(x => _cryptographyService.HashTreeRoot(x));
                IList <IList <Hash32> > tree      = CalculateMerkleTreeFromLeaves(allLeaves);


                IList <Hash32> merkleProof = GetMerkleProof(tree, index, 32);
                List <Hash32>  proof       = new List <Hash32>(merkleProof);
                Span <byte>    indexBytes  = new Span <byte>(new byte[32]);
                BitConverter.TryWriteBytes(indexBytes, (ulong)index + 1);
                if (!BitConverter.IsLittleEndian)
                {
                    indexBytes.Slice(0, 8).Reverse();
                }

                Hash32 indexHash = new Hash32(indexBytes);
                proof.Add(indexHash);
                Hash32 leaf = _cryptographyService.HashTreeRoot(depositData);
                _beaconChainUtility.IsValidMerkleBranch(leaf, proof, _chainConstants.DepositContractTreeDepth + 1, (ulong)index, root);
                Deposit deposit = new Deposit(proof, depositData);

                if (_logger.IsEnabled(LogLevel.Debug))
                {
                    LogDebug.QuickStartAddValidator(_logger, validatorIndex, publicKey.ToString().Substring(0, 12),
                                                    null);
                }

                deposits.Add(deposit);
            }

            BeaconState genesisState = _beaconChain.InitializeBeaconStateFromEth1(quickStartParameters.Eth1BlockHash, quickStartParameters.Eth1Timestamp, deposits);

            // We use the state directly, and don't test IsValid
            genesisState.SetGenesisTime(quickStartParameters.GenesisTime);
            IStore store = _forkChoice.GetGenesisStore(genesisState);

            if (_logger.IsEnabled(LogLevel.Debug))
            {
                LogDebug.QuickStartStoreCreated(_logger, store.GenesisTime, null);
            }
        }
Example #21
0
 public override void Debug(string message)
 {
     LogDebug.Invoke(logtype, message);
 }
        public Task <Eth1GenesisData> GetEth1GenesisDataAsync(CancellationToken cancellationToken)
        {
            QuickStartParameters quickStartParameters = _quickStartParameterOptions.CurrentValue;

            if (_logger.IsWarn())
            {
                Log.MockedQuickStart(_logger, quickStartParameters.GenesisTime, quickStartParameters.ValidatorCount,
                                     null);
            }

            GweiValues       gweiValues       = _gweiValueOptions.CurrentValue;
            InitialValues    initialValues    = _initialValueOptions.CurrentValue;
            TimeParameters   timeParameters   = _timeParameterOptions.CurrentValue;
            SignatureDomains signatureDomains = _signatureDomainOptions.CurrentValue;

            // Fixed amount
            Gwei amount = gweiValues.MaximumEffectiveBalance;

            // Build deposits
            List <DepositData> depositDataList = new List <DepositData>();
            List <Deposit>     deposits        = new List <Deposit>();

            for (ulong validatorIndex = 0uL; validatorIndex < quickStartParameters.ValidatorCount; validatorIndex++)
            {
                byte[] privateKey = GeneratePrivateKey(validatorIndex);

                // Public Key
                BLSParameters blsParameters = new BLSParameters()
                {
                    PrivateKey = privateKey
                };
                using BLS bls = BLS.Create(blsParameters);
                byte[] publicKeyBytes = new byte[BlsPublicKey.Length];
                bls.TryExportBlsPublicKey(publicKeyBytes, out int publicKeyBytesWritten);
                BlsPublicKey publicKey = new BlsPublicKey(publicKeyBytes);

                // Withdrawal Credentials
                byte[] withdrawalCredentialBytes = _cryptographyService.Hash(publicKey.AsSpan()).AsSpan().ToArray();
                withdrawalCredentialBytes[0] = initialValues.BlsWithdrawalPrefix;
                Bytes32 withdrawalCredentials = new Bytes32(withdrawalCredentialBytes);

                // Build deposit data
                DepositData depositData = new DepositData(publicKey, withdrawalCredentials, amount, BlsSignature.Zero);

                // Sign deposit data
                Domain         domain         = _beaconChainUtility.ComputeDomain(signatureDomains.Deposit);
                DepositMessage depositMessage = new DepositMessage(depositData.PublicKey,
                                                                   depositData.WithdrawalCredentials, depositData.Amount);
                Root   depositMessageRoot     = _cryptographyService.HashTreeRoot(depositMessage);
                Root   depositDataSigningRoot = _beaconChainUtility.ComputeSigningRoot(depositMessageRoot, domain);
                byte[] destination            = new byte[96];
                bls.TrySignData(depositDataSigningRoot.AsSpan(), destination, out int bytesWritten);
                BlsSignature depositDataSignature = new BlsSignature(destination);
                depositData.SetSignature(depositDataSignature);

                // Deposit

                // TODO: This seems a very inefficient way (copied from tests) as it recalculates the merkle tree each time
                // (you only need to add one node)

                // TODO: Add some tests around quick start, then improve

                int index = depositDataList.Count;
                depositDataList.Add(depositData);
                //int depositDataLength = (ulong) 1 << _chainConstants.DepositContractTreeDepth;
                Root root = _cryptographyService.HashTreeRoot(depositDataList);
                IEnumerable <Bytes32> allLeaves = depositDataList.Select(x =>
                                                                         new Bytes32(_cryptographyService.HashTreeRoot((DepositData)x).AsSpan()));
                IList <IList <Bytes32> > tree = CalculateMerkleTreeFromLeaves(allLeaves);


                IList <Bytes32> merkleProof = GetMerkleProof(tree, index, 32);
                List <Bytes32>  proof       = new List <Bytes32>(merkleProof);

                byte[] indexBytes = new byte[32];
                BinaryPrimitives.WriteInt32LittleEndian(indexBytes, index + 1);
                Bytes32 indexHash = new Bytes32(indexBytes);
                proof.Add(indexHash);
                Bytes32 leaf = new Bytes32(_cryptographyService.HashTreeRoot(depositData).AsSpan());
                _beaconChainUtility.IsValidMerkleBranch(leaf, proof, _chainConstants.DepositContractTreeDepth + 1,
                                                        (ulong)index, root);
                Deposit deposit = new Deposit(proof, depositData);

                if (_logger.IsEnabled(LogLevel.Debug))
                {
                    LogDebug.QuickStartAddValidator(_logger, validatorIndex, publicKey.ToString().Substring(0, 12),
                                                    null);
                }

                deposits.Add(deposit);
            }

            ulong eth1Timestamp = quickStartParameters.Eth1Timestamp;

            if (eth1Timestamp == 0)
            {
                eth1Timestamp = quickStartParameters.GenesisTime - (ulong)(1.5 * timeParameters.MinimumGenesisDelay);
            }
            else
            {
                ulong minimumEth1TimestampInclusive =
                    quickStartParameters.GenesisTime - 2 * timeParameters.MinimumGenesisDelay;
                ulong maximumEth1TimestampInclusive =
                    quickStartParameters.GenesisTime - timeParameters.MinimumGenesisDelay - 1;
                if (eth1Timestamp < minimumEth1TimestampInclusive)
                {
                    if (_logger.IsEnabled(LogLevel.Warning))
                    {
                        Log.QuickStartEth1TimestampTooLow(_logger, eth1Timestamp, quickStartParameters.GenesisTime,
                                                          minimumEth1TimestampInclusive, null);
                    }
                    eth1Timestamp = minimumEth1TimestampInclusive;
                }
                else if (eth1Timestamp > maximumEth1TimestampInclusive)
                {
                    if (_logger.IsEnabled(LogLevel.Warning))
                    {
                        Log.QuickStartEth1TimestampTooHigh(_logger, eth1Timestamp, quickStartParameters.GenesisTime,
                                                           maximumEth1TimestampInclusive, null);
                    }
                    eth1Timestamp = maximumEth1TimestampInclusive;
                }
            }

            var eth1GenesisData = new Eth1GenesisData(quickStartParameters.Eth1BlockHash, eth1Timestamp,
                                                      deposits);

            if (_logger.IsEnabled(LogLevel.Debug))
            {
                LogDebug.QuickStartGenesisDataCreated(_logger, eth1GenesisData.BlockHash, eth1GenesisData.Timestamp,
                                                      eth1GenesisData.Deposits.Count, null);
            }

            return(Task.FromResult(eth1GenesisData));
        }