Skip to content

Commit 93604d9

Browse files
committed
query from L1 RPC
1 parent 2880bd5 commit 93604d9

File tree

1 file changed

+14
-6
lines changed

1 file changed

+14
-6
lines changed

rollup/internal/controller/sender/sender.go

Lines changed: 14 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -10,10 +10,10 @@ import (
1010
"sync"
1111
"time"
1212

13+
"github.com/ethereum/go-ethereum/common/hexutil"
1314
"github.com/holiman/uint256"
1415
"github.com/prometheus/client_golang/prometheus"
1516
"github.com/scroll-tech/go-ethereum/common"
16-
"github.com/scroll-tech/go-ethereum/consensus/misc"
1717
gethTypes "github.com/scroll-tech/go-ethereum/core/types"
1818
"github.com/scroll-tech/go-ethereum/crypto/kzg4844"
1919
"github.com/scroll-tech/go-ethereum/ethclient"
@@ -67,7 +67,8 @@ type FeeData struct {
6767
// Sender Transaction sender to send transaction to l1/l2
6868
type Sender struct {
6969
config *config.SenderConfig
70-
gethClient *gethclient.Client
70+
rpcClient *rpc.Client // Raw RPC Client
71+
gethClient *gethclient.Client // Client to use for CreateAccessList
7172
client *ethclient.Client // The client to retrieve on chain data (read-only)
7273
writeClients []*ethclient.Client // The clients to send transactions to (write operations)
7374
transactionSigner *TransactionSigner
@@ -141,6 +142,7 @@ func NewSender(ctx context.Context, config *config.SenderConfig, signerConfig *c
141142
sender := &Sender{
142143
ctx: ctx,
143144
config: config,
145+
rpcClient: rpcClient,
144146
gethClient: gethclient.New(rpcClient),
145147
client: client,
146148
writeClients: writeClients,
@@ -842,11 +844,17 @@ func (s *Sender) getBlockNumberAndTimestampAndBaseFeeAndBlobFee(ctx context.Cont
842844
log.Warn("getBlockNumberAndTimestampAndBaseFeeAndBlobFee", "baseFee", header.BaseFee.String(), "baseFeeUint64", baseFee)
843845
}
844846

845-
var blobBaseFee uint64
846-
if excess := header.ExcessBlobGas; excess != nil {
847-
blobBaseFee = misc.CalcBlobFee(*excess).Uint64()
848-
log.Warn("getBlockNumberAndTimestampAndBaseFeeAndBlobFee", "blobBaseFee", misc.CalcBlobFee(*excess).String(), "blobBaseFeeUint64", blobBaseFee)
847+
// Leave it up to the L1 node to return the correct blob base fee.
848+
// Previously we would compute it locally using `CalcBlobFee`, but
849+
// that needs to be in sync with the L1 node's configuration.
850+
var hex hexutil.Big
851+
if err := s.rpcClient.CallContext(ctx, &hex, "eth_blobBaseFee"); err != nil {
852+
return 0, 0, 0, 0, fmt.Errorf("failed to call eth_blobBaseFee, err: %w", err)
849853
}
854+
blobBaseFee := hex.ToInt().Uint64()
855+
856+
log.Warn("getBlockNumberAndTimestampAndBaseFeeAndBlobFee", "blobBaseFeeUint64", blobBaseFee)
857+
850858
// header.Number.Uint64() returns the pendingBlockNumber, so we minus 1 to get the latestBlockNumber.
851859
return header.Number.Uint64() - 1, header.Time, baseFee, blobBaseFee, nil
852860
}

0 commit comments

Comments
 (0)