git ssb

0+

wanderer🌟 / js-primea-hypervisor



Commit 553fa6781ed17dced2be7e810acef66344511e72

Kernel: map out callHandler layout

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

Files changed

index.jschanged
index.jsView
@@ -29,8 +29,10 @@
2929 this.environment = environment
3030 }
3131
3232 // handles running code.
33+ // NOTE: it assumes that wasm will raise an exception if something went wrong,
34+ // otherwise execution succeeded
3335 static codeHandler (code, ethInterface = new Interface(new Environment())) {
3436 const debugInterface = new DebugInterface(ethInterface.environment)
3537
3638 const instance = Wasm.instantiateModule(code, {
@@ -76,9 +78,28 @@
7678
7779 // run tx; the tx message handler
7880 runTx (tx, environment = new Environment()) {
7981 // verify tx then send to call Handler
80- this.callHandler(tx, environment)
82+ // - from account has enough balance
83+ // - check nonce
84+ // - ecrecover
85+ // new ethTx(tx).validate(tx)
86+ // - reduce balance
87+
88+ // Contract deployment
89+ const isDeployment = tx.data && !tx.to;
90+ if (isDeployment) {
91+ this.environment.accounts.set(new Uint8Array())
92+ }
93+
94+ var toAccount = this.environment.accounts.get(new Uint8Array(tx.to).toString())
95+ var fromAccount = this.environment.accounts.get(new Uint8Array(tx.form).toString())
96+
97+ if (!toAccount) {
98+ throw new Error('Account not found')
99+ }
100+
101+ this.callHandler(account.codeHash, environment)
81102 }
82103
83104 // run block; the block message handler
84105 runBlock (block, environment = new Environment()) {

Built with git-ssb-web