Skip to content

Commit

Permalink
Merge pull request #612 from ethereum/go_create2_salt
Browse files Browse the repository at this point in the history
go: create2_salt is not required for execution
  • Loading branch information
chfast authored Jul 16, 2021
2 parents b41c35e + 6d341ee commit 6711434
Show file tree
Hide file tree
Showing 5 changed files with 14 additions and 9 deletions.
5 changes: 5 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,11 @@ and this project adheres to [Semantic Versioning].

## [10.0.0] — unreleased

### Changed

- Go: The `create2Salt` parameter has been removed from the `VM.Execute()`.
[#612](https://github.com/ethereum/evmc/pull/612)

## [9.0.0] — 2021-06-30

### Added
Expand Down
9 changes: 4 additions & 5 deletions bindings/go/evmc/evmc.go
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ static struct evmc_result execute_wrapper(struct evmc_vm* vm,
enum evmc_call_kind kind, uint32_t flags, int32_t depth, int64_t gas,
const evmc_address* destination, const evmc_address* sender,
const uint8_t* input_data, size_t input_size, const evmc_uint256be* value,
const uint8_t* code, size_t code_size, const evmc_bytes32* create2_salt)
const uint8_t* code, size_t code_size)
{
struct evmc_message msg = {
kind,
Expand All @@ -42,7 +42,7 @@ static struct evmc_result execute_wrapper(struct evmc_vm* vm,
input_data,
input_size,
*value,
*create2_salt,
{{0}}, // create2_salt: not required for execution
};
struct evmc_host_context* context = (struct evmc_host_context*)context_index;
Expand Down Expand Up @@ -194,7 +194,7 @@ func (vm *VM) SetOption(name string, value string) (err error) {
func (vm *VM) Execute(ctx HostContext, rev Revision,
kind CallKind, static bool, depth int, gas int64,
destination Address, sender Address, input []byte, value Hash,
code []byte, create2Salt Hash) (output []byte, gasLeft int64, err error) {
code []byte) (output []byte, gasLeft int64, err error) {

flags := C.uint32_t(0)
if static {
Expand All @@ -206,11 +206,10 @@ func (vm *VM) Execute(ctx HostContext, rev Revision,
evmcDestination := evmcAddress(destination)
evmcSender := evmcAddress(sender)
evmcValue := evmcBytes32(value)
evmcCreate2Salt := evmcBytes32(create2Salt)
result := C.execute_wrapper(vm.handle, C.uintptr_t(ctxId), uint32(rev),
C.enum_evmc_call_kind(kind), flags, C.int32_t(depth), C.int64_t(gas),
&evmcDestination, &evmcSender, bytesPtr(input), C.size_t(len(input)), &evmcValue,
bytesPtr(code), C.size_t(len(code)), &evmcCreate2Salt)
bytesPtr(code), C.size_t(len(code)))
removeHostContext(ctxId)

output = C.GoBytes(unsafe.Pointer(result.output_data), C.int(result.output_size))
Expand Down
2 changes: 1 addition & 1 deletion bindings/go/evmc/evmc_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ func TestExecuteEmptyCode(t *testing.T) {

addr := Address{}
h := Hash{}
output, gasLeft, err := vm.Execute(nil, Byzantium, Call, false, 1, 999, addr, addr, nil, h, nil, h)
output, gasLeft, err := vm.Execute(nil, Byzantium, Call, false, 1, 999, addr, addr, nil, h, nil)

if bytes.Compare(output, []byte("")) != 0 {
t.Errorf("execution unexpected output: %x", output)
Expand Down
4 changes: 2 additions & 2 deletions bindings/go/evmc/host_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,7 @@ func TestGetBlockNumberFromTxContext(t *testing.T) {
host := &testHostContext{}
addr := Address{}
h := Hash{}
output, gasLeft, err := vm.Execute(host, Byzantium, Call, false, 1, 100, addr, addr, nil, h, code, h)
output, gasLeft, err := vm.Execute(host, Byzantium, Call, false, 1, 100, addr, addr, nil, h, code)

if len(output) != 32 {
t.Errorf("unexpected output size: %d", len(output))
Expand Down Expand Up @@ -109,7 +109,7 @@ func TestCall(t *testing.T) {
host := &testHostContext{}
addr := Address{}
h := Hash{}
output, gasLeft, err := vm.Execute(host, Byzantium, Call, false, 1, 100, addr, addr, nil, h, code, h)
output, gasLeft, err := vm.Execute(host, Byzantium, Call, false, 1, 100, addr, addr, nil, h, code)

if len(output) != 34 {
t.Errorf("execution unexpected output length: %d", len(output))
Expand Down
3 changes: 2 additions & 1 deletion include/evmc/evmc.h
Original file line number Diff line number Diff line change
Expand Up @@ -137,7 +137,8 @@ struct evmc_message
/**
* The optional value used in new contract address construction.
*
* Ignored unless kind is EVMC_CREATE2.
* Needed only for a Host to calculate created address when kind is ::EVMC_CREATE2.
* Ignored in evmc_execute_fn().
*/
evmc_bytes32 create2_salt;
};
Expand Down

0 comments on commit 6711434

Please sign in to comment.