Skip to content

Commit

Permalink
Coreth nits (#1336)
Browse files Browse the repository at this point in the history
* ensure blob gas is zero in cancun

* txlookup limit cleanup

* use full faker

* use full faker in api tests

---------

Co-authored-by: Darioush Jalali <[email protected]>
  • Loading branch information
ceyonur and darioush committed Sep 9, 2024
1 parent 400862c commit 6fd1328
Show file tree
Hide file tree
Showing 5 changed files with 24 additions and 13 deletions.
3 changes: 3 additions & 0 deletions consensus/dummy/consensus.go
Original file line number Diff line number Diff line change
Expand Up @@ -262,6 +262,9 @@ func (eng *DummyEngine) verifyHeader(chain consensus.ChainHeaderReader, header *
if err := eip4844.VerifyEIP4844Header(parent, header); err != nil {
return err
}
if *header.BlobGasUsed > 0 { // VerifyEIP4844Header ensures BlobGasUsed is non-nil
return fmt.Errorf("blobs not enabled on avalanche networks: used %d blob gas, expected 0", *header.BlobGasUsed)
}
}
return nil
}
Expand Down
3 changes: 2 additions & 1 deletion core/state_processor_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -121,7 +121,8 @@ func TestStateProcessorErrors(t *testing.T) {
},
GasLimit: params.TestChainConfig.FeeConfig.GasLimit.Uint64(),
}
blockchain, _ = NewBlockChain(db, DefaultCacheConfig, gspec, dummy.NewCoinbaseFaker(), vm.Config{}, common.Hash{}, false)
// FullFaker used to skip header verification that enforces no blobs.
blockchain, _ = NewBlockChain(db, DefaultCacheConfig, gspec, dummy.NewFullFaker(), vm.Config{}, common.Hash{}, false)
tooBigInitCode = [params.MaxInitCodeSize + 1]byte{}
)

Expand Down
2 changes: 1 addition & 1 deletion eth/ethconfig/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -171,6 +171,6 @@ type Config struct {

// SkipTxIndexing skips indexing transactions.
// This is useful for validators that don't need to index transactions.
// TxLookupLimit can be still used to control unindexing old transactions.
// TransactionHistory can be still used to control unindexing old transactions.
SkipTxIndexing bool
}
2 changes: 1 addition & 1 deletion internal/ethapi/api_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -1819,7 +1819,7 @@ func setupReceiptBackend(t *testing.T, genBlocks int) (*testBackend, []common.Ha
txHashes = make([]common.Hash, genBlocks)
)

backend := newTestBackend(t, genBlocks, genesis, dummy.NewCoinbaseFaker(), func(i int, b *core.BlockGen) {
backend := newTestBackend(t, genBlocks, genesis, dummy.NewFullFaker(), func(i int, b *core.BlockGen) {
var (
tx *types.Transaction
err error
Expand Down
27 changes: 17 additions & 10 deletions plugin/evm/config_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -72,33 +72,39 @@ func TestUnmarshalConfig(t *testing.T) {
false,
},
{
"empty tx lookup limit",
"empty transaction history ",
[]byte(`{}`),
Config{TxLookupLimit: 0},
Config{TransactionHistory: 0},
false,
},
{
"zero tx lookup limit",
[]byte(`{"tx-lookup-limit": 0}`),
"zero transaction history",
[]byte(`{"transaction-history": 0}`),
func() Config {
return Config{TxLookupLimit: 0}
return Config{TransactionHistory: 0}
}(),
false,
},
{
"1 tx lookup limit",
[]byte(`{"tx-lookup-limit": 1}`),
"1 transaction history",
[]byte(`{"transaction-history": 1}`),
func() Config {
return Config{TxLookupLimit: 1}
return Config{TransactionHistory: 1}
}(),
false,
},
{
"-1 tx lookup limit",
[]byte(`{"tx-lookup-limit": -1}`),
"-1 transaction history",
[]byte(`{"transaction-history": -1}`),
Config{},
true,
},
{
"deprecated tx lookup limit",
[]byte(`{"tx-lookup-limit": 1}`),
Config{TransactionHistory: 1, TxLookupLimit: 1},
false,
},
{
"allow unprotected tx hashes",
[]byte(`{"allow-unprotected-tx-hashes": ["0x803351deb6d745e91545a6a3e1c0ea3e9a6a02a1a4193b70edfcd2f40f71a01c"]}`),
Expand All @@ -115,6 +121,7 @@ func TestUnmarshalConfig(t *testing.T) {
assert.Error(t, err)
} else {
assert.NoError(t, err)
tmp.Deprecate()
assert.Equal(t, tt.expected, tmp)
}
})
Expand Down

0 comments on commit 6fd1328

Please sign in to comment.