mirror of
https://github.com/status-im/nimbus-eth2.git
synced 2025-01-22 20:42:13 +00:00
Address review comments.
This commit is contained in:
parent
5699d2212d
commit
3a9b4f065a
@ -14,7 +14,7 @@ import
|
||||
../networking/network_metadata,
|
||||
web3, web3/confutils_defs, eth/keys, eth/p2p/discoveryv5/random2,
|
||||
stew/[io2, byteutils],
|
||||
../spec/eth2_merkleization,
|
||||
../spec/[eth2_merkleization, helpers],
|
||||
../spec/datatypes/base,
|
||||
../validators/keystore_management
|
||||
|
||||
@ -136,16 +136,13 @@ proc sendEth(web3: Web3, to: Eth1Address, valueEth: int): Future[TxHash] =
|
||||
`from`: web3.defaultAccount,
|
||||
gas: Quantity(3000000).some,
|
||||
gasPrice: Quantity(1).some,
|
||||
value: some(valueEth.u256 * 1000000000000000000.u256),
|
||||
value: some(valueEth.toWei),
|
||||
to: some(to))
|
||||
web3.send(tr)
|
||||
|
||||
type
|
||||
DelayGenerator* = proc(): chronos.Duration {.gcsafe, raises: [].}
|
||||
|
||||
proc ethToWei(eth: UInt256): UInt256 =
|
||||
eth * 1000000000000000000.u256
|
||||
|
||||
proc initWeb3(web3Url, privateKey: string): Future[Web3] {.async.} =
|
||||
result = await newWeb3(web3Url)
|
||||
if privateKey.len != 0:
|
||||
@ -180,7 +177,7 @@ proc sendDeposits*(deposits: seq[LaunchPadDeposit],
|
||||
SignatureBytes(@(dp.signature.toRaw())),
|
||||
FixedBytes[32](hash_tree_root(dp).data))
|
||||
|
||||
let status = await tx.send(value = 32.u256.ethToWei, gasPrice = gasPrice)
|
||||
let status = await tx.send(value = 32.toWei, gasPrice = gasPrice)
|
||||
|
||||
info "Deposit sent", tx = $status
|
||||
|
||||
|
@ -523,3 +523,9 @@ proc blockToBlockHeader*(blck: ForkyBeaconBlock): ExecutionBlockHeader =
|
||||
|
||||
proc compute_execution_block_hash*(blck: ForkyBeaconBlock): Eth2Digest =
|
||||
rlpHash blockToBlockHeader(blck)
|
||||
|
||||
func toWei*(eth: SomeInteger): UInt256 =
|
||||
eth.u256 * 1000000000000000000.u256
|
||||
|
||||
func toWei*(eth: UInt256): UInt256 =
|
||||
eth * 1000000000000000000.u256
|
||||
|
@ -7,7 +7,7 @@
|
||||
|
||||
{.push raises: [].}
|
||||
|
||||
import ".."/spec/[forks, beaconstate, state_transition_block]
|
||||
import ".."/spec/[forks, beaconstate, state_transition_block, helpers]
|
||||
|
||||
type
|
||||
AuxiliaryState = object
|
||||
@ -56,6 +56,8 @@ template withStateAndMaybeBlindedBlck(
|
||||
const consensusFork {.inject, used.} = ConsensusFork.Deneb
|
||||
template forkyState: untyped {.inject.} = s.denebData
|
||||
template forkyBlck: untyped {.inject.} = b
|
||||
else:
|
||||
{.error: "withStateAndMaybeBlindedBlock does not support " & $typeof(b).}
|
||||
|
||||
func init(t: typedesc[AuxiliaryState],
|
||||
forkedState: ForkedHashedBeaconState): Opt[AuxiliaryState] =
|
||||
@ -166,9 +168,6 @@ proc collectFromSyncAggregate(
|
||||
if aggregate.sync_committee_bits[i]:
|
||||
proposerOutcome += proposer_reward
|
||||
|
||||
proc gweiToWei(eth: Gwei): UInt256 =
|
||||
eth.u256 * 1000000000000000000.u256
|
||||
|
||||
proc collectBlockRewards*(
|
||||
forkedState: ForkedHashedBeaconState,
|
||||
forkedBlock: RewardingBlock
|
||||
@ -184,4 +183,4 @@ proc collectBlockRewards*(
|
||||
reward.collectFromAttestations(
|
||||
forkedState, forkedBlock, auxiliaryState, cache)
|
||||
reward.collectFromSyncAggregate(forkedState, forkedBlock, cache)
|
||||
ok(gweiToWei(reward))
|
||||
ok(reward.toWei)
|
||||
|
@ -15,7 +15,7 @@ import
|
||||
../beacon_chain/conf,
|
||||
../beacon_chain/el/el_manager,
|
||||
../beacon_chain/networking/eth2_network,
|
||||
../beacon_chain/spec/eth2_merkleization,
|
||||
../beacon_chain/spec/[eth2_merkleization, helpers],
|
||||
../beacon_chain/spec/datatypes/base,
|
||||
../beacon_chain/spec/eth2_apis/eth2_rest_serialization,
|
||||
../beacon_chain/validators/keystore_management,
|
||||
@ -518,16 +518,13 @@ proc sendEth(web3: Web3, to: Eth1Address, valueEth: int): Future[TxHash] =
|
||||
`from`: web3.defaultAccount,
|
||||
gas: Quantity(3000000).some,
|
||||
gasPrice: Quantity(1).some,
|
||||
value: some(valueEth.u256 * 1000000000000000000.u256),
|
||||
value: some(valueEth.toWei),
|
||||
to: some(to))
|
||||
web3.send(tr)
|
||||
|
||||
type
|
||||
DelayGenerator = proc(): chronos.Duration {.gcsafe, raises: [].}
|
||||
|
||||
func ethToWei(eth: UInt256): UInt256 =
|
||||
eth * 1000000000000000000.u256
|
||||
|
||||
proc initWeb3(web3Url, privateKey: string): Future[Web3] {.async.} =
|
||||
result = await newWeb3(web3Url)
|
||||
if privateKey.len != 0:
|
||||
@ -562,7 +559,7 @@ proc sendDeposits(deposits: seq[LaunchPadDeposit],
|
||||
SignatureBytes(@(dp.signature.toRaw())),
|
||||
FixedBytes[32](hash_tree_root(dp).data))
|
||||
|
||||
let status = await tx.send(value = 32.u256.ethToWei, gasPrice = gasPrice)
|
||||
let status = await tx.send(value = 32.toWei, gasPrice = gasPrice)
|
||||
|
||||
info "Deposit sent", tx = $status
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user