Skip to content
This repository was archived by the owner on Nov 15, 2023. It is now read-only.
This repository was archived by the owner on Nov 15, 2023. It is now read-only.

Expose block hash in pallet-contracts #14724

Open

Description

@SkymanOne

Is there an existing issue?

  • I have searched the existing issues

Experiencing problems? Have you tried our Stack Exchange first?

  • This is not a support question.

Motivation

See use-ink/ink#1849

Request

ink! requires block_hash environment function to be exposed on the pallet-contracts' side:

Solution

No response

Are you willing to help with this request?

Yes!

Activity

  1. agryaznov commented on Aug 7, 2023

    @agryaznov
    Contributor

    If such a host function is intended to serve as a source of randomness, then for the reasons stated in #13204, I don't think we should expose in the pallet API.

  2. burdges commented on Aug 8, 2023

    @burdges

    We removed the collective-flip randomness there, which afaik never really suffices. In theory, you could've whole block fiat-shamir transforms, but this winds up really nasty in practice.

    A smart contract parachain could expose VRF based randomness, of which we've two choices:

    1. Slot VRFs - Adversary knows these 6 hours in advance, so they have many choices for their own tx. If otoh an honest user binds their tx to a specific slot, then the adversary has only one choice, accept the tx or not.
    2. Running hash of slot VRFs - We do not currently collect or expose these in polkadot, except at epoch boundaries, but we'll try to change this in sassafras. An adversary spends like 10 n DOTs to have 2^n choices for a running hash of slot VRFs, but their n is bounded by their control over block production, backing, etc.

    A smart contract could also create commit-reveal protocols, which work somewhat better in some scenarios, but again require thought.

    It all depends somewhat upon what the smart contract chain really does.

  3. SkymanOne commented on Aug 8, 2023

    @SkymanOne
    Author

    We removed the collective-flip randomness there, which afaik never really suffices. In theory, you could've whole block fiat-shamir transforms, but this winds up really nasty in practice.

    A smart contract parachain could expose VRF based randomness, of which we've two choices:

    1. Slot VRFs - Adversary knows these 6 hours in advance, so they have many choices for their own tx. If otoh an honest user binds their tx to a specific slot, then the adversary has only one choice, accept the tx or not.
    2. Running hash of slot VRFs - We do not currently collect or expose these in polkadot, except at epoch boundaries, but we'll try to change this in sassafras. An adversary spends like 10 n DOTs to have 2^n choices for a running hash of slot VRFs, but their n is bounded by their control over block production, backing, etc.

    A smart contract could also create commit-reveal protocols, which work somewhat better in some scenarios, but again require thought.

    It all depends somewhat upon what the smart contract chain really does.

    To sum up what you are saying, it still all comes down to the specific smart contract chain exposing their own randomness interface to the smart contract developer via, let's say, chain extensions, and we should not (or can not) provide a default method of achieving randomness on-chain?

  4. burdges commented on Aug 10, 2023

    @burdges

    It feel premature.. At minimum there should be some way to turn it off since there might even bespoke uses for smart contracts where exposing the block hash creates problems.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    J0-enhancementAn additional feature request.J2-unconfirmedIssue might be valid, but it’s not yet known.

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions