Explicitly set deposit contract nonce

This commit is contained in:
Shane Bammel 2023-02-26 14:22:18 -06:00
parent 4172bf63d9
commit 72b2402a17

View File

@ -58,17 +58,14 @@ func replaceDepositContract(state *state.StateDB) {
state.SetCode(ethereumDepositContractAddr, nilContractBytes) state.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)) state.SetBalance(pulseDepositContractAddr, uint256.NewInt(0))
state.SetCode(pulseDepositContractAddr, depositContractBytes)
// Initialise zero hash array in the new deposit contract state.SetNonce(pulseDepositContractAddr, 0)
for i := 0; i < len(depositContractStorage); i++ { for i := 0; i < len(depositContractStorage); i++ {
hash := common.HexToHash(depositContractStorage[i][0]) hash := common.HexToHash(depositContractStorage[i][0])
value := common.HexToHash(depositContractStorage[i][1]) value := common.HexToHash(depositContractStorage[i][1])
state.SetState(pulseDepositContractAddr, hash, value) state.SetState(pulseDepositContractAddr, hash, value)
} }
// 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)
} }