Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
N
nebula
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
exchain
nebula
Commits
e7b0d3de
Commit
e7b0d3de
authored
Mar 04, 2021
by
Kelvin Fichter
Committed by
GitHub
Mar 04, 2021
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Clean up OVMCodec a bit (#287)
parent
497a8bbd
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
23 additions
and
31 deletions
+23
-31
Lib_OVMCodec.sol
...acts/optimistic-ethereum/libraries/codec/Lib_OVMCodec.sol
+23
-31
No files found.
packages/contracts/contracts/optimistic-ethereum/libraries/codec/Lib_OVMCodec.sol
View file @
e7b0d3de
...
...
@@ -14,19 +14,6 @@ import { Lib_SafeExecutionManagerWrapper } from "../../libraries/wrappers/Lib_Sa
*/
library Lib_OVMCodec {
/*************
* Constants *
*************/
bytes constant internal RLP_NULL_BYTES = hex'80';
bytes constant internal NULL_BYTES = bytes('');
// Ring buffer IDs
bytes32 constant internal RING_BUFFER_SCC_BATCHES = keccak256("RING_BUFFER_SCC_BATCHES");
bytes32 constant internal RING_BUFFER_CTC_BATCHES = keccak256("RING_BUFFER_CTC_BATCHES");
bytes32 constant internal RING_BUFFER_CTC_QUEUE = keccak256("RING_BUFFER_CTC_QUEUE");
/*********
* Enums *
*********/
...
...
@@ -110,14 +97,14 @@ library Lib_OVMCodec {
}
/**********************
***********************
* Internal Functions
: Encoding and Decoding
*
**********************
***********************
/
/**********************
* Internal Functions *
**********************/
/**
* Decodes an EOA transaction (i.e., native Ethereum RLP encoding).
* @param _transaction Encoded EOA transaction.
* @return
_decoded
Transaction decoded into a struct.
* @return Transaction decoded into a struct.
*/
function decodeEIP155Transaction(
bytes memory _transaction,
...
...
@@ -126,7 +113,7 @@ library Lib_OVMCodec {
internal
pure
returns (
EIP155Transaction memory
_decoded
EIP155Transaction memory
)
{
if (_isEthSignedMessage) {
...
...
@@ -165,12 +152,17 @@ library Lib_OVMCodec {
}
}
/**
* Decompresses a compressed EIP155 transaction.
* @param _transaction Compressed EIP155 transaction bytes.
* @return Transaction parsed into a struct.
*/
function decompressEIP155Transaction(
bytes memory _transaction
)
internal
returns (
EIP155Transaction memory
_decompressed
EIP155Transaction memory
)
{
return EIP155Transaction({
...
...
@@ -233,7 +225,7 @@ library Lib_OVMCodec {
/**
* Encodes a standard OVM transaction.
* @param _transaction OVM transaction to encode.
* @return
_encoded
Encoded transaction bytes.
* @return Encoded transaction bytes.
*/
function encodeTransaction(
Transaction memory _transaction
...
...
@@ -241,7 +233,7 @@ library Lib_OVMCodec {
internal
pure
returns (
bytes memory
_encoded
bytes memory
)
{
return abi.encodePacked(
...
...
@@ -258,7 +250,7 @@ library Lib_OVMCodec {
/**
* Hashes a standard OVM transaction.
* @param _transaction OVM transaction to encode.
* @return
_hash
Hashed transaction
* @return Hashed transaction
*/
function hashTransaction(
Transaction memory _transaction
...
...
@@ -266,7 +258,7 @@ library Lib_OVMCodec {
internal
pure
returns (
bytes32
_hash
bytes32
)
{
return keccak256(encodeTransaction(_transaction));
...
...
@@ -275,7 +267,7 @@ library Lib_OVMCodec {
/**
* Converts an OVM account to an EVM account.
* @param _in OVM account to convert.
* @return
_out
Converted EVM account.
* @return Converted EVM account.
*/
function toEVMAccount(
Account memory _in
...
...
@@ -283,7 +275,7 @@ library Lib_OVMCodec {
internal
pure
returns (
EVMAccount memory
_out
EVMAccount memory
)
{
return EVMAccount({
...
...
@@ -297,7 +289,7 @@ library Lib_OVMCodec {
/**
* @notice RLP-encodes an account state struct.
* @param _account Account state struct.
* @return
_encoded
RLP-encoded account state.
* @return RLP-encoded account state.
*/
function encodeEVMAccount(
EVMAccount memory _account
...
...
@@ -305,7 +297,7 @@ library Lib_OVMCodec {
internal
pure
returns (
bytes memory
_encoded
bytes memory
)
{
bytes[] memory raw = new bytes[](4);
...
...
@@ -332,7 +324,7 @@ library Lib_OVMCodec {
/**
* @notice Decodes an RLP-encoded account state into a useful struct.
* @param _encoded RLP-encoded account state.
* @return
_account
Account state struct.
* @return Account state struct.
*/
function decodeEVMAccount(
bytes memory _encoded
...
...
@@ -340,7 +332,7 @@ library Lib_OVMCodec {
internal
pure
returns (
EVMAccount memory
_account
EVMAccount memory
)
{
Lib_RLPReader.RLPItem[] memory accountState = Lib_RLPReader.readList(_encoded);
...
...
@@ -356,7 +348,7 @@ library Lib_OVMCodec {
/**
* Calculates a hash for a given batch header.
* @param _batchHeader Header to hash.
* @return
_hash
Hash of the header.
* @return Hash of the header.
*/
function hashBatchHeader(
Lib_OVMCodec.ChainBatchHeader memory _batchHeader
...
...
@@ -364,7 +356,7 @@ library Lib_OVMCodec {
internal
pure
returns (
bytes32
_hash
bytes32
)
{
return keccak256(
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment