public BeaconState( ulong genesisTime, Fork fork, Eth1Data eth1Data, BeaconBlockHeader latestBlockHeader, Bytes32[] randaoMixes, uint slotsPerHistoricalRoot, ulong epochsPerHistoricalVector, ulong epochsPerSlashingsVector, int justificationBitsLength) { GenesisTime = genesisTime; Fork = fork; Eth1DepositIndex = 0; _eth1DataVotes = new List <Eth1Data>(); Eth1Data = eth1Data; LatestBlockHeader = latestBlockHeader; _randaoMixes = randaoMixes; // Default/empty values: _validators = new List <Validator>(); _balances = new List <Gwei>(); _blockRoots = Enumerable.Repeat(Root.Zero, (int)slotsPerHistoricalRoot).ToArray(); _stateRoots = Enumerable.Repeat(Root.Zero, (int)slotsPerHistoricalRoot).ToArray(); _historicalRoots = new List <Root>(); //_randaoMixes = Enumerable.Repeat(Bytes32.Zero, (int)epochsPerHistoricalVector).ToArray(); _slashings = Enumerable.Repeat(Gwei.Zero, (int)epochsPerSlashingsVector).ToArray(); _previousEpochAttestations = new List <PendingAttestation>(); _currentEpochAttestations = new List <PendingAttestation>(); JustificationBits = new BitArray(justificationBitsLength); CurrentJustifiedCheckpoint = new Checkpoint(new Epoch(0), Root.Zero); PreviousJustifiedCheckpoint = new Checkpoint(new Epoch(0), Root.Zero); FinalizedCheckpoint = new Checkpoint(new Epoch(0), Root.Zero); }
public BeaconState(ulong genesisTime, ulong eth1DepositIndex, Eth1Data eth1Data, BeaconBlockHeader latestBlockHeader, uint slotsPerHistoricalRoot, ulong epochsPerHistoricalVector, ulong epochsPerSlashingsVector, int justificationBitsLength) { GenesisTime = genesisTime; Eth1DepositIndex = eth1DepositIndex; _eth1DataVotes = new List <Eth1Data>(); Eth1Data = eth1Data; LatestBlockHeader = latestBlockHeader; _validators = new List <Validator>(); _balances = new List <Gwei>(); _blockRoots = Enumerable.Repeat(Hash32.Zero, (int)slotsPerHistoricalRoot).ToArray(); _stateRoots = Enumerable.Repeat(Hash32.Zero, (int)slotsPerHistoricalRoot).ToArray(); _historicalRoots = new List <Hash32>(); _randaoMixes = Enumerable.Repeat(Hash32.Zero, (int)epochsPerHistoricalVector).ToArray(); _slashings = Enumerable.Repeat(Gwei.Zero, (int)epochsPerSlashingsVector).ToArray(); _previousEpochAttestations = new List <PendingAttestation>(); _currentEpochAttestations = new List <PendingAttestation>(); JustificationBits = new BitArray(justificationBitsLength); Fork = new Fork(new ForkVersion(), new ForkVersion(), Epoch.Zero); CurrentJustifiedCheckpoint = new Checkpoint(new Epoch(0), Hash32.Zero); PreviousJustifiedCheckpoint = new Checkpoint(new Epoch(0), Hash32.Zero); FinalizedCheckpoint = new Checkpoint(new Epoch(0), Hash32.Zero); //_previousCrosslinks = Enumerable.Repeat(new Crosslink(Shard.Zero), (int)(ulong)shardCount).ToArray(); //_currentCrosslinks = Enumerable.Repeat(new Crosslink(Shard.Zero), (int)(ulong)shardCount).ToArray(); //_currentCrosslinks = Enumerable.Range(0, (int)(ulong)shardCount).Select(x => new Crosslink(new Shard((ulong)x))).ToArray(); }
public BeaconState( // Versioning ulong genesisTime, Slot slot, Fork fork, // History BeaconBlockHeader latestBlockHeader, Root[] blockRoots, Root[] stateRoots, IList <Root> historicalRoots, // Eth1 Eth1Data eth1Data, IList <Eth1Data> eth1DataVotes, ulong eth1DepositIndex, // Registry IList <Validator> validators, IList <Gwei> balances, // Randomness Bytes32[] randaoMixes, // Slashings Gwei[] slashings, // Attestations IList <PendingAttestation> previousEpochAttestations, IList <PendingAttestation> currentEpochAttestations, // Finality BitArray justificationBits, Checkpoint previousJustifiedCheckpoint, Checkpoint currentJustifiedCheckpoint, Checkpoint finalizedCheckpoint) { GenesisTime = genesisTime; Slot = slot; Fork = fork; LatestBlockHeader = latestBlockHeader; _blockRoots = blockRoots; _stateRoots = stateRoots; _historicalRoots = historicalRoots.ToList(); Eth1Data = eth1Data; _eth1DataVotes = eth1DataVotes.ToList(); Eth1DepositIndex = eth1DepositIndex; _validators = validators.ToList(); _balances = balances.ToList(); _randaoMixes = randaoMixes; _slashings = slashings; _previousEpochAttestations = previousEpochAttestations.ToList(); _currentEpochAttestations = currentEpochAttestations.ToList(); JustificationBits = justificationBits; PreviousJustifiedCheckpoint = previousJustifiedCheckpoint; CurrentJustifiedCheckpoint = currentJustifiedCheckpoint; FinalizedCheckpoint = finalizedCheckpoint; }
public bool Equals(BeaconState other) { return(GenesisTime == other.GenesisTime && Slot.Equals(other.Slot) && Fork.Equals(other.Fork) && Equals(LatestBlockHeader, other.LatestBlockHeader) && BlockRoots.Length == other.BlockRoots.Length && StateRoots.Length == other.StateRoots.Length && HistoricalRoots.Length == other.HistoricalRoots.Length && Equals(Eth1Data, other.Eth1Data) && Eth1DataVotes.Length == other.Eth1DataVotes.Length && Eth1DepositIndex == other.Eth1DepositIndex && Validators.Length == other.Validators.Length && Balances.Length == other.Balances.Length && RandaoMixes.Length == other.RandaoMixes.Length && Slashings.Length == other.Slashings.Length && PreviousEpochAttestations.Length == other.PreviousEpochAttestations.Length && CurrentEpochAttestations.Length == other.CurrentEpochAttestations.Length && JustificationBits == other.JustificationBits && PreviousJustifiedCheckpoint.Equals(other.PreviousJustifiedCheckpoint) && CurrentJustifiedCheckpoint.Equals(other.CurrentJustifiedCheckpoint) && FinalizedCheckpoint.Equals(other.FinalizedCheckpoint)); }