-
Notifications
You must be signed in to change notification settings - Fork 130
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks good apart from the missing tests
ethereum/core/src/main/java/tech/pegasys/pantheon/ethereum/core/TransactionReceipt.java
Outdated
Show resolved
Hide resolved
ethereum/core/src/main/java/tech/pegasys/pantheon/ethereum/mainnet/MainnetProtocolSpecs.java
Outdated
Show resolved
Hide resolved
ethereum/core/src/main/java/tech/pegasys/pantheon/ethereum/core/TransactionReceipt.java
Show resolved
Hide resolved
@@ -115,7 +144,9 @@ public void writeTo(final RLPOutput out) { | |||
out.writeLongScalar(cumulativeGasUsed); | |||
out.writeBytesValue(bloomFilter.getBytes()); | |||
out.writeList(logs, Log::writeTo); | |||
|
|||
if (withRevertReason && revertReason.isPresent()) { | |||
out.writeBytesValue(BytesValue.wrap(revertReason.get().getBytes(StandardCharsets.UTF_8))); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If someone has asked for the reason, but it doesn't exist, should we include an empty string?
I.e. Client requested the RevertReason explicitly, probably should give it to them (even if it doesn't exist).
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Don't think an empty string makes sense as an empty string is a valid revert reason. And returning a null for the revert reason as it does now makes more sense as there is no revert reason value to return.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
👍 null
return value for a null
revert reason.
In this context null
and an empty string would have different meanings i.e. no revert message vs an empty revert message.
ethereum/core/src/main/java/tech/pegasys/pantheon/ethereum/core/TransactionReceipt.java
Outdated
Show resolved
Hide resolved
ethereum/core/src/main/java/tech/pegasys/pantheon/ethereum/core/TransactionReceipt.java
Show resolved
Hide resolved
ethereum/core/src/main/java/tech/pegasys/pantheon/ethereum/core/TransactionReceipt.java
Outdated
Show resolved
Hide resolved
import java.util.Arrays; | ||
import java.util.Optional; | ||
|
||
public class BlockDataGeneratorWithReason extends BlockDataGenerator { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Could this just be done with Mocking?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Could be but theres a BlockDataGenerator that already exists. And the code is nicer using the data generator rather than adding mock. I've also added a receipt(revertReason) method to the existing BlockDataGenerator remove need for this extra BlockDataGenerator class.
ethereum/core/src/test/java/tech/pegasys/pantheon/ethereum/core/TransactionReceiptTest.java
Outdated
Show resolved
Hide resolved
...ts/src/test/java/tech/pegasys/pantheon/tests/acceptance/dsl/condition/eth/EthConditions.java
Show resolved
Hide resolved
...ptance-tests/src/test/java/tech/pegasys/pantheon/tests/acceptance/dsl/node/PantheonNode.java
Outdated
Show resolved
Hide resolved
...ptance-tests/src/test/java/tech/pegasys/pantheon/tests/acceptance/dsl/node/PantheonNode.java
Outdated
Show resolved
Hide resolved
…'t need start another server and avoid passing through host and ports in tests
...eon/tests/acceptance/dsl/transaction/eth/EthGetTransactionReceiptRawResponseTransaction.java
Outdated
Show resolved
Hide resolved
acceptance-tests/src/test/java/tech/pegasys/pantheon/tests/web3j/RevertReason.sol
Outdated
Show resolved
Hide resolved
...ptance-tests/src/test/java/tech/pegasys/pantheon/tests/web3j/RevertReasonAcceptanceTest.java
Outdated
Show resolved
Hide resolved
…don't need to expose web3j
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm not keen on the EthGetTransactionReceiptRaw
naming, I think it's disingenuous, it is just a EthGetTransactionReceipt
...n/tests/acceptance/dsl/condition/eth/ExpectSuccessfulEthGetTransactionReceiptWithReason.java
Outdated
Show resolved
Hide resolved
...n/tests/acceptance/dsl/condition/eth/ExpectSuccessfulEthGetTransactionReceiptWithReason.java
Outdated
Show resolved
Hide resolved
...ests/acceptance/dsl/condition/eth/ExpectSuccessfulEthGetTransactionReceiptWithoutReason.java
Outdated
Show resolved
Hide resolved
...ests/acceptance/dsl/condition/eth/ExpectSuccessfulEthGetTransactionReceiptWithoutReason.java
Outdated
Show resolved
Hide resolved
import org.web3j.protocol.core.methods.response.EthSendTransaction; | ||
import org.web3j.tx.RawTransactionManager; | ||
|
||
public class CallSmartContractFunctionWithRevert implements Transaction<EthSendTransaction> { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
What in this class links to WithRevert
? ...as it looks like a generic smart contract function invocation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
renamed to CallSmartContractFunction
import org.web3j.protocol.core.Response; | ||
import org.web3j.protocol.core.methods.response.TransactionReceipt; | ||
|
||
public class EthRawRequestFactory { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This class is bunk.
The one method in the class is calling eth_getTransactionReceipt
, we have simply extended that function to include an additional field. Why not put this new method in Eth
?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Moved this rpc request method into the custom rpc factory
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Only Javadoc issues in this pass
|
||
/** | ||
* Creates an instance of a state root-encoded transaction receipt. | ||
* | ||
* @param stateRoot the state root for the world state after the transaction has been processed | ||
* @param cumulativeGasUsed the total amount of gas consumed in the block after this transaction | ||
* @param logs the logs generated within the transaction | ||
* @param revertReason whether storing the revert reason is for failed transactions |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Grammer.
@param revertReason whether to store the revert reason for failed transactions
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is actually the revert reason not a flag whether or not to store the revert reason. So have updated this and the below constructor to reflect this.
@@ -69,32 +85,40 @@ private TransactionReceipt( | |||
* @param status the status code for the transaction (1 for success and 0 for failure) | |||
* @param cumulativeGasUsed the total amount of gas consumed in the block after this transaction | |||
* @param logs the logs generated within the transaction | |||
* @param revertReason the revert reason |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@param revertReason whether to store the revert reason for failed transactions
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
As above, the java doc was misleading have updated to the same as the java doc for the other constructor
@@ -115,7 +144,9 @@ public void writeTo(final RLPOutput out) { | |||
out.writeLongScalar(cumulativeGasUsed); | |||
out.writeBytesValue(bloomFilter.getBytes()); | |||
out.writeList(logs, Log::writeTo); | |||
|
|||
if (withRevertReason && revertReason.isPresent()) { | |||
out.writeBytesValue(BytesValue.wrap(revertReason.get().getBytes(StandardCharsets.UTF_8))); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
👍 null
return value for a null
revert reason.
In this context null
and an empty string would have different meanings i.e. no revert message vs an empty revert message.
@@ -95,6 +97,13 @@ default boolean isSuccessful() { | |||
* @return the validation result, with the reason for failure (if applicable.) | |||
*/ | |||
ValidationResult<TransactionInvalidReason> getValidationResult(); | |||
|
|||
/** | |||
* Returns the reason a transaction was reverted (if applicable). |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Missing word.
Returns the reason why a transaction was reverted (if applicable).
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
done
PR description
This will include the revert reason associated with revert evm operation as an additional field in the transaction receipt when retrieved via the eth_getTransactionReceipt rpc call.
Fixed Issue(s)
If available, add the revert reason thrown inside a contract to the Transaction Receipt returned via a rpc calls.