fix: warn when contract bytecode too large for EVM

This commit is contained in:
Andre Medeiros 2019-01-22 14:12:39 -05:00 committed by Iuri Matias
parent afe2512eff
commit 387d33a076

View File

@ -3,6 +3,9 @@ let async = require('async');
let utils = require('../../utils/utils.js');
import { ZERO_ADDRESS } from '../../utils/addressUtils';
// Check out definition 97 of the yellow paper: https://ethereum.github.io/yellowpaper/paper.pdf
const MAX_CONTRACT_BYTECODE_LENGTH = 24576;
class ContractDeployer {
constructor(options) {
this.logger = options.logger;
@ -92,10 +95,18 @@ class ContractDeployer {
}
async.waterfall([
function requestBlockchainConnector(callback) {
function checkContractBytesize(next) {
if(contract.code.length > MAX_CONTRACT_BYTECODE_LENGTH) {
return next(new Error(`Bytecode for ${contract.className} contract is too large. Not deploying.`));
}
next();
},
function requestBlockchainConnector(next) {
self.events.request("blockchain:object", (blockchain) => {
self.blockchain = blockchain;
callback();
next();
});
},