protocol: Migrate to a layered context to optimize gas update
This MR introduces a layered representation for the context to get faster functional updates of the gas counter.
Currently, each of these functional updates requires a copy of 200 bytes while this commit reduces this number to 16. This optimization is important because the updates of the gas counter are extremely frequent during script evaluation.
This optimization is part of a sequence to optimize gas update and check for gas exhaustion documented here: https://hackmd.io/@yrg/rkLwB17wD
Edited by Yann Regis-Gianas