mirror of
https://github.com/OffchainLabs/prysm.git
synced 2026-01-09 13:28:01 -05:00
* update diff * deps * add tests for `SaveLightClientUpdate` * cleanup imports * lint * changelog * fix incorrect arithmetic * check for lightclient feature flag * fix tests * fix `saveLightClientBootstrap` and `saveLightClientUpdate` * replace and with or * move feature check to `postBlockProcess` --------- Co-authored-by: Radosław Kapka <rkapka@wp.pl>
46 lines
1.5 KiB
Go
46 lines
1.5 KiB
Go
package lightclient
|
|
|
|
import (
|
|
"context"
|
|
|
|
"github.com/prysmaticlabs/prysm/v5/consensus-types/primitives"
|
|
|
|
"github.com/prysmaticlabs/prysm/v5/api/server/structs"
|
|
lightclient "github.com/prysmaticlabs/prysm/v5/beacon-chain/core/light-client"
|
|
"github.com/prysmaticlabs/prysm/v5/beacon-chain/state"
|
|
"github.com/prysmaticlabs/prysm/v5/consensus-types/interfaces"
|
|
)
|
|
|
|
func newLightClientFinalityUpdateFromBeaconState(
|
|
ctx context.Context,
|
|
currentSlot primitives.Slot,
|
|
state state.BeaconState,
|
|
block interfaces.ReadOnlySignedBeaconBlock,
|
|
attestedState state.BeaconState,
|
|
attestedBlock interfaces.ReadOnlySignedBeaconBlock,
|
|
finalizedBlock interfaces.ReadOnlySignedBeaconBlock,
|
|
) (*structs.LightClientFinalityUpdate, error) {
|
|
result, err := lightclient.NewLightClientFinalityUpdateFromBeaconState(ctx, currentSlot, state, block, attestedState, attestedBlock, finalizedBlock)
|
|
if err != nil {
|
|
return nil, err
|
|
}
|
|
|
|
return structs.LightClientFinalityUpdateFromConsensus(result)
|
|
}
|
|
|
|
func newLightClientOptimisticUpdateFromBeaconState(
|
|
ctx context.Context,
|
|
currentSlot primitives.Slot,
|
|
state state.BeaconState,
|
|
block interfaces.ReadOnlySignedBeaconBlock,
|
|
attestedState state.BeaconState,
|
|
attestedBlock interfaces.ReadOnlySignedBeaconBlock,
|
|
) (*structs.LightClientOptimisticUpdate, error) {
|
|
result, err := lightclient.NewLightClientOptimisticUpdateFromBeaconState(ctx, currentSlot, state, block, attestedState, attestedBlock)
|
|
if err != nil {
|
|
return nil, err
|
|
}
|
|
|
|
return structs.LightClientOptimisticUpdateFromConsensus(result)
|
|
}
|