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
Upgrade chain simulator #3358
Upgrade chain simulator #3358
Conversation
34cdb68
to
80f52da
Compare
4068053
to
72475d5
Compare
72475d5
to
50f95fa
Compare
425a4da
to
c586fc3
Compare
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.
Setting the PrevKeyHash is bugged.
ok = push(CreateTx), | ||
SignedTx = create_tx(Config), | ||
TxHash = aetx_sign:hash(SignedTx), | ||
ct:log("TxHash ~p", [TxHash]), |
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.
This log message wasn't here before.
@@ -674,8 +677,16 @@ init_per_group(GrpName, Config) -> | |||
Config; | |||
_ -> | |||
{ok, ChainP} = start_chain_process(), | |||
{ok, #{pubkey := Initiator, privkey := InitiatorSK}} = aec_chain_sim:new_account(1000000000000000000000000000000000000000000000000000000000000000), |
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.
please define multipliers:
100000000000000000000000000000000000000000000000 -> ... * ?AE_MULT
@@ -674,8 +677,16 @@ init_per_group(GrpName, Config) -> | |||
Config; | |||
_ -> | |||
{ok, ChainP} = start_chain_process(), | |||
{ok, #{pubkey := Initiator, privkey := InitiatorSK}} = aec_chain_sim:new_account(1000000000000000000000000000000000000000000000000000000000000000), | |||
{ok, #{pubkey := Responder, privkey := ResponderSK}} = aec_chain_sim:new_account(1000000000000000000000000000000000000000000000000000000000000000), |
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.
How many AE is that?
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.
"enough"
apps/aecore/test/aec_chain_sim.erl
Outdated
%% | ||
%% Equivalent to add_keyblock(main) | ||
%% | ||
add_keyblock() -> | ||
add_keyblock(main). | ||
|
||
-spec block_by_hash(block_hash()) -> {ok, sim_keyblock() |sim_microblock()}. | ||
-spec block_by_hash(block_hash()) -> {ok, aec_blocks:key_block() |aec_blocks:micro_block()}. |
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.
-spec block_by_hash(block_hash()) -> {ok, aec_blocks:key_block() |aec_blocks:micro_block()}. | |
-spec block_by_hash(block_hash()) -> {ok, aec_blocks:block()}. |
apps/aecore/test/aec_chain_sim.erl
Outdated
#{hash := PrevHash, header := TopHdr} = hd(Blocks), | ||
#{block := B} = hd(Blocks), | ||
TopHdr = aec_blocks:to_header(B), | ||
{ok, PrevHash} = aec_headers:hash_header(TopHdr), | ||
?LOG("PrevHash = ~p", [PrevHash]), | ||
PrevKeyHash = aec_headers:prev_key_hash(TopHdr), |
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.
@uwiger @radrow It seems that the original chain simulator also sets the PrevKeyHash improperly.
This will always point to the genesis hash.
Let me demonstrate:
1. Genesis
2. Genesis <- Gen1Micro1(Prev: Genesis, PrevKey: Genesis) <- ...
3. Genesis <- ... <- Key1(Prev: Gen1MicroN, PrevKey: Genesis)
4. Genesis <- ... <- Key1(Prev: Gen1MicroN, PrevKey: Genesis) <- Gen2Micro1(Prev: Key1, PrevKey: **Genesis**
The correct code:
PrevKeyHash = case aec_headers:is_key(TopHdr) of true -> TopHdrHash; false -> aec_headers:prev_key_hash(TopHdr) end,
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
The simulator is getting mature and becomes an efficient tool and from my perspective, that deserves for some kind of refactoring later (@gorbak25, @radrow, @uwiger your thoughts about?). Also glad to see aec_trees, aec_headers for now it's more real). In the future, it could be nice to see some refactoring here like:
P.S. We just got a small merge conflict here, after you merge I am going to fix my part too. (We have to pass predefined chain state here (I do in the parent manager, as we have configurated genesis pointer before sim is run) |
* First edits to the chain sim. Added staking contract. * Txs are passing * Fixed some SC tests, HTTP is failing * checkpoint * typo * Fix event type * Fix events * Fix the upgrade * Chain sim is finally fully operational * Fix some mismatches * Cleanup * Fix header hash, push aesophia, minor sanity * Minor fix Co-authored-by: Grzegorz Uriasz <gorbak25@gmail.com>
* First edits to the chain sim. Added staking contract. * Txs are passing * Fixed some SC tests, HTTP is failing * checkpoint * typo * Fix event type * Fix events * Fix the upgrade * Chain sim is finally fully operational * Fix some mismatches * Cleanup * Fix header hash, push aesophia, minor sanity * Minor fix Co-authored-by: Grzegorz Uriasz <gorbak25@gmail.com>
* First edits to the chain sim. Added staking contract. * Txs are passing * Fixed some SC tests, HTTP is failing * checkpoint * typo * Fix event type * Fix events * Fix the upgrade * Chain sim is finally fully operational * Fix some mismatches * Cleanup * Fix header hash, push aesophia, minor sanity * Minor fix Co-authored-by: Grzegorz Uriasz <gorbak25@gmail.com>
* First edits to the chain sim. Added staking contract. * Txs are passing * Fixed some SC tests, HTTP is failing * checkpoint * typo * Fix event type * Fix events * Fix the upgrade * Chain sim is finally fully operational * Fix some mismatches * Cleanup * Fix header hash, push aesophia, minor sanity * Minor fix Co-authored-by: Grzegorz Uriasz <gorbak25@gmail.com>
* First edits to the chain sim. Added staking contract. * Txs are passing * Fixed some SC tests, HTTP is failing * checkpoint * typo * Fix event type * Fix events * Fix the upgrade * Chain sim is finally fully operational * Fix some mismatches * Cleanup * Fix header hash, push aesophia, minor sanity * Minor fix Co-authored-by: Grzegorz Uriasz <gorbak25@gmail.com>
…n branch (#2938) Upgrade chain simulator (#3358) * First edits to the chain sim. Added staking contract. * Txs are passing * Fixed some SC tests, HTTP is failing * checkpoint * typo * Fix event type * Fix events * Fix the upgrade * Chain sim is finally fully operational * Fix some mismatches * Cleanup * Fix header hash, push aesophia, minor sanity * Minor fix Co-authored-by: Grzegorz Uriasz <gorbak25@gmail.com>
Upgrade chain simulator (#3358) * First edits to the chain sim. Added staking contract. * Txs are passing * Fixed some SC tests, HTTP is failing * checkpoint * typo * Fix event type * Fix events * Fix the upgrade * Chain sim is finally fully operational * Fix some mismatches * Cleanup * Fix header hash, push aesophia, minor sanity * Minor fix Co-authored-by: Grzegorz Uriasz <gorbak25@gmail.com>
More features, serious block representation, no event discrimination