Skip to content

Commit aedace1

Browse files
authored
Merge pull request #1546 from o1-labs/bugfix/graphql-transaction
Updated handling in graphql to be like ocaml
2 parents 277a79f + bd2304f commit aedace1

File tree

2 files changed

+140
-1
lines changed

2 files changed

+140
-1
lines changed

CHANGELOG.md

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -99,7 +99,11 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
9999
reusing build caches for efficiency
100100
([#1539](https://github.com/o1-labs/mina-rust/pull/1539))
101101
- **Ledger**: document, clean and add tests for the crate `mina-tree`
102-
([#1531](https://github.com/o1-labs/mina-rust/pull/1531).
102+
([#1531](https://github.com/o1-labs/mina-rust/pull/1531)).
103+
- **GraphQL**: fixed parsing when neither signature nor proof is given.
104+
See issue [#1464](https://github.com/o1-labs/mina-rust/issues/1464).
105+
Fixed in [#1546](https://github.com/o1-labs/mina-rust/pull/1546/)
106+
([#1546](https://github.com/o1-labs/mina-rust/pull/1546))
103107

104108
## v0.17.0
105109

node/native/src/graphql/zkapp.rs

Lines changed: 135 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -324,6 +324,7 @@ impl TryFrom<InputGraphQLAuthorization> for MinaBaseControlStableV2 {
324324
)?;
325325
Ok(MinaBaseControlStableV2::Proof(Box::new(proof)))
326326
}
327+
(None, None) => Ok(MinaBaseControlStableV2::NoneGiven),
327328
_ => Err(ConversionError::Custom(
328329
"Either signature or proof must be provided, but not both".into(),
329330
)),
@@ -1566,6 +1567,15 @@ mod test {
15661567
assert_eq!(mina_empty_memo.to_base58check(), expected);
15671568
}
15681569

1570+
#[test]
1571+
fn test_parse_zkapp_bug_1464_no_proof_nor_signature() {
1572+
let input = create_input_graphql_zkapp_bug_1464();
1573+
let _converted: MinaBaseUserCommandStableV2 = input
1574+
.zkapp_command
1575+
.try_into()
1576+
.expect("Failed to parse input");
1577+
}
1578+
15691579
#[test]
15701580
fn test_zkapp_from_input() {
15711581
let bytes = include_bytes!("../../../../tests/files/zkapps/valid_zkapp.bin");
@@ -1613,6 +1623,15 @@ mod test {
16131623
};
16141624
let converted: Result<MinaBaseControlStableV2, _> = proof.try_into();
16151625
assert!(converted.is_ok());
1626+
1627+
let proof = InputGraphQLAuthorization {
1628+
signature: None,
1629+
proof: None,
1630+
};
1631+
let converted: MinaBaseControlStableV2 =
1632+
proof.try_into().expect("Error parsing None given auth");
1633+
1634+
assert_eq!(converted, MinaBaseControlStableV2::NoneGiven);
16161635
}
16171636

16181637
fn create_input_graphql_zkapp() -> InputGraphQLZkapp {
@@ -1839,6 +1858,122 @@ mod test {
18391858
}
18401859
}
18411860

1861+
fn create_input_graphql_zkapp_bug_1464() -> InputGraphQLZkapp {
1862+
InputGraphQLZkapp {
1863+
zkapp_command: InputGraphQLZkappCommand {
1864+
memo: Some("E4YdMZb5VHHE51HPFPs1zUHnyus1q7RW61tWq1F4FNYrp5FKtKZMh".to_string()),
1865+
fee_payer: InputGraphQLFeePayer {
1866+
body: InputGraphQLFeePayerBody {
1867+
public_key: "B62qmGcEhZsZ2EMh2EzRXDJEmaD9PUJcW5xdNq2im2xNVuX2bsEPjoj".to_string(),
1868+
fee: "200000000".to_string(),
1869+
valid_until: None,
1870+
nonce: "250".to_string(),
1871+
},
1872+
authorization: "7mXMa44TWfDGtQmsfGtkRogZVzGVYqosP6qkXCBApsjoZ2ye2Y5AL2VWzp7m5CxkTjZhcoqtDVJkiQRm38tAmQdhpTTsSEr6".to_string(),
1873+
},
1874+
account_updates: vec![
1875+
InputGraphQLAccountUpdate {
1876+
body: InputGraphQLAccountUpdateBody {
1877+
call_depth: 0,
1878+
public_key: "B62qmGcEhZsZ2EMh2EzRXDJEmaD9PUJcW5xdNq2im2xNVuX2bsEPjoj".to_string(),
1879+
token_id: "wSHV2S4qX9jFsLjQo8r1BsMLH2ZRKsZx6EJd1sbozGPieEC4Jf".to_string(),
1880+
update: InputGraphQLAccountUpdateUpdate {
1881+
app_state: vec![
1882+
None,
1883+
None,
1884+
None,
1885+
None,
1886+
None,
1887+
None,
1888+
None,
1889+
None,
1890+
],
1891+
delegate: None,
1892+
verification_key: None,
1893+
permissions: None,
1894+
zkapp_uri: None,
1895+
token_symbol: None,
1896+
timing: None,
1897+
voting_for: None,
1898+
},
1899+
balance_change: InputGraphQLBalanceChange {
1900+
magnitude: "0".to_string(),
1901+
sgn: "Positive".to_string(),
1902+
},
1903+
increment_nonce: false,
1904+
events: vec![vec![
1905+
"852".to_owned(),
1906+
"993".to_owned(),
1907+
"540".to_owned(),
1908+
"951".to_owned(),
1909+
"340".to_owned()
1910+
]],
1911+
actions: vec![],
1912+
call_data: "0".to_string(),
1913+
preconditions: InputGraphQLPreconditions {
1914+
network: InputGraphQLPreconditionsNetwork {
1915+
snarked_ledger_hash: None,
1916+
blockchain_length: None,
1917+
min_window_density: None,
1918+
total_currency: None,
1919+
global_slot_since_genesis: None,
1920+
staking_epoch_data: InputGraphQLPreconditionsNetworkEpochData {
1921+
ledger: InputGraphQLPreconditionsNetworkLedger {
1922+
hash: None,
1923+
total_currency: None,
1924+
},
1925+
seed: None,
1926+
start_checkpoint: None,
1927+
lock_checkpoint: None,
1928+
epoch_length: None,
1929+
},
1930+
next_epoch_data: InputGraphQLPreconditionsNetworkEpochData {
1931+
ledger: InputGraphQLPreconditionsNetworkLedger {
1932+
hash: None,
1933+
total_currency: None,
1934+
},
1935+
seed: None,
1936+
start_checkpoint: None,
1937+
lock_checkpoint: None,
1938+
epoch_length: None,
1939+
},
1940+
},
1941+
account: InputGraphQLPreconditionsAccount {
1942+
balance: None,
1943+
nonce: None,
1944+
receipt_chain_hash: None,
1945+
delegate: None,
1946+
state: vec![
1947+
None, None, None, None, None, None, None, None
1948+
],
1949+
action_state: None,
1950+
proved_state: None,
1951+
is_new: None,
1952+
},
1953+
valid_while: None,
1954+
},
1955+
use_full_commitment: false,
1956+
implicit_account_creation_fee: false,
1957+
may_use_token: InputGraphQLMayUseToken {
1958+
parents_own_token: false,
1959+
inherit_from_parent: false,
1960+
},
1961+
authorization_kind: InputGraphQLAuthorizationKind {
1962+
is_signed: false,
1963+
is_proved: false,
1964+
verification_key_hash: Some("3392518251768960475377392625298437850623664973002200885669375116181514017494".parse().unwrap()),
1965+
},
1966+
},
1967+
authorization: InputGraphQLAuthorization {
1968+
proof: None,
1969+
signature: None
1970+
},
1971+
},
1972+
],
1973+
},
1974+
}
1975+
}
1976+
18421977
#[test]
18431978
pub fn test_bigint_to_decimal() {
18441979
let bigint = BigInt::from_decimal("1").unwrap();

0 commit comments

Comments
 (0)