mirror of
https://github.com/ethereum/go-ethereum.git
synced 2026-07-27 07:06:42 +00:00
beacon/types: update base types for electra
This commit is contained in:
parent
4cdd7c8631
commit
e3dc854979
4 changed files with 25 additions and 8 deletions
|
|
@ -22,11 +22,14 @@ import (
|
|||
|
||||
"github.com/ethereum/go-ethereum/common"
|
||||
"github.com/ethereum/go-ethereum/core/types"
|
||||
"github.com/protolambda/zrnt/eth2/beacon/capella"
|
||||
zrntcommon "github.com/protolambda/zrnt/eth2/beacon/common"
|
||||
"github.com/protolambda/zrnt/eth2/beacon/deneb"
|
||||
"github.com/protolambda/zrnt/eth2/configs"
|
||||
"github.com/protolambda/ztyp/tree"
|
||||
|
||||
// beacon forks
|
||||
"github.com/protolambda/zrnt/eth2/beacon/capella"
|
||||
"github.com/protolambda/zrnt/eth2/beacon/deneb"
|
||||
"github.com/protolambda/zrnt/eth2/beacon/electra"
|
||||
)
|
||||
|
||||
type blockObject interface {
|
||||
|
|
@ -43,10 +46,12 @@ type BeaconBlock struct {
|
|||
func BlockFromJSON(forkName string, data []byte) (*BeaconBlock, error) {
|
||||
var obj blockObject
|
||||
switch forkName {
|
||||
case "deneb":
|
||||
obj = new(deneb.BeaconBlock)
|
||||
case "capella":
|
||||
obj = new(capella.BeaconBlock)
|
||||
case "deneb":
|
||||
obj = new(deneb.BeaconBlock)
|
||||
case "electra":
|
||||
obj = new(electra.BeaconBlock)
|
||||
default:
|
||||
return nil, fmt.Errorf("unsupported fork: %s", forkName)
|
||||
}
|
||||
|
|
@ -63,6 +68,8 @@ func NewBeaconBlock(obj blockObject) *BeaconBlock {
|
|||
return &BeaconBlock{obj}
|
||||
case *deneb.BeaconBlock:
|
||||
return &BeaconBlock{obj}
|
||||
case *electra.BeaconBlock:
|
||||
return &BeaconBlock{obj}
|
||||
default:
|
||||
panic(fmt.Errorf("unsupported block type %T", obj))
|
||||
}
|
||||
|
|
@ -75,6 +82,8 @@ func (b *BeaconBlock) Slot() uint64 {
|
|||
return uint64(obj.Slot)
|
||||
case *deneb.BeaconBlock:
|
||||
return uint64(obj.Slot)
|
||||
case *electra.BeaconBlock:
|
||||
return uint64(obj.Slot)
|
||||
default:
|
||||
panic(fmt.Errorf("unsupported block type %T", b.blockObj))
|
||||
}
|
||||
|
|
@ -87,6 +96,8 @@ func (b *BeaconBlock) ExecutionPayload() (*types.Block, error) {
|
|||
return convertPayload(&obj.Body.ExecutionPayload, &obj.ParentRoot)
|
||||
case *deneb.BeaconBlock:
|
||||
return convertPayload(&obj.Body.ExecutionPayload, &obj.ParentRoot)
|
||||
case *electra.BeaconBlock:
|
||||
return convertPayload(&obj.Body.ExecutionPayload, &obj.ParentRoot)
|
||||
default:
|
||||
panic(fmt.Errorf("unsupported block type %T", b.blockObj))
|
||||
}
|
||||
|
|
@ -99,6 +110,8 @@ func (b *BeaconBlock) Header() Header {
|
|||
return headerFromZRNT(obj.Header(configs.Mainnet))
|
||||
case *deneb.BeaconBlock:
|
||||
return headerFromZRNT(obj.Header(configs.Mainnet))
|
||||
case *electra.BeaconBlock:
|
||||
return headerFromZRNT(obj.Header(configs.Mainnet))
|
||||
default:
|
||||
panic(fmt.Errorf("unsupported block type %T", b.blockObj))
|
||||
}
|
||||
|
|
|
|||
|
|
@ -22,10 +22,12 @@ import (
|
|||
|
||||
"github.com/ethereum/go-ethereum/beacon/merkle"
|
||||
"github.com/ethereum/go-ethereum/common"
|
||||
"github.com/protolambda/zrnt/eth2/beacon/capella"
|
||||
zrntcommon "github.com/protolambda/zrnt/eth2/beacon/common"
|
||||
"github.com/protolambda/zrnt/eth2/beacon/deneb"
|
||||
"github.com/protolambda/ztyp/tree"
|
||||
|
||||
// beacon chain forks
|
||||
"github.com/protolambda/zrnt/eth2/beacon/capella"
|
||||
"github.com/protolambda/zrnt/eth2/beacon/deneb"
|
||||
)
|
||||
|
||||
type headerObject interface {
|
||||
|
|
@ -43,7 +45,7 @@ func ExecutionHeaderFromJSON(forkName string, data []byte) (*ExecutionHeader, er
|
|||
switch forkName {
|
||||
case "capella":
|
||||
obj = new(capella.ExecutionPayloadHeader)
|
||||
case "deneb":
|
||||
case "deneb", "electra": // note: the payload type was not changed in electra
|
||||
obj = new(deneb.ExecutionPayloadHeader)
|
||||
default:
|
||||
return nil, fmt.Errorf("unsupported fork: %s", forkName)
|
||||
|
|
|
|||
2
go.mod
2
go.mod
|
|
@ -53,7 +53,7 @@ require (
|
|||
github.com/peterh/liner v1.1.1-0.20190123174540-a2c9a5303de7
|
||||
github.com/pion/stun/v2 v2.0.0
|
||||
github.com/protolambda/bls12-381-util v0.1.0
|
||||
github.com/protolambda/zrnt v0.32.2
|
||||
github.com/protolambda/zrnt v0.34.1
|
||||
github.com/protolambda/ztyp v0.2.2
|
||||
github.com/rs/cors v1.7.0
|
||||
github.com/shirou/gopsutil v3.21.4-0.20210419000835-c7a38de76ee5+incompatible
|
||||
|
|
|
|||
2
go.sum
2
go.sum
|
|
@ -464,6 +464,8 @@ github.com/protolambda/bls12-381-util v0.1.0 h1:05DU2wJN7DTU7z28+Q+zejXkIsA/MF8J
|
|||
github.com/protolambda/bls12-381-util v0.1.0/go.mod h1:cdkysJTRpeFeuUVx/TXGDQNMTiRAalk1vQw3TYTHcE4=
|
||||
github.com/protolambda/zrnt v0.32.2 h1:KZ48T+3UhsPXNdtE/5QEvGc9DGjUaRI17nJaoznoIaM=
|
||||
github.com/protolambda/zrnt v0.32.2/go.mod h1:A0fezkp9Tt3GBLATSPIbuY4ywYESyAuc/FFmPKg8Lqs=
|
||||
github.com/protolambda/zrnt v0.34.1 h1:qW55rnhZJDnOb3TwFiFRJZi3yTXFrJdGOFQM7vCwYGg=
|
||||
github.com/protolambda/zrnt v0.34.1/go.mod h1:A0fezkp9Tt3GBLATSPIbuY4ywYESyAuc/FFmPKg8Lqs=
|
||||
github.com/protolambda/ztyp v0.2.2 h1:rVcL3vBu9W/aV646zF6caLS/dyn9BN8NYiuJzicLNyY=
|
||||
github.com/protolambda/ztyp v0.2.2/go.mod h1:9bYgKGqg3wJqT9ac1gI2hnVb0STQq7p/1lapqrqY1dU=
|
||||
github.com/prysmaticlabs/gohashtree v0.0.1-alpha.0.20220714111606-acbb2962fb48 h1:cSo6/vk8YpvkLbk9v3FO97cakNmUoxwi2KMP8hd5WIw=
|
||||
|
|
|
|||
Loading…
Reference in a new issue