Skip to content
This repository has been archived by the owner on May 13, 2022. It is now read-only.

Implementing INVALID opcode #757

Merged
merged 1 commit into from
May 8, 2018
Merged

Implementing INVALID opcode #757

merged 1 commit into from
May 8, 2018

Conversation

smblucker
Copy link

These changes implement the invalid opcode; these changes attempt to resolve issue here:

#601

Copy link
Contributor

@silasdavis silasdavis left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good other than comments made

@@ -48,6 +48,7 @@ var (
ErrDataStackUnderflow = errors.New("Data stack underflow")
ErrInvalidContract = errors.New("Invalid contract")
ErrNativeContractCodeCopy = errors.New("Tried to copy native contract code")
ErrInvalidOpcode = errors.New("Invalid opcode")
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This has the potential to read as 'an opcode we don't know about', when it means 'abort the execution'. I'd be tempted to suggest: ErrExecutionAborted = errors.New("Execution aborted").

0x00, 0x00, 0x00, PUSH1, 0x00, MSTORE, PUSH1, 0x0E, PUSH1, 0x00, INVALID)

output, err := ourVm.Call(account1, account2, bytecode, []byte{}, 0, &gas)
assert.Error(t, err, "Expected invalid opcode error")
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Let's assert.Equal(t, ErrInvalidOpcode, err) here seeing as we have declared error values.

@silasdavis
Copy link
Contributor

Could you also try rebasing on develop I have a feeling that might be cause of integration test failures.

@@ -1078,8 +1082,8 @@ func (vm *VM) call(caller acm.Account, callee acm.MutableAccount, code, input []
case STATICCALL, SHL, SHR, SAR, RETURNDATASIZE, RETURNDATACOPY:
return nil, fmt.Errorf("%s not yet implemented", op.Name())
default:
vm.Debugf("(pc) %-3v Invalid opcode %X\n", pc, op)
return nil, fmt.Errorf("invalid opcode %X", op)
vm.Debugf("(pc) %-3v Unknown opcode %X\n", pc, op)
Copy link
Contributor

@silasdavis silasdavis May 8, 2018

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

👍 I prefer 'unknown' here

@smblucker
Copy link
Author

@silasdavis Should I always be rebasing against develop? For the other opcodes, I have been rebasing against new-opcodes2 without any issues.

@silasdavis silasdavis changed the base branch from new-opcodes2 to develop May 8, 2018 21:50
@silasdavis
Copy link
Contributor

I didn't realise your merge base was a feature branch here. I've re-merge-based this to develop and this is now good to go. We'll need to make sure we merge changes on newopcodes-* to develop.

@silasdavis silasdavis merged commit 8cf2080 into hyperledger-archives:develop May 8, 2018
@smblucker smblucker deleted the invalid-opcode-issue601 branch May 9, 2018 14:00
silasdavis pushed a commit to silasdavis/burrow that referenced this pull request Mar 9, 2019
…code-issue601

Implementing INVALID opcode
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Development

Successfully merging this pull request may close these issues.

2 participants