From 59264f0f4882d10d7c4c31a700be42584565d73f Mon Sep 17 00:00:00 2001 From: 0g-wh Date: Mon, 11 Nov 2024 13:16:33 +0800 Subject: [PATCH 1/5] Update tps-single-0g.yml --- .github/workflows/tps-single-0g.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/tps-single-0g.yml b/.github/workflows/tps-single-0g.yml index 288dde8..c1adc67 100644 --- a/.github/workflows/tps-single-0g.yml +++ b/.github/workflows/tps-single-0g.yml @@ -23,7 +23,7 @@ jobs: make build - name: Build Chain run: | - git clone -b v0.4.0 https://github.com/0glabs/0g-chain.git + git clone -b dev0.38 https://github.com/0g-wh/0g-chain.git cd 0g-chain sudo LINK_STATICALLY=true make build-release sed -i '/$BINARY config broadcast-mode sync/a sed -i '\''s/timeout_commit = "5s"/timeout_commit = "1s"/'\'' ~/.0gchain/config/config.toml' localtestnet.sh From f7fb1ba3009c1c4f9806f4ab2c25b9eb2f65bf41 Mon Sep 17 00:00:00 2001 From: 0g-wh Date: Mon, 11 Nov 2024 05:22:34 +0000 Subject: [PATCH 2/5] suspend --- lib/generator/generator.go | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/lib/generator/generator.go b/lib/generator/generator.go index 3d7cde8..d26e249 100644 --- a/lib/generator/generator.go +++ b/lib/generator/generator.go @@ -38,13 +38,13 @@ func NewGenerator(rpcUrl, faucetPrivateKey string, senderCount, txCount int, sho } eip1559 := false - header, err := client.HeaderByNumber(context.Background(), nil) + /*header, err := client.HeaderByNumber(context.Background(), nil) if err != nil { return &Generator{}, err } if header.BaseFee != nil { eip1559 = true - } + }*/ fmt.Println("EIP-1559:", eip1559) From de5b44daee7d5a3063fa7f16f260ccf841d0baa1 Mon Sep 17 00:00:00 2001 From: 0g-wh Date: Mon, 11 Nov 2024 06:07:11 +0000 Subject: [PATCH 3/5] fix 1559 check --- lib/generator/generator.go | 71 +++++++++++++++++++++++++++++++++++--- 1 file changed, 66 insertions(+), 5 deletions(-) diff --git a/lib/generator/generator.go b/lib/generator/generator.go index d26e249..ae2ade8 100644 --- a/lib/generator/generator.go +++ b/lib/generator/generator.go @@ -1,9 +1,13 @@ package generator import ( + "bytes" "context" + "encoding/json" "fmt" + "io" "math/big" + "net/http" "strings" "time" @@ -31,20 +35,77 @@ type Generator struct { EIP1559 bool } +type JSONRPCRequest struct { + Jsonrpc string `json:"jsonrpc"` + Method string `json:"method"` + Params interface{} `json:"params"` + ID int `json:"id"` +} + +type JSONRPCResponse struct { + Jsonrpc string `json:"jsonrpc"` + Result json.RawMessage `json:"result"` + Error *JSONRPCError `json:"error,omitempty"` + ID int `json:"id"` +} + +type JSONRPCError struct { + Code int `json:"code"` + Message string `json:"message"` +} + +func CheckEIP1559(rpcUrl string) (bool, error) { + reqBody := JSONRPCRequest{ + Jsonrpc: "2.0", + Method: "eth_getBlockByNumber", + Params: []interface{}{"latest", false}, + ID: 1, + } + + reqBytes, err := json.Marshal(reqBody) + if err != nil { + return false, fmt.Errorf("failed to marshal request: %v", err) + } + + resp, err := http.Post(rpcUrl, "application/json", bytes.NewBuffer(reqBytes)) + if err != nil { + return false, fmt.Errorf("failed to send request: %v", err) + } + defer resp.Body.Close() + + respBody, err := io.ReadAll(resp.Body) + if err != nil { + return false, fmt.Errorf("failed to read response: %v", err) + } + + var rpcResp JSONRPCResponse + if err := json.Unmarshal(respBody, &rpcResp); err != nil { + return false, fmt.Errorf("failed to unmarshal response: %v", err) + } + + if rpcResp.Error != nil { + return false, fmt.Errorf("RPC error: %v", rpcResp.Error.Message) + } + + var result map[string]interface{} + if err := json.Unmarshal(rpcResp.Result, &result); err != nil { + return false, fmt.Errorf("failed to unmarshal result: %v", err) + } + + baseFee, exists := result["baseFeePerGas"] + return exists && baseFee != nil, nil +} + func NewGenerator(rpcUrl, faucetPrivateKey string, senderCount, txCount int, shouldPersist bool, txStoreDir string) (*Generator, error) { client, err := ethclient.Dial(rpcUrl) if err != nil { return &Generator{}, err } - eip1559 := false - /*header, err := client.HeaderByNumber(context.Background(), nil) + eip1559, nil := CheckEIP1559(rpcUrl) if err != nil { return &Generator{}, err } - if header.BaseFee != nil { - eip1559 = true - }*/ fmt.Println("EIP-1559:", eip1559) From 2ceb2f69deb69d39d6be648c42b5b5bbfbd581d4 Mon Sep 17 00:00:00 2001 From: 0g-wh Date: Mon, 11 Nov 2024 06:14:27 +0000 Subject: [PATCH 4/5] update 0g version --- .github/workflows/tps-erc20-0g.yml | 2 +- .github/workflows/tps-single-0g.yml | 2 +- .github/workflows/tps-uniswap-0g.yml | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/.github/workflows/tps-erc20-0g.yml b/.github/workflows/tps-erc20-0g.yml index e6191c1..9b2677c 100644 --- a/.github/workflows/tps-erc20-0g.yml +++ b/.github/workflows/tps-erc20-0g.yml @@ -23,7 +23,7 @@ jobs: make build - name: Build Chain run: | - git clone -b v0.4.0 https://github.com/0glabs/0g-chain.git + git clone -b dev0.38 https://github.com/0glabs/0g-chain.git cd 0g-chain sudo LINK_STATICALLY=true make build-release sed -i '/$BINARY config broadcast-mode sync/a sed -i '\''s/timeout_commit = "5s"/timeout_commit = "1s"/'\'' ~/.0gchain/config/config.toml' localtestnet.sh diff --git a/.github/workflows/tps-single-0g.yml b/.github/workflows/tps-single-0g.yml index c1adc67..f153c6f 100644 --- a/.github/workflows/tps-single-0g.yml +++ b/.github/workflows/tps-single-0g.yml @@ -23,7 +23,7 @@ jobs: make build - name: Build Chain run: | - git clone -b dev0.38 https://github.com/0g-wh/0g-chain.git + git clone -b dev0.38 https://github.com/0glabs/0g-chain.git cd 0g-chain sudo LINK_STATICALLY=true make build-release sed -i '/$BINARY config broadcast-mode sync/a sed -i '\''s/timeout_commit = "5s"/timeout_commit = "1s"/'\'' ~/.0gchain/config/config.toml' localtestnet.sh diff --git a/.github/workflows/tps-uniswap-0g.yml b/.github/workflows/tps-uniswap-0g.yml index 80025a3..d8221ef 100644 --- a/.github/workflows/tps-uniswap-0g.yml +++ b/.github/workflows/tps-uniswap-0g.yml @@ -23,7 +23,7 @@ jobs: make build - name: Build Chain run: | - git clone -b v0.4.0 https://github.com/0glabs/0g-chain.git + git clone -b dev0.38 https://github.com/0glabs/0g-chain.git cd 0g-chain sudo LINK_STATICALLY=true make build-release sed -i '/$BINARY config broadcast-mode sync/a sed -i '\''s/timeout_commit = "5s"/timeout_commit = "1s"/'\'' ~/.0gchain/config/config.toml' localtestnet.sh From b739878b8b94ff57feec1115e6fbf00dfb8321bf Mon Sep 17 00:00:00 2001 From: 0g-wh Date: Mon, 11 Nov 2024 12:36:29 +0000 Subject: [PATCH 5/5] revert --- lib/generator/generator.go | 71 +++----------------------------------- 1 file changed, 5 insertions(+), 66 deletions(-) diff --git a/lib/generator/generator.go b/lib/generator/generator.go index ae2ade8..3d7cde8 100644 --- a/lib/generator/generator.go +++ b/lib/generator/generator.go @@ -1,13 +1,9 @@ package generator import ( - "bytes" "context" - "encoding/json" "fmt" - "io" "math/big" - "net/http" "strings" "time" @@ -35,77 +31,20 @@ type Generator struct { EIP1559 bool } -type JSONRPCRequest struct { - Jsonrpc string `json:"jsonrpc"` - Method string `json:"method"` - Params interface{} `json:"params"` - ID int `json:"id"` -} - -type JSONRPCResponse struct { - Jsonrpc string `json:"jsonrpc"` - Result json.RawMessage `json:"result"` - Error *JSONRPCError `json:"error,omitempty"` - ID int `json:"id"` -} - -type JSONRPCError struct { - Code int `json:"code"` - Message string `json:"message"` -} - -func CheckEIP1559(rpcUrl string) (bool, error) { - reqBody := JSONRPCRequest{ - Jsonrpc: "2.0", - Method: "eth_getBlockByNumber", - Params: []interface{}{"latest", false}, - ID: 1, - } - - reqBytes, err := json.Marshal(reqBody) - if err != nil { - return false, fmt.Errorf("failed to marshal request: %v", err) - } - - resp, err := http.Post(rpcUrl, "application/json", bytes.NewBuffer(reqBytes)) - if err != nil { - return false, fmt.Errorf("failed to send request: %v", err) - } - defer resp.Body.Close() - - respBody, err := io.ReadAll(resp.Body) - if err != nil { - return false, fmt.Errorf("failed to read response: %v", err) - } - - var rpcResp JSONRPCResponse - if err := json.Unmarshal(respBody, &rpcResp); err != nil { - return false, fmt.Errorf("failed to unmarshal response: %v", err) - } - - if rpcResp.Error != nil { - return false, fmt.Errorf("RPC error: %v", rpcResp.Error.Message) - } - - var result map[string]interface{} - if err := json.Unmarshal(rpcResp.Result, &result); err != nil { - return false, fmt.Errorf("failed to unmarshal result: %v", err) - } - - baseFee, exists := result["baseFeePerGas"] - return exists && baseFee != nil, nil -} - func NewGenerator(rpcUrl, faucetPrivateKey string, senderCount, txCount int, shouldPersist bool, txStoreDir string) (*Generator, error) { client, err := ethclient.Dial(rpcUrl) if err != nil { return &Generator{}, err } - eip1559, nil := CheckEIP1559(rpcUrl) + eip1559 := false + header, err := client.HeaderByNumber(context.Background(), nil) if err != nil { return &Generator{}, err } + if header.BaseFee != nil { + eip1559 = true + } fmt.Println("EIP-1559:", eip1559)