Skip to content
This repository has been archived by the owner on Jan 5, 2019. It is now read-only.

Commit

Permalink
Replace special handling of i64 for CALL with a dedicated gasLimit ty…
Browse files Browse the repository at this point in the history
…pe (64bit)
  • Loading branch information
axic committed Jul 30, 2018
1 parent 1a0304f commit ca396be
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 7 deletions.
4 changes: 2 additions & 2 deletions index.js
Original file line number Diff line number Diff line change
Expand Up @@ -38,8 +38,8 @@ const depMap = new Map([
['BLOCKHASH', ['check_overflow', 'callback_256']],
['SHA3', ['memusegas', 'bswap_m256', 'check_overflow', 'keccak']],
['CALL', ['bswap_m256', 'memusegas', 'check_overflow_i64', 'check_overflow', 'memset', 'callback_32']],
['DELEGATECALL', ['callback', 'memusegas', 'check_overflow', 'memset']],
['CALLCODE', ['bswap_m256', 'callback', 'memusegas', 'check_overflow', 'check_overflow_i64', 'memset', 'callback_32']],
['DELEGATECALL', ['callback', 'memusegas', 'check_overflow_i64', 'check_overflow', 'memset']],
['CALLCODE', ['bswap_m256', 'callback', 'memusegas', 'check_overflow_i64', 'check_overflow', 'check_overflow_i64', 'memset', 'callback_32']],
['CREATE', ['bswap_m256', 'bswap_m160', 'callback_160', 'memusegas', 'check_overflow']],
['RETURN', ['memusegas', 'check_overflow']],
['BALANCE', ['bswap_m256', 'callback_128']],
Expand Down
11 changes: 6 additions & 5 deletions wasm/generateInterface.js
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ const wasmTypes = {
length: 'i32',
ipointer: 'i32',
opointer: 'i32',
gasLimit: 'i64',
// FIXME: these are handled wrongly currently
address: 'i32',
i128: 'i32',
Expand Down Expand Up @@ -139,19 +140,19 @@ const interfaceManifest = {
CALL: {
name: 'call',
async: true,
input: ['i64', 'address', 'i128', 'readOffset', 'length'],
input: ['gasLimit', 'address', 'i128', 'readOffset', 'length'],
output: ['i32']
},
CALLCODE: {
name: 'callCode',
async: true,
input: ['i64', 'address', 'i128', 'readOffset', 'length'],
input: ['gasLimit', 'address', 'i128', 'readOffset', 'length'],
output: ['i32']
},
DELEGATECALL: {
name: 'callDelegate',
async: true,
input: ['i32', 'address', 'i128', 'readOffset', 'length', 'writeOffset', 'length'],
input: ['gasLimit', 'address', 'i128', 'readOffset', 'length', 'writeOffset', 'length'],
output: ['i32']
},
SSTORE: {
Expand Down Expand Up @@ -263,7 +264,7 @@ function generateManifest (interfaceManifest, opts) {
// the wasm memory offset is a new item on the EVM stack
spOffset++
call += `(i32.add (get_global $sp) (i32.const ${spOffset * 32}))`
} else if (input === 'i64' && opcode === 'CALL') {
} else if (input === 'gasLimit') {
// i64 param for CALL is the gas
// add 2300 gas subsidy
// for now this only works if the gas is a 64-bit value
Expand All @@ -281,7 +282,7 @@ function generateManifest (interfaceManifest, opts) {
call += checkOverflowStackItem64(spOffset)
} else if (input === 'i32') {
call += checkOverflowStackItem256(spOffset)
} else if (input === 'i64' && opcode !== 'CALL') {
} else if (input === 'i64') {
call += checkOverflowStackItem64(spOffset)
} else if (input === 'writeOffset' || input === 'readOffset') {
lastOffset = input
Expand Down

0 comments on commit ca396be

Please sign in to comment.