Skip to content

Commit ef51c8b

Browse files
committed
Merge branch 'sentry-tls' into sentry-dummy-adapter-deposits
2 parents 7ac6da6 + def8a14 commit ef51c8b

23 files changed

+417
-93
lines changed

Cargo.lock

Lines changed: 107 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Dockerfile-sentry

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -65,6 +65,11 @@ ENV KEYSTORE_PWD=
6565
# Only applicable if you use the `--adapter dummy`
6666
ENV DUMMY_IDENTITY=
6767

68+
# To setup TLS supply both `PRIVATE_KEYS` & `CERTIFICATES`
69+
# Otherwise you will get an error
70+
ENV PRIVATE_KEYS=
71+
ENV CERTIFICATES=
72+
6873
# If set it will override the configuration file used
6974
ENV CONFIG=
7075

@@ -85,4 +90,6 @@ ENTRYPOINT ["./scripts/entrypoint.sh"]
8590
CMD sentry -a ${ADAPTER:-ethereum} \
8691
${KEYSTORE_FILE:+-k $KEYSTORE_FILE} \
8792
${DUMMY_IDENTITY:+-i $DUMMY_IDENTITY} \
93+
${PRIVATE_KEYS:+--privateKeys $PRIVATE_KEYS} \
94+
${CERTIFICATES:+--certificates $CERTIFICATES} \
8895
${CONFIG}

README.md

Lines changed: 10 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -57,7 +57,13 @@ cargo run -p sentry -- --help
5757

5858
Starting the Sentry API in will always run migrations, this will make sure the database is always up to date with the latest migrations, before starting and exposing the web server.
5959

60-
By default, we use the `development` environment ( [`ENV` environment variable](#environment-variables) ) as it will also seed the database.
60+
By default, we use the `development` environment ( [`ENV` environment variable](#environment-variables) ) ~~as it will also seed the database~~ (seeding is disabled, see #514).
61+
62+
To enable TLS for the sentry server you need to pass both `--privateKeys` and
63+
`--certificates` cli options (paths to `.pem` files) otherwise the cli will
64+
exit with an error.
65+
66+
For full list of available addresses see [primitives/src/test_util.rs#L39-L118](./primitives/src/test_util.rs#L39-L118)
6167

6268
#### Using the `Ethereum` adapter
6369

@@ -100,7 +106,7 @@ POSTGRES_DB="sentry_follower" PORT=8006 KEYSTORE_PWD=ganache1 cargo run -p sentr
100106
IP_ADDR=127.0.0.1 REDIS_URL="redis://127.0.0.1:6379/1" \
101107
POSTGRES_DB="sentry_leader" PORT=8005 cargo run -p sentry -- \
102108
--adapter dummy \
103-
--dummyIdentity 80690751969B234697e9059e04ed72195c3507fa \
109+
--dummyIdentity 0x80690751969B234697e9059e04ed72195c3507fa \
104110
./docs/config/prod.toml
105111
```
106112
##### Follower (`0xf3f583AEC5f7C030722Fe992A5688557e1B86ef7`)
@@ -109,19 +115,18 @@ POSTGRES_DB="sentry_leader" PORT=8005 cargo run -p sentry -- \
109115
IP_ADDR=127.0.0.1 REDIS_URL="redis://127.0.0.1:6379/2" \
110116
POSTGRES_DB="sentry_follower" PORT=8006 cargo run -p sentry -- \
111117
--adapter dummy \
112-
--dummyIdentity f3f583AEC5f7C030722Fe992A5688557e1B86ef7 \
118+
--dummyIdentity 0xf3f583AEC5f7C030722Fe992A5688557e1B86ef7 \
113119
./docs/config/prod.toml
114120
```
115121

116-
For full list, check out [primitives/src/util/tests/prep_db.rs#L29-L43](./primitives/src/util/tests/prep_db.rs#L29-L43)
117-
118122
#### Environment variables
119123

120124
- `ENV` - `production` or `development`; *default*: `development` - passing this env. variable will use the default configuration paths - [`docs/config/dev.toml`](./docs/config/dev.toml) (for `development`) or [`docs/config/prod.toml`](./docs/config/prod.toml) (for `production`). Otherwise you can pass your own configuration file path to the binary (check `cargo run -p sentry --help` for more information). In `development` it will make sure Sentry to seed the database.
121125
- `PORT` - *default*: `8005` - The local port that Sentry API will be accessible at
122126
- `IP_ADDR` - *default*: `0.0.0.0` - the IP address that the API should be listening to
123127

124128
##### Adapter
129+
125130
- `KEYSTORE_PWD` - Password for the `Keystore file`, only available when using `Ethereum` adapter (`--adapter ethereum`)
126131

127132
##### Redis

adview-manager/src/lib.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@ const IPFS_GATEWAY: &str = "https://ipfs.moonicorn.network/ipfs/";
3636
/// Related: <https://github.com/AdExNetwork/adex-adview-manager/issues/17>, <https://github.com/AdExNetwork/adex-adview-manager/issues/35>, <https://github.com/AdExNetwork/adex-adview-manager/issues/46>
3737
///
3838
/// Used for JS [setTimeout](https://developer.mozilla.org/en-US/docs/Web/API/setTimeout) function
39-
const WAIT_FOR_IMPRESSION: u32 = 8000;
39+
pub const WAIT_FOR_IMPRESSION: u32 = 8000;
4040
// The number of impressions (won auctions) kept in history
4141
const HISTORY_LIMIT: u32 = 50;
4242

primitives/src/campaign.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@ use chrono::{
1010
use serde::{Deserialize, Serialize};
1111
use serde_with::with_prefix;
1212

13+
#[doc(inline)]
1314
pub use {
1415
campaign_id::CampaignId,
1516
pricing::{Pricing, PricingBounds},

primitives/src/channel.rs

Lines changed: 2 additions & 48 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
use std::{error::Error, fmt, ops::Deref, str::FromStr};
1+
use std::{fmt, ops::Deref, str::FromStr};
22

33
use ethereum_types::U256;
44

@@ -7,7 +7,7 @@ use serde_hex::{SerHex, StrictPfx};
77

88
use hex::{FromHex, FromHexError};
99

10-
use crate::{chain::Chain, config::TokenInfo, Address, Validator, ValidatorId};
10+
use crate::{Address, Validator, ValidatorId};
1111

1212
#[derive(Serialize, Deserialize, PartialEq, Eq, Copy, Clone, Hash)]
1313
#[serde(transparent)]
@@ -90,12 +90,6 @@ impl FromStr for ChannelId {
9090
}
9191
}
9292

93-
#[derive(Debug, Clone, PartialEq, Eq)]
94-
pub struct ChainContext {
95-
pub token: TokenInfo,
96-
pub chain: Chain,
97-
}
98-
9993
#[derive(Serialize, Deserialize, Debug, Copy, Clone, PartialEq, Eq, Hash)]
10094
#[serde(rename_all = "camelCase")]
10195
pub struct Channel {
@@ -198,46 +192,6 @@ impl Serialize for Nonce {
198192
}
199193
}
200194

201-
#[derive(Debug, PartialEq, Eq)]
202-
pub enum ChannelError {
203-
InvalidArgument(String),
204-
/// When the Adapter address is not listed in the `channel.spec.validators`
205-
/// which in terms means, that the adapter shouldn't handle this Channel
206-
AdapterNotIncluded,
207-
/// when `channel.valid_until` has passed (< now), the channel should be handled
208-
InvalidValidUntil(String),
209-
UnlistedValidator,
210-
UnlistedCreator,
211-
UnlistedAsset,
212-
MinimumValidatorFeeNotMet,
213-
FeeConstraintViolated,
214-
}
215-
216-
impl fmt::Display for ChannelError {
217-
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
218-
match self {
219-
ChannelError::InvalidArgument(error) => write!(f, "{}", error),
220-
ChannelError::AdapterNotIncluded => write!(f, "channel is not validated by us"),
221-
ChannelError::InvalidValidUntil(error) => write!(f, "{}", error),
222-
ChannelError::UnlistedValidator => write!(f, "validators are not in the whitelist"),
223-
ChannelError::UnlistedCreator => write!(f, "channel.creator is not whitelisted"),
224-
ChannelError::UnlistedAsset => write!(f, "channel.depositAsset is not whitelisted"),
225-
ChannelError::MinimumValidatorFeeNotMet => {
226-
write!(f, "channel validator fee is less than MINIMAL_FEE")
227-
}
228-
ChannelError::FeeConstraintViolated => {
229-
write!(f, "total fees <= deposit: fee constraint violated")
230-
}
231-
}
232-
}
233-
}
234-
235-
impl Error for ChannelError {
236-
fn cause(&self) -> Option<&dyn Error> {
237-
None
238-
}
239-
}
240-
241195
#[cfg(test)]
242196
mod test {
243197
use super::*;

primitives/src/lib.rs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55
#![allow(unstable_name_collisions)]
66
use std::{error, fmt};
77

8+
#[doc(inline)]
89
pub use self::{
910
ad_slot::AdSlot,
1011
ad_unit::AdUnit,
@@ -167,6 +168,7 @@ mod deposit {
167168
}
168169

169170
pub mod util {
171+
#[doc(inline)]
170172
pub use api::ApiUrl;
171173

172174
pub mod api;

primitives/src/targeting.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@ pub use eval::*;
44
use serde_json::Number;
55
use std::collections::HashMap;
66

7+
#[doc(inline)]
78
pub use input::{field::GetField, Input};
89

910
mod eval;

primitives/src/test_util.rs

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -129,6 +129,9 @@ pub static DUMMY_AUTH: Lazy<HashMap<Address, String>> = Lazy::new(|| {
129129
auth.insert(*ADVERTISER, "AUTH_awesomeAdvertiser".into());
130130
auth.insert(*PUBLISHER, "AUTH_awesomePublisher".into());
131131
auth.insert(*GUARDIAN_2, "AUTH_awesomeGuardian2".into());
132+
auth.insert(*PUBLISHER_2, "AUTH_awesomePublisher2".into());
133+
auth.insert(*ADVERTISER_2, "AUTH_awesomeAdvertiser2".into());
134+
auth.insert(*LEADER_2, "AUTH_awesomeLeader2".into());
132135

133136
auth
134137
});

primitives/src/validator.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@ use crate::{
99
Address, DomainError, ToETHChecksum, ToHex, UnifiedNum,
1010
};
1111

12+
#[doc(inline)]
1213
pub use messages::*;
1314

1415
#[derive(Serialize, Deserialize, Clone, Copy, PartialEq, Eq, PartialOrd, Ord, Hash)]

0 commit comments

Comments
 (0)