-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Initial Commit: Launch of EVM Chain Sequencer - Optimized for Perform…
…ance and Scalability This commit represents the foundational launch of our EVM Chain Sequencer. Key features include optimized performance, enhanced scalability, and a robust architecture designed for efficient blockchain interactions. This milestone sets the stage for future developments and improvements. Co-authored-by: Shubham Sharma <[email protected]> Co-authored-by: Uddesh Jaiswal <[email protected]> Co-authored-by: Kritarth Agrawal <[email protected]> Co-authored-by: Rahul Singh Maraskole <[email protected]>
- Loading branch information
Showing
25 changed files
with
27,525 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
/data | ||
provingKey.txt | ||
verificationKey.txt | ||
verificationKey.json | ||
.idea |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,151 @@ | ||
package air_leveldb | ||
|
||
import ( | ||
"github.com/syndtr/goleveldb/leveldb" | ||
"log" | ||
) | ||
|
||
var txDbInstance *leveldb.DB | ||
var blockDbInstance *leveldb.DB | ||
var staticDbInstance *leveldb.DB | ||
var batchesDbInstance *leveldb.DB | ||
var proofDbInstance *leveldb.DB | ||
var publicWitnessDbInstance *leveldb.DB | ||
var daDbInstance *leveldb.DB | ||
|
||
// The function initializes a LevelDB database for transactions and returns a boolean indicating | ||
// whether the initialization was successful. | ||
func InitTxDb() bool { | ||
txDB, err := leveldb.OpenFile("data/leveldb/tx", nil) | ||
if err != nil { | ||
log.Fatal("Failed to open transaction LevelDB:", err) | ||
return false | ||
} | ||
txDbInstance = txDB | ||
return true | ||
} | ||
|
||
// The function initializes a LevelDB database for storing blocks and returns a boolean indicating | ||
// whether the initialization was successful. | ||
func InitBlockDb() bool { | ||
blockDB, err := leveldb.OpenFile("data/leveldb/blocks", nil) | ||
if err != nil { | ||
log.Fatal("Failed to open block LevelDB:", err) | ||
return false | ||
} | ||
blockDbInstance = blockDB | ||
return true | ||
} | ||
|
||
// The function initializes a static LevelDB database and returns a boolean indicating whether the | ||
// initialization was successful or not. | ||
func InitStaticDb() bool { | ||
staticDB, err := leveldb.OpenFile("data/leveldb/static", nil) | ||
if err != nil { | ||
log.Fatal("Failed to open static LevelDB:", err) | ||
return false | ||
} | ||
staticDbInstance = staticDB | ||
return true | ||
} | ||
|
||
// The function initializes a batches LevelDB database and returns a boolean indicating whether the | ||
// initialization was successful or not. | ||
func InitBatchesDb() bool { | ||
batchesDB, err := leveldb.OpenFile("data/leveldb/batches", nil) | ||
if err != nil { | ||
log.Fatal("Failed to open batches LevelDB:", err) | ||
return false | ||
} | ||
batchesDbInstance = batchesDB | ||
return true | ||
} | ||
|
||
// The function initializes a proof LevelDB database and returns a boolean indicating whether the | ||
// initialization was successful or not. | ||
func InitProofDb() bool { | ||
proofDB, err := leveldb.OpenFile("data/leveldb/proof", nil) | ||
if err != nil { | ||
log.Fatal("Failed to open proof LevelDB:", err) | ||
return false | ||
} | ||
proofDbInstance = proofDB | ||
return true | ||
} | ||
|
||
func InitPublicWitnessDb() bool { | ||
publicWitnessDB, err := leveldb.OpenFile("data/leveldb/publicWitness", nil) | ||
if err != nil { | ||
log.Fatal("Failed to open public witness LevelDB:", err) | ||
return false | ||
} | ||
publicWitnessDbInstance = publicWitnessDB | ||
return true | ||
} | ||
|
||
func InitDaDb() bool { | ||
daDB, err := leveldb.OpenFile("data/leveldb/da", nil) | ||
if err != nil { | ||
log.Fatal("Failed to open da LevelDB:", err) | ||
return false | ||
} | ||
daDbInstance = daDB | ||
return true | ||
} | ||
|
||
// The function `InitDb` initializes three different databases and returns true if all of them are | ||
// successfully initialized, otherwise it returns false. | ||
func InitDb() bool { | ||
txStatus := InitTxDb() | ||
blockStatus := InitBlockDb() | ||
staticStatus := InitStaticDb() | ||
batchesStatus := InitBatchesDb() | ||
proofStatus := InitProofDb() | ||
publicWitnessStatus := InitPublicWitnessDb() | ||
daDbInstanceStatus := InitDaDb() | ||
|
||
if txStatus && blockStatus && staticStatus && batchesStatus && proofStatus && publicWitnessStatus && daDbInstanceStatus { | ||
return true | ||
} else { | ||
return false | ||
} | ||
} | ||
|
||
// The function GetTxDbInstance returns the instance of the air-leveldb database. | ||
func GetTxDbInstance() *leveldb.DB { | ||
return txDbInstance | ||
} | ||
|
||
// The function returns the instance of the block database. | ||
func GetBlockDbInstance() *leveldb.DB { | ||
return blockDbInstance | ||
} | ||
|
||
// The function `GetStaticDbInstance()` is returning the instance of the LevelDB database that was | ||
// initialized in the `InitStaticDb()` function. This allows other parts of the code to access and use | ||
// the LevelDB database instance for performing operations such as reading or writing data. | ||
func GetStaticDbInstance() *leveldb.DB { | ||
return staticDbInstance | ||
} | ||
|
||
// The function `GetBatchesDbInstance()` is returning the instance of the LevelDB database that was | ||
// initialized in the `InitBatchesDb()` function. This allows other parts of the code to access and use | ||
// the LevelDB database instance for performing operations such as reading or writing data. | ||
func GetBatchesDbInstance() *leveldb.DB { | ||
return batchesDbInstance | ||
} | ||
|
||
// The function `GetProofDbInstance()` is returning the instance of the LevelDB database that was | ||
// initialized in the `InitProofDb()` function. This allows other parts of the code to access and use | ||
// the LevelDB database instance for performing operations such as reading or writing data. | ||
func GetProofDbInstance() *leveldb.DB { | ||
return proofDbInstance | ||
} | ||
|
||
func GetPublicWitnessDbInstance() *leveldb.DB { | ||
return publicWitnessDbInstance | ||
} | ||
|
||
func GetDaDbInstance() *leveldb.DB { | ||
return daDbInstance | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
package common | ||
|
||
const BatchSize = 25 | ||
const BlockDelay = 5 | ||
const ExecutionClientRPC = "http://35.244.25.153/jsonrpc" | ||
const SettlementClientRPC = "http://localhost:8080" | ||
const KeyringDirectory = "./account/keys" | ||
const DaClientRPC = "http://192.168.1.106:5050/celestia" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,87 @@ | ||
package common | ||
|
||
import ( | ||
"context" | ||
"encoding/json" | ||
"fmt" | ||
"github.com/ethereum/go-ethereum/common" | ||
"github.com/ethereum/go-ethereum/rpc" | ||
"io" | ||
"log" | ||
"math/big" | ||
"net/http" | ||
"strconv" | ||
"strings" | ||
) | ||
|
||
func ToString(value interface{}) string { | ||
switch v := value.(type) { | ||
case string: | ||
return v | ||
case []interface{}: | ||
jsonBytes, _ := json.Marshal(v) | ||
return string(jsonBytes) | ||
default: | ||
return fmt.Sprintf("%v", v) | ||
} | ||
} | ||
|
||
func GetBalance(address string, blockNumber uint64) (string, error) { | ||
payload := fmt.Sprintf(`{ | ||
"jsonrpc": "2.0", | ||
"method": "eth_getBalance", | ||
"params": ["%s", "%s"], | ||
"id": 1 | ||
}`, address, "0x"+strconv.FormatUint(blockNumber, 16)) | ||
|
||
resp, err := http.Post(ExecutionClientRPC, "application/json", strings.NewReader(payload)) | ||
if err != nil { | ||
return "", err | ||
} | ||
defer resp.Body.Close() | ||
|
||
body, err := io.ReadAll(resp.Body) | ||
if err != nil { | ||
return "", err | ||
} | ||
|
||
var jsonResponse map[string]interface{} | ||
err = json.Unmarshal(body, &jsonResponse) | ||
if err != nil { | ||
return "", err | ||
} | ||
|
||
if errMsg, ok := jsonResponse["error"]; ok { | ||
return "", fmt.Errorf("error from Ethereum node: %v", errMsg) | ||
} | ||
|
||
if result, ok := jsonResponse["result"].(string); ok { | ||
balance, success := new(big.Int).SetString(result[2:], 16) | ||
if !success { | ||
return "", fmt.Errorf("failed to parse balance") | ||
} | ||
|
||
etherBalance := new(big.Float).Quo(new(big.Float).SetInt(balance), new(big.Float).SetInt64(1e18)) | ||
return etherBalance.String(), nil | ||
} else { | ||
log.Fatal("Failed to parse balance") | ||
return "", err | ||
} | ||
} | ||
|
||
func GetAccountNonce(ctx context.Context, address string, blockNumber uint64) (string, error) { | ||
client, err := rpc.Dial(ExecutionClientRPC) | ||
if err != nil { | ||
return "0", err | ||
} | ||
accountAddress := common.HexToAddress(address) | ||
formatedBlockNumber := "0x" + strconv.FormatUint(blockNumber, 16) | ||
var result string | ||
err = client.CallContext(ctx, &result, "eth_getTransactionCount", accountAddress, formatedBlockNumber) | ||
if err != nil { | ||
fmt.Println("Error getting transaction count:", err) | ||
return "0", err | ||
} | ||
|
||
return result, nil | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
package logs | ||
|
||
import ( | ||
"github.com/ComputerKeeda/sslogger" | ||
) | ||
|
||
var Log sslogger.Logger |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,51 @@ | ||
module github.com/airchains-network/evm-sequencer-node | ||
|
||
go 1.21 | ||
|
||
require ( | ||
github.com/ComputerKeeda/sslogger v1.0.0 | ||
github.com/consensys/gnark v0.9.1 | ||
github.com/consensys/gnark-crypto v0.12.2-0.20231013160410-1f65e75b6dfb | ||
github.com/ethereum/go-ethereum v1.13.5 | ||
github.com/syndtr/goleveldb v1.0.1-0.20210819022825-2ae1ddf74ef7 | ||
) | ||
|
||
require ( | ||
github.com/Microsoft/go-winio v0.6.1 // indirect | ||
github.com/StackExchange/wmi v1.2.1 // indirect | ||
github.com/bits-and-blooms/bitset v1.8.0 // indirect | ||
github.com/blang/semver/v4 v4.0.0 // indirect | ||
github.com/btcsuite/btcd/btcec/v2 v2.2.0 // indirect | ||
github.com/consensys/bavard v0.1.13 // indirect | ||
github.com/crate-crypto/go-kzg-4844 v0.7.0 // indirect | ||
github.com/davecgh/go-spew v1.1.1 // indirect | ||
github.com/deckarep/golang-set/v2 v2.1.0 // indirect | ||
github.com/decred/dcrd/dcrec/secp256k1/v4 v4.0.1 // indirect | ||
github.com/ethereum/c-kzg-4844 v0.4.0 // indirect | ||
github.com/fxamacker/cbor/v2 v2.5.0 // indirect | ||
github.com/go-ole/go-ole v1.2.5 // indirect | ||
github.com/go-stack/stack v1.8.1 // indirect | ||
github.com/golang/snappy v0.0.5-0.20220116011046-fa5810519dcb // indirect | ||
github.com/google/pprof v0.0.0-20230817174616-7a8ec2ada47b // indirect | ||
github.com/gorilla/websocket v1.4.2 // indirect | ||
github.com/holiman/uint256 v1.2.3 // indirect | ||
github.com/mattn/go-colorable v0.1.13 // indirect | ||
github.com/mattn/go-isatty v0.0.19 // indirect | ||
github.com/mmcloughlin/addchain v0.4.0 // indirect | ||
github.com/pmezard/go-difflib v1.0.0 // indirect | ||
github.com/rs/zerolog v1.30.0 // indirect | ||
github.com/shirou/gopsutil v3.21.4-0.20210419000835-c7a38de76ee5+incompatible // indirect | ||
github.com/stretchr/testify v1.8.4 // indirect | ||
github.com/supranational/blst v0.3.11 // indirect | ||
github.com/tklauser/go-sysconf v0.3.12 // indirect | ||
github.com/tklauser/numcpus v0.6.1 // indirect | ||
github.com/x448/float16 v0.8.4 // indirect | ||
golang.org/x/crypto v0.14.0 // indirect | ||
golang.org/x/exp v0.0.0-20230905200255-921286631fa9 // indirect | ||
golang.org/x/mod v0.12.0 // indirect | ||
golang.org/x/sync v0.3.0 // indirect | ||
golang.org/x/sys v0.13.0 // indirect | ||
golang.org/x/tools v0.13.0 // indirect | ||
gopkg.in/yaml.v3 v3.0.1 // indirect | ||
rsc.io/tmplfunc v0.0.3 // indirect | ||
) |
Oops, something went wrong.