What current issue(s) does this address, or what feature is it adding?
audit of mainnet block 3602763 showed a deviation in gas consumption due to an incorrect implementation of the RIGHT VM opcode. The existing JSON tests also do not cover this.
A 0 count operand should result in an empty buffer, the existing implementation used buffer[-count:] which worked fine as long as the count > 0. For the specific case of 0 it would actually return the full buffer instead of an empty buffer as needed. This would return incorrect lenghts, causing an LT->JMPIF sequence to point the IP to the wrong next instruction.
How did you solve this problem?
fix implementation to be explicit. Also addressed possible issue with similar logic for the LEFT instruction.
How did you make sure your solution works?
audit of the given block now passes.
Are there any special changes in the code that we should be aware of?
no
Please check the following, if applicable:
[ ] Did you add any tests?
[] Did you run make lint?
[X] Did you run make test?
[X] Are you making a PR to a feature branch or development rather than master?
[X] Did you add an entry to CHANGELOG.rst? (if not, please do)
Coverage decreased (-0.001%) to 85.307% when pulling ca04c0be308acbdf6e5a4782e0ad6f878f57928d on ixje:fix-right-opcode into 0ea2fc5e528cdb98037baa145ad4de3663498cb8 on CityOfZion:development.
What current issue(s) does this address, or what feature is it adding? audit of mainnet block
3602763
showed a deviation in gas consumption due to an incorrect implementation of theRIGHT
VM opcode. The existing JSON tests also do not cover this. A0
count operand should result in an empty buffer, the existing implementation usedbuffer[-count:]
which worked fine as long as the count > 0. For the specific case of0
it would actually return the full buffer instead of an empty buffer as needed. This would return incorrect lenghts, causing anLT
->JMPIF
sequence to point the IP to the wrong next instruction.How did you solve this problem? fix implementation to be explicit. Also addressed possible issue with similar logic for the
LEFT
instruction.How did you make sure your solution works? audit of the given block now passes.
Are there any special changes in the code that we should be aware of? no
Please check the following, if applicable:
make lint
?make test
?CHANGELOG.rst
? (if not, please do)