mirror of
https://github.com/OffchainLabs/prysm.git
synced 2026-01-08 23:18:15 -05:00
Use Block Interface Across Prysm (#8918)
* commit initial work * checkpoint current work * gaz * checkpoint * req/resp changes * initial-sync * finally works * fix error * fix bugs * fix issue * fix issues * fix refs * tests * more text fixes * more text fixes * more text fixes * fix tests * fix tests * tests * finally fix builds * finally * comments * fix fuzz * share common library * fix * fix * add in more defensive nil checks * add in more defensive nil checks * imports * Apply suggestions from code review Co-authored-by: terence tsao <terence@prysmaticlabs.com> * Apply suggestions from code review Co-authored-by: terence tsao <terence@prysmaticlabs.com> * Update shared/interfaces/block_interface.go Co-authored-by: terence tsao <terence@prysmaticlabs.com> * Update shared/interfaces/block_wrapper.go Co-authored-by: terence tsao <terence@prysmaticlabs.com> * Update shared/interfaces/block_interface.go Co-authored-by: terence tsao <terence@prysmaticlabs.com> * imports * fix bad changes * fix * terence's review * terence's review * fmt * Update beacon-chain/rpc/beacon/blocks.go Co-authored-by: Radosław Kapka <rkapka@wp.pl> * fix tests * fix * fix all tests Co-authored-by: terence tsao <terence@prysmaticlabs.com> Co-authored-by: Radosław Kapka <rkapka@wp.pl>
This commit is contained in:
@@ -15,6 +15,7 @@ go_library(
|
||||
"//proto/beacon/p2p/v1:go_default_library",
|
||||
"//shared/benchutil:go_default_library",
|
||||
"//shared/fileutil:go_default_library",
|
||||
"//shared/interfaces:go_default_library",
|
||||
"//shared/interop:go_default_library",
|
||||
"//shared/params:go_default_library",
|
||||
"//shared/testutil:go_default_library",
|
||||
|
||||
@@ -18,6 +18,7 @@ import (
|
||||
pb "github.com/prysmaticlabs/prysm/proto/beacon/p2p/v1"
|
||||
"github.com/prysmaticlabs/prysm/shared/benchutil"
|
||||
"github.com/prysmaticlabs/prysm/shared/fileutil"
|
||||
"github.com/prysmaticlabs/prysm/shared/interfaces"
|
||||
"github.com/prysmaticlabs/prysm/shared/interop"
|
||||
"github.com/prysmaticlabs/prysm/shared/params"
|
||||
"github.com/prysmaticlabs/prysm/shared/testutil"
|
||||
@@ -102,7 +103,7 @@ func generateMarshalledFullStateAndBlock() error {
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
beaconState, err = state.ExecuteStateTransition(context.Background(), beaconState, block)
|
||||
beaconState, err = state.ExecuteStateTransition(context.Background(), beaconState, interfaces.NewWrappedSignedBeaconBlock(block))
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
@@ -126,7 +127,7 @@ func generateMarshalledFullStateAndBlock() error {
|
||||
}
|
||||
block.Block.Body.Attestations = append(atts, block.Block.Body.Attestations...)
|
||||
|
||||
s, err := state.CalculateStateRoot(context.Background(), beaconState, block)
|
||||
s, err := state.CalculateStateRoot(context.Background(), beaconState, interfaces.NewWrappedSignedBeaconBlock(block))
|
||||
if err != nil {
|
||||
return errors.Wrap(err, "could not calculate state root")
|
||||
}
|
||||
@@ -157,7 +158,7 @@ func generateMarshalledFullStateAndBlock() error {
|
||||
}
|
||||
|
||||
// Running a single state transition to make sure the generated files aren't broken.
|
||||
_, err = state.ExecuteStateTransition(context.Background(), beaconState, block)
|
||||
_, err = state.ExecuteStateTransition(context.Background(), beaconState, interfaces.NewWrappedSignedBeaconBlock(block))
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
@@ -191,7 +192,7 @@ func generate2FullEpochState() error {
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
beaconState, err = state.ExecuteStateTransition(context.Background(), beaconState, block)
|
||||
beaconState, err = state.ExecuteStateTransition(context.Background(), beaconState, interfaces.NewWrappedSignedBeaconBlock(block))
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
@@ -67,7 +67,7 @@ func main() {
|
||||
if err != nil {
|
||||
panic(err)
|
||||
}
|
||||
slot := b.Block.Slot
|
||||
slot := b.Block().Slot()
|
||||
// If the state is not available, roll back
|
||||
for state == nil {
|
||||
slot--
|
||||
@@ -83,11 +83,11 @@ func main() {
|
||||
|
||||
// Construct label of each node.
|
||||
rStr := hex.EncodeToString(r[:2])
|
||||
label := "slot: " + strconv.Itoa(int(b.Block.Slot)) + "\n root: " + rStr
|
||||
label := "slot: " + strconv.Itoa(int(b.Block().Slot())) + "\n root: " + rStr
|
||||
|
||||
dotN := graph.Node(rStr).Box().Attr("label", label)
|
||||
n := &node{
|
||||
parentRoot: bytesutil.ToBytes32(b.Block.ParentRoot),
|
||||
parentRoot: bytesutil.ToBytes32(b.Block().ParentRoot()),
|
||||
dothNode: &dotN,
|
||||
}
|
||||
m[r] = n
|
||||
|
||||
@@ -13,6 +13,7 @@ go_library(
|
||||
"//beacon-chain/core/state:go_default_library",
|
||||
"//beacon-chain/state/stateV0:go_default_library",
|
||||
"//proto/beacon/p2p/v1:go_default_library",
|
||||
"//shared/interfaces:go_default_library",
|
||||
"//shared/sszutil:go_default_library",
|
||||
"//shared/version:go_default_library",
|
||||
"@com_github_ferranbt_fastssz//:go_default_library",
|
||||
|
||||
@@ -15,6 +15,7 @@ import (
|
||||
"github.com/prysmaticlabs/prysm/beacon-chain/core/state"
|
||||
"github.com/prysmaticlabs/prysm/beacon-chain/state/stateV0"
|
||||
pb "github.com/prysmaticlabs/prysm/proto/beacon/p2p/v1"
|
||||
"github.com/prysmaticlabs/prysm/shared/interfaces"
|
||||
"github.com/prysmaticlabs/prysm/shared/sszutil"
|
||||
"github.com/prysmaticlabs/prysm/shared/version"
|
||||
log "github.com/sirupsen/logrus"
|
||||
@@ -175,7 +176,7 @@ func main() {
|
||||
blkRoot,
|
||||
preStateRoot,
|
||||
)
|
||||
postState, err := state.ExecuteStateTransition(context.Background(), stateObj, block)
|
||||
postState, err := state.ExecuteStateTransition(context.Background(), stateObj, interfaces.NewWrappedSignedBeaconBlock(block))
|
||||
if err != nil {
|
||||
log.Fatal(err)
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user