use of org.ethereum.vm.LogInfo in project rskj by rsksmart.
the class ReceiptStoreImplFallbackTest method createReceipt.
// from TransactionTest
private static TransactionReceipt createReceipt() {
byte[] stateRoot = Hex.decode("f5ff3fbd159773816a7c707a9b8cb6bb778b934a8f6466c7830ed970498f4b68");
byte[] gasUsed = Hex.decode("01E848");
Bloom bloom = new Bloom(Hex.decode("0000000000000000800000000000000004000000000000000000000000000000000000000000000000000000000000000000000000000000000000001000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000"));
LogInfo logInfo1 = new LogInfo(Hex.decode("cd2a3d9f938e13cd947ec05abc7fe734df8dd826"), null, Hex.decode("a1a1a1"));
List<LogInfo> logs = new ArrayList<>();
logs.add(logInfo1);
// TODO calculate cumulative gas
TransactionReceipt receipt = new TransactionReceipt(stateRoot, gasUsed, gasUsed, bloom, logs, new byte[] { 0x01 });
receipt.setTransaction(Transaction.builder().build());
return receipt;
}
use of org.ethereum.vm.LogInfo in project rskj by rsksmart.
the class ReceiptStoreImplTest method createReceipt.
// from TransactionTest
private static TransactionReceipt createReceipt(int numOfLogs) {
byte[] stateRoot = Hex.decode("f5ff3fbd159773816a7c707a9b8cb6bb778b934a8f6466c7830ed970498f4b68");
byte[] gasUsed = Hex.decode("01E848");
Bloom bloom = new Bloom(Hex.decode("0000000000000000800000000000000004000000000000000000000000000000000000000000000000000000000000000000000000000000000000001000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000"));
List<LogInfo> logs = new ArrayList<>();
for (int i = 0; i < numOfLogs; i++) {
LogInfo logInfo = new LogInfo(Hex.decode("cd2a3d9f938e13cd947ec05abc7fe734df8dd826"), null, Hex.decode("a1a1a1"));
logs.add(logInfo);
}
// TODO calculate cumulative gas
TransactionReceipt receipt = new TransactionReceipt(stateRoot, gasUsed, gasUsed, bloom, logs, new byte[] { 0x01 });
receipt.setTransaction(Transaction.builder().build());
return receipt;
}
use of org.ethereum.vm.LogInfo in project rskj by rsksmart.
the class LogsValidator method valid.
public static List<String> valid(List<LogInfo> origLogs, List<LogInfo> postLogs, ValidationStats vStats) {
List<String> results = new ArrayList<>();
int i = 0;
for (LogInfo postLog : postLogs) {
if (vStats != null)
vStats.logChecks++;
if (origLogs == null || origLogs.size() - 1 < i) {
String formattedString = String.format("Log: %s: was expected but doesn't exist: address: %s", i, ByteUtil.toHexString(postLog.getAddress()));
results.add(formattedString);
continue;
}
LogInfo realLog = origLogs.get(i);
String postAddress = ByteUtil.toHexString(postLog.getAddress());
String realAddress = ByteUtil.toHexString(realLog.getAddress());
if (vStats != null)
vStats.logChecks++;
if (!postAddress.equals(realAddress)) {
String formattedString = String.format("Log: %s: has unexpected address, expected address: %s found address: %s", i, postAddress, realAddress);
results.add(formattedString);
}
String postData = ByteUtil.toHexString(postLog.getData());
String realData = ByteUtil.toHexString(realLog.getData());
if (vStats != null)
vStats.logChecks++;
if (!postData.equals(realData)) {
String formattedString = String.format("Log: %s: has unexpected data, expected data: %s found data: %s", i, postData, realData);
results.add(formattedString);
}
String postBloom = ByteUtil.toHexString(postLog.getBloom().getData());
String realBloom = ByteUtil.toHexString(realLog.getBloom().getData());
if (vStats != null)
vStats.logChecks++;
if (!postData.equals(realData)) {
String formattedString = String.format("Log: %s: has unexpected bloom, expected bloom: %s found bloom: %s", i, postBloom, realBloom);
results.add(formattedString);
}
List<DataWord> postTopics = postLog.getTopics();
List<DataWord> realTopics = realLog.getTopics();
int j = 0;
for (DataWord postTopic : postTopics) {
DataWord realTopic = realTopics.get(j);
if (vStats != null)
vStats.logChecks++;
if (!postTopic.equals(realTopic)) {
String formattedString = String.format("Log: %s: has unexpected topic: %s, expected topic: %s found topic: %s", i, j, postTopic, realTopic);
results.add(formattedString);
}
++j;
}
++i;
}
return results;
}
use of org.ethereum.vm.LogInfo in project rskj by rsksmart.
the class BridgeEventLoggerImpl method logUnrefundablePegin.
public void logUnrefundablePegin(BtcTransaction btcTx, UnrefundablePeginReason reason) {
CallTransaction.Function event = BridgeEvents.UNREFUNDABLE_PEGIN.getEvent();
byte[][] encodedTopicsInBytes = event.encodeEventTopics(btcTx.getHash().getBytes());
List<DataWord> encodedTopics = LogInfo.byteArrayToList(encodedTopicsInBytes);
byte[] encodedData = event.encodeEventData(reason.getValue());
this.logs.add(new LogInfo(BRIDGE_CONTRACT_ADDRESS, encodedTopics, encodedData));
}
use of org.ethereum.vm.LogInfo in project rskj by rsksmart.
the class BridgeEventLoggerImpl method logCommitFederationInRLPFormat.
private void logCommitFederationInRLPFormat(Block executionBlock, Federation oldFederation, Federation newFederation) {
List<DataWord> topics = Collections.singletonList(Bridge.COMMIT_FEDERATION_TOPIC);
byte[] oldFedFlatPubKeys = flatKeysAsRlpCollection(oldFederation.getBtcPublicKeys());
byte[] oldFedData = RLP.encodeList(RLP.encodeElement(oldFederation.getAddress().getHash160()), RLP.encodeList(oldFedFlatPubKeys));
byte[] newFedFlatPubKeys = flatKeysAsRlpCollection(newFederation.getBtcPublicKeys());
byte[] newFedData = RLP.encodeList(RLP.encodeElement(newFederation.getAddress().getHash160()), RLP.encodeList(newFedFlatPubKeys));
long newFedActivationBlockNumber = executionBlock.getNumber() + this.bridgeConstants.getFederationActivationAge();
byte[] data = RLP.encodeList(oldFedData, newFedData, RLP.encodeString(Long.toString(newFedActivationBlockNumber)));
this.logs.add(new LogInfo(BRIDGE_CONTRACT_ADDRESS, topics, data));
}
Aggregations