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

Add support for non-byte chain id values #234

Closed
conor10 opened this issue Nov 10, 2017 · 9 comments
Closed

Add support for non-byte chain id values #234

conor10 opened this issue Nov 10, 2017 · 9 comments
Labels

Comments

@conor10
Copy link
Contributor

conor10 commented Nov 10, 2017

In the current web3j implementation, the ChainId is of type byte.

The reason for this is historical,to support EIP-155, where you place a byte value in the raw transaction object - see here.

However, further down the original EIP discussion it is mentioned that the v value when the transaction is RLP encoded shouldn't be limited to a single byte. So web3j could be enhanced to accommodate this.

This would mean enhancing the Transaction encoder so that a long value can be provided:

https://github.com/web3j/web3j/blob/master/crypto/src/main/java/org/web3j/crypto/TransactionEncoder.java#L34

The SignatureData object should not however be modified as this requires a byte value for v in transaction signing. This means that in the initial encode of the RawTransaction the chain id field should be RLP encoded, which would require modification of the current encode method.

The ChainId itself should probably become an enum wrapping the underlying long value.

@fcorneli
Copy link
Contributor

fcorneli commented Apr 2, 2018

@conor10 Any news on this issue? We would want to use a geth dev network with chainId 1337...

@fcorneli
Copy link
Contributor

fcorneli commented Apr 5, 2018

I've been looking into this one a bit. See PR #478
ChainId of type byte is really all over the place.
Easiest to move forward here I guess is to first have a TransactionDecoder and proper signature validation within RawTransaction and work your way up from there.

@fcorneli
Copy link
Contributor

fcorneli commented Apr 6, 2018

Started working on that TransactionDecoder:
https://github.com/e-Contract/web3j/tree/transaction-decoder

@fcorneli
Copy link
Contributor

Seems like Sign.signedMessageToKey has a problem when the message has been signed with an explicit chain id.

@fcorneli
Copy link
Contributor

TransactionDecoder ready: #491
Funny thing: change chainId within TransactionDecoderTest.testDecodingSignedChainId to something else than 1, and the test explodes. But anyway, it's already a starting point I guess...

@fcorneli
Copy link
Contributor

You can change chainId within TransactionDecoderTest.testDecodingSignedChainId up to 46 without any problem. Above 46, the v requires more than one byte I guess, so it fails from there on.

@fcorneli
Copy link
Contributor

Next step I guess is to allow for byte array v within Sign.SignatureData:
https://github.com/e-Contract/web3j/tree/signaturedata-v-array

@adridadou
Copy link

any news on that? it's limiting if we want to use it for non public chains ...

@d10r
Copy link
Contributor

d10r commented Sep 11, 2019

Looks like this was fixed in #913, included in release 4.3.
Unfortunately the last android build is 4.2 though. (update: nomore the case, there's no android builds including this fix)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

4 participants