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

fix: incorrect state error for shorter epoch length #1192

Merged
14 changes: 7 additions & 7 deletions cmd/config-utils.go
Original file line number Diff line number Diff line change
Expand Up @@ -209,8 +209,8 @@ func (*UtilsStruct) GetMultiplier() (float32, error) {
//This function returns the buffer percent
func (*UtilsStruct) GetBufferPercent() (int32, error) {
const (
MinBufferPercent = 10
MaxBufferPercent = 30
MinBufferPercent = 0
MaxBufferPercent = 5
)

bufferPercent, err := getConfigValue("buffer", "int32", core.DefaultBufferPercent, "buffer")
Expand All @@ -228,7 +228,7 @@ func (*UtilsStruct) GetBufferPercent() (int32, error) {

// If bufferPercent is 0, use the default value.
if bufferPercentInt32 == 0 {
log.Debugf("BufferPercent is unset, using default value %d", core.DefaultBufferPercent)
log.Debugf("BufferPercent is unset or set to 0, using its default %d value", core.DefaultBufferPercent)
return core.DefaultBufferPercent, nil
}

Expand All @@ -238,8 +238,8 @@ func (*UtilsStruct) GetBufferPercent() (int32, error) {
//This function returns the wait time
func (*UtilsStruct) GetWaitTime() (int32, error) {
const (
MinWaitTime = 1 // Minimum wait time in seconds
MaxWaitTime = 30 // Maximum wait time in seconds
MinWaitTime = 1 // Minimum wait time in seconds
MaxWaitTime = 5 // Maximum wait time in seconds
ashish10677 marked this conversation as resolved.
Show resolved Hide resolved
)

waitTime, err := getConfigValue("wait", "int32", core.DefaultWaitTime, "wait")
Expand Down Expand Up @@ -335,7 +335,7 @@ func (*UtilsStruct) GetGasLimitOverride() (uint64, error) {
func (*UtilsStruct) GetRPCTimeout() (int64, error) {
const (
MinRPCTimeout = 10 // Minimum RPC timeout in seconds
MaxRPCTimeout = 60 // Maximum RPC timeout in seconds
MaxRPCTimeout = 20 // Maximum RPC timeout in seconds
)

rpcTimeout, err := getConfigValue("rpcTimeout", "int64", core.DefaultRPCTimeout, "rpcTimeout")
Expand All @@ -357,7 +357,7 @@ func (*UtilsStruct) GetRPCTimeout() (int64, error) {
func (*UtilsStruct) GetHTTPTimeout() (int64, error) {
const (
MinHTTPTimeout = 10 // Minimum HTTP timeout in seconds
MaxHTTPTimeout = 60 // Maximum HTTP timeout in seconds
MaxHTTPTimeout = 20 // Maximum HTTP timeout in seconds
)

httpTimeout, err := getConfigValue("httpTimeout", "int64", core.DefaultHTTPTimeout, "httpTimeout")
Expand Down
16 changes: 8 additions & 8 deletions cmd/config-utils_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -260,9 +260,9 @@ func TestGetBufferPercent(t *testing.T) {
name: "Test 1: When buffer percent is fetched from root flag",
args: args{
isFlagSet: true,
bufferPercent: 15,
bufferPercent: 5,
},
want: 15,
want: 5,
wantErr: nil,
},
{
Expand All @@ -278,9 +278,9 @@ func TestGetBufferPercent(t *testing.T) {
name: "Test 3: When buffer value is fetched from config",
useDummyConfigFile: true,
args: args{
bufferInTestConfig: 30,
bufferInTestConfig: 1,
},
want: 30,
want: 1,
wantErr: nil,
},
{
Expand Down Expand Up @@ -1130,9 +1130,9 @@ func TestGetWaitTime(t *testing.T) {
name: "Test 1: When wait time is fetched from root flag",
args: args{
isFlagSet: true,
waitTime: 10,
waitTime: 2,
},
want: 10,
want: 2,
wantErr: nil,
},
{
Expand All @@ -1148,9 +1148,9 @@ func TestGetWaitTime(t *testing.T) {
name: "Test 3: When wait time value is fetched from config",
useDummyConfigFile: true,
args: args{
waitInTestConfig: 20,
waitInTestConfig: 3,
},
want: 20,
want: 3,
wantErr: nil,
},
{
Expand Down
14 changes: 3 additions & 11 deletions cmd/vote.go
Original file line number Diff line number Diff line change
Expand Up @@ -132,16 +132,8 @@ func (*UtilsStruct) Vote(ctx context.Context, config types.Configurations, clien
for {
select {
case <-assetCacheTicker.C:
log.Info("ASSET CACHE EXPIRED!")
log.Info("INITIALIZING JOBS AND COLLECTIONS CACHE AGAIN...")
if err := utils.InitJobsCache(client); err != nil {
log.Error("Error in initializing jobs cache: ", err)
continue
}
if err := utils.InitCollectionsCache(client); err != nil {
log.Error("Error in initializing collections cache: ", err)
continue
}
log.Info("ASSET CACHE EXPIRED! INITIALIZING JOBS AND COLLECTIONS CACHE AGAIN...")
go utils.ResetAssetCache(client)
ashish10677 marked this conversation as resolved.
Show resolved Hide resolved
case <-ctx.Done():
return nil
default:
Expand Down Expand Up @@ -529,7 +521,7 @@ func (*UtilsStruct) InitiateReveal(client *ethclient.Client, config types.Config
if revealTxn != core.NilHash {
waitForBlockCompletionErr := razorUtils.WaitForBlockCompletion(client, revealTxn.Hex())
if waitForBlockCompletionErr != nil {
log.Error("Error in WaitForBlockCompletionErr for reveal: ", err)
log.Error("Error in WaitForBlockCompletionErr for reveal: ", waitForBlockCompletionErr)
return err
}
}
Expand Down
8 changes: 4 additions & 4 deletions config.sh
Original file line number Diff line number Diff line change
Expand Up @@ -19,20 +19,20 @@ then
GAS_MULTIPLIER=1.0
fi

read -rp "Buffer Percent: (20) " BUFFER
read -rp "Buffer Percent: (0) " BUFFER
if [ -z "$BUFFER" ];
then
BUFFER=20
BUFFER=0
fi

read -rp "Wait Time: (1) " WAIT_TIME
if [ -z "$WAIT_TIME" ]; then
WAIT_TIME=1
fi

read -rp "Gas Price: (1) " GAS_PRICE
read -rp "Gas Price: (0) " GAS_PRICE
if [ -z "$GAS_PRICE" ]; then
GAS_PRICE=1
GAS_PRICE=0
fi

read -rp "Gas Limit Increment : (2) " GAS_LIMIT
Expand Down
2 changes: 1 addition & 1 deletion core/constants.go
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ var BlockCompletionTimeout = 30
//Following are the default config values for all the config parameters

var DefaultGasMultiplier float32 = 1.0
var DefaultBufferPercent int32 = 20
var DefaultBufferPercent int32 = 0
var DefaultGasPrice int32 = 0
var DefaultWaitTime int32 = 1
var DefaultGasLimit float32 = 2
Expand Down
11 changes: 11 additions & 0 deletions utils/asset.go
Original file line number Diff line number Diff line change
Expand Up @@ -531,6 +531,17 @@ func (*UtilsStruct) HandleOfficialJobsFromJSONFile(client *ethclient.Client, col
return overrideJobs, overriddenJobIds
}

func ResetAssetCache(client *ethclient.Client) {
if err := InitJobsCache(client); err != nil {
log.Error("Error in initializing jobs cache: ", err)
return
}
if err := InitCollectionsCache(client); err != nil {
log.Error("Error in initializing collections cache: ", err)
return
}
}

func InitJobsCache(client *ethclient.Client) error {
cache.JobsCache.Mu.Lock()
defer cache.JobsCache.Mu.Unlock()
Expand Down
Loading