Skip to content

Optimize map/list expansions in validator #79

Open
@jasagredo

Description

@jasagredo

There are cases in which we face a rule for a map with many optional or with non-one occurrence entries. In these cases, the amount of combinations can very easily get out of hand. Take for example:

conway.transaction_body = {
  0: conway.set<conway.transaction_input>,
  1: [* conway.transaction_output],
  2: conway.coin,
  ? 3: conway.slot_no,
  ? 4: conway.certificates,
  ? 5: conway.withdrawals,
  ? 7: conway.auxiliary_data_hash,
  ? 8: conway.slot_no,
  ? 9: conway.mint,
  ? 11: conway.script_data_hash,
  ? 13: conway.nonempty_set<conway.transaction_input>,
  ? 14: conway.required_signers,
  ? 15: conway.network_id,
  ? 16: conway.transaction_output,
  ? 17: conway.coin,
  ? 18: conway.nonempty_set<conway.transaction_input>,
  ? 19: conway.voting_procedures,
  ? 20: conway.proposal_procedures,
  ? 21: conway.coin,
  ? 22: conway.positive_coin,
}

If we have a map with N elements, the amount of rules we would have to check follow this graph:

Image

So there can be 15 million combinations to try, and that can happen for each one of the transactions in the block.

In general we could do an optimization that only expands rules in which the key matches. This in general can be convoluted or again fall into the same problem (keys can match any of the rules), but for cases like this one where the keys are simple integers, it could easily be optimized.

Metadata

Metadata

Assignees

Labels

No labels
No labels

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions