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
c87d94bb
Commit
c87d94bb
authored
Oct 27, 2023
by
clabby
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
@inphi nits
Co-Authored-By:
inphi
<
mlaw2501@gmail.com
>
parent
679eb237
Changes
7
Hide whitespace changes
Inline
Side-by-side
Showing
7 changed files
with
20 additions
and
25 deletions
+20
-25
config.go
op-node/node/config.go
+1
-1
service.go
op-node/service.go
+1
-6
README.md
op-service/rethdb-reader/README.md
+4
-4
lib.rs
op-service/rethdb-reader/src/lib.rs
+2
-2
eth_client.go
op-service/sources/eth_client.go
+2
-2
receipts.go
op-service/sources/receipts.go
+4
-4
reth_db.go
op-service/sources/reth_db.go
+6
-6
No files found.
op-node/node/config.go
View file @
c87d94bb
...
@@ -62,7 +62,7 @@ type Config struct {
...
@@ -62,7 +62,7 @@ type Config struct {
Cancel
context
.
CancelCauseFunc
Cancel
context
.
CancelCauseFunc
// [OPTIONAL] The reth DB path to read receipts from
// [OPTIONAL] The reth DB path to read receipts from
RethDBPath
*
string
RethDBPath
string
}
}
type
RPCConfig
struct
{
type
RPCConfig
struct
{
...
...
op-node/service.go
View file @
c87d94bb
...
@@ -71,11 +71,6 @@ func NewConfig(ctx *cli.Context, log log.Logger) (*node.Config, error) {
...
@@ -71,11 +71,6 @@ func NewConfig(ctx *cli.Context, log log.Logger) (*node.Config, error) {
haltOption
=
""
haltOption
=
""
}
}
var
rethDBPath
*
string
if
rdb
:=
ctx
.
String
(
flags
.
L1RethDBPath
.
Name
);
rdb
!=
""
{
rethDBPath
=
&
rdb
}
cfg
:=
&
node
.
Config
{
cfg
:=
&
node
.
Config
{
L1
:
l1Endpoint
,
L1
:
l1Endpoint
,
L2
:
l2Endpoint
,
L2
:
l2Endpoint
,
...
@@ -109,7 +104,7 @@ func NewConfig(ctx *cli.Context, log log.Logger) (*node.Config, error) {
...
@@ -109,7 +104,7 @@ func NewConfig(ctx *cli.Context, log log.Logger) (*node.Config, error) {
ConfigPersistence
:
configPersistence
,
ConfigPersistence
:
configPersistence
,
Sync
:
*
syncConfig
,
Sync
:
*
syncConfig
,
RollupHalt
:
haltOption
,
RollupHalt
:
haltOption
,
RethDBPath
:
rethDBPath
,
RethDBPath
:
ctx
.
String
(
flags
.
L1RethDBPath
.
Name
)
,
}
}
if
err
:=
cfg
.
LoadPersisted
(
log
);
err
!=
nil
{
if
err
:=
cfg
.
LoadPersisted
(
log
);
err
!=
nil
{
...
...
op-service/rethdb-reader/README.md
View file @
c87d94bb
...
@@ -67,9 +67,9 @@ typedef struct ReceiptsResult {
...
@@ -67,9 +67,9 @@ typedef struct ReceiptsResult {
* - All possible nil pointer dereferences are checked, and the function will return a
* - All possible nil pointer dereferences are checked, and the function will return a
* failing [ReceiptsResult] if any are found.
* failing [ReceiptsResult] if any are found.
*/
*/
struct
ReceiptsResult
read_receipts
(
const
uint8_t
*
block_hash
,
struct
ReceiptsResult
r
db_r
ead_receipts
(
const
uint8_t
*
block_hash
,
uintptr_t
block_hash_len
,
uintptr_t
block_hash_len
,
const
char
*
db_path
);
const
char
*
db_path
);
/**
/**
* Free a string that was allocated in Rust and passed to C.
* Free a string that was allocated in Rust and passed to C.
...
@@ -77,7 +77,7 @@ struct ReceiptsResult read_receipts(const uint8_t *block_hash,
...
@@ -77,7 +77,7 @@ struct ReceiptsResult read_receipts(const uint8_t *block_hash,
* # Safety
* # Safety
* - All possible nil pointer dereferences are checked.
* - All possible nil pointer dereferences are checked.
*/
*/
void
free_string
(
char
*
string
);
void
rdb_
free_string
(
char
*
string
);
```
```
[
rust-toolchain
]:
https://rustup.rs/
[
rust-toolchain
]:
https://rustup.rs/
op-service/rethdb-reader/src/lib.rs
View file @
c87d94bb
...
@@ -11,7 +11,7 @@ mod receipts;
...
@@ -11,7 +11,7 @@ mod receipts;
/// - All possible nil pointer dereferences are checked, and the function will return a
/// - All possible nil pointer dereferences are checked, and the function will return a
/// failing [ReceiptsResult] if any are found.
/// failing [ReceiptsResult] if any are found.
#[no_mangle]
#[no_mangle]
pub
unsafe
extern
"C"
fn
read_receipts
(
pub
unsafe
extern
"C"
fn
r
db_r
ead_receipts
(
block_hash
:
*
const
u8
,
block_hash
:
*
const
u8
,
block_hash_len
:
usize
,
block_hash_len
:
usize
,
db_path
:
*
const
c_char
,
db_path
:
*
const
c_char
,
...
@@ -24,7 +24,7 @@ pub unsafe extern "C" fn read_receipts(
...
@@ -24,7 +24,7 @@ pub unsafe extern "C" fn read_receipts(
/// # Safety
/// # Safety
/// - All possible nil pointer dereferences are checked.
/// - All possible nil pointer dereferences are checked.
#[no_mangle]
#[no_mangle]
pub
unsafe
extern
"C"
fn
free_string
(
string
:
*
mut
c_char
)
{
pub
unsafe
extern
"C"
fn
rdb_
free_string
(
string
:
*
mut
c_char
)
{
// Convert the raw pointer back to a CString and let it go out of scope,
// Convert the raw pointer back to a CString and let it go out of scope,
// which will deallocate the memory.
// which will deallocate the memory.
if
!
string
.is_null
()
{
if
!
string
.is_null
()
{
...
...
op-service/sources/eth_client.go
View file @
c87d94bb
...
@@ -64,7 +64,7 @@ type EthClientConfig struct {
...
@@ -64,7 +64,7 @@ type EthClientConfig struct {
MethodResetDuration
time
.
Duration
MethodResetDuration
time
.
Duration
// [OPTIONAL] The reth DB path to fetch receipts from
// [OPTIONAL] The reth DB path to fetch receipts from
RethDBPath
*
string
RethDBPath
string
}
}
func
(
c
*
EthClientConfig
)
Check
()
error
{
func
(
c
*
EthClientConfig
)
Check
()
error
{
...
@@ -137,7 +137,7 @@ type EthClient struct {
...
@@ -137,7 +137,7 @@ type EthClient struct {
methodResetDuration
time
.
Duration
methodResetDuration
time
.
Duration
// [OPTIONAL] The reth DB path to fetch receipts from
// [OPTIONAL] The reth DB path to fetch receipts from
rethDbPath
*
string
rethDbPath
string
}
}
func
(
s
*
EthClient
)
PickReceiptsMethod
(
txCount
uint64
)
ReceiptsFetchingMethod
{
func
(
s
*
EthClient
)
PickReceiptsMethod
(
txCount
uint64
)
ReceiptsFetchingMethod
{
...
...
op-service/sources/receipts.go
View file @
c87d94bb
...
@@ -390,13 +390,13 @@ type receiptsFetchingJob struct {
...
@@ -390,13 +390,13 @@ type receiptsFetchingJob struct {
fetcher
*
IterativeBatchCall
[
common
.
Hash
,
*
types
.
Receipt
]
fetcher
*
IterativeBatchCall
[
common
.
Hash
,
*
types
.
Receipt
]
// [OPTIONAL] RethDB path to fetch receipts from
// [OPTIONAL] RethDB path to fetch receipts from
rethDbPath
*
string
rethDbPath
string
result
types
.
Receipts
result
types
.
Receipts
}
}
func
NewReceiptsFetchingJob
(
requester
ReceiptsRequester
,
client
rpcClient
,
maxBatchSize
int
,
block
eth
.
BlockID
,
func
NewReceiptsFetchingJob
(
requester
ReceiptsRequester
,
client
rpcClient
,
maxBatchSize
int
,
block
eth
.
BlockID
,
receiptHash
common
.
Hash
,
txHashes
[]
common
.
Hash
,
rethDb
*
string
)
*
receiptsFetchingJob
{
receiptHash
common
.
Hash
,
txHashes
[]
common
.
Hash
,
rethDb
string
)
*
receiptsFetchingJob
{
return
&
receiptsFetchingJob
{
return
&
receiptsFetchingJob
{
requester
:
requester
,
requester
:
requester
,
client
:
client
,
client
:
client
,
...
@@ -483,10 +483,10 @@ func (job *receiptsFetchingJob) runAltMethod(ctx context.Context, m ReceiptsFetc
...
@@ -483,10 +483,10 @@ func (job *receiptsFetchingJob) runAltMethod(ctx context.Context, m ReceiptsFetc
case
ErigonGetBlockReceiptsByBlockHash
:
case
ErigonGetBlockReceiptsByBlockHash
:
err
=
job
.
client
.
CallContext
(
ctx
,
&
result
,
"erigon_getBlockReceiptsByBlockHash"
,
job
.
block
.
Hash
)
err
=
job
.
client
.
CallContext
(
ctx
,
&
result
,
"erigon_getBlockReceiptsByBlockHash"
,
job
.
block
.
Hash
)
case
RethGetBlockReceipts
:
case
RethGetBlockReceipts
:
if
job
.
rethDbPath
==
nil
{
if
job
.
rethDbPath
==
""
{
return
fmt
.
Errorf
(
"reth_db path not set"
)
return
fmt
.
Errorf
(
"reth_db path not set"
)
}
}
res
,
err
:=
FetchRethReceipts
(
*
job
.
rethDbPath
,
&
job
.
block
.
Hash
)
res
,
err
:=
FetchRethReceipts
(
job
.
rethDbPath
,
&
job
.
block
.
Hash
)
if
err
!=
nil
{
if
err
!=
nil
{
return
err
return
err
}
}
...
...
op-service/sources/reth_db.go
View file @
c87d94bb
...
@@ -24,8 +24,8 @@ typedef struct {
...
@@ -24,8 +24,8 @@ typedef struct {
bool error;
bool error;
} ReceiptsResult;
} ReceiptsResult;
extern ReceiptsResult read_receipts(const uint8_t* block_hash, size_t block_hash_len, const char* db_path);
extern ReceiptsResult r
db_r
ead_receipts(const uint8_t* block_hash, size_t block_hash_len, const char* db_path);
extern void free_string(char* string);
extern void
rdb_
free_string(char* string);
*/
*/
import
"C"
import
"C"
...
@@ -45,12 +45,15 @@ func FetchRethReceipts(dbPath string, blockHash *common.Hash) (types.Receipts, e
...
@@ -45,12 +45,15 @@ func FetchRethReceipts(dbPath string, blockHash *common.Hash) (types.Receipts, e
defer
C
.
free
(
unsafe
.
Pointer
(
cDbPath
))
defer
C
.
free
(
unsafe
.
Pointer
(
cDbPath
))
// Call the C function to fetch the receipts from the Reth Database
// Call the C function to fetch the receipts from the Reth Database
receiptsResult
:=
C
.
read_receipts
((
*
C
.
uint8_t
)(
cBlockHash
),
C
.
size_t
(
len
(
blockHash
)),
cDbPath
)
receiptsResult
:=
C
.
r
db_r
ead_receipts
((
*
C
.
uint8_t
)(
cBlockHash
),
C
.
size_t
(
len
(
blockHash
)),
cDbPath
)
if
receiptsResult
.
error
{
if
receiptsResult
.
error
{
return
nil
,
fmt
.
Errorf
(
"Error fetching receipts from Reth Database."
)
return
nil
,
fmt
.
Errorf
(
"Error fetching receipts from Reth Database."
)
}
}
// Free the memory allocated by the C code
defer
C
.
rdb_free_string
(
receiptsResult
.
data
)
// Convert the returned JSON string to Go string and parse it
// Convert the returned JSON string to Go string and parse it
receiptsJSON
:=
C
.
GoStringN
(
receiptsResult
.
data
,
C
.
int
(
receiptsResult
.
data_len
))
receiptsJSON
:=
C
.
GoStringN
(
receiptsResult
.
data
,
C
.
int
(
receiptsResult
.
data_len
))
var
receipts
types
.
Receipts
var
receipts
types
.
Receipts
...
@@ -58,8 +61,5 @@ func FetchRethReceipts(dbPath string, blockHash *common.Hash) (types.Receipts, e
...
@@ -58,8 +61,5 @@ func FetchRethReceipts(dbPath string, blockHash *common.Hash) (types.Receipts, e
return
nil
,
err
return
nil
,
err
}
}
// Free the memory allocated by the C code
C
.
free_string
(
receiptsResult
.
data
)
return
receipts
,
nil
return
receipts
,
nil
}
}
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