Skip to content

Commit

Permalink
Merge pull request #34 from samcm/fix/beacon-changes
Browse files Browse the repository at this point in the history
feat(consensus): Bugfixes for beacon.Node
  • Loading branch information
samcm committed Jul 12, 2022
2 parents 51b25b4 + ec6f3ab commit af18b3d
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 1 deletion.
7 changes: 7 additions & 0 deletions pkg/exporter/consensus/beacon/beacon.go
Original file line number Diff line number Diff line change
Expand Up @@ -264,12 +264,19 @@ func (n *node) subscribeToSelf(ctx context.Context) error {

start := time.Now()

// Sleep a little for the beacon node to actually save the block
time.Sleep(200 * time.Millisecond)

// Grab the entire block from the beacon node
block, err := n.getBlock(ctx, fmt.Sprintf("%v", ev.Slot))
if err != nil {
return err
}

if block == nil {
return errors.New("fetched block is nil")
}

// Insert the beacon block into the state
if err := n.state.AddBeaconBlock(ctx, block, start); err != nil {
return err
Expand Down
8 changes: 7 additions & 1 deletion pkg/exporter/pair/pair.go
Original file line number Diff line number Diff line change
Expand Up @@ -166,8 +166,14 @@ func (p *pair) deriveConsensusMechanism(ctx context.Context) error {

consensusMechanism := DefaultConsensusMechanism

networkID := uint64(1)

if p.networkID != nil {
networkID = p.networkID.Uint64()
}

// Support networks like Goerli that use Proof of Authority as the default consensus mechanism.
if value, exists := DefaultNetworkConsensusMechanism[p.networkID.Uint64()]; exists {
if value, exists := DefaultNetworkConsensusMechanism[networkID]; exists {
consensusMechanism = value
}

Expand Down

0 comments on commit af18b3d

Please sign in to comment.