Skip to content

Commit

Permalink
fix: 1559 tx rlp encoding with access list
Browse files Browse the repository at this point in the history
  • Loading branch information
liewhite committed Dec 27, 2023
1 parent fb46403 commit afbace5
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 18 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -32,9 +32,8 @@
* 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;

Expand All @@ -48,8 +47,7 @@ public Transaction1559(
BigInteger maxPriorityFeePerGas,
BigInteger maxFeePerGas,
List<AccessListObject> accessList) {
super(EIP1559, nonce, null, gasLimit, to, value, data);
this.chainId = chainId;
super(chainId, nonce, null, gasLimit, to, value, data,accessList);
this.maxPriorityFeePerGas = maxPriorityFeePerGas;
this.maxFeePerGas = maxFeePerGas;
}
Expand Down Expand Up @@ -86,7 +84,7 @@ public List<RlpType> asRlpValues(Sign.SignatureData signatureData) {
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())));
Expand Down Expand Up @@ -129,10 +127,6 @@ public BigInteger getGasPrice() {
throw new UnsupportedOperationException("not available for 1559 transaction");
}

public long getChainId() {
return chainId;
}

public BigInteger getMaxPriorityFeePerGas() {
return maxPriorityFeePerGas;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -71,6 +71,18 @@ public List<RlpType> asRlpValues(Sign.SignatureData signatureData) {
result.add(RlpString.create(data));

// access list
result.add(new RlpList(rlpAccessListRlp()));

if (signatureData != null) {
result.add(RlpString.create(Sign.getRecId(signatureData, getChainId())));
result.add(RlpString.create(Bytes.trimLeadingZeroes(signatureData.getR())));
result.add(RlpString.create(Bytes.trimLeadingZeroes(signatureData.getS())));
}

return result;
}
protected List<RlpType> rlpAccessListRlp() {

List<AccessListObject> accessList = getAccessList();
List<RlpType> rlpAccessList = new ArrayList<>();
accessList.forEach(
Expand All @@ -89,15 +101,7 @@ public List<RlpType> asRlpValues(Sign.SignatureData signatureData) {
rlpAccessListObject.add(new RlpList(keyList));
rlpAccessList.add(new RlpList(rlpAccessListObject));
});
result.add(new RlpList(rlpAccessList));

if (signatureData != null) {
result.add(RlpString.create(Sign.getRecId(signatureData, getChainId())));
result.add(RlpString.create(Bytes.trimLeadingZeroes(signatureData.getR())));
result.add(RlpString.create(Bytes.trimLeadingZeroes(signatureData.getS())));
}

return result;
return rlpAccessList;
}

public static Transaction2930 createEtherTransaction(
Expand Down

0 comments on commit afbace5

Please sign in to comment.