mirror of
https://gitlab.com/pulsechaincom/erigon-pulse.git
synced 2024-12-21 19:20:39 +00:00
Fix deposit contract initialization
Erigon requires setting the contract incarnation
This commit is contained in:
parent
75db06fa1d
commit
000c914d82
@ -53,26 +53,24 @@ var (
|
||||
)
|
||||
|
||||
// Destroys & disables the Ethereum deposit contract and deploys the PulseChain deposit contract.
|
||||
func replaceDepositContract(state *state.IntraBlockState) {
|
||||
func replaceDepositContract(statedb *state.IntraBlockState) {
|
||||
// Destroy the old contract
|
||||
state.Selfdestruct(ethereumDepositContractAddr)
|
||||
state.SetCode(ethereumDepositContractAddr, nilContractBytes)
|
||||
statedb.Selfdestruct(ethereumDepositContractAddr)
|
||||
statedb.SetCode(ethereumDepositContractAddr, nilContractBytes)
|
||||
log.Info("ETH2 deposit contract destroyed 💀")
|
||||
|
||||
// Reset balance if any
|
||||
state.SetBalance(pulseDepositContractAddr, uint256.NewInt(0))
|
||||
|
||||
// Initialise zero hash array in the new deposit contract
|
||||
// Initialize the new contract
|
||||
statedb.SetBalance(pulseDepositContractAddr, uint256.NewInt(0))
|
||||
statedb.SetCode(pulseDepositContractAddr, depositContractBytes)
|
||||
statedb.SetNonce(pulseDepositContractAddr, 0)
|
||||
for i := 0; i < len(depositContractStorage); i++ {
|
||||
hash := libcommon.HexToHash(depositContractStorage[i][0])
|
||||
value, err := uint256.FromHex(depositContractStorage[i][1])
|
||||
if err != nil {
|
||||
panic(err)
|
||||
}
|
||||
state.SetState(pulseDepositContractAddr, &hash, *value)
|
||||
statedb.SetState(pulseDepositContractAddr, &hash, *value)
|
||||
}
|
||||
|
||||
// Deploy the new contract code
|
||||
state.SetCode(pulseDepositContractAddr, depositContractBytes)
|
||||
statedb.SetIncarnation(pulseDepositContractAddr, state.FirstContractIncarnation)
|
||||
log.Info("Deployed new beacon deposit contract ✨", "address", pulseDepositContractAddr)
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user