Skip to content

Conversation

gustavo-grieco
Copy link
Collaborator

@gustavo-grieco gustavo-grieco commented Jan 5, 2023

This should be considered experimental until we know it works better

@rappie
Copy link

rappie commented Jan 6, 2023

I have run some tests. It does not seem to be working.

I would expect echidna to be able to break testAmount without the helper. It needs a number between 1e16 and 1e20, which should occur frequently now in the distribution of the random numbers.

pragma solidity ^0.8.0;

contract EchidnaTest {
    uint256 private constant min = 16;
    uint256 private constant max = 20;

    function helper(uint256 amount) public {
        amount = (10**min) + (amount % ((10**max) - (10**min)));
        testAmount(amount);
    }

    function testAmount(uint256 amount) public {
        if (amount > (10**min) && amount < (10**max)) {
            assert(false);
        }
    }
}
testMode: assertion
testLimit: 100000

@gustavo-grieco
Copy link
Collaborator Author

This is working now, thanks @rappie !

@gustavo-grieco gustavo-grieco marked this pull request as ready for review January 6, 2023 21:25
@rappie
Copy link

rappie commented Jan 31, 2023

I have tested this.

As expected, it is noticably slower to break certain properties than before, but it does manage to break them without helpers.

Personally I'd prefer to have only the logarithmic RNG. I believe this to be superior for fuzzing, but then again I'm no expert :)

[ (getRandomR (0, 1023), 1)
, (getRandomR (0, 2 ^ n - 5), 8)
, (getRandomR (2 ^ n - 5, 2 ^ n - 1), 1)
, (getRandomPow (n - 5), 4)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

as I understand the chance of this happening will be 4/14 ~ 28%?

@gustavo-grieco gustavo-grieco merged commit 558baef into master Apr 11, 2023
@gustavo-grieco gustavo-grieco deleted the dev-power-gen branch April 11, 2023 17:37
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

Successfully merging this pull request may close these issues.

3 participants