| 44 | } |
| 45 | |
| 46 | evmc::Result YulEvmoneUtility::deployCode(bytes const& _input, EVMHost& _host) |
| 47 | { |
| 48 | // Zero initialize all message fields |
| 49 | evmc_message msg = {}; |
| 50 | // Gas available (value of type int64_t) is set to its maximum value |
| 51 | msg.gas = std::numeric_limits<int64_t>::max(); |
| 52 | solAssert( |
| 53 | _input.size() <= 0xffff, |
| 54 | "Deployed byte code is larger than the permissible 65535 bytes." |
| 55 | ); |
| 56 | uint8_t inputSizeHigher = static_cast<uint8_t>(_input.size() >> 8); |
| 57 | uint8_t inputSizeLower = _input.size() & 0xff; |
| 58 | /* |
| 59 | * CODESIZE |
| 60 | * PUSH0 0xc |
| 61 | * PUSH0 0x0 |
| 62 | * CODECOPY |
| 63 | * PUSH1 <INPUTSIZE> |
| 64 | * PUSH0 0x0 |
| 65 | * RETURN |
| 66 | */ |
| 67 | bytes deployCode = bytes{ |
| 68 | 0x38, 0x60, 0x0c, 0x60, 0x00, 0x39, 0x61, |
| 69 | inputSizeHigher, inputSizeLower, |
| 70 | 0x60, 0x00, 0xf3 |
| 71 | } + _input; |
| 72 | msg.input_data = deployCode.data(); |
| 73 | msg.input_size = deployCode.size(); |
| 74 | msg.kind = EVMC_CREATE; |
| 75 | return _host.call(msg); |
| 76 | } |
| 77 | |
| 78 | evmc_message YulEvmoneUtility::callMessage(evmc_address _address) |
| 79 | { |
no test coverage detected