forked from ethereum/go-ethereum
-
Notifications
You must be signed in to change notification settings - Fork 9
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #119 from blocknative/TS_nbc
More decoding benchmarks
- Loading branch information
Showing
3 changed files
with
107 additions
and
20 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
package blocknative | ||
|
||
import ( | ||
"github.com/ethereum/go-ethereum/common" | ||
"github.com/ethereum/go-ethereum/core/vm" | ||
"math" | ||
) | ||
|
||
// decoderEVM contains the functionality required by the decoder from the EVM. | ||
type decoderEVM struct { | ||
*vm.EVM | ||
} | ||
|
||
// GetCode returns the bytecode of the account with the given address, or nil | ||
// if the account is not a contract. | ||
func (d decoderEVM) GetCode(addr common.Address) []byte { | ||
return d.StateDB.GetCode(addr) | ||
} | ||
|
||
// CallCode executes the given method on the code at the given address. | ||
func (d decoderEVM) CallCode(addr common.Address, method []byte) ([]byte, error) { | ||
code := d.StateDB.GetCode(addr) | ||
contract := vm.NewContract(vm.AccountRef(common.Address{}), vm.AccountRef(addr), common.Big0, math.MaxUint64) | ||
contract.SetCallCode(&addr, d.StateDB.GetCodeHash(addr), code) | ||
return d.Interpreter().Run(contract, method, false) | ||
} |
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