public bool Equals(Eth1Data?other) { return(!(other is null) && BlockHash == other.BlockHash && DepositCount == other.DepositCount && DepositRoot.Equals(other.DepositRoot)); }
public static BeaconState Create( // Versioning ulong?genesisTime = null, Slot?slot = null, Fork?fork = null, // History BeaconBlockHeader?latestBlockHeader = null, Root[]?blockRoots = null, Root[]?stateRoots = null, IList <Root>?historicalRoots = null, // Eth1 Eth1Data?eth1Data = null, IList <Eth1Data>?eth1DataVotes = null, ulong?eth1DepositIndex = null, // Registry IList <Validator>?validators = null, IList <Gwei>?balances = null, // Randomness Bytes32[]?randaoMixes = null, // Slashings Gwei[]?slashings = null, // Attestations IList <PendingAttestation>?previousEpochAttestations = null, IList <PendingAttestation>?currentEpochAttestations = null, // Finality BitArray?justificationBits = null, Checkpoint?previousJustifiedCheckpoint = null, Checkpoint?currentJustifiedCheckpoint = null, Checkpoint?finalizedCheckpoint = null) { BeaconState state = new BeaconState( genesisTime ?? 0, slot ?? Slot.Zero, fork ?? new Fork(new ForkVersion(), new ForkVersion(), Epoch.Zero), latestBlockHeader ?? BeaconBlockHeader.Zero, blockRoots ?? new Root[0], stateRoots ?? new Root[0], historicalRoots ?? new List <Root>(), eth1Data ?? Eth1Data.Zero, eth1DataVotes ?? new List <Eth1Data>(), eth1DepositIndex ?? 0, validators ?? new List <Validator>(), balances ?? new List <Gwei>(), randaoMixes ?? new Bytes32[0], slashings ?? new Gwei[0], previousEpochAttestations ?? new List <PendingAttestation>(), currentEpochAttestations ?? new List <PendingAttestation>(), justificationBits ?? new BitArray(0), previousJustifiedCheckpoint ?? Checkpoint.Zero, currentJustifiedCheckpoint ?? Checkpoint.Zero, finalizedCheckpoint ?? Checkpoint.Zero); return(state); }
private static void TestEth1DataSsz(byte[] serialized, UInt256 expectedMerkleRoot, string testCaseDir) { Eth1Data?container = Nethermind.Ssz.Ssz.DecodeEth1Data(serialized); byte[] again = new byte[serialized.Length]; Nethermind.Ssz.Ssz.Encode(again, container); Assert.AreEqual(serialized.ToHexString(), again.ToHexString(), testCaseDir); Merkle.Ize(out UInt256 root, container); Assert.AreEqual(expectedMerkleRoot, root); }
public static void Ize(out UInt256 root, Eth1Data?container) { if (container is null) { root = RootOfNull; return; } Merkleizer merkleizer = new Merkleizer(2); merkleizer.Feed(container.DepositRoot); merkleizer.Feed(container.DepositCount); merkleizer.Feed(container.BlockHash); merkleizer.CalculateRoot(out root); }
public static void Encode(Span <byte> span, Eth1Data?container) { if (span.Length != Ssz.Eth1DataLength) { ThrowTargetLength <Eth1Data>(span.Length, Ssz.Eth1DataLength); } if (container == null) { return; } int offset = 0; Encode(span, container.DepositRoot, ref offset); Encode(span, container.DepositCount, ref offset); Encode(span, container.BlockHash, ref offset); }
private static void Encode(Span <byte> span, Eth1Data?value, ref int offset) { Encode(span.Slice(offset, Ssz.Eth1DataLength), value); offset += Ssz.Eth1DataLength; }