aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJeffrey Wilcke <jeffrey@ethereum.org>2016-11-11 17:23:30 +0800
committerJeffrey Wilcke <jeffrey@ethereum.org>2016-11-14 06:26:10 +0800
commit0231d8f86dd1c12a4e308b4f120a89254dc2d02d (patch)
treeb5c2d1cc395e0ccb5737e38d1c3118cc1b5fa3d8
parenta91908e5678397a466060aa614081974a4a36455 (diff)
downloaddexon-0231d8f86dd1c12a4e308b4f120a89254dc2d02d.tar
dexon-0231d8f86dd1c12a4e308b4f120a89254dc2d02d.tar.gz
dexon-0231d8f86dd1c12a4e308b4f120a89254dc2d02d.tar.bz2
dexon-0231d8f86dd1c12a4e308b4f120a89254dc2d02d.tar.lz
dexon-0231d8f86dd1c12a4e308b4f120a89254dc2d02d.tar.xz
dexon-0231d8f86dd1c12a4e308b4f120a89254dc2d02d.tar.zst
dexon-0231d8f86dd1c12a4e308b4f120a89254dc2d02d.zip
core, params: EIP#170
-rw-r--r--core/execution.go8
-rw-r--r--params/protocol_params.go4
2 files changed, 6 insertions, 6 deletions
diff --git a/core/execution.go b/core/execution.go
index 576e05851..e3ea1006c 100644
--- a/core/execution.go
+++ b/core/execution.go
@@ -150,11 +150,13 @@ func Create(env vm.Environment, caller vm.ContractRef, code []byte, gas, gasPric
defer contract.Finalise()
ret, err = env.Vm().Run(contract, nil)
+ // check whether the max code size has been exceeded
+ maxCodeSizeExceeded := len(ret) > params.MaxCodeSize
// if the contract creation ran successfully and no errors were returned
// calculate the gas required to store the code. If the code could not
// be stored due to not enough gas set an error and let it be handled
// by the error checking condition below.
- if err == nil {
+ if err == nil && !maxCodeSizeExceeded {
dataGas := big.NewInt(int64(len(ret)))
dataGas.Mul(dataGas, params.CreateDataGas)
if contract.UseGas(dataGas) {
@@ -167,9 +169,9 @@ func Create(env vm.Environment, caller vm.ContractRef, code []byte, gas, gasPric
// When an error was returned by the EVM or when setting the creation code
// above we revert to the snapshot and consume any gas remaining. Additionally
// when we're in homestead this also counts for code storage gas errors.
- if err != nil && (env.ChainConfig().IsHomestead(env.BlockNumber()) || err != vm.CodeStoreOutOfGasError) {
+ if maxCodeSizeExceeded ||
+ (err != nil && (env.ChainConfig().IsHomestead(env.BlockNumber()) || err != vm.CodeStoreOutOfGasError)) {
contract.UseGas(contract.Gas)
-
env.RevertToSnapshot(snapshotPreTransfer)
// Nothing should be returned when an error is thrown.
diff --git a/params/protocol_params.go b/params/protocol_params.go
index 5079eb111..e98925c2b 100644
--- a/params/protocol_params.go
+++ b/params/protocol_params.go
@@ -14,9 +14,6 @@
// You should have received a copy of the GNU Lesser General Public License
// along with the go-ethereum library. If not, see <http://www.gnu.org/licenses/>.
-// DO NOT EDIT!!!
-// AUTOGENERATED FROM generators/defaults.go
-
package params
import "math/big"
@@ -72,4 +69,5 @@ var (
MemoryGas = big.NewInt(3) // Times the address of the (highest referenced byte in memory + 1). NOTE: referencing happens on read, write and in instructions such as RETURN and CALL.
TxDataNonZeroGas = big.NewInt(68) // Per byte of data attached to a transaction that is not equal to zero. NOTE: Not payable on data of calls between transactions.
+ MaxCodeSize = 24576
)