Skip to content

Commit

Permalink
fix get span size
Browse files Browse the repository at this point in the history
  • Loading branch information
slandymani committed Jan 10, 2024
1 parent 0563a5d commit 3de3c28
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 6 deletions.
8 changes: 6 additions & 2 deletions x/oracle/keeper/owasm.go
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,11 @@ func (k Keeper) PrepareRequest(
)

// Create an execution environment and call Owasm prepare function.
env := types.NewPrepareEnv(req, 1024, int64(k.GetParamUint64(ctx, types.KeyMaxRawRequestCount)))
env := types.NewPrepareEnv(
req,
int64(k.GetParamUint64(ctx, types.KeyMaxDataSize)),
int64(k.GetParamUint64(ctx, types.KeyMaxRawRequestCount)),
int64(k.GetSpanSize(ctx)))
script, err := k.GetOracleScript(ctx, req.OracleScriptID)
if err != nil {
return 0, err
Expand Down Expand Up @@ -162,7 +166,7 @@ func (k Keeper) PrepareRequest(
// assumes that the given request is in a resolvable state with sufficient reporters.
func (k Keeper) ResolveRequest(ctx sdk.Context, reqID types.RequestID) {
req := k.MustGetRequest(ctx, reqID)
env := types.NewExecuteEnv(req, k.GetRequestReports(ctx, reqID), ctx.BlockTime())
env := types.NewExecuteEnv(req, k.GetRequestReports(ctx, reqID), ctx.BlockTime(), int64(k.GetSpanSize(ctx)))
script := k.MustGetOracleScript(ctx, req.OracleScriptID)
code := k.GetFile(script.Filename)

Expand Down
10 changes: 6 additions & 4 deletions x/oracle/types/exec_env.go
Original file line number Diff line number Diff line change
Expand Up @@ -81,10 +81,11 @@ type PrepareEnv struct {
}

// NewPrepareEnv creates a new environment instance for prepare period.
func NewPrepareEnv(req Request, maxCalldataSize int64, maxRawRequests int64) *PrepareEnv {
func NewPrepareEnv(req Request, maxCalldataSize int64, maxRawRequests int64, spanSize int64) *PrepareEnv {
return &PrepareEnv{
BaseEnv: BaseEnv{
request: req,
request: req,
maxSpanSize: spanSize,
},
maxCalldataSize: maxCalldataSize,
maxRawRequests: maxRawRequests,
Expand Down Expand Up @@ -124,7 +125,7 @@ type ExecuteEnv struct {
}

// NewExecuteEnv creates a new environment instance for execution period.
func NewExecuteEnv(req Request, reports []Report, executeTime time.Time) *ExecuteEnv {
func NewExecuteEnv(req Request, reports []Report, executeTime time.Time, spanSize int64) *ExecuteEnv {
envReports := make(map[string]map[ExternalID]RawReport)
for _, report := range reports {
valReports := make(map[ExternalID]RawReport)
Expand All @@ -135,7 +136,8 @@ func NewExecuteEnv(req Request, reports []Report, executeTime time.Time) *Execut
}
return &ExecuteEnv{
BaseEnv: BaseEnv{
request: req,
request: req,
maxSpanSize: spanSize,
},
reports: envReports,
ExecuteTime: executeTime.Unix(),
Expand Down

0 comments on commit 3de3c28

Please sign in to comment.