-
Notifications
You must be signed in to change notification settings - Fork 33
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
w3vm/hooks: Added CallTracer-Hook (#192)
* internal/fourbyte: init * w3vm/hooks: init call tracer * internal/fourbyte: added more funcs * examples: `go mod tidy` * internal/fourbyte: init event generation * internal/fourbyte: added `Event(..)` * w3vm/hooks: improved revert reason decoding * w3vm/hooks: fix * added more funcs and events * internal/fourbyte: added precompiles * added more functions * added functions * added opcode rendering * added option `ShowStaticcall` * `go mod tidy` * examples fix deps * added comments * dropped option --------- Co-authored-by: lmittmann <[email protected]>
- Loading branch information
Showing
10 changed files
with
1,241 additions
and
9 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
Approval(address indexed owner, address indexed spender, uint256 value) | ||
Burn(address indexed sender, uint256 amount0, uint256 amount1, address indexed to) | ||
Mint(address indexed sender, uint256 amount0, uint256 amount1) | ||
PairCreated(address indexed token0, address indexed token1, address pair, uint256) | ||
Swap(address indexed sender, uint256 amount0In, uint256 amount1In, uint256 amount0Out, uint256 amount1Out, address indexed to) | ||
Sync(uint112 reserve0, uint112 reserve1) | ||
Transfer(address indexed from, address indexed to, uint256 value) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
//go:generate go run gen.go | ||
|
||
package fourbyte | ||
|
||
import ( | ||
"github.com/ethereum/go-ethereum/common" | ||
"github.com/lmittmann/w3" | ||
) | ||
|
||
var ( | ||
precompile1 = w3.MustNewFunc("ecRecover(bytes32 hash, uint8 v, bytes32 r, bytes32 s)", "address") | ||
precompile2 = w3.MustNewFunc("keccak(bytes)", "bytes32") | ||
precompile3 = w3.MustNewFunc("ripemd160(bytes)", "bytes32") | ||
precompile4 = w3.MustNewFunc("identity(bytes)", "bytes") | ||
|
||
addr1 = common.BytesToAddress([]byte{0x01}) | ||
addr2 = common.BytesToAddress([]byte{0x02}) | ||
addr3 = common.BytesToAddress([]byte{0x03}) | ||
addr4 = common.BytesToAddress([]byte{0x04}) | ||
) | ||
|
||
func Function(sig [4]byte, addr common.Address) (fn *w3.Func, isPrecompile bool) { | ||
switch addr { | ||
case addr1: | ||
return precompile1, true | ||
case addr2: | ||
return precompile2, true | ||
case addr3: | ||
return precompile3, true | ||
case addr4: | ||
return precompile4, true | ||
} | ||
return functions[sig], false | ||
} | ||
|
||
func Event(topic0 [32]byte, addr common.Address) *w3.Event { | ||
return events[topic0] | ||
} |
Oops, something went wrong.