Search in sources :

Example 1 with Log

use of org.aion.mcf.vm.types.Log in project aion by aionnetwork.

the class AbstractTxReceipt method setLogs.

public void setLogs(List<Log> logInfoList) {
    if (logInfoList == null) {
        return;
    }
    this.logInfoList = logInfoList;
    for (Log loginfo : logInfoList) {
        bloomFilter.or(loginfo.getBloom());
    }
    rlpEncoded = null;
}
Also used : Log(org.aion.mcf.vm.types.Log)

Example 2 with Log

use of org.aion.mcf.vm.types.Log in project aion by aionnetwork.

the class AionTxReceipt method getEncoded.

/**
 * Encodes the receipt, depending on whether the intended destination is for
 * calculation of the receipts trie, or for storage purposes. In effect the
 * receipt stores more information than what is defined in the
 * <a href="http://http://yellowpaper.io/">YP</a>.
 *
 * @param receiptTrie
 *            true if target is "strictly" adhering to YP
 * @return {@code rlpEncoded} byte array representing the receipt
 */
private byte[] getEncoded(boolean receiptTrie) {
    byte[] postTxStateRLP = RLP.encodeElement(this.postTxState);
    byte[] bloomRLP = RLP.encodeElement(this.bloomFilter.data);
    final byte[] logInfoListRLP;
    if (logInfoList != null) {
        byte[][] logInfoListE = new byte[logInfoList.size()][];
        int i = 0;
        for (Log logInfo : logInfoList) {
            logInfoListE[i] = logInfo.getEncoded();
            ++i;
        }
        logInfoListRLP = RLP.encodeList(logInfoListE);
    } else {
        logInfoListRLP = RLP.encodeList();
    }
    return receiptTrie ? RLP.encodeList(postTxStateRLP, bloomRLP, logInfoListRLP) : RLP.encodeList(postTxStateRLP, bloomRLP, logInfoListRLP, RLP.encodeElement(executionResult), RLP.encodeLong(energyUsed), RLP.encodeElement(error.getBytes(StandardCharsets.UTF_8)));
}
Also used : Log(org.aion.mcf.vm.types.Log)

Example 3 with Log

use of org.aion.mcf.vm.types.Log in project aion by aionnetwork.

the class AionTxReceiptTest method testSerialization.

@Test
public void testSerialization() {
    AionTxReceipt receipt = new AionTxReceipt();
    receipt.setError("");
    receipt.setExecutionResult(HashUtil.h256(EMPTY_BYTE_ARRAY));
    List<Log> infos = new ArrayList<>();
    receipt.setLogs(infos);
    receipt.setPostTxState(HashUtil.h256(EMPTY_BYTE_ARRAY));
    byte[] encoded = receipt.getEncoded();
    AionTxReceipt resp = new AionTxReceipt(encoded);
    assertThat(resp.getExecutionResult(), is(equalTo(receipt.getExecutionResult())));
    assertThat(resp.getBloomFilter(), is(equalTo(receipt.getBloomFilter())));
    assertThat(resp.getError(), is(equalTo(receipt.getError())));
}
Also used : Log(org.aion.mcf.vm.types.Log) ArrayList(java.util.ArrayList) AionTxReceipt(org.aion.zero.types.AionTxReceipt) Test(org.junit.Test)

Example 4 with Log

use of org.aion.mcf.vm.types.Log in project aion by aionnetwork.

the class FltrLg method onBlock.

// -------------------------------------------------------------------------------
@Override
public boolean onBlock(IBlockSummary bs) {
    List<AionTxReceipt> receipts = ((AionBlockSummary) bs).getReceipts();
    IBlock blk = bs.getBlock();
    if (matchBloom(new Bloom(((IAionBlock) blk).getLogBloom()))) {
        int txIndex = 0;
        for (AionTxReceipt receipt : receipts) {
            ITransaction tx = receipt.getTransaction();
            if (matchesContractAddress(tx.getTo().toBytes())) {
                if (matchBloom(receipt.getBloomFilter())) {
                    int logIndex = 0;
                    for (Log logInfo : receipt.getLogInfoList()) {
                        if (matchBloom(logInfo.getBloom()) && matchesExactly(logInfo)) {
                            add(new EvtLg(new TxRecptLg(logInfo, blk, txIndex, receipt.getTransaction(), logIndex, true)));
                        }
                        logIndex++;
                    }
                }
            }
            txIndex++;
        }
    }
    return true;
}
Also used : AionBlockSummary(org.aion.zero.impl.types.AionBlockSummary) Log(org.aion.mcf.vm.types.Log) Bloom(org.aion.mcf.vm.types.Bloom) IAionBlock(org.aion.zero.types.IAionBlock) AionTxReceipt(org.aion.zero.types.AionTxReceipt)

Example 5 with Log

use of org.aion.mcf.vm.types.Log in project aion by aionnetwork.

the class FltrLg method onBlock.

// inelegant (distributing chain singleton ref. into here), tradeoff for efficiency and ease of impl.
// rationale: this way, we only retrieve logs from DB for transactions that the bloom
// filter gives a positive match for;
public boolean onBlock(IAionBlock blk, IAionBlockchain chain) {
    if (matchBloom(new Bloom(blk.getLogBloom()))) {
        int txIndex = 0;
        for (ITransaction txn : blk.getTransactionsList()) {
            if (matchesContractAddress(txn.getTo().toBytes())) {
                // now that we know that our filter might match with some logs in this transaction, go ahead
                // and retrieve the txReceipt from the chain
                AionTxInfo txInfo = chain.getTransactionInfo(txn.getHash());
                AionTxReceipt receipt = txInfo.getReceipt();
                if (matchBloom(receipt.getBloomFilter())) {
                    int logIndex = 0;
                    for (Log logInfo : receipt.getLogInfoList()) {
                        if (matchBloom(logInfo.getBloom()) && matchesExactly(logInfo)) {
                            add(new EvtLg(new TxRecptLg(logInfo, blk, txIndex, txn, logIndex, true)));
                        }
                        logIndex++;
                    }
                }
            }
            txIndex++;
        }
    }
    return true;
}
Also used : AionTxInfo(org.aion.zero.impl.types.AionTxInfo) Log(org.aion.mcf.vm.types.Log) Bloom(org.aion.mcf.vm.types.Bloom) AionTxReceipt(org.aion.zero.types.AionTxReceipt)

Aggregations

Log (org.aion.mcf.vm.types.Log)6 AionTxReceipt (org.aion.zero.types.AionTxReceipt)3 Bloom (org.aion.mcf.vm.types.Bloom)2 ArrayList (java.util.ArrayList)1 AionBlockSummary (org.aion.zero.impl.types.AionBlockSummary)1 AionTxInfo (org.aion.zero.impl.types.AionTxInfo)1 IAionBlock (org.aion.zero.types.IAionBlock)1 Test (org.junit.Test)1