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

Releases/v2.0.0 #1249

Merged
merged 36 commits into from
Sep 30, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
36 commits
Select commit Hold shift + click to select a range
fcced07
feat: Github Migration (#1146)
yohanelly95 Oct 12, 2023
8f486d3
Update develop.yml (#1148)
SkandaBhat Oct 12, 2023
2ae4f4f
Update develop.yml (#1149)
SkandaBhat Oct 12, 2023
d7826c1
Update develop.yml
SkandaBhat Oct 12, 2023
952594e
Update develop.yml
SkandaBhat Oct 12, 2023
dbd5950
Update develop.yml
SkandaBhat Oct 12, 2023
6aef029
Fix go mod tidy
Oct 12, 2023
37e0b63
Replaced curve instance elliptic.P256() with crypto.S256() (#1150)
Yashk767 Oct 13, 2023
f1d7d35
fix: Update Dockerfile with version bumps (#1152)
yohanelly95 Oct 13, 2023
211182d
Feature/v1.1.0 (#1154)
SkandaBhat Oct 18, 2023
768f265
feat: Publish to Dockerhub on every merge to develop and release (#1…
yohanelly95 Oct 23, 2023
7dbcc88
Set version meta to empty string (#1159)
Yashk767 Oct 25, 2023
ab83868
Yash/raz 528 npm run build all fails with new update chainid script (…
Yashk767 Oct 26, 2023
917d46a
Merge branch 'main' into develop
Oct 26, 2023
aea43d5
fix: update branch pattern (#1162)
SkandaBhat Oct 26, 2023
0dc7960
fix: conversion of hex to decimal (#1167)
Yashk767 Nov 28, 2023
703aec5
fix: conversion of hex to decimal (#1167) (#1169)
Yashk767 Dec 11, 2023
3bf2914
feat: added support for job returning results in hex array (#1174)
Yashk767 Dec 20, 2023
d076432
refactor: used hash of url and body as a cache key (#1176)
Yashk767 Jan 5, 2024
2bab695
fix: conversion of hex to decimal (#1167) (#1169) (#1178)
Yashk767 Jan 15, 2024
d8a72ec
chore: merge releases/v1.1.0 into develop
Yashk767 Jan 15, 2024
0362b02
chore: merge releases/v1.1.0 into develop
Yashk767 Jan 16, 2024
8aac72a
release: v1.1.1-dev (#1190)
Yashk767 Feb 21, 2024
2fd96c8
fix: incorrect state error for shorter epoch length (#1192)
Yashk767 Mar 1, 2024
5ae7e15
revert: fetching jobs/collections from cache (#1198)
Yashk767 Mar 22, 2024
e210cf5
revert: median concurrency changes (#1213)
Yashk767 Jun 13, 2024
f619148
feat: added support for APIs responding in json array (#1216)
Yashk767 Jul 2, 2024
89d1552
chore: merge updates from main to develop branch
Yashk767 Aug 7, 2024
12d57a1
chore: merge v1.1.0-patch.1 release changes from main into develop
Yashk767 Aug 9, 2024
07cf9fe
chore: merge feature/v1.2.0 dev release to develop (#1224)
Yashk767 Aug 9, 2024
7f77a9f
refactor: requested changes in refactoring and default values for v1.…
Yashk767 Sep 3, 2024
2f574aa
chore: merge main to develop post v1.2.0 release
Yashk767 Sep 16, 2024
54371f1
chore: merge feature/v2.0.0 to develop (#1242)
Yashk767 Sep 16, 2024
a52c658
hotfix: updated retry parameters and default timeouts (#1246)
Yashk767 Sep 24, 2024
d9c8f51
hotfix: update epoch length to 7.5 minutes (#1247)
Yashk767 Sep 24, 2024
9949ef0
hotfix: updated mainnet addresses to 7.5 minute epoch contract addres…
Yashk767 Sep 26, 2024
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
8 changes: 4 additions & 4 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ jobs:
- name: Setup Node.js
uses: actions/setup-node@v3
with:
node-version: "18"
node-version: "20"
- name: Setup Go
uses: actions/setup-go@v2
with:
Expand Down Expand Up @@ -85,7 +85,7 @@ jobs:
- name: Setup Node.js
uses: actions/setup-node@v3
with:
node-version: "18"
node-version: "20"

- name: Setup Go
uses: actions/setup-go@v2
Expand Down Expand Up @@ -136,7 +136,7 @@ jobs:
- name: Setup Node.js
uses: actions/setup-node@v3
with:
node-version: "18"
node-version: "20"

- name: Setup Go
uses: actions/setup-go@v2
Expand Down Expand Up @@ -194,7 +194,7 @@ jobs:
- name: Setup Node.js
uses: actions/setup-node@v3
with:
node-version: "18"
node-version: "20"

- name: Download Artifacts AMD
uses: actions/download-artifact@v3
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/develop.yml
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ jobs:
- name: Setup Node.js
uses: actions/setup-node@v3
with:
node-version: "18"
node-version: "20"
- name: Setup Go
uses: actions/setup-go@v2
with:
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ jobs:
- name: Setup Node.js
uses: actions/setup-node@v3
with:
node-version: "18"
node-version: "20"
- name: Setup Go
uses: actions/setup-go@v2
with:
Expand Down
6 changes: 3 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ docker network create razor_network
2. Start razor-go container

```
docker run -d -it --entrypoint /bin/sh --network=razor_network --name razor-go -v "$(echo $HOME)"/.razor:/root/.razor razornetwork/razor-go:v1.0.0-mainnet
docker run -d -it --entrypoint /bin/sh --network=razor_network --name razor-go -v "$(echo $HOME)"/.razor:/root/.razor razornetwork/razor-go:v2.0.0
```

> **_NOTE:_** We leverage Docker bind-mounts to mount the .razor directory, ensuring a shared mount between the host and the container. The `.razor` directory holds keys to the addresses that we use in `razor-go`, along with logs and config. We do this to persist data in the host machine, otherwise you would lose your keys once you delete the container.
Expand Down Expand Up @@ -124,15 +124,15 @@ docker exec -it razor-go razor setConfig --provider <rpc_provider> --alternatePr
Example:

```
$ ./razor setConfig --provider https://mainnet.skalenodes.com/v1/turbulent-unique-scheat --alternateProvider https://ce2m-skale.chainode.tech:10200/ --gasmultiplier 1 --buffer 20 --wait 30 --gasprice 0 --logLevel debug --gasLimit 2 --rpcTimeout 10 --httpTimeout 10 --logFileMaxSize 200 --logFileMaxBackups 10 --logFileMaxAge 60
$ ./razor setConfig --provider https://mainnet.skalenodes.com/v1/elated-tan-skat --gasmultiplier 1 --buffer 5 --wait 1 --gasprice 0 --logLevel debug --gasLimit 2 --rpcTimeout 5 --httpTimeout 5 --logFileMaxSize 200 --logFileMaxBackups 10 --logFileMaxAge 60
```

Besides, setting these parameters in the config, you can use different values for these parameters in various commands. Just add the same flag to any command you want to use and the new config changes will appear for that command.

Example:

```
$ ./razor vote --address 0x5a0b54d5dc17e0aadc383d2db43b0a0d3e029c4c --gasprice 10
$ ./razor vote --address 0x5a0b54d5dc17e0aadc383d2db43b0a0d3e029c4c --gasprice 1
```

This will cause this particular vote command to run with a gas price of 10.
Expand Down
20 changes: 10 additions & 10 deletions addresses/mainnet.json
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
{
"Governance": "0xAc40E8dA38B5a381008059a38bb9bf45f0D3C4e2",
"BlockManager": "0x11aB70d78f1Dd2c3F967180d8A64858Db03A0aBa",
"CollectionManager": "0x367962d1462C568A0dDd0e2448311469451bF5a3",
"StakeManager": "0xe0bC695203d9C9f379bcdE9260B9F71B64B85298",
"RewardManager": "0x301779E4c95f951D2E17B4c3EdDC717551df2EBb",
"VoteManager": "0x641BAD0641eB5B94B19568C0a22a55AEbDAF1870",
"Delegator": "0xC74745eA5a3fac1864FAcd8f48d72C21A4ab883D",
"RAZOR": "0xcbf70914Fae03B3acB91E953De60CfDAaCA8145f",
"StakedTokenFactory": "0xEffA78888Dc1b6033286E5dF9b170bc5223178AB",
"RandomNoManager": "0xC6eF45F5Add040800D30FE6dEe01b4EBC4BfC467"
"Governance": "0xBFF76e9E6B394e6945ef92C686444Ee4Ed5f1216",
"BlockManager": "0xEa74913E6Ed2dce4c89c89F5A328b507AfD86c0e",
"CollectionManager": "0x389B9dCe6819735059d23bDdadCB91a6d89eFE77",
"StakeManager": "0xd492408e4901CF658c7874285984F6D5Db648D1E",
"RewardManager": "0xc9F3fc25B57B7F954A5e051b0f81CDF7A83dB610",
"VoteManager": "0xa1f4Ff01bc744Db0aF31360f85D35366c7CfBA9F",
"Delegator": "0x66468f0FD37c3A0f5EaFA4cbDD0552ef9FbE7DAB",
"RAZOR": "0xCA46B70cA3c510Ce9D0c43D25817032e2F5354c0",
"StakedTokenFactory": "0x75f3E9b560BcF36Ae5fB9E9a218f8e0AAfa88446",
"RandomNoManager": "0xF7c2F6362Cd8e3a7ec1CCa368d84799F7C49A609"
}
21 changes: 10 additions & 11 deletions addresses/testnet.json
Original file line number Diff line number Diff line change
@@ -1,13 +1,12 @@
{
"Governance": "0x0b9CC11E7f7D3D4f9bBc0cCaB85b73B96C322c78",
"BlockManager": "0x076df1c2d81C40D30DF115Ab68A13251fBD3FFA4",
"CollectionManager": "0x83f4D7ad6dD366c3F04Af45a1437c77636b03388",
"StakeManager": "0xf99a873a6afdF1b24388ac02ea0f1CFE3c70A80b",
"RewardManager": "0x522d2A51639332388dA4788DF59fB4E598278fAd",
"VoteManager": "0x2399D4d92b4D8762971605d0bC9597F780852CC4",
"Delegator": "0x81c72fB60d19Bfc3A0adDfE394501150d290cd66",
"RAZOR": "0x504C6635af1e7E6fdc586c8A89973783b9281A77",
"StakedTokenFactory": "0xf271bd91104946Cb8e43BC0e83423ed073ab136e",
"RandomNoManager": "0x2dc9E4663675c933f78D97cDD44463ee9C43144c",
"DelegatorV2": "0x4e9E5AE58Fb6d7Ca5b79A196b8d0FCF7CA15C100"
"Governance": "0x40c9339735D8A323240C775BAa2aA3DFf4a9068a",
"BlockManager": "0x2c44089cf0b69bB99937E18d3F68E410CDbd72D5",
"CollectionManager": "0x6565F307ADfb1c7105ECa401f600C4c352F4B65f",
"StakeManager": "0x3CD0B9650642D9D47614754f1f25b2D78821a998",
"RewardManager": "0x87da99bEB8F781f7FCC606812BA6E8c5eB46CcD5",
"VoteManager": "0x4B7d5280490BB97D78a9a733678d669c782EaFCA",
"Delegator": "0x36294b24E27AA5a1B82c9f4127CEB082fdB13a99",
"RAZOR": "0x56ea26865DF007dD16b642ecAA3E0B21DeE7Ec64",
"StakedTokenFactory": "0xEd8d85d4fDB870f07A7D92e6400AD46C2e983Bd7",
"RandomNoManager": "0x728038fb03d28866e5028da4fD3b5004fB4C36CE"
}
65 changes: 26 additions & 39 deletions cache/cache.go
Original file line number Diff line number Diff line change
Expand Up @@ -11,53 +11,17 @@ type cachedData struct {
}

type LocalCache struct {
stop chan struct{}

wg sync.WaitGroup
mu sync.RWMutex
URLs map[string]cachedData //URLs
}

func NewLocalCache(cleanupInterval time.Duration) *LocalCache {
lc := &LocalCache{
// NewLocalCache creates a new LocalCache instance
func NewLocalCache() *LocalCache {
return &LocalCache{
URLs: make(map[string]cachedData),
stop: make(chan struct{}),
}

lc.wg.Add(1)
go func(cleanupInterval time.Duration) {
defer lc.wg.Done()
lc.cleanupLoop(cleanupInterval)
}(cleanupInterval)

return lc
}

func (lc *LocalCache) cleanupLoop(interval time.Duration) {
t := time.NewTicker(interval)
defer t.Stop()

for {
select {
case <-lc.stop:
return
case <-t.C:
lc.mu.Lock()
for url, cu := range lc.URLs {
if cu.expireAtTimestamp <= time.Now().Unix() {
delete(lc.URLs, url)
}
}
lc.mu.Unlock()
}
}
}

func (lc *LocalCache) StopCleanup() {
close(lc.stop)
lc.wg.Wait()
}

func (lc *LocalCache) Update(data []byte, url string, expireAtTimestamp int64) {
lc.mu.Lock()
defer lc.mu.Unlock()
Expand All @@ -80,3 +44,26 @@ func (lc *LocalCache) Read(url string) ([]byte, bool) {

return cacheData.Result, true
}

// ClearAll deletes all entries in the cache
func (lc *LocalCache) ClearAll() {
lc.mu.Lock()
defer lc.mu.Unlock()

for key := range lc.URLs {
delete(lc.URLs, key)
}
}

// Cleanup removes expired cache entries
func (lc *LocalCache) Cleanup() {
lc.mu.Lock()
defer lc.mu.Unlock()

for url, data := range lc.URLs {
// Remove expired data after the expireAtTimestamp is passed
if data.expireAtTimestamp <= time.Now().Unix() {
delete(lc.URLs, url)
}
}
}
4 changes: 4 additions & 0 deletions cmd/cmd-utils.go
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,10 @@ func (*UtilsStruct) GetEpochAndState(client *ethclient.Client) (uint32, int64, e
if err != nil {
return 0, 0, err
}
err = ValidateBufferPercentLimit(client, bufferPercent)
if err != nil {
return 0, 0, err
}
latestHeader, err := clientUtils.GetLatestBlockWithRetry(client)
if err != nil {
log.Error("Error in fetching block: ", err)
Expand Down
31 changes: 31 additions & 0 deletions cmd/cmd-utils_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,8 @@ func TestGetEpochAndState(t *testing.T) {
latestHeaderErr error
bufferPercent int32
bufferPercentErr error
stateBuffer uint64
stateBufferErr error
state int64
stateErr error
stateName string
Expand All @@ -37,6 +39,7 @@ func TestGetEpochAndState(t *testing.T) {
epoch: 4,
latestHeader: &Types.Header{},
bufferPercent: 20,
stateBuffer: 5,
state: 0,
stateName: "commit",
},
Expand All @@ -50,6 +53,7 @@ func TestGetEpochAndState(t *testing.T) {
epochErr: errors.New("epoch error"),
latestHeader: &Types.Header{},
bufferPercent: 20,
stateBuffer: 5,
state: 0,
stateName: "commit",
},
Expand All @@ -76,6 +80,7 @@ func TestGetEpochAndState(t *testing.T) {
epoch: 4,
latestHeader: &Types.Header{},
bufferPercent: 20,
stateBuffer: 5,
stateErr: errors.New("state error"),
},
wantEpoch: 0,
Expand All @@ -88,20 +93,46 @@ func TestGetEpochAndState(t *testing.T) {
epoch: 4,
latestHeaderErr: errors.New("header error"),
bufferPercent: 20,
stateBuffer: 5,
state: 0,
stateName: "commit",
},
wantEpoch: 0,
wantState: 0,
wantErr: errors.New("header error"),
},
{
name: "Test 6: When validating buffer percent limit fails",
args: args{
epoch: 4,
latestHeader: &Types.Header{},
bufferPercent: 50,
stateBuffer: 10,
},
wantEpoch: 0,
wantState: 0,
wantErr: errors.New("buffer percent exceeds limit"),
},
{
name: "Test 7: When there is an error in validating buffer percent limit",
args: args{
epoch: 4,
latestHeader: &Types.Header{},
bufferPercent: 50,
stateBufferErr: errors.New("state buffer error"),
},
wantEpoch: 0,
wantState: 0,
wantErr: errors.New("state buffer error"),
},
}
for _, tt := range tests {
t.Run(tt.name, func(t *testing.T) {
SetUpMockInterfaces()

utilsMock.On("GetEpoch", mock.AnythingOfType("*ethclient.Client")).Return(tt.args.epoch, tt.args.epochErr)
cmdUtilsMock.On("GetBufferPercent").Return(tt.args.bufferPercent, tt.args.bufferPercentErr)
utilsMock.On("GetStateBuffer", mock.Anything).Return(tt.args.stateBuffer, tt.args.stateBufferErr)
clientUtilsMock.On("GetLatestBlockWithRetry", mock.Anything).Return(tt.args.latestHeader, tt.args.latestHeaderErr)
utilsMock.On("GetBufferedState", mock.Anything, mock.Anything, mock.Anything).Return(tt.args.state, tt.args.stateErr)

Expand Down
12 changes: 3 additions & 9 deletions cmd/commit.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,16 +4,13 @@ package cmd
import (
"encoding/hex"
"errors"
Types "github.com/ethereum/go-ethereum/core/types"
"math/big"
"razor/cache"
"razor/core"
"razor/core/types"
"razor/pkg/bindings"
"razor/utils"
"sync"
"time"

Types "github.com/ethereum/go-ethereum/core/types"

"github.com/ethereum/go-ethereum/common"
"github.com/ethereum/go-ethereum/ethclient"
Expand Down Expand Up @@ -79,8 +76,8 @@ func (*UtilsStruct) HandleCommitState(client *ethclient.Client, epoch uint32, se

var wg sync.WaitGroup

log.Debug("Creating a local cache which will store API result and expire at the end of commit state")
commitParams.LocalCache = cache.NewLocalCache(time.Second * time.Duration(core.StateLength))
// Clean up any expired API results cache data before performing the commit
commitParams.LocalCache.Cleanup()

log.Debug("Iterating over all the collections...")
for i := 0; i < int(numActiveCollections); i++ {
Expand Down Expand Up @@ -129,7 +126,6 @@ func (*UtilsStruct) HandleCommitState(client *ethclient.Client, epoch uint32, se
if err != nil {
// Returning the first error from the error channel
log.Error("Error in getting collection data: ", err)
commitParams.LocalCache.StopCleanup()
return types.CommitData{}, err
}
}
Expand All @@ -139,8 +135,6 @@ func (*UtilsStruct) HandleCommitState(client *ethclient.Client, epoch uint32, se
log.Debug("HandleCommitState: SeqAllottedCollections: ", seqAllottedCollections)
log.Debug("HandleCommitState: Leaves: ", leavesOfTree)

commitParams.LocalCache.StopCleanup()

return types.CommitData{
AssignedCollections: assignedCollections,
SeqAllottedCollections: seqAllottedCollections,
Expand Down
5 changes: 2 additions & 3 deletions cmd/commit_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,6 @@ import (
"razor/utils"
"reflect"
"testing"
"time"
)

func TestCommit(t *testing.T) {
Expand Down Expand Up @@ -226,7 +225,7 @@ func TestHandleCommitState(t *testing.T) {
}
for _, tt := range tests {
t.Run(tt.name, func(t *testing.T) {
localCache := cache.NewLocalCache(time.Second * 10)
localCache := cache.NewLocalCache()
commitParams := &types.CommitParams{
LocalCache: localCache,
}
Expand Down Expand Up @@ -396,7 +395,7 @@ func BenchmarkHandleCommitState(b *testing.B) {
for _, v := range table {
b.Run(fmt.Sprintf("Number_Of_Active_Collections%d", v.numActiveCollections), func(b *testing.B) {
for i := 0; i < b.N; i++ {
localCache := cache.NewLocalCache(time.Second * 10)
localCache := cache.NewLocalCache()
commitParams := &types.CommitParams{
LocalCache: localCache,
}
Expand Down
Loading
Loading