|
5 | 5 | "math/big" |
6 | 6 |
|
7 | 7 | "github.com/ethereum/go-ethereum/common" |
| 8 | + "github.com/ethereum/go-ethereum/crypto" |
8 | 9 | "github.com/ethereum/go-ethereum/state" |
9 | 10 | "github.com/ethereum/go-ethereum/vm" |
10 | 11 | ) |
@@ -195,9 +196,9 @@ func (self *StateTransition) transitionState() (ret []byte, usedGas *big.Int, er |
195 | 196 | vmenv := self.env |
196 | 197 | var ref vm.ContextRef |
197 | 198 | if MessageCreatesContract(msg) { |
198 | | - //contract := makeContract(msg, self.state) |
199 | | - //addr := contract.Address() |
200 | | - ret, err, ref = vmenv.Create(sender, self.msg.Data(), self.gas, self.gasPrice, self.value) |
| 199 | + contract := makeContract(msg, self.state) |
| 200 | + addr := contract.Address() |
| 201 | + ret, err, ref = vmenv.Create(sender, &addr, self.msg.Data(), self.gas, self.gasPrice, self.value) |
201 | 202 | if err == nil { |
202 | 203 | dataGas := big.NewInt(int64(len(ret))) |
203 | 204 | dataGas.Mul(dataGas, vm.GasCreateByte) |
@@ -243,13 +244,11 @@ func (self *StateTransition) gasUsed() *big.Int { |
243 | 244 |
|
244 | 245 | // Converts an message in to a state object |
245 | 246 | func makeContract(msg Message, state *state.StateDB) *state.StateObject { |
246 | | - /* |
247 | | - addr := AddressFromMessage(msg) |
| 247 | + faddr, _ := msg.From() |
| 248 | + addr := crypto.CreateAddress(faddr, msg.Nonce()) |
248 | 249 |
|
249 | | - contract := state.GetOrNewStateObject(addr) |
250 | | - contract.SetInitCode(msg.Data()) |
| 250 | + contract := state.GetOrNewStateObject(addr) |
| 251 | + contract.SetInitCode(msg.Data()) |
251 | 252 |
|
252 | | - return contract |
253 | | - */ |
254 | | - return nil |
| 253 | + return contract |
255 | 254 | } |
0 commit comments