ethereum / remix-project

Remix is a browser-based compiler and IDE that enables users to build Ethereum contracts with Solidity language and to debug transactions.
https://remix-ide.readthedocs.io
MIT License
2.46k stars 952 forks source link

Remix Crash Array #302

Open iulianivg opened 6 years ago

iulianivg commented 6 years ago

I have a basic contract which I run in remix. I'm using it to test different random algorithms. Unfortunately, when I have an array of 300-400 addresses and I run the 'selectParticipant' function, it takes a while to load (mining transaction) then it simply crashes. No message, it just refreshes everything, deletes my code and sends me back to ballot.sol

pragma solidity ^0.4.17;

contract TestingRandom{
address public theCreator;
address[] public participants;
uint public Secretkey1;
string public Secretkey2;

constructor() public {theCreator = msg.sender;}

function enterArray() public payable{
if (msg.value == 1 ether){
participants.push(msg.sender);}

else {if(msg.value == 2 ether){
for(int i; i<150; i++)
participants.push(msg.sender);
}}}

function key1(uint anInput) public {
Secretkey1 = anInput; }

function key2(string anInput) public {
Secretkey2 = anInput;}

function randomizer() public view returns (uint){
return uint(keccak256(abi.encodePacked(Secretkey1, Secretkey2, participants)));}

function selectParticipant() public {
 randomizer() % participants.length;   
 participants = new address[](0);
}
}

Instructions on how to use: 1) Deploy the contract. Select gas 4000000 instead of 3000000 2) Select Value 2 ETH and call enterArray function (will place this address 150 times in the array) 3) Repeat step 2 for 3-4 times to have 450-600 entries in the array 4) Select an integer for key1 and a string for key2 5) Call 'selectParticipant' function. Remix will crash for script running too long and you will lose everything, including the code.

IMPORTANT: Everything works fine if you input less than 20-50 addresses in the array.

MiguelGonzales-WIV commented 1 year ago

Same here. Found a fix?