Skip to content

Commit

Permalink
Merge branch 'master' into corpus_report_open
Browse files Browse the repository at this point in the history
  • Loading branch information
anishnaik authored Nov 8, 2023
2 parents 626a01d + 0c4d0a8 commit 297836f
Show file tree
Hide file tree
Showing 11 changed files with 50 additions and 31 deletions.
8 changes: 4 additions & 4 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ jobs:
timeout-minutes: 10

steps:
- uses: actions/checkout@v3
- uses: actions/checkout@v4

- name: Speed up Go (Windows)
if: runner.os == 'Windows'
Expand Down Expand Up @@ -76,7 +76,7 @@ jobs:
timeout-minutes: 10

steps:
- uses: actions/checkout@v3
- uses: actions/checkout@v4

- uses: actions/setup-go@v4
with:
Expand Down Expand Up @@ -116,7 +116,7 @@ jobs:
timeout-minutes: 20

steps:
- uses: actions/checkout@v3
- uses: actions/checkout@v4

- name: Speed up Go, Python, Node (Windows)
if: runner.os == 'Windows'
Expand Down Expand Up @@ -155,7 +155,7 @@ jobs:

- name: Install Python dependencies
run: |
pip3 install --no-cache-dir solc-select crytic-compile
pip3 install --no-cache-dir setuptools solc-select crytic-compile
- name: Install solc
run: |
Expand Down
10 changes: 6 additions & 4 deletions chain/test_chain.go
Original file line number Diff line number Diff line change
Expand Up @@ -856,8 +856,9 @@ func (t *TestChain) emitContractChangeEvents(reverting bool, messageResults ...*
// this execution result is being committed to chain.
if deploymentChange.Creation {
err = t.Events.ContractDeploymentAddedEventEmitter.Publish(ContractDeploymentsAddedEvent{
Chain: t,
Contract: deploymentChange.Contract,
Chain: t,
Contract: deploymentChange.Contract,
DynamicDeployment: deploymentChange.DynamicCreation,
})
} else if deploymentChange.Destroyed {
err = t.Events.ContractDeploymentRemovedEventEmitter.Publish(ContractDeploymentsRemovedEvent{
Expand Down Expand Up @@ -887,8 +888,9 @@ func (t *TestChain) emitContractChangeEvents(reverting bool, messageResults ...*
})
} else if deploymentChange.Destroyed {
err = t.Events.ContractDeploymentAddedEventEmitter.Publish(ContractDeploymentsAddedEvent{
Chain: t,
Contract: deploymentChange.Contract,
Chain: t,
Contract: deploymentChange.Contract,
DynamicDeployment: deploymentChange.DynamicCreation,
})
}
if err != nil {
Expand Down
21 changes: 12 additions & 9 deletions chain/test_chain_deployments_tracer.go
Original file line number Diff line number Diff line change
Expand Up @@ -74,9 +74,10 @@ func (t *testChainDeploymentsTracer) CaptureStart(env *vm.EVM, from common.Addre
InitBytecode: input,
RuntimeBytecode: nil,
},
Creation: true,
SelfDestructed: false,
Destroyed: false,
Creation: true,
DynamicCreation: false,
SelfDestructed: false,
Destroyed: false,
})
}
}
Expand Down Expand Up @@ -118,9 +119,10 @@ func (t *testChainDeploymentsTracer) CaptureEnter(typ vm.OpCode, from common.Add
InitBytecode: input,
RuntimeBytecode: nil,
},
Creation: true,
SelfDestructed: false,
Destroyed: false,
Creation: true,
DynamicCreation: true,
SelfDestructed: false,
Destroyed: false,
})
}
}
Expand Down Expand Up @@ -158,9 +160,10 @@ func (t *testChainDeploymentsTracer) CaptureState(pc uint64, op vm.OpCode, gas,
InitBytecode: nil,
RuntimeBytecode: t.evm.StateDB.GetCode(scope.Contract.Address()),
},
Creation: false,
SelfDestructed: true,
Destroyed: t.selfDestructDestroysCode,
Creation: false,
DynamicCreation: false,
SelfDestructed: true,
Destroyed: t.selfDestructDestroysCode,
})
}
}
Expand Down
4 changes: 4 additions & 0 deletions chain/test_chain_events.go
Original file line number Diff line number Diff line change
Expand Up @@ -93,6 +93,10 @@ type ContractDeploymentsAddedEvent struct {

// Contract defines information for the contract which was deployed to the Chain.
Contract *types.DeployedContractBytecode

// DynamicDeployment describes whether this contract deployment was dynamic (e.g. `c = new MyContract()`) or was
// because of a traditional transaction
DynamicDeployment bool
}

// ContractDeploymentsRemovedEvent describes an event where a contract has become unavailable on the TestChain, either
Expand Down
4 changes: 4 additions & 0 deletions chain/types/deployed_contract_bytecode.go
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,10 @@ type DeployedContractBytecodeChange struct {
// Destroyed are true.
Creation bool

// DynamicCreation indicates whether the change made was a _dynamic_ contract creation. This cannot be true if
// Creation is false.
DynamicCreation bool

// SelfDestructed indicates whether the change made was due to a self-destruct instruction being executed. This
// cannot be true if Creation is true.
// Note: This may not be indicative of contract removal (as is the case with Destroyed), as proposed changes to
Expand Down
2 changes: 1 addition & 1 deletion fuzzing/config/config_defaults.go
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ func GetDefaultProjectConfig(platform string) (*ProjectConfig, error) {
TransactionGasLimit: 12_500_000,
Testing: TestingConfig{
StopOnFailedTest: true,
StopOnFailedContractMatching: true,
StopOnFailedContractMatching: false,
StopOnNoTests: true,
TestAllContracts: false,
TraceAll: false,
Expand Down
1 change: 1 addition & 0 deletions fuzzing/fuzzer_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -398,6 +398,7 @@ func TestDeploymentsSelfDestruct(t *testing.T) {
config.Fuzzing.DeploymentOrder = []string{"InnerDeploymentFactory"}
config.Fuzzing.TestLimit = 500 // this test should expose a failure quickly.
config.Fuzzing.Testing.StopOnNoTests = false
config.Fuzzing.Testing.TestAllContracts = true
},
method: func(f *fuzzerTestContext) {
// Subscribe to any mined block events globally. When receiving them, check contract changes for a
Expand Down
5 changes: 5 additions & 0 deletions fuzzing/fuzzer_worker.go
Original file line number Diff line number Diff line change
Expand Up @@ -152,6 +152,11 @@ func (fw *FuzzerWorker) getNewCorpusCallSequenceWeight() *big.Int {
// onChainContractDeploymentAddedEvent is the event callback used when the chain detects a new contract deployment.
// It attempts bytecode matching and updates the list of deployed contracts the worker should use for fuzz testing.
func (fw *FuzzerWorker) onChainContractDeploymentAddedEvent(event chain.ContractDeploymentsAddedEvent) error {
// Do not track the deployed contract if the contract deployment was a dynamic one and testAllContracts is false
if !fw.fuzzer.config.Fuzzing.Testing.TestAllContracts && event.DynamicDeployment {
return nil
}

// Add the contract address to our value set so our generator can use it in calls.
fw.valueSet.AddAddress(event.Contract.Address)

Expand Down
8 changes: 4 additions & 4 deletions go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -8,15 +8,15 @@ require (
github.com/fxamacker/cbor v1.5.1
github.com/google/uuid v1.3.1
github.com/pkg/errors v0.9.1
github.com/rs/zerolog v1.30.0
github.com/rs/zerolog v1.31.0
github.com/shopspring/decimal v1.3.1
github.com/spf13/cobra v1.7.0
github.com/spf13/pflag v1.0.5
github.com/stretchr/testify v1.8.4
golang.org/x/crypto v0.13.0
golang.org/x/crypto v0.14.0
golang.org/x/exp v0.0.0-20230206171751-46f607a40771
golang.org/x/net v0.14.0
golang.org/x/sys v0.12.0
golang.org/x/sys v0.13.0
)

require (
Expand Down Expand Up @@ -47,7 +47,7 @@ require (
github.com/kr/pretty v0.3.1 // indirect
github.com/kr/text v0.2.0 // indirect
github.com/mattn/go-colorable v0.1.13 // indirect
github.com/mattn/go-isatty v0.0.16 // indirect
github.com/mattn/go-isatty v0.0.19 // indirect
github.com/mattn/go-runewidth v0.0.14 // indirect
github.com/matttproud/golang_protobuf_extensions v1.0.4 // indirect
github.com/olekukonko/tablewriter v0.0.5 // indirect
Expand Down
16 changes: 8 additions & 8 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -183,16 +183,16 @@ github.com/magiconair/properties v1.8.0/go.mod h1:PppfXfuXeibc/6YijjN8zIbojt8czP
github.com/mattn/go-colorable v0.1.2/go.mod h1:U0ppj6V5qS13XJ6of8GYAs25YV2eR4EVcfRqFIhoBtE=
github.com/mattn/go-colorable v0.1.8/go.mod h1:u6P/XSegPjTcexA+o6vUJrdnUu04hMope9wVRipJSqc=
github.com/mattn/go-colorable v0.1.11/go.mod h1:u5H1YNBxpqRaxsYJYSkiCWKzEfiAb1Gb520KVy5xxl4=
github.com/mattn/go-colorable v0.1.12/go.mod h1:u5H1YNBxpqRaxsYJYSkiCWKzEfiAb1Gb520KVy5xxl4=
github.com/mattn/go-colorable v0.1.13 h1:fFA4WZxdEF4tXPZVKMLwD8oUnCTTo08duU7wxecdEvA=
github.com/mattn/go-colorable v0.1.13/go.mod h1:7S9/ev0klgBDR4GtXTXX8a3vIGJpMovkB8vQcUbaXHg=
github.com/mattn/go-isatty v0.0.7/go.mod h1:Iq45c/XA43vh69/j3iqttzPXn0bhXyGjM0Hdxcsrc5s=
github.com/mattn/go-isatty v0.0.8/go.mod h1:Iq45c/XA43vh69/j3iqttzPXn0bhXyGjM0Hdxcsrc5s=
github.com/mattn/go-isatty v0.0.9/go.mod h1:YNRxwqDuOph6SZLI9vUUz6OYw3QyUt7WiY2yME+cCiQ=
github.com/mattn/go-isatty v0.0.12/go.mod h1:cbi8OIDigv2wuxKPP5vlRcQ1OAZbq2CE4Kysco4FUpU=
github.com/mattn/go-isatty v0.0.14/go.mod h1:7GGIvUiUoEMVVmxf/4nioHXj79iQHKdU27kJ6hsGG94=
github.com/mattn/go-isatty v0.0.16 h1:bq3VjFmv/sOjHtdEhmkEV4x1AJtvUvOJ2PFAZ5+peKQ=
github.com/mattn/go-isatty v0.0.16/go.mod h1:kYGgaQfpe5nmfYZH+SKPsOc2e4SrIfOl2e/yFXSvRLM=
github.com/mattn/go-isatty v0.0.19 h1:JITubQf0MOLdlGRuRq+jtsDlekdYPia9ZFsB8h/APPA=
github.com/mattn/go-isatty v0.0.19/go.mod h1:W+V8PltTTMOvKvAeJH7IuucS94S2C6jfK/D7dTCTo3Y=
github.com/mattn/go-runewidth v0.0.9/go.mod h1:H031xJmbD/WCDINGzjvQ9THkh0rPKHF+m2gUSrubnMI=
github.com/mattn/go-runewidth v0.0.14 h1:+xnbZSEeDbOIg5/mE6JF0w6n9duR1l3/WmbinWVwUuU=
github.com/mattn/go-runewidth v0.0.14/go.mod h1:Jdepj2loyihRzMpdS35Xk/zdY8IAYHsh153qUoGf23w=
Expand Down Expand Up @@ -250,8 +250,8 @@ github.com/rogpeppe/go-internal v1.8.1/go.mod h1:JeRgkft04UBgHMgCIwADu4Pn6Mtm5d4
github.com/rogpeppe/go-internal v1.9.0 h1:73kH8U+JUqXU8lRuOHeVHaa/SZPifC7BkcraZVejAe8=
github.com/rogpeppe/go-internal v1.9.0/go.mod h1:WtVeX8xhTBvf0smdhujwtBcq4Qrzq/fJaraNFVN+nFs=
github.com/rs/xid v1.5.0/go.mod h1:trrq9SKmegXys3aeAKXMUTdJsYXVwGY3RLcfgqegfbg=
github.com/rs/zerolog v1.30.0 h1:SymVODrcRsaRaSInD9yQtKbtWqwsfoPcRff/oRXLj4c=
github.com/rs/zerolog v1.30.0/go.mod h1:/tk+P47gFdPXq4QYjvCmT5/Gsug2nagsFWBWhAiSi1w=
github.com/rs/zerolog v1.31.0 h1:FcTR3NnLWW+NnTwwhFWiJSZr4ECLpqCm6QsEnyvbV4A=
github.com/rs/zerolog v1.31.0/go.mod h1:/7mN4D5sKwJLZQ2b/znpjC3/GQWY/xaDXUM0kKWRHss=
github.com/russross/blackfriday v1.5.2/go.mod h1:JO/DiYxRf+HjHt06OyowR9PTA263kcR/rfWxYHBV53g=
github.com/russross/blackfriday/v2 v2.1.0/go.mod h1:+Rmxgy9KzJVeS9/2gXHxylqXiyQDYRxCVz55jmeOWTM=
github.com/ryanuber/columnize v2.1.0+incompatible/go.mod h1:sm1tb6uqfes/u+d4ooFouqFdy9/2g9QGwK3SQygK0Ts=
Expand Down Expand Up @@ -321,8 +321,8 @@ golang.org/x/crypto v0.0.0-20191227163750-53104e6ec876/go.mod h1:LzIPMQfyMNhhGPh
golang.org/x/crypto v0.0.0-20200622213623-75b288015ac9/go.mod h1:LzIPMQfyMNhhGPhUkYOs5KpL4U8rLKemX1yGLhDgUto=
golang.org/x/crypto v0.0.0-20210322153248-0c34fe9e7dc2/go.mod h1:T9bdIzuCu7OtxOm1hfPfRQxPLYneinmdGuTeoZ9dtd4=
golang.org/x/crypto v0.0.0-20210921155107-089bfa567519/go.mod h1:GvvjBRRGRdwPK5ydBHafDWAxML/pGHZbMvKqRZ5+Abc=
golang.org/x/crypto v0.13.0 h1:mvySKfSWJ+UKUii46M40LOvyWfN0s2U+46/jDd0e6Ck=
golang.org/x/crypto v0.13.0/go.mod h1:y6Z2r+Rw4iayiXXAIxJIDAJ1zMW4yaTpebo8fPOliYc=
golang.org/x/crypto v0.14.0 h1:wBqGXzWJW6m1XrIKlAH0Hs1JJ7+9KBwnIO8v66Q9cHc=
golang.org/x/crypto v0.14.0/go.mod h1:MVFd36DqK4CsrnJYDkBA3VC4m2GkXAM0PvzMCn4JQf4=
golang.org/x/exp v0.0.0-20190121172915-509febef88a4/go.mod h1:CJ0aWSM057203Lf6IL+f9T1iT9GByDxfZKAQTCR3kQA=
golang.org/x/exp v0.0.0-20230206171751-46f607a40771 h1:xP7rWLUr1e1n2xkK5YB4LI0hPEy3LJC6Wk+D4pGlOJg=
golang.org/x/exp v0.0.0-20230206171751-46f607a40771/go.mod h1:CxIveKay+FTh1D0yPZemJVgC/95VzuuOLq5Qi4xnoYc=
Expand Down Expand Up @@ -396,8 +396,8 @@ golang.org/x/sys v0.0.0-20220209214540-3681064d5158/go.mod h1:oPkhp1MJrh7nUepCBc
golang.org/x/sys v0.0.0-20220405052023-b1e9470b6e64/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
golang.org/x/sys v0.0.0-20220811171246-fbc7d0a398ab/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
golang.org/x/sys v0.2.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
golang.org/x/sys v0.12.0 h1:CM0HF96J0hcLAwsHPJZjfdNzs0gftsLfgKt57wWHJ0o=
golang.org/x/sys v0.12.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
golang.org/x/sys v0.13.0 h1:Af8nKPmuFypiUBjVoU9V20FiaFXOcuZI21p0ycVYYGE=
golang.org/x/sys v0.13.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
golang.org/x/term v0.0.0-20201126162022-7de9c90e9dd1/go.mod h1:bj7SfCRtBDWHUb9snDiAeCFNEtKQo2Wmx5Cou7ajbmo=
golang.org/x/text v0.3.0/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ=
golang.org/x/text v0.3.2/go.mod h1:bEr9sfX3Q8Zfm5fL9x+3itogRgK3+ptLWKqgva+5dAk=
Expand Down
2 changes: 1 addition & 1 deletion logging/logger_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -70,6 +70,6 @@ func TestDisabledColors(t *testing.T) {

// Ensure that msg doesn't include colors afterwards
prefix := fmt.Sprintf("%s %s", colors.LEFT_ARROW, "foo")
_, ok := strings.CutPrefix(buf.String(), prefix)
_, _, ok := strings.Cut(buf.String(), prefix)
assert.True(t, ok)
}

0 comments on commit 297836f

Please sign in to comment.