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

Expose gas cost in chain info #1244

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -11,3 +11,4 @@ lcov.info
version-compatibility/Cargo.lock
benches/benches-outputs/Cargo.lock
benches/benches-outputs/src/test_gas_costs_output.rs
.idea
1 change: 1 addition & 0 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -110,3 +110,4 @@ itertools = "0.10"
insta = "1.8"
tempfile = "3.4"
tikv-jemallocator = "0.5"

109 changes: 109 additions & 0 deletions crates/client/assets/schema.sdl
Original file line number Diff line number Diff line change
Expand Up @@ -96,6 +96,7 @@ type ChainInfo {
baseChainHeight: U32!
peerCount: Int!
consensusParameters: ConsensusParameters!
gasCosts: GasCosts!
}

type ChangeOutput {
Expand Down Expand Up @@ -252,6 +253,11 @@ type ContractOutput {
stateRoot: Bytes32!
}

type DependentCost {
base: U64!
depPerUnit: U64!
}

input ExcludeInput {
"""
Utxos to exclude from the selection.
Expand All @@ -271,6 +277,109 @@ type FailureStatus {
}


type GasCosts {
add: U64!
addi: U64!
aloc: U64!
and: U64!
andi: U64!
bal: U64!
bhei: U64!
bhsh: U64!
burn: U64!
cb: U64!
cfei: U64!
cfsi: U64!
croo: U64!
div: U64!
divi: U64!
ecr: U64!
eq: U64!
exp: U64!
expi: U64!
flag: U64!
gm: U64!
gt: U64!
gtf: U64!
ji: U64!
jmp: U64!
jne: U64!
jnei: U64!
jnzi: U64!
jmpf: U64!
jmpb: U64!
jnzf: U64!
jnzb: U64!
jnef: U64!
jneb: U64!
k256: U64!
lb: U64!
log: U64!
lt: U64!
lw: U64!
mcpi: U64!
mint: U64!
mlog: U64!
modOp: U64!
modi: U64!
moveOp: U64!
movi: U64!
mroo: U64!
mul: U64!
muli: U64!
mldv: U64!
noop: U64!
not: U64!
or: U64!
ori: U64!
ret: U64!
rvrt: U64!
s256: U64!
sb: U64!
scwq: U64!
sll: U64!
slli: U64!
srl: U64!
srli: U64!
srw: U64!
sub: U64!
subi: U64!
sw: U64!
sww: U64!
swwq: U64!
time: U64!
tr: U64!
tro: U64!
wdcm: U64!
wqcm: U64!
wdop: U64!
wqop: U64!
wdml: U64!
wqml: U64!
wddv: U64!
wqdv: U64!
wdmd: U64!
wqmd: U64!
wdam: U64!
wqam: U64!
wdmm: U64!
wqmm: U64!
xor: U64!
xori: U64!
call: DependentCost!
ccp: DependentCost!
csiz: DependentCost!
ldc: DependentCost!
logd: DependentCost!
mcl: DependentCost!
mcli: DependentCost!
mcp: DependentCost!
meq: DependentCost!
retd: DependentCost!
smo: DependentCost!
srwq: DependentCost!
}

type Genesis {
"""
The chain configs define what consensus type to use, what settlement layer to use,
Expand Down
114 changes: 114 additions & 0 deletions crates/client/src/client/schema/chain.rs
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,119 @@ pub struct ConsensusParameters {
pub chain_id: U64,
}

#[derive(cynic::QueryFragment, Debug)]
#[cynic(schema_path = "./assets/schema.sdl")]
pub struct GasCosts {
pub add: U64,
pub addi: U64,
pub aloc: U64,
pub and: U64,
pub andi: U64,
pub bal: U64,
pub bhei: U64,
pub bhsh: U64,
pub burn: U64,
pub cb: U64,
pub cfei: U64,
pub cfsi: U64,
pub croo: U64,
pub div: U64,
pub divi: U64,
pub ecr: U64,
pub eq: U64,
pub exp: U64,
pub expi: U64,
pub flag: U64,
pub gm: U64,
pub gt: U64,
pub gtf: U64,
pub ji: U64,
pub jmp: U64,
pub jne: U64,
pub jnei: U64,
pub jnzi: U64,
pub jmpf: U64,
pub jmpb: U64,
pub jnzf: U64,
pub jnzb: U64,
pub jnef: U64,
pub jneb: U64,
pub k256: U64,
pub lb: U64,
pub log: U64,
pub lt: U64,
pub lw: U64,
pub mcpi: U64,
pub mint: U64,
pub mlog: U64,
pub mod_op: U64,
pub modi: U64,
pub move_op: U64,
pub movi: U64,
pub mroo: U64,
pub mul: U64,
pub muli: U64,
pub mldv: U64,
pub noop: U64,
pub not: U64,
pub or: U64,
pub ori: U64,
pub ret: U64,
pub rvrt: U64,
pub s256: U64,
pub sb: U64,
pub scwq: U64,
pub sll: U64,
pub slli: U64,
pub srl: U64,
pub srli: U64,
pub srw: U64,
pub sub: U64,
pub subi: U64,
pub sw: U64,
pub sww: U64,
pub swwq: U64,
pub time: U64,
pub tr: U64,
pub tro: U64,
pub wdcm: U64,
pub wqcm: U64,
pub wdop: U64,
pub wqop: U64,
pub wdml: U64,
pub wqml: U64,
pub wddv: U64,
pub wqdv: U64,
pub wdmd: U64,
pub wqmd: U64,
pub wdam: U64,
pub wqam: U64,
pub wdmm: U64,
pub wqmm: U64,
pub xor: U64,
pub xori: U64,

pub call: DependentCost,
pub ccp: DependentCost,
pub csiz: DependentCost,
pub ldc: DependentCost,
pub logd: DependentCost,
pub mcl: DependentCost,
pub mcli: DependentCost,
pub mcp: DependentCost,
pub meq: DependentCost,
pub retd: DependentCost,
pub smo: DependentCost,
pub srwq: DependentCost,
}

#[derive(cynic::QueryFragment, Debug)]
#[cynic(schema_path = "./assets/schema.sdl")]
pub struct DependentCost {
pub base: U64,
pub dep_per_unit: U64,
}

impl From<ConsensusParameters> for TxConsensusParameters {
fn from(params: ConsensusParameters) -> Self {
Self {
Expand Down Expand Up @@ -62,6 +175,7 @@ pub struct ChainInfo {
pub peer_count: i32,
pub latest_block: Block,
pub consensus_parameters: ConsensusParameters,
pub gas_costs: GasCosts,
}

#[cfg(test)]
Expand Down
Loading
Loading