public UInt256?BlockGasLimit(BlockHeader parentHeader)
        {
            this.BlockActivationCheck(parentHeader);
            var function   = nameof(BlockGasLimit);
            var returnData = Constant.Call(new CallInfo(parentHeader, function, Address.Zero));

            return((returnData?.Length ?? 0) == 0 ? (UInt256?)null : (UInt256)returnData[0]);
        }
 public virtual UInt256 ContractVersion(BlockHeader blockHeader)
 {
     try
     {
         return(Constant.Call <UInt256>(blockHeader, nameof(ContractVersion), Address.Zero));
     }
     catch (Exception)
     {
         return(UInt256.One);
     }
 }
Esempio n. 3
0
 /// <summary>
 /// Returns the Keccak-256 hash and cipher of the validator's secret for the specified collection round and the specified validator stored by the validator through the `commitHash` function.
 /// </summary>
 /// <param name="parentHeader">Block header on which this is to be executed on.</param>
 /// <param name="collectRound">The serial number of the collection round for which hash and cipher should be retrieved.</param>
 /// <returns>Keccak-256 hash and cipher of the validator's secret for the specified collection round and the specified validator stored by the validator through the `commitHash` function.</returns>
 /// <remarks>
 /// The mining address of validator is last contract parameter.
 /// </remarks>
 public (Keccak Hash, byte[] Cipher) GetCommitAndCipher(BlockHeader parentHeader, UInt256 collectRound)
 {
     var(hash, cipher) = Constant.Call <byte[], byte[]>(parentHeader, nameof(GetCommitAndCipher), _nodeAddress, collectRound, _nodeAddress);
     return(new Keccak(hash), cipher);
 }
Esempio n. 4
0
 /// <summary>
 /// Returns a boolean flag indicating whether the current phase of the current collection round is a `commits phase`.
 /// Used by the validator's node to determine if it should commit the hash of the secret during the current collection round.
 /// </summary>
 /// <param name="parentHeader">Block header on which this is to be executed on.</param>
 /// <returns>Boolean flag indicating whether the current phase of the current collection round is a `commits phase`.</returns>
 private bool IsCommitPhase(BlockHeader parentHeader) => Constant.Call <bool>(parentHeader, nameof(IsCommitPhase), _nodeAddress);
Esempio n. 5
0
 /// <summary>
 /// Returns the serial number of the current collection round.
 /// </summary>
 /// <param name="parentHeader">Block header on which this is to be executed on.</param>
 /// <returns>Serial number of the current collection round.</returns>
 private UInt256 CurrentCollectRound(BlockHeader parentHeader) => Constant.Call <UInt256>(parentHeader, nameof(CurrentCollectRound), _nodeAddress);
Esempio n. 6
0
 /// <summary>
 /// Returns a boolean flag indicating whether the specified validator has committed their secret's hash for the specified collection round.
 /// </summary>
 /// <param name="parentHeader">Block header on which this is to be executed on.</param>
 /// <param name="collectRound">The serial number of the collection round for which the checkup should be done.</param>
 /// <returns>Boolean flag indicating whether the specified validator has committed their secret's hash for the specified collection round.</returns>
 /// <remarks>
 /// The mining address of validator is last contract parameter.
 /// </remarks>
 private bool IsCommitted(BlockHeader parentHeader, UInt256 collectRound) => Constant.Call <bool>(parentHeader, nameof(IsCommitted), _nodeAddress, collectRound, _nodeAddress);
Esempio n. 7
0
 /// <summary>
 /// Returns a boolean flag of whether the specified validator has revealed their number for the specified collection round.
 /// </summary>
 /// <param name="parentHeader">Block header on which this is to be executed on.</param>
 /// <param name="collectRound">The serial number of the collection round for which the checkup should be done.</param>
 /// <returns>Boolean flag of whether the specified validator has revealed their number for the specified collection round.</returns>
 /// <remarks>
 /// The mining address of validator is last contract parameter.
 /// </remarks>
 private bool SentReveal(BlockHeader parentHeader, UInt256 collectRound) => Constant.Call <bool>(parentHeader, nameof(SentReveal), _nodeAddress, collectRound, _nodeAddress);
Esempio n. 8
0
 /// <summary>
 /// Returns a boolean flag indicating whether the current phase of the current collection round is a `commits phase`.
 /// Used by the validator's node to determine if it should commit the hash of the secret during the current collection round.
 /// </summary>
 /// <param name="parentHeader">Block header on which this is to be executed on.</param>
 /// <returns>Boolean flag indicating whether the current phase of the current collection round is a `commits phase`.</returns>
 private bool IsCommitPhase(BlockHeader parentHeader) => Constant.Call <bool>(parentHeader, Definition.GetFunction(nameof(IsCommitPhase)), _nodeAddress);
Esempio n. 9
0
 /// <summary>
 /// Returns the serial number of the current collection round.
 /// </summary>
 /// <param name="parentHeader">Block header on which this is to be executed on.</param>
 /// <returns>Serial number of the current collection round.</returns>
 private UInt256 CurrentCollectRound(BlockHeader parentHeader) => Constant.Call <UInt256>(parentHeader, Definition.GetFunction(nameof(CurrentCollectRound)), _nodeAddress);
Esempio n. 10
0
 /// <summary>
 /// Returns a boolean flag indicating whether the specified validator has committed their secret's hash for the specified collection round.
 /// </summary>
 /// <param name="parentHeader">Block header on which this is to be executed on.</param>
 /// <param name="collectRound">The serial number of the collection round for which the checkup should be done.</param>
 /// <returns>Boolean flag indicating whether the specified validator has committed their secret's hash for the specified collection round.</returns>
 /// <remarks>
 /// The mining address of validator is last contract parameter.
 /// </remarks>
 private bool IsCommitted(BlockHeader parentHeader, UInt256 collectRound) => Constant.Call <bool>(parentHeader, Definition.GetFunction(nameof(IsCommitted)), _nodeAddress, collectRound, _nodeAddress);
Esempio n. 11
0
 /// <summary>
 /// Returns a boolean flag of whether the specified validator has revealed their number for the specified collection round.
 /// </summary>
 /// <param name="parentHeader">Block header on which this is to be executed on.</param>
 /// <param name="collectRound">The serial number of the collection round for which the checkup should be done.</param>
 /// <returns>Boolean flag of whether the specified validator has revealed their number for the specified collection round.</returns>
 /// <remarks>
 /// The mining address of validator is last contract parameter.
 /// </remarks>
 private bool SentReveal(BlockHeader parentHeader, UInt256 collectRound) => Constant.Call <bool>(parentHeader, Definition.GetFunction(nameof(SentReveal)), _nodeAddress, collectRound, _nodeAddress);
 /// <summary>
 /// Returns a boolean flag indicating whether the `emitInitiateChange` function can be called at the moment. Used by a validator's node and `TxPermission` contract (to deny dummy calling).
 /// </summary>
 public bool EmitInitiateChangeCallable(BlockHeader parentHeader) => Constant.Call <bool>(parentHeader, nameof(EmitInitiateChangeCallable), Address.SystemUser);
 public virtual UInt256 ContractVersion(BlockHeader blockHeader)
 {
     return(Constant.Call <UInt256>(blockHeader, nameof(ContractVersion), Address.Zero));
 }
 protected virtual (ITransactionPermissionContract.TxPermissions, bool) CallAllowedTxTypes(PermissionConstantContract.PermissionCallInfo callInfo) =>
 Constant.Call <ITransactionPermissionContract.TxPermissions, bool>(callInfo);
 /// <summary>
 /// Returns the Keccak-256 hash and cipher of the validator's secret for the specified collection round and the specified validator stored by the validator through the `commitHash` function.
 /// </summary>
 /// <param name="blockHeader">Block header on which this is to be executed on.</param>
 /// <param name="collectRound">The serial number of the collection round for which hash and cipher should be retrieved.</param>
 /// <returns>Keccak-256 hash and cipher of the validator's secret for the specified collection round and the specified validator stored by the validator through the `commitHash` function.</returns>
 /// <remarks>
 /// The mining address of validator is last contract parameter.
 /// </remarks>
 public (Keccak Hash, byte[] Cipher) GetCommitAndCipher(BlockHeader blockHeader, UInt256 collectRound)
 {
     var(hash, cipher) = Constant.Call <byte[], byte[]>(blockHeader, Definition.GetFunction(nameof(GetCommitAndCipher)), _nodeAddress, collectRound, _nodeAddress);
     return(new Keccak(hash), cipher);
 }