Commit 51739ba9fc171bb7d0f5e1bfee7b9021587cdede
fix lint
wanderer committed on 11/22/2016, 2:20:55 AMParent: 59cc2a5d79adce2a9ce41c522b086bee196c3cc7
Files changed
EVMinterface.js | changed |
package.json | changed |
precompiles/create.js | changed |
runBlock.js | changed |
runTx.js | changed |
EVMinterface.js | ||
---|---|---|
@@ -429,11 +429,11 @@ | ||
429 | 429 | create (valueOffset, dataOffset, length, resultOffset, cbIndex) { |
430 | 430 | this.takeGas(32000) |
431 | 431 | |
432 | 432 | const value = U256.fromMemory(this.getMemory(valueOffset, U128_SIZE_BYTES)) |
433 | - if (length) { | |
434 | - const code = this.getMemory(dataOffset, length).slice(0) | |
435 | - } | |
433 | + // if (length) { | |
434 | + // const code = this.getMemory(dataOffset, length).slice(0) | |
435 | + // } | |
436 | 436 | |
437 | 437 | let opPromise |
438 | 438 | |
439 | 439 | if (value.gt(this.kernel.environment.value)) { |
package.json | ||
---|---|---|
@@ -24,9 +24,9 @@ | ||
24 | 24 | "author": "mjbecze <mjbecze@gmail.com>", |
25 | 25 | "contributors": "Alex Beregszaszi <alex@rtfs.hu>", |
26 | 26 | "license": "MPL-2.0", |
27 | 27 | "devDependencies": { |
28 | - "standard": "^8.5.0", | |
28 | + "standard": "*", | |
29 | 29 | "tape": "^4.5.1" |
30 | 30 | }, |
31 | 31 | "standard": { |
32 | 32 | "ignore": [ |
precompiles/create.js | ||
---|---|---|
@@ -1,55 +1,55 @@ | ||
1 | - createHandler (create) { | |
2 | - let code = create.data | |
1 | + // createHandler (create) { | |
2 | + // let code = create.data | |
3 | 3 | |
4 | - // Inject metering | |
5 | - if (Utils.isWASMCode(code)) { | |
6 | - // FIXME: decide if these are the right values here: from: 0, gasLimit: 0, value: 0 | |
7 | - code = this.callHandler({ | |
8 | - from: Address.zero(), | |
9 | - to: meteringContract, | |
10 | - gasLimit: 0, | |
11 | - value: new U256(0), | |
12 | - data: code | |
13 | - }).returnValue | |
4 | + // // Inject metering | |
5 | + // if (Utils.isWASMCode(code)) { | |
6 | + // // FIXME: decide if these are the right values here: from: 0, gasLimit: 0, value: 0 | |
7 | + // code = this.callHandler({ | |
8 | + // from: Address.zero(), | |
9 | + // to: meteringContract, | |
10 | + // gasLimit: 0, | |
11 | + // value: new U256(0), | |
12 | + // data: code | |
13 | + // }).returnValue | |
14 | 14 | |
15 | - if (code[0] === 0) { | |
16 | - code = code.slice(1) | |
17 | - } else { | |
18 | - throw new Error('Metering injection failed: ' + Buffer.from(code).slice(1).toString()) | |
19 | - } | |
20 | - } | |
15 | + // if (code[0] === 0) { | |
16 | + // code = code.slice(1) | |
17 | + // } else { | |
18 | + // throw new Error('Metering injection failed: ' + Buffer.from(code).slice(1).toString()) | |
19 | + // } | |
20 | + // } | |
21 | 21 | |
22 | - let account = this.environment.state.get(create.from.toString()) | |
23 | - if (!account) { | |
24 | - throw new Error('Account not found: ' + create.from.toString()) | |
25 | - } | |
22 | + // let account = this.environment.state.get(create.from.toString()) | |
23 | + // if (!account) { | |
24 | + // throw new Error('Account not found: ' + create.from.toString()) | |
25 | + // } | |
26 | 26 | |
27 | - let address = Utils.newAccountAddress(create.from, account.get('nonce')) | |
27 | + // let address = Utils.newAccountAddress(create.from, account.get('nonce')) | |
28 | 28 | |
29 | - this.environment.addAccount(address.toString(), { | |
30 | - balance: create.value, | |
31 | - code: code | |
32 | - }) | |
29 | + // this.environment.addAccount(address.toString(), { | |
30 | + // balance: create.value, | |
31 | + // code: code | |
32 | + // }) | |
33 | 33 | |
34 | - // Run code and take return value as contract code | |
35 | - // FIXME: decide if these are the right values here: value: 0, data: '' | |
36 | - code = this.messageHandler({ | |
37 | - from: create.from, | |
38 | - to: address, | |
39 | - gasLimit: create.gasLimit, | |
40 | - value: new U256(0), | |
41 | - data: new Uint8Array() | |
42 | - }).returnValue | |
34 | + // // Run code and take return value as contract code | |
35 | + // // FIXME: decide if these are the right values here: value: 0, data: '' | |
36 | + // code = this.messageHandler({ | |
37 | + // from: create.from, | |
38 | + // to: address, | |
39 | + // gasLimit: create.gasLimit, | |
40 | + // value: new U256(0), | |
41 | + // data: new Uint8Array() | |
42 | + // }).returnValue | |
43 | 43 | |
44 | - // FIXME: special handling for selfdestruct | |
44 | + // // FIXME: special handling for selfdestruct | |
45 | 45 | |
46 | - this.environment.state.get(address.toString()).set('code', code) | |
46 | + // this.environment.state.get(address.toString()).set('code', code) | |
47 | 47 | |
48 | - return { | |
49 | - executionOutcome: 1, // success | |
50 | - gasLeft: new U256(this.environment.gasLeft), | |
51 | - gasRefund: new U256(this.environment.gasRefund), | |
52 | - accountCreated: address, | |
53 | - logs: this.environment.logs | |
54 | - } | |
55 | - } | |
48 | + // return { | |
49 | + // executionOutcome: 1, // success | |
50 | + // gasLeft: new U256(this.environment.gasLeft), | |
51 | + // gasRefund: new U256(this.environment.gasRefund), | |
52 | + // accountCreated: address, | |
53 | + // logs: this.environment.logs | |
54 | + // } | |
55 | + // } |
runBlock.js | ||
---|---|---|
@@ -1,10 +1,11 @@ | ||
1 | - // run block; the block message handler | |
2 | - runBlock(block, environment = new Environment()) { | |
1 | +// run block; the block message handler:w | |
2 | +const Environment = require('./environment') | |
3 | + | |
4 | +module.exports = class runBlock { | |
5 | + constuctor (block, environment = new Environment()) { | |
3 | 6 | // verify block then run each tx |
4 | 7 | block.tx.forEach((tx) => { |
5 | 8 | this.runTx(tx, environment) |
6 | 9 | }) |
7 | 10 | } |
8 | - | |
9 | - // run blockchain | |
10 | - // runBlockchain () {} | |
11 | +} |
runTx.js | ||
---|---|---|
@@ -1,77 +1,77 @@ | ||
1 | 1 | |
2 | 2 | // run tx; the tx message handler |
3 | - runTx (tx, environment = new Environment()) { | |
4 | - this.environment = environment | |
3 | + // runTx (tx, environment = new Environment()) { | |
4 | + // this.environment = environment | |
5 | 5 | |
6 | - if (Buffer.isBuffer(tx) || typeof tx === 'string') { | |
7 | - tx = new Transaction(tx) | |
8 | - if (!tx.valid) { | |
9 | - throw new Error('Invalid transaction signature') | |
10 | - } | |
11 | - } | |
6 | + // if (Buffer.isBuffer(tx) || typeof tx === 'string') { | |
7 | + // tx = new Transaction(tx) | |
8 | + // if (!tx.valid) { | |
9 | + // throw new Error('Invalid transaction signature') | |
10 | + // } | |
11 | + // } | |
12 | 12 | |
13 | - // look up sender | |
14 | - let fromAccount = this.environment.state.get(tx.from.toString()) | |
15 | - if (!fromAccount) { | |
16 | - throw new Error('Sender account not found: ' + tx.from.toString()) | |
17 | - } | |
13 | + // // look up sender | |
14 | + // let fromAccount = this.environment.state.get(tx.from.toString()) | |
15 | + // if (!fromAccount) { | |
16 | + // throw new Error('Sender account not found: ' + tx.from.toString()) | |
17 | + // } | |
18 | 18 | |
19 | - if (fromAccount.get('nonce').gt(tx.nonce)) { | |
20 | - throw new Error(`Invalid nonce: ${fromAccount.get('nonce')} > ${tx.nonce}`) | |
21 | - } | |
19 | + // if (fromAccount.get('nonce').gt(tx.nonce)) { | |
20 | + // throw new Error(`Invalid nonce: ${fromAccount.get('nonce')} > ${tx.nonce}`) | |
21 | + // } | |
22 | 22 | |
23 | - fromAccount.set('nonce', fromAccount.get('nonce').add(new U256(1))) | |
23 | + // fromAccount.set('nonce', fromAccount.get('nonce').add(new U256(1))) | |
24 | 24 | |
25 | - let isCreation = false | |
25 | + // let isCreation = false | |
26 | 26 | |
27 | - // Special case: contract deployment | |
28 | - if (tx.to.isZero() && (tx.data.length !== 0)) { | |
29 | - console.log('This is a contract deployment transaction') | |
30 | - isCreation = true | |
31 | - } | |
27 | + // // Special case: contract deployment | |
28 | + // if (tx.to.isZero() && (tx.data.length !== 0)) { | |
29 | + // console.log('This is a contract deployment transaction') | |
30 | + // isCreation = true | |
31 | + // } | |
32 | 32 | |
33 | - // This cost will not be refunded | |
34 | - let txCost = 21000 + (isCreation ? 32000 : 0) | |
35 | - tx.data.forEach((item) => { | |
36 | - if (item === 0) { | |
37 | - txCost += 4 | |
38 | - } else { | |
39 | - txCost += 68 | |
40 | - } | |
41 | - }) | |
33 | + // // This cost will not be refunded | |
34 | + // let txCost = 21000 + (isCreation ? 32000 : 0) | |
35 | + // tx.data.forEach((item) => { | |
36 | + // if (item === 0) { | |
37 | + // txCost += 4 | |
38 | + // } else { | |
39 | + // txCost += 68 | |
40 | + // } | |
41 | + // }) | |
42 | 42 | |
43 | - if (tx.gasLimit.lt(new U256(txCost))) { | |
44 | - throw new Error(`Minimum transaction gas limit not met: ${txCost}`) | |
45 | - } | |
43 | + // if (tx.gasLimit.lt(new U256(txCost))) { | |
44 | + // throw new Error(`Minimum transaction gas limit not met: ${txCost}`) | |
45 | + // } | |
46 | 46 | |
47 | - if (fromAccount.get('balance').lt(tx.gasLimit.mul(tx.gasPrice))) { | |
48 | - throw new Error(`Insufficient account balance: ${fromAccount.get('balance').toString()} < ${tx.gasLimit.mul(tx.gasPrice).toString()}`) | |
49 | - } | |
47 | + // if (fromAccount.get('balance').lt(tx.gasLimit.mul(tx.gasPrice))) { | |
48 | + // throw new Error(`Insufficient account balance: ${fromAccount.get('balance').toString()} < ${tx.gasLimit.mul(tx.gasPrice).toString()}`) | |
49 | + // } | |
50 | 50 | |
51 | - // deduct gasLimit * gasPrice from sender | |
52 | - fromAccount.set('balance', fromAccount.get('balance').sub(tx.gasLimit.mul(tx.gasPrice))) | |
51 | + // // deduct gasLimit * gasPrice from sender | |
52 | + // fromAccount.set('balance', fromAccount.get('balance').sub(tx.gasLimit.mul(tx.gasPrice))) | |
53 | 53 | |
54 | - const handler = isCreation ? this.createHandler.bind(this) : this.callHandler.bind(this) | |
55 | - let ret = handler({ | |
56 | - to: tx.to, | |
57 | - from: tx.from, | |
58 | - gasLimit: tx.gasLimit - txCost, | |
59 | - value: tx.value, | |
60 | - data: tx.data | |
61 | - }) | |
54 | + // const handler = isCreation ? this.createHandler.bind(this) : this.callHandler.bind(this) | |
55 | + // let ret = handler({ | |
56 | + // to: tx.to, | |
57 | + // from: tx.from, | |
58 | + // gasLimit: tx.gasLimit - txCost, | |
59 | + // value: tx.value, | |
60 | + // data: tx.data | |
61 | + // }) | |
62 | 62 | |
63 | - // refund unused gas | |
64 | - if (ret.executionOutcome === 1) { | |
65 | - fromAccount.set('balance', fromAccount.get('balance').add(tx.gasPrice.mul(ret.gasLeft.add(ret.gasRefund)))) | |
66 | - } | |
63 | + // // refund unused gas | |
64 | + // if (ret.executionOutcome === 1) { | |
65 | + // fromAccount.set('balance', fromAccount.get('balance').add(tx.gasPrice.mul(ret.gasLeft.add(ret.gasRefund)))) | |
66 | + // } | |
67 | 67 | |
68 | - // save new state? | |
68 | + // // save new state? | |
69 | 69 | |
70 | - return { | |
71 | - executionOutcome: ret.executionOutcome, | |
72 | - accountCreated: isCreation ? ret.accountCreated : undefined, | |
73 | - returnValue: isCreation ? undefined : ret.returnValue, | |
74 | - gasLeft: ret.gasLeft, | |
75 | - logs: ret.logs | |
76 | - } | |
77 | - } | |
70 | + // return { | |
71 | + // executionOutcome: ret.executionOutcome, | |
72 | + // accountCreated: isCreation ? ret.accountCreated : undefined, | |
73 | + // returnValue: isCreation ? undefined : ret.returnValue, | |
74 | + // gasLeft: ret.gasLeft, | |
75 | + // logs: ret.logs | |
76 | + // } | |
77 | + // } |
Built with git-ssb-web