Skip to content

Commit

Permalink
fix: fix some failed UTs;
Browse files Browse the repository at this point in the history
  • Loading branch information
galaio committed Mar 29, 2024
1 parent c87d377 commit 1179ad9
Show file tree
Hide file tree
Showing 6 changed files with 7 additions and 10 deletions.
3 changes: 1 addition & 2 deletions core/chain_makers.go
Original file line number Diff line number Diff line change
Expand Up @@ -481,8 +481,7 @@ func (cm *chainMaker) makeHeader(parent *types.Block, state *state.StateDB, engi
header.ExcessBlobGas = &excessBlobGas
header.BlobGasUsed = new(uint64)
if cm.config.Parlia != nil {
header.WithdrawalsHash = new(common.Hash)
*header.WithdrawalsHash = types.EmptyWithdrawalsHash
header.WithdrawalsHash = &types.EmptyWithdrawalsHash
}
if cm.config.Parlia == nil {
header.ParentBeaconRoot = new(common.Hash)
Expand Down
3 changes: 1 addition & 2 deletions core/genesis.go
Original file line number Diff line number Diff line change
Expand Up @@ -446,8 +446,7 @@ func (g *Genesis) ToBlock() *types.Block {
}
if conf.IsCancun(num, g.Timestamp) {
if conf.Parlia != nil {
head.WithdrawalsHash = new(common.Hash)
*head.WithdrawalsHash = types.EmptyWithdrawalsHash
head.WithdrawalsHash = &types.EmptyWithdrawalsHash
}

// EIP-4788: The parentBeaconBlockRoot of the genesis block is always
Expand Down
2 changes: 1 addition & 1 deletion eth/catalyst/api.go
Original file line number Diff line number Diff line change
Expand Up @@ -874,7 +874,7 @@ func getBody(block *types.Block) *engine.ExecutionPayloadBodyV1 {
}

// Post-shanghai withdrawals MUST be set to empty slice instead of nil
if withdrawals == nil && !block.Header().EmptyWithdrawalsHash() {
if withdrawals == nil && block.Header().WithdrawalsHash != nil {
withdrawals = make([]*types.Withdrawal, 0)
}

Expand Down
2 changes: 1 addition & 1 deletion graphql/graphql.go
Original file line number Diff line number Diff line change
Expand Up @@ -1041,7 +1041,7 @@ func (b *Block) WithdrawalsRoot(ctx context.Context) (*common.Hash, error) {
return nil, err
}
// Pre-shanghai blocks
if header.EmptyWithdrawalsHash() {
if header.WithdrawalsHash == nil {
return nil, nil
}
return header.WithdrawalsHash, nil
Expand Down
4 changes: 2 additions & 2 deletions internal/ethapi/api.go
Original file line number Diff line number Diff line change
Expand Up @@ -1517,7 +1517,7 @@ func RPCMarshalHeader(head *types.Header) map[string]interface{} {
if head.BaseFee != nil {
result["baseFeePerGas"] = (*hexutil.Big)(head.BaseFee)
}
if !head.EmptyWithdrawalsHash() {
if head.WithdrawalsHash != nil {
result["withdrawalsRoot"] = head.WithdrawalsHash
}
if head.BlobGasUsed != nil {
Expand Down Expand Up @@ -1561,7 +1561,7 @@ func RPCMarshalBlock(block *types.Block, inclTx bool, fullTx bool, config *param
uncleHashes[i] = uncle.Hash()
}
fields["uncles"] = uncleHashes
if !block.Header().EmptyWithdrawalsHash() {
if block.Header().WithdrawalsHash != nil {
fields["withdrawals"] = block.Withdrawals()
}
return fields
Expand Down
3 changes: 1 addition & 2 deletions miner/worker.go
Original file line number Diff line number Diff line change
Expand Up @@ -1014,8 +1014,7 @@ func (w *worker) prepareWork(genParams *generateParams) (*environment, error) {
header.BlobGasUsed = new(uint64)
header.ExcessBlobGas = &excessBlobGas
if w.chainConfig.Parlia != nil {
header.WithdrawalsHash = new(common.Hash)
*header.WithdrawalsHash = types.EmptyWithdrawalsHash
header.WithdrawalsHash = &types.EmptyWithdrawalsHash
}
if w.chainConfig.Parlia == nil {
header.ParentBeaconRoot = genParams.beaconRoot
Expand Down

0 comments on commit 1179ad9

Please sign in to comment.