Add support for markets with permissioned cranks (#170)
* Add optional crank authority to markets * Introduce separate ConsumeEventsPermissioned instruction
This commit is contained in:
parent
d82f6cd7a0
commit
0c730d678f
|
@ -272,7 +272,7 @@ checksum = "5d85653f070353a16313d0046f173f70d1aadd5b42600a14de626f0dfb3473a5"
|
|||
dependencies = [
|
||||
"byteorder",
|
||||
"digest 0.8.1",
|
||||
"rand_core",
|
||||
"rand_core 0.5.1",
|
||||
"subtle",
|
||||
"zeroize",
|
||||
]
|
||||
|
@ -406,7 +406,18 @@ checksum = "7abc8dd8451921606d809ba32e95b6111925cd2906060d2dcc29c070220503eb"
|
|||
dependencies = [
|
||||
"cfg-if 0.1.10",
|
||||
"libc",
|
||||
"wasi",
|
||||
"wasi 0.9.0+wasi-snapshot-preview1",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "getrandom"
|
||||
version = "0.2.3"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "7fcd999463524c52659517fe2cea98493cfe485d10565e7b0fb07dbba7ad2753"
|
||||
dependencies = [
|
||||
"cfg-if 1.0.0",
|
||||
"libc",
|
||||
"wasi 0.10.2+wasi-snapshot-preview1",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
|
@ -516,7 +527,7 @@ dependencies = [
|
|||
"libsecp256k1-core",
|
||||
"libsecp256k1-gen-ecmult",
|
||||
"libsecp256k1-gen-genmult",
|
||||
"rand",
|
||||
"rand 0.7.3",
|
||||
"serde",
|
||||
"sha2",
|
||||
"typenum",
|
||||
|
@ -688,18 +699,18 @@ dependencies = [
|
|||
|
||||
[[package]]
|
||||
name = "proptest"
|
||||
version = "0.10.0"
|
||||
version = "1.0.0"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "2520fe6373cf6a3a61e2d200e987c183778ade8d9248ac3e6614ab0edfe4a0c1"
|
||||
checksum = "1e0d9cc07f18492d879586c92b485def06bc850da3118075cd45d50e9c95b0e5"
|
||||
dependencies = [
|
||||
"bit-set",
|
||||
"bitflags",
|
||||
"byteorder",
|
||||
"lazy_static",
|
||||
"num-traits",
|
||||
"quick-error",
|
||||
"rand",
|
||||
"rand_chacha",
|
||||
"quick-error 2.0.1",
|
||||
"rand 0.8.4",
|
||||
"rand_chacha 0.3.1",
|
||||
"rand_xorshift",
|
||||
"regex-syntax",
|
||||
"rusty-fork",
|
||||
|
@ -708,9 +719,9 @@ dependencies = [
|
|||
|
||||
[[package]]
|
||||
name = "proptest-derive"
|
||||
version = "0.2.0"
|
||||
version = "0.3.0"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "051d9d20dbe9e9dfe594328b6eaab72ccf571fee818991dd1c1ba5469b5f32d4"
|
||||
checksum = "90b46295382dc76166cb7cf2bb4a97952464e4b7ed5a43e6cd34e1fec3349ddc"
|
||||
dependencies = [
|
||||
"proc-macro2 0.4.30",
|
||||
"quote 0.6.13",
|
||||
|
@ -723,6 +734,12 @@ version = "1.2.3"
|
|||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "a1d01941d82fa2ab50be1e79e6714289dd7cde78eba4c074bc5a4374f650dfe0"
|
||||
|
||||
[[package]]
|
||||
name = "quick-error"
|
||||
version = "2.0.1"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "a993555f31e5a609f617c12db6250dedcac1b0a85076912c436e6fc9b2c8e6a3"
|
||||
|
||||
[[package]]
|
||||
name = "quote"
|
||||
version = "0.6.13"
|
||||
|
@ -747,13 +764,24 @@ version = "0.7.3"
|
|||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "6a6b1679d49b24bbfe0c803429aa1874472f50d9b363131f0e89fc356b544d03"
|
||||
dependencies = [
|
||||
"getrandom",
|
||||
"getrandom 0.1.14",
|
||||
"libc",
|
||||
"rand_chacha",
|
||||
"rand_core",
|
||||
"rand_chacha 0.2.2",
|
||||
"rand_core 0.5.1",
|
||||
"rand_hc",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "rand"
|
||||
version = "0.8.4"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "2e7573632e6454cf6b99d7aac4ccca54be06da05aca2ef7423d22d27d4d4bcd8"
|
||||
dependencies = [
|
||||
"libc",
|
||||
"rand_chacha 0.3.1",
|
||||
"rand_core 0.6.3",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "rand_chacha"
|
||||
version = "0.2.2"
|
||||
|
@ -761,7 +789,17 @@ source = "registry+https://github.com/rust-lang/crates.io-index"
|
|||
checksum = "f4c8ed856279c9737206bf725bf36935d8666ead7aa69b52be55af369d193402"
|
||||
dependencies = [
|
||||
"ppv-lite86",
|
||||
"rand_core",
|
||||
"rand_core 0.5.1",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "rand_chacha"
|
||||
version = "0.3.1"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "e6c10a63a0fa32252be49d21e7709d4d4baf8d231c2dbce1eaa8141b9b127d88"
|
||||
dependencies = [
|
||||
"ppv-lite86",
|
||||
"rand_core 0.6.3",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
|
@ -770,7 +808,16 @@ version = "0.5.1"
|
|||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "90bde5296fc891b0cef12a6d03ddccc162ce7b2aff54160af9338f8d40df6d19"
|
||||
dependencies = [
|
||||
"getrandom",
|
||||
"getrandom 0.1.14",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "rand_core"
|
||||
version = "0.6.3"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "d34f1408f55294453790c48b2f1ebbb1c5b4b7563eb1f418bcfcfdbb06ebb4e7"
|
||||
dependencies = [
|
||||
"getrandom 0.2.3",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
|
@ -779,16 +826,16 @@ version = "0.2.0"
|
|||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "ca3129af7b92a17112d59ad498c6f81eaf463253766b90396d39ea7a39d6613c"
|
||||
dependencies = [
|
||||
"rand_core",
|
||||
"rand_core 0.5.1",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "rand_xorshift"
|
||||
version = "0.2.0"
|
||||
version = "0.3.0"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "77d416b86801d23dde1aa643023b775c3a462efc0ed96443add11546cdf1dca8"
|
||||
checksum = "d25bf25ec5ae4a3f1b92f929810509a2f53d7dca2f50b794ff57e3face536c8f"
|
||||
dependencies = [
|
||||
"rand_core",
|
||||
"rand_core 0.6.3",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
|
@ -860,7 +907,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index"
|
|||
checksum = "cb3dcc6e454c328bb824492db107ab7c0ae8fcffe4ad210136ef014458c1bc4f"
|
||||
dependencies = [
|
||||
"fnv",
|
||||
"quick-error",
|
||||
"quick-error 1.2.3",
|
||||
"tempfile",
|
||||
"wait-timeout",
|
||||
]
|
||||
|
@ -935,7 +982,7 @@ dependencies = [
|
|||
|
||||
[[package]]
|
||||
name = "serum_dex"
|
||||
version = "0.3.1"
|
||||
version = "0.4.0"
|
||||
dependencies = [
|
||||
"arbitrary",
|
||||
"arrayref",
|
||||
|
@ -951,7 +998,7 @@ dependencies = [
|
|||
"num_enum",
|
||||
"proptest",
|
||||
"proptest-derive",
|
||||
"rand",
|
||||
"rand 0.7.3",
|
||||
"safe-transmute",
|
||||
"serde",
|
||||
"solana-program",
|
||||
|
@ -1049,7 +1096,7 @@ dependencies = [
|
|||
"log",
|
||||
"num-derive",
|
||||
"num-traits",
|
||||
"rand",
|
||||
"rand 0.7.3",
|
||||
"rustc_version 0.2.3",
|
||||
"rustversion",
|
||||
"serde",
|
||||
|
@ -1133,7 +1180,7 @@ checksum = "7a6e24d9338a0a5be79593e2fa15a648add6138caa803e2d5bc782c371732ca9"
|
|||
dependencies = [
|
||||
"cfg-if 0.1.10",
|
||||
"libc",
|
||||
"rand",
|
||||
"rand 0.7.3",
|
||||
"redox_syscall",
|
||||
"remove_dir_all",
|
||||
"winapi",
|
||||
|
@ -1231,6 +1278,12 @@ version = "0.9.0+wasi-snapshot-preview1"
|
|||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "cccddf32554fecc6acb585f82a32a72e28b48f8c4c1883ddfeeeaa96f7d8e519"
|
||||
|
||||
[[package]]
|
||||
name = "wasi"
|
||||
version = "0.10.2+wasi-snapshot-preview1"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "fd6fbd9a79829dd1ad0cc20627bf1ed606756a7f77edff7b66b7064f9cb327c6"
|
||||
|
||||
[[package]]
|
||||
name = "winapi"
|
||||
version = "0.3.9"
|
||||
|
|
|
@ -40,8 +40,8 @@ crate-type = ["cdylib", "lib"]
|
|||
[dev-dependencies]
|
||||
rand = "0.7.3"
|
||||
hexdump = "0.1.0"
|
||||
proptest = "0.10.0"
|
||||
proptest-derive = "0.2.0"
|
||||
proptest = "1.0.0"
|
||||
proptest-derive = "0.3.0"
|
||||
bumpalo = { version = "3.4.0", features = ["collections"] }
|
||||
|
||||
[profile.release]
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
#![deny(safe_packed_borrows)]
|
||||
#![deny(unaligned_references)]
|
||||
#![allow(dead_code)]
|
||||
|
||||
use std::borrow::Cow;
|
||||
|
@ -1214,6 +1214,7 @@ pub fn list_market(
|
|||
&pc_vault.pubkey(),
|
||||
None,
|
||||
None,
|
||||
None,
|
||||
&bids_key.pubkey(),
|
||||
&asks_key.pubkey(),
|
||||
&req_q_key.pubkey(),
|
||||
|
|
|
@ -61,6 +61,12 @@ version = "1.0.1"
|
|||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "cdb031dd78e28731d87d56cc8ffef4a8f36ca26c38fe2de700543e627f8a464a"
|
||||
|
||||
[[package]]
|
||||
name = "base64"
|
||||
version = "0.12.3"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "3441f0f7b02788e948e47f457ca01f1d7e6d92c693bc132c22b087d3141c03ff"
|
||||
|
||||
[[package]]
|
||||
name = "bincode"
|
||||
version = "1.3.1"
|
||||
|
@ -92,14 +98,21 @@ version = "0.9.0"
|
|||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "4152116fd6e9dadb291ae18fc1ec3575ed6d84c29642d97890f4b4a3417297e4"
|
||||
dependencies = [
|
||||
"block-padding",
|
||||
"generic-array 0.14.4",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "borsh"
|
||||
version = "0.8.2"
|
||||
name = "block-padding"
|
||||
version = "0.2.1"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "09a7111f797cc721407885a323fb071636aee57f750b1a4ddc27397eba168a74"
|
||||
checksum = "8d696c370c750c948ada61c69a0ee2cbbb9c50b1019ddb86d9317157a99c2cae"
|
||||
|
||||
[[package]]
|
||||
name = "borsh"
|
||||
version = "0.9.1"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "18dda7dc709193c0d86a1a51050a926dc3df1cf262ec46a23a25dba421ea1924"
|
||||
dependencies = [
|
||||
"borsh-derive",
|
||||
"hashbrown",
|
||||
|
@ -107,9 +120,9 @@ dependencies = [
|
|||
|
||||
[[package]]
|
||||
name = "borsh-derive"
|
||||
version = "0.8.2"
|
||||
version = "0.9.1"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "307f3740906bac2c118a8122fe22681232b244f1369273e45f1156b45c43d2dd"
|
||||
checksum = "684155372435f578c0fa1acd13ebbb182cc19d6b38b64ae7901da4393217d264"
|
||||
dependencies = [
|
||||
"borsh-derive-internal",
|
||||
"borsh-schema-derive-internal",
|
||||
|
@ -120,9 +133,9 @@ dependencies = [
|
|||
|
||||
[[package]]
|
||||
name = "borsh-derive-internal"
|
||||
version = "0.8.2"
|
||||
version = "0.9.1"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "d2104c73179359431cc98e016998f2f23bc7a05bc53e79741bcba705f30047bc"
|
||||
checksum = "2102f62f8b6d3edeab871830782285b64cc1830168094db05c8e458f209bc5c3"
|
||||
dependencies = [
|
||||
"proc-macro2",
|
||||
"quote",
|
||||
|
@ -131,9 +144,9 @@ dependencies = [
|
|||
|
||||
[[package]]
|
||||
name = "borsh-schema-derive-internal"
|
||||
version = "0.8.2"
|
||||
version = "0.9.1"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "ae29eb8418fcd46f723f8691a2ac06857d31179d33d2f2d91eb13967de97c728"
|
||||
checksum = "196c978c4c9b0b142d446ef3240690bf5a8a33497074a113ff9a337ccb750483"
|
||||
dependencies = [
|
||||
"proc-macro2",
|
||||
"quote",
|
||||
|
@ -204,6 +217,12 @@ version = "0.1.2"
|
|||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "8aebca1129a03dc6dc2b127edd729435bbc4a37e1d5f4d7513165089ceb02634"
|
||||
|
||||
[[package]]
|
||||
name = "crunchy"
|
||||
version = "0.2.2"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "7a81dae078cea95a014a339291cec439d2f232ebe854a9d672b796c6afafa9b7"
|
||||
|
||||
[[package]]
|
||||
name = "crypto-mac"
|
||||
version = "0.8.0"
|
||||
|
@ -377,6 +396,27 @@ version = "0.4.2"
|
|||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "644f9158b2f133fd50f5fb3242878846d9eb792e445c893805ff0e3824006e35"
|
||||
|
||||
[[package]]
|
||||
name = "hmac"
|
||||
version = "0.8.1"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "126888268dcc288495a26bf004b38c5fdbb31682f992c84ceb046a1f0fe38840"
|
||||
dependencies = [
|
||||
"crypto-mac",
|
||||
"digest 0.9.0",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "hmac-drbg"
|
||||
version = "0.3.0"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "17ea0a1394df5b6574da6e0c1ade9e78868c9fb0a4e5ef4428e32da4676b85b1"
|
||||
dependencies = [
|
||||
"digest 0.9.0",
|
||||
"generic-array 0.14.4",
|
||||
"hmac",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "humantime"
|
||||
version = "2.1.0"
|
||||
|
@ -392,6 +432,12 @@ dependencies = [
|
|||
"either",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "keccak"
|
||||
version = "0.1.0"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "67c21572b4949434e4fc1e1978b99c5f77064153c59d998bf13ecd96fb5ecba7"
|
||||
|
||||
[[package]]
|
||||
name = "lazy_static"
|
||||
version = "1.4.0"
|
||||
|
@ -414,6 +460,54 @@ dependencies = [
|
|||
"cc",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "libsecp256k1"
|
||||
version = "0.5.0"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "bd1137239ab33b41aa9637a88a28249e5e70c40a42ccc92db7f12cc356c1fcd7"
|
||||
dependencies = [
|
||||
"arrayref",
|
||||
"base64",
|
||||
"digest 0.9.0",
|
||||
"hmac-drbg",
|
||||
"libsecp256k1-core",
|
||||
"libsecp256k1-gen-ecmult",
|
||||
"libsecp256k1-gen-genmult",
|
||||
"rand",
|
||||
"serde",
|
||||
"sha2",
|
||||
"typenum",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "libsecp256k1-core"
|
||||
version = "0.2.2"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "d0f6ab710cec28cef759c5f18671a27dae2a5f952cdaaee1d8e2908cb2478a80"
|
||||
dependencies = [
|
||||
"crunchy",
|
||||
"digest 0.9.0",
|
||||
"subtle",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "libsecp256k1-gen-ecmult"
|
||||
version = "0.2.1"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "ccab96b584d38fac86a83f07e659f0deafd0253dc096dab5a36d53efe653c5c3"
|
||||
dependencies = [
|
||||
"libsecp256k1-core",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "libsecp256k1-gen-genmult"
|
||||
version = "0.2.1"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "67abfe149395e3aa1c48a2beb32b068e2334402df8181f818d3aee2b304c4f5d"
|
||||
dependencies = [
|
||||
"libsecp256k1-core",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "log"
|
||||
version = "0.4.11"
|
||||
|
@ -695,7 +789,7 @@ dependencies = [
|
|||
|
||||
[[package]]
|
||||
name = "serum_dex"
|
||||
version = "0.3.1"
|
||||
version = "0.4.0"
|
||||
dependencies = [
|
||||
"arbitrary",
|
||||
"arrayref",
|
||||
|
@ -746,10 +840,22 @@ dependencies = [
|
|||
]
|
||||
|
||||
[[package]]
|
||||
name = "solana-frozen-abi"
|
||||
version = "1.6.7"
|
||||
name = "sha3"
|
||||
version = "0.9.1"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "7ac46e7039558eed109b9f009774f51114a31875d7759d903608b6c59584b47c"
|
||||
checksum = "f81199417d4e5de3f04b1e871023acea7389672c4135918f05aa9cbf2f2fa809"
|
||||
dependencies = [
|
||||
"block-buffer",
|
||||
"digest 0.9.0",
|
||||
"keccak",
|
||||
"opaque-debug",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "solana-frozen-abi"
|
||||
version = "1.7.11"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "21ddfc2b65a555c0e0156c043bce092d473bc4f00daa7ca3c223d97d92d2e807"
|
||||
dependencies = [
|
||||
"bs58",
|
||||
"bv",
|
||||
|
@ -767,11 +873,10 @@ dependencies = [
|
|||
|
||||
[[package]]
|
||||
name = "solana-frozen-abi-macro"
|
||||
version = "1.6.7"
|
||||
version = "1.7.11"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "c4c0bfcdc5101c92aa8d6bed6d691730ea126647abeb28ac32d306a72bdbe89e"
|
||||
checksum = "a876aa31298fdee6560c8ee0695ebed313bbdbb6fbbee439ac3b9df8aebfb87c"
|
||||
dependencies = [
|
||||
"lazy_static",
|
||||
"proc-macro2",
|
||||
"quote",
|
||||
"rustc_version 0.2.3",
|
||||
|
@ -780,9 +885,9 @@ dependencies = [
|
|||
|
||||
[[package]]
|
||||
name = "solana-logger"
|
||||
version = "1.6.7"
|
||||
version = "1.7.11"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "2fecb07fe2c884d7acbc8df907372fc5616b3107f4058ee1be1e7992ae44d557"
|
||||
checksum = "98a07290cc521e529bff0b0afd3aacd1d3904a41f35321ede6d1f3574efa3e94"
|
||||
dependencies = [
|
||||
"env_logger",
|
||||
"lazy_static",
|
||||
|
@ -791,9 +896,9 @@ dependencies = [
|
|||
|
||||
[[package]]
|
||||
name = "solana-program"
|
||||
version = "1.6.7"
|
||||
version = "1.7.11"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "f9d955bebb7e03f5e5e3034ddf03d6dee9176df8e99124a8ce5d64f8ecb4fe4d"
|
||||
checksum = "49ffc60d33a318300682e42d28ff4f1276327f6374cab9591c8620a54be7aec1"
|
||||
dependencies = [
|
||||
"bincode",
|
||||
"blake3",
|
||||
|
@ -805,6 +910,7 @@ dependencies = [
|
|||
"hex",
|
||||
"itertools",
|
||||
"lazy_static",
|
||||
"libsecp256k1",
|
||||
"log",
|
||||
"num-derive",
|
||||
"num-traits",
|
||||
|
@ -815,6 +921,7 @@ dependencies = [
|
|||
"serde_bytes",
|
||||
"serde_derive",
|
||||
"sha2",
|
||||
"sha3",
|
||||
"solana-frozen-abi",
|
||||
"solana-frozen-abi-macro",
|
||||
"solana-logger",
|
||||
|
@ -824,9 +931,9 @@ dependencies = [
|
|||
|
||||
[[package]]
|
||||
name = "solana-sdk-macro"
|
||||
version = "1.6.7"
|
||||
version = "1.7.11"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "35ee9059dd33539766787e57065334696c920d127ebfac62c97ffed3149c7da2"
|
||||
checksum = "b453dca160617b1676c47e3cfd4361f455dc5bb1c93659ec84b0c5d566b5c039"
|
||||
dependencies = [
|
||||
"bs58",
|
||||
"proc-macro2",
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
#![no_main]
|
||||
#![deny(safe_packed_borrows)]
|
||||
#![deny(unaligned_references)]
|
||||
|
||||
use std::cell::RefMut;
|
||||
use std::cmp::max;
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
#![deny(safe_packed_borrows)]
|
||||
#![deny(unaligned_references)]
|
||||
use std::mem::size_of;
|
||||
|
||||
use bumpalo::Bump;
|
||||
|
@ -269,6 +269,7 @@ pub fn setup_market(bump: &Bump, is_permissioned: bool) -> MarketAccounts {
|
|||
pc_vault.key,
|
||||
open_orders_authority.as_ref().map(|a| a.key),
|
||||
prune_authority.as_ref().map(|a| a.key),
|
||||
None,
|
||||
bids.key,
|
||||
asks.key,
|
||||
req_q.key,
|
||||
|
|
|
@ -333,6 +333,7 @@ pub enum MarketInstruction {
|
|||
/// 9. `[]` the rent sysvar
|
||||
/// 10. `[]` open orders market authority (optional)
|
||||
/// 11. `[]` prune authority (optional, requires open orders market authority)
|
||||
/// 12. `[]` crank authority (optional, requires prune authority)
|
||||
InitializeMarket(InitializeMarketInstruction),
|
||||
/// 0. `[writable]` the market
|
||||
/// 1. `[writable]` the OpenOrders account to use
|
||||
|
@ -456,6 +457,11 @@ pub enum MarketInstruction {
|
|||
/// 5. `[]` open orders owner.
|
||||
/// 6. `[writable]` event queue.
|
||||
Prune(u16),
|
||||
/// ... `[writable]` OpenOrders
|
||||
/// accounts.len() - 3 `[writable]` market
|
||||
/// accounts.len() - 2 `[writable]` event queue
|
||||
/// accounts.len() - 1 `[signer]` crank authority
|
||||
ConsumeEventsPermissioned(u16),
|
||||
}
|
||||
|
||||
impl MarketInstruction {
|
||||
|
@ -553,6 +559,10 @@ impl MarketInstruction {
|
|||
let limit = array_ref![data, 0, 2];
|
||||
MarketInstruction::Prune(u16::from_le_bytes(*limit))
|
||||
}
|
||||
(17, 2) => {
|
||||
let limit = array_ref![data, 0, 2];
|
||||
MarketInstruction::ConsumeEventsPermissioned(u16::from_le_bytes(*limit))
|
||||
}
|
||||
_ => return None,
|
||||
})
|
||||
}
|
||||
|
@ -577,6 +587,7 @@ pub fn initialize_market(
|
|||
pc_vault_pk: &Pubkey,
|
||||
authority_pk: Option<&Pubkey>,
|
||||
prune_authority_pk: Option<&Pubkey>,
|
||||
consume_events_authority_pk: Option<&Pubkey>,
|
||||
// srm_vault_pk: &Pubkey,
|
||||
bids_pk: &Pubkey,
|
||||
asks_pk: &Pubkey,
|
||||
|
@ -631,6 +642,10 @@ pub fn initialize_market(
|
|||
if let Some(prune_auth) = prune_authority_pk {
|
||||
let authority = AccountMeta::new_readonly(*prune_auth, false);
|
||||
accounts.push(authority);
|
||||
if let Some(consume_events_auth) = consume_events_authority_pk {
|
||||
let authority = AccountMeta::new_readonly(*consume_events_auth, false);
|
||||
accounts.push(authority);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -755,6 +770,31 @@ pub fn consume_events(
|
|||
})
|
||||
}
|
||||
|
||||
pub fn consume_events_permissioned(
|
||||
program_id: &Pubkey,
|
||||
open_orders_accounts: Vec<&Pubkey>,
|
||||
market: &Pubkey,
|
||||
event_queue: &Pubkey,
|
||||
consume_events_authority: &Pubkey,
|
||||
limit: u16,
|
||||
) -> Result<Instruction, DexError> {
|
||||
let data = MarketInstruction::ConsumeEvents(limit).pack();
|
||||
let mut accounts: Vec<AccountMeta> = open_orders_accounts
|
||||
.iter()
|
||||
.map(|key| AccountMeta::new(**key, false))
|
||||
.collect();
|
||||
accounts.append(&mut vec![
|
||||
AccountMeta::new(*market, false),
|
||||
AccountMeta::new(*event_queue, false),
|
||||
AccountMeta::new_readonly(*consume_events_authority, true),
|
||||
]);
|
||||
Ok(Instruction {
|
||||
program_id: *program_id,
|
||||
data,
|
||||
accounts,
|
||||
})
|
||||
}
|
||||
|
||||
pub fn cancel_order(
|
||||
program_id: &Pubkey,
|
||||
market: &Pubkey,
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
#![deny(safe_packed_borrows)]
|
||||
#![deny(unaligned_references)]
|
||||
#![allow(clippy::try_err)]
|
||||
|
||||
#[macro_use]
|
||||
|
|
|
@ -59,6 +59,7 @@ pub enum AccountFlag {
|
|||
Disabled = 1u64 << 7,
|
||||
Closed = 1u64 << 8,
|
||||
Permissioned = 1u64 << 9,
|
||||
CrankAuthorityRequired = 1u64 << 10,
|
||||
}
|
||||
|
||||
// Versioned frontend for market accounts.
|
||||
|
@ -125,6 +126,20 @@ impl<'a> Market<'a> {
|
|||
}
|
||||
}
|
||||
|
||||
pub fn consume_events_authority(&self) -> Option<&Pubkey> {
|
||||
match &self {
|
||||
Market::V1(_) => None,
|
||||
Market::V2(state) => {
|
||||
let flags = BitFlags::from_bits(state.inner.account_flags).unwrap();
|
||||
if flags.intersects(AccountFlag::CrankAuthorityRequired) {
|
||||
Some(&state.consume_events_authority)
|
||||
} else {
|
||||
None
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
pub fn load_orders_mut(
|
||||
&self,
|
||||
orders_account: &'a AccountInfo,
|
||||
|
@ -177,8 +192,9 @@ pub struct MarketStateV2 {
|
|||
pub inner: MarketState,
|
||||
pub open_orders_authority: Pubkey,
|
||||
pub prune_authority: Pubkey,
|
||||
pub consume_events_authority: Pubkey,
|
||||
// Unused bytes for future upgrades.
|
||||
padding: [u8; 1024],
|
||||
padding: [u8; 992],
|
||||
}
|
||||
|
||||
impl Deref for MarketStateV2 {
|
||||
|
@ -1553,6 +1569,7 @@ pub(crate) mod account_parser {
|
|||
pub pc_vault_and_mint: TokenAccountAndMint<'a, 'b>,
|
||||
pub market_authority: Option<&'a AccountInfo<'b>>,
|
||||
pub prune_authority: Option<&'a AccountInfo<'b>>,
|
||||
pub consume_events_authority: Option<&'a AccountInfo<'b>>,
|
||||
}
|
||||
|
||||
impl<'a, 'b: 'a> InitializeMarketArgs<'a, 'b> {
|
||||
|
@ -1571,7 +1588,9 @@ pub(crate) mod account_parser {
|
|||
) = array_refs![accounts, 5, 2, 2, 1; .. ;];
|
||||
|
||||
let mut rem_iter = remaining_accounts.iter();
|
||||
let (market_authority, prune_authority) = (rem_iter.next(), rem_iter.next());
|
||||
let market_authority = rem_iter.next();
|
||||
let prune_authority = rem_iter.next();
|
||||
let consume_events_authority = rem_iter.next();
|
||||
|
||||
{
|
||||
// Dynamic sysvars don't work in unit tests.
|
||||
|
@ -1634,6 +1653,7 @@ pub(crate) mod account_parser {
|
|||
pc_vault_and_mint,
|
||||
market_authority,
|
||||
prune_authority,
|
||||
consume_events_authority,
|
||||
})
|
||||
}
|
||||
|
||||
|
@ -1876,11 +1896,48 @@ pub(crate) mod account_parser {
|
|||
let (
|
||||
&[],
|
||||
open_orders_accounts,
|
||||
&[ref market_acc],
|
||||
&[ref event_q_acc],
|
||||
_unused
|
||||
) = array_refs![accounts, 0; .. ; 1, 1, 2];
|
||||
&[
|
||||
ref market_acc,
|
||||
ref event_q_acc,
|
||||
],
|
||||
_
|
||||
) = array_refs![accounts, 0; .. ; 2, 2];
|
||||
let market = Market::load(market_acc, program_id)?;
|
||||
check_assert!(market.consume_events_authority().is_none())?;
|
||||
let event_q = market.load_event_queue_mut(event_q_acc)?;
|
||||
let args = ConsumeEventsArgs {
|
||||
limit,
|
||||
program_id,
|
||||
open_orders_accounts,
|
||||
market,
|
||||
event_q,
|
||||
};
|
||||
f(args)
|
||||
}
|
||||
|
||||
pub fn with_parsed_args_permissioned<T>(
|
||||
program_id: &'a Pubkey,
|
||||
accounts: &'a [AccountInfo<'b>],
|
||||
limit: u16,
|
||||
f: impl FnOnce(ConsumeEventsArgs) -> DexResult<T>,
|
||||
) -> DexResult<T> {
|
||||
check_assert!(accounts.len() >= 4)?;
|
||||
#[rustfmt::skip]
|
||||
let (
|
||||
&[],
|
||||
open_orders_accounts,
|
||||
&[
|
||||
ref market_acc,
|
||||
ref event_q_acc,
|
||||
ref consume_events_auth,
|
||||
]
|
||||
) = array_refs![accounts, 0; .. ; 3];
|
||||
let market = Market::load(market_acc, program_id)?;
|
||||
check_assert!(consume_events_auth.is_signer)?;
|
||||
check_assert_eq!(
|
||||
Some(consume_events_auth.key),
|
||||
market.consume_events_authority()
|
||||
)?;
|
||||
let event_q = market.load_event_queue_mut(event_q_acc)?;
|
||||
let args = ConsumeEventsArgs {
|
||||
limit,
|
||||
|
@ -2371,6 +2428,14 @@ impl State {
|
|||
Self::process_consume_events,
|
||||
)?
|
||||
}
|
||||
MarketInstruction::ConsumeEventsPermissioned(limit) => {
|
||||
account_parser::ConsumeEventsArgs::with_parsed_args_permissioned(
|
||||
program_id,
|
||||
accounts,
|
||||
limit,
|
||||
Self::process_consume_events,
|
||||
)?
|
||||
}
|
||||
MarketInstruction::CancelOrder(_inner) => {
|
||||
unimplemented!()
|
||||
}
|
||||
|
@ -3004,6 +3069,7 @@ impl State {
|
|||
let pc_mint = args.pc_vault_and_mint.get_mint().inner();
|
||||
let market_authority = args.market_authority;
|
||||
let prune_authority = args.prune_authority;
|
||||
let consume_events_authority = args.consume_events_authority;
|
||||
|
||||
// initialize request queue
|
||||
let mut rq_data = req_q.try_borrow_mut_data()?;
|
||||
|
@ -3060,6 +3126,9 @@ impl State {
|
|||
let mut account_flags = AccountFlag::Initialized | AccountFlag::Market;
|
||||
if market_authority.is_some() {
|
||||
account_flags |= AccountFlag::Permissioned;
|
||||
if consume_events_authority.is_some() {
|
||||
account_flags |= AccountFlag::CrankAuthorityRequired;
|
||||
}
|
||||
}
|
||||
let market_state = MarketState {
|
||||
coin_lot_size,
|
||||
|
@ -3096,10 +3165,14 @@ impl State {
|
|||
Some(oo_auth) => {
|
||||
let market_hdr: &mut MarketStateV2 =
|
||||
try_from_bytes_mut(cast_slice_mut(market_view)).or(check_unreachable!())?;
|
||||
(*market_hdr).inner = market_state;
|
||||
(*market_hdr).open_orders_authority = *oo_auth.key;
|
||||
(*market_hdr).prune_authority =
|
||||
market_hdr.inner = market_state;
|
||||
market_hdr.open_orders_authority = *oo_auth.key;
|
||||
market_hdr.prune_authority =
|
||||
prune_authority.map(|p| *p.key).unwrap_or(Pubkey::default());
|
||||
|
||||
if let Some(consume_events_authority) = consume_events_authority {
|
||||
market_hdr.consume_events_authority = *consume_events_authority.key;
|
||||
}
|
||||
}
|
||||
}
|
||||
Ok(())
|
||||
|
|
|
@ -202,6 +202,7 @@ fn setup_market<'bump, R: Rng>(rng: &mut R, bump: &'bump Bump) -> MarketAccounts
|
|||
&pc_vault.key,
|
||||
None,
|
||||
None,
|
||||
None,
|
||||
&bids.key,
|
||||
&asks.key,
|
||||
&req_q.key,
|
||||
|
|
Loading…
Reference in New Issue