Skip to content
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

feat: access list support for signature calculation #17041

Open
wants to merge 5 commits into
base: main
Choose a base branch
from

Conversation

mmyslariane
Copy link

Description:
When sending transaction with access list the public key and the address of the transaction sender is not properly calculated and it results in error for example of INVALID_ACCOUNT_ID. We added changes in EthTxData.java and EthTxSigs.java to fix this behaviour by firstly read accessList as object of RLPList instance and put it different variable accessListAsRLP. If this variable is present we transform it to array of Object containing byte array and then we add this to RLPEncoder.
We also put unit tests to check if now transactions on which we found this error are now calculating proper signature.

Related issue(s):
#17040

Notes for reviewer:

Checklist

  • Documented (Code comments, README, etc.)
  • Tested (unit, integration, etc.)

…ure in EthTxSigs by passing it as array of object and encoding it as list in RLPEncoder
@mmyslariane mmyslariane requested review from a team as code owners December 12, 2024 13:57
@@ -45,6 +46,7 @@ public record EthTxData(
BigInteger value, // weibar, always positive - note that high-bit might be ON in RLP encoding: still positive
byte[] callData,
byte[] accessList,
RLPList accessListAsRLP,
Copy link
Member

@david-bakin-sl david-bakin-sl Dec 13, 2024

Choose a reason for hiding this comment

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

This is awkward. This is a fairly widely used class from a module that is intended to hide certain implementation details. One of those details would be the use of the headlong library - from which the RLPList type comes. And sure enough, the headlong library isn't exported from the module's module-info.java.

Problem is - what to replace it with?

No good suggestions, but what I have is: Since the only other use is in EthTxSigs in this very same module (and I wouldn't anticipate this field being used anywhere else in the near future): You could hold it in the record as an Object - and then EthTxSigs would have to know the intimate details of EthTxData - but it is in the same package ... (And also being an Object would signal to users outside the package that they should stay away from it.)

Copy link
Author

Choose a reason for hiding this comment

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

Ok, I have a question, do you wish to get rid off using of headlong library in the EthTxData class or do not use RLPList as a field in this class? Because if you only wish to not use RLPList as an record than maybe the best solution would be holding this record field accessListAsRLP as an array of Object? Instead of using the new method in EthTxSigs

static Object[] encodeRLPList(RLPList rlpList) {
        return rlpList.elements().stream().map(rlpItem -> {
            if (rlpItem.isList()) {
                return encodeRLPList(rlpItem.asRLPList());
            }
            else {
                return rlpItem.data();
            }
        }).toArray();
    }

I could always move it to EthTxData and do the transformation here and save the result as the new record as an array of Object and then only use the result in calculating the signature. Would that be ok?

Copy link
Member

Choose a reason for hiding this comment

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

RIght, not get rid of the use of headlong, just don't expose any headlong type (RLPList in this case) as a record field which means other modules will see it.

Holding it as an Object[] is just fine - just do whatever you need to do in EthTxSigs. Sound OK?

Copy link
Author

Choose a reason for hiding this comment

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

Sounds great! Ok, so I will make this change and push it soon

@david-bakin-sl david-bakin-sl changed the title #17040 access list support for signature calculation feat: access list support for signature calculation Dec 13, 2024
@david-bakin-sl david-bakin-sl added this to the v0.58 milestone Dec 13, 2024
@arianejasuwienas arianejasuwienas added the Feature Enhancement Enhancing an existing feature driven by business requirements. Typically backwards compatible. label Jan 7, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Feature Enhancement Enhancing an existing feature driven by business requirements. Typically backwards compatible.
Projects
Status: In progress
Development

Successfully merging this pull request may close these issues.

3 participants