From 0a65522e223d2d149f6497c439baa07229a66aca Mon Sep 17 00:00:00 2001 From: ccamel Date: Fri, 24 Mar 2023 21:59:57 +0100 Subject: [PATCH] feat(logic): implement support for user output --- x/logic/interpreter/interpreter.go | 71 +++++++++++++++++------- x/logic/keeper/interpreter.go | 33 +++++++---- x/logic/types/params.pb.go | 88 +++++++++++++++--------------- x/logic/util/buffer.go | 12 ++-- 4 files changed, 122 insertions(+), 82 deletions(-) diff --git a/x/logic/interpreter/interpreter.go b/x/logic/interpreter/interpreter.go index b78bc59e..78003483 100644 --- a/x/logic/interpreter/interpreter.go +++ b/x/logic/interpreter/interpreter.go @@ -3,43 +3,72 @@ package interpreter import ( goctx "context" "fmt" + "io" "io/fs" sdk "github.com/cosmos/cosmos-sdk/types" "github.com/ichiban/prolog" + "github.com/ichiban/prolog/engine" ) // Predicates is a map of predicate names to their execution costs. type Predicates map[string]uint64 -// New creates a new prolog.Interpreter with: -// - a list of predefined predicates (with their execution costs). -// - a compiled bootstrap script, that can be used to perform setup tasks. -// - a meter to track gas consumption. -// - a file system to load external files. -// +// Option is a function that configures an Interpreter. +type Option func(*prolog.Interpreter) error + +// WithPredicates configures the interpreter to register the specified predicates. // The predicates names must be present in the registry, otherwise the function will return an error. -// The bootstrap script can be an empty string if no bootstrap script is needed. If compilation of the bootstrap script -// fails, the function will return an error. +func WithPredicates(_ goctx.Context, predicates Predicates, meter sdk.GasMeter) Option { + return func(i *prolog.Interpreter) error { + for predicate, cost := range predicates { + if err := Register(i, predicate, cost, meter); err != nil { + return fmt.Errorf("error registering predicate '%s': %w", predicate, err) + } + } + return nil + } +} + +// WithBootstrap configures the interpreter to compile the specified bootstrap script to serve as setup context. +// If compilation of the bootstrap script fails, the function will return an error. +func WithBootstrap(ctx goctx.Context, bootstrap string) Option { + return func(i *prolog.Interpreter) error { + if err := i.Compile(ctx, bootstrap); err != nil { + return fmt.Errorf("error compiling bootstrap script: %w", err) + } + return nil + } +} + +// WithUserOutputWriter configures the interpreter to use the specified writer for user output. +func WithUserOutputWriter(w io.Writer) Option { + return func(i *prolog.Interpreter) error { + i.SetUserOutput(engine.NewOutputTextStream(w)) + + return nil + } +} + +// WithFS configures the interpreter to use the specified file system. +func WithFS(fs fs.FS) Option { + return func(i *prolog.Interpreter) error { + i.FS = fs + return nil + } +} + +// New creates a new prolog.Interpreter with the specified options. func New( - ctx goctx.Context, - predicates Predicates, - bootstrap string, - meter sdk.GasMeter, - fs fs.FS, + opts ...Option, ) (*prolog.Interpreter, error) { var i prolog.Interpreter - i.FS = fs - for predicate, cost := range predicates { - if err := Register(&i, predicate, cost, meter); err != nil { - return nil, fmt.Errorf("error registering predicate '%s': %w", predicate, err) + for _, opt := range opts { + if err := opt(&i); err != nil { + return nil, err } } - if err := i.Compile(ctx, bootstrap); err != nil { - return nil, fmt.Errorf("error compiling bootstrap script: %w", err) - } - return &i, nil } diff --git a/x/logic/keeper/interpreter.go b/x/logic/keeper/interpreter.go index b7b29b5f..7c3228fc 100644 --- a/x/logic/keeper/interpreter.go +++ b/x/logic/keeper/interpreter.go @@ -37,7 +37,7 @@ func (k Keeper) execute(ctx goctx.Context, program, query string) (*types.QueryS ctx = k.enhanceContext(ctx) sdkCtx := sdk.UnwrapSDKContext(ctx) - i, err := k.newInterpreter(ctx) + i, userOutputBuffer, err := k.newInterpreter(ctx) if err != nil { return nil, sdkerrors.Wrapf(types.Internal, "error creating interpreter: %v", err.Error()) } @@ -77,6 +77,11 @@ func (k Keeper) execute(ctx goctx.Context, program, query string) (*types.QueryS panic(sdk.ErrorOutOfGas{Descriptor: "Prolog interpreter execution"}) } + var userOutput string + if userOutputBuffer != nil { + userOutput = userOutputBuffer.String() + } + return &types.QueryServiceAskResponse{ Height: uint64(sdkCtx.BlockHeight()), GasUsed: sdkCtx.GasMeter().GasConsumed(), @@ -86,6 +91,7 @@ func (k Keeper) execute(ctx goctx.Context, program, query string) (*types.QueryS Variables: variables, Results: results, }, + UserOutput: userOutput, }, nil } @@ -100,12 +106,13 @@ func checkLimits(request *types.QueryServiceAskRequest, limits types.Limits) err } // newInterpreter creates a new interpreter properly configured. -func (k Keeper) newInterpreter(ctx goctx.Context) (*prolog.Interpreter, error) { +func (k Keeper) newInterpreter(ctx goctx.Context) (*prolog.Interpreter, *util.BoundedBuffer, error) { sdkctx := sdk.UnwrapSDKContext(ctx) params := k.GetParams(sdkctx) interpreterParams := params.GetInterpreter() gasPolicy := params.GetGasPolicy() + limits := params.GetLimits() whitelist := util.NonZeroOrDefault(interpreterParams.PredicatesWhitelist, interpreter.RegistryNames) blacklist := interpreterParams.GetPredicatesBlacklist() @@ -125,15 +132,21 @@ func (k Keeper) newInterpreter(ctx goctx.Context) (*prolog.Interpreter, error) { }, interpreter.Predicates{}) - interpreted, err := interpreter.New( - ctx, - predicates, - util.NonZeroOrDefault(interpreterParams.GetBootstrap(), bootstrap.Bootstrap()), - gasMeter, - k.fsProvider(ctx), - ) + options := []interpreter.Option{ + interpreter.WithPredicates(ctx, predicates, gasMeter), + interpreter.WithBootstrap(ctx, util.NonZeroOrDefault(interpreterParams.GetBootstrap(), bootstrap.Bootstrap())), + interpreter.WithFS(k.fsProvider(ctx)), + } + + var userOutputBuffer *util.BoundedBuffer + if limits.MaxUserOutputSize != nil && limits.MaxUserOutputSize.GT(sdkmath.ZeroUint()) { + userOutputBuffer = util.NewBoundedBufferMust(int(limits.MaxUserOutputSize.Uint64())) + options = append(options, interpreter.WithUserOutputWriter(userOutputBuffer)) + } + + i, err := interpreter.New(options...) - return interpreted, err + return i, userOutputBuffer, err } // filterPredicates filters the given predicate (with arity) according to the given whitelist and blacklist. diff --git a/x/logic/types/params.pb.go b/x/logic/types/params.pb.go index 9d99a880..89c123d5 100644 --- a/x/logic/types/params.pb.go +++ b/x/logic/types/params.pb.go @@ -331,49 +331,51 @@ func init() { func init() { proto.RegisterFile("logic/v1beta2/params.proto", fileDescriptor_3af0daa241de0fa3) } var fileDescriptor_3af0daa241de0fa3 = []byte{ - // 666 bytes of a gzipped FileDescriptorProto - 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0x9c, 0x94, 0xbd, 0x6f, 0xd3, 0x4e, - 0x18, 0xc7, 0xe3, 0xa4, 0xca, 0xef, 0xe7, 0x8b, 0xfa, 0xc2, 0xd1, 0x82, 0x09, 0x34, 0xa9, 0xae, - 0x03, 0x1d, 0x20, 0x16, 0x05, 0x75, 0xa8, 0xc4, 0xe2, 0x22, 0xca, 0xdb, 0x10, 0x1d, 0xe2, 0x45, - 0x08, 0x14, 0x5d, 0x9c, 0xab, 0x7b, 0xaa, 0x9d, 0xb3, 0x7c, 0x17, 0x9a, 0x74, 0x64, 0x60, 0x66, - 0x64, 0x64, 0xe1, 0x7f, 0x29, 0x5b, 0x47, 0xc4, 0x10, 0xa1, 0xf6, 0x2f, 0xa0, 0x2b, 0x0b, 0xf2, - 0xf9, 0x62, 0x3b, 0x56, 0x25, 0x14, 0x96, 0x36, 0x7a, 0x9e, 0xef, 0xf3, 0xf9, 0x3e, 0xf7, 0x3c, - 0x77, 0x06, 0x75, 0x9f, 0x7b, 0xcc, 0xb5, 0xdf, 0xdf, 0xe9, 0x52, 0x49, 0x36, 0xed, 0x90, 0x44, - 0x24, 0x10, 0xad, 0x30, 0xe2, 0x92, 0xc3, 0x79, 0x95, 0x6b, 0xe9, 0x5c, 0x7d, 0xd9, 0xe3, 0x1e, - 0x57, 0x19, 0x3b, 0xfe, 0x95, 0x88, 0xd0, 0x87, 0x32, 0xa8, 0xb6, 0x55, 0x15, 0x7c, 0x0d, 0x6a, - 0xac, 0x2f, 0x69, 0x14, 0x46, 0x54, 0xd2, 0xc8, 0x32, 0xd6, 0x8c, 0x8d, 0xda, 0x66, 0xbd, 0x35, - 0x45, 0x69, 0x3d, 0xce, 0x14, 0x4e, 0xfd, 0x78, 0xdc, 0x2c, 0x9d, 0x8f, 0x9b, 0x70, 0x44, 0x02, - 0x7f, 0x1b, 0xe5, 0x8a, 0x11, 0xce, 0xa3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c, 0xd4, 0x36, 0x6f, 0x14, 0x9e, 0xed, 0x54, 0x99, 0xb3, 0xaa, 0x9f, - 0xee, 0x4a, 0x61, 0x79, 0xda, 0x6b, 0x21, 0xcc, 0xab, 0x05, 0xfa, 0x6a, 0x80, 0xf9, 0x69, 0xdf, - 0x2d, 0x60, 0xa6, 0x1a, 0x3d, 0xf0, 0xc2, 0x0e, 0xd3, 0x34, 0xc2, 0x99, 0x14, 0xbe, 0x05, 0x73, - 0xb9, 0x29, 0x3d, 0x9a, 0x7d, 0x4a, 0xba, 0x63, 0xd5, 0x67, 0xee, 0xd9, 0x2b, 0xaa, 0x73, 0xff, - 0xf8, 0xb4, 0x61, 0x9c, 0x9c, 0x36, 0x8c, 0x9f, 0xa7, 0x0d, 0xe3, 0xd3, 0x59, 0xa3, 0x74, 0x72, - 0xd6, 0x28, 0x7d, 0x3f, 0x6b, 0x94, 0xde, 0xac, 0xe7, 0x1c, 0xf8, 0x41, 0x78, 0x4f, 0xfd, 0xe9, - 0xd9, 0x43, 0x3b, 0xf9, 0xba, 0x2b, 0x8b, 0x6e, 0x55, 0x7d, 0xb0, 0xef, 0xfe, 0x09, 0x00, 0x00, - 0xff, 0xff, 0xc3, 0xc1, 0xb6, 0x82, 0xf3, 0x05, 0x00, 0x00, + // 702 bytes of a gzipped FileDescriptorProto + 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0x9c, 0x95, 0x3f, 0x6f, 0xd3, 0x40, + 0x18, 0xc6, 0xe3, 0xa4, 0x0a, 0xf8, 0xa2, 0xfe, 0x3b, 0x52, 0x30, 0x81, 0x26, 0xd5, 0x75, 0xa0, + 0x03, 0x24, 0xa2, 0xa0, 0x0e, 0x95, 0x58, 0x5c, 0x44, 0xf9, 0x27, 0x88, 0x0e, 0x15, 0x10, 0x02, + 0x45, 0x17, 0xe7, 0xea, 0x9e, 0x1a, 0xe7, 0x2c, 0xdf, 0x85, 0x26, 0x5d, 0x90, 0x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 0xe6, 0x6e, 0x00, 0x33, 0xf6, 0xe8, 0x03, 0xcf, 0x3c, 0xc3, 0xb8, 0x8c, 0x70, 0x62, 0x85, + 0x6f, 0xc1, 0x4c, 0xea, 0x94, 0x1e, 0x4e, 0x7f, 0x4a, 0x7a, 0xc5, 0x6a, 0x9d, 0xa9, 0x7b, 0x47, + 0x51, 0xed, 0x7b, 0x47, 0x27, 0x55, 0xe3, 0xf8, 0xa4, 0x6a, 0xfc, 0x3a, 0xa9, 0x1a, 0x9f, 0x4f, + 0xab, 0xb9, 0xe3, 0xd3, 0x6a, 0xee, 0xc7, 0x69, 0x35, 0xf7, 0x66, 0x35, 0x95, 0xc0, 0xf7, 0xfd, + 0xbb, 0xea, 0xa3, 0xd3, 0x18, 0x34, 0xa2, 0xd7, 0x8b, 0x8a, 0x68, 0x17, 0xd5, 0x1b, 0xe3, 0xce, + 0xdf, 0x00, 0x00, 0x00, 0xff, 0xff, 0xd8, 0x56, 0x08, 0x95, 0x74, 0x06, 0x00, 0x00, } func (m *Params) Marshal() (dAtA []byte, err error) { diff --git a/x/logic/util/buffer.go b/x/logic/util/buffer.go index d1d7d1ce..8fc54353 100644 --- a/x/logic/util/buffer.go +++ b/x/logic/util/buffer.go @@ -5,15 +5,11 @@ import ( "io" ) -var ( - _ = io.Writer(&BoundedBuffer{}) -) +var _ = io.Writer(&BoundedBuffer{}) -var ( - ErrInvalidSize = func(size int) error { - return fmt.Errorf("invalid buffer size %d", size) - } -) +var ErrInvalidSize = func(size int) error { + return fmt.Errorf("invalid buffer size %d", size) +} // BoundedBuffer is a fixed size buffer that overwrites older data when the buffer is full. type BoundedBuffer struct {