Skip to content

Commit

Permalink
ROLLUP-471/fix-deployment (#109)
Browse files Browse the repository at this point in the history
* fix(dev-ticker): install ca-certificates to avoid cert verification issues

* fix: update dev-ticker image of all the docker-compose files

* chore: fix typo in comment

* fix: load chain config only instead of all the config

* fix(fee_ticker): do not retrieve market volume for RBTC, RDOC, USDRIF

* fix: create mnemonic using the rsk path

* fix: update docker-compose to use the latest dev-ticker

* build: updated server version in docker-compose

* fix: use the uppercase symbol when comparing tokens

* refactor: fix dev ticker

* ci: rename docker-compose-runner.yml and fix ci

* ci: fix dev-ticker restart

* ci: fix ci by creating an empty dev.env file

* ci: fix ci by starting dev-ticker

---------

Co-authored-by: Francisco Tobar <[email protected]>
  • Loading branch information
antomor and franciscotobar authored Oct 30, 2023
1 parent 03e7619 commit e2e2236
Show file tree
Hide file tree
Showing 18 changed files with 57 additions and 52 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/ci-iov-sim-tool.yml
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ jobs:
- name: start-services
run: |
docker-compose -f docker-compose-runner.yml up --build -d zk
docker-compose -f docker-compose.ci.yml up --build -d zk
- name: init
run: |
Expand Down
27 changes: 16 additions & 11 deletions .github/workflows/ci-iov.yml
Original file line number Diff line number Diff line change
Expand Up @@ -21,12 +21,17 @@ jobs:
run: |
echo ZKSYNC_HOME=$(pwd) >> $GITHUB_ENV
echo $(pwd)/bin >> $GITHUB_PATH
# dev.env file is required before running zk init
- name: create-empty-dev-file
run: |
touch $ZKSYNC_HOME/etc/env/dev.env
- name: start-services
run: |
docker-compose -f docker-compose-runner.yml down
docker-compose -f docker-compose-runner.yml pull
docker-compose -f docker-compose-runner.yml -f docker-compose-runner.unit-tests.yml up --build -d rskj postgres zk
docker-compose -f docker-compose.ci.yml down
docker-compose -f docker-compose.ci.yml pull
docker-compose -f docker-compose.ci.yml -f docker-compose.ci.unit-tests.yml up --build -d rskj postgres zk
ci_run sccache --start-server &
- name: generate SSL certificates
Expand All @@ -44,8 +49,8 @@ jobs:
ci_run zk
ci_run zk init
- name: restart dev-ticker
run: docker-compose -f docker-compose-runner.yml restart dev-ticker
- name: start dev-ticker
run: docker-compose -f docker-compose.ci.yml up -d dev-ticker

- name: Toolchain info
run: |
Expand All @@ -70,18 +75,18 @@ jobs:

- name: start-services (rskj, postgres, zk)
run: |
docker-compose -f docker-compose-runner.yml down
docker-compose -f docker-compose-runner.yml pull
docker-compose -f docker-compose-runner.yml up --build -d rskj postgres zk
docker-compose -f docker-compose.ci.yml down
docker-compose -f docker-compose.ci.yml pull
docker-compose -f docker-compose.ci.yml up --build -d rskj postgres zk
ci_run sccache --start-server &
- name: run zk init
run: |
ci_run zk
ci_run zk init
- name: restart dev-ticker
run: docker-compose -f docker-compose-runner.yml restart dev-ticker
- name: start dev-ticker
run: docker-compose -f docker-compose.ci.yml up -d dev-ticker

- name: run-services
run: |
Expand Down Expand Up @@ -113,7 +118,7 @@ jobs:
ci_run cat dummy_prover.log
ci_run mkdir -p ./target/release/coverage/
ci_run "grcov . --binary-path ./target/release/deps/ -s . -t lcov --branch --ignore-not-existing --ignore '../*' --ignore '/*' -o ./target/release/coverage/lcov.info"
docker compose -f docker-compose-runner.yml cp zk:/usr/src/zksync/target/release/coverage/lcov.info lcov.info
docker compose -f docker-compose.ci.yml cp zk:/usr/src/zksync/target/release/coverage/lcov.info lcov.info
du lcov.info
- uses: codecov/codecov-action@v3
Expand Down
2 changes: 1 addition & 1 deletion bin/ci_run
Original file line number Diff line number Diff line change
Expand Up @@ -3,4 +3,4 @@
# Runs the command from within CI docker-compose environment.
export ZKSYNC_HOME=$(pwd) && \
cd $ZKSYNC_HOME || exit 1 && \
docker-compose -f docker-compose-runner.yml exec -T zk $@
docker-compose -f docker-compose.ci.yml exec -T zk $@
2 changes: 1 addition & 1 deletion contracts/scripts/governance-add-erc20.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ const ethTestConfig = JSON.parse(fs.readFileSync(`${testConfigPath}/eth.json`, {
const deployer = new Deployer({ deployWallet: ethers.Wallet.createRandom() });
const provider = web3Provider();
const governorWallet = process.env.MNEMONIC
? Wallet.fromMnemonic(process.env.MNEMONIC, "m/44'/137'/0'/0/1").connect(provider)
? Wallet.fromMnemonic(process.env.MNEMONIC, "m/44'/37310'/0'/0/0").connect(provider)
: new Wallet(Buffer.from(ethTestConfig.account_with_rbtc_cow1_privK, 'hex'), provider);

async function governanceAddToken(address: string) {
Expand Down
4 changes: 2 additions & 2 deletions core/bin/zksync_api/src/bin/dev_ticker_server.rs
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ use std::{
};
use structopt::StructOpt;
use tokio::sync::Mutex;
use zksync_config::ZkSyncConfig;
use zksync_config::ChainConfig;
use zksync_types::{network::Network, TokenInfo};
use zksync_utils::parse_env;

Expand All @@ -37,7 +37,7 @@ fn load_tokens(path: impl AsRef<Path>) -> Result<Vec<TokenInfo>, serde_json::Err
#[actix_web::main]
async fn main() -> std::io::Result<()> {
let _vlog_guard = vlog::init();
let network = ZkSyncConfig::from_env().chain.eth.network;
let network = ChainConfig::from_env().eth.network;

let opts = FeeTickerOpts::from_args();
if opts.sloppy {
Expand Down
25 changes: 3 additions & 22 deletions core/bin/zksync_api/src/bin/providers/proxy_price_provider.rs
Original file line number Diff line number Diff line change
Expand Up @@ -22,17 +22,11 @@ async fn fetch_coins_list() -> HttpResponse {
// TODO: we always return the platforms, instead of checking for the query param `include_platform` to be true
let rif_token = CoinsListItem {
id: "rif-token".to_string(),
platforms: Some(rootstock_platform.clone()),
platforms: Some(rootstock_platform),
name: "RIF Token".to_string(),
symbol: "TRIF".to_string(),
};
let rbtc = CoinsListItem {
id: "rootstock".to_string(),
symbol: "TRBTC".to_string(),
name: "Rootstock RSK".to_string(),
platforms: Some(rootstock_platform),
};
let coin_list: &[CoinsListItem] = &[rif_token, rbtc];
let coin_list: &[CoinsListItem] = &[rif_token];

HttpResponse::Ok().json(coin_list)
}
Expand Down Expand Up @@ -111,9 +105,8 @@ mod fetch_coins_list_tests {
let body: Vec<CoinsListItem> = serde_json::from_slice(&body_bytes).unwrap();

let rif_token = body.iter().find(|coin| coin.id == "rif-token").unwrap();
let rbtc = body.iter().find(|coin| coin.id == "rootstock").unwrap();

assert_eq!(body.len(), 2);
assert_eq!(body.len(), 1);
assert_eq!(rif_token.name, "RIF Token");
assert_eq!(rif_token.symbol, "TRIF");
assert_eq!(
Expand All @@ -127,17 +120,5 @@ mod fetch_coins_list_tests {
.unwrap(),
RIF_TOKEN_TESTNET_ADDRESS
);
assert_eq!(rbtc.name, "Rootstock RSK");
assert_eq!(rbtc.symbol, "TRBTC");
assert_eq!(
rbtc.platforms
.as_ref()
.unwrap()
.get("rootstock")
.unwrap()
.as_ref()
.unwrap(),
RIF_TOKEN_TESTNET_ADDRESS
);
}
}
2 changes: 1 addition & 1 deletion core/bin/zksync_api/src/fee_ticker/ticker_api/coingecko.rs
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,7 @@ impl TokenPriceAPI for CoinGeckoAPI {
.query(&[
("vs_currency", "usd"),
("days", "1"),
// Removed ("interval", "hourly"), parameter as hourly charts are only available to coingecko enterprice plan customers
// Removed ("interval", "hourly"), parameter as hourly charts are only available to coingecko enterprise plan customers
// The default interval is daily
])
.send()
Expand Down
2 changes: 1 addition & 1 deletion core/bin/zksync_api/src/fee_ticker/ticker_info.rs
Original file line number Diff line number Diff line change
Expand Up @@ -200,7 +200,7 @@ impl FeeTickerInfo for TickerInfo {
};

// TODO: remove hardcode for tokens
if ["RDOC", "USDRIF"].contains(&token.symbol.as_str()) {
if ["RDOC", "USDRIF"].contains(&token.symbol.to_uppercase().as_str()) {
metrics::histogram!(TICKET_INFO_GET_LAST_TOKEN_PRICE, start.elapsed(), "type" => token.symbol);
return Ok(price_1_usd);
}
Expand Down
17 changes: 16 additions & 1 deletion core/bin/zksync_api/src/fee_ticker/validator/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ use std::{
use bigdecimal::BigDecimal;
use chrono::Utc;

use itertools::Itertools;
// Workspace uses
use zksync_types::{
tokens::{Token, TokenLike, TokenMarketVolume},
Expand Down Expand Up @@ -73,10 +74,24 @@ impl<W: TokenWatcher> MarketUpdater<W> {
pub async fn keep_updated(mut self, duration_secs: u64) {
let mut error_counter = 0;

// Market volume is not available for these tokens and
// we don't need it because they're added among the unconditionally_valid_tokens
let unavailable_market_volume_tokens = ["RDOC", "RBTC", "USDRIF"];
loop {
let tokens = self.tokens_cache.get_all_tokens().await;
let result = match tokens {
Ok(tokens) => self.update_all_tokens(tokens).await,
Ok(tokens) => {
self.update_all_tokens(
tokens
.into_iter()
.filter(|token| {
!unavailable_market_volume_tokens
.contains(&token.symbol.to_uppercase().as_str())
})
.collect_vec(),
)
.await
}
Err(e) => Err(e),
};

Expand Down
File renamed without changes.
6 changes: 4 additions & 2 deletions docker-compose-runner.yml → docker-compose.ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -17,9 +17,12 @@ services:
- ./docker/rskj/node.conf:/etc/rsk/node.conf

dev-ticker:
image: "rsksmart/rollup-dev-ticker:1.0.0-beta"
image: "rsksmart/rollup-dev-ticker:1.1.2-beta"
env_file:
- ./etc/env/dev.env
- ./etc/env/docker.env
environment:
- ZKSYNC_HOME=/
volumes:
- ./etc/tokens/:/etc/tokens

Expand All @@ -28,7 +31,6 @@ services:
depends_on:
- postgres
- rskj
- dev-ticker
command: tail -f /dev/null
volumes:
- .:/usr/src/zksync
Expand Down
7 changes: 5 additions & 2 deletions docker-compose.deploy.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ version: '3.2'
services:

server:
image: "rsksmart/rollup-server:1.0.1-beta"
image: "rsksmart/rollup-server:1.1.1-beta"
ports: #Ports that where configured using the environment variables
- 3001:3001 # RestApi
- 3002:3002 # Web3
Expand Down Expand Up @@ -51,9 +51,12 @@ services:
- ./etc/env/${ENV_OVERRIDE-deploy}.env

dev-ticker:
image: "rsksmart/rollup-dev-ticker:1.0.0-beta"
image: "rsksmart/rollup-dev-ticker:1.1.2-beta"
env_file:
- ./etc/env/${ZKSYNC_ENV-dev}.env
- ./etc/env/${ENV_OVERRIDE-deploy}.env
environment:
- ZKSYNC_HOME=/
ports:
- "9876:9876"
volumes:
Expand Down
2 changes: 1 addition & 1 deletion docker-compose.yml
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ services:
start_period: 15s

dev-ticker:
image: "rsksmart/rollup-dev-ticker:1.1.0-beta"
image: "rsksmart/rollup-dev-ticker:1.1.2-beta"
env_file:
- ./etc/env/${ZKSYNC_ENV-dev}.env
- ./etc/env/${ENV_OVERRIDE-deploy}.env
Expand Down
3 changes: 1 addition & 2 deletions docker/dev-ticker/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,7 @@ RUN --mount=type=cache,target=/usr/local/cargo/registry \
cargo build --bin dev_ticker_server --release

FROM debian:bullseye
RUN apt update
RUN apt install openssl -y
RUN apt-get update && apt-get install -y openssl ca-certificates && rm -rf /var/lib/apt/lists/*
EXPOSE 9876
ENV RUST_BACKTRACE "full"
ENV RUST_LOG info
Expand Down
2 changes: 1 addition & 1 deletion docker/rskj/node.conf
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ rpc {
hosts = [
"localhost",
"127.0.0.1",
"rskj", # rskj is the service name in docker-compose-runner.ymlfor CI
"rskj", # rskj is the service name in docker-compose.ci.yml for CI
"host.docker.internal", # host.docker.internal localhost from container Windows and Mac
"172.17.0.1" # 172.17.0.1 localhost from container Linux
]
Expand Down
2 changes: 1 addition & 1 deletion etc/env/qa/forced_exit_requests.toml
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ wait_confirmations=1

# The account of the ForcedExit sender
# The private key is defined in sender_eth_private_key <env_address>
sender_account_address="0xa4dea4d5c954f5fd9e87f0e9752911e83a3d18b3"
sender_account_address="0x47DD9BB622fFF25CF562aC264e6075807B754EC8"

# The time after which an invalid request is deleted in milliseconds
expiration_period=3000
Expand Down
2 changes: 1 addition & 1 deletion etc/env/qa/private.toml
Original file line number Diff line number Diff line change
Expand Up @@ -38,4 +38,4 @@ fee_account_private_key="0xea09e1fe584019bef786ba95da92bd0c256f599457aa6bf1520c0
# L2 private key of the account that sends ForcedExits <env_priv_key>
sender_private_key="0x0092788f3890ed50dcab7f72fb574a0a9d30b1bc778ba076c609c311a8555352"
# L1 private key of the account that sends ForcedExits <env_priv_key>
sender_eth_private_key="0xd77b8a342be95c5c31fa85c20450b424663c4fb4a499cfc80c202c592c85c219"
sender_eth_private_key="0xd783469124d7db80f6531ca19156cb777a1922d9edbbb1a9a35b75b5b981b2d8"
2 changes: 1 addition & 1 deletion etc/env/testnet/forced_exit_requests.toml
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ wait_confirmations=1

# The account of the ForcedExit sender
# The private key is defined in sender_eth_private_key <env_address>
sender_account_address="0xa4dea4d5c954f5fd9e87f0e9752911e83a3d18b3"
sender_account_address="0xe10C0796fF6f6Ff4185109bE8Cf133a66e5f024D"

# The time after which an invalid request is deleted in milliseconds
expiration_period=3000
Expand Down

0 comments on commit e2e2236

Please sign in to comment.