@@ -11,6 +11,7 @@ import (
11
11
"github.com/ethereum/go-ethereum/common"
12
12
"github.com/ethereum/go-ethereum/common/hexutil"
13
13
"github.com/ethereum/go-ethereum/consensus/ethash"
14
+ "github.com/ethereum/go-ethereum/consensus/misc"
14
15
"github.com/ethereum/go-ethereum/core"
15
16
"github.com/ethereum/go-ethereum/core/beacon"
16
17
"github.com/ethereum/go-ethereum/core/rawdb"
@@ -20,7 +21,6 @@ import (
20
21
"github.com/ethereum/go-ethereum/eth/downloader"
21
22
"github.com/ethereum/go-ethereum/eth/ethconfig"
22
23
"github.com/ethereum/go-ethereum/eth/tracers/logger"
23
- "github.com/ethereum/go-ethereum/log"
24
24
"github.com/ethereum/go-ethereum/node"
25
25
"github.com/ethereum/go-ethereum/p2p"
26
26
"github.com/ethereum/go-ethereum/params"
@@ -68,14 +68,14 @@ func TestValidateBuilderSubmissionV1(t *testing.T) {
68
68
cc , _ := types .SignTx (types .NewContractCreation (nonce + 1 , new (big.Int ), 1000000 , big .NewInt (2 * params .InitialBaseFee ), logCode ), types .LatestSigner (ethservice .BlockChain ().Config ()), testKey )
69
69
ethservice .TxPool ().AddLocal (cc )
70
70
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 )
72
73
ethservice .TxPool ().AddLocal (tx2 )
73
74
74
75
execData , err := assembleBlock (api , parent .Hash (), & beacon.PayloadAttributesV1 {
75
76
Timestamp : parent .Time () + 5 ,
76
77
SuggestedFeeRecipient : testValidatorAddr ,
77
78
})
78
- require .NoError (t , err )
79
79
require .EqualValues (t , len (execData .Transactions ), 4 )
80
80
require .NoError (t , err )
81
81
@@ -85,22 +85,37 @@ func TestValidateBuilderSubmissionV1(t *testing.T) {
85
85
proposerAddr := boostTypes.Address {}
86
86
proposerAddr .FromSlice (testValidatorAddr [:])
87
87
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 ,
96
99
},
97
- ExecutionPayload : payload ,
100
+ RegisteredGasLimit : execData . GasLimit ,
98
101
}
102
+
99
103
blockRequest .Message .Value = boostTypes .IntToU256 (190526394825529 )
100
104
require .ErrorContains (t , api .ValidateBuilderSubmissionV1 (blockRequest ), "inaccurate payment" )
101
- blockRequest .Message .Value = boostTypes .IntToU256 (190526394825530 )
105
+ blockRequest .Message .Value = boostTypes .IntToU256 (149830884438530 )
102
106
require .NoError (t , api .ValidateBuilderSubmissionV1 (blockRequest ))
103
107
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
+
104
119
// TODO: test with contract calling blacklisted address
105
120
// Test tx from blacklisted address
106
121
api .accessVerifier = & AccessVerifier {
@@ -130,17 +145,16 @@ func TestValidateBuilderSubmissionV1(t *testing.T) {
130
145
131
146
txData , err := invalidTx .MarshalBinary ()
132
147
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 )
135
149
136
150
invalidPayload , err := ExecutableDataToExecutionPayload (execData )
137
151
require .NoError (t , err )
138
152
invalidPayload .GasUsed = execData .GasUsed
139
153
invalidPayload .LogsBloom = boostTypes.Bloom {}
140
154
copy (invalidPayload .ReceiptsRoot [:], hexutil .MustDecode ("0x56e81f171bcc55a6ff8345e692c0f86e5b48e01b996cadc001622fb5e363b421" )[:32 ])
141
155
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" )
144
158
}
145
159
146
160
func generatePreMergeChain (n int ) (* core.Genesis , []* types.Block ) {
@@ -211,7 +225,6 @@ func assembleBlock(api *BlockValidationAPI, parentHash common.Hash, params *beac
211
225
if err != nil {
212
226
return nil , err
213
227
}
214
- log .Info ("b" , "block" , block )
215
228
return beacon .BlockToExecutableData (block ), nil
216
229
}
217
230
0 commit comments