Accountsdb: support config in Json5 (#22605)
* accountsdb: support config in json5 * update docs * remove not required dependencies Co-authored-by: Lijun Wang <83639177+lijunwangs@users.noreply.github.com>
This commit is contained in:
parent
92e43df266
commit
31ed4c18f9
|
@ -45,7 +45,7 @@ dependencies = [
|
||||||
"cfg-if 1.0.0",
|
"cfg-if 1.0.0",
|
||||||
"cipher",
|
"cipher",
|
||||||
"cpufeatures",
|
"cpufeatures",
|
||||||
"opaque-debug",
|
"opaque-debug 0.3.0",
|
||||||
]
|
]
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
|
@ -371,13 +371,25 @@ dependencies = [
|
||||||
"digest 0.10.1",
|
"digest 0.10.1",
|
||||||
]
|
]
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "block-buffer"
|
||||||
|
version = "0.7.3"
|
||||||
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
|
checksum = "c0940dc441f31689269e10ac70eb1002a3a1d3ad1390e030043662eb7fe4688b"
|
||||||
|
dependencies = [
|
||||||
|
"block-padding 0.1.5",
|
||||||
|
"byte-tools",
|
||||||
|
"byteorder",
|
||||||
|
"generic-array 0.12.4",
|
||||||
|
]
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "block-buffer"
|
name = "block-buffer"
|
||||||
version = "0.9.0"
|
version = "0.9.0"
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
checksum = "4152116fd6e9dadb291ae18fc1ec3575ed6d84c29642d97890f4b4a3417297e4"
|
checksum = "4152116fd6e9dadb291ae18fc1ec3575ed6d84c29642d97890f4b4a3417297e4"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"block-padding",
|
"block-padding 0.2.1",
|
||||||
"generic-array 0.14.5",
|
"generic-array 0.14.5",
|
||||||
]
|
]
|
||||||
|
|
||||||
|
@ -390,6 +402,15 @@ dependencies = [
|
||||||
"generic-array 0.14.5",
|
"generic-array 0.14.5",
|
||||||
]
|
]
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "block-padding"
|
||||||
|
version = "0.1.5"
|
||||||
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
|
checksum = "fa79dedbb091f449f1f39e53edf88d5dbe95f895dae6135a8d7b881fb5af73f5"
|
||||||
|
dependencies = [
|
||||||
|
"byte-tools",
|
||||||
|
]
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "block-padding"
|
name = "block-padding"
|
||||||
version = "0.2.1"
|
version = "0.2.1"
|
||||||
|
@ -481,6 +502,12 @@ dependencies = [
|
||||||
"serde",
|
"serde",
|
||||||
]
|
]
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "byte-tools"
|
||||||
|
version = "0.3.1"
|
||||||
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
|
checksum = "e3b5ca7a04898ad4bcd41c90c5285445ff5b791899bb1b0abdd2a2aa791211d7"
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "byte-unit"
|
name = "byte-unit"
|
||||||
version = "4.0.13"
|
version = "4.0.13"
|
||||||
|
@ -1390,6 +1417,12 @@ dependencies = [
|
||||||
"synstructure",
|
"synstructure",
|
||||||
]
|
]
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "fake-simd"
|
||||||
|
version = "0.1.2"
|
||||||
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
|
checksum = "e88a8acf291dafb59c2d96e8f59828f3838bb1a70398823ade51a84de6a6deed"
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "fast-math"
|
name = "fast-math"
|
||||||
version = "0.1.1"
|
version = "0.1.1"
|
||||||
|
@ -2139,6 +2172,17 @@ dependencies = [
|
||||||
"wasm-bindgen",
|
"wasm-bindgen",
|
||||||
]
|
]
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "json5"
|
||||||
|
version = "0.4.1"
|
||||||
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
|
checksum = "96b0db21af676c1ce64250b5f40f3ce2cf27e4e47cb91ed91eb6fe9350b430c1"
|
||||||
|
dependencies = [
|
||||||
|
"pest",
|
||||||
|
"pest_derive",
|
||||||
|
"serde",
|
||||||
|
]
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "jsonrpc-client-transports"
|
name = "jsonrpc-client-transports"
|
||||||
version = "18.0.0"
|
version = "18.0.0"
|
||||||
|
@ -2446,6 +2490,12 @@ dependencies = [
|
||||||
"hashbrown 0.11.2",
|
"hashbrown 0.11.2",
|
||||||
]
|
]
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "maplit"
|
||||||
|
version = "1.0.2"
|
||||||
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
|
checksum = "3e2e65a1a2e43cfcb47a895c4c8b10d1f4a61097f9f254f183aee60cad9c651d"
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "matches"
|
name = "matches"
|
||||||
version = "0.1.9"
|
version = "0.1.9"
|
||||||
|
@ -2782,6 +2832,12 @@ version = "1.8.0"
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
checksum = "692fcb63b64b1758029e0a96ee63e049ce8c5948587f2f7208df04625e5f6b56"
|
checksum = "692fcb63b64b1758029e0a96ee63e049ce8c5948587f2f7208df04625e5f6b56"
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "opaque-debug"
|
||||||
|
version = "0.2.3"
|
||||||
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
|
checksum = "2839e79665f131bdb5782e51f2c6c9599c133c6098982a54c794358bf432529c"
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "opaque-debug"
|
name = "opaque-debug"
|
||||||
version = "0.3.0"
|
version = "0.3.0"
|
||||||
|
@ -2991,6 +3047,40 @@ dependencies = [
|
||||||
"ucd-trie",
|
"ucd-trie",
|
||||||
]
|
]
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "pest_derive"
|
||||||
|
version = "2.1.0"
|
||||||
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
|
checksum = "833d1ae558dc601e9a60366421196a8d94bc0ac980476d0b67e1d0988d72b2d0"
|
||||||
|
dependencies = [
|
||||||
|
"pest",
|
||||||
|
"pest_generator",
|
||||||
|
]
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "pest_generator"
|
||||||
|
version = "2.1.3"
|
||||||
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
|
checksum = "99b8db626e31e5b81787b9783425769681b347011cc59471e33ea46d2ea0cf55"
|
||||||
|
dependencies = [
|
||||||
|
"pest",
|
||||||
|
"pest_meta",
|
||||||
|
"proc-macro2 1.0.32",
|
||||||
|
"quote 1.0.10",
|
||||||
|
"syn 1.0.81",
|
||||||
|
]
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "pest_meta"
|
||||||
|
version = "2.1.3"
|
||||||
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
|
checksum = "54be6e404f5317079812fc8f9f5279de376d8856929e21c184ecf6bbd692a11d"
|
||||||
|
dependencies = [
|
||||||
|
"maplit",
|
||||||
|
"pest",
|
||||||
|
"sha-1 0.8.2",
|
||||||
|
]
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "petgraph"
|
name = "petgraph"
|
||||||
version = "0.6.0"
|
version = "0.6.0"
|
||||||
|
@ -3066,7 +3156,7 @@ checksum = "8419d2b623c7c0896ff2d5d96e2cb4ede590fed28fcc34934f4c33c036e620a1"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"cfg-if 1.0.0",
|
"cfg-if 1.0.0",
|
||||||
"cpufeatures",
|
"cpufeatures",
|
||||||
"opaque-debug",
|
"opaque-debug 0.3.0",
|
||||||
"universal-hash",
|
"universal-hash",
|
||||||
]
|
]
|
||||||
|
|
||||||
|
@ -4039,6 +4129,18 @@ dependencies = [
|
||||||
"syn 1.0.81",
|
"syn 1.0.81",
|
||||||
]
|
]
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "sha-1"
|
||||||
|
version = "0.8.2"
|
||||||
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
|
checksum = "f7d94d0bede923b3cea61f3f1ff57ff8cdfd77b400fb8f9998949e0cf04163df"
|
||||||
|
dependencies = [
|
||||||
|
"block-buffer 0.7.3",
|
||||||
|
"digest 0.8.1",
|
||||||
|
"fake-simd",
|
||||||
|
"opaque-debug 0.2.3",
|
||||||
|
]
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "sha-1"
|
name = "sha-1"
|
||||||
version = "0.9.8"
|
version = "0.9.8"
|
||||||
|
@ -4049,7 +4151,7 @@ dependencies = [
|
||||||
"cfg-if 1.0.0",
|
"cfg-if 1.0.0",
|
||||||
"cpufeatures",
|
"cpufeatures",
|
||||||
"digest 0.9.0",
|
"digest 0.9.0",
|
||||||
"opaque-debug",
|
"opaque-debug 0.3.0",
|
||||||
]
|
]
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
|
@ -4068,7 +4170,7 @@ dependencies = [
|
||||||
"cfg-if 1.0.0",
|
"cfg-if 1.0.0",
|
||||||
"cpufeatures",
|
"cpufeatures",
|
||||||
"digest 0.9.0",
|
"digest 0.9.0",
|
||||||
"opaque-debug",
|
"opaque-debug 0.3.0",
|
||||||
]
|
]
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
|
@ -4091,7 +4193,7 @@ dependencies = [
|
||||||
"block-buffer 0.9.0",
|
"block-buffer 0.9.0",
|
||||||
"digest 0.9.0",
|
"digest 0.9.0",
|
||||||
"keccak",
|
"keccak",
|
||||||
"opaque-debug",
|
"opaque-debug 0.3.0",
|
||||||
]
|
]
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
|
@ -4209,7 +4311,7 @@ dependencies = [
|
||||||
"httparse",
|
"httparse",
|
||||||
"log 0.4.14",
|
"log 0.4.14",
|
||||||
"rand 0.8.4",
|
"rand 0.8.4",
|
||||||
"sha-1",
|
"sha-1 0.9.8",
|
||||||
]
|
]
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
|
@ -4290,10 +4392,9 @@ version = "1.10.0"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"bs58 0.4.0",
|
"bs58 0.4.0",
|
||||||
"crossbeam-channel",
|
"crossbeam-channel",
|
||||||
|
"json5",
|
||||||
"libloading",
|
"libloading",
|
||||||
"log 0.4.14",
|
"log 0.4.14",
|
||||||
"serde",
|
|
||||||
"serde_derive",
|
|
||||||
"serde_json",
|
"serde_json",
|
||||||
"solana-accountsdb-plugin-interface",
|
"solana-accountsdb-plugin-interface",
|
||||||
"solana-measure",
|
"solana-measure",
|
||||||
|
@ -6991,7 +7092,7 @@ dependencies = [
|
||||||
"log 0.4.14",
|
"log 0.4.14",
|
||||||
"rand 0.8.4",
|
"rand 0.8.4",
|
||||||
"rustls 0.20.0",
|
"rustls 0.20.0",
|
||||||
"sha-1",
|
"sha-1 0.9.8",
|
||||||
"thiserror",
|
"thiserror",
|
||||||
"url 2.2.2",
|
"url 2.2.2",
|
||||||
"utf-8",
|
"utf-8",
|
||||||
|
|
|
@ -12,10 +12,9 @@ documentation = "https://docs.rs/solana-validator"
|
||||||
[dependencies]
|
[dependencies]
|
||||||
bs58 = "0.4.0"
|
bs58 = "0.4.0"
|
||||||
crossbeam-channel = "0.5"
|
crossbeam-channel = "0.5"
|
||||||
|
json5 = "0.4.1"
|
||||||
libloading = "0.7.3"
|
libloading = "0.7.3"
|
||||||
log = "0.4.11"
|
log = "0.4.11"
|
||||||
serde = "1.0.134"
|
|
||||||
serde_derive = "1.0.103"
|
|
||||||
serde_json = "1.0.75"
|
serde_json = "1.0.75"
|
||||||
solana-accountsdb-plugin-interface = { path = "../accountsdb-plugin-interface", version = "=1.10.0" }
|
solana-accountsdb-plugin-interface = { path = "../accountsdb-plugin-interface", version = "=1.10.0" }
|
||||||
solana-measure = { path = "../measure", version = "=1.10.0" }
|
solana-measure = { path = "../measure", version = "=1.10.0" }
|
||||||
|
|
|
@ -9,7 +9,6 @@ use {
|
||||||
},
|
},
|
||||||
crossbeam_channel::Receiver,
|
crossbeam_channel::Receiver,
|
||||||
log::*,
|
log::*,
|
||||||
serde_json,
|
|
||||||
solana_rpc::{
|
solana_rpc::{
|
||||||
optimistically_confirmed_bank_tracker::BankNotification,
|
optimistically_confirmed_bank_tracker::BankNotification,
|
||||||
transaction_notifier_interface::TransactionNotifierLock,
|
transaction_notifier_interface::TransactionNotifierLock,
|
||||||
|
@ -156,12 +155,12 @@ impl AccountsDbPluginService {
|
||||||
)));
|
)));
|
||||||
}
|
}
|
||||||
|
|
||||||
let result: serde_json::Value = match serde_json::from_str(&contents) {
|
let result: serde_json::Value = match json5::from_str(&contents) {
|
||||||
Ok(value) => value,
|
Ok(value) => value,
|
||||||
Err(err) => {
|
Err(err) => {
|
||||||
return Err(AccountsdbPluginServiceError::InvalidConfigFileFormat(
|
return Err(AccountsdbPluginServiceError::InvalidConfigFileFormat(
|
||||||
format!(
|
format!(
|
||||||
"The config file {:?} is not in a valid Json format, error: {:?}",
|
"The config file {:?} is not in a valid Json5 format, error: {:?}",
|
||||||
accountsdb_plugin_config_file, err
|
accountsdb_plugin_config_file, err
|
||||||
),
|
),
|
||||||
));
|
));
|
||||||
|
|
|
@ -58,7 +58,7 @@ pub unsafe extern "C" fn _create_plugin() -> *mut dyn AccountsDbPlugin {
|
||||||
A plugin implementation can implement the `on_load` method to initialize itself.
|
A plugin implementation can implement the `on_load` method to initialize itself.
|
||||||
This function is invoked after a plugin is dynamically loaded into the validator
|
This function is invoked after a plugin is dynamically loaded into the validator
|
||||||
when it starts. The configuration of the plugin is controlled by a configuration
|
when it starts. The configuration of the plugin is controlled by a configuration
|
||||||
file in JSON format. The JSON file must have a field `libpath` that points
|
file in JSON5 format. The JSON5 file must have a field `libpath` that points
|
||||||
to the full path name of the shared library implementing the plugin, and may
|
to the full path name of the shared library implementing the plugin, and may
|
||||||
have other configuration information, like connection parameters for the external
|
have other configuration information, like connection parameters for the external
|
||||||
database. The plugin configuration file is specified by the validator's CLI
|
database. The plugin configuration file is specified by the validator's CLI
|
||||||
|
|
Loading…
Reference in New Issue