Skip to content

Conversation

@cgewecke
Copy link
Member

@cgewecke cgewecke commented Sep 6, 2019

Modifies the instrumentation strategy to use a function call with the instrumentation hash as an argument. This provides a way of getting around 'stack-too-deep' compiler errors which seem more common than initially anticipated. (An initial test on aragon-court triggered many of these.)

Instrumentation now looks something like...

contract Test {
  // Hex identifier postfixes are hashes of the filename 
  function coverage_0xab123(bytes32 c__0xab123) public pure {}

  function a(uint x) public {

    coverage_0xab123(0xdc08f...08ed1); /* function */ 
    coverage_0xab123(0xa9065...549e2); /* line */         
    coverage_0xab123(0x6ac83...f2037); /* statement */ 
  
    if (x == 1) {
  
      coverage_0xab123(0x85e7e...afacf); /* branch */ 
      coverage_0xab123(0xfa262...4fb28); /* line */  
      coverage_0xab123(0xa3e17...38d49); /* statement */ 
  
      x = 3;
  
    } else { 
      coverage_0xab123(0xb54c1...3ef6b); /* branch */ 
    }
}

Gas cost for each instrumentation method call is 13 - possibly small enough make gas distortion a non-issue.

Also added a "stack too deep" test.

if (typeof info !== 'object' || !info.opcode ) return;

if (info.opcode.name.includes("PUSH") && info.stack.length > 0){
if (info.opcode.name.includes("PUSH1") && info.stack.length > 0){
Copy link
Member Author

@cgewecke cgewecke Sep 6, 2019

Choose a reason for hiding this comment

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

Hope this ok - the VM reports that both PUSH1 and PUSH2 are called with the same hash at the top of the stack, resulting in duplicate hits. This makes everything contingent on a very specific implementation detail at Solidity though...

@cgewecke cgewecke merged commit 9aa52f8 into truffle-plugin Sep 6, 2019
@cgewecke cgewecke deleted the fix/stack-too-deep branch September 6, 2019 04:01
cgewecke added a commit that referenced this pull request Sep 25, 2019
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.

2 participants