Skip to content

Commit 77dc8d7

Browse files
authored
Increase MAX_SIGNED_INCLUSION_LIST_SIZE to the worst-case size (#5576)
1 parent 4813cf1 commit 77dc8d7

8 files changed

Lines changed: 34 additions & 41 deletions

File tree

presets/mainnet/heze.yaml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,5 +9,5 @@ INCLUSION_LIST_COMMITTEE_SIZE: 16
99
# ---------------------------------------------------------------
1010
# 196,934 bytes, ~192 KiB
1111
MAX_SIGNED_EXECUTION_PAYLOAD_BID_SIZE_HEZE: 196934
12-
# 8,348 bytes, ~8 KiB
13-
MAX_SIGNED_INCLUSION_LIST_SIZE: 8348
12+
# 41,112 bytes, ~40 KiB
13+
MAX_SIGNED_INCLUSION_LIST_SIZE: 41112

presets/minimal/heze.yaml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,5 +9,5 @@ INCLUSION_LIST_COMMITTEE_SIZE: 16
99
# ---------------------------------------------------------------
1010
# 196,934 bytes, ~192 KiB
1111
MAX_SIGNED_EXECUTION_PAYLOAD_BID_SIZE_HEZE: 196934
12-
# 8,348 bytes, ~8 KiB
13-
MAX_SIGNED_INCLUSION_LIST_SIZE: 8348
12+
# 41,112 bytes, ~40 KiB
13+
MAX_SIGNED_INCLUSION_LIST_SIZE: 41112

specs/heze/fork-choice.md

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -268,10 +268,14 @@ def on_inclusion_list(store: Store, signed_inclusion_list: SignedInclusionList)
268268
inclusion_list = signed_inclusion_list.message
269269
current_slot = get_current_slot(store)
270270

271-
# The transactions must not exceed the maximum size
271+
# The transactions must be non-empty and not exceed the maximum size
272272
transactions_size = sum(len(transaction) for transaction in inclusion_list.transactions)
273+
assert transactions_size > 0
273274
assert transactions_size <= MAX_TRANSACTIONS_BYTES_PER_INCLUSION_LIST
274275

276+
# Every transaction must be non-empty
277+
assert all(len(transaction) > 0 for transaction in inclusion_list.transactions)
278+
275279
# The slot must be within the retention window
276280
assert inclusion_list.slot <= current_slot
277281
assert inclusion_list.slot + MIN_SLOTS_FOR_INCLUSION_LISTS_REQUESTS >= current_slot

specs/heze/p2p-interface.md

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@ specifications of previous upgrades, and assumes them as pre-requisite.
3939
| Name | Value |
4040
| -------------------------------------------- | ----------------------------- |
4141
| `MAX_SIGNED_EXECUTION_PAYLOAD_BID_SIZE_HEZE` | `Uint64(196934)` (= ~192 KiB) |
42-
| `MAX_SIGNED_INCLUSION_LIST_SIZE` | `Uint64(8348)` (= ~8 KiB) |
42+
| `MAX_SIGNED_INCLUSION_LIST_SIZE` | `Uint64(41112)` (= ~40 KiB) |
4343

4444
## Configs
4545

@@ -126,8 +126,10 @@ This topic is used to propagate signed inclusion list as `SignedInclusionList`.
126126
The following validations MUST pass before forwarding the `inclusion_list` on
127127
the network, assuming the alias `message = signed_inclusion_list.message`:
128128

129+
- _[IGNORE]_ The size of `message.transactions` is greater than 0.
129130
- _[REJECT]_ The size of `message.transactions` is within upperbound
130131
`MAX_TRANSACTIONS_BYTES_PER_INCLUSION_LIST`.
132+
- _[REJECT]_ Every transaction in `message.transactions` is non-empty.
131133
- _[IGNORE]_ The slot `message.slot` is equal to the current slot (with a
132134
`MAXIMUM_GOSSIP_CLOCK_DISPARITY` allowance), i.e.
133135
`message.slot == current_slot`.

tests/core/pyspec/eth_consensus_specs/test/helpers/inclusion_list.py

Lines changed: 4 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -34,22 +34,6 @@ def get_empty_inclusion_list(spec, store, state, slot=None, validator_index=None
3434
return empty_inclusion_list
3535

3636

37-
def get_empty_signed_inclusion_list(
38-
spec,
39-
store,
40-
state,
41-
slot=None,
42-
validator_index=None,
43-
):
44-
"""
45-
Build an empty signed inclusion list for ``slot``. Slot must be greater than or equal to the current slot in ``state``.
46-
"""
47-
empty_inclusion_list = get_empty_inclusion_list(spec, store, state, slot, validator_index)
48-
signed_inclusion_list = sign_inclusion_list(spec, state, empty_inclusion_list)
49-
50-
return signed_inclusion_list
51-
52-
5337
def get_sample_inclusion_list(
5438
spec,
5539
store,
@@ -107,14 +91,13 @@ def get_sample_transactions(spec, max_transaction_size=200, max_transaction_coun
10791
"""
10892
Build a list of sample transactions.
10993
"""
110-
transaction_size = min(
111-
max_transaction_size, spec.config.MAX_TRANSACTIONS_BYTES_PER_INCLUSION_LIST
94+
# Transactions must be non-empty and their total size within the bound
95+
transaction_size = max(
96+
1, min(max_transaction_size, spec.config.MAX_TRANSACTIONS_BYTES_PER_INCLUSION_LIST)
11297
)
11398
transaction_count = min(
11499
max_transaction_count,
115-
spec.config.MAX_TRANSACTIONS_BYTES_PER_INCLUSION_LIST // transaction_size
116-
if transaction_size
117-
else spec.config.MAX_TRANSACTIONS_BYTES_PER_INCLUSION_LIST,
100+
spec.config.MAX_TRANSACTIONS_BYTES_PER_INCLUSION_LIST // transaction_size,
118101
)
119102

120103
assert transaction_size >= 0

tests/core/pyspec/eth_consensus_specs/test/helpers/p2p_size_bounds.py

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -86,8 +86,12 @@ def build_max_size_partial_data_column_sidecar(spec):
8686

8787

8888
def build_max_size_signed_inclusion_list(spec):
89-
transactions_size = spec.config.MAX_TRANSACTIONS_BYTES_PER_INCLUSION_LIST
90-
transactions = spec.Transactions.of(spec.Transaction(data=list(b"\x00" * transactions_size)))
89+
# The largest valid list: MAX_TRANSACTIONS_BYTES_PER_INCLUSION_LIST one-byte transactions,
90+
# each costing its byte plus a 4-byte SSZ offset
91+
transaction_count = spec.config.MAX_TRANSACTIONS_BYTES_PER_INCLUSION_LIST
92+
transactions = spec.Transactions.of(
93+
*[spec.Transaction(data=[0]) for _ in range(transaction_count)]
94+
)
9195
inclusion_list = spec.InclusionList(
9296
slot=spec.Slot(0),
9397
validator_index=spec.ValidatorIndex(0),

tests/core/pyspec/eth_consensus_specs/test/heze/unittests/inclusion_list/test_inclusion_list_store.py

Lines changed: 2 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,6 @@
1212
run_on_block,
1313
)
1414
from eth_consensus_specs.test.helpers.inclusion_list import (
15-
get_empty_signed_inclusion_list,
1615
get_sample_inclusion_list,
1716
get_sample_signed_inclusion_list,
1817
get_sample_transactions,
@@ -45,21 +44,14 @@ def run_func():
4544

4645
signed_inclusion_lists = []
4746

48-
# An empty IL.
49-
signed_inclusion_lists.append(
50-
get_empty_signed_inclusion_list(
51-
spec, forkchoice_store, state, validator_index=inclusion_list_committee[0]
52-
)
53-
)
54-
55-
# An IL with empty transactions.
47+
# An IL with minimal (one-byte) transactions.
5648
signed_inclusion_lists.append(
5749
get_sample_signed_inclusion_list(
5850
spec,
5951
forkchoice_store,
6052
state,
6153
validator_index=inclusion_list_committee[1],
62-
max_transaction_size=0,
54+
max_transaction_size=1,
6355
max_transaction_count=5,
6456
)
6557
)

tests/core/pyspec/eth_consensus_specs/test/heze/unittests/validator/test_validator.py

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,10 @@
1010
with_heze_and_later,
1111
)
1212
from eth_consensus_specs.test.helpers.fork_choice import get_genesis_forkchoice_store
13-
from eth_consensus_specs.test.helpers.inclusion_list import get_empty_inclusion_list
13+
from eth_consensus_specs.test.helpers.inclusion_list import (
14+
get_sample_inclusion_list,
15+
get_sample_transactions,
16+
)
1417
from eth_consensus_specs.test.helpers.keys import privkeys, pubkeys
1518
from eth_consensus_specs.test.phase0.unittests.validator.test_validator_unittest import (
1619
run_get_signature_test,
@@ -87,7 +90,12 @@ def test_get_inclusion_committee_assignment_out_bound_epoch(spec, state):
8790
@always_bls
8891
def test_get_inclusion_list_signature(spec, state):
8992
forkchoice_store = get_genesis_forkchoice_store(spec, state)
90-
inclusion_list = get_empty_inclusion_list(spec, forkchoice_store, state)
93+
inclusion_list = get_sample_inclusion_list(
94+
spec,
95+
forkchoice_store,
96+
state,
97+
transactions=get_sample_transactions(spec, max_transaction_count=3),
98+
)
9199
domain = spec.get_domain(
92100
state, spec.DOMAIN_INCLUSION_LIST_COMMITTEE, spec.compute_epoch_at_slot(inclusion_list.slot)
93101
)

0 commit comments

Comments
 (0)