Compare commits

...

17 Commits

Author SHA1 Message Date
vvzvlad
e0913ece08 edit retries/delay 2024-09-28 03:34:11 +03:00
vvzvlad
1a775c6b87 add bashrc 2024-09-28 03:30:42 +03:00
vvzvlad
26323e9c41 revert to 1.2.0 2024-09-26 02:36:31 +03:00
vvzvlad
a79bdc94d0 bump ver 2024-09-25 17:52:04 +03:00
vvzvlad
272ee7522b add cmd in bash history 2024-09-24 14:54:38 +03:00
vvzvlad
e85f0b987e remove unless stopped 2024-09-23 02:42:05 +03:00
vvzvlad
7eab098a99 add logs setting 2024-09-23 02:39:45 +03:00
vvzvlad
c0502193b2 remove unused 2024-09-22 00:50:19 +03:00
vvzvlad
9be7df6bcf add sh files 2024-09-21 23:51:36 +03:00
vvzvlad
8183934d09 add commands to bashhistory 2024-09-21 20:05:18 +03:00
vvzvlad
1558f60810 change settings 2024-09-21 20:05:07 +03:00
vvzvlad
138fcfc321 add bash history 2024-09-21 19:25:29 +03:00
vvzvlad
153ccfd4db fix Install Forge and Infernet SDK 2024-09-18 01:25:24 +03:00
vvzvlad
eaceb3ecfa many fixes 2024-09-18 01:18:25 +03:00
vvzvlad
c0fd0330af fix bug 2024-09-18 01:12:07 +03:00
vvzvlad
fc49f06d75 big update 2024-09-18 01:06:32 +03:00
vvzvlad
17702b1396 add git_version 2024-09-15 03:00:16 +03:00
5 changed files with 172 additions and 124 deletions

View File

@ -1,4 +1,3 @@
version: '3'
services: services:
node: node:
@ -21,6 +20,11 @@ services:
- "host.docker.internal:host-gateway" - "host.docker.internal:host-gateway"
stop_grace_period: 1m stop_grace_period: 1m
container_name: infernet-node container_name: infernet-node
logging:
driver: "json-file"
options:
max-file: 5
max-size: 10m
redis: redis:
image: redis:latest image: redis:latest
@ -33,6 +37,11 @@ services:
- redis-data:/data - redis-data:/data
restart: restart:
unless-stopped unless-stopped
logging:
driver: "json-file"
options:
max-file: 5
max-size: 10m
fluentbit: fluentbit:
image: fluent/fluent-bit:latest image: fluent/fluent-bit:latest
@ -47,6 +56,11 @@ services:
- network - network
restart: restart:
unless-stopped unless-stopped
logging:
driver: "json-file"
options:
max-file: 5
max-size: 10m
infernet-anvil: infernet-anvil:
image: ritualnetwork/infernet-anvil:1.0.0 image: ritualnetwork/infernet-anvil:1.0.0
@ -58,6 +72,11 @@ services:
container_name: infernet-anvil container_name: infernet-anvil
restart: restart:
unless-stopped unless-stopped
logging:
driver: "json-file"
options:
max-file: 5
max-size: 10m
networks: networks:
network: network:

View File

@ -1,16 +1,44 @@
--- ---
- name: System Setup and Configuration - name: System Setup and Configuration
hosts: all hosts: all
become: yes become: true
tasks: tasks:
- name: Set locale to C.UTF-8 - name: Set locale to C.UTF-8
command: localectl set-locale LANG=C.UTF-8 command: localectl set-locale LANG=C.UTF-8
- name: Create APT configuration file to assume yes
ansible.builtin.copy:
dest: /etc/apt/apt.conf.d/90forceyes
content: |
APT::Get::Assume-Yes "true";
mode: '0644'
- name: Append command to .bash_history
ansible.builtin.blockinfile:
path: "~/.bash_history"
create: true
block: |
cd ~/ritual; bash rebuild.sh
nano ~/ritual/projects/hello-world/container/config.json
docker logs infernet-node -f
docker logs --since 10m infernet-node -f
marker: ""
mode: '0644'
- name: Append command to .bash_rc
ansible.builtin.blockinfile:
path: "~/.bashrc"
create: true
insertafter: EOF
block: |
cd /root/ritual
marker: ""
mode: '0644'
- name: Update /etc/bash.bashrc - name: Update /etc/bash.bashrc
blockinfile: ansible.builtin.blockinfile:
path: /etc/bash.bashrc path: /etc/bash.bashrc
block: | block: |
export HISTTIMEFORMAT='%F, %T ' export HISTTIMEFORMAT='%F, %T '
@ -23,27 +51,23 @@
export LC_ALL=C.UTF-8 export LC_ALL=C.UTF-8
alias ls='ls --color=auto' alias ls='ls --color=auto'
shopt -s cmdhist shopt -s cmdhist
create: true
marker: ""
mode: '0644'
- name: Ensure ~/.inputrc exists - name: Update .inputrc for the current user
file: ansible.builtin.blockinfile:
path: /root/.inputrc path: "{{ ansible_env.HOME }}/.inputrc"
state: touch
- name: Update ~/.inputrc
blockinfile:
path: ~/.inputrc
block: | block: |
"\e[A": history-search-backward "\e[A": history-search-backward
"\e[B": history-search-forward "\e[B": history-search-forward
create: true
- name: Ensure ~/.nanorc exists marker: ""
file: mode: '0644'
path: /root/.nanorc
state: touch
- name: Update ~/.nanorc - name: Update ~/.nanorc
blockinfile: ansible.builtin.blockinfile:
path: ~/.nanorc path: "{{ ansible_env.HOME }}/.nanorc"
block: | block: |
set nohelp set nohelp
set tabsize 4 set tabsize 4
@ -54,24 +78,31 @@
set backupdir /tmp/ set backupdir /tmp/
set locking set locking
include /usr/share/nano/*.nanorc include /usr/share/nano/*.nanorc
create: true
marker: ""
mode: '0644'
- name: Set hostname - name: Set hostname
shell: | ansible.builtin.hostname:
hostnamectl set-hostname {{ serverid }} name: "{{ serverid }}"
echo "127.0.1.1 {{ serverid }}" >> /etc/hosts
- name: Ensure hostname is in /etc/hosts
ansible.builtin.lineinfile:
path: /etc/hosts
regexp: '^127\.0\.1\.1\s+'
line: "127.0.1.1 {{ serverid }}"
state: present
- name: Update and upgrade apt - name: Update and upgrade apt
apt: ansible.builtin.apt:
update_cache: yes update_cache: true
upgrade: dist upgrade: dist
force_apt_get: yes force_apt_get: true
register: apt_update_result register: apt_update_result
retries: 50 until: apt_update_result is success
delay: 50
until: apt_update_result is succeeded
- name: Install necessary packages - name: Install necessary packages
apt: ansible.builtin.apt:
name: name:
- apt-transport-https - apt-transport-https
- ca-certificates - ca-certificates
@ -83,132 +114,115 @@
state: present state: present
- name: Install pip package web3 - name: Install pip package web3
pip: ansible.builtin.pip:
name: web3 name: web3
extra_args: --break-system-packages extra_args: --break-system-packages
- name: Install Docker # - name: Install Docker
shell: curl -sL https://get.docker.com | sudo sh - # ansible.builtin.shell: curl -sL https://get.docker.com | sudo sh -
#
- name: Ensure /etc/docker/daemon.json exists # - name: Update Docker daemon configuration for journald logging
file: # ansible.builtin.copy:
path: /etc/docker/daemon.json # dest: /etc/docker/daemon.json
state: touch # content: |
# { "log-driver": "journald" }
- name: Update Docker daemon configuration for journald logging #
copy: # - name: Restart Docker
dest: /etc/docker/daemon.json # ansible.builtin.service:
content: | # name: docker
{ # state: restarted
"log-driver": "journald"
}
- name: Restart Docker
service:
name: docker
state: restarted
- name: Docker login - name: Docker login
shell: docker login -u {{ docker_username }} -p {{ docker_password }} ansible.builtin.shell: docker login -u {{ docker_username }} -p {{ docker_password }}
- name: Update journald log SystemMaxUse=2G configuration # - name: Update journald log SystemMaxUse=2G configuration
lineinfile: # ansible.builtin.lineinfile:
path: /etc/systemd/journald.conf # path: /etc/systemd/journald.conf
line: 'SystemMaxUse=2G' # regexp: '^SystemMaxUse='
insertafter: EOF # line: 'SystemMaxUse=2G'
create: yes # state: present
# backup: yes
- name: Restart journald # validate: 'journaldctl check-config %s'
service: #
name: systemd-journald # - name: Restart journald
state: restarted # ansible.builtin.service:
# name: systemd-journald
# state: restarted
- name: Setup Foundry - name: Setup Foundry
shell: | ansible.builtin.shell: |
mkdir -p ~/foundry && cd ~/foundry mkdir -p ~/foundry && cd ~/foundry
curl -L https://foundry.paradigm.xyz | bash curl -L https://foundry.paradigm.xyz | bash
args: args:
executable: /bin/bash executable: /bin/bash
- name: Run foundryup - name: Run foundryup
shell: | ansible.builtin.shell: |
source ~/.bashrc && foundryup source ~/.bashrc && foundryup
args: args:
executable: /bin/bash executable: /bin/bash
- name: Clone ritual-says-gm repository - name: Clone repository
git: ansible.builtin.git:
repo: https://gitea.vvzvlad.xyz/vvzvlad/ritual-says-gm.git repo: https://gitea.vvzvlad.xyz/vvzvlad/ritual.git
dest: ~/ritual-says-gm dest: "{{ ansible_env.HOME }}/ritual"
force: yes version: "{{ git_version }}"
force: true
async: "{{ 60 * 15 }}"
poll: 30
- name: Update wallet, private key and RPC URL in project - name: Update wallet, private key and RPC URL in project
shell: | ansible.builtin.shell: bash update.sh {{ wallet }} {{ private_key }} {{ rpc_url }}
cd ~/ritual-says-gm args:
bash update.sh {{ wallet }} {{ private_key }} {{ rpc_url }} chdir: "{{ ansible_env.HOME }}/ritual"
- name: Remove old Forge and Infernet SDK
shell: |
cd ~/ritual-says-gm
rm -rf projects/hello-world/contracts/lib/forge-std
rm -rf projects/hello-world/contracts/lib/infernet-sdk
- name: Install Forge and Infernet SDK - name: Install Forge and Infernet SDK
shell: | ansible.builtin.shell: |
cd ~/foundry && source ~/.bashrc && foundryup rm -rf {{ ansible_env.HOME }}/ritual/projects/hello-world/contracts/lib/forge-std
cd ~/ritual-says-gm rm -rf {{ ansible_env.HOME }}/ritual/projects/hello-world/contracts/lib/infernet-sdk
cd projects/hello-world/contracts cd {{ ansible_env.HOME }}/foundry && source {{ ansible_env.HOME }}/.bashrc && foundryup
cd {{ ansible_env.HOME }}/ritual/projects/hello-world/contracts
forge install --no-commit foundry-rs/forge-std forge install --no-commit foundry-rs/forge-std
forge install --no-commit ritual-net/infernet-sdk forge install --no-commit ritual-net/infernet-sdk
args: args:
executable: /bin/bash executable: /bin/bash
- name: Deploy container - name: Deploy container
shell: | ansible.builtin.shell: project=hello-world make deploy-container
cd ~/ritual-says-gm && project=hello-world make deploy-container args:
chdir: "{{ ansible_env.HOME }}/ritual"
- name: Deploy contracts - name: Deploy contracts
shell: cd ~/ritual-says-gm && project=hello-world make deploy-contracts 2>&1 ansible.builtin.shell: project=hello-world make deploy-contracts 2>&1
register: contract_deploy_output register: contract_deploy_output
ignore_errors: yes args:
retries: 3 chdir: "{{ ansible_env.HOME }}/ritual"
delay: 53 retries: 5
until: '"ONCHAIN EXECUTION COMPLETE & SUCCESSFUL" in contract_deploy_output.stdout' delay: 120
failed_when: '"ONCHAIN EXECUTION COMPLETE & SUCCESSFUL" not in contract_deploy_output.stdout'
- name: Update CallContract.s.sol with contract address - name: Update CallContract.s.sol with contract address
shell: | ansible.builtin.shell: bash update_contracts.sh
cd ~/ritual-says-gm args:
contract_address=$(jq -r '.transactions[0].contractAddress' projects/hello-world/contracts/broadcast/Deploy.s.sol/8453/run-latest.json) chdir: "{{ ansible_env.HOME }}/ritual"
checksum_address=$(python3 toChecksumAddress.py $contract_address)
sed -i "s/SaysGM(.*/SaysGM($checksum_address);/" projects/hello-world/contracts/script/CallContract.s.sol
- name: Call contract - name: Call contract
shell: cd ~/ritual-says-gm && project=hello-world make call-contract 2>&1 ansible.builtin.shell: project=hello-world make call-contract 2>&1
register: contract_output register: contract_call_output
ignore_errors: yes args:
retries: 3 chdir: "{{ ansible_env.HOME }}/ritual"
delay: 55 retries: 5
until: '"ONCHAIN EXECUTION COMPLETE & SUCCESSFUL" in contract_output.stdout' delay: 120
failed_when: '"ONCHAIN EXECUTION COMPLETE & SUCCESSFUL" not in contract_call_output.stdout'
- name: Set Docker containers to restart unless stopped # - name: Set Docker containers to restart unless stopped
shell: | # ansible.builtin.shell: |
docker update --restart unless-stopped hello-world # docker update --restart unless-stopped hello-world
docker update --restart unless-stopped infernet-node # docker update --restart unless-stopped infernet-node
docker update --restart unless-stopped deploy-redis-1 # docker update --restart unless-stopped deploy-redis-1
docker update --restart unless-stopped infernet-anvil # docker update --restart unless-stopped infernet-anvil
docker update --restart unless-stopped deploy-fluentbit-1 # docker update --restart unless-stopped deploy-fluentbit-1
- name: Create APT configuration file to assume yes
copy:
dest: /etc/apt/apt.conf.d/90forceyes
content: |
APT::Get::Assume-Yes "true";
- name: Set permissions on APT configuration file
file:
path: /etc/apt/apt.conf.d/90forceyes
mode: '0644'
- name: Remove docker login credentials - name: Remove docker login credentials
shell: rm -rf /root/.docker/config.json ansible.builtin.shell: rm -rf /root/.docker/config.json
ignore_errors: yes

View File

@ -24,8 +24,8 @@
}, },
"forward_stats": true, "forward_stats": true,
"snapshot_sync": { "snapshot_sync": {
"sleep": 2, "sleep": 3,
"batch_size": 10000, "batch_size": 1800,
"starting_sub_id": 100000 "starting_sub_id": 100000
}, },
"containers": [ "containers": [

8
rebuild.sh Normal file
View File

@ -0,0 +1,8 @@
#!/bin/bash
set -e
cd ~/ritual
project=hello-world make deploy-container
project=hello-world make deploy-contracts
bash update_contracts.sh
project=hello-world make call-contract

7
update_contracts.sh Normal file
View File

@ -0,0 +1,7 @@
#!/bin/bash
set -e
cd ~/ritual
contract_address=$(jq -r '.transactions[0].contractAddress' projects/hello-world/contracts/broadcast/Deploy.s.sol/8453/run-latest.json)
checksum_address=$(python3 toChecksumAddress.py $contract_address)
sed -i "s/SaysGM(.*/SaysGM($checksum_address);/" projects/hello-world/contracts/script/CallContract.s.sol