Move src/logger.rs into logger/ crate to unify logging across the workspace
This commit is contained in:
@ -14,11 +14,11 @@ bpf_c = []
|
||||
bincode = "1.0.0"
|
||||
byteorder = "1.2.1"
|
||||
elf = "0.0.10"
|
||||
env_logger = "0.6.0"
|
||||
libc = "0.2.45"
|
||||
log = "0.4.2"
|
||||
solana_rbpf = "=0.1.5"
|
||||
serde = "1.0.82"
|
||||
solana-logger = { path = "../../../logger", version = "0.11.0" }
|
||||
solana-sdk = { path = "../../../sdk", version = "0.11.0" }
|
||||
|
||||
[lib]
|
||||
|
@ -1,8 +1,6 @@
|
||||
pub mod bpf_verifier;
|
||||
|
||||
extern crate bincode;
|
||||
extern crate byteorder;
|
||||
extern crate env_logger;
|
||||
#[macro_use]
|
||||
extern crate log;
|
||||
extern crate libc;
|
||||
@ -10,7 +8,6 @@ extern crate solana_rbpf;
|
||||
#[macro_use]
|
||||
extern crate solana_sdk;
|
||||
|
||||
use bincode::deserialize;
|
||||
use byteorder::{ByteOrder, LittleEndian, WriteBytesExt};
|
||||
use libc::c_char;
|
||||
use solana_rbpf::EbpfVmRaw;
|
||||
@ -22,7 +19,6 @@ use std::ffi::CStr;
|
||||
use std::io::prelude::*;
|
||||
use std::io::{Error, ErrorKind};
|
||||
use std::mem;
|
||||
use std::sync::{Once, ONCE_INIT};
|
||||
|
||||
// TODO use rbpf's disassemble
|
||||
#[allow(dead_code)]
|
||||
@ -153,11 +149,7 @@ fn entrypoint(
|
||||
tx_data: &[u8],
|
||||
tick_height: u64,
|
||||
) -> Result<(), ProgramError> {
|
||||
static INIT: Once = ONCE_INIT;
|
||||
INIT.call_once(|| {
|
||||
// env_logger can only be initialized once
|
||||
env_logger::init();
|
||||
});
|
||||
solana_logger::setup();
|
||||
|
||||
if keyed_accounts[0].account.executable {
|
||||
let prog = keyed_accounts[0].account.userdata.clone();
|
||||
@ -188,7 +180,7 @@ fn entrypoint(
|
||||
"BPF program executed {} instructions",
|
||||
vm.get_last_instruction_count()
|
||||
);
|
||||
} else if let Ok(instruction) = deserialize(tx_data) {
|
||||
} else if let Ok(instruction) = bincode::deserialize(tx_data) {
|
||||
if keyed_accounts[0].signer_key().is_none() {
|
||||
warn!("key[0] did not sign the transaction");
|
||||
return Err(ProgramError::GenericError);
|
||||
|
@ -10,10 +10,10 @@ homepage = "https://solana.com/"
|
||||
[dependencies]
|
||||
bincode = "1.0.0"
|
||||
chrono = { version = "0.4.0", features = ["serde"] }
|
||||
env_logger = "0.6.0"
|
||||
log = "0.4.2"
|
||||
serde = "1.0.82"
|
||||
serde_derive = "1.0.82"
|
||||
solana-logger = { path = "../../../logger", version = "0.11.0" }
|
||||
solana-sdk = { path = "../../../sdk", version = "0.11.0" }
|
||||
|
||||
[lib]
|
||||
|
@ -1,6 +1,5 @@
|
||||
extern crate bincode;
|
||||
extern crate chrono;
|
||||
extern crate env_logger;
|
||||
#[macro_use]
|
||||
extern crate log;
|
||||
#[macro_use]
|
||||
@ -13,7 +12,6 @@ mod budget_program;
|
||||
use solana_sdk::account::KeyedAccount;
|
||||
use solana_sdk::native_program::ProgramError;
|
||||
use solana_sdk::pubkey::Pubkey;
|
||||
use std::sync::{Once, ONCE_INIT};
|
||||
|
||||
use budget_program::process_instruction;
|
||||
|
||||
@ -24,11 +22,7 @@ fn entrypoint(
|
||||
data: &[u8],
|
||||
_tick_height: u64,
|
||||
) -> Result<(), ProgramError> {
|
||||
static INIT: Once = ONCE_INIT;
|
||||
INIT.call_once(|| {
|
||||
// env_logger can only be initialized once
|
||||
env_logger::init();
|
||||
});
|
||||
solana_logger::setup();
|
||||
|
||||
trace!("process_instruction: {:?}", data);
|
||||
trace!("keyed_accounts: {:?}", keyed_accounts);
|
||||
|
@ -9,10 +9,10 @@ homepage = "https://solana.com/"
|
||||
|
||||
[dependencies]
|
||||
bincode = "1.0.0"
|
||||
env_logger = "0.6.0"
|
||||
log = "0.4.2"
|
||||
serde = "1.0.82"
|
||||
serde_derive = "1.0.82"
|
||||
solana-logger = { path = "../../../logger", version = "0.11.0" }
|
||||
solana-sdk = { path = "../../../sdk", version = "0.11.0" }
|
||||
|
||||
[lib]
|
||||
|
@ -1,7 +1,6 @@
|
||||
//! The `erc20` library implements a generic erc20-like token
|
||||
|
||||
extern crate bincode;
|
||||
extern crate env_logger;
|
||||
#[macro_use]
|
||||
extern crate log;
|
||||
extern crate serde;
|
||||
@ -13,7 +12,6 @@ extern crate solana_sdk;
|
||||
use solana_sdk::account::KeyedAccount;
|
||||
use solana_sdk::native_program::ProgramError;
|
||||
use solana_sdk::pubkey::Pubkey;
|
||||
use std::sync::{Once, ONCE_INIT};
|
||||
|
||||
mod token_program;
|
||||
|
||||
@ -24,9 +22,7 @@ fn entrypoint(
|
||||
input: &[u8],
|
||||
_tick_height: u64,
|
||||
) -> Result<(), ProgramError> {
|
||||
// env_logger can only be initialized once
|
||||
static INIT: Once = ONCE_INIT;
|
||||
INIT.call_once(env_logger::init);
|
||||
solana_logger::setup();
|
||||
|
||||
token_program::TokenProgram::process(program_id, info, input).map_err(|err| {
|
||||
error!("error: {:?}", err);
|
||||
|
@ -9,11 +9,11 @@ homepage = "https://solana.com/"
|
||||
|
||||
[dependencies]
|
||||
bincode = "1.0.0"
|
||||
env_logger = "0.6.0"
|
||||
log = "0.4.2"
|
||||
rlua = "0.15.2"
|
||||
serde = "1.0.82"
|
||||
serde_derive = "1.0.82"
|
||||
solana-logger = { path = "../../../logger", version = "0.11.0" }
|
||||
solana-sdk = { path = "../../../sdk", version = "0.11.0" }
|
||||
|
||||
[dev-dependencies]
|
||||
|
@ -1,19 +1,15 @@
|
||||
extern crate bincode;
|
||||
extern crate env_logger;
|
||||
#[macro_use]
|
||||
extern crate log;
|
||||
extern crate rlua;
|
||||
#[macro_use]
|
||||
extern crate solana_sdk;
|
||||
|
||||
use bincode::deserialize;
|
||||
use rlua::{Lua, Table};
|
||||
use solana_sdk::account::KeyedAccount;
|
||||
use solana_sdk::loader_instruction::LoaderInstruction;
|
||||
use solana_sdk::native_program::ProgramError;
|
||||
use solana_sdk::pubkey::Pubkey;
|
||||
use std::str;
|
||||
use std::sync::{Once, ONCE_INIT};
|
||||
|
||||
/// Make KeyAccount values available to Lua.
|
||||
fn set_accounts(lua: &Lua, name: &str, keyed_accounts: &[KeyedAccount]) -> rlua::Result<()> {
|
||||
@ -68,11 +64,7 @@ fn entrypoint(
|
||||
tx_data: &[u8],
|
||||
_tick_height: u64,
|
||||
) -> Result<(), ProgramError> {
|
||||
static INIT: Once = ONCE_INIT;
|
||||
INIT.call_once(|| {
|
||||
// env_logger can only be initialized once
|
||||
env_logger::init();
|
||||
});
|
||||
solana_logger::setup();
|
||||
|
||||
if keyed_accounts[0].account.executable {
|
||||
let code = keyed_accounts[0].account.userdata.clone();
|
||||
@ -86,7 +78,7 @@ fn entrypoint(
|
||||
return Err(ProgramError::GenericError);
|
||||
}
|
||||
}
|
||||
} else if let Ok(instruction) = deserialize(tx_data) {
|
||||
} else if let Ok(instruction) = bincode::deserialize(tx_data) {
|
||||
if keyed_accounts[0].signer_key().is_none() {
|
||||
warn!("key[0] did not sign the transaction");
|
||||
return Err(ProgramError::GenericError);
|
||||
|
@ -9,10 +9,10 @@ homepage = "https://solana.com/"
|
||||
|
||||
[dependencies]
|
||||
bincode = "1.0.0"
|
||||
env_logger = "0.6.0"
|
||||
log = "0.4.2"
|
||||
serde = "1.0.27"
|
||||
serde_derive = "1.0.27"
|
||||
solana-logger = { path = "../../../logger", version = "0.11.0" }
|
||||
solana-sdk = { path = "../../../sdk", version = "0.11.0" }
|
||||
|
||||
[lib]
|
||||
|
@ -2,14 +2,11 @@
|
||||
//! Receive mining proofs from miners, validate the answers
|
||||
//! and give reward for good proofs.
|
||||
|
||||
extern crate bincode;
|
||||
extern crate env_logger;
|
||||
#[macro_use]
|
||||
extern crate log;
|
||||
#[macro_use]
|
||||
extern crate solana_sdk;
|
||||
|
||||
use bincode::deserialize;
|
||||
use solana_sdk::account::KeyedAccount;
|
||||
use solana_sdk::native_program::ProgramError;
|
||||
use solana_sdk::pubkey::Pubkey;
|
||||
@ -22,13 +19,15 @@ fn entrypoint(
|
||||
data: &[u8],
|
||||
_tick_height: u64,
|
||||
) -> Result<(), ProgramError> {
|
||||
solana_logger::setup();
|
||||
|
||||
// accounts_keys[0] must be signed
|
||||
if keyed_accounts[0].signer_key().is_none() {
|
||||
info!("account[0] is unsigned");
|
||||
Err(ProgramError::InvalidArgument)?;
|
||||
}
|
||||
|
||||
if let Ok(syscall) = deserialize(data) {
|
||||
if let Ok(syscall) = bincode::deserialize(data) {
|
||||
match syscall {
|
||||
StorageProgram::SubmitMiningProof {
|
||||
sha_state,
|
||||
|
@ -9,7 +9,6 @@ homepage = "https://solana.com/"
|
||||
|
||||
[dependencies]
|
||||
bincode = "1.0.0"
|
||||
env_logger = "0.6.0"
|
||||
log = "0.4.2"
|
||||
serde = "1.0.27"
|
||||
solana-sdk = { path = "../../../sdk", version = "0.11.0" }
|
||||
|
@ -1,10 +1,8 @@
|
||||
extern crate bincode;
|
||||
#[macro_use]
|
||||
extern crate log;
|
||||
#[macro_use]
|
||||
extern crate solana_sdk;
|
||||
|
||||
use bincode::deserialize;
|
||||
use solana_sdk::account::KeyedAccount;
|
||||
use solana_sdk::native_program::ProgramError;
|
||||
use solana_sdk::pubkey::Pubkey;
|
||||
@ -18,7 +16,7 @@ pub fn entrypoint(
|
||||
data: &[u8],
|
||||
_tick_height: u64,
|
||||
) -> Result<(), ProgramError> {
|
||||
if let Ok(syscall) = deserialize(data) {
|
||||
if let Ok(syscall) = bincode::deserialize(data) {
|
||||
trace!("process_instruction: {:?}", syscall);
|
||||
trace!("keyed_accounts: {:?}", keyed_accounts);
|
||||
let from = 0;
|
||||
|
@ -9,10 +9,10 @@ homepage = "https://solana.com/"
|
||||
|
||||
[dependencies]
|
||||
bincode = "1.0.0"
|
||||
env_logger = "0.6.0"
|
||||
log = "0.4.2"
|
||||
serde = "1.0.82"
|
||||
serde_derive = "1.0.82"
|
||||
solana-logger = { path = "../../../logger", version = "0.11.0" }
|
||||
solana-metrics = { path = "../../../metrics", version = "0.11.0" }
|
||||
solana-sdk = { path = "../../../sdk", version = "0.11.0" }
|
||||
|
||||
|
@ -1,22 +1,16 @@
|
||||
//! Vote program
|
||||
//! Receive and processes votes from validators
|
||||
|
||||
extern crate bincode;
|
||||
extern crate env_logger;
|
||||
#[macro_use]
|
||||
extern crate log;
|
||||
extern crate solana_metrics;
|
||||
#[macro_use]
|
||||
extern crate solana_sdk;
|
||||
|
||||
use bincode::deserialize;
|
||||
use solana_metrics::{influxdb, submit};
|
||||
use solana_sdk::account::KeyedAccount;
|
||||
use solana_sdk::native_program::ProgramError;
|
||||
use solana_sdk::pubkey::Pubkey;
|
||||
use solana_sdk::vote_program::*;
|
||||
use std::collections::VecDeque;
|
||||
use std::sync::{Once, ONCE_INIT};
|
||||
|
||||
solana_entrypoint!(entrypoint);
|
||||
fn entrypoint(
|
||||
@ -25,11 +19,7 @@ fn entrypoint(
|
||||
data: &[u8],
|
||||
_tick_height: u64,
|
||||
) -> Result<(), ProgramError> {
|
||||
static INIT: Once = ONCE_INIT;
|
||||
INIT.call_once(|| {
|
||||
// env_logger can only be initialized once
|
||||
env_logger::init();
|
||||
});
|
||||
solana_logger::setup();
|
||||
|
||||
trace!("process_instruction: {:?}", data);
|
||||
trace!("keyed_accounts: {:?}", keyed_accounts);
|
||||
@ -40,7 +30,7 @@ fn entrypoint(
|
||||
Err(ProgramError::InvalidArgument)?;
|
||||
}
|
||||
|
||||
match deserialize(data) {
|
||||
match bincode::deserialize(data) {
|
||||
Ok(VoteInstruction::RegisterAccount) => {
|
||||
if !check_id(&keyed_accounts[1].account.owner) {
|
||||
error!("account[1] is not assigned to the VOTE_PROGRAM");
|
||||
@ -64,9 +54,9 @@ fn entrypoint(
|
||||
Err(ProgramError::InvalidArgument)?;
|
||||
}
|
||||
debug!("{:?} by {}", vote, keyed_accounts[0].signer_key().unwrap());
|
||||
submit(
|
||||
influxdb::Point::new("vote-native")
|
||||
.add_field("count", influxdb::Value::Integer(1))
|
||||
solana_metrics::submit(
|
||||
solana_metrics::influxdb::Point::new("vote-native")
|
||||
.add_field("count", solana_metrics::influxdb::Value::Integer(1))
|
||||
.to_owned(),
|
||||
);
|
||||
|
||||
|
Reference in New Issue
Block a user