Skip to content

Commit

Permalink
Use header + transactions as input rather than a block
Browse files Browse the repository at this point in the history
  • Loading branch information
mdehoog committed Sep 26, 2024
1 parent e729893 commit 53635f9
Show file tree
Hide file tree
Showing 4 changed files with 18 additions and 51 deletions.
38 changes: 0 additions & 38 deletions enclave/block.go

This file was deleted.

4 changes: 2 additions & 2 deletions enclave/client.go
Original file line number Diff line number Diff line change
Expand Up @@ -49,9 +49,9 @@ func (c *Client) SetSignerKey(ctx context.Context, encrypted hexutil.Bytes) erro
return c.callContext(ctx, nil, "setSignerKey", encrypted)
}

func (c *Client) ExecuteStateless(ctx context.Context, config *RollupConfig, l1Origin *types.Header, l1Receipts types.Receipts, previousBlockTxs []*types.Transaction, block *Block, witness hexutil.Bytes, messageAccount *eth.AccountResult, prevMessageAccountHash common.Hash) (*Proposal, error) {
func (c *Client) ExecuteStateless(ctx context.Context, config *RollupConfig, l1Origin *types.Header, l1Receipts types.Receipts, previousBlockTxs types.Transactions, blockHeader *types.Header, blockTxs types.Transactions, witness hexutil.Bytes, messageAccount *eth.AccountResult, prevMessageAccountHash common.Hash) (*Proposal, error) {
var result Proposal
return &result, c.callContext(ctx, &result, "executeStateless", config, l1Origin, l1Receipts, previousBlockTxs, block, witness, messageAccount, prevMessageAccountHash)
return &result, c.callContext(ctx, &result, "executeStateless", config, l1Origin, l1Receipts, previousBlockTxs, blockHeader, blockTxs, witness, messageAccount, prevMessageAccountHash)
}

func (c *Client) Aggregate(ctx context.Context, configHash common.Hash, prevOutputRoot common.Hash, proposals []*Proposal) (*Proposal, error) {
Expand Down
5 changes: 3 additions & 2 deletions enclave/rpc.go
Original file line number Diff line number Diff line change
Expand Up @@ -23,8 +23,9 @@ type RPC interface {
config *RollupConfig,
l1Origin *types.Header,
l1Receipts types.Receipts,
previousBlockTxs []*types.Transaction,
block *Block,
previousBlockTxs types.Transactions,
blockHeader *types.Header,
blockTxs types.Transactions,
witness hexutil.Bytes,
messageAccount *eth.AccountResult,
prevMessageAccountHash common.Hash,
Expand Down
22 changes: 13 additions & 9 deletions enclave/server.go
Original file line number Diff line number Diff line change
Expand Up @@ -223,8 +223,9 @@ func (s *Server) ExecuteStateless(
config *RollupConfig,
l1Origin *types.Header,
l1Receipts types.Receipts,
previousBlockTxs []*types.Transaction,
block *Block,
previousBlockTxs types.Transactions,
blockHeader *types.Header,
blockTxs types.Transactions,
witness hexutil.Bytes,
messageAccount *eth.AccountResult,
prevMessageAccountHash common.Hash,
Expand All @@ -243,7 +244,7 @@ func (s *Server) ExecuteStateless(

previousBlockHeader := w.Headers[0]
previousBlockHash := previousBlockHeader.Hash()
if block.Header().ParentHash != previousBlockHash {
if blockHeader.ParentHash != previousBlockHash {
return nil, errors.New("invalid parent hash")
}

Expand Down Expand Up @@ -277,12 +278,12 @@ func (s *Server) ExecuteStateless(
return nil, fmt.Errorf("failed to prepare payload attributes: %w", err)
}

if block.Transactions().Len() < len(payload.Transactions) {
if blockTxs.Len() < len(payload.Transactions) {
return nil, errors.New("invalid transaction count")
}

for i, payloadTx := range payload.Transactions {
tx := block.Transactions()[i]
tx := blockTxs[i]
if !tx.IsDepositTx() {
return nil, errors.New("invalid transaction type")
}
Expand All @@ -296,12 +297,15 @@ func (s *Server) ExecuteStateless(
}

// block must only contain deposit transactions if it is outside the sequencer drift
if block.Transactions().Len() > len(payload.Transactions) &&
block.Time() > l1Origin.Time+maxSequencerDriftFjord {
if blockTxs.Len() > len(payload.Transactions) &&
blockHeader.Time > l1Origin.Time+maxSequencerDriftFjord {
return nil, errors.New("L1 origin is too old")
}

stateRoot, _, err := core.ExecuteStateless(&config.ChainConfig, block.Block, w)
block := types.NewBlockWithHeader(blockHeader).WithBody(types.Body{
Transactions: blockTxs,
})
stateRoot, _, err := core.ExecuteStateless(&config.ChainConfig, block, w)

if messageAccount.Address.Cmp(l2ToL1MessagePasserAddress) != 0 {
return nil, errors.New("invalid message account address")
Expand All @@ -311,7 +315,7 @@ func (s *Server) ExecuteStateless(
}

prevOutputRoot := outputRootV0(previousBlockHeader, prevMessageAccountHash)
outputRoot := outputRootV0(block.Header(), messageAccount.StorageHash)
outputRoot := outputRootV0(blockHeader, messageAccount.StorageHash)

configBin, err := config.MarshalBinary()
if err != nil {
Expand Down

0 comments on commit 53635f9

Please sign in to comment.