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

EIP158 & 160 Hardfork #3179

Merged
merged 8 commits into from
Nov 14, 2016
Merged

EIP158 & 160 Hardfork #3179

merged 8 commits into from
Nov 14, 2016

Conversation

obscuren
Copy link
Contributor

@obscuren obscuren commented Oct 19, 2016

This PR implements the EIP158 proposal and EIP160.

It also changes the location where the chain configuration is kept to the params package. This is done so that any time a HF proposal is added or if the chain config needs modification, only a single location needs to be changed. This also means that the vm.Environment no longer has a RuleSet but a ChainConfig directly. All locations in the tests where core.GenerateChain took a nil parameter for the ChainConfig are now passing params.TestChainConfig.

ChainConfig is no longer optional, it is an requirement. Passing nil anywhere (as done in most GenerateChain calls) will result in a hard panic.

Note for reviewers: please make sure that a params.TestChainConfig is suitable for your tests. It has the following parameters: homestead = 0, dao = 0, daoEnabled = true, EIP150 = true, EIP158 = true.


TODO list

  • refactored core.ChainConfig and moved to params package instead
  • If an account is empty it's no longer written to the trie. An empty account is defined as (balance=0, nonce=0, storage=0, code=0).
  • An empty account is redefined as either non-existent or empty.
  • Zero value calls and zero value suicides no longer consume the 25k creation costs.
  • Gas costs for EXP
  • Clearing batches (1k)
  • Implement 158.2 (just in case, separate commit)
  • replay protection (EIP#155)

@mention-bot
Copy link

@obscuren, thanks for your PR! By analyzing the history of the files in this pull request, we identified @fjl, @karalabe and @zsfelfoldi to be potential reviewers.

@obscuren obscuren force-pushed the eip-158 branch 17 times, most recently from 00b71cf to 97b4109 Compare October 20, 2016 13:50
@obscuren obscuren changed the title EIP158 Hardfork EIP158 & 160 Hardfork Oct 20, 2016
@obscuren obscuren force-pushed the eip-158 branch 6 times, most recently from eda9c0f to 2e6397f Compare October 27, 2016 11:07

// Nothing should be returned when an error is thrown.
return nil, addr, err
} else if env.ChainConfig().IsEIP170(env.BlockNumber()) && len(ret) > params.MaxCodeSize {
Copy link
Contributor

Choose a reason for hiding this comment

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

A few lines up, back at L:157, there's if err == nil, where the clause which does setCode is performed. I suggest to check MaxCodeSize up there instead of down here, and then also skip the SetCode stuff.

@obscuren obscuren force-pushed the eip-158 branch 5 times, most recently from 7f8828b to e6c838f Compare November 11, 2016 12:30
EIP155Block *big.Int `json:"EIP155Block"` // EIP155 HF block
EIP158Block *big.Int `json:"EIP158Block"` // EIP158 HF block
EIP155Block *big.Int `json:"eip155Block"` // EIP155 HF block
EIP158Block *big.Int `json:"eiP158Block"` // EIP158 HF block
Copy link
Contributor

Choose a reason for hiding this comment

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

this P is uppercase

if tx.Protected() {
signer = types.NewEIP155Signer(tx.ChainId())
}
if _, r, _ := types.SignatureValues(signer, tx); r == nil {
Copy link
Contributor

@fjl fjl Nov 11, 2016

Choose a reason for hiding this comment

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

You can use RawSignatureValues here (and below). The point of this check is to see whether the fields were set in JSON.

signer = types.NewEIP155Signer(tx.ChainId())
}
from, _ := types.Sender(signer, tx)
v, r, s := types.SignatureValues(signer, tx)
Copy link
Contributor

Choose a reason for hiding this comment

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

I think this should be RawSignatureValues. The v, r, s JSON fields are new in 1.5 and we can define the semantics for them. Raw values are preferable here because the client should be able to reconstruct the whole transaction.

e.g. if you do

client, _ := ethclient.Dial("http://127.0.0.1:8085")
tx, _ := client.TransactionByHash(ctx, common.HexToHash("...."))
from, _ := types.Sender(types.NewEIP155Signer(signer), tx))

The from value should be the same as it was on the server. Normalising the values breaks this.

@obscuren obscuren force-pushed the eip-158 branch 2 times, most recently from 7449ade to aa3017c Compare November 11, 2016 17:05
@@ -40,10 +40,11 @@ type ChainConfig struct {

EIP155Block *big.Int `json:"eip155Block"` // EIP155 HF block
EIP158Block *big.Int `json:"eiP158Block"` // EIP158 HF block
EIP170Block *big.Int `json:"eip158Block"` // EIP170 HF block
Copy link
Contributor

Choose a reason for hiding this comment

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

s/eip158Block/eip170Block no?

@obscuren obscuren force-pushed the eip-158 branch 3 times, most recently from f108749 to 75bf510 Compare November 11, 2016 22:38
This commit implements EIP158 part 1, 2, 3 & 4

1. If an account is empty it's no longer written to the trie. An empty
  account is defined as (balance=0, nonce=0, storage=0, code=0).
2. Delete an empty account if it's touched
3. An empty account is redefined as either non-existent or empty.
4. Zero value calls and zero value suicides no longer consume the 25k
  reation costs.

params: moved core/config to params

Signed-off-by: Jeffrey Wilcke <jeffrey@ethereum.org>
@fjl
Copy link
Contributor

fjl commented Nov 13, 2016

@obscuren please fix the go vet issue

@fjl fjl merged commit ca73dea into ethereum:develop Nov 14, 2016
@obscuren obscuren deleted the eip-158 branch November 15, 2016 20:46
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants