Skip to content

Commit

Permalink
Merge pull request ava-labs#1 from StephenButtolph/update-ipcs
Browse files Browse the repository at this point in the history
Resolve merge conflicts
  • Loading branch information
tyler-smith authored Aug 5, 2020
2 parents 7014fc8 + ab27ef9 commit c6ce11d
Show file tree
Hide file tree
Showing 32 changed files with 324 additions and 42 deletions.
16 changes: 13 additions & 3 deletions .ci/run_e2e_tests.sh
Original file line number Diff line number Diff line change
Expand Up @@ -4,13 +4,23 @@ SRC_PATH=$(dirname "${SCRIPTS_PATH}")
bash "${SRC_PATH}"/scripts/build_image.sh
GECKO_IMAGE=$(docker image ls --format="{{.Repository}}" | head -n 1)

# login to AWS for byzantine images
export AWS_ACCESS_KEY_ID="${BYZ_REG_AWS_ID}"
export AWS_SECRET_ACCESS_KEY="${BYZ_REG_AWS_KEY}"
export AWS_DEFAULT_REGION="${BYZ_REG_AWS_REGION}"
aws ecr get-login-password --region "${AWS_DEFAULT_REGION}" | docker login --username AWS --password-stdin 964377072876.dkr.ecr.us-east-1.amazonaws.com
CHIT_SPAMMER_IMAGE="964377072876.dkr.ecr.us-east-1.amazonaws.com/gecko-byzantine:latest"

docker pull "${CHIT_SPAMMER_IMAGE}"

# Turn off GO111MODULE to pull e2e test source code in order to get run script.
GO111MODULE=off go get -t -v github.com/kurtosis-tech/ava-e2e-tests/...
cd "${GOPATH}"/src/github.com/kurtosis-tech/ava-e2e-tests/ || exit
git clone https://github.com/kurtosis-tech/ava-e2e-tests.git
cd ava-e2e-tests/ || exit
git checkout 0.6.0

bash "./scripts/rebuild_initializer_binary.sh"
bash "./scripts/rebuild_controller_image.sh"
# TODO: Make the controller image label a parameter to rebuild_controller_image script
# Standard controller image label used by above scripts.
CONTROLLER_IMAGE="kurtosistech/ava-e2e-tests_controller:latest"
./build/ava-e2e-tests --gecko-image-name="${GECKO_IMAGE}" --test-controller-image-name="${CONTROLLER_IMAGE}" --test-names="fiveStakingNodeGetValidatorsTest,fiveStakingNodeFullyConnectedTest"
./build/ava-e2e-tests --gecko-image-name="${GECKO_IMAGE}" --test-controller-image-name="${CONTROLLER_IMAGE}" --chit-spammer-image-name="${CHIT_SPAMMER_IMAGE}"
1 change: 1 addition & 0 deletions .github/workflows/ansible-lint.yml
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ jobs:
scripts/ansible/kill_playbook.yml
scripts/ansible/ping_playbook.yml
scripts/ansible/restart_playbook.yml
scripts/ansible/service_playbook.yml
scripts/ansible/update_playbook.yml
args:
Expand Down
3 changes: 2 additions & 1 deletion .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,8 @@ env:
- DOCKERHUB_REPO=avaplatform/gecko
- secure: "L/A9+re0NEKP6EV6H9RcTGiDhX3WMvsiWrkRKDYKqnviqbjY30RK6EM4vvjrM4Lrw2QwsO3YKgnku3+zioE/TxEZFkpkbjNUXru0nYBrWAg1TKVsDXnYaIZkHUejfryST3E8N7F4Hx6zCtGEO0sEdUeKuT+MNUIuHezHooTgGzDjMogm70EWMFjQHc7VucTJu7dWU1RBPjovWQ0q9qflrtCpbrvXFIiihQQ1PQha1Q2C4wLakKuLbhhSafue90Mnyss0blaPHy/tyewcASJu4vsGTKRBn0DzttlkNTwuD6+nKrbmJY0ohunnkVFzYjrZAw1gyN+DCDb/lPbz4ZDItKPwrIUPEtL5xuUOrxUZPUh+0io3Q2d6rjaqkdGjd1KQXzbnW1mn0BxX3d3b2UpIqhBn9umYYjHBKnMuoRiTK33b7U9+LF3K84+tEvVDCPeHs/mw6Inp5jGRSravnM6yPQ6feGzogs4+3EMzZXxnkngKFKCsnd67Oe9xfV9amOU2aQAx4jaAwlPjEpBEkUa8YKx3lPznvmUk1QsNCUbLjdSl5JBaXojLJoiuPbj29hp4S5AXXgn+3Hvwk3ndcFCxi6/l1W9mjYSOtFqg3EAUdF4EgnA/ykQg9ZokkoKY0+qgOzG2bKOAYuCDWeGr7P1apToh00ccsQXL81nVPiq7uDw="
- secure: "zfTm7tJBYiPYrli76d4Ep6Lc2TJQ8Xv//+7OoqTA/aIf6YJDHe05f2GFTWAHG2iOIix/yjwHYwnhyIW66eWPb+Ujejnmh4eXlYZFufX9J5jUpDpbFu/+ybOLgE1Tmr0je0ycneSMe/NAaS74nWU1wnP34/cEE4sYL7TJyhwbeEtgz3cbSWwkpdvHFbXCjSOA196jdIYYUwsnqU9yycAG+2WUSk3DHHzzdtMrh/UOH2r1VFyp5US0zmbW90WkWX+o3TIlzZJgTUGQRNnWKq95Mrh1EQotxgL6CJ8NkfY4bVAGAhusPjdjscJsHxfY93WRMH64TzPYYp0zdibatH0ztyhnZPXVKqv+AIIVTEW+xWv5V18kTQAd1uBW103NFacbgXhIGWtbFcN9g1+ws29HROMclYs7ci6+72Qnq0eL55huqSyFx6+InhYwn+LfJmaBcGW4wx1umdp505M0obZ4ghlyn6b0pDYmqsu1XyBC3mjUTFbwlQmWE2Fize4L5o+DdH4ZDc9japF9ntxIMvO+b3nOicr7tplY2AGp61bB89o3dUAFlN5mDaEJotiAuFk5mo244rY1FjSzyGiKkA3M9TkTIbgcbN098hOJoMCYybH7yqiPwNnZiFvUuYjHuC5D1kIYBWuqqO0iVcbIZn0rV2jyzbVFlhFVk2clTZGhkrY="
before_install:
before_install:
- pip install --user awscli # need awscli to access byz-gecko images
- if [ "$TRAVIS_OS_NAME" = "linux" ]; then .ci/before_install_linux.sh; fi

install:
Expand Down
16 changes: 8 additions & 8 deletions api/ipcs/server.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ import (
"fmt"
"net/http"

_ "nanomsg.org/go/mangos/v2/transport/ipc" // registers the IPC transport
_ "go.nanomsg.org/mangos/v3/transport/ipc" // registers the IPC transport

"github.com/gorilla/rpc/v2"

Expand All @@ -19,7 +19,7 @@ import (
"github.com/ava-labs/gecko/utils/logging"
)

// IPCs maintains the IPCs
// IPCServer maintains the IPCs
type IPCServer struct {
httpServer *api.Server
chainManager chains.Manager
Expand Down Expand Up @@ -57,17 +57,17 @@ type PublishBlockchainReply struct {
}

// PublishBlockchain publishes the finalized accepted transactions from the blockchainID over the IPC
func (ipcServer *IPCServer) PublishBlockchain(r *http.Request, args *PublishBlockchainArgs, reply *PublishBlockchainReply) error {
ipcServer.log.Info("IPCs: PublishBlockchain called with BlockchainID: %s", args.BlockchainID)
chainID, err := ipcServer.chainManager.Lookup(args.BlockchainID)
func (ipc *IPCServer) PublishBlockchain(r *http.Request, args *PublishBlockchainArgs, reply *PublishBlockchainReply) error {
ipc.log.Info("IPCs: PublishBlockchain called with BlockchainID: %s", args.BlockchainID)
chainID, err := ipc.chainManager.Lookup(args.BlockchainID)
if err != nil {
ipcServer.log.Error("unknown blockchainID: %s", err)
ipc.log.Error("unknown blockchainID: %s", err)
return err
}

ipcs, err := ipcServer.ipcs.Publish(chainID)
ipcs, err := ipc.ipcs.Publish(chainID)
if err != nil {
ipcServer.log.Error("couldn't publish blockchainID: %s", err)
ipc.log.Error("couldn't publish blockchainID: %s", err)
return err
}

Expand Down
2 changes: 1 addition & 1 deletion go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -44,10 +44,10 @@ require (
github.com/syndtr/goleveldb v1.0.0
github.com/tyler-smith/go-bip39 v1.0.2 // indirect
github.com/wsddn/go-ecdh v0.0.0-20161211032359-48726bab9208 // indirect
go.nanomsg.org/mangos/v3 v3.0.1
golang.org/x/crypto v0.0.0-20200510223506-06a226fb4e37
golang.org/x/net v0.0.0-20200520182314-0ba52f642ac2
google.golang.org/grpc v1.29.1
gopkg.in/olebedev/go-duktape.v3 v3.0.0-20200316214253-d7b0ff38cac9 // indirect
gopkg.in/urfave/cli.v1 v1.20.0 // indirect
nanomsg.org/go/mangos/v2 v2.0.8
)
3 changes: 3 additions & 0 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -265,6 +265,9 @@ github.com/xdg/scram v0.0.0-20180814205039-7eeb5667e42c/go.mod h1:lB8K/P019DLNhe
github.com/xdg/stringprep v1.0.0/go.mod h1:Jhud4/sHMO4oL310DaZAKk9ZaJ08SJfe+sJh0HrGL1Y=
github.com/xtaci/kcp-go v5.4.20+incompatible/go.mod h1:bN6vIwHQbfHaHtFpEssmWsN45a+AZwO7eyRCmEIbtvE=
github.com/xtaci/lossyconn v0.0.0-20190602105132-8df528c0c9ae/go.mod h1:gXtu8J62kEgmN++bm9BVICuT/e8yiLI2KFobd/TRFsE=
go.nanomsg.org/mangos v2.0.0+incompatible h1:Ll6GIzeGGld6/bFrVgBB8CjwibhHXZtF5jon+GoH1bE=
go.nanomsg.org/mangos/v3 v3.0.1 h1:xR8nca0ZeAvwsoRWjeEHuR2/B0N+Po/ZJpGNCpDz6To=
go.nanomsg.org/mangos/v3 v3.0.1/go.mod h1:RxVwsn46YtfJ74mF8MeVo+MFjg545KCI50NuZrFXmzc=
go.opencensus.io v0.22.1 h1:8dP3SGL7MPB94crU3bEPplMPe83FI4EouesJUeFHv50=
go.opencensus.io v0.22.1/go.mod h1:Ap50jQcDJrx6rB6VgeeFPtuPIf3wMRvRfrfYDO6+BmA=
golang.org/x/crypto v0.0.0-20180904163835-0709b304e793/go.mod h1:6SG95UA2DQfeDnfUPMdvaQW0Q7yPrPDi9nlGo2tz2b4=
Expand Down
7 changes: 4 additions & 3 deletions ipcs/chainipc.go
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ import (
)

const (
// DefaultBaseURL can be used as a reasonable default value for the base URL
DefaultBaseURL = "/tmp"

ipcIdentifierPrefix = "ipc"
Expand All @@ -29,7 +30,7 @@ type context struct {
// ChainIPCs maintains IPCs for a set of chains
type ChainIPCs struct {
context
chains map[[32]byte]*eventSockets
chains map[[32]byte]*EventSockets
consensusEvents *triggers.EventDispatcher
decisionEvents *triggers.EventDispatcher
}
Expand All @@ -43,7 +44,7 @@ func NewChainIPCs(log logging.Logger, path string, networkID uint32, consensusEv
networkID: networkID,
path: path,
},
chains: make(map[[32]byte]*eventSockets),
chains: make(map[[32]byte]*EventSockets),
consensusEvents: consensusEvents,
decisionEvents: decisionEvents,
}
Expand All @@ -56,7 +57,7 @@ func NewChainIPCs(log logging.Logger, path string, networkID uint32, consensusEv
}

// Publish creates a set of eventSockets for the given chainID
func (cipcs *ChainIPCs) Publish(chainID ids.ID) (*eventSockets, error) {
func (cipcs *ChainIPCs) Publish(chainID ids.ID) (*EventSockets, error) {
chainIDKey := chainID.Key()

if es, ok := cipcs.chains[chainIDKey]; ok {
Expand Down
21 changes: 11 additions & 10 deletions ipcs/eventsocket.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,9 @@
package ipcs

import (
"nanomsg.org/go/mangos/v2"
"nanomsg.org/go/mangos/v2/protocol/pub"
"go.nanomsg.org/mangos/v3/protocol/pub"

mangos "go.nanomsg.org/mangos/v3"

"github.com/ava-labs/gecko/ids"
"github.com/ava-labs/gecko/snow/triggers"
Expand All @@ -19,14 +20,14 @@ type chainEventDipatcher struct {
events *triggers.EventDispatcher
}

// eventSockets is a set of named eventSockets
type eventSockets struct {
// EventSockets is a set of named eventSockets
type EventSockets struct {
consensusSocket *eventSocket
decisionsSocket *eventSocket
}

// newEventSockets creates a *ChainIPCs with both consensus and decisions IPCs
func newEventSockets(ctx context, chainID ids.ID, consensusEvents *triggers.EventDispatcher, decisionEvents *triggers.EventDispatcher) (*eventSockets, error) {
func newEventSockets(ctx context, chainID ids.ID, consensusEvents *triggers.EventDispatcher, decisionEvents *triggers.EventDispatcher) (*EventSockets, error) {
consensusIPC, err := newEventIPCSocket(ctx, chainID, ipcConsensusIdentifier, consensusEvents)
if err != nil {
return nil, err
Expand All @@ -37,14 +38,14 @@ func newEventSockets(ctx context, chainID ids.ID, consensusEvents *triggers.Even
return nil, err
}

return &eventSockets{
return &EventSockets{
consensusSocket: consensusIPC,
decisionsSocket: decisionsIPC,
}, nil
}

// Accept delivers a message to the underlying eventSockets
func (ipcs *eventSockets) Accept(chainID, containerID ids.ID, container []byte) error {
func (ipcs *EventSockets) Accept(chainID, containerID ids.ID, container []byte) error {
if ipcs.consensusSocket != nil {
if err := ipcs.consensusSocket.Accept(chainID, containerID, container); err != nil {
return err
Expand All @@ -61,7 +62,7 @@ func (ipcs *eventSockets) Accept(chainID, containerID ids.ID, container []byte)
}

// stop closes the underlying eventSockets
func (ipcs *eventSockets) stop() error {
func (ipcs *EventSockets) stop() error {
errs := wrappers.Errs{}

if ipcs.consensusSocket != nil {
Expand All @@ -76,12 +77,12 @@ func (ipcs *eventSockets) stop() error {
}

// ConsensusURL returns the URL of socket receiving consensus events
func (ipcs *eventSockets) ConsensusURL() string {
func (ipcs *EventSockets) ConsensusURL() string {
return ipcs.consensusSocket.URL()
}

// DecisionsURL returns the URL of socket receiving decisions events
func (ipcs *eventSockets) DecisionsURL() string {
func (ipcs *EventSockets) DecisionsURL() string {
return ipcs.decisionsSocket.URL()
}

Expand Down
12 changes: 11 additions & 1 deletion scripts/ansible/ansible.cfg
Original file line number Diff line number Diff line change
@@ -1,6 +1,16 @@
[defaults]
any_errors_fatal = true
transport = ssh
deprecation_warnings = false
host_key_checking = false

[ssh_connection]
ssh_args = -o ForwardAgent=yes -o StrictHostKeyChecking=no -o UserKnownHostsFile=/dev/null
# Optimisation, speeds up playbook execution by reducing network round trips.
# However, remote systems must not have requiretty set in /etc/sudoers.
pipelining = true
ssh_args =
-C
-o ControlMaster=auto
-o ControlPersist=60s
-o ForwardAgent=yes
-o UserKnownHostsFile=/dev/null
3 changes: 3 additions & 0 deletions scripts/ansible/inventory.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
ava_nodes:
hosts:
localhost:
2 changes: 1 addition & 1 deletion scripts/ansible/kill_playbook.yml
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@

#!/usr/bin/env ansible-playbook
---
- name: Update the network
connection: ssh
Expand Down
2 changes: 1 addition & 1 deletion scripts/ansible/ping_playbook.yml
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@

#!/usr/bin/env ansible-playbook
---
- name: Update the network
connection: ssh
Expand Down
7 changes: 1 addition & 6 deletions scripts/ansible/restart_playbook.yml
Original file line number Diff line number Diff line change
@@ -1,14 +1,9 @@

#!/usr/bin/env ansible-playbook
---
- name: Update the network
connection: ssh
gather_facts: false
hosts: all
vars:
ava_binary: ~/go/src/github.com/ava-labs/gecko/build/ava
repo_folder: ~/go/src/github.com/ava-labs/gecko
repo_name: ava-labs/gecko
repo_branch: master
roles:
- name: ava-stop
- name: ava-build
Expand Down
15 changes: 15 additions & 0 deletions scripts/ansible/roles/ava-base/tasks/main.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
- name: Install AVA dependencies
become: true
apt:
name:
# Build
- cmake
- curl
- g++
- libssl-dev
- libuv1-dev
- make
# Staking key management
- openssl
- python3-cryptography
state: present
5 changes: 5 additions & 0 deletions scripts/ansible/roles/ava-build/defaults/main.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
ava_binary: ~/go/src/github.com/ava-labs/gecko/build/ava
repo_folder: ~/go/src/github.com/ava-labs/gecko
repo_name: ava-labs/gecko
repo_url: https://github.com/{{ repo_name }}
repo_branch: master
2 changes: 1 addition & 1 deletion scripts/ansible/roles/ava-build/tasks/main.yml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
- name: Update git clone
git:
repo: ssh://[email protected]/{{ repo_name }}.git
repo: "{{ repo_url }}"
dest: "{{ repo_folder }}"
version: "{{ repo_branch }}"
update: yes
Expand Down
22 changes: 22 additions & 0 deletions scripts/ansible/roles/ava-install/defaults/main.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
# These names, & default values are based on Meson build builtin options;
# which in turn follow established *nix conventions.
# See
# https://mesonbuild.com/Builtin-options.html
# https://www.gnu.org/prep/standards/html_node/Directory-Variables.html
prefix: "/usr/local"
bindir: "{{ prefix }}/bin"
libdir: "{{ prefix }}/lib"
localstatedir: "{{ prefix | replace('/usr', '/var') }}"
sharedstatedir: "{{ localstatedir }}/lib"
# Has no Meson builtin equivalent
logdir: "{{ localstatedir }}/log"

# These names are specific to AVA. Default values are based loosely on *nix
# conventions.
ava_daemon_home_dir: "{{ sharedstatedir }}/ava"
ava_daemon_db_dir: "{{ ava_daemon_home_dir }}/db"
ava_daemon_log_dir: "{{ logdir }}/ava"
ava_daemon_plugin_dir: "{{ libdir }}/ava/plugins"
ava_daemon_staking_dir: "{{ ava_daemon_home_dir }}/staking"
ava_daemon_staking_tls_cert: "{{ ava_daemon_staking_dir }}/staker.crt"
ava_daemon_staking_tls_key: "{{ ava_daemon_staking_dir }}/staker.key"
64 changes: 64 additions & 0 deletions scripts/ansible/roles/ava-install/tasks/main.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,64 @@
- name: Create shared directories
become: true
file:
# Don't specify owner, mode etc for directories not specific to AVA.
# OS defaults, or local defaults are better than any guess we could make.
path: "{{ item.path }}"
state: directory
loop:
- path: "{{ sharedstatedir }}"
- path: "{{ logdir }}"

- name: Create AVA directories
become: true
file:
path: "{{ item.path }}"
owner: "{{ item.owner | default(ava_daemon_user) }}"
group: "{{ item.group | default(ava_daemon_group) }}"
mode: "{{ item.mode }}"
recurse: "{{ item.recurse | default(omit) }}"
state: directory
loop:
- path: "{{ ava_daemon_home_dir }}"
mode: u=rwX,go=rX
- path: "{{ ava_daemon_db_dir }}"
mode: u=rwX,go=rX
- path: "{{ ava_daemon_staking_dir }}"
mode: u=rX,go=
- path: "{{ ava_daemon_log_dir }}"
mode: u=rwX,go=rX
- path: "{{ ava_daemon_plugin_dir }}"
owner: root
group: root
mode: u=rwX,go=rX
recurse: true
loop_control:
label: "{{ item.path }}"
notify:
- Restart AVA service

- name: Install AVA binary
become: true
copy:
src: "{{ ava_binary }}"
dest: "{{ bindir }}/ava"
remote_src: true
owner: root
group: root
mode: u=rwx,go=rx
notify:
- Restart AVA service

- name: Install AVA plugins
become: true
copy:
src: "{{ item.path }}"
dest: "{{ ava_daemon_plugin_dir }}"
owner: root
group: root
mode: u=rwx,go=rx
remote_src: true
loop:
- path: "{{ repo_folder }}/build/plugins/evm"
notify:
- Restart AVA service
2 changes: 2 additions & 0 deletions scripts/ansible/roles/ava-service/defaults/main.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
ava_daemon_http_host: localhost
log_level: info
10 changes: 10 additions & 0 deletions scripts/ansible/roles/ava-service/handlers/main.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
- name: Reload systemd
become: true
systemd:
daemon_reload: true

- name: Restart AVA service
become: true
service:
name: ava
state: restarted
Loading

0 comments on commit c6ce11d

Please sign in to comment.