Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Refactor Obscuroscan to Tenscan #1716

Merged
merged 19 commits into from
Dec 27, 2023
Merged
Show file tree
Hide file tree
Changes from 4 commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .dockerignore
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ go/enclave/main/main
tools/walletextension/main/main
tools/walletextension/main/wallet_extension
tools/networkmanager/main/main
tools/obscuroscan/main/main
tools/tenscan/main/main
**/node_modules/
**/dist
.git
Expand Down
3 changes: 2 additions & 1 deletion .github/workflows/build-pr.yml
Original file line number Diff line number Diff line change
Expand Up @@ -42,8 +42,9 @@ jobs:
integration/.build/wallet_extension/wal-ext-*.txt
integration/.build/eth2/*
integration/.build/faucet/*
integration/.build/obscuroscan/*
integration/.build/tenscan/*
integration/.build/tengateway/*
integration/.build/contractdeployer/*
retention-days: 1


85 changes: 0 additions & 85 deletions .github/workflows/manual-deploy-obscuro-scan-2.yml

This file was deleted.

Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
# Deploys Tenscan on Azure for Testnet
# Builds the Tenscan image, pushes the image to dockerhub and starts the Tenscan on Azure

name: "[M] Deploy Tenscan 3 Testnet"
name: "[M] Deploy Tenscan Testnet"
run-name: "[M] Deploy Tenscan Testnet ( ${{ github.event.inputs.testnet_type }} )"
on:
workflow_dispatch:
Expand Down Expand Up @@ -46,21 +46,21 @@ jobs:

- name: Build and Push Docker FE Image
run: |
DOCKER_BUILDKIT=1 docker build -t ${{ vars.DOCKER_BUILD_TAG_SCAN_FE }} -f ./tools/obscuroscan_v3/frontend/Dockerfile .
DOCKER_BUILDKIT=1 docker build -t ${{ vars.DOCKER_BUILD_TAG_SCAN_FE }} -f ./tools/tenscan/frontend/Dockerfile .
docker push ${{ vars.DOCKER_BUILD_TAG_SCAN_FE }}

- name: Build and Push Docker API Image
run: |
DOCKER_BUILDKIT=1 docker build -t ${{ vars.DOCKER_BUILD_TAG_SCAN_API }} -f ./tools/obscuroscan_v2/backend/Dockerfile .
DOCKER_BUILDKIT=1 docker build -t ${{ vars.DOCKER_BUILD_TAG_SCAN_API }} -f ./tools/tenscan/backend/Dockerfile .
docker push ${{ vars.DOCKER_BUILD_TAG_SCAN_API }}

- name: "Deploy FE to Azure Container Instances"
uses: "azure/aci-deploy@v1"
with:
resource-group: ${{ secrets.RESOURCE_GROUP }}
dns-name-label: ${{ github.event.inputs.testnet_type }}-obscuro-scan-v3
dns-name-label: ${{ github.event.inputs.testnet_type }}-ten-scan
image: ${{ vars.DOCKER_BUILD_TAG_SCAN_FE }}
name: ${{ github.event.inputs.testnet_type }}-fe-obscuro-scan-v3
name: ${{ github.event.inputs.testnet_type }}-fe-ten-scan
location: "uksouth"
restart-policy: "Never"
environment-variables: NEXT_PUBLIC_API_HOST=https://${{ github.event.inputs.testnet_type }}-api.obscuroscan.io NEXT_PUBLIC_FE_VERSION=${{ GITHUB.RUN_NUMBER }}-${{ GITHUB.SHA }}
Expand All @@ -73,9 +73,9 @@ jobs:
uses: "azure/aci-deploy@v1"
with:
resource-group: ${{ secrets.RESOURCE_GROUP }}
dns-name-label: ${{ github.event.inputs.testnet_type }}-api-obscuro-scan-v3
dns-name-label: ${{ github.event.inputs.testnet_type }}-api-ten-scan
image: ${{ vars.DOCKER_BUILD_TAG_SCAN_API }}
name: ${{ github.event.inputs.testnet_type }}-api-obscuro-scan-v3
name: ${{ github.event.inputs.testnet_type }}-api-ten-scan
location: "uksouth"
restart-policy: "Never"
command-line: ./cmd/backend --nodeHostAddress http://${{ vars.L2_RPC_URL_VALIDATOR }}:80 --serverAddress 0.0.0.0:80
Expand Down
4 changes: 2 additions & 2 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ tools/walletextension/main/main
tools/walletextension/bin/**
tools/walletextension/main/wallet_extension
tools/networkmanager/main/main
tools/obscuroscan/main/main
tools/tenscan/main/main
integration/eth2network/main/main


Expand All @@ -44,7 +44,7 @@ integration/eth2network/main/main
**/enclave_logs.txt
**/host_logs.txt
**/wallet_extension_logs.txt
**/obscuroscan_logs.txt
**/tenscan_logs.txt

# Temp env files
testnet/.env
Expand Down
4 changes: 2 additions & 2 deletions docs/_data/navigation.yml
Original file line number Diff line number Diff line change
Expand Up @@ -58,8 +58,8 @@ sidebar-list:

- title: Tools
children:
- title: ObscuroScan
url: testnet/obscuroscan
- title: Tenscan
url: testnet/tenscan
- title: Token Faucet
url: testnet/faucet

Expand Down
2 changes: 1 addition & 1 deletion docs/_docs/testnet/deploying-a-smart-contract.md
Original file line number Diff line number Diff line change
Expand Up @@ -48,4 +48,4 @@ Congratulations, your smart contract is now deployed to Ten Testnet!

Because Ten provides full privacy, the details of your transaction are encrypted and only visible to you, as the holder of your wallet's private key.

Now head over to the [TenScan page](https://docs.obscu.ro/testnet/obscuroscan/) to see how you can view the transaction details.
Now head over to the [TenScan page](https://docs.obscu.ro/testnet/tenscan/) to see how you can view the transaction details.
2 changes: 1 addition & 1 deletion go/common/httputil/httputil.go
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@ func ExecuteHTTPReq(client *http.Client, req *http.Request) ([]byte, error) {
return body, nil
}

// EnableCORS Allows Obscuroscan and WalletExtension APIs to serve other web apps via CORS.
// EnableCORS Allows Tenscan and WalletExtension APIs to serve other web apps via CORS.
func EnableCORS(resp http.ResponseWriter, req *http.Request) bool {
resp.Header().Set(CorsAllowOrigin, OriginAll)
if (*req).Method == ReqOptions {
Expand Down
2 changes: 1 addition & 1 deletion go/common/log/log.go
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ const (
WalletExtCmp = "wallet_extension"
TestGethNetwCmp = "test_geth_network"
EthereumL1Cmp = "l1_host"
ObscuroscanCmp = "obscuroscan"
TenscanCmp = "tenscan"
CrossChainCmp = "cross_chain"
)

Expand Down
20 changes: 10 additions & 10 deletions go/host/container/host_container.go
Original file line number Diff line number Diff line change
Expand Up @@ -26,14 +26,14 @@ import (
)

const (
APIVersion1 = "1.0"
APINamespaceObscuro = "obscuro"
APINamespaceEth = "eth"
APINamespaceObscuroScan = "obscuroscan"
APINamespaceScan = "scan"
APINamespaceNetwork = "net"
APINamespaceTest = "test"
APINamespaceDebug = "debug"
APIVersion1 = "1.0"
APINamespaceObscuro = "obscuro"
APINamespaceEth = "eth"
APINamespaceTenScan = "tenscan"
APINamespaceScan = "scan"
APINamespaceNetwork = "net"
APINamespaceTest = "test"
APINamespaceDebug = "debug"
)

type HostContainer struct {
Expand Down Expand Up @@ -173,9 +173,9 @@ func NewHostContainer(cfg *config.HostConfig, services *host.ServicesRegistry, p
Public: true,
},
{
Namespace: APINamespaceObscuroScan,
Namespace: APINamespaceTenScan,
Version: APIVersion1,
Service: clientapi.NewObscuroScanAPI(h),
Service: clientapi.NewTenScanAPI(h),
Public: true,
},
{
Expand Down
20 changes: 10 additions & 10 deletions go/host/rpc/clientapi/client_api_obscuroscan.go
Original file line number Diff line number Diff line change
Expand Up @@ -16,19 +16,19 @@ import (

const txLimit = 100

// ObscuroScanAPI implements ObscuroScan-specific JSON RPC operations.
type ObscuroScanAPI struct {
// TenScanAPI implements TenScan-specific JSON RPC operations.
type TenScanAPI struct {
host host.Host
}

func NewObscuroScanAPI(host host.Host) *ObscuroScanAPI {
return &ObscuroScanAPI{
func NewTenScanAPI(host host.Host) *TenScanAPI {
return &TenScanAPI{
host: host,
}
}

// GetBlockHeaderByHash returns the header for the block with the given hash.
func (api *ObscuroScanAPI) GetBlockHeaderByHash(blockHash gethcommon.Hash) (*types.Header, error) {
func (api *TenScanAPI) GetBlockHeaderByHash(blockHash gethcommon.Hash) (*types.Header, error) {
blockHeader, err := api.host.DB().GetBlockByHash(blockHash)
if err != nil {
if errors.Is(err, errutil.ErrNotFound) {
Expand All @@ -41,12 +41,12 @@ func (api *ObscuroScanAPI) GetBlockHeaderByHash(blockHash gethcommon.Hash) (*typ

// GetBatch returns the batch with the given hash. Unlike `EthereumAPI.GetBlockByHash()`, returns the full
// `ExtBatch`, and not just the header.
func (api *ObscuroScanAPI) GetBatch(batchHash gethcommon.Hash) (*common.ExtBatch, error) {
func (api *TenScanAPI) GetBatch(batchHash gethcommon.Hash) (*common.ExtBatch, error) {
return api.host.DB().GetBatch(batchHash)
}

// GetBatchForTx returns the batch containing a given transaction hash.
func (api *ObscuroScanAPI) GetBatchForTx(txHash gethcommon.Hash) (*common.ExtBatch, error) {
func (api *TenScanAPI) GetBatchForTx(txHash gethcommon.Hash) (*common.ExtBatch, error) {
batchNumber, err := api.host.DB().GetBatchNumber(txHash)
if err != nil {
return nil, fmt.Errorf("could not retrieve batch containing a transaction with hash %s. Cause: %w", txHash, err)
Expand All @@ -62,7 +62,7 @@ func (api *ObscuroScanAPI) GetBatchForTx(txHash gethcommon.Hash) (*common.ExtBat

// GetLatestTransactions returns the hashes of the latest `num` transactions confirmed in batches (or all the
// transactions if there are less than `num` total transactions).
func (api *ObscuroScanAPI) GetLatestTransactions(num int) ([]gethcommon.Hash, error) {
func (api *TenScanAPI) GetLatestTransactions(num int) ([]gethcommon.Hash, error) {
// We prevent someone from requesting an excessive amount of transactions.
if num > txLimit {
return nil, fmt.Errorf("cannot request more than 100 latest transactions")
Expand Down Expand Up @@ -105,11 +105,11 @@ func (api *ObscuroScanAPI) GetLatestTransactions(num int) ([]gethcommon.Hash, er
}

// GetTotalTransactions returns the number of recorded transactions on the network.
func (api *ObscuroScanAPI) GetTotalTransactions() (*big.Int, error) {
func (api *TenScanAPI) GetTotalTransactions() (*big.Int, error) {
return api.host.DB().GetTotalTransactions()
}

// Attestation returns the node's attestation details.
func (api *ObscuroScanAPI) Attestation() (*common.AttestationReport, error) {
func (api *TenScanAPI) Attestation() (*common.AttestationReport, error) {
return api.host.EnclaveClient().Attestation()
}
12 changes: 6 additions & 6 deletions go/rpc/client.go
Original file line number Diff line number Diff line change
Expand Up @@ -26,12 +26,12 @@ const (
Health = "obscuro_health"
Config = "obscuro_config"

GetBlockHeaderByHash = "obscuroscan_getBlockHeaderByHash"
GetBatch = "obscuroscan_getBatch"
GetBatchForTx = "obscuroscan_getBatchForTx"
GetLatestTxs = "obscuroscan_getLatestTransactions"
GetTotalTxs = "obscuroscan_getTotalTransactions"
Attestation = "obscuroscan_attestation"
GetBlockHeaderByHash = "tenscan_getBlockHeaderByHash"
GetBatch = "tenscan_getBatch"
GetBatchForTx = "tenscan_getBatchForTx"
GetLatestTxs = "tenscan_getLatestTransactions"
GetTotalTxs = "tenscan_getTotalTransactions"
Attestation = "tenscan_attestation"
StopHost = "test_stopHost"
Subscribe = "eth_subscribe"
Unsubscribe = "eth_unsubscribe"
Expand Down
2 changes: 1 addition & 1 deletion integration/contractdeployer/contract_deployer_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ const (
func init() { //nolint:gochecknoinits
testlog.Setup(&testlog.Cfg{
LogDir: testLogs,
TestType: "noderunner",
TestType: "contractdeployer",
TestSubtype: "test",
LogLevel: log.LvlInfo,
})
Expand Down
2 changes: 2 additions & 0 deletions integration/obscurogateway/tengateway_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -103,6 +103,8 @@ func TestTenGateway(t *testing.T) {
}

// Gracefully shutdown
// todo remove this sleep when tests stabilize
time.Sleep(10 * time.Second)
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The introduction of a time.Sleep call in tests is generally a sign of potential flakiness or synchronization issues. It's better to use a more deterministic synchronization mechanism, such as waiting for a specific condition or event.

- // todo remove this sleep when tests stabilize
- time.Sleep(10 * time.Second)
+ // TODO: Implement a more robust synchronization mechanism

Committable suggestion

IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation.

Suggested change
// todo remove this sleep when tests stabilize
time.Sleep(10 * time.Second)
// TODO: Implement a more robust synchronization mechanism

err = tenGwContainer.Stop()
assert.NoError(t, err)
}
Expand Down
Loading
Loading