Scaffolding toward Blockstore-based XBlock runtime [LX-73]


*❗This PR has been superseded by*


This is a new XBlock runtime edx-platform, designed to be used for pure XBlocks (not XModules) that are stored in Blockstore. (In the future, it will also support XBlocks that are stored in some optimized format derived from Blockstore.)



      1. Goals are:

  • Be able to run alongside the existing XBlock runtime + modulestore without interfering with them (any XBlock in modulestore will use the old runtime, and in Blockstore will use the new runtime with no overlap, and they'll store user state etc. in different database tables)

  • Be able to load XBlock data (OLX) directly from Blockstore, including draft bundles, and (in the future) from some more optimized format.

  • Have little or no dependencies on the rest of the edx-platform codebase, so that we can separate the runtime in the future.

  • Support XBlock sandboxing by allowing XBlock frontend code to call XBlock handlers without needing any cookies (this lets us block XBlock frontend code from seeing any of the user's edX cookies at all)

  • First-class support for anonymous users (allow users who aren't logged in to still save state in the session, like Studio does, if the XBlock supports it)



      1. Non-goals:

  • Support XModules

  • Support Modulestore

  • Support `course`, `section`, or `subsection` XModules



      1. Status:

  • Can load an individual XBlock's OLX from Blockstore, instantiate that XBlock, render its `author_view` or `student_view`, then return the resulting HTML+JS+CSS via an API endpoint. The idea is that a React frontend would consume this API and add the JS runtime, displaying the XBlock.

  • In progress: persist user state for registered users

Not ready for wide review.


    1. Testing instructions

So far I only have confirmed this works with a Drag and Drop XBlock (that said, it should work with any pure XBlock). Haven't yet tested XModules or blocks with children, but they probably aren't working yet.

1. [Set up `blockstore` on your docker devstack](
1. Also install and configure [openedx-blockstore-relay](
1. Check out this branch.
1. Run `make studio-shell` then `pip install -e .` to update the required entry points. Restart Studio (`make studio-restart` on the host).
1. Create a course in Studio with a Drag and Drop v2 XBlock. Customize the drag and drop XBlock, changing the title, descriptions, mode, and other settings (but don't change the image). Publish the changes.
1. Import the drag and drop xblock into blockstore. See the [relay README]( for instructions. The command should look like: `./ cms transfer_to_blockstore --verbosity=2 --collection-uuid "PUT_UUID_HERE" --block-key "block-v1:OpenCraft+B+1+type@drag-and-drop-v2+block@blah"`
1. Note the *UUID* from the resulting bundle. Put them into the URL and visit in in your browser:
1. The resulting API response should include a URL for each XBlock in the bundle, like http://localhost:18010/api/bundles/v0/block/gblock-v1:ec2566b7-e618-429b-8d97-b3ded042b862:drag-and-drop-v2:971aadaaaa5a4886b37fee3ced711b30/ . Go to that URL. Check the resulting HTML / fragment data.



      1. Todos:

  • [ ] Add tests

  • [ ] Fix outdated docstring: "each XBlock gets its own instance of XBlockRuntime."

  • [ ] Test with XBlocks with children

  • [x] Cleanup: Current XBlockruntime is overly coupled to Blockstore KVS - calls `collect_parsed_fields()` within `parse_xml_file()`: fixed in

  • [x] Develop an opaque ID format for definitions within blockstore and usages based thereon:

  • [ ] Be able to persist edits back to Blockstore, creating an updated draft



      1. Outline of future PRs:

  • Implement user state storage for registered users

  • Implement user state storage for anonymous users

  • Create pluggable "learning context" model, including a simple content library implementation which defines how permissions work ( In `edxapp`, there would be a `libraries` model that associates a library bundle UUID with metadata such as the users who have permission to edit it, and a `class LibraryContext(LearningContext)` implementation which defines how to determine if the given user has permission to view and/or edit XBlocks in the given context.

  • Add Permissions checks

  • Connect with grades & completion systems

  • Consider changing the XBlock API to make working with XML less painful?

Won't Do




Open Source Pull Request Bot



Contributor Name

Braden MacDonald




Epic Link


OSCM Assignee


Platform Map Area (Levels 1 & 2)


Platform Map Area (Levels 3 & 4)


Blended Hour Utilization Percentage


edX Theme


edX Squad


Github Lines Added


Github Lines Deleted