-
Notifications
You must be signed in to change notification settings - Fork 11.4k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[graphql/rpc] Protocol config impl (#13402)
- Loading branch information
Showing
9 changed files
with
206 additions
and
4 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
// Copyright (c) Mysten Labs, Inc. | ||
// SPDX-License-Identifier: Apache-2.0 | ||
|
||
use async_graphql::*; | ||
|
||
#[derive(Clone, Debug, PartialEq, Eq, SimpleObject)] | ||
pub(crate) struct DisplayEntry { | ||
pub key: String, | ||
pub value: String, | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
// Copyright (c) Mysten Labs, Inc. | ||
// SPDX-License-Identifier: Apache-2.0 | ||
|
||
use crate::types::object::Object; | ||
use async_graphql::*; | ||
|
||
use super::{address::Address, big_int::BigInt}; | ||
|
||
#[derive(Clone, Debug, PartialEq, Eq, SimpleObject)] | ||
pub(crate) struct GasInput { | ||
pub gas_sponsor: Option<Address>, | ||
pub gas_payment: Option<Vec<Object>>, | ||
pub gas_price: Option<BigInt>, | ||
pub gas_budget: Option<BigInt>, | ||
} | ||
|
||
#[derive(Clone, Debug, PartialEq, Eq, SimpleObject)] | ||
pub(crate) struct GasCostSummary { | ||
pub computation_cost: Option<BigInt>, | ||
pub storage_cost: Option<BigInt>, | ||
pub storage_rebate: Option<BigInt>, | ||
pub non_refundable_storage_fee: Option<BigInt>, | ||
} | ||
|
||
#[derive(Clone, Debug, PartialEq, Eq, SimpleObject)] | ||
pub(crate) struct GasEffects { | ||
pub gas_object: Option<Object>, | ||
pub gas_summary: Option<GasCostSummary>, | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,83 @@ | ||
// Copyright (c) Mysten Labs, Inc. | ||
// SPDX-License-Identifier: Apache-2.0 | ||
|
||
use async_graphql::*; | ||
|
||
use crate::server::data_provider::fetch_protocol_config; | ||
|
||
#[derive(Clone, Debug, PartialEq, Eq, SimpleObject)] | ||
pub(crate) struct ProtocolConfigAttr { | ||
pub key: String, | ||
pub value: String, | ||
} | ||
|
||
#[derive(Clone, Debug, PartialEq, Eq, SimpleObject)] | ||
pub(crate) struct ProtocolConfigFeatureFlag { | ||
pub key: String, | ||
pub value: bool, | ||
} | ||
|
||
#[derive(Clone, Debug, PartialEq, Eq)] | ||
pub(crate) struct ProtocolConfigs { | ||
pub configs: Vec<ProtocolConfigAttr>, | ||
pub feature_flags: Vec<ProtocolConfigFeatureFlag>, | ||
pub protocol_version: u64, | ||
} | ||
|
||
#[allow(unreachable_code)] | ||
#[allow(unused_variables)] | ||
#[Object] | ||
impl ProtocolConfigs { | ||
async fn configs(&self, ctx: &Context<'_>) -> Result<Option<Vec<ProtocolConfigAttr>>> { | ||
Ok(Some( | ||
fetch_protocol_config(ctx.data_unchecked::<sui_sdk::SuiClient>(), None) | ||
.await? | ||
.configs, | ||
)) | ||
} | ||
|
||
async fn feature_flags( | ||
&self, | ||
ctx: &Context<'_>, | ||
) -> Result<Option<Vec<ProtocolConfigFeatureFlag>>> { | ||
Ok(Some( | ||
fetch_protocol_config(ctx.data_unchecked::<sui_sdk::SuiClient>(), None) | ||
.await? | ||
.feature_flags, | ||
)) | ||
} | ||
|
||
async fn protocol_version(&self, ctx: &Context<'_>) -> Result<u64> { | ||
Ok( | ||
fetch_protocol_config(ctx.data_unchecked::<sui_sdk::SuiClient>(), None) | ||
.await? | ||
.protocol_version, | ||
) | ||
} | ||
|
||
async fn config(&self, ctx: &Context<'_>, key: String) -> Result<Option<ProtocolConfigAttr>> { | ||
match self | ||
.configs(ctx) | ||
.await? | ||
.map(|configs| configs.into_iter().find(|config| config.key == key)) | ||
{ | ||
Some(config) => Ok(config), | ||
None => Ok(None), | ||
} | ||
} | ||
|
||
async fn feature_flag( | ||
&self, | ||
ctx: &Context<'_>, | ||
key: String, | ||
) -> Result<Option<ProtocolConfigFeatureFlag>> { | ||
match self | ||
.feature_flags(ctx) | ||
.await? | ||
.map(|flags| flags.into_iter().find(|config| config.key == key)) | ||
{ | ||
Some(config) => Ok(config), | ||
None => Ok(None), | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
587ae58
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.
Successfully deployed to the following URLs:
sui-typescript-docs – ./sdk/docs
sui-typescript-docs-git-main-mysten-labs.vercel.app
sui-typescript-docs-mysten-labs.vercel.app
sui-typescript-docs.vercel.app
sui-wallet-kit.vercel.app
587ae58
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.
4 Validators 500/s Owned Transactions Benchmark Results
4 Validators 500/s Shared Transactions Benchmark Results
20 Validators 50/s Owned Transactions Benchmark Results
20 Validators 50/s Shared Transactions Benchmark Results
Narwhal Benchmark Results