-
Notifications
You must be signed in to change notification settings - Fork 20.4k
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
core, vm, common: define constantinople fork + shift #16045
Conversation
I wonder why is |
@axic SHL does memory allocs as it needs to grow the bignum, and only afterwards is it clipped to 256 bits. |
Oh, that is a good point. Perhaps even worth noting in the EIP. Is it possible to have it operate on a fixed 256 bit length? |
It is, but what we really should do is swap out the entire bignums-on-stack implementation with a 256-bit-fixedlength-on-stack. It's a pretty big undertaking (which may be worth doing) |
Actually isn't this quite a big problem with for example multiplying |
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.
Generally looks good to me, just disable it on all code paths for now imho. Also pls gofmt.
core/vm/jump_table.go
Outdated
// byzantium and contantinople instructions. | ||
func NewConstantinopleInstructionSet() [256]operation { | ||
// instructions that can be executed during the byzantium phase. | ||
instructionSet := NewHomesteadInstructionSet() |
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.
NewHomesteadInstructionSet -> NewByzantiumInstructionSet
params/config.go
Outdated
|
||
// AllCliqueProtocolChanges contains every protocol change (EIPs) introduced | ||
// and accepted by the Ethereum core developers into the Clique consensus. | ||
// | ||
// This configuration is intentionally not using keyed fields to force anyone | ||
// adding flags to the config to also have to set these fields. | ||
AllCliqueProtocolChanges = &ChainConfig{big.NewInt(1337), big.NewInt(0), nil, false, big.NewInt(0), common.Hash{}, big.NewInt(0), big.NewInt(0), big.NewInt(0), nil, &CliqueConfig{Period: 0, Epoch: 30000}} | ||
AllCliqueProtocolChanges = &ChainConfig{big.NewInt(1337), big.NewInt(0), nil, false, big.NewInt(0), common.Hash{}, big.NewInt(0), big.NewInt(0), big.NewInt(0), big.NewInt(0), nil, &CliqueConfig{Period: 0, Epoch: 30000}} |
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 don't think we should enable it before it's actually accepted. --dev
uses these and we don't really want users to start using alpha code.
params/config.go
Outdated
@@ -82,16 +82,16 @@ var ( | |||
// | |||
// This configuration is intentionally not using keyed fields to force anyone | |||
// adding flags to the config to also have to set these fields. | |||
AllEthashProtocolChanges = &ChainConfig{big.NewInt(1337), big.NewInt(0), nil, false, big.NewInt(0), common.Hash{}, big.NewInt(0), big.NewInt(0), big.NewInt(0), new(EthashConfig), nil} | |||
AllEthashProtocolChanges = &ChainConfig{big.NewInt(1337), big.NewInt(0), nil, false, big.NewInt(0), common.Hash{}, big.NewInt(0), big.NewInt(0), big.NewInt(0), big.NewInt(0), new(EthashConfig), nil} |
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 don't think we should enable it before it's actually accepted. --dev
uses these and we don't really want users to start using alpha code.
cmd/puppeth/wizard_genesis.go
Outdated
fmt.Println() | ||
fmt.Printf("Which block should Constantinople come into effect? (default = %v)\n", w.conf.Genesis.Config.ConstantinopleBlock) | ||
w.conf.Genesis.Config.ConstantinopleBlock = w.readDefaultBigInt(w.conf.Genesis.Config.ConstantinopleBlock) | ||
|
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 don't think puppeth should offer Constantinople until it's actually finalized. Otherwise people will end up with broken chains.
b5c9446
to
26b8d50
Compare
Review concerns addressed, rebased to fix conflicts. PTAL |
@@ -63,6 +63,9 @@ const ( | |||
XOR | |||
NOT | |||
BYTE | |||
SHL | |||
SHR | |||
SAR |
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.
Ah, missed this previously. You'll need to add these opcodes to the opcode
-> string
map in the same file a few hundred lines below this into opCodeToString
.
Fixed, ptal |
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.
LGTM
* core, vm, common: define constantinople fork, start implementation of shift instructions * vm: more testcases * vm: add tests for intpool erroneous intpool handling * core, vm, common: fix constantinople review concerns * vm: add string<->op definitions for new opcodes
* core, vm, common: define constantinople fork, start implementation of shift instructions * vm: more testcases * vm: add tests for intpool erroneous intpool handling * core, vm, common: fix constantinople review concerns * vm: add string<->op definitions for new opcodes
This PR defines Constantinople hard fork in genesis and instruction set. Additionally, it implementes
SHR
,SHL
andSAR
, along with testcases defined in the EIP .Benchmarks:
The new shifts are defined with gascost
GasFastestStep
, same asADD
,SUB
,GT
,LT
,SLT
,SGT
,EQ
,ISZERO
,AND
,XOR
,OR
,NOT
andBYTE
.Selecting only those in the benchmark results, and ordering them by speed, we get:
They weigh in around the average of the other ops (we could probably improve
SLT
andSGT
by not allocating as many bigints.)This should not go in 1.8.0, but does not need to be "constantinople-complete" to be merged to master: the sooner we get it in the better -- the only prerequisite should be that it will not interfere with pre-constantinople vm runtime. If it panic's when constantinople is enabled, that's fine -- the more testing we get the better, and gives the test-team the possibility to validate their testcases across clients.