-
Notifications
You must be signed in to change notification settings - Fork 145
Add arg to take Unix integer as genesis time #686
Add arg to take Unix integer as genesis time #686
Conversation
genesis_time_group = testnet_generator_parser.add_mutually_exclusive_group( | ||
required=True, | ||
) | ||
genesis_time_group.add_argument( | ||
"--genesis-delay", |
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.
You could probably simplify this by changing this to simply compute what the equivalent would be in --genesis-time
and to have it populate that value onto genesis_time
.
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, the description "Seconds before genesis time from now" should be changed to "Set seconds delay after the genesis state is created as genesis time".
Since the usage of --genesis-delay
option is for debugging, and the genesis state takes a long time to create, the "delay" actually starts after the latter is done. So for example when debugging in eth2/beacon/scripts/run_beacon_nodes.py
, the choice of delay can be independent of the time to create the genesis state.
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! left some comments
@@ -156,7 +187,7 @@ def generate_keys(cls, | |||
|
|||
@classmethod | |||
def generate_genesis_state(cls, | |||
genesis_delay: Second, | |||
get_genesis_time: Callable[[], Timestamp], |
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.
Reviewing this a second time I'm a little confused by this API. Can you explain why we don't/can't just pass in a firm timestamp?
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.
There are two possibilities for get_genesis_time
: the one produced with get_genesis_time_from_constant()
and the other by get_genesis_time_from_delay()
. The reason to have a get_genesis_time
interface is beacause for the latter case, the genesis time is determined after the create_mock_genesis finished.
An alternative could be
def generate_genesis_state(..., genesis_time, genesis_delay=None):
state, _ = create_mock_genesis(
...
genesis_time=genesis_time if genesis_time is not None else 0,
)
if genesis_delay is not None:
state = state.copy(genesis_time=Timestamp(int(time.time()) + genesis_delay))
...
Is this all to account for the time it takes to generate the genesis state?
Sent from ProtonMail mobile
…-------- Original Message --------
On Jun 4, 2019, 11:49 AM, Chih Cheng Liang wrote:
@ChihChengLiang commented on this pull request.
---------------------------------------------------------------
In [trinity/plugins/eth2/network_generator/plugin.py](#686 (comment)):
> @@ -156,7 +187,7 @@ def generate_keys(cls,
@classmethod
def generate_genesis_state(cls,
- genesis_delay: Second,
+ get_genesis_time: Callable[[], Timestamp],
There are two possibilities for get_genesis_time: the one produced with get_genesis_time_from_constant()and the other by get_genesis_time_from_delay(). The reason to have a get_genesis_time interface is beacause for the latter case, the genesis time is determined after the create_mock_genesis finished.
An alternative could be
def
generate_genesis_state
(...,
genesis_time
,
genesis_delay
=
None
):
state, _
=
create_mock_genesis(
...
genesis_time
=
genesis_time
if
genesis_time
is
not
None
else
0
,
)
if
genesis_delay
is
not
None
:
state
=
state.copy(
genesis_time
=
Timestamp(
int
(time.time())
+
genesis_delay))
...
—
You are receiving this because you commented.
Reply to this email directly, [view it on GitHub](#686?email_source=notifications&email_token=AAGJHAUE7HNIN45JN4JTNXLPY2TKPA5CNFSM4HR4BW5KYY3PNVWWK3TUL52HS4DFWFIHK3DMKJSXC5LFON2FEZLWNFSXPKTDN5WW2ZLOORPWSZGOB2RZ3LA#discussion_r290418931), or [mute the thread](https://github.com/notifications/unsubscribe-auth/AAGJHAVXAFI57ORI4WU6SULPY2TKPANCNFSM4HR4BW5A).
|
Exactly |
* add arg to take specific genesis time * fix log style * PR feedback * test_missing_genesis_time_arg
What was wrong?
Now Eth2 network generator only takes seconds delay as the genesis time.
How was it fixed?
Add a parser argument to take Unix integer as genesis time
Cute Animal Picture