Generate concrete transaction sequence.

    :param global_state: GlobalState to generate transaction sequence for
    :param constraints: list of constraints used to generate transaction sequence
963330
def get_transaction_sequence(global_state, constraints):
    

    transaction_sequence = global_state.world_state.transaction_sequence

    # gaslimit & gasprice don't exist yet
    tx_template = {
        "calldata": None,
        "call_value": None,
        "caller": "0xCA11EDEADBEEF37E636E6CA11EDEADBEEFCA11ED",
    }

    concrete_transactions = {}
    creation_tx_ids = []
    tx_constraints = constraints.copy()
    minimize = []

    transactions = []
    for transaction in transaction_sequence:
        tx_id = str(transaction.id)
        if not isinstance(transaction, ContractCreationTransaction):
            transactions.append(transaction)
            # Constrain calldatasize
            max_calldatasize = symbol_factory.BitVecVal(5000, 256)
            tx_constraints.append(
                UGE(max_calldatasize, transaction.call_data.calldatasize)
            )

            minimize.append(transaction.call_data.calldatasize)
            minimize.append(transaction.call_value)

            concrete_transactions[tx_id] = tx_template.copy()

        else:
            creation_tx_ids.append(tx_id)

    model = get_model(tx_constraints, minimize=minimize)

    for transaction in transactions:
        tx_id = str(transaction.id)

        concrete_transactions[tx_id]["calldata"] = "0x" + "".join(
            [
                hex(b)[2:] if len(hex(b)) % 2 == 0 else "0" + hex(b)[2:]
                for b in transaction.call_data.concrete(model)
            ]
        )

        concrete_transactions[tx_id]["call_value"] = (
            "0x%x"
            % model.eval(transaction.call_value.raw, model_completion=True).as_long()
        )
        concrete_transactions[tx_id]["caller"] = "0x" + (
            "%x" % model.eval(transaction.caller.raw, model_completion=True).as_long()
        ).zfill(40)

    return concrete_transactions
272340
def globals(self):
        """"""
        defglobal = lib.EnvGetNextDefglobal(self._env, ffi.NULL)

        while defglobal != ffi.NULL:
            yield Global(self._env, defglobal)

            defglobal = lib.EnvGetNextDefglobal(self._env, defglobal)
306684
def build_state(
            cls,
            db: BaseAtomicDB,
            header: BlockHeader,
            previous_hashes: Iterable[Hash32] = ()) -> BaseState:
        

        execution_context = header.create_execution_context(previous_hashes)
        return cls.get_state_class()(db, execution_context, header.state_root)
877302
def Transactional(fn, self, *argv, **argd):
    
    return self._transactional(fn, *argv, **argd)
1089157
protected void createRealizationAndState(
    MessageProcessor messageProcessor,
    TransactionCommon transaction)
  {
    if (TraceComponent.isAnyTracingEnabled() && tc.isEntryEnabled())
      SibTr.entry(
        tc,
        "createRealizationAndState",
        new Object[] {
          messageProcessor,
          transaction });

                                         
    /*
     * Create associated state handler of appropriate type
     */
      _ptoPRealization = new LinkState(this,
                                          messageProcessor,
                                          getLocalisationManager());
      _protoRealization = _ptoPRealization;
    
          
    if (TraceComponent.isAnyTracingEnabled() && tc.isEntryEnabled())
      SibTr.exit(tc, "createRealizationAndState");
  }
523675
@Override
    public Vote prepare(String globalId) throws SystemException, HeuristicHazardException, HeuristicMixedException, RollbackException {

        final TransactionWrapper t = TransactionWrapper.getTransactionWrapper(globalId);

        if (t != null) {
            return t.prepare();
        } else {
            if (TraceComponent.isAnyTracingEnabled() && tc.isDebugEnabled())
                Tr.debug(tc, "No matching TransactionWrapper: " + globalId);
            throw new SystemException();
        }
    }
811084
def initialize_constraint_table(cfg_list):
    """"""
    for cfg in cfg_list:
        constraint_table.update(dict.fromkeys(cfg.nodes, 0))
293284
def build_sequence(self, xs, masks, init, is_left_to_right):
        '''
        
        '''
        states = []
        last = init
        if is_left_to_right:
            for i, xs_i in enumerate(xs):
                h = self.build(xs_i, last, masks[i])
                states.append(h)
                last = h
        else:
            for i in range(len(xs) - 1, -1, -1):
                h = self.build(xs[i], last, masks[i])
                states.insert(0, h)
                last = h
        return states
861262
def initialize_copy(orig)
      super
      @states = orig.states.collect { |state| state.clone }
      @events = {}
      orig.events.each_pair { |name, event| @events[name] = event.clone }
      @global_callbacks = @global_callbacks.dup
    end
395428
def create_table_with_constraints(self, tbl, primaryKeys, foreignKeys):
    
    self.send_create_table_with_constraints(tbl, primaryKeys, foreignKeys)
    self.recv_create_table_with_constraints()
673978
def mkconstraints():
    
    constraints = []

    for j in range(1, 10):
        vars = ["%s%d" % (i, j) for i in uppercase[:9]]
        constraints.extend((c, const_different) for c in combinations(vars, 2))

    for i in uppercase[:9]:
        vars = ["%s%d" % (i, j) for j in range(1, 10)]
        constraints.extend((c, const_different) for c in combinations(vars, 2))

    for b0 in ['ABC', 'DEF', 'GHI']:
        for b1 in [[1, 2, 3], [4, 5, 6], [7, 8, 9]]:
            vars = ["%s%d" % (i, j) for i in b0 for j in b1]
            l = list((c, const_different) for c in combinations(vars, 2))
            constraints.extend(l)

    return constraints
663558
@Override
    public boolean importTransaction(String globalId, int expires) throws SystemException {

        //The first thing we need to do is distinguish between local and remote invocations. If the UOW currently associated
        //with the thread is a global txn then we know the invocation must be local. The other case is where the remote servers
        //web container has begun a local txn in the absence of the global context. We do know that there was a global txn on 
        //invocation else there wouldn't even be a cc available.
        final UOWCoordinator uowCoord = _uowc.getUOWCoord();
        _threadUOWCoord.set(uowCoord);

        if (uowCoord != null && uowCoord.isGlobal()) {
            if (TraceComponent.isAnyTracingEnabled() && tc.isDebugEnabled())
                Tr.debug(tc, "The Web Service request is a local invocation");

            ((DistributableTransaction) uowCoord).resumeAssociation();
            return false;
        }

        if (TraceComponent.isAnyTracingEnabled() && tc.isDebugEnabled())
            Tr.debug(tc, "The Web Service request is a remote invocation");

        try {
            TMHelper.checkTMState();
        } catch (NotSupportedException e) {
            final SystemException se = new SystemException();
            se.initCause(e);
            throw se;
        }

        //The web container will start a local tran as there will not be a global context
        //on thread. We need to suspend this before attaching the global tran
        final LocalTransactionCoordinator ltc = LocalTranCurrentSet.instance().suspend();
        if (TraceComponent.isAnyTracingEnabled() && tc.isDebugEnabled())
            Tr.debug(tc, "Suspended LTC", ltc);

        boolean createdNewTransaction = false;

        DistributableTransaction tx = getTransactionForID(globalId);

        if (tx == null) {
            tx = new EmbeddableTransactionImpl(expires, globalId);
            createdNewTransaction = true;

            new TransactionWrapper((EmbeddableTransactionImpl) tx);
        }

        _threadImportedTran.set(tx);

        // Add association to police single thread per tran
        tx.addAssociation();

        // Resume transaction on this thread
        try {
            _tm.resume((Transaction) tx);
        } catch (Exception e) {
            SystemException se = new SystemException();
            se.initCause(e);
            throw se;
        }

        return createdNewTransaction;
    }
1100356
def commit_state_create( self, nameop, current_block_number ):
        

        # have to have read-write disposition 
        if self.disposition != DISPOSITION_RW:
            log.error("FATAL: borrowing violation: not a read-write connection")
            traceback.print_stack()
            os.abort()

        cur = self.db.cursor()
        opcode = nameop.get('opcode', None)

        try:
            assert state_create_is_valid( nameop ), "Invalid state-creation"
            assert opcode is not None, "BUG: did not set opcode"
            
            preorder = state_create_get_preorder( nameop )
        except Exception, e:
            log.exception(e)
            log.error("FATAL: missing preorder and/or prior history and/or opcode")
            os.abort()

        initial_state = self.sanitize_op( nameop )
        table = state_create_get_table( nameop )
        history_id_key = state_create_get_history_id_key( nameop )
        history_id = nameop[history_id_key]
        constraints_ignored = state_create_get_always_set( nameop )

        # cannot have collided 
        if BlockstackDB.nameop_is_collided( nameop ):
            # TODO: is this reachable?
            log.debug("Not commiting '%s' since we're collided" % history_id)
            self.log_reject( current_block_number, nameop['vtxindex'], nameop['op'], nameop )
            return {}

        self.log_accept( current_block_number, nameop['vtxindex'], nameop['op'], nameop )
        
        canonical_opdata = None

        if preorder is not None:
            # preordered a name or a namespace, possibly not for the first time even.
            try:
                assert 'preorder_hash' in preorder, 'BUG: missing preorder-hash'
            except Exception as e:
                log.exception(e)
                log.error("FATAL: invalid preorder")
                os.abort()

            canonical_opdata = namedb_state_create(cur, opcode, initial_state, current_block_number,
                                                   initial_state['vtxindex'], initial_state['txid'],
                                                   history_id, preorder, table, constraints_ignored=constraints_ignored)

            if not canonical_opdata:
                log.error("FATAL: failed to create '{}'".format(history_id))
                self.db.rollback()
                os.abort()

            self.db.commit()
        
        else:
            # importing a name
            try:
                assert opcode in OPCODE_NAME_STATE_IMPORTS, "BUG: not an import operation"
            except Exception, e:
                log.exception(e)
                log.error("FATAL: invalid import operation")
                os.abort()

            canonical_opdata = namedb_state_create_as_import(self.db, opcode, initial_state, 
                                                             current_block_number, initial_state['vtxindex'], initial_state['txid'],
                                                             history_id, table, constraints_ignored=constraints_ignored)

            if not canonical_opdata:
                log.error("FATAL: failed to create '{}' as import".format(history_id))
                self.db.rollback()
                os.abort()

            self.db.commit()
        
        return canonical_opdata
1309255
def _make_allowed_states(self) -> Iterator[Text]:
        

        for trans in self.transitions:
            yield trans.dest.name()

            if trans.origin:
                yield trans.origin.name()
1006563
public GlobalDescr globalStatement( PackageDescrBuilder pkg ) throws RecognitionException {
        GlobalDescrBuilder global = null;
        try {
            global = helper.start( pkg,
                                   GlobalDescrBuilder.class,
                                   null );

            // 'global'
            match( input,
                   DRL5Lexer.ID,
                   DroolsSoftKeywords.GLOBAL,
                   null,
                   DroolsEditorType.KEYWORD );
            if ( state.failed ) return null;

            // type
            String type = type();
            if ( state.backtracking == 0 ) global.type( type );
            if ( state.failed ) return null;

            // identifier
            Token id = match( input,
                              DRL5Lexer.ID,
                              null,
                              null,
                              DroolsEditorType.IDENTIFIER_TYPE );
            if ( state.failed ) return null;
            if ( state.backtracking == 0 ) {
                global.identifier( id.getText() );
                helper.setParaphrasesValue( DroolsParaphraseTypes.GLOBAL,
                                            id.getText() );
            }

        } catch ( RecognitionException re ) {
            reportError( re );
        } finally {
            helper.end( GlobalDescrBuilder.class,
                        global );
        }
        return (global != null) ? global.getDescr() : null;
    }
290738
def _push_new_state(self):
        
        try:
            base = self._states[-1]
        except IndexError:
            graph = DirectedGraph()
            graph.add(None)     # Sentinel as root dependencies' parent.
            state = State(mapping={}, graph=graph)
        else:
            state = State(
                mapping=base.mapping.copy(),
                graph=base.graph.copy(),
            )
        self._states.append(state)
791375
def create_global_steps():
        """"""
        global_step = tf.Variable(0, name="global_step", trainable=False, dtype=tf.int32)
        increment_step = tf.assign(global_step, tf.add(global_step, 1))
        return global_step, increment_step