Skip to content

Commit

Permalink
Merge pull request #1312 from CortexFoundation/wormhole
Browse files Browse the repository at this point in the history
Wormhole
  • Loading branch information
ucwong authored Sep 21, 2022
2 parents 69bfe23 + 40f957e commit 06e838c
Show file tree
Hide file tree
Showing 72 changed files with 941 additions and 594 deletions.
1 change: 1 addition & 0 deletions cmd/cortex/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -161,6 +161,7 @@ var (
utils.StorageDisableDHTFlag,
utils.StorageDisableTCPFlag,
utils.StorageEnableUTPFlag,
utils.StorageEnableWormholeFlag,
utils.StorageFullFlag,
utils.StorageModeFlag,
utils.StorageBoostFlag,
Expand Down
1 change: 1 addition & 0 deletions cmd/cortex/usage.go
Original file line number Diff line number Diff line change
Expand Up @@ -226,6 +226,7 @@ var AppHelpFlagGroups = []flagGroup{
utils.StorageDisableDHTFlag,
utils.StorageDisableTCPFlag,
utils.StorageEnableUTPFlag,
utils.StorageEnableWormholeFlag,
utils.StorageFullFlag,
utils.StorageModeFlag,
utils.StorageBoostFlag,
Expand Down
5 changes: 5 additions & 0 deletions cmd/utils/flags.go
Original file line number Diff line number Diff line change
Expand Up @@ -270,6 +270,10 @@ var (
Name: "storage.utp",
Usage: "enable UTP network in FS (EXPERIMENTAL)",
}
StorageEnableWormholeFlag = cli.BoolFlag{
Name: "storage.wormhole",
Usage: "enable wormhole network in FS (EXPERIMENTAL)",
}
StorageFullFlag = cli.BoolFlag{
Name: "storage.full",
Usage: "download full file",
Expand Down Expand Up @@ -1689,6 +1693,7 @@ func SetTorrentFsConfig(ctx *cli.Context, cfg *torrentfs.Config) {
cfg.DisableDHT = ctx.GlobalBool(StorageDisableDHTFlag.Name)
cfg.DisableTCP = ctx.GlobalBool(StorageDisableTCPFlag.Name)
cfg.DisableUTP = !ctx.GlobalBool(StorageEnableUTPFlag.Name)
cfg.Wormhole = ctx.GlobalBool(StorageEnableWormholeFlag.Name)
//cfg.FullSeed = ctx.GlobalBool(StorageFullFlag.Name)
//if cfg.Mode == "full" {
// cfg.FullSeed = true
Expand Down
6 changes: 5 additions & 1 deletion core/rawdb/chain_freezer.go
Original file line number Diff line number Diff line change
Expand Up @@ -92,6 +92,9 @@ func (f *chainFreezer) freeze(db ctxcdb.KeyValueStore) {
backoff bool
triggered chan struct{} // Used in tests
)

timer := time.NewTimer(freezerRecheckInterval)
defer timer.Stop()
for {
select {
case <-f.quit:
Expand All @@ -106,8 +109,9 @@ func (f *chainFreezer) freeze(db ctxcdb.KeyValueStore) {
triggered = nil
}
select {
case <-time.NewTimer(freezerRecheckInterval).C:
case <-timer.C:
backoff = false
timer.Reset(freezerRecheckInterval)
case triggered = <-f.trigger:
backoff = false
case <-f.quit:
Expand Down
8 changes: 6 additions & 2 deletions core/tx_noncer.go
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,9 @@ func (txn *txNoncer) get(addr common.Address) uint64 {
defer txn.lock.Unlock()

if _, ok := txn.nonces[addr]; !ok {
txn.nonces[addr] = txn.fallback.GetNonce(addr)
if nonce := txn.fallback.GetNonce(addr); nonce != 0 {
txn.nonces[addr] = nonce
}
}
return txn.nonces[addr]
}
Expand All @@ -70,7 +72,9 @@ func (txn *txNoncer) setIfLower(addr common.Address, nonce uint64) {
defer txn.lock.Unlock()

if _, ok := txn.nonces[addr]; !ok {
txn.nonces[addr] = txn.fallback.GetNonce(addr)
if nonce := txn.fallback.GetNonce(addr); nonce != 0 {
txn.nonces[addr] = nonce
}
}
if txn.nonces[addr] <= nonce {
return
Expand Down
3 changes: 0 additions & 3 deletions core/tx_pool.go
Original file line number Diff line number Diff line change
Expand Up @@ -465,9 +465,6 @@ func (pool *TxPool) SetGasPrice(price *big.Int) {
// Nonce returns the next nonce of an account, with all transactions executable
// by the pool already applied on top.
func (pool *TxPool) Nonce(addr common.Address) uint64 {
pool.mu.RLock()
defer pool.mu.RUnlock()

return pool.pendingNonces.get(addr)
}

Expand Down
2 changes: 1 addition & 1 deletion ctxc/fetcher/tx_fetcher.go
Original file line number Diff line number Diff line change
Expand Up @@ -326,7 +326,7 @@ func (f *TxFetcher) Enqueue(peer string, txs []*types.Transaction, direct bool)
// If 'other reject' is >25% of the deliveries in any batch, sleep a bit.
if otherreject > 128/4 {
time.Sleep(200 * time.Millisecond)
log.Warn("Peer delivering stale transactions", "peer", peer, "rejected", otherreject)
log.Trace("Peer delivering stale transactions", "peer", peer, "rejected", otherreject)
}
}
select {
Expand Down
44 changes: 22 additions & 22 deletions go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -6,21 +6,21 @@ require (
github.com/Azure/azure-sdk-for-go/sdk/storage/azblob v0.4.1
github.com/CortexFoundation/inference v1.0.2-0.20220421072809-9c87efb8a557
github.com/CortexFoundation/statik v0.0.0-20210315012922-8bb8a7b5dc66
github.com/CortexFoundation/torrentfs v1.0.25-0.20220911183628-8dda6c268af6
github.com/CortexFoundation/torrentfs v1.0.25-0.20220921211320-7179a2e15e3f
github.com/VictoriaMetrics/fastcache v1.10.0
github.com/arsham/figurine v1.2.0
github.com/aws/aws-sdk-go-v2 v1.16.14
github.com/aws/aws-sdk-go-v2/config v1.17.5
github.com/aws/aws-sdk-go-v2/credentials v1.12.18
github.com/aws/aws-sdk-go-v2/service/route53 v1.21.11
github.com/aws/aws-sdk-go-v2 v1.16.15
github.com/aws/aws-sdk-go-v2/config v1.17.6
github.com/aws/aws-sdk-go-v2/credentials v1.12.19
github.com/aws/aws-sdk-go-v2/service/route53 v1.22.0
github.com/btcsuite/btcd/btcec/v2 v2.2.1
github.com/cespare/cp v1.1.1
github.com/charmbracelet/bubbletea v0.22.1
github.com/cloudflare/cloudflare-go v0.49.0
github.com/cloudflare/cloudflare-go v0.50.0
github.com/davecgh/go-spew v1.1.2-0.20180830191138-d8f796af33cc
github.com/deckarep/golang-set v1.8.0
github.com/docker/docker v20.10.18+incompatible
github.com/dop251/goja v0.0.0-20220906144433-c4d370b87b45
github.com/dop251/goja v0.0.0-20220915101355-d79e1b125a30
github.com/fjl/gencodec v0.0.0-20220412091415-8bb9e558978c
github.com/fjl/memsize v0.0.1
github.com/fogleman/ease v0.0.0-20170301025033-8da417bf1776
Expand Down Expand Up @@ -60,7 +60,7 @@ require (
golang.org/x/crypto v0.0.0-20220829220503-c86fa9a7ed90
golang.org/x/mobile v0.0.0-20201217150744-e6ae53a27f4f
golang.org/x/sync v0.0.0-20220907140024-f12130a52804
golang.org/x/sys v0.0.0-20220913153101-76c7481b5158
golang.org/x/sys v0.0.0-20220915200043-7b5979e65e41
golang.org/x/text v0.3.7
golang.org/x/time v0.0.0-20220722155302-e5dcc9cfc0b9
golang.org/x/tools v0.1.13-0.20220812184215-3f9b119300de
Expand All @@ -83,7 +83,7 @@ require (
github.com/alecthomas/atomic v0.1.0-alpha2 // indirect
github.com/allegro/bigcache/v3 v3.0.3-0.20220614095342-7c2932edbec2 // indirect
github.com/anacrolix/chansync v0.3.0 // indirect
github.com/anacrolix/dht/v2 v2.18.1 // indirect
github.com/anacrolix/dht/v2 v2.19.0 // indirect
github.com/anacrolix/envpprof v1.2.1 // indirect
github.com/anacrolix/generics v0.0.0-20220618083756-f99e35403a60 // indirect
github.com/anacrolix/go-libutp v1.2.0 // indirect
Expand All @@ -95,26 +95,26 @@ require (
github.com/anacrolix/multiless v0.3.0 // indirect
github.com/anacrolix/stm v0.4.0 // indirect
github.com/anacrolix/sync v0.4.0 // indirect
github.com/anacrolix/torrent v1.46.1-0.20220831010947-648acc0120a4 // indirect
github.com/anacrolix/torrent v1.47.0 // indirect
github.com/anacrolix/upnp v0.1.3-0.20220123035249-922794e51c96 // indirect
github.com/anacrolix/utp v0.1.0 // indirect
github.com/andreyvit/diff v0.0.0-20170406064948-c7f18ee00883 // indirect
github.com/apache/arrow/go/v7 v7.0.1 // indirect
github.com/arsham/rainbow v1.2.1 // indirect
github.com/aws/aws-sdk-go v1.37.0 // indirect
github.com/aws/aws-sdk-go-v2/feature/ec2/imds v1.12.15 // indirect
github.com/aws/aws-sdk-go-v2/internal/configsources v1.1.21 // indirect
github.com/aws/aws-sdk-go-v2/internal/endpoints/v2 v2.4.15 // indirect
github.com/aws/aws-sdk-go-v2/internal/ini v1.3.22 // indirect
github.com/aws/aws-sdk-go-v2/service/internal/presigned-url v1.9.15 // indirect
github.com/aws/aws-sdk-go-v2/service/sso v1.11.21 // indirect
github.com/aws/aws-sdk-go-v2/service/ssooidc v1.13.3 // indirect
github.com/aws/aws-sdk-go-v2/service/sts v1.16.17 // indirect
github.com/aws/smithy-go v1.13.2 // indirect
github.com/aws/aws-sdk-go-v2/feature/ec2/imds v1.12.16 // indirect
github.com/aws/aws-sdk-go-v2/internal/configsources v1.1.22 // indirect
github.com/aws/aws-sdk-go-v2/internal/endpoints/v2 v2.4.16 // indirect
github.com/aws/aws-sdk-go-v2/internal/ini v1.3.23 // indirect
github.com/aws/aws-sdk-go-v2/service/internal/presigned-url v1.9.16 // indirect
github.com/aws/aws-sdk-go-v2/service/sso v1.11.22 // indirect
github.com/aws/aws-sdk-go-v2/service/ssooidc v1.13.4 // indirect
github.com/aws/aws-sdk-go-v2/service/sts v1.16.18 // indirect
github.com/aws/smithy-go v1.13.3 // indirect
github.com/bahlo/generic-list-go v0.2.0 // indirect
github.com/benbjohnson/immutable v0.3.0 // indirect
github.com/beorn7/perks v1.0.1 // indirect
github.com/bits-and-blooms/bitset v1.3.2 // indirect
github.com/bits-and-blooms/bitset v1.3.3 // indirect
github.com/bradfitz/iter v0.0.0-20191230175014-e8f45d346db8 // indirect
github.com/btcsuite/btcd/chaincfg/chainhash v1.0.2-0.20220413172512-bf64c8bdbbbf // indirect
github.com/cespare/xxhash v1.1.0 // indirect
Expand Down Expand Up @@ -174,7 +174,7 @@ require (
github.com/pion/transport v0.13.1 // indirect
github.com/pion/turn/v2 v2.0.8 // indirect
github.com/pion/udp v0.1.1 // indirect
github.com/pion/webrtc/v3 v3.1.43 // indirect
github.com/pion/webrtc/v3 v3.1.44 // indirect
github.com/pkg/errors v0.9.1 // indirect
github.com/pmezard/go-difflib v1.0.0 // indirect
github.com/prometheus/client_golang v1.13.0 // indirect
Expand All @@ -201,7 +201,7 @@ require (
go.uber.org/atomic v1.10.0 // indirect
go.uber.org/multierr v1.8.0 // indirect
go.uber.org/zap v1.23.0 // indirect
golang.org/x/exp v0.0.0-20220909182711-5c715a9e8561 // indirect
golang.org/x/exp v0.0.0-20220916125017-b168a2c6b86b // indirect
golang.org/x/mod v0.6.0-dev.0.20220419223038-86c51ed26bb4 // indirect
golang.org/x/net v0.0.0-20220909164309-bea034e7d591 // indirect
golang.org/x/oauth2 v0.0.0-20220822191816-0ebed06d0094 // indirect
Expand Down
Loading

0 comments on commit 06e838c

Please sign in to comment.