Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Test gen configs created: small, smoke and standard #12

Merged
merged 7 commits into from
May 16, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
151 changes: 132 additions & 19 deletions tests/generators/fork_choice_generated/generate_test_instances.py
Original file line number Diff line number Diff line change
Expand Up @@ -72,6 +72,9 @@ def solve_block_cover(anchor_epoch: int,
assert number_of_solutions is not None
result = instance.solve(nr_solutions=number_of_solutions)

if anchor_epoch == 0 and not store_justified_epoch_equal_zero:
return

for s in result.solution:
max_block = s.max_block
yield {'block_epochs': s.es[:max_block + 1],
Expand Down Expand Up @@ -111,41 +114,151 @@ def generate_block_cover(params):
# }

gen_params = {
'block_tree_test': {
'out_path': 'block_tree.yaml',
###################
# small instances #
###################

'block_tree_tree_small': {
'out_path': 'small/block_tree_tree.yaml',
'models': ['sm_link', 'block_tree'],
'params': [
({'anchor_epoch': 0, 'number_of_epochs': 4, 'number_of_links': 3}, {'number_of_blocks': 8, 'max_children': 2, 'number_of_solutions': 3}),
([{'sm_links': [[0, 1], [0, 2], [2, 3], [3, 4]]}], {'number_of_blocks': 16, 'max_children': 2, 'number_of_solutions': 3}),
]
},
'block_tree_other_small': {
'out_path': 'small/block_tree_other.yaml',
'models': ['sm_link', 'block_tree'],
'params': [
([{'sm_links': [[0, 1], [0, 2], [2, 3], [3, 4]]}], {'number_of_blocks': 12, 'max_children': 2, 'number_of_solutions': 3}),
]
},
'block_cover_small': {
'out_path': 'small/block_cover.yaml',
'models': ['block_cover'],
'params': [
({'anchor_epoch': 0, 'number_of_solutions': 1},),
({'anchor_epoch': 2, 'number_of_solutions': 1},),
]
},

###################
# smoke instances #
###################

'block_tree_tree_smoke': {
'out_path': 'smoke/block_tree_tree.yaml',
'models': ['sm_link', 'block_tree'],
'params': [
({'anchor_epoch': 0, 'number_of_epochs': 5, 'number_of_links': 3}, {'number_of_blocks': 16, 'max_children': 2, 'number_of_solutions': 2}),
([{'sm_links': [[0, 1], [0, 2], [2, 3], [3, 4]]}], {'number_of_blocks': 5, 'max_children': 3, 'number_of_solutions': None}),
([{'sm_links': [[0, 1], [0, 2], [2, 3], [3, 4]]}], {'number_of_blocks': 12, 'max_children': 2, 'number_of_solutions': 73}),
]
},
'block_tree_tree_smoke_2': {
'out_path': 'smoke/block_tree_tree_2.yaml',
'models': ['sm_link', 'block_tree'],
'params': [
({'anchor_epoch': 0, 'number_of_epochs': 6, 'number_of_links': 4}, {'number_of_blocks': 16, 'max_children': 2, 'number_of_solutions': 2}),
([{'sm_links': [[0, 1], [0, 2], [2, 3], [3, 4]]}], {'number_of_blocks': 6, 'max_children': 4, 'number_of_solutions': None}),
([{'sm_links': [[0, 1], [0, 2], [2, 3], [3, 4]]}], {'number_of_blocks': 12, 'max_children': 2, 'number_of_solutions': 283}),
]
},
'block_tree_other_smoke': {
'out_path': 'smoke/block_tree_other.yaml',
'models': ['sm_link', 'block_tree'],
'params': [
({'anchor_epoch': 0, 'number_of_epochs': 4, 'number_of_links': 2}, {'number_of_blocks': 16, 'max_children': 3, 'number_of_solutions': 4}),
({'anchor_epoch': 0, 'number_of_epochs': 4, 'number_of_links': 3}, {'number_of_blocks': 4, 'max_children': 3, 'number_of_solutions': 4}),
({'anchor_epoch': 0, 'number_of_epochs': 5, 'number_of_links': 4}, {'number_of_blocks': 4, 'max_children': 3, 'number_of_solutions': 4}),
([{'sm_links': [[0, 1], [0, 2], [2, 3], [3, 4]]}], {'number_of_blocks': 12, 'max_children': 2, 'number_of_solutions': 4}),
]
},
'attester_slashings_test': {
'out_path': 'attester_slashings.yaml',
'block_cover_smoke': {
'out_path': 'smoke/block_cover.yaml',
'models': ['block_cover'],
'params': [
({'anchor_epoch': 0, 'number_of_solutions': 2},),
({'anchor_epoch': 2, 'number_of_solutions': 2},),
]
},

######################
# standard instances #
######################

'block_tree_tree': {
'out_path': 'standard/block_tree_tree.yaml',
'models': ['sm_link', 'block_tree'],
'params': [
([{'sm_links': [[0, 1], [0, 2], [2, 3], [3, 4]]}], {'number_of_blocks': 16, 'max_children': 3, 'number_of_solutions': 4}),
({'anchor_epoch': 0, 'number_of_epochs': 4, 'number_of_links': 3}, {'number_of_blocks': 4, 'max_children': 3, 'number_of_solutions': 4}),
({'anchor_epoch': 0, 'number_of_epochs': 5, 'number_of_links': 4}, {'number_of_blocks': 4, 'max_children': 3, 'number_of_solutions': 4}),
({'anchor_epoch': 0, 'number_of_epochs': 6, 'number_of_links': 4}, {'number_of_blocks': 16, 'max_children': 2, 'number_of_solutions': 5}),
([{'sm_links': [[0, 1], [0, 2], [2, 3], [3, 4]]}], {'number_of_blocks': 6, 'max_children': 4, 'number_of_solutions': None}),
([{'sm_links': [[0, 1], [0, 2], [2, 3], [3, 4]]}], {'number_of_blocks': 7, 'max_children': 2, 'number_of_solutions': None}),
([{'sm_links': [[0, 1], [0, 2], [2, 3], [3, 4]]}], {'number_of_blocks': 16, 'max_children': 2, 'number_of_solutions': 358}),
]
},
'invalid_messages_test': {
'out_path': 'invalid_messages.yaml',
'block_tree_tree_2': {
'out_path': 'standard/block_tree_tree_2.yaml',
'models': ['sm_link', 'block_tree'],
'params': [
([{'sm_links': [[0, 1], [0, 2], [2, 3], [3, 4]]}], {'number_of_blocks': 16, 'max_children': 3, 'number_of_solutions': 4}),
({'anchor_epoch': 0, 'number_of_epochs': 4, 'number_of_links': 3}, {'number_of_blocks': 4, 'max_children': 3, 'number_of_solutions': 4}),
({'anchor_epoch': 0, 'number_of_epochs': 5, 'number_of_links': 4}, {'number_of_blocks': 4, 'max_children': 3, 'number_of_solutions': 4}),
({'anchor_epoch': 0, 'number_of_epochs': 6, 'number_of_links': 4}, {'number_of_blocks': 16, 'max_children': 2, 'number_of_solutions': 5}),
([{'sm_links': [[0, 1], [0, 2], [2, 3], [3, 4]]}], {'number_of_blocks': 6, 'max_children': 4, 'number_of_solutions': None}),
([{'sm_links': [[0, 1], [0, 2], [2, 3], [3, 4]]}], {'number_of_blocks': 7, 'max_children': 3, 'number_of_solutions': None}),
([{'sm_links': [[0, 1], [0, 2], [2, 3], [3, 4]]}], {'number_of_blocks': 16, 'max_children': 2, 'number_of_solutions': 3101}),
]
},
'block_tree_other': {
'out_path': 'standard/block_tree_other.yaml',
'models': ['sm_link', 'block_tree'],
'params': [
([{'sm_links': [[0, 1], [0, 2], [2, 3], [3, 4]]}], {'number_of_blocks': 12, 'max_children': 2, 'number_of_solutions': 8}),
]
},
'block_cover': {
'out_path': 'block_cover.yaml',
'out_path': 'standard/block_cover.yaml',
'models': ['block_cover'],
'params': [
({'anchor_epoch': 0, 'number_of_solutions': 1},),
({'anchor_epoch': 2, 'number_of_solutions': 1},),
({'anchor_epoch': 0, 'number_of_solutions': 2},),
({'anchor_epoch': 2, 'number_of_solutions': 5},),
]
}
},


#############
# old stuff #
#############

# 'attester_slashings_test': {
# 'out_path': 'attester_slashings.yaml',
# 'models': ['sm_link', 'block_tree'],
# 'params': [
# ([{'sm_links': [[0, 1], [0, 2], [2, 3], [3, 4]]}], {'number_of_blocks': 16, 'max_children': 3, 'number_of_solutions': 4}),
# ({'anchor_epoch': 0, 'number_of_epochs': 4, 'number_of_links': 3}, {'number_of_blocks': 4, 'max_children': 3, 'number_of_solutions': 4}),
# ({'anchor_epoch': 0, 'number_of_epochs': 5, 'number_of_links': 4}, {'number_of_blocks': 4, 'max_children': 3, 'number_of_solutions': 4}),
# ]
# },
# 'invalid_messages_test': {
# 'out_path': 'invalid_messages.yaml',
# 'models': ['sm_link', 'block_tree'],
# 'params': [
# ([{'sm_links': [[0, 1], [0, 2], [2, 3], [3, 4]]}], {'number_of_blocks': 16, 'max_children': 3, 'number_of_solutions': 4}),
# ({'anchor_epoch': 0, 'number_of_epochs': 4, 'number_of_links': 3}, {'number_of_blocks': 4, 'max_children': 3, 'number_of_solutions': 4}),
# ({'anchor_epoch': 0, 'number_of_epochs': 5, 'number_of_links': 4}, {'number_of_blocks': 4, 'max_children': 3, 'number_of_solutions': 4}),
# ]
# },
# 'block_cover_1': {
# 'out_path': 'block_cover_1.yaml',
# 'models': ['block_cover'],
# 'params': [
# ({'anchor_epoch': 0, 'number_of_solutions': 1},),
# ({'anchor_epoch': 2, 'number_of_solutions': 1},),
# ]
# },
# 'block_cover_100': {
# 'out_path': 'block_cover_100.yaml',
# 'models': ['block_cover'],
# 'params': [
# ({'anchor_epoch': 0, 'number_of_solutions': 100},),
# ({'anchor_epoch': 2, 'number_of_solutions': 100},),
# ]
# }
}


Expand Down
108 changes: 108 additions & 0 deletions tests/generators/fork_choice_generated/small/block_cover.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,108 @@
- block_epochs: [0]
current_epoch: 1
current_justifications: [false]
parents: [0]
predicates: {block_is_leaf: true, block_vse_eq_store_je: true, block_vse_plus_two_ge_curr_e: true,
store_je_eq_zero: true}
previous_justifications: [false]
store_justified_epoch: 0
target_block: 0
- block_epochs: [0, 1]
current_epoch: 1
current_justifications: [false, false]
parents: [0, 0]
predicates: {block_is_leaf: false, block_vse_eq_store_je: true, block_vse_plus_two_ge_curr_e: true,
store_je_eq_zero: true}
previous_justifications: [false, false]
store_justified_epoch: 0
target_block: 0
- block_epochs: [0]
current_epoch: 3
current_justifications: [false]
parents: [0]
predicates: {block_is_leaf: true, block_vse_eq_store_je: true, block_vse_plus_two_ge_curr_e: false,
store_je_eq_zero: true}
previous_justifications: [false]
store_justified_epoch: 0
target_block: 0
- block_epochs: [0, 1]
current_epoch: 3
current_justifications: [false, false]
parents: [0, 0]
predicates: {block_is_leaf: false, block_vse_eq_store_je: true, block_vse_plus_two_ge_curr_e: false,
store_je_eq_zero: true}
previous_justifications: [false, false]
store_justified_epoch: 0
target_block: 0
- block_epochs: [2]
current_epoch: 3
current_justifications: [false]
parents: [0]
predicates: {block_is_leaf: true, block_vse_eq_store_je: true, block_vse_plus_two_ge_curr_e: true,
store_je_eq_zero: false}
previous_justifications: [false]
store_justified_epoch: 2
target_block: 0
- block_epochs: [2, 3]
current_epoch: 3
current_justifications: [false, false]
parents: [0, 0]
predicates: {block_is_leaf: false, block_vse_eq_store_je: true, block_vse_plus_two_ge_curr_e: true,
store_je_eq_zero: false}
previous_justifications: [false, false]
store_justified_epoch: 2
target_block: 0
- block_epochs: [2]
current_epoch: 5
current_justifications: [false]
parents: [0]
predicates: {block_is_leaf: true, block_vse_eq_store_je: true, block_vse_plus_two_ge_curr_e: false,
store_je_eq_zero: false}
previous_justifications: [false]
store_justified_epoch: 2
target_block: 0
- block_epochs: [2, 3]
current_epoch: 5
current_justifications: [false, false]
parents: [0, 0]
predicates: {block_is_leaf: false, block_vse_eq_store_je: true, block_vse_plus_two_ge_curr_e: false,
store_je_eq_zero: false}
previous_justifications: [false, false]
store_justified_epoch: 2
target_block: 0
- block_epochs: [2, 3, 3]
current_epoch: 4
current_justifications: [false, false, true]
parents: [0, 0, 0]
predicates: {block_is_leaf: true, block_vse_eq_store_je: false, block_vse_plus_two_ge_curr_e: true,
store_je_eq_zero: false}
previous_justifications: [false, false, false]
store_justified_epoch: 3
target_block: 1
- block_epochs: [2, 3]
current_epoch: 4
current_justifications: [false, true]
parents: [0, 0]
predicates: {block_is_leaf: false, block_vse_eq_store_je: false, block_vse_plus_two_ge_curr_e: true,
store_je_eq_zero: false}
previous_justifications: [false, false]
store_justified_epoch: 3
target_block: 0
- block_epochs: [2, 3, 3]
current_epoch: 5
current_justifications: [false, false, true]
parents: [0, 0, 0]
predicates: {block_is_leaf: true, block_vse_eq_store_je: false, block_vse_plus_two_ge_curr_e: false,
store_je_eq_zero: false}
previous_justifications: [false, false, false]
store_justified_epoch: 3
target_block: 1
- block_epochs: [2, 3]
current_epoch: 5
current_justifications: [false, true]
parents: [0, 0]
predicates: {block_is_leaf: false, block_vse_eq_store_je: false, block_vse_plus_two_ge_curr_e: false,
store_je_eq_zero: false}
previous_justifications: [false, false]
store_justified_epoch: 3
target_block: 0
10 changes: 10 additions & 0 deletions tests/generators/fork_choice_generated/small/block_tree_other.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
- block_parents: [0, 0, 1, 2, 3, 4, 5, 4, 3, 2, 1, 0]
sm_links: &id001
- [0, 1]
- [0, 2]
- [2, 3]
- [3, 4]
- block_parents: [0, 0, 1, 2, 3, 4, 4, 5, 3, 2, 1, 0]
sm_links: *id001
- block_parents: [0, 0, 1, 2, 3, 4, 5, 5, 3, 2, 1, 0]
sm_links: *id001
37 changes: 37 additions & 0 deletions tests/generators/fork_choice_generated/small/block_tree_tree.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
- block_parents: &id002 [0, 0, 1, 2, 3, 2, 1, 0]
sm_links: &id001
- [0, 1]
- [0, 2]
- [0, 3]
- block_parents: &id003 [0, 0, 1, 2, 2, 3, 1, 0]
sm_links: *id001
- block_parents: &id005 [0, 0, 1, 2, 3, 3, 1, 0]
sm_links: *id001
- block_parents: *id002
sm_links: &id004
- [0, 1]
- [0, 2]
- [1, 3]
- block_parents: *id003
sm_links: *id004
- block_parents: *id005
sm_links: *id004
- block_parents: *id002
sm_links: &id006
- [0, 1]
- [0, 2]
- [2, 3]
- block_parents: *id003
sm_links: *id006
- block_parents: *id005
sm_links: *id006
- block_parents: [0, 0, 1, 2, 3, 4, 5, 6, 7, 6, 5, 4, 3, 2, 1, 0]
sm_links: &id007
- [0, 1]
- [0, 2]
- [2, 3]
- [3, 4]
- block_parents: [0, 0, 1, 2, 3, 4, 5, 6, 6, 7, 5, 4, 3, 2, 1, 0]
sm_links: *id007
- block_parents: [0, 0, 1, 2, 3, 4, 5, 6, 7, 7, 5, 4, 3, 2, 1, 0]
sm_links: *id007
Original file line number Diff line number Diff line change
@@ -1,26 +1,32 @@
block_tree_test:
test_type: block_tree
instances: block_tree.yaml
instances: block_tree_tree.yaml # 12
seed: 123
nr_variations: 1
nr_variations: 2
nr_mutations: 1
block_weight_test:
test_type: block_tree
instances: block_tree_other.yaml # 3
seed: 123
nr_variations: 5
nr_mutations: 0
attester_slashing_test:
test_type: block_tree
instances: block_tree.yaml
instances: block_tree_other.yaml # 3
seed: 123
nr_variations: 1
nr_variations: 2
nr_mutations: 1
with_attester_slashings: true
invalid_message_test:
test_type: block_tree
instances: block_tree.yaml
instances: block_tree_other.yaml # 3
seed: 123
nr_variations: 1
nr_variations: 2
nr_mutations: 1
with_invalid_messages: true
block_cover_test:
test_type: block_cover
instances: block_cover.yaml
instances: block_cover.yaml # 12
seed: 456
nr_variations: 1
nr_variations: 2
nr_mutations: 1
Loading
Loading