mirror of
https://github.com/ethereum/go-ethereum.git
synced 2026-08-09 05:23:47 +00:00
fix: improve L1Message RPC encoding (#368)
correctly encode L1 messages in RPC response
This commit is contained in:
parent
43be9a6450
commit
b14a4024cd
2 changed files with 27 additions and 3 deletions
28
eth/api.go
28
eth/api.go
|
|
@ -613,6 +613,17 @@ type ScrollAPI struct {
|
||||||
eth *Ethereum
|
eth *Ethereum
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// l1MessageTxRPC is the RPC-layer representation of an L1 message.
|
||||||
|
type l1MessageTxRPC struct {
|
||||||
|
QueueIndex uint64 `json:"queueIndex"`
|
||||||
|
Gas uint64 `json:"gas"`
|
||||||
|
To *common.Address `json:"to"`
|
||||||
|
Value *hexutil.Big `json:"value"`
|
||||||
|
Data hexutil.Bytes `json:"data"`
|
||||||
|
Sender common.Address `json:"sender"`
|
||||||
|
Hash common.Hash `json:"hash"`
|
||||||
|
}
|
||||||
|
|
||||||
// NewScrollAPI creates a new RPC service to query the L1 message database.
|
// NewScrollAPI creates a new RPC service to query the L1 message database.
|
||||||
func NewScrollAPI(eth *Ethereum) *ScrollAPI {
|
func NewScrollAPI(eth *Ethereum) *ScrollAPI {
|
||||||
return &ScrollAPI{eth: eth}
|
return &ScrollAPI{eth: eth}
|
||||||
|
|
@ -624,8 +635,21 @@ func (api *ScrollAPI) GetL1SyncHeight(ctx context.Context) (height *uint64, err
|
||||||
}
|
}
|
||||||
|
|
||||||
// GetL1MessageByIndex queries an L1 message by its index in the local database.
|
// GetL1MessageByIndex queries an L1 message by its index in the local database.
|
||||||
func (api *ScrollAPI) GetL1MessageByIndex(ctx context.Context, queueIndex uint64) (height *types.L1MessageTx, err error) {
|
func (api *ScrollAPI) GetL1MessageByIndex(ctx context.Context, queueIndex uint64) (height *l1MessageTxRPC, err error) {
|
||||||
return rawdb.ReadL1Message(api.eth.ChainDb(), queueIndex), nil
|
msg := rawdb.ReadL1Message(api.eth.ChainDb(), queueIndex)
|
||||||
|
if msg == nil {
|
||||||
|
return nil, nil
|
||||||
|
}
|
||||||
|
rpcMsg := l1MessageTxRPC{
|
||||||
|
QueueIndex: msg.QueueIndex,
|
||||||
|
Gas: msg.Gas,
|
||||||
|
To: msg.To,
|
||||||
|
Value: (*hexutil.Big)(msg.Value),
|
||||||
|
Data: msg.Data,
|
||||||
|
Sender: msg.Sender,
|
||||||
|
Hash: types.NewTx(msg).Hash(),
|
||||||
|
}
|
||||||
|
return &rpcMsg, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
// GetFirstQueueIndexNotInL2Block returns the first L1 message queue index that is
|
// GetFirstQueueIndexNotInL2Block returns the first L1 message queue index that is
|
||||||
|
|
|
||||||
|
|
@ -24,7 +24,7 @@ import (
|
||||||
const (
|
const (
|
||||||
VersionMajor = 4 // Major version component of the current release
|
VersionMajor = 4 // Major version component of the current release
|
||||||
VersionMinor = 2 // Minor version component of the current release
|
VersionMinor = 2 // Minor version component of the current release
|
||||||
VersionPatch = 1 // Patch version component of the current release
|
VersionPatch = 2 // Patch version component of the current release
|
||||||
VersionMeta = "sepolia" // Version metadata to append to the version string
|
VersionMeta = "sepolia" // Version metadata to append to the version string
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue