Skip to content

Adding support for EIP1559 Private Transactions #1980

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 7 commits into from
Nov 30, 2023
Merged

Conversation

NickSneo
Copy link
Member

@NickSneo NickSneo commented Nov 3, 2023

What does this PR do?

refactored private txs logic, to include more type of private txs
Adds support for EIP1559 private tx

Where should the reviewer start?

Review all files

Why is it needed?

#1966

@NickSneo NickSneo requested a review from conor10 as a code owner November 3, 2023 08:42
@NickSneo NickSneo marked this pull request as draft November 3, 2023 08:42
Copy link

codecov bot commented Nov 3, 2023

Codecov Report

Attention: 29 lines in your changes are missing coverage. Please review.

Comparison is base (9ee5b4f) 68.45% compared to head (c254a72) 68.69%.

Files Patch % Lines
...protocol/eea/crypto/PrivateTransactionDecoder.java 90.32% 4 Missing and 2 partials ⚠️
...rypto/transaction/type/PrivateTransaction1559.java 84.61% 5 Missing and 1 partial ⚠️
...b3j/protocol/eea/crypto/RawPrivateTransaction.java 77.27% 5 Missing ⚠️
...pto/transaction/type/LegacyPrivateTransaction.java 90.00% 4 Missing and 1 partial ⚠️
...n/java/org/web3j/tx/PrivateTransactionManager.java 20.00% 4 Missing ⚠️
.../protocol/eea/crypto/PrivateTxSignServiceImpl.java 0.00% 2 Missing ⚠️
abi/src/main/java/org/web3j/abi/TypeDecoder.java 0.00% 1 Missing ⚠️
Additional details and impacted files
@@             Coverage Diff              @@
##             master    #1980      +/-   ##
============================================
+ Coverage     68.45%   68.69%   +0.24%     
- Complexity     3005     3041      +36     
============================================
  Files           488      490       +2     
  Lines         12568    12715     +147     
  Branches       1643     1653      +10     
============================================
+ Hits           8603     8735     +132     
- Misses         3485     3497      +12     
- Partials        480      483       +3     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

Signed-off-by: Nischal Sharma <[email protected]>
@NickSneo NickSneo marked this pull request as ready for review November 6, 2023 09:22
Copy link
Contributor

@cfelde cfelde left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Some questions around the approach, let's discuss.

}

private static byte[] longToBytes(long x) {
ByteBuffer buffer = ByteBuffer.allocate(Long.BYTES);
buffer.putLong(x);
return buffer.array();
}

public static List<RlpType> asRlpValues(
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Any issue with this being removed for backwards compatibility?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

So every Tx type has its own different asRlpValues(), so it is being transferred from here.

import org.web3j.utils.Numeric;
import org.web3j.utils.Restriction;

public class PrivateTransaction1559 extends RawPrivateTransaction implements ITransaction {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is it not a bit odd that RawTransaction does not implement ITransaction, if PrivateTransaction1559 does? It seems like a bit of a broken pattern?

Genuine question: Why should PrivateTransaction1559 implement the interface is RawTransaction does not?

@@ -24,7 +24,7 @@
import org.web3j.abi.datatypes.generated.Bytes32;
import org.web3j.crypto.Credentials;
import org.web3j.protocol.eea.crypto.PrivateTransactionEncoder;
import org.web3j.protocol.eea.crypto.RawPrivateTransaction;
import org.web3j.protocol.eea.crypto.transaction.type.RawPrivateTransaction;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

As we talked about, I guess this package change will break backwards compatibility?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yeah we can change the class path to original so that it doesn't break anything

@NickSneo NickSneo requested a review from cfelde November 13, 2023 02:49
@jframe
Copy link
Contributor

jframe commented Nov 29, 2023

Hi @NickSneo, Thanks for adding this functionality to web3j, these are the changes we needed for web3signer

@jframe jframe mentioned this pull request Nov 29, 2023
11 tasks
@NickSneo NickSneo merged commit 4b583dd into master Nov 30, 2023
@NickSneo NickSneo deleted the nicks/issue-1966 branch November 30, 2023 09:29
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants