@@ -15,15 +15,17 @@ import (
15
15
"github.com/ethereum/go-ethereum/core/rawdb"
16
16
"github.com/ethereum/go-ethereum/core/types"
17
17
"github.com/ethereum/go-ethereum/log"
18
+ "github.com/ethereum/go-ethereum/rlp"
18
19
"github.com/holiman/uint256"
19
20
echojwt "github.com/labstack/echo-jwt/v4"
20
21
"github.com/labstack/echo/v4"
21
22
"github.com/labstack/echo/v4/middleware"
22
23
"github.com/libp2p/go-libp2p/core/peer"
23
24
24
- txListDecompressor "github.com/taikoxyz/taiko-mono/packages/taiko-client/driver/txlist_decompressor"
25
25
"github.com/taikoxyz/taiko-mono/packages/taiko-client/internal/metrics"
26
26
"github.com/taikoxyz/taiko-mono/packages/taiko-client/pkg/rpc"
27
+ "github.com/taikoxyz/taiko-mono/packages/taiko-client/pkg/utils"
28
+ validator "github.com/taikoxyz/taiko-mono/packages/taiko-client/prover/anchor_tx_validator"
27
29
)
28
30
29
31
// preconfBlockChainSyncer is an interface for preconf block chain syncer.
@@ -44,10 +46,10 @@ type preconfBlockChainSyncer interface {
44
46
// @license.url https://github.com/taikoxyz/taiko-mono/blob/main/LICENSE.md
45
47
// PreconfBlockAPIServer represents a preconfirmation block server instance.
46
48
type PreconfBlockAPIServer struct {
47
- echo * echo.Echo
48
- chainSyncer preconfBlockChainSyncer
49
- rpc * rpc.Client
50
- txListDecompressor * txListDecompressor. TxListDecompressor
49
+ echo * echo.Echo
50
+ chainSyncer preconfBlockChainSyncer
51
+ rpc * rpc.Client
52
+ anchorValidator * validator. AnchorTxValidator
51
53
// P2P network for preconf block propagation
52
54
p2pNode * p2p.NodeP2P
53
55
p2pSigner p2p.Signer
@@ -60,25 +62,22 @@ type PreconfBlockAPIServer struct {
60
62
func New (
61
63
cors string ,
62
64
jwtSecret []byte ,
65
+ taikoAnchorAddress common.Address ,
63
66
chainSyncer preconfBlockChainSyncer ,
64
67
cli * rpc.Client ,
65
68
) (* PreconfBlockAPIServer , error ) {
66
- protocolConfigs , err := cli . GetProtocolConfigs ( nil )
69
+ anchorValidator , err := validator . New ( taikoAnchorAddress , cli . L2 . ChainID , cli )
67
70
if err != nil {
68
- return nil , fmt . Errorf ( "failed to fetch protocol configs: %w" , err )
71
+ return nil , err
69
72
}
70
73
71
74
server := & PreconfBlockAPIServer {
72
- echo : echo .New (),
73
- chainSyncer : chainSyncer ,
74
- txListDecompressor : txListDecompressor .NewTxListDecompressor (
75
- uint64 (protocolConfigs .BlockMaxGasLimit ()),
76
- uint64 (rpc .BlobBytes ),
77
- cli .L2 .ChainID ,
78
- ),
79
- rpc : cli ,
80
- payloadsCache : newPayloadQueue (),
81
- lookahead : & Lookahead {},
75
+ echo : echo .New (),
76
+ anchorValidator : anchorValidator ,
77
+ chainSyncer : chainSyncer ,
78
+ rpc : cli ,
79
+ payloadsCache : newPayloadQueue (),
80
+ lookahead : & Lookahead {},
82
81
}
83
82
84
83
server .echo .HideBanner = true
@@ -375,6 +374,22 @@ func (s *PreconfBlockAPIServer) ValidateExecutionPayload(payload *eth.ExecutionP
375
374
if len (payload .Transactions [0 ]) > eth .MaxBlobDataSize {
376
375
return errors .New ("compressed transactions size exceeds max blob data size" )
377
376
}
377
+
378
+ var txs types.Transactions
379
+ b , err := utils .DecompressPacaya (payload .Transactions [0 ])
380
+ if err != nil {
381
+ return fmt .Errorf ("invalid zlib bytes for transactions: %w" , err )
382
+ }
383
+ if err := rlp .DecodeBytes (b , & txs ); err != nil {
384
+ return fmt .Errorf ("invalid RLP bytes for transactions: %w" , err )
385
+ }
386
+ if len (txs ) == 0 {
387
+ return errors .New ("empty transactions list, missing anchor transaction" )
388
+ }
389
+ if err := s .anchorValidator .ValidateAnchorTx (txs [0 ]); err != nil {
390
+ return fmt .Errorf ("invalid anchor transaction: %w" , err )
391
+ }
392
+
378
393
return nil
379
394
}
380
395
0 commit comments