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

VMC Optimization #37

Closed
3 tasks done
hwwhww opened this issue Dec 12, 2017 · 2 comments
Closed
3 tasks done

VMC Optimization #37

hwwhww opened this issue Dec 12, 2017 · 2 comments
Assignees

Comments

@hwwhww
Copy link
Collaborator

hwwhww commented Dec 12, 2017

Thanks to @vbuterin for providing some suggestions.

Goal

Get down to ~90-100k gas in practice without too much effort

Items

  • Storing score and parent inside a single storage key
    • giving collations a 24 byte ID instead of 32 byte: ID = num256_add(shift(parent, -192), num256_and(sha3(header), as_num256(<valueof 2**192 - 1 here>)))
  • Using emitting log instead of storing collations_with_score mapping
  • Remove validator code, just use the signature of the transaction itself.
    • Record the address of validator in validators mapping and remove validator_code_addr:
      validators: public({
          # Amount of wei the validator holds
          deposit: wei_value,
          # The address which the validator
          validation_addr: address,
          # Addess to withdraw to
          return_addr: address,
          # The cycle number which the validator would be included after
          # Will be [DEPRECATED] for stateless client
          cycle: num,
      }[num])
    • Make get_eligible_proposer return validator_addr
    • Change the input of add_header by removing sig field:
      add_header(shard_id: num, expected_period_number: num, period_start_prevhash: bytes32, parent_collation_hash: bytes32, tx_list_root: bytes32, collation_coinbase: address, post_state_root: bytes32, receipt_root: bytes32, collation_number: num)
    • [in add_header] assert msg.sender == self.get_eligible_proposer(shard_id, block.number / self.period_length)
    • Remove the RLP decoding and update entire_header_hash: entire_header_hash = sha3(concat(as_bytes32(shard_id), as_bytes32(expected_period_number) ... as_bytes32(collation_number)))
    • [in withdraw] assert msg.sender == self.validators[validator_index].validator_addr
@mhchia
Copy link
Collaborator

mhchia commented Mar 1, 2018

Link to collation header optimisation

@hwwhww
Copy link
Collaborator Author

hwwhww commented Apr 5, 2018

yay! this issue is done.

@hwwhww hwwhww closed this as completed Apr 5, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants