@@ -11,6 +11,7 @@ import (
1111 "github.com/ethereum/go-ethereum/common"
1212 "github.com/ethereum/go-ethereum/common/hexutil"
1313 "github.com/ethereum/go-ethereum/consensus/ethash"
14+ "github.com/ethereum/go-ethereum/consensus/misc"
1415 "github.com/ethereum/go-ethereum/core"
1516 "github.com/ethereum/go-ethereum/core/beacon"
1617 "github.com/ethereum/go-ethereum/core/rawdb"
@@ -20,7 +21,6 @@ import (
2021 "github.com/ethereum/go-ethereum/eth/downloader"
2122 "github.com/ethereum/go-ethereum/eth/ethconfig"
2223 "github.com/ethereum/go-ethereum/eth/tracers/logger"
23- "github.com/ethereum/go-ethereum/log"
2424 "github.com/ethereum/go-ethereum/node"
2525 "github.com/ethereum/go-ethereum/p2p"
2626 "github.com/ethereum/go-ethereum/params"
@@ -68,14 +68,14 @@ func TestValidateBuilderSubmissionV1(t *testing.T) {
6868 cc , _ := types .SignTx (types .NewContractCreation (nonce + 1 , new (big.Int ), 1000000 , big .NewInt (2 * params .InitialBaseFee ), logCode ), types .LatestSigner (ethservice .BlockChain ().Config ()), testKey )
6969 ethservice .TxPool ().AddLocal (cc )
7070
71- tx2 , _ := types .SignTx (types .NewTransaction (nonce + 2 , testAddr , big .NewInt (10 ), 21000 , big .NewInt (2 * params .InitialBaseFee ), nil ), types .LatestSigner (ethservice .BlockChain ().Config ()), testKey )
71+ baseFee := misc .CalcBaseFee (params .AllEthashProtocolChanges , preMergeBlocks [len (preMergeBlocks )- 1 ].Header ())
72+ tx2 , _ := types .SignTx (types .NewTransaction (nonce + 2 , testAddr , big .NewInt (10 ), 21000 , baseFee , nil ), types .LatestSigner (ethservice .BlockChain ().Config ()), testKey )
7273 ethservice .TxPool ().AddLocal (tx2 )
7374
7475 execData , err := assembleBlock (api , parent .Hash (), & beacon.PayloadAttributesV1 {
7576 Timestamp : parent .Time () + 5 ,
7677 SuggestedFeeRecipient : testValidatorAddr ,
7778 })
78- require .NoError (t , err )
7979 require .EqualValues (t , len (execData .Transactions ), 4 )
8080 require .NoError (t , err )
8181
@@ -85,22 +85,37 @@ func TestValidateBuilderSubmissionV1(t *testing.T) {
8585 proposerAddr := boostTypes.Address {}
8686 proposerAddr .FromSlice (testValidatorAddr [:])
8787
88- blockRequest := & boostTypes.BuilderSubmitBlockRequest {
89- Signature : boostTypes.Signature {},
90- Message : & boostTypes.BidTrace {
91- ParentHash : boostTypes .Hash (execData .ParentHash ),
92- BlockHash : boostTypes .Hash (execData .BlockHash ),
93- ProposerFeeRecipient : proposerAddr ,
94- GasLimit : execData .GasLimit ,
95- GasUsed : execData .GasUsed ,
88+ blockRequest := & BuilderBlockValidationRequest {
89+ BuilderSubmitBlockRequest : boostTypes.BuilderSubmitBlockRequest {
90+ Signature : boostTypes.Signature {},
91+ Message : & boostTypes.BidTrace {
92+ ParentHash : boostTypes .Hash (execData .ParentHash ),
93+ BlockHash : boostTypes .Hash (execData .BlockHash ),
94+ ProposerFeeRecipient : proposerAddr ,
95+ GasLimit : execData .GasLimit ,
96+ GasUsed : execData .GasUsed ,
97+ },
98+ ExecutionPayload : payload ,
9699 },
97- ExecutionPayload : payload ,
100+ RegisteredGasLimit : execData . GasLimit ,
98101 }
102+
99103 blockRequest .Message .Value = boostTypes .IntToU256 (190526394825529 )
100104 require .ErrorContains (t , api .ValidateBuilderSubmissionV1 (blockRequest ), "inaccurate payment" )
101- blockRequest .Message .Value = boostTypes .IntToU256 (190526394825530 )
105+ blockRequest .Message .Value = boostTypes .IntToU256 (149830884438530 )
102106 require .NoError (t , api .ValidateBuilderSubmissionV1 (blockRequest ))
103107
108+ blockRequest .Message .GasLimit += 1
109+ blockRequest .ExecutionPayload .GasLimit += 1
110+
111+ oldHash := blockRequest .Message .BlockHash
112+ copy (blockRequest .Message .BlockHash [:], hexutil .MustDecode ("0x56cbdd508966f89cfb6ba16535e3676b59ae3ac3774478b631466bc99c1033c9" )[:32 ])
113+ require .ErrorContains (t , api .ValidateBuilderSubmissionV1 (blockRequest ), "incorrect gas limit set" )
114+
115+ blockRequest .Message .GasLimit -= 1
116+ blockRequest .ExecutionPayload .GasLimit -= 1
117+ blockRequest .Message .BlockHash = oldHash
118+
104119 // TODO: test with contract calling blacklisted address
105120 // Test tx from blacklisted address
106121 api .accessVerifier = & AccessVerifier {
@@ -130,17 +145,16 @@ func TestValidateBuilderSubmissionV1(t *testing.T) {
130145
131146 txData , err := invalidTx .MarshalBinary ()
132147 require .NoError (t , err )
133- execData .Transactions = append (execData .Transactions , execData .Transactions [3 ])
134- execData .Transactions [3 ] = txData
148+ execData .Transactions = append (execData .Transactions , txData )
135149
136150 invalidPayload , err := ExecutableDataToExecutionPayload (execData )
137151 require .NoError (t , err )
138152 invalidPayload .GasUsed = execData .GasUsed
139153 invalidPayload .LogsBloom = boostTypes.Bloom {}
140154 copy (invalidPayload .ReceiptsRoot [:], hexutil .MustDecode ("0x56e81f171bcc55a6ff8345e692c0f86e5b48e01b996cadc001622fb5e363b421" )[:32 ])
141155 blockRequest .ExecutionPayload = invalidPayload
142- copy (blockRequest .Message .BlockHash [:], hexutil .MustDecode ("0x2ff468dee2e05f1f58744d5496f3ab22fdc23c8141f86f907b4b0f2c8e22afc4 " )[:32 ])
143- require .ErrorContains (t , api .ValidateBuilderSubmissionV1 (blockRequest ), "could not apply tx 3 " , "insufficient funds for gas * price + value" )
156+ copy (blockRequest .Message .BlockHash [:], hexutil .MustDecode ("0x595cba7ab70a18b7e11ae7541661cb6692909a0acd3eba3f1cf6ae694f85a8bd " )[:32 ])
157+ require .ErrorContains (t , api .ValidateBuilderSubmissionV1 (blockRequest ), "could not apply tx 4 " , "insufficient funds for gas * price + value" )
144158}
145159
146160func generatePreMergeChain (n int ) (* core.Genesis , []* types.Block ) {
@@ -211,7 +225,6 @@ func assembleBlock(api *BlockValidationAPI, parentHash common.Hash, params *beac
211225 if err != nil {
212226 return nil , err
213227 }
214- log .Info ("b" , "block" , block )
215228 return beacon .BlockToExecutableData (block ), nil
216229}
217230
0 commit comments