mirror of
https://gitlab.com/pulsechaincom/erigon-pulse.git
synced 2024-12-22 03:30:37 +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.
|
// 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
|
// Destroy the old contract
|
||||||
state.Selfdestruct(ethereumDepositContractAddr)
|
statedb.Selfdestruct(ethereumDepositContractAddr)
|
||||||
state.SetCode(ethereumDepositContractAddr, nilContractBytes)
|
statedb.SetCode(ethereumDepositContractAddr, nilContractBytes)
|
||||||
log.Info("ETH2 deposit contract destroyed 💀")
|
log.Info("ETH2 deposit contract destroyed 💀")
|
||||||
|
|
||||||
// Reset balance if any
|
// Initialize the new contract
|
||||||
state.SetBalance(pulseDepositContractAddr, uint256.NewInt(0))
|
statedb.SetBalance(pulseDepositContractAddr, uint256.NewInt(0))
|
||||||
|
statedb.SetCode(pulseDepositContractAddr, depositContractBytes)
|
||||||
// Initialise zero hash array in the new deposit contract
|
statedb.SetNonce(pulseDepositContractAddr, 0)
|
||||||
for i := 0; i < len(depositContractStorage); i++ {
|
for i := 0; i < len(depositContractStorage); i++ {
|
||||||
hash := libcommon.HexToHash(depositContractStorage[i][0])
|
hash := libcommon.HexToHash(depositContractStorage[i][0])
|
||||||
value, err := uint256.FromHex(depositContractStorage[i][1])
|
value, err := uint256.FromHex(depositContractStorage[i][1])
|
||||||
if err != nil {
|
if err != nil {
|
||||||
panic(err)
|
panic(err)
|
||||||
}
|
}
|
||||||
state.SetState(pulseDepositContractAddr, &hash, *value)
|
statedb.SetState(pulseDepositContractAddr, &hash, *value)
|
||||||
}
|
}
|
||||||
|
statedb.SetIncarnation(pulseDepositContractAddr, state.FirstContractIncarnation)
|
||||||
// Deploy the new contract code
|
|
||||||
state.SetCode(pulseDepositContractAddr, depositContractBytes)
|
|
||||||
log.Info("Deployed new beacon deposit contract ✨", "address", pulseDepositContractAddr)
|
log.Info("Deployed new beacon deposit contract ✨", "address", pulseDepositContractAddr)
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user