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

Implement EIP232 new transaction format #375

Closed
NIC619 opened this issue Feb 16, 2018 · 1 comment
Closed

Implement EIP232 new transaction format #375

NIC619 opened this issue Feb 16, 2018 · 1 comment

Comments

@NIC619
Copy link
Contributor

NIC619 commented Feb 16, 2018

What is wrong?

Discussion started in #326 which are about how to supply salt value to contract-creating transaction in Sharding where CREATE2 style contract creation is implemented. CREATE2 takes in a value salt and init code code, address of the new contract is derived from hashing these two values together: sha3(salt | code).

In the short term, we can simply add a salt field in transaction format, but this field is only useful in contract creation transactions. EIP232 provides a more elastic format which adopts the notion of a version(or format) number. With EIP232 we can assign different type of transaction with different version/format number which corresponds to different transaction format.

How can it be fixed

Implement EIP232 in Sharding.
@pipermerriam provides a rough sketch of the possible implementation in the thread(#326 (comment)):
Quote:

class EIP232Transaction(rlp.Serializable):
    fields = (
        ('version', ...),
        ('inner_data', sedes.binary),
    (
    transaction_formats = {
        1: TransactionFormatA,
        2: TransactionFormatB,
    }

    def __init__(self, *args, **kwargs):
        super().__init__(*args, **kwargs)
        self.txn_data = rlp.decode(self.inner_data, sedes=self.transaction_formats[self.version])

    def __getattr__(self, name):
        return getattr(self.txn_data, name)

We have an outer transaction class which contains a mapping of version numbers to inner transaction classes. Then, during initialization, we decode the outer data packet, and then lookup the appropriate inner transaction class and use it to decode the inner data packet. Then we put some convenience APIs on the outer class to allow direct property access to the inner transaction properties.

@hwwhww
Copy link
Contributor

hwwhww commented Sep 26, 2018

deactivate

@hwwhww hwwhww closed this as completed Sep 26, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants