Skip to content

Commit

Permalink
Refactor Obscuroscan to Tenscan (#1716)
Browse files Browse the repository at this point in the history
* Refactor Obscuroscan to Tenscan

* lint

* update folder names

* sleep on tests

* restart build

* update gas values

* updating gas prices

* expand ports

* bump gas

* bump gas

* add geth checks

* sleep between first batches

* nits

* .

* weird get tx count handling

* add logs around port reuse
  • Loading branch information
otherview authored Dec 27, 2023
1 parent 5cd64e8 commit 33d59d1
Show file tree
Hide file tree
Showing 242 changed files with 97 additions and 7,736 deletions.
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/*
integration/.build/smartcontracts/*
retention-days: 1

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

This file was deleted.

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(20 * time.Second)
err = tenGwContainer.Stop()
assert.NoError(t, err)
}
Expand Down
21 changes: 11 additions & 10 deletions integration/obscuroscan/obscuroscan_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,9 @@ import (
"testing"
"time"

"github.com/ten-protocol/go-ten/tools/tenscan/backend/config"
"github.com/ten-protocol/go-ten/tools/tenscan/backend/container"

gethcommon "github.com/ethereum/go-ethereum/common"
"github.com/ethereum/go-ethereum/core/types"
"github.com/stretchr/testify/require"
Expand All @@ -19,8 +22,6 @@ import (
"github.com/ten-protocol/go-ten/go/rpc"
"github.com/ten-protocol/go-ten/go/wallet"
"github.com/ten-protocol/go-ten/integration/datagenerator"
"github.com/ten-protocol/go-ten/tools/obscuroscan_v2/backend/config"
"github.com/ten-protocol/go-ten/tools/obscuroscan_v2/backend/container"
"github.com/valyala/fasthttp"

"github.com/ethereum/go-ethereum/log"
Expand All @@ -36,31 +37,31 @@ import (
func init() { //nolint:gochecknoinits
testlog.Setup(&testlog.Cfg{
LogDir: testLogs,
TestType: "obscuroscan",
TestType: "tenscan",
TestSubtype: "test",
LogLevel: log.LvlInfo,
})
}

const (
testLogs = "../.build/obscuroscan/"
testLogs = "../.build/tenscan/"
)

func TestObscuroscan(t *testing.T) {
func TestTenscan(t *testing.T) {
startPort := integration.StartPortTenscanUnitTest
createObscuroNetwork(t, startPort)

obsScanConfig := &config.Config{
tenScanConfig := &config.Config{
NodeHostAddress: fmt.Sprintf("http://127.0.0.1:%d", startPort+integration.DefaultHostRPCHTTPOffset),
ServerAddress: fmt.Sprintf("127.0.0.1:%d", startPort+integration.DefaultTenscanHTTPPortOffset),
LogPath: "sys_out",
}
serverAddress := fmt.Sprintf("http://%s", obsScanConfig.ServerAddress)
serverAddress := fmt.Sprintf("http://%s", tenScanConfig.ServerAddress)

obsScanContainer, err := container.NewObscuroScanContainer(obsScanConfig)
tenScanContainer, err := container.NewTenScanContainer(tenScanConfig)
require.NoError(t, err)

err = obsScanContainer.Start()
err = tenScanContainer.Start()
require.NoError(t, err)

// wait for the msg bus contract to be deployed
Expand Down Expand Up @@ -182,7 +183,7 @@ func TestObscuroscan(t *testing.T) {
assert.NotEqual(t, configFetchObj.Item.SequencerID, gethcommon.Address{})

// Gracefully shutdown
err = obsScanContainer.Stop()
err = tenScanContainer.Stop()
assert.NoError(t, err)
}

Expand Down
Loading

0 comments on commit 33d59d1

Please sign in to comment.