Skip to content

Commit

Permalink
fix: broken successor chains causing division by zero (#603)
Browse files Browse the repository at this point in the history
* chore: bump vega version b870a4d

* fix: return successor configuration

* fix: return first successful market

* feat: add sync fn to proposals

* feat: default to fuzzed and non-fuzzed future and perp markets

* chore: remove unused code

* feat: update ci fuzz tests
  • Loading branch information
cdummett authored Jan 30, 2024
1 parent 0269765 commit d8f03d8
Show file tree
Hide file tree
Showing 22 changed files with 879 additions and 868 deletions.
2 changes: 1 addition & 1 deletion .env
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
VEGA_SIM_VEGA_TAG=b266ecbf146f32f2af05e34c74740515359c406d
VEGA_SIM_VEGA_TAG="b870a4d1d64748903b1f12c38b33d382213aa3da"
VEGA_SIM_CONSOLE_TAG=develop
VEGA_DEFAULT_KEY_NAME='Key 1'
VEGA_SIM_NETWORKS_INTERNAL_TAG=main
Expand Down
2 changes: 1 addition & 1 deletion Jenkinsfile
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ pipeline {
disableConcurrentBuilds(abortPrevious: true)
}
parameters {
string( name: 'VEGA_VERSION', defaultValue: 'b266ecbf146f32f2af05e34c74740515359c406d',
string( name: 'VEGA_VERSION', defaultValue: 'b870a4d1d64748903b1f12c38b33d382213aa3da',
description: 'Git branch, tag or hash of the vegaprotocol/vega repository')
string( name: 'VEGACAPSULE_VERSION', defaultValue: 'main',
description: 'Git branch, tag or hash of the vegaprotocol/vegacapsule repository')
Expand Down
13 changes: 3 additions & 10 deletions tests/integration/test_fuzz.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,14 +9,7 @@ def test_fuzz_run():
# Simply testing that it doesn't error
with tempfile.TemporaryDirectory() as temp_dir:
fuzz._run(
steps=100, output=True, output_dir=temp_dir, perp_market_probability=0.0
)


@pytest.mark.integration
def test_fuzz_run_perps():
# Simply testing that it doesn't error
with tempfile.TemporaryDirectory() as temp_dir:
fuzz._run(
steps=10, output=True, output_dir=temp_dir, perp_market_probability=1.0
steps=100,
output=True,
output_dir=temp_dir,
)
13 changes: 11 additions & 2 deletions vega_sim/api/governance.py
Original file line number Diff line number Diff line change
Expand Up @@ -89,6 +89,7 @@ def propose_market_from_config(
closing_time: Union[str, int],
enactment_time: Union[str, int],
time_forward_fn: Optional[Callable[[], None]] = None,
sync_fn: Optional[Callable[[], None]] = None,
governance_asset: Optional[str] = "VOTE",
proposal_wallet_name: Optional[str] = None,
) -> str:
Expand Down Expand Up @@ -135,6 +136,7 @@ def propose_market_from_config(
proposal=proposal,
data_client=data_client,
time_forward_fn=time_forward_fn,
sync_fn=sync_fn,
).proposal.id


Expand Down Expand Up @@ -806,6 +808,7 @@ def _make_and_wait_for_proposal(
proposal: commands_protos.commands.ProposalSubmission,
data_client: vac.VegaTradingDataClientV2,
time_forward_fn: Optional[Callable[[], None]] = None,
sync_fn: Optional[Callable[[], None]] = None,
wallet_name: Optional[str] = None,
) -> ProposalSubmission:
wallet.submit_transaction(
Expand All @@ -818,13 +821,19 @@ def _make_and_wait_for_proposal(

# Allow one failure, forward once more
try:
time_forward_fn()
if time_forward_fn is not None:
time_forward_fn()
if sync_fn is not None:
sync_fn()
proposal = wait_for_acceptance(
proposal.reference,
lambda p: _proposal_loader(p, data_client),
)
except ProposalNotAcceptedError:
time_forward_fn()
if time_forward_fn is not None:
time_forward_fn()
if sync_fn is not None:
sync_fn()
proposal = wait_for_acceptance(
proposal.reference,
lambda p: _proposal_loader(p, data_client),
Expand Down
2 changes: 1 addition & 1 deletion vega_sim/builders/governance.py
Original file line number Diff line number Diff line change
Expand Up @@ -255,7 +255,7 @@ def instrument_configuration(
def successor_configuration(
parent_market_id: str, insurance_pool_fraction: float
) -> vega_protos.governance.SuccessorConfiguration:
vega_protos.governance.SuccessorConfiguration(
return vega_protos.governance.SuccessorConfiguration(
parent_market_id=parent_market_id,
insurance_pool_fraction=str(insurance_pool_fraction),
)
Expand Down
330 changes: 165 additions & 165 deletions vega_sim/proto/data_node/api/v2/trading_data_pb2.py

Large diffs are not rendered by default.

9 changes: 8 additions & 1 deletion vega_sim/proto/data_node/api/v2/trading_data_pb2.pyi
Original file line number Diff line number Diff line change
Expand Up @@ -4381,21 +4381,24 @@ class ReferralProgram(_message.Message):
) -> None: ...

class ReferralSet(_message.Message):
__slots__ = ("id", "referrer", "created_at", "updated_at")
__slots__ = ("id", "referrer", "created_at", "updated_at", "total_members")
ID_FIELD_NUMBER: _ClassVar[int]
REFERRER_FIELD_NUMBER: _ClassVar[int]
CREATED_AT_FIELD_NUMBER: _ClassVar[int]
UPDATED_AT_FIELD_NUMBER: _ClassVar[int]
TOTAL_MEMBERS_FIELD_NUMBER: _ClassVar[int]
id: str
referrer: str
created_at: int
updated_at: int
total_members: int
def __init__(
self,
id: _Optional[str] = ...,
referrer: _Optional[str] = ...,
created_at: _Optional[int] = ...,
updated_at: _Optional[int] = ...,
total_members: _Optional[int] = ...,
) -> None: ...

class ReferralSetEdge(_message.Message):
Expand Down Expand Up @@ -4649,6 +4652,7 @@ class Team(_message.Message):
"closed",
"created_at_epoch",
"allow_list",
"total_members",
)
TEAM_ID_FIELD_NUMBER: _ClassVar[int]
REFERRER_FIELD_NUMBER: _ClassVar[int]
Expand All @@ -4659,6 +4663,7 @@ class Team(_message.Message):
CLOSED_FIELD_NUMBER: _ClassVar[int]
CREATED_AT_EPOCH_FIELD_NUMBER: _ClassVar[int]
ALLOW_LIST_FIELD_NUMBER: _ClassVar[int]
TOTAL_MEMBERS_FIELD_NUMBER: _ClassVar[int]
team_id: str
referrer: str
name: str
Expand All @@ -4668,6 +4673,7 @@ class Team(_message.Message):
closed: bool
created_at_epoch: int
allow_list: _containers.RepeatedScalarFieldContainer[str]
total_members: int
def __init__(
self,
team_id: _Optional[str] = ...,
Expand All @@ -4679,6 +4685,7 @@ class Team(_message.Message):
closed: bool = ...,
created_at_epoch: _Optional[int] = ...,
allow_list: _Optional[_Iterable[str]] = ...,
total_members: _Optional[int] = ...,
) -> None: ...

class TeamEdge(_message.Message):
Expand Down
2 changes: 1 addition & 1 deletion vega_sim/proto/vega/commands/v1/transaction_pb2.py

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

24 changes: 12 additions & 12 deletions vega_sim/proto/vega/commands/v1/transaction_pb2.pyi
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,8 @@ class InputData(_message.Message):
"apply_referral_code",
"update_margin_mode",
"join_team",
"batch_proposal_submission",
"update_party_profile",
"node_vote",
"node_signature",
"chain_event",
Expand All @@ -60,8 +62,6 @@ class InputData(_message.Message):
"protocol_upgrade_proposal",
"issue_signatures",
"oracle_data_submission",
"batch_proposal_submission",
"update_party_profile",
)
NONCE_FIELD_NUMBER: _ClassVar[int]
BLOCK_HEIGHT_FIELD_NUMBER: _ClassVar[int]
Expand All @@ -87,6 +87,8 @@ class InputData(_message.Message):
APPLY_REFERRAL_CODE_FIELD_NUMBER: _ClassVar[int]
UPDATE_MARGIN_MODE_FIELD_NUMBER: _ClassVar[int]
JOIN_TEAM_FIELD_NUMBER: _ClassVar[int]
BATCH_PROPOSAL_SUBMISSION_FIELD_NUMBER: _ClassVar[int]
UPDATE_PARTY_PROFILE_FIELD_NUMBER: _ClassVar[int]
NODE_VOTE_FIELD_NUMBER: _ClassVar[int]
NODE_SIGNATURE_FIELD_NUMBER: _ClassVar[int]
CHAIN_EVENT_FIELD_NUMBER: _ClassVar[int]
Expand All @@ -97,8 +99,6 @@ class InputData(_message.Message):
PROTOCOL_UPGRADE_PROPOSAL_FIELD_NUMBER: _ClassVar[int]
ISSUE_SIGNATURES_FIELD_NUMBER: _ClassVar[int]
ORACLE_DATA_SUBMISSION_FIELD_NUMBER: _ClassVar[int]
BATCH_PROPOSAL_SUBMISSION_FIELD_NUMBER: _ClassVar[int]
UPDATE_PARTY_PROFILE_FIELD_NUMBER: _ClassVar[int]
nonce: int
block_height: int
order_submission: _commands_pb2.OrderSubmission
Expand All @@ -123,6 +123,8 @@ class InputData(_message.Message):
apply_referral_code: _commands_pb2.ApplyReferralCode
update_margin_mode: _commands_pb2.UpdateMarginMode
join_team: _commands_pb2.JoinTeam
batch_proposal_submission: _commands_pb2.BatchProposalSubmission
update_party_profile: _commands_pb2.UpdatePartyProfile
node_vote: _validator_commands_pb2.NodeVote
node_signature: _validator_commands_pb2.NodeSignature
chain_event: _validator_commands_pb2.ChainEvent
Expand All @@ -133,8 +135,6 @@ class InputData(_message.Message):
protocol_upgrade_proposal: _validator_commands_pb2.ProtocolUpgradeProposal
issue_signatures: _commands_pb2.IssueSignatures
oracle_data_submission: _data_pb2.OracleDataSubmission
batch_proposal_submission: _commands_pb2.BatchProposalSubmission
update_party_profile: _commands_pb2.UpdatePartyProfile
def __init__(
self,
nonce: _Optional[int] = ...,
Expand Down Expand Up @@ -201,6 +201,12 @@ class InputData(_message.Message):
_Union[_commands_pb2.UpdateMarginMode, _Mapping]
] = ...,
join_team: _Optional[_Union[_commands_pb2.JoinTeam, _Mapping]] = ...,
batch_proposal_submission: _Optional[
_Union[_commands_pb2.BatchProposalSubmission, _Mapping]
] = ...,
update_party_profile: _Optional[
_Union[_commands_pb2.UpdatePartyProfile, _Mapping]
] = ...,
node_vote: _Optional[_Union[_validator_commands_pb2.NodeVote, _Mapping]] = ...,
node_signature: _Optional[
_Union[_validator_commands_pb2.NodeSignature, _Mapping]
Expand Down Expand Up @@ -229,12 +235,6 @@ class InputData(_message.Message):
oracle_data_submission: _Optional[
_Union[_data_pb2.OracleDataSubmission, _Mapping]
] = ...,
batch_proposal_submission: _Optional[
_Union[_commands_pb2.BatchProposalSubmission, _Mapping]
] = ...,
update_party_profile: _Optional[
_Union[_commands_pb2.UpdatePartyProfile, _Mapping]
] = ...,
) -> None: ...

class Transaction(_message.Message):
Expand Down
188 changes: 94 additions & 94 deletions vega_sim/proto/vega/governance_pb2.py

Large diffs are not rendered by default.

Loading

0 comments on commit d8f03d8

Please sign in to comment.