Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Test/test execution http rpc #88

Closed
wants to merge 15 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 17 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,13 @@
Selene is a fast, open source, portable & secure light client for Ethereum written in Golang. We plan to ship Selene as the underlying software behind wallets that use light clients. We derived our inspiration from [Helios](https://github.com/a16z/helios) which is a light client written in Rust. The project is in active maintenance on the [dev](https://github.com/BlocSoc-iitr/selene/tree/dev) branch.

# Architecture
## High Level Overview
The image attached below is a simple demonstration of what Selene is and how it works at a high level:

![High Level Overview](https://github.com/user-attachments/assets/948541ef-5407-4035-a49d-e0d23711aadc)
## Architecture
Below is the complete architecture of how a light client like Selene works under the hood:

![Selene Architecture](https://github.com/user-attachments/assets/db7eb9d7-5bc3-4911-a849-1b2d05239942)
## Data Flow

Expand Down Expand Up @@ -54,5 +61,15 @@ In progress.
# Warning
Selene is still experimental software. We hope to ship v0.1 by November 2024.

# Current Team behind Selene
[Vasu Khanna](https://github.com/star-gazer111) ( Chief Innovator ) <br>
[Sambhav Jain](https://github.com/DarkLord017) <br>
[Veer Chaurasia](https://github.com/VeerChaurasia)<br>
[Nilav Prajapati](https://github.com/gerceboss)<br>
[Utsav Sharma](https://github.com/x-senpai-x)<br>
[Shourya Choudhary](https://github.com/18aaddy)<br>
[Abdullah Azeem](https://github.com/ABD-AZE)<br>


# Contributing
We openly welcome contributions to selene from the broader ethereum community. For details, refer [CONTRIBUTION GUIDELINES](https://github.com/BlocSoc-iitr/selene/blob/dev/CONTRIBUTING.md).
43 changes: 22 additions & 21 deletions common/types.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,10 @@ package common
import (
"encoding/json"
"fmt"
"math/big"
"strconv"

"github.com/ethereum/go-ethereum/common"
"github.com/ethereum/go-ethereum/common/hexutil"
"github.com/ethereum/go-ethereum/core/types"
"github.com/holiman/uint256"
)
Expand Down Expand Up @@ -45,27 +45,28 @@ type Transactions struct {
Hashes [][32]byte
Full []Transaction // transaction needs to be defined
}

// Updated as earlier, txn data fetched from rpc was not able to unmarshal
// into the struct
type Transaction struct {
AccessList types.AccessList
Hash common.Hash
Nonce uint64
BlockHash [32]byte
BlockNumber *uint64
TransactionIndex uint64
From string
To *common.Address
Value *big.Int
GasPrice *big.Int
Gas uint64
Input []byte
ChainID *big.Int
TransactionType uint8
Signature *Signature
MaxFeePerGas *big.Int
MaxPriorityFeePerGas *big.Int
MaxFeePerBlobGas *big.Int
BlobVersionedHashes []common.Hash
AccessList types.AccessList `json:"accessList"`
Hash common.Hash `json:"hash"`
Nonce hexutil.Uint64 `json:"nonce"`
BlockHash string `json:"blockHash"` // Pointer because it's nullable
BlockNumber hexutil.Uint64 `json:"blockNumber"` // Pointer because it's nullable
TransactionIndex hexutil.Uint64 `json:"transactionIndex"`
From string `json:"from"`
To *common.Address `json:"to"` // Pointer because 'to' can be null for contract creation
Value hexutil.Big `json:"value"`
GasPrice hexutil.Big `json:"gasPrice"`
Gas hexutil.Uint64 `json:"gas"`
Input hexutil.Bytes `json:"input"`
ChainID hexutil.Big `json:"chainId"`
TransactionType hexutil.Uint `json:"type"`
Signature *Signature `json:"signature"`
MaxFeePerGas hexutil.Big `json:"maxFeePerGas"`
MaxPriorityFeePerGas hexutil.Big `json:"maxPriorityFeePerGas"`
MaxFeePerBlobGas hexutil.Big `json:"maxFeePerBlobGas"`
BlobVersionedHashes []common.Hash `json:"blobVersionedHashes"`
}

type Signature struct {
Expand Down
36 changes: 21 additions & 15 deletions consensus/consensus.go
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ import (
"github.com/ethereum/go-ethereum/core/types"
"github.com/holiman/uint256"
"github.com/pkg/errors"
"github.com/ethereum/go-ethereum/common/hexutil"
)

// Error definitions
Expand Down Expand Up @@ -953,20 +954,24 @@ func processTransaction(txBytes *[1073741824]byte, blockHash consensus_core.Byte
if err != nil {
return common.Transaction{}, fmt.Errorf("failed to decode transaction: %v", err)
}

// Updated due to update in Transaction struct
tx := common.Transaction{
Hash: txEnvelope.Hash(),
Nonce: txEnvelope.Nonce(),
BlockHash: blockHash,
BlockNumber: blockNumber,
TransactionIndex: index,
Nonce: hexutil.Uint64(txEnvelope.Nonce()),
BlockHash: func() string {
data := [32]byte(blockHash)
hexString := hex.EncodeToString(data[:])
return hexString
}(),
BlockNumber: hexutil.Uint64(*blockNumber),
TransactionIndex: hexutil.Uint64(index),
To: txEnvelope.To(),
Value: txEnvelope.Value(),
GasPrice: txEnvelope.GasPrice(),
Gas: txEnvelope.Gas(),
Value: hexutil.Big(*txEnvelope.Value()),
GasPrice: hexutil.Big(*txEnvelope.GasPrice()),
Gas: hexutil.Uint64(txEnvelope.Gas()),
Input: txEnvelope.Data(),
ChainID: txEnvelope.ChainId(),
TransactionType: txEnvelope.Type(),
ChainID: hexutil.Big(*txEnvelope.ChainId()),
TransactionType: hexutil.Uint(uint(txEnvelope.Type())),
}

// Handle signature and transaction type logic
Expand All @@ -990,12 +995,13 @@ func processTransaction(txBytes *[1073741824]byte, blockHash consensus_core.Byte
case types.AccessListTxType:
tx.AccessList = txEnvelope.AccessList()
case types.DynamicFeeTxType:
tx.MaxFeePerGas = new(big.Int).Set(txEnvelope.GasFeeCap())
tx.MaxPriorityFeePerGas = new(big.Int).Set(txEnvelope.GasTipCap())
// Update due to update in Transaction struct
tx.MaxFeePerGas = hexutil.Big(*new(big.Int).Set(txEnvelope.GasFeeCap()))
tx.MaxPriorityFeePerGas = hexutil.Big(*new(big.Int).Set(txEnvelope.GasTipCap()))
case types.BlobTxType:
tx.MaxFeePerGas = new(big.Int).Set(txEnvelope.GasFeeCap())
tx.MaxPriorityFeePerGas = new(big.Int).Set(txEnvelope.GasTipCap())
tx.MaxFeePerBlobGas = new(big.Int).Set(txEnvelope.BlobGasFeeCap())
tx.MaxFeePerGas = hexutil.Big(*new(big.Int).Set(txEnvelope.GasFeeCap()))
tx.MaxPriorityFeePerGas = hexutil.Big(*new(big.Int).Set(txEnvelope.GasTipCap()))
tx.MaxFeePerBlobGas = hexutil.Big(*new(big.Int).Set(txEnvelope.BlobGasFeeCap()))
tx.BlobVersionedHashes = txEnvelope.BlobHashes()
default:
fmt.Println("Unhandled transaction type")
Expand Down
Loading