Skip to content

Commit

Permalink
Merge pull request ethereum#44 from MariusVanDerWijden/devnet-patches-2
Browse files Browse the repository at this point in the history
eth/catalyst: core: add changes for prague dev mode
  • Loading branch information
lightclient authored May 13, 2024
2 parents 6694516 + dcdb0f3 commit 3d8028a
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 5 deletions.
10 changes: 10 additions & 0 deletions core/types/block.go
Original file line number Diff line number Diff line change
Expand Up @@ -366,6 +366,11 @@ func (b *Block) Requests() Requests { return b.requests }

func (b *Block) Deposits() Deposits {
var deps Deposits
if b.requests != nil {
// If requests is non-nil, it means deposits are available in block and we
// should return an empty slice instead of nil if there are no deposits.
deps = make(Deposits, 0)
}
for _, r := range b.requests {
if d, ok := r.inner.(*Deposit); ok {
deps = append(deps, d)
Expand All @@ -375,6 +380,11 @@ func (b *Block) Deposits() Deposits {
}
func (b *Block) WithdrawalRequests() WithdrawalRequests {
var wxs WithdrawalRequests
if b.requests != nil {
// If requests is non-nil, it means wx requests are available in block and
// we should return an empty slice instead of nil if there are no wxs.
wxs = make(WithdrawalRequests, 0)
}
for _, r := range b.requests {
if w, ok := r.inner.(*WithdrawalRequest); ok {
wxs = append(wxs, w)
Expand Down
4 changes: 2 additions & 2 deletions eth/catalyst/api.go
Original file line number Diff line number Diff line change
Expand Up @@ -553,8 +553,8 @@ func (api *ConsensusAPI) NewPayloadV4(params engine.ExecutableData, versionedHas
return engine.PayloadStatusV1{Status: engine.INVALID}, engine.InvalidParams.With(errors.New("nil beaconRoot post-cancun"))
}

if api.eth.BlockChain().Config().LatestFork(params.Timestamp) != forks.Cancun {
return engine.PayloadStatusV1{Status: engine.INVALID}, engine.UnsupportedFork.With(errors.New("newPayloadV3 must only be called for cancun payloads"))
if api.eth.BlockChain().Config().LatestFork(params.Timestamp) != forks.Prague {
return engine.PayloadStatusV1{Status: engine.INVALID}, engine.UnsupportedFork.With(errors.New("newPayloadV4 must only be called for prague payloads"))
}
return api.newPayload(params, versionedHashes, beaconRoot)
}
Expand Down
6 changes: 3 additions & 3 deletions eth/catalyst/simulated_beacon.go
Original file line number Diff line number Diff line change
Expand Up @@ -101,7 +101,7 @@ func NewSimulatedBeacon(period uint64, eth *eth.Ethereum) (*SimulatedBeacon, err

// if genesis block, send forkchoiceUpdated to trigger transition to PoS
if block.Number.Sign() == 0 {
if _, err := engineAPI.ForkchoiceUpdatedV2(current, nil); err != nil {
if _, err := engineAPI.ForkchoiceUpdatedV3(current, nil); err != nil {
return nil, err
}
}
Expand Down Expand Up @@ -202,13 +202,13 @@ func (c *SimulatedBeacon) sealBlock(withdrawals []*types.Withdrawal, timestamp u
}
}
// Mark the payload as canon
if _, err = c.engineAPI.NewPayloadV3(*payload, blobHashes, &common.Hash{}); err != nil {
if _, err = c.engineAPI.NewPayloadV4(*payload, blobHashes, &common.Hash{}); err != nil {
return err
}
c.setCurrentState(payload.BlockHash, finalizedHash)

// Mark the block containing the payload as canonical
if _, err = c.engineAPI.ForkchoiceUpdatedV2(c.curForkchoiceState, nil); err != nil {
if _, err = c.engineAPI.ForkchoiceUpdatedV3(c.curForkchoiceState, nil); err != nil {
return err
}
c.lastBlockTime = payload.Timestamp
Expand Down

0 comments on commit 3d8028a

Please sign in to comment.