diff --git a/packages/vm/core/testcore/blob_test.go b/packages/vm/core/testcore/blob_test.go index f40de73d9e..f9567fb4ff 100644 --- a/packages/vm/core/testcore/blob_test.go +++ b/packages/vm/core/testcore/blob_test.go @@ -1,6 +1,7 @@ package testcore import ( + "crypto/rand" "fmt" "testing" @@ -12,6 +13,7 @@ import ( "github.com/iotaledger/wasp/packages/kv/codec" "github.com/iotaledger/wasp/packages/solo" "github.com/iotaledger/wasp/packages/vm/core/blob" + "github.com/iotaledger/wasp/packages/vm/gas" ) const ( @@ -32,6 +34,29 @@ func TestUploadBlob(t *testing.T) { _, ok := ch.GetBlobInfo(h) require.True(t, ok) }) + t.Run("huge", func(t *testing.T) { + env := solo.New(t) + ch := env.NewChain() + + err := ch.DepositBaseTokensToL2(1_000_000, nil) + require.NoError(t, err) + + limits := *gas.LimitsDefault + limits.MaxGasPerRequest = 10 * limits.MaxGasPerRequest + limits.MaxGasExternalViewCall = 10 * limits.MaxGasExternalViewCall + ch.SetGasLimits(nil, &limits) + ch.WaitForRequestsMark() + + size := int64(1 * 900 * 1024) // 900 KB + randomData := make([]byte, size+1) + _, err = rand.Read(randomData) + require.NoError(t, err) + h, err := ch.UploadBlob(nil, "field", randomData) + require.NoError(t, err) + + _, ok := ch.GetBlobInfo(h) + require.True(t, ok) + }) t.Run("from file", func(t *testing.T) { env := solo.New(t) ch := env.NewChain() diff --git a/tools/cluster/tests/offledger_requests_test.go b/tools/cluster/tests/offledger_requests_test.go index de85fe6c6a..e9926b16d9 100644 --- a/tools/cluster/tests/offledger_requests_test.go +++ b/tools/cluster/tests/offledger_requests_test.go @@ -18,6 +18,8 @@ import ( "github.com/iotaledger/wasp/packages/kv/dict" "github.com/iotaledger/wasp/packages/vm/core/accounts" "github.com/iotaledger/wasp/packages/vm/core/blob" + "github.com/iotaledger/wasp/packages/vm/core/governance" + "github.com/iotaledger/wasp/packages/vm/gas" ) func TestOffledgerRequestAccessNode(t *testing.T) { @@ -107,15 +109,49 @@ func testOffledgerRequest900KB(t *testing.T, e *ChainEnv) { paramsDict := dict.Dict{"data": randomData} expectedHash := blob.MustGetBlobHash(paramsDict) + // raise gas limits, gas cost for 900KB has exceeded the limits + { + limits1 := *gas.LimitsDefault + limits1.MaxGasPerRequest = 10 * limits1.MaxGasPerRequest + limits1.MaxGasExternalViewCall = 10 * limits1.MaxGasExternalViewCall + govClient := e.Chain.SCClient(governance.Contract.Hname(), e.Chain.OriginatorKeyPair) + gasLimitsReq, err := govClient.PostOffLedgerRequest( + governance.FuncSetGasLimits.Name, + chainclient.PostRequestParams{ + Args: dict.Dict{ + governance.ParamGasLimitsBytes: limits1.Bytes(), + }, + }, + ) + require.NoError(t, err) + _, _, err = e.Clu.WaspClient(0).ChainsApi. + WaitForRequest(context.Background(), e.Chain.ChainID.String(), gasLimitsReq.ID().String()). + TimeoutSeconds(10). + Execute() + require.NoError(t, err) + + retDict, err := govClient.CallView(context.Background(), + governance.ViewGetGasLimits.Name, + dict.Dict{}, + ) + require.NoError(t, err) + limits2, err := gas.LimitsFromBytes(retDict.Get(governance.ParamGasLimitsBytes)) + require.Equal(t, limits1, *limits2) + require.NoError(t, err) + } + offledgerReq, err := chClient.PostOffLedgerRequest(context.Background(), blob.Contract.Hname(), blob.FuncStoreBlob.Hname(), chainclient.PostRequestParams{ - Args: paramsDict, - }) + Args: paramsDict, + Allowance: isc.NewAssetsBaseTokens(10 * isc.Million), + }, + ) require.NoError(t, err) - _, err = e.Chain.CommitteeMultiClient().WaitUntilRequestProcessedSuccessfully(e.Chain.ChainID, offledgerReq.ID(), false, 30*time.Second) + _, err = e.Chain.CommitteeMultiClient(). + WaitUntilRequestProcessedSuccessfully(e.Chain.ChainID, offledgerReq.ID(), false, 30*time.Second) require.NoError(t, err) // ensure blob was stored by the cluster