Skip to content

Commit

Permalink
Add compatibility for new dump (ethereum#239)
Browse files Browse the repository at this point in the history
* add conditional setting

* whitespace
  • Loading branch information
ben-chain authored Mar 2, 2021
1 parent ab5e36c commit 2bc7ae1
Showing 1 changed file with 13 additions and 4 deletions.
17 changes: 13 additions & 4 deletions core/genesis.go
Original file line number Diff line number Diff line change
Expand Up @@ -300,11 +300,20 @@ func ApplyOvmStateToState(statedb *state.StateDB, stateDump *dump.OvmDump, l1XDo
}
OVM_ETH, ok := stateDump.Accounts["OVM_ETH"]
if ok {
// Set the gateway of OVM_ETH
log.Info("Setting OVM_L1ETHGateway in OVM_ETH", "address", l1ETHGatewayAddress.Hex())
l1GatewaySlot := common.HexToHash("0x0000000000000000000000000000000000000000000000000000000000000008")
l1GatewayValue := common.BytesToHash(l1ETHGatewayAddress.Bytes())
statedb.SetState(OVM_ETH.Address, l1GatewaySlot, l1GatewayValue)
if strings.Contains(OVM_ETH.Code, "a84ce98") {
// Set the gateway of OVM_ETH at new dump
log.Info("Detected current OVM_ETH dump, setting slot 0x1 ")
l1GatewaySlot := common.HexToHash("0x0000000000000000000000000000000000000000000000000000000000000001")
l1GatewayValue := common.BytesToHash(l1ETHGatewayAddress.Bytes())
statedb.SetState(OVM_ETH.Address, l1GatewaySlot, l1GatewayValue)
} else {
// Set the gateway of OVM_ETH at legacy slot
log.Info("Detected legacy OVM_ETH dump, setting slot 0x8")
l1GatewaySlot := common.HexToHash("0x0000000000000000000000000000000000000000000000000000000000000008")
l1GatewayValue := common.BytesToHash(l1ETHGatewayAddress.Bytes())
statedb.SetState(OVM_ETH.Address, l1GatewaySlot, l1GatewayValue)
}
}
}

Expand Down

0 comments on commit 2bc7ae1

Please sign in to comment.