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

remove the random builtin function #1041

Merged
merged 1 commit into from
Oct 19, 2022
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
15 changes: 0 additions & 15 deletions docs/language/builtins.rst
Original file line number Diff line number Diff line change
Expand Up @@ -31,10 +31,6 @@ Returns the blockhash for a particular block. This not possible for the current
block, or any block except for the most recent 256. Do not use this a source of
randomness unless you know what you are doing.

.. note::
This function is not available on Parity Substrate. When using Parity Substrate,
use ``random()`` as a source of random data.

.. note::
This function is not available on Solana. There is the
`recent block hashes account <https://edge.docs.solana.com/developing/runtime-facilities/sysvars#recentblockhashes>`_
Expand All @@ -44,17 +40,6 @@ randomness unless you know what you are doing.
- It does not give any slot of block number, so it is not possible to provide a matching
function signature.

random(bytes subject) returns (bytes32)
+++++++++++++++++++++++++++++++++++++++

Returns random bytes based on the subject. The same subject for the same transaction
will return the same random bytes, so the result is deterministic. The chain has
a ``max_subject_len``, and if *subject* exceeds that, the transaction will be aborted.

.. note::

This function is only available on Parity Substrate.

``msg`` properties
++++++++++++++++++

Expand Down
13 changes: 0 additions & 13 deletions integration/substrate/randomizer.sol

This file was deleted.

45 changes: 0 additions & 45 deletions integration/substrate/randomizer.spec.ts

This file was deleted.

13 changes: 1 addition & 12 deletions src/sema/builtin.rs
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ pub struct Prototype {
}

// A list of all Solidity builtins functions
static BUILTIN_FUNCTIONS: Lazy<[Prototype; 28]> = Lazy::new(|| {
static BUILTIN_FUNCTIONS: Lazy<[Prototype; 27]> = Lazy::new(|| {
[
Prototype {
builtin: Builtin::Assert,
Expand Down Expand Up @@ -187,17 +187,6 @@ static BUILTIN_FUNCTIONS: Lazy<[Prototype; 28]> = Lazy::new(|| {
doc: "Returns the block hash for given block number",
constant: false,
},
Prototype {
builtin: Builtin::Random,
namespace: None,
method: None,
name: "random",
params: vec![Type::DynamicBytes],
ret: vec![Type::Bytes(32)],
target: vec![Target::default_substrate()],
doc: "Returns deterministic random bytes",
constant: false,
},
Prototype {
builtin: Builtin::AbiDecode,
namespace: Some("abi"),
Expand Down
15 changes: 0 additions & 15 deletions tests/substrate_tests/builtins.rs
Original file line number Diff line number Diff line change
Expand Up @@ -416,21 +416,6 @@ fn functions() {
);

runtime.function("test", Vec::new());

let mut runtime = build_solidity(
r##"
contract c {
function test() public {
bytes32 o = random(
"abcd"
);

assert(o == hex"429ccf3ebce07f0c6d7cd0d1dead74459f753cdf53ed8359e42728042a91c39c");
}
}"##,
);

runtime.function("test", Vec::new());
}

#[test]
Expand Down