コード例 #1
0
ファイル: JitVM.cpp プロジェクト: EarthDollar/farmer
bytesConstRef JitVM::execImpl(u256& io_gas, ExtVMFace& _ext, OnOpFunc const& _onOp)
{
	auto rejected = false;
	// TODO: Rejecting transactions with gas limit > 2^63 can be used by attacker to take JIT out of scope
	rejected |= io_gas > std::numeric_limits<decltype(m_data.gas)>::max(); // Do not accept requests with gas > 2^63 (int64 max)
	rejected |= _ext.gasPrice > std::numeric_limits<decltype(m_data.gasPrice)>::max();
	rejected |= _ext.envInfo().number() > std::numeric_limits<decltype(m_data.number)>::max();
	rejected |= _ext.envInfo().timestamp() > std::numeric_limits<decltype(m_data.timestamp)>::max();
	if (!toJITSchedule(_ext.evmSchedule(), m_schedule))
	{
		cwarn << "Schedule changed, not suitable for JIT!";
		rejected = true;
	}
	if (rejected)
	{
		cwarn << "Execution rejected by EVM JIT (gas limit: " << io_gas << "), executing with interpreter";
		m_fallbackVM = VMFactory::create(VMKind::Interpreter);
		return m_fallbackVM->execImpl(io_gas, _ext, _onOp);
	}

	m_data.gas 			= static_cast<decltype(m_data.gas)>(io_gas);
	m_data.gasPrice		= static_cast<decltype(m_data.gasPrice)>(_ext.gasPrice);
	m_data.callData 	= _ext.data.data();
	m_data.callDataSize = _ext.data.size();
	m_data.address      = eth2jit(fromAddress(_ext.myAddress));
	m_data.caller       = eth2jit(fromAddress(_ext.caller));
	m_data.origin       = eth2jit(fromAddress(_ext.origin));
	m_data.transferredValue = eth2jit(_ext.value);
	m_data.apparentValue = eth2jit(_ext.value);
	m_data.coinBase     = eth2jit(fromAddress(_ext.envInfo().author()));
	m_data.difficulty   = eth2jit(_ext.envInfo().difficulty());
	m_data.gasLimit     = eth2jit(_ext.envInfo().gasLimit());
	m_data.number 		= static_cast<decltype(m_data.number)>(_ext.envInfo().number());
	m_data.timestamp 	= static_cast<decltype(m_data.timestamp)>(_ext.envInfo().timestamp());
	m_data.code     	= _ext.code.data();
	m_data.codeSize 	= _ext.code.size();
	m_data.codeHash		= eth2jit(_ext.codeHash);

	// Pass pointer to ExtVMFace casted to evmjit::Env* opaque type.
	// JIT will do nothing with the pointer, just pass it to Env callback functions implemented in Env.cpp.
	m_context.init(m_data, reinterpret_cast<evmjit::Env*>(&_ext));
	auto exitCode = evmjit::JIT::exec(m_context, m_schedule);
	switch (exitCode)
	{
	case evmjit::ReturnCode::Suicide:
		_ext.suicide(right160(jit2eth(m_data.address)));
		break;

	case evmjit::ReturnCode::OutOfGas:
		BOOST_THROW_EXCEPTION(OutOfGas());
	case evmjit::ReturnCode::LinkerWorkaround:	// never happens
		env_sload();					// but forces linker to include env_* JIT callback functions
		break;
	default:
		break;
	}

	io_gas = m_data.gas;
	return {std::get<0>(m_context.returnData), std::get<1>(m_context.returnData)};
}
コード例 #2
0
ファイル: support_maemo6.cpp プロジェクト: zccrs/qt-mobility
QMessageAccountId addAccount(const Parameters &params)
{
    qWarning() << "ADDDDD";
    QString name(params["name"]);
    QString fromAddress(params["fromAddress"]);

    if (!name.isEmpty()) {
        QMailAccount account;
        account.setName(name);
        account.setStatus(QMailAccount::Enabled, true);
        account.setStatus(QMailAccount::CanTransmit, true);
        account.setMessageType(QMailMessage::Email);

        if (!fromAddress.isEmpty()) {
            account.setFromAddress(QMailAddress(QString(), fromAddress));
        }

        // Ensure that we initialise to the current version for file storage
        const QString key("qmfstoragemanager");

        QMailAccountConfiguration config;
        config.addServiceConfiguration(key);
        QMailAccountConfiguration::ServiceConfiguration &svcCfg(config.serviceConfiguration(key));
        svcCfg.setValue("servicetype", "storage");
        svcCfg.setValue("version", "101");

        if (!QMailStore::instance()->addAccount(&account, &config)) {
            qWarning() << "Unable to addAccount:" << name;
        } else {
            return QmfHelpers::convert(account.id());
        }
    }

    return QMessageAccountId();
}
コード例 #3
0
ファイル: VM.cpp プロジェクト: beautifularea/aleth
        NEXT

        CASE(ORIGIN)
        {
            ON_OP();
            updateIOGas();

            m_SPP[0] = fromAddress(fromEvmC(getTxContext().tx_origin));
        }
コード例 #4
0
ファイル: VM.cpp プロジェクト: beautifularea/aleth
        CONTINUE

        CASE(ADDRESS)
        {
            ON_OP();
            updateIOGas();

            m_SPP[0] = fromAddress(fromEvmC(m_message->destination));
        }
コード例 #5
0
ファイル: VM.cpp プロジェクト: beautifularea/aleth
        NEXT

        CASE(COINBASE)
        {
            ON_OP();
            updateIOGas();

            m_SPP[0] = fromAddress(fromEvmC(getTxContext().block_coinbase));
        }
コード例 #6
0
ファイル: VM.cpp プロジェクト: beautifularea/aleth
        NEXT


        CASE(CALLER)
        {
            ON_OP();
            updateIOGas();

            m_SPP[0] = fromAddress(fromEvmC(m_message->sender));
        }
コード例 #7
0
ファイル: request.cpp プロジェクト: pvuorela/kcalcore
  QByteArray Request::headerFields( const QString & fromRealName ) const {
    if ( !emitHeaders() )
      return 0;

    assert( hasFromAddress() ); // should have been checked for by
                                // caller (MAIL FROM comes before DATA)

    QByteArray result = "From: " + formatFromAddress( fromRealName, fromAddress() ) + "\r\n";

    if ( !subject().isEmpty() )
      result += "Subject: " + formatSubject( subject() ) + "\r\n";
    if ( !to().empty() )
      result += QByteArray( "To: " ) + to().join( QLatin1String(",\r\n\t") /* line folding */ ).toLatin1() + "\r\n";
    if ( !cc().empty() )
      result += QByteArray( "Cc: " ) + cc().join( QLatin1String(",\r\n\t") /* line folding */ ).toLatin1() + "\r\n";
    return result;
  }