mirror of
https://github.com/ethereum/go-ethereum.git
synced 2026-07-27 15:16:43 +00:00
Add function to get deployment code
This commit is contained in:
parent
a98e562ef1
commit
34416a9569
1 changed files with 17 additions and 0 deletions
|
|
@ -530,6 +530,23 @@ func (evm *EVM) CreateWithAddress(caller ContractRef, code []byte, gas uint64, v
|
|||
return evm.create(caller, &codeAndHash{code: code}, gas, value, address, CREATE)
|
||||
}
|
||||
|
||||
func (evm *EVM) GetDeploymentCode(caller ContractRef, code []byte, gas uint64, value *big.Int, address common.Address) ([]byte, error) {
|
||||
contract := NewContract(caller, AccountRef(address), value, gas)
|
||||
contract.SetCodeOptionalHash(&address, &codeAndHash{code: code})
|
||||
|
||||
ret, err := evm.interpreter.Run(contract, nil, false)
|
||||
// Check whether the max code size has been exceeded, assign err if the case.
|
||||
if err == nil && evm.chainRules.IsEIP158 && len(ret) > params.MaxCodeSize {
|
||||
err = ErrMaxCodeSizeExceeded
|
||||
}
|
||||
|
||||
// Reject code starting with 0xEF if EIP-3541 is enabled.
|
||||
if err == nil && len(ret) >= 1 && ret[0] == 0xEF && evm.chainRules.IsLondon {
|
||||
err = ErrInvalidCode
|
||||
}
|
||||
return ret, err
|
||||
}
|
||||
|
||||
// ChainConfig returns the environment's chain configuration
|
||||
func (evm *EVM) ChainConfig() *params.ChainConfig { return evm.chainConfig }
|
||||
|
||||
|
|
|
|||
Loading…
Reference in a new issue