Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 4 additions & 7 deletions pkg/builder/payload_builder.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@ import (
"context"
"encoding/json"
"fmt"
"math/big"
"sync"
"time"

Expand Down Expand Up @@ -242,11 +241,9 @@ func (b *PayloadBuilder) BuildPayloadFromAttributes(
var blockHash phase0.Hash32
copy(blockHash[:], payload.BlockHash[:])

var blockValueGwei uint64
var blockValueWei uint64
if payloadResult.BlockValue != nil {
// BlockValue from engine API is in wei; convert to gwei for bid values.
gweiValue := new(big.Int).Div(payloadResult.BlockValue, big.NewInt(1_000_000_000))
blockValueGwei = gweiValue.Uint64()
blockValueWei = payloadResult.BlockValue.Uint64()
}

txCount := len(payload.Transactions)
Expand All @@ -263,7 +260,7 @@ func (b *PayloadBuilder) BuildPayloadFromAttributes(
GasLimit: payload.GasLimit,
PrevRandao: attrs.PrevRandao,
FeeRecipient: proposerFeeRecipient,
BlockValue: blockValueGwei,
BlockValue: blockValueWei,
BuildSource: BuildSourceBlock,
ReadyAt: time.Now(),
}
Expand All @@ -272,7 +269,7 @@ func (b *PayloadBuilder) BuildPayloadFromAttributes(
"slot": attrs.ProposalSlot,
"block_hash": fmt.Sprintf("%x", blockHash[:8]),
"parent_hash": finalityInfo.HeadExecutionBlockHash,
"block_value": blockValueGwei,
"block_value": blockValueWei,
"has_blobs": payloadResult.BlobsBundle != nil,
"has_exec_requests": len(payloadResult.ExecutionRequests) > 0,
"txs_in_payload": txCount,
Expand Down
3 changes: 2 additions & 1 deletion pkg/builderapi/fulu/build.go
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,8 @@ func BuildSignedBuilderBid(
value := new(uint256.Int)
value.SetUint64(event.BlockValue)
if subsidyGwei > 0 {
value.Add(value, new(uint256.Int).SetUint64(subsidyGwei))
subsidyWei := subsidyGwei * 1_000_000_000
value.Add(value, new(uint256.Int).SetUint64(subsidyWei))
}

bid := &BuilderBid{
Expand Down
10 changes: 5 additions & 5 deletions pkg/builderapi/fulu/build_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ func TestBuildSignedBuilderBid_NoSubsidy(t *testing.T) {
require.NoError(t, err)
pk := blsSigner.PublicKey()

blockValue := uint64(1_000_000) // 0.001 ETH in Gwei
blockValue := uint64(1_000_000_000_000_000) // 0.001 ETH in wei
event := minimalPayloadReadyEvent(t, blockValue)

var genesisForkVersion phase0.Version // zero version
Expand All @@ -51,8 +51,8 @@ func TestBuildSignedBuilderBid_SubsidyAdded(t *testing.T) {
require.NoError(t, err)
pk := blsSigner.PublicKey()

blockValue := uint64(500_000)
subsidy := uint64(1_000_000) // 0.001 ETH
blockValue := uint64(500_000_000_000_000) // 0.0005 ETH in wei
subsidy := uint64(1_000_000) // 0.001 ETH subsidy in gwei
event := minimalPayloadReadyEvent(t, blockValue)

var genesisForkVersion phase0.Version // zero version
Expand All @@ -64,8 +64,8 @@ func TestBuildSignedBuilderBid_SubsidyAdded(t *testing.T) {
require.NotNil(t, bid.Message)
require.NotNil(t, bid.Message.Value)
assert.True(t, bid.Message.Value.IsUint64())
assert.Equal(t, blockValue+subsidy, bid.Message.Value.Uint64(),
"bid value should be block_value + subsidy")
assert.Equal(t, blockValue+subsidy*1_000_000_000, bid.Message.Value.Uint64(),
"bid value should be block_value_wei + subsidy_gwei_converted_to_wei")
}

func minimalPayloadReadyEvent(t *testing.T, blockValue uint64) *builder.PayloadReadyEvent {
Expand Down
6 changes: 3 additions & 3 deletions pkg/builderapi/server_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -239,7 +239,7 @@ func TestGetHeader_SubsidyInBidValue(t *testing.T) {
ParentBlockHash: parentHash,
BlockHash: phase0.Hash32(payload.BlockHash),
Payload: payload,
BlockValue: 500_000, // 0.0005 ETH in Gwei
BlockValue: 500_000_000_000_000, // 0.0005 ETH in wei
}
cache.Store(event)
mock := &mockPayloadCacheProvider{cache: cache}
Expand All @@ -266,8 +266,8 @@ func TestGetHeader_SubsidyInBidValue(t *testing.T) {
} `json:"data"`
}
require.NoError(t, json.NewDecoder(rec.Body).Decode(&resp))
// block_value 500_000 + subsidy 1_000_000 = 1_500_000
assert.Equal(t, "1500000", resp.Data.Message.Value, "bid value should be block_value + subsidy")
// block_value 500_000_000_000_000 wei + subsidy 1_000_000 gwei (= 1_000_000_000_000_000 wei) = 1_500_000_000_000_000 wei
assert.Equal(t, "1500000000000000", resp.Data.Message.Value, "bid value should be block_value_wei + subsidy_wei")
}

// TestSubmitBlindedBlockV2_InvalidJSON returns 400 for invalid JSON body.
Expand Down
3 changes: 2 additions & 1 deletion pkg/epbs/scheduler.go
Original file line number Diff line number Diff line change
Expand Up @@ -213,7 +213,8 @@ func (s *Scheduler) checkSlotForBidding(ctx context.Context, slot phase0.Slot, n

// Calculate bid value.
// Start from block value with BidMinAmount as a floor.
bidBase := payload.BlockValue
// BlockValue is in wei; BidMinAmount/BidIncrease/P2PBidSubsidy are in gwei.
bidBase := payload.BlockValue / 1_000_000_000
if s.cfg.BidMinAmount > bidBase {
bidBase = s.cfg.BidMinAmount
}
Expand Down