use of org.hyperledger.besu.ethereum.rlp.RLPInput in project besu by hyperledger.
the class TransactionIntegrationTest method shouldDecodeInterestingRlpFromARealTransactionGeneratedUsingRemixAndASimpleContract.
@Test
public void shouldDecodeInterestingRlpFromARealTransactionGeneratedUsingRemixAndASimpleContract() {
final String encodedString = "0xf902560c843b9aca00832dc6c08080b90202608060405234801561001057600080fd5b506040516020806101e283398101604052516000556101ae806100346000396000f30060806040526004361061006c5763ffffffff7c01000000000000000000000000000000000000000000000000000000006000350416632113522a81146100715780632a1afcd9146100af5780633bc5de30146100d657806360fe47b1146100eb578063db613e8114610105575b600080fd5b34801561007d57600080fd5b5061008661011a565b6040805173ffffffffffffffffffffffffffffffffffffffff9092168252519081900360200190f35b3480156100bb57600080fd5b506100c4610136565b60408051918252519081900360200190f35b3480156100e257600080fd5b506100c461013c565b3480156100f757600080fd5b50610103600435610142565b005b34801561011157600080fd5b50610086610166565b60015473ffffffffffffffffffffffffffffffffffffffff1681565b60005481565b60005490565b6000556001805473ffffffffffffffffffffffffffffffffffffffff191633179055565b60015473ffffffffffffffffffffffffffffffffffffffff16905600a165627a7a723058208293fac83e9cc01039adf5e41eefd557d1324a3a4c830a4802fa1dd2515227a20029000000000000000000000000000000000000000000000000000000000000007b820fe8a009e7b69af4c318e7fb915f53649bd9f99e5423d41c2cd6a01ab69bb34a951b2fa01b5d39b7c9041ec022d13e6e89eec2cddbe27572eda7956ada5de1032cd5da15";
final Bytes encoded = Bytes.fromHexString(encodedString);
final RLPInput input = RLP.input(encoded);
final Transaction transaction = Transaction.readFrom(input);
assertThat(transaction).isNotNull();
assertThat(transaction.isContractCreation()).isTrue();
assertThat(transaction.getChainId()).contains(BigInteger.valueOf(2018));
assertThat(transaction.getSender()).isEqualTo(Address.fromHexString("0xfe3b557e8fb62b89f4916b721be55ceb828dbd73"));
}
use of org.hyperledger.besu.ethereum.rlp.RLPInput in project besu by hyperledger.
the class TransactionIntegrationTest method shouldDecodeAndEncodeTransactionCorrectly.
@Test
public void shouldDecodeAndEncodeTransactionCorrectly() {
final String encodedString = "0xf9025780843b9aca00832dc6c08080b90202608060405234801561001057600080fd5b506040516020806101e283398101604052516000556101ae806100346000396000f30060806040526004361061006c5763ffffffff7c01000000000000000000000000000000000000000000000000000000006000350416632113522a81146100715780632a1afcd9146100af5780633bc5de30146100d657806360fe47b1146100eb578063db613e8114610105575b600080fd5b34801561007d57600080fd5b5061008661011a565b6040805173ffffffffffffffffffffffffffffffffffffffff9092168252519081900360200190f35b3480156100bb57600080fd5b506100c4610136565b60408051918252519081900360200190f35b3480156100e257600080fd5b506100c461013c565b3480156100f757600080fd5b50610103600435610142565b005b34801561011157600080fd5b50610086610166565b60015473ffffffffffffffffffffffffffffffffffffffff1681565b60005481565b60005490565b6000556001805473ffffffffffffffffffffffffffffffffffffffff191633179055565b60015473ffffffffffffffffffffffffffffffffffffffff16905600a165627a7a723058208293fac83e9cc01039adf5e41eefd557d1324a3a4c830a4802fa1dd2515227a20029000000000000000000000000000000000000000000000000000000000000000c830628cba0482ba9b1136cd9337408938eea6b991fd153900a014867da2f4bb113d4003888a00c5a2f8f279fe2c86831afb5c9578dd1c3be457e3aca3abe439b1a5dd122e676";
final Bytes encoded = Bytes.fromHexString(encodedString);
final RLPInput input = RLP.input(encoded);
final Transaction transaction = Transaction.readFrom(input);
final BytesValueRLPOutput output = new BytesValueRLPOutput();
transaction.writeTo(output);
assertThat(output.encoded().toString()).isEqualTo(encodedString);
}
use of org.hyperledger.besu.ethereum.rlp.RLPInput in project besu by hyperledger.
the class TransactionIntegrationTest method shouldDecodeTransactionWithLargeChainId.
@Test
public void shouldDecodeTransactionWithLargeChainId() {
final String encodedString = "0xf86a018609184e72a0008276c094d30c3d13b07029deba00de1da369cd69a02c20560180850100000021a07d344f26d7329e8932d2878b99f07b12752bbd13a0b3b822644dbf9600fe718da01d6e6b6c66e1aadf4e33e318a7eef03d3bd3602de52662f0cb5af5b372d44dcd";
final Bytes encoded = Bytes.fromHexString(encodedString);
final RLPInput input = RLP.input(encoded);
final Transaction transaction = Transaction.readFrom(input);
assertThat(transaction).isNotNull();
assertThat(transaction.isContractCreation()).isFalse();
assertThat(transaction.getChainId()).contains(BigInteger.valueOf(2147483647));
assertThat(transaction.getSender()).isEqualTo(Address.fromHexString("0xdf664d0d2270ef97b48f222e3187bd14c8ca9428"));
assertThat(transaction.getTo()).contains(Address.fromHexString("0xd30c3d13b07029deba00de1da369cd69a02c2056"));
}
use of org.hyperledger.besu.ethereum.rlp.RLPInput in project besu by hyperledger.
the class TransactionDecoderTest method decodeGoQuorumPrivateTransactionRlp.
@Test
void decodeGoQuorumPrivateTransactionRlp() {
boolean goQuorumCompatibilityMode = true;
RLPInput input = RLP.input(Bytes.fromHexString(GOQUORUM_PRIVATE_TX_RLP));
final Transaction transaction = TransactionDecoder.decodeForWire(input, goQuorumCompatibilityMode);
assertThat(transaction).isNotNull();
assertThat(transaction.getV()).isEqualTo(38);
assertThat(transaction.getSender()).isEqualByComparingTo(Address.fromHexString("0xed9d02e382b34818e88b88a309c7fe71e65f419d"));
}
use of org.hyperledger.besu.ethereum.rlp.RLPInput in project besu by hyperledger.
the class QbftExtraDataCodec method decodeRaw.
@Override
public BftExtraData decodeRaw(final Bytes input) {
if (input.isEmpty()) {
throw new IllegalArgumentException("Invalid Bytes supplied - Bft Extra Data required.");
}
final RLPInput rlpInput = new BytesValueRLPInput(input, false);
// This accounts for the "root node" which contains BFT data items.
rlpInput.enterList();
final Bytes vanityData = rlpInput.readBytes();
final List<Address> validators = rlpInput.readList(Address::readFrom);
final Optional<Vote> vote;
if (rlpInput.nextIsList() && rlpInput.nextSize() == 0) {
vote = Optional.empty();
rlpInput.skipNext();
} else {
vote = Optional.of(decodeVote(rlpInput));
}
final int round = rlpInput.readIntScalar();
final List<SECPSignature> seals = rlpInput.readList(rlp -> SignatureAlgorithmFactory.getInstance().decodeSignature(rlp.readBytes()));
rlpInput.leaveListLenient();
return new BftExtraData(vanityData, seals, vote, round, validators);
}
Aggregations