-
-
Notifications
You must be signed in to change notification settings - Fork 1.7k
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
Add AccessList to 1559 transaction rlp encoding #1992
Merged
Merged
Changes from all commits
Commits
Show all changes
3 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -14,25 +14,24 @@ | |
|
||
import java.math.BigInteger; | ||
import java.util.ArrayList; | ||
import java.util.Collections; | ||
import java.util.List; | ||
|
||
import org.web3j.crypto.AccessListObject; | ||
import org.web3j.crypto.Sign; | ||
import org.web3j.rlp.RlpList; | ||
import org.web3j.rlp.RlpString; | ||
import org.web3j.rlp.RlpType; | ||
import org.web3j.utils.Bytes; | ||
import org.web3j.utils.Numeric; | ||
|
||
import static org.web3j.crypto.transaction.type.TransactionType.EIP1559; | ||
|
||
/** | ||
* Transaction class used for signing 1559 transactions locally.<br> | ||
* For the specification, refer to p4 of the <a href="http://gavwood.com/paper.pdf">yellow | ||
* paper</a>. | ||
*/ | ||
public class Transaction1559 extends LegacyTransaction implements ITransaction { | ||
public class Transaction1559 extends Transaction2930 implements ITransaction { | ||
|
||
private long chainId; | ||
private BigInteger maxPriorityFeePerGas; | ||
private BigInteger maxFeePerGas; | ||
|
||
|
@@ -45,8 +44,22 @@ | |
String data, | ||
BigInteger maxPriorityFeePerGas, | ||
BigInteger maxFeePerGas) { | ||
super(EIP1559, nonce, null, gasLimit, to, value, data); | ||
this.chainId = chainId; | ||
super(chainId, nonce, null, gasLimit, to, value, data, Collections.emptyList()); | ||
this.maxPriorityFeePerGas = maxPriorityFeePerGas; | ||
this.maxFeePerGas = maxFeePerGas; | ||
} | ||
|
||
public Transaction1559( | ||
long chainId, | ||
BigInteger nonce, | ||
BigInteger gasLimit, | ||
String to, | ||
BigInteger value, | ||
String data, | ||
BigInteger maxPriorityFeePerGas, | ||
BigInteger maxFeePerGas, | ||
List<AccessListObject> accessList) { | ||
super(chainId, nonce, null, gasLimit, to, value, data, accessList); | ||
this.maxPriorityFeePerGas = maxPriorityFeePerGas; | ||
this.maxFeePerGas = maxFeePerGas; | ||
} | ||
|
@@ -83,7 +96,7 @@ | |
result.add(RlpString.create(data)); | ||
|
||
// access list | ||
result.add(new RlpList()); | ||
result.add(new RlpList(rlpAccessListRlp())); | ||
|
||
if (signatureData != null) { | ||
result.add(RlpString.create(Sign.getRecId(signatureData, getChainId()))); | ||
|
@@ -103,7 +116,38 @@ | |
BigInteger maxPriorityFeePerGas, | ||
BigInteger maxFeePerGas) { | ||
return new Transaction1559( | ||
chainId, nonce, gasLimit, to, value, "", maxPriorityFeePerGas, maxFeePerGas); | ||
chainId, | ||
nonce, | ||
gasLimit, | ||
to, | ||
value, | ||
"", | ||
maxPriorityFeePerGas, | ||
maxFeePerGas, | ||
Collections.emptyList()); | ||
} | ||
|
||
public static Transaction1559 createTransaction( | ||
long chainId, | ||
BigInteger nonce, | ||
BigInteger gasLimit, | ||
String to, | ||
BigInteger value, | ||
String data, | ||
BigInteger maxPriorityFeePerGas, | ||
BigInteger maxFeePerGas, | ||
List<AccessListObject> accessList) { | ||
|
||
return new Transaction1559( | ||
chainId, | ||
nonce, | ||
gasLimit, | ||
to, | ||
value, | ||
data, | ||
maxPriorityFeePerGas, | ||
maxFeePerGas, | ||
accessList); | ||
} | ||
|
||
public static Transaction1559 createTransaction( | ||
|
@@ -121,12 +165,13 @@ | |
} | ||
|
||
@Override | ||
public BigInteger getGasPrice() { | ||
throw new UnsupportedOperationException("not available for 1559 transaction"); | ||
public TransactionType getType() { | ||
return TransactionType.EIP1559; | ||
} | ||
|
||
public long getChainId() { | ||
return chainId; | ||
@Override | ||
public BigInteger getGasPrice() { | ||
throw new UnsupportedOperationException("not available for 1559 transaction"); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Should be nice to have a test case for this |
||
} | ||
|
||
public BigInteger getMaxPriorityFeePerGas() { | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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.
Even if it looks simple a test case will be worth here, also will improve the test coverage