-
Notifications
You must be signed in to change notification settings - Fork 976
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
handling altered constants at forks #1101
Comments
I agree that we need this. I'm a bit concerned that the code for this would be very clumsy. Is there a more elegant solution? |
Overwriting loses the ability to have a granular control on the constants on the border of a fork. See my above transfer example. Given the current structure of the pyspec, I don't see a path that would be elegant :/ py-evm has a notion of VirtualMachines and StateMachines that are applied at certain block or slot heights. Constants can change at these heights and these machines can easily handle constants on the border. Just remembered proto and I discussed this weeks ago in the context of "fork timelines" for testing and defining production and testnet configurations (https://github.com/ethereum/eth2.0-specs/tree/dev/configs/fork_timelines). The easy solution is to just define these constant changes here and let clients handle the fork complexity locally instead of defining a mechanism in spec like signature domains. We can then hack a solution in the pytests/test generation instead of in spec. |
The current phase 1 executable PR #1061 builds the phases into If there’s a hard fork For the cross-fork tests, we can take the import eth2spec.phase0.spec as phase0_spec
import eth2spec.phase1.spec as phase0_<FORK_NAME>_spec
import eth2spec.phase1.spec as phase1_spec
def get_spec(epoch, fork_timeline):
if fork_timeline['phase0'] <= epoch < fork_timeline['phase0_<FORK_NAME>']:
return phase0_spec
elif fork_timeline['phase0_<FORK_NAME>'] <= epoch < fork_timeline['phase1']:
return phase0_<FORK_NAME>_spec
elif epoch >= fork_timeline['phase1']:
return phase1_spec
else:
raise Exception('Out of fork_timeline') |
How often is a pure constant change applicable? I would invest in infrastructure facilitating more general changes to the state transition function. (See also item 8 in #1054 which suggests removing transfers from the phase 0 spec.) |
In @protolambda 's test_format design, it seems there's one
I guess we need to update constant_presets to serve for multiple forks/phases like: phase0:
SHARD_COUNT: 8
TARGET_COMMITTEE_SIZE: 4
...
MAX_TRANSFERS: 0
phase1:
BYTES_PER_SHARD_BLOCK: 16384
...
MAX_TRANSFERS: 16 only list the new or altered constants. |
Current approach is to never modify config vars. Instead to just have new vars at new forks |
We currently don't have a good mechanism for handling a changed constant at a fork boundary. We likely want to use the same
BeaconState
versioning technique as for signatures.The first constant we are discussing changing in production is
MAX_TRANSFERS
(from 0 to non-zero). We need to ensure that blocks prior to the fork epoch have validity conditionlen(block.transfers) == 0
but after the fork epoch havelen(block.transfers) == non_zero_value
.We don't necessarily need to build this in to the spec at this point, but it will certainly be a requirement that clients can handle different constants per fork version.
Solution might look something like
get_constant(state, var_string_name, epoch)
The text was updated successfully, but these errors were encountered: