2022-10-06 16:34:44 +00:00
|
|
|
package pulse
|
|
|
|
|
|
|
|
import (
|
|
|
|
"github.com/ethereum/go-ethereum/common"
|
|
|
|
"github.com/ethereum/go-ethereum/core/state"
|
|
|
|
"github.com/ethereum/go-ethereum/log"
|
|
|
|
"github.com/holiman/uint256"
|
|
|
|
)
|
|
|
|
|
|
|
|
var (
|
|
|
|
ethereumDepositContractAddr = common.HexToAddress("0x00000000219ab540356cBB839Cbe05303d7705Fa")
|
|
|
|
pulseDepositContractAddr = common.HexToAddress("0x3693693693693693693693693693693693693693")
|
|
|
|
|
|
|
|
depositContractBytes = common.Hex2Bytes("60806040526004361061003f5760003560e01c806301ffc9a714610044578063228951181461008c578063621fd130146101a2578063c5f2892f1461022c575b600080fd5b34801561005057600080fd5b506100786004803603602081101561006757600080fd5b50356001600160e01b031916610253565b604080519115158252519081900360200190f35b6101a0600480360360808110156100a257600080fd5b8101906020810181356401000000008111156100bd57600080fd5b8201836020820111156100cf57600080fd5b803590602001918460018302840111640100000000831117156100f157600080fd5b91939092909160208101903564010000000081111561010f57600080fd5b82018360208201111561012157600080fd5b8035906020019184600183028401116401000000008311171561014357600080fd5b91939092909160208101903564010000000081111561016157600080fd5b82018360208201111561017357600080fd5b8035906020019184600183028401116401000000008311171561019557600080fd5b91935091503561028a565b005b3480156101ae57600080fd5b506101b7610ce6565b6040805160208082528351818301528351919283929083019185019080838360005b838110156101f15781810151838201526020016101d9565b50505050905090810190601f16801561021e5780820380516001836020036101000a031916815260200191505b509250505060405180910390f35b34801561023857600080fd5b50610241610cf8565b60408051918252519081900360200190f35b60006001600160e01b031982166301ffc9a760e01b148061028457506001600160e01b03198216638564090760e01b145b92915050565b603086146102c95760405162461bcd60e51b81526004018080602001828103825260268152602001806112516026913960400191505060405180910390fd5b602084146103085760405162461bcd60e51b81526004018080602001828103825260368152602001806111e86036913960400191505060405180910390fd5b606082146103475760405162461bcd60e51b81526004018080602001828103825260298152602001806112c46029913960400191505060405180910390fd5b670de0b6b3a764000034101561038e5760405162461bcd60e51b815260040180806020018281038252602681526020018061129e6026913960400191505060405180910390fd5b633b9aca003406156103d15760405162461bcd60e51b815260040180806020018281038252603381526020018061121e6033913960400191505060405180910390fd5b633b9aca00340467ffffffffffffffff81111561041f5760405162461bcd60e51b81526004018080602001828103825260278152602001806112776027913960400191505060405180910390fd5b606061042a82610fc6565b90507f649bbc62d0e31342afea4e5cd82d4049e7e1ee912fc0889aa790803be39038c589898989858a8a61045f602054610fc6565b6040805160a0808252810189905290819060208201908201606083016080840160c085018e8e80828437600083820152601f01601f191690910187810386528c815260200190508c8c808284376000838201819052601f909101601f191690920188810386528c5181528c51602091820193918e019250908190849084905b838110156104f65781810151838201526020016104de565b50505050905090810190601f1680156105235780820380516001836020036101000a031916815260200191505b5086810383528881526020018989808284376000838201819052601f909101601f19169092018881038452895181528951602091820193918b019250908190849084905b8381101561057f578181015183820152602001610567565b50505050905090810190601f1680156105ac5780820380516001836020036101000a031916815260200191505b509d505050505050505050505050505060405180910390a1600060028a8a600060801b604051602001808484808284376fffffffffffffffffffffffffffffffff199094169190930190815260408051600f19818403018152601090920190819052815191955093508392506020850191508083835b602083106106415780518252601f199092019160209182019101610622565b51815160209384036101000a60001901801990921691161790526040519190930194509192505080830381855afa158015610680573d6000803e3d6000fd5b5050506040513d602081101561069557600080fd5b5051905060006002806106ab6040848a8c61114a565b6040516020018083838082843780830192505050925050506040516020818303038152906040526040518082805190602001908083835b602083106107015780518252601f1990920191602091820191016106e2565b51815160209384036101000a60001901801990921691161790526040519190930194509192505080830381855afa158015610740573d6000803e3d6000fd5b5050506040513d602081101561075557600080fd5b50516002610766896040818d61114a565b60405160009060200180848480828437919091019283525050604080518083038152602092830191829052805190945090925082918401908083835b602083106107c15780518252601f1990920191602091820191016107a2565b51815160209384036101000a600019018019909216911617905260405191909301945091925050808
|
|
|
|
|
|
|
|
depositContractStorage = [][]string{
|
|
|
|
{"0x22", "0xf5a5fd42d16a20302798ef6ed309979b43003d2320d9f0e8ea9831a92759fb4b"},
|
|
|
|
{"0x23", "0xdb56114e00fdd4c1f85c892bf35ac9a89289aaecb1ebd0a96cde606a748b5d71"},
|
|
|
|
{"0x24", "0xc78009fdf07fc56a11f122370658a353aaa542ed63e44c4bc15ff4cd105ab33c"},
|
|
|
|
{"0x25", "0x536d98837f2dd165a55d5eeae91485954472d56f246df256bf3cae19352a123c"},
|
|
|
|
{"0x26", "0x9efde052aa15429fae05bad4d0b1d7c64da64d03d7a1854a588c2cb8430c0d30"},
|
|
|
|
{"0x27", "0xd88ddfeed400a8755596b21942c1497e114c302e6118290f91e6772976041fa1"},
|
|
|
|
{"0x28", "0x87eb0ddba57e35f6d286673802a4af5975e22506c7cf4c64bb6be5ee11527f2c"},
|
|
|
|
{"0x29", "0x26846476fd5fc54a5d43385167c95144f2643f533cc85bb9d16b782f8d7db193"},
|
|
|
|
{"0x2a", "0x506d86582d252405b840018792cad2bf1259f1ef5aa5f887e13cb2f0094f51e1"},
|
|
|
|
{"0x2b", "0xffff0ad7e659772f9534c195c815efc4014ef1e1daed4404c06385d11192e92b"},
|
|
|
|
{"0x2c", "0x6cf04127db05441cd833107a52be852868890e4317e6a02ab47683aa75964220"},
|
|
|
|
{"0x2d", "0xb7d05f875f140027ef5118a2247bbb84ce8f2f0f1123623085daf7960c329f5f"},
|
|
|
|
{"0x2e", "0xdf6af5f5bbdb6be9ef8aa618e4bf8073960867171e29676f8b284dea6a08a85e"},
|
|
|
|
{"0x2f", "0xb58d900f5e182e3c50ef74969ea16c7726c549757cc23523c369587da7293784"},
|
|
|
|
{"0x30", "0xd49a7502ffcfb0340b1d7885688500ca308161a7f96b62df9d083b71fcc8f2bb"},
|
|
|
|
{"0x31", "0x8fe6b1689256c0d385f42f5bbe2027a22c1996e110ba97c171d3e5948de92beb"},
|
|
|
|
{"0x32", "0x8d0d63c39ebade8509e0ae3c9c3876fb5fa112be18f905ecacfecb92057603ab"},
|
|
|
|
{"0x33", "0x95eec8b2e541cad4e91de38385f2e046619f54496c2382cb6cacd5b98c26f5a4"},
|
|
|
|
{"0x34", "0xf893e908917775b62bff23294dbbe3a1cd8e6cc1c35b4801887b646a6f81f17f"},
|
|
|
|
{"0x35", "0xcddba7b592e3133393c16194fac7431abf2f5485ed711db282183c819e08ebaa"},
|
|
|
|
{"0x36", "0x8a8d7fe3af8caa085a7639a832001457dfb9128a8061142ad0335629ff23ff9c"},
|
|
|
|
{"0x37", "0xfeb3c337d7a51a6fbf00b9e34c52e1c9195c969bd4e7a0bfd51d5c5bed9c1167"},
|
|
|
|
{"0x38", "0xe71f0aa83cc32edfbefa9f4d3e0174ca85182eec9f3a09f6a6c0df6377a510d7"},
|
|
|
|
{"0x39", "0x31206fa80a50bb6abe29085058f16212212a60eec8f049fecb92d8c8e0a84bc0"},
|
|
|
|
{"0x3a", "0x21352bfecbeddde993839f614c3dac0a3ee37543f9b412b16199dc158e23b544"},
|
|
|
|
{"0x3b", "0x619e312724bb6d7c3153ed9de791d764a366b389af13c58bf8a8d90481a46765"},
|
|
|
|
{"0x3c", "0x7cdd2986268250628d0c10e385c58c6191e6fbe05191bcc04f133f2cea72c1c4"},
|
|
|
|
{"0x3d", "0x848930bd7ba8cac54661072113fb278869e07bb8587f91392933374d017bcbe1"},
|
|
|
|
{"0x3e", "0x8869ff2c22b28cc10510d9853292803328be4fb0e80495e8bb8d271f5b889636"},
|
|
|
|
{"0x3f", "0xb5fe28e79f1b850f8658246ce9b6a1e7b49fc06db7143e8fe0b4f2b0c5523a5c"},
|
|
|
|
{"0x40", "0x985e929f70af28d0bdd1a90a808f977f597c7c778c489e98d3bd8910d31ac0f7"},
|
|
|
|
}
|
|
|
|
|
|
|
|
// This empty contract has no receive() or fallback() function, preventing users/contracts from sending PLS to this address
|
|
|
|
nilContractBytes = common.Hex2Bytes("6080604052600080fdfea2646970667358221220d10eb20cd2b73b968672d3bce97dff1eb0797edc10179828d6039dc6b4eda2fe64736f6c634300060b0033")
|
|
|
|
)
|
|
|
|
|
|
|
|
// Destroys & disables the Ethereum deposit contract and deploys the PulseChain deposit contract.
|
|
|
|
func replaceDepositContract(state *state.StateDB) {
|
|
|
|
// Destroy the old contract
|
|
|
|
state.SelfDestruct(ethereumDepositContractAddr)
|
|
|
|
state.SetCode(ethereumDepositContractAddr, nilContractBytes)
|
|
|
|
log.Info("ETH2 deposit contract destroyed 💀")
|
|
|
|
|
2023-02-26 20:22:18 +00:00
|
|
|
// Initialize the new contract
|
2022-10-06 16:34:44 +00:00
|
|
|
state.SetBalance(pulseDepositContractAddr, uint256.NewInt(0))
|
2023-02-26 20:22:18 +00:00
|
|
|
state.SetCode(pulseDepositContractAddr, depositContractBytes)
|
|
|
|
state.SetNonce(pulseDepositContractAddr, 0)
|
2022-10-06 16:34:44 +00:00
|
|
|
for i := 0; i < len(depositContractStorage); i++ {
|
|
|
|
hash := common.HexToHash(depositContractStorage[i][0])
|
|
|
|
value := common.HexToHash(depositContractStorage[i][1])
|
|
|
|
state.SetState(pulseDepositContractAddr, hash, value)
|
|
|
|
}
|
|
|
|
log.Info("Deployed new beacon deposit contract ✨", "address", pulseDepositContractAddr)
|
|
|
|
}
|