Skip to content

Commit

Permalink
Fix gateway logging and remove Datadog agents from gateway (#2038)
Browse files Browse the repository at this point in the history
  • Loading branch information
zkokelj authored Aug 29, 2024
1 parent aaa489f commit 8964784
Show file tree
Hide file tree
Showing 5 changed files with 14 additions and 33 deletions.
14 changes: 0 additions & 14 deletions .github/workflows/manual-deploy-obscuro-gateway-database.yml
Original file line number Diff line number Diff line change
Expand Up @@ -90,20 +90,6 @@ jobs:
&& curl -fsSL https://get.docker.com -o get-docker.sh && sh ./get-docker.sh \
&& git clone --depth 1 -b ${{ env.BRANCH_NAME }} https://github.com/ten-protocol/go-ten.git /home/obscuro/go-obscuro \
&& docker network create --driver bridge node_network || true \
&& docker run -d --name datadog-agent \
--network node_network \
-e DD_API_KEY=${{ secrets.DD_API_KEY }} \
-e DD_LOGS_ENABLED=true \
-e DD_LOGS_CONFIG_CONTAINER_COLLECT_ALL=true \
-e DD_LOGS_CONFIG_AUTO_MULTI_LINE_DETECTION=true \
-e DD_CONTAINER_EXCLUDE_LOGS="name:datadog-agent" \
-e DD_SITE="datadoghq.eu" \
-v /var/run/docker.sock:/var/run/docker.sock:ro \
-v /proc/:/host/proc/:ro \
-v /opt/datadog-agent/run:/opt/datadog-agent/run:rw \
-v /sys/fs/cgroup/:/host/sys/fs/cgroup:ro \
--log-opt max-file=3 --log-opt max-size=10m \
datadog/agent:latest \
&& cd /home/obscuro/go-obscuro/ \
&& docker run -d --name ${{ github.event.inputs.testnet_type }}-OG-MariaDB-${{ GITHUB.RUN_NUMBER }} \
-p 3306:3306 \
Expand Down
14 changes: 0 additions & 14 deletions .github/workflows/manual-deploy-obscuro-gateway.yml
Original file line number Diff line number Diff line change
Expand Up @@ -205,20 +205,6 @@ jobs:
&& curl -fsSL https://get.docker.com -o get-docker.sh && sh ./get-docker.sh \
&& git clone --depth 1 -b ${{ env.BRANCH_NAME }} https://github.com/ten-protocol/go-ten.git /home/obscuro/go-obscuro \
&& docker network create --driver bridge node_network || true \
&& docker run -d --name datadog-agent \
--network node_network \
-e DD_API_KEY=${{ secrets.DD_API_KEY }} \
-e DD_LOGS_ENABLED=true \
-e DD_LOGS_CONFIG_CONTAINER_COLLECT_ALL=true \
-e DD_LOGS_CONFIG_AUTO_MULTI_LINE_DETECTION=true \
-e DD_CONTAINER_EXCLUDE_LOGS="name:datadog-agent" \
-e DD_SITE="datadoghq.eu" \
-v /var/run/docker.sock:/var/run/docker.sock:ro \
-v /proc/:/host/proc/:ro \
-v /opt/datadog-agent/run:/opt/datadog-agent/run:rw \
-v /sys/fs/cgroup/:/host/sys/fs/cgroup:ro \
--log-opt max-file=3 --log-opt max-size=10m \
datadog/agent:latest \
&& cd /home/obscuro/go-obscuro/ \
&& docker run -d -p 80:80 -p 81:81 --name "${{ env.VM_NAME }}" \
-e OBSCURO_GATEWAY_VERSION="${{ GITHUB.RUN_NUMBER }}-${{ GITHUB.SHA }}" \
Expand Down
1 change: 1 addition & 0 deletions go/common/log/log.go
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,7 @@ const (
)

// New - helper function used to create a top level logger for a component.
// Note: this expects legacy geth log levels, you will get unexpected behaviour if you use gethlog.<LEVEL> directly.
func New(component string, level int, out string, ctx ...interface{}) gethlog.Logger {
logFile := ""
if out != SysOut {
Expand Down
13 changes: 8 additions & 5 deletions tools/walletextension/main/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -11,12 +11,15 @@ import (

"github.com/ten-protocol/go-ten/go/common/log"
"github.com/ten-protocol/go-ten/tools/walletextension/common"

gethlog "github.com/ethereum/go-ethereum/log"
)

const (
tcp = "tcp"
// @fixme -
// this is a temporary fix as out forked version of log.go does not map with gethlog.Level<Level>
//and should be fixed as part of logging refactoring in the future
legacyLevelDebug = 4
legacyLevelError = 1
)

func main() {
Expand Down Expand Up @@ -53,11 +56,11 @@ func main() {
}
}

logLvl := gethlog.LevelError
logLvl := legacyLevelError
if config.VerboseFlag {
logLvl = gethlog.LevelDebug
logLvl = legacyLevelDebug
}
logger := log.New(log.WalletExtCmp, int(logLvl), config.LogPath)
logger := log.New(log.WalletExtCmp, logLvl, config.LogPath)

walletExtContainer := walletextension.NewContainerFromConfig(config, logger)

Expand Down
5 changes: 5 additions & 0 deletions tools/walletextension/rpcapi/wallet_extension.go
Original file line number Diff line number Diff line change
Expand Up @@ -166,6 +166,7 @@ func (w *Services) Logger() gethlog.Logger {

// GenerateAndStoreNewUser generates new key-pair and userID, stores it in the database and returns hex encoded userID and error
func (w *Services) GenerateAndStoreNewUser() ([]byte, error) {
audit(w, "Generating and storing new user")
requestStartTime := time.Now()
// generate new key-pair
viewingKeyPrivate, err := crypto.GenerateKey()
Expand All @@ -191,6 +192,7 @@ func (w *Services) GenerateAndStoreNewUser() ([]byte, error) {

// AddAddressToUser checks if a message is in correct format and if signature is valid. If all checks pass we save address and signature against userID
func (w *Services) AddAddressToUser(userID []byte, address string, signature []byte, signatureType viewingkey.SignatureType) error {
audit(w, "Adding address to user: %s, address: %s", hexutils.BytesToHex(userID), address)
requestStartTime := time.Now()
addressFromMessage := gethcommon.HexToAddress(address)
// check if a message was signed by the correct address and if the signature is valid
Expand Down Expand Up @@ -273,6 +275,7 @@ func (w *Services) Version() string {
}

func (w *Services) GetTenNodeHealthStatus() (bool, error) {
audit(w, "Getting Ten node health status")
res, err := withPlainRPCConnection[bool](context.Background(), w, func(client *gethrpc.Client) (*bool, error) {
res, err := obsclient.NewObsClient(client).Health()
return &res, err
Expand All @@ -281,6 +284,7 @@ func (w *Services) GetTenNodeHealthStatus() (bool, error) {
}

func (w *Services) GetTenNetworkConfig() (tencommon.TenNetworkInfo, error) {
audit(w, "Getting Ten network config")
res, err := withPlainRPCConnection[tencommon.TenNetworkInfo](context.Background(), w, func(client *gethrpc.Client) (*tencommon.TenNetworkInfo, error) {
res, err := obsclient.NewObsClient(client).GetConfig()
return res, err
Expand All @@ -289,6 +293,7 @@ func (w *Services) GetTenNetworkConfig() (tencommon.TenNetworkInfo, error) {
}

func (w *Services) GenerateUserMessageToSign(encryptionToken []byte, formatsSlice []string) (string, error) {
audit(w, "Generating user message to sign")
// Check if the formats are valid
for _, format := range formatsSlice {
if _, exists := viewingkey.SignatureTypeMap[format]; !exists {
Expand Down

0 comments on commit 8964784

Please sign in to comment.