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

Store proposed producers and proposed finalizers in building block #188

Merged
merged 1 commit into from
May 23, 2024

Conversation

heifner
Copy link
Member

@heifner heifner commented May 22, 2024

The chainbase global_property_object was used to store finalizer_policy during block construction as a means to provide automatic rollback if the transaction/block failed. See #99. However, finalizer_policy contains non-shared types of std::vector and fc::crypto::blslib::bls_public_key.

This PR solves the problem of avoiding side-effects of proposed finalizer policy made in an aborted transaction in a different way than committing the speculative changes into the global_property_object in chainbase. Now we store the speculative changes in the transaction context. Then if we commit the transaction, it copies them over (assuming they are not nullopt) from the transaction context to the building block. This avoids having to add a shared version of the finalizer_policy and bls_public_key.

For symmetry, the proposer schedule in Savanna was modified to also be managed the same way as finalier_policy in transaction_context.

This PR removes proposed_fin_pol_block_num and proposed_fin_pol from global_property_object and therefore is not state compatible with previous versions. The proposed schedule proposed_schedule_block_num & proposed_schedule were not removed from global_property_object because they are still needed pre-Savanna.

Resolves #182

…lock instead of global_property_object. Fixes bug with non-shared types of finalizer_policy being stored in chainbase.
@heifner heifner requested review from linh2931 and spoonincode May 22, 2024 17:07
@heifner heifner added the OCI Work exclusive to OCI team label May 22, 2024
@ericpassmore
Copy link
Contributor

ericpassmore commented May 22, 2024

Validated this works, no crash. Version v1.0.0-dev-1c4fb165390c179d16292517beefab25b549c422

Log message New finalizer policy becoming active in block seems to be duplicated. Checked that the correct key was in use by the block producer.

info  2024-05-22T18:52:29.054 net-1     block_header_state.cpp:262    finish_next          ] Finalizer policy generation change: 1 -> 2
info  2024-05-22T18:52:29.054 net-1     block_header_state.cpp:264    finish_next          ] New finalizer policy becoming active in block 000005a11f0af1785746b07b1a8bee85ec54fe1961464897976b1134cad11337: {"generation":2,"threshold":3,"finalizers":[{"description":"bpa","weight":1,"public_key":"PUB_BLS_GMw0JRDY2nUeSszpW_OHb8xjfCc61FP_Ei9qoZ63r_-twOPn9fTOeHDDFccYgL8Ar7NbwrV-Z9RJXrTSNPtEjEbdJwnSsgsaIulRIDwFGiKg0XQuABfEhhyGxklXORQTEvep8Q"},{"description":"bpc","weight":1,"public_key":"PUB_BLS_kIQ5EsjgIyL8XUDWqeTn6BrZCi0ziS7Wx8tAFEADMIvFPS_j8mmqe-8fvdet8E4KwPfRMOyOcf3qY7wN-TCN6piHLLxn1CMlzRGpWwdT8b1cki9GG0gRT1ExOrgY8hcLmVB8Nw"},{"description":"bpb","weight":1,"public_key":"PUB_BLS_woMzcifQYxMIuh227prW04BoGScfV_67RUDcsnu4CqeOOHNq5TKkHIlpVG9j13IX_tWjAWPZ-oft1Hxj5yG5YQi2mPDxtSTDmOPU00TfHRsaBIfZFcgx3-Pqy2D3I1UO5NeStA"}]}
info  2024-05-22T18:52:29.059 nodeos    block_header_state.cpp:262    finish_next          ] Finalizer policy generation change: 1 -> 2
info  2024-05-22T18:52:29.059 nodeos    block_header_state.cpp:264    finish_next          ] New finalizer policy becoming active in block 000005a11f0af1785746b07b1a8bee85ec54fe1961464897976b1134cad11337: {"generation":2,"threshold":3,"finalizers":[{"description":"bpa","weight":1,"public_key":"PUB_BLS_GMw0JRDY2nUeSszpW_OHb8xjfCc61FP_Ei9qoZ63r_-twOPn9fTOeHDDFccYgL8Ar7NbwrV-Z9RJXrTSNPtEjEbdJwnSsgsaIulRIDwFGiKg0XQuABfEhhyGxklXORQTEvep8Q"},{"description":"bpc","weight":1,"public_key":"PUB_BLS_kIQ5EsjgIyL8XUDWqeTn6BrZCi0ziS7Wx8tAFEADMIvFPS_j8mmqe-8fvdet8E4KwPfRMOyOcf3qY7wN-TCN6piHLLxn1CMlzRGpWwdT8b1cki9GG0gRT1ExOrgY8hcLmVB8Nw"},{"description":"bpb","weight":1,"public_key":"PUB_BLS_woMzcifQYxMIuh227prW04BoGScfV_67RUDcsnu4CqeOOHNq5TKkHIlpVG9j13IX_tWjAWPZ-oft1Hxj5yG5YQi2mPDxtSTDmOPU00TfHRsaBIfZFcgx3-Pqy2D3I1UO5NeStA"}]}
cleos get table eosio eosio finalizers
{
  "rows": [{
      "finalizer_name": "bpa",
      "active_key_id": 0,
      "active_key_binary": "18cc342510d8da751e4acce95bf3876fcc637c273ad453ff122f6aa19eb7afffadc0e3e7f5f4ce7870c315c71880bf00afb35bc2b57e67d4495eb4d234fb448c46dd2709d2b20b1a22e951203c051a22a0d1742e0017c4861c86c64957391413",
      "finalizer_key_count": 1
    },{
      "finalizer_name": "bpb",
      "active_key_id": 3,
      "active_key_binary": "c283337227d0631308ba1db6ee9ad6d3806819271f57febb4540dcb27bb80aa78e38736ae532a41c8969546f63d77217fed5a30163d9fa87edd47c63e721b96108b698f0f1b524c398e3d4d344df1d1b1a0487d915c831dfe3eacb60f723550e",
      "finalizer_key_count": 2
    },{
      "finalizer_name": "bpc",
      "active_key_id": 2,
      "active_key_binary": "90843912c8e02322fc5d40d6a9e4e7e81ad90a2d33892ed6c7cb40144003308bc53d2fe3f269aa7bef1fbdd7adf04e0ac0f7d130ec8e71fdea63bc0df9308dea98872cbc67d42325cd11a95b0753f1bd5c922f461b48114f51313ab818f2170b",
      "finalizer_key_count": 1
    }
  ],
  "more": false,
  "next_key": ""
}
 cleos get table eosio eosio finkeys   
{
  "rows": [{
      "id": 0,
      "finalizer_name": "bpa",
      "finalizer_key": "PUB_BLS_GMw0JRDY2nUeSszpW_OHb8xjfCc61FP_Ei9qoZ63r_-twOPn9fTOeHDDFccYgL8Ar7NbwrV-Z9RJXrTSNPtEjEbdJwnSsgsaIulRIDwFGiKg0XQuABfEhhyGxklXORQTEvep8Q",
      "finalizer_key_binary": "18cc342510d8da751e4acce95bf3876fcc637c273ad453ff122f6aa19eb7afffadc0e3e7f5f4ce7870c315c71880bf00afb35bc2b57e67d4495eb4d234fb448c46dd2709d2b20b1a22e951203c051a22a0d1742e0017c4861c86c64957391413"
    },{
      "id": 1,
      "finalizer_name": "bpb",
      "finalizer_key": "PUB_BLS_OKiUyiTv4_KbgO2AaGO4xRUIgdwY4kl0itPqfjpVtgPh_Pyq9fA7sUsHzVd3QToE6dsjEDnTUaM9CkF08IGUus2FTq7No5biTa3IR3vgYFFyj3GK4ejzhfyUc-nERNoLUn0OOA",
      "finalizer_key_binary": "38a894ca24efe3f29b80ed806863b8c5150881dc18e249748ad3ea7e3a55b603e1fcfcaaf5f03bb14b07cd5777413a04e9db231039d351a33d0a4174f08194bacd854eaecda396e24dadc8477be06051728f718ae1e8f385fc9473e9c444da0b"
    },{
      "id": 2,
      "finalizer_name": "bpc",
      "finalizer_key": "PUB_BLS_kIQ5EsjgIyL8XUDWqeTn6BrZCi0ziS7Wx8tAFEADMIvFPS_j8mmqe-8fvdet8E4KwPfRMOyOcf3qY7wN-TCN6piHLLxn1CMlzRGpWwdT8b1cki9GG0gRT1ExOrgY8hcLmVB8Nw",
      "finalizer_key_binary": "90843912c8e02322fc5d40d6a9e4e7e81ad90a2d33892ed6c7cb40144003308bc53d2fe3f269aa7bef1fbdd7adf04e0ac0f7d130ec8e71fdea63bc0df9308dea98872cbc67d42325cd11a95b0753f1bd5c922f461b48114f51313ab818f2170b"
    },{
      "id": 3,
      "finalizer_name": "bpb",
      "finalizer_key": "PUB_BLS_woMzcifQYxMIuh227prW04BoGScfV_67RUDcsnu4CqeOOHNq5TKkHIlpVG9j13IX_tWjAWPZ-oft1Hxj5yG5YQi2mPDxtSTDmOPU00TfHRsaBIfZFcgx3-Pqy2D3I1UO5NeStA",
      "finalizer_key_binary": "c283337227d0631308ba1db6ee9ad6d3806819271f57febb4540dcb27bb80aa78e38736ae532a41c8969546f63d77217fed5a30163d9fa87edd47c63e721b96108b698f0f1b524c398e3d4d344df1d1b1a0487d915c831dfe3eacb60f723550e"
    }
  ],
  "more": false,
  "next_key": ""
}

@ericpassmore
Copy link
Contributor

ericpassmore commented May 22, 2024

Reran the tests.

  • Transition to Savanna at block 187
  • Stopped nodeos instance 2 after LIB 434 2024-05-22T20:08:28.000
  • Restarted and ran network to LIB 493 2024-05-22T20:08:56.000
  • Registered New BLS Key
  • Ran network to LIB 611 2024-05-22T20:09:56.500
  • Actfinkey policy change in log between 641 and 642
  • Checked network LIB 644 2024-05-22T20:10:13.000
info  2024-05-22T20:06:23.964 nodeos    controller.cpp:1363           transition_to_savann ] Transitioning to savanna, IF Genesis Block 140, IF Critical Block 186
info  2024-05-22T20:06:23.964 nodeos    controller.cpp:1384           operator()           ] Transition to instant finality happening after block 186, First IF Proper Block 187
2024-05-22T20:10:13.000 signed by bpa [trxs: 0, lib: 641, net: 0, cpu: 100, elapsed: 105, time: 321, latency: -102 ms]
info  2024-05-22T20:10:13.353 net-1     block_header_state.cpp:262    finish_next          ] Finalizer policy generation change: 1 -> 2
info  2024-05-22T20:10:13.354 net-1     block_header_state.cpp:264    finish_next          ] New finalizer policy becoming active in block 000002857cafecb928e1194e9be0817de6c53665829c2b1fa1765f1f69072000: {"generation":2,"threshold":3,"finalizers":[{"description":"bpa","weight":1,"public_key":"PUB_BLS__R2F6U9SbAxXUq79ro6BFhFqhY2KTDZ2wvpbSt0WxQn1Ps4Lh-h923lSOPdsEoMBGfG1TMTJsakaiSztWsjygRT-V7OO9SYa9kpe0WA40e9anSaCkcGnDu4WIWwRxA8W60VBRw"},{"description":"bpc","weight":1,"public_key":"PUB_BLS_RBLVFJB_CdRWGl_PTvLQjLT2z-riKPGjPzeJb4McgmEJKM1vUusfVd35YQz5_DEDg0Wnj5z4JTbbt4X9Zo-hw4oeUeLboK16NBQ8GxgkI4YPXNDo3E3Fvv8UfCjFyjIPAoGbpA"},{"description":"bpb","weight":1,"public_key":"PUB_BLS_woMzcifQYxMIuh227prW04BoGScfV_67RUDcsnu4CqeOOHNq5TKkHIlpVG9j13IX_tWjAWPZ-oft1Hxj5yG5YQi2mPDxtSTDmOPU00TfHRsaBIfZFcgx3-Pqy2D3I1UO5NeStA"}]}
info  2024-05-22T20:10:13.360 nodeos    block_header_state.cpp:262    finish_next          ] Finalizer policy generation change: 1 -> 2
info  2024-05-22T20:10:13.360 nodeos    block_header_state.cpp:264    finish_next          ] New finalizer policy becoming active in block 000002857cafecb928e1194e9be0817de6c53665829c2b1fa1765f1f69072000: {"generation":2,"threshold":3,"finalizers":[{"description":"bpa","weight":1,"public_key":"PUB_BLS__R2F6U9SbAxXUq79ro6BFhFqhY2KTDZ2wvpbSt0WxQn1Ps4Lh-h923lSOPdsEoMBGfG1TMTJsakaiSztWsjygRT-V7OO9SYa9kpe0WA40e9anSaCkcGnDu4WIWwRxA8W60VBRw"},{"description":"bpc","weight":1,"public_key":"PUB_BLS_RBLVFJB_CdRWGl_PTvLQjLT2z-riKPGjPzeJb4McgmEJKM1vUusfVd35YQz5_DEDg0Wnj5z4JTbbt4X9Zo-hw4oeUeLboK16NBQ8GxgkI4YPXNDo3E3Fvv8UfCjFyjIPAoGbpA"},{"description":"bpb","weight":1,"public_key":"PUB_BLS_woMzcifQYxMIuh227prW04BoGScfV_67RUDcsnu4CqeOOHNq5TKkHIlpVG9j13IX_tWjAWPZ-oft1Hxj5yG5YQi2mPDxtSTDmOPU00TfHRsaBIfZFcgx3-Pqy2D3I1UO5NeStA"}]}
info  2024-05-22T20:10:13.360 nodeos    controller.cpp:3457           log_applied          ] Received block 7cafecb928e1194e... #645 @ 2024-05-22T20:10:13.500 signed by bpa [trxs: 0, lib: 642, net: 0, cpu: 100, elapsed: 86, time: 357, latency: -139 ms]

@heifner
Copy link
Member Author

heifner commented May 22, 2024

Log message New finalizer policy becoming active in block seems to be duplicated.

I will address this in a separate PR: #192

@heifner heifner merged commit c1a4895 into main May 23, 2024
36 checks passed
@heifner heifner deleted the GH-182-gpo branch May 23, 2024 16:21
@ericpassmore
Copy link
Contributor

Note:start
group: IF
category: BUG
summary: Improve data safety for transaction rollback and avoid unintended side effects for a proposed finalizer policy change during an aborted transaction.
Note:end

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
OCI Work exclusive to OCI team
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Nodeos Crashes after actfinkey action
4 participants