Skip to content

Commit

Permalink
Merge pull request #60 from 0xPolygonHermez/feature/fix-ft-global-to-ctx
Browse files Browse the repository at this point in the history
fix vars from global to ctx on FT
  • Loading branch information
krlosMata committed Jan 25, 2024
2 parents d8ca5c8 + 493fd8e commit b651f11
Showing 1 changed file with 9 additions and 2 deletions.
11 changes: 9 additions & 2 deletions src/sm/sm_main/debug/full-tracer.js
Original file line number Diff line number Diff line change
Expand Up @@ -255,6 +255,7 @@ class FullTracer {
gas_limit: `0x${Constants.BLOCK_GAS_LIMIT.toString(16)}`,
responses: [],
error: '',
ctx: Number(ctx.CTX),
};

// add current block to the final trace
Expand All @@ -268,10 +269,16 @@ class FullTracer {
* @param {Object} ctx Current context object
*/
onFinishBlock(ctx) {
// recover chnageL2Block context to get data from there
const ctxBlock = this.currentBlock.ctx;

// get data ctx
this.currentBlock.ger = ethers.utils.hexlify(getVarFromCtx(ctx, false, 'gerL1InfoTree', ctxBlock));
this.currentBlock.block_hash_l1 = ethers.utils.hexlify(getVarFromCtx(ctx, false, 'blockHashL1InfoTree', ctxBlock));

// get global data
this.currentBlock.parent_hash = ethers.utils.hexlify(getVarFromCtx(ctx, true, 'previousBlockHash'));
this.currentBlock.timestamp = Number(getVarFromCtx(ctx, true, 'timestamp'));
this.currentBlock.ger = ethers.utils.hexlify(getVarFromCtx(ctx, true, 'gerL1InfoTree'));
this.currentBlock.block_hash_l1 = ethers.utils.hexlify(getVarFromCtx(ctx, true, 'blockHashL1InfoTree'));
this.currentBlock.gas_used = Number(getVarFromCtx(ctx, true, 'cumulativeGasUsed'));
this.currentBlock.block_info_root = ethers.utils.hexlify(getVarFromCtx(ctx, true, 'blockInfoSR'));
this.currentBlock.block_hash = ethers.utils.hexlify(fea2scalar(ctx.Fr, ctx.SR));
Expand Down

0 comments on commit b651f11

Please sign in to comment.