-
Notifications
You must be signed in to change notification settings - Fork 222
Implement CIP35 for Donut hard fork #1431
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
Conversation
Big ints are encoded and decoded as RLP scalars, which are not nullable. The 'nil' tag had no effect, so this commit removes it.
f702603 to
5600d27
Compare
This is necessary in order to verify non-EIP155 signatures, which are supported as EIP-155 does not require clients to use replay-protection.
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.
Left some comments
| tx.data.Payload, | ||
| s.chainId, uint(0), uint(0), | ||
| }) | ||
| } else { |
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.
golang lint rules would ask you to remove the else claus and just return
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.
Turns out we don't have golint (or any drop-in replacement) enabled in our golangci config. If I add it, it gives a ton of errors of different sorts (including some of this rule, e.g. https://github.com/celo-org/celo-blockchain/blob/master/rpc/client.go#L392-L396)
Personally, I am not a fan of this if/else lint rule. I remember when I first used golint I didn't like it and also didn't like that golint doesn't let you disable individual rules. But if you like that rule I can change them.
| tx.data.Amount, | ||
| tx.data.Payload, | ||
| }) | ||
| } else { |
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.
same
| // Update all fork indicator by next pending block number. | ||
| next := new(big.Int).Add(newHead.Number, big.NewInt(1)) | ||
| pool.istanbul = pool.chainconfig.IsIstanbul(next) | ||
| pool.donut = pool.chainconfig.IsDonut(next) |
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.
do we call validateTx after this is enabled? Or old tx will continue to existt on the txpool?
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.
Good point! validateTx() is only called when adding a transaction. For later on it only checks a subset of what validateTx() checks, and this should be checked as well.
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.
I added a commit making it so that unprotected transactions are removed when Donut is activated. I still need to add a test for it, though.
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.
Gave this a look and didn't have any comments beyond what @mcortesi already added 👍
|
Added a test for |
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.
What's here looks good to me. Looks like there's a tx pool conflict, and the CI branches need to be straightened out, but otherwise everything looks ready.
Conflicts: core/types/transaction.go
Thanks! Merged in master and resolved the conflict. |
…e the monorepo PR is merged)
|
Pointed the CI back to monorepo master. This means the new e2e tests won't run, but they will after the corresponding PR on monorepo is merged (I believe this is a chicken-and-egg scenario, but I could be wrong) |
### Description This PR adds e2e tests for CIP35 (support for eth-compatible transactions), to be included in the Donut hard fork. ### Other changes * Modifies the `GenesisConfig` type to allow `null` values for `churritoBlock` and `donutBlock`, which indicate the forks are not to be activated. This is necessary because mycelo (used in the new e2e tests) defaults to activating them, so in order to have them not activated we must be able to specify `null` in the config rather than `undefined` (which means no override). * Sets CI to use the branch `oneeman/cip35` of `celo-blockchain`. This should be reverted to `master` once that branch has been merged, before merging this PR. So I added the "do not merge" label to this PR, to ensure it's not merged until that is done. * Moves the mnemonic used for e2e tests out of the function it was in to be a top-level exported constant. This lets the e2e tests use the mnemonic directly if they need to (and also allows them to derive the validator's address rather than hard-code it and relying on the mnemonic not having changed). * Adds support for `verbose: true` when using mycelo to create a genesis file (to not hide mycelo's console output if verbose is true) ### Tested * e2e tests as part of CI ### Related issues - PR on celo-blockchain: celo-org/celo-blockchain#1431 ### Backwards compatibility No issues, but will need to point back to `celo-blockchain`'s master before merging.
Starting at the Donut hard-fork activation: (a) adds support for ethereum-compatible transactions as specified in CIP35, (b) make replay protection (using EIP-155) mandatory. * Remove rlp:"nil" tag from txdata.GatewayFee. Big ints are encoded and decoded as RLP scalars, which are not nullable. The 'nil' tag had no effect, so this commit removes it. * rlp: handle case of normal EOF in Stream.readFull() * Add support for eth-compatible transactions * Make replay protection mandatory once Donut is activated
Description
This PR implements CIP35 as specified at https://github.com/celo-org/celo-proposals/blob/master/CIPs/cip-0035.md.
Summary of changes:
Transactiontype has a new fieldEthCompatibleto distinguish between normal transactions (with the Celo-only fields) and ethereum-compatible ones (without those fields)EthCompatibleEthCompatibleEthCompatiblefield is encoded asethCompatible.(a)
EthCompatibleis true but Donut has not been activated,(b)
EthCompatibleis true but they have non-trivial values for any of the Celo-only fields (which can't happen if decoding from RLP, but can if decoding from JSON), or(c) Donut has been activated but the transaction doesn't use replay protection (EIP-155)
Other changes
rlp:niltag fromtxdata.GatewayFee. This tag is not respected for*big.Intvalues, and so its presence was misleading.oneeman/cip35-e2e-tests. This was not strictly speaking necessary, since I have a PR on celo-monorepo pointing at this branch, the tests will execute there. Regardless, this change will be reverted to point it back to masterTested
eth_sendTransactionvs usingeth_sendRawTransaction.Backwards compatibility
Transactionand other types like it (e.g.RPCTransaction) have a new field. However, as the zero value for boolean fields isfalse(which means normal Celo transactions), no changes should be required for software importingcelo-blockchainpackages as a library.ethCompatible. This should not break existing software as additional fields are generally ignored during JSON parsing. In particular, contractkit is not affected, as may be seen in the e2e tests.