diff --git a/docs/language/builtins.rst b/docs/language/builtins.rst index dccebf402..f30c3358f 100644 --- a/docs/language/builtins.rst +++ b/docs/language/builtins.rst @@ -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 `_ @@ -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 ++++++++++++++++++ diff --git a/integration/substrate/randomizer.sol b/integration/substrate/randomizer.sol deleted file mode 100644 index 93aa1969a..000000000 --- a/integration/substrate/randomizer.sol +++ /dev/null @@ -1,13 +0,0 @@ -contract randomizer { - bytes32 public value; - - function get_random(bytes subject) public returns (bytes32) { - bytes32 r1 = random(subject); - // if we call random again in the same transaction, we should get the same result - bytes32 r2 = random(subject); - - assert(r1 == r2); - value = r1; - return r1; - } -} \ No newline at end of file diff --git a/integration/substrate/randomizer.spec.ts b/integration/substrate/randomizer.spec.ts deleted file mode 100644 index 26db7d2a6..000000000 --- a/integration/substrate/randomizer.spec.ts +++ /dev/null @@ -1,45 +0,0 @@ -import expect from 'expect'; -import { gasLimit, createConnection, deploy, transaction, aliceKeypair, daveKeypair } from './index'; -import { ContractPromise } from '@polkadot/api-contract'; -import { ApiPromise } from '@polkadot/api'; - -describe('Deploy randomizer contract and test', () => { - let conn: ApiPromise; - - before(async function () { - conn = await createConnection(); - }); - - after(async function () { - await conn.disconnect(); - }); - - it('randomizer', async function () { - this.timeout(50000); - - const alice = aliceKeypair(); - const dave = daveKeypair(); - - // call the constructors - let deploy_contract = await deploy(conn, alice, 'randomizer.contract', BigInt(0)); - - let contract = new ContractPromise(conn, deploy_contract.abi, deploy_contract.address); - - let { output: queryOutput } = await contract.query.getRandom(alice.address, {}, '01234567'); - - let tx = contract.tx.getRandom({ gasLimit }, '01234567'); - - await transaction(tx, alice); - - let { output: txOutput } = await contract.query.value(alice.address, {}); - - let queryRandom = queryOutput!.toU8a(); - let txRandom = txOutput!.toU8a(); - - expect(queryRandom.length).toBe(32); - expect(txRandom.length).toBe(32); - expect(txRandom).not.toBe(queryRandom); - expect(queryRandom).not.toBe(Buffer.alloc(32)); - expect(txRandom).not.toBe(Buffer.alloc(32)); - }); -}); diff --git a/src/sema/builtin.rs b/src/sema/builtin.rs index bedaf04f0..c21bac016 100644 --- a/src/sema/builtin.rs +++ b/src/sema/builtin.rs @@ -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, @@ -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"), diff --git a/tests/substrate_tests/builtins.rs b/tests/substrate_tests/builtins.rs index 039b27a32..6b88d93e3 100644 --- a/tests/substrate_tests/builtins.rs +++ b/tests/substrate_tests/builtins.rs @@ -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]