Commit eabb5dd8 authored by Kelvin Fichter's avatar Kelvin Fichter

Lots of library cleanup

parent aa67fe22
......@@ -3,8 +3,9 @@ pragma solidity ^0.7.0;
pragma experimental ABIEncoderV2;
/* Library Imports */
import { Lib_OVMCodec } from "../../libraries/codec/Lib_OVMCodec.sol";
import { Lib_AddressResolver } from "../../libraries/resolver/Lib_AddressResolver.sol";
import { Lib_EthMerkleTrie } from "../../libraries/trie/Lib_EthMerkleTrie.sol";
import { Lib_SecureMerkleTrie } from "../../libraries/trie/Lib_SecureMerkleTrie.sol";
import { Lib_BytesUtils } from "../../libraries/utils/Lib_BytesUtils.sol";
/* Interface Imports */
......@@ -221,11 +222,27 @@ contract OVM_L1CrossDomainMessenger is iOVM_L1CrossDomainMessenger, OVM_BaseCros
)
);
return Lib_EthMerkleTrie.proveAccountStorageSlotValue(
0x4200000000000000000000000000000000000000,
storageKey,
bytes32(uint256(1)),
(
bool exists,
bytes memory encodedMessagePassingAccount
) = Lib_SecureMerkleTrie.get(
abi.encodePacked(0x4200000000000000000000000000000000000000),
_proof.stateTrieWitness,
_proof.stateRoot
);
require(
exists == true,
"Message passing precompile has not been initialized or invalid proof provided."
);
Lib_OVMCodec.EVMAccount memory account = Lib_OVMCodec.decodeEVMAccount(
encodedMessagePassingAccount
);
return Lib_SecureMerkleTrie.verifyInclusionProof(
abi.encodePacked(storageKey),
abi.encodePacked(uint256(1)),
_proof.storageTrieWitness,
_proof.stateRoot
);
......
......@@ -1519,10 +1519,12 @@ contract OVM_ExecutionManager is iOVM_ExecutionManager, Lib_AddressResolver {
bool _valid
)
{
// Always have to be below the maximum gas limit.
if (_gasLimit > gasMeterConfig.maxTransactionGasLimit) {
return false;
}
// Always have to be above the minumum gas limit.
if (_gasLimit < gasMeterConfig.minTransactionGasLimit) {
return false;
}
......
......@@ -111,6 +111,20 @@ contract OVM_StateManager is iOVM_StateManager {
accounts[_address] = _account;
}
/**
* Marks an account as empty.
* @param _address Address of the account to mark.
*/
function putEmptyAccount(
address _address
)
override
public
authenticated
{
accounts[_address].codeHash = EMPTY_ACCOUNT_CODE_HASH;
}
/**
* Retrieves an account from the state.
* @param _address Address of the account to retrieve.
......@@ -215,6 +229,24 @@ contract OVM_StateManager is iOVM_StateManager {
return accounts[_address].ethAddress;
}
/**
* Retrieves the storage root of an account.
* @param _address Address of the account to access.
* @return _storageRoot Corresponding storage root.
*/
function getAccountStorageRoot(
address _address
)
override
public
view
returns (
bytes32 _storageRoot
)
{
return accounts[_address].storageRoot;
}
/**
* Initializes a pending account (during CREATE or CREATE2) with the default values.
* @param _address Address of the account to initialize.
......@@ -228,7 +260,7 @@ contract OVM_StateManager is iOVM_StateManager {
{
Lib_OVMCodec.Account storage account = accounts[_address];
account.nonce = 1;
account.codeHash = keccak256(hex'80');
account.codeHash = keccak256(hex'');
account.isFresh = true;
}
......
......@@ -6,7 +6,7 @@ pragma experimental ABIEncoderV2;
import { Lib_OVMCodec } from "../../libraries/codec/Lib_OVMCodec.sol";
import { Lib_AddressResolver } from "../../libraries/resolver/Lib_AddressResolver.sol";
import { Lib_EthUtils } from "../../libraries/utils/Lib_EthUtils.sol";
import { Lib_EthMerkleTrie } from "../../libraries/trie/Lib_EthMerkleTrie.sol";
import { Lib_SecureMerkleTrie } from "../../libraries/trie/Lib_SecureMerkleTrie.sol";
/* Interface Imports */
import { iOVM_StateTransitioner } from "../../iOVM/verification/iOVM_StateTransitioner.sol";
......@@ -14,6 +14,9 @@ import { iOVM_ExecutionManager } from "../../iOVM/execution/iOVM_ExecutionManage
import { iOVM_StateManager } from "../../iOVM/execution/iOVM_StateManager.sol";
import { iOVM_StateManagerFactory } from "../../iOVM/execution/iOVM_StateManagerFactory.sol";
/* Logging Imports */
import { console } from "@nomiclabs/buidler/console.sol";
/**
* @title OVM_StateTransitioner
*/
......@@ -158,73 +161,115 @@ contract OVM_StateTransitioner is iOVM_StateTransitioner, Lib_AddressResolver {
*/
function proveContractState(
address _ovmContractAddress,
Lib_OVMCodec.Account memory _account,
address _ethContractAddress,
Lib_OVMCodec.EVMAccount memory _account,
bytes memory _stateTrieWitness
)
override
public
onlyDuringPhase(TransitionPhase.PRE_EXECUTION)
{
// Exit quickly to avoid unnecessary work.
require(
ovmStateManager.hasAccount(_ovmContractAddress) == false,
"Account state has already been proven"
);
require(
_account.codeHash == Lib_EthUtils.getCodeHash(_account.ethAddress),
_account.codeHash == Lib_EthUtils.getCodeHash(_ethContractAddress),
"Invalid code hash provided."
);
require(
Lib_EthMerkleTrie.proveAccountState(
_ovmContractAddress,
Lib_OVMCodec.EVMAccount({
balance: _account.balance,
nonce: _account.nonce,
storageRoot: _account.storageRoot,
codeHash: _account.codeHash
}),
Lib_SecureMerkleTrie.verifyInclusionProof(
abi.encodePacked(_ovmContractAddress),
Lib_OVMCodec.encodeEVMAccount(_account),
_stateTrieWitness,
preStateRoot
),
"Invalid account state provided."
"Account state is not correct or invalid inclusion proof provided."
);
ovmStateManager.putAccount(
_ovmContractAddress,
_account
Lib_OVMCodec.Account({
nonce: _account.nonce,
balance: _account.balance,
storageRoot: _account.storageRoot,
codeHash: _account.codeHash,
ethAddress: _ethContractAddress,
isFresh: false
})
);
}
/**
* Allows a user to prove that an account does *not* exist in the state.
* @param _ovmContractAddress Address of the contract on the OVM.
* @param _stateTrieWitness Proof of the (empty) account state.
*/
function proveEmptyContractState(
address _ovmContractAddress,
bytes memory _stateTrieWitness
)
override
public
onlyDuringPhase(TransitionPhase.PRE_EXECUTION)
{
// Exit quickly to avoid unnecessary work.
require(
ovmStateManager.hasEmptyAccount(_ovmContractAddress) == false,
"Account state has already been proven."
);
require(
Lib_SecureMerkleTrie.verifyExclusionProof(
abi.encodePacked(_ovmContractAddress),
_stateTrieWitness,
preStateRoot
),
"Account is not empty or invalid inclusion proof provided."
);
ovmStateManager.putEmptyAccount(_ovmContractAddress);
}
/**
* Allows a user to prove the initial state of a contract storage slot.
* @param _ovmContractAddress Address of the contract on the OVM.
* @param _key Claimed account slot key.
* @param _value Claimed account slot value.
* @param _stateTrieWitness Proof of the account state.
* @param _storageTrieWitness Proof of the storage slot.
*/
function proveStorageSlot(
address _ovmContractAddress,
bytes32 _key,
bytes32 _value,
bytes memory _stateTrieWitness,
bytes memory _storageTrieWitness
)
override
public
onlyDuringPhase(TransitionPhase.PRE_EXECUTION)
{
// Exit quickly to avoid unnecessary work.
require(
ovmStateManager.hasContractStorage(_ovmContractAddress, _key) == false,
"Storage slot has already been proven."
);
require(
ovmStateManager.hasAccount(_ovmContractAddress) == true,
"Contract must be verified before proving a storage slot."
);
require(
Lib_EthMerkleTrie.proveAccountStorageSlotValue(
_ovmContractAddress,
_key,
_value,
_stateTrieWitness,
Lib_SecureMerkleTrie.verifyInclusionProof(
abi.encodePacked(_key),
abi.encodePacked(_value),
_storageTrieWitness,
preStateRoot
ovmStateManager.getAccountStorageRoot(_ovmContractAddress)
),
"Invalid account state provided."
"Storage slot is invalid or invalid inclusion proof provided."
);
ovmStateManager.putContractStorage(
......@@ -254,9 +299,14 @@ contract OVM_StateTransitioner is iOVM_StateTransitioner, Lib_AddressResolver {
"Invalid transaction provided."
);
// TODO: Set state manager for EM here.
// We call `setExecutionManager` right before `run` (and not earlier) just in case the
// OVM_ExecutionManager address was updated between the time when this contract was created
// and when `applyTransaction` was called.
ovmStateManager.setExecutionManager(resolve("OVM_ExecutionManager"));
// `run` always succeeds *unless* the user hasn't provided enough gas to `applyTransaction`
// or an INVALID_STATE_ACCESS flag was triggered. Either way, we won't get beyond this line
// if that's the case.
ovmExecutionManager.run(_transaction, address(ovmStateManager));
phase = TransitionPhase.POST_EXECUTION;
......@@ -275,7 +325,7 @@ contract OVM_StateTransitioner is iOVM_StateTransitioner, Lib_AddressResolver {
*/
function commitContractState(
address _ovmContractAddress,
Lib_OVMCodec.Account memory _account,
Lib_OVMCodec.EVMAccount memory _account,
bytes memory _stateTrieWitness
)
override
......@@ -284,17 +334,12 @@ contract OVM_StateTransitioner is iOVM_StateTransitioner, Lib_AddressResolver {
{
require(
ovmStateManager.commitAccount(_ovmContractAddress) == true,
"Cannot commit an account that has not been changed."
"Account was not changed or has already been committed."
);
postStateRoot = Lib_EthMerkleTrie.updateAccountState(
_ovmContractAddress,
Lib_OVMCodec.EVMAccount({
balance: _account.balance,
nonce: _account.nonce,
storageRoot: _account.storageRoot,
codeHash: _account.codeHash
}),
postStateRoot = Lib_SecureMerkleTrie.update(
abi.encodePacked(_ovmContractAddress),
Lib_OVMCodec.encodeEVMAccount(_account),
_stateTrieWitness,
postStateRoot
);
......@@ -321,15 +366,24 @@ contract OVM_StateTransitioner is iOVM_StateTransitioner, Lib_AddressResolver {
{
require(
ovmStateManager.commitContractStorage(_ovmContractAddress, _key) == true,
"Cannot commit a storage slot that has not been changed."
"Storage slot was not changed or has already been committed."
);
postStateRoot = Lib_EthMerkleTrie.updateAccountStorageSlotValue(
_ovmContractAddress,
_key,
_value,
_stateTrieWitness,
Lib_OVMCodec.EVMAccount memory account = Lib_OVMCodec.toEVMAccount(
ovmStateManager.getAccount(_ovmContractAddress)
);
account.storageRoot = Lib_SecureMerkleTrie.update(
abi.encodePacked(_key),
abi.encodePacked(_value),
_storageTrieWitness,
account.storageRoot
);
postStateRoot = Lib_SecureMerkleTrie.update(
abi.encodePacked(_ovmContractAddress),
Lib_OVMCodec.encodeEVMAccount(account),
_stateTrieWitness,
postStateRoot
);
}
......
......@@ -34,12 +34,14 @@ interface iOVM_StateManager {
************************************/
function putAccount(address _address, Lib_OVMCodec.Account memory _account) external;
function putEmptyAccount(address _address) external;
function getAccount(address _address) external view returns (Lib_OVMCodec.Account memory _account);
function hasAccount(address _address) external view returns (bool _exists);
function hasEmptyAccount(address _address) external view returns (bool _exists);
function setAccountNonce(address _address, uint256 _nonce) external;
function getAccountNonce(address _address) external view returns (uint256 _nonce);
function getAccountEthAddress(address _address) external view returns (address _ethAddress);
function getAccountStorageRoot(address _address) external view returns (bytes32 _storageRoot);
function initPendingAccount(address _address) external;
function commitPendingAccount(address _address, address _ethAddress, bytes32 _codeHash) external;
function testAndSetAccountLoaded(address _address) external returns (bool _wasAccountAlreadyLoaded);
......
......@@ -25,7 +25,13 @@ interface iOVM_StateTransitioner {
function proveContractState(
address _ovmContractAddress,
Lib_OVMCodec.Account calldata _account,
address _ethContractAddress,
Lib_OVMCodec.EVMAccount calldata _account,
bytes calldata _stateTrieWitness
) external;
function proveEmptyContractState(
address _ovmContractAddress,
bytes calldata _stateTrieWitness
) external;
......@@ -33,7 +39,6 @@ interface iOVM_StateTransitioner {
address _ovmContractAddress,
bytes32 _key,
bytes32 _value,
bytes calldata _stateTrieWitness,
bytes calldata _storageTrieWitness
) external;
......@@ -53,7 +58,7 @@ interface iOVM_StateTransitioner {
function commitContractState(
address _ovmContractAddress,
Lib_OVMCodec.Account calldata _account,
Lib_OVMCodec.EVMAccount calldata _account,
bytes calldata _stateTrieWitness
) external;
......
......@@ -4,12 +4,24 @@ pragma experimental ABIEncoderV2;
/* Library Imports */
import { Lib_RLPReader } from "../rlp/Lib_RLPReader.sol";
import { Lib_RLPWriter } from "../rlp/Lib_RLPWriter.sol";
/**
* @title Lib_OVMCodec
*/
library Lib_OVMCodec {
/*************
* Constants *
*************/
bytes constant internal RLP_NULL_BYTES = hex'80';
bytes constant internal NULL_BYTES = bytes('');
bytes32 constant internal NULL_BYTES32 = bytes32('');
bytes32 constant internal KECCAK256_RLP_NULL_BYTES = keccak256(RLP_NULL_BYTES);
bytes32 constant internal KECCAK256_NULL_BYTES = keccak256(NULL_BYTES);
/*********
* Enums *
*********/
......@@ -100,13 +112,13 @@ library Lib_OVMCodec {
EOATransaction memory _decoded
)
{
Lib_RLPReader.RLPItem[] memory decoded = Lib_RLPReader.toList(Lib_RLPReader.toRlpItem(_transaction));
Lib_RLPReader.RLPItem[] memory decoded = Lib_RLPReader.readList(_transaction);
return EOATransaction({
nonce: Lib_RLPReader.toUint(decoded[0]),
gasLimit: Lib_RLPReader.toUint(decoded[2]),
target: Lib_RLPReader.toAddress(decoded[3]),
data: Lib_RLPReader.toBytes(decoded[5])
nonce: Lib_RLPReader.readUint256(decoded[0]),
gasLimit: Lib_RLPReader.readUint256(decoded[2]),
target: Lib_RLPReader.readAddress(decoded[3]),
data: Lib_RLPReader.readBytes(decoded[5])
});
}
......@@ -151,4 +163,77 @@ library Lib_OVMCodec {
{
return keccak256(encodeTransaction(_transaction));
}
/**
* Converts an OVM account to an EVM account.
* @param _in OVM account to convert.
* @return _out Converted EVM account.
*/
function toEVMAccount(
Account memory _in
)
internal
pure
returns (
EVMAccount memory _out
)
{
return EVMAccount({
nonce: _in.nonce,
balance: _in.balance,
storageRoot: _in.storageRoot,
codeHash: _in.codeHash
});
}
/**
* @notice RLP-encodes an account state struct.
* @param _account Account state struct.
* @return _encoded RLP-encoded account state.
*/
function encodeEVMAccount(
EVMAccount memory _account
)
internal
pure
returns (
bytes memory _encoded
)
{
bytes[] memory raw = new bytes[](4);
// Unfortunately we can't create this array outright because
// RLPWriter.encodeList will reject fixed-size arrays. Assigning
// index-by-index circumvents this issue.
raw[0] = Lib_RLPWriter.encodeUint(_account.nonce);
raw[1] = Lib_RLPWriter.encodeUint(_account.balance);
raw[2] = _account.storageRoot == 0 ? RLP_NULL_BYTES : Lib_RLPWriter.encodeBytes(abi.encodePacked(_account.storageRoot));
raw[3] = _account.codeHash == 0 ? RLP_NULL_BYTES : Lib_RLPWriter.encodeBytes(abi.encodePacked(_account.codeHash));
return Lib_RLPWriter.encodeList(raw);
}
/**
* @notice Decodes an RLP-encoded account state into a useful struct.
* @param _encoded RLP-encoded account state.
* @return _account Account state struct.
*/
function decodeEVMAccount(
bytes memory _encoded
)
internal
pure
returns (
EVMAccount memory _account
)
{
Lib_RLPReader.RLPItem[] memory accountState = Lib_RLPReader.readList(_encoded);
return EVMAccount({
nonce: Lib_RLPReader.readUint256(accountState[0]),
balance: Lib_RLPReader.readUint256(accountState[1]),
storageRoot: Lib_RLPReader.readBytes32(accountState[2]),
codeHash: Lib_RLPReader.readBytes32(accountState[3])
});
}
}
// SPDX-License-Identifier: UNLICENSED
pragma solidity ^0.7.0;
pragma experimental ABIEncoderV2;
/**
* @title RLPReader
* @author Hamdi Allam hamdi.allam97@gmail.com
* @title Lib_RLPReader
* @dev Adapted from "RLPReader" by Hamdi Allam (hamdi.allam97@gmail.com).
*/
library Lib_RLPReader {
/*
* Data Structures
*/
struct RLPItem {
uint len;
uint memPtr;
}
/*************
* Constants *
*************/
uint256 constant internal MAX_LIST_LENGTH = 32;
/*
* Contract Constants
*/
uint8 constant private STRING_SHORT_START = 0x80;
uint8 constant private STRING_LONG_START = 0xb8;
uint8 constant private LIST_SHORT_START = 0xc0;
uint8 constant private LIST_LONG_START = 0xf8;
uint8 constant private WORD_SIZE = 32;
/*********
* Enums *
*********/
/*
* Public Functions
*/
enum RLPItemType {
DATA_ITEM,
LIST_ITEM
}
/***********
* Structs *
***********/
struct RLPItem {
uint256 length;
uint256 ptr;
}
/**********************
* Internal Functions *
**********************/
/**
* @param item RLP encoded bytes
* Converts bytes to a reference to memory position and length.
* @param _in Input bytes to convert.
* @return Output memory reference.
*/
function toRlpItem(
bytes memory item
function toRLPItem(
bytes memory _in
)
internal
pure
returns (RLPItem memory)
returns (
RLPItem memory
)
{
uint memPtr;
uint256 ptr;
assembly {
memPtr := add(item, 0x20)
ptr := add(_in, 32)
}
return RLPItem(item.length, memPtr);
return RLPItem({
length: _in.length,
ptr: ptr
});
}
/**
* @param item RLP encoded bytes
* Reads an RLP list value into a list of RLP items.
* @param _in RLP list value.
* @return Decoded RLP list items.
*/
function rlpLen(
RLPItem memory item
function readList(
RLPItem memory _in
)
internal
pure
returns (uint)
returns (
RLPItem[] memory
)
{
return item.len;
(
uint256 listOffset,
uint256 listLength,
RLPItemType itemType
) = _decodeLength(_in);
require(
itemType == RLPItemType.LIST_ITEM,
"Invalid RLP list value."
);
// Solidity in-memory arrays can't be increased in size, but *can* be decreased in size by
// writing to the length. Since we can't know the number of RLP items without looping over
// the entire input, we'd have to loop twice to accurately size this array. It's easier to
// simply set a reasonable maximum list length and decrease the size before we finish.
RLPItem[] memory out = new RLPItem[](MAX_LIST_LENGTH);
uint256 itemCount = 0;
uint256 offset = listOffset;
while (offset < _in.length) {
require(
itemCount < MAX_LIST_LENGTH,
"Provided RLP list exceeds max list length."
);
(
uint256 itemOffset,
uint256 itemLength,
) = _decodeLength(RLPItem({
length: _in.length - offset,
ptr: _in.ptr + offset
}));
out[itemCount] = RLPItem({
length: itemLength + itemOffset,
ptr: _in.ptr + offset
});
itemCount += 1;
offset += itemOffset + itemLength;
}
// Decrease the array size to match the actual item count.
assembly {
mstore(out, itemCount)
}
return out;
}
/**
* @param item RLP encoded bytes
* Reads an RLP list value into a list of RLP items.
* @param _in RLP list value.
* @return Decoded RLP list items.
*/
function payloadLen(
RLPItem memory item
function readList(
bytes memory _in
)
internal
pure
returns (uint)
returns (
RLPItem[] memory
)
{
return item.len - _payloadOffset(item.memPtr);
return readList(
toRLPItem(_in)
);
}
/**
* @param item RLP encoded list in bytes
* Reads an RLP bytes value into bytes.
* @param _in RLP bytes value.
* @return Decoded bytes.
*/
function toList(
RLPItem memory item
function readBytes(
RLPItem memory _in
)
internal
pure
returns (RLPItem[] memory result)
returns (
bytes memory
)
{
require(isList(item));
uint items = numItems(item);
result = new RLPItem[](items);
uint memPtr = item.memPtr + _payloadOffset(item.memPtr);
uint dataLen;
for (uint i = 0; i < items; i++) {
dataLen = _itemLength(memPtr);
result[i] = RLPItem(dataLen, memPtr);
memPtr = memPtr + dataLen;
}
(
uint256 itemOffset,
uint256 itemLength,
RLPItemType itemType
) = _decodeLength(_in);
require(
itemType == RLPItemType.DATA_ITEM,
"Invalid RLP bytes value."
);
return _copy(_in.ptr, itemOffset, itemLength);
}
// @return indicator whether encoded payload is a list. negate this function call for isData.
function isList(
RLPItem memory item
/**
* Reads an RLP bytes value into bytes.
* @param _in RLP bytes value.
* @return Decoded bytes.
*/
function readBytes(
bytes memory _in
)
internal
pure
returns (bool)
returns (
bytes memory
)
{
if (item.len == 0) return false;
uint8 byte0;
uint memPtr = item.memPtr;
assembly {
byte0 := byte(0, mload(memPtr))
}
if (byte0 < LIST_SHORT_START)
return false;
return true;
return readBytes(
toRLPItem(_in)
);
}
/** RLPItem conversions into data types **/
// @returns raw rlp encoding in bytes
function toRlpBytes(
RLPItem memory item
/**
* Reads an RLP string value into a string.
* @param _in RLP string value.
* @return Decoded string.
*/
function readString(
RLPItem memory _in
)
internal
pure
returns (bytes memory)
returns (
string memory
)
{
bytes memory result = new bytes(item.len);
if (result.length == 0) return result;
uint ptr;
assembly {
ptr := add(0x20, result)
}
return string(readBytes(_in));
}
copy(item.memPtr, ptr, item.len);
return result;
/**
* Reads an RLP string value into a string.
* @param _in RLP string value.
* @return Decoded string.
*/
function readString(
bytes memory _in
)
internal
pure
returns (
string memory
)
{
return readString(
toRLPItem(_in)
);
}
// any non-zero byte is considered true
function toBoolean(
RLPItem memory item
/**
* Reads an RLP bytes32 value into a bytes32.
* @param _in RLP bytes32 value.
* @return Decoded bytes32.
*/
function readBytes32(
RLPItem memory _in
)
internal
pure
returns (bool)
returns (
bytes32
)
{
require(item.len == 1);
uint result;
uint memPtr = item.memPtr;
require(
_in.length <= 33,
"Invalid RLP bytes32 value."
);
(
uint256 itemOffset,
uint256 itemLength,
RLPItemType itemType
) = _decodeLength(_in);
require(
itemType == RLPItemType.DATA_ITEM,
"Invalid RLP bytes32 value."
);
uint256 ptr = _in.ptr + itemOffset;
bytes32 out;
assembly {
result := byte(0, mload(memPtr))
out := mload(ptr)
// Shift the bytes over to match the item size.
if lt(itemLength, 32) {
out := div(out, exp(256, sub(32, itemLength)))
}
}
return result == 0 ? false : true;
return out;
}
function toAddress(
RLPItem memory item
/**
* Reads an RLP bytes32 value into a bytes32.
* @param _in RLP bytes32 value.
* @return Decoded bytes32.
*/
function readBytes32(
bytes memory _in
)
internal
pure
returns (address)
returns (
bytes32
)
{
// 1 byte for the length prefix
require(item.len == 21);
return address(toUint(item));
return readBytes32(
toRLPItem(_in)
);
}
function toUint(
RLPItem memory item
/**
* Reads an RLP uint256 value into a uint256.
* @param _in RLP uint256 value.
* @return Decoded uint256.
*/
function readUint256(
RLPItem memory _in
)
internal
pure
returns (uint)
returns (
uint256
)
{
require(item.len > 0 && item.len <= 33);
uint offset = _payloadOffset(item.memPtr);
uint len = item.len - offset;
uint result;
uint memPtr = item.memPtr + offset;
assembly {
result := mload(memPtr)
// shfit to the correct location if neccesary
if lt(len, 32) {
result := div(result, exp(256, sub(32, len)))
}
}
return uint256(readBytes32(_in));
}
return result;
/**
* Reads an RLP uint256 value into a uint256.
* @param _in RLP uint256 value.
* @return Decoded uint256.
*/
function readUint256(
bytes memory _in
)
internal
pure
returns (
uint256
)
{
return readUint256(
toRLPItem(_in)
);
}
// enforces 32 byte length
function toUintStrict(
RLPItem memory item
/**
* Reads an RLP bool value into a bool.
* @param _in RLP bool value.
* @return Decoded bool.
*/
function readBool(
RLPItem memory _in
)
internal
pure
returns (uint)
returns (
bool
)
{
// one byte prefix
require(item.len == 33);
require(
_in.length == 1,
"Invalid RLP boolean value."
);
uint result;
uint memPtr = item.memPtr + 1;
uint256 ptr = _in.ptr;
uint256 out;
assembly {
result := mload(memPtr)
out := byte(0, mload(ptr))
}
return result;
return out != 0;
}
function toBytes(
RLPItem memory item
/**
* Reads an RLP bool value into a bool.
* @param _in RLP bool value.
* @return Decoded bool.
*/
function readBool(
bytes memory _in
)
internal
pure
returns (bytes memory)
returns (
bool
)
{
require(item.len > 0);
uint offset = _payloadOffset(item.memPtr);
uint len = item.len - offset; // data length
bytes memory result = new bytes(len);
return readBool(
toRLPItem(_in)
);
}
uint destPtr;
assembly {
destPtr := add(0x20, result)
}
/**
* Reads an RLP address value into a address.
* @param _in RLP address value.
* @return Decoded address.
*/
function readAddress(
RLPItem memory _in
)
internal
pure
returns (
address
)
{
require(
_in.length == 21,
"Invalid RLP address value."
);
copy(item.memPtr + offset, destPtr, len);
return result;
return address(readUint256(_in));
}
/*
* Private Functions
/**
* Reads an RLP address value into a address.
* @param _in RLP address value.
* @return Decoded address.
*/
// @return number of payload items inside an encoded list.
function numItems(
RLPItem memory item
function readAddress(
bytes memory _in
)
private
internal
pure
returns (uint)
returns (
address
)
{
if (item.len == 0) return 0;
uint count = 0;
uint currPtr = item.memPtr + _payloadOffset(item.memPtr);
uint endPtr = item.memPtr + item.len;
while (currPtr < endPtr) {
currPtr = currPtr + _itemLength(currPtr); // skip over an item
count++;
}
return readAddress(
toRLPItem(_in)
);
}
return count;
/**
* Reads the raw bytes of an RLP item.
* @param _in RLP item to read.
* @return Raw RLP bytes.
*/
function readRawBytes(
RLPItem memory _in
)
internal
pure
returns (
bytes memory
)
{
return _copy(_in);
}
// @return entire rlp item byte length
function _itemLength(
uint memPtr
/*********************
* Private Functions *
*********************/
/**
* Decodes the length of an RLP item.
* @param _in RLP item to decode.
* @return Offset of the encoded data.
* @return Length of the encoded data.
* @return RLP item type (LIST_ITEM or DATA_ITEM).
*/
function _decodeLength(
RLPItem memory _in
)
private
pure
returns (uint len)
returns (
uint256,
uint256,
RLPItemType
)
{
uint byte0;
require(
_in.length > 0,
"RLP item cannot be null."
);
uint256 ptr = _in.ptr;
uint256 prefix;
assembly {
byte0 := byte(0, mload(memPtr))
prefix := byte(0, mload(ptr))
}
if (byte0 < STRING_SHORT_START)
return 1;
else if (byte0 < STRING_LONG_START)
return byte0 - STRING_SHORT_START + 1;
if (prefix <= 0x7f) {
// Single byte.
return (0, 1, RLPItemType.DATA_ITEM);
} else if (prefix <= 0xb7) {
// Short string.
uint256 strLen = prefix - 0x80;
require(
_in.length > strLen,
"Invalid RLP short string."
);
else if (byte0 < LIST_SHORT_START) {
return (1, strLen, RLPItemType.DATA_ITEM);
} else if (prefix <= 0xbf) {
// Long string.
uint256 lenOfStrLen = prefix - 0xb7;
require(
_in.length > lenOfStrLen,
"Invalid RLP long string length."
);
uint256 strLen;
assembly {
let byteLen := sub(byte0, 0xb7) // number of bytes the actual length is
memPtr := add(memPtr, 1) // skip over the first byte
/* 32 byte word size */
let dataLen := div(mload(memPtr), exp(256, sub(32, byteLen))) // right shifting to get the len
len := add(dataLen, add(byteLen, 1))
// Pick out the string length.
strLen := div(
mload(add(ptr, 1)),
exp(256, sub(32, lenOfStrLen))
)
}
}
else if (byte0 < LIST_LONG_START) {
return byte0 - LIST_SHORT_START + 1;
}
require(
_in.length > lenOfStrLen + strLen,
"Invalid RLP long string."
);
else {
assembly {
let byteLen := sub(byte0, 0xf7)
memPtr := add(memPtr, 1)
return (1 + lenOfStrLen, strLen, RLPItemType.DATA_ITEM);
} else if (prefix <= 0xf7) {
// Short list.
uint256 listLen = prefix - 0xc0;
let dataLen := div(mload(memPtr), exp(256, sub(32, byteLen))) // right shifting to the correct length
len := add(dataLen, add(byteLen, 1))
require(
_in.length > listLen,
"Invalid RLP short list."
);
return (1, listLen, RLPItemType.LIST_ITEM);
} else {
// Long list.
uint256 lenOfListLen = prefix - 0xf7;
require(
_in.length > lenOfListLen,
"Invalid RLP long list length."
);
uint256 listLen;
assembly {
// Pick out the list length.
listLen := div(
mload(add(ptr, 1)),
exp(256, sub(32, lenOfListLen))
)
}
require(
_in.length > lenOfListLen + listLen,
"Invalid RLP long list."
);
return (1 + lenOfListLen, listLen, RLPItemType.LIST_ITEM);
}
}
// @return number of bytes until the data
function _payloadOffset(
uint memPtr
/**
* Copies the bytes from a memory location.
* @param _src Pointer to the location to read from.
* @param _offset Offset to start reading from.
* @param _length Number of bytes to read.
* @return Copied bytes.
*/
function _copy(
uint256 _src,
uint256 _offset,
uint256 _length
)
private
pure
returns (uint)
returns (
bytes memory
)
{
uint byte0;
assembly {
byte0 := byte(0, mload(memPtr))
bytes memory out = new bytes(_length);
if (out.length == 0) {
return out;
}
if (byte0 < STRING_SHORT_START)
return 0;
else if (byte0 < STRING_LONG_START || (byte0 >= LIST_SHORT_START && byte0 < LIST_LONG_START))
return 1;
else if (byte0 < LIST_SHORT_START) // being explicit
return byte0 - (STRING_LONG_START - 1) + 1;
else
return byte0 - (LIST_LONG_START - 1) + 1;
}
/*
* @param src Pointer to source
* @param dest Pointer to destination
* @param len Amount of memory to copy from the source
*/
function copy(
uint src,
uint dest,
uint len
)
private
pure
{
if (len == 0) return;
uint256 src = _src + _offset;
uint256 dest;
assembly {
dest := add(out, 32)
}
// copy as many word sizes as possible
for (; len >= WORD_SIZE; len -= WORD_SIZE) {
// Copy over as many complete words as we can.
for (uint256 i = 0; i < _length / 32; i++) {
assembly {
mstore(dest, mload(src))
}
src += WORD_SIZE;
dest += WORD_SIZE;
src += 32;
dest += 32;
}
// left over bytes. Mask is used to remove unwanted bytes from the word
uint mask = 256 ** (WORD_SIZE - len) - 1;
// Pick out the remaining bytes.
uint256 mask = 256 ** (32 - (_length % 32)) - 1;
assembly {
let srcpart := and(mload(src), not(mask)) // zero out src
let destpart := and(mload(dest), mask) // retrieve the bytes
mstore(dest, or(destpart, srcpart))
mstore(
dest,
or(
and(mload(src), not(mask)),
and(mload(dest), mask)
)
)
}
return out;
}
/**
* Copies an RLP item into bytes.
* @param _in RLP item to copy.
* @return Copied bytes.
*/
function _copy(
RLPItem memory _in
)
private
pure
returns (
bytes memory
)
{
return _copy(_in.ptr, 0, _in.length);
}
}
\ No newline at end of file
}
// SPDX-License-Identifier: UNLICENSED
pragma solidity ^0.7.0;
pragma experimental ABIEncoderV2;
/* Library Imports */
import { Lib_SecureMerkleTrie } from "./Lib_SecureMerkleTrie.sol";
import { Lib_OVMCodec } from "../codec/Lib_OVMCodec.sol";
import { Lib_BytesUtils } from "../utils/Lib_BytesUtils.sol";
import { Lib_RLPWriter } from "../rlp/Lib_RLPWriter.sol";
import { Lib_RLPReader } from "../rlp/Lib_RLPReader.sol";
/**
* @title Lib_EthMerkleTrie
*/
library Lib_EthMerkleTrie {
/**********************
* Contract Constants *
**********************/
bytes constant private RLP_NULL_BYTES = hex'80';
bytes32 constant private BYTES32_NULL = bytes32('');
uint256 constant private UINT256_NULL = uint256(0);
/*************************************
* Internal Functions: Storage Slots *
*************************************/
/**
* @notice Verifies a proof for the value of an account storage slot.
* @param _address Address of the contract account.
* @param _key Key for the storage slot.
* @param _value Value for the storage slot.
* @param _stateTrieWitness Inclusion proof for the account state within
* the state trie.
* @param _storageTrieWitness Inclusion proof for the specific storage
* slot associated with the given key.
* @param _stateTrieRoot Known root of the state trie.
* @return `true` if the k/v pair is included, `false` otherwise.
*/
function proveAccountStorageSlotValue(
address _address,
bytes32 _key,
bytes32 _value,
bytes memory _stateTrieWitness,
bytes memory _storageTrieWitness,
bytes32 _stateTrieRoot
)
internal
view
returns (bool)
{
// Retrieve the current storage root.
Lib_OVMCodec.EVMAccount memory accountState = getAccountState(
_address,
_stateTrieWitness,
_stateTrieRoot
);
// Verify inclusion of the given k/v pair in the storage trie.
return Lib_SecureMerkleTrie.verifyInclusionProof(
abi.encodePacked(_key),
abi.encodePacked(_value),
_storageTrieWitness,
accountState.storageRoot
);
}
/**
* @notice Updates the value for a given account storage slot.
* @param _address Address of the contract account.
* @param _key Key for the storage slot.
* @param _value New value for the storage slot.
* @param _stateTrieWitness Inclusion proof for the account state within
* the state trie.
* @param _storageTrieWitness Inclusion proof for the specific storage
* slot associated with the given key.
* @param _stateTrieRoot Known root of the state trie.
* @return Root hash of the updated state trie.
*/
function updateAccountStorageSlotValue(
address _address,
bytes32 _key,
bytes32 _value,
bytes memory _stateTrieWitness,
bytes memory _storageTrieWitness,
bytes32 _stateTrieRoot
)
internal
view
returns (bytes32)
{
// Retreive the old storage root.
Lib_OVMCodec.EVMAccount memory accountState = getAccountState(
_address,
_stateTrieWitness,
_stateTrieRoot
);
// Generate a new storage root.
accountState.storageRoot = Lib_SecureMerkleTrie.update(
abi.encodePacked(_key),
abi.encodePacked(_value),
_storageTrieWitness,
accountState.storageRoot
);
// Update the state trie with the new storage root.
return setAccountState(
accountState,
_address,
_stateTrieWitness,
_stateTrieRoot
);
}
/**************************************
* Internal Functions: Account Proofs *
*************************************/
/**
* @notice Verifies a proof of the current state for a given account.
* @param _address Address of the target account.
* @param _accountState Account state object to verify.
* @param _stateTrieWitness Inclusion proof for the account state within
* the state trie.
* @param _stateTrieRoot Known root of the state trie.
* @return `true` if the given account state is valid, `false` otherwise.
*/
function proveAccountState(
address _address,
Lib_OVMCodec.EVMAccount memory _accountState,
bytes memory _stateTrieWitness,
bytes32 _stateTrieRoot
)
internal
view
returns (bool)
{
// Pull the current account state.
Lib_OVMCodec.EVMAccount memory accountState = getAccountState(
_address,
_stateTrieWitness,
_stateTrieRoot
);
return (
accountState.nonce == _accountState.nonce
&& accountState.balance == _accountState.balance
&& accountState.storageRoot == _accountState.storageRoot
&& accountState.codeHash == _accountState.codeHash
);
}
/***************************************
* Internal Functions: Account Updates *
***************************************/
/**
* @notice Updates the current state for a given account.
* @param _address Address of the target account.
* @param _accountState Account state to insert.
* @param _stateTrieWitness Inclusion proof for the account state within
* the state trie.
* @param _stateTrieRoot Known root of the state trie.
* @return Root hash of the updated state trie.
*/
function updateAccountState(
address _address,
Lib_OVMCodec.EVMAccount memory _accountState,
bytes memory _stateTrieWitness,
bytes32 _stateTrieRoot
)
internal
view
returns (bytes32)
{
return setAccountState(
_accountState,
_address,
_stateTrieWitness,
_stateTrieRoot
);
}
/*********************
* Private Functions *
*********************/
/**
* @notice Decodes an RLP-encoded account state into a useful struct.
* @param _encodedAccountState RLP-encoded account state.
* @return Account state struct.
*/
function decodeAccountState(
bytes memory _encodedAccountState
)
private
view
returns (Lib_OVMCodec.EVMAccount memory)
{
Lib_RLPReader.RLPItem[] memory accountState = Lib_RLPReader.toList(Lib_RLPReader.toRlpItem(_encodedAccountState));
return Lib_OVMCodec.EVMAccount({
nonce: Lib_RLPReader.toUint(accountState[0]),
balance: Lib_RLPReader.toUint(accountState[1]),
storageRoot: Lib_BytesUtils.toBytes32(Lib_RLPReader.toBytes(accountState[2])),
codeHash: Lib_BytesUtils.toBytes32(Lib_RLPReader.toBytes(accountState[3]))
});
}
/**
* @notice RLP-encodes an account state struct.
* @param _accountState Account state struct.
* @return RLP-encoded account state.
*/
function encodeAccountState(
Lib_OVMCodec.EVMAccount memory _accountState
)
private
view
returns (bytes memory)
{
bytes[] memory raw = new bytes[](4);
// Unfortunately we can't create this array outright because
// RLPWriter.encodeList will reject fixed-size arrays. Assigning
// index-by-index circumvents this issue.
raw[0] = Lib_RLPWriter.encodeUint(_accountState.nonce);
raw[1] = Lib_RLPWriter.encodeUint(_accountState.balance);
raw[2] = _accountState.storageRoot == 0 ? RLP_NULL_BYTES : Lib_RLPWriter.encodeBytes(abi.encodePacked(_accountState.storageRoot));
raw[3] = _accountState.codeHash == 0 ? RLP_NULL_BYTES : Lib_RLPWriter.encodeBytes(abi.encodePacked(_accountState.codeHash));
return Lib_RLPWriter.encodeList(raw);
}
/**
* @notice Retrieves the current account state and converts into a struct.
* @param _address Account address.
* @param _stateTrieWitness Inclusion proof for the account state within
* the state trie.
* @param _stateTrieRoot Known root of the state trie.
*/
function getAccountState(
address _address,
bytes memory _stateTrieWitness,
bytes32 _stateTrieRoot
)
private
view
returns (Lib_OVMCodec.EVMAccount memory)
{
Lib_OVMCodec.EVMAccount memory DEFAULT_ACCOUNT_STATE = Lib_OVMCodec.EVMAccount({
nonce: UINT256_NULL,
balance: UINT256_NULL,
storageRoot: keccak256(hex'80'),
codeHash: keccak256(hex'')
});
// TODO: Needs "single node root hash" logic.
(
bool exists,
bytes memory encodedAccountState
) = Lib_SecureMerkleTrie.get(
abi.encodePacked(_address),
_stateTrieWitness,
_stateTrieRoot
);
// TODO: Must fix this logic, in the next PR.
return exists ? decodeAccountState(encodedAccountState) : DEFAULT_ACCOUNT_STATE;
}
/**
* @notice Updates the current account state for a given address.
* @param _accountState New account state, as a struct.
* @param _address Account address.
* @param _stateTrieWitness Inclusion proof for the account state within
* the state trie.
* @param _stateTrieRoot Known root of the state trie.
* @return Root hash of the updated state trie.
*/
function setAccountState(
Lib_OVMCodec.EVMAccount memory _accountState,
address _address,
bytes memory _stateTrieWitness,
bytes32 _stateTrieRoot
)
private
view
returns (bytes32)
{
bytes memory encodedAccountState = encodeAccountState(_accountState);
return Lib_SecureMerkleTrie.update(
abi.encodePacked(_address),
encodedAccountState,
_stateTrieWitness,
_stateTrieRoot
);
}
}
\ No newline at end of file
......@@ -53,6 +53,7 @@ library Lib_MerkleTrie {
// Just a utility constant. RLP represents `NULL` as 0x80.
bytes1 constant RLP_NULL = bytes1(0x80);
bytes constant RLP_NULL_BYTES = hex'80';
bytes32 constant internal KECCAK256_RLP_NULL_BYTES = keccak256(RLP_NULL_BYTES);
/**********************
......@@ -69,7 +70,7 @@ library Lib_MerkleTrie {
* of a list of RLP-encoded nodes that make a path down to the target node.
* @param _root Known root of the Merkle trie. Used to verify that the
* included proof is correctly constructed.
* @return `true` if the k/v pair exists in the trie, `false` otherwise.
* @return _verified `true` if the k/v pair exists in the trie, `false` otherwise.
*/
function verifyInclusionProof(
bytes memory _key,
......@@ -80,37 +81,45 @@ library Lib_MerkleTrie {
internal
view
returns (
bool
bool _verified
)
{
return _verifyProof(_key, _value, _proof, _root, true);
(
bool exists,
bytes memory value
) = get(_key, _proof, _root);
return (
exists && Lib_BytesUtils.equal(_value, value)
);
}
/**
* @notice Verifies a proof that a given key/value pair is *not* present in
* @notice Verifies a proof that a given key is *not* present in
* the Merkle trie.
* @param _key Key of the node to search for, as a hex string.
* @param _value Value of the node to search for, as a hex string.
* @param _proof Merkle trie inclusion proof for the node *nearest* the
* target node. We effectively need to show that either the key exists and
* its value differs, or the key does not exist at all.
* target node.
* @param _root Known root of the Merkle trie. Used to verify that the
* included proof is correctly constructed.
* @return `true` if the k/v pair is absent in the trie, `false` otherwise.
* @return _verified `true` if the key is absent in the trie, `false` otherwise.
*/
function verifyExclusionProof(
bytes memory _key,
bytes memory _value,
bytes memory _proof,
bytes32 _root
)
internal
view
returns (
bool
bool _verified
)
{
return _verifyProof(_key, _value, _proof, _root, false);
(
bool exists,
) = get(_key, _proof, _root);
return exists == false;
}
/**
......@@ -122,7 +131,7 @@ library Lib_MerkleTrie {
* Otherwise, we need to modify the trie to handle the new k/v pair.
* @param _root Known root of the Merkle trie. Used to verify that the
* included proof is correctly constructed.
* @return Root hash of the newly constructed trie.
* @return _updatedRoot Root hash of the newly constructed trie.
*/
function update(
bytes memory _key,
......@@ -133,12 +142,18 @@ library Lib_MerkleTrie {
internal
view
returns (
bytes32
bytes32 _updatedRoot
)
{
// Special case when inserting the very first node.
if (_root == KECCAK256_RLP_NULL_BYTES) {
return keccak256(
_makeLeafNode(_key, _value).encoded
);
}
TrieNode[] memory proof = _parseProof(_proof);
(uint256 pathLength, bytes memory keyRemainder, ) = _walkNodePath(proof, _key, _root);
TrieNode[] memory newPath = _getNewPath(proof, pathLength, keyRemainder, _value);
return _getUpdatedTrieRoot(newPath, _key);
......@@ -149,7 +164,8 @@ library Lib_MerkleTrie {
* @param _key Key to search for, as hex bytes.
* @param _proof Merkle trie inclusion proof for the key.
* @param _root Known root of the Merkle trie.
* @return Whether the node exists, value associated with the key if so.
* @return _exists Whether or not the key exists.
* @return _value Value of the key if it exists.
*/
function get(
bytes memory _key,
......@@ -159,14 +175,20 @@ library Lib_MerkleTrie {
internal
view
returns (
bool,
bytes memory
bool _exists,
bytes memory _value
)
{
TrieNode[] memory proof = _parseProof(_proof);
(uint256 pathLength, bytes memory keyRemainder, ) = _walkNodePath(proof, _key, _root);
(uint256 pathLength, bytes memory keyRemainder, bool isFinalNode) = _walkNodePath(proof, _key, _root);
bool exists = keyRemainder.length == 0;
require(
exists || isFinalNode,
"Provided proof is invalid."
);
bytes memory value = exists ? _getNodeValue(proof[pathLength - 1]) : bytes('');
return (
......@@ -179,7 +201,7 @@ library Lib_MerkleTrie {
* Computes the root hash for a trie with a single node.
* @param _key Key for the single node.
* @param _value Value for the single node.
* @return Hash of the trie.
* @return _updatedRoot Hash of the trie.
*/
function getSingleNodeRootHash(
bytes memory _key,
......@@ -188,7 +210,7 @@ library Lib_MerkleTrie {
internal
view
returns (
bytes32
bytes32 _updatedRoot
)
{
return keccak256(_makeLeafNode(
......@@ -202,62 +224,14 @@ library Lib_MerkleTrie {
* Private Functions *
*********************/
/**
* @notice Utility function that handles verification of inclusion or
* exclusion proofs. Since the verification methods are almost identical,
* it's easier to shove this into a single function.
* @param _key Key of the node to search for, as a hex string.
* @param _value Value of the node to search for, as a hex string.
* @param _proof Merkle trie inclusion proof for the node *nearest* the
* target node. If we're proving explicit inclusion, the nearest node
* should be the target node.
* @param _root Known root of the Merkle trie. Used to verify that the
* included proof is correctly constructed.
* @param _inclusion Whether to check for inclusion or exclusion.
* @return `true` if the k/v pair is (in/not in) the trie, `false` otherwise.
*/
function _verifyProof(
bytes memory _key,
bytes memory _value,
bytes memory _proof,
bytes32 _root,
bool _inclusion
)
private
view
returns (
bool
)
{
TrieNode[] memory proof = _parseProof(_proof);
(uint256 pathLength, bytes memory keyRemainder, bool isFinalNode) = _walkNodePath(proof, _key, _root);
if (_inclusion) {
// Included leaf nodes should have no key remainder, values should match.
return (
keyRemainder.length == 0 &&
Lib_BytesUtils.equal(_getNodeValue(proof[pathLength - 1]), _value)
);
} else {
// If there's no key remainder then a leaf with the given key exists and the value should differ.
// Otherwise, we need to make sure that we've hit a dead end.
return (
(keyRemainder.length == 0 && !Lib_BytesUtils.equal(_getNodeValue(proof[pathLength - 1]), _value)) ||
(keyRemainder.length != 0 && isFinalNode)
);
}
}
/**
* @notice Walks through a proof using a provided key.
* @param _proof Inclusion proof to walk through.
* @param _key Key to use for the walk.
* @param _root Known root of the trie.
* @return (
* Length of the final path;
* Portion of the key remaining after the walk;
* Whether or not we've hit a dead end;
* )
* @return _pathLength Length of the final path
* @return _keyRemainder Portion of the key remaining after the walk.
* @return _isFinalNode Whether or not we've hit a dead end.
*/
function _walkNodePath(
TrieNode[] memory _proof,
......@@ -267,9 +241,9 @@ library Lib_MerkleTrie {
private
view
returns (
uint256,
bytes memory,
bool
uint256 _pathLength,
bytes memory _keyRemainder,
bool _isFinalNode
)
{
uint256 pathLength = 0;
......@@ -377,7 +351,7 @@ library Lib_MerkleTrie {
* @param _keyRemainder Portion of the initial key that must be inserted
* into the trie.
* @param _value Value to insert at the given key.
* @return A new path with the inserted k/v pair and extra supporting nodes.
* @return _newPath A new path with the inserted k/v pair and extra supporting nodes.
*/
function _getNewPath(
TrieNode[] memory _path,
......@@ -388,7 +362,7 @@ library Lib_MerkleTrie {
private
view
returns (
TrieNode[] memory
TrieNode[] memory _newPath
)
{
bytes memory keyRemainder = _keyRemainder;
......@@ -505,7 +479,7 @@ library Lib_MerkleTrie {
* @notice Computes the trie root from a given path.
* @param _nodes Path to some k/v pair.
* @param _key Key for the k/v pair.
* @return Root hash for the updated trie.
* @return _updatedRoot Root hash for the updated trie.
*/
function _getUpdatedTrieRoot(
TrieNode[] memory _nodes,
......@@ -514,7 +488,7 @@ library Lib_MerkleTrie {
private
view
returns (
bytes32
bytes32 _updatedRoot
)
{
bytes memory key = Lib_BytesUtils.toNibbles(_key);
......@@ -569,7 +543,7 @@ library Lib_MerkleTrie {
/**
* @notice Parses an RLP-encoded proof into something more useful.
* @param _proof RLP-encoded proof to parse.
* @return Proof parsed into easily accessible structs.
* @return _parsed Proof parsed into easily accessible structs.
*/
function _parseProof(
bytes memory _proof
......@@ -577,17 +551,17 @@ library Lib_MerkleTrie {
private
view
returns (
TrieNode[] memory
TrieNode[] memory _parsed
)
{
Lib_RLPReader.RLPItem[] memory nodes = Lib_RLPReader.toList(Lib_RLPReader.toRlpItem(_proof));
Lib_RLPReader.RLPItem[] memory nodes = Lib_RLPReader.readList(_proof);
TrieNode[] memory proof = new TrieNode[](nodes.length);
for (uint256 i = 0; i < nodes.length; i++) {
bytes memory encoded = Lib_RLPReader.toBytes(nodes[i]);
bytes memory encoded = Lib_RLPReader.readBytes(nodes[i]);
proof[i] = TrieNode({
encoded: encoded,
decoded: Lib_RLPReader.toList(Lib_RLPReader.toRlpItem(encoded))
decoded: Lib_RLPReader.readList(encoded)
});
}
......@@ -599,7 +573,7 @@ library Lib_MerkleTrie {
* "hash" within the specification, but nodes < 32 bytes are not actually
* hashed.
* @param _node Node to pull an ID for.
* @return ID for the node, depending on the size of its contents.
* @return _nodeID ID for the node, depending on the size of its contents.
*/
function _getNodeID(
Lib_RLPReader.RLPItem memory _node
......@@ -607,17 +581,17 @@ library Lib_MerkleTrie {
private
view
returns (
bytes32
bytes32 _nodeID
)
{
bytes memory nodeID;
if (_node.len < 32) {
if (_node.length < 32) {
// Nodes smaller than 32 bytes are RLP encoded.
nodeID = Lib_RLPReader.toRlpBytes(_node);
nodeID = Lib_RLPReader.readRawBytes(_node);
} else {
// Nodes 32 bytes or larger are hashed.
nodeID = Lib_RLPReader.toBytes(_node);
nodeID = Lib_RLPReader.readBytes(_node);
}
return Lib_BytesUtils.toBytes32(nodeID);
......@@ -626,7 +600,7 @@ library Lib_MerkleTrie {
/**
* @notice Gets the path for a leaf or extension node.
* @param _node Node to get a path for.
* @return Node path, converted to an array of nibbles.
* @return _path Node path, converted to an array of nibbles.
*/
function _getNodePath(
TrieNode memory _node
......@@ -634,17 +608,17 @@ library Lib_MerkleTrie {
private
view
returns (
bytes memory
bytes memory _path
)
{
return Lib_BytesUtils.toNibbles(Lib_RLPReader.toBytes(_node.decoded[0]));
return Lib_BytesUtils.toNibbles(Lib_RLPReader.readBytes(_node.decoded[0]));
}
/**
* @notice Gets the key for a leaf or extension node. Keys are essentially
* just paths without any prefix.
* @param _node Node to get a key for.
* @return Node key, converted to an array of nibbles.
* @return _key Node key, converted to an array of nibbles.
*/
function _getNodeKey(
TrieNode memory _node
......@@ -652,7 +626,7 @@ library Lib_MerkleTrie {
private
view
returns (
bytes memory
bytes memory _key
)
{
return _removeHexPrefix(_getNodePath(_node));
......@@ -661,7 +635,7 @@ library Lib_MerkleTrie {
/**
* @notice Gets the path for a node.
* @param _node Node to get a value for.
* @return Node value, as hex bytes.
* @return _value Node value, as hex bytes.
*/
function _getNodeValue(
TrieNode memory _node
......@@ -669,17 +643,17 @@ library Lib_MerkleTrie {
private
view
returns (
bytes memory
bytes memory _value
)
{
return Lib_RLPReader.toBytes(_node.decoded[_node.decoded.length - 1]);
return Lib_RLPReader.readBytes(_node.decoded[_node.decoded.length - 1]);
}
/**
* @notice Computes the node hash for an encoded node. Nodes < 32 bytes
* are not hashed, all others are keccak256 hashed.
* @param _encoded Encoded node to hash.
* @return Hash of the encoded node. Simply the input if < 32 bytes.
* @return _hash Hash of the encoded node. Simply the input if < 32 bytes.
*/
function _getNodeHash(
bytes memory _encoded
......@@ -687,7 +661,7 @@ library Lib_MerkleTrie {
private
pure
returns (
bytes memory
bytes memory _hash
)
{
if (_encoded.length < 32) {
......@@ -700,7 +674,7 @@ library Lib_MerkleTrie {
/**
* @notice Determines the type for a given node.
* @param _node Node to determine a type for.
* @return Type of the node; BranchNode/ExtensionNode/LeafNode.
* @return _type Type of the node; BranchNode/ExtensionNode/LeafNode.
*/
function _getNodeType(
TrieNode memory _node
......@@ -708,7 +682,7 @@ library Lib_MerkleTrie {
private
view
returns (
NodeType
NodeType _type
)
{
if (_node.decoded.length == BRANCH_NODE_LENGTH) {
......@@ -732,7 +706,7 @@ library Lib_MerkleTrie {
* nibble arrays.
* @param _a First nibble array.
* @param _b Second nibble array.
* @return Number of shared nibbles.
* @return _shared Number of shared nibbles.
*/
function _getSharedNibbleLength(
bytes memory _a,
......@@ -741,7 +715,7 @@ library Lib_MerkleTrie {
private
view
returns (
uint256
uint256 _shared
)
{
uint256 i = 0;
......@@ -754,7 +728,7 @@ library Lib_MerkleTrie {
/**
* @notice Utility; converts an RLP-encoded node into our nice struct.
* @param _raw RLP-encoded node to convert.
* @return Node as a TrieNode struct.
* @return _node Node as a TrieNode struct.
*/
function _makeNode(
bytes[] memory _raw
......@@ -762,21 +736,21 @@ library Lib_MerkleTrie {
private
view
returns (
TrieNode memory
TrieNode memory _node
)
{
bytes memory encoded = Lib_RLPWriter.encodeList(_raw);
return TrieNode({
encoded: encoded,
decoded: Lib_RLPReader.toList(Lib_RLPReader.toRlpItem(encoded))
decoded: Lib_RLPReader.readList(encoded)
});
}
/**
* @notice Utility; converts an RLP-decoded node into our nice struct.
* @param _items RLP-decoded node to convert.
* @return Node as a TrieNode struct.
* @return _node Node as a TrieNode struct.
*/
function _makeNode(
Lib_RLPReader.RLPItem[] memory _items
......@@ -784,12 +758,12 @@ library Lib_MerkleTrie {
private
view
returns (
TrieNode memory
TrieNode memory _node
)
{
bytes[] memory raw = new bytes[](_items.length);
for (uint256 i = 0; i < _items.length; i++) {
raw[i] = Lib_RLPReader.toRlpBytes(_items[i]);
raw[i] = Lib_RLPReader.readRawBytes(_items[i]);
}
return _makeNode(raw);
}
......@@ -798,7 +772,7 @@ library Lib_MerkleTrie {
* @notice Creates a new extension node.
* @param _key Key for the extension node, unprefixed.
* @param _value Value for the extension node.
* @return New extension node with the given k/v pair.
* @return _node New extension node with the given k/v pair.
*/
function _makeExtensionNode(
bytes memory _key,
......@@ -807,7 +781,7 @@ library Lib_MerkleTrie {
private
view
returns (
TrieNode memory
TrieNode memory _node
)
{
bytes[] memory raw = new bytes[](2);
......@@ -824,7 +798,7 @@ library Lib_MerkleTrie {
* more gas efficient to keep them separate and duplicate the logic.
* @param _key Key for the leaf node, unprefixed.
* @param _value Value for the leaf node.
* @return New leaf node with the given k/v pair.
* @return _node New leaf node with the given k/v pair.
*/
function _makeLeafNode(
bytes memory _key,
......@@ -833,7 +807,7 @@ library Lib_MerkleTrie {
private
view
returns (
TrieNode memory
TrieNode memory _node
)
{
bytes[] memory raw = new bytes[](2);
......@@ -845,13 +819,13 @@ library Lib_MerkleTrie {
/**
* @notice Creates an empty branch node.
* @return Empty branch node as a TrieNode stuct.
* @return _node Empty branch node as a TrieNode stuct.
*/
function _makeEmptyBranchNode()
private
view
returns (
TrieNode memory
TrieNode memory _node
)
{
bytes[] memory raw = new bytes[](BRANCH_NODE_LENGTH);
......@@ -865,7 +839,7 @@ library Lib_MerkleTrie {
* @notice Modifies the value slot for a given branch.
* @param _branch Branch node to modify.
* @param _value Value to insert into the branch.
* @return Modified branch node.
* @return _updatedNode Modified branch node.
*/
function _editBranchValue(
TrieNode memory _branch,
......@@ -874,11 +848,11 @@ library Lib_MerkleTrie {
private
view
returns (
TrieNode memory
TrieNode memory _updatedNode
)
{
bytes memory encoded = Lib_RLPWriter.encodeBytes(_value);
_branch.decoded[_branch.decoded.length - 1] = Lib_RLPReader.toRlpItem(encoded);
_branch.decoded[_branch.decoded.length - 1] = Lib_RLPReader.toRLPItem(encoded);
return _makeNode(_branch.decoded);
}
......@@ -887,7 +861,7 @@ library Lib_MerkleTrie {
* @param _branch Branch node to modify.
* @param _index Slot index to modify.
* @param _value Value to insert into the slot.
* @return Modified branch node.
* @return _updatedNode Modified branch node.
*/
function _editBranchIndex(
TrieNode memory _branch,
......@@ -897,11 +871,11 @@ library Lib_MerkleTrie {
private
view
returns (
TrieNode memory
TrieNode memory _updatedNode
)
{
bytes memory encoded = _value.length < 32 ? _value : Lib_RLPWriter.encodeBytes(_value);
_branch.decoded[_index] = Lib_RLPReader.toRlpItem(encoded);
_branch.decoded[_index] = Lib_RLPReader.toRLPItem(encoded);
return _makeNode(_branch.decoded);
}
......@@ -909,7 +883,7 @@ library Lib_MerkleTrie {
* @notice Utility; adds a prefix to a key.
* @param _key Key to prefix.
* @param _isLeaf Whether or not the key belongs to a leaf.
* @return Prefixed key.
* @return _prefixedKey Prefixed key.
*/
function _addHexPrefix(
bytes memory _key,
......@@ -918,7 +892,7 @@ library Lib_MerkleTrie {
private
view
returns (
bytes memory
bytes memory _prefixedKey
)
{
uint8 prefix = _isLeaf ? uint8(0x02) : uint8(0x00);
......@@ -931,7 +905,7 @@ library Lib_MerkleTrie {
/**
* @notice Utility; removes a prefix from a path.
* @param _path Path to remove the prefix from.
* @return Unprefixed key.
* @return _unprefixedKey Unprefixed key.
*/
function _removeHexPrefix(
bytes memory _path
......@@ -939,7 +913,7 @@ library Lib_MerkleTrie {
private
view
returns (
bytes memory
bytes memory _unprefixedKey
)
{
if (uint8(_path[0]) % 2 == 0) {
......@@ -957,7 +931,7 @@ library Lib_MerkleTrie {
* @param _aLength Length of the first array.
* @param _b Second array to join.
* @param _bLength Length of the second array.
* @return Combined node array.
* @return _joined Combined node array.
*/
function _joinNodeArrays(
TrieNode[] memory _a,
......@@ -968,7 +942,7 @@ library Lib_MerkleTrie {
private
pure
returns (
TrieNode[] memory
TrieNode[] memory _joined
)
{
TrieNode[] memory ret = new TrieNode[](_aLength + _bLength);
......
......@@ -24,7 +24,7 @@ library Lib_SecureMerkleTrie {
* of a list of RLP-encoded nodes that make a path down to the target node.
* @param _root Known root of the Merkle trie. Used to verify that the
* included proof is correctly constructed.
* @return `true` if the k/v pair exists in the trie, `false` otherwise.
* @return _verified `true` if the k/v pair exists in the trie, `false` otherwise.
*/
function verifyInclusionProof(
bytes memory _key,
......@@ -35,7 +35,7 @@ library Lib_SecureMerkleTrie {
internal
view
returns (
bool
bool _verified
)
{
bytes memory key = _getSecureKey(_key);
......@@ -43,31 +43,28 @@ library Lib_SecureMerkleTrie {
}
/**
* @notice Verifies a proof that a given key/value pair is *not* present in
* @notice Verifies a proof that a given key is *not* present in
* the Merkle trie.
* @param _key Key of the node to search for, as a hex string.
* @param _value Value of the node to search for, as a hex string.
* @param _proof Merkle trie inclusion proof for the node *nearest* the
* target node. We effectively need to show that either the key exists and
* its value differs, or the key does not exist at all.
* target node.
* @param _root Known root of the Merkle trie. Used to verify that the
* included proof is correctly constructed.
* @return `true` if the k/v pair is absent in the trie, `false` otherwise.
* @return _verified `true` if the key is not present in the trie, `false` otherwise.
*/
function verifyExclusionProof(
bytes memory _key,
bytes memory _value,
bytes memory _proof,
bytes32 _root
)
internal
view
returns (
bool
bool _verified
)
{
bytes memory key = _getSecureKey(_key);
return Lib_MerkleTrie.verifyExclusionProof(key, _value, _proof, _root);
return Lib_MerkleTrie.verifyExclusionProof(key, _proof, _root);
}
/**
......@@ -79,7 +76,7 @@ library Lib_SecureMerkleTrie {
* Otherwise, we need to modify the trie to handle the new k/v pair.
* @param _root Known root of the Merkle trie. Used to verify that the
* included proof is correctly constructed.
* @return Root hash of the newly constructed trie.
* @return _updatedRoot Root hash of the newly constructed trie.
*/
function update(
bytes memory _key,
......@@ -90,7 +87,7 @@ library Lib_SecureMerkleTrie {
internal
view
returns (
bytes32
bytes32 _updatedRoot
)
{
bytes memory key = _getSecureKey(_key);
......@@ -102,7 +99,8 @@ library Lib_SecureMerkleTrie {
* @param _key Key to search for, as hex bytes.
* @param _proof Merkle trie inclusion proof for the key.
* @param _root Known root of the Merkle trie.
* @return Whether the node exists, value associated with the key if so.
* @return _exists Whether or not the key exists.
* @return _value Value of the key if it exists.
*/
function get(
bytes memory _key,
......@@ -112,8 +110,8 @@ library Lib_SecureMerkleTrie {
internal
view
returns (
bool,
bytes memory
bool _exists,
bytes memory _value
)
{
bytes memory key = _getSecureKey(_key);
......@@ -124,7 +122,7 @@ library Lib_SecureMerkleTrie {
* Computes the root hash for a trie with a single node.
* @param _key Key for the single node.
* @param _value Value for the single node.
* @return Hash of the trie.
* @return _updatedRoot Hash of the trie.
*/
function getSingleNodeRootHash(
bytes memory _key,
......@@ -133,7 +131,7 @@ library Lib_SecureMerkleTrie {
internal
view
returns (
bytes32
bytes32 _updatedRoot
)
{
bytes memory key = _getSecureKey(_key);
......@@ -145,13 +143,18 @@ library Lib_SecureMerkleTrie {
* Private Functions *
*********************/
/**
* Computes the secure counterpart to a key.
* @param _key Key to get a secure key from.
* @return _secureKey Secure version of the key.
*/
function _getSecureKey(
bytes memory _key
)
private
pure
returns (
bytes memory
bytes memory _secureKey
)
{
return abi.encodePacked(keccak256(_key));
......
......@@ -8,7 +8,7 @@ import { Lib_OVMCodec } from "../../optimistic-ethereum/libraries/codec/Lib_OVMC
/**
* @title TestLib_OVMCodec
*/
library TestLib_OVMCodec {
contract TestLib_OVMCodec {
function decodeEOATransaction(
bytes memory _transaction
......
// SPDX-License-Identifier: UNLICENSED
pragma solidity ^0.7.0;
pragma experimental ABIEncoderV2;
/* Library Imports */
import { Lib_RLPReader } from "../../optimistic-ethereum/libraries/rlp/Lib_RLPReader.sol";
/**
* @title TestLib_RLPReader
*/
contract TestLib_RLPReader {
function readList(
bytes memory _in
)
public
view
returns (
bytes[] memory
)
{
Lib_RLPReader.RLPItem[] memory decoded = Lib_RLPReader.readList(_in);
bytes[] memory out = new bytes[](decoded.length);
for (uint256 i = 0; i < out.length; i++) {
out[i] = Lib_RLPReader.readRawBytes(decoded[i]);
}
return out;
}
function readString(
bytes memory _in
)
public
view
returns (
string memory
)
{
return Lib_RLPReader.readString(_in);
}
function readBytes(
bytes memory _in
)
public
view
returns (
bytes memory
)
{
return Lib_RLPReader.readBytes(_in);
}
function readBytes32(
bytes memory _in
)
public
view
returns (
bytes32
)
{
return Lib_RLPReader.readBytes32(_in);
}
function readUint256(
bytes memory _in
)
public
view
returns (
uint256
)
{
return Lib_RLPReader.readUint256(_in);
}
function readBool(
bytes memory _in
)
public
view
returns (
bool
)
{
return Lib_RLPReader.readBool(_in);
}
function readAddress(
bytes memory _in
)
public
view
returns (
address
)
{
return Lib_RLPReader.readAddress(_in);
}
}
......@@ -8,7 +8,7 @@ import { Lib_RLPWriter } from "../../optimistic-ethereum/libraries/rlp/Lib_RLPWr
/**
* @title TestLib_RLPWriter
*/
library TestLib_RLPWriter {
contract TestLib_RLPWriter {
function encodeBytes(
bytes memory _in
......
// SPDX-License-Identifier: UNLICENSED
pragma solidity ^0.7.0;
pragma experimental ABIEncoderV2;
/* Library Imports */
import { Lib_EthMerkleTrie } from "../../optimistic-ethereum/libraries/trie/Lib_EthMerkleTrie.sol";
import { Lib_OVMCodec } from "../../optimistic-ethereum/libraries/codec/Lib_OVMCodec.sol";
/**
* @title TestLib_EthMerkleTrie
*/
contract TestLib_EthMerkleTrie {
function proveAccountStorageSlotValue(
address _address,
bytes32 _key,
bytes32 _value,
bytes memory _stateTrieWitness,
bytes memory _storageTrieWitness,
bytes32 _stateTrieRoot
)
public
view
returns (bool)
{
return Lib_EthMerkleTrie.proveAccountStorageSlotValue(
_address,
_key,
_value,
_stateTrieWitness,
_storageTrieWitness,
_stateTrieRoot
);
}
function updateAccountStorageSlotValue(
address _address,
bytes32 _key,
bytes32 _value,
bytes memory _stateTrieWitness,
bytes memory _storageTrieWitness,
bytes32 _stateTrieRoot
)
public
view
returns (bytes32)
{
return Lib_EthMerkleTrie.updateAccountStorageSlotValue(
_address,
_key,
_value,
_stateTrieWitness,
_storageTrieWitness,
_stateTrieRoot
);
}
function proveAccountState(
address _address,
Lib_OVMCodec.EVMAccount memory _accountState,
bytes memory _stateTrieWitness,
bytes32 _stateTrieRoot
)
public
view
returns (bool)
{
return Lib_EthMerkleTrie.proveAccountState(
_address,
_accountState,
_stateTrieWitness,
_stateTrieRoot
);
}
function updateAccountState(
address _address,
Lib_OVMCodec.EVMAccount memory _accountState,
bytes memory _stateTrieWitness,
bytes32 _stateTrieRoot
)
public
view
returns (bytes32)
{
return Lib_EthMerkleTrie.updateAccountState(
_address,
_accountState,
_stateTrieWitness,
_stateTrieRoot
);
}
}
......@@ -7,7 +7,7 @@ import { Lib_MerkleTrie } from "../../optimistic-ethereum/libraries/trie/Lib_Mer
/**
* @title TestLib_MerkleTrie
*/
library TestLib_MerkleTrie {
contract TestLib_MerkleTrie {
function verifyInclusionProof(
bytes memory _key,
......@@ -31,7 +31,6 @@ library TestLib_MerkleTrie {
function verifyExclusionProof(
bytes memory _key,
bytes memory _value,
bytes memory _proof,
bytes32 _root
)
......@@ -43,7 +42,6 @@ library TestLib_MerkleTrie {
{
return Lib_MerkleTrie.verifyExclusionProof(
_key,
_value,
_proof,
_root
);
......
......@@ -8,7 +8,7 @@ import { Lib_SecureMerkleTrie } from "../../optimistic-ethereum/libraries/trie/L
/**
* @title TestLib_SecureMerkleTrie
*/
library TestLib_SecureMerkleTrie {
contract TestLib_SecureMerkleTrie {
function verifyInclusionProof(
bytes memory _key,
......@@ -32,7 +32,6 @@ library TestLib_SecureMerkleTrie {
function verifyExclusionProof(
bytes memory _key,
bytes memory _value,
bytes memory _proof,
bytes32 _root
)
......@@ -44,7 +43,6 @@ library TestLib_SecureMerkleTrie {
{
return Lib_SecureMerkleTrie.verifyExclusionProof(
_key,
_value,
_proof,
_root
);
......
......@@ -7,7 +7,7 @@ import { Lib_Bytes32Utils } from "../../optimistic-ethereum/libraries/utils/Lib_
/**
* @title TestLib_Byte32Utils
*/
library TestLib_Bytes32Utils {
contract TestLib_Bytes32Utils {
function toBool(
bytes32 _in
......
......@@ -8,7 +8,7 @@ import { Lib_BytesUtils } from "../../optimistic-ethereum/libraries/utils/Lib_By
/**
* @title TestLib_BytesUtils
*/
library TestLib_BytesUtils {
contract TestLib_BytesUtils {
function concat(
bytes memory _preBytes,
......
......@@ -7,7 +7,7 @@ import { Lib_ECDSAUtils } from "../../optimistic-ethereum/libraries/utils/Lib_EC
/**
* @title TestLib_ECDSAUtils
*/
library TestLib_ECDSAUtils {
contract TestLib_ECDSAUtils {
function recover(
bytes memory _message,
......
......@@ -8,7 +8,7 @@ import { Lib_EthUtils } from "../../optimistic-ethereum/libraries/utils/Lib_EthU
/**
* @title TestLib_EthUtils
*/
library TestLib_EthUtils {
contract TestLib_EthUtils {
function getCode(
address _address,
......
......@@ -8,7 +8,7 @@ import { Lib_MerkleUtils } from "../../optimistic-ethereum/libraries/utils/Lib_M
/**
* @title TestLib_MerkleUtils
*/
library TestLib_MerkleUtils {
contract TestLib_MerkleUtils {
function getMerkleRoot(
bytes32[] memory _hashes
......
......@@ -10,7 +10,7 @@
"build:dump": "ts-node \"bin/take-dump.ts\"",
"build:copy": "copyfiles -u 2 \"contracts/optimistic-ethereum/**/*.sol\" \"build/contracts\"",
"test": "yarn run test:contracts",
"test:contracts": "buidler test \"test/contracts/libraries/trie/Lib_EthMerkleTrie.spec.ts\" --show-stack-traces",
"test:contracts": "buidler test \"test/contracts/libraries/rlp/Lib_RLPReader.spec.ts\" --show-stack-traces",
"lint": "yarn run lint:typescript",
"lint:typescript": "tslint --format stylish --project .",
"lint:fix": "yarn run lint:fix:typescript",
......
yarn run v1.22.5
$ yarn run test:contracts
$ buidler test "test/contracts/libraries/rlp/Lib_RLPReader.spec.ts" --show-stack-traces
All contracts have already been compiled, skipping compilation.
{
"emptystring": {
"in": [
"0x80"
],
"out": [
""
]
},
"bytestring00": {
"in": [
"0x00"
],
"out": [
"\u0000"
]
},
"bytestring01": {
"in": [
"0x01"
],
"out": [
"\u0001"
]
},
"bytestring7F": {
"in": [
"0x7f"
],
"out": [
""
]
},
"shortstring": {
"in": [
"0x83646f67"
],
"out": [
"dog"
]
},
"shortstring2": {
"in": [
"0xb74c6f72656d20697073756d20646f6c6f722073697420616d65742c20636f6e7365637465747572206164697069736963696e6720656c69"
],
"out": [
"Lorem ipsum dolor sit amet, consectetur adipisicing eli"
]
},
"longstring": {
"in": [
"0xb8384c6f72656d20697073756d20646f6c6f722073697420616d65742c20636f6e7365637465747572206164697069736963696e6720656c6974"
],
"out": [
"Lorem ipsum dolor sit amet, consectetur adipisicing elit"
]
},
"longstring2": {
"in": [
"0xb904004c6f72656d20697073756d20646f6c6f722073697420616d65742c20636f6e73656374657475722061646970697363696e6720656c69742e20437572616269747572206d6175726973206d61676e612c20737573636970697420736564207665686963756c61206e6f6e2c20696163756c697320666175636962757320746f72746f722e2050726f696e20737573636970697420756c74726963696573206d616c6573756164612e204475697320746f72746f7220656c69742c2064696374756d2071756973207472697374697175652065752c20756c7472696365732061742072697375732e204d6f72626920612065737420696d70657264696574206d6920756c6c616d636f7270657220616c6971756574207375736369706974206e6563206c6f72656d2e2041656e65616e2071756973206c656f206d6f6c6c69732c2076756c70757461746520656c6974207661726975732c20636f6e73657175617420656e696d2e204e756c6c6120756c74726963657320747572706973206a7573746f2c20657420706f73756572652075726e6120636f6e7365637465747572206e65632e2050726f696e206e6f6e20636f6e76616c6c6973206d657475732e20446f6e65632074656d706f7220697073756d20696e206d617572697320636f6e67756520736f6c6c696369747564696e2e20566573746962756c756d20616e746520697073756d207072696d697320696e206661756369627573206f726369206c756374757320657420756c74726963657320706f737565726520637562696c69612043757261653b2053757370656e646973736520636f6e76616c6c69732073656d2076656c206d617373612066617563696275732c2065676574206c6163696e6961206c616375732074656d706f722e204e756c6c61207175697320756c747269636965732070757275732e2050726f696e20617563746f722072686f6e637573206e69626820636f6e64696d656e74756d206d6f6c6c69732e20416c697175616d20636f6e73657175617420656e696d206174206d65747573206c75637475732c206120656c656966656e6420707572757320656765737461732e20437572616269747572206174206e696268206d657475732e204e616d20626962656e64756d2c206e6571756520617420617563746f72207472697374697175652c206c6f72656d206c696265726f20616c697175657420617263752c206e6f6e20696e74657264756d2074656c6c7573206c65637475732073697420616d65742065726f732e20437261732072686f6e6375732c206d65747573206163206f726e617265206375727375732c20646f6c6f72206a7573746f20756c747269636573206d657475732c20617420756c6c616d636f7270657220766f6c7574706174"
],
"out": [
"Lorem ipsum dolor sit amet, consectetur adipiscing elit. Curabitur mauris magna, suscipit sed vehicula non, iaculis faucibus tortor. Proin suscipit ultricies malesuada. Duis tortor elit, dictum quis tristique eu, ultrices at risus. Morbi a est imperdiet mi ullamcorper aliquet suscipit nec lorem. Aenean quis leo mollis, vulputate elit varius, consequat enim. Nulla ultrices turpis justo, et posuere urna consectetur nec. Proin non convallis metus. Donec tempor ipsum in mauris congue sollicitudin. Vestibulum ante ipsum primis in faucibus orci luctus et ultrices posuere cubilia Curae; Suspendisse convallis sem vel massa faucibus, eget lacinia lacus tempor. Nulla quis ultricies purus. Proin auctor rhoncus nibh condimentum mollis. Aliquam consequat enim at metus luctus, a eleifend purus egestas. Curabitur at nibh metus. Nam bibendum, neque at auctor tristique, lorem libero aliquet arcu, non interdum tellus lectus sit amet eros. Cras rhoncus, metus ac ornare cursus, dolor justo ultrices metus, at ullamcorper volutpat"
]
},
"zero": {
"in": [
"0x80"
],
"out": [
0
]
},
"smallint": {
"in": [
"0x01"
],
"out": [
1
]
},
"smallint2": {
"in": [
"0x10"
],
"out": [
16
]
},
"smallint3": {
"in": [
"0x4f"
],
"out": [
79
]
},
"smallint4": {
"in": [
"0x7f"
],
"out": [
127
]
},
"mediumint1": {
"in": [
"0x8180"
],
"out": [
128
]
},
"mediumint2": {
"in": [
"0x8203e8"
],
"out": [
1000
]
},
"mediumint3": {
"in": [
"0x830186a0"
],
"out": [
100000
]
},
"mediumint4": {
"in": [
"0x8f102030405060708090a0b0c0d0e0f2"
],
"out": [
"#83729609699884896815286331701780722"
]
},
"mediumint5": {
"in": [
"0x9c0100020003000400050006000700080009000a000b000c000d000e01"
],
"out": [
"#105315505618206987246253880190783558935785933862974822347068935681"
]
},
"emptylist": {
"in": [
"0xc0"
],
"out": [
[]
]
},
"stringlist": {
"in": [
"0xcc83646f6783676f6483636174"
],
"out": [
[
"0x83646f67",
"0x83676f64",
"0x83636174"
]
]
},
"multilist": {
"in": [
"0xc6827a77c10401"
],
"out": [
[
"0x827a77",
"0xc104",
"0x01"
]
]
},
"shortListMax1": {
"in": [
"0xf784617364668471776572847a78637684617364668471776572847a78637684617364668471776572847a78637684617364668471776572"
],
"out": [
[
"0x8461736466",
"0x8471776572",
"0x847a786376",
"0x8461736466",
"0x8471776572",
"0x847a786376",
"0x8461736466",
"0x8471776572",
"0x847a786376",
"0x8461736466",
"0x8471776572"
]
]
},
"longList1": {
"in": [
"0xf840cf84617364668471776572847a786376cf84617364668471776572847a786376cf84617364668471776572847a786376cf84617364668471776572847a786376"
],
"out": [
[
"0xcf84617364668471776572847a786376",
"0xcf84617364668471776572847a786376",
"0xcf84617364668471776572847a786376",
"0xcf84617364668471776572847a786376"
]
]
},
"longList2": {
"in": [
"0xf90200cf84617364668471776572847a786376cf84617364668471776572847a786376cf84617364668471776572847a786376cf84617364668471776572847a786376cf84617364668471776572847a786376cf84617364668471776572847a786376cf84617364668471776572847a786376cf84617364668471776572847a786376cf84617364668471776572847a786376cf84617364668471776572847a786376cf84617364668471776572847a786376cf84617364668471776572847a786376cf84617364668471776572847a786376cf84617364668471776572847a786376cf84617364668471776572847a786376cf84617364668471776572847a786376cf84617364668471776572847a786376cf84617364668471776572847a786376cf84617364668471776572847a786376cf84617364668471776572847a786376cf84617364668471776572847a786376cf84617364668471776572847a786376cf84617364668471776572847a786376cf84617364668471776572847a786376cf84617364668471776572847a786376cf84617364668471776572847a786376cf84617364668471776572847a786376cf84617364668471776572847a786376cf84617364668471776572847a786376cf84617364668471776572847a786376cf84617364668471776572847a786376cf84617364668471776572847a786376"
],
"out": [
[
"0xcf84617364668471776572847a786376",
"0xcf84617364668471776572847a786376",
"0xcf84617364668471776572847a786376",
"0xcf84617364668471776572847a786376",
"0xcf84617364668471776572847a786376",
"0xcf84617364668471776572847a786376",
"0xcf84617364668471776572847a786376",
"0xcf84617364668471776572847a786376",
"0xcf84617364668471776572847a786376",
"0xcf84617364668471776572847a786376",
"0xcf84617364668471776572847a786376",
"0xcf84617364668471776572847a786376",
"0xcf84617364668471776572847a786376",
"0xcf84617364668471776572847a786376",
"0xcf84617364668471776572847a786376",
"0xcf84617364668471776572847a786376",
"0xcf84617364668471776572847a786376",
"0xcf84617364668471776572847a786376",
"0xcf84617364668471776572847a786376",
"0xcf84617364668471776572847a786376",
"0xcf84617364668471776572847a786376",
"0xcf84617364668471776572847a786376",
"0xcf84617364668471776572847a786376",
"0xcf84617364668471776572847a786376",
"0xcf84617364668471776572847a786376",
"0xcf84617364668471776572847a786376",
"0xcf84617364668471776572847a786376",
"0xcf84617364668471776572847a786376",
"0xcf84617364668471776572847a786376",
"0xcf84617364668471776572847a786376",
"0xcf84617364668471776572847a786376",
"0xcf84617364668471776572847a786376"
]
]
},
"listsoflists": {
"in": [
"0xc4c2c0c0c0"
],
"out": [
[
"0xc2c0c0",
"0xc0"
]
]
},
"listsoflists2": {
"in": [
"0xc7c0c1c0c3c0c1c0"
],
"out": [
[
"0xc0",
"0xc1c0",
"0xc3c0c1c0"
]
]
},
"dictTest1": {
"in": [
"0xecca846b6579318476616c31ca846b6579328476616c32ca846b6579338476616c33ca846b6579348476616c34"
],
"out": [
[
"0xca846b6579318476616c31",
"0xca846b6579328476616c32",
"0xca846b6579338476616c33",
"0xca846b6579348476616c34"
]
]
}
}
Lib_RLPReader
JSON tests
readList
160
0xc0
0x000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000
should run test: emptylist (58ms)
160
0xcc83646f6783676f6483636174
1
3
0x0000000000000000000000000000000000000000000000000000000000000001
0x0000010000030000000000000000000000000000000000000000000000000000
1
3
0x0000000000000000000000000000000000000000000000000000000000000001
0x0000010000030000000000000000000000000000000000000000000000000000
1
3
0x0000000000000000000000000000000000000000000000000000000000000001
0x0000010000030000000000000000000000000000000000000000000000000000
0x000001000003000001000003000001000003000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000
----
0x0000010000030000010000030000010000030000000000000000000000000000
3
1
----
----
0x0000010000030000010000030000000000000000000000000000000000000000
3
1
----
----
0x0000010000030000000000000000000000000000000000000000000000000000
3
1
----
0x83646f67
0x83676f64
0x83636174
1) should run test: stringlist
160
0xc6827a77c10401
1
2
0x0000000000000000000000000000000000000000000000000000000000000001
0x0000010000020000000000000000000000000000000000000000000000000000
1
1
0x0000000000000000000000000000000000000000000000000000000000000001
0x0000010000010000000000000000000000000000000000000000000000000000
0
1
0x0000000000000000000000000000000000000000000000000000000000000000
0x0000000000010000000000000000000000000000000000000000000000000000
0x000001000002000001000001000000000001000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000
----
0x0000010000020000010000010000000000010000000000000000000000000000
2
1
----
----
0x0000010000010000000000010000000000000000000000000000000000000000
1
1
----
----
0x0000000000010000000000000000000000000000000000000000000000000000
1
0
----
0x827a77
0xc104
0x0100
2) should run test: multilist
160
0xf784617364668471776572847a78637684617364668471776572847a78637684000000000000000000000000000000000000000000000000
1
4
0x0000000000000000000000000000000000000000000000000000000000000001
0x0000010000040000000000000000000000000000000000000000000000000000
1
4
0x0000000000000000000000000000000000000000000000000000000000000001
0x0000010000040000000000000000000000000000000000000000000000000000
1
4
0x0000000000000000000000000000000000000000000000000000000000000001
0x0000010000040000000000000000000000000000000000000000000000000000
1
4
0x0000000000000000000000000000000000000000000000000000000000000001
0x0000010000040000000000000000000000000000000000000000000000000000
1
4
0x0000000000000000000000000000000000000000000000000000000000000001
0x0000010000040000000000000000000000000000000000000000000000000000
1
4
0x0000000000000000000000000000000000000000000000000000000000000001
0x0000010000040000000000000000000000000000000000000000000000000000
1
4
0x0000000000000000000000000000000000000000000000000000000000000001
0x0000010000040000000000000000000000000000000000000000000000000000
1
4
0x0000000000000000000000000000000000000000000000000000000000000001
0x0000010000040000000000000000000000000000000000000000000000000000
1
4
0x0000000000000000000000000000000000000000000000000000000000000001
0x0000010000040000000000000000000000000000000000000000000000000000
1
4
0x0000000000000000000000000000000000000000000000000000000000000001
0x0000010000040000000000000000000000000000000000000000000000000000
1
4
0x0000000000000000000000000000000000000000000000000000000000000001
0x0000010000040000000000000000000000000000000000000000000000000000
0x000001000004000001000004000001000004000001000004000001000004000001000004000001000004000001000004000001000004000001000004000001000004000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000
----
0x0000010000040000010000040000010000040000010000040000010000040000
4
1
----
----
0x0000010000040000010000040000010000040000010000040000010000040000
4
1
----
----
0x0000010000040000010000040000010000040000010000040000010000040000
4
1
----
----
0x0000010000040000010000040000010000040000010000040000010000040000
4
1
----
----
0x0000010000040000010000040000010000040000010000040000010000040000
4
1
----
----
0x0000010000040000010000040000010000040000010000040000010000040000
4
1
----
----
0x0000010000040000010000040000010000040000010000040000010000040000
4
1
----
----
0x0000010000040000010000040000010000040000010000040000000000000000
4
1
----
----
0x0000010000040000010000040000010000040000000000000000000000000000
4
1
----
----
0x0000010000040000010000040000000000000000000000000000000000000000
4
1
----
----
0x0000010000040000000000000000000000000000000000000000000000000000
4
1
----
0x8461736466
0x8471776572
0x847a786376
0x8461736466
0x8471776572
0x847a786376
0x8461736466
0x8471776572
0x847a786376
0x8461736466
0x8471776572
3) should run test: shortListMax1
160
0xf840cf84617364668471776572847a786376cf84617364668471776572847a7800000000000000000000000000000000000000000000000000000000000000000000
1
15
0x0000000000000000000000000000000000000000000000000000000000000001
0x00000100000f0000000000000000000000000000000000000000000000000000
1
15
0x0000000000000000000000000000000000000000000000000000000000000001
0x00000100000f0000000000000000000000000000000000000000000000000000
1
15
0x0000000000000000000000000000000000000000000000000000000000000001
0x00000100000f0000000000000000000000000000000000000000000000000000
1
15
0x0000000000000000000000000000000000000000000000000000000000000001
0x00000100000f0000000000000000000000000000000000000000000000000000
0x00000100000f00000100000f00000100000f00000100000f000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000
----
0x00000100000f00000100000f00000100000f00000100000f0000000000000000
15
1
----
----
0x00000100000f00000100000f00000100000f0000000000000000000000000000
15
1
----
----
0x00000100000f00000100000f0000000000000000000000000000000000000000
15
1
----
----
0x00000100000f0000000000000000000000000000000000000000000000000000
15
1
----
0xcf84617364668471776572847a786376
0xcf84617364668471776572847a786376
0xcf84617364668471776572847a786376
0xcf84617364668471776572847a786376
4) should run test: longList1
160
0xf90200cf84617364668471776572847a786376cf84617364668471776572847a000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000
1
15
0x0000000000000000000000000000000000000000000000000000000000000001
0x00000100000f0000000000000000000000000000000000000000000000000000
1
15
0x0000000000000000000000000000000000000000000000000000000000000001
0x00000100000f0000000000000000000000000000000000000000000000000000
1
15
0x0000000000000000000000000000000000000000000000000000000000000001
0x00000100000f0000000000000000000000000000000000000000000000000000
1
15
0x0000000000000000000000000000000000000000000000000000000000000001
0x00000100000f0000000000000000000000000000000000000000000000000000
1
15
0x0000000000000000000000000000000000000000000000000000000000000001
0x00000100000f0000000000000000000000000000000000000000000000000000
1
15
0x0000000000000000000000000000000000000000000000000000000000000001
0x00000100000f0000000000000000000000000000000000000000000000000000
1
15
0x0000000000000000000000000000000000000000000000000000000000000001
0x00000100000f0000000000000000000000000000000000000000000000000000
1
15
0x0000000000000000000000000000000000000000000000000000000000000001
0x00000100000f0000000000000000000000000000000000000000000000000000
1
15
0x0000000000000000000000000000000000000000000000000000000000000001
0x00000100000f0000000000000000000000000000000000000000000000000000
1
15
0x0000000000000000000000000000000000000000000000000000000000000001
0x00000100000f0000000000000000000000000000000000000000000000000000
1
15
0x0000000000000000000000000000000000000000000000000000000000000001
0x00000100000f0000000000000000000000000000000000000000000000000000
1
15
0x0000000000000000000000000000000000000000000000000000000000000001
0x00000100000f0000000000000000000000000000000000000000000000000000
1
15
0x0000000000000000000000000000000000000000000000000000000000000001
0x00000100000f0000000000000000000000000000000000000000000000000000
1
15
0x0000000000000000000000000000000000000000000000000000000000000001
0x00000100000f0000000000000000000000000000000000000000000000000000
1
15
0x0000000000000000000000000000000000000000000000000000000000000001
0x00000100000f0000000000000000000000000000000000000000000000000000
1
15
0x0000000000000000000000000000000000000000000000000000000000000001
0x00000100000f0000000000000000000000000000000000000000000000000000
1
15
0x0000000000000000000000000000000000000000000000000000000000000001
0x00000100000f0000000000000000000000000000000000000000000000000000
1
15
0x0000000000000000000000000000000000000000000000000000000000000001
0x00000100000f0000000000000000000000000000000000000000000000000000
1
15
0x0000000000000000000000000000000000000000000000000000000000000001
0x00000100000f0000000000000000000000000000000000000000000000000000
1
15
0x0000000000000000000000000000000000000000000000000000000000000001
0x00000100000f0000000000000000000000000000000000000000000000000000
1
15
0x0000000000000000000000000000000000000000000000000000000000000001
0x00000100000f0000000000000000000000000000000000000000000000000000
1
15
0x0000000000000000000000000000000000000000000000000000000000000001
0x00000100000f0000000000000000000000000000000000000000000000000000
1
15
0x0000000000000000000000000000000000000000000000000000000000000001
0x00000100000f0000000000000000000000000000000000000000000000000000
1
15
0x0000000000000000000000000000000000000000000000000000000000000001
0x00000100000f0000000000000000000000000000000000000000000000000000
1
15
0x0000000000000000000000000000000000000000000000000000000000000001
0x00000100000f0000000000000000000000000000000000000000000000000000
1
15
0x0000000000000000000000000000000000000000000000000000000000000001
0x00000100000f0000000000000000000000000000000000000000000000000000
1
15
0x0000000000000000000000000000000000000000000000000000000000000001
0x00000100000f0000000000000000000000000000000000000000000000000000
1
15
0x0000000000000000000000000000000000000000000000000000000000000001
0x00000100000f0000000000000000000000000000000000000000000000000000
1
15
0x0000000000000000000000000000000000000000000000000000000000000001
0x00000100000f0000000000000000000000000000000000000000000000000000
1
15
0x0000000000000000000000000000000000000000000000000000000000000001
0x00000100000f0000000000000000000000000000000000000000000000000000
1
15
0x0000000000000000000000000000000000000000000000000000000000000001
0x00000100000f0000000000000000000000000000000000000000000000000000
1
15
0x0000000000000000000000000000000000000000000000000000000000000001
0x00000100000f0000000000000000000000000000000000000000000000000000
0x00000100000f00000100000f00000100000f00000100000f00000100000f00000100000f00000100000f00000100000f00000100000f00000100000f00000100000f00000100000f00000100000f00000100000f00000100000f00000100000f00000100000f00000100000f00000100000f00000100000f00000100000f00000100000f00000100000f00000100000f00000100000f00000100000f00000100000f00000100000f00000100000f00000100000f00000100000f00000100000f
----
0x00000100000f00000100000f00000100000f00000100000f00000100000f0000
15
1
----
----
0x00000100000f00000100000f00000100000f00000100000f00000100000f0000
15
1
----
----
0x00000100000f00000100000f00000100000f00000100000f00000100000f0000
15
1
----
----
0x00000100000f00000100000f00000100000f00000100000f00000100000f0000
15
1
----
----
0x00000100000f00000100000f00000100000f00000100000f00000100000f0000
15
1
----
----
0x00000100000f00000100000f00000100000f00000100000f00000100000f0000
15
1
----
----
0x00000100000f00000100000f00000100000f00000100000f00000100000f0000
15
1
----
----
0x00000100000f00000100000f00000100000f00000100000f00000100000f0000
15
1
----
----
0x00000100000f00000100000f00000100000f00000100000f00000100000f0000
15
1
----
----
0x00000100000f00000100000f00000100000f00000100000f00000100000f0000
15
1
----
----
0x00000100000f00000100000f00000100000f00000100000f00000100000f0000
15
1
----
----
0x00000100000f00000100000f00000100000f00000100000f00000100000f0000
15
1
----
----
0x00000100000f00000100000f00000100000f00000100000f00000100000f0000
15
1
----
----
0x00000100000f00000100000f00000100000f00000100000f00000100000f0000
15
1
----
----
0x00000100000f00000100000f00000100000f00000100000f00000100000f0000
15
1
----
----
0x00000100000f00000100000f00000100000f00000100000f00000100000f0000
15
1
----
----
0x00000100000f00000100000f00000100000f00000100000f00000100000f0000
15
1
----
----
0x00000100000f00000100000f00000100000f00000100000f00000100000f0000
15
1
----
----
0x00000100000f00000100000f00000100000f00000100000f00000100000f0000
15
1
----
----
0x00000100000f00000100000f00000100000f00000100000f00000100000f0000
15
1
----
----
0x00000100000f00000100000f00000100000f00000100000f00000100000f0000
15
1
----
----
0x00000100000f00000100000f00000100000f00000100000f00000100000f0000
15
1
----
----
0x00000100000f00000100000f00000100000f00000100000f00000100000f0000
15
1
----
----
0x00000100000f00000100000f00000100000f00000100000f00000100000f0000
15
1
----
----
0x00000100000f00000100000f00000100000f00000100000f00000100000f0000
15
1
----
----
0x00000100000f00000100000f00000100000f00000100000f00000100000f0000
15
1
----
----
0x00000100000f00000100000f00000100000f00000100000f00000100000f0000
15
1
----
----
0x00000100000f00000100000f00000100000f00000100000f00000100000f0000
15
1
----
----
0x00000100000f00000100000f00000100000f00000100000f0000000000000000
15
1
----
----
0x00000100000f00000100000f00000100000f0000000000000000000000000000
15
1
----
----
0x00000100000f00000100000f0000000000000000000000000000000000000000
15
1
----
----
0x00000100000f0000000000000000000000000000000000000000000000000000
15
1
----
0xcf84617364668471776572847a786376
0xcf84617364668471776572847a786376
0xcf84617364668471776572847a786376
0xcf84617364668471776572847a786376
0xcf84617364668471776572847a786376
0xcf84617364668471776572847a786376
0xcf84617364668471776572847a786376
0xcf84617364668471776572847a786376
0xcf84617364668471776572847a786376
0xcf84617364668471776572847a786376
0xcf84617364668471776572847a786376
0xcf84617364668471776572847a786376
0xcf84617364668471776572847a786376
0xcf84617364668471776572847a786376
0xcf84617364668471776572847a786376
0xcf84617364668471776572847a786376
0xcf84617364668471776572847a786376
0xcf84617364668471776572847a786376
0xcf84617364668471776572847a786376
0xcf84617364668471776572847a786376
0xcf84617364668471776572847a786376
0xcf84617364668471776572847a786376
0xcf84617364668471776572847a786376
0xcf84617364668471776572847a786376
0xcf84617364668471776572847a786376
0xcf84617364668471776572847a786376
0xcf84617364668471776572847a786376
0xcf84617364668471776572847a786376
0xcf84617364668471776572847a786376
0xcf84617364668471776572847a786376
0xcf84617364668471776572847a786376
0xcf84617364668471776572847a786376
5) should run test: longList2
160
0xc4c2c0c0c0
1
2
0x0000000000000000000000000000000000000000000000000000000000000001
0x0000010000020000000000000000000000000000000000000000000000000000
1
0
0x0000000000000000000000000000000000000000000000000000000000000001
0x0000010000000000000000000000000000000000000000000000000000000000
0x000001000002000001000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000
----
0x0000010000020000010000000000000000000000000000000000000000000000
2
1
----
----
0x0000010000000000000000000000000000000000000000000000000000000000
0
1
----
0xc2c0c0
0xc0
6) should run test: listsoflists
160
0xc7c0c1c0c3c0c1c0
1
0
0x0000000000000000000000000000000000000000000000000000000000000001
0x0000010000000000000000000000000000000000000000000000000000000000
1
1
0x0000000000000000000000000000000000000000000000000000000000000001
0x0000010000010000000000000000000000000000000000000000000000000000
1
3
0x0000000000000000000000000000000000000000000000000000000000000001
0x0000010000030000000000000000000000000000000000000000000000000000
0x000001000000000001000001000001000003000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000
----
0x0000010000000000010000010000010000030000000000000000000000000000
0
1
----
----
0x0000010000010000010000030000000000000000000000000000000000000000
1
1
----
----
0x0000010000030000000000000000000000000000000000000000000000000000
3
1
----
0xc0
0xc1c0
0xc3c0c1c0
7) should run test: listsoflists2
160
0xecca846b6579318476616c31ca846b6579328476616c32ca846b65793384766100000000000000000000000000
1
10
0x0000000000000000000000000000000000000000000000000000000000000001
0x00000100000a0000000000000000000000000000000000000000000000000000
1
10
0x0000000000000000000000000000000000000000000000000000000000000001
0x00000100000a0000000000000000000000000000000000000000000000000000
1
10
0x0000000000000000000000000000000000000000000000000000000000000001
0x00000100000a0000000000000000000000000000000000000000000000000000
1
10
0x0000000000000000000000000000000000000000000000000000000000000001
0x00000100000a0000000000000000000000000000000000000000000000000000
0x00000100000a00000100000a00000100000a00000100000a000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000
----
0x00000100000a00000100000a00000100000a00000100000a0000000000000000
10
1
----
----
0x00000100000a00000100000a00000100000a0000000000000000000000000000
10
1
----
----
0x00000100000a00000100000a0000000000000000000000000000000000000000
10
1
----
----
0x00000100000a0000000000000000000000000000000000000000000000000000
10
1
----
0xca846b6579318476616c31
0xca846b6579328476616c32
0xca846b6579338476616c33
0xca846b6579348476616c34
8) should run test: dictTest1
1 passing (2s)
8 failing
1) Lib_RLPReader
JSON tests
readList
should run test: stringlist:
AssertionError: expected [ Array(1) ] to deeply equal [ Array(1) ]
+ expected - actual
[
[
- "0x83646f67"
- "0x83676f64"
- "0x83636174"
+ "0xcc83646f6783676f6483636174"
+ "0xcc83646f6783676f6483636174"
+ "0xcc83646f6783676f6483636174"
]
]
at Context.<anonymous> (test/helpers/test-runner/json-test-runner.ts:21:100)
at processTicksAndRejections (internal/process/task_queues.js:93:5)
2) Lib_RLPReader
JSON tests
readList
should run test: multilist:
AssertionError: expected [ [ '0x827a77', '0xc104', '0x0100' ] ] to deeply equal [ Array(1) ]
+ expected - actual
[
[
- "0x827a77"
- "0xc104"
- "0x0100"
+ "0xc6827a77c10401"
+ "0xc6827a77c10401"
+ "0xc6827a77c10401"
]
]
at Context.<anonymous> (test/helpers/test-runner/json-test-runner.ts:21:100)
at processTicksAndRejections (internal/process/task_queues.js:93:5)
3) Lib_RLPReader
JSON tests
readList
should run test: shortListMax1:
AssertionError: expected [ Array(1) ] to deeply equal [ Array(1) ]
+ expected - actual
[
[
- "0x8461736466"
- "0x8471776572"
- "0x847a786376"
- "0x8461736466"
- "0x8471776572"
- "0x847a786376"
- "0x8461736466"
- "0x8471776572"
- "0x847a786376"
- "0x8461736466"
- "0x8471776572"
+ "0xf784617364668471776572847a78637684617364668471776572847a78637684617364668471776572847a78637684617364668471776572"
+ "0xf784617364668471776572847a78637684617364668471776572847a78637684617364668471776572847a78637684617364668471776572"
+ "0xf784617364668471776572847a78637684617364668471776572847a78637684617364668471776572847a78637684617364668471776572"
+ "0xf784617364668471776572847a78637684617364668471776572847a78637684617364668471776572847a78637684617364668471776572"
+ "0xf784617364668471776572847a78637684617364668471776572847a78637684617364668471776572847a78637684617364668471776572"
+ "0xf784617364668471776572847a78637684617364668471776572847a78637684617364668471776572847a78637684617364668471776572"
+ "0xf784617364668471776572847a78637684617364668471776572847a78637684617364668471776572847a78637684617364668471776572"
+ "0xf784617364668471776572847a78637684617364668471776572847a78637684617364668471776572847a78637684617364668471776572"
+ "0xf784617364668471776572847a78637684617364668471776572847a78637684617364668471776572847a78637684617364668471776572"
+ "0xf784617364668471776572847a78637684617364668471776572847a78637684617364668471776572847a78637684617364668471776572"
+ "0xf784617364668471776572847a78637684617364668471776572847a78637684617364668471776572847a78637684617364668471776572"
]
]
at Context.<anonymous> (test/helpers/test-runner/json-test-runner.ts:21:100)
at processTicksAndRejections (internal/process/task_queues.js:93:5)
4) Lib_RLPReader
JSON tests
readList
should run test: longList1:
AssertionError: expected [ Array(1) ] to deeply equal [ Array(1) ]
+ expected - actual
[
[
- "0xcf84617364668471776572847a786376"
- "0xcf84617364668471776572847a786376"
- "0xcf84617364668471776572847a786376"
- "0xcf84617364668471776572847a786376"
+ "0xf840cf84617364668471776572847a786376cf84617364668471776572847a786376cf84617364668471776572847a786376cf84617364668471776572847a786376"
+ "0xf840cf84617364668471776572847a786376cf84617364668471776572847a786376cf84617364668471776572847a786376cf84617364668471776572847a786376"
+ "0xf840cf84617364668471776572847a786376cf84617364668471776572847a786376cf84617364668471776572847a786376cf84617364668471776572847a786376"
+ "0xf840cf84617364668471776572847a786376cf84617364668471776572847a786376cf84617364668471776572847a786376cf84617364668471776572847a786376"
]
]
at Context.<anonymous> (test/helpers/test-runner/json-test-runner.ts:21:100)
at processTicksAndRejections (internal/process/task_queues.js:93:5)
5) Lib_RLPReader
JSON tests
readList
should run test: longList2:
AssertionError: expected [ Array(1) ] to deeply equal [ Array(1) ]
+ expected - actual
[
[
- "0xcf84617364668471776572847a786376"
- "0xcf84617364668471776572847a786376"
- "0xcf84617364668471776572847a786376"
- "0xcf84617364668471776572847a786376"
- "0xcf84617364668471776572847a786376"
- "0xcf84617364668471776572847a786376"
- "0xcf84617364668471776572847a786376"
- "0xcf84617364668471776572847a786376"
- "0xcf84617364668471776572847a786376"
- "0xcf84617364668471776572847a786376"
- "0xcf84617364668471776572847a786376"
- "0xcf84617364668471776572847a786376"
- "0xcf84617364668471776572847a786376"
- "0xcf84617364668471776572847a786376"
- "0xcf84617364668471776572847a786376"
- "0xcf84617364668471776572847a786376"
- "0xcf84617364668471776572847a786376"
- "0xcf84617364668471776572847a786376"
- "0xcf84617364668471776572847a786376"
- "0xcf84617364668471776572847a786376"
- "0xcf84617364668471776572847a786376"
- "0xcf84617364668471776572847a786376"
- "0xcf84617364668471776572847a786376"
- "0xcf84617364668471776572847a786376"
- "0xcf84617364668471776572847a786376"
- "0xcf84617364668471776572847a786376"
- "0xcf84617364668471776572847a786376"
- "0xcf84617364668471776572847a786376"
- "0xcf84617364668471776572847a786376"
- "0xcf84617364668471776572847a786376"
- "0xcf84617364668471776572847a786376"
- "0xcf84617364668471776572847a786376"
+ "0xf90200cf84617364668471776572847a786376cf84617364668471776572847a786376cf84617364668471776572847a786376cf84617364668471776572847a786376cf84617364668471776572847a786376cf84617364668471776572847a786376cf84617364668471776572847a786376cf84617364668471776572847a786376cf84617364668471776572847a786376cf84617364668471776572847a786376cf84617364668471776572847a786376cf84617364668471776572847a786376cf84617364668471776572847a786376cf84617364668471776572847a786376cf84617364668471776572847a786376cf84617364668471776572847a786376cf84617364668471776572847a786376cf84617364668471776572847a786376cf84617364668471776572847a786376cf84617364668471776572847a786376cf84617364668471776572847a786376cf84617364668471776572847a786376cf84617364668471776572847a786376cf84617364668471776572847a786376cf84617364668471776572847a786376cf84617364668471776572847a786376cf84617364668471776572847a786376cf84617364668471776572847a786376cf84617364668471776572847a786376cf84617364668471776572847a786376cf84617364668471776572847a786376cf84617364668471776572847a786376"
+ "0xf90200cf84617364668471776572847a786376cf84617364668471776572847a786376cf84617364668471776572847a786376cf84617364668471776572847a786376cf84617364668471776572847a786376cf84617364668471776572847a786376cf84617364668471776572847a786376cf84617364668471776572847a786376cf84617364668471776572847a786376cf84617364668471776572847a786376cf84617364668471776572847a786376cf84617364668471776572847a786376cf84617364668471776572847a786376cf84617364668471776572847a786376cf84617364668471776572847a786376cf84617364668471776572847a786376cf84617364668471776572847a786376cf84617364668471776572847a786376cf84617364668471776572847a786376cf84617364668471776572847a786376cf84617364668471776572847a786376cf84617364668471776572847a786376cf84617364668471776572847a786376cf84617364668471776572847a786376cf84617364668471776572847a786376cf84617364668471776572847a786376cf84617364668471776572847a786376cf84617364668471776572847a786376cf84617364668471776572847a786376cf84617364668471776572847a786376cf84617364668471776572847a786376cf84617364668471776572847a786376"
+ "0xf90200cf84617364668471776572847a786376cf84617364668471776572847a786376cf84617364668471776572847a786376cf84617364668471776572847a786376cf84617364668471776572847a786376cf84617364668471776572847a786376cf84617364668471776572847a786376cf84617364668471776572847a786376cf84617364668471776572847a786376cf84617364668471776572847a786376cf84617364668471776572847a786376cf84617364668471776572847a786376cf84617364668471776572847a786376cf84617364668471776572847a786376cf84617364668471776572847a786376cf84617364668471776572847a786376cf84617364668471776572847a786376cf84617364668471776572847a786376cf84617364668471776572847a786376cf84617364668471776572847a786376cf84617364668471776572847a786376cf84617364668471776572847a786376cf84617364668471776572847a786376cf84617364668471776572847a786376cf84617364668471776572847a786376cf84617364668471776572847a786376cf84617364668471776572847a786376cf84617364668471776572847a786376cf84617364668471776572847a786376cf84617364668471776572847a786376cf84617364668471776572847a786376cf84617364668471776572847a786376"
+ "0xf90200cf84617364668471776572847a786376cf84617364668471776572847a786376cf84617364668471776572847a786376cf84617364668471776572847a786376cf84617364668471776572847a786376cf84617364668471776572847a786376cf84617364668471776572847a786376cf84617364668471776572847a786376cf84617364668471776572847a786376cf84617364668471776572847a786376cf84617364668471776572847a786376cf84617364668471776572847a786376cf84617364668471776572847a786376cf84617364668471776572847a786376cf84617364668471776572847a786376cf84617364668471776572847a786376cf84617364668471776572847a786376cf84617364668471776572847a786376cf84617364668471776572847a786376cf84617364668471776572847a786376cf84617364668471776572847a786376cf84617364668471776572847a786376cf84617364668471776572847a786376cf84617364668471776572847a786376cf84617364668471776572847a786376cf84617364668471776572847a786376cf84617364668471776572847a786376cf84617364668471776572847a786376cf84617364668471776572847a786376cf84617364668471776572847a786376cf84617364668471776572847a786376cf84617364668471776572847a786376"
+ "0xf90200cf84617364668471776572847a786376cf84617364668471776572847a786376cf84617364668471776572847a786376cf84617364668471776572847a786376cf84617364668471776572847a786376cf84617364668471776572847a786376cf84617364668471776572847a786376cf84617364668471776572847a786376cf84617364668471776572847a786376cf84617364668471776572847a786376cf84617364668471776572847a786376cf84617364668471776572847a786376cf84617364668471776572847a786376cf84617364668471776572847a786376cf84617364668471776572847a786376cf84617364668471776572847a786376cf84617364668471776572847a786376cf84617364668471776572847a786376cf84617364668471776572847a786376cf84617364668471776572847a786376cf84617364668471776572847a786376cf84617364668471776572847a786376cf84617364668471776572847a786376cf84617364668471776572847a786376cf84617364668471776572847a786376cf84617364668471776572847a786376cf84617364668471776572847a786376cf84617364668471776572847a786376cf84617364668471776572847a786376cf84617364668471776572847a786376cf84617364668471776572847a786376cf84617364668471776572847a786376"
+ "0xf90200cf84617364668471776572847a786376cf84617364668471776572847a786376cf84617364668471776572847a786376cf84617364668471776572847a786376cf84617364668471776572847a786376cf84617364668471776572847a786376cf84617364668471776572847a786376cf84617364668471776572847a786376cf84617364668471776572847a786376cf84617364668471776572847a786376cf84617364668471776572847a786376cf84617364668471776572847a786376cf84617364668471776572847a786376cf84617364668471776572847a786376cf84617364668471776572847a786376cf84617364668471776572847a786376cf84617364668471776572847a786376cf84617364668471776572847a786376cf84617364668471776572847a786376cf84617364668471776572847a786376cf84617364668471776572847a786376cf84617364668471776572847a786376cf84617364668471776572847a786376cf84617364668471776572847a786376cf84617364668471776572847a786376cf84617364668471776572847a786376cf84617364668471776572847a786376cf84617364668471776572847a786376cf84617364668471776572847a786376cf84617364668471776572847a786376cf84617364668471776572847a786376cf84617364668471776572847a786376"
+ "0xf90200cf84617364668471776572847a786376cf84617364668471776572847a786376cf84617364668471776572847a786376cf84617364668471776572847a786376cf84617364668471776572847a786376cf84617364668471776572847a786376cf84617364668471776572847a786376cf84617364668471776572847a786376cf84617364668471776572847a786376cf84617364668471776572847a786376cf84617364668471776572847a786376cf84617364668471776572847a786376cf84617364668471776572847a786376cf84617364668471776572847a786376cf84617364668471776572847a786376cf84617364668471776572847a786376cf84617364668471776572847a786376cf84617364668471776572847a786376cf84617364668471776572847a786376cf84617364668471776572847a786376cf84617364668471776572847a786376cf84617364668471776572847a786376cf84617364668471776572847a786376cf84617364668471776572847a786376cf84617364668471776572847a786376cf84617364668471776572847a786376cf84617364668471776572847a786376cf84617364668471776572847a786376cf84617364668471776572847a786376cf84617364668471776572847a786376cf84617364668471776572847a786376cf84617364668471776572847a786376"
+ "0xf90200cf84617364668471776572847a786376cf84617364668471776572847a786376cf84617364668471776572847a786376cf84617364668471776572847a786376cf84617364668471776572847a786376cf84617364668471776572847a786376cf84617364668471776572847a786376cf84617364668471776572847a786376cf84617364668471776572847a786376cf84617364668471776572847a786376cf84617364668471776572847a786376cf84617364668471776572847a786376cf84617364668471776572847a786376cf84617364668471776572847a786376cf84617364668471776572847a786376cf84617364668471776572847a786376cf84617364668471776572847a786376cf84617364668471776572847a786376cf84617364668471776572847a786376cf84617364668471776572847a786376cf84617364668471776572847a786376cf84617364668471776572847a786376cf84617364668471776572847a786376cf84617364668471776572847a786376cf84617364668471776572847a786376cf84617364668471776572847a786376cf84617364668471776572847a786376cf84617364668471776572847a786376cf84617364668471776572847a786376cf84617364668471776572847a786376cf84617364668471776572847a786376cf84617364668471776572847a786376"
+ "0xf90200cf84617364668471776572847a786376cf84617364668471776572847a786376cf84617364668471776572847a786376cf84617364668471776572847a786376cf84617364668471776572847a786376cf84617364668471776572847a786376cf84617364668471776572847a786376cf84617364668471776572847a786376cf84617364668471776572847a786376cf84617364668471776572847a786376cf84617364668471776572847a786376cf84617364668471776572847a786376cf84617364668471776572847a786376cf84617364668471776572847a786376cf84617364668471776572847a786376cf84617364668471776572847a786376cf84617364668471776572847a786376cf84617364668471776572847a786376cf84617364668471776572847a786376cf84617364668471776572847a786376cf84617364668471776572847a786376cf84617364668471776572847a786376cf84617364668471776572847a786376cf84617364668471776572847a786376cf84617364668471776572847a786376cf84617364668471776572847a786376cf84617364668471776572847a786376cf84617364668471776572847a786376cf84617364668471776572847a786376cf84617364668471776572847a786376cf84617364668471776572847a786376cf84617364668471776572847a786376"
+ "0xf90200cf84617364668471776572847a786376cf84617364668471776572847a786376cf84617364668471776572847a786376cf84617364668471776572847a786376cf84617364668471776572847a786376cf84617364668471776572847a786376cf84617364668471776572847a786376cf84617364668471776572847a786376cf84617364668471776572847a786376cf84617364668471776572847a786376cf84617364668471776572847a786376cf84617364668471776572847a786376cf84617364668471776572847a786376cf84617364668471776572847a786376cf84617364668471776572847a786376cf84617364668471776572847a786376cf84617364668471776572847a786376cf84617364668471776572847a786376cf84617364668471776572847a786376cf84617364668471776572847a786376cf84617364668471776572847a786376cf84617364668471776572847a786376cf84617364668471776572847a786376cf84617364668471776572847a786376cf84617364668471776572847a786376cf84617364668471776572847a786376cf84617364668471776572847a786376cf84617364668471776572847a786376cf84617364668471776572847a786376cf84617364668471776572847a786376cf84617364668471776572847a786376cf84617364668471776572847a786376"
+ "0xf90200cf84617364668471776572847a786376cf84617364668471776572847a786376cf84617364668471776572847a786376cf84617364668471776572847a786376cf84617364668471776572847a786376cf84617364668471776572847a786376cf84617364668471776572847a786376cf84617364668471776572847a786376cf84617364668471776572847a786376cf84617364668471776572847a786376cf84617364668471776572847a786376cf84617364668471776572847a786376cf84617364668471776572847a786376cf84617364668471776572847a786376cf84617364668471776572847a786376cf84617364668471776572847a786376cf84617364668471776572847a786376cf84617364668471776572847a786376cf84617364668471776572847a786376cf84617364668471776572847a786376cf84617364668471776572847a786376cf84617364668471776572847a786376cf84617364668471776572847a786376cf84617364668471776572847a786376cf84617364668471776572847a786376cf84617364668471776572847a786376cf84617364668471776572847a786376cf84617364668471776572847a786376cf84617364668471776572847a786376cf84617364668471776572847a786376cf84617364668471776572847a786376cf84617364668471776572847a786376"
+ "0xf90200cf84617364668471776572847a786376cf84617364668471776572847a786376cf84617364668471776572847a786376cf84617364668471776572847a786376cf84617364668471776572847a786376cf84617364668471776572847a786376cf84617364668471776572847a786376cf84617364668471776572847a786376cf84617364668471776572847a786376cf84617364668471776572847a786376cf84617364668471776572847a786376cf84617364668471776572847a786376cf84617364668471776572847a786376cf84617364668471776572847a786376cf84617364668471776572847a786376cf84617364668471776572847a786376cf84617364668471776572847a786376cf84617364668471776572847a786376cf84617364668471776572847a786376cf84617364668471776572847a786376cf84617364668471776572847a786376cf84617364668471776572847a786376cf84617364668471776572847a786376cf84617364668471776572847a786376cf84617364668471776572847a786376cf84617364668471776572847a786376cf84617364668471776572847a786376cf84617364668471776572847a786376cf84617364668471776572847a786376cf84617364668471776572847a786376cf84617364668471776572847a786376cf84617364668471776572847a786376"
+ "0xf90200cf84617364668471776572847a786376cf84617364668471776572847a786376cf84617364668471776572847a786376cf84617364668471776572847a786376cf84617364668471776572847a786376cf84617364668471776572847a786376cf84617364668471776572847a786376cf84617364668471776572847a786376cf84617364668471776572847a786376cf84617364668471776572847a786376cf84617364668471776572847a786376cf84617364668471776572847a786376cf84617364668471776572847a786376cf84617364668471776572847a786376cf84617364668471776572847a786376cf84617364668471776572847a786376cf84617364668471776572847a786376cf84617364668471776572847a786376cf84617364668471776572847a786376cf84617364668471776572847a786376cf84617364668471776572847a786376cf84617364668471776572847a786376cf84617364668471776572847a786376cf84617364668471776572847a786376cf84617364668471776572847a786376cf84617364668471776572847a786376cf84617364668471776572847a786376cf84617364668471776572847a786376cf84617364668471776572847a786376cf84617364668471776572847a786376cf84617364668471776572847a786376cf84617364668471776572847a786376"
+ "0xf90200cf84617364668471776572847a786376cf84617364668471776572847a786376cf84617364668471776572847a786376cf84617364668471776572847a786376cf84617364668471776572847a786376cf84617364668471776572847a786376cf84617364668471776572847a786376cf84617364668471776572847a786376cf84617364668471776572847a786376cf84617364668471776572847a786376cf84617364668471776572847a786376cf84617364668471776572847a786376cf84617364668471776572847a786376cf84617364668471776572847a786376cf84617364668471776572847a786376cf84617364668471776572847a786376cf84617364668471776572847a786376cf84617364668471776572847a786376cf84617364668471776572847a786376cf84617364668471776572847a786376cf84617364668471776572847a786376cf84617364668471776572847a786376cf84617364668471776572847a786376cf84617364668471776572847a786376cf84617364668471776572847a786376cf84617364668471776572847a786376cf84617364668471776572847a786376cf84617364668471776572847a786376cf84617364668471776572847a786376cf84617364668471776572847a786376cf84617364668471776572847a786376cf84617364668471776572847a786376"
+ "0xf90200cf84617364668471776572847a786376cf84617364668471776572847a786376cf84617364668471776572847a786376cf84617364668471776572847a786376cf84617364668471776572847a786376cf84617364668471776572847a786376cf84617364668471776572847a786376cf84617364668471776572847a786376cf84617364668471776572847a786376cf84617364668471776572847a786376cf84617364668471776572847a786376cf84617364668471776572847a786376cf84617364668471776572847a786376cf84617364668471776572847a786376cf84617364668471776572847a786376cf84617364668471776572847a786376cf84617364668471776572847a786376cf84617364668471776572847a786376cf84617364668471776572847a786376cf84617364668471776572847a786376cf84617364668471776572847a786376cf84617364668471776572847a786376cf84617364668471776572847a786376cf84617364668471776572847a786376cf84617364668471776572847a786376cf84617364668471776572847a786376cf84617364668471776572847a786376cf84617364668471776572847a786376cf84617364668471776572847a786376cf84617364668471776572847a786376cf84617364668471776572847a786376cf84617364668471776572847a786376"
+ "0xf90200cf84617364668471776572847a786376cf84617364668471776572847a786376cf84617364668471776572847a786376cf84617364668471776572847a786376cf84617364668471776572847a786376cf84617364668471776572847a786376cf84617364668471776572847a786376cf84617364668471776572847a786376cf84617364668471776572847a786376cf84617364668471776572847a786376cf84617364668471776572847a786376cf84617364668471776572847a786376cf84617364668471776572847a786376cf84617364668471776572847a786376cf84617364668471776572847a786376cf84617364668471776572847a786376cf84617364668471776572847a786376cf84617364668471776572847a786376cf84617364668471776572847a786376cf84617364668471776572847a786376cf84617364668471776572847a786376cf84617364668471776572847a786376cf84617364668471776572847a786376cf84617364668471776572847a786376cf84617364668471776572847a786376cf84617364668471776572847a786376cf84617364668471776572847a786376cf84617364668471776572847a786376cf84617364668471776572847a786376cf84617364668471776572847a786376cf84617364668471776572847a786376cf84617364668471776572847a786376"
+ "0xf90200cf84617364668471776572847a786376cf84617364668471776572847a786376cf84617364668471776572847a786376cf84617364668471776572847a786376cf84617364668471776572847a786376cf84617364668471776572847a786376cf84617364668471776572847a786376cf84617364668471776572847a786376cf84617364668471776572847a786376cf84617364668471776572847a786376cf84617364668471776572847a786376cf84617364668471776572847a786376cf84617364668471776572847a786376cf84617364668471776572847a786376cf84617364668471776572847a786376cf84617364668471776572847a786376cf84617364668471776572847a786376cf84617364668471776572847a786376cf84617364668471776572847a786376cf84617364668471776572847a786376cf84617364668471776572847a786376cf84617364668471776572847a786376cf84617364668471776572847a786376cf84617364668471776572847a786376cf84617364668471776572847a786376cf84617364668471776572847a786376cf84617364668471776572847a786376cf84617364668471776572847a786376cf84617364668471776572847a786376cf84617364668471776572847a786376cf84617364668471776572847a786376cf84617364668471776572847a786376"
+ "0xf90200cf84617364668471776572847a786376cf84617364668471776572847a786376cf84617364668471776572847a786376cf84617364668471776572847a786376cf84617364668471776572847a786376cf84617364668471776572847a786376cf84617364668471776572847a786376cf84617364668471776572847a786376cf84617364668471776572847a786376cf84617364668471776572847a786376cf84617364668471776572847a786376cf84617364668471776572847a786376cf84617364668471776572847a786376cf84617364668471776572847a786376cf84617364668471776572847a786376cf84617364668471776572847a786376cf84617364668471776572847a786376cf84617364668471776572847a786376cf84617364668471776572847a786376cf84617364668471776572847a786376cf84617364668471776572847a786376cf84617364668471776572847a786376cf84617364668471776572847a786376cf84617364668471776572847a786376cf84617364668471776572847a786376cf84617364668471776572847a786376cf84617364668471776572847a786376cf84617364668471776572847a786376cf84617364668471776572847a786376cf84617364668471776572847a786376cf84617364668471776572847a786376cf84617364668471776572847a786376"
+ "0xf90200cf84617364668471776572847a786376cf84617364668471776572847a786376cf84617364668471776572847a786376cf84617364668471776572847a786376cf84617364668471776572847a786376cf84617364668471776572847a786376cf84617364668471776572847a786376cf84617364668471776572847a786376cf84617364668471776572847a786376cf84617364668471776572847a786376cf84617364668471776572847a786376cf84617364668471776572847a786376cf84617364668471776572847a786376cf84617364668471776572847a786376cf84617364668471776572847a786376cf84617364668471776572847a786376cf84617364668471776572847a786376cf84617364668471776572847a786376cf84617364668471776572847a786376cf84617364668471776572847a786376cf84617364668471776572847a786376cf84617364668471776572847a786376cf84617364668471776572847a786376cf84617364668471776572847a786376cf84617364668471776572847a786376cf84617364668471776572847a786376cf84617364668471776572847a786376cf84617364668471776572847a786376cf84617364668471776572847a786376cf84617364668471776572847a786376cf84617364668471776572847a786376cf84617364668471776572847a786376"
+ "0xf90200cf84617364668471776572847a786376cf84617364668471776572847a786376cf84617364668471776572847a786376cf84617364668471776572847a786376cf84617364668471776572847a786376cf84617364668471776572847a786376cf84617364668471776572847a786376cf84617364668471776572847a786376cf84617364668471776572847a786376cf84617364668471776572847a786376cf84617364668471776572847a786376cf84617364668471776572847a786376cf84617364668471776572847a786376cf84617364668471776572847a786376cf84617364668471776572847a786376cf84617364668471776572847a786376cf84617364668471776572847a786376cf84617364668471776572847a786376cf84617364668471776572847a786376cf84617364668471776572847a786376cf84617364668471776572847a786376cf84617364668471776572847a786376cf84617364668471776572847a786376cf84617364668471776572847a786376cf84617364668471776572847a786376cf84617364668471776572847a786376cf84617364668471776572847a786376cf84617364668471776572847a786376cf84617364668471776572847a786376cf84617364668471776572847a786376cf84617364668471776572847a786376cf84617364668471776572847a786376"
+ "0xf90200cf84617364668471776572847a786376cf84617364668471776572847a786376cf84617364668471776572847a786376cf84617364668471776572847a786376cf84617364668471776572847a786376cf84617364668471776572847a786376cf84617364668471776572847a786376cf84617364668471776572847a786376cf84617364668471776572847a786376cf84617364668471776572847a786376cf84617364668471776572847a786376cf84617364668471776572847a786376cf84617364668471776572847a786376cf84617364668471776572847a786376cf84617364668471776572847a786376cf84617364668471776572847a786376cf84617364668471776572847a786376cf84617364668471776572847a786376cf84617364668471776572847a786376cf84617364668471776572847a786376cf84617364668471776572847a786376cf84617364668471776572847a786376cf84617364668471776572847a786376cf84617364668471776572847a786376cf84617364668471776572847a786376cf84617364668471776572847a786376cf84617364668471776572847a786376cf84617364668471776572847a786376cf84617364668471776572847a786376cf84617364668471776572847a786376cf84617364668471776572847a786376cf84617364668471776572847a786376"
+ "0xf90200cf84617364668471776572847a786376cf84617364668471776572847a786376cf84617364668471776572847a786376cf84617364668471776572847a786376cf84617364668471776572847a786376cf84617364668471776572847a786376cf84617364668471776572847a786376cf84617364668471776572847a786376cf84617364668471776572847a786376cf84617364668471776572847a786376cf84617364668471776572847a786376cf84617364668471776572847a786376cf84617364668471776572847a786376cf84617364668471776572847a786376cf84617364668471776572847a786376cf84617364668471776572847a786376cf84617364668471776572847a786376cf84617364668471776572847a786376cf84617364668471776572847a786376cf84617364668471776572847a786376cf84617364668471776572847a786376cf84617364668471776572847a786376cf84617364668471776572847a786376cf84617364668471776572847a786376cf84617364668471776572847a786376cf84617364668471776572847a786376cf84617364668471776572847a786376cf84617364668471776572847a786376cf84617364668471776572847a786376cf84617364668471776572847a786376cf84617364668471776572847a786376cf84617364668471776572847a786376"
+ "0xf90200cf84617364668471776572847a786376cf84617364668471776572847a786376cf84617364668471776572847a786376cf84617364668471776572847a786376cf84617364668471776572847a786376cf84617364668471776572847a786376cf84617364668471776572847a786376cf84617364668471776572847a786376cf84617364668471776572847a786376cf84617364668471776572847a786376cf84617364668471776572847a786376cf84617364668471776572847a786376cf84617364668471776572847a786376cf84617364668471776572847a786376cf84617364668471776572847a786376cf84617364668471776572847a786376cf84617364668471776572847a786376cf84617364668471776572847a786376cf84617364668471776572847a786376cf84617364668471776572847a786376cf84617364668471776572847a786376cf84617364668471776572847a786376cf84617364668471776572847a786376cf84617364668471776572847a786376cf84617364668471776572847a786376cf84617364668471776572847a786376cf84617364668471776572847a786376cf84617364668471776572847a786376cf84617364668471776572847a786376cf84617364668471776572847a786376cf84617364668471776572847a786376cf84617364668471776572847a786376"
+ "0xf90200cf84617364668471776572847a786376cf84617364668471776572847a786376cf84617364668471776572847a786376cf84617364668471776572847a786376cf84617364668471776572847a786376cf84617364668471776572847a786376cf84617364668471776572847a786376cf84617364668471776572847a786376cf84617364668471776572847a786376cf84617364668471776572847a786376cf84617364668471776572847a786376cf84617364668471776572847a786376cf84617364668471776572847a786376cf84617364668471776572847a786376cf84617364668471776572847a786376cf84617364668471776572847a786376cf84617364668471776572847a786376cf84617364668471776572847a786376cf84617364668471776572847a786376cf84617364668471776572847a786376cf84617364668471776572847a786376cf84617364668471776572847a786376cf84617364668471776572847a786376cf84617364668471776572847a786376cf84617364668471776572847a786376cf84617364668471776572847a786376cf84617364668471776572847a786376cf84617364668471776572847a786376cf84617364668471776572847a786376cf84617364668471776572847a786376cf84617364668471776572847a786376cf84617364668471776572847a786376"
+ "0xf90200cf84617364668471776572847a786376cf84617364668471776572847a786376cf84617364668471776572847a786376cf84617364668471776572847a786376cf84617364668471776572847a786376cf84617364668471776572847a786376cf84617364668471776572847a786376cf84617364668471776572847a786376cf84617364668471776572847a786376cf84617364668471776572847a786376cf84617364668471776572847a786376cf84617364668471776572847a786376cf84617364668471776572847a786376cf84617364668471776572847a786376cf84617364668471776572847a786376cf84617364668471776572847a786376cf84617364668471776572847a786376cf84617364668471776572847a786376cf84617364668471776572847a786376cf84617364668471776572847a786376cf84617364668471776572847a786376cf84617364668471776572847a786376cf84617364668471776572847a786376cf84617364668471776572847a786376cf84617364668471776572847a786376cf84617364668471776572847a786376cf84617364668471776572847a786376cf84617364668471776572847a786376cf84617364668471776572847a786376cf84617364668471776572847a786376cf84617364668471776572847a786376cf84617364668471776572847a786376"
+ "0xf90200cf84617364668471776572847a786376cf84617364668471776572847a786376cf84617364668471776572847a786376cf84617364668471776572847a786376cf84617364668471776572847a786376cf84617364668471776572847a786376cf84617364668471776572847a786376cf84617364668471776572847a786376cf84617364668471776572847a786376cf84617364668471776572847a786376cf84617364668471776572847a786376cf84617364668471776572847a786376cf84617364668471776572847a786376cf84617364668471776572847a786376cf84617364668471776572847a786376cf84617364668471776572847a786376cf84617364668471776572847a786376cf84617364668471776572847a786376cf84617364668471776572847a786376cf84617364668471776572847a786376cf84617364668471776572847a786376cf84617364668471776572847a786376cf84617364668471776572847a786376cf84617364668471776572847a786376cf84617364668471776572847a786376cf84617364668471776572847a786376cf84617364668471776572847a786376cf84617364668471776572847a786376cf84617364668471776572847a786376cf84617364668471776572847a786376cf84617364668471776572847a786376cf84617364668471776572847a786376"
+ "0xf90200cf84617364668471776572847a786376cf84617364668471776572847a786376cf84617364668471776572847a786376cf84617364668471776572847a786376cf84617364668471776572847a786376cf84617364668471776572847a786376cf84617364668471776572847a786376cf84617364668471776572847a786376cf84617364668471776572847a786376cf84617364668471776572847a786376cf84617364668471776572847a786376cf84617364668471776572847a786376cf84617364668471776572847a786376cf84617364668471776572847a786376cf84617364668471776572847a786376cf84617364668471776572847a786376cf84617364668471776572847a786376cf84617364668471776572847a786376cf84617364668471776572847a786376cf84617364668471776572847a786376cf84617364668471776572847a786376cf84617364668471776572847a786376cf84617364668471776572847a786376cf84617364668471776572847a786376cf84617364668471776572847a786376cf84617364668471776572847a786376cf84617364668471776572847a786376cf84617364668471776572847a786376cf84617364668471776572847a786376cf84617364668471776572847a786376cf84617364668471776572847a786376cf84617364668471776572847a786376"
+ "0xf90200cf84617364668471776572847a786376cf84617364668471776572847a786376cf84617364668471776572847a786376cf84617364668471776572847a786376cf84617364668471776572847a786376cf84617364668471776572847a786376cf84617364668471776572847a786376cf84617364668471776572847a786376cf84617364668471776572847a786376cf84617364668471776572847a786376cf84617364668471776572847a786376cf84617364668471776572847a786376cf84617364668471776572847a786376cf84617364668471776572847a786376cf84617364668471776572847a786376cf84617364668471776572847a786376cf84617364668471776572847a786376cf84617364668471776572847a786376cf84617364668471776572847a786376cf84617364668471776572847a786376cf84617364668471776572847a786376cf84617364668471776572847a786376cf84617364668471776572847a786376cf84617364668471776572847a786376cf84617364668471776572847a786376cf84617364668471776572847a786376cf84617364668471776572847a786376cf84617364668471776572847a786376cf84617364668471776572847a786376cf84617364668471776572847a786376cf84617364668471776572847a786376cf84617364668471776572847a786376"
+ "0xf90200cf84617364668471776572847a786376cf84617364668471776572847a786376cf84617364668471776572847a786376cf84617364668471776572847a786376cf84617364668471776572847a786376cf84617364668471776572847a786376cf84617364668471776572847a786376cf84617364668471776572847a786376cf84617364668471776572847a786376cf84617364668471776572847a786376cf84617364668471776572847a786376cf84617364668471776572847a786376cf84617364668471776572847a786376cf84617364668471776572847a786376cf84617364668471776572847a786376cf84617364668471776572847a786376cf84617364668471776572847a786376cf84617364668471776572847a786376cf84617364668471776572847a786376cf84617364668471776572847a786376cf84617364668471776572847a786376cf84617364668471776572847a786376cf84617364668471776572847a786376cf84617364668471776572847a786376cf84617364668471776572847a786376cf84617364668471776572847a786376cf84617364668471776572847a786376cf84617364668471776572847a786376cf84617364668471776572847a786376cf84617364668471776572847a786376cf84617364668471776572847a786376cf84617364668471776572847a786376"
+ "0xf90200cf84617364668471776572847a786376cf84617364668471776572847a786376cf84617364668471776572847a786376cf84617364668471776572847a786376cf84617364668471776572847a786376cf84617364668471776572847a786376cf84617364668471776572847a786376cf84617364668471776572847a786376cf84617364668471776572847a786376cf84617364668471776572847a786376cf84617364668471776572847a786376cf84617364668471776572847a786376cf84617364668471776572847a786376cf84617364668471776572847a786376cf84617364668471776572847a786376cf84617364668471776572847a786376cf84617364668471776572847a786376cf84617364668471776572847a786376cf84617364668471776572847a786376cf84617364668471776572847a786376cf84617364668471776572847a786376cf84617364668471776572847a786376cf84617364668471776572847a786376cf84617364668471776572847a786376cf84617364668471776572847a786376cf84617364668471776572847a786376cf84617364668471776572847a786376cf84617364668471776572847a786376cf84617364668471776572847a786376cf84617364668471776572847a786376cf84617364668471776572847a786376cf84617364668471776572847a786376"
+ "0xf90200cf84617364668471776572847a786376cf84617364668471776572847a786376cf84617364668471776572847a786376cf84617364668471776572847a786376cf84617364668471776572847a786376cf84617364668471776572847a786376cf84617364668471776572847a786376cf84617364668471776572847a786376cf84617364668471776572847a786376cf84617364668471776572847a786376cf84617364668471776572847a786376cf84617364668471776572847a786376cf84617364668471776572847a786376cf84617364668471776572847a786376cf84617364668471776572847a786376cf84617364668471776572847a786376cf84617364668471776572847a786376cf84617364668471776572847a786376cf84617364668471776572847a786376cf84617364668471776572847a786376cf84617364668471776572847a786376cf84617364668471776572847a786376cf84617364668471776572847a786376cf84617364668471776572847a786376cf84617364668471776572847a786376cf84617364668471776572847a786376cf84617364668471776572847a786376cf84617364668471776572847a786376cf84617364668471776572847a786376cf84617364668471776572847a786376cf84617364668471776572847a786376cf84617364668471776572847a786376"
+ "0xf90200cf84617364668471776572847a786376cf84617364668471776572847a786376cf84617364668471776572847a786376cf84617364668471776572847a786376cf84617364668471776572847a786376cf84617364668471776572847a786376cf84617364668471776572847a786376cf84617364668471776572847a786376cf84617364668471776572847a786376cf84617364668471776572847a786376cf84617364668471776572847a786376cf84617364668471776572847a786376cf84617364668471776572847a786376cf84617364668471776572847a786376cf84617364668471776572847a786376cf84617364668471776572847a786376cf84617364668471776572847a786376cf84617364668471776572847a786376cf84617364668471776572847a786376cf84617364668471776572847a786376cf84617364668471776572847a786376cf84617364668471776572847a786376cf84617364668471776572847a786376cf84617364668471776572847a786376cf84617364668471776572847a786376cf84617364668471776572847a786376cf84617364668471776572847a786376cf84617364668471776572847a786376cf84617364668471776572847a786376cf84617364668471776572847a786376cf84617364668471776572847a786376cf84617364668471776572847a786376"
]
]
at Context.<anonymous> (test/helpers/test-runner/json-test-runner.ts:21:100)
at processTicksAndRejections (internal/process/task_queues.js:93:5)
6) Lib_RLPReader
JSON tests
readList
should run test: listsoflists:
AssertionError: expected [ [ '0xc2c0c0', '0xc0' ] ] to deeply equal [ [ '0xc4c2c0c0c0', '0xc4c2c0c0c0' ] ]
+ expected - actual
[
[
- "0xc2c0c0"
- "0xc0"
+ "0xc4c2c0c0c0"
+ "0xc4c2c0c0c0"
]
]
at Context.<anonymous> (test/helpers/test-runner/json-test-runner.ts:21:100)
at runMicrotasks (<anonymous>)
at processTicksAndRejections (internal/process/task_queues.js:93:5)
7) Lib_RLPReader
JSON tests
readList
should run test: listsoflists2:
AssertionError: expected [ [ '0xc0', '0xc1c0', '0xc3c0c1c0' ] ] to deeply equal [ Array(1) ]
+ expected - actual
[
[
- "0xc0"
- "0xc1c0"
- "0xc3c0c1c0"
+ "0xc7c0c1c0c3c0c1c0"
+ "0xc7c0c1c0c3c0c1c0"
+ "0xc7c0c1c0c3c0c1c0"
]
]
at Context.<anonymous> (test/helpers/test-runner/json-test-runner.ts:21:100)
at runMicrotasks (<anonymous>)
at processTicksAndRejections (internal/process/task_queues.js:93:5)
8) Lib_RLPReader
JSON tests
readList
should run test: dictTest1:
AssertionError: expected [ Array(1) ] to deeply equal [ Array(1) ]
+ expected - actual
[
[
- "0xca846b6579318476616c31"
- "0xca846b6579328476616c32"
- "0xca846b6579338476616c33"
- "0xca846b6579348476616c34"
+ "0xecca846b6579318476616c31ca846b6579328476616c32ca846b6579338476616c33ca846b6579348476616c34"
+ "0xecca846b6579318476616c31ca846b6579328476616c32ca846b6579338476616c33ca846b6579348476616c34"
+ "0xecca846b6579318476616c31ca846b6579328476616c32ca846b6579338476616c33ca846b6579348476616c34"
+ "0xecca846b6579318476616c31ca846b6579328476616c32ca846b6579338476616c33ca846b6579348476616c34"
]
]
at Context.<anonymous> (test/helpers/test-runner/json-test-runner.ts:21:100)
at runMicrotasks (<anonymous>)
at processTicksAndRejections (internal/process/task_queues.js:93:5)
info Visit https://yarnpkg.com/en/docs/cli/run for documentation about this command.
info Visit https://yarnpkg.com/en/docs/cli/run for documentation about this command.
/* tslint:disable:no-empty */
import { expect } from '../../../setup'
/* External Imports */
import { ethers } from '@nomiclabs/buidler'
import { BigNumber, Contract, ContractFactory } from 'ethers'
/* Internal Imports */
import {
makeAddressManager,
NON_NULL_BYTES32,
NON_ZERO_ADDRESS,
NULL_BYTES32,
setProxyTarget,
TrieTestGenerator,
ZERO_ADDRESS,
} from '../../../helpers'
import { MockContract, smockit } from '@eth-optimism/smock'
import { keccak256 } from 'ethers/lib/utils'
describe('OVM_StateTransitioner', () => {
let AddressManager: Contract
before(async () => {
AddressManager = await makeAddressManager()
})
let Mock__OVM_ExecutionManager: MockContract
let Mock__OVM_StateManagerFactory: MockContract
let Mock__OVM_StateManager: MockContract
before(async () => {
Mock__OVM_ExecutionManager = smockit(
await ethers.getContractFactory('OVM_ExecutionManager')
)
Mock__OVM_StateManagerFactory = smockit(
await ethers.getContractFactory('OVM_StateManagerFactory')
)
Mock__OVM_StateManager = smockit(
await ethers.getContractFactory('OVM_StateManager')
)
await setProxyTarget(
AddressManager,
'OVM_ExecutionManager',
Mock__OVM_ExecutionManager
)
await setProxyTarget(
AddressManager,
'OVM_StateManagerFactory',
Mock__OVM_StateManagerFactory
)
Mock__OVM_StateManagerFactory.smocked.create.will.return.with(
Mock__OVM_StateManager.address
)
Mock__OVM_StateManager.smocked.putAccount.will.return()
})
let Factory__OVM_StateTransitioner: ContractFactory
before(async () => {
Factory__OVM_StateTransitioner = await ethers.getContractFactory(
'OVM_StateTransitioner'
)
})
let OVM_StateTransitioner: Contract
beforeEach(async () => {
OVM_StateTransitioner = await Factory__OVM_StateTransitioner.deploy(
AddressManager.address,
0,
NULL_BYTES32,
NULL_BYTES32
)
})
describe('proveContractState', () => {
let account: any
beforeEach(() => {
account = {
nonce: 0,
balance: 0,
storageRoot: NULL_BYTES32,
codeHash: NULL_BYTES32,
ethAddress: ZERO_ADDRESS,
isFresh: false,
}
})
describe('when provided an invalid code hash', () => {
it('should revert', async () => {})
beforeEach(() => {
account.ethAddress = NON_ZERO_ADDRESS
account.codeHash = NON_NULL_BYTES32
})
it('should revert', async () => {
await expect(
OVM_StateTransitioner.proveContractState(ZERO_ADDRESS, account, '0x')
).to.be.revertedWith('Invalid code hash provided.')
})
})
describe('when provided a valid code hash', () => {
beforeEach(async () => {
account.ethAddress = OVM_StateTransitioner.address
account.codeHash = keccak256(
await ethers.provider.getCode(OVM_StateTransitioner.address)
)
})
describe('when provided an invalid account inclusion proof', () => {
it('should revert', async () => {})
const proof = '0x'
it('should revert', async () => {
await expect(
OVM_StateTransitioner.proveContractState(
ZERO_ADDRESS,
account,
proof
)
).to.be.reverted
})
})
describe('when provided a valid account inclusion proof', () => {})
describe('when provided a valid account inclusion proof', () => {
let proof: string
beforeEach(async () => {
const generator = await TrieTestGenerator.fromAccounts({
accounts: [
{
...account,
address: NON_ZERO_ADDRESS,
},
],
secure: true,
})
const test = await generator.makeAccountProofTest(NON_ZERO_ADDRESS)
proof = test.accountTrieWitness
OVM_StateTransitioner = await Factory__OVM_StateTransitioner.deploy(
AddressManager.address,
0,
test.accountTrieRoot,
NULL_BYTES32
)
})
it('should put the account in the state manager', async () => {
await expect(
OVM_StateTransitioner.proveContractState(
NON_ZERO_ADDRESS,
account,
proof
)
).to.not.be.reverted
expect(
Mock__OVM_StateManager.smocked.putAccount.calls[0]
).to.deep.equal([
NON_ZERO_ADDRESS,
[
BigNumber.from(account.nonce),
BigNumber.from(account.balance),
account.storageRoot,
account.codeHash,
account.ethAddress,
account.isFresh,
],
])
})
})
})
})
describe('proveStorageSlot', () => {
describe('when the corresponding account is not proven', () => {
it('should revert', async () => {})
beforeEach(() => {
Mock__OVM_StateManager.smocked.hasAccount.will.return.with(false)
})
it('should revert', async () => {
await expect(
OVM_StateTransitioner.proveStorageSlot(
NON_ZERO_ADDRESS,
NON_NULL_BYTES32,
NON_NULL_BYTES32,
'0x',
'0x'
)
).to.be.revertedWith(
'Contract must be verified before proving a storage slot.'
)
})
})
describe('when the corresponding account is proven', () => {
beforeEach(() => {
Mock__OVM_StateManager.smocked.hasAccount.will.return.with(false)
})
describe('when provided an invalid slot inclusion proof', () => {
let account: any
let proof: string
beforeEach(async () => {
account = {
nonce: 0,
balance: 0,
storageRoot: NULL_BYTES32,
codeHash: NULL_BYTES32,
ethAddress: ZERO_ADDRESS,
isFresh: false,
}
const generator = await TrieTestGenerator.fromAccounts({
accounts: [
{
...account,
address: NON_ZERO_ADDRESS,
storage: [
{
key: keccak256('0x1234'),
val: keccak256('0x5678'),
},
],
},
],
secure: true,
})
const test = await generator.makeAccountProofTest(NON_ZERO_ADDRESS)
proof = test.accountTrieWitness
OVM_StateTransitioner = await Factory__OVM_StateTransitioner.deploy(
AddressManager.address,
0,
test.accountTrieRoot,
NULL_BYTES32
)
})
it('should revert', async () => {})
})
......
/* External Imports */
import * as rlp from 'rlp'
/* Internal Imports */
import { Lib_RLPReader_TEST_JSON } from '../../../data'
import { runJsonTest, toHexString } from '../../../helpers'
describe('Lib_RLPReader', () => {
//console.log(JSON.stringify(Lib_RLPReader_TEST_JSON2, null, 4))
describe('JSON tests', () => {
runJsonTest('TestLib_RLPReader', Lib_RLPReader_TEST_JSON)
})
})
export { tests as Lib_RLPWriter_TEST_JSON } from './json/libraries/rlp/Lib_RLPWriter.test.json'
export { tests as Lib_RLPReader_TEST_JSON } from './json/libraries/rlp/Lib_RLPReader.test.json'
export { tests as Lib_Bytes32Utils_TEST_JSON } from './json/libraries/utils/Lib_Bytes32Utils.test.json'
export { tests as Lib_BytesUtils_TEST_JSON } from './json/libraries/utils/Lib_BytesUtils.test.json'
export { tests as Lib_ECDSAUtils_TEST_JSON } from './json/libraries/utils/Lib_ECDSAUtils.test.json'
......
{
"tests": {
"readBool": {
"true": {
"in": [
"0x01"
],
"out": [
true
]
},
"false": {
"in": [
"0x00"
],
"out": [
false
]
}
},
"readAddress": {
"valid address": {
"in": [
"0x941212121212121212121212121212121212121212"
],
"out": [
"0x1212121212121212121212121212121212121212"
]
}
},
"readBytes": {
"bytestring00": {
"in": [
"0x00"
],
"out": [
"0x00"
]
},
"bytestring01": {
"in": [
"0x01"
],
"out": [
"0x01"
]
},
"bytestring7F": {
"in": [
"0x7f"
],
"out": [
"0x7f"
]
}
},
"readString": {
"emptystring": {
"in": [
"0x80"
],
"out": [
""
]
},
"shortstring": {
"in": [
"0x83646f67"
],
"out": [
"dog"
]
},
"shortstring2": {
"in": [
"0xb74c6f72656d20697073756d20646f6c6f722073697420616d65742c20636f6e7365637465747572206164697069736963696e6720656c69"
],
"out": [
"Lorem ipsum dolor sit amet, consectetur adipisicing eli"
]
},
"longstring": {
"in": [
"0xb8384c6f72656d20697073756d20646f6c6f722073697420616d65742c20636f6e7365637465747572206164697069736963696e6720656c6974"
],
"out": [
"Lorem ipsum dolor sit amet, consectetur adipisicing elit"
]
},
"longstring2": {
"in": [
"0xb904004c6f72656d20697073756d20646f6c6f722073697420616d65742c20636f6e73656374657475722061646970697363696e6720656c69742e20437572616269747572206d6175726973206d61676e612c20737573636970697420736564207665686963756c61206e6f6e2c20696163756c697320666175636962757320746f72746f722e2050726f696e20737573636970697420756c74726963696573206d616c6573756164612e204475697320746f72746f7220656c69742c2064696374756d2071756973207472697374697175652065752c20756c7472696365732061742072697375732e204d6f72626920612065737420696d70657264696574206d6920756c6c616d636f7270657220616c6971756574207375736369706974206e6563206c6f72656d2e2041656e65616e2071756973206c656f206d6f6c6c69732c2076756c70757461746520656c6974207661726975732c20636f6e73657175617420656e696d2e204e756c6c6120756c74726963657320747572706973206a7573746f2c20657420706f73756572652075726e6120636f6e7365637465747572206e65632e2050726f696e206e6f6e20636f6e76616c6c6973206d657475732e20446f6e65632074656d706f7220697073756d20696e206d617572697320636f6e67756520736f6c6c696369747564696e2e20566573746962756c756d20616e746520697073756d207072696d697320696e206661756369627573206f726369206c756374757320657420756c74726963657320706f737565726520637562696c69612043757261653b2053757370656e646973736520636f6e76616c6c69732073656d2076656c206d617373612066617563696275732c2065676574206c6163696e6961206c616375732074656d706f722e204e756c6c61207175697320756c747269636965732070757275732e2050726f696e20617563746f722072686f6e637573206e69626820636f6e64696d656e74756d206d6f6c6c69732e20416c697175616d20636f6e73657175617420656e696d206174206d65747573206c75637475732c206120656c656966656e6420707572757320656765737461732e20437572616269747572206174206e696268206d657475732e204e616d20626962656e64756d2c206e6571756520617420617563746f72207472697374697175652c206c6f72656d206c696265726f20616c697175657420617263752c206e6f6e20696e74657264756d2074656c6c7573206c65637475732073697420616d65742065726f732e20437261732072686f6e6375732c206d65747573206163206f726e617265206375727375732c20646f6c6f72206a7573746f20756c747269636573206d657475732c20617420756c6c616d636f7270657220766f6c7574706174"
],
"out": [
"Lorem ipsum dolor sit amet, consectetur adipiscing elit. Curabitur mauris magna, suscipit sed vehicula non, iaculis faucibus tortor. Proin suscipit ultricies malesuada. Duis tortor elit, dictum quis tristique eu, ultrices at risus. Morbi a est imperdiet mi ullamcorper aliquet suscipit nec lorem. Aenean quis leo mollis, vulputate elit varius, consequat enim. Nulla ultrices turpis justo, et posuere urna consectetur nec. Proin non convallis metus. Donec tempor ipsum in mauris congue sollicitudin. Vestibulum ante ipsum primis in faucibus orci luctus et ultrices posuere cubilia Curae; Suspendisse convallis sem vel massa faucibus, eget lacinia lacus tempor. Nulla quis ultricies purus. Proin auctor rhoncus nibh condimentum mollis. Aliquam consequat enim at metus luctus, a eleifend purus egestas. Curabitur at nibh metus. Nam bibendum, neque at auctor tristique, lorem libero aliquet arcu, non interdum tellus lectus sit amet eros. Cras rhoncus, metus ac ornare cursus, dolor justo ultrices metus, at ullamcorper volutpat"
]
}
},
"readUint256": {
"zero": {
"in": [
"0x80"
],
"out": [
0
]
},
"smallint": {
"in": [
"0x01"
],
"out": [
1
]
},
"smallint2": {
"in": [
"0x10"
],
"out": [
16
]
},
"smallint3": {
"in": [
"0x4f"
],
"out": [
79
]
},
"smallint4": {
"in": [
"0x7f"
],
"out": [
127
]
},
"mediumint1": {
"in": [
"0x8180"
],
"out": [
128
]
},
"mediumint2": {
"in": [
"0x8203e8"
],
"out": [
1000
]
},
"mediumint3": {
"in": [
"0x830186a0"
],
"out": [
100000
]
}
},
"readList": {
"emptylist": {
"in": [
"0xc0"
],
"out": [
[]
]
},
"stringlist": {
"in": [
"0xcc83646f6783676f6483636174"
],
"out": [
[
"0x83646f67",
"0x83676f64",
"0x83636174"
]
]
},
"multilist": {
"in": [
"0xc6827a77c10401"
],
"out": [
[
"0x827a77",
"0xc104",
"0x01"
]
]
},
"shortListMax1": {
"in": [
"0xf784617364668471776572847a78637684617364668471776572847a78637684617364668471776572847a78637684617364668471776572"
],
"out": [
[
"0x8461736466",
"0x8471776572",
"0x847a786376",
"0x8461736466",
"0x8471776572",
"0x847a786376",
"0x8461736466",
"0x8471776572",
"0x847a786376",
"0x8461736466",
"0x8471776572"
]
]
},
"longList1": {
"in": [
"0xf840cf84617364668471776572847a786376cf84617364668471776572847a786376cf84617364668471776572847a786376cf84617364668471776572847a786376"
],
"out": [
[
"0xcf84617364668471776572847a786376",
"0xcf84617364668471776572847a786376",
"0xcf84617364668471776572847a786376",
"0xcf84617364668471776572847a786376"
]
]
},
"longList2": {
"in": [
"0xf90200cf84617364668471776572847a786376cf84617364668471776572847a786376cf84617364668471776572847a786376cf84617364668471776572847a786376cf84617364668471776572847a786376cf84617364668471776572847a786376cf84617364668471776572847a786376cf84617364668471776572847a786376cf84617364668471776572847a786376cf84617364668471776572847a786376cf84617364668471776572847a786376cf84617364668471776572847a786376cf84617364668471776572847a786376cf84617364668471776572847a786376cf84617364668471776572847a786376cf84617364668471776572847a786376cf84617364668471776572847a786376cf84617364668471776572847a786376cf84617364668471776572847a786376cf84617364668471776572847a786376cf84617364668471776572847a786376cf84617364668471776572847a786376cf84617364668471776572847a786376cf84617364668471776572847a786376cf84617364668471776572847a786376cf84617364668471776572847a786376cf84617364668471776572847a786376cf84617364668471776572847a786376cf84617364668471776572847a786376cf84617364668471776572847a786376cf84617364668471776572847a786376cf84617364668471776572847a786376"
],
"out": [
[
"0xcf84617364668471776572847a786376",
"0xcf84617364668471776572847a786376",
"0xcf84617364668471776572847a786376",
"0xcf84617364668471776572847a786376",
"0xcf84617364668471776572847a786376",
"0xcf84617364668471776572847a786376",
"0xcf84617364668471776572847a786376",
"0xcf84617364668471776572847a786376",
"0xcf84617364668471776572847a786376",
"0xcf84617364668471776572847a786376",
"0xcf84617364668471776572847a786376",
"0xcf84617364668471776572847a786376",
"0xcf84617364668471776572847a786376",
"0xcf84617364668471776572847a786376",
"0xcf84617364668471776572847a786376",
"0xcf84617364668471776572847a786376",
"0xcf84617364668471776572847a786376",
"0xcf84617364668471776572847a786376",
"0xcf84617364668471776572847a786376",
"0xcf84617364668471776572847a786376",
"0xcf84617364668471776572847a786376",
"0xcf84617364668471776572847a786376",
"0xcf84617364668471776572847a786376",
"0xcf84617364668471776572847a786376",
"0xcf84617364668471776572847a786376",
"0xcf84617364668471776572847a786376",
"0xcf84617364668471776572847a786376",
"0xcf84617364668471776572847a786376",
"0xcf84617364668471776572847a786376",
"0xcf84617364668471776572847a786376",
"0xcf84617364668471776572847a786376",
"0xcf84617364668471776572847a786376"
]
]
},
"listsoflists": {
"in": [
"0xc4c2c0c0c0"
],
"out": [
[
"0xc2c0c0",
"0xc0"
]
]
},
"listsoflists2": {
"in": [
"0xc7c0c1c0c3c0c1c0"
],
"out": [
[
"0xc0",
"0xc1c0",
"0xc3c0c1c0"
]
]
},
"dictTest1": {
"in": [
"0xecca846b6579318476616c31ca846b6579328476616c32ca846b6579338476616c33ca846b6579348476616c34"
],
"out": [
[
"0xca846b6579318476616c31",
"0xca846b6579328476616c32",
"0xca846b6579338476616c33",
"0xca846b6579348476616c34"
]
]
}
}
}
}
......@@ -48,8 +48,8 @@ const rlpEncodeAccount = (account: EthereumAccount): string => {
rlp.encode([
account.nonce,
account.balance,
account.codeHash || NULL_BYTES32,
account.storageRoot || NULL_BYTES32,
account.codeHash || NULL_BYTES32,
])
)
}
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment