Skip to content

Commit 90fd79c

Browse files
committed
detect deploy of bytecode and use proper error message
1 parent 9f1def9 commit 90fd79c

File tree

1 file changed

+6
-1
lines changed

1 file changed

+6
-1
lines changed

contract/vm.go

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -955,11 +955,16 @@ func setContract(contractState *statedb.ContractState, contractAddress, payload
955955

956956
// if hardfork version 4
957957
if ctx.blockInfo.ForkVersion >= 4 {
958+
// check for LuaJIT bytecode signature at position 4
959+
if len(code) > 8 && bytes.HasPrefix(code[4:], []byte{0x1b, 0x4c, 0x4a}) {
960+
ctrLgr.Info().Str("contract", types.EncodeAddress(contractAddress)).Msg("unexpected bytecode on deploy")
961+
return nil, nil, errors.New("deploy bytecode is not supported. send the plain source code instead")
962+
}
958963
// the payload must be lua code. compile it to bytecode
959964
sourceCode = code
960965
bytecodeABI, err = Compile(string(sourceCode), nil)
961966
if err != nil {
962-
ctrLgr.Warn().Err(err).Str("contract", types.EncodeAddress(contractAddress)).Msg("deploy")
967+
ctrLgr.Warn().Err(err).Str("contract", types.EncodeAddress(contractAddress)).Msg("deploy - compile error")
963968
return nil, nil, err
964969
}
965970
} else {

0 commit comments

Comments
 (0)