Skip to content

Commit

Permalink
fix: use signature in traces to handle overloaded function names (#336)
Browse files Browse the repository at this point in the history
* fix: use signature in traces to handle overloaded function names

* fix test

---------

Co-authored-by: anishnaik <[email protected]>
  • Loading branch information
0xalpharush and anishnaik authored Mar 25, 2024
1 parent da11676 commit 382f7f2
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 9 deletions.
5 changes: 3 additions & 2 deletions fuzzing/calls/call_sequence.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,8 @@ package calls
import (
"encoding/binary"
"fmt"
"strconv"

"github.com/crytic/medusa/chain"
chainTypes "github.com/crytic/medusa/chain/types"
fuzzingTypes "github.com/crytic/medusa/fuzzing/contracts"
Expand All @@ -13,7 +15,6 @@ import (
"github.com/ethereum/go-ethereum/accounts/abi"
"github.com/ethereum/go-ethereum/common"
"github.com/ethereum/go-ethereum/crypto"
"strconv"
)

// CallSequence describes a sequence of calls sent to a chain.
Expand Down Expand Up @@ -230,7 +231,7 @@ func (cse *CallSequenceElement) String() string {
method, err := cse.Method()
methodName := "<unresolved method>"
if err == nil && method != nil {
methodName = method.Name
methodName = method.Sig
}

// Next decode our arguments (we jump four bytes to skip the function selector)
Expand Down
7 changes: 4 additions & 3 deletions fuzzing/executiontracer/execution_trace.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,9 @@ package executiontracer
import (
"encoding/hex"
"fmt"
"regexp"
"strings"

"github.com/crytic/medusa/chain"
"github.com/crytic/medusa/compilation/abiutils"
"github.com/crytic/medusa/fuzzing/contracts"
Expand All @@ -12,8 +15,6 @@ import (
"github.com/ethereum/go-ethereum/accounts/abi"
coreTypes "github.com/ethereum/go-ethereum/core/types"
"github.com/ethereum/go-ethereum/core/vm"
"regexp"
"strings"
)

// ExecutionTrace contains information recorded by an ExecutionTracer. It contains information about each call
Expand Down Expand Up @@ -77,7 +78,7 @@ func (t *ExecutionTrace) generateCallFrameEnterElements(callFrame *CallFrame) ([
} else {
method, err = callFrame.CodeContractAbi.MethodById(callFrame.InputData)
if err == nil {
methodName = method.Name
methodName = method.Sig
}
}
}
Expand Down
9 changes: 5 additions & 4 deletions fuzzing/fuzzer_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,15 +2,16 @@ package fuzzing

import (
"encoding/hex"
"math/big"
"math/rand"
"testing"

"github.com/crytic/medusa/chain"
"github.com/crytic/medusa/events"
"github.com/crytic/medusa/fuzzing/calls"
"github.com/crytic/medusa/fuzzing/valuegeneration"
"github.com/crytic/medusa/utils"
"github.com/ethereum/go-ethereum/common"
"math/big"
"math/rand"
"testing"

"github.com/crytic/medusa/fuzzing/config"
"github.com/stretchr/testify/assert"
Expand Down Expand Up @@ -461,7 +462,7 @@ func TestDeploymentsSelfDestruct(t *testing.T) {
func TestExecutionTraces(t *testing.T) {
expectedMessagesPerTest := map[string][]string{
"testdata/contracts/execution_tracing/call_and_deployment_args.sol": {"Hello from deployment args!", "Hello from call args!"},
"testdata/contracts/execution_tracing/cheatcodes.sol": {"StdCheats.toString(true)"},
"testdata/contracts/execution_tracing/cheatcodes.sol": {"StdCheats.toString(bool)(true)"},
"testdata/contracts/execution_tracing/event_emission.sol": {"TestEvent", "TestIndexedEvent", "TestMixedEvent", "Hello from event args!", "Hello from library event args!"},
"testdata/contracts/execution_tracing/proxy_call.sol": {"TestContract -> InnerDeploymentContract.setXY", "Hello from proxy call args!"},
"testdata/contracts/execution_tracing/revert_custom_error.sol": {"CustomError", "Hello from a custom error!"},
Expand Down

0 comments on commit 382f7f2

Please sign in to comment.