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

Cleanup - Fix bug with stop endpoint & add object type to get objects #892

Merged
merged 2 commits into from
Mar 17, 2022

Conversation

arun-koshy
Copy link
Contributor

Few cleanup items here

  • /sui/stop endpoint was not working properly because server_state needed to be cleared so you can run /genesis & /start again.

  • Make /objects a little bit more useful by adding the object type as part of the return. i.e.

{
    "objects": [{
        "objectId": "3E603B3ADFF7B9A36DEA3215946A74C4F0E9927C",
        "objType": "0x2::Coin::Coin<0x2::GAS::GAS>",
        "version": "SequenceNumber(0)",
        "objectDigest": "o#e3fa1aedcaf88ca202dc5a26eb0c5b62a1c75f784acd92bd447418d77c2d4380"
    }, {
        "objectId": "47D918DBDD13E294A52BB275B07940318C5AB4FC",
        "objType": "0x2::Coin::Coin<0x2::GAS::GAS>",
        "version": "SequenceNumber(0)",
        "objectDigest": "o#b8fc9fa23c5c88e5b97825ef156ae6a7eeb6c9201922277131e29a1656072451"
    }, {
        "objectId": "D11E5547DC75073AC5D3AE0CFD8A442D84650663",
        "objType": "0x2::Coin::Coin<0x2::GAS::GAS>",
        "version": "SequenceNumber(0)",
        "objectDigest": "o#c9004b61adef15af6511dba7522976bc1e9b386fdecc7d9993835265c92d93d4"
    }, {
        "objectId": "DA5BFFB4DF89F26E0C2DD5AA14065419483916BE",
        "objType": "0x2::Coin::Coin<0x2::GAS::GAS>",
        "version": "SequenceNumber(0)",
        "objectDigest": "o#c1cdccc1bc450ff29c15950792bbccb9a51617423f3f3af0e8119f62e8beec54"
    }, {
        "objectId": "F2EFB4D9F3E5756B24C868B65164F4CE28C0D8E9",
        "objType": "0x2::Coin::Coin<0x2::GAS::GAS>",
        "version": "SequenceNumber(0)",
        "objectDigest": "o#59e1a71728f34d0bbc2c2ac3c56244a0858f2fe56707a702dc1ebcbd94a9bfc4"
    }]
}

@arun-koshy arun-koshy requested review from patrickkuo and 666lcz March 17, 2022 08:05
Copy link
Contributor

@patrickkuo patrickkuo left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

// Taking state object without returning ownership
let mut state = server_context.server_state.lock().await;
let state = state.as_mut().ok_or_else(server_state_error)?;
{
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

why the extra braces??

Copy link
Contributor Author

@arun-koshy arun-koshy Mar 17, 2022

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

So that the initial lock on the server_state will clear when it goes out of scope. Then I can set it to None. Not sure if there is better way to do this?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I see, In that case we can use take() instead of as_mut() here, then we can remove the brace and don't need to set the context to None afterward

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Now I can use take() properly, nice!

@arun-koshy arun-koshy merged commit f7cef3a into main Mar 17, 2022
@arun-koshy arun-koshy deleted the arun/rest-bug-fix branch March 17, 2022 17:56
mwtian pushed a commit that referenced this pull request Sep 12, 2022
…892)

Fixes a bug where the primary would panic if an RPC comes in while a
node is shutting down. Instead this patch just returns an error to
requester.

Fixes: #891
mwtian pushed a commit to mwtian/sui that referenced this pull request Sep 29, 2022
…ystenLabs#892)

Fixes a bug where the primary would panic if an RPC comes in while a
node is shutting down. Instead this patch just returns an error to
requester.

Fixes: MystenLabs#891
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants