git ssb

0+

wanderer🌟 / js-primea-hypervisor



Commit 20390909a4485d06cd4a720d5f69fc9deca7a9b3

Kernel: pass the correct details to callHandler from runTx

Alex Beregszaszi committed on 8/23/2016, 12:27:46 AM
Parent: 4c7c54ec09858f22c767210f0814625380b32c55

Files changed

index.jschanged
index.jsView
@@ -63,10 +63,10 @@
6363 // loads code from the merkle trie and delegates the message
6464 // Detects if code is EVM or WASM
6565 // Detects if the code injection is needed
6666 // Detects if transcompilation is needed
67- callHandler (address, gaslimit, gasprice, value, data) {
68- let account = this.environment.state.get(address.toString())
67+ callHandler (call) {
68+ let account = this.environment.state.get(call.to.toString())
6969 if (!account) {
7070 throw new Error('Account not found')
7171 }
7272
@@ -79,11 +79,21 @@
7979 throw new Error('Not an eWASM contract')
8080 }
8181
8282 // creats a new Kernel
83- const environment = new Environment(data)
83+ const environment = new Environment()
8484 environment.parent = this
8585
86+ // copy the transaction details
87+ environment.code = code
88+ environment.address = call.to
89+ // FIXME: make distinction between origin and caller
90+ environment.origin = call.from
91+ environment.caller = call.from
92+ environment.callData = call.data
93+ environment.callValue = call.value
94+ environment.gasLimit = call.gasLimit
95+
8696 //environment.setCallHandler(callHandler)
8797
8898 const kernel = new Kernel(this, environment)
8999 kernel.codeHandler(code, new Interface(environment))
@@ -159,9 +169,15 @@
159169 }
160170
161171 fromAccount.set('balance', fromAccount.get('balance').sub(tx.gasLimit.mul(tx.gasPrice)))
162172
163- let ret = this.callHandler(tx.to, tx.gasLimit, tx.gasPrice, tx.value, tx.data)
173+ let ret = this.callHandler({
174+ to: tx.to,
175+ from: tx.from,
176+ gasLimit: tx.gasLimit,
177+ value: tx.value,
178+ data: tx.data
179+ })
164180
165181 // refund gas
166182 if (ret.executionOutcome === 1) {
167183 fromAccount.set('balance', fromAccount.get('balance').add(tx.gasPrice.mul(ret.gasLeft.add(ret.gasRefund))))

Built with git-ssb-web