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
2 changes: 2 additions & 0 deletions eth/catalyst/api_types.go
Original file line number Diff line number Diff line change
Expand Up @@ -41,12 +41,14 @@ type assembleBlockParamsMarshaling struct {
type AssembleL2BlockParams struct {
Number uint64 `json:"number" gencodec:"required"`
Transactions [][]byte `json:"transactions"`
Timestamp *uint64 `json:"timestamp"`
}
Comment thread
curryxbo marked this conversation as resolved.

// JSON type overrides for assembleL2BlockParams.
type assembleL2BlockParamsMarshaling struct {
Number hexutil.Uint64
Transactions []hexutil.Bytes
Timestamp *hexutil.Uint64
}

//go:generate go run github.com/fjl/gencodec -type executableData -field-override executableDataMarshaling -out gen_ed.go
Expand Down
6 changes: 6 additions & 0 deletions eth/catalyst/gen_l2blockparams.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

6 changes: 5 additions & 1 deletion eth/catalyst/l2_api.go
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,11 @@ func (api *l2ConsensusAPI) AssembleL2Block(params AssembleL2BlockParams) (*Execu
}

start := time.Now()
newBlockResult, err := api.eth.Miner().BuildBlock(parent.Hash(), time.Now(), transactions)
timestamp := time.Now()
if params.Timestamp != nil {
timestamp = time.Unix(int64(*params.Timestamp), 0)
}
newBlockResult, err := api.eth.Miner().BuildBlock(parent.Hash(), timestamp, transactions)
if err != nil {
return nil, err
}
Expand Down
3 changes: 2 additions & 1 deletion ethclient/authclient/engine.go
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ import (
)

// AssembleL2Block assembles L2 Block used for L2 sequencer to propose a block in L2 consensus progress
func (ec *Client) AssembleL2Block(ctx context.Context, number *big.Int, transactions types.Transactions) (*catalyst.ExecutableL2Data, error) {
func (ec *Client) AssembleL2Block(ctx context.Context, timeStamp *uint64, number *big.Int, transactions types.Transactions) (*catalyst.ExecutableL2Data, error) {
txs := make([][]byte, 0, len(transactions))
for i, tx := range transactions {
bz, err := tx.MarshalBinary()
Expand All @@ -25,6 +25,7 @@ func (ec *Client) AssembleL2Block(ctx context.Context, number *big.Int, transact
err := ec.c.CallContext(ctx, &result, "engine_assembleL2Block", &catalyst.AssembleL2BlockParams{
Number: number.Uint64(),
Transactions: txs,
Timestamp: timeStamp,
})
return &result, err
}
Expand Down
2 changes: 1 addition & 1 deletion miner/worker.go
Original file line number Diff line number Diff line change
Expand Up @@ -164,7 +164,7 @@ func (miner *Miner) prepareWork(genParams *generateParams) (*environment, error)
}

timestamp := genParams.timestamp
if parent.Time() >= genParams.timestamp {
if parent.Time() > genParams.timestamp {
timestamp = parent.Time() + 1
}
var coinBase common.Address
Expand Down