ETH Price: $2,553.48 (-1.64%)

Transaction Decoder

Block:
16513420 at Jan-29-2023 03:38:35 PM +UTC
Transaction Fee:
0.002525438953632135 ETH $6.45
Gas Used:
86,005 Gas / 29.363862027 Gwei

Emitted Events:

159 MemoryPageFactRegistry.LogMemoryPageFactContinuous( factHash=5C470A71F87EC7C6B83D81A7A6951337F441BAB68A4C2607BCB1EC10B84C565C, memoryHash=6956745510180786379360541589845535115058585205988485674423965847766559301095, prod=3112336154918227475414226865374149347920124361127032095603595250316182103778 )

Account State Difference:

  Address   Before After State Difference Code
0x28067505...8E73edECD
(dYdX: Memory Page Fact Registry 2)
0x99Ade43B...98e211FDA
34.453291839382247349 Eth
Nonce: 58149
34.450766400428615214 Eth
Nonce: 58150
0.002525438953632135
(Flashbots: Builder)
1.19805980385481005 Eth1.19814580885481005 Eth0.000086005

Execution Trace

MemoryPageFactRegistry.registerContinuousMemoryPage( startAddr=9882112, values=[1551281718933837811994613622269688590192200361585458760947987678988491982370, 262934119656832620470254498897688504104414165077388987542899513954618503482, 221832054997313817411925733335840317216458882025010055361065510456740197027, 2382857208087303589735784366868465173681327830410451660151382378461836313222, 465874, 31, 63, 0, 21, 0, 0, 0, 2258234041835150663899921017340170361088646357076919136471136581785240259808, 1103114524755001640548555873671808205895038091681120606634696969331999845790, 7186722336238609232133760576, 2677546288929267678972362572562437345715274174322372291804843985316503150230, 1103114524755001640548555873671808205895038091681120606634696969331999845790, 6364490207745139779089369088, 290847338117667480389935951328270057233911321540906591717099262629724008675, 1103114524755001640548555873671808205895038091681120606634696969331999845790, 8383454581319355287466996336, 2701769176831805479336904828489757977791668551499127925011403451539346822699, 636117700839179604858620718832286872417390350654465827892936533551518041557, 8271288692810562456272807936, 2064744798413828026342147181881510096469528853963451083000232344870165406770, 1103114524755001640548555873671808205895038091681120606634696969331999845790, 27870991930154986872662432, 3321758489756817243366210478010703091834543143294620046973794814098202896357, 636117700839179604858620718832286872417390350654465827892936533551518041557, 402143770843465385438341120, 1349810435948100597038909209126573711827470803661150386298408388008022473598, 1103114524755001640548555873671808205895038091681120606634696969331999845790, 8561029783514934792811951872, 451744801831474168405812831440142156377671388396544653867026413927922595976, 1103114524755001640548555873671808205895038091681120606634696969331999845790, 8364021213138863380413504576, 434839542676288005607821802161733668579023482969492297015483373693555555185, 1103114524755001640548555873671808205895038091681120606634696969331999845790, 8209086806749592045791682800, 3578461820735592724838008513319228391029485770015234308469649416570103715510, 1103114524755001640548555873671808205895038091681120606634696969331999845790, 8561000932807203495983224448, 2950445406990593824224946816636685363585929625954442634745644683126007392056, 1103114524755001640548555873671808205895038091681120606634696969331999845790, 6900795220551940862373734336, 3566350484501023868887445216957844382095279462023214020186953835426978821531, 525164948494449116421805041713913612934056483342602240145121349090983728353, 6638158078489017454409392128, 3461234319642740822251896202472529834683641950508543676440009241163724655133, 636117700839179604858620718832286872417390350654465827892936533551518041557, 8560993074494228093090236032, 331170400618478017102911154214368288991056551391703875557578052010701538006, 636117700839179604858620718832286872417390350654465827892936533551518041557, 773447251150202691604938752, 2914117846296902625001138611527286595903082184167432590076720773850182759067, 88914301944088089141574999348394996493546404963067902156417732601144566237, 8561057047802675839486997724, 810768978625301105490322798465287380877719542227477145446194347315448434997, 1103114524755001640548555873671808205895038091681120606634696969331999845790, 7881122051629389559056630720, 568893742353754082434954719846095883898963058700663538109606505930676432219, 1125223003001074656178455529439603029082973884966680368655489058248875828864, 6146579502531825816502970880, 568893742353754082434954719846095883898963058700663538109606505930676432219, 1103114524755001640548555873671808205895038091681120606634696969331999845790, 6569103595939550533972925312, 22521640654850660807483121765227971999585199892156715151059001561632184432, 88914301944088089141574999348394996493546404963067902156417732601144566237, 7060778205646099286410059456, 422702473380030117105032343267479080586854705180475376586240402837292640315, 1103114524755001640548555873671808205895038091681120606634696969331999845790, 28177669050380407584568432, 1460747256384641514048835712397190001700501181065989006594903943663051488103, 1103114524755001640548555873671808205895038091681120606634696969331999845790, 6911515047808287178092879104], z=1979779893587478003332197864573233970979232184999964041072730496349433034249, alpha=2641897283973523646622478259560261871569732741497555765101863383056126168617, prime=3618502788666131213697322783095070105623107215331596699973092056135872020481 ) => ( factHash=5C470A71F87EC7C6B83D81A7A6951337F441BAB68A4C2607BCB1EC10B84C565C, memoryHash=6956745510180786379360541589845535115058585205988485674423965847766559301095, prod=3112336154918227475414226865374149347920124361127032095603595250316182103778 )
{"FactRegistry.sol":{"content":"/*\n  Copyright 2019-2022 StarkWare Industries Ltd.\n\n  Licensed under the Apache License, Version 2.0 (the \"License\").\n  You may not use this file except in compliance with the License.\n  You may obtain a copy of the License at\n\n  https://www.starkware.co/open-source-license/\n\n  Unless required by applicable law or agreed to in writing,\n  software distributed under the License is distributed on an \"AS IS\" BASIS,\n  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n  See the License for the specific language governing permissions\n  and limitations under the License.\n*/\n// SPDX-License-Identifier: Apache-2.0.\npragma solidity ^0.6.12;\n\nimport \"IQueryableFactRegistry.sol\";\n\ncontract FactRegistry is IQueryableFactRegistry {\n    // Mapping: fact hash -\u003e true.\n    mapping(bytes32 =\u003e bool) private verifiedFact;\n\n    // Indicates whether the Fact Registry has at least one fact registered.\n    bool anyFactRegistered = false;\n\n    /*\n      Checks if a fact has been verified.\n    */\n    function isValid(bytes32 fact) external view override returns (bool) {\n        return _factCheck(fact);\n    }\n\n    /*\n      This is an internal method to check if the fact is already registered.\n      In current implementation of FactRegistry it\u0027s identical to isValid().\n      But the check is against the local fact registry,\n      So for a derived referral fact registry, it\u0027s not the same.\n    */\n    function _factCheck(bytes32 fact) internal view returns (bool) {\n        return verifiedFact[fact];\n    }\n\n    function registerFact(bytes32 factHash) internal {\n        // This function stores the fact hash in the mapping.\n        verifiedFact[factHash] = true;\n\n        // Mark first time off.\n        if (!anyFactRegistered) {\n            anyFactRegistered = true;\n        }\n    }\n\n    /*\n      Indicates whether at least one fact was registered.\n    */\n    function hasRegisteredFact() external view override returns (bool) {\n        return anyFactRegistered;\n    }\n}\n"},"IFactRegistry.sol":{"content":"/*\n  Copyright 2019-2022 StarkWare Industries Ltd.\n\n  Licensed under the Apache License, Version 2.0 (the \"License\").\n  You may not use this file except in compliance with the License.\n  You may obtain a copy of the License at\n\n  https://www.starkware.co/open-source-license/\n\n  Unless required by applicable law or agreed to in writing,\n  software distributed under the License is distributed on an \"AS IS\" BASIS,\n  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n  See the License for the specific language governing permissions\n  and limitations under the License.\n*/\n// SPDX-License-Identifier: Apache-2.0.\npragma solidity ^0.6.12;\n\n/*\n  The Fact Registry design pattern is a way to separate cryptographic verification from the\n  business logic of the contract flow.\n\n  A fact registry holds a hash table of verified \"facts\" which are represented by a hash of claims\n  that the registry hash check and found valid. This table may be queried by accessing the\n  isValid() function of the registry with a given hash.\n\n  In addition, each fact registry exposes a registry specific function for submitting new claims\n  together with their proofs. The information submitted varies from one registry to the other\n  depending of the type of fact requiring verification.\n\n  For further reading on the Fact Registry design pattern see this\n  `StarkWare blog post \u003chttps://medium.com/starkware/the-fact-registry-a64aafb598b6\u003e`_.\n*/\ninterface IFactRegistry {\n    /*\n      Returns true if the given fact was previously registered in the contract.\n    */\n    function isValid(bytes32 fact) external view returns (bool);\n}\n"},"IQueryableFactRegistry.sol":{"content":"/*\n  Copyright 2019-2022 StarkWare Industries Ltd.\n\n  Licensed under the Apache License, Version 2.0 (the \"License\").\n  You may not use this file except in compliance with the License.\n  You may obtain a copy of the License at\n\n  https://www.starkware.co/open-source-license/\n\n  Unless required by applicable law or agreed to in writing,\n  software distributed under the License is distributed on an \"AS IS\" BASIS,\n  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n  See the License for the specific language governing permissions\n  and limitations under the License.\n*/\n// SPDX-License-Identifier: Apache-2.0.\npragma solidity ^0.6.12;\n\nimport \"IFactRegistry.sol\";\n\n/*\n  Extends the IFactRegistry interface with a query method that indicates\n  whether the fact registry has successfully registered any fact or is still empty of such facts.\n*/\ninterface IQueryableFactRegistry is IFactRegistry {\n    /*\n      Returns true if at least one fact has been registered.\n    */\n    function hasRegisteredFact() external view returns (bool);\n}\n"},"MemoryPageFactRegistry.sol":{"content":"/*\n  Copyright 2019-2022 StarkWare Industries Ltd.\n\n  Licensed under the Apache License, Version 2.0 (the \"License\").\n  You may not use this file except in compliance with the License.\n  You may obtain a copy of the License at\n\n  https://www.starkware.co/open-source-license/\n\n  Unless required by applicable law or agreed to in writing,\n  software distributed under the License is distributed on an \"AS IS\" BASIS,\n  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n  See the License for the specific language governing permissions\n  and limitations under the License.\n*/\n// SPDX-License-Identifier: Apache-2.0.\npragma solidity ^0.6.12;\n\nimport \"FactRegistry.sol\";\n\ncontract MemoryPageFactRegistryConstants {\n    // A page based on a list of pairs (address, value).\n    // In this case, memoryHash = hash(address, value, address, value, address, value, ...).\n    uint256 internal constant REGULAR_PAGE = 0;\n    // A page based on adjacent memory cells, starting from a given address.\n    // In this case, memoryHash = hash(value, value, value, ...).\n    uint256 internal constant CONTINUOUS_PAGE = 1;\n}\n\n/*\n  A fact registry for the claim:\n    I know n pairs (addr, value) for which the hash of the pairs is memoryHash, and the cumulative\n    product: \\prod_i( z - (addr_i + alpha * value_i) ) is prod.\n  The exact format of the hash depends on the type of the page\n  (see MemoryPageFactRegistryConstants).\n  The fact consists of (pageType, prime, n, z, alpha, prod, memoryHash, address).\n  Note that address is only available for CONTINUOUS_PAGE, and otherwise it is 0.\n*/\ncontract MemoryPageFactRegistry is FactRegistry, MemoryPageFactRegistryConstants {\n    event LogMemoryPageFactRegular(bytes32 factHash, uint256 memoryHash, uint256 prod);\n    event LogMemoryPageFactContinuous(bytes32 factHash, uint256 memoryHash, uint256 prod);\n\n    /*\n      Registers a fact based of the given memory (address, value) pairs (REGULAR_PAGE).\n    */\n    function registerRegularMemoryPage(\n        uint256[] calldata memoryPairs,\n        uint256 z,\n        uint256 alpha,\n        uint256 prime\n    )\n        external\n        returns (\n            bytes32 factHash,\n            uint256 memoryHash,\n            uint256 prod\n        )\n    {\n        require(memoryPairs.length \u003c 2**20, \"Too many memory values.\");\n        require(memoryPairs.length % 2 == 0, \"Size of memoryPairs must be even.\");\n        require(z \u003c prime, \"Invalid value of z.\");\n        require(alpha \u003c prime, \"Invalid value of alpha.\");\n        (factHash, memoryHash, prod) = computeFactHash(memoryPairs, z, alpha, prime);\n        emit LogMemoryPageFactRegular(factHash, memoryHash, prod);\n\n        registerFact(factHash);\n    }\n\n    function computeFactHash(\n        uint256[] memory memoryPairs,\n        uint256 z,\n        uint256 alpha,\n        uint256 prime\n    )\n        private\n        pure\n        returns (\n            bytes32 factHash,\n            uint256 memoryHash,\n            uint256 prod\n        )\n    {\n        uint256 memorySize = memoryPairs.length / 2; // NOLINT: divide-before-multiply.\n\n        prod = 1;\n\n        assembly {\n            let memoryPtr := add(memoryPairs, 0x20)\n\n            // Each value of memoryPairs is a pair: (address, value).\n            let lastPtr := add(memoryPtr, mul(memorySize, 0x40))\n            for {\n                let ptr := memoryPtr\n            } lt(ptr, lastPtr) {\n                ptr := add(ptr, 0x40)\n            } {\n                // Compute address + alpha * value.\n                let address_value_lin_comb := addmod(\n                    // address=\n                    mload(ptr),\n                    mulmod(\n                        // value=\n                        mload(add(ptr, 0x20)),\n                        alpha,\n                        prime\n                    ),\n                    prime\n                )\n                prod := mulmod(prod, add(z, sub(prime, address_value_lin_comb)), prime)\n            }\n\n            memoryHash := keccak256(\n                memoryPtr,\n                mul(\n                    // 0x20 * 2.\n                    0x40,\n                    memorySize\n                )\n            )\n        }\n\n        factHash = keccak256(\n            abi.encodePacked(\n                REGULAR_PAGE,\n                prime,\n                memorySize,\n                z,\n                alpha,\n                prod,\n                memoryHash,\n                uint256(0)\n            )\n        );\n    }\n\n    /*\n      Registers a fact based on the given values, assuming continuous addresses.\n      values should be [value at startAddr, value at (startAddr + 1), ...].\n    */\n    function registerContinuousMemoryPage(\n        // NOLINT: external-function.\n        uint256 startAddr,\n        uint256[] memory values,\n        uint256 z,\n        uint256 alpha,\n        uint256 prime\n    )\n        public\n        returns (\n            bytes32 factHash,\n            uint256 memoryHash,\n            uint256 prod\n        )\n    {\n        require(values.length \u003c 2**20, \"Too many memory values.\");\n        require(prime \u003c 2**254, \"prime is too big for the optimizations in this function.\");\n        require(z \u003c prime, \"Invalid value of z.\");\n        require(alpha \u003c prime, \"Invalid value of alpha.\");\n        require(startAddr \u003c 2**64 \u0026\u0026 startAddr \u003c prime, \"Invalid value of startAddr.\");\n\n        uint256 nValues = values.length;\n\n        assembly {\n            // Initialize prod to 1.\n            prod := 1\n            // Initialize valuesPtr to point to the first value in the array.\n            let valuesPtr := add(values, 0x20)\n\n            let minus_z := mod(sub(prime, z), prime)\n\n            // Start by processing full batches of 8 cells, addr represents the last address in each\n            // batch.\n            let addr := add(startAddr, 7)\n            let lastAddr := add(startAddr, nValues)\n            for {\n\n            } lt(addr, lastAddr) {\n                addr := add(addr, 8)\n            } {\n                // Compute the product of (lin_comb - z) instead of (z - lin_comb), since we\u0027re\n                // doing an even number of iterations, the result is the same.\n                prod := mulmod(\n                    prod,\n                    mulmod(\n                        add(add(sub(addr, 7), mulmod(mload(valuesPtr), alpha, prime)), minus_z),\n                        add(\n                            add(sub(addr, 6), mulmod(mload(add(valuesPtr, 0x20)), alpha, prime)),\n                            minus_z\n                        ),\n                        prime\n                    ),\n                    prime\n                )\n\n                prod := mulmod(\n                    prod,\n                    mulmod(\n                        add(\n                            add(sub(addr, 5), mulmod(mload(add(valuesPtr, 0x40)), alpha, prime)),\n                            minus_z\n                        ),\n                        add(\n                            add(sub(addr, 4), mulmod(mload(add(valuesPtr, 0x60)), alpha, prime)),\n                            minus_z\n                        ),\n                        prime\n                    ),\n                    prime\n                )\n\n                prod := mulmod(\n                    prod,\n                    mulmod(\n                        add(\n                            add(sub(addr, 3), mulmod(mload(add(valuesPtr, 0x80)), alpha, prime)),\n                            minus_z\n                        ),\n                        add(\n                            add(sub(addr, 2), mulmod(mload(add(valuesPtr, 0xa0)), alpha, prime)),\n                            minus_z\n                        ),\n                        prime\n                    ),\n                    prime\n                )\n\n                prod := mulmod(\n                    prod,\n                    mulmod(\n                        add(\n                            add(sub(addr, 1), mulmod(mload(add(valuesPtr, 0xc0)), alpha, prime)),\n                            minus_z\n                        ),\n                        add(add(addr, mulmod(mload(add(valuesPtr, 0xe0)), alpha, prime)), minus_z),\n                        prime\n                    ),\n                    prime\n                )\n\n                valuesPtr := add(valuesPtr, 0x100)\n            }\n\n            // Handle leftover.\n            // Translate addr to the beginning of the last incomplete batch.\n            addr := sub(addr, 7)\n            for {\n\n            } lt(addr, lastAddr) {\n                addr := add(addr, 1)\n            } {\n                let address_value_lin_comb := addmod(\n                    addr,\n                    mulmod(mload(valuesPtr), alpha, prime),\n                    prime\n                )\n                prod := mulmod(prod, add(z, sub(prime, address_value_lin_comb)), prime)\n                valuesPtr := add(valuesPtr, 0x20)\n            }\n\n            memoryHash := keccak256(add(values, 0x20), mul(0x20, nValues))\n        }\n\n        factHash = keccak256(\n            abi.encodePacked(CONTINUOUS_PAGE, prime, nValues, z, alpha, prod, memoryHash, startAddr)\n        );\n\n        emit LogMemoryPageFactContinuous(factHash, memoryHash, prod);\n\n        registerFact(factHash);\n    }\n}\n"}}