git ssb

0+

wanderer🌟 / js-primea-hypervisor



Commit e7e36382dc9e3373aad516a7c37df5e4fa7554a6

Kernel: use Frontier-style address generation for accounts

Alex Beregszaszi committed on 8/26/2016, 11:41:38 PM
Parent: 3cb8a54180de3ba70e81bfebcd2e944557d99715

Files changed

index.jschanged
utils.jschanged
index.jsView
@@ -134,10 +134,15 @@
134134 // FIXME: decide if these are the right values here: from: 0, gasLimit: 0, value: 0
135135 code = this.callHandler({ from: Address.zero(), to: meteringContract, gasLimit: 0, value: new U256(0), data: code }).returnValue
136136 }
137137
138- let address = Utils.newAccountAddress(create.from, code)
138+ let account = this.environment.state.get(create.from.toString())
139+ if (!account) {
140+ throw new Error('Account not found: ' + create.from.toString())
141+ }
139142
143+ let address = Utils.newAccountAddress(create.from, account.get('nonce'))
144+
140145 this.environment.addAccount(address.toString(), {
141146 balance: create.value,
142147 code: code
143148 })
utils.jsView
@@ -6,9 +6,9 @@
66 Utils.isWASMCode = function (code) {
77 return code.slice(0, 4).toString() === new Uint8Array([0, 0x61, 0x73, 0x6d]).toString()
88 }
99
10-Utils.newAccountAddress = function (sender, data) {
11- return new Address('0x' + ethUtil.sha3(Buffer.concat([ sender.toBuffer(), Buffer.from(data) ])).slice(0, 20).toString('hex'))
10+Utils.newAccountAddress = function (sender, nonce) {
11+ return new Address('0x' + ethUtil.generateAddress(sender.toString(), nonce.toString()).toString('hex'))
1212 }
1313
1414 module.exports = Utils

Built with git-ssb-web